dns-worker 1.1.1 → 1.1.2
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/README.md +3 -3
- package/dist/serverfull.mjs +73 -69
- package/dist/serverfull.mjs.map +4 -4
- package/package.json +3 -1
- package/static/assets/AccountView-p5jSjMAE.js +4 -0
- package/static/assets/{AnalyticsView-C_g_jz14.js → AnalyticsView-BywwDzah.js} +2 -2
- package/static/assets/AuthView-qoUKd5PS.js +2 -0
- package/static/assets/{DestinationMap-jSW7gimP.js → DestinationMap-9Yc54Mdj.js} +1 -1
- package/static/assets/FilteringView-Bs3__NpV.js +1 -0
- package/static/assets/LogsView-B-U9oaxB.js +5 -0
- package/static/assets/{QRCodeCanvas-Cu_-aNyM.js → QRCodeCanvas-DQ-xNuwF.js} +2 -2
- package/static/assets/{RulesView-CfVeQv0-.js → RulesView-B2kL1QhI.js} +1 -1
- package/static/assets/SettingsView-DTGI6eSd.js +1 -0
- package/static/assets/SetupView-DE9MM-32.js +1 -0
- package/static/assets/{SwipeableDrawer-BrmEzhuP.js → SwipeableDrawer-B81ANpsc.js} +1 -1
- package/static/assets/{TrendChart-Dc5yJndv.js → TrendChart-CCR1W3fC.js} +3 -3
- package/static/assets/browser-Dc5iKjY4.js +1 -0
- package/static/assets/date-CpvuBM37.js +1 -0
- package/static/assets/{de-DE-CA3VPcoz.js → de-DE-kDnumQOF.js} +1 -1
- package/static/assets/{es-ES-CHvRWwd-.js → es-ES-CqKS7vHl.js} +1 -1
- package/static/assets/{fr-FR-CqGOuepx.js → fr-FR-BRcdpT35.js} +1 -1
- package/static/assets/getFlagEmoji-DRubsb7D.js +1 -0
- package/static/assets/index-Bheo8y3N.css +2 -0
- package/static/assets/index-dXN_pYn1.js +16 -0
- package/static/assets/{ja-JP-BJSbUSmh.js → ja-JP-C5jk6SuH.js} +1 -1
- package/static/assets/{ko-KR-Chzg6jwO.js → ko-KR-z38NtMFa.js} +1 -1
- package/static/assets/{ru-RU-CSyCGGPn.js → ru-RU-Bicx52lz.js} +1 -1
- package/static/assets/services-BVnEJBDq.js +1 -0
- package/static/assets/vendor-i18next-BKUzkAKP.js +1 -0
- package/static/assets/vendor-react-BmoHsW1x.js +11 -0
- package/static/assets/{vendor-ui-core-sfZn2C08.js → vendor-ui-core-CY_WyMIf.js} +1 -1
- package/static/assets/{vendor-utils-CnB7BG7m.js → vendor-utils-BWSB0jGn.js} +1 -1
- package/static/assets/{vi-VN-D7rcA1IX.js → vi-VN-CvS_mTAu.js} +1 -1
- package/static/assets/{zh-CN-CSPdaOkF.js → zh-CN-B0nRgJTD.js} +1 -1
- package/static/assets/{zh-TW-DETA1X3X.js → zh-TW-lc_SSoVI.js} +1 -1
- package/static/index.html +6 -6
- package/static/sw.js +1 -1
- package/static/assets/AccountView-CGRwz6ae.js +0 -4
- package/static/assets/AuthView-BQzmEyvO.js +0 -2
- package/static/assets/FilteringView-CQ7sX3Rp.js +0 -1
- package/static/assets/LogsView-eLfZMRVo.js +0 -5
- package/static/assets/SettingsView-agJiYEt5.js +0 -1
- package/static/assets/SetupView-CTgCUAgk.js +0 -1
- package/static/assets/browser-DPi2BX_1.js +0 -1
- package/static/assets/date-IKj2stuv.js +0 -1
- package/static/assets/getFlagEmoji-_Wxhq0lT.js +0 -1
- package/static/assets/index-919BqnYI.css +0 -2
- package/static/assets/index-CbTjGMTZ.js +0 -16
- package/static/assets/services-Cwvmit1q.js +0 -1
- package/static/assets/vendor-i18next-cO7FDf_e.js +0 -1
- package/static/assets/vendor-react-CHk5ngkq.js +0 -11
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{$ as t,E as n,Q as r,St as i,Zt as a,ht as o,j as s,lt as c}from"./vendor-react-CHk5ngkq.js";import{S as l,b as u}from"./vendor-icons-other-Bme3ywH9.js";import"./vendor-i18next-cO7FDf_e.js";import{A as d,B as f,H as p,L as m,N as h,O as g,R as _,S as v,V as y,f as b,m as x,p as S,r as C,v as w,x as T,z as E}from"./vendor-ui-core-sfZn2C08.js";import{_t as D}from"./vendor-utils-CnB7BG7m.js";import{C as O,Dt as k,Jt as ee,Lt as A,N as j,O as M,P as N,Pt as te,S as P,Ut as F,Xt as I,Yt as L,Zt as R,_ as z,b as B,d as V,en as H,f as U,g as ne,h as W,i as G,in as K,j as q,m as re,nn as ie,r as J,u as Y,x as ae,y as oe}from"./index-CbTjGMTZ.js";import{t as X}from"./QRCodeCanvas-Cu_-aNyM.js";var Z=e(l(),1),Q=e(u(),1);const $=({username:e,setUsername:t,isTurnstileEnabled:n,turnstileRef:r,loading:i,turnstileStatus:o,onSubmit:s})=>{let{t:c}=a();return(0,Q.jsxs)(`form`,{onSubmit:s,className:`space-y-4`,children:[(0,Q.jsx)(S,{label:c(`auth.username`),labelFor:`username`,children:(0,Q.jsx)(b,{id:`username`,leftIcon:`user`,placeholder:c(`auth.usernamePlaceholder`),size:`large`,className:`rounded-xl w-full`,value:e,onChange:e=>t(e.target.value),autoFocus:!0,required:!0})}),n&&(0,Q.jsx)(`div`,{className:`py-2 flex justify-center min-h-16.25`,children:(0,Q.jsx)(`div`,{ref:r})}),(0,Q.jsx)(h,{fill:!0,size:`large`,intent:y.PRIMARY,type:`submit`,loading:i||o===`verifying`,disabled:!!n&&o!==`success`,className:`mt-6 font-bold py-6 rounded-xl shadow-lg shadow-blue-500/20`,children:o===`verifying`?c(`auth.verifying`):c(`auth.next`,`Next`)})]})},se=({password:e,setPassword:t,hasMfa:n,onSwitchToMfa:r,loading:i,onSubmit:o,keepLoggedIn:s,setKeepLoggedIn:c,optionalSessionExpirationDays:l})=>{let[u,d]=Z.useState(!1),{t:f}=a();return(0,Q.jsxs)(`form`,{onSubmit:o,className:`space-y-4`,children:[(0,Q.jsx)(S,{label:f(`auth.password`),labelFor:`password`,children:(0,Q.jsx)(b,{id:`password`,leftIcon:`lock`,placeholder:f(`auth.passwordPlaceholder`),type:u?`text`:`password`,size:`large`,className:`rounded-xl`,value:e,onChange:e=>t(e.target.value),rightElement:(()=>(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[e&&(0,Q.jsx)(h,{minimal:!0,icon:`cross`,onClick:()=>t(``)}),(0,Q.jsx)(h,{minimal:!0,icon:u?`eye-open`:`eye-off`,onClick:()=>d(!u),title:u?f(`auth.hidePassword`,`Hide password`):f(`auth.showPassword`,`Show password`)})]}))(),autoFocus:!0,required:!0})}),(0,Q.jsx)(x,{checked:s,onChange:e=>c(e.currentTarget.checked),label:f(`auth.keepLoggedIn`,`Keep me logged in for {{days}} days`,{days:l}),className:`mt-4 text-left`}),(0,Q.jsxs)(`div`,{className:`pt-2 space-y-3`,children:[(0,Q.jsx)(h,{fill:!0,size:`large`,intent:y.PRIMARY,type:`submit`,loading:i,className:`font-bold py-6 rounded-xl shadow-lg shadow-blue-500/20`,children:n?f(`auth.next`,`Next`):f(`auth.loginBtn`,`Login`)}),n&&r&&(0,Q.jsx)(h,{fill:!0,minimal:!0,size:`large`,type:`button`,disabled:i,onClick:r,className:`font-medium text-blue-600 dark:text-blue-400 py-2.5 rounded-xl transition-colors hover:bg-blue-50 dark:hover:bg-blue-950/30`,children:f(`auth.otherOptions`,`其他选项`)})]})]})},ce=({value:e,onChange:t,disabled:n=!1,autoFocus:r=!0,className:i=``})=>{let{t:o}=a(),s=(0,Z.useRef)([]),c=(e=>{let t=e.replace(/\D/g,``).slice(0,30),n=[];for(let e=0;e<5;e++)n.push(t.slice(e*6,(e+1)*6));return n})(e);(0,Z.useEffect)(()=>{r&&s.current[0]&&s.current[0].focus()},[r]);let l=(e,n)=>{let r=n.replace(/\D/g,``).slice(0,6),i=[...c];i[e]=r,t(i.join(`-`)),r.length===6&&e<4&&s.current[e+1]?.focus()},u=(e,t)=>{if(t.key===`Backspace`&&c[e].length===0&&e>0){t.preventDefault();let n=s.current[e-1];n&&n.focus()}else t.key===`ArrowLeft`&&(t.currentTarget.selectionStart??0)===0&&e>0?(t.preventDefault(),s.current[e-1]?.focus()):t.key===`ArrowRight`&&(t.currentTarget.selectionStart??0)===c[e].length&&e<4&&(t.preventDefault(),s.current[e+1]?.focus())},d=(e,n)=>{let r=n.clipboardData.getData(`text`).replace(/\D/g,``);if(r.length>6){n.preventDefault();let i=[...c],a=0;for(let t=e;t<5&&a<r.length;t++){let e=r.slice(a,a+6);i[t]=e,a+=e.length}t(i.join(`-`));let o=Math.min(4,e+Math.ceil(r.length/6)-1);s.current[o]?.focus()}},f=c.map((e,t)=>e.length===6&&!B(e)?t:-1).filter(e=>e!==-1);return(0,Q.jsxs)(`div`,{className:`space-y-2 ${i}`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between gap-1 sm:gap-2`,children:c.map((e,t)=>{let r=e.length===6,i=r&&!B(e),a=r&&!i,c=`border-gray-300 dark:border-gray-600 focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20`;return i?c=`border-red-500 ring-2 ring-red-500/30 bg-red-50/40 dark:bg-red-950/20 text-red-600 dark:text-red-400`:a&&(c=`border-green-500/80 dark:border-green-500/60 bg-green-50/20 dark:bg-green-950/10 text-gray-900 dark:text-gray-100`),(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(`input`,{ref:e=>{s.current[t]=e},type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,maxLength:6,value:e,disabled:n,placeholder:`000000`,onChange:e=>l(t,e.target.value),onKeyDown:e=>u(t,e),onPaste:e=>d(t,e),className:`w-full min-w-0 text-center font-mono text-xs sm:text-sm tracking-wider py-2 sm:py-2.5 px-1 rounded-lg border transition-all duration-150 outline-none ${c}`,title:i?o(`auth.recoveryChecksumError`,{defaultValue:`校验码错误:该组 6 位数无法被 11 整除`,group:t+1}):void 0}),t<4&&(0,Q.jsx)(`span`,{className:`text-gray-400 dark:text-gray-500 font-bold select-none text-xs`,children:`-`})]},t)})}),f.length>0&&(0,Q.jsx)(`p`,{className:`text-xs text-red-500 dark:text-red-400 text-center font-medium mt-1`,children:o(`auth.recoveryChecksumErrorDesc`,{defaultValue:`第 {{groups}} 组校验码错误,请核对后重试`,groups:f.map(e=>e+1).join(`、`)})})]})},le=({hasPasskey:e,requiresTotp:n,mfaMethod:i,setMfaMethod:o,passkeyLoading:s,onPasskeyLogin:c,totpToken:l,setTotpToken:u,recoveryKey:d,setRecoveryKey:f,loading:p,onClearError:m,onSubmit:g,keepLoggedIn:_,setKeepLoggedIn:v,optionalSessionExpirationDays:b})=>{let{t:C}=a(),w=e=>{o(e),m()};return(0,Q.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),i===`passkey`){c();return}g(e)},className:`space-y-4`,children:[i===`passkey`&&(0,Q.jsxs)(`div`,{className:`space-y-5 text-center py-2`,children:[(0,Q.jsx)(`div`,{className:`mx-auto w-16 h-16 rounded-2xl bg-blue-50 dark:bg-blue-950/40 flex items-center justify-center text-blue-600 dark:text-blue-400`,children:(0,Q.jsx)(r,{size:36})}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`h4`,{className:`text-base font-semibold text-gray-900 dark:text-gray-100 m-0`,children:C(`auth.passkeyVerification`,`Passkey Verification`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 max-w-xs mx-auto leading-relaxed`,children:C(`auth.passkeyPromptDesc`,`Use your registered device's biometric or hardware security key to verify`)})]}),(0,Q.jsx)(x,{checked:_,onChange:e=>v(e.currentTarget.checked),label:C(`auth.keepLoggedIn`,`Keep me logged in for {{days}} days`,{days:b}),className:`text-left inline-block mt-2`}),(0,Q.jsxs)(`div`,{className:`pt-2 space-y-3`,children:[(0,Q.jsxs)(h,{fill:!0,size:`large`,intent:y.PRIMARY,type:`button`,loading:s,disabled:p,onClick:c,className:`font-semibold py-6 rounded-xl shadow-lg shadow-blue-500/20 flex items-center justify-center space-x-2`,children:[(0,Q.jsx)(r,{size:20,className:`inline mr-1.5`}),(0,Q.jsx)(`span`,{children:C(`auth.verifyWithPasskey`,`Verify with Passkey`)})]}),n&&(0,Q.jsx)(h,{fill:!0,minimal:!0,size:`large`,type:`button`,disabled:s||p,onClick:()=>w(`totp`),className:`font-medium text-blue-600 dark:text-blue-400 py-2.5 rounded-xl transition-colors hover:bg-blue-50 dark:hover:bg-blue-950/30`,children:C(`auth.otherOptions`,`Other Options`)}),(0,Q.jsx)(`div`,{className:`pt-1`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>w(`recovery`),className:`text-xs text-gray-500 hover:text-blue-600 dark:hover:text-blue-400 hover:underline bg-transparent border-none cursor-pointer p-0 font-normal inline-flex items-center gap-1`,children:[(0,Q.jsx)(t,{size:12}),(0,Q.jsx)(`span`,{children:C(`auth.totpUseRecovery`,`Use Recovery Key`)})]})})]})]}),i===`totp`&&(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(S,{label:C(`account.totp.title`,`Time-based One-time Password (TOTP)`),helperText:C(`auth.totpPrompt`,`Please enter the 6-digit code from your authentication app`),children:(0,Q.jsx)(`div`,{className:`pt-2`,children:(0,Q.jsx)(G,{length:6,value:l,onChange:u,disabled:p,autoFocus:!0})})}),(0,Q.jsx)(x,{checked:_,onChange:e=>v(e.currentTarget.checked),label:C(`auth.keepLoggedIn`,`Keep me logged in for {{days}} days`,{days:b}),className:`mt-4 text-left`}),(0,Q.jsxs)(`div`,{className:`pt-2 space-y-3`,children:[(0,Q.jsx)(h,{fill:!0,size:`large`,intent:y.PRIMARY,type:`submit`,loading:p,className:`font-bold py-6 rounded-xl shadow-lg shadow-blue-500/20`,children:C(`auth.loginBtn`,`Login`)}),e&&(0,Q.jsx)(h,{fill:!0,minimal:!0,size:`large`,type:`button`,disabled:p,onClick:()=>w(`passkey`),className:`font-medium text-blue-600 dark:text-blue-400 py-2.5 rounded-xl transition-colors hover:bg-blue-50 dark:hover:bg-blue-950/30`,children:C(`auth.otherOptions`,`Other Options`)}),(0,Q.jsx)(`div`,{className:`text-center pt-1`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>w(`recovery`),className:`text-xs text-gray-500 hover:text-blue-600 dark:hover:text-blue-400 hover:underline bg-transparent border-none cursor-pointer p-0 font-normal inline-flex items-center gap-1`,children:[(0,Q.jsx)(t,{size:12}),(0,Q.jsx)(`span`,{children:C(`auth.totpUseRecovery`,`Use Recovery Key`)})]})})]})]}),i===`recovery`&&(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(S,{label:C(`account.totp.recoveryKeysTitle`,`Recovery Keys`),helperText:C(`auth.recoveryPrompt`,`Please enter your 30-character recovery key (5 groups of 6 digits)`),children:(0,Q.jsx)(`div`,{className:`pt-2`,children:(0,Q.jsx)(ce,{value:d,onChange:f,disabled:p,autoFocus:!0})})}),(0,Q.jsx)(x,{checked:_,onChange:e=>v(e.currentTarget.checked),label:C(`auth.keepLoggedIn`,`Keep me logged in for {{days}} days`,{days:b}),className:`mt-4 text-left`}),(0,Q.jsxs)(`div`,{className:`pt-2 space-y-3`,children:[(0,Q.jsx)(h,{fill:!0,size:`large`,intent:y.PRIMARY,type:`submit`,loading:p,className:`font-bold py-6 rounded-xl shadow-lg shadow-blue-500/20`,children:C(`auth.loginBtn`,`Login`)}),(0,Q.jsx)(`div`,{className:`text-center pt-1`,children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>w(e?`passkey`:`totp`),className:`text-xs text-blue-600 dark:text-blue-400 hover:underline bg-transparent border-none cursor-pointer p-0 font-normal`,children:e?C(`auth.backToPasskey`,`Back to Passkey Verification`):C(`auth.totpUseApp`,`Use Authentication App`)})})]})]})]})};function ue({siteKey:e,enabled:t,turnstileReady:n,isActive:r,onError:i,onClearError:o}){let[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(`idle`),d=(0,Z.useRef)(null),f=(0,Z.useRef)(null),{t:p}=a();return(0,Z.useEffect)(()=>{if(r&&t&&e&&(n||window.turnstile)&&d.current)try{f.current&&window.turnstile&&(window.turnstile.remove(f.current),f.current=null),u(`verifying`),d.current.innerHTML=``,f.current=window.turnstile.render(d.current,{sitekey:e,callback:e=>{c(e),u(`success`),o()},"expired-callback":()=>{c(null),u(`idle`)},"error-callback":e=>{console.error(`Turnstile error:`,e),u(`error`),i(p(`auth.turnstileError`,`Verification service failed to load. Please reload and try again.`)),c(null)}})}catch(e){console.error(`Turnstile render error:`,e),u(`error`)}return()=>{f.current&&window.turnstile&&(window.turnstile.remove(f.current),f.current=null)}},[r,t,e,n,p,i,o]),{turnstileToken:s,setTurnstileToken:c,turnstileStatus:l,turnstileRef:d,resetTurnstile:()=>{window.turnstile&&f.current&&window.turnstile.reset(f.current),c(null),u(`idle`)}}}function de({username:e,password:t,passwordVersion:n,nonce:r,serverSalt:i,keepLoggedIn:o,onSuccess:s}){let[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),{t:m}=a();return{loading:c,error:u,setError:d,rotatedRecoveryKey:f,setRotatedRecoveryKey:p,executeLogin:async a=>{l(!0),d(``);try{let c={keepLoggedIn:o,passkeyAssertion:a.passkeyAssertion,totpTokenHash:a.totpTokenHash,totpSalt:a.totpSalt,recoveryKey:a.recoveryKey};if(a.useEnteredPassword&&t)if(n===2){if(!r||!i)throw Error(m(`auth.sessionExpired`,`Session expired, please start over`));c.password=await W(await Y(await U(t,e),i),r)}else c.password=t;let l=await H(c);if(l.accessToken&&M(l.accessToken),l.needsMigration&&t&&await A(await U(t,e),t),l.rotatedRecoveryKey&&a.recoveryKey){try{await q.unlockWithRecoveryKey(a.recoveryKey),await q.wrapCurrentKeyForRecovery(l.rotatedRecoveryKey)}catch(e){console.warn(`[Login] Could not auto re-wrap E2EE key with rotated recovery key:`,e)}p(l.rotatedRecoveryKey);return}s()}catch(e){e instanceof L&&ne({status:e.status},e.bodyText)?d(m(`auth.passwordLeaked`)):d(V(e,m))}finally{l(!1)}}}}function fe({hasPasswordEntered:e,passkeyOptions:t,executeLogin:n,onError:r}){let[i,o]=(0,Z.useState)(`passkey`),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),{t:p}=a();return{mfaMethod:i,setMfaMethod:o,totpToken:s,setTotpToken:c,recoveryKey:l,setRecoveryKey:u,passkeyLoading:d,setPasskeyLoading:f,handlePasskeyLogin:async()=>{if(t){f(!0),r(``);try{await n({useEnteredPassword:e,passkeyAssertion:await j(t)})}catch(e){console.error(`Passkey authentication error:`,e),r(V(e,p))}finally{f(!1)}}},handleStep3Submit:async t=>{if(t.preventDefault(),i===`totp`){let t=s.replace(/\s/g,``);if(t.length!==6){r(p(`auth.totpFormatError`,`Please enter a valid 6-digit code`));return}let i=crypto.randomUUID();await n({useEnteredPassword:e,totpTokenHash:await re(t,i),totpSalt:i})}else if(i===`recovery`){let t=l.replace(/[-\s]/g,``);if(!t){r(p(`auth.recoveryKeyRequired`,`Please enter your recovery key`));return}await n({useEnteredPassword:e,recoveryKey:t})}},resetMfaFields:()=>{c(``),u(``),f(!1),o(`passkey`)}}}const pe=({authConfig:e,turnstileReady:t,onSuccess:n})=>{let{t:r}=a(),[i,o]=(0,Z.useState)(1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(1),[h,g]=(0,Z.useState)(void 0),[_,v]=(0,Z.useState)(void 0),[y,b]=(0,Z.useState)(!0),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),{loading:D,error:O,setError:k,rotatedRecoveryKey:ee,setRotatedRecoveryKey:A,executeLogin:j}=de({username:s,password:l,passwordVersion:p,nonce:h,serverSalt:_,keepLoggedIn:d,onSuccess:n}),[M,N]=(0,Z.useState)(!1),te=D||M,P=e?.turnstile_enabled_login,{turnstileToken:F,turnstileStatus:I,turnstileRef:L,resetTurnstile:R}=ue({siteKey:e?.turnstile_site_key,enabled:P,turnstileReady:t,isActive:i===1,onError:k,onClearError:()=>k(``)}),{mfaMethod:z,setMfaMethod:B,totpToken:H,setTotpToken:U,recoveryKey:ne,setRecoveryKey:W,passkeyLoading:G,handlePasskeyLogin:K,handleStep3Submit:q,resetMfaFields:re}=fe({hasPasswordEntered:!!l,passkeyOptions:T,executeLogin:j,onError:k}),J=async t=>{if(t.preventDefault(),!ae(s)){k(r(`auth.formatTipUsername`));return}if(P&&e?.turnstile_site_key&&!F){k(r(`auth.turnstileRequired`));return}N(!0),k(``);try{let e=await ie({username:s,turnstileToken:F});b(e.requires_password),S(e.requires_totp),w(!!e.has_passkey),E(e.passkey_options||null),m(e.password_version??1),g(e.nonce),v(e.serverSalt),B(e.has_passkey?`passkey`:`totp`),e.requires_password?o(2):o(3)}catch(e){k(V(e,r)),R()}finally{N(!1)}},Y=async e=>{if(e.preventDefault(),!l){k(r(`auth.passwordRequiredFirst`,`Please enter your password first`));return}C||x?(k(``),o(3),B(C?`passkey`:`totp`)):await j({useEnteredPassword:!0})},oe=()=>{u(``),k(``),o(3),B(C?`passkey`:`totp`)},X=()=>{o(1),u(``),k(``),g(void 0),v(void 0),w(!1),E(null),re(),R()};return{loginStep:i,username:s,setUsername:c,password:l,setPassword:u,totpToken:H,setTotpToken:U,recoveryKey:ne,setRecoveryKey:W,requiresPassword:y,requiresTotp:x,hasPasskey:C,mfaMethod:z,setMfaMethod:B,passkeyLoading:G,loading:te,error:O,setError:k,turnstileStatus:I,turnstileRef:L,isTurnstileEnabled:P,keepLoggedIn:d,setKeepLoggedIn:f,handleStep1Submit:J,handleStep2Submit:Y,handleStep3Submit:q,handleSwitchToMfa:oe,handlePasskeyLogin:K,handleBack:()=>{k(``),i===2?X():i===3&&(y?o(2):X())},resetToStep1:X,rotatedRecoveryKey:ee,handleAcknowledgeRotatedKey:()=>{A(null),n()}}},me=({authConfig:e,turnstileReady:t,onSuccess:n,onToggleMode:r})=>{let{t:l}=a(),{loginStep:u,username:f,setUsername:p,password:b,setPassword:x,totpToken:S,setTotpToken:C,recoveryKey:w,setRecoveryKey:T,requiresTotp:D,hasPasskey:O,mfaMethod:k,setMfaMethod:ee,passkeyLoading:A,loading:j,error:M,setError:N,turnstileStatus:te,turnstileRef:F,isTurnstileEnabled:I,keepLoggedIn:L,setKeepLoggedIn:R,handleStep1Submit:z,handleStep2Submit:B,handleStep3Submit:V,handleSwitchToMfa:H,handlePasskeyLogin:U,handleBack:ne,rotatedRecoveryKey:W,handleAcknowledgeRotatedKey:G}=pe({authConfig:e,turnstileReady:t,onSuccess:n}),[K,q]=(0,Z.useState)(!1),re=e=>{navigator.clipboard.writeText(e),q(!0),setTimeout(()=>q(!1),2e3)};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col items-center mb-8 relative`,children:[u!==1&&(0,Q.jsx)(`button`,{type:`button`,onClick:ne,className:`absolute left-0 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 bg-transparent border-none cursor-pointer p-1 rounded-lg transition-colors`,title:l(`common.back`,`返回`),children:(0,Q.jsx)(i,{size:24})}),(0,Q.jsx)(`img`,{src:P,alt:`DNS Worker Logo`,className:`w-20 h-20 object-contain`}),(0,Q.jsx)(d,{className:`font-bold tracking-tight text-2xl mt-4`,children:(()=>{switch(u){case 1:return l(`auth.login`);case 2:return l(`auth.password`);case 3:return l(`auth.mfaVerification`,`多因素认证`)}})()}),(0,Q.jsx)(`p`,{className:`text-gray-500 mt-2 text-center text-sm leading-relaxed`,children:u===1?l(`auth.protectInternet`):f})]}),e?.has_users===!1&&(0,Q.jsx)(v,{intent:y.PRIMARY,icon:`info-sign`,className:`mb-6 rounded-xl`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:l(`auth.noUsersRegistered`,`系统尚无账号,请注册成为管理员。`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs bg-blue-600 hover:bg-blue-700 text-white font-semibold py-1.5 px-3 rounded-lg border-none cursor-pointer whitespace-nowrap transition-colors`,children:l(`auth.goToRegisterAdmin`,`注册管理员`)})]})}),M&&(0,Q.jsx)(v,{intent:y.DANGER,className:`mb-6 rounded-xl`,title:l(`auth.error`),children:M}),u===1&&(0,Q.jsx)($,{username:f,setUsername:p,isTurnstileEnabled:I,turnstileRef:F,loading:j,turnstileStatus:te,onSubmit:z}),u===2&&(0,Q.jsx)(se,{password:b,setPassword:x,hasMfa:O||D,onSwitchToMfa:H,loading:j,onSubmit:B,keepLoggedIn:L,setKeepLoggedIn:R,optionalSessionExpirationDays:e?.optional_session_expiration_days??7}),u===3&&(0,Q.jsx)(le,{hasPasskey:O,requiresTotp:D,mfaMethod:k,setMfaMethod:ee,passkeyLoading:A,onPasskeyLogin:U,totpToken:S,setTotpToken:C,recoveryKey:w,setRecoveryKey:T,loading:j,onClearError:()=>N(``),onSubmit:V,keepLoggedIn:L,setKeepLoggedIn:R,optionalSessionExpirationDays:e?.optional_session_expiration_days??7}),u===1&&(e?.has_users===!1||e?.registration_enabled!==!1)&&(0,Q.jsx)(`div`,{className:`mt-8 pt-6 border-t border-gray-100 dark:border-gray-800 flex justify-center items-center text-sm`,children:(0,Q.jsx)(`button`,{onClick:r,className:`text-blue-600 dark:text-blue-400 font-semibold hover:underline bg-transparent border-none cursor-pointer`,children:l(`auth.noAccount`)})}),(0,Q.jsxs)(g,{isOpen:!!W,onClose:G,title:l(`account.recoveryKey.autoRotatedTitle`,`恢复密钥已自动轮换`),icon:`warning-sign`,isCloseButtonShown:!1,canOutsideClickClose:!1,className:`dark:bg-gray-900`,children:[(0,Q.jsxs)(`div`,{className:m,children:[(0,Q.jsx)(v,{intent:y.WARNING,icon:(0,Q.jsx)(s,{size:16}),className:`mb-4 text-xs`,children:l(`account.recoveryKey.autoRotatedNotice`,`根据恢复密钥单次使用规则,您的原恢复密钥已失效,系统已为您生成全新 30 位紧急恢复密钥。请务必立即复制并妥善离线保存,关闭后将无法再次查看!`)}),W&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`div`,{className:`p-3 bg-gray-100 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700 font-mono text-center text-lg font-bold tracking-widest select-all text-gray-900 dark:text-gray-100`,children:W}),(0,Q.jsx)(`div`,{className:`flex justify-center`,children:(0,Q.jsx)(h,{intent:y.PRIMARY,icon:K?(0,Q.jsx)(o,{size:14,className:`text-green-400`}):(0,Q.jsx)(c,{size:14}),text:K?l(`common.copied`,`已复制`):l(`common.copyKey`,`复制新恢复密钥`),onClick:()=>re(W)})})]})]}),(0,Q.jsx)(`div`,{className:_,children:(0,Q.jsx)(`div`,{className:E,children:(0,Q.jsx)(h,{intent:y.SUCCESS,onClick:G,text:l(`account.recoveryKey.savedAndContinue`,`我已妥善保存并进入控制台`)})})})]})]})},he=({username:e,setUsername:t,usernameFocused:n,setUsernameFocused:r,checkUsernameDuplicate:i,loading:o,onSubmit:s,onClearError:c})=>{let{t:l}=a();return(0,Q.jsxs)(`form`,{onSubmit:s,className:`space-y-4`,children:[(0,Q.jsx)(S,{label:l(`auth.username`),labelFor:`username`,children:(0,Q.jsx)(w,{content:l(`auth.formatTipUsername`),isOpen:n,position:f.TOP,intent:y.PRIMARY,className:`w-full`,children:(0,Q.jsx)(`div`,{className:`w-full block`,children:(0,Q.jsx)(b,{id:`username`,leftIcon:`user`,placeholder:l(`auth.usernamePlaceholder`),size:`large`,className:`rounded-xl w-full`,value:e,onChange:e=>{t(e.target.value),c()},onFocus:()=>r(!0),onBlur:()=>{r(!1),i(e)},autoFocus:!0,required:!0})})})}),(0,Q.jsx)(h,{fill:!0,size:`large`,intent:y.PRIMARY,type:`submit`,loading:o,className:`mt-6 font-bold py-6 rounded-xl shadow-lg shadow-blue-500/20`,children:l(`auth.next`,`Next`)})]})},ge=({password:e,setPassword:t,passwordFocused:n,setPasswordFocused:r,loading:i,onSubmit:o,isTurnstileEnabled:s,turnstileRef:c,turnstileStatus:l})=>{let[u,d]=Z.useState(!1),{t:p}=a();return(0,Q.jsxs)(`form`,{onSubmit:o,className:`space-y-4`,children:[(0,Q.jsx)(S,{label:p(`auth.password`),labelFor:`password`,children:(0,Q.jsx)(w,{content:p(`auth.formatTipPassword`),isOpen:n,position:f.TOP,intent:y.PRIMARY,className:`w-full`,children:(0,Q.jsx)(`div`,{className:`w-full block`,children:(0,Q.jsx)(b,{id:`password`,leftIcon:`lock`,placeholder:p(`auth.passwordPlaceholder`),type:u?`text`:`password`,size:`large`,className:`rounded-xl w-full`,value:e,onChange:e=>t(e.target.value),onFocus:()=>r(!0),onBlur:()=>r(!1),rightElement:(()=>(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[e&&(0,Q.jsx)(h,{minimal:!0,icon:`cross`,onClick:()=>t(``)}),(0,Q.jsx)(h,{minimal:!0,icon:u?`eye-open`:`eye-off`,onClick:()=>d(!u),title:u?p(`auth.hidePassword`,`Hide password`):p(`auth.showPassword`,`Show password`)})]}))(),required:!0,autoFocus:!0})})})}),s&&(0,Q.jsx)(`div`,{className:`py-2 flex justify-center min-h-16.25`,children:(0,Q.jsx)(`div`,{ref:c})}),(0,Q.jsx)(h,{fill:!0,size:`large`,intent:y.PRIMARY,type:`submit`,loading:i||l===`verifying`,disabled:!!s&&l!==`success`,className:`mt-6 font-bold py-6 rounded-xl shadow-lg shadow-blue-500/20`,children:p(l===`verifying`?`auth.verifying`:`auth.signupBtn`)})]})},_e=({mfaChoice:e,setMfaChoice:t,onRegisterPasskey:o,passkeyRegLoading:s,passkeyRegError:c,onStartTotp:l,totpSetupData:u,totpSetupToken:d,setTotpSetupToken:f,totpSetupError:m,totpSetupLoading:g,onTotpSubmit:_,onSkip:b})=>{let{t:x}=a();return e===`choose`?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[c&&(0,Q.jsx)(v,{intent:y.DANGER,className:`rounded-xl`,children:c}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(T,{elevation:p.ONE,className:`p-4 rounded-xl border border-blue-100 dark:border-blue-900/40 hover:border-blue-300 dark:hover:border-blue-700 transition-colors cursor-pointer`,onClick:s?void 0:o,children:[(0,Q.jsx)(`div`,{className:`flex items-start justify-between`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`p-2.5 bg-blue-50 dark:bg-blue-950/40 text-blue-600 dark:text-blue-400 rounded-xl`,children:(0,Q.jsx)(r,{size:24})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-bold text-gray-800 dark:text-gray-100 m-0`,children:x(`account.passkey.title`,`通行密钥 (Passkey)`)}),(0,Q.jsx)(C,{intent:y.PRIMARY,minimal:!0,round:!0,children:x(`auth.mfaRecommended`,`推荐 · 无密码`)})]}),(0,Q.jsx)(`div`,{className:`text-xs text-blue-600 dark:text-blue-400 font-mono mt-0.5`,children:window.location.hostname}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1 mb-0 leading-relaxed`,children:x(`auth.passkeySignupDesc`,`使用本设备生物识别 (Touch ID / Face ID / Windows Hello) 或硬件密钥 (YubiKey),一键快捷且防钓鱼。`)})]})]})}),(0,Q.jsx)(`div`,{className:`mt-3 text-right`,children:(0,Q.jsx)(h,{intent:y.PRIMARY,loading:s,text:x(`auth.bindPasskeyNow`,`绑定通行密钥`),className:`rounded-lg font-medium`})})]}),(0,Q.jsxs)(T,{elevation:p.ONE,className:`p-4 rounded-xl border border-gray-100 dark:border-gray-800 hover:border-gray-300 dark:hover:border-gray-700 transition-colors cursor-pointer`,onClick:l,children:[(0,Q.jsx)(`div`,{className:`flex items-start justify-between`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`p-2.5 bg-purple-50 dark:bg-purple-950/40 text-purple-600 dark:text-purple-400 rounded-xl`,children:(0,Q.jsx)(n,{size:24})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-bold text-gray-800 dark:text-gray-100 m-0`,children:x(`auth.mfaMethodTotp`,`数字验证器 (TOTP)`)}),(0,Q.jsx)(C,{intent:y.NONE,minimal:!0,round:!0,children:x(`auth.mfaUniversal`,`通用应用`)})]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1 mb-0 leading-relaxed`,children:x(`account.totp.setupDesc`,`使用 Google Authenticator、1Password 等验证器应用扫码绑定 6 位动态验证码。`)})]})]})}),(0,Q.jsx)(`div`,{className:`mt-3 text-right`,children:(0,Q.jsx)(h,{minimal:!0,text:x(`auth.setupTotpBtn`,`扫码配置验证器`),className:`rounded-lg font-medium text-gray-700 dark:text-gray-200`})})]})]}),(0,Q.jsx)(`div`,{className:`text-center pt-2`,children:(0,Q.jsx)(h,{minimal:!0,text:x(`auth.skipMfaSetup`,`跳过多因素认证配置,直接进入系统`),onClick:b,className:`text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-200`})})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>t(`choose`),className:`text-xs text-blue-600 hover:underline flex items-center gap-1 bg-transparent border-none cursor-pointer p-0`,children:[(0,Q.jsx)(i,{size:14}),(0,Q.jsx)(`span`,{children:x(`auth.backToMfaOptions`,`选择其他认证方式`)})]})}),u&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,Q.jsx)(X,{uri:u.uri}),(0,Q.jsxs)(`div`,{className:`text-center`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mb-1`,children:x(`account.totp.orEnterManually`,`Or enter the key manually:`)}),(0,Q.jsx)(`code`,{className:`text-xs font-mono bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded select-all`,children:u.secret})]})]}),m&&(0,Q.jsx)(v,{intent:y.DANGER,className:`rounded-xl`,children:m}),(0,Q.jsxs)(`form`,{onSubmit:_,className:`space-y-4`,children:[(0,Q.jsx)(S,{label:x(`account.totp.enterCode`,`Enter the 6-digit code:`),helperText:x(`account.totp.enterCodeHint`,`Enter the 6-digit code to confirm.`),children:(0,Q.jsx)(G,{length:6,value:d,onChange:f,disabled:g,autoFocus:!0})}),(0,Q.jsx)(h,{fill:!0,size:`large`,intent:y.PRIMARY,type:`submit`,loading:g,disabled:d.length!==6,className:`rounded-xl font-bold py-3`,children:x(`account.totp.activate`,`Activate`)})]})]})},ve=({totpRecoveryKeys:e,copiedRecovery:t,onCopy:n,onSuccess:r})=>{let{t:i}=a();return Z.useEffect(()=>{let e=e=>{e.key===`Enter`&&r()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[r]),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`div`,{className:e.length===1?`space-y-2 mb-4`:`grid grid-cols-2 gap-2 mb-4`,children:e.map((e,t)=>(0,Q.jsx)(`code`,{className:`block font-mono text-sm sm:text-base font-semibold bg-gray-100 dark:bg-gray-800 text-blue-600 dark:text-blue-400 px-4 py-3 rounded-xl text-center tracking-widest break-all select-all border border-gray-200 dark:border-gray-700`,children:e},t))}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(h,{fill:!0,icon:(0,Q.jsx)(c,{size:14}),text:t?i(`account.totp.copied`,`Copied!`):i(`account.totp.copyKeys`,`Copy All Keys`),intent:t?y.SUCCESS:y.NONE,onClick:n}),(0,Q.jsx)(h,{fill:!0,intent:y.PRIMARY,text:i(`account.totp.done`,`Done`),onClick:r})]})]})},ye=({authConfig:e,turnstileReady:t,onSuccess:n})=>{let[r,i]=(0,Z.useState)(`username`),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,A]=(0,Z.useState)(``),[j,P]=(0,Z.useState)(`choose`),[R,z]=(0,Z.useState)(!1),[B,H]=(0,Z.useState)(``),[W,G]=(0,Z.useState)(null),[ie,J]=(0,Z.useState)(`idle`),Y=(0,Z.useRef)(null),X=(0,Z.useRef)(null),{t:Q}=a(),$=e?.turnstile_enabled_signup;(0,Z.useEffect)(()=>{if(r===`password`&&$&&e?.turnstile_site_key&&(t||window.turnstile)&&Y.current)try{X.current&&window.turnstile&&(window.turnstile.remove(X.current),X.current=null),J(`verifying`),Y.current.innerHTML=``,X.current=window.turnstile.render(Y.current,{sitekey:e.turnstile_site_key,callback:e=>{G(e),J(`success`),y(``)},"expired-callback":()=>{G(null),J(`idle`)},"error-callback":e=>{console.error(`Turnstile error:`,e),J(`error`),y(Q(`auth.turnstileError`,`Verification service failed to load. Please reload and try again.`)),G(null)}})}catch(e){console.error(`Turnstile render error:`,e),J(`error`)}return()=>{X.current&&window.turnstile&&(window.turnstile.remove(X.current),X.current=null)}},[$,e,r,t,Q]);let se=async e=>{if(!(!e||!ae(e)))try{await I(e)?y(Q(`auth.usernameExists`)):y(e=>e===Q(`auth.usernameExists`)?``:e)}catch(e){console.error(`Failed to check username duplicate`,e)}},ce=async e=>{if(e.preventDefault(),!ae(o)){y(Q(`auth.formatTipUsername`));return}_(!0),y(``);try{await I(o)?y(Q(`auth.usernameExists`)):i(`password`)}catch{y(Q(`auth.networkError`))}finally{_(!1)}},le=async()=>{D(!0),A(``);try{p(await F()),i(`totp`)}catch(e){console.error(`Network error during signup TOTP setup:`,e),n()}finally{D(!1)}};return{signupStep:r,setSignupStep:i,username:o,setUsername:s,password:c,setPassword:l,mfaChoice:j,setMfaChoice:P,passkeyRegLoading:R,passkeyRegError:B,handleRegisterPasskey:async()=>{z(!0),H(``);try{let e=await ee({name:`primary_passkey`,credential:await N(await te())}),t=e?.passkey?.id||e?.id;if(t)try{await q.wrapCurrentKeyForPasskey(t)}catch(e){console.warn(`Failed to wrap key for new passkey:`,e)}e.recovery_keys&&e.recovery_keys.length>0&&h(e.recovery_keys),i(`recovery`)}catch(e){console.error(`Passkey registration failed:`,e),H(V(e,Q))}finally{z(!1)}},handleChooseTotp:async()=>{P(`totp`),await le()},totpSetupToken:u,setTotpSetupToken:d,totpSetupData:f,setTotpSetupData:p,totpRecoveryKeys:m,setTotpRecoveryKeys:h,loading:g,error:v,setError:y,usernameFocused:b,setUsernameFocused:x,passwordFocused:S,setPasswordFocused:C,copiedRecovery:w,totpSetupLoading:E,totpSetupError:O,turnstileStatus:ie,turnstileRef:Y,isTurnstileEnabled:$,checkUsernameDuplicate:se,handleSignupUsernameSubmit:ce,handleSignupTotpConfirm:async e=>{if(e.preventDefault(),f){D(!0),A(``);try{let e=u.replace(/\s/g,``),t=crypto.randomUUID(),n=await re(e,t),r=await k({secret:f.secret,totpTokenHash:n,salt:t});r.recovery_keys&&r.recovery_keys.length>0&&h(r.recovery_keys),i(`recovery`)}catch(e){A(e.message||Q(`common.errorNetwork`))}finally{D(!1)}}},handleCopySignupRecoveryKeys:()=>{m&&navigator.clipboard.writeText(m.join(`
|
|
2
|
-
`)).then(()=>{T(!0),setTimeout(()=>T(!1),2e3)})},handleSignupSubmit:async t=>{if(t.preventDefault(),!ae(o)){y(Q(`auth.formatTipUsername`));return}if(!oe(c)){y(Q(`auth.formatTipPassword`));return}if($&&e?.turnstile_site_key&&!W){y(Q(`auth.turnstileRequired`));return}_(!0),y(``);try{let e=await K({username:o,password:await U(c,o),turnstileToken:W});if(e.accessToken&&M(e.accessToken),e.recoveryKey){h([e.recoveryKey]);try{await q.initUserE2eeWithRecoveryKey(e.recoveryKey)}catch(e){console.error(`Failed to initialize user E2EE with recovery key:`,e)}}P(`choose`),i(`totp`)}catch(e){e instanceof L&&ne({status:e.status},e.bodyText)?y(Q(`auth.passwordLeaked`)):y(V(e,Q)),window.turnstile&&window.turnstile.reset(),G(null)}finally{_(!1)}}}},be=({authConfig:e,turnstileReady:t,onSuccess:n,onToggleMode:r})=>{let{t:o}=a(),{signupStep:s,setSignupStep:c,username:l,setUsername:u,password:f,setPassword:p,mfaChoice:m,setMfaChoice:h,passkeyRegLoading:g,passkeyRegError:_,handleRegisterPasskey:b,handleChooseTotp:x,totpSetupToken:S,setTotpSetupToken:C,totpSetupData:w,totpRecoveryKeys:T,loading:E,error:D,setError:O,usernameFocused:k,setUsernameFocused:ee,passwordFocused:A,setPasswordFocused:j,copiedRecovery:M,totpSetupLoading:N,totpSetupError:te,turnstileStatus:F,turnstileRef:I,isTurnstileEnabled:L,checkUsernameDuplicate:R,handleSignupUsernameSubmit:z,handleSignupTotpConfirm:B,handleCopySignupRecoveryKeys:V,handleSignupSubmit:H}=ye({authConfig:e,turnstileReady:t,onSuccess:n});return e&&e.has_users!==!1&&e.registration_enabled===!1?(0,Q.jsxs)(`div`,{className:`space-y-6 text-center`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,Q.jsx)(`img`,{src:P,alt:`DNS Worker Logo`,className:`w-20 h-20 object-contain`}),(0,Q.jsx)(d,{className:`font-bold tracking-tight text-2xl mt-4`,children:o(`auth.signup`)})]}),(0,Q.jsx)(v,{intent:y.WARNING,icon:`lock`,title:o(`auth.registrationDisabledTitle`,`注册已停用`),children:o(`auth.registrationDisabledDesc`,`当前系统已暂停开放新用户注册,请联系系统管理员分配账号。`)}),(0,Q.jsx)(`div`,{className:`pt-4 border-t border-gray-100 dark:border-gray-800 flex justify-center items-center text-sm`,children:(0,Q.jsxs)(`button`,{onClick:r,className:`text-blue-600 dark:text-blue-400 font-semibold hover:underline bg-transparent border-none cursor-pointer flex items-center gap-1`,children:[(0,Q.jsx)(i,{size:16}),o(`auth.backToLogin`,`返回登录`)]})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col items-center mb-8 relative`,children:[s===`password`&&(0,Q.jsx)(`button`,{onClick:()=>{c(`username`),O(``)},className:`absolute left-0 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 bg-transparent border-none cursor-pointer`,title:`Back to username`,children:(0,Q.jsx)(i,{size:24})}),(0,Q.jsx)(`img`,{src:P,alt:`DNS Worker Logo`,className:`w-20 h-20 object-contain`}),(0,Q.jsx)(d,{className:`font-bold tracking-tight text-2xl mt-4`,children:s===`username`||s===`password`?e?.has_users===!1?o(`auth.registerAdminTitle`,`注册管理员账号`):o(`auth.signup`):s===`totp`?o(`auth.mfaSetupTitle`,`配置多因素认证 (MFA)`):o(`account.totp.recoveryKeysTitle`,`Save Recovery Keys`)}),(0,Q.jsx)(`p`,{className:`text-gray-500 mt-2 text-center text-sm leading-relaxed`,children:s===`username`||s===`password`?s===`password`?l:e?.has_users===!1?o(`auth.registerAdminDesc`,`系统尚无账号,首位注册用户将自动成为系统管理员。`):o(`auth.protectInternet`):s===`totp`?o(`auth.mfaSetupDesc`,`任选一种认证方式即可完成配置,保障账号安全。`):o(`account.totp.recoveryKeysWarning`,`Store keys safely.`)})]}),D&&(0,Q.jsx)(v,{intent:y.DANGER,className:`mb-6 rounded-xl`,title:o(`auth.error`),children:D}),s===`username`&&(0,Q.jsx)(he,{username:l,setUsername:u,usernameFocused:k,setUsernameFocused:ee,checkUsernameDuplicate:R,loading:E,onSubmit:z,onClearError:()=>O(e=>e===o(`auth.usernameExists`)?``:e)}),s===`password`&&(0,Q.jsx)(ge,{password:f,setPassword:p,passwordFocused:A,setPasswordFocused:j,loading:E,onSubmit:H,isTurnstileEnabled:L,turnstileRef:I,turnstileStatus:F}),s===`totp`&&(0,Q.jsx)(_e,{mfaChoice:m,setMfaChoice:h,onRegisterPasskey:b,passkeyRegLoading:g,passkeyRegError:_,onStartTotp:x,totpSetupData:w,totpSetupToken:S,setTotpSetupToken:C,totpSetupError:te,totpSetupLoading:N,onTotpSubmit:B,onSkip:()=>{T&&T.length>0?c(`recovery`):n()}}),s===`recovery`&&T&&(0,Q.jsx)(ve,{totpRecoveryKeys:T,copiedRecovery:M,onCopy:V,onSuccess:n}),s===`username`&&(0,Q.jsx)(`div`,{className:`mt-8 pt-6 border-t border-gray-100 dark:border-gray-800 text-center`,children:(0,Q.jsx)(`button`,{onClick:r,className:`text-blue-600 dark:text-blue-400 font-semibold hover:underline bg-transparent border-none cursor-pointer text-sm`,children:o(`auth.haveAccount`)})})]})},xe=({onSuccess:e})=>{let[t,n]=(0,Z.useState)(!0),[r,i]=(0,Z.useState)(!0),[o,s]=(0,Z.useState)(!1),{t:c}=a(),l=()=>{s(!0),setTimeout(()=>{n(e=>!e),s(!1)},300)},[u,d]=(0,Z.useState)(null),[f,m]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{(async()=>{try{let e=await R();d(e),e&&e.has_users===!1&&n(!1)}catch(e){console.error(`Failed to load auth config`,e)}})()},[]);let g=t?u?.turnstile_enabled_login:u?.turnstile_enabled_signup;return(0,Z.useEffect)(()=>{g&&u?.turnstile_site_key&&z(()=>{m(!0)})},[g,u]),(0,Q.jsxs)(`div`,{className:`flex flex-row min-h-screen bg-white dark:bg-gray-950 overflow-hidden relative`,children:[(0,Q.jsx)(`div`,{className:`hidden lg:block w-1/2 h-screen overflow-hidden border-r border-gray-100 dark:border-gray-900`,children:(0,Q.jsx)(J,{})}),(0,Q.jsx)(`div`,{className:`lg:hidden absolute inset-0 z-0 transition-opacity duration-500 cursor-pointer ${r?`opacity-25`:`opacity-70`}`,onClick:()=>i(!0),children:(0,Q.jsx)(J,{})}),!r&&(0,Q.jsx)(`div`,{className:`lg:hidden fixed bottom-12 left-1/2 -translate-x-1/2 z-50 animate-bounce`,children:(0,Q.jsx)(h,{large:!0,intent:`primary`,icon:`log-in`,text:c(`auth.loginBtn`),onClick:()=>i(!0),className:`shadow-2xl px-8 py-4 rounded-full`})}),(0,Q.jsxs)(`div`,{className:`flex-1 flex items-center justify-center p-4 relative z-10 bg-gray-50/50 dark:bg-gray-900/30 lg:bg-gray-50 lg:dark:bg-gray-900/50 transition-all duration-500 ease-in-out ${r?`translate-x-0 opacity-100`:`max-lg:translate-x-full max-lg:opacity-0 max-lg:pointer-events-none`}`,onClick:e=>{window.innerWidth<1024&&e.target===e.currentTarget&&i(!1)},children:[(0,Q.jsx)(`div`,{className:`absolute top-4 right-4 z-50`,children:(0,Q.jsx)(O,{})}),(0,Q.jsx)(`div`,{className:D(`w-full max-w-md transition-all duration-200 ease-in-out transform-gpu`,o?`blur-lg opacity-20 scale-95`:`blur-0 opacity-100 scale-100`),children:(0,Q.jsx)(T,{elevation:p.FOUR,className:`w-full p-8 rounded-2xl shadow-none! z-10 dark:bg-gray-900 border border-gray-100 dark:border-gray-800`,onClick:e=>e.stopPropagation(),children:t?(0,Q.jsx)(me,{authConfig:u,turnstileReady:f,onSuccess:e,onToggleMode:l}):(0,Q.jsx)(be,{authConfig:u,turnstileReady:f,onSuccess:e,onToggleMode:l})})})]})]})};export{xe as AuthView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{C as t,F as n,R as r,Zt as i,at as a,jt as o,k as s,lt as c}from"./vendor-react-CHk5ngkq.js";import{S as l,b as u}from"./vendor-icons-other-Bme3ywH9.js";import{C as d,E as f,H as p,N as m,O as h,S as g,T as _,V as v,f as y,h as b,r as x,u as S,w as C,x as w}from"./vendor-ui-core-sfZn2C08.js";import{_t as T}from"./vendor-utils-CnB7BG7m.js";import{$ as E,St as D,W as O,X as k,bt as A,dt as j,on as M,rt as N,tt as P,w as F}from"./index-CbTjGMTZ.js";var I=e(l(),1);const L=()=>{let{t:e}=i(),[t,n]=(0,I.useState)([]);return(0,I.useEffect)(()=>{O().then(t=>{t&&Array.isArray(t)&&n(t.map(t=>({label:e(t.label),url:t.url})))}).catch(e=>console.warn(`Failed to fetch preset filters from API`,e))},[e]),t};var R=e(u(),1);const z=({newUrl:e,setNewUrl:t,onAddList:n,syncing:r,loading:a,lists:o})=>{let{t:s}=i(),c=(0,R.jsx)(f,{className:`min-w-96`,children:L().map((e,t)=>(0,R.jsx)(C,{text:e.label,onClick:()=>n(e.url),disabled:o.some(t=>t.url===e.url),labelElement:(0,R.jsx)(`div`,{className:`flex flex-col items-end text-right`,children:(0,R.jsx)(`span`,{className:`text-[9px] opacity-85 max-w-xl truncate`,title:e.url,children:e.url})})},t))});return(0,R.jsx)(w,{elevation:p.ONE,className:`mb-6`,children:(0,R.jsxs)(`div`,{className:`flex gap-2 flex-col sm:flex-row`,children:[(0,R.jsx)(y,{fill:!0,size:`large`,placeholder:s(`filtering.urlPlaceholder`),value:e,onChange:e=>t(e.target.value),leftIcon:`globe`,rightElement:(0,R.jsx)(_,{content:c,placement:`bottom-end`,animation:`minimal`,arrow:!1,usePortal:!0,children:(0,R.jsx)(m,{variant:`minimal`,icon:`chevron-down`})})}),(0,R.jsx)(m,{intent:v.PRIMARY,size:`large`,icon:`plus`,onClick:()=>n(),className:`shrink-0`,loading:r||a,disabled:r||a,children:s(`filtering.addSubscription`)})]})})},B=({lists:e,onSelect:t})=>{let{t:n}=i(),r=[{key:`url`,header:n(`filtering.tableUrl`),cellClassName:`font-mono text-sm max-w-md truncate`,render:e=>e.url},{key:`lastSync`,header:n(`filtering.tableLastSync`),cellClassName:`text-xs opacity-60`,render:e=>e.last_synced_at?F(new Date(e.last_synced_at*1e3)):n(`filtering.neverSynced`)},{key:`status`,header:n(`filtering.tableStatus`),render:e=>{if(!e.enabled)return(0,R.jsx)(x,{intent:v.NONE,minimal:!0,children:n(`filtering.statusDisabled`,`Disabled`)});let t=!!e.sync_error,r=!!e.last_synced_at,i=n(`filtering.statusNormal`,`Active`),a=v.SUCCESS;return t&&(r?(i=n(`filtering.statusOutdated`,`Outdated`),a=v.WARNING):(i=n(`filtering.statusMissing`,`Missing`),a=v.DANGER)),(0,R.jsx)(x,{intent:a,minimal:!0,children:i})}}];return(0,R.jsx)(`div`,{className:`w-full max-w-full overflow-x-auto pb-4`,children:(0,R.jsxs)(S,{interactive:!0,striped:!0,className:`w-full min-w-max whitespace-nowrap`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsx)(`tr`,{children:r.map(e=>(0,R.jsx)(`th`,{className:e.headerClassName,children:e.header},e.key))})}),(0,R.jsx)(`tbody`,{children:e.map(e=>(0,R.jsx)(`tr`,{onClick:()=>t(e),className:`cursor-pointer`,children:r.map(t=>(0,R.jsx)(`td`,{className:t.cellClassName,children:t.render(e)},t.key))},e.id))})]})})},V=({profileId:e,selectedList:r,onClose:o,onCopy:l,onDelete:u,onToggleEnabled:d,onAllowDomain:f})=>{let{t:p}=i(),[_,S]=(0,I.useState)(``),[C,w]=(0,I.useState)(!1),[T,E]=(0,I.useState)(null),[D,O]=(0,I.useState)(null),[k,A]=(0,I.useState)(!1),[j,M]=(0,I.useState)(!1),[N,L]=(0,I.useState)(!1),z=(0,I.useRef)(0),B=()=>{z.current++,w(!1),S(``),E(null),O(null),M(!1)},V=async()=>{let t=_.trim().toLowerCase();if(!t||!r||(t=t.replace(/^https?:\/\//,``).split(`/`)[0].split(`:`)[0].replace(/\.+$/,``),!t))return;S(t);let n=++z.current,i=r.id;w(!0),O(null),E(null),M(!1);try{let r=await P(e,i,t);z.current===n&&E(r)}catch(e){z.current===n&&O(e instanceof Error?e.message:String(e))}finally{z.current===n&&w(!1)}},H=async e=>{if(r){L(!0);try{await d(r.id,e)}finally{L(!1)}}},U=async()=>{if(T?.matchedEntry){A(!0);try{await f(T.domain),M(!0)}catch(e){O(e instanceof Error?e.message:String(e))}finally{A(!1)}}};return(0,R.jsxs)(h,{isOpen:r!==null,onClose:()=>{B(),o()},title:p(`filtering.listDetails`,`List Details`),icon:`info-sign`,children:[(0,R.jsxs)(`div`,{className:`p-6 space-y-4`,children:[r?.sync_error&&(0,R.jsx)(g,{intent:v.WARNING,title:p(`filtering.syncError`),icon:`warning-sign`,children:r.sync_error}),(0,R.jsx)(`div`,{className:`bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700 break-all font-mono text-sm`,children:r?.url}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between border border-gray-200 dark:border-gray-700 rounded-lg p-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-sm font-bold`,children:p(`filtering.listEnabled`,`List active`)}),(0,R.jsx)(`div`,{className:`text-xs opacity-60`,children:p(`filtering.listEnabledHint`,`Disable to stop filtering with this list without deleting it. Its subscription and sync history are kept.`)})]}),(0,R.jsx)(b,{large:!0,checked:!!r?.enabled,disabled:N,onChange:e=>H(e.target.checked)})]}),(0,R.jsxs)(`div`,{className:`border border-gray-200 dark:border-gray-700 rounded-lg p-3 space-y-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-sm font-bold`,children:p(`filtering.checkDomain`,`Check a domain`)}),(0,R.jsx)(`div`,{className:`text-xs opacity-60`,children:p(`filtering.checkDomainHint`,`Lists are stored as compact filters, so their entries cannot be browsed. You can test any domain against this list instantly.`)})]}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(y,{fill:!0,placeholder:`example.com`,value:_,disabled:C,leftIcon:`globe-network`,onChange:e=>{S(e.target.value),E(null)},onKeyDown:e=>{e.key===`Enter`&&V()}}),(0,R.jsx)(m,{icon:(0,R.jsx)(n,{size:14}),text:p(`filtering.check`,`Check`),loading:C,disabled:!_.trim(),onClick:()=>void V()})]}),D&&(0,R.jsx)(g,{intent:v.DANGER,className:`text-xs`,children:D}),T&&!T.synced&&(0,R.jsx)(g,{intent:v.WARNING,className:`text-xs`,children:p(`filtering.checkNotSynced`,`This list has not finished syncing yet, so there is nothing to check against.`)}),T?.synced&&T.enabled===!1&&(0,R.jsx)(g,{intent:v.NONE,className:`text-xs`,children:p(`filtering.checkListDisabled`,`This list is currently disabled, so it is not filtering anything right now.`)}),T?.synced&&(0,R.jsx)(g,{intent:T.blocked?v.WARNING:v.SUCCESS,className:`text-xs`,icon:T.blocked?`ban-circle`:`tick-circle`,children:T.blocked?(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`div`,{children:[p(`filtering.checkBlocked`,`Blocked by this list`),T.matchedEntry&&T.matchedEntry!==T.domain&&(0,R.jsxs)(R.Fragment,{children:[` `,(0,R.jsx)(x,{minimal:!0,className:`font-mono`,children:T.matchedEntry}),` `,p(`filtering.checkViaParent`,`(matched a parent domain)`)]})]}),(0,R.jsx)(`div`,{className:`opacity-75`,children:T.falsePositiveRate?p(`filtering.checkProbabilisticRate`,{defaultValue:`Filters are probabilistic: roughly 1 match in {{odds}} is a false positive. Adding an exception also covers every subdomain of it.`,odds:Math.round(1/T.falsePositiveRate).toLocaleString()}):p(`filtering.checkProbabilistic`,`Filters are probabilistic, so a small share of matches are false positives. Adding an exception also covers every subdomain of it.`)}),j?(0,R.jsx)(x,{intent:v.SUCCESS,minimal:!0,children:p(`filtering.checkAllowed`,`Exception added - this domain now resolves`)}):(0,R.jsx)(m,{small:!0,icon:(0,R.jsx)(s,{size:12}),intent:v.PRIMARY,loading:k,text:p(`filtering.checkAllowAction`,`Allow anyway`),onClick:()=>void U()})]}):p(`filtering.checkNotBlocked`,`Not blocked by this list`)})]}),(0,R.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,R.jsxs)(`span`,{className:`text-xs opacity-50`,children:[p(`filtering.tableLastSync`),`:`,` `,r?.last_synced_at?F(new Date(r.last_synced_at*1e3)):`-`]}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(m,{icon:(0,R.jsx)(c,{size:14}),text:p(`setup.copyUrl`,`Copy link`),onClick:()=>{r&&l(r.url)}}),(0,R.jsx)(m,{icon:(0,R.jsx)(a,{size:14}),text:p(`setup.learnMore`,`Open link`),onClick:()=>{r&&window.open(r.url,`_blank`)}})]})]})]}),(0,R.jsxs)(`div`,{className:`p-4 border-t border-gray-100 dark:border-gray-800 flex justify-between`,children:[(0,R.jsx)(m,{icon:(0,R.jsx)(t,{size:14}),intent:v.DANGER,text:p(`rules.delete`,`Delete`),onClick:()=>{if(!r)return;let e=r.id;B(),u(e)}}),(0,R.jsx)(m,{onClick:()=>{B(),o()},text:p(`rules.close`,`Close`)})]})]})},H=({profileId:e,toasterRef:t})=>{let n=o(),a=M(),[s,c]=(0,I.useState)([]),[l,u]=(0,I.useState)(``),[f,p]=(0,I.useState)(!0),[h,_]=(0,I.useState)(!1),{t:y}=i(),[b,x]=(0,I.useState)(null),S=async()=>{p(!0);try{c(await j(e))}catch(e){console.error(`Failed to fetch filters`,e)}finally{p(!1)}},C=e=>{navigator.clipboard.writeText(e),t?.current?.show({message:y(`setup.copied`,`已复制到剪贴板`),intent:v.SUCCESS,icon:`duplicate`})},w=async t=>{let n=new Map(t.map(e=>[e.id,e.last_synced_at])),r=0;for(;r<15;){await new Promise(e=>setTimeout(e,2e3));try{let t=await j(e),r=!0;for(let e of t){if(n.has(e.id)&&e.last_synced_at===n.get(e.id)){r=!1;break}if(!n.has(e.id)&&!e.last_synced_at){r=!1;break}}if(r&&t.length>0)return c(t),!0}catch{}r++}return await S(),!1};return(0,I.useEffect)(()=>{S()},[e]),(0,R.jsxs)(`div`,{className:T(`md:px-8 w-full min-w-0 max-w-5xl mx-auto`,a?`p-1`:`px-8`),children:[(0,R.jsxs)(`div`,{className:`mb-8 flex flex-col md:flex-row justify-between items-start md:items-end gap-4`,children:[(0,R.jsxs)(`div`,{className:`w-full md:w-auto flex-1`,children:[a?(0,R.jsxs)(d,{minimal:!0,fill:a,children:[(0,R.jsx)(m,{active:!1,onClick:()=>n(`/dash/${e}/rules`),text:y(`rules.title`),large:!0}),(0,R.jsx)(m,{active:!0,onClick:()=>n(`/dash/${e}/filter`),text:y(`filtering.title`),large:!0})]}):(0,R.jsx)(`h1`,{className:`bp6-heading`,children:y(`rules.title`)}),(0,R.jsx)(`p`,{className:`bp6-text-muted mt-2!`,children:y(`filtering.subtitle`)})]}),(0,R.jsx)(m,{icon:(0,R.jsx)(r,{size:16}),text:y(`filtering.syncAll`),onClick:async()=>{_(!0);try{await A(e),t?.current?.show({message:y(`filtering.syncTaskStarted`),intent:v.PRIMARY,icon:`cloud-download`}),await w(s)&&t?.current?.show({message:y(`filtering.syncCheckComplete`),intent:v.SUCCESS,icon:`tick`})}catch(e){console.error(e)}finally{_(!1)}},loading:h||f,disabled:h||f||s.length===0,className:a?`w-full`:``})]}),(0,R.jsx)(g,{intent:v.WARNING,icon:`info-sign`,className:`mb-6`,children:(0,R.jsx)(`p`,{children:y(`filtering.formatDisclaimer`,`本系统只支持有限的 AdGuard 格式列表和纯域名列表。仅支持基础的拦截规则(如 ||example.com^),会绕过 "@@" 白名单,暂不支持 "$" 重写规则以及 "*" 省略规则。系统会自动匹配域名的所有子域名。`)})}),(0,R.jsx)(z,{newUrl:l,setNewUrl:u,onAddList:async n=>{let r=n||l;if(r){_(!0);try{await k(e,r),t?.current?.show({message:y(`filtering.addSuccess`),intent:v.SUCCESS,icon:`tick`}),u(``),t?.current?.show({message:y(`filtering.syncTaskStarted`),intent:v.PRIMARY,icon:`cloud-download`}),await w(s)&&t?.current?.show({message:y(`filtering.syncCheckComplete`),intent:v.SUCCESS,icon:`tick`})}catch(e){console.error(e)}finally{_(!1)}}},syncing:h,loading:f,lists:s}),(0,R.jsx)(B,{lists:s,onSelect:x}),(0,R.jsx)(V,{profileId:e,selectedList:b,onClose:()=>x(null),onCopy:C,onDelete:async n=>{try{await N(e,n),t?.current?.show({message:y(`filtering.deleteSuccess`),intent:v.PRIMARY,icon:`trash`}),x(null),await S()}catch(e){console.error(e)}},onToggleEnabled:async(n,r)=>{try{await D(e,n,r),x(e=>e&&e.id===n?{...e,enabled:r}:e),t?.current?.show({message:r?y(`filtering.listEnabledToast`,`List enabled - rebuilding filter`):y(`filtering.listDisabledToast`,`List disabled - rebuilding filter`),intent:v.PRIMARY,icon:r?`tick`:`disable`}),await S()}catch(e){console.error(e),t?.current?.show({message:e instanceof Error?e.message:String(e),intent:v.DANGER,icon:`error`})}},onAllowDomain:async n=>{await E(e,{type:`ALLOW`,pattern:n}),t?.current?.show({message:y(`filtering.allowRuleAdded`,`Exception added for {{domain}}`,{domain:n}),intent:v.SUCCESS,icon:`tick`})}})]})};export{H as FilteringView};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/services-Cwvmit1q.js","assets/index-CbTjGMTZ.js","assets/vendor-icons-other-Bme3ywH9.js","assets/vendor-icons-16-BgwRBCeU.js","assets/rolldown-runtime-C4Xdq4VV.js","assets/vendor-icons-20-X5NPN60g.js","assets/vendor-react-CHk5ngkq.js","assets/vendor-ui-core-sfZn2C08.js","assets/vendor-utils-CnB7BG7m.js","assets/vendor-i18next-cO7FDf_e.js","assets/index-919BqnYI.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{A as t,G as n,H as r,Q as i,Tt as a,V as o,X as s,Zt as c,_t as l,b as u,bt as d,ht as f,j as p,lt as m,nt as h,q as g,tt as _}from"./vendor-react-CHk5ngkq.js";import{S as v,b as y,x as b}from"./vendor-icons-other-Bme3ywH9.js";import{C as x,E as S,L as C,M as w,N as T,O as E,P as D,R as O,S as k,T as A,V as j,a as M,f as N,h as ee,l as P,o as F,p as I,r as L,u as te,w as R,x as ne,z}from"./vendor-ui-core-sfZn2C08.js";import{_t as B}from"./vendor-utils-CnB7BG7m.js";import{D as V,Vt as re,ct as ie,ft as ae,j as H,k as U,lt as W,on as oe,pt as G,ut as K,w as q}from"./index-CbTjGMTZ.js";import{n as se,t as J}from"./formatCountryName-CSBD8pP8.js";import{t as Y}from"./getFlagEmoji-_Wxhq0lT.js";import{t as ce}from"./SwipeableDrawer-BrmEzhuP.js";var X=e(v(),1),Z=e(y(),1);const le=({range:e,setRange:t,customRange:n,setCustomRange:r,nowStr:i,fetchLogs:a,isMobile:o,logRetentionDays:s})=>{let{t:u}=c(),d=[{key:`10m`,days:.007},{key:`1h`,days:.0416},{key:`24h`,days:1},{key:`7d`,days:7},{key:`30d`,days:30}].filter(e=>e.days<=s).map(e=>e.key);return(0,Z.jsx)(`div`,{className:`overflow-x-auto pb-1 -mx-4 px-4 md:mx-0 md:px-0`,children:(0,Z.jsxs)(x,{minimal:o,variant:o?void 0:`minimal`,children:[d.map(n=>(0,Z.jsx)(T,{active:e===n,onClick:()=>t(n),text:n.toUpperCase(),small:o},n)),(0,Z.jsx)(A,{content:(0,Z.jsxs)(`div`,{className:`p-4 space-y-2 w-64`,children:[(0,Z.jsx)(w,{children:u(`analytics.customRange`)}),(0,Z.jsx)(I,{label:u(`analytics.startTime`),children:(0,Z.jsx)(N,{type:`datetime-local`,max:n.end||i,value:n.start,onChange:e=>r({...n,start:e.target.value})})}),(0,Z.jsx)(I,{label:u(`analytics.endTime`),children:(0,Z.jsx)(N,{type:`datetime-local`,min:n.start,max:i,value:n.end,onChange:e=>r({...n,end:e.target.value})})}),(0,Z.jsx)(T,{fill:!0,intent:j.PRIMARY,text:u(`analytics.apply`),onClick:()=>{t(`custom`),a(`custom`,!0)}})]}),children:(0,Z.jsx)(T,{active:e===`custom`,icon:(0,Z.jsx)(l,{size:14}),text:o?``:u(`analytics.custom`),small:o})})]})})},ue=({statusFilter:e,setStatusFilter:t,isMobile:n})=>{let{t:r}=c(),i=(0,Z.jsxs)(S,{children:[(0,Z.jsx)(R,{icon:e===null?`tick`:void 0,text:r(`logs.allStatus`),onClick:()=>t(null)}),(0,Z.jsx)(P,{}),(0,Z.jsx)(R,{icon:e===`PASS`?`tick`:void 0,intent:j.SUCCESS,text:r(`logs.onlyPass`),onClick:()=>t(`PASS`)}),(0,Z.jsx)(R,{icon:e===`BLOCK`?`tick`:void 0,intent:j.DANGER,text:r(`logs.onlyBlock`),onClick:()=>t(`BLOCK`)}),(0,Z.jsx)(R,{icon:e===`REDIRECT`?`tick`:void 0,intent:j.WARNING,text:r(`logs.onlyRedirect`),onClick:()=>t(`REDIRECT`)})]}),a=(()=>{switch(e){case`PASS`:return{text:r(`logs.statusPass`),intent:j.SUCCESS};case`BLOCK`:return{text:r(`logs.statusBlock`),intent:j.DANGER};case`REDIRECT`:return{text:r(`logs.statusRedirect`),intent:j.WARNING};default:return{text:r(`logs.allStatus`),intent:j.NONE}}})();return(0,Z.jsx)(A,{content:i,placement:`bottom-start`,children:(0,Z.jsx)(T,{icon:(0,Z.jsx)(h,{size:14}),rightIcon:`caret-down`,intent:a.intent,text:a.text,variant:`outlined`,fill:n})})},de=({accessPointIdFilter:e,setAccessPointIdFilter:t,accessPoints:r,isMobile:i})=>{let{t:a}=c(),o=(0,Z.jsxs)(S,{children:[(0,Z.jsx)(R,{icon:e===null?`tick`:void 0,text:a(`logs.allAccessPoint`),onClick:()=>t(null)}),(0,Z.jsx)(P,{}),r.map(n=>(0,Z.jsx)(R,{icon:e===n.id?`tick`:void 0,text:n.name,onClick:()=>t(n.id)},n.id))]}),s=e&&r.find(t=>t.id===e)?.name||a(`logs.allAccessPoint`);return(0,Z.jsx)(A,{content:o,placement:`bottom-start`,children:(0,Z.jsx)(T,{icon:(0,Z.jsx)(n,{size:14}),rightIcon:`caret-down`,intent:e?j.PRIMARY:j.NONE,text:s,variant:`outlined`,fill:i})})},fe=Array.from(new Set(Object.values(se))).sort((e,t)=>e.localeCompare(t)),pe=({destCountryFilter:e,setDestCountryFilter:t,isMobile:n})=>{let{t:r,i18n:i}=c(),[a,o]=(0,X.useState)(!1),[s,l]=(0,X.useState)(``),u=(0,X.useMemo)(()=>{let e=i.language;return fe.map(t=>{let n=J(t,e),r=J(t,`en`);return{code:t,name:n||r||t,searchStr:`${t} ${n} ${r}`.toLowerCase()}})},[i.language]),d=(0,X.useMemo)(()=>{let e=s.trim().toLowerCase();return e?u.filter(t=>t.searchStr.includes(e)):u},[u,s]),f=(0,Z.jsxs)(`div`,{className:`w-72 flex flex-col p-1.5`,children:[(0,Z.jsx)(`div`,{className:`pb-1.5`,children:(0,Z.jsx)(N,{leftIcon:`search`,placeholder:r(`logs.searchCountry`,`Search country...`),value:s,onChange:e=>l(e.target.value),small:!0,autoFocus:!0,rightElement:s?(0,Z.jsx)(T,{icon:`cross`,variant:`minimal`,small:!0,onClick:()=>l(``)}):void 0})}),(0,Z.jsxs)(S,{className:`max-h-64 overflow-y-auto`,children:[!s&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(R,{icon:e===null?`tick`:void 0,text:r(`logs.allCountry`),onClick:()=>{t(null),o(!1)}}),(0,Z.jsx)(P,{})]}),d.length===0?(0,Z.jsx)(R,{disabled:!0,text:r(`logs.noMatchingCountries`,`No matching countries found`)}):d.map(n=>(0,Z.jsx)(R,{icon:e===n.code?`tick`:void 0,text:(0,Z.jsxs)(`span`,{className:`flex items-center justify-between gap-2 w-full`,children:[(0,Z.jsxs)(`span`,{className:`truncate`,children:[Y(n.code),` `,n.name]}),(0,Z.jsx)(`span`,{className:`text-xs text-gray-400 shrink-0 font-mono`,children:n.code})]}),onClick:()=>{t(n.code),o(!1)}},n.code))]})]}),p=e?`${Y(e)} ${J(e,i.language)||e} (${e})`:r(`logs.allCountry`);return(0,Z.jsx)(A,{content:f,placement:`bottom-start`,isOpen:a,onInteraction:e=>{o(e),e||l(``)},children:(0,Z.jsx)(T,{icon:(0,Z.jsx)(_,{size:14}),rightIcon:`caret-down`,intent:e?j.PRIMARY:j.NONE,text:p,variant:`outlined`,fill:n})})},me=({profileId:e,range:t,customRange:n,destCountryFilter:i,accessPointIdFilter:a,ispFilter:o,setIspFilter:s,isMobile:l})=>{let{t:u}=c(),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)([]),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(``),y=(0,X.useRef)(``),b=`${e}:${t}:${n.start?Math.floor(new Date(n.start).getTime()/1e3):``}:${n.end?Math.floor(new Date(n.end).getTime()/1e3):``}:${i||``}:${a||``}`,x=async()=>{g(!0);try{let r=Math.floor(Date.now()/1e3),o,s=r,c=new URLSearchParams;if(t===`custom`&&n.start&&n.end)o=Math.floor(new Date(n.start).getTime()/1e3),s=Math.floor(new Date(n.end).getTime()/1e3),c.set(`range`,`custom`),c.set(`start`,String(o)),c.set(`end`,String(s));else{switch(t){case`10m`:o=r-600;break;case`1h`:o=r-3600;break;case`24h`:o=r-86400;break;case`7d`:o=r-604800;break;case`30d`:o=r-2592e3;break;default:o=r-86400;break}c.set(`range`,t)}i&&c.set(`country_code`,i),a&&c.set(`access_point_id`,a);try{let t=await U.queryISPs({profileId:e,countryCode:i||void 0,since:o,until:s,accessPointId:a||void 0});if(t&&t.length>0){m(t),y.current=b,g(!1);return}}catch(e){console.warn(`[IspFilter] Local SQLite query failed, falling back to server:`,e)}let l=await W(e,`isps`,c.toString());m(Array.isArray(l)?l:[]),y.current=b}catch(e){console.error(`Failed to fetch ISPs for filter`,e)}finally{g(!1)}},C=e=>{f(e),e?y.current!==b&&x():v(``)},w=(0,X.useMemo)(()=>{let e=_.trim().toLowerCase();return e?p.filter(t=>t.name.toLowerCase().includes(e)):p},[p,_]),E=(0,Z.jsxs)(`div`,{className:`w-72 flex flex-col p-1.5`,children:[(0,Z.jsx)(`div`,{className:`pb-1.5`,children:(0,Z.jsx)(N,{leftIcon:`search`,placeholder:u(`logs.searchIsp`,`Search ISP...`),value:_,onChange:e=>v(e.target.value),small:!0,autoFocus:!0,rightElement:_?(0,Z.jsx)(T,{icon:`cross`,variant:`minimal`,small:!0,onClick:()=>v(``)}):void 0})}),(0,Z.jsx)(S,{className:`max-h-64 overflow-y-auto`,children:h?(0,Z.jsxs)(`div`,{className:`flex items-center justify-center p-6 text-gray-500 gap-2`,children:[(0,Z.jsx)(D,{size:16}),(0,Z.jsx)(`span`,{className:`text-xs`,children:u(`logs.loadingIsps`,`Loading ISPs...`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[!_&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(R,{icon:o===null?`tick`:void 0,text:u(`logs.allIsp`),onClick:()=>{s(null),f(!1)}}),(0,Z.jsx)(P,{})]}),w.length===0?(0,Z.jsx)(R,{disabled:!0,text:u(`logs.noMatchingIsps`,`No matching ISPs found`)}):w.map(e=>(0,Z.jsx)(R,{icon:o===e.name?`tick`:void 0,text:(0,Z.jsxs)(`span`,{className:`flex items-center justify-between gap-2 w-full`,children:[(0,Z.jsx)(`span`,{className:`truncate`,title:e.name,children:e.name}),(0,Z.jsx)(`span`,{className:`text-xs text-gray-400 shrink-0 font-mono`,children:e.count.toLocaleString()})]}),onClick:()=>{s(e.name),f(!1)}},e.name))]})})]}),O=o||u(`logs.allIsp`);return(0,Z.jsx)(A,{content:E,placement:`bottom-start`,isOpen:d,onInteraction:C,children:(0,Z.jsx)(T,{icon:(0,Z.jsx)(r,{size:14}),rightIcon:`caret-down`,intent:o?j.PRIMARY:j.NONE,text:O,variant:`outlined`,fill:l})})},he=({profileId:e,range:t,setRange:n,customRange:r,setCustomRange:i,nowStr:a,fetchLogs:o,isMobile:s,realtimeRefresh:l,setRealtimeRefresh:u,statusFilter:d,setStatusFilter:f,accessPointIdFilter:p,setAccessPointIdFilter:m,accessPoints:h,destCountryFilter:g,setDestCountryFilter:_,ispFilter:v,setIspFilter:y,searchQuery:b,setSearchQuery:x,stats:S,logRetentionDays:C,onExport:w,exporting:E})=>{let{t:D}=c(),[O,k]=(0,X.useState)(!0),A=d!==null||p!==null||g!==null||v!==null;return(0,Z.jsxs)(`div`,{className:`p-4 ${s&&O?`space-y-0`:`space-y-4`} shrink-0 bg-white/50 dark:bg-gray-900/50 backdrop-blur-sm border-b border-gray-100 dark:border-gray-800`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between w-full md:w-auto`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h2`,{className:`bp6-heading flex flex-wrap items-center gap-2 text-xl md:text-2xl m-0`,children:[D(`logs.title`),` `,(!s||!O)&&(0,Z.jsx)(L,{minimal:!0,round:!0,children:t===`custom`?D(`analytics.custom`):t.toUpperCase()}),S&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(L,{minimal:!0,round:!0,children:S.total.toLocaleString()}),(0,Z.jsx)(L,{minimal:!0,round:!0,intent:j.SUCCESS,children:S.pass.toLocaleString()}),(0,Z.jsx)(L,{minimal:!0,round:!0,intent:j.DANGER,children:S.block.toLocaleString()}),(0,Z.jsx)(L,{minimal:!0,round:!0,intent:j.WARNING,children:S.redirect.toLocaleString()})]})]}),!s&&(0,Z.jsx)(`p`,{className:`bp6-text-muted mt-1`,children:D(`logs.subtitle`)})]}),s&&(0,Z.jsx)(T,{icon:O?`chevron-down`:`chevron-up`,variant:`minimal`,onClick:()=>k(!O)})]}),(!s||!O)&&(0,Z.jsxs)(`div`,{className:`flex flex-col items-stretch md:items-end gap-2`,children:[(0,Z.jsx)(le,{range:t,setRange:n,customRange:r,setCustomRange:i,nowStr:a,fetchLogs:o,isMobile:s,logRetentionDays:C}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-4`,children:[(0,Z.jsx)(T,{icon:`download`,onClick:w,loading:E,title:D(`logs.export`,`Export Logs`),text:s?void 0:D(`logs.export`,`Export Logs`)}),(0,Z.jsx)(ee,{label:D(`logs.realtime`),checked:l,onChange:e=>u(e.target.checked),className:`mb-0!`}),(0,Z.jsx)(T,{icon:`refresh`,onClick:()=>o(t,!0,!1,!0),variant:`minimal`,small:s})]})]})]}),(!s||!O)&&(0,Z.jsxs)(`div`,{className:`flex flex-col md:flex-row items-stretch md:items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 md:flex md:items-center gap-2`,children:[A&&(0,Z.jsx)(`div`,{className:`col-span-2 md:contents`,children:(0,Z.jsx)(T,{icon:`filter-remove`,onClick:()=>{f(null),m(null),_(null),y(null)},variant:`minimal`,title:D(`logs.clearFilters`),text:s?D(`logs.clearFilters`):void 0,fill:s})}),(0,Z.jsx)(ue,{statusFilter:d,setStatusFilter:f,isMobile:s}),h.length>0&&(0,Z.jsx)(de,{accessPointIdFilter:p,setAccessPointIdFilter:m,accessPoints:h,isMobile:s}),(0,Z.jsx)(pe,{destCountryFilter:g,setDestCountryFilter:_,isMobile:s}),(0,Z.jsx)(me,{profileId:e,range:t,customRange:r,destCountryFilter:g,accessPointIdFilter:p,ispFilter:v,setIspFilter:y,isMobile:s})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2 flex-1 md:max-w-md justify-end`,children:(0,Z.jsx)(`div`,{className:`flex-1 md:max-w-xs`,children:(0,Z.jsx)(N,{leftIcon:`search`,placeholder:D(`logs.searchPlaceholder`),value:b,onChange:e=>x(e.target.value),rightElement:b?(0,Z.jsx)(T,{icon:`cross`,minimal:!0,onClick:()=>x(``)}):void 0,fill:!0})})})]})]})},ge=({logs:e,setSelectedLog:t,setIsDrawerOpen:n,lastLogElementRef:r,prevLatestTimestamp:i,realtimeRefresh:a})=>{let{t:o}=c();return(0,Z.jsx)(`div`,{className:`space-y-3 py-4`,children:e.map((c,l)=>{let u=a&&i!==null&&c.timestamp>i,d=(c.encrypt_version??0)>0||!!(c.kem_key_id||c.encrypted_payload),f=d&&(!c.domain||c.domain===`[Encrypted]`),p=d&&!!(c.domain&&c.domain!==`[Encrypted]`);return(0,Z.jsxs)(ne,{interactive:!0,onClick:()=>{t(c),n(!0)},className:B(`p-3 dark:bg-gray-900 rounded-xl border border-gray-200 dark:border-gray-800 shadow-sm overflow-hidden`,{"animate-row-glow":u}),ref:l===e.length-1?r:null,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between items-start mb-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[f?(0,Z.jsx)(s,{size:14,className:`text-amber-500 shrink-0`}):(0,Z.jsx)(`img`,{src:`/api/icon/${c.domain.replace(/^\*\./,``)}.ico`,className:`w-4 h-4 rounded-sm shrink-0`,alt:``,referrerPolicy:`no-referrer`,onError:e=>e.currentTarget.style.opacity=`0`}),(0,Z.jsx)(`span`,{className:B(`font-bold text-sm truncate`,{"italic text-gray-400 dark:text-gray-500":f}),children:f?o(`logs.encryptedRecord`,`[加密记录]`):c.domain}),p&&(0,Z.jsx)(s,{size:12,className:`text-emerald-500 shrink-0 opacity-80`})]}),(0,Z.jsx)(L,{minimal:!0,round:!0,intent:c.action===`PASS`?j.SUCCESS:c.action===`BLOCK`?j.DANGER:j.WARNING,className:`text-[10px] shrink-0`,children:c.action})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-mono opacity-50`,children:new Date(c.timestamp*1e3).toLocaleTimeString([],{hour12:!1})}),(0,Z.jsx)(`span`,{className:`text-[10px] bg-gray-100 dark:bg-gray-800 px-1 rounded opacity-60`,children:c.record_type}),c.access_point_name&&(0,Z.jsx)(`span`,{className:`text-[10px] opacity-50 truncate max-w-25`,children:c.access_point_name})]}),(0,Z.jsx)(`div`,{className:`text-[10px] opacity-40 font-mono italic`,children:c.latency?`${c.latency}ms`:``})]})]},c.id)})})},_e=({logs:e,setSelectedLog:t,setIsDrawerOpen:n,lastLogElementRef:r,prevLatestTimestamp:i,realtimeRefresh:a})=>{let{t:o}=c(),l=[{key:`time`,header:o(`logs.tableTime`),headerClassName:`w-24 rounded-tl-xl`,cellClassName:`font-mono text-[11px] opacity-60`,render:e=>new Date(e.timestamp*1e3).toLocaleTimeString([],{hour12:!1})},{key:`domain`,header:o(`logs.tableDomain`),headerClassName:`w-1/4`,render:e=>{let t=(e.encrypt_version??0)>0||!!(e.kem_key_id||e.encrypted_payload),n=t&&(!e.domain||e.domain===`[Encrypted]`),r=t&&!!(e.domain&&e.domain!==`[Encrypted]`);return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[n?(0,Z.jsx)(s,{size:14,className:`text-amber-500 shrink-0`}):(0,Z.jsx)(`img`,{src:`/api/icon/${e.domain.replace(/^\*\./,``)}.ico`,className:`w-4 h-4 rounded-sm shrink-0`,alt:``,referrerPolicy:`no-referrer`}),(0,Z.jsx)(`span`,{className:B(`font-bold text-sm truncate`,{"italic text-gray-400 dark:text-gray-500":n}),children:n?o(`logs.encryptedRecord`,`[加密记录]`):e.domain}),r&&(0,Z.jsx)(`span`,{title:o(`settings.e2eeEnabled`,`已加密`),className:`inline-flex items-center`,children:(0,Z.jsx)(s,{size:12,className:`text-emerald-500 shrink-0 opacity-80`})})]})}},{key:`answer`,header:o(`logs.tableAnswer`),headerClassName:`w-1/4`,cellClassName:`truncate font-mono text-[11px] opacity-70`,render:e=>e.answer||`-`},{key:`source`,header:o(`logs.tableSource`),headerClassName:`w-32`,render:e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(L,{minimal:!0,className:`font-mono text-[10px]`,children:Y(e.geo_country||`UN`)}),e.access_point_name&&(0,Z.jsx)(`span`,{className:`text-xs opacity-70 truncate max-w-20`,title:e.access_point_name,children:e.access_point_name})]})},{key:`type`,header:o(`logs.tableType`),headerClassName:`w-20`,cellClassName:`text-center`,render:e=>(0,Z.jsx)(`code`,{className:`text-[10px]`,children:e.record_type})},{key:`status`,header:o(`logs.tableStatus`),headerClassName:`w-28`,cellClassName:`text-center`,render:e=>(0,Z.jsx)(`span`,{className:B(`bp6-tag`,`bp6-fill`,`bp6-minimal`,`bp6-round`,{"bp6-intent-success":e.action===`PASS`,"bp6-intent-danger":e.action===`BLOCK`,"bp6-intent-warning":e.action===`REDIRECT`}),children:(0,Z.jsx)(`span`,{className:`bp6-text-overflow-ellipsis bp6-fill text-center`,children:e.action})})},{key:`reason`,header:o(`logs.tableReason`),headerClassName:`rounded-tr-xl`,cellClassName:`text-xs text-gray-500 italic truncate`,render:e=>e.reason||`-`}];return(0,Z.jsx)(`div`,{className:`min-w-full inline-block align-middle py-0`,children:(0,Z.jsx)(`div`,{className:`bg-white dark:bg-gray-900 rounded-xl border border-gray-200 dark:border-gray-800 shadow-sm overflow-visible`,children:(0,Z.jsxs)(te,{interactive:!0,striped:!0,className:`w-full table-fixed`,children:[(0,Z.jsx)(`thead`,{className:`sticky top-0 z-20 backdrop-blur-md`,children:(0,Z.jsx)(`tr`,{children:l.map(e=>(0,Z.jsx)(`th`,{className:B(`px-4 py-3 text-xs font-bold uppercase text-gray-500 bg-white/80 dark:bg-gray-900/80 border-b border-gray-100 dark:border-gray-800`,e.headerClassName),children:e.header},e.key))})}),(0,Z.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-gray-800`,children:e.map((o,s)=>{let c=a&&i!==null&&o.timestamp>i;return(0,Z.jsx)(`tr`,{onClick:()=>{t(o),n(!0)},className:B(`cursor-pointer`,{"animate-row-glow":c}),ref:s===e.length-1?r:null,children:l.map(e=>(0,Z.jsx)(`td`,{className:B(`px-4 py-3`,e.cellClassName),children:e.render(o,s)},e.key))},o.id)})})]})})})},ve=({logs:e,loading:t,loadingMore:n,hasMore:r,realtimeRefresh:i,isMobile:a,searchQuery:o,scrollContainerRef:s,lastLogElementRef:l,prevLatestTimestamp:u,setSelectedLog:d,setIsDrawerOpen:f,logRetentionDays:p})=>{let{t:m}=c();return(0,Z.jsxs)(`div`,{ref:s,className:B(`flex-1 overflow-y-auto relative`,a?`px-1`:`px-4`),children:[e.length===0&&!t?(0,Z.jsx)(`div`,{className:`py-20`,children:(0,Z.jsx)(k,{title:p===0?m(`logs.loggingDisabledTitle`,`日志记录已关闭`):m(o?`logs.noResults`:`logs.noRecords`),icon:p===0?`disable`:o?`search`:`outdated`,intent:p===0?j.WARNING:j.NONE,children:p===0?m(`logs.loggingDisabledDesc`,`当前配置的日志留存已设置为“关闭”,系统不记录任何查询日志。如需查看,请在设置中启用日志留存。`):o?m(`logs.noResultsDesc`,{query:o}):m(`logs.noRecordsDesc`)})}):a?(0,Z.jsx)(ge,{logs:e,setSelectedLog:d,setIsDrawerOpen:f,lastLogElementRef:l,prevLatestTimestamp:u,realtimeRefresh:i}):(0,Z.jsx)(_e,{logs:e,setSelectedLog:d,setIsDrawerOpen:f,lastLogElementRef:l,prevLatestTimestamp:u,realtimeRefresh:i}),(0,Z.jsx)(`div`,{className:`p-6 flex flex-col items-center`,children:n?(0,Z.jsx)(D,{size:16}):i?e.length>0&&(0,Z.jsx)(`span`,{className:`text-[10px] opacity-30 italic`,children:m(`logs.realtimeLoadMoreTip`)}):!r&&e.length>0&&(0,Z.jsx)(`span`,{className:`text-[10px] opacity-30 italic`,children:m(`logs.loadedAll`,{count:e.length})})})]})};function ye(e,t,n){let[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{if(e&&t?.id){o(!0),i(t);let e=new AbortController;return ae(n,t.id,t.timestamp,{signal:e.signal}).then(async r=>{if(!e.signal.aborted)try{let e=r?.encrypt_version??t.encrypt_version,a=await H.decryptLogEntry(n,r);i(n=>({...n||t,...a,encrypt_version:e??a.encrypt_version}))}catch{i(e=>({...e||t,...r}))}}).catch(e=>{e.name!==`AbortError`&&(console.error(e),i(e=>e||t))}).finally(()=>{e.signal.aborted||o(!1)}),()=>{e.abort()}}else i(null)},[e,t?.id,n]),{detailedLog:r,loading:a}}const Q=({label:e,value:t,bold:n,italic:r})=>(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:e}),(0,Z.jsx)(`span`,{className:B(`text-sm text-right`,n&&`font-bold`,r&&`italic`),children:t})]}),be=({selectedLog:e,detailedLog:t,loading:n})=>{let{t:r}=c(),i=t?.encrypt_version??e.encrypt_version??(t?.kem_key_id||e.kem_key_id?2:0),o=i>0||!!(e.kem_key_id||e.encrypted_payload||t?.kem_key_id||t?.encrypted_payload),l=i===2||!!(e.kem_key_id||t?.kem_key_id),u=o&&(!e.domain||e.domain===`[Encrypted]`);return(0,Z.jsx)(F,{title:r(`logs.basicInfo`),icon:(0,Z.jsx)(a,{size:16}),className:`shadow-none! rounded-lg!`,children:(0,Z.jsx)(M,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(Q,{label:r(`logs.detailDomain`),value:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 justify-end font-bold`,children:[u?(0,Z.jsx)(s,{size:14,className:`text-amber-500`}):(0,Z.jsx)(`img`,{src:`/api/icon/${e.domain.replace(/^\*\./,``)}.ico`,className:`w-4 h-4 rounded-sm`,alt:``,referrerPolicy:`no-referrer`,onError:e=>e.currentTarget.style.display=`none`}),(0,Z.jsx)(`span`,{className:B({"italic text-gray-400 dark:text-gray-500":u}),children:u?r(`logs.encryptedRecord`,`[加密记录]`):e.domain})]}),bold:!0}),(0,Z.jsx)(Q,{label:r(`logs.detailType`),value:e.record_type}),(0,Z.jsx)(Q,{label:r(`logs.detailLatency`),value:e.latency?`${e.latency} ms`:`-`}),(0,Z.jsx)(Q,{label:r(`logs.detailAccessPoint`),value:(()=>{let r=t?.access_point_name||e.access_point_name,i=t?.access_point_id||e.access_point_id;return r?i&&i!==r?(0,Z.jsx)(`span`,{title:i,className:`cursor-help`,children:r}):r:i?(0,Z.jsx)(`span`,{className:`font-mono text-xs`,children:i}):n?(0,Z.jsx)(D,{size:12}):`-`})()}),(0,Z.jsx)(Q,{label:r(`logs.detailProfile`),value:t?.profile_name||t?.client_ip||e.client_ip||(n?(0,Z.jsx)(D,{size:12}):`-`)}),(0,Z.jsx)(Q,{label:r(`logs.detailTime`),value:q(new Date(e.timestamp*1e3))}),(0,Z.jsx)(Q,{label:r(`logs.detailStatus`),value:(0,Z.jsx)(L,{minimal:!0,intent:e.action===`PASS`?j.SUCCESS:e.action===`BLOCK`?j.DANGER:j.WARNING,children:e.action})}),(0,Z.jsx)(Q,{label:r(`logs.detailUpstream`),value:t?.upstream||e.upstream||(n?(0,Z.jsx)(D,{size:12}):`-`)}),(0,Z.jsx)(Q,{label:r(`logs.detailReason`),value:e.reason||r(`logs.detailNoReason`),italic:!0}),(0,Z.jsx)(Q,{label:r(`logs.detailECS`),value:t?.ecs||e.ecs||(n?(0,Z.jsx)(D,{size:12}):`-`),italic:!0}),(0,Z.jsx)(Q,{label:r(`logs.detailIsClientEncrypted`,`是否用户端加密`),value:o?(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 justify-end`,children:[(0,Z.jsx)(s,{size:13,className:u?`text-amber-500`:`text-emerald-500`}),(0,Z.jsxs)(`span`,{className:B(`text-xs font-medium`,u?`text-amber-600 dark:text-amber-400`:`text-emerald-600 dark:text-emerald-400`),children:[u?r(`logs.encryptedLocked`,`是 (未解锁)`):r(`logs.encryptedYes`,`是`),l?` (PQC)`:``]})]}):(0,Z.jsx)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:r(`logs.notEncrypted`,`否`)})})]})})})},xe=({selectedLog:e})=>{let{t}=c(),n=e.record_type===`HTTPS`||e.record_type===`SVCB`||e.record_type===`TYPE65`||e.record_type===`TYPE64`,r=n&&(e.reason===`ECH Rewritten`||(e.reason?.toLowerCase().includes(`rewritten`)??!1));return(0,Z.jsx)(F,{title:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between w-full pr-2`,children:[(0,Z.jsx)(`span`,{children:t(`logs.resolutionResult`)}),r&&(0,Z.jsx)(L,{minimal:!0,intent:j.PRIMARY,className:`text-xs`,children:t(`logs.rewritten`,`已重写`)})]}),icon:(0,Z.jsx)(_,{size:16}),className:`shadow-none! rounded-lg!`,children:(0,Z.jsx)(M,{children:(0,Z.jsx)(`div`,{className:`bg-gray-50 dark:bg-gray-800 p-3 font-mono text-xs break-all leading-relaxed rounded-lg`,children:(()=>{if(!e.answer)return t(`logs.noResult`);let r=e.answer.split(`
|
|
3
|
-
`).map(e=>e.trim()).filter(Boolean);return r.length===0?t(`logs.noResult`):(0,Z.jsx)(`div`,{className:`space-y-2`,children:r.map((e,t)=>{let r=e.match(/^(\d+)\s+([^\s]+)(?:\s+(.*))?$/);if(r&&(n||e.includes(`alpn=`)||e.includes(`ech=`)||e.includes(`ipv4hint=`))){let e=r[1],n=r[2],i=(r[3]||``).split(/\s+/).filter(Boolean);return(0,Z.jsxs)(`div`,{className:`bg-white dark:bg-gray-900 p-2.5 rounded-md space-y-2 border border-gray-200 dark:border-gray-700`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsxs)(L,{minimal:!0,intent:j.PRIMARY,children:[`Priority `,e]}),(0,Z.jsxs)(`span`,{className:`font-semibold text-gray-700 dark:text-gray-300`,children:[`Target: `,n]})]}),i.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1 border-t border-gray-100 dark:border-gray-800 text-xs`,children:i.map((e,t)=>{let n=e.indexOf(`=`);if(n===-1)return(0,Z.jsx)(L,{minimal:!0,className:`font-mono`,children:e},t);let r=e.substring(0,n),i=e.substring(n+1);return r===`ech`?(0,Z.jsxs)(L,{minimal:!0,intent:j.SUCCESS,className:`font-mono break-all max-w-full select-all text-left whitespace-normal h-auto py-1 inline-block`,title:i,children:[(0,Z.jsx)(`span`,{className:`font-bold`,children:`ech:`}),` `,i]},t):r===`alpn`?(0,Z.jsxs)(L,{minimal:!0,intent:j.WARNING,className:`font-mono`,children:[(0,Z.jsx)(`span`,{className:`font-bold`,children:`alpn:`}),` `,i]},t):(0,Z.jsxs)(L,{minimal:!0,className:`font-mono`,children:[(0,Z.jsxs)(`span`,{className:`font-bold`,children:[r,`:`]}),` `,i]},t)})})]},t)}return(0,Z.jsx)(`div`,{className:`space-y-1`,children:e.split(`,`).map(e=>e.trim()).filter(Boolean).map((e,t)=>(0,Z.jsx)(`div`,{className:`text-xs font-mono text-gray-800 dark:text-gray-200 select-all`,children:e},t))},t)})})})()})})})},Se=({selectedLog:e,detailedLog:t,loading:n})=>{let{t:r}=c(),i=t?.client_ip||e.client_ip,a=t?.geo_country||e.geo_country,o=t?.dest_country_code||e.dest_country_code,s=t?.dest_country||e.dest_country,l=t?.dest_isp||e.dest_isp,d=null,f=t?.dest_geoip||e.dest_geoip;if(f)try{let e=JSON.parse(f);!o&&e.country_code&&(o=e.country_code);let t=[e.city,e.region,e.country].filter(Boolean),n=s||o||void 0;d={locationTitle:t.length>0?t.join(`, `):n,isp:e.isp||l||void 0,as:e.as||void 0}}catch{}return!d&&(s||o||l)&&(d={locationTitle:s||o||void 0,isp:l||void 0}),(0,Z.jsx)(F,{title:r(`logs.networkDetails`),icon:(0,Z.jsx)(u,{size:16}),className:`shadow-none! rounded-lg!`,children:(0,Z.jsx)(M,{children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-50 mb-1`,children:r(`logs.clientSource`)}),(0,Z.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:i||(n?(0,Z.jsx)(D,{size:12}):`-`)}),(a||n)&&(0,Z.jsx)(L,{minimal:!0,title:a||`Unknown`,children:a?Y(a):`-`})]})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`flex justify-between items-center mb-1`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-50`,children:r(`logs.destination`)}),(o||n)&&(0,Z.jsx)(L,{minimal:!0,title:s||o||`Unknown`,children:o?Y(o):`-`})]}),n&&!d?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-2`,children:(0,Z.jsx)(D,{size:16})}):d?(0,Z.jsx)(`div`,{className:`bg-gray-50 dark:bg-gray-800 p-3 rounded-lg mt-1`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Z.jsx)(g,{size:16,className:`oklch(60.9% 0.126 221.723) mt-1 shrink-0`}),(0,Z.jsxs)(`div`,{children:[d.locationTitle&&(0,Z.jsx)(`div`,{className:`font-bold text-sm`,children:d.locationTitle}),(d.isp||d.as)&&(0,Z.jsxs)(`div`,{className:`text-xs opacity-70 mt-1`,children:[d.isp,d.as&&(0,Z.jsx)(`span`,{className:`opacity-60 block mt-0.5`,children:d.as})]})]})]})}):(0,Z.jsx)(`div`,{className:`text-xs opacity-50 py-1`,children:`-`})]})]})})})},Ce=({selectedLog:e,onQuickAction:n})=>{let{t:r}=c(),i=(e.encrypt_version??0)>0&&(!e.domain||e.domain===`[Encrypted]`);return(0,Z.jsx)(F,{title:r(`logs.quickActions`),icon:(0,Z.jsx)(o,{size:16}),className:`shadow-none! rounded-lg!`,children:(0,Z.jsx)(M,{children:i?(0,Z.jsx)(`p`,{className:`text-xs text-center text-gray-500 italic py-2 m-0`,children:r(`settings.e2eeUnlockPrompt`,`此记录已加密,请先解锁私钥后再进行操作。`)}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(T,{fill:!0,intent:j.SUCCESS,icon:(0,Z.jsx)(t,{size:16}),text:r(`logs.actionAllow`),onClick:()=>n?.(e.domain,`ALLOW`)}),(0,Z.jsx)(T,{fill:!0,intent:j.DANGER,icon:(0,Z.jsx)(p,{size:16}),text:r(`logs.actionBlock`),onClick:()=>n?.(e.domain,`BLOCK`)}),(0,Z.jsx)(T,{fill:!0,icon:(0,Z.jsx)(d,{size:16}),text:r(`logs.actionRedirect`),onClick:()=>n?.(e.domain,`REDIRECT`,e.record_type)})]})})})},we=({isDrawerOpen:e,setIsDrawerOpen:t,selectedLog:n,profileId:r,isMobile:i,onQuickAction:o})=>{let{t:s}=c(),{detailedLog:l,loading:u}=ye(e,n,r);return(0,Z.jsx)(ce,{isOpen:e&&n!==null,onClose:()=>t(!1),title:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(a,{size:18}),(0,Z.jsx)(`span`,{children:s(`logs.logDetails`)})]}),icon:`info-sign`,size:i?`100%`:`450px`,children:n&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(be,{selectedLog:n,detailedLog:l,loading:u}),(0,Z.jsx)(xe,{selectedLog:n}),(0,Z.jsx)(Se,{selectedLog:n,detailedLog:l,loading:u}),(0,Z.jsx)(Ce,{selectedLog:n,onQuickAction:o})]})})},Te=({isMobile:e,unlocking:t,onUnlockPasskey:n,onOpenRecoveryDialog:r})=>{let{t:a}=c();return(0,Z.jsx)(`div`,{className:B(`mb-2 shrink-0`,e?`px-2`:`px-4`),children:(0,Z.jsx)(k,{intent:j.PRIMARY,icon:`lock`,title:a(`settings.e2eeTitle`,`端到端加密日志`),children:(0,Z.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3 mt-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs opacity-80 m-0`,children:a(`settings.e2eeUnlockPrompt`,`日志已通过端到端加密保护。请验证已授权的硬件 Passkey 或输入紧急恢复密钥以在本地解密。`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap shrink-0`,children:[(0,Z.jsx)(T,{intent:j.PRIMARY,icon:`key`,small:!0,loading:t,onClick:n,className:`font-medium`,children:a(`settings.e2eeUnlockNow`,`验证 Passkey 解锁`)}),(0,Z.jsx)(T,{intent:j.NONE,icon:(0,Z.jsx)(i,{size:14}),small:!0,disabled:t,onClick:r,className:`font-medium`,children:a(`settings.e2eeUnlockRecovery`,`使用恢复密钥解锁`)})]})]})})})},Ee=({isOpen:e,onClose:t,recoveryKeyInput:n,setRecoveryKeyInput:r,recoveryError:i,unlocking:a,onSubmit:o})=>{let{t:s}=c();return(0,Z.jsx)(E,{isOpen:e,onClose:t,title:s(`account.e2ee.unlockWithRecoveryTitle`,`使用恢复密钥解锁`),icon:`key`,className:`dark:bg-gray-900`,children:(0,Z.jsxs)(`form`,{onSubmit:o,children:[(0,Z.jsxs)(`div`,{className:C,children:[(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:s(`account.e2ee.unlockWithRecoveryDesc`,`请输入 30 位紧急恢复密钥。注意:根据单次使用规则,恢复密钥验证成功后将立即自动轮换。`)}),i&&(0,Z.jsx)(k,{intent:j.DANGER,className:`mb-3 text-xs`,children:i}),(0,Z.jsx)(I,{label:s(`account.e2ee.recoveryKeyInputLabel`,`恢复密钥`),labelFor:`recovery-key-input-logs`,children:(0,Z.jsx)(N,{id:`recovery-key-input-logs`,placeholder:`123456-789012-345678-901234-567890`,value:n,onChange:e=>r(e.target.value),leftIcon:`key`,className:`font-mono text-xs`,autoFocus:!0})})]}),(0,Z.jsx)(`div`,{className:O,children:(0,Z.jsxs)(`div`,{className:z,children:[(0,Z.jsx)(T,{onClick:t,text:s(`common.cancel`,`取消`)}),(0,Z.jsx)(T,{type:`submit`,intent:j.PRIMARY,loading:a,disabled:!n.trim(),text:s(`account.e2ee.unlockConfirm`,`解锁日志`)})]})})]})})},De=({rotatedKey:e,onClose:t,copiedKey:n,onCopyKey:r})=>{let{t:i}=c();return(0,Z.jsxs)(E,{isOpen:!!e,onClose:t,title:i(`account.recoveryKey.autoRotatedTitle`,`恢复密钥已自动轮换`),icon:`warning-sign`,isCloseButtonShown:!1,canOutsideClickClose:!1,className:`dark:bg-gray-900`,children:[(0,Z.jsxs)(`div`,{className:C,children:[(0,Z.jsx)(k,{intent:j.WARNING,icon:(0,Z.jsx)(p,{size:16}),className:`mb-4 text-xs`,children:i(`account.recoveryKey.autoRotatedNotice`,`根据恢复密钥单次使用规则,您的原恢复密钥已失效,系统已为您生成全新 30 位紧急恢复密钥。请务必立即复制并妥善离线保存,关闭后将无法再次查看!`)}),e&&(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`div`,{className:`p-3 bg-gray-100 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700 font-mono text-center text-lg font-bold tracking-widest select-all text-gray-900 dark:text-gray-100`,children:e}),(0,Z.jsx)(`div`,{className:`flex justify-center`,children:(0,Z.jsx)(T,{intent:j.PRIMARY,icon:n?(0,Z.jsx)(f,{size:14,className:`text-green-400`}):(0,Z.jsx)(m,{size:14}),text:n?i(`common.copied`,`已复制`):i(`common.copyKey`,`复制新恢复密钥`),onClick:()=>r(e)})})]})]}),(0,Z.jsx)(`div`,{className:O,children:(0,Z.jsx)(`div`,{className:z,children:(0,Z.jsx)(T,{intent:j.SUCCESS,onClick:t,text:i(`account.recoveryKey.savedAndClose`,`我已妥善保存并继续`)})})})]})};function Oe(e){let[t,n]=(0,X.useState)(`24h`),[r,i]=(0,X.useState)({start:``,end:``}),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)([]),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(``);return(0,X.useEffect)(()=>{ie(e).then(u).catch(console.error)},[e]),(0,X.useEffect)(()=>{m(null)},[d]),{range:t,setRange:n,customRange:r,setCustomRange:i,statusFilter:a,setStatusFilter:o,accessPointIdFilter:s,setAccessPointIdFilter:c,accessPoints:l,destCountryFilter:d,setDestCountryFilter:f,ispFilter:p,setIspFilter:m,searchQuery:h,setSearchQuery:g}}function ke(e){let[t,n]=(0,X.useState)(30);return(0,X.useEffect)(()=>{K(e).then(e=>{try{let t=JSON.parse(e.settings||`{}`);n(t.log_retention_days===void 0?30:Number(t.log_retention_days))}catch(e){console.error(`[useProfileRetention] Failed to parse settings:`,e)}}).catch(e=>console.error(`[useProfileRetention] Failed to fetch profile details:`,e))},[e]),t}function Ae(e,t){let n=Math.floor(Date.now()/1e3);if(e===`custom`&&t.start&&t.end)return{since:Math.floor(new Date(t.start).getTime()/1e3),until:Math.floor(new Date(t.end).getTime()/1e3)};let r;switch(e){case`10m`:r=n-600;break;case`1h`:r=n-3600;break;case`24h`:r=n-86400;break;case`7d`:r=n-604800;break;case`30d`:r=n-2592e3;break;default:r=n-86400;break}return{since:r,until:n}}function je({profileId:e,range:t,customRange:n,statusFilter:r,accessPointIdFilter:i,destCountryFilter:a,ispFilter:o,searchQuery:s,realtimeRefresh:c}){let[l,u]=(0,X.useState)([]),[d,f]=(0,X.useState)(!0),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(!0),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(null),x=(0,X.useRef)([]);(0,X.useEffect)(()=>{x.current=l},[l]);let S=(0,X.useRef)(null),C=(0,X.useRef)(!1);return(0,X.useEffect)(()=>()=>{S.current&&S.current.abort()},[]),{logs:l,setLogs:u,loading:d,loadingMore:p,hasMore:h,setHasMore:g,stats:_,setStats:v,prevLatestTimestamp:y,setPrevLatestTimestamp:b,fetchLogs:(0,X.useCallback)(async(t,l=!0,d=!1,p=!1)=>{S.current&&S.current.abort();let h=new AbortController;S.current=h,C.current=!0,l?f(!0):m(!0);try{let _=c?25:50,{since:y,until:w}=Ae(t,n),T=!1;try{if(await U.init()&&!h.signal.aborted){let t=!l&&x.current.length>0?x.current[x.current.length-1].timestamp:void 0;if(l){let t=await U.queryLogs({profileId:e,search:s||void 0,action:r||void 0,accessPointId:i||void 0,destCountry:a||void 0,isp:o||void 0,since:y,until:w,before:void 0,limit:_,offset:0});if(h.signal.aborted)return;t.rows.length>0&&(T=!0,b(d&&x.current.length>0?x.current[0].timestamp:null),u(t.rows),g(c?!1:t.rows.length>=_),c&&t.rows.length>0&&V.updateCursor(t.rows[0].timestamp,t.rows[0].id),t.stats&&v(t.stats),f(!1));try{let n=await U.syncProfileLogs(e,void 0,y,h.signal,p);if(!h.signal.aborted&&(n>0||t.rows.length===0)){if(t=await U.queryLogs({profileId:e,search:s||void 0,action:r||void 0,accessPointId:i||void 0,destCountry:a||void 0,isp:o||void 0,since:y,until:w,before:void 0,limit:_,offset:0}),h.signal.aborted)return;T=!0,b(d&&x.current.length>0?x.current[0].timestamp:null),u(t.rows),g(c?!1:t.rows.length>=_),c&&t.rows.length>0&&V.updateCursor(t.rows[0].timestamp,t.rows[0].id),t.stats&&v(t.stats)}else !h.signal.aborted&&t.rows.length>0&&(T=!0)}catch(e){e.name!==`AbortError`&&console.warn(`[useLogsFetcher] Incremental sync error:`,e)}}else if(t!==void 0){let n=await U.queryLogs({profileId:e,search:s||void 0,action:r||void 0,accessPointId:i||void 0,destCountry:a||void 0,isp:o||void 0,since:y,until:w,before:t,limit:_,offset:0});if(h.signal.aborted)return;if(n.rows.length>=_)T=!0,u(e=>[...e,...n.rows]),g(c?!1:n.rows.length>=_);else if(t>y)try{let l=await U.backfillLogs(e,t,y,_,h.signal);if(h.signal.aborted)return;if(T=!0,l.length>0){let n=await U.queryLogs({profileId:e,search:s||void 0,action:r||void 0,accessPointId:i||void 0,destCountry:a||void 0,isp:o||void 0,since:y,until:w,before:t,limit:_,offset:0});if(h.signal.aborted)return;u(e=>[...e,...n.rows]),g(c?!1:n.rows.length>=_&&l.length>=_)}else n.rows.length>0&&u(e=>[...e,...n.rows]),g(!1)}catch(e){e.name!==`AbortError`&&console.warn(`[useLogsFetcher] Backfill error:`,e),n.rows.length>0&&u(e=>[...e,...n.rows]),T=!0,g(!1)}else T=!0,n.rows.length>0&&u(e=>[...e,...n.rows]),g(!1)}else T=!0,g(!1);if(T&&x.current.length>0){let e=Array.from(new Set(x.current.map(e=>e.domain)));`serviceWorker`in navigator&&navigator.serviceWorker.controller&&navigator.serviceWorker.controller.postMessage({type:`PREFETCH_ICONS`,domains:e})}}}catch(e){console.warn(`[useLogsFetcher] Local SQLite failed, falling back to server:`,e),T=!1}if(T){S.current===h&&(f(!1),m(!1),C.current=!1);return}let E=new URLSearchParams({range:t,limit:String(_)});t===`custom`&&n.start&&n.end&&(E.set(`start`,String(y)),E.set(`end`,String(w))),r&&E.set(`status`,r),i&&E.set(`access_point_id`,i),a&&E.set(`dest_country`,a),o&&E.set(`isp`,o),s&&E.set(`search`,s),!l&&x.current.length>0&&E.set(`before`,String(x.current[x.current.length-1].timestamp));let D=G(e,E.toString(),{signal:h.signal}),O=Promise.resolve(null);if(l){let r=new URLSearchParams({range:t});t===`custom`&&n.start&&n.end&&(r.set(`start`,String(y)),r.set(`end`,String(w))),s&&r.set(`search`,s),O=W(e,`summary`,r.toString(),{signal:h.signal})}let[k,A]=await Promise.all([D,O]);if(l){if(b(d&&x.current.length>0?x.current[0].timestamp:null),u(k),g(c?!1:k.length>=_),A){let e={total:0,pass:0,block:0,redirect:0};A.forEach(t=>{let n=t.count;e.total+=n,t.action===`PASS`?e.pass=n:t.action===`BLOCK`?e.block=n:t.action===`REDIRECT`&&(e.redirect=n)}),v(e)}}else u(e=>[...e,...k]),g(c?!1:k.length>=_);if(k&&k.length>0){c&&V.updateCursor(k[0].timestamp,k[0].id);let e=Array.from(new Set(k.map(e=>e.domain)));`serviceWorker`in navigator&&navigator.serviceWorker.controller&&navigator.serviceWorker.controller.postMessage({type:`PREFETCH_ICONS`,domains:e})}}catch(e){e.name!==`AbortError`&&console.error(e)}finally{S.current===h&&(f(!1),m(!1),C.current=!1)}},[e,c,n,s,r,i,a,o]),isFetchingRef:C,logsRef:x}}function Me({realtimeRefresh:e,statusFilter:t,accessPointIdFilter:n,destCountryFilter:r,ispFilter:i,searchQuery:a,pageSize:o,logsRef:s,setLogs:c,setStats:l,setPrevLatestTimestamp:u}){(0,X.useEffect)(()=>{if(e)return V.onNewLogs(e=>{if(!e||e.length===0)return;let d=e.filter(e=>{if(t&&e.action!==t||n&&e.access_point_id!==n||r&&(e.dest_country_code||e.dest_country)!==r||i&&e.dest_isp!==i)return!1;if(a){let t=a.toLowerCase(),n=e.domain?.toLowerCase().includes(t),r=e.client_ip?.toLowerCase().includes(t),i=e.reason?.toLowerCase().includes(t);if(!n&&!r&&!i)return!1}return!0});d.length!==0&&(u(s.current.length>0?s.current[0].timestamp:null),c(e=>{let t=new Set(e.map(e=>`${e.timestamp}-${e.id}`)),n=d.filter(e=>!t.has(`${e.timestamp}-${e.id}`));return n.length===0?e:[...n,...e].slice(0,o)}),l(t=>{if(!t)return t;let n=0,r=0,i=0;for(let t of e)t.action===`PASS`?n++:t.action===`BLOCK`?r++:t.action===`REDIRECT`&&i++;return{total:t.total+e.length,pass:t.pass+n,block:t.block+r,redirect:t.redirect+i}}))})},[e,t,n,r,i,a,o,s,c,l,u])}function Ne({profileId:e,range:t,customRange:n,statusFilter:r,accessPointIdFilter:i,destCountryFilter:a,ispFilter:o,searchQuery:s,realtimeRefresh:c}){let l=ke(e),{logs:u,setLogs:d,loading:f,loadingMore:p,hasMore:m,stats:h,setStats:g,prevLatestTimestamp:_,setPrevLatestTimestamp:v,fetchLogs:y,isFetchingRef:b,logsRef:x}=je({profileId:e,range:t,customRange:n,statusFilter:r,accessPointIdFilter:i,destCountryFilter:a,ispFilter:o,searchQuery:s,realtimeRefresh:c});Me({realtimeRefresh:c,statusFilter:r,accessPointIdFilter:i,destCountryFilter:a,ispFilter:o,searchQuery:s,pageSize:25,logsRef:x,setLogs:d,setStats:g,setPrevLatestTimestamp:v});let S=(0,X.useRef)(null),C=(0,X.useRef)(null),w=(0,X.useCallback)(()=>{c||b.current||f||p||!m||y(t,!1)},[f,p,m,t,c,y,b]),T=(0,X.useCallback)(e=>{C.current&&C.current.disconnect(),!(f||p||c||!m)&&(C.current=new IntersectionObserver(e=>{e[0]?.isIntersecting&&m&&!b.current&&w()},{root:S.current,rootMargin:`100px`}),e&&C.current.observe(e))},[f,p,m,w,c,b]);return(0,X.useEffect)(()=>{if(t===`custom`&&(!n.start||!n.end))return;let e=setTimeout(()=>{y(t,!0)},s?500:0);return()=>clearTimeout(e)},[t,n.start,n.end,s,y]),{logs:u,loading:f,loadingMore:p,hasMore:m,stats:h,logRetentionDays:l,prevLatestTimestamp:_,scrollContainerRef:S,lastLogElementRef:T,fetchLogs:y,isFetchingRef:b,logsRef:x}}function Pe({profileId:e,range:t,searchQuery:n,realtimeRefresh:r,scrollContainerRef:i,isFetchingRef:a,fetchLogs:o,logsRef:s}){let c=(0,X.useRef)({range:t,searchQuery:n,fetchLogs:o,logsRef:s});(0,X.useEffect)(()=>{c.current={range:t,searchQuery:n,fetchLogs:o,logsRef:s}}),(0,X.useEffect)(()=>{if(!r){V.disconnect();return}let t=!1,n=null,o=()=>{n||=setInterval(()=>{let{range:e,searchQuery:n,fetchLogs:r}=c.current;!t&&document.visibilityState===`visible`&&i.current&&i.current.scrollTop<50&&!a.current&&!n&&e!==`custom`&&r(e,!0,!0)},8e3)},s=()=>{n&&=(clearInterval(n),null)},l=V.onStatusChange(e=>{t=e,e?s():o()}),u=c.current.logsRef.current,d=u.length>0?u[0]:null,f=d?d.timestamp:Math.floor(Date.now()/1e3)-60,p=d?d.id:0;V.connect(e,f,p);let m=setTimeout(()=>{t||o()},2500),h=()=>{if(document.visibilityState===`visible`)if(t){let e=c.current.logsRef.current,t=e.length>0?e[0]:null;t&&V.updateCursor(t.timestamp,t.id)}else{let{range:e,fetchLogs:t}=c.current;t(e,!0,!0)}};return document.addEventListener(`visibilitychange`,h),()=>{clearTimeout(m),s(),l(),V.disconnect(),document.removeEventListener(`visibilitychange`,h)}},[e,r])}function $(e){let t=new Date(e*1e3),n=-t.getTimezoneOffset(),r=n>=0?`+`:`-`,i=e=>String(e).padStart(2,`0`);return t.getFullYear()+`-`+i(t.getMonth()+1)+`-`+i(t.getDate())+`T`+i(t.getHours())+`:`+i(t.getMinutes())+`:`+i(t.getSeconds())+`.`+(e=>String(e).padStart(3,`0`))(t.getMilliseconds())+(n===0?`Z`:r+i(Math.floor(Math.abs(n)/60))+`:`+i(Math.abs(n)%60))}function Fe(e){let t=[`profile_id`,`access_point_id`,`time`,`client_ip`,`geo_country`,`domain`,`record_type`,`action`,`reason`,`answer`,`dest_geoip`,`ecs`,`upstream`,`latency`],n=[t.join(`,`)];for(let r of e){let e=t.map(e=>{let t=``;t=e===`time`?$(r.timestamp):r[e]!==null&&r[e]!==void 0?String(r[e]):``;let n=t.replace(/"/g,`""`);return n.includes(`,`)||n.includes(`
|
|
4
|
-
`)||n.includes(`\r`)||n.includes(`"`)?`"${n}"`:n});n.push(e.join(`,`))}return n.join(`
|
|
5
|
-
`)}function Ie(e,t){let n=new Blob([e],{type:`text/csv;charset=utf-8;`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.setAttribute(`href`,r),i.setAttribute(`download`,t),document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}function Le(e,t,n,r){return`query_logs_${e}_${$(t)}_${$(n)}_${r.toString()}.csv`}function Re({profileId:e,range:t,customRange:n,statusFilter:r,accessPointIdFilter:i,destCountryFilter:a,ispFilter:o,searchQuery:s,toasterRef:l}){let{t:u}=c(),[d,f]=(0,X.useState)(!1);return{exporting:d,handleExportLogs:async()=>{f(!0);try{let c=new URLSearchParams({range:t});if(t===`custom`&&n.start&&n.end){let e=Math.floor(new Date(n.start).getTime()/1e3),t=Math.floor(new Date(n.end).getTime()/1e3);c.set(`start`,String(e)),c.set(`end`,String(t))}r&&c.set(`status`,r),i&&c.set(`access_point_id`,i),a&&c.set(`dest_country`,a),o&&c.set(`isp`,o),s&&c.set(`search`,s);let{exportProfileLogs:d}=await b(async()=>{let{exportProfileLogs:e}=await import(`./services-Cwvmit1q.js`);return{exportProfileLogs:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),f=await d(e,c.toString());if(!f||f.length===0){l?.current?.show({message:u(`logs.noResults`,`No logs found to export`),intent:j.WARNING});return}Ie(Fe(f),Le(e,f[0].timestamp,f[f.length-1].timestamp,c)),l?.current?.show({message:u(`logs.exportSuccess`,`Logs exported successfully`),intent:j.SUCCESS})}catch(e){console.error(`Failed to export logs`,e),l?.current?.show({message:u(`logs.exportError`,`Failed to export logs`),intent:j.DANGER})}finally{f(!1)}}}}function ze({profileId:e,toasterRef:t}){let[n,r]=(0,X.useState)(!1),i=Oe(e),a=Ne({profileId:e,realtimeRefresh:n,range:i.range,customRange:i.customRange,statusFilter:i.statusFilter,accessPointIdFilter:i.accessPointIdFilter,destCountryFilter:i.destCountryFilter,ispFilter:i.ispFilter,searchQuery:i.searchQuery});Pe({profileId:e,realtimeRefresh:n,range:i.range,searchQuery:i.searchQuery,scrollContainerRef:a.scrollContainerRef,isFetchingRef:a.isFetchingRef,fetchLogs:a.fetchLogs,logsRef:a.logsRef});let o=Re({profileId:e,range:i.range,customRange:i.customRange,statusFilter:i.statusFilter,accessPointIdFilter:i.accessPointIdFilter,destCountryFilter:i.destCountryFilter,ispFilter:i.ispFilter,searchQuery:i.searchQuery,toasterRef:t});return{realtimeRefresh:n,setRealtimeRefresh:r,...i,...a,...o}}function Be({profileId:e,range:t,fetchLogs:n,toasterRef:r}){let{t:i}=c(),[a,o]=(0,X.useState)(!1),[s,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(``),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(!1),S=(0,X.useRef)(!1),C=(0,X.useRef)(e);C.current!==e&&(C.current=e,S.current=!1);let w=(0,X.useCallback)(async()=>{try{let r=await H.getStatus(e),i=r.enabled||!!r.hasKeys;o(i);let a=H.isProfileUnlocked(e);if(l(a),i&&!a&&r.wrappedPasskeys&&r.wrappedPasskeys.length>0&&!S.current){S.current=!0;try{await H.unlockProfile(e)&&(l(!0),await U.reDecryptLocalLogs(e),n(t,!0))}catch(e){console.debug(`[useLogsE2ee] Silent auto-unlock skipped or cancelled:`,e)}}}catch{o(!1)}},[e,n,t]);return(0,X.useEffect)(()=>{w()},[w]),{isE2eeEnabled:a,isE2eeUnlocked:s,unlocking:u,recoveryDialogOpen:f,setRecoveryDialogOpen:p,recoveryKeyInput:m,setRecoveryKeyInput:h,recoveryError:g,setRecoveryError:_,rotatedKey:v,setRotatedKey:y,copiedKey:b,handleCopyRotatedKey:e=>{navigator.clipboard.writeText(e),x(!0),setTimeout(()=>x(!1),2e3)},handleUnlockPasskey:async()=>{try{d(!0),await H.unlockProfile(e)&&(l(!0),await U.reDecryptLocalLogs(e),r?.current?.show({message:i(`settings.e2eeUnlockSuccess`,`私钥已成功在此设备解锁`),intent:j.SUCCESS}),n(t,!0))}catch(e){console.error(`Failed to unlock E2EE via Passkey:`,e),r?.current?.show({message:e.message||i(`settings.e2eeUnlockError`,`验证 Passkey 解锁失败`),intent:j.DANGER})}finally{d(!1)}},handleUnlockRecoveryKey:async a=>{a.preventDefault();let o=m.trim();if(o){d(!0),_(``);try{await H.unlockWithRecoveryKey(o);try{let e=await re({recoveryKey:o});await H.wrapCurrentKeyForRecovery(e.recovery_key),y(e.recovery_key)}catch(e){console.warn(`[useLogsE2ee] Recovery key auto-rotation failed:`,e)}l(!0),p(!1),h(``),await U.reDecryptLocalLogs(e),r?.current?.show({message:i(`settings.e2eeUnlockSuccess`,`私钥已成功在此设备解锁`),intent:j.SUCCESS}),n(t,!0)}catch(e){console.error(`Failed to unlock E2EE via recovery key:`,e),_(e.message||i(`account.e2ee.recoveryUnlockFailed`,`恢复密钥无效或解析失败`))}finally{d(!1)}}}}}const Ve=({profileId:e,onQuickAction:t,toasterRef:n})=>{let r=oe(),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(!1),{realtimeRefresh:c,setRealtimeRefresh:l,range:u,setRange:d,customRange:f,setCustomRange:p,statusFilter:m,setStatusFilter:h,accessPointIdFilter:g,setAccessPointIdFilter:_,accessPoints:v,destCountryFilter:y,setDestCountryFilter:b,ispFilter:x,setIspFilter:S,searchQuery:C,setSearchQuery:w,logs:T,loading:E,loadingMore:O,hasMore:k,stats:A,logRetentionDays:j,prevLatestTimestamp:M,scrollContainerRef:N,lastLogElementRef:ee,fetchLogs:P,exporting:F,handleExportLogs:I}=ze({profileId:e,toasterRef:n}),{isE2eeEnabled:L,isE2eeUnlocked:te,unlocking:R,recoveryDialogOpen:ne,setRecoveryDialogOpen:z,recoveryKeyInput:B,setRecoveryKeyInput:V,recoveryError:re,setRecoveryError:ie,rotatedKey:ae,setRotatedKey:H,copiedKey:U,handleCopyRotatedKey:W,handleUnlockPasskey:G,handleUnlockRecoveryKey:K}=Be({profileId:e,range:u,fetchLogs:P,toasterRef:n}),q=new Date().toLocaleString(`sv-SE`).replace(` `,`T`).slice(0,16);return E&&T.length===0?(0,Z.jsx)(`div`,{className:`h-full flex items-center justify-center`,children:(0,Z.jsx)(D,{})}):(0,Z.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden bg-gray-50/30 dark:bg-gray-950/10 max-w-7xl mx-auto w-full pt-14`,children:[(0,Z.jsx)(he,{profileId:e,range:u,setRange:d,customRange:f,setCustomRange:p,nowStr:q,fetchLogs:P,isMobile:r,realtimeRefresh:c,setRealtimeRefresh:l,statusFilter:m,setStatusFilter:h,accessPointIdFilter:g,setAccessPointIdFilter:_,accessPoints:v,destCountryFilter:y,setDestCountryFilter:b,ispFilter:x,setIspFilter:S,searchQuery:C,setSearchQuery:w,stats:A,logRetentionDays:j,onExport:I,exporting:F}),L&&!te&&(0,Z.jsx)(Te,{isMobile:r,unlocking:R,onUnlockPasskey:G,onOpenRecoveryDialog:()=>{ie(``),V(``),z(!0)}}),(0,Z.jsx)(ve,{logs:T,loading:E,loadingMore:O,hasMore:k,realtimeRefresh:c,isMobile:r,searchQuery:C,scrollContainerRef:N,lastLogElementRef:ee,prevLatestTimestamp:M,setSelectedLog:a,setIsDrawerOpen:s,logRetentionDays:j}),(0,Z.jsx)(we,{isDrawerOpen:o,setIsDrawerOpen:s,selectedLog:i,profileId:e,isMobile:r,onQuickAction:t}),(0,Z.jsx)(Ee,{isOpen:ne,onClose:()=>z(!1),recoveryKeyInput:B,setRecoveryKeyInput:V,recoveryError:re,unlocking:R,onSubmit:K}),(0,Z.jsx)(De,{rotatedKey:ae,onClose:()=>H(null),copiedKey:U,onCopyKey:W})]})};export{Ve as LogsView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{B as t,C as n,D as r,P as i,Tt as a,X as o,Zt as s,at as c,dt as l,et as u,ht as d,ot as f,q as p,st as m,tt as h,v as g,y as _}from"./vendor-react-CHk5ngkq.js";import{S as v,b as y}from"./vendor-icons-other-Bme3ywH9.js";import{B as b,D as x,E as S,H as C,M as w,N as T,P as E,S as D,T as O,V as k,_ as A,d as j,f as M,h as N,p as P,r as F,v as I,w as L,x as R}from"./vendor-ui-core-sfZn2C08.js";import"./vendor-utils-CnB7BG7m.js";import{G as z,U as B,_t as V,c as H,dt as U,k as W,mt as G,ut as K,wt as q,xt as J}from"./index-CbTjGMTZ.js";var Y=e(v(),1),X=e(y(),1);const Z=({profile:e,isEditingName:n,setIsEditingName:r,editName:i,setEditName:a,updateProfileName:o,exportProfile:c})=>{let{t:l}=s(),[u,p]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{className:`mb-6 flex flex-col md:flex-row justify-between items-start md:items-center gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col justify-start`,children:[n?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,X.jsx)(I,{content:l(`common.profileNameFormatTip`,`Profile Name tip: 1-30 characters, duplicates not allowed`),isOpen:u,position:b.TOP,intent:k.PRIMARY,className:`flex-1`,children:(0,X.jsx)(`div`,{className:`w-full block`,children:(0,X.jsx)(M,{value:i,onChange:e=>a(e.target.value),onFocus:()=>p(!0),onBlur:()=>p(!1),autoFocus:!0,onKeyDown:t=>{t.key===`Enter`&&o(),t.key===`Escape`&&(r(!1),a(e?.name||``))}})})}),(0,X.jsx)(T,{icon:(0,X.jsx)(d,{size:16}),intent:k.SUCCESS,minimal:!0,onClick:o,disabled:!H.test(i)}),(0,X.jsx)(T,{icon:(0,X.jsx)(_,{size:16}),minimal:!0,onClick:()=>{r(!1),a(e?.name||``)}})]}):(0,X.jsxs)(`div`,{className:`group flex items-center gap-2 mb-1 cursor-pointer`,onClick:()=>r(!0),children:[(0,X.jsx)(`h2`,{className:`bp6-heading mb-0`,children:e?.name}),(0,X.jsx)(T,{icon:(0,X.jsx)(t,{size:14}),minimal:!0,className:`opacity-30 group-hover:opacity-100 transition-opacity`})]}),(0,X.jsx)(`p`,{className:`bp6-text-muted`,children:l(`settings.subtitle`)})]}),(0,X.jsx)(`div`,{className:`flex gap-2 items-center`,children:(0,X.jsx)(T,{size:`large`,icon:(0,X.jsx)(f,{size:18}),text:l(`settings.export`,`导出配置`),onClick:c})})]})},Q=()=>{let{t:e}=s(),[t,n]=(0,Y.useState)([]);return(0,Y.useEffect)(()=>{z().then(t=>{t&&Array.isArray(t)&&n(t.map(t=>({label:e(t.label),url:t.url})))}).catch(e=>console.warn(`Failed to fetch preset upstreams from API`,e))},[e]),t},$=(e,t)=>{let{t:n}=s();return(0,Y.useMemo)(()=>{let e=[{label:n(`settings.retentionDisabled`,`关闭 (隐私需要)`),value:0},{label:n(`settings.retention10m`,`10 分钟`),value:.007},{label:n(`settings.retention1h`),value:.0416},{label:n(`settings.retention24h`),value:1},{label:n(`settings.retention7d`),value:7},{label:n(`settings.retention30d`),value:30},{label:n(`settings.retention90d`),value:90}],r=t>0?t:30,i=e.filter(e=>e.value<=r);return i.length>0?i:[e[0]]},[n,t])},ee=({settings:e,setSettings:t})=>{let{t:n}=s(),r=(0,X.jsx)(S,{className:`min-w-96`,children:Q().map((n,r)=>(0,X.jsx)(L,{text:n.label,onClick:()=>t({...e,upstream:[n.url]}),labelElement:(0,X.jsx)(`div`,{className:`flex flex-col items-end text-right`,children:(0,X.jsx)(`span`,{className:`text-[9px] opacity-85 max-w-64 truncate`,title:n.url,children:n.url})})},r))});return(0,X.jsxs)(R,{elevation:C.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 mb-4 font-bold`,children:[(0,X.jsx)(i,{size:18,className:`text-blue-500`}),` `,n(`settings.upstreamTitle`)]}),(0,X.jsx)(P,{label:`DoH (https://) / DoT (tls://) / DNS Stamp (sdns://) / ${n(`settings.classicDns`)}`,children:(0,X.jsx)(M,{fill:!0,placeholder:`https://... | tls://... | sdns://... | 1.1.1.1`,value:e.upstream?.[0]||``,onChange:n=>t({...e,upstream:[n.target.value]}),onFocus:e=>e.target.select(),rightElement:(0,X.jsx)(O,{content:r,placement:`bottom-end`,animation:`minimal`,arrow:!1,children:(0,X.jsx)(T,{variant:`minimal`,icon:`chevron-down`})})})}),(0,X.jsx)(`p`,{className:`text-xs opacity-60`,children:n(`settings.upstreamDesc`)})]})},te=({settings:e,setSettings:t})=>{let{t:n}=s();return(0,X.jsxs)(R,{elevation:C.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 mb-4 font-bold`,children:[(0,X.jsx)(r,{size:18,className:`text-green-500`}),` `,n(`settings.defaultPolicyTitle`)]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(P,{label:n(`settings.onNoMatch`),children:(0,X.jsxs)(j,{fill:!0,value:e.default_policy,onChange:n=>t({...e,default_policy:n.target.value}),children:[(0,X.jsx)(`option`,{value:`ALLOW`,children:n(`settings.allowAll`)}),(0,X.jsx)(`option`,{value:`BLOCK`,children:n(`settings.blockAll`)})]})}),(0,X.jsx)(A,{}),(0,X.jsx)(P,{label:n(`settings.blockModeTitle`),helperText:n(`settings.blockModeDesc`),children:(0,X.jsxs)(j,{fill:!0,value:e.block_mode||`NULL_IP`,onChange:n=>t({...e,block_mode:n.target.value}),children:[(0,X.jsxs)(`option`,{value:`NULL_IP`,children:[`0.0.0.0 / :: (`,n(`settings.default`),`)`]}),(0,X.jsxs)(`option`,{value:`NXDOMAIN`,children:[`NXDOMAIN (`,n(`settings.NXDOMAIN`),`)`]}),(0,X.jsxs)(`option`,{value:`NODATA`,children:[`NODATA (`,n(`settings.NODATA`),`)`]}),(0,X.jsx)(`option`,{value:`CUSTOM_IP`,children:n(`settings.customIP`)})]})}),e.block_mode===`CUSTOM_IP`&&(0,X.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1`,children:[(0,X.jsx)(M,{placeholder:`IPv4: 127.0.0.1`,value:e.custom_block_ipv4||``,onChange:n=>t({...e,custom_block_ipv4:n.target.value})}),(0,X.jsx)(M,{placeholder:`IPv6: ::1`,value:e.custom_block_ipv6||``,onChange:n=>t({...e,custom_block_ipv6:n.target.value})})]})]})]})},ne=({settings:e,setSettings:t,isAdmin:n,maxRetentionDays:r})=>{let{t:i}=s(),a=$(n,r);Y.useEffect(()=>{if(r>0&&e.log_retention_days>r&&a.length>0){let n=a[a.length-1];n&&e.log_retention_days!==n.value&&t({...e,log_retention_days:n.value})}},[r,e.log_retention_days,a,t]);let o=e.log_retention_days===0;return(0,X.jsxs)(R,{elevation:C.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 mb-4 font-bold`,children:[(0,X.jsx)(l,{size:18,className:`text-purple-500`}),` `,i(`settings.logRetentionTitle`)]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(P,{label:i(`settings.retentionDuration`),children:(0,X.jsx)(j,{fill:!0,value:e.log_retention_days,onChange:n=>t({...e,log_retention_days:parseFloat(n.target.value)}),children:a.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),(0,X.jsx)(`p`,{className:`text-xs opacity-60`,children:o?i(`settings.retentionDisabledDesc`,`已关闭日志记录。系统将不会记录任何 DNS 查询日志并立即清空历史日志。`):i(`settings.retentionDesc`)}),(0,X.jsxs)(`div`,{className:`pt-3 border-t border-gray-100 dark:border-gray-800/80`,children:[(0,X.jsx)(N,{label:i(`settings.skipLogOnPass`,`不记录放行记录`),checked:!o&&!!e.skip_log_on_pass,disabled:o,onChange:n=>t({...e,skip_log_on_pass:n.currentTarget.checked})}),(0,X.jsx)(`p`,{className:`text-xs opacity-60 mt-1`,children:i(`settings.skipLogOnPassDesc`,`启用后不记录正常放行的 DNS 查询,仅记录被拦截、重定向或解析失败的记录。可大幅减少存储占用与写操作。`)})]})]})]})},re=({profileId:e,toasterRef:t})=>{let{t:r}=s(),[i,a]=(0,Y.useState)(()=>W.getLocalRetentionDays()),[o,c]=(0,Y.useState)(!1),[l,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(!1),_=(0,Y.useCallback)(async()=>{try{await W.init();let t=await W.getStorageInfo();c(t?.isOpfs??W.getIsOpfs());let n=t.profileStats.find(t=>t.profile_id===e);d(n?n.count:0)}catch(e){console.error(`[LocalRetentionCard] Failed to load storage info:`,e),c(W.getIsOpfs()),d(0)}},[e]);(0,Y.useEffect)(()=>{_()},[_]);let v=e=>{a(e),W.setLocalRetentionDays(e),_()};return(0,X.jsxs)(R,{elevation:C.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 mb-4 font-bold`,children:[(0,X.jsx)(m,{size:18,className:`text-cyan-500`}),` `,r(`settings.localRetentionTitle`,`本地存储与留存`)]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(P,{label:r(`settings.localRetentionDuration`,`本地保留时长`),children:(0,X.jsxs)(j,{fill:!0,value:i,onChange:e=>v(parseInt(e.target.value,10)),children:[(0,X.jsx)(`option`,{value:30,children:r(`settings.localRetention30d`,`30 天`)}),(0,X.jsx)(`option`,{value:90,children:r(`settings.localRetention90d`,`90 天 (推荐)`)}),(0,X.jsx)(`option`,{value:180,children:r(`settings.localRetention180d`,`180 天`)}),(0,X.jsx)(`option`,{value:365,children:r(`settings.localRetention365d`,`365 天 (1 年)`)}),(0,X.jsx)(`option`,{value:0,children:r(`settings.localRetentionUnlimited`,`永久保留 (直到手动清除)`)})]})}),(0,X.jsx)(`p`,{className:`text-xs opacity-60`,children:r(`settings.localRetentionDesc`,`日志将持久化保存在当前浏览器本地的 SQLite 数据库 (OPFS) 中,提供秒级本地搜索并节省云端存储费用。超出此时长的本地日志将自动清除。`)}),(0,X.jsxs)(`div`,{className:`pt-3 border-t border-gray-100 dark:border-gray-800/80 space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5 opacity-70`,children:[(0,X.jsx)(u,{size:14}),r(`settings.localEngineStorage`,`存储引擎`),`:`]}),(0,X.jsx)(F,{minimal:!0,intent:o?k.SUCCESS:k.WARNING,className:`text-[11px]`,children:o?r(`settings.localEngineOpfs`,`OPFS 本地持久化`):r(`settings.localEngineMemory`,`内存临时存储 (无痕/私密模式)`)})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,X.jsxs)(`span`,{className:`opacity-70`,children:[r(`settings.localCachedCount`,`本地已缓存日志`),`:`]}),(0,X.jsx)(`span`,{className:`font-mono font-medium`,children:l===null?`...`:r(`settings.localCachedCountUnit`,`{{count}} 条记录`,{count:l})})]}),(0,X.jsx)(`div`,{className:`pt-1 flex justify-end`,children:(0,X.jsx)(T,{minimal:!0,small:!0,intent:k.DANGER,icon:(0,X.jsx)(n,{size:13}),text:r(`settings.clearLocalData`,`清空本地日志`),disabled:l===0||l===null||h,onClick:()=>p(!0)})})]})]}),(0,X.jsx)(x,{isOpen:f,confirmButtonText:r(`common.confirm`,`确认清空`),cancelButtonText:r(`common.cancel`,`取消`),intent:k.DANGER,icon:`trash`,onConfirm:async()=>{g(!0);try{await W.clearProfile(e),d(0),t?.current?.show({message:r(`settings.clearLocalDataSuccess`,`本地日志已成功清空`),intent:k.SUCCESS,icon:`tick`})}catch(e){console.error(`[LocalRetentionCard] Failed to clear local profile logs:`,e),t?.current?.show({message:r(`settings.clearLocalDataError`,`清空本地日志失败`),intent:k.DANGER,icon:`error`})}finally{g(!1),p(!1)}},onCancel:()=>p(!1),loading:h,children:(0,X.jsx)(`p`,{children:r(`settings.clearLocalDataConfirm`,`确定要清空此配置在本地保存的所有日志吗?(云端日志不受影响)`)})})]})},ie=({settings:e,setSettings:t})=>{let{t:n}=s();return(0,X.jsxs)(R,{elevation:C.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 mb-3 font-bold`,children:[(0,X.jsx)(h,{size:18,className:`text-orange-500`}),` `,n(`settings.ecsTitle`)]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(N,{label:n(`settings.sendEcs`),checked:e.ecs.enabled,onChange:n=>t({...e,ecs:{...e.ecs,enabled:n.currentTarget.checked}})}),(0,X.jsx)(N,{label:n(`settings.customSubnet`),disabled:!e.ecs.enabled,checked:!e.ecs.use_client_ip,onChange:n=>t({...e,ecs:{...e.ecs,use_client_ip:!n.currentTarget.checked}})}),(0,X.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-gray-100 dark:border-gray-800`,children:[(0,X.jsx)(P,{label:n(`settings.customIpv4`),labelInfo:n(`settings.ipv4Hint`),disabled:!(e.ecs.enabled&&!e.ecs.use_client_ip),children:(0,X.jsx)(M,{placeholder:`0.0.0.0/0`,value:e.ecs.ipv4_cidr||``,disabled:!(e.ecs.enabled&&!e.ecs.use_client_ip),onChange:n=>t({...e,ecs:{...e.ecs,ipv4_cidr:n.target.value}})})}),(0,X.jsx)(P,{label:n(`settings.customIpv6`),labelInfo:n(`settings.ipv6Hint`),disabled:!(e.ecs.enabled&&!e.ecs.use_client_ip),children:(0,X.jsx)(M,{placeholder:`::/0`,value:e.ecs.ipv6_cidr||``,disabled:!(e.ecs.enabled&&!e.ecs.use_client_ip),onChange:n=>t({...e,ecs:{...e.ecs,ipv6_cidr:n.target.value}})})})]}),(0,X.jsx)(`p`,{className:`text-xs opacity-60`,children:n(`settings.ecsUpstreamHint`)})]})]})};var ae=[{domain:`cloudflare-ech.com`,isPreferred:!0},{domain:`crypto.cloudflare.com`,isPreferred:!1},{domain:`one.one.one.one`,isPreferred:!1},{domain:`www.cloudflare.com`,isPreferred:!1},{domain:`encryptedsni.com`,isPreferred:!1},{domain:`cdnjs.com`,isPreferred:!1}];const oe=({settings:e,setSettings:t})=>{let{t:n}=s(),[r,i]=Y.useState(ae);Y.useEffect(()=>{B().then(e=>{Array.isArray(e)&&e.length>0&&i(e.map(e=>typeof e==`string`?{domain:e,isPreferred:e===`cloudflare-ech.com`}:{domain:e.domain,isPreferred:!!e.isPreferred}))}).catch(e=>console.warn(`Failed to fetch preset ECH fronting domains from API`,e))},[]);let a=typeof e.best_effort_ech==`boolean`?e.best_effort_ech:!!e.best_effort_ech?.enabled,l=typeof e.best_effort_ech==`object`&&e.best_effort_ech?.fronting_domain?e.best_effort_ech.fronting_domain:`cloudflare-ech.com`,u=n=>{t({...e,best_effort_ech:{enabled:n,fronting_domain:l||`cloudflare-ech.com`}})},d=n=>{t({...e,best_effort_ech:{enabled:a,fronting_domain:n}})},f=(0,X.jsx)(S,{className:`min-w-72`,children:r.map(e=>(0,X.jsx)(L,{text:e.domain,onClick:()=>d(e.domain),labelElement:e.isPreferred?(0,X.jsx)(F,{minimal:!0,intent:k.PRIMARY,className:`text-[10px]`,children:n(`settings.echPreferred`,`首选`)}):void 0},e.domain))});return(0,X.jsxs)(R,{elevation:C.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 m-0 font-bold text-purple-600 dark:text-purple-400`,children:[(0,X.jsx)(o,{size:18}),` `,n(`settings.echTitle`)]}),(0,X.jsx)(O,{placement:`bottom-end`,usePortal:!0,content:(0,X.jsxs)(`div`,{className:`p-4 max-w-sm`,children:[(0,X.jsx)(w,{children:n(`settings.whatIsEch`,`何为 ECH (Encrypted Client Hello)?`)}),(0,X.jsx)(`p`,{className:`text-sm mb-2`,children:n(`settings.echHelpDesc`)}),(0,X.jsxs)(`ul`,{className:`list-disc list-inside text-sm opacity-80 mb-3 space-y-1`,children:[(0,X.jsx)(`li`,{children:n(`settings.echHelpBenefit1`)}),(0,X.jsx)(`li`,{children:n(`settings.echHelpBenefit2`)})]}),(0,X.jsx)(`div`,{className:`text-xs border-t border-gray-100 dark:border-gray-700 pt-2`,children:(0,X.jsxs)(`a`,{href:`https://en.wikipedia.org/wiki/Encrypted_Client_Hello`,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-1 text-blue-500 hover:underline`,children:[(0,X.jsx)(c,{size:10}),` `,n(`setup.learnMore`,`了解更多`)]})})]}),children:(0,X.jsx)(T,{icon:`help`,variant:`minimal`,intent:k.NONE})})]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(N,{label:n(`settings.enableEch`,`启用重写 ECH`),checked:a,onChange:e=>u(e.currentTarget.checked)}),(0,X.jsx)(`p`,{className:`text-xs opacity-60 leading-relaxed`,children:n(`settings.echDesc`,`针对由 Cloudflare 代理的域名,当查询 HTTPS (Type 65) 或 SVCB (Type 64) 记录且上游未配置 ECH 时,自动重写注入 ECH 参数以保护 SNI 隐私。`)}),a&&(0,X.jsx)(`div`,{className:`space-y-3 pt-3 border-t border-gray-100 dark:border-gray-800`,children:(0,X.jsx)(P,{label:n(`settings.echFrontingTitle`,`表层 SNI (ECH Fronting)`),labelInfo:(0,X.jsx)(`span`,{className:`text-xs opacity-60`,children:n(`settings.echFrontingDesc`,`TLS 握手外层可见的伪装域名`)}),children:(0,X.jsx)(M,{fill:!0,placeholder:n(`settings.echFrontingCustomPlaceholder`,`输入自定义表层域名,例如 crypto.cloudflare.com`),value:l,onChange:e=>d(e.target.value),onFocus:e=>e.target.select(),className:`font-mono text-sm`,rightElement:(0,X.jsx)(O,{content:f,placement:`bottom-end`,animation:`minimal`,arrow:!1,children:(0,X.jsx)(T,{variant:`minimal`,icon:`chevron-down`})})})})})]})]})},se=({testInput:e,setTestInput:t,handleDnsTest:n,testing:r,testResult:i})=>{let{t:o}=s();return(0,X.jsxs)(R,{elevation:C.TWO,className:`dark:bg-gray-900 border-t-2 border-blue-500`,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 mb-6 font-bold`,children:[(0,X.jsx)(g,{size:20,className:`text-yellow-500 fill-yellow-500`}),` `,o(`settings.testToolTitle`)]}),(0,X.jsxs)(`div`,{className:`flex flex-col space-y-6`,children:[(0,X.jsx)(P,{label:o(`settings.testDomain`),className:`mb-0`,children:(0,X.jsx)(M,{fill:!0,large:!0,placeholder:o(`settings.domainPlaceholder`),value:e.domain,onChange:n=>t({...e,domain:n.target.value}),onKeyDown:e=>e.key===`Enter`&&n()})}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-4 items-end`,children:[(0,X.jsx)(P,{label:o(`settings.recordType`),className:`w-32 mb-0`,children:(0,X.jsxs)(j,{fill:!0,large:!0,value:e.type,onChange:n=>t({...e,type:n.target.value}),children:[(0,X.jsx)(`option`,{value:`A`,children:`A`}),(0,X.jsx)(`option`,{value:`AAAA`,children:`AAAA`}),(0,X.jsx)(`option`,{value:`CNAME`,children:`CNAME`}),(0,X.jsx)(`option`,{value:`TXT`,children:`TXT`})]})}),(0,X.jsx)(P,{label:`\xA0`,className:`mb-0`,children:(0,X.jsx)(T,{size:`large`,intent:k.PRIMARY,icon:`search`,text:o(`settings.runTest`),onClick:n,loading:r})})]}),i&&(0,X.jsxs)(`div`,{className:`bg-gray-50 dark:bg-gray-800/50 p-6 rounded-xl border border-gray-100 dark:border-gray-800 space-y-6 animate-in fade-in slide-in-from-top-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-4 items-center`,children:[(0,X.jsx)(F,{large:!0,round:!0,intent:i.action===`PASS`?k.SUCCESS:i.action===`BLOCK`?k.DANGER:k.WARNING,className:`px-4 font-bold`,children:i.action}),(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{className:`text-[10px] uppercase font-bold opacity-40`,children:o(`settings.hitRule`)}),(0,X.jsx)(`span`,{className:`text-sm font-bold`,children:i.reason||o(`settings.defaultAllow`)})]}),(0,X.jsxs)(`div`,{className:`flex flex-col border-l border-gray-200 dark:border-gray-700 pl-4`,children:[(0,X.jsx)(`span`,{className:`text-[10px] uppercase font-bold opacity-40`,children:o(`settings.parseLatency`)}),(0,X.jsx)(`span`,{className:`text-sm font-mono font-bold`,children:i.latency?`${i.latency}ms`:`-`})]}),i.timings&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 border-l border-gray-200 dark:border-gray-700 pl-4 max-w-md`,children:Object.entries(i.timings).map(([e,t])=>(0,X.jsxs)(`div`,{className:`flex gap-1 items-baseline`,children:[(0,X.jsxs)(`span`,{className:`text-[9px] opacity-40 uppercase font-mono`,children:[e,`:`]}),(0,X.jsxs)(`span`,{className:`text-[10px] font-mono font-bold`,children:[t,`ms`]})]},e))}),(0,X.jsx)(A,{}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 bg-white dark:bg-gray-900 px-3 py-1.5 rounded-lg shadow-sm border border-gray-100 dark:border-gray-800`,children:[(0,X.jsx)(p,{size:14,className:`text-red-500`}),(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{className:`text-[10px] uppercase font-bold opacity-40 leading-none`,children:o(`settings.sourceIp`)}),(0,X.jsxs)(`span`,{className:`text-xs font-mono`,children:[i.client_ip,` (`,i.geo_country,`)`]})]})]})]}),(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{className:`text-[10px] uppercase font-bold opacity-40 flex items-center gap-1`,children:[(0,X.jsx)(a,{size:10}),` `,o(`settings.answerSection`)]}),(0,X.jsx)(`div`,{className:`font-mono text-sm leading-relaxed bg-white dark:bg-gray-900 p-4 rounded-xl border border-gray-100 dark:border-gray-800 shadow-inner`,children:i.answers&&i.answers.length>0?i.answers.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex gap-4 py-1 border-b border-gray-50 dark:border-gray-800 last:border-0 hover:bg-blue-50/50 dark:hover:bg-blue-900/10 transition-colors px-2`,children:[(0,X.jsx)(`span`,{className:`w-16 font-bold text-blue-500`,children:e.type}),(0,X.jsx)(`span`,{className:`flex-1 dark:text-gray-300`,children:e.data}),(0,X.jsxs)(`span`,{className:`text-[10px] opacity-30 italic`,children:[`TTL: `,e.ttl,`s`]})]},t)):(0,X.jsx)(`div`,{className:`p-4 opacity-40 italic text-center`,children:o(`settings.noRecordsReturned`)})})]}),i.diagnostics&&(0,X.jsx)(D,{minimal:!0,intent:i.action===`FAIL`?k.DANGER:k.NONE,className:`text-xs font-mono`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,X.jsx)(`span`,{className:`font-bold uppercase tracking-wider`,children:o(`settings.diagnostics`)}),(0,X.jsx)(`span`,{className:`font-bold`,children:i.action===`FAIL`?i.diagnostics.status>0?`HTTP ${i.diagnostics.status}${i.diagnostics.status_text?` (${i.diagnostics.status_text})`:``}`:`Network / Connection Error`:i.diagnostics.method===`POST`||i.diagnostics.method===`GET`?`HTTP ${i.diagnostics.status}${i.diagnostics.status_text?` (${i.diagnostics.status_text})`:``}`:`Connected (OK)`})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs opacity-80`,children:[(0,X.jsx)(`span`,{className:`px-1.5 py-0.5 bg-gray-200 dark:bg-gray-700 rounded text-[10px] font-bold`,children:i.diagnostics.method}),(0,X.jsx)(`span`,{className:`break-all`,children:i.diagnostics.upstream_url})]}),i.diagnostics.cf_ray&&(0,X.jsxs)(`div`,{className:`text-[11px] opacity-75`,children:[`CF-Ray: `,(0,X.jsx)(`span`,{className:`font-bold`,children:i.diagnostics.cf_ray})]}),i.diagnostics.error_detail&&i.action===`FAIL`&&(0,X.jsxs)(`div`,{className:`p-2 bg-red-50 dark:bg-red-950/40 rounded border border-red-200 dark:border-red-900/50 text-red-700 dark:text-red-300 break-words`,children:[(0,X.jsxs)(`div`,{className:`font-bold mb-0.5`,children:[o(`settings.errorDetail`),`:`]}),(0,X.jsx)(`div`,{children:i.diagnostics.error_detail})]}),i.diagnostics.response_body&&(0,X.jsxs)(`div`,{className:`p-2 bg-gray-100 dark:bg-gray-900 rounded border border-gray-200 dark:border-gray-700 text-gray-700 dark:text-gray-300 break-words text-[11px]`,children:[(0,X.jsxs)(`div`,{className:`font-bold mb-0.5 opacity-60`,children:[o(`settings.upstreamResponse`),`:`]}),(0,X.jsx)(`div`,{className:`line-clamp-3`,children:i.diagnostics.response_body})]})]})})]})]})]})},ce=({profileId:e,toasterRef:t,currentUser:n,onSavingChange:r})=>{let[i,a]=(0,Y.useState)(null),[o,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!0),[d,f]=(0,Y.useState)(!1),{t:p}=s();(0,Y.useEffect)(()=>(r?.(d),()=>{r?.(!1)}),[d,r]);let m=(0,Y.useRef)(!0),h=(0,Y.useRef)(null),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)({domain:`o-o.myaddr.l.google.com`,type:`TXT`}),[S,C]=(0,Y.useState)(null),[w,T]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{(async()=>{try{let t=await K(e);return a(t),y(t.name),c(JSON.parse(t.settings)),i}catch(e){console.error(e)}finally{u(!1)}})()},[e]),(0,Y.useEffect)(()=>{if(!l&&o){let e=setTimeout(()=>{m.current=!1},500);return()=>clearTimeout(e)}},[l,o]),(0,Y.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]);let D=async()=>{if(!v||v===i?.name){_(!1);return}try{await V(e,v),a(e=>e?{...e,name:v}:null),_(!1),t?.current?.show({message:p(`settings.nameUpdateSuccess`,`名称已更新`),intent:k.SUCCESS})}catch(e){console.error(e);let n=e.message,r=n;n===`The profile name already exists`?r=p(`common.profileNameExists`,`The profile name already exists`):n===`Invalid Profile Name format`&&(r=p(`common.profileNameFormatError`,`Invalid Profile Name format`)),t?.current?.show({message:r||p(`settings.nameUpdateFailed`,`更新失败`),intent:k.DANGER})}},O=(0,Y.useCallback)(async n=>{if(n){f(!0);try{await q(e,n)}catch(e){console.error(e),t?.current?.show({message:p(`settings.saveError`),intent:k.DANGER,icon:`error`})}finally{f(!1)}}},[e,t,p]),A=(0,Y.useCallback)(e=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{O(e)},600)},[O]),j=(0,Y.useCallback)(e=>{c(e),m.current||A(e)},[A]);return l||!o?(0,X.jsx)(`div`,{className:`p-20 flex justify-center`,children:(0,X.jsx)(E,{})}):(0,X.jsxs)(`div`,{className:`p-0 sm:px-4 lg:px-8 max-w-5xl mx-auto space-y-8 pb-20`,children:[(0,X.jsx)(Z,{profile:i,isEditingName:g,setIsEditingName:_,editName:v,setEditName:y,updateProfileName:D,exportProfile:async()=>{if(!(!i||!o))try{let[n,r]=await Promise.all([G(e).catch(()=>[]),U(e).catch(()=>[])]),a=new Set,s=(n||[]).filter(e=>{let t=(e.pattern||``).trim().toLowerCase();return!t||a.has(t)?!1:(a.add(t),!0)}),c=new Set,l=(r||[]).filter(e=>{let t=(e.url||``).trim().toLowerCase();return!t||c.has(t)?!1:(c.add(t),!0)}).map(e=>({url:e.url,enabled:!!e.enabled})),u={version:2,name:i.name,settings:o,rules:s,filters:l,exported_at:Math.floor(Date.now()/1e3)},d=new Blob([JSON.stringify(u,null,2)],{type:`application/json`}),f=URL.createObjectURL(d),m=document.createElement(`a`);m.href=f,m.download=`dns-worker-${i.name||e}.json`,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(f),t?.current?.show({message:p(`settings.exportSuccess`,`配置成功导出`),intent:k.SUCCESS,icon:`download`})}catch(e){console.error(e),t?.current?.show({message:p(`settings.exportError`,`导出失败`),intent:k.DANGER,icon:`error`})}}}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,X.jsx)(ee,{settings:o,setSettings:j}),(0,X.jsx)(te,{settings:o,setSettings:j}),(0,X.jsx)(ne,{settings:o,setSettings:j,isAdmin:n?.role===`admin`,maxRetentionDays:n?.max_log_retention_days??(n?.role===`admin`?30:7)}),(0,X.jsx)(re,{profileId:e,toasterRef:t}),(0,X.jsx)(ie,{settings:o,setSettings:j}),(0,X.jsx)(oe,{settings:o,setSettings:j})]}),(0,X.jsx)(se,{testInput:b,setTestInput:x,handleDnsTest:async()=>{if(b.domain){T(!0),C(null);try{C(await J(e,b))}catch(e){console.error(e)}finally{T(!1)}}},testing:w,testResult:S})]})};export{ce as SettingsView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{A as t,B as n,C as r,E as i,F as a,G as o,I as s,N as c,P as l,R as u,Tt as d,W as f,Zt as p,at as m,it as h,lt as g,q as _,rt as v,tt as y,w as b,wt as x,z as S}from"./vendor-react-CHk5ngkq.js";import{S as C,b as w}from"./vendor-icons-other-Bme3ywH9.js";import{A as T,B as E,F as D,L as O,M as k,N as A,O as j,P as M,R as N,S as P,T as F,V as I,a as L,d as R,f as z,i as B,n as V,o as H,r as U,v as W,z as G}from"./vendor-ui-core-sfZn2C08.js";import{_t as K,t as ee,vt as q}from"./vendor-utils-CnB7BG7m.js";import{B as te,E as ne,K as re,V as ie,Y as ae,Z as oe,a as se,at as ce,ct as le,n as J,on as ue,q as Y,t as de,ut as fe,vt as pe,w as me,yt as he}from"./index-CbTjGMTZ.js";import{t as ge}from"./SwipeableDrawer-BrmEzhuP.js";var X=e(C(),1),Z=e(w(),1);const _e=()=>{let{t:e}=p();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)(T,{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,{})})]})},ve=({isVerifying:e,verifyResult:n,handleVerify:r,isMobile:i,clientInfo:a,showIp:o,setShowIp:s,showLocation:c,setShowLocation:u,traceInfo:f,edgeLocation:m})=>{let{t:g}=p(),{isServerfull:b}=J();return(0,Z.jsx)(H,{title:g(`setup.verifyConnection`),icon:(0,Z.jsx)(d,{size:16}),children:(0,Z.jsx)(L,{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)(M,{size:24}):n?.success?(0,Z.jsx)(t,{size:24}):(0,Z.jsx)(l,{size:24})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-bold text-lg`,children:e?g(`setup.verifying`):n?.success?g(`setup.connected`):g(`setup.notConnected`)}),(0,Z.jsx)(`div`,{className:`text-sm opacity-60`,children:n?.success?n.profileMatch?g(`setup.profileMatch`):g(`setup.profileMismatch`):g(`setup.verifyHint`)})]})]}),(0,Z.jsx)(A,{size:`large`,intent:n?.success?I.SUCCESS:I.PRIMARY,icon:`refresh`,text:g(`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)(y,{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:g(`setup.egressIp`)}),(0,Z.jsx)(`button`,{onClick:()=>s(!o),className:`text-gray-400 hover:text-blue-500 transition-colors`,children:o?(0,Z.jsx)(v,{size:16}):(0,Z.jsx)(h,{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)(_,{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:g(`setup.currentLocation`)}),(0,Z.jsx)(`button`,{onClick:()=>u(!c),className:`text-gray-400 hover:text-red-500 transition-colors`,children:c?(0,Z.jsx)(v,{size:16}):(0,Z.jsx)(h,{size:16})})]}),(0,Z.jsx)(`div`,{className:`font-bold truncate`,children:(0,Z.jsxs)(`span`,{className:q(`transition-[filter] duration-200 inline-block`,!c&&`filter blur-[6px] select-none`),children:[a.city,`, `,a.region?`${a.region}, `:``,a.country]})})]})]}),(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 select-none`,children:[(0,Z.jsx)(l,{size:18,className:`text-purple-500 mt-1`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-40`,children:b?g(`setup.serverLocation`,`服务器位置`):g(`setup.edgeServer`)}),(0,Z.jsx)(`div`,{className:`font-bold truncate`,title:b?m||``:m||f?.colo||``,children:b?m||g(`setup.detecting`):m||f?.colo||g(`setup.detecting`)})]})]})]})]})})})},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})]})})},ye=({accessPoints:e,selectedApId:t,onSelectAp:n,accessPointName:r,onManageAccessPoints:i,isMobile:a})=>{let{t:s}=p();return(0,Z.jsxs)(H,{title:s(`setup.accessPointsCardTitle`,`接入点`),icon:(0,Z.jsx)(o,{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)(L,{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)(R,{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:I.PRIMARY,className:`text-xs`,children:e.length})]})]}),(0,Z.jsx)(A,{variant:`outlined`,intent:I.NONE,icon:(0,Z.jsx)(c,{size:14}),text:s(`setup.manageAccessPoints`,`管理接入点`),onClick:i,fill:a,className:`shrink-0`})]})})]})},be=({dohUrl:e,copyToClipboard:t,isMobile:n})=>{let{t:r}=p();return(0,Z.jsxs)(H,{title:r(`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)(F,{placement:`bottom-end`,usePortal:!0,content:(0,Z.jsxs)(`div`,{className:`p-4 max-w-sm`,children:[(0,Z.jsx)(k,{children:r(`setup.whatIsDoh`)}),(0,Z.jsx)(`p`,{className:`text-sm mb-2`,children:r(`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:r(`setup.dohBenefit1`)}),(0,Z.jsx)(`li`,{children:r(`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}),` `,r(`setup.learnMore`)]})})]}),children:(0,Z.jsx)(A,{icon:`help`,variant:`minimal`,intent:I.NONE})}),children:[(0,Z.jsx)(Q,{step:2}),(0,Z.jsx)(L,{children:(0,Z.jsxs)(`div`,{className:`w-full bg-gray-100 dark:bg-gray-800 p-3 rounded-lg border border-gray-200 dark:border-gray-700 flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-blue-600 dark:text-blue-400 break-all text-xs sm:text-sm`,children:e}),(0,Z.jsx)(A,{intent:I.PRIMARY,icon:`duplicate`,text:r(`setup.copyUrl`),fill:n,onClick:()=>t(e),className:`shrink-0`})]})})]})};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 xe(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 Se(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=xe(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 Ce=({isMobile:e,copyToClipboard:t,profileKey:n,profileName:r,accessPointName:a,currentIps:o,dotDomain:c})=>{let{t:l}=p(),{isCloudflare:u}=J();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)(B,{id:`browsers`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(y,{size:16,className:`inline mr-2`}),l(`setup.browsers`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(k,{className:`font-bold`,children:l(`setup.browserTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:l(`setup.browserSteps`)}),(0,Z.jsx)(`p`,{className:`text-[10px] opacity-50 cursor-pointer`,onClick:()=>t(`chrome://settings/security`),children:l(`setup.browserTips`,`or copy this URL to the address bar: `)+`chrome://settings/security`})]})}),(0,Z.jsx)(B,{id:`apple`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(x,{size:16,className:`inline mr-2`}),l(`setup.apple`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(k,{className:`font-bold`,children:l(`setup.appleTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:l(`setup.appleDesc`)}),(0,Z.jsx)(`p`,{className:`text-[10px] opacity-50 text-center`,children:l(`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)(D,{icon:`document`,size:40,className:`opacity-20 mb-4`}),(0,Z.jsx)(A,{intent:I.PRIMARY,text:l(`setup.downloadConfig`),icon:`download`,onClick:()=>{let e=Se({profileKey:n,profileName:r,accessPointName:a,origin:window.location.origin}),t=new Blob([e],{type:`application/x-apple-aspen-config`}),i=URL.createObjectURL(t),o=document.createElement(`a`);o.href=i;let s=xe(r,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(i)}})]}),(0,Z.jsx)(`p`,{className:`text-[10px] opacity-50 mt-4! text-center`,children:l(`setup.appleInstallHint`)})]})}),(0,Z.jsx)(B,{id:`windows`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(f,{size:16,className:`inline mr-2`}),l(`setup.windows`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(k,{className:`font-bold`,children:l(`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:l(`setup.windowsStep0`)})}),(0,Z.jsx)(`li`,{children:l(`setup.windowsStep1`)}),(0,Z.jsxs)(`li`,{children:[l(`setup.windowsStep2`),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:o.map(n=>(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(U,{minimal:!0,interactive:!0,onClick:()=>t(n.ip),icon:`duplicate`,className:`font-mono`,children:n.ip}),!e&&(0,Z.jsx)(`span`,{className:`text-[9px] opacity-40 ml-1`,children:n.area})]},n.ip))})]}),(0,Z.jsx)(`li`,{children:l(`setup.windowsStep3`)}),(0,Z.jsx)(`li`,{children:l(`setup.windowsStep4`)})]})]})}),(0,Z.jsx)(B,{id:`linux`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(b,{size:16,className:`inline mr-2`}),l(`setup.linux`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(k,{className:`font-bold`,children:l(`setup.linuxTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:l(`setup.linuxDesc`)}),(0,Z.jsxs)(`div`,{className:`mt-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-bold mb-2`,children:l(`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)(A,{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:l(`setup.linuxStep2`)})})]})}),(0,Z.jsx)(B,{id:`routeros`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(s,{size:16,className:`inline mr-2`}),l(`setup.routeros`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(k,{className:`font-bold`,children:l(`setup.routerosTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:l(`setup.routerosDesc`)}),(0,Z.jsxs)(`div`,{className:`mt-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-bold mb-2`,children:l(`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)(A,{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:l(`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}),` `,l(`setup.routerosDocs`)]})]})}),(0,Z.jsx)(B,{id:`android`,title:(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(i,{size:16,className:`inline mr-2`}),l(`setup.android`)]}),panel:(0,Z.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Z.jsx)(k,{className:`font-bold`,children:l(`setup.androidTitle`)}),(0,Z.jsx)(`p`,{className:`text-sm`,children:l(`setup.androidDesc`)}),u?(0,Z.jsxs)(P,{intent:I.WARNING,icon:`warning-sign`,className:`text-xs`,children:[(0,Z.jsx)(`div`,{className:`font-semibold mb-1`,children:l(`setup.dotUnavailableCfTitle`)}),(0,Z.jsx)(`div`,{children:l(`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=(c||``).trim().replace(/^\*\./,``),i=!Y(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:l(`setup.androidDotTitle`,`私有 DNS (DoT / DoQ)`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:l(`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:I.PRIMARY,children:`${n}.${i}`})})}):(0,Z.jsx)(P,{intent:I.WARNING,icon:`warning-sign`,className:`text-xs`,children:l(`setup.androidIpNotice`,`检测到当前通过 IP 或本地地址访问面板。DoT / DoQ 仅接受域名,请在 .env 中配置 SERVERFULL_DOT_DOMAIN (例如 dns.example.com) 后刷新。`)})]})})(),!u&&(0,Z.jsx)(P,{intent:I.PRIMARY,icon:`info-sign`,className:`text-xs`,children:l(`setup.androidWarning`)})]})})]})]})};function we({profileId:e,accessPoints:t,onRefresh:n,toasterRef:r}){let{t:i}=p(),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(null),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(!1),[v,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,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(``);return{isAddDialogOpen:a,setIsAddDialogOpen:o,newApName:s,setNewApName:c,isAdding:l,renameApId:d,setRenameApId:f,renameApName:m,setRenameApName:h,isRenaming:g,rotatingApId:v,deletingApId:b,newApNameFocused:S,setNewApNameFocused:C,renameApNameFocused:w,setRenameApNameFocused:T,rotateConfirmApId:E,setRotateConfirmApId:D,isSearchOpen:O,setIsSearchOpen:k,searchQuery:A,setSearchQuery:j,filteredAccessPoints:t.filter(e=>e.name.toLowerCase().includes(A.toLowerCase())||e.token.toLowerCase().includes(A.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:I.DANGER});return}u(!0);try{await oe(e,a),r.current?.show({message:i(`setup.accessPointCreated`),intent:I.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:I.DANGER})}finally{u(!1)}}},handleRename:async()=>{let a=m.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:I.DANGER});return}_(!0);try{await pe(e,d,a),r.current?.show({message:i(`setup.accessPointRenamed`),intent:I.SUCCESS}),f(null),n()}catch(e){r.current?.show({message:e.message||`Failed to rename access point`,intent:I.DANGER})}finally{_(!1)}}},handleRotate:async t=>{y(t);try{await he(e,t),r.current?.show({message:i(`setup.tokenRotated`),intent:I.SUCCESS}),n()}catch(e){console.error(e)}finally{y(null)}},handleDelete:async t=>{if(confirm(i(`setup.deleteAccessPointConfirm`))){x(t);try{await ce(e,t),r.current?.show({message:i(`setup.accessPointDeleted`),intent:I.SUCCESS}),n()}catch(e){console.error(e)}finally{x(null)}}}}}const Te=({isOpen:e,onClose:t,newApName:n,setNewApName:r,newApNameFocused:i,setNewApNameFocused:a,handleAdd:o,isAdding:s,isValidApName:c})=>{let{t:l}=p();return(0,Z.jsxs)(j,{isOpen:e,onClose:t,title:l(`setup.addAccessPoint`),children:[(0,Z.jsx)(`div`,{className:O,children:(0,Z.jsx)(W,{content:l(`setup.accessPointNameFormatTip`,`1-30 characters, letters, numbers, hyphens and underscores allowed`),isOpen:i,position:E.TOP,intent:I.PRIMARY,className:`w-full`,children:(0,Z.jsx)(`div`,{className:`w-full block`,children:(0,Z.jsx)(z,{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:N,children:(0,Z.jsxs)(`div`,{className:G,children:[(0,Z.jsx)(A,{onClick:t,children:l(`common.cancel`,`Cancel`)}),(0,Z.jsx)(A,{intent:I.PRIMARY,onClick:o,loading:s,disabled:!c(n),children:l(`common.create`)})]})})]})},Ee=({isOpen:e,onClose:t,renameApName:n,setRenameApName:r,renameApNameFocused:i,setRenameApNameFocused:a,handleRename:o,isRenaming:s,isValidApName:c})=>{let{t:l}=p();return(0,Z.jsxs)(j,{isOpen:e,onClose:t,title:l(`setup.renameAccessPoint`),children:[(0,Z.jsx)(`div`,{className:O,children:(0,Z.jsx)(W,{content:l(`setup.accessPointNameFormatTip`,`1-30 characters, letters, numbers, hyphens and underscores allowed`),isOpen:i,position:E.TOP,intent:I.PRIMARY,className:`w-full`,children:(0,Z.jsx)(`div`,{className:`w-full block`,children:(0,Z.jsx)(z,{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:N,children:(0,Z.jsxs)(`div`,{className:G,children:[(0,Z.jsx)(A,{onClick:t,children:l(`common.cancel`,`Cancel`)}),(0,Z.jsx)(A,{intent:I.PRIMARY,onClick:o,loading:s,disabled:!c(n),children:l(`common.save`)})]})})]})},De=({ap:e,totalApCount:t,toasterRef:i,onRenameTrigger:a,rotateConfirmApId:s,setRotateConfirmApId:c,rotatingApId:l,handleRotate:d,deletingApId:f,handleDelete:m})=>{let{t:h}=p();return(0,Z.jsx)(H,{title:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(o,{size:16}),(0,Z.jsx)(`span`,{children:e.name})]}),className:`shadow-none! rounded-lg!`,children:(0,Z.jsxs)(L,{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}`),i.current?.show({message:h(`setup.copied`),intent:I.SUCCESS})},title:h(`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:h(`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:me(new Date(e.created_at*1e3))})]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex gap-2 flex-wrap`,children:[(0,Z.jsx)(A,{small:!0,icon:(0,Z.jsx)(n,{size:14}),text:h(`setup.renameAccessPoint`),onClick:()=>a(e.id,e.name)}),(0,Z.jsx)(F,{isOpen:s===e.id,onInteraction:e=>{e||c(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:h(`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)(A,{small:!0,minimal:!0,text:h(`common.cancel`,`Cancel`),onClick:()=>c(null)}),(0,Z.jsx)(A,{small:!0,intent:I.DANGER,text:h(`common.confirm`,`Confirm`),onClick:()=>{c(null),d(e.id)}})]})]}),placement:`top`,children:(0,Z.jsx)(A,{small:!0,icon:(0,Z.jsx)(u,{size:14}),text:h(`setup.rotateToken`),loading:l===e.id,onClick:()=>c(e.id)})}),(0,Z.jsx)(A,{small:!0,intent:I.DANGER,icon:(0,Z.jsx)(r,{size:14}),text:h(`setup.deleteAccessPoint`),loading:f===e.id,onClick:()=>m(e.id),disabled:t<=1,title:t<=1?`Cannot delete the only access point`:void 0})]})]})})},Oe=({isOpen:e,onClose:t,profileId:n,isMobile:r,accessPoints:i,loading:o,onRefresh:s,toasterRef:c})=>{let{t:l}=p(),{isAddDialogOpen:u,setIsAddDialogOpen:d,newApName:f,setNewApName:m,isAdding:h,renameApId:g,setRenameApId:_,renameApName:v,setRenameApName:y,isRenaming:b,rotatingApId:x,deletingApId:C,newApNameFocused:w,setNewApNameFocused:T,renameApNameFocused:E,setRenameApNameFocused:D,rotateConfirmApId:O,setRotateConfirmApId:k,isSearchOpen:j,setIsSearchOpen:N,searchQuery:P,setSearchQuery:F,filteredAccessPoints:L,isValidApName:R,handleAdd:B,handleRename:V,handleRotate:H,handleDelete:U}=we({profileId:n,accessPoints:i,onRefresh:s,toasterRef:c});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ge,{isOpen:e,onClose:t,title:j?(0,Z.jsx)(z,{leftIcon:`search`,placeholder:l(`setup.searchAccessPoints`,`Search...`),value:P,onChange:e=>F(e.target.value),rightElement:(0,Z.jsx)(A,{icon:`cross`,minimal:!0,onClick:()=>{N(!1),F(``)}}),autoFocus:!0}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{children:l(`setup.manageAccessPoints`)}),(0,Z.jsx)(A,{icon:(0,Z.jsx)(a,{size:14}),minimal:!0,onClick:()=>N(!0),className:`opacity-50 hover:opacity-100`})]}),icon:`diagram-tree`,size:r?`100%`:`450px`,children:[(0,Z.jsx)(A,{fill:!0,intent:I.PRIMARY,icon:(0,Z.jsx)(S,{size:16}),text:l(`setup.addAccessPoint`),onClick:()=>d(!0),large:!0}),o?(0,Z.jsx)(`div`,{className:`flex justify-center p-8`,children:(0,Z.jsx)(M,{})}):(0,Z.jsx)(`div`,{className:`space-y-4 mt-4`,children:L.map(e=>(0,Z.jsx)(De,{ap:e,totalApCount:i.length,toasterRef:c,onRenameTrigger:(e,t)=>{_(e),y(t)},rotateConfirmApId:O,setRotateConfirmApId:k,rotatingApId:x,handleRotate:H,deletingApId:C,handleDelete:U},e.id))})]}),(0,Z.jsx)(Te,{isOpen:u,onClose:()=>{d(!1),m(``)},newApName:f,setNewApName:m,newApNameFocused:w,setNewApNameFocused:T,handleAdd:B,isAdding:h,isValidApName:R}),(0,Z.jsx)(Ee,{isOpen:!!g,onClose:()=>_(null),renameApName:v,setRenameApName:y,renameApNameFocused:E,setRenameApNameFocused:D,handleRename:V,isRenaming:b,isValidApName:R})]})},ke=({profileId:e,profileKey:t,profileName:n,toasterRef:r})=>{let i=ue(),{t:a}=p(),[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,m]=(0,X.useState)(null),h=async()=>{l(!0);try{s(await le(e))}catch(e){console.error(e)}finally{l(!1)}};(0,X.useEffect)(()=>{h()},[e]);let[g,_]=(0,X.useState)(n||``);(0,X.useEffect)(()=>{n?_(n):e&&fe(e).then(e=>{e?.name&&_(e.name)}).catch(()=>{})},[e,n]);let v=(0,X.useMemo)(()=>o.length===0?null:o.find(e=>e.id===f)||o[0],[o,f]),y=v?v.token:t,b=v?v.name:void 0,x=`${window.location.origin}/${y}`,[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(null),[M,N]=(0,X.useState)(null),[P,F]=(0,X.useState)({ipv4:[],ipv6:[]}),[L,R]=(0,X.useState)(null),z=e=>{navigator.clipboard.writeText(e),r?.current?.show({message:a(`setup.copied`),intent:I.SUCCESS})},B=async()=>{T(!0),R(null);try{let[t,n]=await Promise.all([te(),re()]);C(t),j(n),t.timezone&&t.timezone!==`UNKNOWN`&&ne(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&&!Y(t.dotDomain)),a=r&&i||i?t.dotDomain:window.location.hostname||``;ie(a).then(e=>N(e)).catch(e=>console.warn(`Failed fetching domain geo location:`,e)),ae(a).then(e=>F(e)).catch(e=>console.warn(`Failed resolving domain DNS IPs:`,e)),R({success:!!t.connectedProfileId,profileMatch:t.connectedProfileId===e})}catch(e){console.error(`Verification failed`,e)}finally{T(!1)}};(0,X.useEffect)(()=>{B()},[e]);let V=(0,X.useMemo)(()=>{let e=[];for(let t of P.ipv4)e.push({ip:t,area:`IPv4`});for(let t of P.ipv6)e.push({ip:t,area:`IPv6`});return e},[P]);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)(_e,{isMobile:i}),(0,Z.jsx)(ve,{isVerifying:w,verifyResult:L,handleVerify:B,isMobile:i,clientInfo:S,showIp:E,setShowIp:D,showLocation:O,setShowLocation:k,traceInfo:A,edgeLocation:M}),(0,Z.jsx)(ye,{accessPoints:o,selectedApId:v?.id||null,onSelectAp:m,accessPointName:b,onManageAccessPoints:()=>d(!0),isMobile:i}),(0,Z.jsx)(be,{dohUrl:x,copyToClipboard:z,isMobile:i}),(0,Z.jsx)(Ce,{isMobile:i,copyToClipboard:z,profileKey:y,profileName:g||void 0,accessPointName:b,currentIps:V,dotDomain:S?.dotDomain}),(0,Z.jsx)(Oe,{isOpen:u,onClose:()=>d(!1),profileId:e,isMobile:i,accessPoints:o,loading:c,onRefresh:h,toasterRef:r})]})};export{ke as SetupView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{gt as e}from"./vendor-utils-CnB7BG7m.js";export default e();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as e,T as t,w as n}from"./index-CbTjGMTZ.js";export{t as setSystemLocale,e as setSystemTimeZone};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e){if(!e)return`🌐`;let t=e.toUpperCase().split(``).map(e=>127397+e.charCodeAt(0));return String.fromCodePoint(...t)}export{e as t};
|