dns-worker 1.2.4 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/serverfull.mjs +159 -251
- package/dist/serverfull.mjs.map +4 -4
- package/migrations/0070_add_list_stats_metadata.sql +2 -0
- package/package.json +5 -5
- package/static/assets/{AccountView-DWLPLl2r.js → AccountView-DilMdIu2.js} +4 -4
- package/static/assets/AnalyticsView-mYuaq2d3.js +2 -0
- package/static/assets/{DestinationMap-BFN0JDey.js → DestinationMap-DfE-_-qj.js} +1 -1
- package/static/assets/FilteringView-Rla6nBYN.js +1 -0
- package/static/assets/LogsView-Bi5St4cR.js +5 -0
- package/static/assets/{RulesView-Cdq10tRc.js → RulesView-FQHhXpVf.js} +1 -1
- package/static/assets/SettingsView-gLzsNIju.js +1 -0
- package/static/assets/{SetupView-CLixnmKc.js → SetupView-BUA7BYMb.js} +1 -1
- package/static/assets/{SwipeableDrawer-UY1QWnPj.js → SwipeableDrawer-BHXXZw7l.js} +1 -1
- package/static/assets/SystemView-BbOt5twD.js +1 -0
- package/static/assets/{TrendChart-DAMeH8DG.js → TrendChart-Kzctv9EA.js} +3 -3
- package/static/assets/allPaths-a_Gma8ca.js +1 -0
- package/static/assets/allPathsLoader-sY5nfYNE.js +1 -0
- package/static/assets/browser-xdENJ9hN.js +1 -0
- package/static/assets/date-CuEX0HAJ.js +1 -0
- package/static/assets/de-DE-sdqvOhE2.js +25 -0
- package/static/assets/es-ES-CZMRaxMw.js +25 -0
- package/static/assets/fr-FR-2IQyivXi.js +25 -0
- package/static/assets/index-CxK16i2C.js +30 -0
- package/static/assets/index-frQljXGb.css +2 -0
- package/static/assets/ja-JP-CuCkEZDz.js +25 -0
- package/static/assets/{ko-KR--ebX4PUe.js → ko-KR-CWUU7L79.js} +1 -1
- package/static/assets/ru-RU-DnuUcJXU.js +25 -0
- package/static/assets/services-B-Y_EKlc.js +1 -0
- package/static/assets/splitPathsBySizeLoader-CagJEoij.js +1 -0
- package/static/assets/{sqlite.worker-BQk-r3bK.js → sqlite.worker-RAW9CPiV.js} +2 -2
- package/static/assets/{useLogsE2ee-C5IGsZNu.js → useLogsE2ee-BEETAe5O.js} +1 -1
- package/static/assets/vendor-i18next-J2aoF7F1.js +1 -0
- package/static/assets/{vendor-icons-other-BTYC6Wvz.js → vendor-icons-other-kRhgWBno.js} +2 -2
- package/static/assets/vendor-react-R4_BUhus.js +11 -0
- package/static/assets/vendor-ui-core-CKSrm0Y8.js +1 -0
- package/static/assets/{vendor-utils-Bab4qB3W.js → vendor-utils-y3vK_J_u.js} +1 -1
- package/static/assets/vi-VN-Cyv4XVb4.js +25 -0
- package/static/assets/zh-CN-BFVuQTvF.js +25 -0
- package/static/assets/zh-TW-y_EkxxXD.js +25 -0
- package/static/index.html +7 -7
- package/static/assets/AnalyticsView-DOZ_4PlV.js +0 -2
- package/static/assets/FilteringView-YlS6S19l.js +0 -1
- package/static/assets/LogsView-C5on_f9X.js +0 -5
- package/static/assets/SettingsView-D8Q09eFj.js +0 -1
- package/static/assets/SystemView-0acjSWwE.js +0 -1
- package/static/assets/allPaths-ZKIw3HqD.js +0 -1
- package/static/assets/allPathsLoader-CvGx1ejI.js +0 -1
- package/static/assets/browser-D1bxqOmO.js +0 -1
- package/static/assets/date-Mn7JuCwI.js +0 -1
- package/static/assets/de-DE-ChqTmNoZ.js +0 -25
- package/static/assets/es-ES-DJyD_FHe.js +0 -25
- package/static/assets/fr-FR-BA1vQe8U.js +0 -25
- package/static/assets/index-BlF_HYXE.css +0 -2
- package/static/assets/index-C--PEfmU.js +0 -30
- package/static/assets/ja-JP-ndkxicCP.js +0 -25
- package/static/assets/ru-RU-DOZjzIx2.js +0 -25
- package/static/assets/services-DTfjQuNl.js +0 -1
- package/static/assets/splitPathsBySizeLoader-htHoS0DT.js +0 -1
- package/static/assets/vendor-i18next-DlmslyBB.js +0 -1
- package/static/assets/vendor-react-DYK5a2J9.js +0 -11
- package/static/assets/vendor-ui-core-CodM8CpF.js +0 -1
- package/static/assets/vi-VN-DgVTajq8.js +0 -25
- package/static/assets/zh-CN-C_Po-z3K.js +0 -25
- package/static/assets/zh-TW-C4h6ckgV.js +0 -25
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{At as t,B as n,D as r,F as i,J as a,L as o,M as s,P as c,R as l,T as u,U as d,V as f,X as p,ct as m,ft as h,it as g,kt as _,nn as v,ot as y,q as b,st as x,w as S}from"./vendor-react-DYK5a2J9.js";import{S as C,b as w}from"./vendor-icons-other-BTYC6Wvz.js";import"./vendor-i18next-DlmslyBB.js";import{B as T,C as E,E as D,F as O,H as k,I as A,N as j,P as M,R as N,V as P,a as F,d as I,f as L,i as R,j as z,k as B,n as V,o as H,r as U,v as W,z as G}from"./vendor-ui-core-CodM8CpF.js";import{_t as K,t as ee,vt as q}from"./vendor-utils-Bab4qB3W.js";import{$ as te,Ct as ne,U as re,W as ie,X as ae,Y as oe,Z as J,_n as se,a as ce,g as le,ht as ue,n as Y,pt as de,t as fe,tt as pe,ut as me,v as he,wt as ge}from"./index-C--PEfmU.js";import{t as _e}from"./SwipeableDrawer-UY1QWnPj.js";var X=e(C(),1),Z=e(w(),1);const ve=()=>{let{t:e}=v();return(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(z,{className:`font-bold text-gray-900 dark:text-white m-0`,children:e(`setup.title`)}),(0,Z.jsx)(`p`,{className:`bp6-text-muted m-0 mt-1`,children:e(`setup.subtitle`)})]}),(0,Z.jsx)(`div`,{className:`flex items-center`,children:(0,Z.jsx)(fe,{})})]})},ye=({isVerifying:e,verifyResult:n,handleVerify:r,isMobile:i,clientInfo:a,showIp:o,setShowIp:l,showLocation:u,setShowLocation:d,traceInfo:f,edgeLocation:m})=>{let{t:h}=v(),{isServerfull:_}=Y(),[b,S]=(0,X.useState)(!1),C=(0,Z.jsxs)(`div`,{className:q(`bg-white dark:bg-gray-900 p-4 rounded-lg border border-gray-100 dark:border-gray-800 shadow-sm flex items-start gap-3 select-none h-full transition-all`,!_),children:[(0,Z.jsx)(c,{size:18,className:`text-purple-500 mt-1 shrink-0`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-40`,children:_?h(`setup.serverLocation`,`服务器位置`):h(`setup.edgeServer`)}),(0,Z.jsx)(`div`,{className:`font-bold truncate`,title:_?m||``:m||f?.colo||``,children:_?m||h(`setup.detecting`):m||f?.colo||h(`setup.detecting`)})]})]});return(0,Z.jsx)(H,{title:h(`setup.verifyConnection`),icon:(0,Z.jsx)(t,{size:16}),children:(0,Z.jsx)(F,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col md:flex-row items-center justify-between bg-gray-50 dark:bg-gray-800/50 p-6 rounded-xl border border-gray-100 dark:border-gray-800 gap-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col md:flex-row items-center gap-4 text-center md:text-left`,children:[(0,Z.jsx)(`div`,{className:`p-3 rounded-full ${n?.success?`bg-green-100 text-green-600`:n?`bg-red-100 text-red-600`:`bg-blue-100 text-blue-600`}`,children:e?(0,Z.jsx)(O,{size:24}):n?.success?(0,Z.jsx)(s,{size:24}):(0,Z.jsx)(c,{size:24})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-bold text-lg`,children:e?h(`setup.verifying`):n?.success?h(`setup.connected`):h(`setup.notConnected`)}),(0,Z.jsx)(`div`,{className:`text-sm opacity-60`,children:n?.success?n.profileMatch?h(`setup.profileMatch`):h(`setup.profileMismatch`):h(`setup.verifyHint`)})]})]}),(0,Z.jsx)(M,{size:`large`,intent:n?.success?k.SUCCESS:k.PRIMARY,icon:`refresh`,text:h(`setup.refreshStatus`),onClick:r,loading:e,fill:i})]}),a&&(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4`,children:[(0,Z.jsxs)(`div`,{className:`bg-white dark:bg-gray-900 p-4 rounded-lg border border-gray-100 dark:border-gray-800 shadow-sm flex items-start gap-3`,children:[(0,Z.jsx)(g,{size:18,className:`text-blue-500 mt-1`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-40`,children:h(`setup.egressIp`)}),(0,Z.jsx)(`button`,{onClick:()=>l(!o),className:`text-gray-400 hover:text-blue-500 transition-colors`,children:o?(0,Z.jsx)(y,{size:16}):(0,Z.jsx)(x,{size:16})})]}),(0,Z.jsx)(`div`,{className:`font-mono font-bold text-blue-600 dark:text-blue-400 truncate`,children:(0,Z.jsx)(`span`,{className:q(`transition-[filter] duration-200 inline-block`,!o&&`filter blur-[6px] select-none`),children:a.ip})})]})]}),(0,Z.jsxs)(`div`,{className:`bg-white dark:bg-gray-900 p-4 rounded-lg border border-gray-100 dark:border-gray-800 shadow-sm flex items-start gap-3`,children:[(0,Z.jsx)(p,{size:18,className:`text-red-500 mt-1`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-40`,children:h(`setup.currentLocation`)}),(0,Z.jsx)(`button`,{onClick:()=>d(!u),className:`text-gray-400 hover:text-red-500 transition-colors`,children:u?(0,Z.jsx)(y,{size:16}):(0,Z.jsx)(x,{size:16})})]}),(0,Z.jsx)(`div`,{className:`font-bold truncate`,children:(0,Z.jsx)(`span`,{className:q(`transition-[filter] duration-200 inline-block`,!u&&`filter blur-[6px] select-none`),children:(()=>{let e=[a.city,a.region,a.country].filter(e=>!!(e&&e!==`UNKNOWN`));return e.length>0?e.join(`, `):h(`setup.detecting`)})()})})]})]}),_?C:(0,Z.jsx)(D,{isOpen:b,onInteraction:S,placement:`bottom-end`,portalClassName:`z-20000`,fill:!0,targetProps:{className:`h-full`},content:(0,Z.jsxs)(`div`,{className:`p-3 select-text w-72 sm:w-80 max-w-[85vw] space-y-2`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-mono font-bold text-gray-500 dark:text-gray-400 tracking-wide border-b border-gray-100 dark:border-gray-800 pb-1.5`,children:`/cdn-cgi/trace`}),(0,Z.jsx)(`pre`,{className:`m-0 font-mono text-xs leading-relaxed whitespace-pre-wrap break-all overflow-x-hidden max-h-64 overflow-y-auto text-gray-800 dark:text-gray-200`,children:f?.raw||h(`setup.noTraceData`,`暂无 Trace 数据`)})]}),children:C})]})]})})})},Q=({step:e,className:t,size:n=144})=>{let r=e===1?47:50,i=e===1?45.5:45;return(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:K(`absolute -top-7 -left-7 pointer-events-none select-none z-0`,`text-blue-600/[0.08] dark:text-blue-400/[0.12]`,`transition-all duration-500 ease-out`,`blur-none group-hover:blur-md group-hover:opacity-0`,t),style:{width:n,height:n},children:(0,Z.jsxs)(`svg`,{viewBox:`0 0 100 100`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:`w-full h-full`,children:[(0,Z.jsx)(`circle`,{cx:`50`,cy:`50`,r:`46`,stroke:`currentColor`,strokeWidth:`4`}),(0,Z.jsx)(`text`,{x:r,y:i,textAnchor:`middle`,dominantBaseline:`central`,fill:`currentColor`,fontSize:`80`,fontWeight:`900`,fontFamily:`'Helvetica Neue', Helvetica, Arial, sans-serif`,children:e})]})})},be=({accessPoints:e,selectedApId:t,onSelectAp:n,accessPointName:r,onManageAccessPoints:o,isMobile:s})=>{let{t:c}=v();return(0,Z.jsxs)(H,{title:c(`setup.accessPointsCardTitle`,`接入点`),icon:(0,Z.jsx)(a,{size:16}),className:`group relative overflow-hidden [&_.bp6-section-header]:relative [&_.bp6-section-header]:z-10 [&_.bp6-section-card]:relative [&_.bp6-section-card]:z-10`,children:[(0,Z.jsx)(Q,{step:1}),(0,Z.jsx)(F,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 w-full sm:w-auto`,children:[(0,Z.jsx)(`span`,{className:`text-xs opacity-50 font-medium`,children:c(`setup.selectAccessPointToConfigure`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.length>0?(0,Z.jsx)(I,{value:t||``,onChange:e=>n(e.target.value),options:e.map(e=>({label:e.name,value:e.id})),className:`font-semibold text-gray-900 dark:text-gray-100`}):(0,Z.jsx)(`div`,{className:`font-semibold text-gray-900 dark:text-gray-100 flex items-center gap-2`,children:r||c(`setup.defaultAccessPointName`,`设备-1`)}),e.length>0&&(0,Z.jsx)(U,{minimal:!0,round:!0,intent:k.PRIMARY,className:`text-xs`,children:e.length})]})]}),(0,Z.jsx)(M,{variant:`outlined`,intent:k.NONE,icon:(0,Z.jsx)(i,{size:14}),text:c(`setup.manageAccessPoints`,`管理接入点`),onClick:o,fill:s,className:`shrink-0`})]})})]})},xe=({dohUrl:e,copyToClipboard:t,isMobile:n,flashTrigger:r=0})=>{let{t:i}=v();return(0,Z.jsxs)(H,{title:i(`setup.accessPointTitle`,`Access DoH URL`),icon:`globe`,className:`group relative overflow-hidden [&_.bp6-section-header]:relative [&_.bp6-section-header]:z-10 [&_.bp6-section-card]:relative [&_.bp6-section-card]:z-10`,rightElement:(0,Z.jsx)(D,{placement:`bottom-end`,usePortal:!0,content:(0,Z.jsxs)(`div`,{className:`p-4 max-w-sm`,children:[(0,Z.jsx)(j,{children:i(`setup.whatIsDoh`)}),(0,Z.jsx)(`p`,{className:`text-sm mb-2`,children:i(`setup.dohDesc`)}),(0,Z.jsxs)(`ul`,{className:`list-disc list-inside text-sm opacity-80 mb-3 space-y-1`,children:[(0,Z.jsx)(`li`,{children:i(`setup.dohBenefit1`)}),(0,Z.jsx)(`li`,{children:i(`setup.dohBenefit2`)})]}),(0,Z.jsx)(`div`,{className:`text-xs border-t border-gray-100 dark:border-gray-700 pt-2`,children:(0,Z.jsxs)(`a`,{href:`https://en.wikipedia.org/wiki/DNS_over_HTTPS`,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-1 text-blue-500 hover:underline`,children:[(0,Z.jsx)(m,{size:10}),` `,i(`setup.learnMore`)]})})]}),children:(0,Z.jsx)(M,{icon:`help`,variant:`minimal`,intent:k.NONE})}),children:[(0,Z.jsx)(Q,{step:2}),(0,Z.jsx)(F,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,Z.jsx)(`div`,{className:`w-full bg-gray-100 dark:bg-gray-800 px-4 py-4 sm:px-6 sm:py-5 rounded-lg border border-gray-200 dark:border-gray-700 flex items-center justify-center ${r>0?`animate-box-glow`:``}`,children:(0,Z.jsx)(`span`,{className:`font-mono text-sm sm:text-base font-medium text-center text-blue-600 dark:text-blue-400 break-all select-all`,children:e})},r),(0,Z.jsx)(`div`,{className:`w-full flex justify-center`,children:(0,Z.jsx)(M,{intent:k.PRIMARY,icon:`duplicate`,text:i(`setup.copyUrl`),fill:n,onClick:()=>t(e),className:`shrink-0 whitespace-nowrap min-w-fit`})})]})})]})};function $(e){let t=e.trim();try{return new URL(t.startsWith(`http://`)||t.startsWith(`https://`)?t:`https://${t}`).hostname||t}catch{return t.replace(/^https?:\/\//,``).split(`/`)[0].split(`:`)[0]||t}}function Se(e,t){let n=(e||``).trim(),r=(t||``).trim();if(!r&&n.includes(`(`)&&n.endsWith(`)`)){let e=n.match(/^(.+?)\s*\((.+?)\)$/);e&&(n=e[1].trim(),r=e[2].trim())}let i=n&&n!==`DNS Worker`?n:``,a=r&&r!==`DNS Worker`?r:``;return i&&a?i.toLowerCase()===a.toLowerCase()?i:`${i} - ${a}`:i||a||``}function Ce(e,t,n,r){let i,a,o,s;typeof e==`object`?(i=e.profileKey,a=e.profileName,o=e.accessPointName,s=e.origin):(i=e,a=t,s=n||``,o=r);let c=s.trim(),l=$(c),u=`${c}/${i}`,d=Se(a,o),f=crypto.randomUUID(),p=crypto.randomUUID(),m=d?`DNS Worker - ${l} (${d})`:`DNS Worker (${l})`,h=d?`DNS Worker DoH - ${l} (${d})`:`DNS Worker DoH - ${l}`,g=d?`DNS Worker DoH configuration profile for ${d} via ${l}`:`DNS Worker DoH configuration profile via ${l}`,_=d?`Configures encrypted DNS over HTTPS (DoH) for ${d} via ${l}`:`Configures encrypted DNS over HTTPS (DoH) via ${l}`;return ee({PayloadContent:[{DNSSettings:{DNSProtocol:`HTTPS`,ServerHTTPVersion:3,ServerURL:u},OnDemandRules:[{Action:`Connect`,InterfaceTypeMatch:`WiFi`},{Action:`Connect`,InterfaceTypeMatch:`Cellular`},{Action:`Disconnect`}],PayloadDescription:_,PayloadDisplayName:h,PayloadIdentifier:`com.apple.dnsSettings.managed.${f}`,PayloadName:h,PayloadType:`com.apple.dnsSettings.managed`,PayloadUUID:f,PayloadVersion:1}],PayloadDescription:g,PayloadDisplayName:m,PayloadIdentifier:`com.dnsworker.profile.${i}`,PayloadName:m,PayloadRemovalDisallowed:!1,PayloadType:`Configuration`,PayloadUUID:p,PayloadVersion:1},{indent:` `})}const we=({isMobile:e,copyToClipboard:t,profileKey:n,profileName:i,accessPointName:a,currentIps:o,dotDomain:s})=>{let{t:c}=v(),{isCloudflare:d}=Y();return(0,Z.jsxs)(`div`,{className:`group relative overflow-hidden rounded-xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm`,children:[(0,Z.jsx)(Q,{step:3}),(0,Z.jsxs)(V,{id:`setup-tabs`,renderActiveTabPanelOnly:!0,vertical:!e,size:`large`,className:K(`p-4 md:p-6 setup-tabs-container relative z-10 bg-transparent`,e&&[`[&_.bp6-tab-list]:overflow-x-auto!`,`[&_.bp6-tab-list]:flex-nowrap!`,`[&_.bp6-tab-list]:pb-1`,`[&_.bp6-tab-list]:scrollbar-none`,`[&_.bp6-tab-list]:[-ms-overflow-style:none]`,`[&_.bp6-tab-list::-webkit-scrollbar]:hidden`,`[&_.bp6-tab]:shrink-0`]),children:[(0,Z.jsx)(R,{id:`browsers`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(g,{size:16,className:`inline mr-2`}),c(`setup.browsers`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:c(`setup.browserTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:c(`setup.browserSteps`)}),(0,Z.jsx)(`p`,{className:`text-[10px] opacity-50 cursor-pointer`,onClick:()=>t(`chrome://settings/security`),children:c(`setup.browserTips`,`or copy this URL to the address bar: `)+`chrome://settings/security`})]})}),(0,Z.jsx)(R,{id:`apple`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(_,{size:16,className:`inline mr-2`}),c(`setup.apple`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:c(`setup.appleTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:c(`setup.appleDesc`)}),(0,Z.jsx)(`p`,{className:`text-[10px] opacity-50 text-center`,children:c(`setup.appleWarning`)}),(0,Z.jsxs)(`div`,{className:`p-6 bg-gray-50 dark:bg-gray-800 rounded-xl border border-dashed border-gray-300 dark:border-gray-700 flex flex-col items-center justify-center`,children:[(0,Z.jsx)(A,{icon:`document`,size:40,className:`opacity-20 mb-4`}),(0,Z.jsx)(M,{intent:k.PRIMARY,text:c(`setup.downloadConfig`),icon:`download`,onClick:()=>{let e=Ce({profileKey:n,profileName:i,accessPointName:a,origin:window.location.origin}),t=new Blob([e],{type:`application/x-apple-aspen-config`}),r=URL.createObjectURL(t),o=document.createElement(`a`);o.href=r;let s=Se(i,a),c=$(window.location.origin);o.download=`dns_worker-${(s||c).replace(/[^a-zA-Z0-9_\-\u4e00-\u9fa5]/g,`_`).replace(/_+/g,`_`).replace(/^_|_$/g,``)}-${n}.mobileconfig`,o.click(),URL.revokeObjectURL(r)}})]}),(0,Z.jsx)(`p`,{className:`text-[10px] opacity-50 mt-4! text-center`,children:c(`setup.appleInstallHint`)})]})}),(0,Z.jsx)(R,{id:`windows`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(b,{size:16,className:`inline mr-2`}),c(`setup.windows`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:c(`setup.windowsTitle`)}),(0,Z.jsxs)(`ol`,{className:`list-decimal list-inside space-y-4 text-sm leading-relaxed`,children:[(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`a`,{href:`ms-settings:network-status`,children:c(`setup.windowsStep0`)})}),(0,Z.jsx)(`li`,{children:c(`setup.windowsStep1`)}),(0,Z.jsxs)(`li`,{children:[c(`setup.windowsStep2`),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:o.map(e=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(U,{minimal:!0,interactive:!0,onClick:()=>t(e.ip),icon:`duplicate`,className:`font-mono`,children:e.ip}),(0,Z.jsx)(`span`,{className:`text-[9px] opacity-50 ml-1 font-mono`,children:e.area})]},e.ip))})]}),(0,Z.jsx)(`li`,{children:c(`setup.windowsStep3`)}),(0,Z.jsx)(`li`,{children:c(`setup.windowsStep4`)})]})]})}),(0,Z.jsx)(R,{id:`linux`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(u,{size:16,className:`inline mr-2`}),c(`setup.linux`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:c(`setup.linuxTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:c(`setup.linuxDesc`)}),(0,Z.jsxs)(`div`,{className:`mt-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-bold mb-2`,children:c(`setup.linuxStep1`)}),(0,Z.jsxs)(`div`,{className:`relative group`,children:[(0,Z.jsx)(`pre`,{className:`bg-gray-100 dark:bg-gray-800 p-4 rounded-lg overflow-x-auto text-xs font-mono border border-gray-200 dark:border-gray-700`,children:(0,Z.jsx)(`code`,{children:`curl -sL "${window.location.origin}/setup.sh?key=${n}&origin=${window.location.origin}" | sudo bash`})}),(0,Z.jsx)(M,{className:`absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity`,icon:`duplicate`,minimal:!0,small:!0,onClick:()=>{t(`curl -sL "${window.location.origin}/setup.sh?key=${n}&origin=${window.location.origin}" | sudo bash`)}})]})]}),(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(`p`,{className:`text-sm font-bold`,children:c(`setup.linuxStep2`)})})]})}),(0,Z.jsx)(R,{id:`routeros`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(l,{size:16,className:`inline mr-2`}),c(`setup.routeros`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:c(`setup.routerosTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:c(`setup.routerosDesc`)}),(0,Z.jsxs)(`div`,{className:`mt-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-bold mb-2`,children:c(`setup.routerosStep1`)}),(0,Z.jsxs)(`div`,{className:`relative group`,children:[(0,Z.jsx)(`pre`,{className:`bg-gray-100 dark:bg-gray-800 p-4 rounded-lg overflow-x-auto text-xs font-mono border border-gray-200 dark:border-gray-700`,children:(0,Z.jsx)(`code`,{children:`/ip dns set use-doh-server="${window.location.origin}/${n}" verify-doh-cert=yes`})}),(0,Z.jsx)(M,{className:`absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity`,icon:`duplicate`,minimal:!0,small:!0,onClick:()=>{t(`/ip dns set use-doh-server="${window.location.origin}/${n}" verify-doh-cert=yes`)}})]})]}),(0,Z.jsx)(`p`,{className:`text-sm`,children:c(`setup.routerosNote`)}),(0,Z.jsxs)(`a`,{href:`https://help.mikrotik.com/docs/spaces/ROS/pages/37748767/DNS`,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-1 text-xs text-blue-500 hover:underline`,children:[(0,Z.jsx)(m,{size:10}),` `,c(`setup.routerosDocs`)]})]})}),(0,Z.jsx)(R,{id:`android`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(r,{size:16,className:`inline mr-2`}),c(`setup.android`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:c(`setup.androidTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:c(`setup.androidDesc`)}),d?(0,Z.jsxs)(E,{intent:k.WARNING,icon:`warning-sign`,className:`text-xs`,children:[(0,Z.jsx)(`div`,{className:`font-semibold mb-1`,children:c(`setup.dotUnavailableCfTitle`)}),(0,Z.jsx)(`div`,{children:c(`setup.dotUnavailableCfDesc`)})]}):(()=>{let e=/^(\d{1,3}\.){3}\d{1,3}$/.test(window.location.hostname)||window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`||window.location.hostname.includes(`:`),r=(s||``).trim().replace(/^\*\./,``),i=!J(r)&&r||(e?``:window.location.hostname);return(0,Z.jsxs)(`div`,{className:`p-4 bg-gray-50 dark:bg-gray-800/60 rounded-xl border border-gray-200 dark:border-gray-700 space-y-3`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold text-gray-700 dark:text-gray-300`,children:c(`setup.androidDotTitle`,`私有 DNS (DoT / DoQ)`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c(`setup.androidDotDesc`,`支持 Android 原生“私有 DNS (DoT)”及各类现代 DoQ 客户端。提供商主机名:`)}),i?(0,Z.jsx)(`div`,{className:`space-y-3 pt-1`,children:(0,Z.jsx)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-1.5 sm:gap-2`,children:(0,Z.jsx)(U,{minimal:!0,interactive:!0,onClick:()=>t(`${n}.${i}`),icon:`duplicate`,className:`font-mono text-xs sm:text-sm py-1 px-3 self-start`,intent:k.PRIMARY,children:`${n}.${i}`})})}):(0,Z.jsx)(E,{intent:k.WARNING,icon:`warning-sign`,className:`text-xs`,children:c(`setup.androidIpNotice`,`检测到当前通过 IP 或本地地址访问面板。DoT / DoQ 仅接受域名,请在 .env 中配置 SERVERFULL_DOT_DOMAIN (例如 dns.example.com) 后刷新。`)})]})})(),!d&&(0,Z.jsx)(E,{intent:k.PRIMARY,icon:`info-sign`,className:`text-xs`,children:c(`setup.androidWarning`)})]})})]})]})};function Te({profileId:e,accessPoints:t,onRefresh:n,toasterRef:r}){let{t:i}=v(),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(!1),[_,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(null),[O,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(``);return{isAddDialogOpen:a,setIsAddDialogOpen:o,newApName:s,setNewApName:c,isAdding:l,renameApId:d,setRenameApId:f,renameApName:p,setRenameApName:m,isRenaming:h,rotatingApId:_,deletingApId:b,newApNameFocused:S,setNewApNameFocused:C,renameApNameFocused:w,setRenameApNameFocused:T,rotateConfirmApId:E,setRotateConfirmApId:D,isSearchOpen:O,setIsSearchOpen:A,searchQuery:j,setSearchQuery:M,filteredAccessPoints:t.filter(e=>e.name.toLowerCase().includes(j.toLowerCase())||e.token.toLowerCase().includes(j.toLowerCase())),isValidApName:e=>ce.test(e),handleAdd:async()=>{let a=s.trim();if(a){if(t.some(e=>e.name.toLowerCase()===a.toLowerCase())){r.current?.show({message:i(`setup.accessPointNameExists`,`Access Point name already exists`),intent:k.DANGER});return}u(!0);try{await pe(e,a),r.current?.show({message:i(`setup.accessPointCreated`),intent:k.SUCCESS}),o(!1),c(``),n()}catch(e){let t=e.message||`Failed to create access point`,n=t;if(t.startsWith(`Access point limit exceeded`)){let e=t.match(/\(max (\d+)\)/),r=e?e[1]:`100`;n=i(`setup.accessPointLimitExceeded`,{max:r,defaultValue:`Access Point limit exceeded (max ${r})`})}r.current?.show({message:n,intent:k.DANGER})}finally{u(!1)}}},handleRename:async()=>{let a=p.trim();if(!(!a||!d)){if(t.some(e=>e.id!==d&&e.name.toLowerCase()===a.toLowerCase())){r.current?.show({message:i(`setup.accessPointNameExists`,`Access Point name already exists`),intent:k.DANGER});return}g(!0);try{await ne(e,d,a),r.current?.show({message:i(`setup.accessPointRenamed`),intent:k.SUCCESS}),f(null),n()}catch(e){r.current?.show({message:e.message||`Failed to rename access point`,intent:k.DANGER})}finally{g(!1)}}},handleRotate:async t=>{y(t);try{await ge(e,t),r.current?.show({message:i(`setup.tokenRotated`),intent:k.SUCCESS}),n()}catch(e){console.error(e)}finally{y(null)}},handleDelete:async t=>{if(confirm(i(`setup.deleteAccessPointConfirm`))){x(t);try{await me(e,t),r.current?.show({message:i(`setup.accessPointDeleted`),intent:k.SUCCESS}),n()}catch(e){console.error(e)}finally{x(null)}}}}}const Ee=({isOpen:e,onClose:t,newApName:n,setNewApName:r,newApNameFocused:i,setNewApNameFocused:a,handleAdd:o,isAdding:s,isValidApName:c})=>{let{t:l}=v();return(0,Z.jsxs)(B,{isOpen:e,onClose:t,title:l(`setup.addAccessPoint`),children:[(0,Z.jsx)(`div`,{className:N,children:(0,Z.jsx)(W,{content:l(`setup.accessPointNameFormatTip`,`1-30 characters, letters, numbers, hyphens and underscores allowed`),isOpen:i,position:P.TOP,intent:k.PRIMARY,className:`w-full`,children:(0,Z.jsx)(`div`,{className:`w-full block`,children:(0,Z.jsx)(L,{autoFocus:!0,large:!0,placeholder:l(`setup.accessPointName`),value:n,onChange:e=>r(e.target.value),onFocus:()=>a(!0),onBlur:()=>a(!1)})})})}),(0,Z.jsx)(`div`,{className:G,children:(0,Z.jsxs)(`div`,{className:T,children:[(0,Z.jsx)(M,{onClick:t,children:l(`common.cancel`,`Cancel`)}),(0,Z.jsx)(M,{intent:k.PRIMARY,onClick:o,loading:s,disabled:!c(n),children:l(`common.create`)})]})})]})},De=({isOpen:e,onClose:t,renameApName:n,setRenameApName:r,renameApNameFocused:i,setRenameApNameFocused:a,handleRename:o,isRenaming:s,isValidApName:c})=>{let{t:l}=v();return(0,Z.jsxs)(B,{isOpen:e,onClose:t,title:l(`setup.renameAccessPoint`),children:[(0,Z.jsx)(`div`,{className:N,children:(0,Z.jsx)(W,{content:l(`setup.accessPointNameFormatTip`,`1-30 characters, letters, numbers, hyphens and underscores allowed`),isOpen:i,position:P.TOP,intent:k.PRIMARY,className:`w-full`,children:(0,Z.jsx)(`div`,{className:`w-full block`,children:(0,Z.jsx)(L,{autoFocus:!0,large:!0,placeholder:l(`setup.accessPointName`),value:n,onChange:e=>r(e.target.value),onFocus:()=>a(!0),onBlur:()=>a(!1)})})})}),(0,Z.jsx)(`div`,{className:G,children:(0,Z.jsxs)(`div`,{className:T,children:[(0,Z.jsx)(M,{onClick:t,children:l(`common.cancel`,`Cancel`)}),(0,Z.jsx)(M,{intent:k.PRIMARY,onClick:o,loading:s,disabled:!c(n),children:l(`common.save`)})]})})]})},Oe=({ap:e,totalApCount:t,toasterRef:r,onRenameTrigger:i,rotateConfirmApId:o,setRotateConfirmApId:s,rotatingApId:c,handleRotate:l,deletingApId:u,handleDelete:f})=>{let{t:p}=v();return(0,Z.jsx)(H,{title:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(a,{size:16}),(0,Z.jsx)(`span`,{children:e.name})]}),className:`shadow-none! rounded-lg!`,children:(0,Z.jsxs)(F,{children:[(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-xs opacity-50 mt-1`,children:`DoH URL`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-mono bg-blue-50 text-blue-600 dark:bg-blue-900/20 dark:text-blue-400 px-2 py-1 rounded cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-900/40 transition-colors break-all`,onClick:()=>{navigator.clipboard.writeText(`${window.location.origin}/${e.token}`),r.current?.show({message:p(`setup.copied`),intent:k.SUCCESS})},title:p(`setup.copyUrl`),children:[(0,Z.jsx)(`span`,{className:`select-all`,children:`${window.location.origin}/${e.token}`}),(0,Z.jsx)(h,{size:14,className:`shrink-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-xs opacity-50 mt-1`,children:p(`setup.accessPointToken`)}),(0,Z.jsx)(`span`,{className:`text-sm font-mono bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded select-all break-all`,children:e.token})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-xs opacity-50 mt-1`,children:`Created`}),(0,Z.jsx)(`span`,{className:`text-sm`,children:le(new Date(e.created_at*1e3))})]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex gap-2 flex-wrap`,children:[(0,Z.jsx)(M,{small:!0,icon:(0,Z.jsx)(d,{size:14}),text:p(`setup.renameAccessPoint`),onClick:()=>i(e.id,e.name)}),(0,Z.jsx)(D,{isOpen:o===e.id,onInteraction:e=>{e||s(null)},content:(0,Z.jsxs)(`div`,{className:`p-4 space-y-3 dark:bg-gray-800 dark:text-white max-w-xs`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-semibold leading-relaxed`,children:p(`setup.rotateTokenConfirmDesc`,`Rotating the key will immediately disconnect devices using the old key. Are you sure you want to continue?`)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(M,{small:!0,minimal:!0,text:p(`common.cancel`,`Cancel`),onClick:()=>s(null)}),(0,Z.jsx)(M,{small:!0,intent:k.DANGER,text:p(`common.confirm`,`Confirm`),onClick:()=>{s(null),l(e.id)}})]})]}),placement:`top`,children:(0,Z.jsx)(M,{small:!0,icon:(0,Z.jsx)(n,{size:14}),text:p(`setup.rotateToken`),loading:c===e.id,onClick:()=>s(e.id)})}),(0,Z.jsx)(M,{small:!0,intent:k.DANGER,icon:(0,Z.jsx)(S,{size:14}),text:p(`setup.deleteAccessPoint`),loading:u===e.id,onClick:()=>f(e.id),disabled:t<=1,title:t<=1?`Cannot delete the only access point`:void 0})]})]})})},ke=({isOpen:e,onClose:t,profileId:n,isMobile:r,accessPoints:i,loading:a,onRefresh:s,toasterRef:c})=>{let{t:l}=v(),{isAddDialogOpen:u,setIsAddDialogOpen:d,newApName:p,setNewApName:m,isAdding:h,renameApId:g,setRenameApId:_,renameApName:y,setRenameApName:b,isRenaming:x,rotatingApId:S,deletingApId:C,newApNameFocused:w,setNewApNameFocused:T,renameApNameFocused:E,setRenameApNameFocused:D,rotateConfirmApId:A,setRotateConfirmApId:j,isSearchOpen:N,setIsSearchOpen:P,searchQuery:F,setSearchQuery:I,filteredAccessPoints:R,isValidApName:z,handleAdd:B,handleRename:V,handleRotate:H,handleDelete:U}=Te({profileId:n,accessPoints:i,onRefresh:s,toasterRef:c});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(_e,{isOpen:e,onClose:t,title:N?(0,Z.jsx)(L,{leftIcon:`search`,placeholder:l(`setup.searchAccessPoints`,`Search...`),value:F,onChange:e=>I(e.target.value),rightElement:(0,Z.jsx)(M,{icon:`cross`,minimal:!0,onClick:()=>{P(!1),I(``)}}),autoFocus:!0}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:l(`setup.manageAccessPoints`)}),(0,Z.jsx)(M,{icon:(0,Z.jsx)(o,{size:14}),minimal:!0,onClick:()=>P(!0),className:`opacity-50 hover:opacity-100`})]}),icon:`diagram-tree`,size:r?`100%`:`450px`,children:[(0,Z.jsx)(M,{fill:!0,intent:k.PRIMARY,icon:(0,Z.jsx)(f,{size:16}),text:l(`setup.addAccessPoint`),onClick:()=>d(!0),large:!0}),a?(0,Z.jsx)(`div`,{className:`flex justify-center p-8`,children:(0,Z.jsx)(O,{})}):(0,Z.jsx)(`div`,{className:`space-y-4 mt-4`,children:R.map(e=>(0,Z.jsx)(Oe,{ap:e,totalApCount:i.length,toasterRef:c,onRenameTrigger:(e,t)=>{_(e),b(t)},rotateConfirmApId:A,setRotateConfirmApId:j,rotatingApId:S,handleRotate:H,deletingApId:C,handleDelete:U},e.id))})]}),(0,Z.jsx)(Ee,{isOpen:u,onClose:()=>{d(!1),m(``)},newApName:p,setNewApName:m,newApNameFocused:w,setNewApNameFocused:T,handleAdd:B,isAdding:h,isValidApName:z}),(0,Z.jsx)(De,{isOpen:!!g,onClose:()=>_(null),renameApName:y,setRenameApName:b,renameApNameFocused:E,setRenameApNameFocused:D,handleRename:V,isRenaming:x,isValidApName:z})]})},Ae=({profileId:e,profileKey:t,profileName:n,toasterRef:r})=>{let i=se(),{t:a}=v(),[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(0),g=e=>{e!==f&&(p(e),h(e=>e+1))},_=async()=>{l(!0);try{s(await de(e))}catch(e){console.error(e)}finally{l(!1)}};(0,X.useEffect)(()=>{_()},[e]);let[y,b]=(0,X.useState)(n||``);(0,X.useEffect)(()=>{n?b(n):e&&ue(e).then(e=>{e?.name&&b(e.name)}).catch(()=>{})},[e,n]);let x=(0,X.useMemo)(()=>o.length===0?null:o.find(e=>e.id===f)||o[0],[o,f]),S=x?x.token:t,C=x?x.name:void 0,w=`${window.location.origin}/${S}`,[T,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(!1),[A,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(!1),[P,F]=(0,X.useState)(null),[I,L]=(0,X.useState)(null),[R,z]=(0,X.useState)({ipv4:[],ipv6:[]}),[B,V]=(0,X.useState)(null),H=e=>{navigator.clipboard.writeText(e),r?.current?.show({message:a(`setup.copied`),intent:k.SUCCESS})},U=async()=>{O(!0),V(null);try{let[t,n]=await Promise.all([re(),ae()]);if(t.ip&&(t.country===`UNKNOWN`||!t.country))try{let e=await fetch(`/api/geoip?ip=${encodeURIComponent(t.ip)}`);if(e.ok){let n=await e.json();n.success&&(n.country&&(t.country=n.country),n.region&&(t.region=n.region),n.city&&(t.city=n.city),n.timezone?.id&&(t.timezone=n.timezone.id),n.connection?.org&&(t.asOrganization=n.connection.org))}}catch{}E(t),F(n),t.timezone&&t.timezone!==`UNKNOWN`&&he(t.timezone);let r=window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`||window.location.hostname===`::1`||window.location.hostname.startsWith(`192.168.`)||window.location.hostname.startsWith(`10.`)||/^172\.(1[6-9]|2\d|3[01])\./.test(window.location.hostname),i=!!(t.dotDomain&&!J(t.dotDomain));ie(r&&i||i?t.dotDomain:window.location.hostname||``).then(e=>L(e)).catch(e=>console.warn(`Failed fetching domain geo location:`,e));let a=t.substituteDomain||`www.okx.com`;oe().then(e=>{z(t=>t.ipv4.length>0||t.ipv6.length>0?t:{ipv4:e.ip?[e.ip]:[],ipv6:e.ipv6?[e.ipv6]:[]})}).catch(()=>{}),te(a).then(e=>{(e.ipv4.length>0||e.ipv6.length>0)&&z(e)}).catch(e=>console.warn(`Failed resolving substitute domain DNS IPs:`,e)),V({success:!!t.connectedProfileId,profileMatch:t.connectedProfileId===e})}catch(e){console.error(`Verification failed`,e)}finally{O(!1)}};(0,X.useEffect)(()=>{U()},[e]);let W=(0,X.useMemo)(()=>{let e=[],t=(R.ipv4||[]).slice(0,2),n=(R.ipv6||[]).slice(0,2),r=T?.substituteDomain||`www.okx.com`;for(let n of t)e.push({ip:n,area:`${r} IPv4`});for(let t of n)e.push({ip:t,area:`${r} IPv6`});return e},[R,T?.substituteDomain]);return(0,Z.jsxs)(`div`,{className:`mx-auto space-y-8 pb-24 ${i?`p-1`:`px-8 max-w-5xl`}`,children:[(0,Z.jsx)(ve,{isMobile:i}),(0,Z.jsx)(ye,{isVerifying:D,verifyResult:B,handleVerify:U,isMobile:i,clientInfo:T,showIp:A,setShowIp:j,showLocation:M,setShowLocation:N,traceInfo:P,edgeLocation:I}),(0,Z.jsx)(be,{accessPoints:o,selectedApId:x?.id||null,onSelectAp:g,accessPointName:C,onManageAccessPoints:()=>d(!0),isMobile:i}),(0,Z.jsx)(xe,{dohUrl:w,copyToClipboard:H,isMobile:i,flashTrigger:m}),(0,Z.jsx)(we,{isMobile:i,copyToClipboard:H,profileKey:S,profileName:y||void 0,accessPointName:C,currentIps:W,dotDomain:T?.dotDomain}),(0,Z.jsx)(ke,{isOpen:u,onClose:()=>d(!1),profileId:e,isMobile:i,accessPoints:o,loading:c,onRefresh:_,toasterRef:r})]})};export{Ae as SetupView};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{At as t,B as n,D as r,F as i,J as a,K as o,L as s,M as c,P as l,R as u,T as d,U as f,V as p,X as m,ct as h,ft as g,it as _,jt as v,ot as y,rn as b,st as x,w as S}from"./vendor-react-R4_BUhus.js";import{S as C,b as w}from"./vendor-icons-other-kRhgWBno.js";import"./vendor-i18next-J2aoF7F1.js";import{B as T,C as E,E as D,F as O,H as k,I as A,N as j,P as M,R as N,V as P,a as F,d as I,f as L,i as R,j as z,k as B,n as V,o as H,r as U,v as W,z as G}from"./vendor-ui-core-CKSrm0Y8.js";import{_t as K,t as ee,vt as q}from"./vendor-utils-y3vK_J_u.js";import{$ as te,Tt as ne,U as re,W as ie,X as ae,Y as oe,Z as J,a as se,g as ce,ht as le,n as Y,pt as ue,t as de,tt as fe,ut as pe,v as me,vn as he,wt as ge}from"./index-CxK16i2C.js";import{t as _e}from"./SwipeableDrawer-BHXXZw7l.js";var X=e(C(),1),Z=e(w(),1);const ve=()=>{let{t:e}=b();return(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(z,{className:`font-bold text-gray-900 dark:text-white m-0`,children:e(`setup.title`)}),(0,Z.jsx)(`p`,{className:`bp6-text-muted m-0 mt-1`,children:e(`setup.subtitle`)})]}),(0,Z.jsx)(`div`,{className:`flex items-center`,children:(0,Z.jsx)(de,{})})]})},ye=({isVerifying:e,verifyResult:t,handleVerify:n,isMobile:r,clientInfo:a,showIp:o,setShowIp:s,showLocation:l,setShowLocation:u,traceInfo:d,edgeLocation:f})=>{let{t:p}=b(),{isServerfull:h}=Y(),[g,S]=(0,X.useState)(!1),C=(0,Z.jsxs)(`div`,{className:q(`bg-white dark:bg-gray-900 p-4 rounded-lg border border-gray-100 dark:border-gray-800 shadow-sm flex items-start gap-3 select-none h-full transition-all`,!h),children:[(0,Z.jsx)(i,{size:18,className:`text-purple-500 mt-1 shrink-0`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-40`,children:h?p(`setup.serverLocation`,`服务器位置`):p(`setup.edgeServer`)}),(0,Z.jsx)(`div`,{className:`font-bold truncate`,title:h?f||``:f||d?.colo||``,children:h?f||p(`setup.detecting`):f||d?.colo||p(`setup.detecting`)})]})]});return(0,Z.jsx)(H,{title:p(`setup.verifyConnection`),icon:(0,Z.jsx)(v,{size:16}),children:(0,Z.jsx)(F,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col md:flex-row items-center justify-between bg-gray-50 dark:bg-gray-800/50 p-6 rounded-xl border border-gray-100 dark:border-gray-800 gap-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col md:flex-row items-center gap-4 text-center md:text-left`,children:[(0,Z.jsx)(`div`,{className:`p-3 rounded-full ${t?.success?`bg-green-100 text-green-600`:t?`bg-red-100 text-red-600`:`bg-blue-100 text-blue-600`}`,children:e?(0,Z.jsx)(O,{size:24}):t?.success?(0,Z.jsx)(c,{size:24}):(0,Z.jsx)(i,{size:24})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-bold text-lg`,children:e?p(`setup.verifying`):t?.success?p(`setup.connected`):p(`setup.notConnected`)}),(0,Z.jsx)(`div`,{className:`text-sm opacity-60`,children:t?.success?t.profileMatch?p(`setup.profileMatch`):p(`setup.profileMismatch`):p(`setup.verifyHint`)})]})]}),(0,Z.jsx)(M,{size:`large`,intent:t?.success?k.SUCCESS:k.PRIMARY,icon:`refresh`,text:p(`setup.refreshStatus`),onClick:n,loading:e,fill:r})]}),a&&(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4`,children:[(0,Z.jsxs)(`div`,{className:`bg-white dark:bg-gray-900 p-4 rounded-lg border border-gray-100 dark:border-gray-800 shadow-sm flex items-start gap-3`,children:[(0,Z.jsx)(_,{size:18,className:`text-blue-500 mt-1`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-40`,children:p(`setup.egressIp`)}),(0,Z.jsx)(`button`,{onClick:()=>s(!o),className:`text-gray-400 hover:text-blue-500 transition-colors`,children:o?(0,Z.jsx)(y,{size:16}):(0,Z.jsx)(x,{size:16})})]}),(0,Z.jsx)(`div`,{className:`font-mono font-bold text-blue-600 dark:text-blue-400 truncate`,children:(0,Z.jsx)(`span`,{className:q(`transition-[filter] duration-200 inline-block`,!o&&`filter blur-[6px] select-none`),children:a.ip})})]})]}),(0,Z.jsxs)(`div`,{className:`bg-white dark:bg-gray-900 p-4 rounded-lg border border-gray-100 dark:border-gray-800 shadow-sm flex items-start gap-3`,children:[(0,Z.jsx)(m,{size:18,className:`text-red-500 mt-1`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-40`,children:p(`setup.currentLocation`)}),(0,Z.jsx)(`button`,{onClick:()=>u(!l),className:`text-gray-400 hover:text-red-500 transition-colors`,children:l?(0,Z.jsx)(y,{size:16}):(0,Z.jsx)(x,{size:16})})]}),(0,Z.jsx)(`div`,{className:`font-bold truncate`,children:(0,Z.jsx)(`span`,{className:q(`transition-[filter] duration-200 inline-block`,!l&&`filter blur-[6px] select-none`),children:(()=>{let e=[a.city,a.region,a.country].filter(e=>!!(e&&e!==`UNKNOWN`));return e.length>0?e.join(`, `):p(`setup.detecting`)})()})})]})]}),h?C:(0,Z.jsx)(D,{isOpen:g,onInteraction:S,placement:`bottom-end`,portalClassName:`z-20000`,fill:!0,targetProps:{className:`h-full`},content:(0,Z.jsxs)(`div`,{className:`p-3 select-text w-72 sm:w-80 max-w-[85vw] space-y-2`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-mono font-bold text-gray-500 dark:text-gray-400 tracking-wide border-b border-gray-100 dark:border-gray-800 pb-1.5`,children:`/cdn-cgi/trace`}),(0,Z.jsx)(`pre`,{className:`m-0 font-mono text-xs leading-relaxed whitespace-pre-wrap break-all overflow-x-hidden max-h-64 overflow-y-auto text-gray-800 dark:text-gray-200`,children:d?.raw||p(`setup.noTraceData`,`暂无 Trace 数据`)})]}),children:C})]})]})})})},Q=({step:e,className:t,size:n=144})=>{let r=e===1?47:50,i=e===1?45.5:45;return(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:K(`absolute -top-7 -left-7 pointer-events-none select-none z-0`,`text-blue-600/[0.08] dark:text-blue-400/[0.12]`,`transition-all duration-500 ease-out`,`blur-none group-hover:blur-md group-hover:opacity-0`,t),style:{width:n,height:n},children:(0,Z.jsxs)(`svg`,{viewBox:`0 0 100 100`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:`w-full h-full`,children:[(0,Z.jsx)(`circle`,{cx:`50`,cy:`50`,r:`46`,stroke:`currentColor`,strokeWidth:`4`}),(0,Z.jsx)(`text`,{x:r,y:i,textAnchor:`middle`,dominantBaseline:`central`,fill:`currentColor`,fontSize:`80`,fontWeight:`900`,fontFamily:`'Helvetica Neue', Helvetica, Arial, sans-serif`,children:e})]})})},be=({accessPoints:e,selectedApId:t,onSelectAp:n,accessPointName:r,onManageAccessPoints:i,isMobile:o})=>{let{t:s}=b();return(0,Z.jsxs)(H,{title:s(`setup.accessPointsCardTitle`,`接入点`),icon:(0,Z.jsx)(a,{size:16}),className:`group relative overflow-hidden [&_.bp6-section-header]:relative [&_.bp6-section-header]:z-10 [&_.bp6-section-card]:relative [&_.bp6-section-card]:z-10`,children:[(0,Z.jsx)(Q,{step:1}),(0,Z.jsx)(F,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 w-full sm:w-auto`,children:[(0,Z.jsx)(`span`,{className:`text-xs opacity-50 font-medium`,children:s(`setup.selectAccessPointToConfigure`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.length>0?(0,Z.jsx)(I,{value:t||``,onChange:e=>n(e.target.value),options:e.map(e=>({label:e.name,value:e.id})),className:`font-semibold text-gray-900 dark:text-gray-100`}):(0,Z.jsx)(`div`,{className:`font-semibold text-gray-900 dark:text-gray-100 flex items-center gap-2`,children:r||s(`setup.defaultAccessPointName`,`设备-1`)}),e.length>0&&(0,Z.jsx)(U,{minimal:!0,round:!0,intent:k.PRIMARY,className:`text-xs`,children:e.length})]})]}),(0,Z.jsx)(M,{variant:`outlined`,intent:k.NONE,icon:(0,Z.jsx)(l,{size:14}),text:s(`setup.manageAccessPoints`,`管理接入点`),onClick:i,fill:o,className:`shrink-0`})]})})]})},xe=({dohUrl:e,copyToClipboard:t,isMobile:n,flashTrigger:r=0})=>{let{t:i}=b();return(0,Z.jsxs)(H,{title:i(`setup.accessPointTitle`,`Access DoH URL`),icon:`globe`,className:`group relative overflow-hidden [&_.bp6-section-header]:relative [&_.bp6-section-header]:z-10 [&_.bp6-section-card]:relative [&_.bp6-section-card]:z-10`,rightElement:(0,Z.jsx)(D,{placement:`bottom-end`,usePortal:!0,content:(0,Z.jsxs)(`div`,{className:`p-4 max-w-sm`,children:[(0,Z.jsx)(j,{children:i(`setup.whatIsDoh`)}),(0,Z.jsx)(`p`,{className:`text-sm mb-2`,children:i(`setup.dohDesc`)}),(0,Z.jsxs)(`ul`,{className:`list-disc list-inside text-sm opacity-80 mb-3 space-y-1`,children:[(0,Z.jsx)(`li`,{children:i(`setup.dohBenefit1`)}),(0,Z.jsx)(`li`,{children:i(`setup.dohBenefit2`)})]}),(0,Z.jsx)(`div`,{className:`text-xs border-t border-gray-100 dark:border-gray-700 pt-2`,children:(0,Z.jsxs)(`a`,{href:`https://en.wikipedia.org/wiki/DNS_over_HTTPS`,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-1 text-blue-500 hover:underline`,children:[(0,Z.jsx)(h,{size:10}),` `,i(`setup.learnMore`)]})})]}),children:(0,Z.jsx)(M,{icon:`help`,variant:`minimal`,intent:k.NONE})}),children:[(0,Z.jsx)(Q,{step:2}),(0,Z.jsx)(F,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,Z.jsx)(`div`,{className:`w-full bg-gray-100 dark:bg-gray-800 px-4 py-4 sm:px-6 sm:py-5 rounded-lg border border-gray-200 dark:border-gray-700 flex items-center justify-center ${r>0?`animate-box-glow`:``}`,children:(0,Z.jsx)(`span`,{className:`font-mono text-sm sm:text-base font-medium text-center text-blue-600 dark:text-blue-400 break-all select-all`,children:e})},r),(0,Z.jsx)(`div`,{className:`w-full flex justify-center`,children:(0,Z.jsx)(M,{intent:k.PRIMARY,icon:`duplicate`,text:i(`setup.copyUrl`),fill:n,onClick:()=>t(e),className:`shrink-0 whitespace-nowrap min-w-fit`})})]})})]})};function $(e){let t=e.trim();try{return new URL(t.startsWith(`http://`)||t.startsWith(`https://`)?t:`https://${t}`).hostname||t}catch{return t.replace(/^https?:\/\//,``).split(`/`)[0].split(`:`)[0]||t}}function Se(e,t){let n=(e||``).trim(),r=(t||``).trim();if(!r&&n.includes(`(`)&&n.endsWith(`)`)){let e=n.match(/^(.+?)\s*\((.+?)\)$/);e&&(n=e[1].trim(),r=e[2].trim())}let i=n&&n!==`DNS Worker`?n:``,a=r&&r!==`DNS Worker`?r:``;return i&&a?i.toLowerCase()===a.toLowerCase()?i:`${i} - ${a}`:i||a||``}function Ce(e,t,n,r){let i,a,o,s;typeof e==`object`?(i=e.profileKey,a=e.profileName,o=e.accessPointName,s=e.origin):(i=e,a=t,s=n||``,o=r);let c=s.trim(),l=$(c),u=`${c}/${i}`,d=Se(a,o),f=crypto.randomUUID(),p=crypto.randomUUID(),m=d?`DNS Worker - ${l} (${d})`:`DNS Worker (${l})`,h=d?`DNS Worker DoH - ${l} (${d})`:`DNS Worker DoH - ${l}`,g=d?`DNS Worker DoH configuration profile for ${d} via ${l}`:`DNS Worker DoH configuration profile via ${l}`,_=d?`Configures encrypted DNS over HTTPS (DoH) for ${d} via ${l}`:`Configures encrypted DNS over HTTPS (DoH) via ${l}`;return ee({PayloadContent:[{DNSSettings:{DNSProtocol:`HTTPS`,ServerHTTPVersion:3,ServerURL:u},OnDemandRules:[{Action:`Connect`,InterfaceTypeMatch:`WiFi`},{Action:`Connect`,InterfaceTypeMatch:`Cellular`},{Action:`Disconnect`}],PayloadDescription:_,PayloadDisplayName:h,PayloadIdentifier:`com.apple.dnsSettings.managed.${f}`,PayloadName:h,PayloadType:`com.apple.dnsSettings.managed`,PayloadUUID:f,PayloadVersion:1}],PayloadDescription:g,PayloadDisplayName:m,PayloadIdentifier:`com.dnsworker.profile.${i}`,PayloadName:m,PayloadRemovalDisallowed:!1,PayloadType:`Configuration`,PayloadUUID:p,PayloadVersion:1},{indent:` `})}const we=({isMobile:e,copyToClipboard:n,profileKey:i,profileName:a,accessPointName:s,currentIps:c,dotDomain:l})=>{let{t:f}=b(),{isCloudflare:p}=Y();return(0,Z.jsxs)(`div`,{className:`group relative overflow-hidden rounded-xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm`,children:[(0,Z.jsx)(Q,{step:3}),(0,Z.jsxs)(V,{id:`setup-tabs`,renderActiveTabPanelOnly:!0,vertical:!e,size:`large`,className:K(`p-4 md:p-6 setup-tabs-container relative z-10 bg-transparent`,e&&[`[&_.bp6-tab-list]:overflow-x-auto!`,`[&_.bp6-tab-list]:flex-nowrap!`,`[&_.bp6-tab-list]:pb-1`,`[&_.bp6-tab-list]:scrollbar-none`,`[&_.bp6-tab-list]:[-ms-overflow-style:none]`,`[&_.bp6-tab-list::-webkit-scrollbar]:hidden`,`[&_.bp6-tab]:shrink-0`]),children:[(0,Z.jsx)(R,{id:`browsers`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(_,{size:16,className:`inline mr-2`}),f(`setup.browsers`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:f(`setup.browserTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:f(`setup.browserSteps`)}),(0,Z.jsx)(`p`,{className:`text-[10px] opacity-50 cursor-pointer`,onClick:()=>n(`chrome://settings/security`),children:f(`setup.browserTips`,`or copy this URL to the address bar: `)+`chrome://settings/security`})]})}),(0,Z.jsx)(R,{id:`apple`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(t,{size:16,className:`inline mr-2`}),f(`setup.apple`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:f(`setup.appleTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:f(`setup.appleDesc`)}),(0,Z.jsx)(`p`,{className:`text-[10px] opacity-50 text-center`,children:f(`setup.appleWarning`)}),(0,Z.jsxs)(`div`,{className:`p-6 bg-gray-50 dark:bg-gray-800 rounded-xl border border-dashed border-gray-300 dark:border-gray-700 flex flex-col items-center justify-center`,children:[(0,Z.jsx)(A,{icon:`document`,size:40,className:`opacity-20 mb-4`}),(0,Z.jsx)(M,{intent:k.PRIMARY,text:f(`setup.downloadConfig`),icon:`download`,onClick:()=>{let e=Ce({profileKey:i,profileName:a,accessPointName:s,origin:window.location.origin}),t=new Blob([e],{type:`application/x-apple-aspen-config`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n;let o=Se(a,s),c=$(window.location.origin);r.download=`dns_worker-${(o||c).replace(/[^a-zA-Z0-9_\-\u4e00-\u9fa5]/g,`_`).replace(/_+/g,`_`).replace(/^_|_$/g,``)}-${i}.mobileconfig`,r.click(),URL.revokeObjectURL(n)}})]}),(0,Z.jsx)(`p`,{className:`text-[10px] opacity-50 mt-4! text-center`,children:f(`setup.appleInstallHint`)})]})}),(0,Z.jsx)(R,{id:`windows`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(o,{size:16,className:`inline mr-2`}),f(`setup.windows`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:f(`setup.windowsTitle`)}),(0,Z.jsxs)(`ol`,{className:`list-decimal list-inside space-y-4 text-sm leading-relaxed`,children:[(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`a`,{href:`ms-settings:network-status`,children:f(`setup.windowsStep0`)})}),(0,Z.jsx)(`li`,{children:f(`setup.windowsStep1`)}),(0,Z.jsxs)(`li`,{children:[f(`setup.windowsStep2`),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:c.map(e=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(U,{minimal:!0,interactive:!0,onClick:()=>n(e.ip),icon:`duplicate`,className:`font-mono`,children:e.ip}),(0,Z.jsx)(`span`,{className:`text-[9px] opacity-50 ml-1 font-mono`,children:e.area})]},e.ip))})]}),(0,Z.jsx)(`li`,{children:f(`setup.windowsStep3`)}),(0,Z.jsx)(`li`,{children:f(`setup.windowsStep4`)})]})]})}),(0,Z.jsx)(R,{id:`linux`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(d,{size:16,className:`inline mr-2`}),f(`setup.linux`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:f(`setup.linuxTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:f(`setup.linuxDesc`)}),(0,Z.jsxs)(`div`,{className:`mt-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-bold mb-2`,children:f(`setup.linuxStep1`)}),(0,Z.jsxs)(`div`,{className:`relative group`,children:[(0,Z.jsx)(`pre`,{className:`bg-gray-100 dark:bg-gray-800 p-4 rounded-lg overflow-x-auto text-xs font-mono border border-gray-200 dark:border-gray-700`,children:(0,Z.jsx)(`code`,{children:`curl -sL "${window.location.origin}/setup.sh?key=${i}&origin=${window.location.origin}" | sudo bash`})}),(0,Z.jsx)(M,{className:`absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity`,icon:`duplicate`,minimal:!0,small:!0,onClick:()=>{n(`curl -sL "${window.location.origin}/setup.sh?key=${i}&origin=${window.location.origin}" | sudo bash`)}})]})]}),(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(`p`,{className:`text-sm font-bold`,children:f(`setup.linuxStep2`)})})]})}),(0,Z.jsx)(R,{id:`routeros`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(u,{size:16,className:`inline mr-2`}),f(`setup.routeros`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:f(`setup.routerosTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:f(`setup.routerosDesc`)}),(0,Z.jsxs)(`div`,{className:`mt-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-bold mb-2`,children:f(`setup.routerosStep1`)}),(0,Z.jsxs)(`div`,{className:`relative group`,children:[(0,Z.jsx)(`pre`,{className:`bg-gray-100 dark:bg-gray-800 p-4 rounded-lg overflow-x-auto text-xs font-mono border border-gray-200 dark:border-gray-700`,children:(0,Z.jsx)(`code`,{children:`/ip dns set use-doh-server="${window.location.origin}/${i}" verify-doh-cert=yes`})}),(0,Z.jsx)(M,{className:`absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity`,icon:`duplicate`,minimal:!0,small:!0,onClick:()=>{n(`/ip dns set use-doh-server="${window.location.origin}/${i}" verify-doh-cert=yes`)}})]})]}),(0,Z.jsx)(`p`,{className:`text-sm`,children:f(`setup.routerosNote`)}),(0,Z.jsxs)(`a`,{href:`https://help.mikrotik.com/docs/spaces/ROS/pages/37748767/DNS`,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-1 text-xs text-blue-500 hover:underline`,children:[(0,Z.jsx)(h,{size:10}),` `,f(`setup.routerosDocs`)]})]})}),(0,Z.jsx)(R,{id:`android`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(r,{size:16,className:`inline mr-2`}),f(`setup.android`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(j,{className:`font-bold`,children:f(`setup.androidTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:f(`setup.androidDesc`)}),p?(0,Z.jsxs)(E,{intent:k.WARNING,icon:`warning-sign`,className:`text-xs`,children:[(0,Z.jsx)(`div`,{className:`font-semibold mb-1`,children:f(`setup.dotUnavailableCfTitle`)}),(0,Z.jsx)(`div`,{children:f(`setup.dotUnavailableCfDesc`)})]}):(()=>{let e=/^(\d{1,3}\.){3}\d{1,3}$/.test(window.location.hostname)||window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`||window.location.hostname.includes(`:`),t=(l||``).trim().replace(/^\*\./,``),r=!J(t)&&t||(e?``:window.location.hostname);return(0,Z.jsxs)(`div`,{className:`p-4 bg-gray-50 dark:bg-gray-800/60 rounded-xl border border-gray-200 dark:border-gray-700 space-y-3`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold text-gray-700 dark:text-gray-300`,children:f(`setup.androidDotTitle`,`私有 DNS (DoT / DoQ)`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:f(`setup.androidDotDesc`,`支持 Android 原生“私有 DNS (DoT)”及各类现代 DoQ 客户端。提供商主机名:`)}),r?(0,Z.jsx)(`div`,{className:`space-y-3 pt-1`,children:(0,Z.jsx)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-1.5 sm:gap-2`,children:(0,Z.jsx)(U,{minimal:!0,interactive:!0,onClick:()=>n(`${i}.${r}`),icon:`duplicate`,className:`font-mono text-xs sm:text-sm py-1 px-3 self-start`,intent:k.PRIMARY,children:`${i}.${r}`})})}):(0,Z.jsx)(E,{intent:k.WARNING,icon:`warning-sign`,className:`text-xs`,children:f(`setup.androidIpNotice`,`检测到当前通过 IP 或本地地址访问面板。DoT / DoQ 仅接受域名,请在 .env 中配置 SERVERFULL_DOT_DOMAIN (例如 dns.example.com) 后刷新。`)})]})})(),!p&&(0,Z.jsx)(E,{intent:k.PRIMARY,icon:`info-sign`,className:`text-xs`,children:f(`setup.androidWarning`)})]})})]})]})};function Te({profileId:e,accessPoints:t,onRefresh:n,toasterRef:r}){let{t:i}=b(),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(null),[y,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(null),[O,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(``);return{isAddDialogOpen:a,setIsAddDialogOpen:o,newApName:s,setNewApName:c,isAdding:l,renameApId:d,setRenameApId:f,renameApName:p,setRenameApName:m,isRenaming:h,rotatingApId:_,deletingApId:y,newApNameFocused:S,setNewApNameFocused:C,renameApNameFocused:w,setRenameApNameFocused:T,rotateConfirmApId:E,setRotateConfirmApId:D,isSearchOpen:O,setIsSearchOpen:A,searchQuery:j,setSearchQuery:M,filteredAccessPoints:t.filter(e=>e.name.toLowerCase().includes(j.toLowerCase())||e.token.toLowerCase().includes(j.toLowerCase())),isValidApName:e=>se.test(e),handleAdd:async()=>{let a=s.trim();if(a){if(t.some(e=>e.name.toLowerCase()===a.toLowerCase())){r.current?.show({message:i(`setup.accessPointNameExists`,`Access Point name already exists`),intent:k.DANGER});return}u(!0);try{await fe(e,a),r.current?.show({message:i(`setup.accessPointCreated`),intent:k.SUCCESS}),o(!1),c(``),n()}catch(e){let t=e.message||`Failed to create access point`,n=t;if(t.startsWith(`Access point limit exceeded`)){let e=t.match(/\(max (\d+)\)/),r=e?e[1]:`100`;n=i(`setup.accessPointLimitExceeded`,{max:r,defaultValue:`Access Point limit exceeded (max ${r})`})}r.current?.show({message:n,intent:k.DANGER})}finally{u(!1)}}},handleRename:async()=>{let a=p.trim();if(!(!a||!d)){if(t.some(e=>e.id!==d&&e.name.toLowerCase()===a.toLowerCase())){r.current?.show({message:i(`setup.accessPointNameExists`,`Access Point name already exists`),intent:k.DANGER});return}g(!0);try{await ge(e,d,a),r.current?.show({message:i(`setup.accessPointRenamed`),intent:k.SUCCESS}),f(null),n()}catch(e){r.current?.show({message:e.message||`Failed to rename access point`,intent:k.DANGER})}finally{g(!1)}}},handleRotate:async t=>{v(t);try{await ne(e,t),r.current?.show({message:i(`setup.tokenRotated`),intent:k.SUCCESS}),n()}catch(e){console.error(e)}finally{v(null)}},handleDelete:async t=>{if(confirm(i(`setup.deleteAccessPointConfirm`))){x(t);try{await pe(e,t),r.current?.show({message:i(`setup.accessPointDeleted`),intent:k.SUCCESS}),n()}catch(e){console.error(e)}finally{x(null)}}}}}const Ee=({isOpen:e,onClose:t,newApName:n,setNewApName:r,newApNameFocused:i,setNewApNameFocused:a,handleAdd:o,isAdding:s,isValidApName:c})=>{let{t:l}=b();return(0,Z.jsxs)(B,{isOpen:e,onClose:t,title:l(`setup.addAccessPoint`),children:[(0,Z.jsx)(`div`,{className:N,children:(0,Z.jsx)(W,{content:l(`setup.accessPointNameFormatTip`,`1-30 characters, letters, numbers, hyphens and underscores allowed`),isOpen:i,position:P.TOP,intent:k.PRIMARY,className:`w-full`,children:(0,Z.jsx)(`div`,{className:`w-full block`,children:(0,Z.jsx)(L,{autoFocus:!0,large:!0,placeholder:l(`setup.accessPointName`),value:n,onChange:e=>r(e.target.value),onFocus:()=>a(!0),onBlur:()=>a(!1)})})})}),(0,Z.jsx)(`div`,{className:G,children:(0,Z.jsxs)(`div`,{className:T,children:[(0,Z.jsx)(M,{onClick:t,children:l(`common.cancel`,`Cancel`)}),(0,Z.jsx)(M,{intent:k.PRIMARY,onClick:o,loading:s,disabled:!c(n),children:l(`common.create`)})]})})]})},De=({isOpen:e,onClose:t,renameApName:n,setRenameApName:r,renameApNameFocused:i,setRenameApNameFocused:a,handleRename:o,isRenaming:s,isValidApName:c})=>{let{t:l}=b();return(0,Z.jsxs)(B,{isOpen:e,onClose:t,title:l(`setup.renameAccessPoint`),children:[(0,Z.jsx)(`div`,{className:N,children:(0,Z.jsx)(W,{content:l(`setup.accessPointNameFormatTip`,`1-30 characters, letters, numbers, hyphens and underscores allowed`),isOpen:i,position:P.TOP,intent:k.PRIMARY,className:`w-full`,children:(0,Z.jsx)(`div`,{className:`w-full block`,children:(0,Z.jsx)(L,{autoFocus:!0,large:!0,placeholder:l(`setup.accessPointName`),value:n,onChange:e=>r(e.target.value),onFocus:()=>a(!0),onBlur:()=>a(!1)})})})}),(0,Z.jsx)(`div`,{className:G,children:(0,Z.jsxs)(`div`,{className:T,children:[(0,Z.jsx)(M,{onClick:t,children:l(`common.cancel`,`Cancel`)}),(0,Z.jsx)(M,{intent:k.PRIMARY,onClick:o,loading:s,disabled:!c(n),children:l(`common.save`)})]})})]})},Oe=({ap:e,totalApCount:t,toasterRef:r,onRenameTrigger:i,rotateConfirmApId:o,setRotateConfirmApId:s,rotatingApId:c,handleRotate:l,deletingApId:u,handleDelete:d})=>{let{t:p}=b();return(0,Z.jsx)(H,{title:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(a,{size:16}),(0,Z.jsx)(`span`,{children:e.name})]}),className:`shadow-none! rounded-lg!`,children:(0,Z.jsxs)(F,{children:[(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-xs opacity-50 mt-1`,children:`DoH URL`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-mono bg-blue-50 text-blue-600 dark:bg-blue-900/20 dark:text-blue-400 px-2 py-1 rounded cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-900/40 transition-colors break-all`,onClick:()=>{navigator.clipboard.writeText(`${window.location.origin}/${e.token}`),r.current?.show({message:p(`setup.copied`),intent:k.SUCCESS})},title:p(`setup.copyUrl`),children:[(0,Z.jsx)(`span`,{className:`select-all`,children:`${window.location.origin}/${e.token}`}),(0,Z.jsx)(g,{size:14,className:`shrink-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-xs opacity-50 mt-1`,children:p(`setup.accessPointToken`)}),(0,Z.jsx)(`span`,{className:`text-sm font-mono bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded select-all break-all`,children:e.token})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-xs opacity-50 mt-1`,children:`Created`}),(0,Z.jsx)(`span`,{className:`text-sm`,children:ce(new Date(e.created_at*1e3))})]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex gap-2 flex-wrap`,children:[(0,Z.jsx)(M,{small:!0,icon:(0,Z.jsx)(f,{size:14}),text:p(`setup.renameAccessPoint`),onClick:()=>i(e.id,e.name)}),(0,Z.jsx)(D,{isOpen:o===e.id,onInteraction:e=>{e||s(null)},content:(0,Z.jsxs)(`div`,{className:`p-4 space-y-3 dark:bg-gray-800 dark:text-white max-w-xs`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-semibold leading-relaxed`,children:p(`setup.rotateTokenConfirmDesc`,`Rotating the key will immediately disconnect devices using the old key. Are you sure you want to continue?`)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(M,{small:!0,minimal:!0,text:p(`common.cancel`,`Cancel`),onClick:()=>s(null)}),(0,Z.jsx)(M,{small:!0,intent:k.DANGER,text:p(`common.confirm`,`Confirm`),onClick:()=>{s(null),l(e.id)}})]})]}),placement:`top`,children:(0,Z.jsx)(M,{small:!0,icon:(0,Z.jsx)(n,{size:14}),text:p(`setup.rotateToken`),loading:c===e.id,onClick:()=>s(e.id)})}),(0,Z.jsx)(M,{small:!0,intent:k.DANGER,icon:(0,Z.jsx)(S,{size:14}),text:p(`setup.deleteAccessPoint`),loading:u===e.id,onClick:()=>d(e.id),disabled:t<=1,title:t<=1?`Cannot delete the only access point`:void 0})]})]})})},ke=({isOpen:e,onClose:t,profileId:n,isMobile:r,accessPoints:i,loading:a,onRefresh:o,toasterRef:c})=>{let{t:l}=b(),{isAddDialogOpen:u,setIsAddDialogOpen:d,newApName:f,setNewApName:m,isAdding:h,renameApId:g,setRenameApId:_,renameApName:v,setRenameApName:y,isRenaming:x,rotatingApId:S,deletingApId:C,newApNameFocused:w,setNewApNameFocused:T,renameApNameFocused:E,setRenameApNameFocused:D,rotateConfirmApId:A,setRotateConfirmApId:j,isSearchOpen:N,setIsSearchOpen:P,searchQuery:F,setSearchQuery:I,filteredAccessPoints:R,isValidApName:z,handleAdd:B,handleRename:V,handleRotate:H,handleDelete:U}=Te({profileId:n,accessPoints:i,onRefresh:o,toasterRef:c});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(_e,{isOpen:e,onClose:t,title:N?(0,Z.jsx)(L,{leftIcon:`search`,placeholder:l(`setup.searchAccessPoints`,`Search...`),value:F,onChange:e=>I(e.target.value),rightElement:(0,Z.jsx)(M,{icon:`cross`,minimal:!0,onClick:()=>{P(!1),I(``)}}),autoFocus:!0}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:l(`setup.manageAccessPoints`)}),(0,Z.jsx)(M,{icon:(0,Z.jsx)(s,{size:14}),minimal:!0,onClick:()=>P(!0),className:`opacity-50 hover:opacity-100`})]}),icon:`diagram-tree`,size:r?`100%`:`450px`,children:[(0,Z.jsx)(M,{fill:!0,intent:k.PRIMARY,icon:(0,Z.jsx)(p,{size:16}),text:l(`setup.addAccessPoint`),onClick:()=>d(!0),large:!0}),a?(0,Z.jsx)(`div`,{className:`flex justify-center p-8`,children:(0,Z.jsx)(O,{})}):(0,Z.jsx)(`div`,{className:`space-y-4 mt-4`,children:R.map(e=>(0,Z.jsx)(Oe,{ap:e,totalApCount:i.length,toasterRef:c,onRenameTrigger:(e,t)=>{_(e),y(t)},rotateConfirmApId:A,setRotateConfirmApId:j,rotatingApId:S,handleRotate:H,deletingApId:C,handleDelete:U},e.id))})]}),(0,Z.jsx)(Ee,{isOpen:u,onClose:()=>{d(!1),m(``)},newApName:f,setNewApName:m,newApNameFocused:w,setNewApNameFocused:T,handleAdd:B,isAdding:h,isValidApName:z}),(0,Z.jsx)(De,{isOpen:!!g,onClose:()=>_(null),renameApName:v,setRenameApName:y,renameApNameFocused:E,setRenameApNameFocused:D,handleRename:V,isRenaming:x,isValidApName:z})]})},Ae=({profileId:e,profileKey:t,profileName:n,toasterRef:r})=>{let i=he(),{t:a}=b(),[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(0),g=e=>{e!==f&&(p(e),h(e=>e+1))},_=async()=>{l(!0);try{s(await ue(e))}catch(e){console.error(e)}finally{l(!1)}};(0,X.useEffect)(()=>{_()},[e]);let[v,y]=(0,X.useState)(n||``);(0,X.useEffect)(()=>{n?y(n):e&&le(e).then(e=>{e?.name&&y(e.name)}).catch(()=>{})},[e,n]);let x=(0,X.useMemo)(()=>o.length===0?null:o.find(e=>e.id===f)||o[0],[o,f]),S=x?x.token:t,C=x?x.name:void 0,w=`${window.location.origin}/${S}`,[T,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(!1),[A,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(!1),[P,F]=(0,X.useState)(null),[I,L]=(0,X.useState)(null),[R,z]=(0,X.useState)({ipv4:[],ipv6:[]}),[B,V]=(0,X.useState)(null),H=e=>{navigator.clipboard.writeText(e),r?.current?.show({message:a(`setup.copied`),intent:k.SUCCESS})},U=async()=>{O(!0),V(null);try{let[t,n]=await Promise.all([re(),ae()]);if(t.ip&&(t.country===`UNKNOWN`||!t.country))try{let e=await fetch(`/api/geoip?ip=${encodeURIComponent(t.ip)}`);if(e.ok){let n=await e.json();n.success&&(n.country&&(t.country=n.country),n.region&&(t.region=n.region),n.city&&(t.city=n.city),n.timezone?.id&&(t.timezone=n.timezone.id),n.connection?.org&&(t.asOrganization=n.connection.org))}}catch{}E(t),F(n),t.timezone&&t.timezone!==`UNKNOWN`&&me(t.timezone);let r=window.location.hostname===`localhost`||window.location.hostname===`127.0.0.1`||window.location.hostname===`::1`||window.location.hostname.startsWith(`192.168.`)||window.location.hostname.startsWith(`10.`)||/^172\.(1[6-9]|2\d|3[01])\./.test(window.location.hostname),i=!!(t.dotDomain&&!J(t.dotDomain));ie(r&&i||i?t.dotDomain:window.location.hostname||``).then(e=>L(e)).catch(e=>console.warn(`Failed fetching domain geo location:`,e));let a=t.substituteDomain||`www.okx.com`;oe().then(e=>{z(t=>t.ipv4.length>0||t.ipv6.length>0?t:{ipv4:e.ip?[e.ip]:[],ipv6:e.ipv6?[e.ipv6]:[]})}).catch(()=>{}),te(a).then(e=>{(e.ipv4.length>0||e.ipv6.length>0)&&z(e)}).catch(e=>console.warn(`Failed resolving substitute domain DNS IPs:`,e)),V({success:!!t.connectedProfileId,profileMatch:t.connectedProfileId===e})}catch(e){console.error(`Verification failed`,e)}finally{O(!1)}};(0,X.useEffect)(()=>{U()},[e]);let W=(0,X.useMemo)(()=>{let e=[],t=(R.ipv4||[]).slice(0,2),n=(R.ipv6||[]).slice(0,2),r=T?.substituteDomain||`www.okx.com`;for(let n of t)e.push({ip:n,area:`${r} IPv4`});for(let t of n)e.push({ip:t,area:`${r} IPv6`});return e},[R,T?.substituteDomain]);return(0,Z.jsxs)(`div`,{className:`mx-auto space-y-8 pb-24 ${i?`p-1`:`px-8 max-w-5xl`}`,children:[(0,Z.jsx)(ve,{isMobile:i}),(0,Z.jsx)(ye,{isVerifying:D,verifyResult:B,handleVerify:U,isMobile:i,clientInfo:T,showIp:A,setShowIp:j,showLocation:M,setShowLocation:N,traceInfo:P,edgeLocation:I}),(0,Z.jsx)(be,{accessPoints:o,selectedApId:x?.id||null,onSelectAp:g,accessPointName:C,onManageAccessPoints:()=>d(!0),isMobile:i}),(0,Z.jsx)(xe,{dohUrl:w,copyToClipboard:H,isMobile:i,flashTrigger:m}),(0,Z.jsx)(we,{isMobile:i,copyToClipboard:H,profileKey:S,profileName:v||void 0,accessPointName:C,currentIps:W,dotDomain:T?.dotDomain}),(0,Z.jsx)(ke,{isOpen:u,onClose:()=>d(!1),profileId:e,isMobile:i,accessPoints:o,loading:c,onRefresh:_,toasterRef:r})]})};export{Ae as SetupView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{S as t,b as n}from"./vendor-icons-other-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{S as t,b as n}from"./vendor-icons-other-kRhgWBno.js";import{V as r,g as i}from"./vendor-ui-core-CKSrm0Y8.js";var a=e(t(),1),o=e(n(),1);const s=({isOpen:e,onClose:t,title:n,icon:s,size:c,className:l,children:u,...d})=>{let f=(0,a.useRef)(null),p=e=>{let t=e.touches[0];f.current={x:t.clientX,y:t.clientY}},m=e=>{if(!f.current)return;let n=e.touches[0],r=n.clientX-f.current.x,i=n.clientY-f.current.y;r>80&&Math.abs(r)>Math.abs(i)*1.5&&(t(),f.current=null)},h=()=>{f.current=null},g=`dark:bg-gray-900 dark:text-white shadow-none! bg-transparent! bg-bulletin! backdrop-blur-sm! ${l||``}`;return(0,o.jsx)(i,{isOpen:e,onClose:t,title:n,icon:s,position:r.RIGHT,size:c,className:g,...d,children:(0,o.jsx)(`div`,{className:`p-6 space-y-4 overflow-y-auto h-full pb-safe`,onTouchStart:p,onTouchMove:m,onTouchEnd:h,children:u})})};export{s as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{B as t,C as n,H as r,I as i,M as a,N as o,S as s,_t as c,at as l,et as u,gt as d,rn as f,ut as p,w as m,x as h}from"./vendor-react-R4_BUhus.js";import{S as g,b as _}from"./vendor-icons-other-kRhgWBno.js";import"./vendor-i18next-J2aoF7F1.js";import{C as v,E as y,H as b,M as x,N as S,P as C,S as w,U as T,_ as E,d as D,f as O,h as k,k as A,p as j,r as M,u as N}from"./vendor-ui-core-CKSrm0Y8.js";import{_t as P}from"./vendor-utils-y3vK_J_u.js";import{B as F,F as I,H as L,I as R,L as z,N as B,P as V,R as H,V as U,d as W,f as G,g as K,l as ee,o as te,q,u as ne,vn as J,z as Y,zt as X}from"./index-CxK16i2C.js";import{t as Z}from"./async-R_IFRE5c.js";var Q=e(g(),1),$=e(_(),1);const re=({users:e,currentUserId:t,onRefresh:n,registrationEnabled:r=!0,maxUsers:i,onRefreshSettings:o,onSavingChange:s,toasterRef:c})=>{let{t:l}=f(),[u,d]=(0,Q.useState)(!1),[p,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(``),[y,S]=(0,Q.useState)(`user`),[E,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!1),[R,z]=(0,Q.useState)(r),[H,U]=(0,Q.useState)(!1),q=i!=null&&i!==``?parseInt(String(i),10):0,J=q>0&&e.length>=q;(0,Q.useEffect)(()=>{z(r)},[r]);let Y=async e=>{let t=R;z(e),U(!0),s?.(!0);try{await Z(L({registration_enabled:String(e)}),1e4),c?.current?.show({message:l(`common.saveSuccess`,`保存成功`),intent:b.SUCCESS,icon:`tick`}),o?.()}catch(e){console.error(e),z(t),c?.current?.show({message:e.message||l(`common.saveFailed`,`保存失败`),intent:b.DANGER,icon:`error`})}finally{U(!1),s?.(!1)}},X=async()=>{if(!ee.test(p)){alert(l(`account.formatTipUsername`));return}if(!te.test(_)){alert(l(`account.formatTipPassword`));return}P(!0);try{if((await ne(_,p)).breached){alert(l(`auth.passwordLeaked`,`This password has been exposed in a data breach or is too predictable. Please choose a different password.`)),P(!1);return}await B({username:p,password:await G(_,p),role:y}),d(!1),g(``),v(``),I(!1),n()}catch(e){console.error(e),alert(W(e,l))}finally{P(!1)}},re=async e=>{if(confirm(l(`account.confirmDeleteUser`)))try{await V(e),n()}catch(e){console.error(e)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(a,{size:20,className:`text-red-500`}),(0,$.jsx)(x,{style:{margin:0},children:l(`account.userManagement`)}),q>0?(0,$.jsxs)(M,{minimal:!0,intent:J?b.DANGER:b.PRIMARY,round:!0,children:[e.length,` / `,q]}):(0,$.jsx)(M,{minimal:!0,round:!0,children:e.length})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 flex-wrap`,children:[(0,$.jsx)(k,{label:l(`account.enableRegistration`,`开放新用户注册`),checked:R,disabled:H,onChange:e=>Y(e.currentTarget.checked),className:`mb-0`}),(0,$.jsx)(C,{className:`whitespace-nowrap`,icon:(0,$.jsx)(h,{size:16}),intent:b.SUCCESS,text:l(`account.createUser`),disabled:J,title:J?l(`auth.maxUsersReached`,`当前系统已达到用户数量上限,无法创建新用户。`):void 0,onClick:()=>d(!0)})]})]}),(0,$.jsx)(w,{elevation:T.ONE,className:`p-0 overflow-hidden overflow-x-auto`,children:(0,$.jsxs)(N,{interactive:!0,striped:!0,className:`w-full whitespace-nowrap`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{className:`whitespace-nowrap`,children:l(`account.username`)}),(0,$.jsx)(`th`,{className:`whitespace-nowrap`,children:l(`account.role`)}),(0,$.jsx)(`th`,{className:`whitespace-nowrap`,children:`MFA`}),(0,$.jsx)(`th`,{className:`whitespace-nowrap`,children:`ID`}),(0,$.jsx)(`th`,{className:`whitespace-nowrap`,children:l(`account.createdAt`)}),(0,$.jsx)(`th`,{className:`whitespace-nowrap`,children:l(`account.lastActive`)}),(0,$.jsx)(`th`,{className:`whitespace-nowrap`,children:l(`account.lastResolve`)}),(0,$.jsx)(`th`,{className:`text-right whitespace-nowrap`,children:l(`account.actions`)})]})}),(0,$.jsx)(`tbody`,{children:e.map(e=>(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`td`,{className:`font-bold whitespace-nowrap`,children:e.username}),(0,$.jsx)(`td`,{className:`whitespace-nowrap`,children:(0,$.jsx)(M,{minimal:!0,intent:e.role===`admin`?b.DANGER:b.NONE,className:`whitespace-nowrap`,children:e.role===`admin`?l(`account.roleAdmin`):l(`account.roleUser`)})}),(0,$.jsx)(`td`,{className:`whitespace-nowrap`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[!!e.totp_enabled&&(0,$.jsx)(M,{minimal:!0,intent:b.SUCCESS,className:`whitespace-nowrap`,children:`TOTP`}),!!(e.passkeys_count&&e.passkeys_count>0)&&(0,$.jsx)(M,{minimal:!0,intent:b.PRIMARY,className:`whitespace-nowrap`,children:`Passkey`}),!e.totp_enabled&&!(e.passkeys_count&&e.passkeys_count>0)&&(0,$.jsx)(M,{minimal:!0,intent:b.NONE,style:{color:`#8a9ba8`},className:`whitespace-nowrap`,children:l(`account.mfaNone`,`无`)})]})}),(0,$.jsx)(`td`,{className:`whitespace-nowrap`,children:(0,$.jsx)(`code`,{className:`text-xs`,children:e.id})}),(0,$.jsx)(`td`,{className:`text-xs text-gray-500 whitespace-nowrap`,children:e.created_at?K(new Date(e.created_at*1e3)):`-`}),(0,$.jsx)(`td`,{className:`text-xs text-gray-500 whitespace-nowrap`,children:e.last_active_at?K(new Date(e.last_active_at*1e3)):`-`}),(0,$.jsx)(`td`,{className:`text-xs text-gray-500 whitespace-nowrap`,children:e.last_resolve_at?K(new Date(e.last_resolve_at*1e3)):`-`}),(0,$.jsx)(`td`,{className:`text-right whitespace-nowrap`,children:(0,$.jsx)(`div`,{className:`inline-flex items-center gap-1`,children:(0,$.jsx)(C,{minimal:!0,intent:b.DANGER,icon:(0,$.jsx)(m,{size:14}),disabled:e.id===t,onClick:()=>re(e.id)})})})]},e.id))})]})}),(0,$.jsx)(A,{isOpen:u,onClose:()=>{d(!1),I(!1)},title:l(`account.createNewUser`),icon:`user`,children:(0,$.jsxs)(`div`,{className:`p-6 space-y-4`,children:[(0,$.jsx)(j,{label:l(`account.username`),children:(0,$.jsx)(O,{value:p,onChange:e=>g(e.target.value),placeholder:l(`auth.usernamePlaceholder`)})}),(0,$.jsx)(j,{label:l(`account.initialPassword`),children:(0,$.jsx)(O,{type:F?`text`:`password`,value:_,onChange:e=>v(e.target.value),placeholder:l(`auth.passwordPlaceholder`),rightElement:(0,$.jsx)(C,{minimal:!0,icon:F?`eye-open`:`eye-off`,onClick:()=>I(!F),title:F?l(`auth.hidePassword`,`Hide password`):l(`auth.showPassword`,`Show password`)})})}),(0,$.jsx)(j,{label:l(`account.userRole`),children:(0,$.jsx)(D,{fill:!0,value:y,onChange:e=>S(e.target.value),options:[{label:l(`account.roleUser`),value:`user`},{label:l(`account.roleAdmin`),value:`admin`}]})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 mt-6`,children:[(0,$.jsx)(C,{text:l(`account.cancel`),onClick:()=>d(!1)}),(0,$.jsx)(C,{intent:b.PRIMARY,text:l(`account.createNow`),loading:E,onClick:X})]})]})})]})},ie=({toasterRef:e,onSavingChange:t})=>{let{t:n}=f(),[r,a]=(0,Q.useState)(``),[o,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)([]),[g,_]=(0,Q.useState)(null),[D,k]=(0,Q.useState)(null),[A,N]=(0,Q.useState)([]),[P,L]=(0,Q.useState)(!1),[R,B]=(0,Q.useState)(null),[V,H]=(0,Q.useState)(null),U=(0,Q.useCallback)(async()=>{L(!0);try{N(await z())}catch(e){console.warn(`Failed to fetch distributed filter lists`,e)}finally{L(!1)}},[]);(0,Q.useEffect)(()=>{q().then(e=>{e&&Array.isArray(e)&&h(e.map(e=>({label:String(n(e.label,{defaultValue:e.label})),url:String(e.url||``)})))}).catch(e=>console.warn(`Failed to fetch preset filters`,e)),U()},[n,U]);let W=async()=>{let i=r.trim();if(i){p(!0),k(null),_(null),t?.(!0);try{let t=await I(i);_(t),a(``);let r=t.failedCount>0?n(`admin.distributeFilter.toastPartialSuccess`,`系统过滤列表已下发至 {{added}} 位用户,{{failed}} 位用户下发失败`,{added:t.addedCount,failed:t.failedCount}):n(`admin.distributeFilter.toastSuccess`,`系统过滤列表已成功下发至 {{count}} 位用户`,{count:t.addedCount});e?.current?.show({message:r,intent:t.failedCount>0&&t.addedCount===0?b.DANGER:t.failedCount>0?b.WARNING:b.SUCCESS,icon:t.failedCount>0&&t.addedCount===0?`error`:`tick`}),t.addedCount>0&&N(e=>e.some(e=>e.url===t.url)?e.map(e=>e.url===t.url?{...e,userCount:e.userCount+t.addedCount,usernames:Array.from(new Set([...e.usernames,...t.addedUsernames]))}:e):[...e,{url:t.url,profileCount:t.affectedProfilesCount,userCount:t.addedCount,usernames:t.addedUsernames}].sort((e,t)=>e.url.localeCompare(t.url))),await U()}catch(t){let n=t instanceof Error?t.message:String(t);k(n),e?.current?.show({message:n,intent:b.DANGER,icon:`error`})}finally{p(!1),t?.(!1)}}},G=async r=>{B(r),H(null),t?.(!0);try{let t=await F(r);e?.current?.show({message:n(`admin.distributeFilter.toastRevokeSuccess`,`已成功撤回系统过滤列表,移除了 {{count}} 位用户的系统规则`,{count:t.revokedCount}),intent:b.SUCCESS,icon:`tick`}),N(e=>e.filter(e=>e.url!==r&&e.url!==t.url)),await U()}catch(t){let n=t instanceof Error?t.message:String(t);e?.current?.show({message:n,intent:b.DANGER,icon:`error`})}finally{B(null),t?.(!1)}};return(0,$.jsxs)(w,{elevation:T.ZERO,className:`p-6 border border-gray-200 dark:border-gray-800 rounded-xl space-y-6`,children:[(0,$.jsx)(`div`,{className:`flex items-start justify-between`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(x,{className:`flex items-center space-x-2 text-base font-semibold`,children:[(0,$.jsx)(i,{className:`w-5 h-5 text-indigo-500`}),(0,$.jsx)(`span`,{children:n(`admin.distributeFilter.title`,`系统过滤列表 (管理员)`)})]}),(0,$.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 mt-1`,children:n(`admin.distributeFilter.description`,`向系统中所有用户账号下发系统级过滤列表。规则自动继承并应用于所有用户账号,带有“系统”标签。如果用户已存在相同规则则自动跳过。`)})]})}),m.length>0&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 flex items-center space-x-1`,children:[(0,$.jsx)(l,{className:`w-3.5 h-3.5`}),(0,$.jsx)(`span`,{children:n(`admin.distributeFilter.quickPresets`,`快捷预设`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:m.map(e=>(0,$.jsx)(C,{minimal:!0,small:!0,className:`text-xs`,intent:r===e.url?b.PRIMARY:b.NONE,onClick:()=>a(e.url),children:e.label},e.url))})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(j,{label:n(`admin.distributeFilter.urlLabel`,`规则列表 URL`),labelFor:`distribute-filter-url`,helperText:n(`admin.distributeFilter.urlHelper`,`支持 AdGuard、Hosts、EasyList 等标准格式 URL`),children:(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,$.jsx)(O,{id:`distribute-filter-url`,fill:!0,placeholder:`https://example.com/filter.txt`,value:r,onChange:e=>a(e.target.value),disabled:o,className:`font-mono text-sm`,onKeyDown:e=>{e.key===`Enter`&&r.trim()&&!o&&W()}}),(0,$.jsx)(C,{intent:b.PRIMARY,icon:(0,$.jsx)(i,{className:`w-4 h-4 mr-1`}),text:n(`admin.distributeFilter.submitBtn`,`立即下发`),loading:o,disabled:!r.trim(),onClick:W,className:`shrink-0`})]})}),D&&(0,$.jsxs)(v,{intent:b.DANGER,icon:null,children:[(0,$.jsxs)(S,{className:`flex items-center gap-2 mb-2 font-semibold`,children:[(0,$.jsx)(d,{className:`w-4 h-4 shrink-0`}),(0,$.jsx)(`span`,{children:n(`common.error`,`错误`)})]}),(0,$.jsx)(`div`,{className:`text-sm`,children:D})]}),g&&(0,$.jsxs)(v,{intent:g.failedCount>0?g.addedCount>0?b.WARNING:b.DANGER:b.SUCCESS,icon:null,children:[(0,$.jsxs)(S,{className:`flex items-center gap-2 mb-2 font-semibold`,children:[g.failedCount>0&&g.addedCount===0?(0,$.jsx)(d,{className:`w-4 h-4 shrink-0 text-red-500`}):(0,$.jsx)(c,{className:`w-4 h-4 shrink-0 text-green-500`}),(0,$.jsx)(`span`,{children:n(`admin.distributeFilter.resultTitle`,`下发执行完成`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,$.jsx)(`p`,{children:g.failedCount>0?n(`admin.distributeFilter.resultSummaryWithFailed`,`系统共 {{total}} 位用户:成功下发至 {{added}} 位用户,跳过 {{skipped}} 位已存在该规则的用户,{{failed}} 位用户下发失败。`,{total:g.totalUsers,added:g.addedCount,skipped:g.skippedCount,failed:g.failedCount}):n(`admin.distributeFilter.resultSummary`,`系统共 {{total}} 位用户:成功下发至 {{added}} 位用户,跳过 {{skipped}} 位已存在该规则的用户。`,{total:g.totalUsers,added:g.addedCount,skipped:g.skippedCount})}),g.addedUsernames.length>0&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-1`,children:[(0,$.jsxs)(`span`,{className:`text-xs font-medium text-gray-500`,children:[n(`admin.distributeFilter.addedUsers`,`下发成功用户`),`:`]}),g.addedUsernames.map(e=>(0,$.jsx)(M,{intent:b.SUCCESS,minimal:!0,round:!0,children:e},e))]}),g.skippedUsernames.length>0&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-1`,children:[(0,$.jsxs)(`span`,{className:`text-xs font-medium text-gray-500`,children:[n(`admin.distributeFilter.skippedUsers`,`已存在规则用户`),`:`]}),g.skippedUsernames.map(e=>(0,$.jsx)(M,{intent:b.NONE,minimal:!0,round:!0,children:e},e))]}),g.failedUsernames.length>0&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-1`,children:[(0,$.jsxs)(`span`,{className:`text-xs font-medium text-red-500 dark:text-red-400`,children:[n(`admin.distributeFilter.failedUsers`,`下发失败用户`),`:`]}),g.failedUsernames.map(e=>(0,$.jsx)(M,{intent:b.DANGER,minimal:!0,round:!0,children:e},e))]})]})]})]}),(0,$.jsx)(E,{}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`text-sm font-semibold flex items-center space-x-2`,children:[(0,$.jsx)(u,{className:`w-4 h-4 text-indigo-500`}),(0,$.jsx)(`span`,{children:n(`admin.distributeFilter.activeDistributedTitle`,`已下发系统规则`)})]}),A.length>0&&(0,$.jsx)(M,{minimal:!0,round:!0,intent:b.PRIMARY,children:A.length})]}),(0,$.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:n(`admin.distributeFilter.activeDistributedDesc`,`当前处于系统下发状态且带有“系统”标签的规则列表。撤回后将从所有用户账号中移除此系统规则,用户自建的同名规则不受影响。`)}),P?(0,$.jsx)(`div`,{className:`text-xs text-gray-400 py-3 text-center`,children:n(`common.loading`,`加载中...`)}):A.length===0?(0,$.jsx)(`div`,{className:`text-xs text-gray-400 dark:text-gray-500 py-4 px-3 bg-gray-50 dark:bg-gray-800/50 rounded-lg text-center border border-dashed border-gray-200 dark:border-gray-700`,children:n(`admin.distributeFilter.noDistributedFilters`,`当前系统中无已下发的系统过滤列表`)}):(0,$.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-gray-800 border border-gray-200 dark:border-gray-800 rounded-lg overflow-hidden`,children:A.map(e=>(0,$.jsxs)(`div`,{className:`p-3 bg-white dark:bg-gray-900 flex flex-col sm:flex-row sm:items-center justify-between gap-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,$.jsx)(`div`,{className:`font-mono text-xs text-gray-800 dark:text-gray-200 truncate select-all`,title:e.url,children:e.url}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-gray-500`,children:[(0,$.jsx)(M,{minimal:!0,round:!0,intent:b.PRIMARY,children:n(`admin.distributeFilter.usersCount`,`{{count}} 位用户`,{count:e.userCount})}),e.usernames.length>0&&(0,$.jsxs)(`span`,{className:`text-xs text-gray-400 truncate max-w-xs`,children:[`(`,e.usernames.join(`, `),`)`]})]})]}),(0,$.jsx)(`div`,{className:`shrink-0`,children:(0,$.jsx)(y,{isOpen:V===e.url,onInteraction:t=>H(t?e.url:null),placement:`top-end`,portalClassName:`z-20000`,content:(0,$.jsxs)(`div`,{className:`p-3 space-y-3 max-w-xs`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold leading-relaxed m-0 text-gray-800 dark:text-gray-200`,children:n(`admin.distributeFilter.revokeConfirm`,`确定撤回此系统过滤列表?系统将从所有用户账号中移除此系统规则,用户自建的同名规则不受影响。`)}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(C,{small:!0,variant:`minimal`,text:n(`common.cancel`,`取消`),onClick:()=>H(null)}),(0,$.jsx)(C,{small:!0,intent:b.DANGER,loading:R===e.url,text:n(`admin.distributeFilter.confirmRevoke`,`确认撤回`),onClick:()=>G(e.url)})]})]}),children:(0,$.jsx)(C,{small:!0,intent:b.DANGER,minimal:!0,icon:(0,$.jsx)(s,{className:`w-3.5 h-3.5`}),text:n(`admin.distributeFilter.revokeBtn`,`撤回`),loading:R===e.url,onClick:()=>H(e.url)})})})]},e.url))})]})]})},ae=({initialSettings:e,onRefresh:t,onSavingChange:n,toasterRef:r})=>{let{t:i}=f(),[a,s]=(0,Q.useState)(e),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{s(e)},[e]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(o,{size:20,className:`text-gray-500`}),(0,$.jsx)(x,{style:{margin:0},children:i(`account.systemSettings`,`System Settings`)})]}),(0,$.jsxs)(w,{elevation:T.ONE,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(x,{className:`text-sm font-bold opacity-70 text-blue-500`,children:`Cloudflare Turnstile`}),(0,$.jsx)(j,{label:`Site Key`,children:(0,$.jsx)(O,{value:a.turnstile_site_key||``,onChange:e=>s({...a,turnstile_site_key:e.target.value}),placeholder:`0x000...`})}),(0,$.jsx)(j,{label:`Secret Key`,children:(0,$.jsx)(O,{type:u?`text`:`password`,value:a.turnstile_secret_key||``,onChange:e=>s({...a,turnstile_secret_key:e.target.value}),placeholder:`0x000...`,rightElement:(0,$.jsx)(C,{minimal:!0,icon:u?`eye-open`:`eye-off`,onClick:()=>d(!u),title:u?i(`auth.hidePassword`,`Hide password`):i(`auth.showPassword`,`Show password`)})})})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(x,{className:`text-sm font-bold opacity-70 text-green-500`,children:i(`account.featureToggle`,`Feature Toggle`)}),(0,$.jsx)(k,{label:i(`account.enableTurnstileSignup`,`Enable verification on Signup`),checked:a.turnstile_enabled_signup===`true`,onChange:e=>s({...a,turnstile_enabled_signup:String(e.currentTarget.checked)})}),(0,$.jsx)(k,{label:i(`account.enableTurnstileLogin`,`Enable verification on Login`),checked:a.turnstile_enabled_login===`true`,onChange:e=>s({...a,turnstile_enabled_login:String(e.currentTarget.checked)})}),(0,$.jsx)(E,{className:`my-2`}),(0,$.jsx)(x,{className:`text-sm font-bold opacity-70 text-indigo-500`,children:i(`account.userLimits`,`User Quota`)}),(0,$.jsx)(j,{label:i(`account.maxUsers`,`Max Users`),helperText:i(`account.maxUsersHelper`,`Maximum number of users allowed in the system (0 for unlimited).`),children:(0,$.jsx)(O,{type:`number`,min:0,value:a.max_users||``,onChange:e=>s({...a,max_users:e.target.value}),placeholder:`0`})})]})]}),(0,$.jsx)(E,{className:`my-4`}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(C,{intent:b.PRIMARY,icon:`floppy-disk`,text:i(`common.save`,`Save`),loading:c,onClick:async()=>{l(!0),n?.(!0);try{await Z(L({turnstile_site_key:a.turnstile_site_key||``,turnstile_secret_key:a.turnstile_secret_key||``,turnstile_enabled_signup:a.turnstile_enabled_signup||`false`,turnstile_enabled_login:a.turnstile_enabled_login||`false`,max_users:a.max_users||`0`}),1e4),r?.current?.show({message:i(`common.saveSuccess`,`保存成功`),intent:b.SUCCESS,icon:`tick`}),t()}catch(t){console.error(t),s(e),r?.current?.show({message:t.message||i(`common.saveFailed`,`保存失败`),intent:b.DANGER,icon:`error`})}finally{l(!1),n?.(!1)}}})})]})]})},oe=({status:e,onRefresh:n,toasterRef:i})=>{let{t:a}=f(),[o,s]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),m=e?.migrations,h=m?.completed??!1;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(p,{size:20,className:`text-gray-500`}),(0,$.jsx)(x,{style:{margin:0},children:a(`account.databaseSettings`,`数据库 (管理员)`)})]}),m?(0,$.jsx)(M,{large:!0,round:!0,intent:h?b.SUCCESS:b.WARNING,icon:h?(0,$.jsx)(c,{size:16}):(0,$.jsx)(d,{size:16}),className:`whitespace-nowrap self-start sm:self-auto`,children:h?a(`account.migrationCompleted`,`迁移已完成`):a(`account.migrationPending`,`有待执行迁移`)}):(0,$.jsx)(M,{large:!0,round:!0,intent:b.NONE,className:`whitespace-nowrap self-start sm:self-auto`,children:a(`common.loading`,`加载中...`)})]}),(0,$.jsx)(w,{elevation:T.ONE,children:(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-xs uppercase font-semibold text-gray-500 tracking-wider`,children:a(`account.databaseEngine`,`数据库服务`)}),(0,$.jsx)(`div`,{className:`text-sm font-medium mt-1`,children:(e=>e===`Turso`?`Turso (libSQL)`:e===`D1`?`Cloudflare D1`:e===`File`?`SQLite (Local File)`:e||`SQLite`)(e?.databaseService)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-xs uppercase font-semibold text-gray-500 tracking-wider`,children:a(`account.lastAppliedMigration`,`最近应用版本`)}),(0,$.jsx)(`div`,{className:`text-sm font-medium font-mono text-gray-700 dark:text-gray-300 mt-1 truncate`,children:m?.lastApplied||a(`account.noMigrationsApplied`,`无`)})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-xs uppercase font-semibold text-gray-500 tracking-wider`,children:a(`account.migrationStatus`,`架构状态`)}),(0,$.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-300 mt-1`,children:m?h?a(`account.migrationCompletedDesc`,{total:m?.totalAvailable||0}):a(`account.migrationPendingDesc`,{applied:m?.appliedCount||0,total:m?.totalAvailable||0,pending:m?.pendingCount||0}):a(`common.loading`,`加载中...`)})]}),!h&&m&&m.pendingFiles.length>0&&(0,$.jsxs)(v,{intent:b.WARNING,icon:null,children:[(0,$.jsxs)(S,{className:`flex items-center gap-2 mb-1 text-xs font-semibold`,children:[(0,$.jsx)(d,{className:`w-4 h-4 shrink-0`}),(0,$.jsx)(`span`,{children:a(`account.pendingMigrationsList`,`待应用的架构迁移文件:`)})]}),(0,$.jsx)(`ul`,{className:`list-disc list-inside text-xs font-mono space-y-0.5 text-gray-700 dark:text-gray-300 max-h-32 overflow-y-auto`,children:m.pendingFiles.map(e=>(0,$.jsx)(`li`,{children:e},e))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between pt-2 border-t border-gray-100 dark:border-gray-800`,children:[(0,$.jsx)(C,{minimal:!0,icon:(0,$.jsx)(t,{size:14,className:l?`animate-spin`:``}),text:a(`account.checkMigration`,`刷新状态`),onClick:async()=>{u(!0);try{await n(),window.dispatchEvent(new Event(`db-migration-updated`))}finally{u(!1)}},disabled:o||l}),(0,$.jsx)(C,{intent:b.PRIMARY,icon:(0,$.jsx)(r,{size:14}),text:o?a(`account.runningMigration`,`正在迁移...`):a(`account.runMigration`,`执行迁移`),loading:o,disabled:h||o,onClick:async()=>{s(!0);try{let e=await U();i?.current?.show({message:a(`account.migrationSuccess`,{count:e.appliedCount}),intent:b.SUCCESS,icon:`tick`}),await n(),window.dispatchEvent(new Event(`db-migration-updated`))}catch(e){console.error(e),i?.current?.show({message:e.message||a(`account.migrationFailed`),intent:b.DANGER,icon:`error`})}finally{s(!1)}}})]})]})})]})},se=({onSavingChange:e,toasterRef:t})=>{let[r,i]=(0,Q.useState)(null),[o,s]=(0,Q.useState)([]),[c,l]=(0,Q.useState)(!0),{t:u}=f(),d=J(),[p,m]=(0,Q.useState)({}),[h,g]=(0,Q.useState)(null),_=async()=>{try{s(await Y())}catch(e){console.error(e)}},y=async()=>{try{m(await H())}catch(e){console.error(e)}},x=(0,Q.useCallback)(async()=>{try{g(await R())}catch(e){console.error(`Failed to fetch database status:`,e)}},[]),C=(0,Q.useCallback)(async()=>{try{let e=await X();i(e),e.role===`admin`&&(_(),y(),x())}catch(e){console.error(e)}finally{l(!1)}},[x]);return(0,Q.useEffect)(()=>{C()},[C]),c?(0,$.jsx)(`div`,{className:`p-8 text-center`,children:u(`common.loading`,`加载中...`)}):r?.role===`admin`?(0,$.jsxs)(`div`,{className:P(`max-w-5xl mx-auto space-y-8`,d?`p-0`:`px-8`),children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-start sm:items-end gap-3 flex-wrap sm:flex-nowrap`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`bp6-heading`,children:u(`system.title`,`系统管理`)}),(0,$.jsx)(`p`,{className:`bp6-text-muted`,children:u(`system.subtitle`,`管理用户、系统过滤列表、系统配置与数据库维护`)})]}),(0,$.jsx)(M,{large:!0,round:!0,intent:b.DANGER,icon:(0,$.jsx)(a,{size:16}),className:`shrink-0 whitespace-nowrap`,children:u(`account.roleAdmin`,`管理员`)})]}),r?.jwt_secret_warning&&(0,$.jsxs)(v,{intent:b.WARNING,icon:null,children:[(0,$.jsxs)(S,{className:`flex items-center gap-2 mb-1 font-semibold`,children:[(0,$.jsx)(n,{className:`w-4 h-4 shrink-0`}),(0,$.jsx)(`span`,{children:u(`account.jwtSecretWarningTitle`)})]}),(0,$.jsx)(`div`,{className:`text-sm leading-relaxed mt-1`,children:u(`account.jwtSecretWarningDesc`)})]}),(0,$.jsx)(`div`,{className:`space-y-4`,children:(0,$.jsx)(re,{users:o,currentUserId:r.id,onRefresh:_,registrationEnabled:p.registration_enabled!==`false`,maxUsers:p.max_users,onRefreshSettings:y,onSavingChange:e,toasterRef:t})}),(0,$.jsx)(E,{}),(0,$.jsx)(`div`,{className:`space-y-4`,children:(0,$.jsx)(ie,{onSavingChange:e,toasterRef:t})}),(0,$.jsx)(E,{}),(0,$.jsx)(`div`,{className:`space-y-4`,children:(0,$.jsx)(ae,{initialSettings:p,onRefresh:y,onSavingChange:e,toasterRef:t})}),(0,$.jsx)(E,{}),(0,$.jsx)(`div`,{className:`space-y-4`,children:(0,$.jsx)(oe,{status:h,onRefresh:x,toasterRef:t})})]}):(0,$.jsx)(`div`,{className:P(`max-w-5xl mx-auto space-y-6`,d?`p-0`:`px-8`),children:(0,$.jsx)(v,{intent:b.DANGER,icon:`error`,title:u(`system.accessDenied`,`访问受限`),children:u(`system.accessDeniedDesc`,`当前页面仅限管理员访问。`)})})};export{se as SystemView};
|