import{r as e}from"./chunk-CilyBKbf.js";import{$ as t,A as n,C as r,E as i,H as a,O as o,S as s,T as c,V as l,W as u,c as d,d as f,ft as p,it as m,nt as h,ot as g,pt as _,q as v,rt as y,s as b,ut as x,w as S,x as C}from"./index-BlxIUgpX.js";var w=p(),T=g((0,w.jsxs)(`g`,{fillRule:`evenodd`,children:[(0,w.jsx)(`circle`,{cx:`17`,cy:`15.5`,r:`1.12`}),(0,w.jsx)(`path`,{d:`M17 17.5c-.73 0-2.19.36-2.24 1.08.5.71 1.32 1.17 2.24 1.17s1.74-.46 2.24-1.17c-.05-.72-1.51-1.08-2.24-1.08`}),(0,w.jsx)(`path`,{d:`M18 11.09V6.27L10.5 3 3 6.27v4.91c0 4.54 3.2 8.79 7.5 9.82.55-.13 1.08-.32 1.6-.55C13.18 21.99 14.97 23 17 23c3.31 0 6-2.69 6-6 0-2.97-2.16-5.43-5-5.91M11 17c0 .56.08 1.11.23 1.62-.24.11-.48.22-.73.3-3.17-1-5.5-4.24-5.5-7.74v-3.6l5.5-2.4 5.5 2.4v3.51c-2.84.48-5 2.94-5 5.91m6 4c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4`})]}),`AdminPanelSettingsOutlined`),E=g((0,w.jsx)(`path`,{d:`M10.5 4.5c.28 0 .5.22.5.5v2h6v6h2c.28 0 .5.22.5.5s-.22.5-.5.5h-2v6h-2.12c-.68-1.75-2.39-3-4.38-3s-3.7 1.25-4.38 3H4v-2.12c1.75-.68 3-2.39 3-4.38S5.76 9.8 4.01 9.12L4 7h6V5c0-.28.22-.5.5-.5m0-2C9.12 2.5 8 3.62 8 5H4c-1.1 0-1.99.9-1.99 2v3.8h.29c1.49 0 2.7 1.21 2.7 2.7s-1.21 2.7-2.7 2.7H2V20c0 1.1.9 2 2 2h3.8v-.3c0-1.49 1.21-2.7 2.7-2.7s2.7 1.21 2.7 2.7v.3H17c1.1 0 2-.9 2-2v-4c1.38 0 2.5-1.12 2.5-2.5S20.38 11 19 11V7c0-1.1-.9-2-2-2h-4c0-1.38-1.12-2.5-2.5-2.5`}),`ExtensionOutlined`),D=g((0,w.jsx)(`path`,{d:`M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8`}),`InfoOutlined`),O=e(_(),1),k=()=>{let{t:e}=l(),{verge:p,patchVerge:g}=i(),_=x(),{isAdminMode:k,isSidecarMode:A}=d(),{installServiceAndRestartCore:j}=b(),{checkUpdate:M,lastCheckUpdate:N}=S(!0),[P,F]=(0,O.useState)(``),I=(0,O.useMemo)(()=>N?new Date(N).toLocaleString():`-`,[N]);(0,O.useEffect)(()=>{o().then(e=>{let t=e.split(`
`);if(t.length>0){let e=t[0].split(`: `)[1]||``,n=t[1].split(`: `)[1]||``;e&&n.toLowerCase().startsWith(e.toLowerCase())&&(n=n.substring(e.length).trim()),F(`${e} ${n}`)}}).catch(console.error)},[]),(0,O.useEffect)(()=>{if(!p?.auto_check_update||s()!==null)return;r();let e=window.setTimeout(()=>{M().catch(console.error)},5e3);return()=>window.clearTimeout(e)},[p?.auto_check_update,M]);let L=(0,O.useCallback)(()=>{_(`/settings`)},[_]),R=(0,O.useCallback)(async()=>{if(p)try{await g({enable_auto_launch:!p.enable_auto_launch})}catch(e){console.error(`切换开机自启动状态失败:`,e)}},[p,g]),z=(0,O.useCallback)(()=>{(A||k&&A)&&j()},[A,k,j]),B=C(async()=>{try{(await M()).data?.available?(n.info(`shared.feedback.notifications.updateAvailable`,2e3),L()):n.success(`settings.components.verge.advanced.notifications.latestVersion`)}catch(e){n.error(e)}}),V=(0,O.useMemo)(()=>p?.enable_auto_launch||!1,[p]),H=(0,O.useMemo)(()=>({cursor:A||k&&A?`pointer`:`default`,textDecoration:A||k&&A?`underline`:`none`,display:`flex`,alignItems:`center`,gap:.5,"&:hover":{opacity:A||k&&A?.7:1}}),[A,k]),U=()=>k?A?(0,w.jsx)(T,{sx:{color:`primary.main`,fontSize:16},titleAccess:e(`home.components.systemInfo.badges.adminMode`)}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(T,{sx:{color:`primary.main`,fontSize:16},titleAccess:e(`home.components.systemInfo.badges.adminMode`)}),(0,w.jsx)(u,{sx:{color:`success.main`,fontSize:16,ml:.5},titleAccess:e(`home.components.systemInfo.badges.serviceMode`)})]}):A?(0,w.jsx)(E,{sx:{color:`info.main`,fontSize:16},titleAccess:e(`home.components.systemInfo.badges.sidecarMode`)}):(0,w.jsx)(u,{sx:{color:`success.main`,fontSize:16},titleAccess:e(`home.components.systemInfo.badges.serviceMode`)}),W=()=>e(k?A?`home.components.systemInfo.badges.adminMode`:`home.components.systemInfo.badges.adminServiceMode`:A?`home.components.systemInfo.badges.sidecarMode`:`home.components.systemInfo.badges.serviceMode`);return p?(0,w.jsx)(f,{title:e(`home.components.systemInfo.title`),icon:(0,w.jsx)(D,{}),iconColor:`error`,action:(0,w.jsx)(m,{size:`small`,onClick:L,title:e(`home.components.systemInfo.actions.settings`),children:(0,w.jsx)(a,{fontSize:`small`})}),children:(0,w.jsxs)(v,{spacing:1.5,children:[(0,w.jsxs)(v,{direction:`row`,sx:{justifyContent:`space-between`},children:[(0,w.jsx)(y,{variant:`body2`,color:`text.secondary`,children:e(`home.components.systemInfo.fields.osInfo`)}),(0,w.jsx)(y,{variant:`body2`,sx:{fontWeight:`medium`},children:P})]}),(0,w.jsx)(t,{}),(0,w.jsxs)(v,{direction:`row`,sx:{justifyContent:`space-between`,alignItems:`center`},children:[(0,w.jsx)(y,{variant:`body2`,color:`text.secondary`,children:e(`home.components.systemInfo.fields.autoLaunch`)}),(0,w.jsx)(v,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:(0,w.jsx)(h,{size:`small`,label:e(V?`shared.statuses.enabled`:`shared.statuses.disabled`),color:V?`success`:`default`,variant:V?`filled`:`outlined`,onClick:R,sx:{cursor:`pointer`}})})]}),(0,w.jsx)(t,{}),(0,w.jsxs)(v,{direction:`row`,sx:{justifyContent:`space-between`,alignItems:`center`},children:[(0,w.jsx)(y,{variant:`body2`,color:`text.secondary`,children:e(`home.components.systemInfo.fields.runningMode`)}),(0,w.jsxs)(y,{variant:`body2`,onClick:z,sx:{...H,fontWeight:`medium`},children:[U(),W()]})]}),(0,w.jsx)(t,{}),(0,w.jsxs)(v,{direction:`row`,sx:{justifyContent:`space-between`},children:[(0,w.jsx)(y,{variant:`body2`,color:`text.secondary`,children:e(`home.components.systemInfo.fields.lastCheckUpdate`)}),(0,w.jsx)(y,{variant:`body2`,onClick:B,sx:{cursor:`pointer`,textDecoration:`underline`,fontWeight:`medium`,"&:hover":{opacity:.7}},children:I})]}),(0,w.jsx)(t,{}),(0,w.jsxs)(v,{direction:`row`,sx:{justifyContent:`space-between`},children:[(0,w.jsx)(y,{variant:`body2`,color:`text.secondary`,children:e(`home.components.systemInfo.fields.vergeVersion`)}),(0,w.jsxs)(y,{variant:`body2`,sx:{fontWeight:`medium`},children:[`v`,c]})]})]})}):null};export{k as SystemInfoCard};