From 349451da0de5f590f19b4a84b865ed376aacef63 Mon Sep 17 00:00:00 2001 From: SaintShit Date: Mon, 22 Jul 2024 17:41:13 +0330 Subject: [PATCH] bump version to 0.6.0 --- app/__init__.py | 2 +- app/dashboard/build/404.html | 2 +- .../build/assets/{index.ec887564.js => index.a97b5769.js} | 6 +++--- app/dashboard/build/index.html | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename app/dashboard/build/assets/{index.ec887564.js => index.a97b5769.js} (65%) diff --git a/app/__init__.py b/app/__init__.py index 2e7c2995..2144b497 100755 --- a/app/__init__.py +++ b/app/__init__.py @@ -11,7 +11,7 @@ from config import DOCS, XRAY_SUBSCRIPTION_PATH -__version__ = "0.5.2" +__version__ = "0.6.0" app = FastAPI( diff --git a/app/dashboard/build/404.html b/app/dashboard/build/404.html index c075c0c8..128e9aed 100644 --- a/app/dashboard/build/404.html +++ b/app/dashboard/build/404.html @@ -33,7 +33,7 @@ - + diff --git a/app/dashboard/build/assets/index.ec887564.js b/app/dashboard/build/assets/index.a97b5769.js similarity index 65% rename from app/dashboard/build/assets/index.ec887564.js rename to app/dashboard/build/assets/index.a97b5769.js index 55758c57..4f7ab6a1 100644 --- a/app/dashboard/build/assets/index.ec887564.js +++ b/app/dashboard/build/assets/index.a97b5769.js @@ -1,4 +1,4 @@ -import{i as Mt,B as sn,a as an,b as ln,j as vr,d as B,U as jt,z as cn,r as dn,f as hn,Q as un,e as pn,$ as mn,c as zt,g as x,h as gn,C as fn,k as Dt,u as Ht,l as j,m as r,H as _,n as e,T as h,o as bn,p as D,s as xn,q as f,t as ht,J as yn,v as Ir,A as Et,w as Sn,x as Cn,M as oe,y as se,D as ae,E as ie,F as le,G as fe,I as Ve,K as zr,L as wn,N as lt,O as ce,P as R,R as H,S as Dr,V as ne,W as U,X as pe,Y as Z,Z as Re,_ as F,a0 as Ut,a1 as rt,a2 as _n,a3 as Ee,a4 as Ne,a5 as kn,a6 as Er,a7 as Ur,a8 as st,a9 as St,aa as vn,ab as je,ac as Ct,ad as Xt,ae as In,af as Rr,ag as Lr,ah as Tr,ai as me,aj as zn,ak as Dn,al as En,am as Un,an as Rn,ao as Bt,ap as Ar,aq as Mr,ar as ge,as as Jt,at as Ln,au as Tn,av as An,aw as Nt,ax as Mn,ay as Nn,az as Fn,aA as Pn,aB as Wn,aC as On,aD as wt,aE as jn,aF as Me,aG as Hn,aH as S,aI as ut,aJ as Nr,aK as pt,aL as N,aM as $t,aN as Bn,aO as He,aP as Be,aQ as Ft,aR as $e,aS as Ce,aT as we,aU as _e,aV as ke,aW as ve,aX as Ie,aY as Kt,aZ as $n,a_ as _t,a$ as at,b0 as Vt,b1 as Vn,b2 as Gn,b3 as Yn,b4 as Fr,b5 as Zn,b6 as ct,b7 as kt,b8 as Pr,b9 as Qn,ba as qn,bb as Wr,bc as Ae,bd as Xn,be as Jn,bf as Kn,bg as Gt,bh as Rt,bi as er,bj as Or,bk as eo,bl as to,bm as tr,bn as ro,bo as rr,bp as jr,bq as no,br as Hr,bs as oo,bt as so,bu as Br,bv as ao,bw as io,bx as $r,by as Vr,bz as Gr,bA as X,bB as lo,bC as Yr,bD as nr,bE as co,bF as ho,bG as uo,bH as po,bI as mo,bJ as go,bK as Zr,bL as fo,bM as or,bN as sr,bO as Oe,bP as ze,bQ as ar,bR as ue,bS as ir,bT as bo,bU as xo,bV as yo,bW as So,bX as Co,bY as wo,bZ as _o,b_ as ko,b$ as vo,c0 as Io,c1 as zo,c2 as Do,c3 as Eo,c4 as Uo,c5 as Ro,c6 as Lo,c7 as To}from"./vendor.8aa8dc93.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&s(l)}).observe(document,{childList:!0,subtree:!0});function o(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerpolicy&&(a.referrerPolicy=i.referrerpolicy),i.crossorigin==="use-credentials"?a.credentials="include":i.crossorigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(i){if(i.ep)return;i.ep=!0;const a=o(i);fetch(i.href,a)}})();Mt.use(sn).use(an).use(ln).init({debug:{}.NODE_ENV==="development",returnNull:!1,fallbackLng:"en",interpolation:{escapeValue:!1},react:{useSuspense:!1},load:"languageOnly",detection:{caches:["localStorage","sessionStorage","cookie"]},backend:{loadPath:vr(["/dashboard/","locales/{{lng}}.json"])}},function(t,n){B.locale(Mt.language)});Mt.on("languageChanged",t=>{B.locale(t)});jt("zh-cn",cn);jt("ru",dn);jt("fa",hn);const Pt=new un,Qr=t=>{const n=document.querySelector('meta[name="theme-color"]');n==null||n.setAttribute("content",t=="dark"?"#1A202C":"#3B81F6")},Ao=pn({shadows:{outline:"0 0 0 2px var(--chakra-colors-primary-200)"},fonts:{body:"Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif"},colors:{"light-border":"#d2d2d4",primary:{50:"#9cb7f2",100:"#88a9ef",200:"#749aec",300:"#618ce9",400:"#4d7de7",500:"#396fe4",600:"#3364cd",700:"#2e59b6",800:"#284ea0",900:"#224389"},gray:{750:"#222C3B"}},components:{Alert:{baseStyle:{container:{borderRadius:"6px",fontSize:"sm"}}},Select:{baseStyle:{field:{_dark:{borderColor:"gray.600",borderRadius:"6px"},_light:{borderRadius:"6px"}}}},FormHelperText:{baseStyle:{fontSize:"xs"}},FormLabel:{baseStyle:{fontSize:"sm",fontWeight:"medium",mb:"1",_dark:{color:"gray.300"}}},Input:{baseStyle:{addon:{_dark:{borderColor:"gray.600",_placeholder:{color:"gray.500"}}},field:{_focusVisible:{boxShadow:"none",borderColor:"primary.200",outlineColor:"primary.200"},_dark:{borderColor:"gray.600",_disabled:{color:"gray.400",borderColor:"gray.500"},_placeholder:{color:"gray.500"}}}}},Table:{baseStyle:{table:{borderCollapse:"separate",borderSpacing:0},thead:{borderBottomColor:"light-border"},th:{background:"#F9FAFB",borderColor:"light-border !important",borderBottomColor:"light-border !important",borderTop:"1px solid ",borderTopColor:"light-border !important",_first:{borderLeft:"1px solid",borderColor:"light-border !important"},_last:{borderRight:"1px solid",borderColor:"light-border !important"},_dark:{borderColor:"gray.600 !important",background:"gray.750"}},td:{transition:"all .1s ease-out",borderColor:"light-border",borderBottomColor:"light-border !important",_first:{borderLeft:"1px solid",borderColor:"light-border",_dark:{borderColor:"gray.600"}},_last:{borderRight:"1px solid",borderColor:"light-border",_dark:{borderColor:"gray.600"}},_dark:{borderColor:"gray.600",borderBottomColor:"gray.600 !important"}},tr:{"&.interactive":{cursor:"pointer",_hover:{"& > td":{bg:"gray.200"},_dark:{"& > td":{bg:"gray.750"}}}},_last:{"& > td":{_first:{borderBottomLeftRadius:"8px"},_last:{borderBottomRightRadius:"8px"}}}}}}}});const vt=()=>localStorage.getItem("token"),Mo=t=>{localStorage.setItem("token",t)},No=()=>{localStorage.removeItem("token")},Fo=mn.create({baseURL:"/api/"}),Po=(t,n={})=>(vt()&&(n.headers={...(n==null?void 0:n.headers)||{},Authorization:`Bearer ${vt()}`}),Fo(t,n)),O=Po,Wo=zt(t=>({isLoading:!0,isPostLoading:!1,version:null,started:!1,logs_websocket:null,config:"",fetchCoreSettings:()=>{t({isLoading:!0}),Promise.all([O("/core").then(({version:n,started:o,logs_websocket:s})=>t({version:n,started:o,logs_websocket:s})),O("/core/config").then(n=>t({config:n}))]).finally(()=>t({isLoading:!1}))},updateConfig:n=>(t({isPostLoading:!0}),O("/core/config",{method:"PUT",body:n}).finally(()=>{t({isPostLoading:!1})})),restartCore:()=>O("/core/restart",{method:"POST"})}));function re(t,n=2,o=!1){if(!+t)return"0 B";const s=1024,i=n<0?0:n,a=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],l=Math.floor(Math.log(t)/Math.log(s));return o?[parseFloat((t/Math.pow(s,l)).toFixed(i)),a[l]]:`${parseFloat((t/Math.pow(s,l)).toFixed(i))} ${a[l]}`}const lr=t=>{if(t!==null)return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},Oo=x(gn,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),jo=x(fn,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),Ho=x(Dt,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),Lt=({title:t,content:n,icon:o})=>r(bn,{p:6,borderWidth:"1px",borderColor:"light-border",bg:"#F9FAFB",_dark:{borderColor:"gray.600",bg:"gray.750"},borderStyle:"solid",boxShadow:"none",borderRadius:"12px",width:"full",display:"flex",justifyContent:"space-between",flexDirection:"row",children:[r(_,{alignItems:"center",columnGap:"4",children:[e(D,{p:"2",position:"relative",color:"white",_before:{content:'""',position:"absolute",top:0,left:0,bg:"primary.400",display:"block",w:"full",h:"full",borderRadius:"5px",opacity:".5",z:"1"},_after:{content:'""',position:"absolute",top:"-5px",left:"-5px",bg:"primary.400",display:"block",w:"calc(100% + 10px)",h:"calc(100% + 10px)",borderRadius:"8px",opacity:".4",z:"1"},children:o}),e(h,{color:"gray.600",_dark:{color:"gray.300"},fontWeight:"medium",textTransform:"capitalize",fontSize:"sm",children:t})]}),e(D,{fontSize:"3xl",fontWeight:"semibold",mt:"2",children:n})]}),Wt="statistics-query-key",Bo=t=>{const{version:n}=E(),{data:o}=Ht({queryKey:Wt,queryFn:()=>O("/system"),refetchInterval:5e3,onSuccess:({version:i})=>{n!==i&&E.setState({version:i})}}),{t:s}=j();return r(_,{justifyContent:"space-between",gap:0,columnGap:{lg:4,md:0},rowGap:{lg:0,base:4},display:"flex",flexDirection:{lg:"row",base:"column"},...t,children:[e(Lt,{title:s("activeUsers"),content:o&&r(_,{alignItems:"flex-end",children:[e(h,{children:lr(o.users_active)}),r(h,{fontWeight:"normal",fontSize:"lg",as:"span",display:"inline-block",pb:"5px",children:["/ ",lr(o.total_user)]})]}),icon:e(Oo,{})}),e(Lt,{title:s("dataUsage"),content:o&&re(o.incoming_bandwidth+o.outgoing_bandwidth),icon:e(jo,{})}),e(Lt,{title:s("memoryUsage"),content:o&&r(_,{alignItems:"flex-end",children:[e(h,{children:re(o.mem_used,1,!0)[0]}),r(h,{fontWeight:"normal",fontSize:"lg",as:"span",display:"inline-block",pb:"5px",children:[re(o.mem_used,1,!0)[1]," /"," ",re(o.mem_total,1)]})]}),icon:e(Ho,{})})]})},qr="marzban-num-users-per-page",cr=10,$o=()=>{const t=localStorage.getItem(qr)||cr.toString();return parseInt(t)||cr},Vo=t=>localStorage.setItem(qr,t),Go=t=>{for(const n in t)t[n]||delete t[n];return E.setState({loading:!0}),O("/users",{query:t}).then(n=>(E.setState({users:n}),n)).finally(()=>{E.setState({loading:!1})})},Yo=()=>O("/inbounds").then(t=>{E.setState({inbounds:new Map(Object.entries(t))})}).finally(()=>{E.setState({loading:!1})}),E=zt(xn((t,n)=>({version:null,editingUser:null,deletingUser:null,isCreatingNewUser:!1,QRcodeLinks:null,subscribeUrl:null,users:{users:[],total:0},loading:!0,isResetingAllUsage:!1,isEditingHosts:!1,isEditingNodes:!1,isShowingNodesUsage:!1,resetUsageUser:null,revokeSubscriptionUser:null,filters:{username:"",limit:$o(),sort:"-created_at"},inbounds:new Map,isEditingCore:!1,refetchUsers:()=>{Go(n().filters)},resetAllUsage:()=>O("/users/reset",{method:"POST"}).then(()=>{n().onResetAllUsage(!1),n().refetchUsers()}),onResetAllUsage:o=>t({isResetingAllUsage:o}),onCreateUser:o=>t({isCreatingNewUser:o}),onEditingUser:o=>{t({editingUser:o})},onDeletingUser:o=>{t({deletingUser:o})},onFilterChange:o=>{t({filters:{...n().filters,...o}}),n().refetchUsers()},setQRCode:o=>{t({QRcodeLinks:o})},deleteUser:o=>(t({editingUser:null}),O(`/user/${o.username}`,{method:"DELETE"}).then(()=>{t({deletingUser:null}),n().refetchUsers(),Pt.invalidateQueries(Wt)})),createUser:o=>O("/user",{method:"POST",body:o}).then(()=>{t({editingUser:null}),n().refetchUsers(),Pt.invalidateQueries(Wt)}),editUser:o=>O(`/user/${o.username}`,{method:"PUT",body:o}).then(()=>{n().onEditingUser(null),n().refetchUsers()}),fetchUserUsage:(o,s)=>{for(const i in s)s[i]||delete s[i];return O(`/user/${o.username}/usage`,{method:"GET",query:s})},onEditingHosts:o=>{t({isEditingHosts:o})},onEditingNodes:o=>{t({isEditingNodes:o})},onShowingNodesUsage:o=>{t({isShowingNodesUsage:o})},setSubLink:o=>{t({subscribeUrl:o})},resetDataUsage:o=>O(`/user/${o.username}/reset`,{method:"POST"}).then(()=>{t({resetUsageUser:null}),n().refetchUsers()}),revokeSubscription:o=>O(`/user/${o.username}/revoke_sub`,{method:"POST"}).then(s=>{t({revokeSubscriptionUser:null,editingUser:s}),n().refetchUsers()})}))),de=({children:t,color:n})=>e(D,{position:"relative",width:"36px",height:"36px",display:"flex",justifyContent:"center",alignItems:"center",_before:{content:'""',display:"block",position:"absolute",top:"0",left:"0",width:"calc(100%)",height:"calc(100%)",bg:`${n}.400`,opacity:".5",borderRadius:"5px",zIndex:"1",_dark:{bg:`${n}.400`}},_after:{content:'""',display:"block",position:"absolute",top:"0",left:"0",width:"calc(100% + 10px)",height:"calc(100% + 10px)",transform:"translate(-5px, -5px)",bg:`${n}.400`,opacity:".4",borderRadius:"8px",zIndex:"1",_dark:{bg:`${n}.400`}},children:e(h,{color:`${n}.500`,_dark:{color:`${n}.900`},position:"relative",zIndex:"2",children:t})});window.ace.define("ace/theme/nord_dark",["require","exports","module","ace/lib/dom"],(t,n,o)=>{n.isDark=!0,n.cssClass="ace-nord-dark",t("../lib/dom").importCssString(n.cssText,n.cssClass)});window.ace.define("ace/theme/dawn",["require","exports","module","ace/lib/dom"],(t,n,o)=>{n.isDark=!1,n.cssClass="ace-dawn",t("../lib/dom").importCssString(n.cssText,n.cssClass)});const Zo=f.exports.forwardRef(({json:t,onChange:n,mode:o="code"},s)=>{const{colorMode:i}=ht(),a={mode:o,onChangeText:n,statusBar:!1,mainMenuBar:!1,theme:i==="dark"?"ace/theme/nord_dark":"ace/theme/dawn"},l=f.exports.useRef(null),u=f.exports.useRef(null);return f.exports.useEffect(()=>(u.current=new yn(l.current,a),()=>{u.current&&u.current.destroy()}),[]),f.exports.useEffect(()=>{u.current&&u.current.update(t)},[t]),e(D,{ref:s,border:"1px solid",borderColor:"gray.300",_dark:{borderColor:"gray.500"},borderRadius:5,h:"full",children:e(D,{height:"full",ref:l})})}),dr=500,Qo=x(Ir,{baseStyle:{w:5,h:5}}),qo=x(Et,{baseStyle:{w:4,h:4}}),Xo=x(Sn,{baseStyle:{w:4,h:4}}),Jo=x(Cn,{baseStyle:{w:3,h:3}}),Ko=t=>({[rt.ReadyState.CONNECTING]:"connecting",[rt.ReadyState.OPEN]:"connected",[rt.ReadyState.CLOSING]:"closed",[rt.ReadyState.CLOSED]:"closed",[rt.ReadyState.UNINSTANTIATED]:"closed"})[t],es=()=>{try{let t=new URL("/api/".startsWith("/")?window.location.origin+"/api/":"/api/");return(t.protocol==="https:"?"wss://":"ws://")+vr([t.host+t.pathname,"/core/logs"])+"?interval=1&token="+vt()}catch(t){return console.error("Unable to generate websocket url"),console.error(t),null}};let Le=[];const ts=()=>{const{isEditingCore:t}=E(),{fetchCoreSettings:n,updateConfig:o,isLoading:s,config:i,isPostLoading:a,version:l,restartCore:u}=Wo(),p=f.exports.useRef(null),[C,d]=f.exports.useState([]),{t:c}=j(),w=fe(),v=Ve({defaultValues:{config:i||{}}});f.exports.useEffect(()=>{i&&v.setValue("config",i)},[i]),f.exports.useEffect(()=>{t&&n()},[t]);const m=f.exports.useRef(!0),y=f.exports.useCallback(zr(L=>{var J,z,P;const V=Math.abs((((J=p.current)==null?void 0:J.scrollTop)||0)-(((z=p.current)==null?void 0:z.scrollHeight)||0)+(((P=p.current)==null?void 0:P.offsetHeight)||0))<10;p.current&&V?m.current=!0:m.current=!1,L.length<40&&d(L)},300),[]),{readyState:T}=wn(es(),{onMessage:L=>{Le.push(L.data),Le.length>dr&&(Le=Le.splice(0,Le.length-dr)),y([...Le])},shouldReconnect:()=>!0,reconnectAttempts:10,reconnectInterval:1e3});f.exports.useEffect(()=>{var L;p.current&&m.current&&(p.current.scrollTop=(L=p.current)==null?void 0:L.scrollHeight)},[C]),f.exports.useEffect(()=>()=>{Le=[]},[]);const g=Ko(T.toString()),{mutate:b,isLoading:W}=lt(u),$=({config:L})=>{o(L).then(()=>{w({title:c("core.successMessage"),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(V=>{let J=c("core.generalErrorMessage");typeof V.response._data.detail=="object"&&(J=V.response._data.detail[Object.keys(V.response._data.detail)[0]]),typeof V.response._data.detail=="string"&&(J=V.response._data.detail),w({title:J,status:"error",isClosable:!0,position:"top",duration:3e3})})},I=f.exports.useRef(null),[A,Y]=f.exports.useState(!1),q=()=>{var L;document.fullscreenElement?(document.exitFullscreen(),Y(!1)):((L=I.current)==null||L.requestFullscreen(),Y(!0))};return r("form",{onSubmit:v.handleSubmit($),children:[r(ce,{children:[r(R,{children:[r(_,{justifyContent:"space-between",alignItems:"flex-start",children:[r(H,{children:[c("core.configuration")," ",s&&e(Dr,{isIndeterminate:!0,size:"15px"})]}),e(_,{gap:0,children:e(ne,{label:"Xray Version",placement:"top",children:e(U,{height:"100%",textTransform:"lowercase",children:l&&`v${l}`})})})]}),r(D,{position:"relative",ref:I,minHeight:"300px",children:[e(pe,{control:v.control,name:"config",render:({field:L})=>e(Zo,{json:i,onChange:L.onChange})}),e(Z,{size:"xs","aria-label":"full screen",variant:"ghost",position:"absolute",top:"2",right:"4",onClick:q,children:A?e(Jo,{}):e(Xo,{})})]})]}),r(R,{mt:"4",children:[r(_,{justifyContent:"space-between",children:[e(H,{children:c("core.logs")}),e(h,{as:H,children:c(`core.socket.${g}`)})]}),e(D,{border:"1px solid",borderColor:"gray.300",bg:"#F9F9F9",_dark:{borderColor:"gray.500",bg:"#2e3440"},borderRadius:5,minHeight:"200px",maxHeight:"250px",p:2,overflowY:"auto",ref:p,children:C.map((L,V)=>e(h,{fontSize:"xs",opacity:.8,whiteSpace:"pre-line",children:L},V))})]})]}),e(Re,{children:r(_,{w:"full",justifyContent:"space-between",children:[e(D,{children:e(F,{size:"sm",leftIcon:e(qo,{className:Ut({"animate-spin":W})}),onClick:()=>b(),children:c(W?"core.restarting":"core.restartCore")})}),e(_,{children:e(F,{size:"sm",variant:"solid",colorScheme:"primary",px:"5",type:"submit",isDisabled:s||a,isLoading:a,children:c("core.save")})})]})})]})},rs=()=>{const{isEditingCore:t}=E(),n=E.setState.bind(null,{isEditingCore:!1}),{t:o}=j();return r(oe,{isOpen:t,onClose:n,size:"3xl",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"full",children:[e(ie,{pt:6,children:r(_,{gap:2,children:[e(de,{color:"primary",children:e(Qo,{color:"white"})}),e(h,{fontWeight:"semibold",fontSize:"lg",children:o("core.title")})]})}),e(le,{mt:3}),e(ts,{})]})]})},mt=x(_n,{baseStyle:{w:5,h:5}}),ns=()=>{const[t,n]=f.exports.useState(!1),{deletingUser:o,onDeletingUser:s,deleteUser:i}=E(),{t:a}=j(),l=fe(),u=()=>{s(null)},p=()=>{o&&(n(!0),i(o).then(()=>{l({title:a("deleteUser.deleteSuccess",{username:o.username}),status:"success",isClosable:!0,position:"top",duration:3e3})}).then(u).finally(n.bind(null,!1)))};return r(oe,{isCentered:!0,isOpen:!!o,onClose:u,size:"sm",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",children:[e(ie,{pt:6,children:e(de,{color:"red",children:e(mt,{})})}),e(le,{mt:3}),r(ce,{children:[e(h,{fontWeight:"semibold",fontSize:"lg",children:a("deleteUser.title")}),o&&e(h,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(Ee,{components:{b:e("b",{})},children:a("deleteUser.prompt",{username:o.username})})})]}),r(Re,{display:"flex",children:[e(F,{size:"sm",onClick:u,mr:3,w:"full",variant:"outline",children:a("cancel")}),e(F,{size:"sm",w:"full",colorScheme:"red",onClick:p,leftIcon:t?e(Ne,{size:"xs"}):void 0,children:a("delete")})]})]})]})},Yt={baseStyle:{w:4,h:4}},os=x(kn,Yt),ss=x(Er,Yt),Xr=x(Et,Yt),as=zr(t=>{E.getState().onFilterChange({...E.getState().filters,offset:0,search:t})},300),is=({...t})=>{const{loading:n,filters:o,onFilterChange:s,refetchUsers:i,onCreateUser:a}=E(),{t:l}=j(),[u,p]=f.exports.useState(""),C=c=>{p(c.target.value),as(c.target.value)},d=()=>{p(""),s({...o,offset:0,search:""})};return r(Ur,{id:"filters",templateColumns:{lg:"repeat(3, 1fr)",md:"repeat(4, 1fr)",base:"repeat(1, 1fr)"},position:"sticky",top:0,mx:"-6",px:"6",rowGap:4,gap:{lg:4,base:0},bg:"var(--chakra-colors-chakra-body-bg)",py:4,zIndex:"docked",...t,children:[e(st,{colSpan:{base:1,md:2,lg:1},order:{base:2,md:1},children:r(St,{children:[e(vn,{pointerEvents:"none",children:e(os,{})}),e(je,{placeholder:l("search"),value:u,borderColor:"light-border",onChange:C}),r(Ct,{children:[n&&e(Ne,{size:"xs"}),o.search&&o.search.length>0&&e(Z,{onClick:d,"aria-label":"clear",size:"xs",variant:"ghost",children:e(ss,{})})]})]})}),e(st,{colSpan:2,order:{base:1,md:2},children:r(_,{justifyContent:"flex-end",alignItems:"center",h:"full",children:[e(Z,{"aria-label":"refresh users",disabled:n,onClick:i,size:"sm",variant:"outline",children:e(Xr,{className:Ut({"animate-spin":n})})}),e(F,{colorScheme:"primary",size:"sm",onClick:()=>a(!0),px:5,children:l("createUser")})]})})]})},Jr="https://github.com/Gozargah/Marzban",ls="https://github.com/Gozargah",cs="https://github.com/Gozargah/Marzban#donation",Kr=t=>{const{version:n}=E();return e(_,{w:"full",py:"0",position:"relative",...t,children:r(h,{display:"inline-block",flexGrow:1,textAlign:"center",color:"gray.500",fontSize:"xs",children:[e(Xt,{color:"blue.400",href:Jr,children:"Marzban"}),n?` (v${n}), `:", ","Made with \u2764\uFE0F in"," ",e(Xt,{color:"blue.400",href:ls,children:"Gozargah"})]})})},ds=x(In,{baseStyle:{w:4,h:4}}),en=({actions:t})=>{const{i18n:n}=j();var o=s=>{n.changeLanguage(s)};return r(Rr,{placement:"bottom-end",children:[e(Lr,{as:Z,size:"sm",variant:"outline",icon:e(ds,{}),position:"relative"}),r(Tr,{minW:"100px",zIndex:9999,children:[e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("en"),children:"English"}),e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("fa"),children:"\u0641\u0627\u0631\u0633\u06CC"}),e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("zh-cn"),children:"\u7B80\u4F53\u4E2D\u6587"}),e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("ru"),children:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"})]})]})},be={baseStyle:{w:4,h:4}},hs=x(zn,be),us=x(Dn,be),ps=x(Ir,be),ms=x(En,be),gs=x(Un,be),fs=x(Rn,be),bs=x(Bt,be),xs=x(Ar,be),ys=x(Dt,be),Ss=x(Mr,be),hr=x(D,{baseStyle:{bg:"yellow.500",w:"2",h:"2",rounded:"full",position:"absolute"}}),tn="marzban-menu-notification",Cs=()=>{const t=localStorage.getItem(tn);if(!t)return!0;try{return t&&Tn(parseInt(t))?An(new Date,new Date(parseInt(t)))>=7:!0}catch{return!0}},ws=({actions:t})=>{const{onEditingHosts:n,onResetAllUsage:o,onEditingNodes:s,onShowingNodesUsage:i}=E(),{t:a}=j(),{colorMode:l,toggleColorMode:u}=ht(),[p,C]=f.exports.useState(Cs()),d=l==="dark"?"dark_dimmed":l,c=()=>{localStorage.setItem(tn,new Date().getTime().toString()),C(!1)};return r(_,{gap:2,justifyContent:"space-between",__css:{"& .menuList":{direction:"ltr"}},position:"relative",children:[e(h,{as:"h1",fontWeight:"semibold",fontSize:"2xl",children:a("users")}),p&&e(hr,{top:"0",right:"0",zIndex:9999}),e(D,{overflow:"auto",css:{direction:"rtl"},children:r(_,{alignItems:"center",children:[r(Rr,{children:[e(Lr,{as:Z,size:"sm",variant:"outline",icon:e(ge,{children:e(ms,{})}),position:"relative"}),r(Tr,{minW:"170px",zIndex:99999,className:"menuList",children:[e(me,{maxW:"170px",fontSize:"sm",icon:e(bs,{}),onClick:n.bind(null,!0),children:a("header.hostSettings")}),e(me,{maxW:"170px",fontSize:"sm",icon:e(xs,{}),onClick:s.bind(null,!0),children:a("header.nodeSettings")}),e(me,{maxW:"170px",fontSize:"sm",icon:e(ys,{}),onClick:i.bind(null,!0),children:a("header.nodesUsage")}),e(me,{maxW:"170px",fontSize:"sm",icon:e(Ss,{}),onClick:o.bind(null,!0),children:a("resetAllUsage")}),e(Jt,{to:cs,target:"_blank",children:r(me,{maxW:"170px",fontSize:"sm",icon:e(fs,{}),position:"relative",onClick:c,children:[a("header.donation")," ",p&&e(hr,{top:"3",right:"2"})]})}),e(Jt,{to:"/login",children:e(me,{maxW:"170px",fontSize:"sm",icon:e(gs,{}),children:a("header.logout")})})]})]}),e(Z,{size:"sm",variant:"outline","aria-label":"core settings",onClick:()=>{E.setState({isEditingCore:!0})},children:e(ps,{})}),e(en,{}),e(Z,{size:"sm",variant:"outline","aria-label":"switch theme",onClick:()=>{Qr(l=="dark"?"light":"dark"),u()},children:l==="light"?e(hs,{}):e(us,{})}),e(D,{css:{direction:"ltr"},display:"flex",alignItems:"center",pr:"2",__css:{"& span":{display:"inline-flex"}},children:e(Ln,{href:Jr,"data-color-scheme":`no-preference: ${d}; light: ${d}; dark: ${d};`,"data-size":"large","data-show-count":"true","aria-label":"Star Marzban on GitHub",children:"Star"})})]})})]})},_s=[{title:"Inbound's default",value:"inbound_default"},{title:"TLS",value:"tls"},{title:"None",value:"none"}],ks=[{title:"",value:""},{title:"h3",value:"h3"},{title:"h2",value:"h2"},{title:"http/1.1",value:"http/1.1"},{title:"h3,h2,http/1.1",value:"h3,h2,http/1.1"},{title:"h3,h2",value:"h3,h2"},{title:"h2,http/1.1",value:"h2,http/1.1"}],vs=[{title:"",value:""},...["chrome","firefox","safari","ios","android","edge","360","qq","random","randomized"].map(t=>({title:t,value:t}))],Is=[{title:"none",value:""},{title:"xtls-rprx-vision",value:"xtls-rprx-vision"}],zs=["aes-128-gcm","aes-256-gcm","chacha20-ietf-poly1305"],Ds=zt(t=>({isLoading:!1,isPostLoading:!1,hosts:{},fetchHosts:()=>{t({isLoading:!0}),O("/hosts").then(n=>t({hosts:n})).finally(()=>t({isLoading:!1}))},setHosts:n=>(t({isPostLoading:!0}),O("/hosts",{method:"PUT",body:n}).finally(()=>{t({isPostLoading:!1})}))}));const Es=x(Er,{baseStyle:{w:4,h:4}}),Ue=Nt.forwardRef(({disabled:t,step:n,label:o,className:s,startAdornment:i,endAdornment:a,type:l="text",placeholder:u,onChange:p,onBlur:C,name:d,value:c,onClick:w,error:v,clearable:m=!1,...y},T)=>{const g=()=>{p&&p({target:{value:"",name:d}})},{size:b="md"}=y,W=l=="number"?jn:je,$=l=="number"?Mn:Nt.Fragment,I=l=="number"?{keepWithinRange:!0,precision:5,format:A=>isNaN(parseFloat(String(A)))||Number(parseFloat(String(A)).toFixed(5))===0?A:Number(parseFloat(String(A)).toFixed(5)),min:0,step:n,name:d,type:l,placeholder:u,onChange:A=>{p&&p(A)},onBlur:C,value:c,onClick:w,disabled:t,flexGrow:1,size:b}:{};return r(R,{isInvalid:!!v,children:[o&&e(H,{children:o}),r(St,{size:b,w:"full",rounded:"md",_focusWithin:{outline:"2px solid",outlineColor:"primary.200"},bg:t?"gray.100":"transparent",_dark:{bg:t?"gray.600":"transparent"},children:[i&&e(Nn,{children:i}),r($,{...I,children:[e(W,{name:d,ref:T,step:n,className:Ut(s),type:l,placeholder:u,onChange:p,onBlur:C,value:c,onClick:w,disabled:t,flexGrow:1,_focusVisible:{outline:"none",borderTopColor:"transparent",borderRightColor:"transparent",borderBottomColor:"transparent"},_disabled:{cursor:"not-allowed"},...y,roundedLeft:i?"0":"md",roundedRight:a?"0":"md"}),l=="number"&&e(ge,{children:r(Fn,{children:[e(Pn,{}),e(Wn,{})]})})]}),a&&e(On,{borderLeftRadius:0,borderRightRadius:"6px",bg:"transparent",children:a}),m&&c&&c.length&&e(Ct,{borderLeftRadius:0,borderRightRadius:"6px",bg:"transparent",onClick:g,cursor:"pointer",children:e(Es,{})})]}),!!v&&e(wt,{children:v})]})}),Tt=x(Me,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Te=x(Ue,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Us=x(Bt,{baseStyle:{w:5,h:5}}),De=x(Hn,{baseStyle:{w:4,h:4,color:"gray.400",cursor:"pointer"}}),Rs=S.record(S.string().min(1),S.array(S.object({remark:S.string().min(1,"Remark is required"),address:S.string().min(1,"Address is required"),port:S.string().or(S.number()).nullable().transform(t=>typeof t=="number"?t:t!==null&&!isNaN(parseInt(t))?Number(parseInt(t)):null),path:S.string().nullable(),sni:S.string().nullable(),host:S.string().nullable(),mux_enable:S.boolean().default(!1),allowinsecure:S.boolean().nullable().default(!1),is_disabled:S.boolean().default(!0),fragment_setting:S.string().nullable(),random_user_agent:S.boolean().default(!1),security:S.string(),alpn:S.string(),fingerprint:S.string()}))),Se=x(wt,{baseStyle:{color:"red.400",display:"block",textAlign:"left",w:"100%"}}),Ls=({hostKey:t,isOpen:n,toggleAccordion:o})=>{const{inbounds:s}=E(),i=[...s.values()].flat().filter(v=>v.tag===t)[0],a=$t(),{fields:l,append:u,remove:p}=Bn({control:a.control,name:t}),{errors:C}=a.formState,{t:d}=j(),c=C[t],w=()=>{u({host:"",sni:"",port:null,path:null,address:"",remark:"",mux_enable:!1,allowinsecure:!1,is_disabled:!1,fragment_setting:"",random_user_agent:!1,security:"inbound_default",alpn:"",fingerprint:""})};return f.exports.useEffect(()=>{c&&!n&&o()},[c]),r(He,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[r(Be,{px:2,borderRadius:"3px",onClick:o,children:[e(h,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},children:t}),e(Ft,{})]}),e($e,{px:2,pb:2,children:r(N,{gap:3,children:[l.map((v,m)=>{var y,T,g,b,W,$,I,A,Y,q,L,V,J,z,P,K,Fe,bt,xt,ee,Pe,Ye,Ze,Qe,qe,Xe,k,M,te,xe,he,ye,G,Je,Ke,et,tt;return r(N,{border:"1px solid",_dark:{borderColor:"gray.600",bg:"#273142"},_light:{borderColor:"gray.200",bg:"#fcfbfb"},p:2,w:"full",borderRadius:"4px",children:[e(_,{w:"100%",alignItems:"flex-start",children:r(R,{position:"relative",zIndex:10,isInvalid:!!(c&&((y=c[m])==null?void 0:y.remark)),children:[r(St,{children:[e(Te,{...a.register(t+"."+m+".remark"),size:"sm",borderRadius:"4px",placeholder:"Remark"}),e(Ct,{children:r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(D,{mt:"-8px",children:e(De,{})})}),e(_e,{children:r(ke,{children:[e(ve,{}),e(Ie,{}),e(Kt,{children:r(D,{fontSize:"xs",children:[e(h,{pr:"20px",children:d("hostsDialog.desc")}),r(h,{children:[r(U,{children:["{","SERVER_IP","}"]})," ",d("hostsDialog.currentServer")]}),r(h,{mt:1,children:[r(U,{children:["{","SERVER_IPV6","}"]})," ",d("hostsDialog.currentServerv6")]}),r(h,{mt:1,children:[r(U,{children:["{","USERNAME","}"]})," ",d("hostsDialog.username")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_USAGE","}"]})," ",d("hostsDialog.dataUsage")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LEFT","}"]})," ",d("hostsDialog.remainingData")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LIMIT","}"]})," ",d("hostsDialog.dataLimit")]}),r(h,{mt:1,children:[r(U,{children:["{","DAYS_LEFT","}"]})," ",d("hostsDialog.remainingDays")]}),r(h,{mt:1,children:[r(U,{children:["{","EXPIRE_DATE","}"]})," ",d("hostsDialog.expireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","JALALI_EXPIRE_DATE","}"]})," ",d("hostsDialog.jalaliExpireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","TIME_LEFT","}"]})," ",d("hostsDialog.remainingTime")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_TEXT","}"]})," ",d("hostsDialog.statusText")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_EMOJI","}"]})," ",d("hostsDialog.statusEmoji")]}),r(h,{mt:1,children:[r(U,{children:["{","PROTOCOL","}"]})," ",d("hostsDialog.proxyProtocol")]}),r(h,{mt:1,children:[r(U,{children:["{","TRANSPORT","}"]})," ",d("hostsDialog.proxyMethod")]})]})})]})})]})})]}),c&&((T=c[m])==null?void 0:T.remark)&&e(Se,{children:(b=(g=c[m])==null?void 0:g.remark)==null?void 0:b.message})]})}),r(R,{isInvalid:!!(c&&((W=c[m])==null?void 0:W.address)),children:[r(St,{children:[e(Te,{size:"sm",borderRadius:"4px",placeholder:"Address (e.g. example.com)",...a.register(t+"."+m+".address")}),e(Ct,{children:r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(D,{mt:"-8px",children:e(De,{})})}),e(_e,{children:r(ke,{children:[e(ve,{}),e(Ie,{}),e(Kt,{children:r(D,{fontSize:"xs",children:[e(h,{pr:"20px",children:d("hostsDialog.desc")}),r(h,{children:[r(U,{children:["{","SERVER_IP","}"]})," ",d("hostsDialog.currentServer")]}),r(h,{mt:1,children:[r(U,{children:["{","SERVER_IPV6","}"]})," ",d("hostsDialog.currentServerv6")]}),r(h,{mt:1,children:[r(U,{children:["{","USERNAME","}"]})," ",d("hostsDialog.username")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_USAGE","}"]})," ",d("hostsDialog.dataUsage")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LEFT","}"]})," ",d("hostsDialog.remainingData")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LIMIT","}"]})," ",d("hostsDialog.dataLimit")]}),r(h,{mt:1,children:[r(U,{children:["{","DAYS_LEFT","}"]})," ",d("hostsDialog.remainingDays")]}),r(h,{mt:1,children:[r(U,{children:["{","EXPIRE_DATE","}"]})," ",d("hostsDialog.expireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","JALALI_EXPIRE_DATE","}"]})," ",d("hostsDialog.jalaliExpireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","TIME_LEFT","}"]})," ",d("hostsDialog.remainingTime")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_TEXT","}"]})," ",d("hostsDialog.statusText")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_EMOJI","}"]})," ",d("hostsDialog.statusEmoji")]}),r(h,{mt:1,children:[r(U,{children:["{","PROTOCOL","}"]})," ",d("hostsDialog.proxyProtocol")]}),r(h,{mt:1,children:[r(U,{children:["{","TRANSPORT","}"]})," ",d("hostsDialog.proxyMethod")]})]})})]})})]})})]}),c&&(($=c[m])==null?void 0:$.address)&&e(Se,{children:(A=(I=c[m])==null?void 0:I.address)==null?void 0:A.message})]}),e(pt,{w:"full",allowToggle:!0,children:r(He,{border:"0",children:[r(Be,{display:"flex",px:0,py:1,borderRadius:3,_hover:{bg:"transparent"},children:[r(h,{flex:"3",align:"start",fontSize:"xs",color:"gray.600",_dark:{color:"gray.500"},pl:1,children:[d("hostsDialog.advancedOptions"),e(Ft,{fontSize:"sm",ml:1})]}),r($n,{flex:"1",px:"0",children:[e(pe,{control:a.control,name:`${t}.${m}.is_disabled`,render:({field:Q})=>e(_t,{mx:"1.5",colorScheme:"primary",...Q,value:void 0,isChecked:!Q.value,onChange:We=>{console.log(We.target.checked),Q.onChange(!We.target.checked)}})}),e(ne,{label:"Delete",placement:"top",children:e(Z,{"aria-label":"Delete",size:"sm",colorScheme:"red",variant:"ghost",onClick:p.bind(null,m),children:e(mt,{})})})]})]}),e($e,{w:"full",p:1,children:r(N,{w:"full",borderRadius:"4px",children:[r(R,{isInvalid:!!(c&&((Y=c[m])==null?void 0:Y.port)),children:[r(H,{display:"flex",pb:1,alignItems:"center",justifyContent:"space-between",gap:1,m:"0",children:[e("span",{children:d("hostsDialog.port")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.port.info")})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:String(i.port||"8080"),type:"number",...a.register(t+"."+m+".port")})]}),r(R,{isInvalid:!!(c&&((q=c[m])==null?void 0:q.sni)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.sni")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.sni.info")}),e(h,{fontSize:"xs",mt:"2",children:e(Ee,{i18nKey:"hostsDialog.host.wildcard",components:{badge:e(U,{})}})}),e(h,{fontSize:"xs",children:e(Ee,{i18nKey:"hostsDialog.host.multiHost",components:{badge:e(U,{})}})})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"SNI (e.g. example.com)",...a.register(t+"."+m+".sni")}),c&&((L=c[m])==null?void 0:L.sni)&&e(Se,{children:(J=(V=c[m])==null?void 0:V.sni)==null?void 0:J.message})]}),r(R,{isInvalid:!!(c&&((z=c[m])==null?void 0:z.host)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.host")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.host.info")}),e(h,{fontSize:"xs",mt:"2",children:e(Ee,{i18nKey:"hostsDialog.host.wildcard",components:{badge:e(U,{})}})}),e(h,{fontSize:"xs",children:e(Ee,{i18nKey:"hostsDialog.host.multiHost",components:{badge:e(U,{})}})})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"Host (e.g. example.com)",...a.register(t+"."+m+".host")}),c&&((P=c[m])==null?void 0:P.host)&&e(Se,{children:(Fe=(K=c[m])==null?void 0:K.host)==null?void 0:Fe.message})]}),r(R,{isInvalid:!!(c&&((bt=c[m])==null?void 0:bt.path)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.path")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.path.info")})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"path (e.g. /vless)",...a.register(t+"."+m+".path")}),c&&((xt=c[m])==null?void 0:xt.path)&&e(Se,{children:(Pe=(ee=c[m])==null?void 0:ee.path)==null?void 0:Pe.message})]}),r(R,{height:"66px",children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.security")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.security.info")})]})})]})]}),e(Tt,{size:"sm",...a.register(t+"."+m+".security"),children:_s.map(Q=>e("option",{value:Q.value,children:Q.title},Q.value))})]}),r(R,{height:"66px",children:[e(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:e("span",{children:d("hostsDialog.alpn")})}),e(Tt,{size:"sm",...a.register(t+"."+m+".alpn"),children:ks.map(Q=>e("option",{value:Q.value,children:Q.title},Q.value))})]}),r(R,{height:"66px",children:[e(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:e("span",{children:d("hostsDialog.fingerprint")})}),e(Tt,{size:"sm",...a.register(t+"."+m+".fingerprint"),children:vs.map(Q=>e("option",{value:Q.value,children:Q.title},Q.value))})]}),r(R,{isInvalid:!!(c&&((Ye=c[m])==null?void 0:Ye.fragment_setting)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.fragment")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.fragment.info")}),e(h,{fontSize:"xs",pr:5,pt:2,pb:1,children:d("hostsDialog.fragment.info.examples")}),e(h,{fontSize:"xs",pr:5,children:"100-200,10-20,tlshello"}),e(h,{fontSize:"xs",pr:5,children:"100-200,10-20,1-3"}),e(h,{fontSize:"xs",pr:5,pt:"3",children:d("hostsDialog.fragment.info.attention")})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"Fragment settings by pattern",...a.register(t+"."+m+".fragment_setting")}),c&&((Ze=c[m])==null?void 0:Ze.fragment_setting)&&e(Se,{children:(qe=(Qe=c[m])==null?void 0:Qe.fragment_setting)==null?void 0:qe.message})]}),e(R,{isInvalid:!!(c&&((Xe=c[m])==null?void 0:Xe.allowinsecure)),children:r(at,{...a.register(t+"."+m+".allowinsecure"),name:t+"."+m+".allowinsecure",children:[e(H,{children:d("hostsDialog.allowinsecure")}),c&&((k=c[m])==null?void 0:k.allowinsecure)&&e(Se,{children:(te=(M=c[m])==null?void 0:M.allowinsecure)==null?void 0:te.message})]})}),r(R,{isInvalid:!!(c&&((xe=c[m])==null?void 0:xe.mux_enable)),children:[e(at,{...a.register(t+"."+m+".mux_enable"),children:e(H,{children:d("hostsDialog.muxEnable")})}),c&&((he=c[m])==null?void 0:he.mux_enable)&&e(Se,{children:(G=(ye=c[m])==null?void 0:ye.mux_enable)==null?void 0:G.message})]}),r(R,{isInvalid:!!(c&&((Je=c[m])==null?void 0:Je.random_user_agent)),children:[e(at,{...a.register(t+"."+m+".random_user_agent"),children:e(H,{children:d("hostsDialog.randomUserAgent")})}),c&&((Ke=c[m])==null?void 0:Ke.random_user_agent)&&e(Se,{children:(tt=(et=c[m])==null?void 0:et.random_user_agent)==null?void 0:tt.message})]})]},m)})]})})]},m)}),e(F,{variant:"outline",w:"full",size:"sm",color:"",fontWeight:"normal",onClick:w,children:d("hostsDialog.addHost")})]})})]})},Ts=()=>{const{isEditingHosts:t,onEditingHosts:n,refetchUsers:o,inbounds:s}=E(),{isLoading:i,hosts:a,fetchHosts:l,isPostLoading:u,setHosts:p}=Ds(),C=fe(),{t:d}=j(),[c,w]=f.exports.useState({});f.exports.useEffect(()=>{t&&l()},[t]);const v=Ve({resolver:ut(Rs)});f.exports.useEffect(()=>{a&&t&&v.reset(a)},[a]);const m=()=>{w({}),n(!1)},y=g=>{p(g).then(()=>{C({title:d("hostsDialog.savedSuccess"),status:"success",isClosable:!0,position:"top",duration:3e3}),o()}).catch(b=>{var W,$,I,A,Y;(((W=b==null?void 0:b.response)==null?void 0:W.status)===409||(($=b==null?void 0:b.response)==null?void 0:$.status)===400)&&C({title:(A=(I=b.response)==null?void 0:I._data)==null?void 0:A.detail,status:"error",isClosable:!0,position:"top",duration:3e3}),((Y=b==null?void 0:b.response)==null?void 0:Y.status)===422&&Object.keys(b.response._data.detail).forEach(q=>{C({title:b.response._data.detail[q]+" ("+q+")",status:"error",isClosable:!0,position:"top",duration:3e3})})})},T=g=>{c[String(g)]?delete c[String(g)]:c[String(g)]={},w({...c})};return r(oe,{isOpen:t,onClose:m,children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(ie,{pt:6,children:e(de,{color:"primary",children:e(Us,{color:"white"})})}),e(le,{mt:3}),e(ce,{w:"440px",pb:3,pt:3,children:e(Nr,{...v,children:r("form",{onSubmit:v.handleSubmit(y),children:[e(h,{mb:3,opacity:.8,fontSize:"sm",children:d("hostsDialog.title")}),i&&d("hostsDialog.loading"),!i&&a&&(Object.keys(a).length>0?e(pt,{w:"full",allowToggle:!0,allowMultiple:!0,index:Object.keys(c).map(g=>parseInt(g)),children:e(N,{w:"full",children:Object.keys(a).map((g,b)=>e(Ls,{toggleAccordion:()=>T(b),isOpen:c[String(b)],hostKey:g},g))})}):"No inbound found. Please check your Xray config file."),e(_,{justifyContent:"flex-end",py:2,children:e(F,{variant:"solid",mt:"2",type:"submit",colorScheme:"primary",size:"sm",px:5,isLoading:u,disabled:u,children:d("hostsDialog.apply")})})]})})})]})]})},rn=S.object({name:S.string().min(1),address:S.string().min(1),port:S.number().min(1).or(S.string().transform(t=>parseFloat(t))),api_port:S.number().min(1).or(S.string().transform(t=>parseFloat(t))),xray_version:S.string().nullable().optional(),id:S.number().nullable().optional(),status:S.enum(["connected","connecting","error","disabled"]).nullable().optional(),message:S.string().nullable().optional(),add_as_new_host:S.boolean().optional(),usage_coefficient:S.number().or(S.string().transform(t=>parseFloat(t)))}),As=()=>({name:"",address:"",port:62050,api_port:62051,xray_version:"",usage_coefficient:1}),dt="fetch-nodes-query-key",Ms=()=>{const{isEditingNodes:t}=E();return Ht({queryKey:dt,queryFn:gt.getState().fetchNodes,refetchInterval:t?3e3:void 0,refetchOnWindowFocus:!1})},gt=zt((t,n)=>({nodes:[],addNode(o){return O("/node",{method:"POST",body:o})},fetchNodes(){return O("/nodes")},fetchNodesUsage(o){return O("/nodes/usage",{query:o})},updateNode(o){return O(`/node/${o.id}`,{method:"PUT",body:o})},setDeletingNode(o){t({deletingNode:o})},reconnectNode(o){return O(`/node/${o.id}/reconnect`,{method:"POST"})},deleteNode:()=>{var o;return O(`/node/${(o=n().deletingNode)==null?void 0:o.id}`,{method:"DELETE"})}})),Zt=(t,n,o)=>{if(t.response&&t.response._data){if(typeof t.response._data.detail=="string")return n({title:t.response._data.detail,status:"error",isClosable:!0,position:"top",duration:3e3});if(typeof t.response._data.detail=="object"&&o){Object.keys(t.response._data.detail).forEach(s=>o.setError(s,{message:t.response._data.detail[s]}));return}}return n({title:"Something went wrong!",status:"error",isClosable:!0,position:"top",duration:3e3})},Qt=(t,n)=>n({title:t,status:"success",isClosable:!0,position:"top",duration:3e3}),Ns=({deleteCallback:t})=>{const{deleteNode:n,deletingNode:o,setDeletingNode:s}=gt(),{t:i}=j(),a=fe(),l=Vt(),u=()=>{s(null)},{isLoading:p,mutate:C}=lt(n,{onSuccess:()=>{Qt(i("deleteNode.deleteSuccess",{name:o&&o.name}),a),s(null),l.invalidateQueries(dt),t&&t()},onError:d=>{Zt(d,a)}});return r(oe,{isCentered:!0,isOpen:!!o,onClose:u,size:"sm",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",children:[e(ie,{pt:6,children:e(de,{color:"red",children:e(mt,{})})}),e(le,{mt:3}),r(ce,{children:[e(h,{fontWeight:"semibold",fontSize:"lg",children:i("deleteNode.title")}),o&&e(h,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(Ee,{components:{b:e("b",{})},children:i("deleteNode.prompt",{name:o.name})})})]}),r(Re,{display:"flex",children:[e(F,{size:"sm",onClick:u,mr:3,w:"full",variant:"outline",children:i("cancel")}),e(F,{size:"sm",w:"full",colorScheme:"red",onClick:()=>C(),leftIcon:p?e(Ne,{size:"xs"}):void 0,children:i("delete")})]})]})]})},ft={baseStyle:{strokeWidth:"2px",w:4,h:4}},ur=x(Vn,ft),Fs=x(Gn,ft),pr=x(Yn,ft),mr=x(Fr,ft),Ps=x(Fr,ft),Ot=[{title:"No",value:"no_reset"},{title:"Daily",value:"day"},{title:"Weekly",value:"week"},{title:"Monthly",value:"month"},{title:"Annually",value:"year"}],it={active:{statusColor:"green",bandWidthColor:"primary",icon:ur},connected:{statusColor:"green",bandWidthColor:"primary",icon:ur},disabled:{statusColor:"gray",bandWidthColor:"gray",icon:Fs},expired:{statusColor:"orange",bandWidthColor:"orange",icon:mr},on_hold:{statusColor:"purple",bandWidthColor:"purple",icon:Ps},connecting:{statusColor:"orange",bandWidthColor:"orange",icon:mr},limited:{statusColor:"red",bandWidthColor:"red",icon:pr},error:{statusColor:"red",bandWidthColor:"red",icon:pr}},qt=t=>{let n={status:"",time:""};if(t){B(t*1e3).utc().isAfter(B().utc())?n.status="expires":n.status="expired";const o=[],s=B.duration(B(t*1e3).utc().diff(B()));s.years()!=0&&o.push(Math.abs(s.years())+" year"+(Math.abs(s.years())!=1?"s":"")),s.months()!=0&&o.push(Math.abs(s.months())+" month"+(Math.abs(s.months())!=1?"s":"")),s.days()!=0&&o.push(Math.abs(s.days())+" day"+(Math.abs(s.days())!=1?"s":"")),o.length===0&&(s.hours()!=0&&o.push(Math.abs(s.hours())+" hour"+(Math.abs(s.hours())!=1?"s":"")),s.minutes()!=0&&o.push(Math.abs(s.minutes())+" min"+(Math.abs(s.minutes())!=1?"s":""))),n.time=o.join(", ")}return n},yt=({expiryDate:t,status:n,compact:o=!1,showDetail:s=!0,extraText:i})=>{const{t:a}=j(),l=qt(t),u=it[n].icon;return r(ge,{children:[r(U,{colorScheme:it[n].statusColor,rounded:"full",display:"inline-flex",px:3,py:1,columnGap:o?1:2,alignItems:"center",children:[e(u,{w:o?3:4}),s&&r(h,{textTransform:"capitalize",fontSize:o?".7rem":".875rem",lineHeight:o?"1rem":"1.25rem",fontWeight:"medium",letterSpacing:"tighter",children:[n==="on_hold"?a(n):n,i&&`: ${i}`]})]}),s&&t&&e(h,{display:"inline-block",fontSize:"xs",fontWeight:"medium",ml:"2",color:"gray.600",_dark:{color:"gray.400"},children:a(l.status,{time:l.time})})]})},nt=x(Ue,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Ws=x(Ar,{baseStyle:{w:5,h:5}}),Os=x(Zn,{baseStyle:{w:5,h:5,strokeWidth:2}}),js=({toggleAccordion:t,node:n})=>{const{updateNode:o,reconnectNode:s,setDeletingNode:i}=gt(),{t:a}=j(),l=Vt(),u=fe(),p=Ve({defaultValues:n,resolver:ut(rn)}),C=i.bind(null,n),{isLoading:d,mutate:c}=lt(o,{onSuccess:()=>{Qt("Node updated successfully",u),l.invalidateQueries(dt)},onError:y=>{Zt(y,u,p)}}),{isLoading:w,mutate:v}=lt(s.bind(null,n),{onSuccess:()=>{l.invalidateQueries(dt)}}),m=w?"connecting":n.status?n.status:"error";return r(He,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[r(Be,{px:2,borderRadius:"3px",onClick:t,children:[r(_,{w:"full",justifyContent:"space-between",pr:2,children:[e(h,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},children:n.name}),r(_,{children:[n.xray_version&&e(U,{colorScheme:"blue",rounded:"full",display:"inline-flex",px:3,py:1,children:r(h,{textTransform:"capitalize",fontSize:"0.7rem",fontWeight:"medium",letterSpacing:"tighter",children:["Xray ",n.xray_version]})}),n.status&&e(yt,{status:m,compact:!0})]})]}),e(Ft,{})]}),r($e,{px:2,pb:2,children:[e(N,{pb:3,alignItems:"flex-start",children:m==="error"&&e(ct,{status:"error",size:"xs",children:r(D,{children:[r(_,{w:"full",children:[e(kt,{w:4}),e(h,{marginInlineEnd:0,children:n.message})]}),e(_,{justifyContent:"flex-end",w:"full",children:e(F,{size:"sm","aria-label":"reconnect node",leftIcon:e(Xr,{}),onClick:()=>v(),disabled:w,children:a(w?"nodes.reconnecting":"nodes.reconnect")})})]})})}),e(nn,{form:p,mutate:c,isLoading:d,submitBtnText:a("nodes.editNode"),btnLeftAdornment:e(ne,{label:a("delete"),placement:"top",children:e(Z,{colorScheme:"red",variant:"ghost",size:"sm","aria-label":"delete node",onClick:C,children:e(mt,{})})})})]})]})},Hs=({toggleAccordion:t,resetAccordions:n})=>{const o=fe(),{t:s}=j(),i=Vt(),{addNode:a}=gt(),l=Ve({resolver:ut(rn),defaultValues:{...As(),add_as_new_host:!0}}),{isLoading:u,mutate:p}=lt(a,{onSuccess:()=>{Qt(s("nodes.addNodeSuccess",{name:l.getValues("name")}),o),i.invalidateQueries(dt),l.reset(),n()},onError:C=>{Zt(C,o,l)}});return r(He,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[e(Be,{px:2,borderRadius:"3px",onClick:t,children:r(h,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},display:"flex",gap:1,children:[e(Os,{display:"inline-block"})," ",e("span",{children:s("nodes.addNewMarzbanNode")})]})}),e($e,{px:2,py:4,children:e(nn,{form:l,mutate:p,isLoading:u,submitBtnText:s("nodes.addNode"),btnProps:{variant:"solid"},addAsHost:!0})})]})},nn=({form:t,mutate:n,isLoading:o,submitBtnText:s,btnProps:i={},btnLeftAdornment:a,addAsHost:l=!1})=>{var v,m,y,T,g,b,W,$,I,A,Y,q,L,V,J;const{t:u}=j(),[p,C]=f.exports.useState(!1),{data:d,isLoading:c}=Ht({queryKey:"node-settings",queryFn:()=>O("/node/settings")});function w(z){if(document.body.createTextRange){const P=document.body.createTextRange();P.moveToElementText(z),P.select()}else if(window.getSelection){const P=window.getSelection(),K=document.createRange();K.selectNodeContents(z),P.removeAllRanges(),P.addRange(K)}else console.warn("Could not select text in node: Unsupported browser.")}return e("form",{onSubmit:t.handleSubmit(z=>n(z)),children:r(N,{children:[d&&d.certificate&&e(ct,{status:"info",alignItems:"start",children:r(Pr,{display:"flex",flexDirection:"column",overflow:"hidden",children:[e("span",{children:u("nodes.connection-hint")}),r(_,{justify:"end",py:2,children:[e(F,{as:"a",colorScheme:"primary",size:"xs",download:"ssl_client_cert.pem",href:URL.createObjectURL(new Blob([d.certificate],{type:"text/plain"})),children:u("nodes.download-certificate")}),e(ne,{placement:"top",label:u("nodes.show-certificate"),children:e(Z,{"aria-label":u("nodes.show-certificate"),onClick:C.bind(null,!p),colorScheme:"whiteAlpha",color:"primary",size:"xs",children:p?e(qn,{width:"15px"}):e(Qn,{width:"15px"})})})]}),e(Wr,{in:p,animateOpacity:!0,children:e(h,{bg:"rgba(255,255,255,.5)",_dark:{bg:"rgba(255,255,255,.2)"},rounded:"md",p:"2",lineHeight:"1.2",fontSize:"10px",fontFamily:"Courier",whiteSpace:"pre",overflow:"auto",onClick:z=>{w(z.target)},children:d.certificate})})]})}),r(_,{w:"full",children:[e(R,{children:e(nt,{label:u("nodes.nodeName"),size:"sm",placeholder:"Marzban-S2",...t.register("name"),error:(y=(m=(v=t.formState)==null?void 0:v.errors)==null?void 0:m.name)==null?void 0:y.message})}),e(_,{px:1,children:e(pe,{name:"status",control:t.control,render:({field:z})=>e(ne,{placement:"top",label:`${u("usersTable.status")}: `+(z.value!=="disabled"?u("active"):u("disabled")),textTransform:"capitalize",children:e(D,{mt:"6",children:e(_t,{colorScheme:"primary",isChecked:z.value!=="disabled",onChange:P=>{P.target.checked?z.onChange("connecting"):z.onChange("disabled")}})})},z.value)})})]}),e(_,{alignItems:"flex-start",w:"100%",children:e(D,{w:"100%",children:e(nt,{label:u("nodes.nodeAddress"),size:"sm",placeholder:"51.20.12.13",...t.register("address"),error:(b=(g=(T=t.formState)==null?void 0:T.errors)==null?void 0:g.address)==null?void 0:b.message})})}),r(_,{alignItems:"flex-start",w:"100%",children:[e(D,{children:e(nt,{label:u("nodes.nodePort"),size:"sm",placeholder:"62050",...t.register("port"),error:(I=($=(W=t.formState)==null?void 0:W.errors)==null?void 0:$.port)==null?void 0:I.message})}),e(D,{children:e(nt,{label:u("nodes.nodeAPIPort"),size:"sm",placeholder:"62051",...t.register("api_port"),error:(q=(Y=(A=t.formState)==null?void 0:A.errors)==null?void 0:Y.api_port)==null?void 0:q.message})}),e(D,{children:e(nt,{label:u("nodes.usageCoefficient"),size:"sm",placeholder:"1",...t.register("usage_coefficient"),error:(J=(V=(L=t.formState)==null?void 0:L.errors)==null?void 0:V.usage_coefficient)==null?void 0:J.message})})]}),l&&e(R,{py:1,children:e(at,{...t.register("add_as_new_host"),children:e(H,{m:0,children:u("nodes.addHostForEveryInbound")})})}),r(_,{w:"full",children:[a,e(F,{flexGrow:1,type:"submit",colorScheme:"primary",size:"sm",px:5,w:"full",isLoading:o,...i,children:s})]})]})})},Bs=()=>{const{isEditingNodes:t,onEditingNodes:n}=E(),{t:o}=j(),[s,i]=f.exports.useState({}),{data:a,isLoading:l}=Ms(),u=()=>{i({}),n(!1)},p=C=>{s[String(C)]?delete s[String(C)]:s[String(C)]={},i({...s})};return r(ge,{children:[r(oe,{isOpen:t,onClose:u,children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(ie,{pt:6,children:e(de,{color:"primary",children:e(Ws,{color:"white"})})}),e(le,{mt:3}),r(ce,{w:"440px",pb:6,pt:3,children:[e(h,{mb:3,opacity:.8,fontSize:"sm",children:o("nodes.title")}),l&&"loading...",e(pt,{w:"full",allowToggle:!0,index:Object.keys(s).map(C=>parseInt(C)),children:r(N,{w:"full",children:[!l&&a&&a.map((C,d)=>e(js,{toggleAccordion:()=>p(d),node:C},C.name)),e(Hs,{toggleAccordion:()=>p((a||[]).length),resetAccordions:()=>i({})})]})})]})]})]}),e(Ns,{deleteCallback:()=>i({})})]})};function $s(t){const n=360/t,o=90,s=47,i=[];for(let a=0;a(w<0&&(w+=1),w>1&&(w-=1),w<.16666666666666666?d+(c-d)*6*w:w<.5?c:w<.6666666666666666?d+(c-d)*(.6666666666666666-w)*6:d),p=o<.5?o*(1+n):o+n-o*n,C=2*o-p;s=Math.round(u(C,p,t+1/3)*255),i=Math.round(u(C,p,t)*255),a=Math.round(u(C,p,t-1/3)*255)}const l=u=>{const p=u.toString(16);return p.length===1?"0"+p:p};return`#${l(s)}${l(i)}${l(a)}`}const gr=({border:t,...n})=>{const{getInputProps:o,getRadioProps:s}=no(n),i=Ae({base:"xs",md:"sm"});return r(D,{as:"label",children:[e("input",{...o()}),e(D,{...s(),minW:"48px",w:"full",h:"full",textAlign:"center",cursor:"pointer",fontSize:i,borderWidth:t?"1px":"0px",borderRadius:"md",_checked:{bg:"primary.500",color:"white",borderColor:"primary.500"},_focus:{boxShadow:"outline"},px:3,py:1,children:n.children})]})},on=({onChange:t,defaultValue:n,...o})=>{const{t:s,i18n:i}=j();ht();const a=Ae({base:["7h","1d","3d","1w"],md:["7h","1d","3d","1w","1m","3m"]}),l={h:"hour",d:"day",w:"week",m:"month",y:"year"},u=Ae({base:[{title:"hours",options:["1h","3h","6h","12h"]},{title:"days",options:["1d","2d","3d","4d"]},{title:"weeks",options:["1w","2w","3w","4w"]},{title:"months",options:["1m","2m","3m","6m"]}],md:[{title:"hours",options:["1h","2h","3h","6h","8h","12h"]},{title:"days",options:["1d","2d","3d","4d","5d","6d"]},{title:"weeks",options:["1w","2w","3w","4w"]},{title:"months",options:["1m","2m","3m","6m","8m"]}]}),{getRootProps:p,getRadioProps:C,setValue:d}=Xn({name:"filter",defaultValue:n,onChange:z=>{if(z==="custom")return;v(),a.indexOf(z)>=0?(T(s("userDialog.custom")),b(!1)):(T(s("userDialog.custom")+` (${z})`),b(!0));const P=Number(z.substring(0,z.length-1)),K=l[z[z.length-1]];t(z,{start:B().utc().subtract(P,K).format("YYYY-MM-DDTHH:00:00")})}}),{isOpen:c,onOpen:w,onClose:v}=Jn(),m=f.exports.useRef(null);Kn({ref:m,handler:v});const[y,T]=f.exports.useState(s("userDialog.custom")),[g,b]=f.exports.useState(!1),[W,$]=f.exports.useState(0),I=Ae({base:1,md:2}),A=Ae({base:"xs",md:"sm"}),[Y,q]=f.exports.useState(null),[L,V]=f.exports.useState(null),J=z=>{const[P,K]=z;L&&!K?(q(null),V(null)):(q(P),V(K),P&&K&&(v(),t("custom",{start:B(P).format("YYYY-MM-DDT00:00:00"),end:B(K).format("YYYY-MM-DDT23:59:59")})))};return r(N,{...o,children:[W==0&&r(Gt,{...p(),gap:0,display:"flex",borderWidth:"1px",borderRadius:"md",minW:{base:"320px",md:"400px"},children:[a.map(z=>e(gr,{...C({value:z}),children:z},z)),e(D,{onClick:()=>{q(null),V(null),w()},cursor:"pointer",borderRadius:"md",w:"full",fontSize:A,px:3,py:1,bg:g?"primary.500":"unset",color:g?"white":"unset",borderColor:g?"primary.500":"unset",children:r(_,{children:[e(h,{children:y}),e(Rt,{as:er,boxSize:"18px"})]})})]}),W==1&&r(_,{onClick:w,cursor:"pointer",fontSize:A,borderRadius:"md",px:3,py:1,minW:{base:"320px",md:"400px"},borderWidth:"1px",children:[e(h,{w:"full",color:Y?"unset":"gray.500",children:Y?B(Y).format("YYYY-MM-DD (00:00)"):s("userDialog.startDate")}),e(Rt,{as:Or,boxSize:"18px"}),e(h,{w:"full",color:L?"unset":"gray.500",children:L?B(L).format("YYYY-MM-DD (23:59)"):s("userDialog.endDate")}),e(Rt,{as:er,boxSize:"18px"})]}),e(N,{ref:m,marginTop:"40px !important",borderRadius:"md",borderWidth:"1px",position:"absolute",zIndex:"1",backgroundColor:"white",_dark:{backgroundColor:"gray.700"},display:c?"unset":"none",children:r(eo,{onChange:z=>$(z),children:[r(to,{children:[e(tr,{fontSize:A,children:s("userDialog.relative")}),e(tr,{fontSize:A,children:s("userDialog.absolute")})]}),r(ro,{children:[e(rr,{children:u.map(z=>e(N,{alignItems:"start",pl:2,pr:2,children:r(_,{justifyItems:"flex-start",mb:4,children:[e(h,{fontSize:A,minW:"60px",children:s("userDialog."+z.title)}),z.options.map(P=>e(gr,{border:!0,...C({value:P}),children:P},P+".custom"))]})},z.title))}),e(rr,{className:"datepicker-panel",children:e(N,{children:e(jr,{locale:i.language.toLocaleLowerCase(),selected:Y,onChange:J,startDate:Y,endDate:L,selectsRange:!0,maxDate:new Date,monthsShown:I,peekNextMonth:!1,inline:!0})})})]})]})})]})};function It(t,n,o=[],s=[]){const i=re(o.reduce((a,l)=>a+=l,0));return{series:o,options:{labels:s,chart:{width:"100%",height:"100%",type:"donut",animations:{enabled:!1}},title:{text:`${n}${i}`,align:"center",style:{fontWeight:"var(--chakra-fontWeights-medium)",color:t==="dark"?"var(--chakra-colors-gray-300)":void 0}},legend:{position:"bottom",labels:{colors:t==="dark"?"#CBD5E0":void 0,useSeriesColors:!1}},stroke:{width:1,colors:void 0},dataLabels:{formatter:(a,{seriesIndex:l,w:u})=>re(u.config.series[l],1)},tooltip:{custom:({series:a,seriesIndex:l,dataPointIndex:u,w:p})=>{const C=re(a[l],1),d=Math.max(a.reduce((w,v)=>w+=v),1),c=Math.round(a[l]/d*1e3)/10+"%";return` +import{i as Nt,B as sn,a as an,b as ln,j as vr,d as B,U as Ht,z as cn,r as dn,f as hn,Q as un,e as pn,$ as mn,c as zt,g as y,h as gn,C as fn,k as Dt,u as Bt,l as j,m as r,H as _,n as e,T as h,o as bn,p as D,s as xn,q as f,t as ht,J as yn,v as Ir,A as Et,w as Sn,x as Cn,M as oe,y as se,D as ae,E as ie,F as le,G as fe,I as Ve,K as zr,L as wn,N as lt,O as ce,P as R,R as H,S as Dr,V as ne,W as U,X as pe,Y as Z,Z as Re,_ as F,a0 as Ut,a1 as rt,a2 as _n,a3 as Ee,a4 as Ne,a5 as kn,a6 as Er,a7 as Ur,a8 as st,a9 as St,aa as vn,ab as je,ac as Ct,ad as Jt,ae as In,af as Rr,ag as Lr,ah as Tr,ai as me,aj as zn,ak as Dn,al as En,am as Un,an as Rn,ao as $t,ap as Ar,aq as Mr,ar as ge,as as Kt,at as Ln,au as Tn,av as An,aw as Ft,ax as Mn,ay as Nn,az as Fn,aA as Pn,aB as Wn,aC as On,aD as wt,aE as jn,aF as Me,aG as Hn,aH as x,aI as ut,aJ as Nr,aK as pt,aL as N,aM as Vt,aN as Bn,aO as He,aP as Be,aQ as Pt,aR as $e,aS as Ce,aT as we,aU as _e,aV as ke,aW as ve,aX as Ie,aY as er,aZ as $n,a_ as _t,a$ as at,b0 as Gt,b1 as Vn,b2 as Gn,b3 as Yn,b4 as Fr,b5 as Zn,b6 as ct,b7 as kt,b8 as Pr,b9 as Qn,ba as qn,bb as Wr,bc as Ae,bd as Xn,be as Jn,bf as Kn,bg as Yt,bh as Rt,bi as tr,bj as Or,bk as eo,bl as to,bm as rr,bn as ro,bo as nr,bp as jr,bq as no,br as Hr,bs as oo,bt as so,bu as Br,bv as ao,bw as io,bx as $r,by as Vr,bz as Gr,bA as X,bB as lo,bC as Yr,bD as or,bE as co,bF as ho,bG as uo,bH as po,bI as mo,bJ as go,bK as Zr,bL as fo,bM as sr,bN as ar,bO as Oe,bP as ze,bQ as ir,bR as ue,bS as lr,bT as bo,bU as xo,bV as yo,bW as So,bX as Co,bY as wo,bZ as _o,b_ as ko,b$ as vo,c0 as Io,c1 as zo,c2 as Do,c3 as Eo,c4 as Uo,c5 as Ro,c6 as Lo,c7 as To}from"./vendor.8aa8dc93.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&s(l)}).observe(document,{childList:!0,subtree:!0});function o(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerpolicy&&(a.referrerPolicy=i.referrerpolicy),i.crossorigin==="use-credentials"?a.credentials="include":i.crossorigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(i){if(i.ep)return;i.ep=!0;const a=o(i);fetch(i.href,a)}})();Nt.use(sn).use(an).use(ln).init({debug:{}.NODE_ENV==="development",returnNull:!1,fallbackLng:"en",interpolation:{escapeValue:!1},react:{useSuspense:!1},load:"languageOnly",detection:{caches:["localStorage","sessionStorage","cookie"]},backend:{loadPath:vr(["/dashboard/","locales/{{lng}}.json"])}},function(t,n){B.locale(Nt.language)});Nt.on("languageChanged",t=>{B.locale(t)});Ht("zh-cn",cn);Ht("ru",dn);Ht("fa",hn);const Wt=new un,Qr=t=>{const n=document.querySelector('meta[name="theme-color"]');n==null||n.setAttribute("content",t=="dark"?"#1A202C":"#3B81F6")},Ao=pn({shadows:{outline:"0 0 0 2px var(--chakra-colors-primary-200)"},fonts:{body:"Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif"},colors:{"light-border":"#d2d2d4",primary:{50:"#9cb7f2",100:"#88a9ef",200:"#749aec",300:"#618ce9",400:"#4d7de7",500:"#396fe4",600:"#3364cd",700:"#2e59b6",800:"#284ea0",900:"#224389"},gray:{750:"#222C3B"}},components:{Alert:{baseStyle:{container:{borderRadius:"6px",fontSize:"sm"}}},Select:{baseStyle:{field:{_dark:{borderColor:"gray.600",borderRadius:"6px"},_light:{borderRadius:"6px"}}}},FormHelperText:{baseStyle:{fontSize:"xs"}},FormLabel:{baseStyle:{fontSize:"sm",fontWeight:"medium",mb:"1",_dark:{color:"gray.300"}}},Input:{baseStyle:{addon:{_dark:{borderColor:"gray.600",_placeholder:{color:"gray.500"}}},field:{_focusVisible:{boxShadow:"none",borderColor:"primary.200",outlineColor:"primary.200"},_dark:{borderColor:"gray.600",_disabled:{color:"gray.400",borderColor:"gray.500"},_placeholder:{color:"gray.500"}}}}},Table:{baseStyle:{table:{borderCollapse:"separate",borderSpacing:0},thead:{borderBottomColor:"light-border"},th:{background:"#F9FAFB",borderColor:"light-border !important",borderBottomColor:"light-border !important",borderTop:"1px solid ",borderTopColor:"light-border !important",_first:{borderLeft:"1px solid",borderColor:"light-border !important"},_last:{borderRight:"1px solid",borderColor:"light-border !important"},_dark:{borderColor:"gray.600 !important",background:"gray.750"}},td:{transition:"all .1s ease-out",borderColor:"light-border",borderBottomColor:"light-border !important",_first:{borderLeft:"1px solid",borderColor:"light-border",_dark:{borderColor:"gray.600"}},_last:{borderRight:"1px solid",borderColor:"light-border",_dark:{borderColor:"gray.600"}},_dark:{borderColor:"gray.600",borderBottomColor:"gray.600 !important"}},tr:{"&.interactive":{cursor:"pointer",_hover:{"& > td":{bg:"gray.200"},_dark:{"& > td":{bg:"gray.750"}}}},_last:{"& > td":{_first:{borderBottomLeftRadius:"8px"},_last:{borderBottomRightRadius:"8px"}}}}}}}});const vt=()=>localStorage.getItem("token"),Mo=t=>{localStorage.setItem("token",t)},No=()=>{localStorage.removeItem("token")},Fo=mn.create({baseURL:"/api/"}),Po=(t,n={})=>(vt()&&(n.headers={...(n==null?void 0:n.headers)||{},Authorization:`Bearer ${vt()}`}),Fo(t,n)),O=Po,Wo=zt(t=>({isLoading:!0,isPostLoading:!1,version:null,started:!1,logs_websocket:null,config:"",fetchCoreSettings:()=>{t({isLoading:!0}),Promise.all([O("/core").then(({version:n,started:o,logs_websocket:s})=>t({version:n,started:o,logs_websocket:s})),O("/core/config").then(n=>t({config:n}))]).finally(()=>t({isLoading:!1}))},updateConfig:n=>(t({isPostLoading:!0}),O("/core/config",{method:"PUT",body:n}).finally(()=>{t({isPostLoading:!1})})),restartCore:()=>O("/core/restart",{method:"POST"})}));function re(t,n=2,o=!1){if(!+t)return"0 B";const s=1024,i=n<0?0:n,a=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],l=Math.floor(Math.log(t)/Math.log(s));return o?[parseFloat((t/Math.pow(s,l)).toFixed(i)),a[l]]:`${parseFloat((t/Math.pow(s,l)).toFixed(i))} ${a[l]}`}const cr=t=>{if(t!==null)return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},Oo=y(gn,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),jo=y(fn,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),Ho=y(Dt,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),Lt=({title:t,content:n,icon:o})=>r(bn,{p:6,borderWidth:"1px",borderColor:"light-border",bg:"#F9FAFB",_dark:{borderColor:"gray.600",bg:"gray.750"},borderStyle:"solid",boxShadow:"none",borderRadius:"12px",width:"full",display:"flex",justifyContent:"space-between",flexDirection:"row",children:[r(_,{alignItems:"center",columnGap:"4",children:[e(D,{p:"2",position:"relative",color:"white",_before:{content:'""',position:"absolute",top:0,left:0,bg:"primary.400",display:"block",w:"full",h:"full",borderRadius:"5px",opacity:".5",z:"1"},_after:{content:'""',position:"absolute",top:"-5px",left:"-5px",bg:"primary.400",display:"block",w:"calc(100% + 10px)",h:"calc(100% + 10px)",borderRadius:"8px",opacity:".4",z:"1"},children:o}),e(h,{color:"gray.600",_dark:{color:"gray.300"},fontWeight:"medium",textTransform:"capitalize",fontSize:"sm",children:t})]}),e(D,{fontSize:"3xl",fontWeight:"semibold",mt:"2",children:n})]}),Ot="statistics-query-key",Bo=t=>{const{version:n}=E(),{data:o}=Bt({queryKey:Ot,queryFn:()=>O("/system"),refetchInterval:5e3,onSuccess:({version:i})=>{n!==i&&E.setState({version:i})}}),{t:s}=j();return r(_,{justifyContent:"space-between",gap:0,columnGap:{lg:4,md:0},rowGap:{lg:0,base:4},display:"flex",flexDirection:{lg:"row",base:"column"},...t,children:[e(Lt,{title:s("activeUsers"),content:o&&r(_,{alignItems:"flex-end",children:[e(h,{children:cr(o.users_active)}),r(h,{fontWeight:"normal",fontSize:"lg",as:"span",display:"inline-block",pb:"5px",children:["/ ",cr(o.total_user)]})]}),icon:e(Oo,{})}),e(Lt,{title:s("dataUsage"),content:o&&re(o.incoming_bandwidth+o.outgoing_bandwidth),icon:e(jo,{})}),e(Lt,{title:s("memoryUsage"),content:o&&r(_,{alignItems:"flex-end",children:[e(h,{children:re(o.mem_used,1,!0)[0]}),r(h,{fontWeight:"normal",fontSize:"lg",as:"span",display:"inline-block",pb:"5px",children:[re(o.mem_used,1,!0)[1]," /"," ",re(o.mem_total,1)]})]}),icon:e(Ho,{})})]})},qr="marzban-num-users-per-page",dr=10,$o=()=>{const t=localStorage.getItem(qr)||dr.toString();return parseInt(t)||dr},Vo=t=>localStorage.setItem(qr,t),Go=t=>{for(const n in t)t[n]||delete t[n];return E.setState({loading:!0}),O("/users",{query:t}).then(n=>(E.setState({users:n}),n)).finally(()=>{E.setState({loading:!1})})},Yo=()=>O("/inbounds").then(t=>{E.setState({inbounds:new Map(Object.entries(t))})}).finally(()=>{E.setState({loading:!1})}),E=zt(xn((t,n)=>({version:null,editingUser:null,deletingUser:null,isCreatingNewUser:!1,QRcodeLinks:null,subscribeUrl:null,users:{users:[],total:0},loading:!0,isResetingAllUsage:!1,isEditingHosts:!1,isEditingNodes:!1,isShowingNodesUsage:!1,resetUsageUser:null,revokeSubscriptionUser:null,filters:{username:"",limit:$o(),sort:"-created_at"},inbounds:new Map,isEditingCore:!1,refetchUsers:()=>{Go(n().filters)},resetAllUsage:()=>O("/users/reset",{method:"POST"}).then(()=>{n().onResetAllUsage(!1),n().refetchUsers()}),onResetAllUsage:o=>t({isResetingAllUsage:o}),onCreateUser:o=>t({isCreatingNewUser:o}),onEditingUser:o=>{t({editingUser:o})},onDeletingUser:o=>{t({deletingUser:o})},onFilterChange:o=>{t({filters:{...n().filters,...o}}),n().refetchUsers()},setQRCode:o=>{t({QRcodeLinks:o})},deleteUser:o=>(t({editingUser:null}),O(`/user/${o.username}`,{method:"DELETE"}).then(()=>{t({deletingUser:null}),n().refetchUsers(),Wt.invalidateQueries(Ot)})),createUser:o=>O("/user",{method:"POST",body:o}).then(()=>{t({editingUser:null}),n().refetchUsers(),Wt.invalidateQueries(Ot)}),editUser:o=>O(`/user/${o.username}`,{method:"PUT",body:o}).then(()=>{n().onEditingUser(null),n().refetchUsers()}),fetchUserUsage:(o,s)=>{for(const i in s)s[i]||delete s[i];return O(`/user/${o.username}/usage`,{method:"GET",query:s})},onEditingHosts:o=>{t({isEditingHosts:o})},onEditingNodes:o=>{t({isEditingNodes:o})},onShowingNodesUsage:o=>{t({isShowingNodesUsage:o})},setSubLink:o=>{t({subscribeUrl:o})},resetDataUsage:o=>O(`/user/${o.username}/reset`,{method:"POST"}).then(()=>{t({resetUsageUser:null}),n().refetchUsers()}),revokeSubscription:o=>O(`/user/${o.username}/revoke_sub`,{method:"POST"}).then(s=>{t({revokeSubscriptionUser:null,editingUser:s}),n().refetchUsers()})}))),de=({children:t,color:n})=>e(D,{position:"relative",width:"36px",height:"36px",display:"flex",justifyContent:"center",alignItems:"center",_before:{content:'""',display:"block",position:"absolute",top:"0",left:"0",width:"calc(100%)",height:"calc(100%)",bg:`${n}.400`,opacity:".5",borderRadius:"5px",zIndex:"1",_dark:{bg:`${n}.400`}},_after:{content:'""',display:"block",position:"absolute",top:"0",left:"0",width:"calc(100% + 10px)",height:"calc(100% + 10px)",transform:"translate(-5px, -5px)",bg:`${n}.400`,opacity:".4",borderRadius:"8px",zIndex:"1",_dark:{bg:`${n}.400`}},children:e(h,{color:`${n}.500`,_dark:{color:`${n}.900`},position:"relative",zIndex:"2",children:t})});window.ace.define("ace/theme/nord_dark",["require","exports","module","ace/lib/dom"],(t,n,o)=>{n.isDark=!0,n.cssClass="ace-nord-dark",t("../lib/dom").importCssString(n.cssText,n.cssClass)});window.ace.define("ace/theme/dawn",["require","exports","module","ace/lib/dom"],(t,n,o)=>{n.isDark=!1,n.cssClass="ace-dawn",t("../lib/dom").importCssString(n.cssText,n.cssClass)});const Zo=f.exports.forwardRef(({json:t,onChange:n,mode:o="code"},s)=>{const{colorMode:i}=ht(),a={mode:o,onChangeText:n,statusBar:!1,mainMenuBar:!1,theme:i==="dark"?"ace/theme/nord_dark":"ace/theme/dawn"},l=f.exports.useRef(null),u=f.exports.useRef(null);return f.exports.useEffect(()=>(u.current=new yn(l.current,a),()=>{u.current&&u.current.destroy()}),[]),f.exports.useEffect(()=>{u.current&&u.current.update(t)},[t]),e(D,{ref:s,border:"1px solid",borderColor:"gray.300",_dark:{borderColor:"gray.500"},borderRadius:5,h:"full",children:e(D,{height:"full",ref:l})})}),hr=500,Qo=y(Ir,{baseStyle:{w:5,h:5}}),qo=y(Et,{baseStyle:{w:4,h:4}}),Xo=y(Sn,{baseStyle:{w:4,h:4}}),Jo=y(Cn,{baseStyle:{w:3,h:3}}),Ko=t=>({[rt.ReadyState.CONNECTING]:"connecting",[rt.ReadyState.OPEN]:"connected",[rt.ReadyState.CLOSING]:"closed",[rt.ReadyState.CLOSED]:"closed",[rt.ReadyState.UNINSTANTIATED]:"closed"})[t],es=()=>{try{let t=new URL("/api/".startsWith("/")?window.location.origin+"/api/":"/api/");return(t.protocol==="https:"?"wss://":"ws://")+vr([t.host+t.pathname,"/core/logs"])+"?interval=1&token="+vt()}catch(t){return console.error("Unable to generate websocket url"),console.error(t),null}};let Le=[];const ts=()=>{const{isEditingCore:t}=E(),{fetchCoreSettings:n,updateConfig:o,isLoading:s,config:i,isPostLoading:a,version:l,restartCore:u}=Wo(),p=f.exports.useRef(null),[C,d]=f.exports.useState([]),{t:c}=j(),w=fe(),v=Ve({defaultValues:{config:i||{}}});f.exports.useEffect(()=>{i&&v.setValue("config",i)},[i]),f.exports.useEffect(()=>{t&&n()},[t]);const m=f.exports.useRef(!0),S=f.exports.useCallback(zr(L=>{var J,z,P;const V=Math.abs((((J=p.current)==null?void 0:J.scrollTop)||0)-(((z=p.current)==null?void 0:z.scrollHeight)||0)+(((P=p.current)==null?void 0:P.offsetHeight)||0))<10;p.current&&V?m.current=!0:m.current=!1,L.length<40&&d(L)},300),[]),{readyState:T}=wn(es(),{onMessage:L=>{Le.push(L.data),Le.length>hr&&(Le=Le.splice(0,Le.length-hr)),S([...Le])},shouldReconnect:()=>!0,reconnectAttempts:10,reconnectInterval:1e3});f.exports.useEffect(()=>{var L;p.current&&m.current&&(p.current.scrollTop=(L=p.current)==null?void 0:L.scrollHeight)},[C]),f.exports.useEffect(()=>()=>{Le=[]},[]);const g=Ko(T.toString()),{mutate:b,isLoading:W}=lt(u),$=({config:L})=>{o(L).then(()=>{w({title:c("core.successMessage"),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(V=>{let J=c("core.generalErrorMessage");typeof V.response._data.detail=="object"&&(J=V.response._data.detail[Object.keys(V.response._data.detail)[0]]),typeof V.response._data.detail=="string"&&(J=V.response._data.detail),w({title:J,status:"error",isClosable:!0,position:"top",duration:3e3})})},I=f.exports.useRef(null),[A,Y]=f.exports.useState(!1),q=()=>{var L;document.fullscreenElement?(document.exitFullscreen(),Y(!1)):((L=I.current)==null||L.requestFullscreen(),Y(!0))};return r("form",{onSubmit:v.handleSubmit($),children:[r(ce,{children:[r(R,{children:[r(_,{justifyContent:"space-between",alignItems:"flex-start",children:[r(H,{children:[c("core.configuration")," ",s&&e(Dr,{isIndeterminate:!0,size:"15px"})]}),e(_,{gap:0,children:e(ne,{label:"Xray Version",placement:"top",children:e(U,{height:"100%",textTransform:"lowercase",children:l&&`v${l}`})})})]}),r(D,{position:"relative",ref:I,minHeight:"300px",children:[e(pe,{control:v.control,name:"config",render:({field:L})=>e(Zo,{json:i,onChange:L.onChange})}),e(Z,{size:"xs","aria-label":"full screen",variant:"ghost",position:"absolute",top:"2",right:"4",onClick:q,children:A?e(Jo,{}):e(Xo,{})})]})]}),r(R,{mt:"4",children:[r(_,{justifyContent:"space-between",children:[e(H,{children:c("core.logs")}),e(h,{as:H,children:c(`core.socket.${g}`)})]}),e(D,{border:"1px solid",borderColor:"gray.300",bg:"#F9F9F9",_dark:{borderColor:"gray.500",bg:"#2e3440"},borderRadius:5,minHeight:"200px",maxHeight:"250px",p:2,overflowY:"auto",ref:p,children:C.map((L,V)=>e(h,{fontSize:"xs",opacity:.8,whiteSpace:"pre-line",children:L},V))})]})]}),e(Re,{children:r(_,{w:"full",justifyContent:"space-between",children:[e(D,{children:e(F,{size:"sm",leftIcon:e(qo,{className:Ut({"animate-spin":W})}),onClick:()=>b(),children:c(W?"core.restarting":"core.restartCore")})}),e(_,{children:e(F,{size:"sm",variant:"solid",colorScheme:"primary",px:"5",type:"submit",isDisabled:s||a,isLoading:a,children:c("core.save")})})]})})]})},rs=()=>{const{isEditingCore:t}=E(),n=E.setState.bind(null,{isEditingCore:!1}),{t:o}=j();return r(oe,{isOpen:t,onClose:n,size:"3xl",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"full",children:[e(ie,{pt:6,children:r(_,{gap:2,children:[e(de,{color:"primary",children:e(Qo,{color:"white"})}),e(h,{fontWeight:"semibold",fontSize:"lg",children:o("core.title")})]})}),e(le,{mt:3}),e(ts,{})]})]})},mt=y(_n,{baseStyle:{w:5,h:5}}),ns=()=>{const[t,n]=f.exports.useState(!1),{deletingUser:o,onDeletingUser:s,deleteUser:i}=E(),{t:a}=j(),l=fe(),u=()=>{s(null)},p=()=>{o&&(n(!0),i(o).then(()=>{l({title:a("deleteUser.deleteSuccess",{username:o.username}),status:"success",isClosable:!0,position:"top",duration:3e3})}).then(u).finally(n.bind(null,!1)))};return r(oe,{isCentered:!0,isOpen:!!o,onClose:u,size:"sm",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",children:[e(ie,{pt:6,children:e(de,{color:"red",children:e(mt,{})})}),e(le,{mt:3}),r(ce,{children:[e(h,{fontWeight:"semibold",fontSize:"lg",children:a("deleteUser.title")}),o&&e(h,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(Ee,{components:{b:e("b",{})},children:a("deleteUser.prompt",{username:o.username})})})]}),r(Re,{display:"flex",children:[e(F,{size:"sm",onClick:u,mr:3,w:"full",variant:"outline",children:a("cancel")}),e(F,{size:"sm",w:"full",colorScheme:"red",onClick:p,leftIcon:t?e(Ne,{size:"xs"}):void 0,children:a("delete")})]})]})]})},Zt={baseStyle:{w:4,h:4}},os=y(kn,Zt),ss=y(Er,Zt),Xr=y(Et,Zt),as=zr(t=>{E.getState().onFilterChange({...E.getState().filters,offset:0,search:t})},300),is=({...t})=>{const{loading:n,filters:o,onFilterChange:s,refetchUsers:i,onCreateUser:a}=E(),{t:l}=j(),[u,p]=f.exports.useState(""),C=c=>{p(c.target.value),as(c.target.value)},d=()=>{p(""),s({...o,offset:0,search:""})};return r(Ur,{id:"filters",templateColumns:{lg:"repeat(3, 1fr)",md:"repeat(4, 1fr)",base:"repeat(1, 1fr)"},position:"sticky",top:0,mx:"-6",px:"6",rowGap:4,gap:{lg:4,base:0},bg:"var(--chakra-colors-chakra-body-bg)",py:4,zIndex:"docked",...t,children:[e(st,{colSpan:{base:1,md:2,lg:1},order:{base:2,md:1},children:r(St,{children:[e(vn,{pointerEvents:"none",children:e(os,{})}),e(je,{placeholder:l("search"),value:u,borderColor:"light-border",onChange:C}),r(Ct,{children:[n&&e(Ne,{size:"xs"}),o.search&&o.search.length>0&&e(Z,{onClick:d,"aria-label":"clear",size:"xs",variant:"ghost",children:e(ss,{})})]})]})}),e(st,{colSpan:2,order:{base:1,md:2},children:r(_,{justifyContent:"flex-end",alignItems:"center",h:"full",children:[e(Z,{"aria-label":"refresh users",disabled:n,onClick:i,size:"sm",variant:"outline",children:e(Xr,{className:Ut({"animate-spin":n})})}),e(F,{colorScheme:"primary",size:"sm",onClick:()=>a(!0),px:5,children:l("createUser")})]})})]})},Jr="https://github.com/Gozargah/Marzban",ls="https://github.com/Gozargah",cs="https://github.com/Gozargah/Marzban#donation",Kr=t=>{const{version:n}=E();return e(_,{w:"full",py:"0",position:"relative",...t,children:r(h,{display:"inline-block",flexGrow:1,textAlign:"center",color:"gray.500",fontSize:"xs",children:[e(Jt,{color:"blue.400",href:Jr,children:"Marzban"}),n?` (v${n}), `:", ","Made with \u2764\uFE0F in"," ",e(Jt,{color:"blue.400",href:ls,children:"Gozargah"})]})})},ds=y(In,{baseStyle:{w:4,h:4}}),en=({actions:t})=>{const{i18n:n}=j();var o=s=>{n.changeLanguage(s)};return r(Rr,{placement:"bottom-end",children:[e(Lr,{as:Z,size:"sm",variant:"outline",icon:e(ds,{}),position:"relative"}),r(Tr,{minW:"100px",zIndex:9999,children:[e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("en"),children:"English"}),e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("fa"),children:"\u0641\u0627\u0631\u0633\u06CC"}),e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("zh-cn"),children:"\u7B80\u4F53\u4E2D\u6587"}),e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("ru"),children:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"})]})]})},be={baseStyle:{w:4,h:4}},hs=y(zn,be),us=y(Dn,be),ps=y(Ir,be),ms=y(En,be),gs=y(Un,be),fs=y(Rn,be),bs=y($t,be),xs=y(Ar,be),ys=y(Dt,be),Ss=y(Mr,be),ur=y(D,{baseStyle:{bg:"yellow.500",w:"2",h:"2",rounded:"full",position:"absolute"}}),tn="marzban-menu-notification",Cs=()=>{const t=localStorage.getItem(tn);if(!t)return!0;try{return t&&Tn(parseInt(t))?An(new Date,new Date(parseInt(t)))>=7:!0}catch{return!0}},ws=({actions:t})=>{const{onEditingHosts:n,onResetAllUsage:o,onEditingNodes:s,onShowingNodesUsage:i}=E(),{t:a}=j(),{colorMode:l,toggleColorMode:u}=ht(),[p,C]=f.exports.useState(Cs()),d=l==="dark"?"dark_dimmed":l,c=()=>{localStorage.setItem(tn,new Date().getTime().toString()),C(!1)};return r(_,{gap:2,justifyContent:"space-between",__css:{"& .menuList":{direction:"ltr"}},position:"relative",children:[e(h,{as:"h1",fontWeight:"semibold",fontSize:"2xl",children:a("users")}),p&&e(ur,{top:"0",right:"0",zIndex:9999}),e(D,{overflow:"auto",css:{direction:"rtl"},children:r(_,{alignItems:"center",children:[r(Rr,{children:[e(Lr,{as:Z,size:"sm",variant:"outline",icon:e(ge,{children:e(ms,{})}),position:"relative"}),r(Tr,{minW:"170px",zIndex:99999,className:"menuList",children:[e(me,{maxW:"170px",fontSize:"sm",icon:e(bs,{}),onClick:n.bind(null,!0),children:a("header.hostSettings")}),e(me,{maxW:"170px",fontSize:"sm",icon:e(xs,{}),onClick:s.bind(null,!0),children:a("header.nodeSettings")}),e(me,{maxW:"170px",fontSize:"sm",icon:e(ys,{}),onClick:i.bind(null,!0),children:a("header.nodesUsage")}),e(me,{maxW:"170px",fontSize:"sm",icon:e(Ss,{}),onClick:o.bind(null,!0),children:a("resetAllUsage")}),e(Kt,{to:cs,target:"_blank",children:r(me,{maxW:"170px",fontSize:"sm",icon:e(fs,{}),position:"relative",onClick:c,children:[a("header.donation")," ",p&&e(ur,{top:"3",right:"2"})]})}),e(Kt,{to:"/login",children:e(me,{maxW:"170px",fontSize:"sm",icon:e(gs,{}),children:a("header.logout")})})]})]}),e(Z,{size:"sm",variant:"outline","aria-label":"core settings",onClick:()=>{E.setState({isEditingCore:!0})},children:e(ps,{})}),e(en,{}),e(Z,{size:"sm",variant:"outline","aria-label":"switch theme",onClick:()=>{Qr(l=="dark"?"light":"dark"),u()},children:l==="light"?e(hs,{}):e(us,{})}),e(D,{css:{direction:"ltr"},display:"flex",alignItems:"center",pr:"2",__css:{"& span":{display:"inline-flex"}},children:e(Ln,{href:Jr,"data-color-scheme":`no-preference: ${d}; light: ${d}; dark: ${d};`,"data-size":"large","data-show-count":"true","aria-label":"Star Marzban on GitHub",children:"Star"})})]})})]})},_s=[{title:"Inbound's default",value:"inbound_default"},{title:"TLS",value:"tls"},{title:"None",value:"none"}],ks=[{title:"",value:""},{title:"h3",value:"h3"},{title:"h2",value:"h2"},{title:"http/1.1",value:"http/1.1"},{title:"h3,h2,http/1.1",value:"h3,h2,http/1.1"},{title:"h3,h2",value:"h3,h2"},{title:"h2,http/1.1",value:"h2,http/1.1"}],vs=[{title:"",value:""},...["chrome","firefox","safari","ios","android","edge","360","qq","random","randomized"].map(t=>({title:t,value:t}))],Is=[{title:"none",value:""},{title:"xtls-rprx-vision",value:"xtls-rprx-vision"}],zs=["aes-128-gcm","aes-256-gcm","chacha20-ietf-poly1305"],Ds=zt(t=>({isLoading:!1,isPostLoading:!1,hosts:{},fetchHosts:()=>{t({isLoading:!0}),O("/hosts").then(n=>t({hosts:n})).finally(()=>t({isLoading:!1}))},setHosts:n=>(t({isPostLoading:!0}),O("/hosts",{method:"PUT",body:n}).finally(()=>{t({isPostLoading:!1})}))}));const Es=y(Er,{baseStyle:{w:4,h:4}}),Ue=Ft.forwardRef(({disabled:t,step:n,label:o,className:s,startAdornment:i,endAdornment:a,type:l="text",placeholder:u,onChange:p,onBlur:C,name:d,value:c,onClick:w,error:v,clearable:m=!1,...S},T)=>{const g=()=>{p&&p({target:{value:"",name:d}})},{size:b="md"}=S,W=l=="number"?jn:je,$=l=="number"?Mn:Ft.Fragment,I=l=="number"?{keepWithinRange:!0,precision:5,format:A=>isNaN(parseFloat(String(A)))||Number(parseFloat(String(A)).toFixed(5))===0?A:Number(parseFloat(String(A)).toFixed(5)),min:0,step:n,name:d,type:l,placeholder:u,onChange:A=>{p&&p(A)},onBlur:C,value:c,onClick:w,disabled:t,flexGrow:1,size:b}:{};return r(R,{isInvalid:!!v,children:[o&&e(H,{children:o}),r(St,{size:b,w:"full",rounded:"md",_focusWithin:{outline:"2px solid",outlineColor:"primary.200"},bg:t?"gray.100":"transparent",_dark:{bg:t?"gray.600":"transparent"},children:[i&&e(Nn,{children:i}),r($,{...I,children:[e(W,{name:d,ref:T,step:n,className:Ut(s),type:l,placeholder:u,onChange:p,onBlur:C,value:c,onClick:w,disabled:t,flexGrow:1,_focusVisible:{outline:"none",borderTopColor:"transparent",borderRightColor:"transparent",borderBottomColor:"transparent"},_disabled:{cursor:"not-allowed"},...S,roundedLeft:i?"0":"md",roundedRight:a?"0":"md"}),l=="number"&&e(ge,{children:r(Fn,{children:[e(Pn,{}),e(Wn,{})]})})]}),a&&e(On,{borderLeftRadius:0,borderRightRadius:"6px",bg:"transparent",children:a}),m&&c&&c.length&&e(Ct,{borderLeftRadius:0,borderRightRadius:"6px",bg:"transparent",onClick:g,cursor:"pointer",children:e(Es,{})})]}),!!v&&e(wt,{children:v})]})}),Tt=y(Me,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Te=y(Ue,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Us=y($t,{baseStyle:{w:5,h:5}}),De=y(Hn,{baseStyle:{w:4,h:4,color:"gray.400",cursor:"pointer"}}),Rs=x.record(x.string().min(1),x.array(x.object({remark:x.string().min(1,"Remark is required"),address:x.string().min(1,"Address is required"),port:x.string().or(x.number()).nullable().transform(t=>typeof t=="number"?t:t!==null&&!isNaN(parseInt(t))?Number(parseInt(t)):null),path:x.string().nullable(),sni:x.string().nullable(),host:x.string().nullable(),mux_enable:x.boolean().default(!1),allowinsecure:x.boolean().nullable().default(!1),is_disabled:x.boolean().default(!0),fragment_setting:x.string().nullable(),random_user_agent:x.boolean().default(!1),security:x.string(),alpn:x.string(),fingerprint:x.string()}))),Se=y(wt,{baseStyle:{color:"red.400",display:"block",textAlign:"left",w:"100%"}}),Ls=({hostKey:t,isOpen:n,toggleAccordion:o})=>{const{inbounds:s}=E(),i=[...s.values()].flat().filter(v=>v.tag===t)[0],a=Vt(),{fields:l,append:u,remove:p}=Bn({control:a.control,name:t}),{errors:C}=a.formState,{t:d}=j(),c=C[t],w=()=>{u({host:"",sni:"",port:null,path:null,address:"",remark:"",mux_enable:!1,allowinsecure:!1,is_disabled:!1,fragment_setting:"",random_user_agent:!1,security:"inbound_default",alpn:"",fingerprint:""})};return f.exports.useEffect(()=>{c&&!n&&o()},[c]),r(He,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[r(Be,{px:2,borderRadius:"3px",onClick:o,children:[e(h,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},children:t}),e(Pt,{})]}),e($e,{px:2,pb:2,children:r(N,{gap:3,children:[l.map((v,m)=>{var S,T,g,b,W,$,I,A,Y,q,L,V,J,z,P,K,Fe,bt,xt,ee,Pe,Ye,Ze,Qe,qe,Xe,k,M,te,xe,he,ye,G,Je,Ke,et,tt;return r(N,{border:"1px solid",_dark:{borderColor:"gray.600",bg:"#273142"},_light:{borderColor:"gray.200",bg:"#fcfbfb"},p:2,w:"full",borderRadius:"4px",children:[e(_,{w:"100%",alignItems:"flex-start",children:r(R,{position:"relative",zIndex:10,isInvalid:!!(c&&((S=c[m])==null?void 0:S.remark)),children:[r(St,{children:[e(Te,{...a.register(t+"."+m+".remark"),size:"sm",borderRadius:"4px",placeholder:"Remark"}),e(Ct,{children:r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(D,{mt:"-8px",children:e(De,{})})}),e(_e,{children:r(ke,{children:[e(ve,{}),e(Ie,{}),e(er,{children:r(D,{fontSize:"xs",children:[e(h,{pr:"20px",children:d("hostsDialog.desc")}),r(h,{children:[r(U,{children:["{","SERVER_IP","}"]})," ",d("hostsDialog.currentServer")]}),r(h,{mt:1,children:[r(U,{children:["{","SERVER_IPV6","}"]})," ",d("hostsDialog.currentServerv6")]}),r(h,{mt:1,children:[r(U,{children:["{","USERNAME","}"]})," ",d("hostsDialog.username")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_USAGE","}"]})," ",d("hostsDialog.dataUsage")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LEFT","}"]})," ",d("hostsDialog.remainingData")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LIMIT","}"]})," ",d("hostsDialog.dataLimit")]}),r(h,{mt:1,children:[r(U,{children:["{","DAYS_LEFT","}"]})," ",d("hostsDialog.remainingDays")]}),r(h,{mt:1,children:[r(U,{children:["{","EXPIRE_DATE","}"]})," ",d("hostsDialog.expireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","JALALI_EXPIRE_DATE","}"]})," ",d("hostsDialog.jalaliExpireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","TIME_LEFT","}"]})," ",d("hostsDialog.remainingTime")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_TEXT","}"]})," ",d("hostsDialog.statusText")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_EMOJI","}"]})," ",d("hostsDialog.statusEmoji")]}),r(h,{mt:1,children:[r(U,{children:["{","PROTOCOL","}"]})," ",d("hostsDialog.proxyProtocol")]}),r(h,{mt:1,children:[r(U,{children:["{","TRANSPORT","}"]})," ",d("hostsDialog.proxyMethod")]})]})})]})})]})})]}),c&&((T=c[m])==null?void 0:T.remark)&&e(Se,{children:(b=(g=c[m])==null?void 0:g.remark)==null?void 0:b.message})]})}),r(R,{isInvalid:!!(c&&((W=c[m])==null?void 0:W.address)),children:[r(St,{children:[e(Te,{size:"sm",borderRadius:"4px",placeholder:"Address (e.g. example.com)",...a.register(t+"."+m+".address")}),e(Ct,{children:r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(D,{mt:"-8px",children:e(De,{})})}),e(_e,{children:r(ke,{children:[e(ve,{}),e(Ie,{}),e(er,{children:r(D,{fontSize:"xs",children:[e(h,{pr:"20px",children:d("hostsDialog.desc")}),r(h,{children:[r(U,{children:["{","SERVER_IP","}"]})," ",d("hostsDialog.currentServer")]}),r(h,{mt:1,children:[r(U,{children:["{","SERVER_IPV6","}"]})," ",d("hostsDialog.currentServerv6")]}),r(h,{mt:1,children:[r(U,{children:["{","USERNAME","}"]})," ",d("hostsDialog.username")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_USAGE","}"]})," ",d("hostsDialog.dataUsage")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LEFT","}"]})," ",d("hostsDialog.remainingData")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LIMIT","}"]})," ",d("hostsDialog.dataLimit")]}),r(h,{mt:1,children:[r(U,{children:["{","DAYS_LEFT","}"]})," ",d("hostsDialog.remainingDays")]}),r(h,{mt:1,children:[r(U,{children:["{","EXPIRE_DATE","}"]})," ",d("hostsDialog.expireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","JALALI_EXPIRE_DATE","}"]})," ",d("hostsDialog.jalaliExpireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","TIME_LEFT","}"]})," ",d("hostsDialog.remainingTime")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_TEXT","}"]})," ",d("hostsDialog.statusText")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_EMOJI","}"]})," ",d("hostsDialog.statusEmoji")]}),r(h,{mt:1,children:[r(U,{children:["{","PROTOCOL","}"]})," ",d("hostsDialog.proxyProtocol")]}),r(h,{mt:1,children:[r(U,{children:["{","TRANSPORT","}"]})," ",d("hostsDialog.proxyMethod")]})]})})]})})]})})]}),c&&(($=c[m])==null?void 0:$.address)&&e(Se,{children:(A=(I=c[m])==null?void 0:I.address)==null?void 0:A.message})]}),e(pt,{w:"full",allowToggle:!0,children:r(He,{border:"0",children:[r(Be,{display:"flex",px:0,py:1,borderRadius:3,_hover:{bg:"transparent"},children:[r(h,{flex:"3",align:"start",fontSize:"xs",color:"gray.600",_dark:{color:"gray.500"},pl:1,children:[d("hostsDialog.advancedOptions"),e(Pt,{fontSize:"sm",ml:1})]}),r($n,{flex:"1",px:"0",children:[e(pe,{control:a.control,name:`${t}.${m}.is_disabled`,render:({field:Q})=>e(_t,{mx:"1.5",colorScheme:"primary",...Q,value:void 0,isChecked:!Q.value,onChange:We=>{console.log(We.target.checked),Q.onChange(!We.target.checked)}})}),e(ne,{label:"Delete",placement:"top",children:e(Z,{"aria-label":"Delete",size:"sm",colorScheme:"red",variant:"ghost",onClick:p.bind(null,m),children:e(mt,{})})})]})]}),e($e,{w:"full",p:1,children:r(N,{w:"full",borderRadius:"4px",children:[r(R,{isInvalid:!!(c&&((Y=c[m])==null?void 0:Y.port)),children:[r(H,{display:"flex",pb:1,alignItems:"center",justifyContent:"space-between",gap:1,m:"0",children:[e("span",{children:d("hostsDialog.port")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.port.info")})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:String(i.port||"8080"),type:"number",...a.register(t+"."+m+".port")})]}),r(R,{isInvalid:!!(c&&((q=c[m])==null?void 0:q.sni)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.sni")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.sni.info")}),e(h,{fontSize:"xs",mt:"2",children:e(Ee,{i18nKey:"hostsDialog.host.wildcard",components:{badge:e(U,{})}})}),e(h,{fontSize:"xs",children:e(Ee,{i18nKey:"hostsDialog.host.multiHost",components:{badge:e(U,{})}})})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"SNI (e.g. example.com)",...a.register(t+"."+m+".sni")}),c&&((L=c[m])==null?void 0:L.sni)&&e(Se,{children:(J=(V=c[m])==null?void 0:V.sni)==null?void 0:J.message})]}),r(R,{isInvalid:!!(c&&((z=c[m])==null?void 0:z.host)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.host")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.host.info")}),e(h,{fontSize:"xs",mt:"2",children:e(Ee,{i18nKey:"hostsDialog.host.wildcard",components:{badge:e(U,{})}})}),e(h,{fontSize:"xs",children:e(Ee,{i18nKey:"hostsDialog.host.multiHost",components:{badge:e(U,{})}})})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"Host (e.g. example.com)",...a.register(t+"."+m+".host")}),c&&((P=c[m])==null?void 0:P.host)&&e(Se,{children:(Fe=(K=c[m])==null?void 0:K.host)==null?void 0:Fe.message})]}),r(R,{isInvalid:!!(c&&((bt=c[m])==null?void 0:bt.path)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.path")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.path.info")})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"path (e.g. /vless)",...a.register(t+"."+m+".path")}),c&&((xt=c[m])==null?void 0:xt.path)&&e(Se,{children:(Pe=(ee=c[m])==null?void 0:ee.path)==null?void 0:Pe.message})]}),r(R,{height:"66px",children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.security")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.security.info")})]})})]})]}),e(Tt,{size:"sm",...a.register(t+"."+m+".security"),children:_s.map(Q=>e("option",{value:Q.value,children:Q.title},Q.value))})]}),r(R,{height:"66px",children:[e(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:e("span",{children:d("hostsDialog.alpn")})}),e(Tt,{size:"sm",...a.register(t+"."+m+".alpn"),children:ks.map(Q=>e("option",{value:Q.value,children:Q.title},Q.value))})]}),r(R,{height:"66px",children:[e(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:e("span",{children:d("hostsDialog.fingerprint")})}),e(Tt,{size:"sm",...a.register(t+"."+m+".fingerprint"),children:vs.map(Q=>e("option",{value:Q.value,children:Q.title},Q.value))})]}),r(R,{isInvalid:!!(c&&((Ye=c[m])==null?void 0:Ye.fragment_setting)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.fragment")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.fragment.info")}),e(h,{fontSize:"xs",pr:5,pt:2,pb:1,children:d("hostsDialog.fragment.info.examples")}),e(h,{fontSize:"xs",pr:5,children:"100-200,10-20,tlshello"}),e(h,{fontSize:"xs",pr:5,children:"100-200,10-20,1-3"}),e(h,{fontSize:"xs",pr:5,pt:"3",children:d("hostsDialog.fragment.info.attention")})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"Fragment settings by pattern",...a.register(t+"."+m+".fragment_setting")}),c&&((Ze=c[m])==null?void 0:Ze.fragment_setting)&&e(Se,{children:(qe=(Qe=c[m])==null?void 0:Qe.fragment_setting)==null?void 0:qe.message})]}),e(R,{isInvalid:!!(c&&((Xe=c[m])==null?void 0:Xe.allowinsecure)),children:r(at,{...a.register(t+"."+m+".allowinsecure"),name:t+"."+m+".allowinsecure",children:[e(H,{children:d("hostsDialog.allowinsecure")}),c&&((k=c[m])==null?void 0:k.allowinsecure)&&e(Se,{children:(te=(M=c[m])==null?void 0:M.allowinsecure)==null?void 0:te.message})]})}),r(R,{isInvalid:!!(c&&((xe=c[m])==null?void 0:xe.mux_enable)),children:[e(at,{...a.register(t+"."+m+".mux_enable"),children:e(H,{children:d("hostsDialog.muxEnable")})}),c&&((he=c[m])==null?void 0:he.mux_enable)&&e(Se,{children:(G=(ye=c[m])==null?void 0:ye.mux_enable)==null?void 0:G.message})]}),r(R,{isInvalid:!!(c&&((Je=c[m])==null?void 0:Je.random_user_agent)),children:[e(at,{...a.register(t+"."+m+".random_user_agent"),children:e(H,{children:d("hostsDialog.randomUserAgent")})}),c&&((Ke=c[m])==null?void 0:Ke.random_user_agent)&&e(Se,{children:(tt=(et=c[m])==null?void 0:et.random_user_agent)==null?void 0:tt.message})]})]},m)})]})})]},m)}),e(F,{variant:"outline",w:"full",size:"sm",color:"",fontWeight:"normal",onClick:w,children:d("hostsDialog.addHost")})]})})]})},Ts=()=>{const{isEditingHosts:t,onEditingHosts:n,refetchUsers:o,inbounds:s}=E(),{isLoading:i,hosts:a,fetchHosts:l,isPostLoading:u,setHosts:p}=Ds(),C=fe(),{t:d}=j(),[c,w]=f.exports.useState({});f.exports.useEffect(()=>{t&&l()},[t]);const v=Ve({resolver:ut(Rs)});f.exports.useEffect(()=>{a&&t&&v.reset(a)},[a]);const m=()=>{w({}),n(!1)},S=g=>{p(g).then(()=>{C({title:d("hostsDialog.savedSuccess"),status:"success",isClosable:!0,position:"top",duration:3e3}),o()}).catch(b=>{var W,$,I,A,Y;(((W=b==null?void 0:b.response)==null?void 0:W.status)===409||(($=b==null?void 0:b.response)==null?void 0:$.status)===400)&&C({title:(A=(I=b.response)==null?void 0:I._data)==null?void 0:A.detail,status:"error",isClosable:!0,position:"top",duration:3e3}),((Y=b==null?void 0:b.response)==null?void 0:Y.status)===422&&Object.keys(b.response._data.detail).forEach(q=>{C({title:b.response._data.detail[q]+" ("+q+")",status:"error",isClosable:!0,position:"top",duration:3e3})})})},T=g=>{c[String(g)]?delete c[String(g)]:c[String(g)]={},w({...c})};return r(oe,{isOpen:t,onClose:m,children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(ie,{pt:6,children:e(de,{color:"primary",children:e(Us,{color:"white"})})}),e(le,{mt:3}),e(ce,{w:"440px",pb:3,pt:3,children:e(Nr,{...v,children:r("form",{onSubmit:v.handleSubmit(S),children:[e(h,{mb:3,opacity:.8,fontSize:"sm",children:d("hostsDialog.title")}),i&&d("hostsDialog.loading"),!i&&a&&(Object.keys(a).length>0?e(pt,{w:"full",allowToggle:!0,allowMultiple:!0,index:Object.keys(c).map(g=>parseInt(g)),children:e(N,{w:"full",children:Object.keys(a).map((g,b)=>e(Ls,{toggleAccordion:()=>T(b),isOpen:c[String(b)],hostKey:g},g))})}):"No inbound found. Please check your Xray config file."),e(_,{justifyContent:"flex-end",py:2,children:e(F,{variant:"solid",mt:"2",type:"submit",colorScheme:"primary",size:"sm",px:5,isLoading:u,disabled:u,children:d("hostsDialog.apply")})})]})})})]})]})},rn=x.object({name:x.string().min(1),address:x.string().min(1),port:x.number().min(1).or(x.string().transform(t=>parseFloat(t))),api_port:x.number().min(1).or(x.string().transform(t=>parseFloat(t))),xray_version:x.string().nullable().optional(),id:x.number().nullable().optional(),status:x.enum(["connected","connecting","error","disabled"]).nullable().optional(),message:x.string().nullable().optional(),add_as_new_host:x.boolean().optional(),usage_coefficient:x.number().or(x.string().transform(t=>parseFloat(t)))}),As=()=>({name:"",address:"",port:62050,api_port:62051,xray_version:"",usage_coefficient:1}),dt="fetch-nodes-query-key",Ms=()=>{const{isEditingNodes:t}=E();return Bt({queryKey:dt,queryFn:gt.getState().fetchNodes,refetchInterval:t?3e3:void 0,refetchOnWindowFocus:!1})},gt=zt((t,n)=>({nodes:[],addNode(o){return O("/node",{method:"POST",body:o})},fetchNodes(){return O("/nodes")},fetchNodesUsage(o){return O("/nodes/usage",{query:o})},updateNode(o){return O(`/node/${o.id}`,{method:"PUT",body:o})},setDeletingNode(o){t({deletingNode:o})},reconnectNode(o){return O(`/node/${o.id}/reconnect`,{method:"POST"})},deleteNode:()=>{var o;return O(`/node/${(o=n().deletingNode)==null?void 0:o.id}`,{method:"DELETE"})}})),Qt=(t,n,o)=>{if(t.response&&t.response._data){if(typeof t.response._data.detail=="string")return n({title:t.response._data.detail,status:"error",isClosable:!0,position:"top",duration:3e3});if(typeof t.response._data.detail=="object"&&o){Object.keys(t.response._data.detail).forEach(s=>o.setError(s,{message:t.response._data.detail[s]}));return}}return n({title:"Something went wrong!",status:"error",isClosable:!0,position:"top",duration:3e3})},qt=(t,n)=>n({title:t,status:"success",isClosable:!0,position:"top",duration:3e3}),Ns=({deleteCallback:t})=>{const{deleteNode:n,deletingNode:o,setDeletingNode:s}=gt(),{t:i}=j(),a=fe(),l=Gt(),u=()=>{s(null)},{isLoading:p,mutate:C}=lt(n,{onSuccess:()=>{qt(i("deleteNode.deleteSuccess",{name:o&&o.name}),a),s(null),l.invalidateQueries(dt),t&&t()},onError:d=>{Qt(d,a)}});return r(oe,{isCentered:!0,isOpen:!!o,onClose:u,size:"sm",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",children:[e(ie,{pt:6,children:e(de,{color:"red",children:e(mt,{})})}),e(le,{mt:3}),r(ce,{children:[e(h,{fontWeight:"semibold",fontSize:"lg",children:i("deleteNode.title")}),o&&e(h,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(Ee,{components:{b:e("b",{})},children:i("deleteNode.prompt",{name:o.name})})})]}),r(Re,{display:"flex",children:[e(F,{size:"sm",onClick:u,mr:3,w:"full",variant:"outline",children:i("cancel")}),e(F,{size:"sm",w:"full",colorScheme:"red",onClick:()=>C(),leftIcon:p?e(Ne,{size:"xs"}):void 0,children:i("delete")})]})]})]})},ft={baseStyle:{strokeWidth:"2px",w:4,h:4}},pr=y(Vn,ft),Fs=y(Gn,ft),mr=y(Yn,ft),gr=y(Fr,ft),Ps=y(Fr,ft),jt=[{title:"No",value:"no_reset"},{title:"Daily",value:"day"},{title:"Weekly",value:"week"},{title:"Monthly",value:"month"},{title:"Annually",value:"year"}],it={active:{statusColor:"green",bandWidthColor:"primary",icon:pr},connected:{statusColor:"green",bandWidthColor:"primary",icon:pr},disabled:{statusColor:"gray",bandWidthColor:"gray",icon:Fs},expired:{statusColor:"orange",bandWidthColor:"orange",icon:gr},on_hold:{statusColor:"purple",bandWidthColor:"purple",icon:Ps},connecting:{statusColor:"orange",bandWidthColor:"orange",icon:gr},limited:{statusColor:"red",bandWidthColor:"red",icon:mr},error:{statusColor:"red",bandWidthColor:"red",icon:mr}},Xt=t=>{let n={status:"",time:""};if(t){B(t*1e3).utc().isAfter(B().utc())?n.status="expires":n.status="expired";const o=[],s=B.duration(B(t*1e3).utc().diff(B()));s.years()!=0&&o.push(Math.abs(s.years())+" year"+(Math.abs(s.years())!=1?"s":"")),s.months()!=0&&o.push(Math.abs(s.months())+" month"+(Math.abs(s.months())!=1?"s":"")),s.days()!=0&&o.push(Math.abs(s.days())+" day"+(Math.abs(s.days())!=1?"s":"")),o.length===0&&(s.hours()!=0&&o.push(Math.abs(s.hours())+" hour"+(Math.abs(s.hours())!=1?"s":"")),s.minutes()!=0&&o.push(Math.abs(s.minutes())+" min"+(Math.abs(s.minutes())!=1?"s":""))),n.time=o.join(", ")}return n},yt=({expiryDate:t,status:n,compact:o=!1,showDetail:s=!0,extraText:i})=>{const{t:a}=j(),l=Xt(t),u=it[n].icon;return r(ge,{children:[r(U,{colorScheme:it[n].statusColor,rounded:"full",display:"inline-flex",px:3,py:1,columnGap:o?1:2,alignItems:"center",children:[e(u,{w:o?3:4}),s&&r(h,{textTransform:"capitalize",fontSize:o?".7rem":".875rem",lineHeight:o?"1rem":"1.25rem",fontWeight:"medium",letterSpacing:"tighter",children:[n==="on_hold"?a(n):n,i&&`: ${i}`]})]}),s&&t&&e(h,{display:"inline-block",fontSize:"xs",fontWeight:"medium",ml:"2",color:"gray.600",_dark:{color:"gray.400"},children:a(l.status,{time:l.time})})]})},nt=y(Ue,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Ws=y(Ar,{baseStyle:{w:5,h:5}}),Os=y(Zn,{baseStyle:{w:5,h:5,strokeWidth:2}}),js=({toggleAccordion:t,node:n})=>{const{updateNode:o,reconnectNode:s,setDeletingNode:i}=gt(),{t:a}=j(),l=Gt(),u=fe(),p=Ve({defaultValues:n,resolver:ut(rn)}),C=i.bind(null,n),{isLoading:d,mutate:c}=lt(o,{onSuccess:()=>{qt("Node updated successfully",u),l.invalidateQueries(dt)},onError:S=>{Qt(S,u,p)}}),{isLoading:w,mutate:v}=lt(s.bind(null,n),{onSuccess:()=>{l.invalidateQueries(dt)}}),m=w?"connecting":n.status?n.status:"error";return r(He,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[r(Be,{px:2,borderRadius:"3px",onClick:t,children:[r(_,{w:"full",justifyContent:"space-between",pr:2,children:[e(h,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},children:n.name}),r(_,{children:[n.xray_version&&e(U,{colorScheme:"blue",rounded:"full",display:"inline-flex",px:3,py:1,children:r(h,{textTransform:"capitalize",fontSize:"0.7rem",fontWeight:"medium",letterSpacing:"tighter",children:["Xray ",n.xray_version]})}),n.status&&e(yt,{status:m,compact:!0})]})]}),e(Pt,{})]}),r($e,{px:2,pb:2,children:[e(N,{pb:3,alignItems:"flex-start",children:m==="error"&&e(ct,{status:"error",size:"xs",children:r(D,{children:[r(_,{w:"full",children:[e(kt,{w:4}),e(h,{marginInlineEnd:0,children:n.message})]}),e(_,{justifyContent:"flex-end",w:"full",children:e(F,{size:"sm","aria-label":"reconnect node",leftIcon:e(Xr,{}),onClick:()=>v(),disabled:w,children:a(w?"nodes.reconnecting":"nodes.reconnect")})})]})})}),e(nn,{form:p,mutate:c,isLoading:d,submitBtnText:a("nodes.editNode"),btnLeftAdornment:e(ne,{label:a("delete"),placement:"top",children:e(Z,{colorScheme:"red",variant:"ghost",size:"sm","aria-label":"delete node",onClick:C,children:e(mt,{})})})})]})]})},Hs=({toggleAccordion:t,resetAccordions:n})=>{const o=fe(),{t:s}=j(),i=Gt(),{addNode:a}=gt(),l=Ve({resolver:ut(rn),defaultValues:{...As(),add_as_new_host:!0}}),{isLoading:u,mutate:p}=lt(a,{onSuccess:()=>{qt(s("nodes.addNodeSuccess",{name:l.getValues("name")}),o),i.invalidateQueries(dt),l.reset(),n()},onError:C=>{Qt(C,o,l)}});return r(He,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[e(Be,{px:2,borderRadius:"3px",onClick:t,children:r(h,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},display:"flex",gap:1,children:[e(Os,{display:"inline-block"})," ",e("span",{children:s("nodes.addNewMarzbanNode")})]})}),e($e,{px:2,py:4,children:e(nn,{form:l,mutate:p,isLoading:u,submitBtnText:s("nodes.addNode"),btnProps:{variant:"solid"},addAsHost:!0})})]})},nn=({form:t,mutate:n,isLoading:o,submitBtnText:s,btnProps:i={},btnLeftAdornment:a,addAsHost:l=!1})=>{var v,m,S,T,g,b,W,$,I,A,Y,q,L,V,J;const{t:u}=j(),[p,C]=f.exports.useState(!1),{data:d,isLoading:c}=Bt({queryKey:"node-settings",queryFn:()=>O("/node/settings")});function w(z){if(document.body.createTextRange){const P=document.body.createTextRange();P.moveToElementText(z),P.select()}else if(window.getSelection){const P=window.getSelection(),K=document.createRange();K.selectNodeContents(z),P.removeAllRanges(),P.addRange(K)}else console.warn("Could not select text in node: Unsupported browser.")}return e("form",{onSubmit:t.handleSubmit(z=>n(z)),children:r(N,{children:[d&&d.certificate&&e(ct,{status:"info",alignItems:"start",children:r(Pr,{display:"flex",flexDirection:"column",overflow:"hidden",children:[e("span",{children:u("nodes.connection-hint")}),r(_,{justify:"end",py:2,children:[e(F,{as:"a",colorScheme:"primary",size:"xs",download:"ssl_client_cert.pem",href:URL.createObjectURL(new Blob([d.certificate],{type:"text/plain"})),children:u("nodes.download-certificate")}),e(ne,{placement:"top",label:u("nodes.show-certificate"),children:e(Z,{"aria-label":u("nodes.show-certificate"),onClick:C.bind(null,!p),colorScheme:"whiteAlpha",color:"primary",size:"xs",children:p?e(qn,{width:"15px"}):e(Qn,{width:"15px"})})})]}),e(Wr,{in:p,animateOpacity:!0,children:e(h,{bg:"rgba(255,255,255,.5)",_dark:{bg:"rgba(255,255,255,.2)"},rounded:"md",p:"2",lineHeight:"1.2",fontSize:"10px",fontFamily:"Courier",whiteSpace:"pre",overflow:"auto",onClick:z=>{w(z.target)},children:d.certificate})})]})}),r(_,{w:"full",children:[e(R,{children:e(nt,{label:u("nodes.nodeName"),size:"sm",placeholder:"Marzban-S2",...t.register("name"),error:(S=(m=(v=t.formState)==null?void 0:v.errors)==null?void 0:m.name)==null?void 0:S.message})}),e(_,{px:1,children:e(pe,{name:"status",control:t.control,render:({field:z})=>e(ne,{placement:"top",label:`${u("usersTable.status")}: `+(z.value!=="disabled"?u("active"):u("disabled")),textTransform:"capitalize",children:e(D,{mt:"6",children:e(_t,{colorScheme:"primary",isChecked:z.value!=="disabled",onChange:P=>{P.target.checked?z.onChange("connecting"):z.onChange("disabled")}})})},z.value)})})]}),e(_,{alignItems:"flex-start",w:"100%",children:e(D,{w:"100%",children:e(nt,{label:u("nodes.nodeAddress"),size:"sm",placeholder:"51.20.12.13",...t.register("address"),error:(b=(g=(T=t.formState)==null?void 0:T.errors)==null?void 0:g.address)==null?void 0:b.message})})}),r(_,{alignItems:"flex-start",w:"100%",children:[e(D,{children:e(nt,{label:u("nodes.nodePort"),size:"sm",placeholder:"62050",...t.register("port"),error:(I=($=(W=t.formState)==null?void 0:W.errors)==null?void 0:$.port)==null?void 0:I.message})}),e(D,{children:e(nt,{label:u("nodes.nodeAPIPort"),size:"sm",placeholder:"62051",...t.register("api_port"),error:(q=(Y=(A=t.formState)==null?void 0:A.errors)==null?void 0:Y.api_port)==null?void 0:q.message})}),e(D,{children:e(nt,{label:u("nodes.usageCoefficient"),size:"sm",placeholder:"1",...t.register("usage_coefficient"),error:(J=(V=(L=t.formState)==null?void 0:L.errors)==null?void 0:V.usage_coefficient)==null?void 0:J.message})})]}),l&&e(R,{py:1,children:e(at,{...t.register("add_as_new_host"),children:e(H,{m:0,children:u("nodes.addHostForEveryInbound")})})}),r(_,{w:"full",children:[a,e(F,{flexGrow:1,type:"submit",colorScheme:"primary",size:"sm",px:5,w:"full",isLoading:o,...i,children:s})]})]})})},Bs=()=>{const{isEditingNodes:t,onEditingNodes:n}=E(),{t:o}=j(),[s,i]=f.exports.useState({}),{data:a,isLoading:l}=Ms(),u=()=>{i({}),n(!1)},p=C=>{s[String(C)]?delete s[String(C)]:s[String(C)]={},i({...s})};return r(ge,{children:[r(oe,{isOpen:t,onClose:u,children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(ie,{pt:6,children:e(de,{color:"primary",children:e(Ws,{color:"white"})})}),e(le,{mt:3}),r(ce,{w:"440px",pb:6,pt:3,children:[e(h,{mb:3,opacity:.8,fontSize:"sm",children:o("nodes.title")}),l&&"loading...",e(pt,{w:"full",allowToggle:!0,index:Object.keys(s).map(C=>parseInt(C)),children:r(N,{w:"full",children:[!l&&a&&a.map((C,d)=>e(js,{toggleAccordion:()=>p(d),node:C},C.name)),e(Hs,{toggleAccordion:()=>p((a||[]).length),resetAccordions:()=>i({})})]})})]})]})]}),e(Ns,{deleteCallback:()=>i({})})]})};function $s(t){const n=360/t,o=90,s=47,i=[];for(let a=0;a(w<0&&(w+=1),w>1&&(w-=1),w<.16666666666666666?d+(c-d)*6*w:w<.5?c:w<.6666666666666666?d+(c-d)*(.6666666666666666-w)*6:d),p=o<.5?o*(1+n):o+n-o*n,C=2*o-p;s=Math.round(u(C,p,t+1/3)*255),i=Math.round(u(C,p,t)*255),a=Math.round(u(C,p,t-1/3)*255)}const l=u=>{const p=u.toString(16);return p.length===1?"0"+p:p};return`#${l(s)}${l(i)}${l(a)}`}const fr=({border:t,...n})=>{const{getInputProps:o,getRadioProps:s}=no(n),i=Ae({base:"xs",md:"sm"});return r(D,{as:"label",children:[e("input",{...o()}),e(D,{...s(),minW:"48px",w:"full",h:"full",textAlign:"center",cursor:"pointer",fontSize:i,borderWidth:t?"1px":"0px",borderRadius:"md",_checked:{bg:"primary.500",color:"white",borderColor:"primary.500"},_focus:{boxShadow:"outline"},px:3,py:1,children:n.children})]})},on=({onChange:t,defaultValue:n,...o})=>{const{t:s,i18n:i}=j();ht();const a=Ae({base:["7h","1d","3d","1w"],md:["7h","1d","3d","1w","1m","3m"]}),l={h:"hour",d:"day",w:"week",m:"month",y:"year"},u=Ae({base:[{title:"hours",options:["1h","3h","6h","12h"]},{title:"days",options:["1d","2d","3d","4d"]},{title:"weeks",options:["1w","2w","3w","4w"]},{title:"months",options:["1m","2m","3m","6m"]}],md:[{title:"hours",options:["1h","2h","3h","6h","8h","12h"]},{title:"days",options:["1d","2d","3d","4d","5d","6d"]},{title:"weeks",options:["1w","2w","3w","4w"]},{title:"months",options:["1m","2m","3m","6m","8m"]}]}),{getRootProps:p,getRadioProps:C,setValue:d}=Xn({name:"filter",defaultValue:n,onChange:z=>{if(z==="custom")return;v(),a.indexOf(z)>=0?(T(s("userDialog.custom")),b(!1)):(T(s("userDialog.custom")+` (${z})`),b(!0));const P=Number(z.substring(0,z.length-1)),K=l[z[z.length-1]];t(z,{start:B().utc().subtract(P,K).format("YYYY-MM-DDTHH:00:00")})}}),{isOpen:c,onOpen:w,onClose:v}=Jn(),m=f.exports.useRef(null);Kn({ref:m,handler:v});const[S,T]=f.exports.useState(s("userDialog.custom")),[g,b]=f.exports.useState(!1),[W,$]=f.exports.useState(0),I=Ae({base:1,md:2}),A=Ae({base:"xs",md:"sm"}),[Y,q]=f.exports.useState(null),[L,V]=f.exports.useState(null),J=z=>{const[P,K]=z;L&&!K?(q(null),V(null)):(q(P),V(K),P&&K&&(v(),t("custom",{start:B(P).format("YYYY-MM-DDT00:00:00"),end:B(K).format("YYYY-MM-DDT23:59:59")})))};return r(N,{...o,children:[W==0&&r(Yt,{...p(),gap:0,display:"flex",borderWidth:"1px",borderRadius:"md",minW:{base:"320px",md:"400px"},children:[a.map(z=>e(fr,{...C({value:z}),children:z},z)),e(D,{onClick:()=>{q(null),V(null),w()},cursor:"pointer",borderRadius:"md",w:"full",fontSize:A,px:3,py:1,bg:g?"primary.500":"unset",color:g?"white":"unset",borderColor:g?"primary.500":"unset",children:r(_,{children:[e(h,{children:S}),e(Rt,{as:tr,boxSize:"18px"})]})})]}),W==1&&r(_,{onClick:w,cursor:"pointer",fontSize:A,borderRadius:"md",px:3,py:1,minW:{base:"320px",md:"400px"},borderWidth:"1px",children:[e(h,{w:"full",color:Y?"unset":"gray.500",children:Y?B(Y).format("YYYY-MM-DD (00:00)"):s("userDialog.startDate")}),e(Rt,{as:Or,boxSize:"18px"}),e(h,{w:"full",color:L?"unset":"gray.500",children:L?B(L).format("YYYY-MM-DD (23:59)"):s("userDialog.endDate")}),e(Rt,{as:tr,boxSize:"18px"})]}),e(N,{ref:m,marginTop:"40px !important",borderRadius:"md",borderWidth:"1px",position:"absolute",zIndex:"1",backgroundColor:"white",_dark:{backgroundColor:"gray.700"},display:c?"unset":"none",children:r(eo,{onChange:z=>$(z),children:[r(to,{children:[e(rr,{fontSize:A,children:s("userDialog.relative")}),e(rr,{fontSize:A,children:s("userDialog.absolute")})]}),r(ro,{children:[e(nr,{children:u.map(z=>e(N,{alignItems:"start",pl:2,pr:2,children:r(_,{justifyItems:"flex-start",mb:4,children:[e(h,{fontSize:A,minW:"60px",children:s("userDialog."+z.title)}),z.options.map(P=>e(fr,{border:!0,...C({value:P}),children:P},P+".custom"))]})},z.title))}),e(nr,{className:"datepicker-panel",children:e(N,{children:e(jr,{locale:i.language.toLocaleLowerCase(),selected:Y,onChange:J,startDate:Y,endDate:L,selectsRange:!0,maxDate:new Date,monthsShown:I,peekNextMonth:!1,inline:!0})})})]})]})})]})};function It(t,n,o=[],s=[]){const i=re(o.reduce((a,l)=>a+=l,0));return{series:o,options:{labels:s,chart:{width:"100%",height:"100%",type:"donut",animations:{enabled:!1}},title:{text:`${n}${i}`,align:"center",style:{fontWeight:"var(--chakra-fontWeights-medium)",color:t==="dark"?"var(--chakra-colors-gray-300)":void 0}},legend:{position:"bottom",labels:{colors:t==="dark"?"#CBD5E0":void 0,useSeriesColors:!1}},stroke:{width:1,colors:void 0},dataLabels:{formatter:(a,{seriesIndex:l,w:u})=>re(u.config.series[l],1)},tooltip:{custom:({series:a,seriesIndex:l,dataPointIndex:u,w:p})=>{const C=re(a[l],1),d=Math.max(a.reduce((w,v)=>w+=v),1),c=Math.round(a[l]/d*1e3)/10+"%";return`
{o(y).then(T=>{const g=[],b=[];for(const W in T.usages){const $=T.usages[W];b.push($.uplink+$.downlink),g.push($.node_name)}C(It(l,u,b,g))})};f.exports.useEffect(()=>{t&&w({start:B().utc().subtract(30,"day").format("YYYY-MM-DDTHH:00:00")})},[t]);const v=()=>{n(!1),c("1m")},m=i;return r(oe,{isOpen:t,onClose:v,size:"2xl",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"full",children:[e(ie,{pt:6,children:r(_,{gap:2,children:[e(de,{color:"primary",children:e(Gs,{color:"white"})}),e(h,{fontWeight:"semibold",fontSize:"lg",children:s("header.nodesUsage")})]})}),e(le,{mt:3,disabled:m}),e(ce,{children:r(N,{gap:4,children:[e(on,{defaultValue:d,onChange:(y,T)=>{c(y),w(T)}}),e(D,{justifySelf:"center",w:"full",maxW:"300px",mt:"4",children:e(f.exports.Suspense,{fallback:e(Dr,{isIndeterminate:!0}),children:e(Hr,{options:p.options,series:p.series,type:"donut",height:"500px"})})})]})}),e(Re,{mt:"3"})]})]})},fr=x(oo),Zs=x(Or,{baseStyle:{w:6,h:6,color:"gray.600",_dark:{color:"white"}}}),Qs=x(so,{baseStyle:{w:6,h:6,color:"gray.600",_dark:{color:"white"}}}),qs=x(Br,{baseStyle:{w:5,h:5}}),Xs=()=>{const{QRcodeLinks:t,setQRCode:n,setSubLink:o,subscribeUrl:s}=E(),i=t!==null,[a,l]=f.exports.useState(0),{t:u}=j(),p=()=>{n(null),o(null)},C=String(s).startsWith("/")?window.location.origin+s:String(s);return r(oe,{isOpen:i,onClose:p,children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(ie,{pt:6,children:e(de,{color:"primary",children:e(qs,{color:"white"})})}),e(le,{mt:3}),t&&r(ce,{gap:{base:"20px",lg:"50px"},pr:{lg:"60px"},px:{base:"50px"},display:"flex",justifyContent:"center",flexDirection:{base:"column",lg:"row"},children:[s&&r(N,{children:[e(fr,{mx:"auto",size:300,p:"2",level:"L",includeMargin:!1,value:C,bg:"white"}),e(h,{display:"block",textAlign:"center",pb:3,mt:1,children:u("qrcodeDialog.sublink")})]}),r(D,{w:"300px",children:[e(ao,{centerPadding:"0px",centerMode:!0,slidesToShow:1,slidesToScroll:1,dots:!1,afterChange:l,onInit:()=>l(0),nextArrow:e(Z,{size:"sm",position:"absolute",display:"flex !important",_before:{content:'""'},"aria-label":"next",mr:"-4",children:e(Zs,{})}),prevArrow:e(Z,{size:"sm",position:"absolute",display:"flex !important",_before:{content:'""'},"aria-label":"prev",ml:"-4",children:e(Qs,{})}),children:t.map((d,c)=>e(_,{children:e(fr,{mx:"auto",size:300,p:"2",level:"L",includeMargin:!1,value:d,bg:"white"})},c))}),r(h,{display:"block",textAlign:"center",pb:3,mt:1,children:[a+1," / ",t.length]})]})]})]})]})},Js=x(Mr,{baseStyle:{w:5,h:5}}),Ks=()=>{const[t,n]=f.exports.useState(!1),{isResetingAllUsage:o,onResetAllUsage:s,resetAllUsage:i}=E(),{t:a}=j(),l=fe(),u=()=>{s(!1)},p=()=>{n(!0),i().then(()=>{l({title:a("resetAllUsage.success"),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(()=>{l({title:a("resetAllUsage.error"),status:"error",isClosable:!0,position:"top",duration:3e3})}).finally(()=>{n(!1)})};return r(oe,{isCentered:!0,isOpen:o,onClose:u,size:"sm",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",children:[e(ie,{pt:6,children:e(de,{color:"red",children:e(Js,{})})}),e(le,{mt:3}),r(ce,{children:[e(h,{fontWeight:"semibold",fontSize:"lg",children:a("resetAllUsage.title")}),o&&e(h,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:a("resetAllUsage.prompt")})]}),r(Re,{display:"flex",children:[e(F,{size:"sm",onClick:u,mr:3,w:"full",variant:"outline",children:a("cancel")}),e(F,{size:"sm",w:"full",colorScheme:"red",onClick:p,leftIcon:t?e(Ne,{size:"xs"}):void 0,children:a("reset")})]})]})]})},ea=x(Et,{baseStyle:{w:5,h:5}}),ta=()=>{const[t,n]=f.exports.useState(!1),{resetUsageUser:o,resetDataUsage:s}=E(),{t:i}=j(),a=fe(),l=()=>{E.setState({resetUsageUser:null})},u=()=>{o&&(n(!0),s(o).then(()=>{a({title:i("resetUserUsage.success",{username:o.username}),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(()=>{a({title:i("resetUserUsage.error"),status:"error",isClosable:!0,position:"top",duration:3e3})}).finally(()=>{n(!1)}))};return r(oe,{isCentered:!0,isOpen:!!o,onClose:l,size:"sm",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",children:[e(ie,{pt:6,children:e(de,{color:"blue",children:e(ea,{})})}),e(le,{mt:3}),r(ce,{children:[e(h,{fontWeight:"semibold",fontSize:"lg",children:i("resetUserUsage.title")}),o&&e(h,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(Ee,{components:{b:e("b",{})},children:i("resetUserUsage.prompt",{username:o.username})})})]}),r(Re,{display:"flex",children:[e(F,{size:"sm",onClick:l,mr:3,w:"full",variant:"outline",children:i("cancel")}),e(F,{size:"sm",w:"full",colorScheme:"blue",onClick:u,leftIcon:t?e(Ne,{size:"xs"}):void 0,children:i("reset")})]})]})]})},ra=x(Et,{baseStyle:{w:5,h:5}}),na=()=>{const[t,n]=f.exports.useState(!1),{revokeSubscriptionUser:o,revokeSubscription:s}=E(),{t:i}=j(),a=fe(),l=()=>{E.setState({revokeSubscriptionUser:null})},u=()=>{o&&(n(!0),s(o).then(()=>{a({title:i("revokeUserSub.success",{username:o.username}),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(()=>{a({title:i("revokeUserSub.error"),status:"error",isClosable:!0,position:"top",duration:3e3})}).finally(()=>{n(!1)}))};return r(oe,{isCentered:!0,isOpen:!!o,onClose:l,size:"sm",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",children:[e(ie,{pt:6,children:e(de,{color:"blue",children:e(ra,{})})}),e(le,{mt:3}),r(ce,{children:[e(h,{fontWeight:"semibold",fontSize:"lg",children:i("revokeUserSub.title")}),o&&e(h,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(Ee,{components:{b:e("b",{})},children:i("revokeUserSub.prompt",{username:o.username})})})]}),r(Re,{display:"flex",children:[e(F,{size:"sm",onClick:l,mr:3,w:"full",variant:"outline",children:i("cancel")}),e(F,{size:"sm",w:"full",colorScheme:"blue",onClick:u,leftIcon:t?e(Ne,{size:"xs"}):void 0,children:i("revoke")})]})]})]})},oa=x(io,{baseStyle:{strokeWidth:"2px",w:5,h:5}}),sa=({inbound:t,...n})=>{const{getCheckboxProps:o,getInputProps:s,getLabelProps:i,htmlProps:a}=Vr(n),l=s();return r(D,{as:"label",children:[e("input",{...l}),r(D,{w:"fll",position:"relative",...a,cursor:"pointer",borderRadius:"sm",border:"1px solid",borderColor:"gray.200",_dark:{borderColor:"gray.600"},display:"flex",alignItems:"center",justifyContent:"space-between",overflow:"hidden",_checked:{bg:"gray.50",outline:"2px",boxShadow:"outline",outlineColor:"primary.500",borderColor:"transparent",fontWeight:"medium",_dark:{bg:"gray.750",borderColor:"transparent"},"& p":{opacity:1}},__css:{"& p":{opacity:.8}},textTransform:"capitalize",px:3,py:2,fontWeight:"medium",...o(),children:[e(at,{size:"sm",w:"full",maxW:"full",color:"gray.700",_dark:{color:"gray.300"},textTransform:"uppercase",colorScheme:"primary",className:"inbound-item",isChecked:l.checked,pointerEvents:"none",flexGrow:1,children:e(_,{justify:"space-between",w:"full",maxW:"calc(100% - 20px)",spacing:0,gap:2,overflow:"hidden",children:r(h,{isTruncated:!0,...i(),fontSize:"xs",children:[t.tag," ",r(h,{as:"span",children:["(",t.network,")"]})]})})}),t.tls&&t.tls!="none"&&e(U,{fontSize:"xs",opacity:".8",size:"xs",children:t.tls})]})]})},aa=({disabled:t,title:n,description:o,toggleAccordion:s,isSelected:i,...a})=>{const l=$t(),{inbounds:u}=E(),{getCheckboxProps:p,getInputProps:C,getLabelProps:d,htmlProps:c}=Vr(a),w=C(),[v]=Gr({name:[`inbounds.${n}`],control:l.control}),{getCheckboxProps:m}=$r({value:v,onChange:b=>{if(l.setValue(`inbounds.${n}`,b),b.length===0){const W=l.getValues("selected_proxies");l.setValue("selected_proxies",W.filter($=>$!==n)),s()}}}),y=v&&i&&(E.getState().inbounds.get(n)||[]).length!==v.length,T=(E.getState().inbounds.get(n)||[]).length>0,g=!i&&!T;return r(He,{isDisabled:!T,borderRadius:"md",borderStyle:"solid",border:"1px",borderColor:"gray.200",bg:g?"gray.100":"transparent",_dark:{borderColor:"gray.600",bg:g?"#364154":"transparent"},_checked:{bg:"gray.50",outline:"2px",boxShadow:"outline",outlineColor:"primary.500",borderColor:"transparent"},...p(),children:[r(D,{as:g?"span":"label",position:"relative",children:[y&&e(D,{position:"absolute",w:"2",h:"2",bg:"yellow.500",top:"-1",right:"-1",rounded:"full",zIndex:999}),e("input",{...w}),r(D,{w:"fll",position:"relative",...c,borderRadius:"md",cursor:g?"not-allowed":"pointer",_checked:{fontWeight:"medium",_dark:{bg:"gray.750",borderColor:"transparent"},"& > svg":{opacity:1,"&.checked":{display:"block"},"&.unchecked":{display:"none"}},"& p":{opacity:1}},__css:{"& > svg":{opacity:.3,"&.checked":{display:"none"},"&.unchecked":{display:"block"}},"& p":{opacity:.8}},textTransform:"capitalize",px:3,py:2,fontWeight:"medium",...p(),children:[e(Be,{display:w.checked&&T?"block":"none",as:"span",className:"checked",color:"primary.200",position:"absolute",right:"3",top:"3",w:"auto",p:0,onClick:s,children:e(Z,{size:"sm","aria-label":"inbound settings",children:e(oa,{})})}),e(h,{fontSize:"sm",color:g?"gray.400":"gray.700",_dark:{color:g?"gray.500":"gray.300"},...d(),children:n}),e(h,{fontWeight:"medium",color:g?"gray.400":"gray.600",_dark:{color:g?"gray.500":"gray.400"},fontSize:"xs",children:o})]})]}),e($e,{px:2,pb:3,roundedBottom:"5px",pt:3,_dark:{bg:w.checked&&"gray.750"},children:r(N,{w:"full",rowGap:2,borderStyle:"solid",borderWidth:"1px",borderRadius:"md",pl:3,pr:3,pt:1.5,_dark:{bg:"gray.700"},children:[r(N,{alignItems:"flex-start",w:"full",children:[e(h,{fontSize:"sm",children:X("inbound")}),e(Gt,{gap:2,alignItems:"flex-start",w:"full",columns:1,spacing:1,children:(u.get(n)||[]).map(b=>e(sa,{...m({value:b.tag}),inbound:b},b.tag))})]}),n==="vmess"&&i&&e(N,{alignItems:"flex-start",w:"full",children:r(R,{height:"66px",children:[e(h,{fontSize:"sm",pb:1,children:"ID"}),e(je,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.vmess.id")})]})}),n==="vless"&&i&&r(N,{alignItems:"flex-start",w:"full",children:[r(R,{height:"66px",children:[e(h,{fontSize:"sm",pb:1,children:"ID"}),e(je,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.vless.id")})]}),r(R,{height:"66px",children:[e(h,{fontSize:"sm",pb:1,children:"Flow"}),e(Me,{fontSize:"xs",size:"sm",borderRadius:"6px",...l.register("proxies.vless.flow"),children:Is.map(b=>e("option",{value:b.value,children:b.title},b.title))})]})]}),n==="trojan"&&i&&e(N,{alignItems:"flex-start",w:"full",children:r(R,{height:"66px",children:[e(h,{fontSize:"sm",pb:1,children:X("password")}),e(je,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.trojan.password")})]})}),n==="shadowsocks"&&i&&r(N,{alignItems:"flex-start",w:"full",children:[r(R,{height:"66px",children:[e(h,{fontSize:"sm",pb:1,children:X("password")}),e(je,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.shadowsocks.password")})]}),r(R,{height:"66px",children:[e(h,{fontSize:"sm",pb:1,children:X("userDialog.method")}),e(Me,{fontSize:"xs",size:"sm",borderRadius:"6px",...l.register("proxies.shadowsocks.method"),children:zs.map(b=>e("option",{value:b,children:b},b))})]})]})]})})]})},ia=f.exports.forwardRef(({name:t,list:n,onChange:o,disabled:s,...i},a)=>{const l=$t(),[u,p]=f.exports.useState([]),C=c=>{u.includes(c)?u.splice(u.indexOf(c),1):u.push(c),p([...u])},{getCheckboxProps:d}=$r({value:i.value,onChange:c=>{var v;const w=c.filter(m=>!i.value.includes(m));w[0]&&l.setValue(`inbounds.${w[0]}`,(v=E.getState().inbounds.get(w[0]))==null?void 0:v.map(m=>m.tag)),p(u.filter(m=>c.find(y=>y===n[m].title))),o({target:{value:c,name:t}})}});return e(pt,{allowToggle:!0,index:u,children:e(Gt,{ref:a,gap:2,alignItems:"flex-start",columns:1,spacing:1,children:n.map((c,w)=>e(aa,{toggleAccordion:C.bind(null,w),disabled:s,title:c.title,description:c.description,isSelected:!!i.value.find(v=>v===c.title),...d({value:c.title})},c.title))})})}),la=x(lo,{baseStyle:{w:5,h:5}}),ca=x(Yr,{baseStyle:{w:5,h:5}}),da=x(Dt,{baseStyle:{w:5,h:5}}),ha=t=>({...t,data_limit:t.data_limit?Number((t.data_limit/1073741824).toFixed(5)):t.data_limit,on_hold_expire_duration:t.on_hold_expire_duration?Number(t.on_hold_expire_duration/(24*60*60)):t.on_hold_expire_duration,selected_proxies:Object.keys(t.proxies)}),At=()=>{const t=Object.fromEntries(E.getState().inbounds),n={};for(const o in t)n[o]=t[o].map(s=>s.tag);return{selected_proxies:Object.keys(t),data_limit:null,expire:null,username:"",data_limit_reset_strategy:"no_reset",status:"active",on_hold_expire_duration:null,note:"",inbounds:n,proxies:{vless:{id:"",flow:""},vmess:{id:""},trojan:{password:""},shadowsocks:{password:"",method:"chacha20-ietf-poly1305"}}}},ua=(t,n)=>{const o=t.reduce((s,i)=>({...s,[i]:{}}),{});return n&&t.forEach(s=>{n[s]&&(o[s]=n[s])}),o},br={username:S.string().min(1,{message:"Required"}),selected_proxies:S.array(S.string()).refine(t=>t.length>0,{message:"userDialog.selectOneProtocol"}),note:S.string().nullable(),proxies:S.record(S.string(),S.record(S.string(),S.any())).transform(t=>{const n=(o,s)=>{o&&o[s]===""&&delete o[s]};return n(t.vmess,"id"),n(t.vless,"id"),n(t.trojan,"password"),n(t.shadowsocks,"password"),n(t.shadowsocks,"method"),t}),data_limit:S.string().min(0).or(S.number()).nullable().transform(t=>t?Number((parseFloat(String(t))*1073741824).toFixed(5)):0),expire:S.number().nullable(),data_limit_reset_strategy:S.string(),inbounds:S.record(S.string(),S.array(S.string())).transform(t=>(Object.keys(t).forEach(n=>{var o;Array.isArray(t[n])&&!((o=t[n])!=null&&o.length)&&delete t[n]}),t))},pa=S.discriminatedUnion("status",[S.object({status:S.literal("active"),...br}),S.object({status:S.literal("on_hold"),on_hold_expire_duration:S.coerce.number().min(.1,"Required").transform(t=>t*(24*60*60)),...br})]),ma=()=>{var Ye,Ze,Qe,qe,Xe;const{editingUser:t,isCreatingNewUser:n,onCreateUser:o,editUser:s,fetchUserUsage:i,onEditingUser:a,createUser:l,onDeletingUser:u}=E(),p=!!t,C=n||p,[d,c]=f.exports.useState(!1),[w,v]=f.exports.useState(""),m=fe(),{t:y,i18n:T}=j(),{colorMode:g}=ht(),[b,W]=f.exports.useState(!1),$=()=>{W(k=>!k)},I=Ve({defaultValues:At(),resolver:ut(pa)});f.exports.useEffect(()=>E.subscribe(k=>k.inbounds,()=>{I.reset(At())}),[]);const[A,Y]=Gr({control:I.control,name:["data_limit","status"]}),q=y("userDialog.total"),[L,V]=f.exports.useState(It(g,q)),[J,z]=f.exports.useState("1m"),P=k=>{i(t,k).then(M=>{const te=[],xe=[];for(const he in M.usages)xe.push(M.usages[he].used_traffic),te.push(M.usages[he].node_name);V(It(g,q,xe,te))})};f.exports.useEffect(()=>{t&&(I.reset(ha(t)),P({start:B().utc().subtract(30,"day").format("YYYY-MM-DDTHH:00:00")}))},[t]);const K=k=>{c(!0);const M={edited:s,created:l},te=p?"edited":"created";v(null);const{selected_proxies:xe,...he}=k;let ye={...he,data_limit:k.data_limit,proxies:ua(xe,k.proxies),data_limit_reset_strategy:k.data_limit&&k.data_limit>0?k.data_limit_reset_strategy:"no_reset",status:k.status==="active"||k.status==="disabled"||k.status==="on_hold"?k.status:"active"};M[te](ye).then(()=>{m({title:y(p?"userDialog.userEdited":"userDialog.userCreated",{username:k.username}),status:"success",isClosable:!0,position:"top",duration:3e3}),Fe()}).catch(G=>{var Je,Ke,et,tt,Q;(((Je=G==null?void 0:G.response)==null?void 0:Je.status)===409||((Ke=G==null?void 0:G.response)==null?void 0:Ke.status)===400)&&v((tt=(et=G==null?void 0:G.response)==null?void 0:et._data)==null?void 0:tt.detail),((Q=G==null?void 0:G.response)==null?void 0:Q.status)===422&&Object.keys(G.response._data.detail).forEach(We=>{v(G==null?void 0:G.response._data.detail[We]),I.setError(We,{type:"custom",message:G.response._data.detail[We]})})}).finally(()=>{c(!1)})},Fe=()=>{I.reset(At()),o(!1),a(null),v(null),W(!1),z("1m")},bt=()=>{E.setState({resetUsageUser:t})},xt=()=>{E.setState({revokeSubscriptionUser:t})},ee=d,Pe=Y==="on_hold";return r(oe,{isOpen:C,onClose:Fe,size:"2xl",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),e(Nr,{...I,children:e(ae,{mx:"3",children:r("form",{onSubmit:I.handleSubmit(K),children:[e(ie,{pt:6,children:r(_,{gap:2,children:[e(de,{color:"primary",children:p?e(ca,{color:"white"}):e(la,{color:"white"})}),e(h,{fontWeight:"semibold",fontSize:"lg",children:y(p?"userDialog.editUserTitle":"createNewUser")})]})}),e(le,{mt:3,disabled:ee}),r(ce,{children:[r(Ur,{templateColumns:{base:"repeat(1, 1fr)",md:"repeat(2, 1fr)"},gap:3,children:[e(st,{children:r(N,{justifyContent:"space-between",children:[r(nr,{flexDirection:"column",gridAutoRows:"min-content",w:"full",children:[r(nr,{flexDirection:"row",w:"full",gap:2,children:[r(R,{mb:"10px",children:[e(H,{children:y("username")}),r(_,{children:[e(Ue,{size:"sm",type:"text",borderRadius:"6px",error:(Ye=I.formState.errors.username)==null?void 0:Ye.message,disabled:ee||p,...I.register("username")}),p&&e(_,{px:1,children:e(pe,{name:"status",control:I.control,render:({field:k})=>e(ne,{placement:"top",label:"status: "+y(k.value),textTransform:"capitalize",children:e(D,{children:e(_t,{colorScheme:"primary",isChecked:k.value==="active",onChange:M=>{M.target.checked?k.onChange("active"):k.onChange("disabled")}})})})})})]})]}),!p&&r(R,{flex:"1",children:[e(H,{whiteSpace:"nowrap",children:y("userDialog.onHold")}),e(pe,{name:"status",control:I.control,render:({field:k})=>{const M=k.value;return e(ge,{children:M?e(_t,{colorScheme:"primary",isChecked:M==="on_hold",onChange:te=>{te.target.checked?k.onChange("on_hold"):k.onChange("active")}}):""})}})]})]}),r(R,{mb:"10px",children:[e(H,{children:y("userDialog.dataLimit")}),e(pe,{control:I.control,name:"data_limit",render:({field:k})=>{var M;return e(Ue,{endAdornment:"GB",type:"number",size:"sm",borderRadius:"6px",onChange:k.onChange,disabled:ee,error:(M=I.formState.errors.data_limit)==null?void 0:M.message,value:k.value?String(k.value):""})}})]}),e(Wr,{in:!!(A&&A>0),animateOpacity:!0,style:{width:"100%"},children:r(R,{height:"66px",children:[e(H,{children:y("userDialog.periodicUsageReset")}),e(pe,{control:I.control,name:"data_limit_reset_strategy",render:({field:k})=>e(Me,{size:"sm",...k,disabled:ee,bg:ee?"gray.100":"transparent",_dark:{bg:ee?"gray.600":"transparent"},children:Ot.map(M=>e("option",{value:M.value,children:y("userDialog.resetStrategy"+M.title)},M.value))})})]})}),r(R,{mb:"10px",children:[e(H,{children:y(Pe?"userDialog.onHoldExpireDuration":"userDialog.expiryDate")}),Pe&&e(pe,{control:I.control,name:"on_hold_expire_duration",render:({field:k})=>{var M;return e(Ue,{endAdornment:"Days",type:"number",size:"sm",borderRadius:"6px",onChange:te=>{I.setValue("expire",null),k.onChange({target:{value:te}})},disabled:ee,error:(M=I.formState.errors.on_hold_expire_duration)==null?void 0:M.message,value:k.value?String(k.value):""})}}),!Pe&&e(pe,{name:"expire",control:I.control,render:({field:k})=>{var he;function M(ye){return B(B(ye*1e3).utc()).toDate()}const{status:te,time:xe}=qt(k.value);return r(ge,{children:[e(jr,{locale:T.language.toLocaleLowerCase(),dateFormat:y("dateFormat"),minDate:new Date,selected:k.value?M(k.value):void 0,onChange:ye=>{I.setValue("on_hold_expire_duration",null),k.onChange({target:{value:ye?B(B(ye).set("hour",23).set("minute",59).set("second",59)).utc().valueOf()/1e3:0,name:"expire"}})},customInput:e(Ue,{size:"sm",type:"text",borderRadius:"6px",clearable:!0,disabled:ee,error:(he=I.formState.errors.expire)==null?void 0:he.message})}),k.value?e(co,{children:y(te,{time:xe})}):""]})}})]}),r(R,{mb:"10px",isInvalid:!!I.formState.errors.note,children:[e(H,{children:y("userDialog.note")}),e(ho,{...I.register("note")}),e(wt,{children:(Qe=(Ze=I.formState.errors)==null?void 0:Ze.note)==null?void 0:Qe.message})]})]}),w&&r(ct,{status:"error",display:{base:"none",md:"flex"},children:[e(kt,{}),w]})]})}),e(st,{children:r(R,{isInvalid:!!((qe=I.formState.errors.selected_proxies)!=null&&qe.message),children:[e(H,{children:y("userDialog.protocols")}),e(pe,{control:I.control,name:"selected_proxies",render:({field:k})=>e(ia,{list:[{title:"vmess",description:y("userDialog.vmessDesc")},{title:"vless",description:y("userDialog.vlessDesc")},{title:"trojan",description:y("userDialog.trojanDesc")},{title:"shadowsocks",description:y("userDialog.shadowsocksDesc")}],disabled:ee,...k})}),e(wt,{children:y((Xe=I.formState.errors.selected_proxies)==null?void 0:Xe.message)})]})}),p&&b&&e(st,{pt:6,colSpan:{base:1,md:2},children:r(N,{gap:4,children:[e(on,{defaultValue:J,onChange:(k,M)=>{z(k),P(M)}}),e(D,{width:{base:"100%",md:"70%"},justifySelf:"center",children:e(Hr,{options:L.options,series:L.series,type:"donut"})})]})})]}),w&&r(ct,{mt:"3",status:"error",display:{base:"flex",md:"none"},children:[e(kt,{}),w]})]}),e(Re,{mt:"3",children:r(_,{justifyContent:"space-between",w:"full",gap:3,flexDirection:{base:"column",sm:"row"},children:[e(_,{justifyContent:"flex-start",w:{base:"full",sm:"unset"},children:p&&r(ge,{children:[e(ne,{label:y("delete"),placement:"top",children:e(Z,{"aria-label":"Delete",size:"sm",onClick:()=>{u(t),Fe()},children:e(mt,{})})}),e(ne,{label:y("userDialog.usage"),placement:"top",children:e(Z,{"aria-label":"usage",size:"sm",onClick:$,children:e(da,{})})}),e(F,{onClick:bt,size:"sm",children:y("userDialog.resetUsage")}),e(F,{onClick:xt,size:"sm",children:y("userDialog.revokeSubscription")})]})}),e(_,{w:"full",maxW:{md:"50%",base:"full"},justify:"end",children:e(F,{type:"submit",size:"sm",px:"8",colorScheme:"primary",leftIcon:d?e(Ne,{size:"xs"}):void 0,disabled:ee,children:y(p?"userDialog.editUser":"createUser")})})]})})]})})})]})},ga=t=>f.exports.createElement("svg",{xmlns:"http://www.w3.org/2000/svg","data-name":"Layer 1",width:782.04441,height:701.88002,viewBox:"0 0 782.04441 701.88002",xmlnsXlink:"http://www.w3.org/1999/xlink",...t},f.exports.createElement("path",{d:"M609.48783,100.59015l-25.44631,6.56209L270.53735,187.9987,245.091,194.56079A48.17927,48.17927,0,0,0,210.508,253.17865L320.849,681.05606a48.17924,48.17924,0,0,0,58.61776,34.58317l.06572-.01695,364.26536-93.93675.06572-.01695a48.17923,48.17923,0,0,0,34.58309-58.6178l-110.341-427.87741A48.17928,48.17928,0,0,0,609.48783,100.59015Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),f.exports.createElement("path",{d:"M612.94784,114.00532l-30.13945,7.77236L278.68955,200.20385l-30.139,7.77223a34.30949,34.30949,0,0,0-24.6275,41.74308l110.341,427.87741a34.30946,34.30946,0,0,0,41.7431,24.62736l.06572-.01695,364.26536-93.93674.06619-.01707a34.30935,34.30935,0,0,0,24.627-41.7429l-110.341-427.87741A34.30938,34.30938,0,0,0,612.94784,114.00532Z",transform:"translate(-208.9778 -99.05999)",fill:"#fff"}),f.exports.createElement("path",{d:"M590.19,252.56327,405.917,300.08359a8.01411,8.01411,0,0,1-4.00241-15.52046l184.273-47.52033A8.01412,8.01412,0,0,1,590.19,252.56327Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),f.exports.createElement("path",{d:"M628.955,270.49906,412.671,326.27437a8.01411,8.01411,0,1,1-4.00241-15.52046l216.284-55.77531a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),f.exports.createElement("path",{d:"M620.45825,369.93676l-184.273,47.52032a8.01411,8.01411,0,1,1-4.00242-15.52046l184.273-47.52032a8.01411,8.01411,0,1,1,4.00241,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),f.exports.createElement("path",{d:"M659.22329,387.87255l-216.284,55.77531a8.01411,8.01411,0,1,1-4.00242-15.52046l216.284-55.77531a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),f.exports.createElement("path",{d:"M650.72653,487.31025l-184.273,47.52033a8.01412,8.01412,0,0,1-4.00242-15.52047l184.273-47.52032a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),f.exports.createElement("path",{d:"M689.49156,505.246l-216.284,55.77532a8.01412,8.01412,0,1,1-4.00241-15.52047l216.284-55.77531a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),f.exports.createElement("path",{d:"M374.45884,348.80871l-65.21246,16.817a3.847,3.847,0,0,1-4.68062-2.76146L289.5963,304.81607a3.847,3.847,0,0,1,2.76145-4.68061l65.21247-16.817a3.847,3.847,0,0,1,4.68061,2.76145l14.96947,58.04817A3.847,3.847,0,0,1,374.45884,348.80871Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M404.72712,466.1822l-65.21247,16.817a3.847,3.847,0,0,1-4.68062-2.76146l-14.96946-58.04816A3.847,3.847,0,0,1,322.626,417.509l65.21246-16.817a3.847,3.847,0,0,1,4.68062,2.76145l14.96946,58.04817A3.847,3.847,0,0,1,404.72712,466.1822Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M434.99539,583.55569l-65.21246,16.817a3.847,3.847,0,0,1-4.68062-2.76145l-14.96946-58.04817a3.847,3.847,0,0,1,2.76145-4.68062l65.21247-16.817a3.847,3.847,0,0,1,4.68061,2.76146l14.96947,58.04816A3.847,3.847,0,0,1,434.99539,583.55569Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M863.63647,209.0517H487.31811a48.17928,48.17928,0,0,0-48.125,48.12512V699.05261a48.17924,48.17924,0,0,0,48.125,48.12507H863.63647a48.17924,48.17924,0,0,0,48.125-48.12507V257.17682A48.17928,48.17928,0,0,0,863.63647,209.0517Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M863.637,222.90589H487.31811a34.30948,34.30948,0,0,0-34.271,34.27093V699.05261a34.30947,34.30947,0,0,0,34.271,34.27088H863.637a34.30936,34.30936,0,0,0,34.27051-34.27088V257.17682A34.30937,34.30937,0,0,0,863.637,222.90589Z",transform:"translate(-208.9778 -99.05999)",fill:"#fff"}),f.exports.createElement("circle",{cx:694.19401,cy:614.02963,r:87.85039,fill:"#3182CE"}),f.exports.createElement("path",{d:"M945.18722,701.63087H914.63056V671.07421a11.45875,11.45875,0,0,0-22.9175,0v30.55666H861.1564a11.45875,11.45875,0,0,0,0,22.9175h30.55666V755.105a11.45875,11.45875,0,1,0,22.9175,0V724.54837h30.55666a11.45875,11.45875,0,0,0,0-22.9175Z",transform:"translate(-208.9778 -99.05999)",fill:"#fff"}),f.exports.createElement("path",{d:"M807.00068,465.71551H616.699a8.01412,8.01412,0,1,1,0-16.02823H807.00068a8.01412,8.01412,0,0,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M840.05889,492.76314H616.699a8.01412,8.01412,0,1,1,0-16.02823H840.05889a8.01411,8.01411,0,1,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M807.00068,586.929H616.699a8.01412,8.01412,0,1,1,0-16.02823H807.00068a8.01411,8.01411,0,0,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M840.05889,613.97661H616.699a8.01412,8.01412,0,1,1,0-16.02823H840.05889a8.01412,8.01412,0,1,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M574.07028,505.04162H506.72434a3.847,3.847,0,0,1-3.84278-3.84278V441.25158a3.847,3.847,0,0,1,3.84278-3.84278h67.34594a3.847,3.847,0,0,1,3.84278,3.84278v59.94726A3.847,3.847,0,0,1,574.07028,505.04162Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M574.07028,626.25509H506.72434a3.847,3.847,0,0,1-3.84278-3.84278V562.46505a3.847,3.847,0,0,1,3.84278-3.84278h67.34594a3.847,3.847,0,0,1,3.84278,3.84278v59.94726A3.847,3.847,0,0,1,574.07028,626.25509Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M807.21185,330.781H666.91017a8.01411,8.01411,0,0,1,0-16.02823H807.21185a8.01411,8.01411,0,0,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#ccc"}),f.exports.createElement("path",{d:"M840.27007,357.82862H666.91017a8.01411,8.01411,0,1,1,0-16.02822h173.3599a8.01411,8.01411,0,0,1,0,16.02822Z",transform:"translate(-208.9778 -99.05999)",fill:"#ccc"}),f.exports.createElement("path",{d:"M635.85911,390.6071H506.51316a3.847,3.847,0,0,1-3.84277-3.84277V285.81706a3.847,3.847,0,0,1,3.84277-3.84277H635.85911a3.847,3.847,0,0,1,3.84277,3.84277V386.76433A3.847,3.847,0,0,1,635.85911,390.6071Z",transform:"translate(-208.9778 -99.05999)",fill:"#ccc"})),fa=t=>{if(!t)return null;const n=new Date(t+"Z");return Math.floor(n.getTime()/1e3)},xr=({lastOnline:t})=>{const n=Math.floor(Date.now()/1e3),o=fa(t);if(typeof t>"u"||t===null)return e("div",{className:"circle pulse orange"});const s=o?n-o:1/0;return s>0&&s<=60?e("div",{className:"circle pulse green"}):e("div",{className:"circle pulse red"})},ba=t=>{if(!t)return null;const n=new Date(t+"Z");return Math.floor(n.getTime()/1e3)},yr=({lastOnline:t})=>{const n=Math.floor(Date.now()/1e3),o=ba(t),s=o?n-o:null,i=o?qt(o):{status:"",time:"Not Connected Yet"};return e(h,{display:"inline-block",fontSize:"xs",fontWeight:"medium",ml:"2",color:"gray.600",_dark:{color:"gray.400"},children:s&&s<=60?"Online":s?`${i.time} ago`:i.time})},xa=x(uo,{baseStyle:{w:4,h:4}}),ya=x(po,{baseStyle:{w:4,h:4}}),Sr=5;function Sa(t,n,o){if(o0&&(i[0]=0,i[1]="prev-more"),i[i.length-1]{const{filters:t,onFilterChange:n,users:{total:o}}=E(),{limit:s,offset:i}=t,a=(i||0)/(s||1),l=Math.ceil(o/(s||1)),u=Sa(l,a,7),p=c=>{n({...t,offset:c*s})},C=c=>{n({...t,limit:parseInt(c.target.value)}),Vo(c.target.value)},{t:d}=j();return r(_,{justifyContent:"space-between",mt:4,w:"full",display:"flex",columnGap:{lg:4,md:0},rowGap:{md:0,base:4},flexDirection:{md:"row",base:"column"},children:[e(D,{order:{base:2,md:1},children:r(_,{children:[r(Me,{minW:"60px",value:s,onChange:C,size:"sm",rounded:"md",children:[e("option",{children:"10"}),e("option",{children:"20"}),e("option",{children:"30"})]}),e(h,{whiteSpace:"nowrap",fontSize:"sm",children:d("itemsPerPage")})]})}),r(mo,{size:"sm",isAttached:!0,variant:"outline",order:{base:1,md:2},children:[e(F,{leftIcon:e(xa,{}),onClick:p.bind(null,a-1),isDisabled:a===0||l===0,children:d("previous")}),u.map(c=>typeof c=="string"?e(F,{children:"..."},c):e(F,{variant:c===a?"solid":"outline",onClick:p.bind(null,c),children:c+1},c)),e(F,{rightIcon:e(ya,{}),onClick:p.bind(null,a+1),isDisabled:a+1===l||l===0,children:d("next")})]})]})},wa=x(ga),Ge={baseStyle:{w:{base:4,md:5},h:{base:4,md:5}}},_a=x(go,Ge),ka=x(Zr,Ge),Cr=x(fo,Ge),va=x(Bt,Ge),Ia=x(Br,Ge),za=x(Yr,Ge),Da=x(Zr,{baseStyle:{width:"15px",height:"15px"}}),Ea=t=>{for(var n=0;n{const{used:n,total:o,dataLimitResetStrategy:s,totalUsedTraffic:i}=t,a=o===0||o===null;return e(_,{justifyContent:"space-between",fontSize:"xs",fontWeight:"medium",color:"gray.600",_dark:{color:"gray.400"},children:r(h,{children:[re(n)," /"," ",a?e(h,{as:"span",fontFamily:"system-ui",children:"\u221E"}):re(o)]})})},wr=t=>{const{used:n,total:o,dataLimitResetStrategy:s,totalUsedTraffic:i,...a}=t,l=o===0||o===null,u=!l&&n/o*100>=100;return r(ge,{children:[e(bo,{orientation:"horizontal",value:l?100:Math.min(n/o*100,100),colorScheme:u?"red":"primary",...a,children:e(xo,{h:"6px",borderRadius:"full",children:e(yo,{borderRadius:"full"})})}),r(_,{justifyContent:"space-between",fontSize:"xs",fontWeight:"medium",color:"gray.600",_dark:{color:"gray.400"},children:[r(h,{children:[re(n)," /"," ",l?e(h,{as:"span",fontFamily:"system-ui",children:"\u221E"}):re(o)+(s&&s!=="no_reset"?" "+X("userDialog.resetStrategy"+Ea(s)):"")]}),r(h,{children:[X("usersTable.total"),": ",re(i)]})]})]})},ot=({sort:t,column:n})=>t.includes(n)?e(Da,{transform:t.startsWith("-")?void 0:"rotate(180deg)"}):null,Ra=t=>{const{filters:n,users:{users:o},users:s,onEditingUser:i,onFilterChange:a}=E(),{t:l}=j(),[u,p]=f.exports.useState(void 0),C=Ae({base:120,lg:72})||72,[d,c]=f.exports.useState(`${C}px`),w=Ae({base:!1,md:!0});f.exports.useEffect(()=>{const g=()=>{const b=document.querySelectorAll("#filters")[0];c(`${b.offsetHeight}px`)};window.addEventListener("scroll",g)},[]);const v=o.length!==s.total,m=g=>{let b=n.sort;b.includes(g)?b.startsWith("-")?b="-created_at":b="-"+g:b=g,a({sort:b})},y=g=>{a({status:g.target.value.length>0?g.target.value:void 0})},T=g=>{p(g===u?void 0:g)};return r(D,{id:"users-table",overflowX:{base:"unset",md:"unset"},children:[e(pt,{allowMultiple:!0,display:{base:"block",md:"none"},index:u,children:r(or,{orientation:"vertical",zIndex:"docked",...t,children:[e(sr,{zIndex:"docked",position:"relative",children:r(Oe,{children:[e(ze,{position:"sticky",top:d,minW:"120px",pl:4,pr:4,cursor:"pointer",onClick:m.bind(null,"username"),children:r(_,{children:[e("span",{children:l("users")}),e(ot,{sort:n.sort,column:"username"})]})}),e(ze,{position:"sticky",top:d,minW:"50px",pl:0,pr:0,w:"140px",cursor:"pointer",children:r(_,{spacing:0,position:"relative",children:[r(h,{position:"absolute",_dark:{bg:"gray.750"},_light:{bg:"#F9FAFB"},userSelect:"none",pointerEvents:"none",zIndex:1,w:"100%",children:[l("usersTable.status"),n.status?": "+n.status:""]}),r(Me,{value:n.sort,fontSize:"xs",fontWeight:"extrabold",textTransform:"uppercase",cursor:"pointer",p:0,border:0,h:"auto",w:"auto",icon:e(ge,{}),_focusVisible:{border:"0 !important"},onChange:y,children:[e("option",{}),e("option",{children:"active"}),e("option",{children:"on_hold"}),e("option",{children:"disabled"}),e("option",{children:"limited"}),e("option",{children:"expired"})]})]})}),e(ze,{position:"sticky",top:d,minW:"100px",cursor:"pointer",pr:0,onClick:m.bind(null,"used_traffic"),children:r(_,{children:[e("span",{children:l("usersTable.dataUsage")}),e(ot,{sort:n.sort,column:"used_traffic"})]})}),e(ze,{position:"sticky",top:d,minW:"32px",w:"32px",p:0,cursor:"pointer"})]})}),e(ar,{children:!w&&(o==null?void 0:o.map((g,b)=>r(f.exports.Fragment,{children:[r(Oe,{onClick:T.bind(null,b),cursor:"pointer",children:[e(ue,{borderBottom:0,minW:"100px",pl:4,pr:4,maxW:"calc(100vw - 50px - 32px - 100px - 48px)",children:r("div",{className:"flex-status",children:[e(xr,{lastOnline:g.online_at}),e(h,{isTruncated:!0,children:g.username})]})}),e(ue,{borderBottom:0,minW:"50px",pl:0,pr:0,children:e(yt,{compact:!0,showDetail:!1,expiryDate:g.expire,status:g.status})}),e(ue,{borderBottom:0,minW:"100px",pr:0,children:e(Ua,{totalUsedTraffic:g.lifetime_used_traffic,dataLimitResetStrategy:g.data_limit_reset_strategy,used:g.used_traffic,total:g.data_limit,colorScheme:it[g.status].bandWidthColor})}),e(ue,{p:0,borderBottom:0,w:"32px",minW:"32px",children:e(ka,{color:"gray.600",_dark:{color:"gray.400"},transition:"transform .2s ease-out",transform:u===b?"rotate(180deg)":"0deg"})})]}),e(Oe,{className:"collapsible",onClick:T.bind(null,b),children:e(ue,{p:0,colSpan:4,children:r(He,{border:0,children:[e(Be,{display:"none"}),e($e,{border:0,cursor:"pointer",px:6,py:3,children:r(N,{justifyContent:"space-between",spacing:"4",children:[r(N,{alignItems:"flex-start",w:"full",spacing:-1,children:[e(h,{textTransform:"capitalize",fontSize:"xs",fontWeight:"bold",color:"gray.600",_dark:{color:"gray.400"},children:l("usersTable.dataUsage")}),e(D,{width:"full",minW:"230px",children:e(wr,{totalUsedTraffic:g.lifetime_used_traffic,dataLimitResetStrategy:g.data_limit_reset_strategy,used:g.used_traffic,total:g.data_limit,colorScheme:it[g.status].bandWidthColor})})]}),r(_,{w:"full",justifyContent:"space-between",children:[r(D,{width:"full",children:[e(yt,{compact:!0,expiryDate:g.expire,status:g.status}),e(yr,{lastOnline:g.online_at})]}),r(_,{children:[e(_r,{user:g}),e(ne,{label:l("userDialog.editUser"),placement:"top",children:e(Z,{p:"0 !important","aria-label":"Edit user",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},onClick:W=>{W.stopPropagation(),i(g)},children:e(za,{})})})]})]})]})})]})})})]},g.username)))})]})}),r(or,{orientation:"vertical",display:{base:"none",md:"table"},...t,children:[e(sr,{zIndex:"docked",position:"relative",children:r(Oe,{children:[e(ze,{position:"sticky",top:{base:"unset",md:d},minW:"140px",cursor:"pointer",onClick:m.bind(null,"username"),children:r(_,{children:[e("span",{children:l("username")}),e(ot,{sort:n.sort,column:"username"})]})}),e(ze,{position:"sticky",top:{base:"unset",md:d},width:"400px",minW:"150px",cursor:"pointer",children:r(_,{position:"relative",gap:"5px",children:[r(h,{_dark:{bg:"gray.750"},_light:{bg:"#F9FAFB"},userSelect:"none",pointerEvents:"none",zIndex:1,children:[l("usersTable.status"),n.status?": "+n.status:""]}),e(h,{children:"/"}),e(ot,{sort:n.sort,column:"expire"}),e(_,{onClick:m.bind(null,"expire"),children:e(h,{children:"Sort by expire"})}),r(Me,{fontSize:"xs",fontWeight:"extrabold",textTransform:"uppercase",cursor:"pointer",position:"absolute",p:0,left:"-40px",border:0,h:"auto",w:"auto",icon:e(ge,{}),_focusVisible:{border:"0 !important"},value:n.sort,onChange:y,children:[e("option",{}),e("option",{children:"active"}),e("option",{children:"on_hold"}),e("option",{children:"disabled"}),e("option",{children:"limited"}),e("option",{children:"expired"})]})]})}),e(ze,{position:"sticky",top:{base:"unset",md:d},width:"350px",minW:"230px",cursor:"pointer",onClick:m.bind(null,"used_traffic"),children:r(_,{children:[e("span",{children:l("usersTable.dataUsage")}),e(ot,{sort:n.sort,column:"used_traffic"})]})}),e(ze,{position:"sticky",top:{base:"unset",md:d},width:"200px",minW:"180px"})]})}),r(ar,{children:[w&&(o==null?void 0:o.map((g,b)=>r(Oe,{className:Ut("interactive",{"last-row":b===o.length-1}),onClick:()=>i(g),children:[e(ue,{minW:"140px",children:r("div",{className:"flex-status",children:[e(xr,{lastOnline:g.online_at}),g.username,e(yr,{lastOnline:g.online_at})]})}),e(ue,{width:"400px",minW:"150px",children:e(yt,{expiryDate:g.expire,status:g.status})}),e(ue,{width:"350px",minW:"230px",children:e(wr,{totalUsedTraffic:g.lifetime_used_traffic,dataLimitResetStrategy:g.data_limit_reset_strategy,used:g.used_traffic,total:g.data_limit,colorScheme:it[g.status].bandWidthColor})}),e(ue,{width:"200px",minW:"180px",children:e(_r,{user:g})})]},g.username))),o.length==0&&e(Oe,{children:e(ue,{colSpan:4,children:e(La,{isFiltered:v})})})]})]}),e(Ca,{})]})},_r=({user:t})=>{const{setQRCode:n,setSubLink:o}=E(),s=t.links.join(`\r -`),[i,a]=f.exports.useState([-1,!1]);return f.exports.useEffect(()=>{i[1]&&setTimeout(()=>{a([-1,!1])},1e3)},[i]),r(_,{justifyContent:"flex-end",onClick:l=>{l.preventDefault(),l.stopPropagation()},children:[e(ir,{text:t.subscription_url.startsWith("/")?window.location.origin+t.subscription_url:t.subscription_url,onCopy:()=>{a([0,!0])},children:e("div",{children:e(ne,{label:i[0]==0&&i[1]?X("usersTable.copied"):X("usersTable.copyLink"),placement:"top",children:e(Z,{p:"0 !important","aria-label":"copy subscription link",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},children:i[0]==0&&i[1]?e(Cr,{}):e(va,{})})})})}),e(ir,{text:s,onCopy:()=>{a([1,!0])},children:e("div",{children:e(ne,{label:i[0]==1&&i[1]?X("usersTable.copied"):X("usersTable.copyConfigs"),placement:"top",children:e(Z,{p:"0 !important","aria-label":"copy configs",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},children:i[0]==1&&i[1]?e(Cr,{}):e(_a,{})})})})}),e(ne,{label:"QR Code",placement:"top",children:e(Z,{p:"0 !important","aria-label":"qr code",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},onClick:()=>{n(t.links),o(t.subscription_url)},children:e(Ia,{})})})]})},La=({isFiltered:t})=>{const{onCreateUser:n}=E();return r(D,{padding:"5",py:"8",display:"flex",alignItems:"center",flexDirection:"column",gap:4,w:"full",children:[e(wa,{maxHeight:"200px",maxWidth:"200px",_dark:{'path[fill="#fff"]':{fill:"gray.800"},'path[fill="#f2f2f2"], path[fill="#e6e6e6"], path[fill="#ccc"]':{fill:"gray.700"},'circle[fill="#3182CE"]':{fill:"primary.300"}},_light:{'path[fill="#f2f2f2"], path[fill="#e6e6e6"], path[fill="#ccc"]':{fill:"gray.300"},'circle[fill="#3182CE"]':{fill:"primary.500"}}}),e(h,{fontWeight:"medium",color:"gray.600",_dark:{color:"gray.400"},children:t?X("usersTable.noUserMatched"):X("usersTable.noUser")}),!t&&e(F,{size:"sm",colorScheme:"primary",onClick:()=>n(!0),children:X("createUser")})]})},Ta=()=>(f.exports.useEffect(()=>{E.getState().refetchUsers(),Yo()},[]),r(N,{justifyContent:"space-between",minH:"100vh",p:"6",rowGap:4,children:[r(D,{w:"full",children:[e(ws,{}),e(Bo,{mt:"4"}),e(is,{}),e(Ra,{}),e(ma,{}),e(ns,{}),e(Xs,{}),e(Ts,{}),e(ta,{}),e(na,{}),e(Bs,{}),e(Ys,{}),e(Ks,{}),e(rs,{})]}),e(Kr,{})]})),Aa=t=>f.exports.createElement("svg",{viewBox:"0 0 747 747",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},f.exports.createElement("path",{d:"M746.671 209.652V77.6572C746.671 72.9384 743.827 68.6832 739.468 66.8811C735.108 65.0738 730.093 66.0739 726.754 69.4072L579.354 216.807C577.453 202.386 570.203 189.203 559.037 179.87C547.875 170.542 533.615 165.744 519.083 166.432C504.551 167.12 490.807 173.24 480.573 183.583L414.375 249.776C412.417 235.391 405.141 222.25 393.985 212.959C382.823 203.662 368.594 198.88 354.083 199.552C339.578 200.224 325.849 206.302 315.594 216.588L274.343 257.828L19.9167 3.41515C16.5781 0.0818157 11.5625 -0.918184 7.20306 0.889149C2.84373 2.69648 0 6.94648 0 11.6651V143.649C0 146.743 1.22917 149.712 3.41667 151.899L191.843 340.339L3.41667 528.753C1.2292 530.94 0 533.909 0 537.003V668.997C0 673.716 2.84373 677.971 7.20306 679.773C11.5624 681.581 16.578 680.58 19.9167 677.247L167.317 529.847C169.285 544.233 176.561 557.358 187.718 566.65C198.869 575.947 213.098 580.728 227.603 580.066C242.103 579.404 255.838 573.342 266.098 563.071L332.295 496.874V496.879C334.259 511.264 341.535 524.395 352.691 533.686C363.853 542.977 378.082 547.759 392.587 547.092C407.093 546.421 420.822 540.348 431.077 530.066L472.327 488.826L726.754 743.239C728.941 745.427 731.91 746.656 735.004 746.656C736.535 746.661 738.056 746.359 739.473 745.77C743.832 743.963 746.671 739.708 746.671 734.989V602.994C746.671 599.901 745.442 596.932 743.254 594.744L554.827 406.318L743.254 217.904H743.259C745.447 215.717 746.676 212.748 746.676 209.654L746.671 209.652ZM23.3373 39.8118L257.844 274.318L208.328 323.818L23.3413 138.818L23.3373 39.8118ZM723.337 706.825L488.831 472.318L538.347 422.818L723.333 607.818L723.337 706.825ZM23.3373 541.825L332.097 233.078C338.764 226.719 347.624 223.172 356.843 223.172C366.056 223.172 374.916 226.719 381.588 233.078C388.151 239.641 391.838 248.548 391.838 257.828C391.838 267.114 388.151 276.016 381.588 282.577L23.3347 640.831L23.3373 541.825ZM249.604 546.575C240.755 555.419 227.864 558.872 215.781 555.638C203.703 552.398 194.265 542.961 191.027 530.883C187.792 518.8 191.245 505.91 200.089 497.06L497.076 200.074C505.92 191.23 518.811 187.772 530.893 191.011C542.971 194.246 552.409 203.678 555.648 215.76C558.888 227.839 555.434 240.73 546.591 249.572L249.604 546.575ZM723.337 204.815L414.577 513.562C407.911 519.926 399.051 523.473 389.832 523.473C380.618 523.473 371.753 519.926 365.087 513.562C358.529 506.999 354.842 498.098 354.842 488.816C354.842 479.535 358.529 470.634 365.087 464.071L723.34 105.818L723.337 204.815Z",fill:"currentColor"})),Ma=S.object({username:S.string().min(1,"login.fieldRequired"),password:S.string().min(1,"login.fieldRequired")}),Na=x(Aa,{baseStyle:{strokeWidth:"10px",w:12,h:12}}),Fa=x(So,{baseStyle:{w:5,h:5,strokeWidth:"2px"}}),kr=()=>{var c,w;const[t,n]=f.exports.useState(""),[o,s]=f.exports.useState(!1),i=Co(),{t:a}=j();let l=wo();const{register:u,formState:{errors:p},handleSubmit:C}=Ve({resolver:ut(Ma)});f.exports.useEffect(()=>{No(),l.pathname!=="/login"&&i("/login",{replace:!0})},[]);const d=v=>{n("");const m=new FormData;m.append("username",v.username),m.append("password",v.password),m.append("grant_type","password"),s(!0),O("/admin/token",{method:"post",body:m}).then(({access_token:y})=>{Mo(y),i("/")}).catch(y=>{n(y.response._data.detail)}).finally(s.bind(null,!1))};return r(N,{justifyContent:"space-between",minH:"100vh",p:"6",w:"full",children:[r(D,{w:"full",children:[e(_,{justifyContent:"end",w:"full",children:e(en,{})}),e(_,{w:"full",justifyContent:"center",alignItems:"center",children:r(D,{w:"full",maxW:"340px",mt:"6",children:[r(N,{alignItems:"center",w:"full",children:[e(Na,{}),e(h,{fontSize:"2xl",fontWeight:"semibold",children:a("login.loginYourAccount")}),e(h,{color:"gray.600",_dark:{color:"gray.400"},children:a("login.welcomeBack")})]}),e(D,{w:"full",maxW:"300px",m:"auto",pt:"4",children:e("form",{onSubmit:C(d),children:r(N,{mt:4,rowGap:2,children:[e(R,{children:e(Ue,{w:"full",placeholder:a("username"),...u("username"),error:a((c=p==null?void 0:p.username)==null?void 0:c.message)})}),e(R,{children:e(Ue,{w:"full",type:"password",placeholder:a("password"),...u("password"),error:a((w=p==null?void 0:p.password)==null?void 0:w.message)})}),t&&r(ct,{status:"error",rounded:"md",children:[e(kt,{}),e(Pr,{children:t})]}),r(F,{isLoading:o,type:"submit",w:"full",colorScheme:"primary",children:[e(Fa,{marginRight:1}),a("login")]})]})})})]})})]}),e(Kr,{})]})},Pa=()=>O("/admin",{headers:{Authorization:`Bearer ${vt()}`}}),Wa=_o([{path:"/",element:e(Ta,{}),errorElement:e(kr,{}),loader:Pa},{path:"/login/",element:e(kr,{})}],{basename:"/dashboard/"});function Oa(){return e("main",{className:"p-8",children:e(ko,{router:Wa})})}B.extend(vo);B.extend(Io);B.extend(zo);B.extend(Do);B.extend(Eo);Qr(Uo.get()||"light");Ro.createRoot(document.getElementById("root")).render(e(Nt.StrictMode,{children:e(Lo,{theme:Ao,children:e(To,{client:Pt,children:e(Oa,{})})})})); + `}},colors:$s(o.length)}}}const Gs=y(Dt,{baseStyle:{w:5,h:5}}),Ys=()=>{const{isShowingNodesUsage:t,onShowingNodesUsage:n}=E(),{fetchNodesUsage:o}=gt(),{t:s}=j(),[i,a]=f.exports.useState(!1),{colorMode:l}=ht(),u=s("userDialog.total"),[p,C]=f.exports.useState(It(l,u)),[d,c]=f.exports.useState("1m"),w=S=>{o(S).then(T=>{const g=[],b=[];for(const W in T.usages){const $=T.usages[W];b.push($.uplink+$.downlink),g.push($.node_name)}C(It(l,u,b,g))})};f.exports.useEffect(()=>{t&&w({start:B().utc().subtract(30,"day").format("YYYY-MM-DDTHH:00:00")})},[t]);const v=()=>{n(!1),c("1m")},m=i;return r(oe,{isOpen:t,onClose:v,size:"2xl",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"full",children:[e(ie,{pt:6,children:r(_,{gap:2,children:[e(de,{color:"primary",children:e(Gs,{color:"white"})}),e(h,{fontWeight:"semibold",fontSize:"lg",children:s("header.nodesUsage")})]})}),e(le,{mt:3,disabled:m}),e(ce,{children:r(N,{gap:4,children:[e(on,{defaultValue:d,onChange:(S,T)=>{c(S),w(T)}}),e(D,{justifySelf:"center",w:"full",maxW:"300px",mt:"4",children:e(f.exports.Suspense,{fallback:e(Dr,{isIndeterminate:!0}),children:e(Hr,{options:p.options,series:p.series,type:"donut",height:"500px"})})})]})}),e(Re,{mt:"3"})]})]})},br=y(oo),Zs=y(Or,{baseStyle:{w:6,h:6,color:"gray.600",_dark:{color:"white"}}}),Qs=y(so,{baseStyle:{w:6,h:6,color:"gray.600",_dark:{color:"white"}}}),qs=y(Br,{baseStyle:{w:5,h:5}}),Xs=()=>{const{QRcodeLinks:t,setQRCode:n,setSubLink:o,subscribeUrl:s}=E(),i=t!==null,[a,l]=f.exports.useState(0),{t:u}=j(),p=()=>{n(null),o(null)},C=String(s).startsWith("/")?window.location.origin+s:String(s);return r(oe,{isOpen:i,onClose:p,children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(ie,{pt:6,children:e(de,{color:"primary",children:e(qs,{color:"white"})})}),e(le,{mt:3}),t&&r(ce,{gap:{base:"20px",lg:"50px"},pr:{lg:"60px"},px:{base:"50px"},display:"flex",justifyContent:"center",flexDirection:{base:"column",lg:"row"},children:[s&&r(N,{children:[e(br,{mx:"auto",size:300,p:"2",level:"L",includeMargin:!1,value:C,bg:"white"}),e(h,{display:"block",textAlign:"center",pb:3,mt:1,children:u("qrcodeDialog.sublink")})]}),r(D,{w:"300px",children:[e(ao,{centerPadding:"0px",centerMode:!0,slidesToShow:1,slidesToScroll:1,dots:!1,afterChange:l,onInit:()=>l(0),nextArrow:e(Z,{size:"sm",position:"absolute",display:"flex !important",_before:{content:'""'},"aria-label":"next",mr:"-4",children:e(Zs,{})}),prevArrow:e(Z,{size:"sm",position:"absolute",display:"flex !important",_before:{content:'""'},"aria-label":"prev",ml:"-4",children:e(Qs,{})}),children:t.map((d,c)=>e(_,{children:e(br,{mx:"auto",size:300,p:"2",level:"L",includeMargin:!1,value:d,bg:"white"})},c))}),r(h,{display:"block",textAlign:"center",pb:3,mt:1,children:[a+1," / ",t.length]})]})]})]})]})},Js=y(Mr,{baseStyle:{w:5,h:5}}),Ks=()=>{const[t,n]=f.exports.useState(!1),{isResetingAllUsage:o,onResetAllUsage:s,resetAllUsage:i}=E(),{t:a}=j(),l=fe(),u=()=>{s(!1)},p=()=>{n(!0),i().then(()=>{l({title:a("resetAllUsage.success"),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(()=>{l({title:a("resetAllUsage.error"),status:"error",isClosable:!0,position:"top",duration:3e3})}).finally(()=>{n(!1)})};return r(oe,{isCentered:!0,isOpen:o,onClose:u,size:"sm",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",children:[e(ie,{pt:6,children:e(de,{color:"red",children:e(Js,{})})}),e(le,{mt:3}),r(ce,{children:[e(h,{fontWeight:"semibold",fontSize:"lg",children:a("resetAllUsage.title")}),o&&e(h,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:a("resetAllUsage.prompt")})]}),r(Re,{display:"flex",children:[e(F,{size:"sm",onClick:u,mr:3,w:"full",variant:"outline",children:a("cancel")}),e(F,{size:"sm",w:"full",colorScheme:"red",onClick:p,leftIcon:t?e(Ne,{size:"xs"}):void 0,children:a("reset")})]})]})]})},ea=y(Et,{baseStyle:{w:5,h:5}}),ta=()=>{const[t,n]=f.exports.useState(!1),{resetUsageUser:o,resetDataUsage:s}=E(),{t:i}=j(),a=fe(),l=()=>{E.setState({resetUsageUser:null})},u=()=>{o&&(n(!0),s(o).then(()=>{a({title:i("resetUserUsage.success",{username:o.username}),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(()=>{a({title:i("resetUserUsage.error"),status:"error",isClosable:!0,position:"top",duration:3e3})}).finally(()=>{n(!1)}))};return r(oe,{isCentered:!0,isOpen:!!o,onClose:l,size:"sm",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",children:[e(ie,{pt:6,children:e(de,{color:"blue",children:e(ea,{})})}),e(le,{mt:3}),r(ce,{children:[e(h,{fontWeight:"semibold",fontSize:"lg",children:i("resetUserUsage.title")}),o&&e(h,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(Ee,{components:{b:e("b",{})},children:i("resetUserUsage.prompt",{username:o.username})})})]}),r(Re,{display:"flex",children:[e(F,{size:"sm",onClick:l,mr:3,w:"full",variant:"outline",children:i("cancel")}),e(F,{size:"sm",w:"full",colorScheme:"blue",onClick:u,leftIcon:t?e(Ne,{size:"xs"}):void 0,children:i("reset")})]})]})]})},ra=y(Et,{baseStyle:{w:5,h:5}}),na=()=>{const[t,n]=f.exports.useState(!1),{revokeSubscriptionUser:o,revokeSubscription:s}=E(),{t:i}=j(),a=fe(),l=()=>{E.setState({revokeSubscriptionUser:null})},u=()=>{o&&(n(!0),s(o).then(()=>{a({title:i("revokeUserSub.success",{username:o.username}),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(()=>{a({title:i("revokeUserSub.error"),status:"error",isClosable:!0,position:"top",duration:3e3})}).finally(()=>{n(!1)}))};return r(oe,{isCentered:!0,isOpen:!!o,onClose:l,size:"sm",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",children:[e(ie,{pt:6,children:e(de,{color:"blue",children:e(ra,{})})}),e(le,{mt:3}),r(ce,{children:[e(h,{fontWeight:"semibold",fontSize:"lg",children:i("revokeUserSub.title")}),o&&e(h,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(Ee,{components:{b:e("b",{})},children:i("revokeUserSub.prompt",{username:o.username})})})]}),r(Re,{display:"flex",children:[e(F,{size:"sm",onClick:l,mr:3,w:"full",variant:"outline",children:i("cancel")}),e(F,{size:"sm",w:"full",colorScheme:"blue",onClick:u,leftIcon:t?e(Ne,{size:"xs"}):void 0,children:i("revoke")})]})]})]})},oa=y(io,{baseStyle:{strokeWidth:"2px",w:5,h:5}}),sa=({inbound:t,...n})=>{const{getCheckboxProps:o,getInputProps:s,getLabelProps:i,htmlProps:a}=Vr(n),l=s();return r(D,{as:"label",children:[e("input",{...l}),r(D,{w:"fll",position:"relative",...a,cursor:"pointer",borderRadius:"sm",border:"1px solid",borderColor:"gray.200",_dark:{borderColor:"gray.600"},display:"flex",alignItems:"center",justifyContent:"space-between",overflow:"hidden",_checked:{bg:"gray.50",outline:"2px",boxShadow:"outline",outlineColor:"primary.500",borderColor:"transparent",fontWeight:"medium",_dark:{bg:"gray.750",borderColor:"transparent"},"& p":{opacity:1}},__css:{"& p":{opacity:.8}},textTransform:"capitalize",px:3,py:2,fontWeight:"medium",...o(),children:[e(at,{size:"sm",w:"full",maxW:"full",color:"gray.700",_dark:{color:"gray.300"},textTransform:"uppercase",colorScheme:"primary",className:"inbound-item",isChecked:l.checked,pointerEvents:"none",flexGrow:1,children:e(_,{justify:"space-between",w:"full",maxW:"calc(100% - 20px)",spacing:0,gap:2,overflow:"hidden",children:r(h,{isTruncated:!0,...i(),fontSize:"xs",children:[t.tag," ",r(h,{as:"span",children:["(",t.network,")"]})]})})}),t.tls&&t.tls!="none"&&e(U,{fontSize:"xs",opacity:".8",size:"xs",children:t.tls})]})]})},aa=({disabled:t,title:n,description:o,toggleAccordion:s,isSelected:i,...a})=>{const l=Vt(),{inbounds:u}=E(),{getCheckboxProps:p,getInputProps:C,getLabelProps:d,htmlProps:c}=Vr(a),w=C(),[v]=Gr({name:[`inbounds.${n}`],control:l.control}),{getCheckboxProps:m}=$r({value:v,onChange:b=>{if(l.setValue(`inbounds.${n}`,b),b.length===0){const W=l.getValues("selected_proxies");l.setValue("selected_proxies",W.filter($=>$!==n)),s()}}}),S=v&&i&&(E.getState().inbounds.get(n)||[]).length!==v.length,T=(E.getState().inbounds.get(n)||[]).length>0,g=!i&&!T;return r(He,{isDisabled:!T,borderRadius:"md",borderStyle:"solid",border:"1px",borderColor:"gray.200",bg:g?"gray.100":"transparent",_dark:{borderColor:"gray.600",bg:g?"#364154":"transparent"},_checked:{bg:"gray.50",outline:"2px",boxShadow:"outline",outlineColor:"primary.500",borderColor:"transparent"},...p(),children:[r(D,{as:g?"span":"label",position:"relative",children:[S&&e(D,{position:"absolute",w:"2",h:"2",bg:"yellow.500",top:"-1",right:"-1",rounded:"full",zIndex:999}),e("input",{...w}),r(D,{w:"fll",position:"relative",...c,borderRadius:"md",cursor:g?"not-allowed":"pointer",_checked:{fontWeight:"medium",_dark:{bg:"gray.750",borderColor:"transparent"},"& > svg":{opacity:1,"&.checked":{display:"block"},"&.unchecked":{display:"none"}},"& p":{opacity:1}},__css:{"& > svg":{opacity:.3,"&.checked":{display:"none"},"&.unchecked":{display:"block"}},"& p":{opacity:.8}},textTransform:"capitalize",px:3,py:2,fontWeight:"medium",...p(),children:[e(Be,{display:w.checked&&T?"block":"none",as:"span",className:"checked",color:"primary.200",position:"absolute",right:"3",top:"3",w:"auto",p:0,onClick:s,children:e(Z,{size:"sm","aria-label":"inbound settings",children:e(oa,{})})}),e(h,{fontSize:"sm",color:g?"gray.400":"gray.700",_dark:{color:g?"gray.500":"gray.300"},...d(),children:n}),e(h,{fontWeight:"medium",color:g?"gray.400":"gray.600",_dark:{color:g?"gray.500":"gray.400"},fontSize:"xs",children:o})]})]}),e($e,{px:2,pb:3,roundedBottom:"5px",pt:3,_dark:{bg:w.checked&&"gray.750"},children:r(N,{w:"full",rowGap:2,borderStyle:"solid",borderWidth:"1px",borderRadius:"md",pl:3,pr:3,pt:1.5,_dark:{bg:"gray.700"},children:[r(N,{alignItems:"flex-start",w:"full",children:[e(h,{fontSize:"sm",children:X("inbound")}),e(Yt,{gap:2,alignItems:"flex-start",w:"full",columns:1,spacing:1,children:(u.get(n)||[]).map(b=>e(sa,{...m({value:b.tag}),inbound:b},b.tag))})]}),n==="vmess"&&i&&e(N,{alignItems:"flex-start",w:"full",children:r(R,{height:"66px",children:[e(h,{fontSize:"sm",pb:1,children:"ID"}),e(je,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.vmess.id")})]})}),n==="vless"&&i&&r(N,{alignItems:"flex-start",w:"full",children:[r(R,{height:"66px",children:[e(h,{fontSize:"sm",pb:1,children:"ID"}),e(je,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.vless.id")})]}),r(R,{height:"66px",children:[e(h,{fontSize:"sm",pb:1,children:"Flow"}),e(Me,{fontSize:"xs",size:"sm",borderRadius:"6px",...l.register("proxies.vless.flow"),children:Is.map(b=>e("option",{value:b.value,children:b.title},b.title))})]})]}),n==="trojan"&&i&&e(N,{alignItems:"flex-start",w:"full",children:r(R,{height:"66px",children:[e(h,{fontSize:"sm",pb:1,children:X("password")}),e(je,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.trojan.password")})]})}),n==="shadowsocks"&&i&&r(N,{alignItems:"flex-start",w:"full",children:[r(R,{height:"66px",children:[e(h,{fontSize:"sm",pb:1,children:X("password")}),e(je,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.shadowsocks.password")})]}),r(R,{height:"66px",children:[e(h,{fontSize:"sm",pb:1,children:X("userDialog.method")}),e(Me,{fontSize:"xs",size:"sm",borderRadius:"6px",...l.register("proxies.shadowsocks.method"),children:zs.map(b=>e("option",{value:b,children:b},b))})]})]})]})})]})},ia=f.exports.forwardRef(({name:t,list:n,onChange:o,disabled:s,...i},a)=>{const l=Vt(),[u,p]=f.exports.useState([]),C=c=>{u.includes(c)?u.splice(u.indexOf(c),1):u.push(c),p([...u])},{getCheckboxProps:d}=$r({value:i.value,onChange:c=>{var v;const w=c.filter(m=>!i.value.includes(m));w[0]&&l.setValue(`inbounds.${w[0]}`,(v=E.getState().inbounds.get(w[0]))==null?void 0:v.map(m=>m.tag)),p(u.filter(m=>c.find(S=>S===n[m].title))),o({target:{value:c,name:t}})}});return e(pt,{allowToggle:!0,index:u,children:e(Yt,{ref:a,gap:2,alignItems:"flex-start",columns:1,spacing:1,children:n.map((c,w)=>e(aa,{toggleAccordion:C.bind(null,w),disabled:s,title:c.title,description:c.description,isSelected:!!i.value.find(v=>v===c.title),...d({value:c.title})},c.title))})})}),la=y(lo,{baseStyle:{w:5,h:5}}),ca=y(Yr,{baseStyle:{w:5,h:5}}),da=y(Dt,{baseStyle:{w:5,h:5}}),ha=t=>({...t,data_limit:t.data_limit?Number((t.data_limit/1073741824).toFixed(5)):t.data_limit,on_hold_expire_duration:t.on_hold_expire_duration?Number(t.on_hold_expire_duration/(24*60*60)):t.on_hold_expire_duration,selected_proxies:Object.keys(t.proxies)}),At=()=>{const t=Object.fromEntries(E.getState().inbounds),n={};for(const o in t)n[o]=t[o].map(s=>s.tag);return{selected_proxies:Object.keys(t),data_limit:null,expire:null,username:"",data_limit_reset_strategy:"no_reset",status:"active",on_hold_expire_duration:null,note:"",inbounds:n,proxies:{vless:{id:"",flow:""},vmess:{id:""},trojan:{password:""},shadowsocks:{password:"",method:"chacha20-ietf-poly1305"}}}},ua=(t,n)=>{const o=t.reduce((s,i)=>({...s,[i]:{}}),{});return n&&t.forEach(s=>{n[s]&&(o[s]=n[s])}),o},Mt={username:x.string().min(1,{message:"Required"}),selected_proxies:x.array(x.string()).refine(t=>t.length>0,{message:"userDialog.selectOneProtocol"}),note:x.string().nullable(),proxies:x.record(x.string(),x.record(x.string(),x.any())).transform(t=>{const n=(o,s)=>{o&&o[s]===""&&delete o[s]};return n(t.vmess,"id"),n(t.vless,"id"),n(t.trojan,"password"),n(t.shadowsocks,"password"),n(t.shadowsocks,"method"),t}),data_limit:x.string().min(0).or(x.number()).nullable().transform(t=>t?Number((parseFloat(String(t))*1073741824).toFixed(5)):0),expire:x.number().nullable(),data_limit_reset_strategy:x.string(),inbounds:x.record(x.string(),x.array(x.string())).transform(t=>(Object.keys(t).forEach(n=>{var o;Array.isArray(t[n])&&!((o=t[n])!=null&&o.length)&&delete t[n]}),t))},pa=x.discriminatedUnion("status",[x.object({status:x.literal("active"),...Mt}),x.object({status:x.literal("disabled"),...Mt}),x.object({status:x.literal("on_hold"),on_hold_expire_duration:x.coerce.number().min(.1,"Required").transform(t=>t*(24*60*60)),...Mt})]),ma=()=>{var Ye,Ze,Qe,qe,Xe;const{editingUser:t,isCreatingNewUser:n,onCreateUser:o,editUser:s,fetchUserUsage:i,onEditingUser:a,createUser:l,onDeletingUser:u}=E(),p=!!t,C=n||p,[d,c]=f.exports.useState(!1),[w,v]=f.exports.useState(""),m=fe(),{t:S,i18n:T}=j(),{colorMode:g}=ht(),[b,W]=f.exports.useState(!1),$=()=>{W(k=>!k)},I=Ve({defaultValues:At(),resolver:ut(pa)});f.exports.useEffect(()=>E.subscribe(k=>k.inbounds,()=>{I.reset(At())}),[]);const[A,Y]=Gr({control:I.control,name:["data_limit","status"]}),q=S("userDialog.total"),[L,V]=f.exports.useState(It(g,q)),[J,z]=f.exports.useState("1m"),P=k=>{i(t,k).then(M=>{const te=[],xe=[];for(const he in M.usages)xe.push(M.usages[he].used_traffic),te.push(M.usages[he].node_name);V(It(g,q,xe,te))})};f.exports.useEffect(()=>{t&&(I.reset(ha(t)),P({start:B().utc().subtract(30,"day").format("YYYY-MM-DDTHH:00:00")}))},[t]);const K=k=>{c(!0);const M={edited:s,created:l},te=p?"edited":"created";v(null);const{selected_proxies:xe,...he}=k;let ye={...he,data_limit:k.data_limit,proxies:ua(xe,k.proxies),data_limit_reset_strategy:k.data_limit&&k.data_limit>0?k.data_limit_reset_strategy:"no_reset",status:k.status==="active"||k.status==="disabled"||k.status==="on_hold"?k.status:"active"};M[te](ye).then(()=>{m({title:S(p?"userDialog.userEdited":"userDialog.userCreated",{username:k.username}),status:"success",isClosable:!0,position:"top",duration:3e3}),Fe()}).catch(G=>{var Je,Ke,et,tt,Q;(((Je=G==null?void 0:G.response)==null?void 0:Je.status)===409||((Ke=G==null?void 0:G.response)==null?void 0:Ke.status)===400)&&v((tt=(et=G==null?void 0:G.response)==null?void 0:et._data)==null?void 0:tt.detail),((Q=G==null?void 0:G.response)==null?void 0:Q.status)===422&&Object.keys(G.response._data.detail).forEach(We=>{v(G==null?void 0:G.response._data.detail[We]),I.setError(We,{type:"custom",message:G.response._data.detail[We]})})}).finally(()=>{c(!1)})},Fe=()=>{I.reset(At()),o(!1),a(null),v(null),W(!1),z("1m")},bt=()=>{E.setState({resetUsageUser:t})},xt=()=>{E.setState({revokeSubscriptionUser:t})},ee=d,Pe=Y==="on_hold";return r(oe,{isOpen:C,onClose:Fe,size:"2xl",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),e(Nr,{...I,children:e(ae,{mx:"3",children:r("form",{onSubmit:I.handleSubmit(K),children:[e(ie,{pt:6,children:r(_,{gap:2,children:[e(de,{color:"primary",children:p?e(ca,{color:"white"}):e(la,{color:"white"})}),e(h,{fontWeight:"semibold",fontSize:"lg",children:S(p?"userDialog.editUserTitle":"createNewUser")})]})}),e(le,{mt:3,disabled:ee}),r(ce,{children:[r(Ur,{templateColumns:{base:"repeat(1, 1fr)",md:"repeat(2, 1fr)"},gap:3,children:[e(st,{children:r(N,{justifyContent:"space-between",children:[r(or,{flexDirection:"column",gridAutoRows:"min-content",w:"full",children:[r(or,{flexDirection:"row",w:"full",gap:2,children:[r(R,{mb:"10px",children:[e(H,{children:S("username")}),r(_,{children:[e(Ue,{size:"sm",type:"text",borderRadius:"6px",error:(Ye=I.formState.errors.username)==null?void 0:Ye.message,disabled:ee||p,...I.register("username")}),p&&e(_,{px:1,children:e(pe,{name:"status",control:I.control,render:({field:k})=>e(ne,{placement:"top",label:"status: "+S(k.value),textTransform:"capitalize",children:e(D,{children:e(_t,{colorScheme:"primary",isChecked:k.value==="active",onChange:M=>{M.target.checked?k.onChange("active"):k.onChange("disabled")}})})})})})]})]}),!p&&r(R,{flex:"1",children:[e(H,{whiteSpace:"nowrap",children:S("userDialog.onHold")}),e(pe,{name:"status",control:I.control,render:({field:k})=>{const M=k.value;return e(ge,{children:M?e(_t,{colorScheme:"primary",isChecked:M==="on_hold",onChange:te=>{te.target.checked?k.onChange("on_hold"):k.onChange("active")}}):""})}})]})]}),r(R,{mb:"10px",children:[e(H,{children:S("userDialog.dataLimit")}),e(pe,{control:I.control,name:"data_limit",render:({field:k})=>{var M;return e(Ue,{endAdornment:"GB",type:"number",size:"sm",borderRadius:"6px",onChange:k.onChange,disabled:ee,error:(M=I.formState.errors.data_limit)==null?void 0:M.message,value:k.value?String(k.value):""})}})]}),e(Wr,{in:!!(A&&A>0),animateOpacity:!0,style:{width:"100%"},children:r(R,{height:"66px",children:[e(H,{children:S("userDialog.periodicUsageReset")}),e(pe,{control:I.control,name:"data_limit_reset_strategy",render:({field:k})=>e(Me,{size:"sm",...k,disabled:ee,bg:ee?"gray.100":"transparent",_dark:{bg:ee?"gray.600":"transparent"},children:jt.map(M=>e("option",{value:M.value,children:S("userDialog.resetStrategy"+M.title)},M.value))})})]})}),r(R,{mb:"10px",children:[e(H,{children:S(Pe?"userDialog.onHoldExpireDuration":"userDialog.expiryDate")}),Pe&&e(pe,{control:I.control,name:"on_hold_expire_duration",render:({field:k})=>{var M;return e(Ue,{endAdornment:"Days",type:"number",size:"sm",borderRadius:"6px",onChange:te=>{I.setValue("expire",null),k.onChange({target:{value:te}})},disabled:ee,error:(M=I.formState.errors.on_hold_expire_duration)==null?void 0:M.message,value:k.value?String(k.value):""})}}),!Pe&&e(pe,{name:"expire",control:I.control,render:({field:k})=>{var he;function M(ye){return B(B(ye*1e3).utc()).toDate()}const{status:te,time:xe}=Xt(k.value);return r(ge,{children:[e(jr,{locale:T.language.toLocaleLowerCase(),dateFormat:S("dateFormat"),minDate:new Date,selected:k.value?M(k.value):void 0,onChange:ye=>{I.setValue("on_hold_expire_duration",null),k.onChange({target:{value:ye?B(B(ye).set("hour",23).set("minute",59).set("second",59)).utc().valueOf()/1e3:0,name:"expire"}})},customInput:e(Ue,{size:"sm",type:"text",borderRadius:"6px",clearable:!0,disabled:ee,error:(he=I.formState.errors.expire)==null?void 0:he.message})}),k.value?e(co,{children:S(te,{time:xe})}):""]})}})]}),r(R,{mb:"10px",isInvalid:!!I.formState.errors.note,children:[e(H,{children:S("userDialog.note")}),e(ho,{...I.register("note")}),e(wt,{children:(Qe=(Ze=I.formState.errors)==null?void 0:Ze.note)==null?void 0:Qe.message})]})]}),w&&r(ct,{status:"error",display:{base:"none",md:"flex"},children:[e(kt,{}),w]})]})}),e(st,{children:r(R,{isInvalid:!!((qe=I.formState.errors.selected_proxies)!=null&&qe.message),children:[e(H,{children:S("userDialog.protocols")}),e(pe,{control:I.control,name:"selected_proxies",render:({field:k})=>e(ia,{list:[{title:"vmess",description:S("userDialog.vmessDesc")},{title:"vless",description:S("userDialog.vlessDesc")},{title:"trojan",description:S("userDialog.trojanDesc")},{title:"shadowsocks",description:S("userDialog.shadowsocksDesc")}],disabled:ee,...k})}),e(wt,{children:S((Xe=I.formState.errors.selected_proxies)==null?void 0:Xe.message)})]})}),p&&b&&e(st,{pt:6,colSpan:{base:1,md:2},children:r(N,{gap:4,children:[e(on,{defaultValue:J,onChange:(k,M)=>{z(k),P(M)}}),e(D,{width:{base:"100%",md:"70%"},justifySelf:"center",children:e(Hr,{options:L.options,series:L.series,type:"donut"})})]})})]}),w&&r(ct,{mt:"3",status:"error",display:{base:"flex",md:"none"},children:[e(kt,{}),w]})]}),e(Re,{mt:"3",children:r(_,{justifyContent:"space-between",w:"full",gap:3,flexDirection:{base:"column",sm:"row"},children:[e(_,{justifyContent:"flex-start",w:{base:"full",sm:"unset"},children:p&&r(ge,{children:[e(ne,{label:S("delete"),placement:"top",children:e(Z,{"aria-label":"Delete",size:"sm",onClick:()=>{u(t),Fe()},children:e(mt,{})})}),e(ne,{label:S("userDialog.usage"),placement:"top",children:e(Z,{"aria-label":"usage",size:"sm",onClick:$,children:e(da,{})})}),e(F,{onClick:bt,size:"sm",children:S("userDialog.resetUsage")}),e(F,{onClick:xt,size:"sm",children:S("userDialog.revokeSubscription")})]})}),e(_,{w:"full",maxW:{md:"50%",base:"full"},justify:"end",children:e(F,{type:"submit",size:"sm",px:"8",colorScheme:"primary",leftIcon:d?e(Ne,{size:"xs"}):void 0,disabled:ee,children:S(p?"userDialog.editUser":"createUser")})})]})})]})})})]})},ga=t=>f.exports.createElement("svg",{xmlns:"http://www.w3.org/2000/svg","data-name":"Layer 1",width:782.04441,height:701.88002,viewBox:"0 0 782.04441 701.88002",xmlnsXlink:"http://www.w3.org/1999/xlink",...t},f.exports.createElement("path",{d:"M609.48783,100.59015l-25.44631,6.56209L270.53735,187.9987,245.091,194.56079A48.17927,48.17927,0,0,0,210.508,253.17865L320.849,681.05606a48.17924,48.17924,0,0,0,58.61776,34.58317l.06572-.01695,364.26536-93.93675.06572-.01695a48.17923,48.17923,0,0,0,34.58309-58.6178l-110.341-427.87741A48.17928,48.17928,0,0,0,609.48783,100.59015Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),f.exports.createElement("path",{d:"M612.94784,114.00532l-30.13945,7.77236L278.68955,200.20385l-30.139,7.77223a34.30949,34.30949,0,0,0-24.6275,41.74308l110.341,427.87741a34.30946,34.30946,0,0,0,41.7431,24.62736l.06572-.01695,364.26536-93.93674.06619-.01707a34.30935,34.30935,0,0,0,24.627-41.7429l-110.341-427.87741A34.30938,34.30938,0,0,0,612.94784,114.00532Z",transform:"translate(-208.9778 -99.05999)",fill:"#fff"}),f.exports.createElement("path",{d:"M590.19,252.56327,405.917,300.08359a8.01411,8.01411,0,0,1-4.00241-15.52046l184.273-47.52033A8.01412,8.01412,0,0,1,590.19,252.56327Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),f.exports.createElement("path",{d:"M628.955,270.49906,412.671,326.27437a8.01411,8.01411,0,1,1-4.00241-15.52046l216.284-55.77531a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),f.exports.createElement("path",{d:"M620.45825,369.93676l-184.273,47.52032a8.01411,8.01411,0,1,1-4.00242-15.52046l184.273-47.52032a8.01411,8.01411,0,1,1,4.00241,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),f.exports.createElement("path",{d:"M659.22329,387.87255l-216.284,55.77531a8.01411,8.01411,0,1,1-4.00242-15.52046l216.284-55.77531a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),f.exports.createElement("path",{d:"M650.72653,487.31025l-184.273,47.52033a8.01412,8.01412,0,0,1-4.00242-15.52047l184.273-47.52032a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),f.exports.createElement("path",{d:"M689.49156,505.246l-216.284,55.77532a8.01412,8.01412,0,1,1-4.00241-15.52047l216.284-55.77531a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),f.exports.createElement("path",{d:"M374.45884,348.80871l-65.21246,16.817a3.847,3.847,0,0,1-4.68062-2.76146L289.5963,304.81607a3.847,3.847,0,0,1,2.76145-4.68061l65.21247-16.817a3.847,3.847,0,0,1,4.68061,2.76145l14.96947,58.04817A3.847,3.847,0,0,1,374.45884,348.80871Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M404.72712,466.1822l-65.21247,16.817a3.847,3.847,0,0,1-4.68062-2.76146l-14.96946-58.04816A3.847,3.847,0,0,1,322.626,417.509l65.21246-16.817a3.847,3.847,0,0,1,4.68062,2.76145l14.96946,58.04817A3.847,3.847,0,0,1,404.72712,466.1822Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M434.99539,583.55569l-65.21246,16.817a3.847,3.847,0,0,1-4.68062-2.76145l-14.96946-58.04817a3.847,3.847,0,0,1,2.76145-4.68062l65.21247-16.817a3.847,3.847,0,0,1,4.68061,2.76146l14.96947,58.04816A3.847,3.847,0,0,1,434.99539,583.55569Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M863.63647,209.0517H487.31811a48.17928,48.17928,0,0,0-48.125,48.12512V699.05261a48.17924,48.17924,0,0,0,48.125,48.12507H863.63647a48.17924,48.17924,0,0,0,48.125-48.12507V257.17682A48.17928,48.17928,0,0,0,863.63647,209.0517Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M863.637,222.90589H487.31811a34.30948,34.30948,0,0,0-34.271,34.27093V699.05261a34.30947,34.30947,0,0,0,34.271,34.27088H863.637a34.30936,34.30936,0,0,0,34.27051-34.27088V257.17682A34.30937,34.30937,0,0,0,863.637,222.90589Z",transform:"translate(-208.9778 -99.05999)",fill:"#fff"}),f.exports.createElement("circle",{cx:694.19401,cy:614.02963,r:87.85039,fill:"#3182CE"}),f.exports.createElement("path",{d:"M945.18722,701.63087H914.63056V671.07421a11.45875,11.45875,0,0,0-22.9175,0v30.55666H861.1564a11.45875,11.45875,0,0,0,0,22.9175h30.55666V755.105a11.45875,11.45875,0,1,0,22.9175,0V724.54837h30.55666a11.45875,11.45875,0,0,0,0-22.9175Z",transform:"translate(-208.9778 -99.05999)",fill:"#fff"}),f.exports.createElement("path",{d:"M807.00068,465.71551H616.699a8.01412,8.01412,0,1,1,0-16.02823H807.00068a8.01412,8.01412,0,0,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M840.05889,492.76314H616.699a8.01412,8.01412,0,1,1,0-16.02823H840.05889a8.01411,8.01411,0,1,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M807.00068,586.929H616.699a8.01412,8.01412,0,1,1,0-16.02823H807.00068a8.01411,8.01411,0,0,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M840.05889,613.97661H616.699a8.01412,8.01412,0,1,1,0-16.02823H840.05889a8.01412,8.01412,0,1,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M574.07028,505.04162H506.72434a3.847,3.847,0,0,1-3.84278-3.84278V441.25158a3.847,3.847,0,0,1,3.84278-3.84278h67.34594a3.847,3.847,0,0,1,3.84278,3.84278v59.94726A3.847,3.847,0,0,1,574.07028,505.04162Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M574.07028,626.25509H506.72434a3.847,3.847,0,0,1-3.84278-3.84278V562.46505a3.847,3.847,0,0,1,3.84278-3.84278h67.34594a3.847,3.847,0,0,1,3.84278,3.84278v59.94726A3.847,3.847,0,0,1,574.07028,626.25509Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),f.exports.createElement("path",{d:"M807.21185,330.781H666.91017a8.01411,8.01411,0,0,1,0-16.02823H807.21185a8.01411,8.01411,0,0,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#ccc"}),f.exports.createElement("path",{d:"M840.27007,357.82862H666.91017a8.01411,8.01411,0,1,1,0-16.02822h173.3599a8.01411,8.01411,0,0,1,0,16.02822Z",transform:"translate(-208.9778 -99.05999)",fill:"#ccc"}),f.exports.createElement("path",{d:"M635.85911,390.6071H506.51316a3.847,3.847,0,0,1-3.84277-3.84277V285.81706a3.847,3.847,0,0,1,3.84277-3.84277H635.85911a3.847,3.847,0,0,1,3.84277,3.84277V386.76433A3.847,3.847,0,0,1,635.85911,390.6071Z",transform:"translate(-208.9778 -99.05999)",fill:"#ccc"})),fa=t=>{if(!t)return null;const n=new Date(t+"Z");return Math.floor(n.getTime()/1e3)},xr=({lastOnline:t})=>{const n=Math.floor(Date.now()/1e3),o=fa(t);if(typeof t>"u"||t===null)return e("div",{className:"circle pulse orange"});const s=o?n-o:1/0;return s>0&&s<=60?e("div",{className:"circle pulse green"}):e("div",{className:"circle pulse red"})},ba=t=>{if(!t)return null;const n=new Date(t+"Z");return Math.floor(n.getTime()/1e3)},yr=({lastOnline:t})=>{const n=Math.floor(Date.now()/1e3),o=ba(t),s=o?n-o:null,i=o?Xt(o):{status:"",time:"Not Connected Yet"};return e(h,{display:"inline-block",fontSize:"xs",fontWeight:"medium",ml:"2",color:"gray.600",_dark:{color:"gray.400"},children:s&&s<=60?"Online":s?`${i.time} ago`:i.time})},xa=y(uo,{baseStyle:{w:4,h:4}}),ya=y(po,{baseStyle:{w:4,h:4}}),Sr=5;function Sa(t,n,o){if(o0&&(i[0]=0,i[1]="prev-more"),i[i.length-1]{const{filters:t,onFilterChange:n,users:{total:o}}=E(),{limit:s,offset:i}=t,a=(i||0)/(s||1),l=Math.ceil(o/(s||1)),u=Sa(l,a,7),p=c=>{n({...t,offset:c*s})},C=c=>{n({...t,limit:parseInt(c.target.value)}),Vo(c.target.value)},{t:d}=j();return r(_,{justifyContent:"space-between",mt:4,w:"full",display:"flex",columnGap:{lg:4,md:0},rowGap:{md:0,base:4},flexDirection:{md:"row",base:"column"},children:[e(D,{order:{base:2,md:1},children:r(_,{children:[r(Me,{minW:"60px",value:s,onChange:C,size:"sm",rounded:"md",children:[e("option",{children:"10"}),e("option",{children:"20"}),e("option",{children:"30"})]}),e(h,{whiteSpace:"nowrap",fontSize:"sm",children:d("itemsPerPage")})]})}),r(mo,{size:"sm",isAttached:!0,variant:"outline",order:{base:1,md:2},children:[e(F,{leftIcon:e(xa,{}),onClick:p.bind(null,a-1),isDisabled:a===0||l===0,children:d("previous")}),u.map(c=>typeof c=="string"?e(F,{children:"..."},c):e(F,{variant:c===a?"solid":"outline",onClick:p.bind(null,c),children:c+1},c)),e(F,{rightIcon:e(ya,{}),onClick:p.bind(null,a+1),isDisabled:a+1===l||l===0,children:d("next")})]})]})},wa=y(ga),Ge={baseStyle:{w:{base:4,md:5},h:{base:4,md:5}}},_a=y(go,Ge),ka=y(Zr,Ge),Cr=y(fo,Ge),va=y($t,Ge),Ia=y(Br,Ge),za=y(Yr,Ge),Da=y(Zr,{baseStyle:{width:"15px",height:"15px"}}),Ea=t=>{for(var n=0;n{const{used:n,total:o,dataLimitResetStrategy:s,totalUsedTraffic:i}=t,a=o===0||o===null;return e(_,{justifyContent:"space-between",fontSize:"xs",fontWeight:"medium",color:"gray.600",_dark:{color:"gray.400"},children:r(h,{children:[re(n)," /"," ",a?e(h,{as:"span",fontFamily:"system-ui",children:"\u221E"}):re(o)]})})},wr=t=>{const{used:n,total:o,dataLimitResetStrategy:s,totalUsedTraffic:i,...a}=t,l=o===0||o===null,u=!l&&n/o*100>=100;return r(ge,{children:[e(bo,{orientation:"horizontal",value:l?100:Math.min(n/o*100,100),colorScheme:u?"red":"primary",...a,children:e(xo,{h:"6px",borderRadius:"full",children:e(yo,{borderRadius:"full"})})}),r(_,{justifyContent:"space-between",fontSize:"xs",fontWeight:"medium",color:"gray.600",_dark:{color:"gray.400"},children:[r(h,{children:[re(n)," /"," ",l?e(h,{as:"span",fontFamily:"system-ui",children:"\u221E"}):re(o)+(s&&s!=="no_reset"?" "+X("userDialog.resetStrategy"+Ea(s)):"")]}),r(h,{children:[X("usersTable.total"),": ",re(i)]})]})]})},ot=({sort:t,column:n})=>t.includes(n)?e(Da,{transform:t.startsWith("-")?void 0:"rotate(180deg)"}):null,Ra=t=>{const{filters:n,users:{users:o},users:s,onEditingUser:i,onFilterChange:a}=E(),{t:l}=j(),[u,p]=f.exports.useState(void 0),C=Ae({base:120,lg:72})||72,[d,c]=f.exports.useState(`${C}px`),w=Ae({base:!1,md:!0});f.exports.useEffect(()=>{const g=()=>{const b=document.querySelectorAll("#filters")[0];c(`${b.offsetHeight}px`)};window.addEventListener("scroll",g)},[]);const v=o.length!==s.total,m=g=>{let b=n.sort;b.includes(g)?b.startsWith("-")?b="-created_at":b="-"+g:b=g,a({sort:b})},S=g=>{a({status:g.target.value.length>0?g.target.value:void 0})},T=g=>{p(g===u?void 0:g)};return r(D,{id:"users-table",overflowX:{base:"unset",md:"unset"},children:[e(pt,{allowMultiple:!0,display:{base:"block",md:"none"},index:u,children:r(sr,{orientation:"vertical",zIndex:"docked",...t,children:[e(ar,{zIndex:"docked",position:"relative",children:r(Oe,{children:[e(ze,{position:"sticky",top:d,minW:"120px",pl:4,pr:4,cursor:"pointer",onClick:m.bind(null,"username"),children:r(_,{children:[e("span",{children:l("users")}),e(ot,{sort:n.sort,column:"username"})]})}),e(ze,{position:"sticky",top:d,minW:"50px",pl:0,pr:0,w:"140px",cursor:"pointer",children:r(_,{spacing:0,position:"relative",children:[r(h,{position:"absolute",_dark:{bg:"gray.750"},_light:{bg:"#F9FAFB"},userSelect:"none",pointerEvents:"none",zIndex:1,w:"100%",children:[l("usersTable.status"),n.status?": "+n.status:""]}),r(Me,{value:n.sort,fontSize:"xs",fontWeight:"extrabold",textTransform:"uppercase",cursor:"pointer",p:0,border:0,h:"auto",w:"auto",icon:e(ge,{}),_focusVisible:{border:"0 !important"},onChange:S,children:[e("option",{}),e("option",{children:"active"}),e("option",{children:"on_hold"}),e("option",{children:"disabled"}),e("option",{children:"limited"}),e("option",{children:"expired"})]})]})}),e(ze,{position:"sticky",top:d,minW:"100px",cursor:"pointer",pr:0,onClick:m.bind(null,"used_traffic"),children:r(_,{children:[e("span",{children:l("usersTable.dataUsage")}),e(ot,{sort:n.sort,column:"used_traffic"})]})}),e(ze,{position:"sticky",top:d,minW:"32px",w:"32px",p:0,cursor:"pointer"})]})}),e(ir,{children:!w&&(o==null?void 0:o.map((g,b)=>r(f.exports.Fragment,{children:[r(Oe,{onClick:T.bind(null,b),cursor:"pointer",children:[e(ue,{borderBottom:0,minW:"100px",pl:4,pr:4,maxW:"calc(100vw - 50px - 32px - 100px - 48px)",children:r("div",{className:"flex-status",children:[e(xr,{lastOnline:g.online_at}),e(h,{isTruncated:!0,children:g.username})]})}),e(ue,{borderBottom:0,minW:"50px",pl:0,pr:0,children:e(yt,{compact:!0,showDetail:!1,expiryDate:g.expire,status:g.status})}),e(ue,{borderBottom:0,minW:"100px",pr:0,children:e(Ua,{totalUsedTraffic:g.lifetime_used_traffic,dataLimitResetStrategy:g.data_limit_reset_strategy,used:g.used_traffic,total:g.data_limit,colorScheme:it[g.status].bandWidthColor})}),e(ue,{p:0,borderBottom:0,w:"32px",minW:"32px",children:e(ka,{color:"gray.600",_dark:{color:"gray.400"},transition:"transform .2s ease-out",transform:u===b?"rotate(180deg)":"0deg"})})]}),e(Oe,{className:"collapsible",onClick:T.bind(null,b),children:e(ue,{p:0,colSpan:4,children:r(He,{border:0,children:[e(Be,{display:"none"}),e($e,{border:0,cursor:"pointer",px:6,py:3,children:r(N,{justifyContent:"space-between",spacing:"4",children:[r(N,{alignItems:"flex-start",w:"full",spacing:-1,children:[e(h,{textTransform:"capitalize",fontSize:"xs",fontWeight:"bold",color:"gray.600",_dark:{color:"gray.400"},children:l("usersTable.dataUsage")}),e(D,{width:"full",minW:"230px",children:e(wr,{totalUsedTraffic:g.lifetime_used_traffic,dataLimitResetStrategy:g.data_limit_reset_strategy,used:g.used_traffic,total:g.data_limit,colorScheme:it[g.status].bandWidthColor})})]}),r(_,{w:"full",justifyContent:"space-between",children:[r(D,{width:"full",children:[e(yt,{compact:!0,expiryDate:g.expire,status:g.status}),e(yr,{lastOnline:g.online_at})]}),r(_,{children:[e(_r,{user:g}),e(ne,{label:l("userDialog.editUser"),placement:"top",children:e(Z,{p:"0 !important","aria-label":"Edit user",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},onClick:W=>{W.stopPropagation(),i(g)},children:e(za,{})})})]})]})]})})]})})})]},g.username)))})]})}),r(sr,{orientation:"vertical",display:{base:"none",md:"table"},...t,children:[e(ar,{zIndex:"docked",position:"relative",children:r(Oe,{children:[e(ze,{position:"sticky",top:{base:"unset",md:d},minW:"140px",cursor:"pointer",onClick:m.bind(null,"username"),children:r(_,{children:[e("span",{children:l("username")}),e(ot,{sort:n.sort,column:"username"})]})}),e(ze,{position:"sticky",top:{base:"unset",md:d},width:"400px",minW:"150px",cursor:"pointer",children:r(_,{position:"relative",gap:"5px",children:[r(h,{_dark:{bg:"gray.750"},_light:{bg:"#F9FAFB"},userSelect:"none",pointerEvents:"none",zIndex:1,children:[l("usersTable.status"),n.status?": "+n.status:""]}),e(h,{children:"/"}),e(ot,{sort:n.sort,column:"expire"}),e(_,{onClick:m.bind(null,"expire"),children:e(h,{children:"Sort by expire"})}),r(Me,{fontSize:"xs",fontWeight:"extrabold",textTransform:"uppercase",cursor:"pointer",position:"absolute",p:0,left:"-40px",border:0,h:"auto",w:"auto",icon:e(ge,{}),_focusVisible:{border:"0 !important"},value:n.sort,onChange:S,children:[e("option",{}),e("option",{children:"active"}),e("option",{children:"on_hold"}),e("option",{children:"disabled"}),e("option",{children:"limited"}),e("option",{children:"expired"})]})]})}),e(ze,{position:"sticky",top:{base:"unset",md:d},width:"350px",minW:"230px",cursor:"pointer",onClick:m.bind(null,"used_traffic"),children:r(_,{children:[e("span",{children:l("usersTable.dataUsage")}),e(ot,{sort:n.sort,column:"used_traffic"})]})}),e(ze,{position:"sticky",top:{base:"unset",md:d},width:"200px",minW:"180px"})]})}),r(ir,{children:[w&&(o==null?void 0:o.map((g,b)=>r(Oe,{className:Ut("interactive",{"last-row":b===o.length-1}),onClick:()=>i(g),children:[e(ue,{minW:"140px",children:r("div",{className:"flex-status",children:[e(xr,{lastOnline:g.online_at}),g.username,e(yr,{lastOnline:g.online_at})]})}),e(ue,{width:"400px",minW:"150px",children:e(yt,{expiryDate:g.expire,status:g.status})}),e(ue,{width:"350px",minW:"230px",children:e(wr,{totalUsedTraffic:g.lifetime_used_traffic,dataLimitResetStrategy:g.data_limit_reset_strategy,used:g.used_traffic,total:g.data_limit,colorScheme:it[g.status].bandWidthColor})}),e(ue,{width:"200px",minW:"180px",children:e(_r,{user:g})})]},g.username))),o.length==0&&e(Oe,{children:e(ue,{colSpan:4,children:e(La,{isFiltered:v})})})]})]}),e(Ca,{})]})},_r=({user:t})=>{const{setQRCode:n,setSubLink:o}=E(),s=t.links.join(`\r +`),[i,a]=f.exports.useState([-1,!1]);return f.exports.useEffect(()=>{i[1]&&setTimeout(()=>{a([-1,!1])},1e3)},[i]),r(_,{justifyContent:"flex-end",onClick:l=>{l.preventDefault(),l.stopPropagation()},children:[e(lr,{text:t.subscription_url.startsWith("/")?window.location.origin+t.subscription_url:t.subscription_url,onCopy:()=>{a([0,!0])},children:e("div",{children:e(ne,{label:i[0]==0&&i[1]?X("usersTable.copied"):X("usersTable.copyLink"),placement:"top",children:e(Z,{p:"0 !important","aria-label":"copy subscription link",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},children:i[0]==0&&i[1]?e(Cr,{}):e(va,{})})})})}),e(lr,{text:s,onCopy:()=>{a([1,!0])},children:e("div",{children:e(ne,{label:i[0]==1&&i[1]?X("usersTable.copied"):X("usersTable.copyConfigs"),placement:"top",children:e(Z,{p:"0 !important","aria-label":"copy configs",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},children:i[0]==1&&i[1]?e(Cr,{}):e(_a,{})})})})}),e(ne,{label:"QR Code",placement:"top",children:e(Z,{p:"0 !important","aria-label":"qr code",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},onClick:()=>{n(t.links),o(t.subscription_url)},children:e(Ia,{})})})]})},La=({isFiltered:t})=>{const{onCreateUser:n}=E();return r(D,{padding:"5",py:"8",display:"flex",alignItems:"center",flexDirection:"column",gap:4,w:"full",children:[e(wa,{maxHeight:"200px",maxWidth:"200px",_dark:{'path[fill="#fff"]':{fill:"gray.800"},'path[fill="#f2f2f2"], path[fill="#e6e6e6"], path[fill="#ccc"]':{fill:"gray.700"},'circle[fill="#3182CE"]':{fill:"primary.300"}},_light:{'path[fill="#f2f2f2"], path[fill="#e6e6e6"], path[fill="#ccc"]':{fill:"gray.300"},'circle[fill="#3182CE"]':{fill:"primary.500"}}}),e(h,{fontWeight:"medium",color:"gray.600",_dark:{color:"gray.400"},children:t?X("usersTable.noUserMatched"):X("usersTable.noUser")}),!t&&e(F,{size:"sm",colorScheme:"primary",onClick:()=>n(!0),children:X("createUser")})]})},Ta=()=>(f.exports.useEffect(()=>{E.getState().refetchUsers(),Yo()},[]),r(N,{justifyContent:"space-between",minH:"100vh",p:"6",rowGap:4,children:[r(D,{w:"full",children:[e(ws,{}),e(Bo,{mt:"4"}),e(is,{}),e(Ra,{}),e(ma,{}),e(ns,{}),e(Xs,{}),e(Ts,{}),e(ta,{}),e(na,{}),e(Bs,{}),e(Ys,{}),e(Ks,{}),e(rs,{})]}),e(Kr,{})]})),Aa=t=>f.exports.createElement("svg",{viewBox:"0 0 747 747",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},f.exports.createElement("path",{d:"M746.671 209.652V77.6572C746.671 72.9384 743.827 68.6832 739.468 66.8811C735.108 65.0738 730.093 66.0739 726.754 69.4072L579.354 216.807C577.453 202.386 570.203 189.203 559.037 179.87C547.875 170.542 533.615 165.744 519.083 166.432C504.551 167.12 490.807 173.24 480.573 183.583L414.375 249.776C412.417 235.391 405.141 222.25 393.985 212.959C382.823 203.662 368.594 198.88 354.083 199.552C339.578 200.224 325.849 206.302 315.594 216.588L274.343 257.828L19.9167 3.41515C16.5781 0.0818157 11.5625 -0.918184 7.20306 0.889149C2.84373 2.69648 0 6.94648 0 11.6651V143.649C0 146.743 1.22917 149.712 3.41667 151.899L191.843 340.339L3.41667 528.753C1.2292 530.94 0 533.909 0 537.003V668.997C0 673.716 2.84373 677.971 7.20306 679.773C11.5624 681.581 16.578 680.58 19.9167 677.247L167.317 529.847C169.285 544.233 176.561 557.358 187.718 566.65C198.869 575.947 213.098 580.728 227.603 580.066C242.103 579.404 255.838 573.342 266.098 563.071L332.295 496.874V496.879C334.259 511.264 341.535 524.395 352.691 533.686C363.853 542.977 378.082 547.759 392.587 547.092C407.093 546.421 420.822 540.348 431.077 530.066L472.327 488.826L726.754 743.239C728.941 745.427 731.91 746.656 735.004 746.656C736.535 746.661 738.056 746.359 739.473 745.77C743.832 743.963 746.671 739.708 746.671 734.989V602.994C746.671 599.901 745.442 596.932 743.254 594.744L554.827 406.318L743.254 217.904H743.259C745.447 215.717 746.676 212.748 746.676 209.654L746.671 209.652ZM23.3373 39.8118L257.844 274.318L208.328 323.818L23.3413 138.818L23.3373 39.8118ZM723.337 706.825L488.831 472.318L538.347 422.818L723.333 607.818L723.337 706.825ZM23.3373 541.825L332.097 233.078C338.764 226.719 347.624 223.172 356.843 223.172C366.056 223.172 374.916 226.719 381.588 233.078C388.151 239.641 391.838 248.548 391.838 257.828C391.838 267.114 388.151 276.016 381.588 282.577L23.3347 640.831L23.3373 541.825ZM249.604 546.575C240.755 555.419 227.864 558.872 215.781 555.638C203.703 552.398 194.265 542.961 191.027 530.883C187.792 518.8 191.245 505.91 200.089 497.06L497.076 200.074C505.92 191.23 518.811 187.772 530.893 191.011C542.971 194.246 552.409 203.678 555.648 215.76C558.888 227.839 555.434 240.73 546.591 249.572L249.604 546.575ZM723.337 204.815L414.577 513.562C407.911 519.926 399.051 523.473 389.832 523.473C380.618 523.473 371.753 519.926 365.087 513.562C358.529 506.999 354.842 498.098 354.842 488.816C354.842 479.535 358.529 470.634 365.087 464.071L723.34 105.818L723.337 204.815Z",fill:"currentColor"})),Ma=x.object({username:x.string().min(1,"login.fieldRequired"),password:x.string().min(1,"login.fieldRequired")}),Na=y(Aa,{baseStyle:{strokeWidth:"10px",w:12,h:12}}),Fa=y(So,{baseStyle:{w:5,h:5,strokeWidth:"2px"}}),kr=()=>{var c,w;const[t,n]=f.exports.useState(""),[o,s]=f.exports.useState(!1),i=Co(),{t:a}=j();let l=wo();const{register:u,formState:{errors:p},handleSubmit:C}=Ve({resolver:ut(Ma)});f.exports.useEffect(()=>{No(),l.pathname!=="/login"&&i("/login",{replace:!0})},[]);const d=v=>{n("");const m=new FormData;m.append("username",v.username),m.append("password",v.password),m.append("grant_type","password"),s(!0),O("/admin/token",{method:"post",body:m}).then(({access_token:S})=>{Mo(S),i("/")}).catch(S=>{n(S.response._data.detail)}).finally(s.bind(null,!1))};return r(N,{justifyContent:"space-between",minH:"100vh",p:"6",w:"full",children:[r(D,{w:"full",children:[e(_,{justifyContent:"end",w:"full",children:e(en,{})}),e(_,{w:"full",justifyContent:"center",alignItems:"center",children:r(D,{w:"full",maxW:"340px",mt:"6",children:[r(N,{alignItems:"center",w:"full",children:[e(Na,{}),e(h,{fontSize:"2xl",fontWeight:"semibold",children:a("login.loginYourAccount")}),e(h,{color:"gray.600",_dark:{color:"gray.400"},children:a("login.welcomeBack")})]}),e(D,{w:"full",maxW:"300px",m:"auto",pt:"4",children:e("form",{onSubmit:C(d),children:r(N,{mt:4,rowGap:2,children:[e(R,{children:e(Ue,{w:"full",placeholder:a("username"),...u("username"),error:a((c=p==null?void 0:p.username)==null?void 0:c.message)})}),e(R,{children:e(Ue,{w:"full",type:"password",placeholder:a("password"),...u("password"),error:a((w=p==null?void 0:p.password)==null?void 0:w.message)})}),t&&r(ct,{status:"error",rounded:"md",children:[e(kt,{}),e(Pr,{children:t})]}),r(F,{isLoading:o,type:"submit",w:"full",colorScheme:"primary",children:[e(Fa,{marginRight:1}),a("login")]})]})})})]})})]}),e(Kr,{})]})},Pa=()=>O("/admin",{headers:{Authorization:`Bearer ${vt()}`}}),Wa=_o([{path:"/",element:e(Ta,{}),errorElement:e(kr,{}),loader:Pa},{path:"/login/",element:e(kr,{})}],{basename:"/dashboard/"});function Oa(){return e("main",{className:"p-8",children:e(ko,{router:Wa})})}B.extend(vo);B.extend(Io);B.extend(zo);B.extend(Do);B.extend(Eo);Qr(Uo.get()||"light");Ro.createRoot(document.getElementById("root")).render(e(Ft.StrictMode,{children:e(Lo,{theme:Ao,children:e(To,{client:Wt,children:e(Oa,{})})})})); diff --git a/app/dashboard/build/index.html b/app/dashboard/build/index.html index c075c0c8..128e9aed 100644 --- a/app/dashboard/build/index.html +++ b/app/dashboard/build/index.html @@ -33,7 +33,7 @@ - +