dns-worker 1.0.2-3.3
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/LICENSE +662 -0
- package/README.md +294 -0
- package/dist/serverfull.mjs +11777 -0
- package/migrations/0000_init.sql +80 -0
- package/migrations/0001_move_lists_to_d1.sql +12 -0
- package/migrations/0002_activity_tracking.sql +7 -0
- package/migrations/0003_fix_profiles_cascade.sql +21 -0
- package/migrations/0004_system_settings.sql +12 -0
- package/migrations/0005_add_bloom_storage.sql +3 -0
- package/migrations/0006_cleanup_profiles_table.sql +18 -0
- package/migrations/0007_user_activity_and_totp.sql +37 -0
- package/migrations/0008_add_profile_key.sql +8 -0
- package/migrations/0009_add_profile_blooms.sql +5 -0
- package/migrations/0010_session_device_info.sql +3 -0
- package/migrations/0011_session_created_at.sql +2 -0
- package/migrations/0012_profile_bloom_chunks.sql +9 -0
- package/migrations/0013_add_session_revoked_to_activity_log.sql +29 -0
- package/migrations/0014_add_session_geo.sql +3 -0
- package/migrations/0015_add_signup_to_activity_log.sql +30 -0
- package/migrations/0016_add_session_rotation_counter.sql +2 -0
- package/migrations/0017_add_access_points.sql +31 -0
- package/migrations/0018_add_list_updated_at.sql +2 -0
- package/migrations/0019_add_list_sync_error.sql +2 -0
- package/migrations/0020_add_session_last_active.sql +5 -0
- package/migrations/0021_add_user_timezone.sql +2 -0
- package/migrations/0022_add_user_locale.sql +2 -0
- package/migrations/0023_add_user_password_version.sql +2 -0
- package/migrations/0024_session_pin_and_pause.sql +37 -0
- package/migrations/0025_add_secret_table.sql +10 -0
- package/migrations/0026_session_lock_config.sql +2 -0
- package/migrations/0027_add_session_id_to_activity_log.sql +2 -0
- package/migrations/0028_rename_session_id_to_session_id_hash.sql +2 -0
- package/migrations/0029_profile_blooms_staging.sql +12 -0
- package/migrations/0030_add_list_blooms.sql +7 -0
- package/migrations/0031_list_blooms_chunks.sql +13 -0
- package/migrations/0032_profile_blooms_cascade.sql +40 -0
- package/migrations/0033_remove_system_secrets.sql +2 -0
- package/migrations/0034_remove_list_entries.sql +2 -0
- package/migrations/0035_add_envelope_encryption_columns.sql +5 -0
- package/migrations/0036_add_cf_proxy_cidrs_setting.sql +7 -0
- package/migrations/0037_optimize_logs_composite_indexes.sql +25 -0
- package/migrations/0038_optimize_logs_table_and_indexes.sql +49 -0
- package/migrations/0039_add_lists_profile_id_index.sql +5 -0
- package/migrations/0040_reduce_logs_indexes_write_cost.sql +9 -0
- package/migrations/0041_create_log_hourly_rollups.sql +21 -0
- package/migrations/0042_add_rule_created_at.sql +3 -0
- package/migrations/0043_create_client_hourly_rollups.sql +26 -0
- package/migrations/0044_create_destination_hourly_rollups.sql +29 -0
- package/migrations/0045_transform_logs_without_rowid.sql +38 -0
- package/migrations/0046_add_passkeys.sql +19 -0
- package/migrations/0047_add_passkey_actions_to_activity_log.sql +35 -0
- package/migrations/0048_add_recovery_key_rotated_to_activity_log.sql +35 -0
- package/migrations/0049_optimize_rollups_and_add_domain_rollups.sql +26 -0
- package/migrations/0050_add_dest_columns_to_logs.sql +6 -0
- package/migrations/0051_add_registration_enabled_setting.sql +2 -0
- package/package.json +71 -0
- package/static/assets/AccountView-BvRvODjN.js +4 -0
- package/static/assets/AnalyticsView-DQ7hDChh.js +2 -0
- package/static/assets/AuthView-Bwv6hbdi.js +2 -0
- package/static/assets/DestinationMap-BEQNbcb-.js +1 -0
- package/static/assets/FilteringView-BWD3e-DS.js +1 -0
- package/static/assets/LogsView-kQy7qTGd.js +5 -0
- package/static/assets/QRCodeCanvas-X07w5x_G.js +2 -0
- package/static/assets/RulesView-3d5hga0L.js +1 -0
- package/static/assets/SettingsView-B9D0kPUF.js +1 -0
- package/static/assets/SetupView-D7d-Gsdr.js +1 -0
- package/static/assets/SwipeableDrawer-B-MfxTWM.js +1 -0
- package/static/assets/TrendChart-B20w7SzD.js +53 -0
- package/static/assets/allPaths-BEI3QvIM.js +1 -0
- package/static/assets/allPathsLoader-DM2JAMeC.js +1 -0
- package/static/assets/browser-icErLjuM.js +1 -0
- package/static/assets/date-C4b8kvr-.js +1 -0
- package/static/assets/de-DE-CXKS_pep.js +10 -0
- package/static/assets/es-ES-B2e3ea35.js +10 -0
- package/static/assets/formatCountryName-CSBD8pP8.js +1 -0
- package/static/assets/fr-FR-1qQHEpoW.js +10 -0
- package/static/assets/getFlagEmoji-_Wxhq0lT.js +1 -0
- package/static/assets/index-7FKlsF79.js +16 -0
- package/static/assets/index-DdQuGqR5.css +2 -0
- package/static/assets/ja-JP-CCVeJXwX.js +10 -0
- package/static/assets/ko-KR-bQ1okpC2.js +10 -0
- package/static/assets/obex_cat_eye_logo-256-CgYNvUIC.webp +0 -0
- package/static/assets/paths-CfqdBnl8.js +1 -0
- package/static/assets/paths-cc-gUzxh.js +1 -0
- package/static/assets/rolldown-runtime-C4Xdq4VV.js +1 -0
- package/static/assets/ru-RU-DeRsms_o.js +10 -0
- package/static/assets/services-fIMx5oSx.js +1 -0
- package/static/assets/splitPathsBySizeLoader-BgBwSA38.js +1 -0
- package/static/assets/vendor-i18next-cO7FDf_e.js +1 -0
- package/static/assets/vendor-icons-16-BgwRBCeU.js +1 -0
- package/static/assets/vendor-icons-20-X5NPN60g.js +1 -0
- package/static/assets/vendor-icons-other-Bme3ywH9.js +2 -0
- package/static/assets/vendor-react-Kt98jRfM.js +11 -0
- package/static/assets/vendor-ui-core-BpucEp_q.js +1 -0
- package/static/assets/vendor-utils-CfYGGC23.js +9 -0
- package/static/assets/vi-VN-BcXfqmzH.js +10 -0
- package/static/assets/zh-CN-D8YK7j27.js +12 -0
- package/static/assets/zh-TW-C2_-uaZk.js +12 -0
- package/static/favicon.webp +0 -0
- package/static/index.html +27 -0
- package/static/manifest.webmanifest +1 -0
- package/static/registerSW.js +1 -0
- package/static/sw.js +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{L as t,Xt as n,_ as r,a as i,c as a,g as o,i as s,l as c,o as l,r as u,s as d,y as f}from"./vendor-react-Kt98jRfM.js";import{S as p,b as m}from"./vendor-icons-other-Bme3ywH9.js";import{$ as h,M as g}from"./index-7FKlsF79.js";import{n as _,t as v}from"./formatCountryName-CSBD8pP8.js";import{t as y}from"./getFlagEmoji-_Wxhq0lT.js";var b=e(p(),1);function x(e){let[t,n]=(0,b.useState)(null);(0,b.useEffect)(()=>{g().then(e=>{if(e&&e.objects){let t={};e.objects.countries&&(t.countries=e.objects.countries),e.objects.land&&(t.land=e.objects.land),e.objects=t}e&&e.objects&&e.objects.countries&&Array.isArray(e.objects.countries.geometries)&&e.objects.countries.geometries.forEach(e=>{e.id!==void 0&&e.id!==null&&(e.id=String(e.id).padStart(3,`0`))}),n(e)}).catch(e=>console.error(`Failed to load map topology`,e))},[]);let r=(0,b.useMemo)(()=>e.reduce((e,t)=>e+t.count,0),[e]),i=(0,b.useMemo)(()=>{if(r<=0)return{maxThreshold:10,step:1};if(r<=1e3)return{maxThreshold:100,step:10};let e=10**Math.floor(Math.log10(r));return{maxThreshold:e,step:e/10}},[r]);return{geographyData:t,destinationMap:(0,b.useMemo)(()=>{let t={};return e.forEach(e=>{if(e.country_code){let n=e.country_code.toUpperCase();t[n]={count:e.count,name:e.country,countryCode:n}}}),t},[e]),scaleConfig:i,getLevel:e=>!e||e<=0?0:Math.min(10,Math.floor(e/i.step)+1),formatNumber:e=>{if(e>=1e6){let t=e/1e6;return Number.isInteger(t)?`${t}M`:`${t.toFixed(1)}M`}if(e>=1e3){let t=e/1e3;return Number.isInteger(t)?`${t}K`:`${t.toFixed(1)}K`}return e.toString()}}}var S=e(m(),1);const C=({onZoomIn:e,onZoomOut:n,onReset:i})=>(0,S.jsxs)(`div`,{className:`absolute top-3 right-3 flex flex-col gap-1.5 bg-white/80 dark:bg-slate-950/80 backdrop-blur-md p-1.5 rounded-lg border border-gray-200/50 dark:border-slate-800/50 shadow-sm z-10`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:e,className:`p-1.5 hover:bg-gray-100 dark:hover:bg-slate-800 rounded text-gray-600 dark:text-gray-300 transition-colors cursor-pointer`,title:`Zoom In`,children:(0,S.jsx)(o,{size:16})}),(0,S.jsx)(`button`,{type:`button`,onClick:n,className:`p-1.5 hover:bg-gray-100 dark:hover:bg-slate-800 rounded text-gray-600 dark:text-gray-300 transition-colors cursor-pointer`,title:`Zoom Out`,children:(0,S.jsx)(r,{size:16})}),(0,S.jsx)(`button`,{type:`button`,onClick:i,className:`p-1.5 hover:bg-gray-100 dark:hover:bg-slate-800 rounded text-gray-600 dark:text-gray-300 transition-colors cursor-pointer`,title:`Reset Zoom`,children:(0,S.jsx)(t,{size:16})})]}),w=({maxThreshold:e,formatNumber:t})=>{let{t:r}=n();return(0,S.jsxs)(`div`,{className:`sm:absolute sm:bottom-3 sm:left-3 relative m-3 sm:m-0 flex flex-col shrink-0 gap-1.5 bg-white/80 dark:bg-slate-950/80 backdrop-blur-md p-2 rounded-lg border border-gray-200/50 dark:border-slate-800/50 shadow-sm z-10 max-w-70`,children:[(0,S.jsx)(`span`,{className:`text-[9px] font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:r(`analytics.queries`)}),(0,S.jsx)(`div`,{className:`flex items-center gap-0.5`,children:Array.from({length:11}).map((e,t)=>(0,S.jsx)(`div`,{className:`w-4 h-2.5 rounded-sm border border-black/5 dark:border-white/5`,style:{backgroundColor:`var(--map-color-${t})`}},t))}),(0,S.jsxs)(`div`,{className:`flex justify-between text-[9px] text-gray-500 dark:text-gray-400 font-semibold px-0.5`,children:[(0,S.jsx)(`span`,{children:`0`}),(0,S.jsx)(`span`,{children:t(e/2)}),(0,S.jsxs)(`span`,{children:[t(e),`+`]})]})]})},T=({name:e,count:t,flag:r,x:i,y:a,countryCode:o,profileId:s,range:c,customRange:l,accessPointId:u,ispCache:d,onCacheIsp:p,isPinned:m,onClose:g})=>{let{t:_}=n(),v=(0,b.useRef)(null),[y,x]=(0,b.useState)({left:i,top:a-10,alignBottom:!1}),[C,w]=(0,b.useState)([]),[T,E]=(0,b.useState)(!1),D=(0,b.useRef)(d);D.current=d;let O=(0,b.useRef)(p);return O.current=p,(0,b.useEffect)(()=>{if(!o||!s)return;if(t<=0){w([]),E(!1);return}let e=D.current[o];if(e){w(e),E(!1);return}E(!0);let n=`?country_code=${o}&range=${c}`;if(c===`custom`&&l.start&&l.end){let e=Math.floor(new Date(l.start).getTime()/1e3),t=Math.floor(new Date(l.end).getTime()/1e3);n+=`&start=${e}&end=${t}`}u&&(n+=`&access_point_id=${u}`);let r=!0,i=setTimeout(()=>{h(s,`isps`,n).then(e=>{O.current(o,e),r&&w(e)}).catch(e=>{console.error(`Failed to fetch ISPs`,e)}).finally(()=>{r&&E(!1)})},200);return()=>{r=!1,clearTimeout(i)}},[o,s,c,l,u,t]),(0,b.useEffect)(()=>{if(!m)return;let e=e=>{if(v.current&&!v.current.contains(e.target)){let t=e.target,n=t.classList.contains(`rsm-geography`)||t.closest(`.rsm-geography`),r=t.classList.contains(`map-marker-circle`)||t.closest(`.map-marker-circle`);!n&&!r&&g()}},t=setTimeout(()=>{document.addEventListener(`click`,e,!0)},0);return()=>{clearTimeout(t),document.removeEventListener(`click`,e,!0)}},[m,g]),(0,b.useLayoutEffect)(()=>{if(!v.current)return;let e=v.current.getBoundingClientRect(),t=v.current.parentElement;if(!t)return;let n=t.getBoundingClientRect(),r=i,o=e.width/2;i-o<4?r=o+4:i+o>n.width-4&&(r=n.width-o-4);let s=a-10,c=!1;a-e.height-15<4&&(s=a+15,c=!0),x({left:r,top:s,alignBottom:c})},[i,a,C]),(0,S.jsxs)(`div`,{ref:v,onMouseLeave:m?g:void 0,className:`absolute bg-white/95 dark:bg-slate-900/95 backdrop-blur-sm px-3 py-2 rounded-lg shadow-xl border border-gray-200/50 dark:border-slate-800/50 text-xs z-50 flex flex-col gap-1 transition-all duration-75 text-gray-900 dark:text-gray-100 ${m?`pointer-events-auto cursor-default`:`pointer-events-none`}`,style:{left:`${y.left}px`,top:`${y.top}px`,transform:y.alignBottom?`translate(-50%, 0)`:`translate(-50%, -100%)`},children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 font-semibold whitespace-nowrap`,children:[(0,S.jsx)(`span`,{className:`text-sm`,children:r}),(0,S.jsx)(`span`,{children:e})]}),(0,S.jsxs)(`div`,{className:`text-gray-500 dark:text-gray-400 whitespace-nowrap`,children:[t.toLocaleString(),` `,_(`analytics.queries`)]})]}),m&&(0,S.jsx)(`button`,{onClick:e=>{e.stopPropagation(),g()},className:`flex items-center justify-center p-2 rounded-lg border border-gray-200 dark:border-slate-800 text-gray-500 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-950/20 hover:border-red-200 dark:hover:border-red-900/50 transition-colors cursor-pointer self-stretch aspect-square`,title:_(`common.close`,`Close`),children:(0,S.jsx)(f,{size:18})})]}),T?(0,S.jsxs)(`div`,{className:`mt-1.5 pt-1.5 border-t border-gray-150 dark:border-slate-850 flex flex-col gap-1 min-w-36`,children:[(0,S.jsx)(`div`,{className:`text-[10px] uppercase font-bold text-gray-400 dark:text-gray-500 tracking-wider`,children:_(`analytics.topIsps`,`Top ISPs`)}),(0,S.jsx)(`div`,{className:`text-[11px] text-gray-400 dark:text-gray-500 italic`,children:_(`analytics.loading`,`Loading...`)})]}):C.length>0&&(0,S.jsxs)(`div`,{className:`mt-1.5 pt-1.5 border-t border-gray-150 dark:border-slate-800 flex flex-col gap-1`,children:[(0,S.jsx)(`div`,{className:`text-[10px] uppercase font-bold text-gray-400 dark:text-gray-500 tracking-wider`,children:_(`analytics.topIsps`,`Top ISPs`)}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-36 max-w-48 ${m?`max-h-36 overflow-y-auto pr-1`:``}`,children:[(m?C:C.slice(0,5)).map(e=>(0,S.jsxs)(`div`,{className:`flex justify-between gap-3 text-[11px] text-gray-600 dark:text-gray-300`,children:[(0,S.jsx)(`span`,{className:`truncate`,title:e.name,children:e.name}),(0,S.jsx)(`span`,{className:`font-mono text-gray-400 dark:text-gray-500`,children:e.count.toLocaleString()})]},e.name)),!m&&C.length>5&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`text-center text-gray-400 dark:text-gray-500 leading-none py-0.5 font-bold`,children:`...`}),(0,S.jsx)(`div`,{className:`text-[10px] text-center text-blue-500 dark:text-blue-400 font-medium whitespace-nowrap mt-0.5`,children:_(`analytics.pressToShowMore`,`Click to show more`)})]})]})]})]})},E=({geographyData:e,destinationMap:t,getLevel:r,containerRef:i,hoveredCountry:o,setHoveredCountry:s})=>{let{i18n:c}=n();return e?(0,S.jsx)(a,{geography:e,children:({geographies:e})=>e.map(e=>{let n=_[e.id],a=n?t[n]:null,l=a?.count||0,u=r(l);return(0,S.jsx)(d,{geography:e,onMouseEnter:e=>{if(!n||o?.isPinned)return;let t=v(n,c.language)||a?.name||n,r=y(n),u=i.current?.getBoundingClientRect();s({name:t,code:n,count:l,flag:r,x:e.clientX-(u?.left||0),y:e.clientY-(u?.top||0)-15})},onMouseMove:e=>{s(t=>{if(t?.isPinned)return t;let n=i.current?.getBoundingClientRect(),r=e.clientX-(n?.left||0),a=e.clientY-(n?.top||0)-15;return t?{...t,x:r,y:a}:null})},onMouseLeave:()=>{s(e=>e?.isPinned?e:null)},onClick:e=>{if(e.stopPropagation(),!n)return;let t=v(n,c.language)||a?.name||n,r=y(n),o=i.current?.getBoundingClientRect(),u=e.clientX-(o?.left||0),d=e.clientY-(o?.top||0)-15;s(e=>e?.code===n&&e?.isPinned?null:{name:t,code:n,count:l,flag:r,x:u,y:d,isPinned:!0})},style:{default:{fill:`var(--map-color-${u})`,stroke:`var(--map-stroke)`,strokeWidth:.5,outline:`none`,transition:`fill 250ms, stroke 250ms`},hover:{fill:`var(--map-hover)`,stroke:`var(--map-stroke)`,strokeWidth:.5,outline:`none`,cursor:`pointer`},pressed:{fill:`var(--map-hover)`,stroke:`var(--map-stroke)`,strokeWidth:.5,outline:`none`}}},e.rsmKey)})}):null},D={SG:{name:`Singapore`,coordinates:[103.8198,1.3521]},HK:{name:`Hong Kong`,coordinates:[114.1694,22.3193]},MO:{name:`Macau`,coordinates:[113.5439,22.1987]},VA:{name:`Vatican City`,coordinates:[12.4534,41.9029]},MC:{name:`Monaco`,coordinates:[7.4246,43.7384]},SM:{name:`San Marino`,coordinates:[12.4578,43.9424]},LI:{name:`Liechtenstein`,coordinates:[9.5209,47.141]},AD:{name:`Andorra`,coordinates:[1.5218,42.5063]},MT:{name:`Malta`,coordinates:[14.3754,35.9375]},GI:{name:`Gibraltar`,coordinates:[-5.3536,36.1408]},BM:{name:`Bermuda`,coordinates:[-64.7505,32.3078]},MV:{name:`Maldives`,coordinates:[73.5089,4.1755]},MU:{name:`Mauritius`,coordinates:[57.5522,-20.3484]}},O=({destinationMap:e,getLevel:t,containerRef:r,hoveredCountry:i,setHoveredCountry:a})=>{let{i18n:o}=n();return(0,S.jsx)(S.Fragment,{children:Object.entries(D).map(([n,s])=>{let u=e[n],d=u?.count||0,f=t(d),p=d>0,m=p?4:1.5;return(0,S.jsx)(c,{coordinates:l(s.coordinates[0],s.coordinates[1]),onMouseEnter:e=>{if(i?.isPinned)return;let t=v(n,o.language)||u?.name||n,s=y(n),c=r.current?.getBoundingClientRect();a({name:t,code:n,count:d,flag:s,x:e.clientX-(c?.left||0),y:e.clientY-(c?.top||0)-15})},onMouseMove:e=>{a(t=>{if(t?.isPinned)return t;let n=r.current?.getBoundingClientRect(),i=e.clientX-(n?.left||0),a=e.clientY-(n?.top||0)-15;return t?{...t,x:i,y:a}:null})},onMouseLeave:()=>{a(e=>e?.isPinned?e:null)},onClick:e=>{e.stopPropagation();let t=v(n,o.language)||u?.name||n,i=y(n),s=r.current?.getBoundingClientRect(),c=e.clientX-(s?.left||0),l=e.clientY-(s?.top||0)-15;a(e=>e?.code===n&&e?.isPinned?null:{name:t,code:n,count:d,flag:i,x:c,y:l,isPinned:!0})},children:p?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`circle`,{r:m+3,fill:`var(--map-color-${f})`,opacity:.4,className:`animate-ping map-marker-circle`}),(0,S.jsx)(`circle`,{r:m,fill:`var(--map-color-${f})`,stroke:`var(--map-stroke)`,strokeWidth:.75,style:{cursor:`pointer`},className:`map-marker-circle`})]}):(0,S.jsx)(`circle`,{r:m,fill:`var(--text-color)`,opacity:.25,style:{pointerEvents:`none`}})},n)})})},k=({destinations:e,profileId:t,range:n,customRange:r,accessPointId:a})=>{let{geographyData:o,destinationMap:c,scaleConfig:d,getLevel:f,formatNumber:p}=x(e),[m,h]=(0,b.useState)({coordinates:l(0,0),zoom:1.2}),[g,_]=(0,b.useState)(null),[v,y]=(0,b.useState)(null),[D,k]=(0,b.useState)({}),A=(0,b.useRef)(null);A.current=g,(0,b.useEffect)(()=>{if(!g){y(null);return}if(g.isPinned){y(g);return}if(v&&v.code===g.code)return;let e=setTimeout(()=>{A.current&&A.current.code===g.code&&y(A.current)},100);return()=>clearTimeout(e)},[g?.code,g?.isPinned,v?.code]),(0,b.useEffect)(()=>{g&&v&&g.code===v.code&&(g.x!==v.x||g.y!==v.y||g.isPinned!==v.isPinned)&&y(g)},[g?.x,g?.y,g?.isPinned,v]);let j=(0,b.useRef)(null);b.useEffect(()=>{k({})},[t,n,r,a]);let M=b.useCallback((e,t)=>{k(n=>({...n,[e]:t}))},[]),N=b.useMemo(()=>u(l(-100,-50),l(900,600)),[]);return(0,S.jsxs)(`div`,{className:`relative w-full min-h-85 max-h-120 aspect-800/566 bg-gray-50 dark:bg-slate-950 rounded-xl overflow-hidden border border-gray-100 dark:border-slate-800 flex flex-col justify-between shadow-sm`,children:[(0,S.jsxs)(`div`,{ref:j,className:`relative w-full flex-1 min-h-0 overflow-hidden select-none cursor-grab active:cursor-grabbing`,onClick:e=>{(e.target===e.currentTarget||e.target.tagName===`svg`)&&_(null)},children:[(0,S.jsx)(s,{projection:`geoEqualEarth`,width:800,height:566,style:{width:`100%`,height:`100%`},children:(0,S.jsxs)(i,{zoom:m.zoom,center:m.coordinates,onMoveEnd:e=>h({coordinates:l(e.coordinates[0],e.coordinates[1]),zoom:e.zoom}),maxZoom:8,minZoom:1,enablePan:!0,translateExtent:N,children:[(0,S.jsx)(E,{geographyData:o,destinationMap:c,getLevel:f,containerRef:j,hoveredCountry:g,setHoveredCountry:_}),(0,S.jsx)(O,{destinationMap:c,getLevel:f,containerRef:j,hoveredCountry:g,setHoveredCountry:_})]})}),v&&(0,S.jsx)(T,{name:v.name,count:v.count,flag:v.flag,x:v.x,y:v.y,countryCode:v.code,profileId:t,range:n,customRange:r,accessPointId:a,ispCache:D,onCacheIsp:M,isPinned:v.isPinned||!1,onClose:()=>_(null)})]}),(0,S.jsx)(C,{onZoomIn:()=>{m.zoom>=8||h(e=>({...e,zoom:e.zoom*1.5}))},onZoomOut:()=>{m.zoom<=1||h(e=>({...e,zoom:e.zoom/1.5}))},onReset:()=>{h({coordinates:l(0,0),zoom:1.2})}}),(0,S.jsx)(w,{maxThreshold:d.maxThreshold,formatNumber:p})]})};export{k as DestinationMap};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{At as t,C as n,F as r,R as i,Xt as a,at as o,ct as s,k as c}from"./vendor-react-Kt98jRfM.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-BpucEp_q.js";import{_t as T}from"./vendor-utils-CfYGGC23.js";import{B as E,C as D,G as O,P as k,U as A,Xt as j,dt as M,lt as N,q as P,tt as F}from"./index-7FKlsF79.js";var I=e(l(),1);const L=()=>{let{t:e}=a(),[t,n]=(0,I.useState)([]);return(0,I.useEffect)(()=>{k().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:i,lists:o})=>{let{t:s}=a(),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||i,disabled:r||i,children:s(`filtering.addSubscription`)})]})})},B=({lists:e,onSelect:t})=>{let{t:n}=a(),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?D(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:t,onClose:i,onCopy:l,onDelete:u,onToggleEnabled:d,onAllowDomain:f})=>{let{t:p}=a(),[_,S]=(0,I.useState)(``),[C,w]=(0,I.useState)(!1),[T,E]=(0,I.useState)(null),[k,A]=(0,I.useState)(null),[j,M]=(0,I.useState)(!1),[N,P]=(0,I.useState)(!1),[F,L]=(0,I.useState)(!1),z=(0,I.useRef)(0),B=()=>{z.current++,w(!1),S(``),E(null),A(null),P(!1)},V=async()=>{let n=_.trim().toLowerCase();if(!n||!t||(n=n.replace(/^https?:\/\//,``).split(`/`)[0].split(`:`)[0].replace(/\.+$/,``),!n))return;S(n);let r=++z.current,i=t.id;w(!0),A(null),E(null),P(!1);try{let t=await O(e,i,n);z.current===r&&E(t)}catch(e){z.current===r&&A(e instanceof Error?e.message:String(e))}finally{z.current===r&&w(!1)}},H=async e=>{if(t){L(!0);try{await d(t.id,e)}finally{L(!1)}}},U=async()=>{if(T?.matchedEntry){M(!0);try{await f(T.domain),P(!0)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}};return(0,R.jsxs)(h,{isOpen:t!==null,onClose:()=>{B(),i()},title:p(`filtering.listDetails`,`List Details`),icon:`info-sign`,children:[(0,R.jsxs)(`div`,{className:`p-6 space-y-4`,children:[t?.sync_error&&(0,R.jsx)(g,{intent:v.WARNING,title:p(`filtering.syncError`),icon:`warning-sign`,children:t.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:t?.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:!!t?.enabled,disabled:F,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)(r,{size:14}),text:p(`filtering.check`,`Check`),loading:C,disabled:!_.trim(),onClick:()=>void V()})]}),k&&(0,R.jsx)(g,{intent:v.DANGER,className:`text-xs`,children:k}),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.`)}),N?(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)(c,{size:12}),intent:v.PRIMARY,loading:j,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`),`:`,` `,t?.last_synced_at?D(new Date(t.last_synced_at*1e3)):`-`]}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(m,{icon:(0,R.jsx)(s,{size:14}),text:p(`setup.copyUrl`,`Copy link`),onClick:()=>{t&&l(t.url)}}),(0,R.jsx)(m,{icon:(0,R.jsx)(o,{size:14}),text:p(`setup.learnMore`,`Open link`),onClick:()=>{t&&window.open(t.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)(n,{size:14}),intent:v.DANGER,text:p(`rules.delete`,`Delete`),onClick:()=>{if(!t)return;let e=t.id;B(),u(e)}}),(0,R.jsx)(m,{onClick:()=>{B(),i()},text:p(`rules.close`,`Close`)})]})]})},H=({profileId:e,toasterRef:n})=>{let r=t(),o=j(),[s,c]=(0,I.useState)([]),[l,u]=(0,I.useState)(``),[f,p]=(0,I.useState)(!0),[h,_]=(0,I.useState)(!1),{t:y}=a(),[b,x]=(0,I.useState)(null),S=async()=>{p(!0);try{c(await F(e))}catch(e){console.error(`Failed to fetch filters`,e)}finally{p(!1)}},C=e=>{navigator.clipboard.writeText(e),n?.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 F(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`,o?`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:[o?(0,R.jsxs)(d,{minimal:!0,fill:o,children:[(0,R.jsx)(m,{active:!1,onClick:()=>r(`/dash/${e}/rules`),text:y(`rules.title`),large:!0}),(0,R.jsx)(m,{active:!0,onClick:()=>r(`/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)(i,{size:16}),text:y(`filtering.syncAll`),onClick:async()=>{_(!0);try{await N(e),n?.current?.show({message:y(`filtering.syncTaskStarted`),intent:v.PRIMARY,icon:`cloud-download`}),await w(s)&&n?.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:o?`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 t=>{let r=t||l;if(r){_(!0);try{await E(e,r),n?.current?.show({message:y(`filtering.addSuccess`),intent:v.SUCCESS,icon:`tick`}),u(``),n?.current?.show({message:y(`filtering.syncTaskStarted`),intent:v.PRIMARY,icon:`cloud-download`}),await w(s)&&n?.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 t=>{try{await P(e,t),n?.current?.show({message:y(`filtering.deleteSuccess`),intent:v.PRIMARY,icon:`trash`}),x(null),await S()}catch(e){console.error(e)}},onToggleEnabled:async(t,r)=>{try{await M(e,t,r),x(e=>e&&e.id===t?{...e,enabled:r}:e),n?.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),n?.current?.show({message:e instanceof Error?e.message:String(e),intent:v.DANGER,icon:`error`})}},onAllowDomain:async t=>{await A(e,{type:`ALLOW`,pattern:t}),n?.current?.show({message:y(`filtering.allowRuleAdded`,`Exception added for {{domain}}`,{domain:t}),intent:v.SUCCESS,icon:`tick`})}})]})};export{H as FilteringView};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/services-fIMx5oSx.js","assets/index-7FKlsF79.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-Kt98jRfM.js","assets/vendor-ui-core-BpucEp_q.js","assets/vendor-utils-CfYGGC23.js","assets/vendor-i18next-cO7FDf_e.js","assets/index-DdQuGqR5.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{A as t,H as n,J as r,K as i,V as a,Xt as o,b as s,gt as c,j as l,nt as u,tt as d,wt as f,yt as p}from"./vendor-react-Kt98jRfM.js";import{S as m,b as h,x as g}from"./vendor-icons-other-Bme3ywH9.js";import{C as _,E as v,M as y,N as b,P as x,S,T as C,V as w,a as T,f as E,h as D,l as O,o as k,p as A,r as j,u as M,w as N,x as P}from"./vendor-ui-core-BpucEp_q.js";import{_t as F}from"./vendor-utils-CfYGGC23.js";import{$ as I,C as L,Q as R,Xt as ee,et as te,nt as z,rt as B}from"./index-7FKlsF79.js";import{n as ne,t as V}from"./formatCountryName-CSBD8pP8.js";import{t as H}from"./getFlagEmoji-_Wxhq0lT.js";import{t as U}from"./SwipeableDrawer-B-MfxTWM.js";var W=e(m(),1),G=e(h(),1);const K=({range:e,setRange:t,customRange:n,setCustomRange:r,nowStr:i,fetchLogs:a,isMobile:s,logRetentionDays:l})=>{let{t:u}=o(),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<=l).map(e=>e.key);return(0,G.jsx)(`div`,{className:`overflow-x-auto pb-1 -mx-4 px-4 md:mx-0 md:px-0`,children:(0,G.jsxs)(_,{minimal:s,variant:s?void 0:`minimal`,children:[d.map(n=>(0,G.jsx)(b,{active:e===n,onClick:()=>t(n),text:n.toUpperCase(),small:s},n)),(0,G.jsx)(C,{content:(0,G.jsxs)(`div`,{className:`p-4 space-y-2 w-64`,children:[(0,G.jsx)(y,{children:u(`analytics.customRange`)}),(0,G.jsx)(A,{label:u(`analytics.startTime`),children:(0,G.jsx)(E,{type:`datetime-local`,max:n.end||i,value:n.start,onChange:e=>r({...n,start:e.target.value})})}),(0,G.jsx)(A,{label:u(`analytics.endTime`),children:(0,G.jsx)(E,{type:`datetime-local`,min:n.start,max:i,value:n.end,onChange:e=>r({...n,end:e.target.value})})}),(0,G.jsx)(b,{fill:!0,intent:w.PRIMARY,text:u(`analytics.apply`),onClick:()=>{t(`custom`),a(`custom`,!0)}})]}),children:(0,G.jsx)(b,{active:e===`custom`,icon:(0,G.jsx)(c,{size:14}),text:s?``:u(`analytics.custom`),small:s})})]})})},q=({statusFilter:e,setStatusFilter:t,isMobile:n})=>{let{t:r}=o(),i=(0,G.jsxs)(v,{children:[(0,G.jsx)(N,{icon:e===null?`tick`:void 0,text:r(`logs.allStatus`),onClick:()=>t(null)}),(0,G.jsx)(O,{}),(0,G.jsx)(N,{icon:e===`PASS`?`tick`:void 0,intent:w.SUCCESS,text:r(`logs.onlyPass`),onClick:()=>t(`PASS`)}),(0,G.jsx)(N,{icon:e===`BLOCK`?`tick`:void 0,intent:w.DANGER,text:r(`logs.onlyBlock`),onClick:()=>t(`BLOCK`)}),(0,G.jsx)(N,{icon:e===`REDIRECT`?`tick`:void 0,intent:w.WARNING,text:r(`logs.onlyRedirect`),onClick:()=>t(`REDIRECT`)})]}),a=(()=>{switch(e){case`PASS`:return{text:r(`logs.statusPass`),intent:w.SUCCESS};case`BLOCK`:return{text:r(`logs.statusBlock`),intent:w.DANGER};case`REDIRECT`:return{text:r(`logs.statusRedirect`),intent:w.WARNING};default:return{text:r(`logs.allStatus`),intent:w.NONE}}})();return(0,G.jsx)(C,{content:i,placement:`bottom-start`,children:(0,G.jsx)(b,{icon:(0,G.jsx)(u,{size:14}),rightIcon:`caret-down`,intent:a.intent,text:a.text,variant:`outlined`,fill:n})})},J=({accessPointIdFilter:e,setAccessPointIdFilter:t,accessPoints:n,isMobile:r})=>{let{t:a}=o(),s=(0,G.jsxs)(v,{children:[(0,G.jsx)(N,{icon:e===null?`tick`:void 0,text:a(`logs.allAccessPoint`),onClick:()=>t(null)}),(0,G.jsx)(O,{}),n.map(n=>(0,G.jsx)(N,{icon:e===n.id?`tick`:void 0,text:n.name,onClick:()=>t(n.id)},n.id))]}),c=e&&n.find(t=>t.id===e)?.name||a(`logs.allAccessPoint`);return(0,G.jsx)(C,{content:s,placement:`bottom-start`,children:(0,G.jsx)(b,{icon:(0,G.jsx)(i,{size:14}),rightIcon:`caret-down`,intent:e?w.PRIMARY:w.NONE,text:c,variant:`outlined`,fill:r})})},Y=Array.from(new Set(Object.values(ne))).sort((e,t)=>e.localeCompare(t)),X=({destCountryFilter:e,setDestCountryFilter:t,isMobile:n})=>{let{t:r,i18n:i}=o(),[a,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(``),u=(0,W.useMemo)(()=>{let e=i.language;return Y.map(t=>{let n=V(t,e),r=V(t,`en`);return{code:t,name:n||r||t,searchStr:`${t} ${n} ${r}`.toLowerCase()}})},[i.language]),f=(0,W.useMemo)(()=>{let e=c.trim().toLowerCase();return e?u.filter(t=>t.searchStr.includes(e)):u},[u,c]),p=(0,G.jsxs)(`div`,{className:`w-72 flex flex-col p-1.5`,children:[(0,G.jsx)(`div`,{className:`pb-1.5`,children:(0,G.jsx)(E,{leftIcon:`search`,placeholder:r(`logs.searchCountry`,`Search country...`),value:c,onChange:e=>l(e.target.value),small:!0,autoFocus:!0,rightElement:c?(0,G.jsx)(b,{icon:`cross`,variant:`minimal`,small:!0,onClick:()=>l(``)}):void 0})}),(0,G.jsxs)(v,{className:`max-h-64 overflow-y-auto`,children:[!c&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(N,{icon:e===null?`tick`:void 0,text:r(`logs.allCountry`),onClick:()=>{t(null),s(!1)}}),(0,G.jsx)(O,{})]}),f.length===0?(0,G.jsx)(N,{disabled:!0,text:r(`logs.noMatchingCountries`,`No matching countries found`)}):f.map(n=>(0,G.jsx)(N,{icon:e===n.code?`tick`:void 0,text:(0,G.jsxs)(`span`,{className:`flex items-center justify-between gap-2 w-full`,children:[(0,G.jsxs)(`span`,{className:`truncate`,children:[H(n.code),` `,n.name]}),(0,G.jsx)(`span`,{className:`text-xs text-gray-400 shrink-0 font-mono`,children:n.code})]}),onClick:()=>{t(n.code),s(!1)}},n.code))]})]}),m=e?`${H(e)} ${V(e,i.language)||e} (${e})`:r(`logs.allCountry`);return(0,G.jsx)(C,{content:p,placement:`bottom-start`,isOpen:a,onInteraction:e=>{s(e),e||l(``)},children:(0,G.jsx)(b,{icon:(0,G.jsx)(d,{size:14}),rightIcon:`caret-down`,intent:e?w.PRIMARY:w.NONE,text:m,variant:`outlined`,fill:n})})},re=({profileId:e,range:t,customRange:r,destCountryFilter:i,accessPointIdFilter:a,ispFilter:s,setIspFilter:c,isMobile:l})=>{let{t:u}=o(),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)([]),[h,g]=(0,W.useState)(!1),[_,y]=(0,W.useState)(``),S=(0,W.useRef)(``),T=`${e}:${t}:${r.start?Math.floor(new Date(r.start).getTime()/1e3):``}:${r.end?Math.floor(new Date(r.end).getTime()/1e3):``}:${i||``}:${a||``}`,D=async()=>{g(!0);try{let n=new URLSearchParams;if(t===`custom`&&r.start&&r.end){let e=Math.floor(new Date(r.start).getTime()/1e3),t=Math.floor(new Date(r.end).getTime()/1e3);n.set(`range`,`custom`),n.set(`start`,String(e)),n.set(`end`,String(t))}else n.set(`range`,t);i&&n.set(`country_code`,i),a&&n.set(`access_point_id`,a);let o=await I(e,`isps`,n.toString());m(Array.isArray(o)?o:[]),S.current=T}catch(e){console.error(`Failed to fetch ISPs for filter`,e)}finally{g(!1)}},k=e=>{f(e),e?S.current!==T&&D():y(``)},A=(0,W.useMemo)(()=>{let e=_.trim().toLowerCase();return e?p.filter(t=>t.name.toLowerCase().includes(e)):p},[p,_]),j=(0,G.jsxs)(`div`,{className:`w-72 flex flex-col p-1.5`,children:[(0,G.jsx)(`div`,{className:`pb-1.5`,children:(0,G.jsx)(E,{leftIcon:`search`,placeholder:u(`logs.searchIsp`,`Search ISP...`),value:_,onChange:e=>y(e.target.value),small:!0,autoFocus:!0,rightElement:_?(0,G.jsx)(b,{icon:`cross`,variant:`minimal`,small:!0,onClick:()=>y(``)}):void 0})}),(0,G.jsx)(v,{className:`max-h-64 overflow-y-auto`,children:h?(0,G.jsxs)(`div`,{className:`flex items-center justify-center p-6 text-gray-500 gap-2`,children:[(0,G.jsx)(x,{size:16}),(0,G.jsx)(`span`,{className:`text-xs`,children:u(`logs.loadingIsps`,`Loading ISPs...`)})]}):(0,G.jsxs)(G.Fragment,{children:[!_&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(N,{icon:s===null?`tick`:void 0,text:u(`logs.allIsp`),onClick:()=>{c(null),f(!1)}}),(0,G.jsx)(O,{})]}),A.length===0?(0,G.jsx)(N,{disabled:!0,text:u(`logs.noMatchingIsps`,`No matching ISPs found`)}):A.map(e=>(0,G.jsx)(N,{icon:s===e.name?`tick`:void 0,text:(0,G.jsxs)(`span`,{className:`flex items-center justify-between gap-2 w-full`,children:[(0,G.jsx)(`span`,{className:`truncate`,title:e.name,children:e.name}),(0,G.jsx)(`span`,{className:`text-xs text-gray-400 shrink-0 font-mono`,children:e.count.toLocaleString()})]}),onClick:()=>{c(e.name),f(!1)}},e.name))]})})]}),M=s||u(`logs.allIsp`);return(0,G.jsx)(C,{content:j,placement:`bottom-start`,isOpen:d,onInteraction:k,children:(0,G.jsx)(b,{icon:(0,G.jsx)(n,{size:14}),rightIcon:`caret-down`,intent:s?w.PRIMARY:w.NONE,text:M,variant:`outlined`,fill:l})})},ie=({profileId:e,range:t,setRange:n,customRange:r,setCustomRange:i,nowStr:a,fetchLogs:s,isMobile:c,realtimeRefresh:l,setRealtimeRefresh:u,statusFilter:d,setStatusFilter:f,accessPointIdFilter:p,setAccessPointIdFilter:m,accessPoints:h,destCountryFilter:g,setDestCountryFilter:_,ispFilter:v,setIspFilter:y,searchQuery:x,setSearchQuery:S,stats:C,logRetentionDays:T,onExport:O,exporting:k})=>{let{t:A}=o(),[M,N]=(0,W.useState)(!0),P=d!==null||p!==null||g!==null||v!==null;return(0,G.jsxs)(`div`,{className:`p-4 ${c&&M?`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,G.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between w-full md:w-auto`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h2`,{className:`bp6-heading flex flex-wrap items-center gap-2 text-xl md:text-2xl m-0`,children:[A(`logs.title`),` `,(!c||!M)&&(0,G.jsx)(j,{minimal:!0,round:!0,children:t===`custom`?A(`analytics.custom`):t.toUpperCase()}),C&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(j,{minimal:!0,round:!0,children:C.total.toLocaleString()}),(0,G.jsx)(j,{minimal:!0,round:!0,intent:w.SUCCESS,children:C.pass.toLocaleString()}),(0,G.jsx)(j,{minimal:!0,round:!0,intent:w.DANGER,children:C.block.toLocaleString()}),(0,G.jsx)(j,{minimal:!0,round:!0,intent:w.WARNING,children:C.redirect.toLocaleString()})]})]}),!c&&(0,G.jsx)(`p`,{className:`bp6-text-muted mt-1`,children:A(`logs.subtitle`)})]}),c&&(0,G.jsx)(b,{icon:M?`chevron-down`:`chevron-up`,variant:`minimal`,onClick:()=>N(!M)})]}),(!c||!M)&&(0,G.jsxs)(`div`,{className:`flex flex-col items-stretch md:items-end gap-2`,children:[(0,G.jsx)(K,{range:t,setRange:n,customRange:r,setCustomRange:i,nowStr:a,fetchLogs:s,isMobile:c,logRetentionDays:T}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-4`,children:[(0,G.jsx)(b,{icon:`download`,onClick:O,loading:k,title:A(`logs.export`,`Export Logs`),text:c?void 0:A(`logs.export`,`Export Logs`)}),(0,G.jsx)(D,{label:A(`logs.realtime`),checked:l,onChange:e=>u(e.target.checked),className:`mb-0!`}),(0,G.jsx)(b,{icon:`refresh`,onClick:()=>s(t,!0),variant:`minimal`,small:c})]})]})]}),(!c||!M)&&(0,G.jsxs)(`div`,{className:`flex flex-col md:flex-row items-stretch md:items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 md:flex md:items-center gap-2`,children:[P&&(0,G.jsx)(`div`,{className:`col-span-2 md:contents`,children:(0,G.jsx)(b,{icon:`filter-remove`,onClick:()=>{f(null),m(null),_(null),y(null)},variant:`minimal`,title:A(`logs.clearFilters`),text:c?A(`logs.clearFilters`):void 0,fill:c})}),(0,G.jsx)(q,{statusFilter:d,setStatusFilter:f,isMobile:c}),h.length>0&&(0,G.jsx)(J,{accessPointIdFilter:p,setAccessPointIdFilter:m,accessPoints:h,isMobile:c}),(0,G.jsx)(X,{destCountryFilter:g,setDestCountryFilter:_,isMobile:c}),(0,G.jsx)(re,{profileId:e,range:t,customRange:r,destCountryFilter:g,accessPointIdFilter:p,ispFilter:v,setIspFilter:y,isMobile:c})]}),(0,G.jsx)(`div`,{className:`flex items-center gap-2 flex-1 md:max-w-md justify-end`,children:(0,G.jsx)(`div`,{className:`flex-1 md:max-w-xs`,children:(0,G.jsx)(E,{leftIcon:`search`,placeholder:A(`logs.searchPlaceholder`),value:x,onChange:e=>S(e.target.value),rightElement:x?(0,G.jsx)(b,{icon:`cross`,minimal:!0,onClick:()=>S(``)}):void 0,fill:!0})})})]})]})},ae=({logs:e,setSelectedLog:t,setIsDrawerOpen:n,lastLogElementRef:r,prevLatestTimestamp:i,realtimeRefresh:a})=>(0,G.jsx)(`div`,{className:`space-y-3 py-4`,children:e.map((o,s)=>{let c=a&&i!==null&&o.timestamp>i;return(0,G.jsxs)(P,{interactive:!0,onClick:()=>{t(o),n(!0)},className:F(`p-3 dark:bg-gray-900 rounded-xl border border-gray-200 dark:border-gray-800 shadow-sm overflow-hidden`,{"animate-row-glow":c}),ref:s===e.length-1?r:null,children:[(0,G.jsxs)(`div`,{className:`flex justify-between items-start mb-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`img`,{src:`/api/icon/${o.domain.replace(/^\*\./,``)}.ico`,className:`w-4 h-4 rounded-sm shrink-0`,alt:``,referrerPolicy:`no-referrer`,onError:e=>e.currentTarget.style.opacity=`0`}),(0,G.jsx)(`span`,{className:`font-bold text-sm truncate`,children:o.domain})]}),(0,G.jsx)(j,{minimal:!0,round:!0,intent:o.action===`PASS`?w.SUCCESS:o.action===`BLOCK`?w.DANGER:w.WARNING,className:`text-[10px] shrink-0`,children:o.action})]}),(0,G.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-mono opacity-50`,children:new Date(o.timestamp*1e3).toLocaleTimeString([],{hour12:!1})}),(0,G.jsx)(`span`,{className:`text-[10px] bg-gray-100 dark:bg-gray-800 px-1 rounded opacity-60`,children:o.record_type}),o.access_point_name&&(0,G.jsx)(`span`,{className:`text-[10px] opacity-50 truncate max-w-25`,children:o.access_point_name})]}),(0,G.jsx)(`div`,{className:`text-[10px] opacity-40 font-mono italic`,children:o.latency?`${o.latency}ms`:``})]})]},o.id)})}),oe=({logs:e,setSelectedLog:t,setIsDrawerOpen:n,lastLogElementRef:r,prevLatestTimestamp:i,realtimeRefresh:a})=>{let{t:s}=o(),c=[{key:`time`,header:s(`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:s(`logs.tableDomain`),headerClassName:`w-1/4`,render:e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[(0,G.jsx)(`img`,{src:`/api/icon/${e.domain.replace(/^\*\./,``)}.ico`,className:`w-4 h-4 rounded-sm`,alt:``,referrerPolicy:`no-referrer`}),(0,G.jsx)(`span`,{className:`font-bold text-sm truncate`,children:e.domain})]})},{key:`answer`,header:s(`logs.tableAnswer`),headerClassName:`w-1/4`,cellClassName:`truncate font-mono text-[11px] opacity-70`,render:e=>e.answer||`-`},{key:`source`,header:s(`logs.tableSource`),headerClassName:`w-32`,render:e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(j,{minimal:!0,className:`font-mono text-[10px]`,children:H(e.geo_country||`UN`)}),e.access_point_name&&(0,G.jsx)(`span`,{className:`text-xs opacity-70 truncate max-w-20`,title:e.access_point_name,children:e.access_point_name})]})},{key:`type`,header:s(`logs.tableType`),headerClassName:`w-20`,cellClassName:`text-center`,render:e=>(0,G.jsx)(`code`,{className:`text-[10px]`,children:e.record_type})},{key:`status`,header:s(`logs.tableStatus`),headerClassName:`w-28`,cellClassName:`text-center`,render:e=>(0,G.jsx)(`span`,{className:F(`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,G.jsx)(`span`,{className:`bp6-text-overflow-ellipsis bp6-fill text-center`,children:e.action})})},{key:`reason`,header:s(`logs.tableReason`),headerClassName:`rounded-tr-xl`,cellClassName:`text-xs text-gray-500 italic truncate`,render:e=>e.reason||`-`}];return(0,G.jsx)(`div`,{className:`min-w-full inline-block align-middle py-0`,children:(0,G.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,G.jsxs)(M,{interactive:!0,striped:!0,className:`w-full table-fixed`,children:[(0,G.jsx)(`thead`,{className:`sticky top-0 z-20 backdrop-blur-md`,children:(0,G.jsx)(`tr`,{children:c.map(e=>(0,G.jsx)(`th`,{className:F(`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,G.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-gray-800`,children:e.map((o,s)=>{let l=a&&i!==null&&o.timestamp>i;return(0,G.jsx)(`tr`,{onClick:()=>{t(o),n(!0)},className:F(`cursor-pointer`,{"animate-row-glow":l}),ref:s===e.length-1?r:null,children:c.map(e=>(0,G.jsx)(`td`,{className:F(`px-4 py-3`,e.cellClassName),children:e.render(o,s)},e.key))},o.id)})})]})})})},se=({logs:e,loading:t,loadingMore:n,hasMore:r,realtimeRefresh:i,isMobile:a,searchQuery:s,scrollContainerRef:c,lastLogElementRef:l,prevLatestTimestamp:u,setSelectedLog:d,setIsDrawerOpen:f,logRetentionDays:p})=>{let{t:m}=o();return(0,G.jsxs)(`div`,{ref:c,className:F(`flex-1 overflow-y-auto relative`,a?`px-1`:`px-4`),children:[e.length===0&&!t?(0,G.jsx)(`div`,{className:`py-20`,children:(0,G.jsx)(S,{title:p===0?m(`logs.loggingDisabledTitle`,`日志记录已关闭`):m(s?`logs.noResults`:`logs.noRecords`),icon:p===0?`disable`:s?`search`:`outdated`,intent:p===0?w.WARNING:w.NONE,children:p===0?m(`logs.loggingDisabledDesc`,`当前配置的日志留存已设置为“关闭”,系统不记录任何查询日志。如需查看,请在设置中启用日志留存。`):s?m(`logs.noResultsDesc`,{query:s}):m(`logs.noRecordsDesc`)})}):a?(0,G.jsx)(ae,{logs:e,setSelectedLog:d,setIsDrawerOpen:f,lastLogElementRef:l,prevLatestTimestamp:u,realtimeRefresh:i}):(0,G.jsx)(oe,{logs:e,setSelectedLog:d,setIsDrawerOpen:f,lastLogElementRef:l,prevLatestTimestamp:u,realtimeRefresh:i}),(0,G.jsx)(`div`,{className:`p-6 flex flex-col items-center`,children:n?(0,G.jsx)(x,{size:16}):i?e.length>0&&(0,G.jsx)(`span`,{className:`text-[10px] opacity-30 italic`,children:m(`logs.realtimeLoadMoreTip`)}):!r&&e.length>0&&(0,G.jsx)(`span`,{className:`text-[10px] opacity-30 italic`,children:m(`logs.loadedAll`,{count:e.length})})})]})};function ce(e,t,n){let[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(!1);return(0,W.useEffect)(()=>{if(e&&t?.id){o(!0),i(null);let e=new AbortController;return z(n,t.id,t.timestamp,{signal:e.signal}).then(e=>{i(e)}).catch(e=>{e.name!==`AbortError`&&console.error(e)}).finally(()=>{o(!1)}),()=>{e.abort()}}else i(null)},[e,t?.id,n]),{detailedLog:r,loading:a}}const Z=({label:e,value:t,bold:n,italic:r})=>(0,G.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,G.jsx)(`span`,{className:`text-xs opacity-50 mt-1`,children:e}),(0,G.jsx)(`span`,{className:F(`text-sm text-right`,n&&`font-bold`,r&&`italic`),children:t})]}),le=({selectedLog:e,detailedLog:t,loading:n})=>{let{t:r}=o();return(0,G.jsx)(k,{title:r(`logs.basicInfo`),icon:(0,G.jsx)(f,{size:16}),className:`shadow-none! rounded-lg!`,children:(0,G.jsx)(T,{children:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(Z,{label:r(`logs.detailDomain`),value:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 justify-end font-bold`,children:[(0,G.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,G.jsx)(`span`,{children:e.domain})]}),bold:!0}),(0,G.jsx)(Z,{label:r(`logs.detailType`),value:e.record_type}),(0,G.jsx)(Z,{label:r(`logs.detailLatency`),value:e.latency?`${e.latency} ms`:`-`}),e.access_point_name&&(0,G.jsx)(Z,{label:r(`logs.detailAccessPoint`),value:e.access_point_name}),(0,G.jsx)(Z,{label:r(`logs.detailProfile`),value:n?(0,G.jsx)(x,{size:12}):t?.profile_name||t?.client_ip||`-`}),(0,G.jsx)(Z,{label:r(`logs.detailTime`),value:L(new Date(e.timestamp*1e3))}),(0,G.jsx)(Z,{label:r(`logs.detailStatus`),value:(0,G.jsx)(j,{minimal:!0,intent:e.action===`PASS`?w.SUCCESS:e.action===`BLOCK`?w.DANGER:w.WARNING,children:e.action})}),(0,G.jsx)(Z,{label:r(`logs.detailUpstream`),value:n?(0,G.jsx)(x,{size:12}):t?.upstream||`-`}),(0,G.jsx)(Z,{label:r(`logs.detailReason`),value:e.reason||r(`logs.detailNoReason`),italic:!0}),(0,G.jsx)(Z,{label:r(`logs.detailECS`),value:n?(0,G.jsx)(x,{size:12}):t?.ecs||`-`,italic:!0})]})})})},ue=({selectedLog:e})=>{let{t}=o(),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,G.jsx)(k,{title:(0,G.jsxs)(`div`,{className:`flex items-center justify-between w-full pr-2`,children:[(0,G.jsx)(`span`,{children:t(`logs.resolutionResult`)}),r&&(0,G.jsx)(j,{minimal:!0,intent:w.PRIMARY,className:`text-xs`,children:t(`logs.rewritten`,`已重写`)})]}),icon:(0,G.jsx)(d,{size:16}),className:`shadow-none! rounded-lg!`,children:(0,G.jsx)(T,{children:(0,G.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,G.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,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsxs)(j,{minimal:!0,intent:w.PRIMARY,children:[`Priority `,e]}),(0,G.jsxs)(`span`,{className:`font-semibold text-gray-700 dark:text-gray-300`,children:[`Target: `,n]})]}),i.length>0&&(0,G.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,G.jsx)(j,{minimal:!0,className:`font-mono`,children:e},t);let r=e.substring(0,n),i=e.substring(n+1);return r===`ech`?(0,G.jsxs)(j,{minimal:!0,intent:w.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,G.jsx)(`span`,{className:`font-bold`,children:`ech:`}),` `,i]},t):r===`alpn`?(0,G.jsxs)(j,{minimal:!0,intent:w.WARNING,className:`font-mono`,children:[(0,G.jsx)(`span`,{className:`font-bold`,children:`alpn:`}),` `,i]},t):(0,G.jsxs)(j,{minimal:!0,className:`font-mono`,children:[(0,G.jsxs)(`span`,{className:`font-bold`,children:[r,`:`]}),` `,i]},t)})})]},t)}return(0,G.jsx)(`div`,{className:`space-y-1`,children:e.split(`,`).map(e=>e.trim()).filter(Boolean).map((e,t)=>(0,G.jsx)(`div`,{className:`text-xs font-mono text-gray-800 dark:text-gray-200 select-all`,children:e},t))},t)})})})()})})})},de=({selectedLog:e,detailedLog:t,loading:n})=>{let{t:i}=o();return(0,G.jsx)(k,{title:i(`logs.networkDetails`),icon:(0,G.jsx)(s,{size:16}),className:`shadow-none! rounded-lg!`,children:(0,G.jsx)(T,{children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-50 mb-1`,children:i(`logs.clientSource`)}),(0,G.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,G.jsx)(`span`,{className:`font-mono`,children:n?(0,G.jsx)(x,{size:12}):t?.client_ip||`-`}),(0,G.jsx)(j,{minimal:!0,title:e.geo_country||`Unknown`,children:H(e.geo_country||``)})]})]}),n?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-2`,children:(0,G.jsx)(x,{size:16})}):t?.dest_geoip&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-50 mb-1`,children:i(`logs.destination`)}),(()=>{try{let e=JSON.parse(t.dest_geoip);return(0,G.jsx)(`div`,{className:`bg-gray-50 dark:bg-gray-800 p-3 rounded-lg`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(r,{size:16,className:`oklch(60.9% 0.126 221.723) mt-1 shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-bold text-sm`,children:[e.city,e.region,e.country].filter(Boolean).join(`, `)}),(0,G.jsxs)(`div`,{className:`text-xs opacity-70 mt-1`,children:[e.isp,e.as&&(0,G.jsx)(`span`,{className:`opacity-60 block mt-0.5`,children:e.as})]})]})]})})}catch{return null}})()]})]})})})},fe=({selectedLog:e,onQuickAction:n})=>{let{t:r}=o();return(0,G.jsx)(k,{title:r(`logs.quickActions`),icon:(0,G.jsx)(a,{size:16}),className:`shadow-none! rounded-lg!`,children:(0,G.jsx)(T,{children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(b,{fill:!0,intent:w.SUCCESS,icon:(0,G.jsx)(t,{size:16}),text:r(`logs.actionAllow`),onClick:()=>n?.(e.domain,`ALLOW`)}),(0,G.jsx)(b,{fill:!0,intent:w.DANGER,icon:(0,G.jsx)(l,{size:16}),text:r(`logs.actionBlock`),onClick:()=>n?.(e.domain,`BLOCK`)}),(0,G.jsx)(b,{fill:!0,icon:(0,G.jsx)(p,{size:16}),text:r(`logs.actionRedirect`),onClick:()=>n?.(e.domain,`REDIRECT`,e.record_type)})]})})})},pe=({isDrawerOpen:e,setIsDrawerOpen:t,selectedLog:n,profileId:r,isMobile:i,onQuickAction:a})=>{let{t:s}=o(),{detailedLog:c,loading:l}=ce(e,n,r);return(0,G.jsx)(U,{isOpen:e&&n!==null,onClose:()=>t(!1),title:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(f,{size:18}),(0,G.jsx)(`span`,{children:s(`logs.logDetails`)})]}),icon:`info-sign`,size:i?`100%`:`450px`,children:n&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(le,{selectedLog:n,detailedLog:c,loading:l}),(0,G.jsx)(ue,{selectedLog:n}),(0,G.jsx)(de,{selectedLog:n,detailedLog:c,loading:l}),(0,G.jsx)(fe,{selectedLog:n,onQuickAction:a})]})})};function me(e){let[t,n]=(0,W.useState)(`24h`),[r,i]=(0,W.useState)({start:``,end:``}),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)([]),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(null),[h,g]=(0,W.useState)(``);return(0,W.useEffect)(()=>{R(e).then(u).catch(console.error)},[e]),(0,W.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}}var Q=50,he=25;function ge({profileId:e,range:t,customRange:n,statusFilter:r,accessPointIdFilter:i,destCountryFilter:a,ispFilter:o,searchQuery:s,realtimeRefresh:c}){let[l,u]=(0,W.useState)([]),[d,f]=(0,W.useState)(!0),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(!0),[_,v]=(0,W.useState)(null),[y,b]=(0,W.useState)(30),[x,S]=(0,W.useState)(null),C=(0,W.useRef)([]);(0,W.useEffect)(()=>{C.current=l},[l]);let w=(0,W.useRef)(null),T=(0,W.useRef)(null),E=(0,W.useRef)(null),D=(0,W.useRef)(!1);(0,W.useEffect)(()=>()=>{E.current&&E.current.abort()},[]),(0,W.useEffect)(()=>{te(e).then(e=>{try{let t=JSON.parse(e.settings||`{}`);b(t.log_retention_days===void 0?30:Number(t.log_retention_days))}catch(e){console.error(`Failed to parse settings`,e)}}).catch(e=>console.error(`Failed to fetch profile settings`,e))},[e]);let O=async(t,d=!0,p=!1)=>{E.current&&E.current.abort();let h=new AbortController;E.current=h,D.current=!0,d?f(!0):m(!0);try{let f=c?he:Q,m=new URLSearchParams({range:t,limit:String(f)});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);m.set(`start`,String(e)),m.set(`end`,String(t))}r&&m.set(`status`,r),i&&m.set(`access_point_id`,i),a&&m.set(`dest_country`,a),o&&m.set(`isp`,o),s&&m.set(`search`,s),!d&&l.length>0&&m.set(`before`,String(l[l.length-1].timestamp));let _=B(e,m.toString(),{signal:h.signal}),y=Promise.resolve(null);if(d){let r=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);r.set(`start`,String(e)),r.set(`end`,String(t))}s&&r.set(`search`,s),y=I(e,`summary`,r.toString(),{signal:h.signal})}let[b,x]=await Promise.all([_,y]);if(d){if(S(p&&C.current.length>0?C.current[0].timestamp:null),u(b),g(c?!1:b.length>=f),x){let e={total:0,pass:0,block:0,redirect:0};x.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,...b]),g(c?!1:b.length>=f);if(b&&b.length>0){let e=Array.from(new Set(b.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{E.current===h&&(f(!1),m(!1),D.current=!1)}},k=(0,W.useCallback)(()=>{c||!d&&!p&&h&&O(t,!1)},[d,p,h,t,e,r,i,a,o,s,l,n,c]),A=(0,W.useCallback)(e=>{T.current&&T.current.disconnect(),!(d||p||c)&&(T.current=new IntersectionObserver(e=>{e[0].isIntersecting&&h&&k()},{root:w.current,rootMargin:`200px`}),e&&T.current.observe(e))},[d,p,h,k,c]);return(0,W.useEffect)(()=>{if(t===`custom`&&(!n.start||!n.end))return;let e=setTimeout(()=>O(t,!0),s?500:0);return()=>clearTimeout(e)},[e,t,r,i,a,o,s,n,c]),{logs:l,loading:d,loadingMore:p,hasMore:h,stats:_,logRetentionDays:y,prevLatestTimestamp:x,scrollContainerRef:w,lastLogElementRef:A,fetchLogs:O,isFetchingRef:D}}function _e({profileId:e,range:t,searchQuery:n,realtimeRefresh:r,statusFilter:i,accessPointIdFilter:a,destCountryFilter:o,ispFilter:s,scrollContainerRef:c,isFetchingRef:l,fetchLogs:u}){(0,W.useEffect)(()=>{if(!r)return;let e=()=>{document.visibilityState===`visible`&&c.current&&c.current.scrollTop<50&&!l.current&&!n&&t!==`custom`&&u(t,!0,!0)},i=setInterval(e,6e3),a=()=>{document.visibilityState===`visible`&&e()};return document.addEventListener(`visibilitychange`,a),()=>{clearInterval(i),document.removeEventListener(`visibilitychange`,a)}},[e,t,n,r,i,a,o,s,c,l,u])}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 ve(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 ye(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 be(e,t,n,r){return`query_logs_${e}_${$(t)}_${$(n)}_${r.toString()}.csv`}function xe({profileId:e,range:t,customRange:n,statusFilter:r,accessPointIdFilter:i,destCountryFilter:a,ispFilter:s,searchQuery:c,toasterRef:l}){let{t:u}=o(),[d,f]=(0,W.useState)(!1);return{exporting:d,handleExportLogs:async()=>{f(!0);try{let o=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);o.set(`start`,String(e)),o.set(`end`,String(t))}r&&o.set(`status`,r),i&&o.set(`access_point_id`,i),a&&o.set(`dest_country`,a),s&&o.set(`isp`,s),c&&o.set(`search`,c);let{exportProfileLogs:d}=await g(async()=>{let{exportProfileLogs:e}=await import(`./services-fIMx5oSx.js`);return{exportProfileLogs:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),f=await d(e,o.toString());if(!f||f.length===0){l?.current?.show({message:u(`logs.noResults`,`No logs found to export`),intent:w.WARNING});return}ye(ve(f),be(e,f[0].timestamp,f[f.length-1].timestamp,o)),l?.current?.show({message:u(`logs.exportSuccess`,`Logs exported successfully`),intent:w.SUCCESS})}catch(e){console.error(`Failed to export logs`,e),l?.current?.show({message:u(`logs.exportError`,`Failed to export logs`),intent:w.DANGER})}finally{f(!1)}}}}function Se({profileId:e,toasterRef:t}){let[n,r]=(0,W.useState)(!1),i=me(e),a=ge({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});_e({profileId:e,realtimeRefresh:n,range:i.range,statusFilter:i.statusFilter,accessPointIdFilter:i.accessPointIdFilter,destCountryFilter:i.destCountryFilter,ispFilter:i.ispFilter,searchQuery:i.searchQuery,scrollContainerRef:a.scrollContainerRef,isFetchingRef:a.isFetchingRef,fetchLogs:a.fetchLogs});let o=xe({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}}const Ce=({profileId:e,onQuickAction:t,toasterRef:n})=>{let r=ee(),[i,a]=(0,W.useState)(null),[o,s]=(0,W.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:S,setIspFilter:C,searchQuery:w,setSearchQuery:T,logs:E,loading:D,loadingMore:O,hasMore:k,stats:A,logRetentionDays:j,prevLatestTimestamp:M,scrollContainerRef:N,lastLogElementRef:P,fetchLogs:F,exporting:I,handleExportLogs:L}=Se({profileId:e,toasterRef:n}),R=new Date().toLocaleString(`sv-SE`).replace(` `,`T`).slice(0,16);return D&&E.length===0?(0,G.jsx)(`div`,{className:`h-full flex items-center justify-center`,children:(0,G.jsx)(x,{})}):(0,G.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,G.jsx)(ie,{profileId:e,range:u,setRange:d,customRange:f,setCustomRange:p,nowStr:R,fetchLogs:F,isMobile:r,realtimeRefresh:c,setRealtimeRefresh:l,statusFilter:m,setStatusFilter:h,accessPointIdFilter:g,setAccessPointIdFilter:_,accessPoints:v,destCountryFilter:y,setDestCountryFilter:b,ispFilter:S,setIspFilter:C,searchQuery:w,setSearchQuery:T,stats:A,logRetentionDays:j,onExport:L,exporting:I}),(0,G.jsx)(se,{logs:E,loading:D,loadingMore:O,hasMore:k,realtimeRefresh:c,isMobile:r,searchQuery:w,scrollContainerRef:N,lastLogElementRef:P,prevLatestTimestamp:M,setSelectedLog:a,setIsDrawerOpen:s,logRetentionDays:j}),(0,G.jsx)(pe,{isDrawerOpen:o,setIsDrawerOpen:s,selectedLog:i,profileId:e,isMobile:r,onQuickAction:t})]})};export{Ce as LogsView};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-icErLjuM.js","assets/vendor-utils-CfYGGC23.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-Kt98jRfM.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e,r as t}from"./rolldown-runtime-C4Xdq4VV.js";import{S as n,b as r,x as i}from"./vendor-icons-other-Bme3ywH9.js";function a(){return typeof window<`u`&&window.PublicKeyCredential!==void 0&&typeof window.PublicKeyCredential==`function`}function o(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`);for(;t.length%4!=0;)t+=`=`;let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}function s(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}async function c(e){if(!a())throw Error(`Passkeys are not supported by this browser.`);let t={...e,challenge:o(e.challenge),user:{...e.user,id:o(e.user.id)},excludeCredentials:(e.excludeCredentials||[]).map(e=>({...e,id:o(e.id)}))},n=await navigator.credentials.create({publicKey:t});if(!n)throw Error(`Credential creation was cancelled or failed.`);let r=n.response,i=r.getTransports?r.getTransports():[];return{id:n.id,rawId:s(n.rawId),response:{clientDataJSON:s(r.clientDataJSON),attestationObject:s(r.attestationObject),transports:i}}}async function l(e){if(!a())throw Error(`Passkeys are not supported by this browser.`);let t={...e,challenge:o(e.challenge),allowCredentials:(e.allowCredentials||[]).map(e=>({...e,id:o(e.id)}))},n=await navigator.credentials.get({publicKey:t});if(!n)throw Error(`Passkey authentication was cancelled.`);let r=n.response;return{id:n.id,rawId:s(n.rawId),response:{clientDataJSON:s(r.clientDataJSON),authenticatorData:s(r.authenticatorData),signature:s(r.signature),userHandle:r.userHandle?s(r.userHandle):null}}}var u=e(n(),1),d=e(r(),1);const f=({uri:e})=>{let n=(0,u.useRef)(null),[r,a]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{!n.current||!e||i(()=>import(`./browser-icErLjuM.js`).then(t(1)),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>{t.toCanvas(n.current,e,{width:200,margin:2,color:{dark:`#1a1a2e`,light:`#ffffff`}},e=>{e&&(console.error(e),a(!0))})}).catch(()=>a(!0))},[e]),r?(0,d.jsx)(`div`,{className:`w-50 h-50 border border-gray-200 rounded-lg flex flex-col items-center justify-center text-center p-4 text-xs text-gray-500`,children:(0,d.jsx)(`p`,{className:`break-all`,children:e})}):(0,d.jsx)(`canvas`,{ref:n,className:`rounded-lg border border-gray-100`})};export{c as i,a as n,l as r,f as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{At as t,C as n,O as r,St as i,Xt as a,_t as o,bt as s,dt as c,tt as l,vt as u,z as d}from"./vendor-react-Kt98jRfM.js";import{S as f,b as p}from"./vendor-icons-other-Bme3ywH9.js";import{C as m,H as h,N as g,O as _,S as v,V as y,b,d as x,f as S,p as C,r as w,u as T,x as E,y as D}from"./vendor-ui-core-BpucEp_q.js";import{_t as O}from"./vendor-utils-CfYGGC23.js";import{C as k,U as A,X as j,Xt as M,et as N,ft as P,it as F}from"./index-7FKlsF79.js";var I=e(f(),1),L=e(p(),1);const R=({newRule:e,setNewRule:t,addRule:n})=>{let{t:r}=a();return(0,L.jsx)(E,{elevation:h.ONE,className:`mb-8 p-6`,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col lg:flex-row justify-between gap-4 items-start lg:items-end`,children:[(0,L.jsx)(`div`,{className:`w-full lg:w-48`,children:(0,L.jsx)(C,{label:r(`rules.action`),labelFor:`rule-type`,children:(0,L.jsx)(x,{id:`rule-type`,fill:!0,large:!0,value:e.type,onChange:n=>t({...e,type:n.target.value}),options:[{label:r(`rules.typeBlock`),value:`BLOCK`},{label:r(`rules.typeAllow`),value:`ALLOW`},{label:r(`rules.typeRedirect`),value:`REDIRECT`}]})})}),(0,L.jsx)(`div`,{className:`flex-1 w-full lg:w-48`,children:(0,L.jsx)(C,{label:r(`rules.pattern`),labelFor:`rule-pattern`,children:(0,L.jsx)(S,{id:`rule-pattern`,size:`large`,placeholder:r(`rules.patternPlaceholder`),value:e.pattern,onChange:n=>t({...e,pattern:n.target.value})})})}),e.type!==`REDIRECT`&&(0,L.jsx)(C,{label:``,labelFor:``,children:(0,L.jsx)(g,{intent:y.PRIMARY,size:`large`,icon:(0,L.jsx)(d,{size:18}),onClick:n,children:r(`rules.addRule`)})})]}),e.type===`REDIRECT`&&(0,L.jsxs)(`div`,{className:`bg-gray-50 dark:bg-gray-800/50 p-6 rounded-xl border border-gray-200 dark:border-gray-700`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-blue-600 dark:text-blue-400`,children:[(0,L.jsx)(l,{size:16}),(0,L.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider`,children:r(`rules.redirectSettings`)})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-4`,children:[(0,L.jsx)(C,{label:r(`rules.aRecord`),labelInfo:r(`rules.optional`),children:(0,L.jsx)(S,{placeholder:r(`rules.ipv4Placeholder`),value:e.v_a,onChange:n=>t({...e,v_a:n.target.value})})}),(0,L.jsx)(C,{label:r(`rules.aaaaRecord`),labelInfo:r(`rules.optional`),children:(0,L.jsx)(S,{placeholder:r(`rules.ipv6Placeholder`),value:e.v_aaaa,onChange:n=>t({...e,v_aaaa:n.target.value})})}),(0,L.jsx)(C,{label:r(`rules.cnameRecord`),labelInfo:r(`rules.optional`),children:(0,L.jsx)(S,{placeholder:r(`rules.cnamePlaceholder`),value:e.v_cname,onChange:n=>t({...e,v_cname:n.target.value})})}),(0,L.jsx)(C,{label:r(`rules.txtRecord`),labelInfo:r(`rules.optional`),children:(0,L.jsx)(S,{placeholder:r(`rules.txtPlaceholder`),value:e.v_txt,onChange:n=>t({...e,v_txt:n.target.value})})})]}),(0,L.jsx)(`div`,{className:`mt-6 pt-4 border-t border-gray-200 dark:border-gray-700 flex justify-end`,children:(0,L.jsx)(g,{intent:y.PRIMARY,large:!0,icon:(0,L.jsx)(d,{size:18}),onClick:n,text:r(`rules.saveRedirectRule`)})})]})]})})},z=({rules:e,startEdit:t,getBlockDetail:n})=>{let{t:l}=a(),[d,f]=(0,I.useState)(`created_at`),[p,m]=(0,I.useState)(`desc`),h=e=>{d===e?m(e=>e===`asc`?`desc`:`asc`):(f(e),m(e===`created_at`?`desc`:`asc`))},g=e=>e.type===`REDIRECT`?[e.v_a,e.v_aaaa,e.v_cname,e.v_txt].filter(Boolean).join(` `):e.type===`BLOCK`?n():l(`rules.detailAllow`,`Forward to upstream`),_=(0,I.useMemo)(()=>[...e].sort((e,t)=>{let n=0;switch(d){case`action`:n=e.type.localeCompare(t.type);break;case`pattern`:n=e.pattern.localeCompare(t.pattern);break;case`details`:n=g(e).localeCompare(g(t));break;case`created_at`:n=(e.created_at??e.id)-(t.created_at??t.id);break}return n===0&&(n=e.id-t.id),p===`asc`?n:-n}),[e,d,p,n,l]),v=[{key:`action`,header:l(`rules.tableAction`),headerClassName:`w-32`,render:e=>(0,L.jsxs)(L.Fragment,{children:[e.type===`BLOCK`&&(0,L.jsx)(w,{intent:y.DANGER,minimal:!0,icon:(0,L.jsx)(r,{size:12,className:`mr-1`}),children:l(`rules.labelBlock`)}),e.type===`ALLOW`&&(0,L.jsx)(w,{intent:y.SUCCESS,minimal:!0,icon:(0,L.jsx)(c,{size:12,className:`mr-1`}),children:l(`rules.labelAllow`)}),e.type===`REDIRECT`&&(0,L.jsx)(w,{intent:y.WARNING,minimal:!0,icon:(0,L.jsx)(s,{size:12,className:`mr-1`}),children:l(`rules.labelRedirect`)})]})},{key:`pattern`,header:l(`rules.tablePattern`),headerClassName:`w-1/4`,cellClassName:`font-mono font-bold`,render:e=>e.pattern},{key:`details`,header:l(`rules.tableDetails`),cellClassName:`py-2`,render:e=>(0,L.jsx)(L.Fragment,{children:e.type===`REDIRECT`?(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.v_a&&(0,L.jsxs)(w,{minimal:!0,className:`font-mono text-[10px]`,children:[`A: `,e.v_a]}),e.v_aaaa&&(0,L.jsxs)(w,{minimal:!0,className:`font-mono text-[10px]`,children:[`AAAA: `,e.v_aaaa]}),e.v_cname&&(0,L.jsxs)(w,{minimal:!0,className:`font-mono text-[10px]`,children:[`CNAME: `,e.v_cname]}),e.v_txt&&(0,L.jsxs)(w,{minimal:!0,className:`font-mono text-[10px]`,children:[`TXT: `,e.v_txt]})]}):e.type===`BLOCK`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-gray-400 text-xs italic`,children:l(`rules.detailBlock`)}),(0,L.jsx)(w,{minimal:!0,round:!0,className:`text-[9px] px-1.5 opacity-70`,children:n()})]}):(0,L.jsx)(`span`,{className:`text-gray-400 text-xs italic`,children:l(`rules.detailAllow`)})})},{key:`created_at`,header:l(`rules.tableCreatedAt`,`添加时间`),headerClassName:`w-44`,cellClassName:`text-xs text-gray-500 align-middle`,render:e=>e.created_at?k(new Date(e.created_at*1e3)):`—`}];return(0,L.jsx)(`div`,{className:`w-full max-w-full overflow-x-auto pb-4`,children:(0,L.jsxs)(T,{interactive:!0,striped:!0,className:`w-full min-w-max whitespace-nowrap`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsx)(`tr`,{children:v.map(e=>(0,L.jsx)(`th`,{onClick:()=>h(e.key),className:O(e.headerClassName,`cursor-pointer select-none transition-colors hover:text-blue-500`),title:l(`rules.clickToSort`,`点击排序`),children:(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(`span`,{children:e.header}),d===e.key?p===`asc`?(0,L.jsx)(o,{size:13,className:`text-blue-500 shrink-0`}):(0,L.jsx)(i,{size:13,className:`text-blue-500 shrink-0`}):(0,L.jsx)(u,{size:12,className:`opacity-30 hover:opacity-75 shrink-0`})]})},e.key))})}),(0,L.jsx)(`tbody`,{children:_.map(e=>(0,L.jsx)(`tr`,{onClick:()=>t(e),className:`cursor-pointer`,children:v.map(t=>(0,L.jsx)(`td`,{className:t.cellClassName,children:t.render(e)},t.key))},e.id))})]})})},B=({editRule:e,setEditRule:t,saveEditRule:r,cancelEdit:i,deleteRule:o})=>{let{t:s}=a();return(0,L.jsxs)(_,{isOpen:!!e,onClose:i,title:s(`rules.editRule`,`Edit Rule`),style:{width:`600px`},children:[(0,L.jsx)(b,{children:e&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`div`,{className:`flex gap-4`,children:[(0,L.jsx)(C,{label:s(`rules.action`),className:`w-40 mb-0`,children:(0,L.jsx)(x,{fill:!0,value:e.type,onChange:n=>t({...e,type:n.target.value}),options:[{label:s(`rules.typeBlock`),value:`BLOCK`},{label:s(`rules.typeAllow`),value:`ALLOW`},{label:s(`rules.typeRedirect`),value:`REDIRECT`}]})}),(0,L.jsx)(C,{label:s(`rules.pattern`),className:`flex-1 mb-0`,children:(0,L.jsx)(S,{placeholder:s(`rules.patternPlaceholder`),value:e.pattern,onChange:n=>t({...e,pattern:n.target.value})})})]}),e.type===`REDIRECT`&&(0,L.jsxs)(`div`,{className:`bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-4 text-blue-600 dark:text-blue-400`,children:[(0,L.jsx)(l,{size:14}),(0,L.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider`,children:s(`rules.redirectSettings`)})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,L.jsx)(C,{label:s(`rules.aRecord`),className:`mb-0`,children:(0,L.jsx)(S,{placeholder:s(`rules.ipv4Placeholder`),value:e.v_a||``,onChange:n=>t({...e,v_a:n.target.value})})}),(0,L.jsx)(C,{label:s(`rules.aaaaRecord`),className:`mb-0`,children:(0,L.jsx)(S,{placeholder:s(`rules.ipv6Placeholder`),value:e.v_aaaa||``,onChange:n=>t({...e,v_aaaa:n.target.value})})}),(0,L.jsx)(C,{label:s(`rules.cnameRecord`),className:`mb-0`,children:(0,L.jsx)(S,{placeholder:s(`rules.cnamePlaceholder`),value:e.v_cname||``,onChange:n=>t({...e,v_cname:n.target.value})})}),(0,L.jsx)(C,{label:s(`rules.txtRecord`),className:`mb-0`,children:(0,L.jsx)(S,{placeholder:s(`rules.txtPlaceholder`),value:e.v_txt||``,onChange:n=>t({...e,v_txt:n.target.value})})})]})]})]})}),(0,L.jsx)(D,{actions:(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(g,{onClick:i,children:s(`rules.cancel`,`Cancel`)}),(0,L.jsx)(g,{intent:y.PRIMARY,onClick:r,children:s(`rules.saveChanges`,`Save Changes`)})]}),children:(0,L.jsx)(g,{icon:(0,L.jsx)(n,{size:14}),intent:y.DANGER,text:s(`rules.delete`,`Delete`),onClick:()=>{e&&o(e.id)}})})]})},V=({profileId:e,prefill:n,onPrefillUsed:r,toasterRef:i})=>{let o=t(),[s,c]=(0,I.useState)([]),[l,u]=(0,I.useState)(null),[,d]=(0,I.useState)(!0),{t:f}=a(),p=M(),[h,_]=(0,I.useState)({type:`BLOCK`,pattern:``,v_a:``,v_aaaa:``,v_txt:``,v_cname:``}),[b,x]=(0,I.useState)(null);(0,I.useEffect)(()=>{n&&(_({type:n.type,pattern:n.domain,v_a:n.recordType===`A`?`0.0.0.0`:``,v_aaaa:n.recordType===`AAAA`?`::`:``,v_txt:n.recordType===`TXT`?`Pre-filled`:``,v_cname:n.recordType===`CNAME`?`target.com`:``}),r?.())},[n,r]);let S=async()=>{d(!0);try{let[t,n]=await Promise.all([F(e),N(e)]);c(t),u(JSON.parse(n.settings||`{}`))}catch(e){console.error(`Failed to fetch data`,e)}finally{d(!1)}};return(0,I.useEffect)(()=>{S()},[e]),(0,L.jsxs)(`div`,{className:O(`md:px-8 w-full min-w-0 max-w-5xl mx-auto`,p?`p-1`:`px-8`),children:[(0,L.jsx)(`div`,{className:`mb-8`,children:(0,L.jsx)(`div`,{className:`flex flex-col md:flex-row justify-between items-start gap-4`,children:(0,L.jsxs)(`div`,{className:`w-full md:w-auto flex-1`,children:[p?(0,L.jsxs)(m,{minimal:!0,fill:p,children:[(0,L.jsx)(g,{active:!0,onClick:()=>o(`/dash/${e}/rules`),text:f(`rules.title`),large:!0}),(0,L.jsx)(g,{active:!1,onClick:()=>o(`/dash/${e}/filter`),text:f(`filtering.title`),large:!0})]}):(0,L.jsx)(`h1`,{className:`bp6-heading`,children:f(`rules.title`)}),(0,L.jsx)(`p`,{className:`bp6-text-muted mt-2!`,children:f(`rules.subtitle`)})]})})}),(0,L.jsx)(R,{newRule:h,setNewRule:_,addRule:async()=>{let t=h.pattern.trim();if(!t){i?.current?.show({message:f(`rules.patternEmpty`,`Domain pattern cannot be empty`),intent:y.DANGER});return}let n=t.toLowerCase();if(s.some(e=>e.pattern.trim().toLowerCase()===n)){i?.current?.show({message:f(`rules.duplicatePattern`,`Rule for this domain already exists`),intent:y.DANGER});return}try{await A(e,{...h,pattern:t}),i?.current?.show({message:f(`rules.addSuccess`,`Rule added successfully`),intent:y.SUCCESS}),_({type:`BLOCK`,pattern:``,v_a:``,v_aaaa:``,v_txt:``,v_cname:``}),S()}catch(e){i?.current?.show({message:e.message||f(`rules.addFailed`,`Failed to add rule`),intent:y.DANGER})}}}),s.length===0?(0,L.jsx)(v,{title:f(`rules.noRulesTitle`),children:f(`rules.noRulesDesc`)}):(0,L.jsx)(z,{rules:s,startEdit:e=>{x({...e})},getBlockDetail:()=>{if(!l)return f(`rules.detailBlock`);switch(l.block_mode||`NULL_IP`){case`NXDOMAIN`:return`NXDOMAIN`;case`NODATA`:return`NODATA`;case`CUSTOM_IP`:return`${l.custom_block_ipv4||`0.0.0.0`} / ${l.custom_block_ipv6||`::`}`;default:return`0.0.0.0 / ::`}}}),(0,L.jsx)(B,{editRule:b,setEditRule:x,saveEditRule:async()=>{if(!b)return;let t=b.pattern.trim();if(!t){i?.current?.show({message:f(`rules.patternEmpty`,`Domain pattern cannot be empty`),intent:y.DANGER});return}let n=t.toLowerCase();if(s.some(e=>e.id!==b.id&&e.pattern.trim().toLowerCase()===n)){i?.current?.show({message:f(`rules.duplicatePattern`,`Rule for this domain already exists`),intent:y.DANGER});return}try{await P(e,{...b,pattern:t}),i?.current?.show({message:f(`rules.updateSuccess`,`Rule updated successfully`),intent:y.SUCCESS}),x(null),S()}catch(e){i?.current?.show({message:e.message||f(`rules.updateFailed`,`Failed to update rule`),intent:y.DANGER})}},cancelEdit:()=>{x(null)},deleteRule:async t=>{try{await j(e,t)}catch(e){console.error(e)}x(null),S()}})]})};export{V as RulesView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{B as t,D as n,J as r,P as i,Xt as a,Z as o,at as s,mt as c,ot as l,tt as u,ut as d,v as f,wt as p,y as m}from"./vendor-react-Kt98jRfM.js";import{S as h,b as g}from"./vendor-icons-other-Bme3ywH9.js";import{B as _,E as v,H as y,M as b,N as x,P as S,S as C,T as w,V as T,_ as E,d as D,f as O,h as k,p as A,r as j,v as M,w as N,x as P}from"./vendor-ui-core-BpucEp_q.js";import{F,N as I,et as L,it as R,ot as z,pt as B,s as V,tt as H,ut as U}from"./index-7FKlsF79.js";var W=e(h(),1),G=e(g(),1);const K=({profile:e,isEditingName:n,setIsEditingName:r,editName:i,setEditName:o,updateProfileName:s,exportProfile:u})=>{let{t:d}=a(),[f,p]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`mb-6 flex flex-col md:flex-row justify-between items-start md:items-center gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col justify-start`,children:[n?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,G.jsx)(M,{content:d(`common.profileNameFormatTip`,`Profile Name tip: 1-30 characters, duplicates not allowed`),isOpen:f,position:_.TOP,intent:T.PRIMARY,className:`flex-1`,children:(0,G.jsx)(`div`,{className:`w-full block`,children:(0,G.jsx)(O,{value:i,onChange:e=>o(e.target.value),onFocus:()=>p(!0),onBlur:()=>p(!1),autoFocus:!0,onKeyDown:t=>{t.key===`Enter`&&s(),t.key===`Escape`&&(r(!1),o(e?.name||``))}})})}),(0,G.jsx)(x,{icon:(0,G.jsx)(c,{size:16}),intent:T.SUCCESS,minimal:!0,onClick:s,disabled:!V.test(i)}),(0,G.jsx)(x,{icon:(0,G.jsx)(m,{size:16}),minimal:!0,onClick:()=>{r(!1),o(e?.name||``)}})]}):(0,G.jsxs)(`div`,{className:`group flex items-center gap-2 mb-1 cursor-pointer`,onClick:()=>r(!0),children:[(0,G.jsx)(`h2`,{className:`bp6-heading mb-0`,children:e?.name}),(0,G.jsx)(x,{icon:(0,G.jsx)(t,{size:14}),minimal:!0,className:`opacity-30 group-hover:opacity-100 transition-opacity`})]}),(0,G.jsx)(`p`,{className:`bp6-text-muted`,children:d(`settings.subtitle`)})]}),(0,G.jsx)(`div`,{className:`flex gap-2 items-center`,children:(0,G.jsx)(x,{size:`large`,icon:(0,G.jsx)(l,{size:18}),text:d(`settings.export`,`导出配置`),onClick:u})})]})},q=()=>{let{t:e}=a(),[t,n]=(0,W.useState)([]);return(0,W.useEffect)(()=>{F().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},J=(e,t)=>{let{t:n}=a();return(0,W.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])},Y=({settings:e,setSettings:t})=>{let{t:n}=a(),r=(0,G.jsx)(v,{className:`min-w-96`,children:q().map((n,r)=>(0,G.jsx)(N,{text:n.label,onClick:()=>t({...e,upstream:[n.url]}),labelElement:(0,G.jsx)(`div`,{className:`flex flex-col items-end text-right`,children:(0,G.jsx)(`span`,{className:`text-[9px] opacity-85 max-w-64 truncate`,title:n.url,children:n.url})})},r))});return(0,G.jsxs)(P,{elevation:y.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,G.jsxs)(b,{className:`flex items-center gap-2 mb-4 font-bold`,children:[(0,G.jsx)(i,{size:18,className:`text-blue-500`}),` `,n(`settings.upstreamTitle`)]}),(0,G.jsx)(A,{label:`DoH (https://) / DoT (tls://) / DNS Stamp (sdns://) / ${n(`settings.classicDns`)}`,children:(0,G.jsx)(O,{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,G.jsx)(w,{content:r,placement:`bottom-end`,animation:`minimal`,arrow:!1,children:(0,G.jsx)(x,{variant:`minimal`,icon:`chevron-down`})})})}),(0,G.jsx)(`p`,{className:`text-xs opacity-60`,children:n(`settings.upstreamDesc`)})]})},X=({settings:e,setSettings:t})=>{let{t:r}=a();return(0,G.jsxs)(P,{elevation:y.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,G.jsxs)(b,{className:`flex items-center gap-2 mb-4 font-bold`,children:[(0,G.jsx)(n,{size:18,className:`text-green-500`}),` `,r(`settings.defaultPolicyTitle`)]}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(A,{label:r(`settings.onNoMatch`),children:(0,G.jsxs)(D,{fill:!0,value:e.default_policy,onChange:n=>t({...e,default_policy:n.target.value}),children:[(0,G.jsx)(`option`,{value:`ALLOW`,children:r(`settings.allowAll`)}),(0,G.jsx)(`option`,{value:`BLOCK`,children:r(`settings.blockAll`)})]})}),(0,G.jsx)(E,{}),(0,G.jsx)(A,{label:r(`settings.blockModeTitle`),helperText:r(`settings.blockModeDesc`),children:(0,G.jsxs)(D,{fill:!0,value:e.block_mode||`NULL_IP`,onChange:n=>t({...e,block_mode:n.target.value}),children:[(0,G.jsxs)(`option`,{value:`NULL_IP`,children:[`0.0.0.0 / :: (`,r(`settings.default`),`)`]}),(0,G.jsxs)(`option`,{value:`NXDOMAIN`,children:[`NXDOMAIN (`,r(`settings.NXDOMAIN`),`)`]}),(0,G.jsxs)(`option`,{value:`NODATA`,children:[`NODATA (`,r(`settings.NODATA`),`)`]}),(0,G.jsx)(`option`,{value:`CUSTOM_IP`,children:r(`settings.customIP`)})]})}),e.block_mode===`CUSTOM_IP`&&(0,G.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1`,children:[(0,G.jsx)(O,{placeholder:`IPv4: 127.0.0.1`,value:e.custom_block_ipv4||``,onChange:n=>t({...e,custom_block_ipv4:n.target.value})}),(0,G.jsx)(O,{placeholder:`IPv6: ::1`,value:e.custom_block_ipv6||``,onChange:n=>t({...e,custom_block_ipv6:n.target.value})})]})]})]})},Z=({settings:e,setSettings:t,isAdmin:n,maxRetentionDays:r})=>{let{t:i}=a(),o=J(n,r);W.useEffect(()=>{if(r>0&&e.log_retention_days>r&&o.length>0){let n=o[o.length-1];n&&e.log_retention_days!==n.value&&t({...e,log_retention_days:n.value})}},[r,e.log_retention_days,o,t]);let s=e.log_retention_days===0;return(0,G.jsxs)(P,{elevation:y.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,G.jsxs)(b,{className:`flex items-center gap-2 mb-4 font-bold`,children:[(0,G.jsx)(d,{size:18,className:`text-purple-500`}),` `,i(`settings.logRetentionTitle`)]}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(A,{label:i(`settings.retentionDuration`),children:(0,G.jsx)(D,{fill:!0,value:e.log_retention_days,onChange:n=>t({...e,log_retention_days:parseFloat(n.target.value)}),children:o.map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),(0,G.jsx)(`p`,{className:`text-xs opacity-60`,children:s?i(`settings.retentionDisabledDesc`,`已关闭日志记录。系统将不会记录任何 DNS 查询日志并立即清空历史日志。`):i(`settings.retentionDesc`)}),(0,G.jsxs)(`div`,{className:`pt-3 border-t border-gray-100 dark:border-gray-800/80`,children:[(0,G.jsx)(k,{label:i(`settings.skipLogOnPass`,`不记录放行记录`),checked:!s&&!!e.skip_log_on_pass,disabled:s,onChange:n=>t({...e,skip_log_on_pass:n.currentTarget.checked})}),(0,G.jsx)(`p`,{className:`text-xs opacity-60 mt-1`,children:i(`settings.skipLogOnPassDesc`,`启用后不记录正常放行的 DNS 查询,仅记录被拦截、重定向或解析失败的记录。可大幅减少存储占用与写操作。`)})]})]})]})},Q=({settings:e,setSettings:t})=>{let{t:n}=a();return(0,G.jsxs)(P,{elevation:y.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,G.jsxs)(b,{className:`flex items-center gap-2 mb-3 font-bold`,children:[(0,G.jsx)(u,{size:18,className:`text-orange-500`}),` `,n(`settings.ecsTitle`)]}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(k,{label:n(`settings.sendEcs`),checked:e.ecs.enabled,onChange:n=>t({...e,ecs:{...e.ecs,enabled:n.currentTarget.checked}})}),(0,G.jsx)(k,{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,G.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-gray-100 dark:border-gray-800`,children:[(0,G.jsx)(A,{label:n(`settings.customIpv4`),labelInfo:n(`settings.ipv4Hint`),disabled:!(e.ecs.enabled&&!e.ecs.use_client_ip),children:(0,G.jsx)(O,{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,G.jsx)(A,{label:n(`settings.customIpv6`),labelInfo:n(`settings.ipv6Hint`),disabled:!(e.ecs.enabled&&!e.ecs.use_client_ip),children:(0,G.jsx)(O,{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,G.jsx)(`p`,{className:`text-xs opacity-60`,children:n(`settings.ecsUpstreamHint`)})]})]})};var $=[{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 ee=({settings:e,setSettings:t})=>{let{t:n}=a(),[r,i]=W.useState($);W.useEffect(()=>{I().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 c=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:c,fronting_domain:n}})},f=(0,G.jsx)(v,{className:`min-w-72`,children:r.map(e=>(0,G.jsx)(N,{text:e.domain,onClick:()=>d(e.domain),labelElement:e.isPreferred?(0,G.jsx)(j,{minimal:!0,intent:T.PRIMARY,className:`text-[10px]`,children:n(`settings.echPreferred`,`首选`)}):void 0},e.domain))});return(0,G.jsxs)(P,{elevation:y.ONE,className:`dark:bg-gray-900 dark:border-gray-800`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,G.jsxs)(b,{className:`flex items-center gap-2 m-0 font-bold text-purple-600 dark:text-purple-400`,children:[(0,G.jsx)(o,{size:18}),` `,n(`settings.echTitle`)]}),(0,G.jsx)(w,{placement:`bottom-end`,usePortal:!0,content:(0,G.jsxs)(`div`,{className:`p-4 max-w-sm`,children:[(0,G.jsx)(b,{children:n(`settings.whatIsEch`,`何为 ECH (Encrypted Client Hello)?`)}),(0,G.jsx)(`p`,{className:`text-sm mb-2`,children:n(`settings.echHelpDesc`)}),(0,G.jsxs)(`ul`,{className:`list-disc list-inside text-sm opacity-80 mb-3 space-y-1`,children:[(0,G.jsx)(`li`,{children:n(`settings.echHelpBenefit1`)}),(0,G.jsx)(`li`,{children:n(`settings.echHelpBenefit2`)})]}),(0,G.jsx)(`div`,{className:`text-xs border-t border-gray-100 dark:border-gray-700 pt-2`,children:(0,G.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,G.jsx)(s,{size:10}),` `,n(`setup.learnMore`,`了解更多`)]})})]}),children:(0,G.jsx)(x,{icon:`help`,variant:`minimal`,intent:T.NONE})})]}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(k,{label:n(`settings.enableEch`,`启用重写 ECH`),checked:c,onChange:e=>u(e.currentTarget.checked)}),(0,G.jsx)(`p`,{className:`text-xs opacity-60 leading-relaxed`,children:n(`settings.echDesc`,`针对由 Cloudflare 代理的域名,当查询 HTTPS (Type 65) 或 SVCB (Type 64) 记录且上游未配置 ECH 时,自动重写注入 ECH 参数以保护 SNI 隐私。`)}),c&&(0,G.jsx)(`div`,{className:`space-y-3 pt-3 border-t border-gray-100 dark:border-gray-800`,children:(0,G.jsx)(A,{label:n(`settings.echFrontingTitle`,`表层 SNI (ECH Fronting)`),labelInfo:(0,G.jsx)(`span`,{className:`text-xs opacity-60`,children:n(`settings.echFrontingDesc`,`TLS 握手外层可见的伪装域名`)}),children:(0,G.jsx)(O,{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,G.jsx)(w,{content:f,placement:`bottom-end`,animation:`minimal`,arrow:!1,children:(0,G.jsx)(x,{variant:`minimal`,icon:`chevron-down`})})})})})]})]})},te=({testInput:e,setTestInput:t,handleDnsTest:n,testing:i,testResult:o})=>{let{t:s}=a();return(0,G.jsxs)(P,{elevation:y.TWO,className:`dark:bg-gray-900 border-t-2 border-blue-500`,children:[(0,G.jsxs)(b,{className:`flex items-center gap-2 mb-6 font-bold`,children:[(0,G.jsx)(f,{size:20,className:`text-yellow-500 fill-yellow-500`}),` `,s(`settings.testToolTitle`)]}),(0,G.jsxs)(`div`,{className:`flex flex-col space-y-6`,children:[(0,G.jsx)(A,{label:s(`settings.testDomain`),className:`mb-0`,children:(0,G.jsx)(O,{fill:!0,large:!0,placeholder:s(`settings.domainPlaceholder`),value:e.domain,onChange:n=>t({...e,domain:n.target.value}),onKeyDown:e=>e.key===`Enter`&&n()})}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-4 items-end`,children:[(0,G.jsx)(A,{label:s(`settings.recordType`),className:`w-32 mb-0`,children:(0,G.jsxs)(D,{fill:!0,large:!0,value:e.type,onChange:n=>t({...e,type:n.target.value}),children:[(0,G.jsx)(`option`,{value:`A`,children:`A`}),(0,G.jsx)(`option`,{value:`AAAA`,children:`AAAA`}),(0,G.jsx)(`option`,{value:`CNAME`,children:`CNAME`}),(0,G.jsx)(`option`,{value:`TXT`,children:`TXT`})]})}),(0,G.jsx)(A,{label:`\xA0`,className:`mb-0`,children:(0,G.jsx)(x,{size:`large`,intent:T.PRIMARY,icon:`search`,text:s(`settings.runTest`),onClick:n,loading:i})})]}),o&&(0,G.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,G.jsxs)(`div`,{className:`flex flex-wrap gap-4 items-center`,children:[(0,G.jsx)(j,{large:!0,round:!0,intent:o.action===`PASS`?T.SUCCESS:o.action===`BLOCK`?T.DANGER:T.WARNING,className:`px-4 font-bold`,children:o.action}),(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase font-bold opacity-40`,children:s(`settings.hitRule`)}),(0,G.jsx)(`span`,{className:`text-sm font-bold`,children:o.reason||s(`settings.defaultAllow`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-col border-l border-gray-200 dark:border-gray-700 pl-4`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase font-bold opacity-40`,children:s(`settings.parseLatency`)}),(0,G.jsx)(`span`,{className:`text-sm font-mono font-bold`,children:o.latency?`${o.latency}ms`:`-`})]}),o.timings&&(0,G.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(o.timings).map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex gap-1 items-baseline`,children:[(0,G.jsxs)(`span`,{className:`text-[9px] opacity-40 uppercase font-mono`,children:[e,`:`]}),(0,G.jsxs)(`span`,{className:`text-[10px] font-mono font-bold`,children:[t,`ms`]})]},e))}),(0,G.jsx)(E,{}),(0,G.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,G.jsx)(r,{size:14,className:`text-red-500`}),(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase font-bold opacity-40 leading-none`,children:s(`settings.sourceIp`)}),(0,G.jsxs)(`span`,{className:`text-xs font-mono`,children:[o.client_ip,` (`,o.geo_country,`)`]})]})]})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`text-[10px] uppercase font-bold opacity-40 flex items-center gap-1`,children:[(0,G.jsx)(p,{size:10}),` `,s(`settings.answerSection`)]}),(0,G.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:o.answers&&o.answers.length>0?o.answers.map((e,t)=>(0,G.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,G.jsx)(`span`,{className:`w-16 font-bold text-blue-500`,children:e.type}),(0,G.jsx)(`span`,{className:`flex-1 dark:text-gray-300`,children:e.data}),(0,G.jsxs)(`span`,{className:`text-[10px] opacity-30 italic`,children:[`TTL: `,e.ttl,`s`]})]},t)):(0,G.jsx)(`div`,{className:`p-4 opacity-40 italic text-center`,children:s(`settings.noRecordsReturned`)})})]}),o.diagnostics&&(0,G.jsx)(C,{minimal:!0,intent:o.action===`FAIL`?T.DANGER:T.NONE,className:`text-xs font-mono`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,G.jsx)(`span`,{className:`font-bold uppercase tracking-wider`,children:s(`settings.diagnostics`)}),(0,G.jsx)(`span`,{className:`font-bold`,children:o.action===`FAIL`?o.diagnostics.status>0?`HTTP ${o.diagnostics.status}${o.diagnostics.status_text?` (${o.diagnostics.status_text})`:``}`:`Network / Connection Error`:o.diagnostics.method===`POST`||o.diagnostics.method===`GET`?`HTTP ${o.diagnostics.status}${o.diagnostics.status_text?` (${o.diagnostics.status_text})`:``}`:`Connected (OK)`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs opacity-80`,children:[(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-gray-200 dark:bg-gray-700 rounded text-[10px] font-bold`,children:o.diagnostics.method}),(0,G.jsx)(`span`,{className:`break-all`,children:o.diagnostics.upstream_url})]}),o.diagnostics.cf_ray&&(0,G.jsxs)(`div`,{className:`text-[11px] opacity-75`,children:[`CF-Ray: `,(0,G.jsx)(`span`,{className:`font-bold`,children:o.diagnostics.cf_ray})]}),o.diagnostics.error_detail&&o.action===`FAIL`&&(0,G.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,G.jsxs)(`div`,{className:`font-bold mb-0.5`,children:[s(`settings.errorDetail`),`:`]}),(0,G.jsx)(`div`,{children:o.diagnostics.error_detail})]}),o.diagnostics.response_body&&(0,G.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,G.jsxs)(`div`,{className:`font-bold mb-0.5 opacity-60`,children:[s(`settings.upstreamResponse`),`:`]}),(0,G.jsx)(`div`,{className:`line-clamp-3`,children:o.diagnostics.response_body})]})]})})]})]})]})},ne=({profileId:e,toasterRef:t,currentUser:n,onSavingChange:r})=>{let[i,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(!0),[d,f]=(0,W.useState)(!1),{t:p}=a();(0,W.useEffect)(()=>(r?.(d),()=>{r?.(!1)}),[d,r]);let m=(0,W.useRef)(!0),h=(0,W.useRef)(null),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(``),[b,x]=(0,W.useState)({domain:`o-o.myaddr.l.google.com`,type:`TXT`}),[C,w]=(0,W.useState)(null),[E,D]=(0,W.useState)(!1);(0,W.useEffect)(()=>{(async()=>{try{let t=await L(e);return o(t),y(t.name),c(JSON.parse(t.settings)),i}catch(e){console.error(e)}finally{u(!1)}})()},[e]),(0,W.useEffect)(()=>{if(!l&&s){let e=setTimeout(()=>{m.current=!1},500);return()=>clearTimeout(e)}},[l,s]),(0,W.useEffect)(()=>()=>{h.current&&clearTimeout(h.current)},[]);let O=async()=>{if(!v||v===i?.name){_(!1);return}try{await z(e,v),o(e=>e?{...e,name:v}:null),_(!1),t?.current?.show({message:p(`settings.nameUpdateSuccess`,`名称已更新`),intent:T.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:T.DANGER})}},k=(0,W.useCallback)(async n=>{if(n){f(!0);try{await B(e,n)}catch(e){console.error(e),t?.current?.show({message:p(`settings.saveError`),intent:T.DANGER,icon:`error`})}finally{f(!1)}}},[e,t,p]),A=(0,W.useCallback)(e=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{k(e)},600)},[k]),j=(0,W.useCallback)(e=>{c(e),m.current||A(e)},[A]);return l||!s?(0,G.jsx)(`div`,{className:`p-20 flex justify-center`,children:(0,G.jsx)(S,{})}):(0,G.jsxs)(`div`,{className:`p-0 sm:px-4 lg:px-8 max-w-5xl mx-auto space-y-8 pb-20`,children:[(0,G.jsx)(K,{profile:i,isEditingName:g,setIsEditingName:_,editName:v,setEditName:y,updateProfileName:O,exportProfile:async()=>{if(!(!i||!s))try{let[n,r]=await Promise.all([R(e).catch(()=>[]),H(e).catch(()=>[])]),a=new Set,o=(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:s,rules:o,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:T.SUCCESS,icon:`download`})}catch(e){console.error(e),t?.current?.show({message:p(`settings.exportError`,`导出失败`),intent:T.DANGER,icon:`error`})}}}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,G.jsx)(Y,{settings:s,setSettings:j}),(0,G.jsx)(X,{settings:s,setSettings:j}),(0,G.jsx)(Z,{settings:s,setSettings:j,isAdmin:n?.role===`admin`,maxRetentionDays:n?.max_log_retention_days??(n?.role===`admin`?30:7)}),(0,G.jsx)(Q,{settings:s,setSettings:j}),(0,G.jsx)(ee,{settings:s,setSettings:j})]}),(0,G.jsx)(te,{testInput:b,setTestInput:x,handleDnsTest:async()=>{if(b.domain){D(!0),w(null);try{w(await U(e,b))}catch(e){console.error(e)}finally{D(!1)}}},testing:E,testResult:C})]})};export{ne as SettingsView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{A as t,B as n,C as r,Ct as i,E as a,F as o,G as s,I as c,J as l,K as u,M as d,P as f,R as p,U as m,Xt as h,at as g,ct as _,it as v,rt as y,tt as b,w as x,wt as S,z as C}from"./vendor-react-Kt98jRfM.js";import{S as w,b as T}from"./vendor-icons-other-Bme3ywH9.js";import{A as E,B as D,C as O,F as k,L as A,M as j,N as M,O as N,P,R as F,S as I,T as L,V as R,a as z,d as B,f as V,i as H,n as U,o as W,r as G,v as K,z as q}from"./vendor-ui-core-BpucEp_q.js";import{_t as J,t as Y,vt as X}from"./vendor-utils-CfYGGC23.js";import{C as ee,I as te,L as ne,Q as re,R as ie,T as ae,V as oe,Xt as se,Y as ce,ct as le,et as ue,i as de,j as fe,st as pe,z as me}from"./index-7FKlsF79.js";import{t as he}from"./SwipeableDrawer-B-MfxTWM.js";var Z=e(w(),1);const ge=e=>{let t={},n={CN:{label:e(`common.mainlandChina`,`Mainland China`),countries:[`CN`]}},r=e=>{if(!e)return null;try{let t=e.trim();t=t.replace(/^"""|"""$/g,``).replace(/^"|"$/g,``).replace(/^'|'$/g,``).trim();let n=JSON.parse(t);return Array.isArray(n)?n:null}catch(t){return console.warn(`Failed to parse region env value:`,e,t),null}},i={CN:void 0};Object.entries(i).forEach(([e,i])=>{let a=r(i);a&&(t[e]={label:n[e]?.label||e,countries:n[e]?.countries||[],ips:a})});try{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1};Object.keys(e).forEach(a=>{if(a.startsWith(`IP_REGION_`)&&!i[a.replace(`IP_REGION_`,``)]){let i=a.replace(`IP_REGION_`,``),o=r(e[a]);o&&(t[i]={label:n[i]?.label||i,countries:n[i]?.countries||[],ips:o})}})}catch{}return t};var Q=e(T(),1);const _e=({isMobile:e,selectedRegion:t,setSelectedRegion:n,allRegions:r})=>{let{t:i}=h();return(0,Q.jsxs)(`div`,{className:`flex flex-col md:flex-row justify-between items-start gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(E,{className:`font-bold text-gray-900 dark:text-white`,children:i(`setup.title`)}),(0,Q.jsx)(`p`,{className:`bp6-text-muted`,children:i(`setup.subtitle`)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col items-end gap-2 w-full md:w-auto`,children:[(0,Q.jsxs)(`span`,{className:`text-[10px] font-bold uppercase opacity-50 flex items-center gap-1`,children:[(0,Q.jsx)(m,{size:10}),` `,i(`setup.regionOptimization`)]}),(0,Q.jsx)(O,{minimal:!0,fill:e,children:Object.keys(r).map(r=>(0,Q.jsx)(M,{active:t===r,onClick:()=>n(r),text:e?r.split(`_`)[0]:r.replace(`_`,` `),small:!0},r))})]})]})},ve=({isVerifying:e,verifyResult:n,handleVerify:r,isMobile:i,clientInfo:a,showIp:o,setShowIp:s,showLocation:c,setShowLocation:u,traceInfo:d})=>{let{t:p}=h(),[m,g]=(0,Z.useState)(!1);return(0,Q.jsx)(W,{title:p(`setup.verifyConnection`),icon:(0,Q.jsx)(S,{size:16}),children:(0,Q.jsx)(z,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col space-y-6`,children:[(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-col md:flex-row items-center gap-4 text-center md:text-left`,children:[(0,Q.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,Q.jsx)(P,{size:24}):n?.success?(0,Q.jsx)(t,{size:24}):(0,Q.jsx)(f,{size:24})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`font-bold text-lg`,children:e?p(`setup.verifying`):n?.success?p(`setup.connected`):p(`setup.notConnected`)}),(0,Q.jsx)(`div`,{className:`text-sm opacity-60`,children:n?.success?n.profileMatch?p(`setup.profileMatch`):p(`setup.profileMismatch`):p(`setup.verifyHint`)})]})]}),(0,Q.jsx)(M,{size:`large`,intent:n?.success?R.SUCCESS:R.PRIMARY,icon:`refresh`,text:p(`setup.refreshStatus`),onClick:r,loading:e,fill:i})]}),a&&(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 ${d?`sm:grid-cols-2 md:grid-cols-3`:`md:grid-cols-2`}`,children:[(0,Q.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,Q.jsx)(b,{size:18,className:`text-blue-500 mt-1`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-40`,children:p(`setup.egressIp`)}),(0,Q.jsx)(`button`,{onClick:()=>s(!o),className:`text-gray-400 hover:text-blue-500 transition-colors`,children:o?(0,Q.jsx)(y,{size:16}):(0,Q.jsx)(v,{size:16})})]}),(0,Q.jsx)(`div`,{className:`font-mono font-bold text-blue-600 dark:text-blue-400 truncate`,children:(0,Q.jsx)(`span`,{className:X(`transition-[filter] duration-200 inline-block`,!o&&`filter blur-[6px] select-none`),children:a.ip})})]})]}),(0,Q.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,Q.jsx)(l,{size:18,className:`text-red-500 mt-1`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-40`,children:p(`setup.currentLocation`)}),(0,Q.jsx)(`button`,{onClick:()=>u(!c),className:`text-gray-400 hover:text-red-500 transition-colors`,children:c?(0,Q.jsx)(y,{size:16}):(0,Q.jsx)(v,{size:16})})]}),(0,Q.jsx)(`div`,{className:`font-bold truncate`,children:(0,Q.jsxs)(`span`,{className:X(`transition-[filter] duration-200 inline-block`,!c&&`filter blur-[6px] select-none`),children:[a.city,`, `,a.region?`${a.region}, `:``,a.country]})})]})]}),d&&(0,Q.jsx)(L,{isOpen:m,onInteraction:e=>g(e),placement:`bottom`,content:(0,Q.jsxs)(`div`,{className:`p-4 max-w-sm max-h-60 overflow-auto font-mono text-xs bg-white dark:bg-gray-900 border border-gray-100 dark:border-gray-800 shadow-lg rounded-lg`,children:[(0,Q.jsx)(`div`,{className:`font-bold border-b border-gray-100 dark:border-gray-800 pb-2 mb-2`,children:`/cdn-cgi/trace`}),(0,Q.jsx)(`pre`,{className:`whitespace-pre-wrap`,children:d.raw})]}),children:(0,Q.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 cursor-pointer select-none`,onDoubleClick:()=>g(!0),children:[(0,Q.jsx)(f,{size:18,className:`text-purple-500 mt-1`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-[10px] uppercase font-bold opacity-40`,children:p(`setup.edgeServer`)}),(0,Q.jsx)(`div`,{className:`font-bold truncate`,children:d.colo})]})]})})]})]})})})},$=({step:e,className:t,size:n=144})=>{let r=e===1?47:50,i=e===1?45.5:45;return(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:J(`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,Q.jsxs)(`svg`,{viewBox:`0 0 100 100`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:`w-full h-full`,children:[(0,Q.jsx)(`circle`,{cx:`50`,cy:`50`,r:`46`,stroke:`currentColor`,strokeWidth:`4`}),(0,Q.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:o}=h();return(0,Q.jsxs)(W,{title:o(`setup.accessPointsCardTitle`,`接入点`),icon:(0,Q.jsx)(u,{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,Q.jsx)($,{step:1}),(0,Q.jsx)(z,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 w-full sm:w-auto`,children:[(0,Q.jsx)(`span`,{className:`text-xs opacity-50 font-medium`,children:o(`setup.selectAccessPointToConfigure`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.length>0?(0,Q.jsx)(B,{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,Q.jsx)(`div`,{className:`font-semibold text-gray-900 dark:text-gray-100 flex items-center gap-2`,children:r||o(`setup.defaultAccessPointName`,`设备-1`)}),e.length>0&&(0,Q.jsx)(G,{minimal:!0,round:!0,intent:R.PRIMARY,className:`text-xs`,children:e.length})]})]}),(0,Q.jsx)(M,{variant:`outlined`,intent:R.NONE,icon:(0,Q.jsx)(d,{size:14}),text:o(`setup.manageAccessPoints`,`管理接入点`),onClick:i,fill:a,className:`shrink-0`})]})})]})},be=({dohUrl:e,copyToClipboard:t,isMobile:n})=>{let{t:r}=h();return(0,Q.jsxs)(W,{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,Q.jsx)(L,{placement:`bottom-end`,usePortal:!0,content:(0,Q.jsxs)(`div`,{className:`p-4 max-w-sm`,children:[(0,Q.jsx)(j,{children:r(`setup.whatIsDoh`)}),(0,Q.jsx)(`p`,{className:`text-sm mb-2`,children:r(`setup.dohDesc`)}),(0,Q.jsxs)(`ul`,{className:`list-disc list-inside text-sm opacity-80 mb-3 space-y-1`,children:[(0,Q.jsx)(`li`,{children:r(`setup.dohBenefit1`)}),(0,Q.jsx)(`li`,{children:r(`setup.dohBenefit2`)})]}),(0,Q.jsx)(`div`,{className:`text-xs border-t border-gray-100 dark:border-gray-700 pt-2`,children:(0,Q.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,Q.jsx)(g,{size:10}),` `,r(`setup.learnMore`)]})})]}),children:(0,Q.jsx)(M,{icon:`help`,variant:`minimal`,intent:R.NONE})}),children:[(0,Q.jsx)($,{step:2}),(0,Q.jsx)(z,{children:(0,Q.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,Q.jsx)(`span`,{className:`font-mono text-blue-600 dark:text-blue-400 break-all text-xs sm:text-sm`,children:e}),(0,Q.jsx)(M,{intent:R.PRIMARY,icon:`duplicate`,text:r(`setup.copyUrl`),fill:n,onClick:()=>t(e),className:`shrink-0`})]})})]})};function xe(e){let t=e.trim();try{return new URL(t.startsWith(`http://`)||t.startsWith(`https://`)?t:`https://${t}`).hostname||t}catch{return t.replace(/^https?:\/\//,``).split(`/`)[0].split(`:`)[0]||t}}function Se(e,t){let n=(e||``).trim(),r=(t||``).trim();if(!r&&n.includes(`(`)&&n.endsWith(`)`)){let e=n.match(/^(.+?)\s*\((.+?)\)$/);e&&(n=e[1].trim(),r=e[2].trim())}let i=n&&n!==`DNS Worker`?n:``,a=r&&r!==`DNS Worker`?r:``;return i&&a?i.toLowerCase()===a.toLowerCase()?i:`${i} - ${a}`:i||a||``}function Ce(e,t,n,r){let i,a,o,s;typeof e==`object`?(i=e.profileKey,a=e.profileName,o=e.accessPointName,s=e.origin):(i=e,a=t,s=n||``,o=r);let c=s.trim(),l=xe(c),u=`${c}/${i}`,d=Se(a,o),f=crypto.randomUUID(),p=crypto.randomUUID(),m=d?`DNS Worker - ${l} (${d})`:`DNS Worker (${l})`,h=d?`DNS Worker DoH - ${l} (${d})`:`DNS Worker DoH - ${l}`,g=d?`DNS Worker DoH configuration profile for ${d} via ${l}`:`DNS Worker DoH configuration profile via ${l}`,_=d?`Configures encrypted DNS over HTTPS (DoH) for ${d} via ${l}`:`Configures encrypted DNS over HTTPS (DoH) via ${l}`;return Y({PayloadContent:[{DNSSettings:{DNSProtocol:`HTTPS`,ServerHTTPVersion:3,ServerURL:u},OnDemandRules:[{Action:`Connect`,InterfaceTypeMatch:`WiFi`},{Action:`Connect`,InterfaceTypeMatch:`Cellular`},{Action:`Disconnect`}],PayloadDescription:_,PayloadDisplayName:h,PayloadIdentifier:`com.apple.dnsSettings.managed.${f}`,PayloadName:h,PayloadType:`com.apple.dnsSettings.managed`,PayloadUUID:f,PayloadVersion:1}],PayloadDescription:g,PayloadDisplayName:m,PayloadIdentifier:`com.dnsworker.profile.${i}`,PayloadName:m,PayloadRemovalDisallowed:!1,PayloadType:`Configuration`,PayloadUUID:p,PayloadVersion:1},{indent:` `})}const we=({isMobile:e,copyToClipboard:t,profileKey:n,profileName:r,accessPointName:o,allRegions:l,selectedRegion:u,currentIps:d})=>{let{t:f}=h();return(0,Q.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,Q.jsx)($,{step:3}),(0,Q.jsxs)(U,{id:`setup-tabs`,renderActiveTabPanelOnly:!0,vertical:!e,size:`large`,className:J(`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,Q.jsx)(H,{id:`browsers`,title:(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(b,{size:16,className:`inline mr-2`}),f(`setup.browsers`)]}),panel:(0,Q.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Q.jsx)(j,{className:`font-bold`,children:f(`setup.browserTitle`)}),(0,Q.jsx)(`p`,{className:`text-sm`,children:f(`setup.browserSteps`)}),(0,Q.jsx)(`p`,{className:`text-[10px] opacity-50 cursor-pointer`,onClick:()=>t(`chrome://settings/security`),children:f(`setup.browserTips`,`or copy this URL to the address bar: `)+`chrome://settings/security`})]})}),(0,Q.jsx)(H,{id:`apple`,title:(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(i,{size:16,className:`inline mr-2`}),f(`setup.apple`)]}),panel:(0,Q.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Q.jsx)(j,{className:`font-bold`,children:f(`setup.appleTitle`)}),(0,Q.jsx)(`p`,{className:`text-sm`,children:f(`setup.appleDesc`)}),(0,Q.jsx)(`p`,{className:`text-[10px] opacity-50 text-center`,children:f(`setup.appleWarning`)}),(0,Q.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,Q.jsx)(k,{icon:`document`,size:40,className:`opacity-20 mb-4`}),(0,Q.jsx)(M,{intent:R.PRIMARY,text:f(`setup.downloadConfig`),icon:`download`,onClick:()=>{let e=Ce({profileKey:n,profileName:r,accessPointName:o,origin:window.location.origin}),t=new Blob([e],{type:`application/x-apple-aspen-config`}),i=URL.createObjectURL(t),a=document.createElement(`a`);a.href=i;let s=Se(r,o),c=xe(window.location.origin);a.download=`dns_worker-${(s||c).replace(/[^a-zA-Z0-9_\-\u4e00-\u9fa5]/g,`_`).replace(/_+/g,`_`).replace(/^_|_$/g,``)}-${n}.mobileconfig`,a.click(),URL.revokeObjectURL(i)}})]}),(0,Q.jsx)(`p`,{className:`text-[10px] opacity-50 mt-4! text-center`,children:f(`setup.appleInstallHint`)})]})}),(0,Q.jsx)(H,{id:`windows`,title:(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(s,{size:16,className:`inline mr-2`}),f(`setup.windows`)]}),panel:(0,Q.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Q.jsx)(j,{className:`font-bold`,children:f(`setup.windowsTitle`,{region:l[u]?.label||f(`setup.otherRegion`)})}),(0,Q.jsxs)(`ol`,{className:`list-decimal list-inside space-y-4 text-sm leading-relaxed`,children:[(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`a`,{href:`ms-settings:network-status`,children:f(`setup.windowsStep0`)})}),(0,Q.jsx)(`li`,{children:f(`setup.windowsStep1`)}),(0,Q.jsxs)(`li`,{children:[f(`setup.windowsStep2`),(0,Q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:d.map(n=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(G,{minimal:!0,interactive:!0,onClick:()=>t(n.ip),icon:`duplicate`,className:`font-mono`,children:n.ip}),!e&&(0,Q.jsx)(`span`,{className:`text-[9px] opacity-40 ml-1`,children:n.area})]},n.ip))})]}),(0,Q.jsx)(`li`,{children:f(`setup.windowsStep3`)}),(0,Q.jsx)(`li`,{children:f(`setup.windowsStep4`)})]})]})}),(0,Q.jsx)(H,{id:`linux`,title:(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(x,{size:16,className:`inline mr-2`}),f(`setup.linux`)]}),panel:(0,Q.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Q.jsx)(j,{className:`font-bold`,children:f(`setup.linuxTitle`)}),(0,Q.jsx)(`p`,{className:`text-sm`,children:f(`setup.linuxDesc`)}),(0,Q.jsxs)(`div`,{className:`mt-4`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-bold mb-2`,children:f(`setup.linuxStep1`)}),(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.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,Q.jsx)(`code`,{children:`curl -sL "${window.location.origin}/setup.sh?key=${n}&origin=${window.location.origin}" | sudo bash`})}),(0,Q.jsx)(M,{className:`absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity`,icon:`duplicate`,minimal:!0,small:!0,onClick:()=>{t(`curl -sL "${window.location.origin}/setup.sh?key=${n}&origin=${window.location.origin}" | sudo bash`)}})]})]}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(`p`,{className:`text-sm font-bold`,children:f(`setup.linuxStep2`)})})]})}),(0,Q.jsx)(H,{id:`routeros`,title:(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(c,{size:16,className:`inline mr-2`}),f(`setup.routeros`)]}),panel:(0,Q.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Q.jsx)(j,{className:`font-bold`,children:f(`setup.routerosTitle`)}),(0,Q.jsx)(`p`,{className:`text-sm`,children:f(`setup.routerosDesc`)}),(0,Q.jsxs)(`div`,{className:`mt-4`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-bold mb-2`,children:f(`setup.routerosStep1`)}),(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.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,Q.jsx)(`code`,{children:`/ip dns set use-doh-server="${window.location.origin}/${n}" verify-doh-cert=yes`})}),(0,Q.jsx)(M,{className:`absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity`,icon:`duplicate`,minimal:!0,small:!0,onClick:()=>{t(`/ip dns set use-doh-server="${window.location.origin}/${n}" verify-doh-cert=yes`)}})]})]}),(0,Q.jsx)(`p`,{className:`text-sm`,children:f(`setup.routerosNote`)}),(0,Q.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,Q.jsx)(g,{size:10}),` `,f(`setup.routerosDocs`)]})]})}),(0,Q.jsx)(H,{id:`android`,title:(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(a,{size:16,className:`inline mr-2`}),f(`setup.android`)]}),panel:(0,Q.jsxs)(`div`,{className:`space-y-4 md:ml-4 mt-4 md:mt-0`,children:[(0,Q.jsx)(j,{className:`font-bold`,children:f(`setup.androidTitle`)}),(0,Q.jsx)(`p`,{className:`text-sm`,children:f(`setup.androidDesc`)}),(0,Q.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-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-semibold text-gray-700 dark:text-gray-300`,children:f(`setup.androidDotTitle`,`私有 DNS (DoT - Serverfull 模式)`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:f(`setup.androidDotDesc`,`设置 > 网络和互联网 > 私有 DNS > 提供商主机名:`)}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)(G,{minimal:!0,interactive:!0,onClick:()=>t(`${n}.${window.location.hostname}`),icon:`duplicate`,className:`font-mono text-sm py-1 px-3`,intent:R.PRIMARY,children:`${n}.${window.location.hostname}`})})]}),(0,Q.jsx)(I,{intent:R.PRIMARY,icon:`info-sign`,className:`text-xs`,children:f(`setup.androidWarning`)})]})})]})]})};function Te({profileId:e,accessPoints:t,onRefresh:n,toasterRef:r}){let{t:i}=h(),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(null),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(``);return{isAddDialogOpen:a,setIsAddDialogOpen:o,newApName:s,setNewApName:c,isAdding:l,renameApId:d,setRenameApId:f,renameApName:p,setRenameApName:m,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=>de.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:R.DANGER});return}u(!0);try{await oe(e,a),r.current?.show({message:i(`setup.accessPointCreated`),intent:R.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:R.DANGER})}finally{u(!1)}}},handleRename:async()=>{let a=p.trim();if(!(!a||!d)){if(t.some(e=>e.id!==d&&e.name.toLowerCase()===a.toLowerCase())){r.current?.show({message:i(`setup.accessPointNameExists`,`Access Point name already exists`),intent:R.DANGER});return}_(!0);try{await pe(e,d,a),r.current?.show({message:i(`setup.accessPointRenamed`),intent:R.SUCCESS}),f(null),n()}catch(e){r.current?.show({message:e.message||`Failed to rename access point`,intent:R.DANGER})}finally{_(!1)}}},handleRotate:async t=>{y(t);try{await le(e,t),r.current?.show({message:i(`setup.tokenRotated`),intent:R.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:R.SUCCESS}),n()}catch(e){console.error(e)}finally{x(null)}}}}}const Ee=({isOpen:e,onClose:t,newApName:n,setNewApName:r,newApNameFocused:i,setNewApNameFocused:a,handleAdd:o,isAdding:s,isValidApName:c})=>{let{t:l}=h();return(0,Q.jsxs)(N,{isOpen:e,onClose:t,title:l(`setup.addAccessPoint`),children:[(0,Q.jsx)(`div`,{className:A,children:(0,Q.jsx)(K,{content:l(`setup.accessPointNameFormatTip`,`1-30 characters, letters, numbers, hyphens and underscores allowed`),isOpen:i,position:D.TOP,intent:R.PRIMARY,className:`w-full`,children:(0,Q.jsx)(`div`,{className:`w-full block`,children:(0,Q.jsx)(V,{autoFocus:!0,large:!0,placeholder:l(`setup.accessPointName`),value:n,onChange:e=>r(e.target.value),onFocus:()=>a(!0),onBlur:()=>a(!1)})})})}),(0,Q.jsx)(`div`,{className:F,children:(0,Q.jsxs)(`div`,{className:q,children:[(0,Q.jsx)(M,{onClick:t,children:l(`common.cancel`,`Cancel`)}),(0,Q.jsx)(M,{intent:R.PRIMARY,onClick:o,loading:s,disabled:!c(n),children:l(`common.create`)})]})})]})},De=({isOpen:e,onClose:t,renameApName:n,setRenameApName:r,renameApNameFocused:i,setRenameApNameFocused:a,handleRename:o,isRenaming:s,isValidApName:c})=>{let{t:l}=h();return(0,Q.jsxs)(N,{isOpen:e,onClose:t,title:l(`setup.renameAccessPoint`),children:[(0,Q.jsx)(`div`,{className:A,children:(0,Q.jsx)(K,{content:l(`setup.accessPointNameFormatTip`,`1-30 characters, letters, numbers, hyphens and underscores allowed`),isOpen:i,position:D.TOP,intent:R.PRIMARY,className:`w-full`,children:(0,Q.jsx)(`div`,{className:`w-full block`,children:(0,Q.jsx)(V,{autoFocus:!0,large:!0,placeholder:l(`setup.accessPointName`),value:n,onChange:e=>r(e.target.value),onFocus:()=>a(!0),onBlur:()=>a(!1)})})})}),(0,Q.jsx)(`div`,{className:F,children:(0,Q.jsxs)(`div`,{className:q,children:[(0,Q.jsx)(M,{onClick:t,children:l(`common.cancel`,`Cancel`)}),(0,Q.jsx)(M,{intent:R.PRIMARY,onClick:o,loading:s,disabled:!c(n),children:l(`common.save`)})]})})]})},Oe=({ap:e,totalApCount:t,toasterRef:i,onRenameTrigger:a,rotateConfirmApId:o,setRotateConfirmApId:s,rotatingApId:c,handleRotate:l,deletingApId:d,handleDelete:f})=>{let{t:m}=h();return(0,Q.jsx)(W,{title:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(u,{size:16}),(0,Q.jsx)(`span`,{children:e.name})]}),className:`shadow-none! rounded-lg!`,children:(0,Q.jsxs)(z,{children:[(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-xs opacity-50 mt-1`,children:`DoH URL`}),(0,Q.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:m(`setup.copied`),intent:R.SUCCESS})},title:m(`setup.copyUrl`),children:[(0,Q.jsx)(`span`,{className:`select-all`,children:`${window.location.origin}/${e.token}`}),(0,Q.jsx)(_,{size:14,className:`shrink-0`})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-xs opacity-50 mt-1`,children:m(`setup.accessPointToken`)}),(0,Q.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,Q.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-xs opacity-50 mt-1`,children:`Created`}),(0,Q.jsx)(`span`,{className:`text-sm`,children:ee(new Date(e.created_at*1e3))})]})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex gap-2 flex-wrap`,children:[(0,Q.jsx)(M,{small:!0,icon:(0,Q.jsx)(n,{size:14}),text:m(`setup.renameAccessPoint`),onClick:()=>a(e.id,e.name)}),(0,Q.jsx)(L,{isOpen:o===e.id,onInteraction:e=>{e||s(null)},content:(0,Q.jsxs)(`div`,{className:`p-4 space-y-3 dark:bg-gray-800 dark:text-white max-w-xs`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-semibold leading-relaxed`,children:m(`setup.rotateTokenConfirmDesc`,`Rotating the key will immediately disconnect devices using the old key. Are you sure you want to continue?`)}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(M,{small:!0,minimal:!0,text:m(`common.cancel`,`Cancel`),onClick:()=>s(null)}),(0,Q.jsx)(M,{small:!0,intent:R.DANGER,text:m(`common.confirm`,`Confirm`),onClick:()=>{s(null),l(e.id)}})]})]}),placement:`top`,children:(0,Q.jsx)(M,{small:!0,icon:(0,Q.jsx)(p,{size:14}),text:m(`setup.rotateToken`),loading:c===e.id,onClick:()=>s(e.id)})}),(0,Q.jsx)(M,{small:!0,intent:R.DANGER,icon:(0,Q.jsx)(r,{size:14}),text:m(`setup.deleteAccessPoint`),loading:d===e.id,onClick:()=>f(e.id),disabled:t<=1,title:t<=1?`Cannot delete the only access point`:void 0})]})]})})},ke=({isOpen:e,onClose:t,profileId:n,isMobile:r,accessPoints:i,loading:a,onRefresh:s,toasterRef:c})=>{let{t:l}=h(),{isAddDialogOpen:u,setIsAddDialogOpen:d,newApName:f,setNewApName:p,isAdding:m,renameApId:g,setRenameApId:_,renameApName:v,setRenameApName:y,isRenaming:b,rotatingApId:x,deletingApId:S,newApNameFocused:w,setNewApNameFocused:T,renameApNameFocused:E,setRenameApNameFocused:D,rotateConfirmApId:O,setRotateConfirmApId:k,isSearchOpen:A,setIsSearchOpen:j,searchQuery:N,setSearchQuery:F,filteredAccessPoints:I,isValidApName:L,handleAdd:z,handleRename:B,handleRotate:H,handleDelete:U}=Te({profileId:n,accessPoints:i,onRefresh:s,toasterRef:c});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(he,{isOpen:e,onClose:t,title:A?(0,Q.jsx)(V,{leftIcon:`search`,placeholder:l(`setup.searchAccessPoints`,`Search...`),value:N,onChange:e=>F(e.target.value),rightElement:(0,Q.jsx)(M,{icon:`cross`,minimal:!0,onClick:()=>{j(!1),F(``)}}),autoFocus:!0}):(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:l(`setup.manageAccessPoints`)}),(0,Q.jsx)(M,{icon:(0,Q.jsx)(o,{size:14}),minimal:!0,onClick:()=>j(!0),className:`opacity-50 hover:opacity-100`})]}),icon:`diagram-tree`,size:r?`100%`:`450px`,children:[(0,Q.jsx)(M,{fill:!0,intent:R.PRIMARY,icon:(0,Q.jsx)(C,{size:16}),text:l(`setup.addAccessPoint`),onClick:()=>d(!0),large:!0}),a?(0,Q.jsx)(`div`,{className:`flex justify-center p-8`,children:(0,Q.jsx)(P,{})}):(0,Q.jsx)(`div`,{className:`space-y-4 mt-4`,children:I.map(e=>(0,Q.jsx)(Oe,{ap:e,totalApCount:i.length,toasterRef:c,onRenameTrigger:(e,t)=>{_(e),y(t)},rotateConfirmApId:O,setRotateConfirmApId:k,rotatingApId:x,handleRotate:H,deletingApId:S,handleDelete:U},e.id))})]}),(0,Q.jsx)(Ee,{isOpen:u,onClose:()=>{d(!1),p(``)},newApName:f,setNewApName:p,newApNameFocused:w,setNewApNameFocused:T,handleAdd:z,isAdding:m,isValidApName:L}),(0,Q.jsx)(De,{isOpen:!!g,onClose:()=>_(null),renameApName:v,setRenameApName:y,renameApNameFocused:E,setRenameApNameFocused:D,handleRename:B,isRenaming:b,isValidApName:L})]})},Ae=({profileId:e,profileKey:t,profileName:n,toasterRef:r})=>{let i=se(),{t:a,i18n:o}=h(),s=(0,Z.useMemo)(()=>ge(a),[o.language,a]),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,g]=(0,Z.useState)(null),_=async()=>{d(!0);try{l(await re(e))}catch(e){console.error(e)}finally{d(!1)}};(0,Z.useEffect)(()=>{_()},[e]);let[v,y]=(0,Z.useState)(n||``);(0,Z.useEffect)(()=>{n?y(n):e&&ue(e).then(e=>{e?.name&&y(e.name)}).catch(()=>{})},[e,n]);let b=(0,Z.useMemo)(()=>c.length===0?null:c.find(e=>e.id===m)||c[0],[c,m]),x=b?b.token:t,S=b?b.name:void 0,C=`${window.location.origin}/${x}`,[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(`CN`),[P,F]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(!1),[z,B]=(0,Z.useState)(null),[V,H]=(0,Z.useState)({}),[U,W]=(0,Z.useState)(null),G={label:a(`setup.otherRegion`),ips:[],countries:[]},K=(0,Z.useMemo)(()=>({...s,...V,Other:G}),[s,V,G]),q=e=>{navigator.clipboard.writeText(e),r?.current?.show({message:a(`setup.copied`),intent:R.SUCCESS})},J=async e=>{let t=async(t,n,r)=>{try{let i=await me(t,e,n);if(i.Answer&&i.Answer.length>0){let e=i.Answer.find(e=>e.type===r);if(e?.data)return e.data}}catch(r){console.warn(`Client-side DNS query failed for ${e} (${n}) via ${t}:`,r)}return null},n=[`cloudflare-dns.com`,`1.1.1.1`],r=null;for(let e of n)if(r=await t(e,`A`,1),r)break;r&&k(r);let i=null;for(let e of n)if(i=await t(e,`AAAA`,28),i)break;i&&j(i)},Y=async()=>{D(!0),W(null);try{let[t,n,r]=await Promise.all([fe(),te(),ie()]);T(t),B(r),t.timezone&&t.timezone!==`UNKNOWN`&&ae(t.timezone);let i=t.substituteDomain||`pages.dev`;try{let e=await ne();e.ip&&k(e.ip),e.ipv6&&j(e.ipv6),(!e.ip||!e.ipv6)&&J(i)}catch(e){console.warn(`Backend substitute lookup failed, falling back to client-side DNS lookup`,e),J(i)}if(n){let e={};for(let[t,r]of Object.entries(n))e[t]={label:s[t]?.label||t,countries:s[t]?.countries||[],ips:r};H(e)}if(t.country){let e=!1;for(let[n,r]of Object.entries(s))if(r.countries.includes(t.country)){N(n),e=!0;break}e||N(`Other`)}W({success:!!t.connectedProfileId,profileMatch:t.connectedProfileId===e})}catch(e){console.error(`Verification failed`,e)}finally{D(!1)}};(0,Z.useEffect)(()=>{Y()},[e]);let X=(0,Z.useMemo)(()=>{let e=[...(K[M]||G).ips],t=w?.substituteDomain||`pages.dev`;return A&&e.unshift({ip:A,area:a(`setup.dynamicFromDomainV6`,{domain:t})}),O&&e.unshift({ip:O,area:a(`setup.dynamicFromDomain`,{domain:t})}),e},[M,K,O,A,w,a,G]);return(0,Q.jsxs)(`div`,{className:`mx-auto space-y-8 pb-24 ${i?`p-1`:`px-8 max-w-5xl`}`,children:[(0,Q.jsx)(_e,{isMobile:i,selectedRegion:M,setSelectedRegion:N,allRegions:K}),(0,Q.jsx)(ve,{isVerifying:E,verifyResult:U,handleVerify:Y,isMobile:i,clientInfo:w,showIp:P,setShowIp:F,showLocation:I,setShowLocation:L,traceInfo:z}),(0,Q.jsx)(ye,{accessPoints:c,selectedApId:b?.id||null,onSelectAp:g,accessPointName:S,onManageAccessPoints:()=>p(!0),isMobile:i}),(0,Q.jsx)(be,{dohUrl:C,copyToClipboard:q,isMobile:i}),(0,Q.jsx)(we,{isMobile:i,copyToClipboard:q,profileKey:x,profileName:v||void 0,accessPointName:S,allRegions:K,selectedRegion:M,currentIps:X}),(0,Q.jsx)(ke,{isOpen:f,onClose:()=>p(!1),profileId:e,isMobile:i,accessPoints:c,loading:u,onRefresh:_,toasterRef:r})]})};export{Ae as SetupView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-C4Xdq4VV.js";import{S as t,b as n}from"./vendor-icons-other-Bme3ywH9.js";import{B as r,g as i}from"./vendor-ui-core-BpucEp_q.js";var a=e(t(),1),o=e(n(),1);const s=({isOpen:e,onClose:t,title:n,icon:s,size:c,className:l,children:u,...d})=>{let f=(0,a.useRef)(null),p=e=>{let t=e.touches[0];f.current={x:t.clientX,y:t.clientY}},m=e=>{if(!f.current)return;let n=e.touches[0],r=n.clientX-f.current.x,i=n.clientY-f.current.y;r>80&&Math.abs(r)>Math.abs(i)*1.5&&(t(),f.current=null)},h=()=>{f.current=null},g=`dark:bg-gray-900 dark:text-white shadow-none! bg-transparent! bg-bulletin! backdrop-blur-sm! ${l||``}`;return(0,o.jsx)(i,{isOpen:e,onClose:t,title:n,icon:s,position:r.RIGHT,size:c,className:g,...d,children:(0,o.jsx)(`div`,{className:`p-6 space-y-4 overflow-y-auto h-full pb-safe`,onTouchStart:p,onTouchMove:m,onTouchEnd:h,children:u})})};export{s as t};
|