import{c as b,r as l,bR as N,c4 as v,p,t as c,i as a,j as e,T as t,aF as o,$ as E,B as y,a as u}from"./index-B2TpLIOm.js";import{B as S}from"./badge-CzOiaoaW.js";import{L as T}from"./loader-circle-CQ-CZxGV.js";const _=b("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);function H(){const[s,i]=l.useState(null),[r,n]=l.useState(!0),[f,j]=l.useState(!1);N()||v(E,"settings",{name:"general"}),l.useEffect(()=>{h()},[]);async function h(){try{n(!0);const d=await p.send("/api/beszel/heartbeat-status",{});i(d)}catch(d){c({title:a._({id:"SlfejT"}),description:d.message,variant:"destructive"})}finally{n(!1)}}async function g(){j(!0);try{const d=await p.send("/api/beszel/test-heartbeat",{method:"POST"});"err"in d&&!d.err?c({title:a._({id:"ukALjL"}),description:a._({id:"vEwQE4"})}):c({title:a._({id:"SlfejT"}),description:d.err??a._({id:"iJcCpo"}),variant:"destructive"})}catch(d){c({title:a._({id:"SlfejT"}),description:d.message,variant:"destructive"})}finally{j(!1)}}return e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-medium mb-2",children:e.jsx(t,{id:"n3pOeJ"})}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:e.jsx(t,{id:"eXxntW"})})]}),e.jsx(o,{className:"my-4"}),s?.enabled?e.jsx(A,{status:s,isTesting:f,sendTestHeartbeat:g}):e.jsx(I,{isLoading:r})]})}function A({status:s,isTesting:i,sendTestHeartbeat:r}){const n=i?T:_;return e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(S,{variant:"success",children:e.jsx(t,{id:"F6pfE9"})})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(m,{label:a._({id:"T3juzf"}),value:s.url??"",mono:!0}),e.jsx(m,{label:a._({id:"0Xa99f"}),value:`${s.interval}s`}),e.jsx(m,{label:a._({id:"bHXYoC"}),value:s.method??"POST"})]}),e.jsx(o,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-medium mb-1",children:e.jsx(t,{id:"he693n"})}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed mb-3",children:e.jsx(t,{id:"Swq9Dg"})}),e.jsxs(y,{type:"button",variant:"outline",className:"flex items-center gap-1.5",onClick:r,disabled:i,children:[e.jsx(n,{className:u("size-4",i&&"animate-spin")}),e.jsx(t,{id:"hE/EzR"})]})]}),e.jsx(o,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-medium mb-2",children:e.jsx(t,{id:"q9J8hC"})}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed mb-2",children:e.jsx(t,{id:"c98p8E"})}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:e.jsx(t,{id:"zyxllz",components:{0:e.jsx("code",{className:"bg-muted rounded-sm px-1 text-primary"}),1:e.jsx("code",{className:"bg-muted rounded-sm px-1 text-primary"}),2:e.jsx("code",{className:"bg-muted rounded-sm px-1 text-primary"})}})})]})]})}function I({isLoading:s}){return e.jsxs("div",{className:u("grid gap-4",s&&"animate-pulse"),children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed mb-3",children:e.jsx(t,{id:"5hIGow"})}),e.jsxs("div",{className:"grid gap-2.5",children:[e.jsx(x,{name:"HEARTBEAT_URL",description:a._({id:"UZtwkH"}),example:"https://uptime.betterstack.com/api/v1/heartbeat/xxxx"}),e.jsx(x,{name:"HEARTBEAT_INTERVAL",description:a._({id:"chIjGp"}),example:"60"}),e.jsx(x,{name:"HEARTBEAT_METHOD",description:a._({id:"bSl7Bg"}),example:"POST"})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:e.jsx(t,{id:"5fFjNP"})})]})}function m({label:s,value:i,mono:r}){return e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-0.5",children:s}),e.jsx("p",{className:u("text-sm text-muted-foreground break-all",r&&"font-mono"),children:i})]})}function x({name:s,description:i,example:r}){return e.jsxs("div",{className:"bg-muted/50 rounded-md px-3 py-2.5 grid gap-1.5",children:[e.jsx("code",{className:"text-sm font-mono text-primary font-medium leading-tight",children:s}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx(t,{id:"frYjym"})," ",e.jsx("code",{className:"font-mono",children:r})]})]})}export{H as default};
