%PDF- %PDF-
| Direktori : /home2/rezakur1/ai.rezakurnia.com/assets/ |
| Current File : /home2/rezakur1/ai.rezakurnia.com/assets/AdminServiceStatusPage-5xZ6yFtQ.js |
import{r as b,a as E,j as e}from"./index-Bu042oJp.js";import{B as $}from"./Badge-BhTU663i.js";import{B}from"./Button-CsqZL9Xc.js";import{C as g,b as N,a as y}from"./Card-TlRU04W7.js";import{f as P,a as t,c as F}from"./format-CjhWL3Ta.js";function L(l=6e4){const[i,x]=b.useState(null),[r,j]=b.useState(!0),[s,o]=b.useState(!1),[d,m]=b.useState(null),u=b.useRef(0),f=b.useCallback(async(h=!1)=>{const w=++u.current;h&&o(!0);try{const p=await E(`/admin/service-status${h?"?refresh=1":""}`);if(u.current!==w)return;x(p),m(null)}catch(p){if(u.current!==w)return;m(p instanceof Error?p.message:"Gagal memuat status layanan")}finally{u.current===w&&(j(!1),o(!1))}},[]);b.useEffect(()=>{f();const h=setInterval(()=>f(),l);return()=>{clearInterval(h),u.current++}},[f,l]);const M=b.useCallback(()=>f(!0),[f]);return{data:i,loading:r,refreshing:s,error:d,refresh:M}}const C=(l,i)=>{const x=Number(l??0),r=Number(i??0);return!Number.isFinite(x)||!Number.isFinite(r)||r<=0?0:Math.min(100,Math.max(0,x/r*100))},z=l=>l>0?new Date(l*1e3).toISOString():"",k=l=>{const i=z(l);return i?P(i):"—"},U=l=>{const i=Math.max(0,Math.floor(Number(l)||0)),x=Math.floor(i/86400),r=Math.floor(i%86400/3600),j=Math.floor(i%3600/60);return x>0?`${x}h ${r}j`:r>0?`${r}j ${j}m`:`${j}m ${i%60}s`};function n({label:l,value:i,hint:x,accent:r="text-white"}){return e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-3.5 py-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:l}),e.jsx("p",{className:`mt-1.5 text-lg font-bold tabular-nums ${r}`,children:i}),x&&e.jsx("p",{className:"mt-0.5 text-[10px] leading-snug text-slate-500",children:x})]})}function T({label:l,value:i}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-lg border border-white/[0.06] bg-white/[0.02] px-2.5 py-1 text-[11px]",children:[e.jsx("span",{className:"text-slate-500",children:l}),e.jsx("span",{className:"font-semibold tabular-nums text-slate-200",children:i})]})}function Q({percent:l,color:i,label:x,sublabel:r}){const s=2*Math.PI*52,o=s-Math.min(100,Math.max(0,l))/100*s;return e.jsxs("div",{className:"relative h-36 w-36",children:[e.jsxs("svg",{viewBox:"0 0 128 128",className:"h-full w-full -rotate-90",children:[e.jsx("circle",{cx:"64",cy:"64",r:52,fill:"none",stroke:"rgba(255,255,255,0.06)",strokeWidth:"10"}),e.jsx("circle",{cx:"64",cy:"64",r:52,fill:"none",stroke:i,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:s,strokeDashoffset:o,className:"transition-all duration-500"})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsx("p",{className:"text-2xl font-bold tabular-nums text-white",children:x}),e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-slate-500",children:r})]})]})}function c({label:l,value:i}){return e.jsxs("tr",{children:[e.jsx("td",{className:"w-1/2 px-4 py-2.5 text-xs text-slate-500",children:l}),e.jsx("td",{className:"px-4 py-2.5 text-right font-mono text-xs text-slate-200",children:i})]})}function G(){return e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"h-52 animate-pulse rounded-2xl border border-white/[0.04] bg-white/[0.02]"}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-6",children:[...Array(6)].map((l,i)=>e.jsx("div",{className:"h-20 animate-pulse rounded-xl border border-white/[0.04] bg-white/[0.02]"},i))}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[e.jsx("div",{className:"h-48 animate-pulse rounded-2xl border border-white/[0.04] bg-white/[0.02]"}),e.jsx("div",{className:"h-48 animate-pulse rounded-2xl border border-white/[0.04] bg-white/[0.02]"})]})]})}function X(){const{data:l,loading:i,refreshing:x,error:r,refresh:j}=L(),s=l==null?void 0:l.provider,o=l==null?void 0:l.gateway,d=l==null?void 0:l.models,m=!!(s!=null&&s.is_expired||(s==null?void 0:s.status)==="expired"),u=!m&&((s==null?void 0:s.remaining_requests)??0)<=0&&!!s,f=m?"danger":u?"warning":"success",M=m?"Kedaluwarsa":u?"Kuota Habis":"Aktif",h=C(s==null?void 0:s.used_requests,s==null?void 0:s.max_requests),w=m?"#f87171":u?"#fbbf24":"#34d399",p=(s==null?void 0:s.bound_ips)??[],R=p.length,S=C(R,s==null?void 0:s.max_ips),q=S>=80,a=s==null?void 0:s.temp,I=!!(a&&(a.quota>0||a.used>0||a.remaining_requests>0||a.remaining_seconds>0||a.expires_at>0)),_=Number((d==null?void 0:d.avg_uptime)??0),K=_>=99?"bg-emerald-400":_>=95?"bg-amber-400":"bg-red-400",A=_>=99?"text-emerald-300":_>=95?"text-amber-300":"text-red-300";return e.jsxs("div",{className:"w-full space-y-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight text-white sm:text-2xl",children:"Service Status"}),l&&e.jsx($,{tone:f,children:M}),(l==null?void 0:l.stale)&&e.jsx($,{tone:"warning",children:"Data cache"})]}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Status kuota provider, kesehatan gateway, dan ringkasan model."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l&&e.jsxs("span",{className:"text-[11px] tabular-nums text-slate-500",children:["Diperbarui ",P(l.fetched_at)," · auto 60 detik"]}),e.jsx(B,{variant:"ghost",size:"sm",onClick:()=>void j(),isLoading:x,children:"Refresh"})]})]}),i&&!l&&e.jsx(G,{}),r&&!l&&e.jsx(g,{children:e.jsxs(N,{children:[e.jsx("p",{className:"text-sm text-red-300",children:r}),e.jsx(B,{variant:"ghost",size:"sm",className:"mt-3",onClick:()=>void j(),children:"Coba lagi"})]})}),l&&s&&e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:"rounded-xl border border-amber-400/20 bg-amber-500/[0.06] px-4 py-2.5 text-xs text-amber-200/80",children:["Gagal memperbarui status: ",r,". Menampilkan data terakhir."]}),m&&e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-red-400/25 bg-red-500/10 px-4 py-3",children:[e.jsx("span",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-red-500/15 text-red-300",children:e.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"})})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-red-200",children:"Key provider sudah kedaluwarsa"}),e.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-red-300/80",children:"Request ke provider akan ditolak sampai masa aktif atau kuota diperpanjang. Perpanjang key, lalu klik Refresh."})]})]}),u&&e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-amber-400/25 bg-amber-500/10 px-4 py-3",children:[e.jsx("span",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-amber-500/15 text-amber-300",children:e.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"})})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-amber-200",children:"Kuota request habis"}),e.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-amber-300/80",children:"Sisa request 0. Tambah kuota provider agar layanan dapat menerima request kembali."})]})]}),e.jsxs(g,{className:"relative overflow-hidden",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_55%_65%_at_85%_-10%,rgba(59,130,246,0.12),transparent)]"}),e.jsx("div",{className:"relative p-5 sm:p-6",children:e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-center",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-brand-300",children:"Sisa Kuota Request"}),e.jsx("p",{className:"mt-2 text-3xl font-extrabold tracking-tight tabular-nums text-white sm:text-4xl sm:text-5xl",children:t(s.remaining_requests)}),e.jsxs("p",{className:"mt-1.5 text-xs text-slate-500",children:["dari ",t(s.max_requests)," request ·"," ",t(s.used_requests)," sudah terpakai"]}),e.jsxs("div",{className:"mt-4 max-w-xl",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] font-medium",children:[e.jsx("span",{className:"text-slate-500",children:"Pemakaian kuota"}),e.jsxs("span",{className:"tabular-nums text-slate-400",children:[h.toFixed(1),"%"]})]}),e.jsx("div",{className:"mt-1.5 h-2 overflow-hidden rounded-full bg-white/[0.06]",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${h}%`,background:w}})})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(T,{label:"Concurrency",value:`${t(s.active_streams)} / ${t(s.max_concurrency)}`}),e.jsx(T,{label:"IP Terikat",value:`${t(R)} / ${t(s.max_ips)}`}),e.jsx(T,{label:"Masa Aktif",value:s.remaining_time||"—"})]})]}),e.jsx("div",{className:"flex justify-center lg:justify-end",children:e.jsx(Q,{percent:h,color:w,label:s.max_requests>0?`${h.toFixed(0)}%`:"—",sublabel:"terpakai"})})]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-6",children:[e.jsx(n,{label:"Sisa Request",value:t(s.remaining_requests),hint:`dari ${t(s.max_requests)}`,accent:m?"text-red-300":u?"text-amber-300":"text-emerald-300"}),e.jsx(n,{label:"Request Terpakai",value:t(s.used_requests),hint:"sejak key dibuat"}),e.jsx(n,{label:"Quota Balance",value:F(s.quota_balance),hint:"saldo kuota provider"}),e.jsx(n,{label:"Concurrency",value:`${t(s.active_streams)} / ${t(s.max_concurrency)}`,hint:"stream aktif / batas"}),e.jsx(n,{label:"IP Terikat",value:`${t(R)} / ${t(s.max_ips)}`,hint:q?"mendekati batas":"IP yang diizinkan",accent:q?"text-amber-300":"text-white"}),e.jsx(n,{label:"Masa Aktif",value:m?"Kedaluwarsa":s.remaining_hours>0?`${t(s.remaining_hours)} jam`:s.remaining_seconds>0?`${t(s.remaining_seconds)} dtk`:"—",hint:k(s.expires_at),accent:m?"text-red-300":"text-white"})]}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[e.jsxs(g,{children:[e.jsx(y,{title:"Kesehatan Gateway",subtitle:"Backend yang melayani request"}),e.jsxs(N,{children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-white/[0.06] bg-white/[0.02] px-3.5 py-2.5",children:[e.jsxs("span",{className:"flex items-center gap-2 text-xs font-medium text-slate-300",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-60"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-emerald-400"})]}),"Gateway"]}),e.jsx($,{tone:"success",children:"Online"})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2.5",children:[e.jsx(n,{label:"Uptime Proses",value:U((o==null?void 0:o.uptime_seconds)??0)}),e.jsx(n,{label:"Environment",value:(o==null?void 0:o.node_env)??"—"})]})]})]}),e.jsxs(g,{children:[e.jsx(y,{title:"Kesehatan Model",subtitle:"Ringkasan katalog & health check"}),e.jsx(N,{children:d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-4",children:[e.jsx(n,{label:"Total",value:t(d.total)}),e.jsx(n,{label:"Aktif",value:t(d.active),accent:"text-emerald-300"}),e.jsx(n,{label:"Maintenance",value:t(d.maintenance),accent:d.maintenance>0?"text-amber-300":"text-white"}),e.jsx(n,{label:"Degraded",value:t(d.degraded),accent:d.degraded>0?"text-red-300":"text-white",hint:"uptime < 99%"})]}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] font-medium",children:[e.jsx("span",{className:"text-slate-500",children:"Rata-rata uptime"}),e.jsxs("span",{className:`tabular-nums ${A}`,children:[_.toFixed(2),"%"]})]}),e.jsx("div",{className:"mt-1.5 h-2 overflow-hidden rounded-full bg-white/[0.06]",children:e.jsx("div",{className:`h-full rounded-full ${K}`,style:{width:`${Math.min(100,Math.max(0,_))}%`}})}),e.jsxs("p",{className:"mt-2 text-[10px] text-slate-500",children:[d.hidden>0&&`${d.hidden} model disembunyikan · `,"Pemeriksaan terakhir"," ",d.last_checked_at?P(d.last_checked_at):"—"]})]})]}):e.jsx("p",{className:"py-6 text-center text-xs text-slate-500",children:"Ringkasan model tidak tersedia."})})]})]}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[e.jsxs(g,{children:[e.jsx(y,{title:"Masa Aktif Key",subtitle:"Berlaku sampai dengan"}),e.jsxs(N,{children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:`text-2xl font-bold tabular-nums ${m?"text-red-300":"text-white"}`,children:k(s.expires_at)}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:s.remaining_time||"—"})]}),e.jsx($,{tone:m?"danger":"success",children:m?"Kedaluwarsa":"Masih berlaku"})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-2.5",children:[e.jsx(n,{label:"Sisa Jam",value:t(s.remaining_hours)}),e.jsx(n,{label:"Sisa Detik",value:t(s.remaining_seconds)})]})]})]}),e.jsxs(g,{children:[e.jsx(y,{title:"Kuota Sementara",subtitle:"Bonus / top-up sementara dari provider"}),e.jsx(N,{children:I?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-4",children:[e.jsx(n,{label:"Kuota",value:t((a==null?void 0:a.quota)??0)}),e.jsx(n,{label:"Terpakai",value:t((a==null?void 0:a.used)??0)}),e.jsx(n,{label:"Sisa",value:t((a==null?void 0:a.remaining_requests)??0),accent:"text-emerald-300"}),e.jsx(n,{label:"Sisa Detik",value:t((a==null?void 0:a.remaining_seconds)??0)})]}),e.jsxs("p",{className:"mt-3 text-[10px] text-slate-500",children:["Berlaku sampai"," ",a!=null&&a.expires_at?k(a.expires_at):"—"]})]}):e.jsx("p",{className:"py-6 text-center text-xs text-slate-500",children:"Tidak ada kuota sementara pada key ini."})})]})]}),e.jsxs(g,{children:[e.jsx(y,{title:"IP Terikat",subtitle:`${t(R)} dari ${t(s.max_ips)} IP diizinkan`,action:e.jsxs($,{tone:q?"warning":"default",children:[S.toFixed(0),"% terpakai"]})}),e.jsxs(N,{children:[e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-white/[0.06]",children:e.jsx("div",{className:`h-full rounded-full ${q?"bg-amber-400":"bg-brand-400"}`,style:{width:`${S}%`}})}),p.length===0?e.jsx("p",{className:"py-6 text-center text-xs text-slate-500",children:"Belum ada IP yang terikat."}):e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:p.map(v=>e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-lg border px-2.5 py-1 font-mono text-[11px] ${v.includes(":")?"border-violet-400/20 bg-violet-500/10 text-violet-200":"border-white/[0.08] bg-white/[0.03] text-slate-300"}`,children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v.includes(":")?"bg-violet-400":"bg-brand-400"}`}),v]},v))}),q&&e.jsxs("p",{className:"mt-3 text-[11px] text-amber-300/80",children:["Jumlah IP sudah mencapai ",S.toFixed(0),"% dari batas. Pertimbangkan membersihkan IP yang tidak dipakai."]})]})]}),e.jsxs(g,{children:[e.jsx(y,{title:"Detail Teknis",subtitle:"Data status dari provider (key disensor)"}),e.jsxs(N,{className:"p-0",children:[e.jsx("dl",{className:"divide-y divide-white/[0.04] md:hidden",children:[["Status",s.status],["Key",s.key_masked||"—"],["Expires At",s.expires_at?`${k(s.expires_at)} (${s.expires_at})`:"—"],["Max Requests",t(s.max_requests)],["Used Requests",t(s.used_requests)],["Total Requests (lifetime)",t(s.total_requests)],["Remaining Requests",t(s.remaining_requests)],["Quota Balance",t(s.quota_balance)],["Max Concurrency",t(s.max_concurrency)],["Active Streams",t(s.active_streams)],["Max IPs",t(s.max_ips)],["Temp Quota",t((a==null?void 0:a.quota)??0)],["Temp Used",t((a==null?void 0:a.used)??0)],["Temp Remaining Requests",t((a==null?void 0:a.remaining_requests)??0)],["Temp Remaining Seconds",t((a==null?void 0:a.remaining_seconds)??0)],["Temp Expires At",a!=null&&a.expires_at?k(a.expires_at):"—"]].map(([v,D])=>e.jsxs("div",{className:"flex items-start justify-between gap-3 px-4 py-2.5",children:[e.jsx("dt",{className:"shrink-0 text-xs text-slate-500",children:v}),e.jsx("dd",{className:"break-all text-right font-mono text-xs text-slate-200",children:D})]},v))}),e.jsx("div",{className:"hidden overflow-x-auto md:block",children:e.jsx("table",{className:"w-full min-w-[520px] text-left",children:e.jsxs("tbody",{className:"divide-y divide-white/[0.04]",children:[e.jsx(c,{label:"Status",value:s.status}),e.jsx(c,{label:"Key",value:s.key_masked||"—"}),e.jsx(c,{label:"Expires At",value:s.expires_at?`${k(s.expires_at)} (${s.expires_at})`:"—"}),e.jsx(c,{label:"Max Requests",value:t(s.max_requests)}),e.jsx(c,{label:"Used Requests",value:t(s.used_requests)}),e.jsx(c,{label:"Total Requests (lifetime)",value:t(s.total_requests)}),e.jsx(c,{label:"Remaining Requests",value:t(s.remaining_requests)}),e.jsx(c,{label:"Quota Balance",value:t(s.quota_balance)}),e.jsx(c,{label:"Max Concurrency",value:t(s.max_concurrency)}),e.jsx(c,{label:"Active Streams",value:t(s.active_streams)}),e.jsx(c,{label:"Max IPs",value:t(s.max_ips)}),e.jsx(c,{label:"Temp Quota",value:t((a==null?void 0:a.quota)??0)}),e.jsx(c,{label:"Temp Used",value:t((a==null?void 0:a.used)??0)}),e.jsx(c,{label:"Temp Remaining Requests",value:t((a==null?void 0:a.remaining_requests)??0)}),e.jsx(c,{label:"Temp Remaining Seconds",value:t((a==null?void 0:a.remaining_seconds)??0)}),e.jsx(c,{label:"Temp Expires At",value:a!=null&&a.expires_at?k(a.expires_at):"—"})]})})}),e.jsx("p",{className:"border-t border-white/[0.06] px-4 py-3 text-[10px] leading-relaxed text-slate-500",children:"Data diambil server-side memakai key provider. Key lengkap tidak pernah dikirim ke browser."})]})," "]})]})]})}export{X as default};