1import{r as e,j as s}from"./vendor-react-DejgYtBM.js";import{W as a,l as t,o as r,m as l,A as i,f as n,R as c,C as d,j as o,B as u,i as h,t as m,M as x,u as p,F as j,z as f,v as g,a1 as y,E as b,J as w,K as _,H as v,D as N,y as I,T as S,a as k}from"./vendor-semi-D8d7bTtM.js";import{u as z,a as C,s as T,A as $,w as q,S as F,$ as V,aK as P,aL as E,aH as R,K as B,aM as D,W as K,aj as M,N as O,at as A,Y as U,J as L,Z as W,aN as G,ac as H,aO as J,a0 as X,V as Y,B as Z,a2 as Q}from"./index-BeIIFw6E.js";import{i as ee,bB as se,ba as ae,U as te,t as re,u as le,x as ie,bm as ne,bw as ce,ah as de,at as oe,aL as ue,q as he,b6 as me,k as xe,b9 as pe,X as je,E as fe,T as ge}from"./vendor-icons-EJvJ5X-w.js";import{u as ye}from"./useTableCompactMode-DWLN7NUj.js";import{C as be}from"./CardTable-Cq0lqlnD.js";import"./vendor-motion-Chfy_MiU.js";import"./useIsMobile-D_kfVI0u.js";const{Text:we,Title:_e}=n,ve=n=>{const{t:m}=z(),x=e.useRef(null),[p,j]=e.useState(!1),f=e.useRef(!1),g=C(),y=()=>{n.handleClose()};return s.jsx(s.Fragment,{children:s.jsx(a,{placement:"left",title:s.jsxs(o,{children:[s.jsx(h,{color:"green",shape:"circle",children:m("æ°å»º")}),s.jsx(_e,{heading:4,className:"m-0",children:m("æ·»å ç¨æ·")})]}),bodyStyle:{padding:"0"},visible:n.visible,width:g?"100%":600,footer:s.jsx("div",{className:"flex justify-end bg-white",children:s.jsxs(o,{children:[s.jsx(u,{theme:"solid",onClick:()=>x.current?.submitForm(),icon:s.jsx(se,{size:16}),loading:p,children:m("æäº¤")}),s.jsx(u,{theme:"light",type:"primary",onClick:y,icon:s.jsx(ae,{size:16}),children:m("åæ¶")})]})}),closeIcon:null,onCancel:()=>y(),children:s.jsx(t,{spinning:p,children:s.jsx(r,{initValues:{username:"",display_name:"",password:"",remark:""},getFormApi:e=>x.current=e,onSubmit:async e=>{if(!f.current){f.current=!0,j(!0);try{const s=await $.post("/api/user/",e),{success:a,message:t}=s.data;a?(q(m("ç¨æ·è´¦æ·å建æåï¼")),x.current?.setValues({username:"",display_name:"",password:"",remark:""}),n.refresh(),n.handleClose()):T(t)}finally{f.current=!1,j(!1)}}},onSubmitFail:e=>{const s=Object.values(e)[0];s&&T(Array.isArray(s)?s[0]:s),x.current?.scrollToError()},children:s.jsx("div",{className:"p-2",children:s.jsxs(l,{className:"!rounded-2xl shadow-sm border-0",children:[s.jsxs("div",{className:"flex items-center mb-2",children:[s.jsx(i,{size:14,color:"blue",className:"mr-2 shadow-md",children:s.jsx(ee,{size:16})}),s.jsxs("div",{children:[s.jsx(we,{className:"text-lg font-medium",children:m("ç¨æ·ä¿¡æ¯")}),s.jsx("div",{className:"text-xs text-gray-600",children:m("å建æ°ç¨æ·è´¦æ·")})]})]}),s.jsxs(c,{gutter:12,children:[s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"username",label:m("ç¨æ·å"),placeholder:m("请è¾å
¥ç¨æ·å"),rules:[{required:!0,message:m("请è¾å
¥ç¨æ·å")}],showClear:!0})}),s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"display_name",label:m("æ¾ç¤ºåç§°"),placeholder:m("请è¾å
¥æ¾ç¤ºåç§°"),showClear:!0})}),s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"password",label:m("å¯ç "),type:"password",placeholder:m("请è¾å
¥å¯ç "),rules:[{required:!0,message:m("请è¾å
¥å¯ç ")}],showClear:!0})}),s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"remark",label:m("夿³¨"),placeholder:m("请è¾å
¥å¤æ³¨ï¼ä»
管çåå¯è§ï¼"),showClear:!0})})]})]})})})})})})},{Text:Ne,Title:Ie}=n,Se="__none__",ke=({formApiRef:a,t,initialDomains:l=[]})=>{const[i,n]=e.useState(l),[c,d]=e.useState(""),[o,m]=e.useState(!1);e.useEffect(()=>{l.length>0?n(l):0===l.length&&n([])},[l]),e.useEffect(()=>{if(a.current&&!o){const e=i.join(",");a.current.setValue("agent_domain",e)}},[i,a,o]);const x=()=>{const e=c.trim();e&&(i.includes(e)?T(t("ååå·²åå¨")):(n([...i,e]),d("")))};return s.jsxs("div",{children:[s.jsx(Ne,{className:"block mb-2 text-sm font-medium text-gray-700",children:t("代çåå")}),s.jsxs("div",{className:"flex gap-2 mb-3",children:[s.jsx(j,{value:c,onChange:d,onKeyPress:e=>{"Enter"===e.key&&(e.preventDefault(),x())},placeholder:t("è¾å
¥ååï¼å¦ï¼example.com"),prefix:s.jsx(ne,{size:16}),style:{flex:1}}),s.jsx(u,{type:"primary",icon:s.jsx(ie,{size:16}),onClick:x,disabled:!c.trim(),children:t("æ·»å ")})]}),s.jsx("div",{className:"space-y-2",children:i.length>0?s.jsx("div",{className:"flex flex-wrap gap-2",children:i.map((e,a)=>s.jsxs(h,{closable:!0,onClose:()=>{return s=e,void n(i.filter(e=>e!==s));var s},color:"blue",className:"px-3 py-1",children:[s.jsx(ne,{className:"mr-1",size:12}),e]},e))}):s.jsx(Ne,{type:"tertiary",className:"text-sm",children:t("ææ ååï¼è¯·æ·»å 代çåå")})}),s.jsx("div",{className:"mt-3 p-3 bg-blue-50 rounded-lg",children:s.jsxs(Ne,{className:"text-xs text-blue-600",children:["ð¡ ",t("æç¤º"),":",t("å¯ä»¥æ·»å å¤ä¸ªååï¼æ¯ä¸ªååå°åç¬æåæ¤ä»£çç«ãæ¯æåååï¼å¦ï¼api.example.comãcdn.example.com")]})}),s.jsx(r.Input,{field:"agent_domain",style:{display:"none"}})]})},ze=n=>{const{t:j}=z(),f=n.editingUser.id,[g,y]=e.useState(!0),[b,w]=e.useState(!1),[_,v]=e.useState(""),[N,I]=e.useState(!1),[S,k]=e.useState(""),M=C(),[O,A]=e.useState([]),[U,L]=e.useState([]),[W]=e.useContext(F),G=!!W?.status?.topup_star_level_enabled,[H,J]=e.useState(0),[X,Y]=e.useState([]),Z=e.useRef(null),Q=e.useRef(!1),ee=e.useRef(null),ce=e.useRef(null),de=Boolean(f),oe=()=>({username:"",display_name:"",password:"",github_id:"",oidc_id:"",wechat_id:"",telegram_id:"",email:"",quota:0,aff_quota:0,group:"default",remark:"",role:1,agent_price:0,agent_domain:"",cost_price_marker:.5,star_level:Se}),ue=()=>n.handleClose();e.useEffect(()=>{n.visible&&((async()=>{y(!0);const e=f?`/api/user/${f}`:"/api/user/self",s=await $.get(e),{success:a,message:t,data:r}=s.data;if(a){if(r.password="",r.quota&&(r.quota=K(r.quota)),r.aff_quota&&(r.aff_quota=K(r.aff_quota)),r.agent_domain){const e=r.agent_domain.split(",").map(e=>e.trim()).filter(e=>""!==e);Y(e)}else Y([]);ce.current="number"==typeof r.cost_price_marker?r.cost_price_marker:null,ee.current="string"==typeof r.star_level?r.star_level:"",J(Number(r.parent_id)||0);const e={...r};e.star_level="string"==typeof r.star_level&&""!==r.star_level?r.star_level:Se,Z.current?.setValues({...oe(),...e})}else T(t);y(!1)})(),f&&((async()=>{try{let e=await $.get("/api/option/permissions");e.data.success?A(e.data.data.map(e=>({label:e,value:e}))):T(e.data.message)}catch(e){T(e.message)}})(),G&&(async()=>{try{const e=await $.get("/api/option/topup_star_levels");if(e.data.success){const s=e.data.data||{},a=[{label:j("ä¸ç»å®æçº§"),value:Se},...Object.entries(s).map(([e,s])=>({label:`${e} (Â¥${Number(s)}/${j("é¢åº¦")})`,value:e}))];L(a)}else T(e.data.message)}catch(e){T(e.message)}})()))},[n.editingUser.id,n.visible,G]);const he=e=>{Z.current?.setValue("quota",K(e.quota)),Z.current?.setValue("aff_quota",K(e.aff_quota))},me=()=>{v("0"),w(!0)},xe=()=>{k("0"),I(!0)};return s.jsxs(s.Fragment,{children:[s.jsx(a,{placement:"right",title:s.jsxs(o,{children:[s.jsx(h,{color:"blue",shape:"circle",children:j(de?"ç¼è¾":"æ°å»º")}),s.jsx(Ie,{heading:4,className:"m-0",children:j(de?"ç¼è¾ç¨æ·":"åå»ºç¨æ·")})]}),bodyStyle:{padding:0},visible:n.visible,width:M?"100%":600,footer:s.jsx("div",{className:"flex justify-end bg-white",children:s.jsxs(o,{children:[s.jsx(u,{theme:"solid",onClick:()=>
1Z.current?.submitForm(),icon:s.jsx(se,{size:16}),loading:g,children:j("æäº¤")}),s.jsx(u,{theme:"light",type:"primary",onClick:ue,icon:s.jsx(ae,{size:16}),children:j("åæ¶")})]})}),closeIcon:null,onCancel:ue,children:s.jsx(t,{spinning:g,children:s.jsx(r,{initValues:oe(),getFormApi:e=>Z.current=e,onSubmit:async e=>{if(!Q.current){Q.current=!0,y(!0);try{await(async e=>{let s={...e};delete s.quota,delete s.aff_quota;const a=s.cost_price_marker;delete s.cost_price_marker;const t=s.star_level;delete s.star_level,void 0!==s.agent_price&&null!==s.agent_price&&""!==s.agent_price&&(s.agent_price=parseFloat(s.agent_price)),f&&(s.id=parseInt(f));const r=f?"/api/user/":"/api/user/self",l=await $.put(r,s),{success:i,message:c}=l.data;if(i){if(f&&V()&&"number"==typeof a){const e=ce.current;if(null===e||Math.abs(a-e)>1e-6)try{const e=await $.put(`/api/user/${f}/cost_price_marker`,{cost_price_marker:a});if(!e?.data?.success)return void T(e?.data?.message||j("æ¿è´§ä»·æ è®°æ´æ°å¤±è´¥ï¼ä¸»ä¿¡æ¯å·²ä¿å"));ce.current=a}catch(d){return void T(d?.message||j("æ¿è´§ä»·æ è®°æ´æ°å¤±è´¥ï¼ä¸»ä¿¡æ¯å·²ä¿å"))}}if(f&&P()&&1===Number(e.role)&&0===H){const e=null==t||t===Se?"":String(t);if(e!==(ee.current??""))try{const s=await $.put(`/api/user/${f}/star_level`,{star_level:e});if(!s?.data?.success)return void T(s?.data?.message||j("æçº§æ´æ°å¤±è´¥ï¼ä¸»ä¿¡æ¯å·²ä¿å"));ee.current=e}catch(d){return void T(d?.message||j("æçº§æ´æ°å¤±è´¥ï¼ä¸»ä¿¡æ¯å·²ä¿å"))}}q(j("ç¨æ·ä¿¡æ¯æ´æ°æåï¼")),n.refresh(),n.handleClose()}else T(c)})(e)}finally{Q.current=!1,y(!1)}}},children:({values:e})=>s.jsxs("div",{className:"p-2",children:[s.jsxs(l,{className:"!rounded-2xl shadow-sm border-0",children:[s.jsxs("div",{className:"flex items-center mb-2",children:[s.jsx(i,{size:14,color:"blue",className:"mr-2 shadow-md",children:s.jsx(te,{size:16})}),s.jsxs("div",{children:[s.jsx(Ne,{className:"text-lg font-medium",children:j("åºæ¬ä¿¡æ¯")}),s.jsx("div",{className:"text-xs text-gray-600",children:j("ç¨æ·çåºæ¬è´¦æ·ä¿¡æ¯")})]})]}),s.jsxs(c,{gutter:12,children:[s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"username",label:j("ç¨æ·å"),placeholder:j("请è¾å
¥æ°çç¨æ·å"),rules:[{required:!0,message:j("请è¾å
¥ç¨æ·å")}],showClear:!0})}),s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"password",label:j("å¯ç "),placeholder:j("请è¾å
¥æ°çå¯ç ï¼æç 8 ä½"),mode:"password",showClear:!0})}),s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"display_name",label:j("æ¾ç¤ºåç§°"),placeholder:j("请è¾å
¥æ°çæ¾ç¤ºåç§°"),showClear:!0})}),s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"remark",label:j("夿³¨"),placeholder:j("请è¾å
¥å¤æ³¨ï¼ä»
管çåå¯è§ï¼"),showClear:!0})}),V()&&s.jsx(d,{span:24,children:s.jsx(r.InputNumber,{field:"cost_price_marker",label:j("æ¿è´§ä»·æ è®°"),step:1e-4,min:0,precision:4,style:{width:"100%"}})}),G&&P()&&f&&1===Number(e.role)&&0===H&&s.jsx(d,{span:24,children:s.jsx(r.Select,{field:"star_level",label:j("å
å¼æçº§"),placeholder:j("ä¸ç»å®æçº§"),optionList:U,style:{width:"100%"},extraText:j("éä¸åè¯¥ç¨æ·å
å¼å°æå¯¹åºæçº§å价计费ï¼è¦ç大颿æ£ï¼ï¼å¨ãç³»ç»è®¾ç½®-ç¨æ·æçº§å价设置ãä¸é
ç½®æçº§")})})]})]}),s.jsxs(l,{className:"!rounded-2xl shadow-sm border-0",children:[s.jsxs("div",{className:"flex items-center mb-2",children:[s.jsx(i,{size:14,color:"orange",className:"mr-2 shadow-md",children:s.jsx(re,{size:16})}),s.jsxs("div",{children:[s.jsx(Ne,{className:"text-lg font-medium",children:j("代çç³»ç»")}),s.jsx("div",{className:"text-xs text-gray-600",children:j("代çççº§åæ¿è´§ä»·è®¾ç½®")})]})]}),s.jsxs(c,{gutter:12,children:[s.jsx(d,{span:24,children:s.jsx(r.RadioGroup,{field:"role",label:j("ç¨æ·ç级"),direction:"horizontal",children:E.filter(e=>100!==e.value).map(e=>s.jsx(m,{value:e.value,children:j(e.labelKey)},e.value))})}),s.jsx(d,{span:24,children:s.jsx(r.InputNumber,{field:"agent_price",label:j("ä»£çæ¿è´§ä»·"),placeholder:j("ä»£çæ¿è´§ä»·"),step:.
1001,min:0,precision:3,prefix:s.jsx(le,{size:16}),style:{width:"100%"},rules:[{required:!0,message:j("请è¾å
¥æ¿è´§ä»·æ ¼")}]})}),s.jsx(d,{span:24,children:s.jsx(ke,{formApiRef:Z,t:j,initialDomains:X})})]})]}),f&&s.jsxs(l,{className:"!rounded-2xl shadow-sm border-0",children:[s.jsxs("div",{className:"flex items-center mb-2",children:[s.jsx(i,{size:14,color:"green",className:"mr-2 shadow-md",children:s.jsx(re,{size:16})}),s.jsxs("div",{children:[s.jsx(Ne,{className:"text-lg font-medium",children:j("æé设置")}),s.jsx("div",{className:"text-xs text-gray-600",children:j("ç¨æ·åç»åé¢åº¦ç®¡ç")})]})]}),s.jsxs(c,{gutter:12,children:[s.jsx(d,{span:24,children:s.jsx(r.Select,{field:"group",label:j("åç»"),placeholder:j("è¯·éæ©åç»"),optionList:O,allowAdditions:!0,additionLabel:j("请å¨ç³»ç»è®¾ç½®é¡µé¢ç¼è¾åç»åçä»¥æ·»å æ°çåç»ï¼"),search:!0,rules:[{required:!0,message:j("è¯·éæ©åç»")}]})}),s.jsx(d,{span:18,children:s.jsx(r.InputNumber,{field:"quota",label:j("å©ä½é¢åº¦"),placeholder:j("请è¾å
¥æ°çå©ä½é¢åº¦ï¼ç¾å
ï¼"),step:.01,precision:6,disabled:!0,prefix:s.jsx(le,{size:16}),extraText:R(B(e.quota)),style:{width:"100%"}})}),s.jsx(d,{span:6,children:s.jsx(r.Slot,{label:j("æ·»å é¢åº¦"),children:s.jsx(u,{onClick:me,icon:s.jsx(ie,{size:16}),block:!0,children:j("æ·»å é¢åº¦")})})}),s.jsx(d,{span:18,children:s.jsx(r.InputNumber,{field:"aff_quota",label:j("é请ä½é¢"),placeholder:j("请è¾å
¥é请å¥å±ä½é¢ï¼ç¾å
ï¼"),step:.01,precision:6,disabled:!0,prefix:s.jsx(le,{size:16}),extraText:R(B(e.aff_quota)),style:{width:"100%"}})}),s.jsx(d,{span:6,children:s.jsx(r.Slot,{label:j("è°æ´é请ä½é¢"),children:s.jsx(u,{onClick:xe,icon:s.jsx(ie,{size:16}),block:!0,children:j("è°æ´")})})})]})]}),s.jsxs(l,{className:"!rounded-2xl shadow-sm border-0",children:[s.jsxs("div",{className:"flex items-center mb-2",children:[s.jsx(i,{size:14,color:"purple",className:"mr-2 shadow-md",children:s.jsx(ne,{size:16})}),s.jsxs("div",{children:[s.jsx(Ne,{className:"text-lg font-medium",children:j("ç»å®ä¿¡æ¯")}),s.jsx("div",{className:"text-xs text-gray-600",children:j("ç¬¬ä¸æ¹è´¦æ·ç»å®ç¶æï¼åªè¯»ï¼")})]})]}),s.jsx(c,{gutter:12,children:["github_id","oidc_id","wechat_id","email","telegram_id"].map(e=>s.jsx(d,{span:24,children:s.jsx(r.Input,{field:e,label:j("å·²ç»å®ç {{type}} è´¦æ·",{type:e.replace("_id","").toUpperCase()}),readonly:!0,placeholder:j("æ¤é¡¹åªè¯»ï¼éè¦ç¨æ·éè¿ä¸ªäººè®¾ç½®é¡µé¢çç¸å
³ç»å®æé®è¿è¡ç»å®ï¼ä¸å¯ç´æ¥ä¿®æ¹")})},e))})]})]})})})}),s.jsxs(x,{centered:!0,visible:b,onOk:async()=>{await(async()=>{const e=parseFloat(_)||0;if(0===e)return;const s=parseInt(B(e)),a=await $.put(`/api/user/${f}/quota`,{quota_delta:s}),{success:t,message:r,data:l}=a.data;t?(he(l),q(j("é¢åº¦è°æ´æå"))):T(r)})(),w(!1)},onCancel:()=>w(!1),closable:null,title:s.jsxs("div",{className:"flex items-center",children:[s.jsx(ie,{size:16,className:"mr-2"}),j("æ·»å é¢åº¦")]}),children:[s.jsx("div",{className:"mb-4",children:(()=>{const e=parseFloat(Z.current?.getValue("quota")||0),a=parseFloat(_||0);return s.jsx(Ne,{type:"secondary",className:"block mb-2",children:`${j("æ°é¢åº¦")} ${D(e.toFixed(6))} + ${D(a.toFixed(6))} = ${D((e+a).toFixed(6))}`})})()}),s.jsx(p,{placeholder:j("éè¦æ·»å çé¢åº¦ï¼ç¾å
ï¼æ¯æè´æ°ï¼"),value:_,onChange:v,style:{width:"100%"},showClear:!0,step:.01,precision:6,prefix:s.jsx(le,{size:16})})]}),s.jsxs(x,{centered:!0,visible:N,onOk:async()=>{await(async()=>{const e=parseFloat(S)||0;if(0===e)return;const s=parseInt(B(e)),a=await $.put(`/api/user/${f}/quota`,{aff_quota_delta:s}),{success:t,message:r,data:l}=a.data;t?(he(l),q(j("é请ä½é¢è°æ´æå"))):T(r)})(),I(!1)},onCancel:()=>I(!1),closable:null,title:s.jsxs("div",{className:"flex items-center",children:[s.jsx(ie,{size:16,className:"mr-2"}),j("è°æ´é请ä½é¢")]}),children:[s.jsx("div",{className:"mb-4",children:(()=>{const e=parseFloat(Z.current?.getValue("aff_quota")||0),a=parseFloat(S||0);return s.jsx(Ne,{type:"secondary",className:"block mb-2",children:`${j("æ°é请ä½é¢")} ${D(e.toFixed(6))} + ${D(a.toFixed(6))} = ${D((e+a).toFixed(6))}`})})()}),s.jsx(p,{placeholder:j("éè¦è°æ´çé请ä½é¢ï¼ç¾å
ï¼æ¯æè´æ°ï¼"),value:S,onChange:k,style:{width:"100%"}
1,showClear:!0,step:.01,precision:6,prefix:s.jsx(le,{size:16})})]})]})},{Text:Ce}=n;function Te(e){return"number"!=typeof e||Number.isNaN(e)?NaN:Math.trunc(100*e)/100}const $e=()=>{const{t:a}=z(),[i]=e.useContext(F),n=i?.status?.transfer_price||0,c=n>0?1.1*n:0,d=n>0?Te(1.1*n):0,m=n>0?Te(n):0,[p,I]=e.useState(!1),[S,k]=e.useState(null),[C,V]=e.useState(""),[P,R]=e.useState(""),[B,D]=e.useState(!0),[K,se]=e.useState(!1),[ae,te]=e.useState(!1),[le,ie]=ye("users"),ne=e.useRef(!1),fe=(e,t)=>{switch(e){case 1:return s.jsx(h,{color:"green",shape:"circle",prefixIcon:s.jsx(xe,{size:14}),children:a("å·²æ¿æ´»")});case 2:{const e=s.jsx(h,{color:"red",shape:"circle",prefixIcon:s.jsx(me,{size:14}),children:a("å·²å°ç¦")});return t?s.jsx(f,{content:s.jsxs("div",{style:{maxWidth:260,wordBreak:"break-all"},children:[s.jsxs("span",{style:{fontWeight:600},children:[a("å°å·åå "),"ï¼"]}),t]}),position:"top",showArrow:!0,children:e}):e}default:return s.jsx(h,{color:"grey",shape:"circle",prefixIcon:s.jsx(he,{size:14}),children:a("æªç¥ç¶æ")})}},ge=[{title:"ID",dataIndex:"id"},{title:a("ç¨æ·å"),dataIndex:"username",render:(e,a)=>{const t=a.remark;if(!t)return s.jsx("span",{children:e});const r=t.length>10?t.slice(0,10)+"â¦":t;return s.jsxs(o,{spacing:2,children:[s.jsx("span",{children:e}),s.jsx(f,{content:t,position:"top",showArrow:!0,children:s.jsx(h,{color:"white",shape:"circle",className:"!text-xs",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("div",{className:"w-2 h-2 flex-shrink-0 rounded-full",style:{backgroundColor:"#10b981"}}),r]})})})]})}},{title:a("åç»"),dataIndex:"group",render:(e,a,t)=>s.jsx("div",{children:M(e)})},{title:a("ç»è®¡ä¿¡æ¯"),dataIndex:"info",render:(e,t,r)=>s.jsx("div",{children:s.jsxs(o,{spacing:1,wrap:!0,children:[s.jsxs(h,{color:"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(ce,{size:14}),children:[a("å©ä½"),": ",O(t.quota)]}),s.jsxs(h,{color:"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(ce,{size:14}),children:[a("å·²ç¨"),": ",O(t.used_quota)]}),s.jsxs(h,{color:"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(de,{size:14}),children:[a("è°ç¨"),": ",A(t.request_count)]})]})})},{title:a("é请信æ¯"),dataIndex:"invite",render:(e,t,r)=>s.jsx("div",{children:s.jsxs(o,{spacing:1,wrap:!0,children:[s.jsx(f,{content:t.aff_count>0?a("ç¹å»æ¥çè¯¥ç¨æ·éè¯·çææç¨æ·"):a("ææ éè¯·ç¨æ·"),children:s.jsxs(h,{color:t.aff_count>0?"blue":"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(re,{size:14}),onClick:()=>$s(t.id,t.username,t.aff_count),style:{cursor:t.aff_count>0?"pointer":"default",transition:"opacity 0.2s"},onMouseEnter:e=>{t.aff_count>0&&(e.currentTarget.style.opacity="0.8")},onMouseLeave:e=>{e.currentTarget.style.opacity="1"},children:[a("é请"),": ",A(t.aff_count)]})}),s.jsxs(h,{color:"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(oe,{size:14}),children:[a("æ¶ç"),": ",O(t.aff_history_quota)]}),s.jsxs(h,{color:"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(oe,{size:14}),children:[a("å©ä½æ¶ç"),": ",O(t.aff_quota)]}),s.jsx(h,{color:"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(ee,{size:14}),children:0===t.inviter_id?a("æ é请人"):a("é请人: {{id}}",{id:t.inviter_id})}),s.jsx(f,{content:t.parent_id>0?a("ç¹å»æ¥ç该代çç«ä¸çææç¨æ·"):a("主ç«ç¨æ·ï¼æ å½å±ä»£ç"),children:s.jsxs(h,{color:t.parent_id>0?"cyan":"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(re,{size:14}),onClick:()=>qs(t.parent_id,t.username),style:{cursor:t.parent_id>0?"pointer":"default",transition:"opacity 0.2s"},onMouseEnter:e=>{t.parent_id>0&&(e.currentTarget.style.opacity="0.8")},onMouseLeave:e=>{e.currentTarget.style.opacity="1"},children:[a("å½å±ä»£ç"),": ",0===t.parent_id?a("æ "):t.parent_id]})})]})})},{title:a("è§è²"),dataIndex:"role",render:(e,t,r)=>{return s.jsx("div",{children:(l=e,H(l,a))});var l}},{title:a("æ³¨åæ¶é´"),dataIndex:"created_at",render:(e,t,r)=>s.jsx("div",{children:e?U(e):a("æªç¥")})},{title:a("注åIP"),dataIndex:"register_ip",render:(e,t,r)=>s.jsx("div",{children:e?s.jsx(h,{color:"cyan",shape:"circle",className:"!text-xs",children:e}):s.jsx("span",{style:{color:"#999"},children:a("æªè®°å½")})})},{title:a("ç¶æ"),dataIndex:"status",render:(e,t,r)=>s.jsx("div",{children:null!==t.DeletedAt?s.jsx(h,{color:"red",shape:"circle",prefixIcon:s.jsx(ue,{size:14}),children:a("已注é")}):fe(e,t.ban_reason)})}],we={title:"",dataIndex:"operate",fixed:"right",render:(e,t,r)=>{if(null!==t.DeletedAt)return s.jsx(s.Fragment,{});const l=[{node:"item",name:a("注é"),type:"danger",onClick:()=>{x.confirm({title:a("ç¡®å®æ¯å¦è¦æ³¨éæ¤ç¨æ·ï¼"),content:a("ç¸å½äºå é¤ç¨æ·ï¼æ¤ä¿®æ¹å°ä¸å¯é"),onOk:()=>{(async()=>{await Ps(t.id,"delete",t),await Bs(),setTimeout(()=>{0===Se.length&&Fe>1&&Bs()},100)})()}})}}];return 1===t.status?l.splice(-1,0,{node:"item",name:a("ç¦ç¨"),type:"warning",onClick:()=>{es(t),Ze(""),Xe(!0)}}):l.splice(-1,0,{node:"item",name:a("å¯ç¨"),type:"secondary",onClick:()=>{Ps(t.id,"enable",t)},disabled:3===t.status}),X()&&l.splice(-1,0,{node:"item",name:a("è¸¢åºææè®¾å¤"),type:"tertiary",onClick:()=>{x.confirm({title:a("ç¡®å®è¦è¸¢åºæ¤ç¨æ·çææè®¾å¤åï¼"),content:a("è¯¥ç¨æ·å¨ææè®¾å¤ä¸çç»å½ä¼è¯å°ç«å³å¤±æï¼éè¦éæ°ç»å½"),onOk:()=>
1{Es(t.id,t.username)}})}}),s.jsxs(o,{children:[s.jsx(u,{type:"tertiary",size:"small",onClick:()=>{He(t),We(!0)},children:a("ç¼è¾")}),s.jsx(v,{trigger:"click",position:"bottomRight",menu:l,children:s.jsx(u,{type:"tertiary",size:"small",icon:s.jsx(pe,{size:16})})})]})}},_e={title:"",dataIndex:"operate",fixed:"right",render:(e,t,r)=>null!==t.DeletedAt?s.jsx(s.Fragment,{}):s.jsxs(o,{children:[!J(t.role)&&s.jsx(u,{type:"tertiary",size:"small",onClick:()=>{k(t.id),V(t.username),I(!0),D(!0),R(""),se(!0),$.get(`/api/user/${t.id}`).then(e=>{const{success:s,data:a}=e.data;if(s&&a&&null!=a.agent_sub_sale_price&&""!==a.agent_sub_sale_price){D(!1);const e=parseFloat(a.agent_sub_sale_price);R(Number.isNaN(e)?String(a.agent_sub_sale_price):String(Te(e)))}else D(!0),R("")}).catch(()=>T(a("å 载失败"))).finally(()=>se(!1))},children:a("å
å¼åä»·")}),s.jsx(u,{type:"primary",size:"small",onClick:()=>{is(t.id),cs(t.username),rs(!0)},children:a("å转ä½é¢")}),2===G()&&s.jsx(u,{type:"tertiary",size:"small",onClick:()=>{ps(!0),ws(null),vs(""),Is(""),fs(!0),$.get(`/api/user/${t.id}`).then(e=>{const{success:s,message:t,data:r}=e.data;s&&r?(ws(r),vs(r.username||""),Is(null!=r.display_name?String(r.display_name):"")):(T(t||a("å 载失败")),ps(!1))}).catch(e=>{T(e.message||a("å 载失败")),ps(!1)}).finally(()=>fs(!1))},children:a("ä¿®æ¹ç¨æ·å")})]})},Ne={title:a("å
å¼åä»·"),dataIndex:"agent_sub_sale_price",width:108,render:(e,t)=>{const r=t.agent_sub_sale_price;if(null==r||""===r)return s.jsx("span",{style:{color:"#999"},children:a("é»è®¤")});const l=parseFloat(r);if(Number.isNaN(l))return s.jsx("span",{style:{color:"#999"},children:"â"});const i=Te(l);return s.jsx("span",{children:i.toFixed(2)})}},Ie=L()?[...ge.slice(0,5),Ne,...ge.slice(5),_e]:[...ge,we],[Se,ke]=e.useState([]),[$e,qe]=e.useState(!0),[Fe,Ve]=e.useState(1),[Pe,Ee]=e.useState(W),[Re,Be]=e.useState(!1),[De,Ke]=e.useState([]),[Me,Oe]=e.useState(W),[Ae,Ue]=e.useState(!1),[Le,We]=e.useState(!1),[Ge,He]=e.useState({id:void 0}),[Je,Xe]=e.useState(!1),[Ye,Ze]=e.useState(""),[Qe,es]=e.useState(null),[ss,as]=e.useState(!1),[ts,rs]=e.useState(!1),[ls,is]=e.useState(null),[ns,cs]=e.useState(""),[ds,os]=e.useState(""),[us,hs]=e.useState(!1),ms=i?.status?.transfer_fee_rate||0,[xs,ps]=e.useState(!1),[js,fs]=e.useState(!1),[gs,ys]=e.useState(!1),[bs,ws]=e.useState(null),[_s,vs]=e.useState(""),[Ns,Is]=e.useState(""),Ss=()=>{ps(!1),ws(null),vs(""),Is(""),fs(!1),ys(!1)},[ks,zs]=e.useState(null),Cs=E.map(e=>({label:a(e.labelKey),value:String(e.value)})),Ts=()=>{const e=ks?ks.getValues():{};return{searchKeyword:e.searchKeyword||"",searchGroup:e.searchGroup||"",searchRole:e.searchRole||"",searchUserId:e.searchUserId||"",searchInviterId:e.searchInviterId||"",searchParentId:e.searchParentId||"",searchStartTime:e.searchStartTime||"",searchEndTime:e.searchEndTime||""}},$s=(e,s,a)=>{0!==a&&(ks&&(ks.setValue("searchInviterId",e),ks.setValue("searchKeyword",""),ks.setValue("searchUserId","")),Ve(1),Rs(1,Pe,"","","","",e,"","",""))},qs=(e,s)=>{0!==e&&(ks&&(ks.setValue("searchParentId",e),ks.setValue("searchKeyword",""),ks.setValue("searchUserId",""),ks.setValue("searchInviterId","")),Ve(1),Rs(1,Pe,"","","","","",e,"",""))},Fs=e=>{for(let s=0;s<e.length;s++)e[s].key=e[s].id;ke(e)},Vs=async(e,s,a=null,t=null)=>{let r=`p=${e}&page_size=${s}`;if(a){const e=new Date(a);e.setHours(0,0,0,0),r+=`&start_time=${Math.floor(e.getTime()/1e3)}`}if(t){const e=new Date(t);e.setHours(23,59,59,999),r+=`&end_time=${Math.floor(e.getTime()/1e3)}`}const l=await $.get(`/api/user/?${r}`),{success:i,message:n,data:c}=l.data;if(i){const e=c.items;Ve(c.page),Oe(c.total),Fs(e)}else T(n);qe(!1)};e.useEffect(()=>{Vs(1,Pe).then().catch(e=>{T(e)}),Ds().then()},[]);const Ps=async(e,s,t,r)=>{const l=await $.post("/api/user/manage",{id:e,action:s,reason:r||""}),{success:i,message:n}=l.data;if(i){q(a("æä½æå宿ï¼"));let e=l.data.data,r=[...Se];"delete"===s||(t.status=e.status,t.role=e.role),ke(r)}else T(n)},Es=async(e,s)=>{try{const t=await $.post(`/api/user/kick/${e}`),{success:r,message:l}=t.data;r?q(a("已踢åºç¨æ· {{username}} çææè®¾å¤",{username:s})):T(l)}catch(t){T(a("æä½å¤±è´¥")+": "+t.message)}},Rs=async(e,s,a=null,t=null,r=null,l=null,i=null,n=null,c=null,d=null)=>{if(null===a||null===t||null===r||null===l||null===i||null===n||null===c||null===d){const e=Ts();a=e.searchKeyword,t=e.searchGroup,r=e.searchRole,l=e.searchUserId,i=e.searchInviterId,n=e.searchParentId,c=e.searchStartTime,d=e.searchEndTime}if(""===a&&""===t&&""===r&&""===l&&""===i&&""===n&&""===c&&""===d)return void(await Vs(e,s));Be(!0);let o=`keyword=${a}&group=${t}&role=${r}&user_id=${l}&inviter_id=${i}&parent_id=${n}`;if(c){const e=new Date(c);e.setHours(0,0,0,0),o+=`&start_time=${Math.floor(e.getTime()/1e3)}`}if(d){const e=new Date(d);e.setHours(23,59,59,999),o+=`&end_time=${Math.floor(e.getTime()/1e3)}`}o+=`&p=${e}&page_size=${s}`;const u=await $.get(`/api/user/search?${o}`),{success:h,message:m,data:x}=u.data;if(h){const e=x.items;Ve(x.page),Oe(x.total),Fs(e)}else T(m);Be(!1)},Bs=async()=>{Ve(1);const{searchKeyword:e,searchGroup:s,searchRole:a,searchUserId:t,searchInviterId:r,searchParentId:l,searchStartTime:i,searchEndTime:n}=Ts();""===e&&""===s&&""===a&&""===t&&""===r&&""===l&&""===i&&""===n?await Vs(1,Pe):await Rs(1,Pe,e,s,a,t,r,l,i,n)},Ds=async()=>{const e=localStorage.getItem("user");if(e&&JSON.parse(e),L(),!L())try{let e=await $.get("/api/option/permissions");if(e.data,e.data.success){const s=e.data.data||[];Ke(s.map(e=>({label:e,value:e})))}else e.data.message,T(e.data.message)}catch(s){T(s.message)}};return s.jsxs(s.Fragment,{children:[s.jsx(ve,{refresh:Bs,visible:Ae,handleClose:()=>{Ue(!1)}}),s.jsx(ze,{refresh:Bs,visible:Le,handleClose:()=>{We(!1),He({id:void 0})},editingUser:Ge}),s.jsx(x,{visible:ts,title:a("åç¨æ·å转ä½é¢"),onOk:async()=>{const e=parseFloat(ds);if(!ds||isNaN(e)||e<=0)T(a("请è¾å
¥ææçå转é¢åº¦"));else{hs(!0);try{const t=Y(),r=Math.floor(e*t);if(r<=0)return void T(a("å转é¢åº¦è¿å°ï¼è¯·è¾å
¥æ´å¤§çéé¢"));const l=await $.post("/api/user/transfer_balance",{user_id:ls,quota:r}),{success:i,message:n,data:c}=l.data;if(i){q(a("ä½é¢å转æå")),rs(!1),os(""),is(null),cs(""),await Bs();try{const e=await $.get("/api/user/self");if(e&&e.data.success){const s=e.data.data,a=localStorage.getItem("user");if(a){const e=JSON.parse(a);void 0!==s.quota&&(e.quota=s.quota),void 0!==s.aff_quota&&(e.aff_quota=s.aff_quota),localStorage.setItem("user",JSON.stringify(e))}}}catch(s){console.error("å·æ°ä½é¢å¤±è´¥:",s)}}else T(n)}catch(s){T(a("å转失败")+": "+s.message)}finally{hs(!1)}}},onCancel:()=>{rs(!1),os(""),is(null),cs("")},confirmLoading:us,okText:a("确认å转"),cancelText:a("åæ¶"),children:s.jsxs("div",{style:{padding:"20px 0"},children:[s.jsxs("p",{style:{marginBottom:"15px",fontSize:"14px",color:"#666"},children:[a("ç®æ ç¨æ·"),": ",s.jsx("strong",{children:ns})," (ID: ",ls,")"]}),s.jsxs("div",{style:{marginBottom:"10px"},children:[s.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:"500"},children:a("å转é¢åº¦ï¼ç¾å
ï¼")}),s.jsx(j,{placeholder:a("请è¾å
¥å转é¢åº¦"),value:ds,onChange:e=>os(e),suffix:s.jsx("span",{style:{color:"#999"},children:"USD"}),type:"number",min:"0",step:"0.01",style:{width:"100%"}})]}),ms>0&&s.jsxs("div",{style:{background:"#fff7e6",border:"1px solid #faad14",borderRadius:8,padding:"12px 16px",marginTop:"10px"},children:[s.jsx("p",{style:{margin:0,fontWeight:"bold",color:"#faad14",fontSize:"14px"},children:a("平尿ç»è´¹æç¤º")}),s.jsxs("p",{style:{margin:"6px 0 0",fontSize:"13px"},children:[a("æç»è´¹ç"),"ï¼",ms,"%"]}),ds&&parseFloat(ds)>0&&s.jsxs(s.Fragment,{children:[s.jsxs("p",{style:{margin:"4px 0 0",fontSize:"13px"},children:[a("æç»è´¹"),"ï¼$",(parseFloat(ds)*ms/100).toFixed(2)]}),s.jsxs("p",{style:{margin:"4px 0 0",fontSize:"13px",fontWeight:"bold"}
1,children:[a("æ¨å°å®é
被æ£é¤"),"ï¼$",(parseFloat(ds)*(1+ms/100)).toFixed(2)]})]})]}),s.jsx("p",{style:{marginTop:"10px",fontSize:"12px",color:"#999"},children:a("æç¤ºï¼æ¤æä½å°ä»æ¨çè´¦æ·ä½é¢ä¸æ£é¤ç¸åºé¢åº¦ï¼å«å¹³å°æç»è´¹ï¼ï¼å¹¶å¢å å°ç®æ ç¨æ·çè´¦æ·ä½é¢ä¸")})]})}),s.jsx(x,{title:a("ä¿®æ¹ç¨æ·å"),visible:xs&&2===G(),onCancel:Ss,onOk:async()=>{const e=(_s||"").trim();if(!e)return T(a("请è¾å
¥ç¨æ·å")),Promise.reject(new Error("validation"));if(!bs)return T(a("å 载失败")),Promise.reject(new Error("no_snapshot"));ys(!0);try{const s=await $.put(`/api/user/${bs.id}/sub_profile`,{username:e,display_name:null==Ns?"":String(Ns).trim()}),{success:t,message:r}=s.data;return t?(q(a("ç¨æ·ä¿¡æ¯æ´æ°æåï¼")),Ss(),void(await Bs())):(T(r),Promise.reject(new Error(r||"api")))}catch(s){return T(s.message||a("æä½å¤±è´¥")),Promise.reject(s)}finally{ys(!1)}},confirmLoading:gs,okText:a("æäº¤"),cancelText:a("åæ¶"),maskClosable:!1,children:s.jsxs(t,{spinning:js,children:[s.jsx("p",{style:{marginBottom:12,fontSize:13,color:"hsl(var(--muted-foreground))"},children:a("ä»
è½ä¿®æ¹ç»å½ç¨æ·å")}),s.jsxs("div",{style:{marginBottom:14},children:[s.jsx(Ce,{type:"secondary",size:"small",style:{display:"block",marginBottom:6},children:a("ç¨æ·å")}),s.jsx(j,{value:_s,onChange:e=>vs(e),placeholder:a("请è¾å
¥ç¨æ·å")})]}),s.jsxs("div",{children:[s.jsx(Ce,{type:"secondary",size:"small",style:{display:"block",marginBottom:6},children:a("æ¾ç¤ºåç§°")}),s.jsx(j,{value:Ns,onChange:e=>Is(e),placeholder:a("请è¾å
¥æ°çæ¾ç¤ºåç§°")})]})]})}),s.jsx(x,{visible:p,title:a("设置ä¸çº§å
å¼åä»·"),onOk:async()=>{if(B){te(!0);try{const e=await $.put(`/api/user/${S}/agent_sub_sale_price`,{agent_sub_sale_price:null});e.data.success?(q(a("ä¿åæå")),I(!1),Bs()):T(e.data.message)}catch(s){T(s.message)}finally{te(!1)}return}const e=Te(parseFloat(P));if(Number.isNaN(e)||e<=0)T(a("请è¾å
¥ææçåä»·"));else if(c>0&&e<c-1e-9)T(a("åä»·ä¸è½ä½äº {{min}}",{min:d}));else{te(!0);try{const s=await $.put(`/api/user/${S}/agent_sub_sale_price`,{agent_sub_sale_price:e});s.data.success?(q(a("ä¿åæå")),I(!1),Bs()):T(s.data.message)}catch(s){T(s.message)}finally{te(!1)}}},onCancel:()=>{I(!1),k(null),V("")},confirmLoading:ae,okText:a("ä¿å"),cancelText:a("åæ¶"),children:s.jsxs("div",{style:{padding:"12px 0"},children:[s.jsxs("p",{style:{marginBottom:"12px",fontSize:"14px",color:"#666"},children:[a("ç®æ ç¨æ·"),": ",s.jsx("strong",{children:C})," (ID: ",S,")"]}),s.jsx("p",{style:{marginBottom:"8px",fontSize:"13px",color:"#888"},children:a("åç¬åä»·é¡»ä¸ä½äºæ¿è´§ä»·ç 1.1 åãå½åæä½ï¼{{min}}ï¼æ¿è´§ä»· {{cost}}ï¼",{min:d,cost:m})}),s.jsx(g,{checked:B,onChange:e=>D(e.target.checked),style:{marginBottom:"12px"},children:a("使ç¨ç«ç¹é»è®¤éå®ä»·")}),s.jsx(j,{placeholder:a("ä¾å¦ 0.66"),value:P,onChange:e=>R(e),onBlur:()=>{if(B||K)return;const e=parseFloat(P);!Number.isNaN(e)&&e>0&&R(String(Te(e)))},disabled:B||K,type:"number",min:c||0,step:"0.01",style:{width:"100%"}})]})}),s.jsx(x,{visible:Je,title:a("å°åç¨æ·è´¦å·"),onOk:async()=>{Ye.trim()?(as(!0),await Ps(Qe.id,"disable",Qe,Ye.trim()),as(!1),Xe(!1),Ze(""),es(null)):T(a("å°åç¨æ·è´¦å·å¿
须填åå°å·åå "))},onCancel:()=>{Xe(!1),Ze(""),es(null)},confirmLoading:ss,okText:a("确认å°å"),cancelText:a("åæ¶"),okButtonProps:{type:"warning"},children:s.jsxs("div",{style:{padding:"12px 0"},children:[s.jsxs("p",{style:{marginBottom:"12px",fontSize:"14px",color:"#666"},children:[a("å°åç¨æ·"),": ",s.jsx("strong",{children:Qe?.username})," (ID: ",Qe?.id,")"]}),s.jsxs("div",{children:[s.jsxs("label",{style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:"500"},children:[a("å°å·åå ")," ",s.jsx("span",{style:{color:"red"},children:"*"})]}),s.jsx(y,{placeholder:a("请填åå°å·åå ï¼å¿
å¡«ï¼"),value:Ye,onChange:e=>Ze(e),rows:4,maxCount:500,showClear:!0,style:{width:"100%"}})]})]})}),s.jsx(l,{className:"!rounded-2xl",title:s.jsxs("div",{className:"flex flex-col w-full",children:[s.jsx("div",{className:"mb-2",children:s.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full",children:[s.jsxs("div",{className:"flex items-center text-blue-500",children:[s.jsx(ee,{size:16,className:"mr-2"}),s.jsx(Ce,{children:a("ç¨æ·ç®¡ç页é¢ï¼å¯ä»¥æ¥çåç®¡çæææ³¨åç¨æ·çä¿¡æ¯ãæéåç¶æã")})]}),s.jsx(u,{type:"tertiary",className:"w-full md:w-auto",onClick:()=>ie(!le),size:"small",children:a(le?"èªéåºå表":"ç´§åå表")})]})}),s.jsxs("div",{className:"flex gap-2 mt-3 mb-2",children:[s.jsx(u,{size:"small",theme:"light",type:"primary",onClick:()=>{Ue(!0)},children:a("æ·»å ç¨æ·")}),X()&&s.jsx(u,{size:"small",type:"danger",onClick:()=>{x.confirm({title:a("å±é©æä½ï¼è¸¢åºææç¨æ·"),content:s.jsxs("div",{children:[s.jsx("p",{style:{color:"red",fontWeight:"bold"},children:a("â ï¸ è¿æ¯ä¸ä¸ªå±é©æä½ï¼")}),s.jsx("p",{children:a("å°å¼ºå¶ææç¨æ·ï¼å
æ¬æ¨èªå·±ï¼éåºç»å½")}),s.jsx("p",{children:a("ææç¨æ·éè¦éæ°ç»å½æè½ç»§ç»ä½¿ç¨")}
1),s.jsx("p",{children:a("éç¨äºç´§æ¥æ
åµæç³»ç»ç»´æ¤")}),s.jsx("p",{style:{marginTop:"10px",color:"#ff7300"},children:a("â±ï¸ 注æï¼å¦æä¼è¯æ°éè¾å¤ï¼æ¤æä½å¯è½éè¦å åéæ¶é´")}),s.jsx("p",{style:{marginTop:"5px"},children:a("ç¡®å®è¦ç»§ç»åï¼")})]}),okText:a("确认踢åº"),cancelText:a("åæ¶"),okButtonProps:{type:"danger"},onOk:async()=>{const e=Z(a("æ£å¨æ¸
餿æä¼è¯ï¼è¯·ç¨å..."));try{const e=await $.post("/api/user/kick_all"),{success:s,message:t,data:r}=e.data;s?(q(r.message||a("å·²è¸¢åºææç¨æ·")),setTimeout(()=>{T(a("æ¨ä¹å·²è¢«è¸¢åºï¼å³å°è·³è½¬å°ç»å½é¡µ...")),setTimeout(()=>{window.location.href="/login"},2e3)},1e3)):T(t)}catch(s){T(a("æä½å¤±è´¥")+": "+s.message)}finally{e&&e.close&&e.close()}}})},children:a("è¸¢åºææç¨æ·")})]}),s.jsx(N,{margin:"12px"}),ks&&(ks.getValue("searchInviterId")||ks.getValue("searchParentId"))&&s.jsxs("div",{className:"mb-2 p-2 bg-blue-50 dark:bg-blue-900/20 rounded-lg flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(re,{size:16,className:"text-blue-500"}),s.jsxs(Ce,{className:"text-sm",children:[ks.getValue("searchInviterId")&&s.jsxs("span",{children:[a("æ£å¨æ¥çç¨æ·")," ",s.jsx("strong",{children:ks.getValue("searchInviterId")})," ",a("éè¯·çææç¨æ·")]}),ks.getValue("searchParentId")&&s.jsxs("span",{children:[ks.getValue("searchInviterId")&&" | ",a("æ£å¨æ¥ç代çç«é¿")," ",s.jsx("strong",{children:ks.getValue("searchParentId")})," ",a("çææç¨æ·")]})]})]}),s.jsx(u,{size:"small",type:"tertiary",onClick:()=>{ks&&(ks.setValue("searchInviterId",""),ks.setValue("searchParentId",""),Ve(1),Rs(1,Pe))},children:a("æ¸
é¤çé")})]}),s.jsx(r,{initValues:{searchKeyword:"",searchGroup:"",searchRole:"",searchUserId:"",searchInviterId:"",searchParentId:"",searchStartTime:"",searchEndTime:""},getFormApi:e=>zs(e),onSubmit:()=>{Ve(1),Rs(1,Pe)},allowEmpty:!0,autoComplete:"on",layout:"horizontal",trigger:"change",stopValidateWithError:!1,children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-start md:justify-end",children:[s.jsx("div",{className:"w-full md:w-40",children:s.jsx(r.Input,{size:"small",field:"searchUserId",name:"users_search_userid",prefix:s.jsx(je,{size:16}),placeholder:a("ç¨æ·IDç²¾åæ¥æ¾"),showClear:!0,pure:!0,type:"number"})}),s.jsx("div",{className:"w-full md:w-64",children:s.jsx(r.Input,{size:"small",field:"searchKeyword",name:"users_search_keyword",prefix:s.jsx(je,{size:16}),placeholder:a("ç¨æ·åãæ¾ç¤ºåç§°ãé®ç®±"),showClear:!0,pure:!0})}),s.jsx("div",{className:"w-full md:w-48",children:s.jsx(r.Select,{size:"small",field:"searchGroup",placeholder:a("éæ©åç»"),optionList:De,className:"w-full",showClear:!0,pure:!0,onChange:()=>{setTimeout(()=>{Ve(1),Rs(1,Pe)},0)}})}),(Q()||L())&&s.jsx("div",{className:"w-full md:w-48",children:s.jsx(r.Select,{size:"small",field:"searchRole",placeholder:a("éæ©æéç»"),optionList:Cs,className:"w-full",showClear:!0,pure:!0,onChange:()=>{setTimeout(()=>{Ve(1),Rs(1,Pe)},0)}})}),s.jsx("div",{className:"w-full md:w-32",children:s.jsx(r.Input,{size:"small",field:"searchInviterId",name:"users_search_inviterid",prefix:s.jsx(je,{size:16}),placeholder:a("é请人ID"),showClear:!0,pure:!0,type:"number"})}),s.jsx("div",{className:"w-full md:w-32",children:s.jsx(r.Input,{size:"small",field:"searchParentId",name:"users_search_parentid",prefix:s.jsx(je,{size:16}),placeholder:a("代çç«ID"),showClear:!0,pure:!0,type:"number"})}),s.jsx("div",{className:"w-full md:w-44",children:s.jsx(r.DatePicker,{size:"small",field:"searchStartTime",name:"users_search_starttime",placeholder:a("注åå¼å§æ¥æ"),showClear:!0,pure:!0,type:"date",format:"yyyy-MM-dd"})}),s.jsx("div",{className:"w-full md:w-44",children:s.jsx(r.DatePicker,{size:"small",field:"searchEndTime",name:"users_search_endtime",placeholder:a("注åç»ææ¥æ"),showClear:!0,pure:!0,type:"date",format:"yyyy-MM-dd"})}),s.jsx(u,{size:"small",type:"tertiary",htmlType:"submit",loading:$e||Re,className:"w-full md:w-auto",children:a("æ¥è¯¢")}),s.jsx(u,{size:"small",type:"tertiary",onClick:()=>{ks&&(ks.reset(),setTimeout(()=>{Ve(1),Rs(1,Pe)},100))},className:"w-full md:w-auto",children:a("éç½®")})]})})]}),shadows:"always",bordered:!1,children:s.jsx(be,{columns:le?Ie.map(({fixed:e,...s})=>s):Ie,dataSource:Se,scroll:le?void 0:{x:"max-content"},pagination:{formatPageText:e=>a("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:e.currentStart,end:e.currentEnd,total:Me}),currentPage:Fe,pageSize:Pe,total:Me,pageSizeOpts:[10,20,50,100],showSizeChanger:!0,onPageSizeChange:e=>{(async e=>{localStorage.setItem("page-size",e+""),Ee(e),Ve(1),ne.current=!0;const{searchKeyword:s,searchGroup:a,searchRole:t,searchUserId:r,searchInviterId:l,searchParentId:i,searchStartTime:n,searchEndTime:c}=Ts();
1try{""===s&&""===a&&""===t&&""===r&&""===l&&""===i&&""===n&&""===c?await Vs(1,e):await Rs(1,e,s,a,t,r,l,i,n,c)}catch(d){T(d)}finally{ne.current=!1}})(e)},onPageChange:e=>{if(ne.current)return;Ve(e);const{searchKeyword:s,searchGroup:a,searchRole:t,searchUserId:r,searchInviterId:l,searchParentId:i,searchStartTime:n,searchEndTime:c}=Ts();""===s&&""===a&&""===t&&""===r&&""===l&&""===i&&""===n&&""===c?Vs(e,Pe).then():Rs(e,Pe,s,a,t,r,l,i,n,c).then()}},loading:$e,onRow:(e,s)=>null!==e.DeletedAt||1!==e.status?{style:{background:"hsl(var(--border))"}}:{},empty:s.jsx(b,{image:s.jsx(_,{style:{width:150,height:150}}),darkModeImage:s.jsx(w,{style:{width:150,height:150}}),description:a("æç´¢æ ç»æ"),style:{padding:30}}),className:"overflow-hidden",size:"middle"})})]})},{Text:qe}=n,Fe=()=>{const[a,t]=e.useState([]),[i,n]=e.useState(!1),[c,d]=e.useState(!1),[m,p]=e.useState(!1),[j,f]=e.useState(!1),[g,y]=e.useState(null),[v,N]=e.useState([]),[S,k]=e.useState(!1),z=e.useCallback(async()=>{n(!0);try{const e=await $.get("/api/business-users/");e.data.success&&t(e.data.data||[])}catch(e){T("è·ååå¡åå·¥å表失败")}finally{n(!1)}},[]);e.useEffect(()=>{z()},[z]);const C=[{title:"å§å",dataIndex:"display_name",key:"display_name",render:(e,s)=>e||s.username},{title:"è´¦å·",dataIndex:"username",key:"username"},{title:"å建æ¶é´",dataIndex:"created_at",key:"created_at",render:e=>e?U(e):"-"},{title:"è´è´£å®¢æ·æ°",dataIndex:"customer_count",key:"customer_count",render:e=>s.jsx(h,{color:"blue",children:e||0})},{title:"",dataIndex:"operate",render:(e,a)=>s.jsxs(o,{children:[s.jsx(u,{type:"tertiary",size:"small",icon:s.jsx(fe,{size:16}),onClick:()=>(async e=>{y(e),f(!0),k(!0);try{const s=await $.get(`/api/assignments/?business_uid=${e.id}&page=1&page_size=100`);s.data.success&&N(s.data.data.list||[])}catch(s){T("è·ååé
å表失败")}finally{k(!1)}})(a),children:"æ¥ç客æ·"}),s.jsx(u,{type:"danger",size:"small",icon:s.jsx(ge,{size:16}),onClick:()=>{return e=a.id,s=a.display_name||a.username,void x.confirm({title:"确认å é¤",content:`ç¡®å®è¦å é¤åå¡åå·¥ã${s}ãåï¼å
¶åä¸çä¼ä¸åé
å
³ç³»å°è¢«èªå¨è§£é¤ã`,okText:"确认å é¤",cancelText:"åæ¶",okButtonProps:{type:"danger"},onOk:async()=>{try{const s=await $.delete(`/api/business-users/${e}`);s.data.success?(q("å 餿å"),z()):T(s.data.message)}catch(s){T("å é¤å¤±è´¥")}}});var e,s},children:"å é¤"})]})}],F=[{title:"ä¼ä¸åç§°",dataIndex:"customer_name",key:"customer_name"},{title:"æä½",key:"action",width:100,render:(e,a)=>s.jsx(u,{size:"small",type:"danger",onClick:()=>(async e=>{try{(await $.delete(`/api/assignments/${e}`)).data.success&&(q("已忶åé
"),N(s=>s.filter(s=>s.id!==e)),z())}catch(s){T("æä½å¤±è´¥")}})(a.id),children:"åæ¶åé
"})}];return s.jsxs(s.Fragment,{children:[s.jsx(l,{className:"!rounded-2xl",title:s.jsxs("div",{className:"flex flex-col w-full",children:[s.jsx("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full",children:s.jsxs("div",{className:"flex items-center text-blue-500",children:[s.jsx(ee,{size:16,className:"mr-2"}),s.jsx(qe,{children:"åå¡å工管çï¼å¯ä»¥æ°å»ºåå¡è´¦å·å¹¶æ¥çå
¶è´è´£çä¼ä¸å®¢æ·ã"})]})}),s.jsx("div",{className:"flex gap-2 mt-3 mb-2",children:s.jsx(u,{size:"small",theme:"light",type:"primary",onClick:()=>d(!0),children:"æ°å»ºåå¡è´¦å·"})})]}),shadows:"always",bordered:!1,children:s.jsx(be,{columns:C,dataSource:a,rowKey:"id",loading:i,pagination:!1,empty:s.jsx(b,{image:s.jsx(_,{style:{width:150,height:150}}),darkModeImage:s.jsx(w,{style:{width:150,height:150}}),description:"ææ åå¡åå·¥",style:{padding:30}}),className:"overflow-hidden",size:"middle"})}),s.jsx(x,{title:"æ°å»ºåå¡è´¦å·",visible:c,onCancel:()=>d(!1),footer:null,closeOnEsc:!0,children:s.jsxs(r,{onSubmit:async e=>{p(!0);try{const s=await $.post("/api/business-users/",e);s.data.success?(q("å建æå"),d(!1),z()):T(s.data.message)}catch(s){T("å建失败")}finally{p(!1)}},labelPosition:"top",style:{paddingTop:12,paddingBottom:12},children:[s.jsx(r.Input,{field:"display_name",label:"å§å",placeholder:"请è¾å
¥å§å",rules:[{required:!0,message:"请è¾å
¥å§å"}]}),s.jsx(r.Input,{field:"username",label:"ç»å½è´¦å·",placeholder:"请è¾å
¥ç»å½è´¦å·",rules:[{required:!0,message:"请è¾å
¥ç»å½è´¦å·"}]}),s.jsx(r.Input,{field:"password",label:"åå§å¯ç ",mode:"password",placeholder:"è³å°6ä½",rules:[{required:!0,message:"请è¾å
¥å¯ç "},{validator:(e,s)=>s&&s.length>=6,message:"å¯ç è³å°6ä½"}]}),s.jsxs("div",{style:{textAlign:"right",marginTop:24},children:[s.jsx(u,{style:{marginRight:8},onClick:()=>d(!1),children:"åæ¶"}),s.jsx(u,{theme:"solid",type:"primary",htmlType:"submit",loading:m,children:"å建"})]})]})}),s.jsx(x,{title:`${g?.display_name||g?.username||""} çåé
客æ·`,visible:j,onCancel:()=>f(!1),footer:null,width:500,children:s.jsx(I,{columns:F,dataSource:v,rowKey:"id",loading:S,pagination:!1,size:"small",empty:s.jsx(b,{description:"ææ åé
客æ·",style:{padding:20}})})})]})},Ve=()=>{const a=V(),[t,r]=e.useState("users");return a?s.jsx("div",{className:"px-2",children:s.jsxs(S,{activeKey:t,onChange:r,children:[s.jsx(k,{tab:"ç¨æ·ç®¡ç",itemKey:"users",children:s.jsx($e,{})}),s.jsx(k,{tab:"åå¡åå·¥",itemKey:"business",children:s.jsx(Fe,{})})]})}):s.jsx("div",{className:"px-2",children:s.jsx($e,{})})};export{Ve as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.