const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chunk-LoadCharts-7rVnVEuJ.js","assets/entry-index-_JNGV0lD.js","assets/chunk-react-vendor-c5ypKtDW.js","assets/index-DzdIfJ-S.css","assets/chunk-chartHelper-CoSPeqLf.js","assets/chunk-Instance-BUMsJWAb.js","assets/chunk-PingChart-BoZ15evw.js"])))=>i.map(i=>d[i]);
import{z as V,A as q,q as L,D as $,r as a,u as G,s as J,d as K,j as e,t as y,C as N,B as f,E as Q,_ as S}from"./entry-index-_JNGV0lD.js";import{F as U,I as W}from"./chunk-Instance-BUMsJWAb.js";import"./chunk-react-vendor-c5ypKtDW.js";const X=a.lazy(()=>S(()=>import("./chunk-LoadCharts-7rVnVEuJ.js"),__vite__mapDeps([0,1,2,3,4,5]))),Y=a.lazy(()=>S(()=>import("./chunk-PingChart-BoZ15evw.js").then(u=>u.a),__vite__mapDeps([6,1,2,3,4,5]))),te=()=>{const{uuid:u}=V(),E=q(),{nodes:g,loading:m}=L(),{liveData:p}=$();L();const[i,D]=a.useState(null),[R,j]=a.useState(!1),[o,A]=a.useState("load"),[h,I]=a.useState("load"),[d,v]=a.useState("fading-in"),[P,k]=a.useState(0),[b,z]=a.useState(1),{enableInstanceDetail:M,enablePingChart:H,publicSettings:_}=G(),F=J(),{t}=K(),r=_?.record_preserve_time||0,l=_?.ping_record_preserve_time||24,x=a.useMemo(()=>[{label:t("instancePage.live"),hours:0},{label:t("instancePage.hours",{count:1}),hours:1},{label:t("instancePage.hours",{count:4}),hours:4},{label:t("instancePage.days",{count:1}),hours:24},{label:t("instancePage.days",{count:7}),hours:168},{label:t("instancePage.days",{count:30}),hours:720}],[t]),O=a.useMemo(()=>{const s=x.filter(n=>n.hours!==0&&n.hours<=l);if(l>720){const n=l%24===0?t("instancePage.days",{count:Math.floor(l/24)}):t("instancePage.hours",{count:l});s.push({label:n,hours:l})}return s},[x,l,t]),B=a.useMemo(()=>{const s=x.filter(n=>n.hours<=r);if(r>720){const n=r%24===0?t("instancePage.days",{count:Math.floor(r/24)}):t("instancePage.hours",{count:r});s.push({label:n,hours:r})}return s},[x,r,t]);a.useEffect(()=>{if(Array.isArray(g)){const s=g.find(n=>n.uuid===u);D(s||null)}},[g,u]),a.useEffect(()=>{j(!1)},[u]);const C=a.useMemo(()=>{if(!(!i||!p))return p[i.uuid]},[i,p]),c=i,T=C?.online??!1;a.useEffect(()=>{if(m){j(!1);return}if(!c)return;const s=setTimeout(()=>j(!0),300);return()=>clearTimeout(s)},[c,m]),a.useEffect(()=>{if(o===h){if(d==="fading-in"){const n=setTimeout(()=>v("idle"),300);return()=>clearTimeout(n)}return}v("fading-out");const s=setTimeout(()=>{I(o),v("fading-in")},200);return()=>clearTimeout(s)},[o,h,d]);const w=s=>{s===o||d==="fading-out"||A(s)};return!c||!i?m?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(y,{text:t("instancePage.loadingNodeInfo")})}):e.jsx("div",{className:"flex items-center justify-center h-full",children:t("instancePage.nodeNotFound")}):R?e.jsxs("div",{className:"text-card-foreground space-y-4 my-4 fade-in @container",children:[e.jsx(N,{className:"flex items-center justify-between p-4 mb-4 text-primary",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(f,{className:"flex-shrink-0",variant:"outline",size:"icon",onClick:()=>E(-1),children:e.jsx(Q,{})}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(U,{flag:c.region}),e.jsx("span",{className:"text-xl md:text-2xl font-bold",children:c.name})]}),e.jsx("span",{className:"text-sm text-secondary-foreground flex-shrink-0",children:t(T?"node.online":"node.offline")})]})}),M&&c&&e.jsx(W,{node:c}),e.jsxs("div",{className:"flex flex-col items-center w-full space-y-4",children:[e.jsx(N,{className:"p-2",children:e.jsxs("div",{className:"flex justify-center space-x-2",children:[e.jsx(f,{variant:o==="load"?"default":"ghost",size:"sm",onClick:()=>w("load"),children:t("instancePage.optionLoad")}),H&&e.jsx(f,{variant:o==="ping"?"default":"ghost",size:"sm",onClick:()=>w("ping"),children:t("instancePage.optionPing")})]})}),e.jsx(N,{className:`justify-center p-2 ${F?"w-full":""}`,children:o==="load"?e.jsx("div",{className:"flex space-x-2 overflow-x-auto whitespace-nowrap",children:B.map(s=>e.jsx(f,{variant:P===s.hours?"default":"ghost",size:"sm",onClick:()=>k(s.hours),children:s.label},s.label))}):e.jsx("div",{className:"flex space-x-2 overflow-x-auto whitespace-nowrap",children:O.map(s=>e.jsx(f,{variant:b===s.hours?"default":"ghost",size:"sm",onClick:()=>z(s.hours),children:s.label},s.label))})})]}),e.jsx("div",{className:d==="fading-out"?"fade-out":d==="fading-in"?"fade-in":void 0,children:e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-96",children:e.jsx(y,{text:t("chart.loading")})}),children:h==="load"&&i?e.jsx(X,{node:i,hours:P,liveData:C,isOnline:T}):h==="ping"&&i?e.jsx(Y,{node:i,hours:b}):null})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(y,{text:t("instancePage.enteringNodeDetails"),className:m?"":"fade-out"})})};export{te as default};
