"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(lc)}catch(e){console.error(e)}}lc(),ls.exports=_e;var Rf=ls.exports,Ku=Rf;Yl.createRoot=Ku.createRoot,Yl.hydrateRoot=Ku.hydrateRoot;const ic=["Bitget","Binance","OKX"];function Ft(e){return e==null||e<=0?"-":e>=100?e.toFixed(2):e>=1?e.toFixed(4):e.toFixed(6)}function Mf(){const[e,t]=D.useState("--:--:--"),[n,r]=D.useState("● 未连接"),[l,i]=D.useState(!1),[o,s]=D.useState({}),[a,c]=D.useState([]),[g,f]=D.useState(""),[m,v]=D.useState([]),[w,k]=D.useState([]),[$,p]=D.useState([]),[d,h]=D.useState([]),[y,S]=D.useState([]),[N,E]=D.useState([]),[C,H]=D.useState([]),[T,ye]=D.useState([]),[kt,et]=D.useState([]),gn=D.useRef({});D.useEffect(()=>{const P=()=>t(new Date().toLocaleTimeString("zh-CN",{hour12:!1}));P();const M=setInterval(P,1e3);return()=>clearInterval(M)},[]),D.useEffect(()=>{let P=new EventSource("/events");return P.addEventListener("connected",()=>{r("● 已连接"),i(!0)}),P.onerror=()=>{r("● 已断开 (重连中...)"),i(!1),setTimeout(()=>{P=new EventSource("/events")},3e3)},P.onmessage=M=>{try{const R=JSON.parse(M.data);switch(R.event){case"prices":_(R.data);break;case"spread_3ex":v(R.data||[]);break;case"momentum":k(R.data||[]);break;case"trend":p(R.data||[]);break;case"cumulative":h(R.data||[]);break;case"trend_filter":E(R.data||[]);break;case"trend_signal":H(Te=>[R.data,...Te].slice(0,100));break;case"surge":ye(R.data||[]);break;case"surge_event":et(Te=>[R.data,...Te].slice(0,200));break;case"status":R.data&&R.data.connections&&s(R.data.connections);break}}catch{}},()=>P.close()},[]);const vn=D.useCallback(async()=>{try{const M=await(await fetch("/api/cm-history")).json();S(M.events||[])}catch{}},[]);D.useEffect(()=>{vn();const P=setInterval(vn,5e3);return()=>clearInterval(P)},[vn]);const St=D.useCallback(async()=>{try{const M=await(await fetch("/api/trend-signals")).json();M.signals&&H(M.signals)}catch{}},[]);D.useEffect(()=>{St();const P=setInterval(St,5e3);return()=>clearInterval(P)},[St]);const _t=D.useCallback(async()=>{try{const M=await(await fetch("/api/surge-events?limit=100")).json();M.events&&et(M.events)}catch{}},[]);D.useEffect(()=>{_t();const P=setInterval(_t,1e4);return()=>clearInterval(P)},[_t]);function _(P){if(!P||P.length===0)return;c(P),f(new Date().toLocaleTimeString("zh-CN",{hour12:!1}));const M=gn.current;for(const R of P)for(const Te of ic){const Sl=R.coin+"."+Te,Io=R[Te]||0;M[Sl]?M[Sl].last=Io:M[Sl]={last:Io}}}function z(){const P=new Set,M=[];if(!a)return M;for(const R of a)P.has(R.coin)||(P.add(R.coin),M.push(R.coin));return M}function L(P,M){var R;return(R=gn.current[P+"."+M])==null?void 0:R.last}function V(P,M){return P==null||M==null?"":M>P?"text-green":M`${P}:${M}`).join(" ");return u.jsxs("div",{id:"app",children:[u.jsxs("header",{children:[u.jsx("h1",{children:"⚡ 三所价差异动监控"}),u.jsxs("div",{className:"header-meta",children:[u.jsx("span",{children:e}),u.jsx("span",{className:"sep",children:"|"}),u.jsx("span",{className:l?"status-online":"status-offline",children:n}),jt&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"sep",children:"|"}),u.jsx("span",{style:{fontSize:11},children:jt})]})]})]}),u.jsxs("div",{className:"grid",children:[u.jsx(Hf,{filterData:N}),u.jsx(Wf,{signals:C}),u.jsx(Vf,{signals:C}),u.jsx(Af,{data:d}),u.jsx(Bf,{history:y}),u.jsx(Df,{coins:Z,prices:a,getPrevPrice:L,priceClass:V,pricesAge:g}),u.jsx(If,{data:m}),u.jsx(Uf,{snapshots:T,events:kt}),u.jsx($f,{momentum:w})]})]})}function Df({coins:e,prices:t,getPrevPrice:n,priceClass:r,pricesAge:l}){return u.jsxs("section",{className:"card",id:"prices-card",children:[u.jsxs("h2",{children:["💰 实时价格 ",u.jsx("span",{className:"text-dim",style:{fontSize:11},children:l})]}),u.jsx("div",{className:"table-wrap",children:u.jsxs("table",{id:"price-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"币种"}),u.jsx("th",{children:"Bitget"}),u.jsx("th",{children:"Binance"}),u.jsx("th",{children:"OKX"}),u.jsx("th",{children:"三所价差"})]})}),u.jsx("tbody",{id:"price-body",children:e.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:"5",className:"loading",children:"等待数据..."})}):e.map(i=>{const o=t.find(g=>g.coin===i);if(!o)return u.jsxs("tr",{children:[u.jsx("td",{children:i}),u.jsx("td",{className:"text-dim",children:"-"}),u.jsx("td",{className:"text-dim",children:"-"}),u.jsx("td",{className:"text-dim",children:"-"}),u.jsx("td",{className:"text-dim",children:"-"})]},i);const s=ic.map(g=>{const f=o[g],m=n(i,g),v=m?r(m,f||0):"";return u.jsx("td",{className:v,children:Ft(f)},g)}),a=o.spread_3ex,c=a>.3?"text-green":a>.1?"text-yellow":"text-dim";return u.jsxs("tr",{children:[u.jsx("td",{children:u.jsx("strong",{children:i})}),s,u.jsx("td",{className:c,children:a!=null?a.toFixed(4)+"%":"-"})]},i)})})]})})]})}function If({data:e}){function t(n){return n==null?"":n>.3?"text-green":n>.1?"text-yellow":"text-dim"}return u.jsxs("section",{className:"card",id:"spread-card",children:[u.jsx("h2",{children:"📊 三所价差扫描 (BN/OKX/BG)"}),u.jsx("div",{className:"table-wrap",children:u.jsxs("table",{id:"spread-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"币种"}),u.jsx("th",{children:"价差%"}),u.jsx("th",{children:"BN价格"}),u.jsx("th",{children:"OKX价格"}),u.jsx("th",{children:"BG价格"}),u.jsx("th",{children:"最高所"}),u.jsx("th",{children:"最低所"})]})}),u.jsx("tbody",{children:!e||e.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:"7",className:"text-dim",children:"等待扫描数据..."})}):e.slice(0,50).map((n,r)=>u.jsxs("tr",{children:[u.jsx("td",{children:u.jsx("strong",{children:n.coin})}),u.jsx("td",{className:"text-right "+t(n.spread_pct),children:u.jsx("strong",{children:n.spread_pct!=null?n.spread_pct.toFixed(4)+"%":"-"})}),u.jsx("td",{className:"text-right",children:n.bn_price?Ft(n.bn_price):"-"}),u.jsx("td",{className:"text-right",children:n.okx_price?Ft(n.okx_price):"-"}),u.jsx("td",{className:"text-right",children:n.bg_price?Ft(n.bg_price):"-"}),u.jsx("td",{children:n.max_ex||"-"}),u.jsx("td",{children:n.min_ex||"-"})]},n.coin||r))})]})})]})}function Uf({snapshots:e,events:t}){const[n,r]=D.useState("snapshot");function l(i,o){return i==null||o==null?"":i>=o?"text-green":"text-dim"}return u.jsxs("section",{className:"card card-wide",id:"surge-card",children:[u.jsxs("h2",{children:["🚀 Surge异动检测",u.jsxs("span",{style:{marginLeft:12,fontSize:12,fontWeight:400},children:[u.jsx("button",{className:"tab-btn"+(n==="snapshot"?" active":""),onClick:()=>r("snapshot"),children:"实时基线"}),u.jsxs("button",{className:"tab-btn"+(n==="events"?" active":""),onClick:()=>r("events"),children:["事件记录 (",t.length,")"]})]})]}),n==="snapshot"&&u.jsx("div",{className:"table-wrap",style:{maxHeight:350},children:u.jsxs("table",{id:"surge-snapshot-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"币种"}),u.jsx("th",{children:"当前价差%"}),u.jsx("th",{children:"基线%"}),u.jsx("th",{children:"阈值%"}),u.jsx("th",{children:"窗口样本"})]})}),u.jsx("tbody",{children:e.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:"5",className:"text-dim",style:{textAlign:"center",padding:20},children:"收集基线数据中... (需要至少 10 个样本)"})}):e.slice(0,50).map((i,o)=>{const s=i.direction;return u.jsxs("tr",{className:s?"surge-active":"",children:[u.jsx("td",{children:u.jsx("strong",{children:i.coin})}),u.jsxs("td",{className:"text-right "+l(i.spread_pct,i.threshold_pct),style:{fontWeight:700},children:[i.spread_pct!=null?i.spread_pct.toFixed(4)+"%":"-",s?" ⚡":""]}),u.jsx("td",{className:"text-right text-dim",children:i.baseline_pct!=null?i.baseline_pct.toFixed(4)+"%":"-"}),u.jsx("td",{className:"text-right text-dim",children:i.threshold_pct!=null?i.threshold_pct.toFixed(4)+"%":"-"}),u.jsx("td",{className:"text-right text-dim",children:i.window_size||0})]},i.coin||o)})})]})}),n==="events"&&u.jsx("div",{className:"table-wrap",style:{maxHeight:400},children:u.jsxs("table",{id:"surge-events-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"时间"}),u.jsx("th",{children:"币种"}),u.jsx("th",{children:"方向"}),u.jsx("th",{children:"价差%"}),u.jsx("th",{children:"基线%"}),u.jsx("th",{children:"阈值%"}),u.jsx("th",{children:"比率"}),u.jsx("th",{children:"BN价格"}),u.jsx("th",{children:"OKX价格"}),u.jsx("th",{children:"BG价格"}),u.jsx("th",{children:"领先所"})]})}),u.jsx("tbody",{children:t.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:"11",className:"text-dim",style:{textAlign:"center",padding:20},children:"暂无Surge事件记录"})}):t.slice(0,100).map((i,o)=>{const s=i.timestamp?new Date(i.timestamp).toLocaleTimeString("zh-CN",{hour12:!1}):"-";return u.jsxs("tr",{className:i.direction==="up"?"surge-up":"surge-down",children:[u.jsx("td",{className:"text-dim",children:s}),u.jsx("td",{children:u.jsx("strong",{children:i.coin})}),u.jsx("td",{className:i.direction==="up"?"text-green":"text-red",style:{fontWeight:600,textAlign:"center"},children:i.direction==="up"?"↑ 涨":"↓ 跌"}),u.jsx("td",{className:"text-right",style:{fontWeight:700},children:i.spread_pct!=null?i.spread_pct.toFixed(4)+"%":"-"}),u.jsx("td",{className:"text-right text-dim",children:i.baseline_pct!=null?i.baseline_pct.toFixed(4)+"%":"-"}),u.jsx("td",{className:"text-right text-dim",children:i.threshold_pct!=null?i.threshold_pct.toFixed(4)+"%":"-"}),u.jsx("td",{className:"text-right",children:i.ratio!=null?i.ratio.toFixed(1)+"x":"-"}),u.jsx("td",{className:"text-right",children:i.bn_price?Ft(i.bn_price):"-"}),u.jsx("td",{className:"text-right",children:i.okx_price?Ft(i.okx_price):"-"}),u.jsx("td",{className:"text-right",children:i.bg_price?Ft(i.bg_price):"-"}),u.jsx("td",{children:i.leading_exchange||"-"})]},i.timestamp+"-"+i.coin+"-"+o)})})]})})]})}function $f({momentum:e}){const[t,n]=D.useState("score"),[r,l]=D.useState("desc");function i(f){t===f?l(r==="asc"?"desc":"asc"):(n(f),l("desc"))}function o(f){return t!==f?"":r==="asc"?" ▲":" ▼"}const s=[...e].sort((f,m)=>{let v,w;switch(t){case"coin":v=f.coin,w=m.coin;break;case"bg_1s":v=f.bg_1s||0,w=m.bg_1s||0;break;case"bg_5s":v=f.bg_5s||0,w=m.bg_5s||0;break;case"bg_15s":v=f.bg_15s||0,w=m.bg_15s||0;break;case"bn_1s":v=f.bn_1s||0,w=m.bn_1s||0;break;case"bn_5s":v=f.bn_5s||0,w=m.bn_5s||0;break;case"bn_15s":v=f.bn_15s||0,w=m.bn_15s||0;break;case"okx_1s":v=f.okx_1s||0,w=m.okx_1s||0;break;case"okx_5s":v=f.okx_5s||0,w=m.okx_5s||0;break;case"okx_15s":v=f.okx_15s||0,w=m.okx_15s||0;break;default:v=f.score||0,w=m.score||0}return typeof v=="string"?r==="asc"?v.localeCompare(w):w.localeCompare(v):r==="asc"?v-w:w-v});function a(f){switch(f){case"up":return"↑";case"down":return"↓";case"flat":return"→";case"mixed":return"↕";default:return"-"}}function c(f){switch(f){case"up":return"text-green";case"down":return"text-red";case"mixed":return"text-yellow";default:return""}}function g(f){return f==null||f===0?"":f>0?"text-green":"text-red"}return u.jsxs("section",{className:"card card-wide",id:"momentum-card",children:[u.jsx("h2",{children:"⚡ 动量扫描 (价格变动%)"}),u.jsx("div",{className:"table-wrap",style:{maxHeight:400},children:u.jsxs("table",{id:"momentum-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsxs("th",{onClick:()=>i("coin"),style:{cursor:"pointer"},children:["币种",o("coin")]}),u.jsxs("th",{onClick:()=>i("score"),style:{cursor:"pointer"},children:["分数",o("score")]}),u.jsx("th",{children:"方向"}),u.jsxs("th",{onClick:()=>i("bg_1s"),style:{cursor:"pointer"},children:["BG 1s",o("bg_1s")]}),u.jsxs("th",{onClick:()=>i("bg_5s"),style:{cursor:"pointer"},children:["BG 5s",o("bg_5s")]}),u.jsxs("th",{onClick:()=>i("bg_15s"),style:{cursor:"pointer"},children:["BG 15s",o("bg_15s")]}),u.jsxs("th",{onClick:()=>i("bn_1s"),style:{cursor:"pointer"},children:["BN 1s",o("bn_1s")]}),u.jsxs("th",{onClick:()=>i("bn_5s"),style:{cursor:"pointer"},children:["BN 5s",o("bn_5s")]}),u.jsxs("th",{onClick:()=>i("bn_15s"),style:{cursor:"pointer"},children:["BN 15s",o("bn_15s")]}),u.jsxs("th",{onClick:()=>i("okx_1s"),style:{cursor:"pointer"},children:["OKX 1s",o("okx_1s")]}),u.jsxs("th",{onClick:()=>i("okx_5s"),style:{cursor:"pointer"},children:["OKX 5s",o("okx_5s")]}),u.jsxs("th",{onClick:()=>i("okx_15s"),style:{cursor:"pointer"},children:["OKX 15s",o("okx_15s")]})]})}),u.jsx("tbody",{children:s.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:"12",className:"text-dim",style:{textAlign:"center",padding:20},children:"正在收集动量数据... (需要至少 15 秒数据)"})}):s.slice(0,50).map(f=>u.jsxs("tr",{children:[u.jsx("td",{children:u.jsx("strong",{children:f.coin})}),u.jsxs("td",{className:"text-right",style:{fontWeight:700},children:[f.score.toFixed(4),"%"]}),u.jsx("td",{className:c(f.direction),style:{textAlign:"center",fontSize:18},children:a(f.direction)}),u.jsx("td",{className:"text-right "+g(f.bg_1s),children:f.bg_1s!=null?f.bg_1s.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+g(f.bg_5s),children:f.bg_5s!=null?f.bg_5s.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+g(f.bg_15s),children:f.bg_15s!=null?f.bg_15s.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+g(f.bn_1s),children:f.bn_1s!=null?f.bn_1s.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+g(f.bn_5s),children:f.bn_5s!=null?f.bn_5s.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+g(f.bn_15s),children:f.bn_15s!=null?f.bn_15s.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+g(f.okx_1s),children:f.okx_1s!=null?f.okx_1s.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+g(f.okx_5s),children:f.okx_5s!=null?f.okx_5s.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+g(f.okx_15s),children:f.okx_15s!=null?f.okx_15s.toFixed(3)+"%":"-"})]},f.coin))})]})})]})}function Af({data:e}){function t(i){switch(i){case"rising":return"↑ 上涨";case"falling":return"↓ 下跌";default:return"− 中性"}}function n(i){switch(i){case"rising":return"text-green";case"falling":return"text-red";default:return"text-dim"}}function r(i){return i==="up"?"text-green":"text-red"}function l(i){return i==null||i===0?"":i>0?"text-green":"text-red"}return u.jsxs("section",{className:"card card-wide",id:"cm-card",children:[u.jsx("h2",{children:"📊 累积变动 (1min 共识)"}),u.jsx("div",{className:"table-wrap",style:{maxHeight:300},children:u.jsxs("table",{id:"cm-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"币种"}),u.jsx("th",{children:"状态"}),u.jsx("th",{children:"方向"}),u.jsx("th",{children:"分数"}),u.jsx("th",{children:"均值%"}),u.jsx("th",{children:"一致"}),u.jsx("th",{children:"BG 1m"}),u.jsx("th",{children:"BN 1m"}),u.jsx("th",{children:"OKX 1m"}),u.jsx("th",{children:"BG 5m"}),u.jsx("th",{children:"BN 5m"}),u.jsx("th",{children:"OKX 5m"}),u.jsx("th",{colSpan:3,style:{borderLeft:"2px solid var(--border)"},children:"1h 趋势"}),u.jsx("th",{children:"BG 1h"}),u.jsx("th",{children:"BN 1h"}),u.jsx("th",{children:"OKX 1h"})]})}),u.jsx("tbody",{children:!e||e.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:"17",className:"text-dim",style:{textAlign:"center",padding:20},children:"等待累积数据... (需要至少 1 分钟数据)"})}):e.slice(0,30).map(i=>u.jsxs("tr",{className:n(i.state),children:[u.jsx("td",{children:u.jsx("strong",{children:i.coin})}),u.jsx("td",{children:t(i.state)}),u.jsx("td",{className:r(i.direction),style:{textAlign:"center",fontSize:16},children:i.direction==="up"?"↑":"↓"}),u.jsx("td",{className:"text-right",style:{fontWeight:700},children:(i.score||0).toFixed(2)}),u.jsxs("td",{className:"text-right",children:[(i.avg_1m||0).toFixed(3),"%"]}),u.jsxs("td",{className:"text-right",children:[i.ex_agree||0,"/",i.ex_total||0]}),u.jsx("td",{className:"text-right "+l(i.bg_1m),children:i.bg_1m!=null?i.bg_1m.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+l(i.bn_1m),children:i.bn_1m!=null?i.bn_1m.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+l(i.okx_1m),children:i.okx_1m!=null?i.okx_1m.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+l(i.bg_5m),children:i.bg_5m!=null?i.bg_5m.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+l(i.bn_5m),children:i.bn_5m!=null?i.bn_5m.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+l(i.okx_5m),children:i.okx_5m!=null?i.okx_5m.toFixed(3)+"%":"-"}),u.jsxs("td",{className:"text-right "+r(i.direction),style:{fontWeight:600,borderLeft:"2px solid var(--border)"},children:[(i.avg_1h||0).toFixed(2),"%"]}),u.jsx("td",{className:"text-right "+l(i.bg_1h),children:i.bg_1h!=null?i.bg_1h.toFixed(2)+"%":"-"}),u.jsx("td",{className:"text-right "+l(i.bn_1h),children:i.bn_1h!=null?i.bn_1h.toFixed(2)+"%":"-"}),u.jsx("td",{className:"text-right "+l(i.okx_1h),children:i.okx_1h!=null?i.okx_1h.toFixed(2)+"%":"-"})]},i.coin))})]})})]})}function Bf({history:e}){function t(i){switch(i){case"rising":return"↑ 上涨";case"falling":return"↓ 下跌";default:return"− 中性"}}function n(i){switch(i){case"rising":return"text-green";case"falling":return"text-red";default:return"text-dim"}}function r(i){return i==="up"?"text-green":"text-red"}function l(i){return i==null||i===0?"":i>0?"text-green":"text-red"}return u.jsxs("section",{className:"card card-wide",id:"cm-history-card",children:[u.jsx("h2",{children:"📋 累积变动事件记录"}),u.jsx("div",{className:"table-wrap",style:{maxHeight:400},children:u.jsxs("table",{id:"cm-history-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"时间"}),u.jsx("th",{children:"币种"}),u.jsx("th",{children:"转换"}),u.jsx("th",{children:"方向"}),u.jsx("th",{children:"分数"}),u.jsx("th",{children:"均值%"}),u.jsx("th",{children:"一致"}),u.jsx("th",{children:"BG 1m"}),u.jsx("th",{children:"BN 1m"}),u.jsx("th",{children:"OKX 1m"}),u.jsx("th",{children:"BG 5m"}),u.jsx("th",{children:"BN 5m"}),u.jsx("th",{children:"OKX 5m"})]})}),u.jsx("tbody",{children:e.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:"13",className:"text-dim",style:{textAlign:"center",padding:20},children:"暂无累积变动事件记录"})}):e.slice(0,100).map((i,o)=>u.jsxs("tr",{children:[u.jsx("td",{className:"text-dim",children:i.created_at?new Date(i.created_at).toLocaleTimeString("zh-CN",{hour12:!1}):"-"}),u.jsx("td",{children:u.jsx("strong",{children:i.coin})}),u.jsxs("td",{className:n(i.new_state),children:[i.prev_state," → ",t(i.new_state)]}),u.jsx("td",{className:r(i.direction),style:{textAlign:"center",fontSize:16},children:i.direction==="up"?"↑":"↓"}),u.jsx("td",{className:"text-right",children:(i.score||0).toFixed(2)}),u.jsxs("td",{className:"text-right",children:[(i.avg_change||0).toFixed(3),"%"]}),u.jsxs("td",{className:"text-right",children:[i.ex_agree||0,"/",i.ex_total||0]}),u.jsx("td",{className:"text-right "+l(i.bg_1m),children:i.bg_1m!=null?i.bg_1m.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+l(i.bn_1m),children:i.bn_1m!=null?i.bn_1m.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+l(i.okx_1m),children:i.okx_1m!=null?i.okx_1m.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+l(i.bg_5m),children:i.bg_5m!=null?i.bg_5m.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+l(i.bn_5m),children:i.bn_5m!=null?i.bn_5m.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right "+l(i.okx_5m),children:i.okx_5m!=null?i.okx_5m.toFixed(3)+"%":"-"})]},(i.id||o)+"-cm"))})]})})]})}function Hf({filterData:e}){const t=e.filter(c=>c.passes_filter).length,n=e.filter(c=>c.signal_score>=80).length,r=e.filter(c=>c.signal_score>=50&&c.signal_score<80).length,l=e.filter(c=>c.fresh_anomaly).length;let i=`高分${n} 中分${r}`;l>0?(i+=` | ${l}币异动中`,t>0&&(i+=` → ${t}通过!`)):i+=" | 等待异动信号";function o(c){return c==null?"":c>=80?"text-green":c>=50?"text-yellow":"text-dim"}function s(c){return c==null||c<=1.5?"":c>3?"text-red":"text-orange"}function a(c){return c==null||c===0?"":c>0?"text-green":"text-red"}return u.jsxs("section",{className:"card card-wide",id:"trend-filter-card",children:[u.jsxs("h2",{children:["趋势过滤 (",t,"通过 / ",e.length,") ",u.jsx("span",{className:"text-dim",style:{fontSize:12,fontWeight:400},children:i})]}),u.jsx("div",{className:"table-wrap",style:{maxHeight:400},children:u.jsxs("table",{id:"trend-filter-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"币种"}),u.jsx("th",{children:"分数"}),u.jsx("th",{children:"24h范围"}),u.jsx("th",{children:"基线"}),u.jsx("th",{children:"1h范围"}),u.jsx("th",{children:"成交量比"}),u.jsx("th",{children:"1h变化"}),u.jsx("th",{children:"EMA52"}),u.jsx("th",{children:"EMA斜率"}),u.jsx("th",{children:"现价"}),u.jsx("th",{children:"> EMA"}),u.jsx("th",{children:"安静24h"}),u.jsx("th",{children:"安静1h"}),u.jsx("th",{children:"异动"}),u.jsx("th",{children:"更新于"})]})}),u.jsx("tbody",{children:e.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:"15",className:"text-dim",style:{textAlign:"center",padding:20},children:"等待K线数据..."})}):e.map(c=>u.jsxs("tr",{className:c.passes_filter?"filter-pass":"",children:[u.jsx("td",{children:u.jsx("strong",{children:c.coin})}),u.jsx("td",{className:"text-right "+o(c.signal_score),style:{fontWeight:700},children:c.signal_score!=null?c.signal_score.toFixed(0):"-"}),u.jsx("td",{className:"text-right "+(c.quiet_24h?"text-green":""),children:c.range_24h!=null?c.range_24h.toFixed(2)+"%":"-"}),u.jsx("td",{className:"text-right text-dim",children:c.vol_baseline!=null?c.vol_baseline.toFixed(2)+"%":"-"}),u.jsx("td",{className:"text-right "+(c.quiet_1h?"text-green":""),children:c.range_1h!=null?c.range_1h.toFixed(2)+"%":"-"}),u.jsx("td",{className:"text-right "+s(c.volume_ratio),children:c.volume_ratio!=null?c.volume_ratio.toFixed(2)+"x":"-"}),u.jsx("td",{className:"text-right "+(c.change_1h>0?"text-green":c.change_1h<0?"text-red":""),children:c.change_1h!=null?(c.change_1h>0?"+":"")+c.change_1h.toFixed(2)+"%":"-"}),u.jsx("td",{className:"text-right",children:c.ema_52?c.ema_52.toFixed(4):"-"}),u.jsx("td",{className:"text-right "+a(c.ema_slope),children:c.ema_slope!=null?(c.ema_slope>0?"+":"")+c.ema_slope.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-right",children:c.current_price?c.current_price.toFixed(4):"-"}),u.jsx("td",{className:c.price_above_ema?"text-green":"text-red",children:c.price_above_ema!=null?c.price_above_ema?"↑":"↓":"-"}),u.jsx("td",{className:c.quiet_24h?"text-green":"text-dim",children:c.quiet_24h!=null?c.quiet_24h?"✓":"✗":"-"}),u.jsx("td",{className:c.quiet_1h?"text-green":"text-dim",children:c.quiet_1h!=null?c.quiet_1h?"✓":"✗":"-"}),u.jsx("td",{className:c.fresh_anomaly?"text-orange":"text-dim",children:c.fresh_anomaly!=null&&c.fresh_anomaly?"⚠":"-"}),u.jsx("td",{className:"text-dim",children:c.last_updated?new Date(c.last_updated).toLocaleTimeString("zh-CN",{hour12:!1}):"-"})]},c.coin))})]})})]})}function Wf({signals:e}){const t=e.filter(r=>r.category==="full"),n=t.filter(r=>r.type==="enter").length;return u.jsxs("section",{className:"card card-wide",id:"trend-signal-card",children:[u.jsxs("h2",{children:["完整信号 (异动+分数≥70) ",n>0&&u.jsxs("span",{className:"text-green",style:{fontSize:12,fontWeight:400,marginLeft:8},children:["共",n,"条"]})]}),u.jsx("div",{className:"table-wrap",style:{maxHeight:350},children:u.jsxs("table",{id:"trend-signal-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"时间"}),u.jsx("th",{children:"币种"}),u.jsx("th",{children:"类型"}),u.jsx("th",{children:"分数"}),u.jsx("th",{children:"价格"}),u.jsx("th",{children:"成交量比"}),u.jsx("th",{children:"EMA斜率"}),u.jsx("th",{children:"趋势状态"})]})}),u.jsx("tbody",{children:t.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:"8",className:"text-dim",style:{textAlign:"center",padding:20},children:"等待完整信号... (FreshAnomaly + 分数≥70)"})}):t.slice(0,50).map((r,l)=>{const i=r.type==="enter"?"signal-enter":"signal-exit",o=r.timestamp?new Date(r.timestamp).toLocaleTimeString("zh-CN",{hour12:!1}):"-";return u.jsxs("tr",{className:i,children:[u.jsx("td",{className:"text-dim",children:o}),u.jsx("td",{children:u.jsx("strong",{children:r.coin})}),u.jsx("td",{className:r.type==="enter"?"text-green":"text-dim",style:{fontWeight:600},children:r.type==="enter"?"开":"关"}),u.jsx("td",{className:"text-right",style:{fontWeight:700},children:r.signal_score!=null?r.signal_score.toFixed(0):"-"}),u.jsx("td",{className:"text-right",children:r.price?r.price.toFixed(4):"-"}),u.jsx("td",{className:"text-right",children:r.volume_ratio!=null?r.volume_ratio.toFixed(2)+"x":"-"}),u.jsx("td",{className:"text-right",children:r.ema_slope!=null?(r.ema_slope>0?"+":"")+r.ema_slope.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-dim",children:r.state||"-"})]},"full-"+r.timestamp+"-"+r.coin+"-"+l)})})]})})]})}function Vf({signals:e}){const t=e.filter(r=>r.category==="high"),n=t.filter(r=>r.type==="enter").length;return u.jsxs("section",{className:"card card-wide",id:"high-score-card",children:[u.jsxs("h2",{children:["高分信号 (分数≥90) ",n>0&&u.jsxs("span",{className:"text-green",style:{fontSize:12,fontWeight:400,marginLeft:8},children:["共",n,"条"]})]}),u.jsx("div",{className:"table-wrap",style:{maxHeight:350},children:u.jsxs("table",{id:"high-score-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"时间"}),u.jsx("th",{children:"币种"}),u.jsx("th",{children:"类型"}),u.jsx("th",{children:"分数"}),u.jsx("th",{children:"价格"}),u.jsx("th",{children:"成交量比"}),u.jsx("th",{children:"EMA斜率"}),u.jsx("th",{children:"趋势状态"})]})}),u.jsx("tbody",{children:t.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:"8",className:"text-dim",style:{textAlign:"center",padding:20},children:"等待高分信号... (分数≥90)"})}):t.slice(0,50).map((r,l)=>{const i=r.type==="enter"?"signal-enter":"signal-exit",o=r.timestamp?new Date(r.timestamp).toLocaleTimeString("zh-CN",{hour12:!1}):"-";return u.jsxs("tr",{className:i,children:[u.jsx("td",{className:"text-dim",children:o}),u.jsx("td",{children:u.jsx("strong",{children:r.coin})}),u.jsx("td",{className:r.type==="enter"?"text-green":"text-dim",style:{fontWeight:600},children:r.type==="enter"?"开":"关"}),u.jsx("td",{className:"text-right",style:{fontWeight:700},children:r.signal_score!=null?r.signal_score.toFixed(0):"-"}),u.jsx("td",{className:"text-right",children:r.price?r.price.toFixed(4):"-"}),u.jsx("td",{className:"text-right",children:r.volume_ratio!=null?r.volume_ratio.toFixed(2)+"x":"-"}),u.jsx("td",{className:"text-right",children:r.ema_slope!=null?(r.ema_slope>0?"+":"")+r.ema_slope.toFixed(3)+"%":"-"}),u.jsx("td",{className:"text-dim",children:r.state||"-"})]},"high-"+r.timestamp+"-"+r.coin+"-"+l)})})]})})]})}Yl.createRoot(document.getElementById("root")).render(u.jsx(Sc.StrictMode,{children:u.jsx(Mf,{})}));
diff --git a/frontend/dist/assets/index-osMYKIfL.js b/frontend/dist/assets/index-osMYKIfL.js
deleted file mode 100644
index 76427ac..0000000
--- a/frontend/dist/assets/index-osMYKIfL.js
+++ /dev/null
@@ -1,40 +0,0 @@
-(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const i of l)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(l){const i={};return l.integrity&&(i.integrity=l.integrity),l.referrerPolicy&&(i.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?i.credentials="include":l.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(l){if(l.ep)return;l.ep=!0;const i=n(l);fetch(l.href,i)}})();function oc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ku={exports:{}},ll={},Yu={exports:{}},D={};/**
- * @license React
- * react.production.min.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */var qn=Symbol.for("react.element"),uc=Symbol.for("react.portal"),sc=Symbol.for("react.fragment"),ac=Symbol.for("react.strict_mode"),cc=Symbol.for("react.profiler"),dc=Symbol.for("react.provider"),fc=Symbol.for("react.context"),pc=Symbol.for("react.forward_ref"),hc=Symbol.for("react.suspense"),mc=Symbol.for("react.memo"),vc=Symbol.for("react.lazy"),Io=Symbol.iterator;function yc(e){return e===null||typeof e!="object"?null:(e=Io&&e[Io]||e["@@iterator"],typeof e=="function"?e:null)}var Xu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Gu=Object.assign,Zu={};function dn(e,t,n){this.props=e,this.context=t,this.refs=Zu,this.updater=n||Xu}dn.prototype.isReactComponent={};dn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};dn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Ju(){}Ju.prototype=dn.prototype;function Bi(e,t,n){this.props=e,this.context=t,this.refs=Zu,this.updater=n||Xu}var Hi=Bi.prototype=new Ju;Hi.constructor=Bi;Gu(Hi,dn.prototype);Hi.isPureReactComponent=!0;var Uo=Array.isArray,qu=Object.prototype.hasOwnProperty,Wi={current:null},bu={key:!0,ref:!0,__self:!0,__source:!0};function es(e,t,n){var r,l={},i=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(i=""+t.key),t)qu.call(t,r)&&!bu.hasOwnProperty(r)&&(l[r]=t[r]);var s=arguments.length-2;if(s===1)l.children=n;else if(1>>1,b=N[X];if(0>>1;Xl(wl,L))jtl(lr,wl)?(N[X]=lr,N[jt]=L,X=jt):(N[X]=wl,N[kt]=L,X=kt);else if(jtl(lr,L))N[X]=lr,N[jt]=L,X=jt;else break e}}return z}function l(N,z){var L=N.sortIndex-z.sortIndex;return L!==0?L:N.id-z.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var a=[],c=[],f=1,v=null,m=3,w=!1,y=!1,S=!1,O=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function h(N){for(var z=n(c);z!==null;){if(z.callback===null)r(c);else if(z.startTime<=N)r(c),z.sortIndex=z.expirationTime,t(a,z);else break;z=n(c)}}function g(N){if(S=!1,h(N),!y)if(n(a)!==null)y=!0,de(k);else{var z=n(c);z!==null&&oe(g,z.startTime-N)}}function k(N,z){y=!1,S&&(S=!1,p(_),_=-1),w=!0;var L=m;try{for(h(z),v=n(a);v!==null&&(!(v.expirationTime>z)||N&&!ne());){var X=v.callback;if(typeof X=="function"){v.callback=null,m=v.priorityLevel;var b=X(v.expirationTime<=z);z=e.unstable_now(),typeof b=="function"?v.callback=b:v===n(a)&&r(a),h(z)}else r(a);v=n(a)}if(v!==null)var rr=!0;else{var kt=n(c);kt!==null&&oe(g,kt.startTime-z),rr=!1}return rr}finally{v=null,m=L,w=!1}}var E=!1,j=null,_=-1,U=5,T=-1;function ne(){return!(e.unstable_now()-TN||125X?(N.sortIndex=L,t(c,N),n(a)===null&&N===n(c)&&(S?(p(_),_=-1):S=!0,oe(g,L-X))):(N.sortIndex=b,t(a,N),y||w||(y=!0,de(k))),N},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(N){var z=m;return function(){var L=m;m=z;try{return N.apply(this,arguments)}finally{m=L}}}})(is);ls.exports=is;var zc=ls.exports;/**
- * @license React
- * react-dom.production.min.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */var Tc=M,Ne=zc;function x(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Xl=Object.prototype.hasOwnProperty,Lc=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,$o={},Vo={};function Dc(e){return Xl.call(Vo,e)?!0:Xl.call($o,e)?!1:Lc.test(e)?Vo[e]=!0:($o[e]=!0,!1)}function Fc(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Rc(e,t,n,r){if(t===null||typeof t>"u"||Fc(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function me(e,t,n,r,l,i,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=o}var ie={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ie[e]=new me(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ie[t]=new me(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ie[e]=new me(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ie[e]=new me(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){ie[e]=new me(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ie[e]=new me(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ie[e]=new me(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ie[e]=new me(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ie[e]=new me(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ki=/[\-:]([a-z])/g;function Yi(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Ki,Yi);ie[t]=new me(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Ki,Yi);ie[t]=new me(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Ki,Yi);ie[t]=new me(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ie[e]=new me(e,1,!1,e.toLowerCase(),null,!1,!1)});ie.xlinkHref=new me("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ie[e]=new me(e,1,!1,e.toLowerCase(),null,!0,!0)});function Xi(e,t,n,r){var l=ie.hasOwnProperty(t)?ie[t]:null;(l!==null?l.type!==0:r||!(2s||l[o]!==i[s]){var a=`
-`+l[o].replace(" at new "," at ");return e.displayName&&a.includes("")&&(a=a.replace("",e.displayName)),a}while(1<=o&&0<=s);break}}}finally{jl=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?kn(e):""}function Oc(e){switch(e.tag){case 5:return kn(e.type);case 16:return kn("Lazy");case 13:return kn("Suspense");case 19:return kn("SuspenseList");case 0:case 2:case 15:return e=Nl(e.type,!1),e;case 11:return e=Nl(e.type.render,!1),e;case 1:return e=Nl(e.type,!0),e;default:return""}}function ql(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case $t:return"Fragment";case At:return"Portal";case Gl:return"Profiler";case Gi:return"StrictMode";case Zl:return"Suspense";case Jl:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ss:return(e.displayName||"Context")+".Consumer";case us:return(e._context.displayName||"Context")+".Provider";case Zi:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ji:return t=e.displayName||null,t!==null?t:ql(e.type)||"Memo";case rt:t=e._payload,e=e._init;try{return ql(e(t))}catch{}}return null}function Mc(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ql(t);case 8:return t===Gi?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function yt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function cs(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Ic(e){var t=cs(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(o){r=""+o,i.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ur(e){e._valueTracker||(e._valueTracker=Ic(e))}function ds(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=cs(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Rr(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function bl(e,t){var n=t.checked;return K({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Ho(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=yt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function fs(e,t){t=t.checked,t!=null&&Xi(e,"checked",t,!1)}function ei(e,t){fs(e,t);var n=yt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?ti(e,t.type,n):t.hasOwnProperty("defaultValue")&&ti(e,t.type,yt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Wo(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function ti(e,t,n){(t!=="number"||Rr(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var jn=Array.isArray;function Jt(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=sr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Mn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Cn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Uc=["Webkit","ms","Moz","O"];Object.keys(Cn).forEach(function(e){Uc.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Cn[t]=Cn[e]})});function vs(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Cn.hasOwnProperty(e)&&Cn[e]?(""+t).trim():t+"px"}function ys(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=vs(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var Ac=K({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function li(e,t){if(t){if(Ac[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(x(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(x(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(x(61))}if(t.style!=null&&typeof t.style!="object")throw Error(x(62))}}function ii(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var oi=null;function qi(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ui=null,qt=null,bt=null;function Yo(e){if(e=tr(e)){if(typeof ui!="function")throw Error(x(280));var t=e.stateNode;t&&(t=al(t),ui(e.stateNode,e.type,t))}}function gs(e){qt?bt?bt.push(e):bt=[e]:qt=e}function xs(){if(qt){var e=qt,t=bt;if(bt=qt=null,Yo(e),t)for(e=0;e>>=0,e===0?32:31-(Zc(e)/Jc|0)|0}var ar=64,cr=4194304;function Nn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Ur(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,i=e.pingedLanes,o=n&268435455;if(o!==0){var s=o&~l;s!==0?r=Nn(s):(i&=o,i!==0&&(r=Nn(i)))}else o=n&~l,o!==0?r=Nn(o):i!==0&&(r=Nn(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,i=t&-t,l>=i||l===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function bn(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ue(t),e[t]=n}function td(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Pn),nu=" ",ru=!1;function As(e,t){switch(e){case"keyup":return zd.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $s(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Vt=!1;function Ld(e,t){switch(e){case"compositionend":return $s(t);case"keypress":return t.which!==32?null:(ru=!0,nu);case"textInput":return e=t.data,e===nu&&ru?null:e;default:return null}}function Dd(e,t){if(Vt)return e==="compositionend"||!oo&&As(e,t)?(e=Is(),Er=ro=ut=null,Vt=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=uu(n)}}function Ws(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ws(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Qs(){for(var e=window,t=Rr();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Rr(e.document)}return t}function uo(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Vd(e){var t=Qs(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Ws(n.ownerDocument.documentElement,n)){if(r!==null&&uo(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,i=Math.min(r.start,l);r=r.end===void 0?i:Math.min(r.end,l),!e.extend&&i>r&&(l=r,r=i,i=l),l=su(n,i);var o=su(n,r);l&&o&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Bt=null,pi=null,Tn=null,hi=!1;function au(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;hi||Bt==null||Bt!==Rr(r)||(r=Bt,"selectionStart"in r&&uo(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Tn&&Bn(Tn,r)||(Tn=r,r=Vr(pi,"onSelect"),0Qt||(e.current=wi[Qt],wi[Qt]=null,Qt--)}function A(e,t){Qt++,wi[Qt]=e.current,e.current=t}var gt={},ce=wt(gt),ge=wt(!1),Lt=gt;function ln(e,t){var n=e.type.contextTypes;if(!n)return gt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},i;for(i in n)l[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function xe(e){return e=e.childContextTypes,e!=null}function Hr(){B(ge),B(ce)}function vu(e,t,n){if(ce.current!==gt)throw Error(x(168));A(ce,t),A(ge,n)}function ea(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(x(108,Mc(e)||"Unknown",l));return K({},n,r)}function Wr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||gt,Lt=ce.current,A(ce,e),A(ge,ge.current),!0}function yu(e,t,n){var r=e.stateNode;if(!r)throw Error(x(169));n?(e=ea(e,t,Lt),r.__reactInternalMemoizedMergedChildContext=e,B(ge),B(ce),A(ce,e)):B(ge),A(ge,n)}var Ye=null,cl=!1,Ul=!1;function ta(e){Ye===null?Ye=[e]:Ye.push(e)}function bd(e){cl=!0,ta(e)}function St(){if(!Ul&&Ye!==null){Ul=!0;var e=0,t=I;try{var n=Ye;for(I=1;e>=o,l-=o,Xe=1<<32-Ue(t)+l|n<_?(U=j,j=null):U=j.sibling;var T=m(p,j,h[_],g);if(T===null){j===null&&(j=U);break}e&&j&&T.alternate===null&&t(p,j),d=i(T,d,_),E===null?k=T:E.sibling=T,E=T,j=U}if(_===h.length)return n(p,j),H&&Nt(p,_),k;if(j===null){for(;__?(U=j,j=null):U=j.sibling;var ne=m(p,j,T.value,g);if(ne===null){j===null&&(j=U);break}e&&j&&ne.alternate===null&&t(p,j),d=i(ne,d,_),E===null?k=ne:E.sibling=ne,E=ne,j=U}if(T.done)return n(p,j),H&&Nt(p,_),k;if(j===null){for(;!T.done;_++,T=h.next())T=v(p,T.value,g),T!==null&&(d=i(T,d,_),E===null?k=T:E.sibling=T,E=T);return H&&Nt(p,_),k}for(j=r(p,j);!T.done;_++,T=h.next())T=w(j,p,_,T.value,g),T!==null&&(e&&T.alternate!==null&&j.delete(T.key===null?_:T.key),d=i(T,d,_),E===null?k=T:E.sibling=T,E=T);return e&&j.forEach(function(_e){return t(p,_e)}),H&&Nt(p,_),k}function O(p,d,h,g){if(typeof h=="object"&&h!==null&&h.type===$t&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case or:e:{for(var k=h.key,E=d;E!==null;){if(E.key===k){if(k=h.type,k===$t){if(E.tag===7){n(p,E.sibling),d=l(E,h.props.children),d.return=p,p=d;break e}}else if(E.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===rt&&wu(k)===E.type){n(p,E.sibling),d=l(E,h.props),d.ref=xn(p,E,h),d.return=p,p=d;break e}n(p,E);break}else t(p,E);E=E.sibling}h.type===$t?(d=Tt(h.props.children,p.mode,g,h.key),d.return=p,p=d):(g=Fr(h.type,h.key,h.props,null,p.mode,g),g.ref=xn(p,d,h),g.return=p,p=g)}return o(p);case At:e:{for(E=h.key;d!==null;){if(d.key===E)if(d.tag===4&&d.stateNode.containerInfo===h.containerInfo&&d.stateNode.implementation===h.implementation){n(p,d.sibling),d=l(d,h.children||[]),d.return=p,p=d;break e}else{n(p,d);break}else t(p,d);d=d.sibling}d=Kl(h,p.mode,g),d.return=p,p=d}return o(p);case rt:return E=h._init,O(p,d,E(h._payload),g)}if(jn(h))return y(p,d,h,g);if(hn(h))return S(p,d,h,g);yr(p,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,d!==null&&d.tag===6?(n(p,d.sibling),d=l(d,h),d.return=p,p=d):(n(p,d),d=Ql(h,p.mode,g),d.return=p,p=d),o(p)):n(p,d)}return O}var un=ia(!0),oa=ia(!1),Yr=wt(null),Xr=null,Xt=null,fo=null;function po(){fo=Xt=Xr=null}function ho(e){var t=Yr.current;B(Yr),e._currentValue=t}function ji(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function tn(e,t){Xr=e,fo=Xt=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ye=!0),e.firstContext=null)}function De(e){var t=e._currentValue;if(fo!==e)if(e={context:e,memoizedValue:t,next:null},Xt===null){if(Xr===null)throw Error(x(308));Xt=e,Xr.dependencies={lanes:0,firstContext:e}}else Xt=Xt.next=e;return t}var _t=null;function mo(e){_t===null?_t=[e]:_t.push(e)}function ua(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,mo(t)):(n.next=l.next,l.next=n),t.interleaved=n,be(e,r)}function be(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var lt=!1;function vo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function sa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ze(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function pt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,R&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,be(e,n)}return l=r.interleaved,l===null?(t.next=t,mo(r)):(t.next=l.next,l.next=t),r.interleaved=t,be(e,n)}function _r(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,eo(e,n)}}function Su(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?l=i=o:i=i.next=o,n=n.next}while(n!==null);i===null?l=i=t:i=i.next=t}else l=i=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Gr(e,t,n,r){var l=e.updateQueue;lt=!1;var i=l.firstBaseUpdate,o=l.lastBaseUpdate,s=l.shared.pending;if(s!==null){l.shared.pending=null;var a=s,c=a.next;a.next=null,o===null?i=c:o.next=c,o=a;var f=e.alternate;f!==null&&(f=f.updateQueue,s=f.lastBaseUpdate,s!==o&&(s===null?f.firstBaseUpdate=c:s.next=c,f.lastBaseUpdate=a))}if(i!==null){var v=l.baseState;o=0,f=c=a=null,s=i;do{var m=s.lane,w=s.eventTime;if((r&m)===m){f!==null&&(f=f.next={eventTime:w,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});e:{var y=e,S=s;switch(m=t,w=n,S.tag){case 1:if(y=S.payload,typeof y=="function"){v=y.call(w,v,m);break e}v=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=S.payload,m=typeof y=="function"?y.call(w,v,m):y,m==null)break e;v=K({},v,m);break e;case 2:lt=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,m=l.effects,m===null?l.effects=[s]:m.push(s))}else w={eventTime:w,lane:m,tag:s.tag,payload:s.payload,callback:s.callback,next:null},f===null?(c=f=w,a=v):f=f.next=w,o|=m;if(s=s.next,s===null){if(s=l.shared.pending,s===null)break;m=s,s=m.next,m.next=null,l.lastBaseUpdate=m,l.shared.pending=null}}while(!0);if(f===null&&(a=v),l.baseState=a,l.firstBaseUpdate=c,l.lastBaseUpdate=f,t=l.shared.interleaved,t!==null){l=t;do o|=l.lane,l=l.next;while(l!==t)}else i===null&&(l.shared.lanes=0);Rt|=o,e.lanes=o,e.memoizedState=v}}function ku(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=$l.transition;$l.transition={};try{e(!1),t()}finally{I=n,$l.transition=r}}function Ea(){return Fe().memoizedState}function rf(e,t,n){var r=mt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ca(e))_a(t,n);else if(n=ua(e,t,n,r),n!==null){var l=pe();Ae(n,e,r,l),Pa(n,t,r)}}function lf(e,t,n){var r=mt(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ca(e))_a(t,l);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var o=t.lastRenderedState,s=i(o,n);if(l.hasEagerState=!0,l.eagerState=s,$e(s,o)){var a=t.interleaved;a===null?(l.next=l,mo(t)):(l.next=a.next,a.next=l),t.interleaved=l;return}}catch{}finally{}n=ua(e,t,l,r),n!==null&&(l=pe(),Ae(n,e,r,l),Pa(n,t,r))}}function Ca(e){var t=e.alternate;return e===Q||t!==null&&t===Q}function _a(e,t){Ln=Jr=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Pa(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,eo(e,n)}}var qr={readContext:De,useCallback:ue,useContext:ue,useEffect:ue,useImperativeHandle:ue,useInsertionEffect:ue,useLayoutEffect:ue,useMemo:ue,useReducer:ue,useRef:ue,useState:ue,useDebugValue:ue,useDeferredValue:ue,useTransition:ue,useMutableSource:ue,useSyncExternalStore:ue,useId:ue,unstable_isNewReconciler:!1},of={readContext:De,useCallback:function(e,t){return Be().memoizedState=[e,t===void 0?null:t],e},useContext:De,useEffect:Nu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,zr(4194308,4,wa.bind(null,t,e),n)},useLayoutEffect:function(e,t){return zr(4194308,4,e,t)},useInsertionEffect:function(e,t){return zr(4,2,e,t)},useMemo:function(e,t){var n=Be();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Be();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=rf.bind(null,Q,e),[r.memoizedState,e]},useRef:function(e){var t=Be();return e={current:e},t.memoizedState=e},useState:ju,useDebugValue:No,useDeferredValue:function(e){return Be().memoizedState=e},useTransition:function(){var e=ju(!1),t=e[0];return e=nf.bind(null,e[1]),Be().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Q,l=Be();if(H){if(n===void 0)throw Error(x(407));n=n()}else{if(n=t(),te===null)throw Error(x(349));Ft&30||fa(r,t,n)}l.memoizedState=n;var i={value:n,getSnapshot:t};return l.queue=i,Nu(ha.bind(null,r,i,e),[e]),r.flags|=2048,Zn(9,pa.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Be(),t=te.identifierPrefix;if(H){var n=Ge,r=Xe;n=(r&~(1<<32-Ue(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Xn++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[He]=t,e[Qn]=r,Ua(e,t,!1,!1),t.stateNode=e;e:{switch(o=ii(n,r),n){case"dialog":V("cancel",e),V("close",e),l=r;break;case"iframe":case"object":case"embed":V("load",e),l=r;break;case"video":case"audio":for(l=0;lcn&&(t.flags|=128,r=!0,wn(i,!1),t.lanes=4194304)}else{if(!r)if(e=Zr(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),wn(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!H)return se(t),null}else 2*G()-i.renderingStartTime>cn&&n!==1073741824&&(t.flags|=128,r=!0,wn(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(n=i.last,n!==null?n.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=G(),t.sibling=null,n=W.current,A(W,r?n&1|2:n&1),t):(se(t),null);case 22:case 23:return To(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Se&1073741824&&(se(t),t.subtreeFlags&6&&(t.flags|=8192)):se(t),null;case 24:return null;case 25:return null}throw Error(x(156,t.tag))}function hf(e,t){switch(ao(t),t.tag){case 1:return xe(t.type)&&Hr(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return sn(),B(ge),B(ce),xo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return go(t),null;case 13:if(B(W),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(x(340));on()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return B(W),null;case 4:return sn(),null;case 10:return ho(t.type._context),null;case 22:case 23:return To(),null;case 24:return null;default:return null}}var xr=!1,ae=!1,mf=typeof WeakSet=="function"?WeakSet:Set,C=null;function Gt(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Y(e,t,r)}else n.current=null}function Di(e,t,n){try{n()}catch(r){Y(e,t,r)}}var Ou=!1;function vf(e,t){if(mi=Ar,e=Qs(),uo(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var o=0,s=-1,a=-1,c=0,f=0,v=e,m=null;t:for(;;){for(var w;v!==n||l!==0&&v.nodeType!==3||(s=o+l),v!==i||r!==0&&v.nodeType!==3||(a=o+r),v.nodeType===3&&(o+=v.nodeValue.length),(w=v.firstChild)!==null;)m=v,v=w;for(;;){if(v===e)break t;if(m===n&&++c===l&&(s=o),m===i&&++f===r&&(a=o),(w=v.nextSibling)!==null)break;v=m,m=v.parentNode}v=w}n=s===-1||a===-1?null:{start:s,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(vi={focusedElem:e,selectionRange:n},Ar=!1,C=t;C!==null;)if(t=C,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,C=e;else for(;C!==null;){t=C;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var S=y.memoizedProps,O=y.memoizedState,p=t.stateNode,d=p.getSnapshotBeforeUpdate(t.elementType===t.type?S:Oe(t.type,S),O);p.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var h=t.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(x(163))}}catch(g){Y(t,t.return,g)}if(e=t.sibling,e!==null){e.return=t.return,C=e;break}C=t.return}return y=Ou,Ou=!1,y}function Dn(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var i=l.destroy;l.destroy=void 0,i!==void 0&&Di(t,n,i)}l=l.next}while(l!==r)}}function pl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Fi(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Va(e){var t=e.alternate;t!==null&&(e.alternate=null,Va(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[He],delete t[Qn],delete t[xi],delete t[Jd],delete t[qd])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Ba(e){return e.tag===5||e.tag===3||e.tag===4}function Mu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ba(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ri(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Br));else if(r!==4&&(e=e.child,e!==null))for(Ri(e,t,n),e=e.sibling;e!==null;)Ri(e,t,n),e=e.sibling}function Oi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Oi(e,t,n),e=e.sibling;e!==null;)Oi(e,t,n),e=e.sibling}var re=null,Me=!1;function nt(e,t,n){for(n=n.child;n!==null;)Ha(e,t,n),n=n.sibling}function Ha(e,t,n){if(We&&typeof We.onCommitFiberUnmount=="function")try{We.onCommitFiberUnmount(il,n)}catch{}switch(n.tag){case 5:ae||Gt(n,t);case 6:var r=re,l=Me;re=null,nt(e,t,n),re=r,Me=l,re!==null&&(Me?(e=re,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):re.removeChild(n.stateNode));break;case 18:re!==null&&(Me?(e=re,n=n.stateNode,e.nodeType===8?Il(e.parentNode,n):e.nodeType===1&&Il(e,n),$n(e)):Il(re,n.stateNode));break;case 4:r=re,l=Me,re=n.stateNode.containerInfo,Me=!0,nt(e,t,n),re=r,Me=l;break;case 0:case 11:case 14:case 15:if(!ae&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var i=l,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&Di(n,t,o),l=l.next}while(l!==r)}nt(e,t,n);break;case 1:if(!ae&&(Gt(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(s){Y(n,t,s)}nt(e,t,n);break;case 21:nt(e,t,n);break;case 22:n.mode&1?(ae=(r=ae)||n.memoizedState!==null,nt(e,t,n),ae=r):nt(e,t,n);break;default:nt(e,t,n)}}function Iu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new mf),t.forEach(function(r){var l=Ef.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Re(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=o),r&=~i}if(r=l,r=G()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*gf(r/1960))-r,10e?16:e,st===null)var r=!1;else{if(e=st,st=null,tl=0,R&6)throw Error(x(331));var l=R;for(R|=4,C=e.current;C!==null;){var i=C,o=i.child;if(C.flags&16){var s=i.deletions;if(s!==null){for(var a=0;aG()-Po?zt(e,0):_o|=n),we(e,t)}function Ja(e,t){t===0&&(e.mode&1?(t=cr,cr<<=1,!(cr&130023424)&&(cr=4194304)):t=1);var n=pe();e=be(e,t),e!==null&&(bn(e,t,n),we(e,n))}function Nf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ja(e,n)}function Ef(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(x(314))}r!==null&&r.delete(t),Ja(e,n)}var qa;qa=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ge.current)ye=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ye=!1,ff(e,t,n);ye=!!(e.flags&131072)}else ye=!1,H&&t.flags&1048576&&na(t,Kr,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Tr(e,t),e=t.pendingProps;var l=ln(t,ce.current);tn(t,n),l=So(null,t,r,e,l,n);var i=ko();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,xe(r)?(i=!0,Wr(t)):i=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,vo(t),l.updater=fl,t.stateNode=l,l._reactInternals=t,Ei(t,r,e,n),t=Pi(null,t,r,!0,i,n)):(t.tag=0,H&&i&&so(t),fe(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Tr(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=_f(r),e=Oe(r,e),l){case 0:t=_i(null,t,r,e,n);break e;case 1:t=Du(null,t,r,e,n);break e;case 11:t=Tu(null,t,r,e,n);break e;case 14:t=Lu(null,t,r,Oe(r.type,e),n);break e}throw Error(x(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Oe(r,l),_i(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Oe(r,l),Du(e,t,r,l,n);case 3:e:{if(Oa(t),e===null)throw Error(x(387));r=t.pendingProps,i=t.memoizedState,l=i.element,sa(e,t),Gr(t,r,null,n);var o=t.memoizedState;if(r=o.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){l=an(Error(x(423)),t),t=Fu(e,t,r,n,l);break e}else if(r!==l){l=an(Error(x(424)),t),t=Fu(e,t,r,n,l);break e}else for(ke=ft(t.stateNode.containerInfo.firstChild),je=t,H=!0,Ie=null,n=oa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(on(),r===l){t=et(e,t,n);break e}fe(e,t,r,n)}t=t.child}return t;case 5:return aa(t),e===null&&ki(t),r=t.type,l=t.pendingProps,i=e!==null?e.memoizedProps:null,o=l.children,yi(r,l)?o=null:i!==null&&yi(r,i)&&(t.flags|=32),Ra(e,t),fe(e,t,o,n),t.child;case 6:return e===null&&ki(t),null;case 13:return Ma(e,t,n);case 4:return yo(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=un(t,null,r,n):fe(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Oe(r,l),Tu(e,t,r,l,n);case 7:return fe(e,t,t.pendingProps,n),t.child;case 8:return fe(e,t,t.pendingProps.children,n),t.child;case 12:return fe(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,i=t.memoizedProps,o=l.value,A(Yr,r._currentValue),r._currentValue=o,i!==null)if($e(i.value,o)){if(i.children===l.children&&!ge.current){t=et(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var s=i.dependencies;if(s!==null){o=i.child;for(var a=s.firstContext;a!==null;){if(a.context===r){if(i.tag===1){a=Ze(-1,n&-n),a.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var f=c.pending;f===null?a.next=a:(a.next=f.next,f.next=a),c.pending=a}}i.lanes|=n,a=i.alternate,a!==null&&(a.lanes|=n),ji(i.return,n,t),s.lanes|=n;break}a=a.next}}else if(i.tag===10)o=i.type===t.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(x(341));o.lanes|=n,s=o.alternate,s!==null&&(s.lanes|=n),ji(o,n,t),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===t){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}fe(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,tn(t,n),l=De(l),r=r(l),t.flags|=1,fe(e,t,r,n),t.child;case 14:return r=t.type,l=Oe(r,t.pendingProps),l=Oe(r.type,l),Lu(e,t,r,l,n);case 15:return Da(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Oe(r,l),Tr(e,t),t.tag=1,xe(r)?(e=!0,Wr(t)):e=!1,tn(t,n),za(t,r,l),Ei(t,r,l,n),Pi(null,t,r,!0,e,n);case 19:return Ia(e,t,n);case 22:return Fa(e,t,n)}throw Error(x(156,t.tag))};function ba(e,t){return Cs(e,t)}function Cf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Te(e,t,n,r){return new Cf(e,t,n,r)}function Do(e){return e=e.prototype,!(!e||!e.isReactComponent)}function _f(e){if(typeof e=="function")return Do(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Zi)return 11;if(e===Ji)return 14}return 2}function vt(e,t){var n=e.alternate;return n===null?(n=Te(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Fr(e,t,n,r,l,i){var o=2;if(r=e,typeof e=="function")Do(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case $t:return Tt(n.children,l,i,t);case Gi:o=8,l|=8;break;case Gl:return e=Te(12,n,t,l|2),e.elementType=Gl,e.lanes=i,e;case Zl:return e=Te(13,n,t,l),e.elementType=Zl,e.lanes=i,e;case Jl:return e=Te(19,n,t,l),e.elementType=Jl,e.lanes=i,e;case as:return ml(n,l,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case us:o=10;break e;case ss:o=9;break e;case Zi:o=11;break e;case Ji:o=14;break e;case rt:o=16,r=null;break e}throw Error(x(130,e==null?e:typeof e,""))}return t=Te(o,n,t,l),t.elementType=e,t.type=r,t.lanes=i,t}function Tt(e,t,n,r){return e=Te(7,e,r,t),e.lanes=n,e}function ml(e,t,n,r){return e=Te(22,e,r,t),e.elementType=as,e.lanes=n,e.stateNode={isHidden:!1},e}function Ql(e,t,n){return e=Te(6,e,null,t),e.lanes=n,e}function Kl(e,t,n){return t=Te(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Pf(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Cl(0),this.expirationTimes=Cl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Cl(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Fo(e,t,n,r,l,i,o,s,a){return e=new Pf(e,t,n,s,a),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Te(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},vo(i),e}function zf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(rc)}catch(e){console.error(e)}}rc(),rs.exports=Ee;var Rf=rs.exports,Qu=Rf;Yl.createRoot=Qu.createRoot,Yl.hydrateRoot=Qu.hydrateRoot;const lc=["HyperLiquid","Bitget"];function $i(e){return e==null||e<=0?"-":e>=100?e.toFixed(2):e>=1?e.toFixed(4):e.toFixed(6)}function Vi(e){return e==null?"":e>0?"text-green":e<0?"text-red":""}function Of(){const[e,t]=M.useState("--:--:--"),[n,r]=M.useState("● 未连接"),[l,i]=M.useState(!1),[o,s]=M.useState(""),[a,c]=M.useState([]),[f,v]=M.useState(""),[m,w]=M.useState([]),[y,S]=M.useState([]),[O,p]=M.useState([]),[d,h]=M.useState({}),[g,k]=M.useState([]),E=M.useRef({});M.useEffect(()=>{const F=()=>t(new Date().toLocaleTimeString("zh-CN",{hour12:!1}));F();const $=setInterval(F,1e3);return()=>clearInterval($)},[]),M.useEffect(()=>{let F=new EventSource("/events");return F.addEventListener("connected",()=>{r("● 已连接"),i(!0)}),F.onerror=()=>{r("● 已断开 (重连中...)"),i(!1),setTimeout(()=>{F=new EventSource("/events")},3e3)},F.onmessage=$=>{try{const P=JSON.parse($.data);switch(P.event){case"prices":_(P.data);break;case"arb":w(P.data||[]);break;case"positions":S(P.data||[]);break;case"blacklist":p(P.data||[]);break;case"stats":h(P.data||{}),P.data&&P.data.blacklist&&p(P.data.blacklist);break;case"trade_close":j();break}}catch{}},()=>F.close()},[]);const j=M.useCallback(async()=>{try{const $=await(await fetch("/api/trades")).json();k($.trades||[])}catch{}},[]);M.useEffect(()=>{j();const F=setInterval(j,1e4);return()=>clearInterval(F)},[j]);function _(F){if(!F||F.length===0)return;c(F),v(new Date().toLocaleTimeString("zh-CN",{hour12:!1}));const $=E.current;for(const P of F)for(const de of lc){const oe=P.coin+"."+de,N=P[de]||0;$[oe]?$[oe].last=N:$[oe]={last:N}}}function U(){const F=new Set,$=[];if(!a)return $;for(const P of a)F.has(P.coin)||(F.add(P.coin),$.push(P.coin));return $}function T(F,$){var P;return(P=E.current[F+"."+$])==null?void 0:P.last}function ne(F,$){return F==null||$==null?"":$>F?"text-green":$`${i}:${o}`).join(" "));let l="";return e.exchange_funds&&(l=Object.entries(e.exchange_funds).map(([i,o])=>`${i}: $${o.balance.toFixed(2)}`).join(" | ")),u.jsxs("section",{className:"card",id:"stats-card",children:[u.jsx("h2",{children:"📊 统计数据"}),u.jsxs("div",{className:"stats-row",children:[u.jsxs("div",{className:"stat",children:[u.jsx("label",{children:"总交易"}),u.jsx("span",{id:"stat-total",children:e.total_trades||0})]}),u.jsxs("div",{className:"stat",children:[u.jsx("label",{children:"收敛"}),u.jsx("span",{className:"pct-green",children:e.converged||0})]}),u.jsxs("div",{className:"stat",children:[u.jsx("label",{children:"发散"}),u.jsx("span",{className:"pct-red",children:e.diverged||0})]}),u.jsxs("div",{className:"stat",children:[u.jsx("label",{children:"持平"}),u.jsx("span",{className:"pct-gray",children:e.flat||0})]}),u.jsxs("div",{className:"stat",children:[u.jsx("label",{children:"持仓"}),u.jsxs("span",{className:"pct-yellow",children:[e.open_positions||0," / ",u.jsx("span",{children:"5"})]})]}),u.jsxs("div",{className:"stat",children:[u.jsx("label",{children:"币种"}),u.jsx("span",{className:"pct-blue",children:e.coins||0})]}),u.jsxs("div",{className:"stat",id:"conn-stats",children:[u.jsx("label",{children:"连接"}),u.jsx("span",{id:"conn-detail",style:{fontSize:11},children:r})]})]}),l&&u.jsx("div",{className:"stats-row",style:{marginTop:2,fontSize:11,opacity:.85},children:u.jsxs("div",{className:"stat",style:{gridColumn:"1 / -1"},children:[u.jsx("label",{children:"资金"}),u.jsx("span",{style:{fontWeight:600},children:l})]})}),t&&u.jsxs("div",{className:"stats-row detail-stats",style:{marginTop:4,fontSize:12,opacity:.85},children:[u.jsxs("div",{className:"stat",children:[u.jsx("label",{children:"总PnL"}),u.jsx("span",{children:(t.total_pnl_usd!=null?"$"+t.total_pnl_usd.toFixed(2):"—")+(t.capital_pnl!=null?" ("+t.capital_pnl.toFixed(4)+"%)":"")})]}),u.jsxs("div",{className:"stat",children:[u.jsx("label",{children:"本金"}),u.jsx("span",{children:n!=null?"$"+n.toFixed(0):"—"})]}),u.jsxs("div",{className:"stat",children:[u.jsx("label",{children:"胜率"}),u.jsx("span",{children:t.win_rate!=null?t.win_rate.toFixed(1)+"%":"—"})]}),u.jsxs("div",{className:"stat",children:[u.jsx("label",{children:"最多盈利"}),u.jsx("span",{className:"text-green",children:t.max_profit!=null?t.max_profit.toFixed(4)+"%":"—"})]}),u.jsxs("div",{className:"stat",children:[u.jsx("label",{children:"最多亏损"}),u.jsx("span",{className:"text-red",children:t.max_loss!=null?t.max_loss.toFixed(4)+"%":"—"})]}),u.jsxs("div",{className:"stat",children:[u.jsx("label",{children:"平均持仓"}),u.jsx("span",{children:t.avg_dur||"—"})]})]})]})}function If({positions:e}){const[t,n]=M.useState(!1),[r,l]=M.useState(null),[i,o]=M.useState([]);function s(c){c&&(n(!0),l(null),o([]),fetch("/api/trade/"+c).then(f=>f.json()).then(f=>{l(f.trade),o(f.orders||[])}).catch(()=>{l({ID:c})}))}function a(){n(!1)}return M.useEffect(()=>{if(!t)return;function c(f){f.key==="Escape"&&a()}return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t]),u.jsxs(u.Fragment,{children:[u.jsxs("section",{className:"card",id:"positions-card",children:[u.jsx("h2",{children:"🔒 当前持仓"}),u.jsx("div",{className:"table-wrap",children:u.jsxs("table",{id:"positions-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"币种"}),u.jsx("th",{children:"方向"}),u.jsx("th",{children:"规模"}),u.jsx("th",{children:"入价差"}),u.jsx("th",{children:"现价差"}),u.jsx("th",{children:"估盈亏"}),u.jsx("th",{children:"加仓"}),u.jsx("th",{children:"时长"})]})}),u.jsx("tbody",{id:"positions-body",children:e.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:"8",className:"loading",children:"无持仓"})}):[...e].sort((c,f)=>c.coin.localeCompare(f.coin)).map(c=>u.jsxs("tr",{className:"trade-row",onClick:()=>s(c.db_trade_id),children:[u.jsx("td",{children:u.jsx("strong",{children:c.coin})}),u.jsx("td",{children:c.direction}),u.jsxs("td",{className:"text-right",children:["$",(c.amount_usd||0).toFixed(0)]}),u.jsxs("td",{className:"text-right",children:[(c.entry_spread||0).toFixed(4),"%"]}),u.jsx("td",{className:"text-right",children:c.current_spread!=null?c.current_spread.toFixed(4)+"%":"-"}),u.jsx("td",{className:"text-right "+Vi(c.pnl_est),children:u.jsx("strong",{children:c.pnl_est!=null?"$"+c.pnl_est.toFixed(4):"-"})}),u.jsx("td",{className:"text-right",children:c.scales||0}),u.jsx("td",{children:c.duration||"-"})]},c.coin))})]})})]}),t&&u.jsx(ic,{trade:r,orders:i,onClose:a})]})}function Uf({blacklist:e}){return u.jsxs("section",{className:"card",id:"bl-card",children:[u.jsx("h2",{children:"⛔ 黑名单"}),u.jsx("div",{className:"stats-row",id:"bl-body",children:!e||e.length===0?u.jsx("span",{className:"text-dim",children:"暂无"}):e.map((t,n)=>{const r=t.remaining_sec||0,l=r>0?`${Math.floor(r/60)}m${r%60}s`:"";return u.jsxs("span",{className:"bl-item",title:`${t.coin}: ${l}`,children:["⛔ ",t.coin,l?` (${l})`:""]},n)})})]})}function Af({coins:e,prices:t,getPrevPrice:n,priceClass:r,pricesAge:l}){return u.jsxs("section",{className:"card",id:"prices-card",children:[u.jsxs("h2",{children:["💰 实时价格 ",u.jsx("span",{className:"text-dim",style:{fontSize:11},children:l})]}),u.jsx("div",{className:"table-wrap",children:u.jsxs("table",{id:"price-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"币种"}),u.jsx("th",{children:"HyperLiquid"}),u.jsx("th",{children:"Bitget"}),u.jsx("th",{children:"毛价差"}),u.jsx("th",{children:"BG→HL净利"}),u.jsx("th",{children:"HL→BG净利"})]})}),u.jsx("tbody",{id:"price-body",children:e.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:"6",className:"loading",children:"等待数据..."})}):e.map(i=>{const o=t.find(y=>y.coin===i);if(!o)return u.jsxs("tr",{children:[u.jsx("td",{children:i}),u.jsx("td",{className:"text-dim",children:"-"}),u.jsx("td",{className:"text-dim",children:"-"}),u.jsx("td",{className:"text-dim",children:"-"}),u.jsx("td",{className:"text-dim",children:"-"}),u.jsx("td",{className:"text-dim",children:"-"})]},i);const s=lc.map(y=>{const S=o[y],O=n(i,y),p=O?r(O,S||0):"";return u.jsx("td",{className:p,children:$i(S)},y)}),a=o.bg_hl_spread,c=a>.2?"text-green":a<-.2?"text-red":"",f=o.net_bg_to_hl,v=o.net_hl_to_bg,m=f!=null?Vi(f):"",w=v!=null?Vi(v):"";return u.jsxs("tr",{children:[u.jsx("td",{children:u.jsx("strong",{children:i})}),s,u.jsx("td",{className:c,children:a!=null?a.toFixed(4)+"%":"-"}),u.jsx("td",{className:m,children:f!=null?f.toFixed(2)+"%":"-"}),u.jsx("td",{className:w,children:v!=null?v.toFixed(2)+"%":"-"})]},i)})})]})})]})}function $f({opps:e}){return u.jsxs("section",{className:"card",id:"arb-card",children:[u.jsx("h2",{children:"🎯 套利机会 (BG↔HL)"}),u.jsx("div",{className:"table-wrap",children:u.jsxs("table",{id:"arb-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"币种"}),u.jsx("th",{children:"方向"}),u.jsx("th",{children:"买价"}),u.jsx("th",{children:"卖价"}),u.jsx("th",{children:"净利%"})]})}),u.jsx("tbody",{id:"arb-body",children:!e||e.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:"5",className:"text-dim",children:"暂无套利机会"})}):e.map((t,n)=>{const r=t.net_profit>.1?"text-green":t.net_profit>.05?"text-yellow":"";return u.jsxs("tr",{children:[u.jsx("td",{children:t.coin}),u.jsx("td",{children:t.direction}),u.jsx("td",{className:"text-right",children:$i(t.buy_price)}),u.jsx("td",{className:"text-right",children:$i(t.sell_price)}),u.jsx("td",{className:"text-right "+r,children:u.jsx("strong",{children:(t.net_profit||0).toFixed(4)})})]},n)})})]})})]})}function Vf({trades:e,onRefresh:t}){const[n,r]=M.useState(null),[l,i]=M.useState([]),[o,s]=M.useState(!1);function a(f){s(!0),r(null),i([]),fetch("/api/trade/"+f).then(v=>v.json()).then(v=>{r(v.trade),i(v.orders||[])}).catch(()=>{r({ID:f})})}function c(){s(!1)}return M.useEffect(()=>{if(!o)return;function f(v){v.key==="Escape"&&c()}return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[o]),u.jsxs(u.Fragment,{children:[u.jsxs("section",{className:"card card-wide",id:"trades-card",children:[u.jsx("h2",{children:"📋 历史交易"}),u.jsx("div",{className:"table-wrap",children:u.jsxs("table",{id:"trades-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"时间"}),u.jsx("th",{children:"币种"}),u.jsx("th",{children:"方向"}),u.jsx("th",{children:"入价差"}),u.jsx("th",{children:"出价差"}),u.jsx("th",{children:"净利%"}),u.jsx("th",{children:"实盈亏"}),u.jsx("th",{children:"结果"}),u.jsx("th",{children:"原因"})]})}),u.jsx("tbody",{id:"trades-body",children:e.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:"9",className:"text-dim",children:"暂无交易记录"})}):e.slice(0,20).map(f=>{const v=f.NetPnl>0?"text-green":f.NetPnl<0?"text-red":"",m=f.Convergence==="价差收敛"?"text-green":f.Convergence==="价差发散"?"text-red":"text-yellow",w=f.NetPnl!=null&&f.AmountUSD!=null?2*f.AmountUSD*f.NetPnl/100:null;return u.jsxs("tr",{className:"trade-row",onClick:()=>a(f.ID),children:[u.jsx("td",{className:"text-dim",children:f.ClosedAt?new Date(f.ClosedAt).toLocaleTimeString("zh-CN",{hour12:!1}):"-"}),u.jsx("td",{children:u.jsx("strong",{children:f.Coin})}),u.jsx("td",{children:f.Direction}),u.jsx("td",{className:"text-right",children:f.EntrySpread!=null?f.EntrySpread.toFixed(4):"-"}),u.jsx("td",{className:"text-right",children:f.ExitSpread!=null?f.ExitSpread.toFixed(4):"-"}),u.jsx("td",{className:"text-right "+v,children:u.jsx("strong",{children:f.NetPnl!=null?f.NetPnl.toFixed(4)+"%":"-"})}),u.jsx("td",{className:"text-right "+v,children:w!=null?"$"+w.toFixed(2):"-"}),u.jsx("td",{className:m,children:f.Convergence||"-"}),u.jsx("td",{children:f.ExitReason||"-"})]},f.ID)})})]})})]}),o&&u.jsx(ic,{trade:n,orders:l,onClose:c})]})}function ic({trade:e,orders:t,onClose:n}){function r(m){m.target===m.currentTarget&&n()}if(!e)return u.jsx("div",{className:"modal-overlay",onClick:r,children:u.jsxs("div",{className:"modal-content",children:[u.jsxs("div",{className:"modal-header",children:[u.jsx("h2",{children:"📋 交易详情"}),u.jsx("button",{className:"modal-close",onClick:n,children:"✕"})]}),u.jsx("div",{id:"trade-detail-body",children:u.jsx("div",{className:"loading",children:"加载中..."})})]})});const l=new Date(e.OpenedAt),i=e.ClosedAt?new Date(e.ClosedAt):null,o=i?Math.round((i-l)/1e3)+"s":"-",s=e.NetPnl>0?"text-green":e.NetPnl<0?"text-red":"",a=[...t||[]].sort((m,w)=>{const y=(m.Exchange||"").localeCompare(w.Exchange||"");return y!==0?y:new Date(m.CreatedAt)-new Date(w.CreatedAt)}),c=e.AmountUSD&&e.LongPnl!=null?e.AmountUSD*e.LongPnl/100:null,f=e.AmountUSD&&e.ShortPnl!=null?e.AmountUSD*e.ShortPnl/100:null,v=e.AmountUSD&&e.NetPnl!=null?2*e.AmountUSD*e.NetPnl/100:null;return u.jsx("div",{className:"modal-overlay",onClick:r,children:u.jsxs("div",{className:"modal-content",children:[u.jsxs("div",{className:"modal-header",children:[u.jsx("h2",{children:"📋 交易详情"}),u.jsx("button",{className:"modal-close",onClick:n,children:"✕"})]}),u.jsxs("div",{id:"trade-detail-body",children:[u.jsxs("div",{className:"detail-grid",children:[u.jsxs("div",{className:"detail-section",children:[u.jsx("h3",{children:"概览"}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"币种"}),u.jsxs("span",{className:"value",children:[u.jsx("strong",{children:e.Coin}),"/USDT"]})]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"方向"}),u.jsx("span",{className:"value",children:e.Direction||"-"})]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"状态"}),u.jsx("span",{className:"value",children:e.Status==="closed"?"已平仓":e.Status})]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"加仓次数"}),u.jsxs("span",{className:"value",children:[e.ScaleCount||0," 次"]})]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"总规模"}),u.jsxs("span",{className:"value",children:["$",(e.AmountUSD||0).toFixed(0)]})]})]}),u.jsxs("div",{className:"detail-section",children:[u.jsx("h3",{children:"时间"}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"开仓"}),u.jsx("span",{className:"value",children:l.toLocaleString("zh-CN",{hour12:!1})})]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"平仓"}),u.jsx("span",{className:"value",children:i?i.toLocaleString("zh-CN",{hour12:!1}):"-"})]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"持仓时长"}),u.jsx("span",{className:"value",children:o})]})]}),u.jsxs("div",{className:"detail-section",children:[u.jsx("h3",{children:"价差"}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"入场价差"}),u.jsx("span",{className:"value",children:e.EntrySpread!=null?e.EntrySpread.toFixed(4)+"%":"-"})]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"出场价差"}),u.jsx("span",{className:"value",children:e.ExitSpread!=null?e.ExitSpread.toFixed(4)+"%":"-"})]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"收敛情况"}),u.jsx("span",{className:"value "+(e.Convergence==="价差收敛"?"text-green":e.Convergence==="价差发散"?"text-red":""),children:e.Convergence||"-"})]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"平仓原因"}),u.jsx("span",{className:"value",children:e.ExitReason||"-"})]})]}),u.jsxs("div",{className:"detail-section",children:[u.jsx("h3",{children:"手续费"}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"开仓费"}),u.jsxs("span",{className:"value",children:["$",(e.FeeEntry||0).toFixed(4)]})]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"平仓费"}),u.jsxs("span",{className:"value",children:["$",(e.FeeExit||0).toFixed(4)]})]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"总手续费"}),u.jsxs("span",{className:"value",children:["$",((e.FeeEntry||0)+(e.FeeExit||0)).toFixed(4)]})]})]}),u.jsxs("div",{className:"detail-section",children:[u.jsxs("h3",{children:["多仓 ",e.LongExchange||"-"]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"入场价"}),u.jsxs("span",{className:"value",children:["$",(e.LongEntry||0).toFixed(6)]})]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"出场价"}),u.jsxs("span",{className:"value",children:["$",(e.LongExit||0).toFixed(6)]})]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"盈亏"}),u.jsxs("span",{className:"value "+(e.LongPnl>0?"text-green":e.LongPnl<0?"text-red":""),children:[e.LongPnl!=null?e.LongPnl.toFixed(4)+"%":"-"," ",c!=null?u.jsxs("span",{style:{fontSize:11,opacity:.8},children:["($",c.toFixed(4),")"]}):null]})]})]}),u.jsxs("div",{className:"detail-section",children:[u.jsxs("h3",{children:["空仓 ",e.ShortExchange||"-"]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"入场价"}),u.jsxs("span",{className:"value",children:["$",(e.ShortEntry||0).toFixed(6)]})]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"出场价"}),u.jsxs("span",{className:"value",children:["$",(e.ShortExit||0).toFixed(6)]})]}),u.jsxs("div",{className:"detail-row",children:[u.jsx("span",{className:"label",children:"盈亏"}),u.jsxs("span",{className:"value "+(e.ShortPnl>0?"text-green":e.ShortPnl<0?"text-red":""),children:[e.ShortPnl!=null?e.ShortPnl.toFixed(4)+"%":"-"," ",f!=null?u.jsxs("span",{style:{fontSize:11,opacity:.8},children:["($",f.toFixed(4),")"]}):null]})]})]}),u.jsxs("div",{className:"detail-section detail-section-full",children:[u.jsx("h3",{children:"净收益"}),u.jsxs("div",{className:"detail-row",style:{fontSize:16},children:[u.jsx("span",{className:"label",children:"总计"}),u.jsxs("span",{className:"value "+s,style:{fontWeight:700},children:[e.NetPnl!=null?e.NetPnl.toFixed(4)+"%":"-"," ",v!=null?u.jsxs("span",{style:{fontSize:12,opacity:.8},children:["($",v.toFixed(4),")"]}):null]})]})]})]}),t.length>0&&u.jsxs("div",{className:"detail-section detail-section-full",style:{borderTop:"1px solid var(--border)"},children:[u.jsxs("h3",{children:["订单明细 (",t.length,")"]}),u.jsxs("table",{className:"detail-orders",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"交易所"}),u.jsx("th",{children:"类型"}),u.jsx("th",{children:"方向"}),u.jsx("th",{children:"价格"}),u.jsx("th",{children:"仓位"}),u.jsx("th",{children:"手续费"}),u.jsx("th",{children:"订单ID"})]})}),u.jsx("tbody",{children:a.map((m,w)=>u.jsxs("tr",{children:[u.jsx("td",{children:m.Exchange}),u.jsx("td",{children:m.Type==="entry"?"开仓":m.Type==="exit"?"平仓":m.Type==="scale"?"加仓":m.Type}),u.jsx("td",{children:m.Side==="buy"?"买":"卖"}),u.jsxs("td",{children:["$",(m.Price||0).toFixed(6)]}),u.jsx("td",{className:"text-right",children:m.Size!=null?Number(m.Size).toFixed(4):"-"}),u.jsx("td",{children:m.Fee!=null?"$"+m.Fee.toFixed(4):"-"}),u.jsx("td",{children:m.OrderID?m.OrderID.substring(0,12)+"...":"-"})]},w))})]})]})]})]})})}function Bf(){const e=M.useRef(null),[t,n]=M.useState([]),[r,l]=M.useState(0);return M.useEffect(()=>{async function i(){try{const c=((await(await fetch("/api/trades?limit=1000")).json()).trades||[]).filter(v=>v.ClosedAt&&v.NetPnl!=null).sort((v,m)=>new Date(v.ClosedAt)-new Date(m.ClosedAt));n(c);const f=c.reduce((v,m)=>v+2*(m.AmountUSD||0)*(m.NetPnl||0)/100,0);l(f)}catch{}}i();const o=setInterval(i,1e4);return()=>clearInterval(o)},[]),M.useEffect(()=>{const i=e.current;if(!i||t.length<2)return;const o=i.parentElement.getBoundingClientRect(),s=window.devicePixelRatio||1,a=o.width,c=o.height;i.width=a*s,i.height=c*s,i.style.width=a+"px",i.style.height=c+"px";const f=i.getContext("2d");f.scale(s,s);const v={top:20,right:20,bottom:35,left:55},m=a-v.left-v.right,w=c-v.top-v.bottom,y=[];let S=0;if(t.length>0){const P=new Date(t[0].ClosedAt).getTime()-1e3;y.push({x:P,y:0})}for(const P of t)S+=2*(P.AmountUSD||0)*(P.NetPnl||0)/100,y.push({x:new Date(P.ClosedAt).getTime(),y:S});const O=y[0].x,p=y[y.length-1].x,d=y.map(P=>P.y),h=Math.min(0,...d),g=Math.max(0,...d),k=Math.max(g-h,.01),E=k*.15,j=P=>v.left+(P-O)/Math.max(p-O,1)*m,_=P=>v.top+w-(P-(h-E))/(k+2*E)*w;f.clearRect(0,0,a,c),f.strokeStyle="rgba(48,54,61,0.5)",f.lineWidth=1,f.font="11px sans-serif",f.fillStyle="#8b949e";const U=5;for(let P=0;P<=U;P++){const de=h-E+(k+2*E)*P/U,oe=_(de);f.beginPath(),f.moveTo(v.left,oe),f.lineTo(a-v.right,oe),f.stroke(),f.fillText("$"+de.toFixed(2),2,oe+4)}if(h<0&&g>0){const P=_(0);f.strokeStyle="rgba(248,81,73,0.3)",f.lineWidth=1,f.setLineDash([4,4]),f.beginPath(),f.moveTo(v.left,P),f.lineTo(a-v.right,P),f.stroke(),f.setLineDash([])}const T=Math.min(6,y.length);for(let P=0;P=0?"#3fb950":"#f85149",f.fill(),f.strokeStyle="#0d1117",f.lineWidth=2,f.stroke(),f.fillStyle="#c9d1d9",f.font="bold 13px sans-serif",f.textAlign="center",f.fillText("$"+_e.y.toFixed(2),F,$-12)},[t]),u.jsxs("section",{className:"card card-wide",id:"pnl-chart-card",children:[u.jsxs("h2",{children:["📈 总PnL成长曲线 ",u.jsx("span",{className:"text-dim",style:{fontSize:11},children:t.length>0?`$${r.toFixed(2)}`:""})]}),u.jsx("div",{className:"chart-container",style:{height:260},children:t.length<1?u.jsx("div",{className:"loading",style:{paddingTop:100},children:"暂无数据..."}):u.jsx("canvas",{ref:e})})]})}Yl.createRoot(document.getElementById("root")).render(u.jsx(kc.StrictMode,{children:u.jsx(Of,{})}));
diff --git a/frontend/dist/assets/main-Cg5_dPUr.js b/frontend/dist/assets/main-Cg5_dPUr.js
new file mode 100644
index 0000000..5fa0904
--- /dev/null
+++ b/frontend/dist/assets/main-Cg5_dPUr.js
@@ -0,0 +1 @@
+import{r as o,j as e,c as U,R as V}from"./client-DYDkQYN6.js";const L=["Bitget","Binance","OKX"];function f(r){return r==null||r<=0?"-":r>=100?r.toFixed(2):r>=1?r.toFixed(4):r.toFixed(6)}function Y(){const[r,h]=o.useState("--:--:--"),[l,n]=o.useState("● 未连接"),[d,t]=o.useState(!1),[a,p]=o.useState({}),[b,s]=o.useState([]),[g,i]=o.useState(""),[_,m]=o.useState([]),[u,T]=o.useState([]),[ce,W]=o.useState([]),[H,K]=o.useState([]),[X,G]=o.useState([]),[I,D]=o.useState([]),[w,B]=o.useState([]),[q,M]=o.useState([]),[P,A]=o.useState([]),E=o.useRef({});o.useEffect(()=>{const c=()=>h(new Date().toLocaleTimeString("zh-CN",{hour12:!1}));c();const x=setInterval(c,1e3);return()=>clearInterval(x)},[]),o.useEffect(()=>{let c=new EventSource("/events");return c.addEventListener("connected",()=>{n("● 已连接"),t(!0)}),c.onerror=()=>{n("● 已断开 (重连中...)"),t(!1),setTimeout(()=>{c=new EventSource("/events")},3e3)},c.onmessage=x=>{try{const j=JSON.parse(x.data);switch(j.event){case"prices":R(j.data);break;case"spread_3ex":m(j.data||[]);break;case"momentum":T(j.data||[]);break;case"trend":W(j.data||[]);break;case"cumulative":K(j.data||[]);break;case"trend_filter":D(j.data||[]);break;case"trend_signal":B(N=>[j.data,...N].slice(0,100));break;case"surge":M(j.data||[]);break;case"surge_event":A(N=>[j.data,...N].slice(0,200));break;case"status":j.data&&j.data.connections&&p(j.data.connections);break}}catch{}},()=>c.close()},[]);const k=o.useCallback(async()=>{try{const x=await(await fetch("/api/cm-history")).json();G(x.events||[])}catch{}},[]);o.useEffect(()=>{k();const c=setInterval(k,5e3);return()=>clearInterval(c)},[k]);const S=o.useCallback(async()=>{try{const x=await(await fetch("/api/trend-signals")).json();x.signals&&B(x.signals)}catch{}},[]);o.useEffect(()=>{S();const c=setInterval(S,5e3);return()=>clearInterval(c)},[S]);const C=o.useCallback(async()=>{try{const x=await(await fetch("/api/surge-events?limit=100")).json();x.events&&A(x.events)}catch{}},[]);o.useEffect(()=>{C();const c=setInterval(C,1e4);return()=>clearInterval(c)},[C]);function R(c){if(!c||c.length===0)return;s(c),i(new Date().toLocaleTimeString("zh-CN",{hour12:!1}));const x=E.current;for(const j of c)for(const N of L){const F=j.coin+"."+N,O=j[N]||0;x[F]?x[F].last=O:x[F]={last:O}}}function $(){const c=new Set,x=[];if(!b)return x;for(const j of b)c.has(j.coin)||(c.add(j.coin),x.push(j.coin));return x}function v(c,x){var j;return(j=E.current[c+"."+x])==null?void 0:j.last}function J(c,x){return c==null||x==null?"":x>c?"text-green":x`${c}:${x}`).join(" ");return e.jsxs("div",{id:"app",children:[e.jsxs("header",{children:[e.jsx("h1",{children:"⚡ 三所价差异动监控"}),e.jsxs("div",{className:"header-meta",children:[e.jsx("span",{children:r}),e.jsx("span",{className:"sep",children:"|"}),e.jsx("span",{className:d?"status-online":"status-offline",children:l}),z&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sep",children:"|"}),e.jsx("span",{style:{fontSize:11},children:z})]})]})]}),e.jsxs("div",{className:"grid",children:[e.jsx(ie,{filterData:I}),e.jsx(re,{signals:w}),e.jsx(le,{signals:w}),e.jsx(se,{data:H}),e.jsx(ne,{history:X}),e.jsx(Z,{coins:Q,prices:b,getPrevPrice:v,priceClass:J,pricesAge:g}),e.jsx(y,{data:_}),e.jsx(ee,{snapshots:q,events:P}),e.jsx(te,{momentum:u})]})]})}function Z({coins:r,prices:h,getPrevPrice:l,priceClass:n,pricesAge:d}){return e.jsxs("section",{className:"card",id:"prices-card",children:[e.jsxs("h2",{children:["💰 实时价格 ",e.jsx("span",{className:"text-dim",style:{fontSize:11},children:d})]}),e.jsx("div",{className:"table-wrap",children:e.jsxs("table",{id:"price-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"币种"}),e.jsx("th",{children:"Bitget"}),e.jsx("th",{children:"Binance"}),e.jsx("th",{children:"OKX"}),e.jsx("th",{children:"三所价差"})]})}),e.jsx("tbody",{id:"price-body",children:r.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:"5",className:"loading",children:"等待数据..."})}):r.map(t=>{const a=h.find(g=>g.coin===t);if(!a)return e.jsxs("tr",{children:[e.jsx("td",{children:t}),e.jsx("td",{className:"text-dim",children:"-"}),e.jsx("td",{className:"text-dim",children:"-"}),e.jsx("td",{className:"text-dim",children:"-"}),e.jsx("td",{className:"text-dim",children:"-"})]},t);const p=L.map(g=>{const i=a[g],_=l(t,g),m=_?n(_,i||0):"";return e.jsx("td",{className:m,children:f(i)},g)}),b=a.spread_3ex,s=b>.3?"text-green":b>.1?"text-yellow":"text-dim";return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("strong",{children:t})}),p,e.jsx("td",{className:s,children:b!=null?b.toFixed(4)+"%":"-"})]},t)})})]})})]})}function y({data:r}){function h(l){return l==null?"":l>.3?"text-green":l>.1?"text-yellow":"text-dim"}return e.jsxs("section",{className:"card",id:"spread-card",children:[e.jsx("h2",{children:"📊 三所价差扫描 (BN/OKX/BG)"}),e.jsx("div",{className:"table-wrap",children:e.jsxs("table",{id:"spread-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"币种"}),e.jsx("th",{children:"价差%"}),e.jsx("th",{children:"BN价格"}),e.jsx("th",{children:"OKX价格"}),e.jsx("th",{children:"BG价格"}),e.jsx("th",{children:"最高所"}),e.jsx("th",{children:"最低所"})]})}),e.jsx("tbody",{children:!r||r.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:"7",className:"text-dim",children:"等待扫描数据..."})}):r.slice(0,50).map((l,n)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("strong",{children:l.coin})}),e.jsx("td",{className:"text-right "+h(l.spread_pct),children:e.jsx("strong",{children:l.spread_pct!=null?l.spread_pct.toFixed(4)+"%":"-"})}),e.jsx("td",{className:"text-right",children:l.bn_price?f(l.bn_price):"-"}),e.jsx("td",{className:"text-right",children:l.okx_price?f(l.okx_price):"-"}),e.jsx("td",{className:"text-right",children:l.bg_price?f(l.bg_price):"-"}),e.jsx("td",{children:l.max_ex||"-"}),e.jsx("td",{children:l.min_ex||"-"})]},l.coin||n))})]})})]})}function ee({snapshots:r,events:h}){const[l,n]=o.useState("snapshot");function d(t,a){return t==null||a==null?"":t>=a?"text-green":"text-dim"}return e.jsxs("section",{className:"card card-wide",id:"surge-card",children:[e.jsxs("h2",{children:["🚀 Surge异动检测",e.jsxs("span",{style:{marginLeft:12,fontSize:12,fontWeight:400},children:[e.jsx("button",{className:"tab-btn"+(l==="snapshot"?" active":""),onClick:()=>n("snapshot"),children:"实时基线"}),e.jsxs("button",{className:"tab-btn"+(l==="events"?" active":""),onClick:()=>n("events"),children:["事件记录 (",h.length,")"]})]})]}),l==="snapshot"&&e.jsx("div",{className:"table-wrap",style:{maxHeight:350},children:e.jsxs("table",{id:"surge-snapshot-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"币种"}),e.jsx("th",{children:"当前价差%"}),e.jsx("th",{children:"基线%"}),e.jsx("th",{children:"阈值%"}),e.jsx("th",{children:"窗口样本"})]})}),e.jsx("tbody",{children:r.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:"5",className:"text-dim",style:{textAlign:"center",padding:20},children:"收集基线数据中... (需要至少 10 个样本)"})}):r.slice(0,50).map((t,a)=>{const p=t.direction;return e.jsxs("tr",{className:p?"surge-active":"",children:[e.jsx("td",{children:e.jsx("strong",{children:t.coin})}),e.jsxs("td",{className:"text-right "+d(t.spread_pct,t.threshold_pct),style:{fontWeight:700},children:[t.spread_pct!=null?t.spread_pct.toFixed(4)+"%":"-",p?" ⚡":""]}),e.jsx("td",{className:"text-right text-dim",children:t.baseline_pct!=null?t.baseline_pct.toFixed(4)+"%":"-"}),e.jsx("td",{className:"text-right text-dim",children:t.threshold_pct!=null?t.threshold_pct.toFixed(4)+"%":"-"}),e.jsx("td",{className:"text-right text-dim",children:t.window_size||0})]},t.coin||a)})})]})}),l==="events"&&e.jsx("div",{className:"table-wrap",style:{maxHeight:400},children:e.jsxs("table",{id:"surge-events-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"时间"}),e.jsx("th",{children:"币种"}),e.jsx("th",{children:"方向"}),e.jsx("th",{children:"价差%"}),e.jsx("th",{children:"基线%"}),e.jsx("th",{children:"阈值%"}),e.jsx("th",{children:"比率"}),e.jsx("th",{children:"BN价格"}),e.jsx("th",{children:"OKX价格"}),e.jsx("th",{children:"BG价格"}),e.jsx("th",{children:"领先所"})]})}),e.jsx("tbody",{children:h.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:"11",className:"text-dim",style:{textAlign:"center",padding:20},children:"暂无Surge事件记录"})}):h.slice(0,100).map((t,a)=>{const p=t.timestamp?new Date(t.timestamp).toLocaleTimeString("zh-CN",{hour12:!1}):"-";return e.jsxs("tr",{className:t.direction==="up"?"surge-up":"surge-down",children:[e.jsx("td",{className:"text-dim",children:p}),e.jsx("td",{children:e.jsx("strong",{children:t.coin})}),e.jsx("td",{className:t.direction==="up"?"text-green":"text-red",style:{fontWeight:600,textAlign:"center"},children:t.direction==="up"?"↑ 涨":"↓ 跌"}),e.jsx("td",{className:"text-right",style:{fontWeight:700},children:t.spread_pct!=null?t.spread_pct.toFixed(4)+"%":"-"}),e.jsx("td",{className:"text-right text-dim",children:t.baseline_pct!=null?t.baseline_pct.toFixed(4)+"%":"-"}),e.jsx("td",{className:"text-right text-dim",children:t.threshold_pct!=null?t.threshold_pct.toFixed(4)+"%":"-"}),e.jsx("td",{className:"text-right",children:t.ratio!=null?t.ratio.toFixed(1)+"x":"-"}),e.jsx("td",{className:"text-right",children:t.bn_price?f(t.bn_price):"-"}),e.jsx("td",{className:"text-right",children:t.okx_price?f(t.okx_price):"-"}),e.jsx("td",{className:"text-right",children:t.bg_price?f(t.bg_price):"-"}),e.jsx("td",{children:t.leading_exchange||"-"})]},t.timestamp+"-"+t.coin+"-"+a)})})]})})]})}function te({momentum:r}){const[h,l]=o.useState("score"),[n,d]=o.useState("desc");function t(i){h===i?d(n==="asc"?"desc":"asc"):(l(i),d("desc"))}function a(i){return h!==i?"":n==="asc"?" ▲":" ▼"}const p=[...r].sort((i,_)=>{let m,u;switch(h){case"coin":m=i.coin,u=_.coin;break;case"bg_1s":m=i.bg_1s||0,u=_.bg_1s||0;break;case"bg_5s":m=i.bg_5s||0,u=_.bg_5s||0;break;case"bg_15s":m=i.bg_15s||0,u=_.bg_15s||0;break;case"bn_1s":m=i.bn_1s||0,u=_.bn_1s||0;break;case"bn_5s":m=i.bn_5s||0,u=_.bn_5s||0;break;case"bn_15s":m=i.bn_15s||0,u=_.bn_15s||0;break;case"okx_1s":m=i.okx_1s||0,u=_.okx_1s||0;break;case"okx_5s":m=i.okx_5s||0,u=_.okx_5s||0;break;case"okx_15s":m=i.okx_15s||0,u=_.okx_15s||0;break;default:m=i.score||0,u=_.score||0}return typeof m=="string"?n==="asc"?m.localeCompare(u):u.localeCompare(m):n==="asc"?m-u:u-m});function b(i){switch(i){case"up":return"↑";case"down":return"↓";case"flat":return"→";case"mixed":return"↕";default:return"-"}}function s(i){switch(i){case"up":return"text-green";case"down":return"text-red";case"mixed":return"text-yellow";default:return""}}function g(i){return i==null||i===0?"":i>0?"text-green":"text-red"}return e.jsxs("section",{className:"card card-wide",id:"momentum-card",children:[e.jsx("h2",{children:"⚡ 动量扫描 (价格变动%)"}),e.jsx("div",{className:"table-wrap",style:{maxHeight:400},children:e.jsxs("table",{id:"momentum-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsxs("th",{onClick:()=>t("coin"),style:{cursor:"pointer"},children:["币种",a("coin")]}),e.jsxs("th",{onClick:()=>t("score"),style:{cursor:"pointer"},children:["分数",a("score")]}),e.jsx("th",{children:"方向"}),e.jsxs("th",{onClick:()=>t("bg_1s"),style:{cursor:"pointer"},children:["BG 1s",a("bg_1s")]}),e.jsxs("th",{onClick:()=>t("bg_5s"),style:{cursor:"pointer"},children:["BG 5s",a("bg_5s")]}),e.jsxs("th",{onClick:()=>t("bg_15s"),style:{cursor:"pointer"},children:["BG 15s",a("bg_15s")]}),e.jsxs("th",{onClick:()=>t("bn_1s"),style:{cursor:"pointer"},children:["BN 1s",a("bn_1s")]}),e.jsxs("th",{onClick:()=>t("bn_5s"),style:{cursor:"pointer"},children:["BN 5s",a("bn_5s")]}),e.jsxs("th",{onClick:()=>t("bn_15s"),style:{cursor:"pointer"},children:["BN 15s",a("bn_15s")]}),e.jsxs("th",{onClick:()=>t("okx_1s"),style:{cursor:"pointer"},children:["OKX 1s",a("okx_1s")]}),e.jsxs("th",{onClick:()=>t("okx_5s"),style:{cursor:"pointer"},children:["OKX 5s",a("okx_5s")]}),e.jsxs("th",{onClick:()=>t("okx_15s"),style:{cursor:"pointer"},children:["OKX 15s",a("okx_15s")]})]})}),e.jsx("tbody",{children:p.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:"12",className:"text-dim",style:{textAlign:"center",padding:20},children:"正在收集动量数据... (需要至少 15 秒数据)"})}):p.slice(0,50).map(i=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("strong",{children:i.coin})}),e.jsxs("td",{className:"text-right",style:{fontWeight:700},children:[i.score.toFixed(4),"%"]}),e.jsx("td",{className:s(i.direction),style:{textAlign:"center",fontSize:18},children:b(i.direction)}),e.jsx("td",{className:"text-right "+g(i.bg_1s),children:i.bg_1s!=null?i.bg_1s.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+g(i.bg_5s),children:i.bg_5s!=null?i.bg_5s.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+g(i.bg_15s),children:i.bg_15s!=null?i.bg_15s.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+g(i.bn_1s),children:i.bn_1s!=null?i.bn_1s.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+g(i.bn_5s),children:i.bn_5s!=null?i.bn_5s.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+g(i.bn_15s),children:i.bn_15s!=null?i.bn_15s.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+g(i.okx_1s),children:i.okx_1s!=null?i.okx_1s.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+g(i.okx_5s),children:i.okx_5s!=null?i.okx_5s.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+g(i.okx_15s),children:i.okx_15s!=null?i.okx_15s.toFixed(3)+"%":"-"})]},i.coin))})]})})]})}function se({data:r}){function h(t){switch(t){case"rising":return"↑ 上涨";case"falling":return"↓ 下跌";default:return"− 中性"}}function l(t){switch(t){case"rising":return"text-green";case"falling":return"text-red";default:return"text-dim"}}function n(t){return t==="up"?"text-green":"text-red"}function d(t){return t==null||t===0?"":t>0?"text-green":"text-red"}return e.jsxs("section",{className:"card card-wide",id:"cm-card",children:[e.jsx("h2",{children:"📊 累积变动 (1min 共识)"}),e.jsx("div",{className:"table-wrap",style:{maxHeight:300},children:e.jsxs("table",{id:"cm-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"币种"}),e.jsx("th",{children:"状态"}),e.jsx("th",{children:"方向"}),e.jsx("th",{children:"分数"}),e.jsx("th",{children:"均值%"}),e.jsx("th",{children:"一致"}),e.jsx("th",{children:"BG 1m"}),e.jsx("th",{children:"BN 1m"}),e.jsx("th",{children:"OKX 1m"}),e.jsx("th",{children:"BG 5m"}),e.jsx("th",{children:"BN 5m"}),e.jsx("th",{children:"OKX 5m"}),e.jsx("th",{colSpan:3,style:{borderLeft:"2px solid var(--border)"},children:"1h 趋势"}),e.jsx("th",{children:"BG 1h"}),e.jsx("th",{children:"BN 1h"}),e.jsx("th",{children:"OKX 1h"})]})}),e.jsx("tbody",{children:!r||r.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:"17",className:"text-dim",style:{textAlign:"center",padding:20},children:"等待累积数据... (需要至少 1 分钟数据)"})}):r.slice(0,30).map(t=>e.jsxs("tr",{className:l(t.state),children:[e.jsx("td",{children:e.jsx("strong",{children:t.coin})}),e.jsx("td",{children:h(t.state)}),e.jsx("td",{className:n(t.direction),style:{textAlign:"center",fontSize:16},children:t.direction==="up"?"↑":"↓"}),e.jsx("td",{className:"text-right",style:{fontWeight:700},children:(t.score||0).toFixed(2)}),e.jsxs("td",{className:"text-right",children:[(t.avg_1m||0).toFixed(3),"%"]}),e.jsxs("td",{className:"text-right",children:[t.ex_agree||0,"/",t.ex_total||0]}),e.jsx("td",{className:"text-right "+d(t.bg_1m),children:t.bg_1m!=null?t.bg_1m.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+d(t.bn_1m),children:t.bn_1m!=null?t.bn_1m.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+d(t.okx_1m),children:t.okx_1m!=null?t.okx_1m.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+d(t.bg_5m),children:t.bg_5m!=null?t.bg_5m.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+d(t.bn_5m),children:t.bn_5m!=null?t.bn_5m.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+d(t.okx_5m),children:t.okx_5m!=null?t.okx_5m.toFixed(3)+"%":"-"}),e.jsxs("td",{className:"text-right "+n(t.direction),style:{fontWeight:600,borderLeft:"2px solid var(--border)"},children:[(t.avg_1h||0).toFixed(2),"%"]}),e.jsx("td",{className:"text-right "+d(t.bg_1h),children:t.bg_1h!=null?t.bg_1h.toFixed(2)+"%":"-"}),e.jsx("td",{className:"text-right "+d(t.bn_1h),children:t.bn_1h!=null?t.bn_1h.toFixed(2)+"%":"-"}),e.jsx("td",{className:"text-right "+d(t.okx_1h),children:t.okx_1h!=null?t.okx_1h.toFixed(2)+"%":"-"})]},t.coin))})]})})]})}function ne({history:r}){function h(t){switch(t){case"rising":return"↑ 上涨";case"falling":return"↓ 下跌";default:return"− 中性"}}function l(t){switch(t){case"rising":return"text-green";case"falling":return"text-red";default:return"text-dim"}}function n(t){return t==="up"?"text-green":"text-red"}function d(t){return t==null||t===0?"":t>0?"text-green":"text-red"}return e.jsxs("section",{className:"card card-wide",id:"cm-history-card",children:[e.jsx("h2",{children:"📋 累积变动事件记录"}),e.jsx("div",{className:"table-wrap",style:{maxHeight:400},children:e.jsxs("table",{id:"cm-history-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"时间"}),e.jsx("th",{children:"币种"}),e.jsx("th",{children:"转换"}),e.jsx("th",{children:"方向"}),e.jsx("th",{children:"分数"}),e.jsx("th",{children:"均值%"}),e.jsx("th",{children:"一致"}),e.jsx("th",{children:"BG 1m"}),e.jsx("th",{children:"BN 1m"}),e.jsx("th",{children:"OKX 1m"}),e.jsx("th",{children:"BG 5m"}),e.jsx("th",{children:"BN 5m"}),e.jsx("th",{children:"OKX 5m"})]})}),e.jsx("tbody",{children:r.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:"13",className:"text-dim",style:{textAlign:"center",padding:20},children:"暂无累积变动事件记录"})}):r.slice(0,100).map((t,a)=>e.jsxs("tr",{children:[e.jsx("td",{className:"text-dim",children:t.created_at?new Date(t.created_at).toLocaleTimeString("zh-CN",{hour12:!1}):"-"}),e.jsx("td",{children:e.jsx("strong",{children:t.coin})}),e.jsxs("td",{className:l(t.new_state),children:[t.prev_state," → ",h(t.new_state)]}),e.jsx("td",{className:n(t.direction),style:{textAlign:"center",fontSize:16},children:t.direction==="up"?"↑":"↓"}),e.jsx("td",{className:"text-right",children:(t.score||0).toFixed(2)}),e.jsxs("td",{className:"text-right",children:[(t.avg_change||0).toFixed(3),"%"]}),e.jsxs("td",{className:"text-right",children:[t.ex_agree||0,"/",t.ex_total||0]}),e.jsx("td",{className:"text-right "+d(t.bg_1m),children:t.bg_1m!=null?t.bg_1m.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+d(t.bn_1m),children:t.bn_1m!=null?t.bn_1m.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+d(t.okx_1m),children:t.okx_1m!=null?t.okx_1m.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+d(t.bg_5m),children:t.bg_5m!=null?t.bg_5m.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+d(t.bn_5m),children:t.bn_5m!=null?t.bn_5m.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right "+d(t.okx_5m),children:t.okx_5m!=null?t.okx_5m.toFixed(3)+"%":"-"})]},(t.id||a)+"-cm"))})]})})]})}function ie({filterData:r}){const h=r.filter(s=>s.passes_filter).length,l=r.filter(s=>s.signal_score>=80).length,n=r.filter(s=>s.signal_score>=50&&s.signal_score<80).length,d=r.filter(s=>s.fresh_anomaly).length;let t=`高分${l} 中分${n}`;d>0?(t+=` | ${d}币异动中`,h>0&&(t+=` → ${h}通过!`)):t+=" | 等待异动信号";function a(s){return s==null?"":s>=80?"text-green":s>=50?"text-yellow":"text-dim"}function p(s){return s==null||s<=1.5?"":s>3?"text-red":"text-orange"}function b(s){return s==null||s===0?"":s>0?"text-green":"text-red"}return e.jsxs("section",{className:"card card-wide",id:"trend-filter-card",children:[e.jsxs("h2",{children:["趋势过滤 (",h,"通过 / ",r.length,") ",e.jsx("span",{className:"text-dim",style:{fontSize:12,fontWeight:400},children:t})]}),e.jsx("div",{className:"table-wrap",style:{maxHeight:400},children:e.jsxs("table",{id:"trend-filter-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"币种"}),e.jsx("th",{children:"分数"}),e.jsx("th",{children:"24h范围"}),e.jsx("th",{children:"基线"}),e.jsx("th",{children:"1h范围"}),e.jsx("th",{children:"成交量比"}),e.jsx("th",{children:"1h变化"}),e.jsx("th",{children:"EMA52"}),e.jsx("th",{children:"EMA斜率"}),e.jsx("th",{children:"现价"}),e.jsx("th",{children:"> EMA"}),e.jsx("th",{children:"安静24h"}),e.jsx("th",{children:"安静1h"}),e.jsx("th",{children:"异动"}),e.jsx("th",{children:"更新于"})]})}),e.jsx("tbody",{children:r.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:"15",className:"text-dim",style:{textAlign:"center",padding:20},children:"等待K线数据..."})}):r.map(s=>e.jsxs("tr",{className:s.passes_filter?"filter-pass":"",children:[e.jsx("td",{children:e.jsx("strong",{children:s.coin})}),e.jsx("td",{className:"text-right "+a(s.signal_score),style:{fontWeight:700},children:s.signal_score!=null?s.signal_score.toFixed(0):"-"}),e.jsx("td",{className:"text-right "+(s.quiet_24h?"text-green":""),children:s.range_24h!=null?s.range_24h.toFixed(2)+"%":"-"}),e.jsx("td",{className:"text-right text-dim",children:s.vol_baseline!=null?s.vol_baseline.toFixed(2)+"%":"-"}),e.jsx("td",{className:"text-right "+(s.quiet_1h?"text-green":""),children:s.range_1h!=null?s.range_1h.toFixed(2)+"%":"-"}),e.jsx("td",{className:"text-right "+p(s.volume_ratio),children:s.volume_ratio!=null?s.volume_ratio.toFixed(2)+"x":"-"}),e.jsx("td",{className:"text-right "+(s.change_1h>0?"text-green":s.change_1h<0?"text-red":""),children:s.change_1h!=null?(s.change_1h>0?"+":"")+s.change_1h.toFixed(2)+"%":"-"}),e.jsx("td",{className:"text-right",children:s.ema_52?s.ema_52.toFixed(4):"-"}),e.jsx("td",{className:"text-right "+b(s.ema_slope),children:s.ema_slope!=null?(s.ema_slope>0?"+":"")+s.ema_slope.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-right",children:s.current_price?s.current_price.toFixed(4):"-"}),e.jsx("td",{className:s.price_above_ema?"text-green":"text-red",children:s.price_above_ema!=null?s.price_above_ema?"↑":"↓":"-"}),e.jsx("td",{className:s.quiet_24h?"text-green":"text-dim",children:s.quiet_24h!=null?s.quiet_24h?"✓":"✗":"-"}),e.jsx("td",{className:s.quiet_1h?"text-green":"text-dim",children:s.quiet_1h!=null?s.quiet_1h?"✓":"✗":"-"}),e.jsx("td",{className:s.fresh_anomaly?"text-orange":"text-dim",children:s.fresh_anomaly!=null&&s.fresh_anomaly?"⚠":"-"}),e.jsx("td",{className:"text-dim",children:s.last_updated?new Date(s.last_updated).toLocaleTimeString("zh-CN",{hour12:!1}):"-"})]},s.coin))})]})})]})}function re({signals:r}){const h=r.filter(n=>n.category==="full"),l=h.filter(n=>n.type==="enter").length;return e.jsxs("section",{className:"card card-wide",id:"trend-signal-card",children:[e.jsxs("h2",{children:["完整信号 (异动+分数≥70) ",l>0&&e.jsxs("span",{className:"text-green",style:{fontSize:12,fontWeight:400,marginLeft:8},children:["共",l,"条"]})]}),e.jsx("div",{className:"table-wrap",style:{maxHeight:350},children:e.jsxs("table",{id:"trend-signal-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"时间"}),e.jsx("th",{children:"币种"}),e.jsx("th",{children:"类型"}),e.jsx("th",{children:"分数"}),e.jsx("th",{children:"价格"}),e.jsx("th",{children:"成交量比"}),e.jsx("th",{children:"EMA斜率"}),e.jsx("th",{children:"趋势状态"})]})}),e.jsx("tbody",{children:h.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:"8",className:"text-dim",style:{textAlign:"center",padding:20},children:"等待完整信号... (FreshAnomaly + 分数≥70)"})}):h.slice(0,50).map((n,d)=>{const t=n.type==="enter"?"signal-enter":"signal-exit",a=n.timestamp?new Date(n.timestamp).toLocaleTimeString("zh-CN",{hour12:!1}):"-";return e.jsxs("tr",{className:t,children:[e.jsx("td",{className:"text-dim",children:a}),e.jsx("td",{children:e.jsx("strong",{children:n.coin})}),e.jsx("td",{className:n.type==="enter"?"text-green":"text-dim",style:{fontWeight:600},children:n.type==="enter"?"开":"关"}),e.jsx("td",{className:"text-right",style:{fontWeight:700},children:n.signal_score!=null?n.signal_score.toFixed(0):"-"}),e.jsx("td",{className:"text-right",children:n.price?n.price.toFixed(4):"-"}),e.jsx("td",{className:"text-right",children:n.volume_ratio!=null?n.volume_ratio.toFixed(2)+"x":"-"}),e.jsx("td",{className:"text-right",children:n.ema_slope!=null?(n.ema_slope>0?"+":"")+n.ema_slope.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-dim",children:n.state||"-"})]},"full-"+n.timestamp+"-"+n.coin+"-"+d)})})]})})]})}function le({signals:r}){const h=r.filter(n=>n.category==="high"),l=h.filter(n=>n.type==="enter").length;return e.jsxs("section",{className:"card card-wide",id:"high-score-card",children:[e.jsxs("h2",{children:["高分信号 (分数≥90) ",l>0&&e.jsxs("span",{className:"text-green",style:{fontSize:12,fontWeight:400,marginLeft:8},children:["共",l,"条"]})]}),e.jsx("div",{className:"table-wrap",style:{maxHeight:350},children:e.jsxs("table",{id:"high-score-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"时间"}),e.jsx("th",{children:"币种"}),e.jsx("th",{children:"类型"}),e.jsx("th",{children:"分数"}),e.jsx("th",{children:"价格"}),e.jsx("th",{children:"成交量比"}),e.jsx("th",{children:"EMA斜率"}),e.jsx("th",{children:"趋势状态"})]})}),e.jsx("tbody",{children:h.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:"8",className:"text-dim",style:{textAlign:"center",padding:20},children:"等待高分信号... (分数≥90)"})}):h.slice(0,50).map((n,d)=>{const t=n.type==="enter"?"signal-enter":"signal-exit",a=n.timestamp?new Date(n.timestamp).toLocaleTimeString("zh-CN",{hour12:!1}):"-";return e.jsxs("tr",{className:t,children:[e.jsx("td",{className:"text-dim",children:a}),e.jsx("td",{children:e.jsx("strong",{children:n.coin})}),e.jsx("td",{className:n.type==="enter"?"text-green":"text-dim",style:{fontWeight:600},children:n.type==="enter"?"开":"关"}),e.jsx("td",{className:"text-right",style:{fontWeight:700},children:n.signal_score!=null?n.signal_score.toFixed(0):"-"}),e.jsx("td",{className:"text-right",children:n.price?n.price.toFixed(4):"-"}),e.jsx("td",{className:"text-right",children:n.volume_ratio!=null?n.volume_ratio.toFixed(2)+"x":"-"}),e.jsx("td",{className:"text-right",children:n.ema_slope!=null?(n.ema_slope>0?"+":"")+n.ema_slope.toFixed(3)+"%":"-"}),e.jsx("td",{className:"text-dim",children:n.state||"-"})]},"high-"+n.timestamp+"-"+n.coin+"-"+d)})})]})})]})}U.createRoot(document.getElementById("root")).render(e.jsx(V.StrictMode,{children:e.jsx(Y,{})}));
diff --git a/frontend/dist/assets/index-vvNDQq2K.css b/frontend/dist/assets/main-vvNDQq2K.css
similarity index 100%
rename from frontend/dist/assets/index-vvNDQq2K.css
rename to frontend/dist/assets/main-vvNDQq2K.css
diff --git a/frontend/dist/binance.html b/frontend/dist/binance.html
new file mode 100644
index 0000000..0001fb2
--- /dev/null
+++ b/frontend/dist/binance.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+ Binance Momentum Monitor
+
+
+
+
+
+
+
+
diff --git a/frontend/dist/index.html b/frontend/dist/index.html
index 6d4c500..2228653 100644
--- a/frontend/dist/index.html
+++ b/frontend/dist/index.html
@@ -4,8 +4,9 @@
Exchange Monitor Dashboard
-
-
+
+
+
diff --git a/frontend/src/BinanceApp.css b/frontend/src/BinanceApp.css
new file mode 100644
index 0000000..2518575
--- /dev/null
+++ b/frontend/src/BinanceApp.css
@@ -0,0 +1,193 @@
+:root {
+ --bg: #0d1117;
+ --card: #161b22;
+ --border: #30363d;
+ --text: #c9d1d9;
+ --text-dim: #8b949e;
+ --accent: #58a6ff;
+ --green: #3fb950;
+ --red: #f85149;
+ --yellow: #d29922;
+}
+
+* { margin: 0; padding: 0; box-sizing: border-box; }
+
+body {
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
+ background: var(--bg);
+ color: var(--text);
+ font-size: 14px;
+ line-height: 1.5;
+ min-height: 100vh;
+}
+
+#bm-app { max-width: 1200px; margin: 0 auto; padding: 16px; }
+
+/* Header */
+header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 12px 16px;
+ background: var(--card);
+ border: 1px solid var(--border);
+ border-radius: 8px;
+ margin-bottom: 12px;
+ flex-wrap: wrap;
+ gap: 8px;
+}
+header h1 { font-size: 18px; font-weight: 600; }
+.header-subtitle { font-size: 12px; color: var(--text-dim); margin-left: 12px; }
+.header-right { display: flex; align-items: center; gap: 10px; font-size: 13px; }
+
+.stat-badge {
+ background: rgba(88, 166, 255, 0.1);
+ color: var(--accent);
+ padding: 2px 8px;
+ border-radius: 10px;
+ font-size: 12px;
+ font-weight: 500;
+}
+.stat-alert {
+ background: rgba(248, 81, 73, 0.15);
+ color: var(--red);
+ animation: pulse 2s infinite;
+}
+@keyframes pulse {
+ 0%, 100% { opacity: 1; }
+ 50% { opacity: 0.6; }
+}
+
+.status-online { color: var(--green); }
+.status-offline { color: var(--red); }
+
+/* Cards */
+.card {
+ background: var(--card);
+ border: 1px solid var(--border);
+ border-radius: 8px;
+ padding: 12px;
+ margin-bottom: 12px;
+}
+.card-wide { }
+.card h2 {
+ font-size: 14px;
+ font-weight: 600;
+ color: var(--text-dim);
+ margin-bottom: 10px;
+ padding-bottom: 8px;
+ border-bottom: 1px solid var(--border);
+}
+
+/* Alert Section */
+.alert-scroll {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+ max-height: 120px;
+ overflow-y: auto;
+}
+.alert-item {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 4px 10px;
+ border-radius: 4px;
+ font-size: 13px;
+ font-variant-numeric: tabular-nums;
+}
+.alert-up { background: rgba(63, 185, 80, 0.08); }
+.alert-down { background: rgba(248, 81, 73, 0.08); }
+.alert-icon { font-size: 14px; }
+.alert-coin {
+ color: var(--accent);
+ text-decoration: none;
+ font-weight: 600;
+ min-width: 50px;
+}
+.alert-coin:hover { text-decoration: underline; }
+.alert-price { color: var(--text-dim); min-width: 90px; }
+.alert-time { font-size: 11px; }
+
+/* Table */
+.table-wrap { overflow-x: auto; overflow-y: auto; }
+table { width: 100%; border-collapse: collapse; font-size: 13px; }
+th {
+ text-align: left;
+ padding: 6px 8px;
+ color: var(--text-dim);
+ font-weight: 500;
+ font-size: 11px;
+ text-transform: uppercase;
+ letter-spacing: 0.5px;
+ position: sticky;
+ top: 0;
+ background: var(--card);
+ border-bottom: 1px solid var(--border);
+ user-select: none;
+}
+th:hover { color: var(--accent); }
+td {
+ padding: 4px 8px;
+ border-bottom: 1px solid rgba(48, 54, 61, 0.5);
+ white-space: nowrap;
+}
+tr:hover td { background: rgba(88, 166, 255, 0.05); }
+
+.coin-link {
+ color: var(--accent);
+ text-decoration: none;
+ font-weight: 600;
+}
+.coin-link:hover { text-decoration: underline; }
+.warmup-badge {
+ font-size: 10px;
+ color: var(--text-dim);
+ margin-left: 6px;
+}
+
+/* Row highlights */
+.row-warmup td { opacity: 0.45; }
+.row-surge-up td { background: rgba(63, 185, 80, 0.1) !important; }
+.row-surge-up:hover td { background: rgba(63, 185, 80, 0.18) !important; }
+.row-surge-down td { background: rgba(248, 81, 73, 0.1) !important; }
+.row-surge-down:hover td { background: rgba(248, 81, 73, 0.18) !important; }
+.row-up td { background: rgba(63, 185, 80, 0.03); }
+.row-down td { background: rgba(248, 81, 73, 0.03); }
+
+/* Bar */
+.bar-track {
+ width: 100px;
+ height: 6px;
+ background: rgba(48, 54, 61, 0.5);
+ border-radius: 3px;
+ overflow: hidden;
+}
+.bar-fill {
+ height: 100%;
+ border-radius: 3px;
+ transition: width 0.3s ease;
+}
+.bar-green { background: var(--green); }
+.bar-red { background: var(--red); }
+.bar-green-dim { background: rgba(63, 185, 80, 0.5); }
+.bar-red-dim { background: rgba(248, 81, 73, 0.5); }
+
+/* Utility */
+.text-green { color: var(--green); }
+.text-red { color: var(--red); }
+.text-dim { color: var(--text-dim); }
+.text-right { text-align: right; }
+.mono { font-variant-numeric: tabular-nums; font-family: 'SF Mono', 'Cascadia Code', monospace; }
+.loading { text-align: center; color: var(--text-dim); padding: 20px !important; }
+
+/* Scrollbar */
+::-webkit-scrollbar { width: 6px; height: 6px; }
+::-webkit-scrollbar-track { background: transparent; }
+::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
+::-webkit-scrollbar-thumb:hover { background: #484f58; }
+
+@media (max-width: 768px) {
+ header { flex-direction: column; }
+ #bm-app { padding: 8px; }
+}
diff --git a/frontend/src/BinanceApp.jsx b/frontend/src/BinanceApp.jsx
new file mode 100644
index 0000000..cc25b81
--- /dev/null
+++ b/frontend/src/BinanceApp.jsx
@@ -0,0 +1,215 @@
+import { useState, useEffect, useRef, useCallback } from 'react'
+
+const BINANCE_BASE = 'https://www.binance.com/en/futures/'
+
+function BinanceApp() {
+ const [coins, setCoins] = useState([])
+ const [alerts, setAlerts] = useState([])
+ const [connStatus, setConnStatus] = useState('● 连接中...')
+ const [connOnline, setConnOnline] = useState(false)
+ const [sortBy, setSortBy] = useState('change_abs')
+ const [sortDir, setSortDir] = useState('desc')
+ const esRef = useRef(null)
+
+ // Connect to SSE
+ const connect = useCallback(() => {
+ const es = new EventSource('/events')
+ esRef.current = es
+
+ es.addEventListener('connected', () => {
+ setConnStatus('● 已连接')
+ setConnOnline(true)
+ })
+
+ // Backend sends events as unnamed SSE messages with JSON {event, data, ts}.
+ // Use onmessage and dispatch by msg.event field.
+ es.onmessage = (e) => {
+ try {
+ const msg = JSON.parse(e.data)
+ switch (msg.event) {
+ case 'binance_momentum':
+ setCoins(msg.data)
+ break
+ case 'binance_alert':
+ setAlerts(prev => [msg.data, ...prev].slice(0, 200))
+ break
+ }
+ } catch {}
+ }
+
+ es.onerror = () => {
+ setConnStatus('● 已断开 (重连中...)')
+ setConnOnline(false)
+ es.close()
+ setTimeout(connect, 3000)
+ }
+ }, [])
+
+ useEffect(() => {
+ connect()
+ return () => {
+ if (esRef.current) esRef.current.close()
+ }
+ }, [connect])
+
+ // Poll alerts as fallback
+ useEffect(() => {
+ const fetchAlerts = async () => {
+ try {
+ const res = await fetch('/api/binance-alerts?limit=50')
+ const data = await res.json()
+ if (data.alerts && data.alerts.length > 0) {
+ setAlerts(prev => {
+ const existing = new Set(prev.map(a => a.timestamp))
+ const merged = [...prev]
+ for (const a of data.alerts) {
+ if (!existing.has(a.timestamp)) {
+ merged.push(a)
+ }
+ }
+ return merged.slice(0, 200)
+ })
+ }
+ } catch {}
+ }
+ const timer = setInterval(fetchAlerts, 10000)
+ return () => clearInterval(timer)
+ }, [])
+
+ // Sort coins
+ const handleSort = (col) => {
+ if (sortBy === col) {
+ setSortDir(d => d === 'asc' ? 'desc' : 'asc')
+ } else {
+ setSortBy(col)
+ setSortDir('desc')
+ }
+ }
+
+ const sortedCoins = [...coins].sort((a, b) => {
+ let va, vb
+ switch (sortBy) {
+ case 'coin':
+ va = a.coin; vb = b.coin
+ return sortDir === 'asc' ? va.localeCompare(vb) : vb.localeCompare(va)
+ case 'price':
+ va = a.price || 0; vb = b.price || 0
+ break
+ case 'change_abs':
+ va = Math.abs(a.change_pct) || 0; vb = Math.abs(b.change_pct) || 0
+ break
+ case 'change':
+ va = a.change_pct || 0; vb = b.change_pct || 0
+ break
+ default:
+ return 0
+ }
+ return sortDir === 'asc' ? va - vb : vb - va
+ })
+
+ // Stats
+ const fullCount = coins.filter(c => c.buffer_full).length
+ const alertingCount = coins.filter(c => Math.abs(c.change_pct) >= 10).length
+
+ return (
+
+ {/* Header */}
+
+
+
BN 1-Min Momentum Monitor
+ Binance 1分钟涨跌监控 | 阈值 ≥10%
+
+
+ {coins.length} coins
+ {fullCount} ready
+ {alertingCount > 0 && {alertingCount} alerting}
+ {connStatus}
+
+
+
+ {/* Alert History */}
+ {alerts.length > 0 && (
+
+ Alert History ({alerts.length})
+
+ {alerts.slice(0, 50).map((a, i) => (
+
+
{a.direction === 'up' ? '🟢' : '🔴'}
+
{a.coin}
+
+ {a.change_pct >= 0 ? '+' : ''}{a.change_pct?.toFixed(2)}%
+
+
${a.price?.toFixed(4)}
+
{new Date(a.timestamp).toLocaleTimeString()}
+
+ ))}
+
+
+ )}
+
+ {/* Coins Table */}
+
+ All Coins ({coins.length})
+
+
+
+
+ | handleSort('coin')} style={{ cursor: 'pointer' }}>
+ Coin {sortBy === 'coin' ? (sortDir === 'asc' ? '▲' : '▼') : ''}
+ |
+ handleSort('price')} style={{ cursor: 'pointer' }}>
+ Price {sortBy === 'price' ? (sortDir === 'asc' ? '▲' : '▼') : ''}
+ |
+ handleSort('change_abs')} style={{ cursor: 'pointer' }}>
+ 1m Change {sortBy === 'change_abs' ? (sortDir === 'asc' ? '▲' : '▼') : ''}
+ |
+ Bar |
+
+
+
+ {sortedCoins.map(c => {
+ const cls = !c.buffer_full ? 'row-warmup'
+ : c.change_pct >= 10 ? 'row-surge-up'
+ : c.change_pct <= -10 ? 'row-surge-down'
+ : c.change_pct > 0 ? 'row-up'
+ : c.change_pct < 0 ? 'row-down'
+ : ''
+ const barPct = Math.min(Math.abs(c.change_pct) / 15 * 100, 100)
+ const barCls = c.change_pct >= 10 ? 'bar-green'
+ : c.change_pct <= -10 ? 'bar-red'
+ : c.change_pct > 0 ? 'bar-green-dim'
+ : 'bar-red-dim'
+ return (
+
+ |
+
+ {c.coin}
+
+ {!c.buffer_full && ···}
+ |
+
+ {c.price ? `$${c.price.toFixed(4)}` : '-'}
+ |
+ = 10 ? 'text-green' : c.change_pct <= -10 ? 'text-red' : c.change_pct > 0 ? 'text-green' : c.change_pct < 0 ? 'text-red' : 'text-dim'}`}>
+ {c.buffer_full ? `${c.change_pct >= 0 ? '+' : ''}${c.change_pct.toFixed(2)}%` : 'warming...'}
+ |
+
+
+ |
+
+ )
+ })}
+ {sortedCoins.length === 0 && (
+ | Waiting for data... |
+ )}
+
+
+
+
+
+ )
+}
+
+export default BinanceApp
diff --git a/frontend/src/binance-main.jsx b/frontend/src/binance-main.jsx
new file mode 100644
index 0000000..0e557f9
--- /dev/null
+++ b/frontend/src/binance-main.jsx
@@ -0,0 +1,10 @@
+import React from 'react'
+import ReactDOM from 'react-dom/client'
+import BinanceApp from './BinanceApp'
+import './BinanceApp.css'
+
+ReactDOM.createRoot(document.getElementById('root')).render(
+
+
+ ,
+)
diff --git a/frontend/vite.config.js b/frontend/vite.config.js
index f10b4f0..344ed25 100644
--- a/frontend/vite.config.js
+++ b/frontend/vite.config.js
@@ -1,5 +1,6 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
+import { resolve } from 'path'
export default defineConfig({
plugins: [react()],
@@ -13,5 +14,11 @@ export default defineConfig({
},
build: {
outDir: 'dist',
+ rollupOptions: {
+ input: {
+ main: resolve(__dirname, 'index.html'),
+ binance: resolve(__dirname, 'binance.html'),
+ },
+ },
},
})
diff --git a/main.go b/main.go
index c1954d6..9869cbe 100644
--- a/main.go
+++ b/main.go
@@ -33,6 +33,14 @@ func main() {
loadDotEnv()
cfg := LoadConfig()
+ // Initialize Telegram sender
+ telegramSender := NewTelegramSender(cfg.TelegramBotToken, cfg.TelegramChatID)
+ if telegramSender.IsEnabled() {
+ log.Printf("[Telegram] Alerts enabled -> chat %s", cfg.TelegramChatID)
+ } else {
+ log.Println("[Telegram] Alerts disabled (missing token or chat ID)")
+ }
+
store := NewPriceStore()
// Initialize momentum tracker (for momentum scanning mode)
@@ -79,8 +87,18 @@ func main() {
}
}
+ // Initialize Binance momentum detector (1-minute Binance price change)
+ binanceMomentumDetector := NewBinanceMomentumDetector(
+ cfg.BinanceMomentumWindowSec, 50, // actual loop tick is fixed 50ms
+ cfg.BinanceMomentumThresholdPct, cfg.BinanceMomentumCooldownSec,
+ )
+ if cfg.BinanceMomentumEnabled {
+ log.Printf("[BinanceMomentum] Detection enabled (window=%ds, threshold=%.1f%%, cooldown=%ds)",
+ cfg.BinanceMomentumWindowSec, cfg.BinanceMomentumThresholdPct, cfg.BinanceMomentumCooldownSec)
+ }
+
// Initialize dashboard (web server + SSE)
- dashboard := NewDashboard(store, database, ":8888", cfg, momentumTracker, trendDetector, cumulativeTracker, trendFilter, surgeDetector)
+ dashboard := NewDashboard(store, database, ":8888", cfg, momentumTracker, trendDetector, cumulativeTracker, trendFilter, surgeDetector, binanceMomentumDetector)
go dashboard.Run()
// Context for graceful shutdown
@@ -172,6 +190,30 @@ func main() {
now := time.Now()
snap := store.GetAll()
+ // Feed Binance prices to momentum detector
+ if cfg.BinanceMomentumEnabled {
+ for _, tc := range TrackedCoins {
+ if exMap := snap[tc.Name]; exMap != nil {
+ if bnPrice, ok := exMap[ExBinance]; ok && bnPrice > 0 {
+ binanceMomentumDetector.Record(tc.Name, bnPrice)
+ }
+ }
+ }
+ alerts := binanceMomentumDetector.Detect()
+ for _, alert := range alerts {
+ log.Printf("[BinanceMomentum] %s %s %.2f%% ($%.4f)",
+ alert.Coin, alert.Direction, alert.ChangePct, alert.Price)
+ dashboard.BroadcastEvent("binance_alert", alert)
+ if telegramSender.IsEnabled() {
+ go func(a BinanceAlert) {
+ if err := telegramSender.SendAlert(a); err != nil {
+ log.Printf("[Telegram] Failed to send alert for %s: %v", a.Coin, err)
+ }
+ }(alert)
+ }
+ }
+ }
+
// Feed prices to momentum tracker (for momentum scanning or trend detection)
if cfg.MomentumEnabled || cfg.TrendEnabled {
for coin, exMap := range snap {
diff --git a/telegram.go b/telegram.go
new file mode 100644
index 0000000..835dc8a
--- /dev/null
+++ b/telegram.go
@@ -0,0 +1,81 @@
+package main
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "log"
+ "net/http"
+ "time"
+)
+
+// TelegramSender sends alerts to a Telegram chat via Bot API.
+type TelegramSender struct {
+ botToken string
+ chatID string
+ client *http.Client
+ enabled bool
+}
+
+// NewTelegramSender creates a sender. Returns a no-op sender if token or chatID is empty.
+func NewTelegramSender(botToken, chatID string) *TelegramSender {
+ return &TelegramSender{
+ botToken: botToken,
+ chatID: chatID,
+ client: &http.Client{
+ Timeout: 10 * time.Second,
+ Transport: &http.Transport{
+ Proxy: http.ProxyFromEnvironment,
+ },
+ },
+ enabled: botToken != "" && chatID != "",
+ }
+}
+
+// IsEnabled returns true if both token and chatID are configured.
+func (t *TelegramSender) IsEnabled() bool {
+ return t.enabled
+}
+
+// SendAlert sends a formatted momentum alert to Telegram.
+func (t *TelegramSender) SendAlert(alert BinanceAlert) error {
+ if !t.enabled {
+ return nil
+ }
+
+ // Build message
+ icon := "🔴"
+ directionWord := "暴跌"
+ if alert.Direction == "up" {
+ icon = "🟢"
+ directionWord = "暴涨"
+ }
+ sign := "+"
+ if alert.ChangePct < 0 {
+ sign = ""
+ }
+
+ text := fmt.Sprintf("%s *%s* %s %s%.2f%% | $%.4f",
+ icon, alert.Coin, directionWord, sign, alert.ChangePct, alert.Price)
+
+ payload := map[string]interface{}{
+ "chat_id": t.chatID,
+ "text": text,
+ "parse_mode": "Markdown",
+ }
+ body, _ := json.Marshal(payload)
+
+ url := fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage", t.botToken)
+ resp, err := t.client.Post(url, "application/json", bytes.NewReader(body))
+ if err != nil {
+ return fmt.Errorf("telegram API call failed: %w", err)
+ }
+ defer resp.Body.Close()
+
+ if resp.StatusCode != 200 {
+ return fmt.Errorf("telegram API returned %d", resp.StatusCode)
+ }
+
+ log.Printf("[Telegram] Alert sent: %s %s %.2f%%", alert.Coin, alert.Direction, alert.ChangePct)
+ return nil
+}