PageSourceSearch

https://cuberouter.com/static/js/async/3761.0de28ef0eb.js

js cuberouter.com collected 2026-10-09 22:58:46 UTC 58,546 bytes, 2 lines download raw bytes

1/*! LICENSE: 3761.0de28ef0eb.js.LICENSE.txt */
2"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[3761],{90114(e,s,t){var a=t(4834);async function r(){return(await a.FH.get("/api/subscription/admin/plans")).data}async function n(e){return(await a.FH.post("/api/subscription/admin/plans",e)).data}async function i(e,s){return(await a.FH.put(`/api/subscription/admin/plans/${e}`,s)).data}async function l(e,s){return(await a.FH.patch(`/api/subscription/admin/plans/${e}`,{enabled:s})).data}async function o(e){return(await a.FH.get(`/api/subscription/admin/users/${e}/subscriptions`)).data}async function d(e,s){return(await a.FH.post(`/api/subscription/admin/users/${e}/subscriptions`,s)).data}async function c(e){return(await a.FH.post(`/api/subscription/admin/user_subscriptions/${e}/invalidate`)).data}async function u(e){return(await a.FH.delete(`/api/subscription/admin/user_subscriptions/${e}`)).data}async function m(e,s){return(await a.FH.post(`/api/subscription/admin/users/${e}/subscriptions/reset`,s)).data}async function p(e,s){return(await a.FH.post(`/api/subscription/admin/plans/${e}/subscriptions/reset`,s)).data}async function h(e){return(await a.FH.post("/api/subscription/stripe/pay",e)).data}async function x(e){return(await a.FH.post("/api/subscription/creem/pay",e)).data}async function y(e){return(await a.FH.post("/api/subscription/waffo-pancake/pay",e)).data}async function g(e){return(await a.FH.post("/api/subscription/balance/pay",e)).data}async function j(e){return(await a.FH.post("/api/option/waffo-pancake/subscription-product",e)).data}async function f(){return(await a.FH.get("/api/option/waffo-pancake/subscription-product-options")).data}async function b(e){let s=await a.FH.post("/api/subscription/epay/pay",e);return{...s.data,url:s.data.url||s.url}}async function _(){return(await a.FH.get("/api/subscription/self")).data}async function v(){return(await a.FH.get("/api/subscription/plans")).data}async function w(e){return(await a.FH.put("/api/subscription/self/preference",{billing_preference:e})).data}async function N(){return(await a.FH.get("/api/group")).data}t.d(s,{Ax:()=>g,Ay:()=>v,DG:()=>j,OX:()=>r,PV:()=>m,S$:()=>w,dW:()=>h,dh:()=>b,eW:()=>u,f:()=>N,gY:()=>c,l7:()=>d,mB:()=>x,oV:()=>l,pK:()=>_,qL:()=>o,qT:()=>n,td:()=>i,vS:()=>p,y8:()=>y,zE:()=>f})},27985(e,s,t){t.d(s,{sX:()=>u,Hc:()=>p,a3:()=>r,ak:()=>n,Ey:()=>i,vD:()=>c,jy:()=>m});var a=t(84935);function r(e,s){let t=e?.duration_unit||"month",a=e?.duration_value||1,r={year:s("years"),month:s("months"),day:s("days"),hour:s("hours"),custom:s("Custom (seconds)")};if("custom"===t){let t=e?.custom_seconds||0;return t>=86400?`${Math.floor(t/86400)} ${s("days")}`:t>=3600?`${Math.floor(t/3600)} ${s("hours")}`:`${t} ${s("seconds")}`}return`${a} ${r[t]||t}`}function n(e,s){let t=e?.quota_reset_period||"never";if("daily"===t)return s("Daily");if("weekly"===t)return s("Weekly");if("monthly"===t)return s("Monthly");if("custom"===t){let t=Number(e?.quota_reset_custom_seconds||0);return t>=86400?`${Math.floor(t/86400)} ${s("days")}`:t>=3600?`${Math.floor(t/3600)} ${s("hours")}`:t>=60?`${Math.floor(t/60)} ${s("minutes")}`:`${t} ${s("seconds")}`}return s("No Reset")}function i(e){return e?(0,a.A)(1e3*e).format("YYYY-MM-DD HH:mm:ss"):"-"}var l=t(25732),o=t(63859),d=t(33271);function c(e){return l.Ik({title:l.Yj().min(1,e("Please enter plan title")),subtitle:l.Yj().optional(),price_amount:o.ai().min(0,e("Please enter amount")),duration_unit:l.k5(["year","month","day","hour","custom"]),duration_value:o.ai().min(1),custom_seconds:o.ai().min(0).optional(),quota_reset_period:l.k5(["never","daily","weekly","monthly","custom"]),quota_reset_custom_seconds:o.ai().min(0).optional(),enabled:l.zM(),sort_order:o.ai(),allow_balance_pay:l.zM(),allow_wallet_overflow:l.zM(),max_purchase_per_user:o.ai().min(0),total_amount:o.ai().min(0),upgrade_group:l.Yj().optional(),downgrade_group:l.Yj().optional(),stripe_price_id:l.Yj().optional(),creem_product_id:l.Yj().optional(),waffo_pancake_product_id:l.Yj().optional()})}let u={title:"",subtitle:"",price_amount:0,duration_unit:"month",duration_value:1,custom_seconds:0,quota_reset_period:"never",quota_reset_custom_seconds:0,enabled:!0,sort_order:0,allow_balance_pay:!0,allow_wallet_overflow:!0,max_purchase_per_user:0,total_amount:0,upgrade_group:"",downgrade_group:"",stripe_price_id:"",creem_product_id:"",waffo_pancake_product_id:""};function m(e){return{title:e.title||"",subtitle:e.subtitle||"",price_amount:Number(e.price_amount||0),duration_unit:e.duration_unit||"month",duration_value:Number(e.duration_value||1),custom_seconds:Number(e.custom_seconds||0),quota_reset_period:e.quota_reset_period||"never",quota_reset_custom_seconds:Number(e.quota_reset_custom_seconds||0),enabled:!1!==e.enabled,sort_order:Number(e.sort_order||0),allow_balance_pay:!1!==e.allow_balance_pay,allow_wallet_overflow:!1!==e.allow_wallet_overflow,max_purchase_per_user:Number(e.max_purchase_per_user||0),total_amount:(0,d.Sh)(Number(e.total_amount||0)),upgrade_group:e.upgrade_group||"",downgrade_group:e.downgrade_group||"",stripe_price_id:e.stripe_price_id||"",creem_product_id:e.creem_product_id||"",waffo_pancake_product_id:e.waffo_pancake_product_id||""}}function p(e){return{plan:{...e,price_amount:Number(e.price_amount||0),currency:"USD",duration_value:Number(e.duration_value||0),custom_seconds:Number(e.custom_seconds||0),quota_reset_period:e.quota_reset_period||"never",quota_reset_custom_seconds:"custom"===e.quota_reset_period?Number(e.quota_reset_custom_seconds||0):0,sort_order:Number(e.sort_order||0),max_purchase_per_user:Number(e.max_purchase_per_user||0),total_amount:(0,d.dD)(Number(e.total_amount||0)),upgrade_group:e.upgrade_group||"",downgrade_group:e.downgrade_group||""}}}},8803(e,s,t){var a=t(68413);let r="page-size";function n(e){let{search:s,navigate:t,pagination:n,globalFilter:i,columnFilters:l=[]}=e,o=n?.pageKey??"page",d=n?.pageSizeKey??"pageSize",c=n?.defaultPage??1,u=n?.defaultPageSize??20,m=i?.key??"filter",p=i?.enabled??!0,h=i?.trim??!0,x=(0,a.useMemo)(()=>{let e=[];for(let t of l){let a=s[t.searchKey],r=t.deserialize??(e=>e);if("string"===t.type){let s=r(a)??"";"string"==typeof s&&""!==s.trim()&&e.push({id:t.columnId,value:s})}else{let s=r(a)??[];Array.isArray(s)&&s.length>0&&e.push({id:t.columnId,value:s})}}return e},[l,s]),[y,g]=(0,a.useState)(x);(0,a.useEffect)(()=>{g(x)},[s]);let j=(0,a.useMemo)(()=>{let e=s[o],t=s[d];return{pageIndex:Math.max(0,("number"==typeof e?e:c)-1),pageSize:"number"==typeof t?t:function(){try{let e=parseInt(localStorage.getItem(r)??"",10);return e>0?e:void 0}catch{return}}()??u}},[s,o,d,c,u]),[f,b]=(0,a.useState)(()=>
2{if(!p)return;let e=s[m];return"string"==typeof e?e:""}),_=p?e=>{let s="function"==typeof e?e(f??""):e,a=h?s.trim():s;b(a),t({search:e=>({...e,[o]:void 0,[m]:a||void 0})})}:void 0;return{globalFilter:p?f??"":void 0,onGlobalFilterChange:_,columnFilters:y,onColumnFiltersChange:e=>{let s="function"==typeof e?e(y):e;g(s);let a={};for(let e of l){let t=s.find(s=>s.id===e.columnId),r=e.serialize??(e=>e);if("string"===e.type){let s="string"==typeof t?.value?t.value:"";a[e.searchKey]=""!==s.trim()?r(s):void 0}else{let s=Array.isArray(t?.value)?t.value:[];a[e.searchKey]=s.length>0?r(s):void 0}}t({search:e=>({...e,[o]:void 0,...a})})},pagination:j,onPaginationChange:e=>{let s="function"==typeof e?e(j):e,a=s.pageIndex+1,n=s.pageSize;n!==j.pageSize&&function(e){try{localStorage.setItem(r,String(e))}catch{}}(n),t({search:e=>({...e,[o]:a<=c?void 0:a,[d]:n})})},ensurePageInRange:function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{resetTo:"first"},r=s[o],n="number"==typeof r?r:c;e>0&&n>e&&t({replace:!0,search:s=>({...s,[o]:"last"===a.resetTo?e:void 0})})}}}t.d(s,{c:()=>n})},10552(e,s,t){var a=t(89795);function r(e,s,t){return!!e&&(e.role===a.z7.SUPER_ADMIN||e.permissions?.admin_permissions?.[s]?.[t]===!0)}function n(e,s){let t=s.roles.find(e=>"admin"===e.key)?.grants??{},a={};for(let r of s.resources){let s={};for(let a of r.actions)s[a.action]=e?.[r.resource]?.[a.action]??t[r.resource]?.[a.action]??!1;a[r.resource]=s}return a}t.d(s,{_m:()=>r,v$:()=>n},{YG:{READ:"read",OPERATE:"operate",WRITE:"write",SENSITIVE_WRITE:"sensitive_write",SECRET_VIEW:"secret_view",BIND:"bind"},kB:{CHANNEL:"channel",TASK_PLUGIN:"task_plugin"},sJ:{resources:[],roles:[]}})},47697(e,s,t){function a(e){return new Map(e.map(e=>[e.provider_id,e]))}function r(e,s){return`https://github.com/login/oauth/authorize?client_id=${e}&state=${s}&scope=user:email`}function n(e,s){let t=new URL("https://discord.com/oauth2/authorize");return t.searchParams.set("client_id",e),t.searchParams.set("redirect_uri",`${window.location.origin}/oauth/discord`),t.searchParams.set("response_type","code"),t.searchParams.set("scope","identify+openid"),t.searchParams.set("state",s),t.toString()}function i(e,s,t){let a=new URL(e);return a.searchParams.set("client_id",s),a.searchParams.set("redirect_uri",`${window.location.origin}/oauth/oidc`),a.searchParams.set("response_type","code"),a.searchParams.set("scope","openid profile email"),a.searchParams.set("state",t),a.toString()}function l(e,s){return`https://connect.linux.do/oauth2/authorize?response_type=code&client_id=${e}&state=${s}`}t.d(s,{N2:()=>a,Nc:()=>n,e_:()=>r,km:()=>i,yp:()=>l})},12944(e,s,t){var a=t(68413),r=t(48707);let n=null;function i(){let{resolvedTheme:e}=(0,r.D)(),[s,i]=(0,a.useState)(!1),l=(0,a.useRef)(null);return(0,a.useEffect)(()=>{let s=!1;return(async()=>{i(!1),n||(n=Promise.resolve().then(t.bind(t,59656)).then(e=>e.ThemeManager));let a=await n;s||(l.current=a,a.setCurrentTheme("dark"===e?"dark":"light"),i(!0))})(),()=>{s=!0}},[e]),{resolvedTheme:e,themeReady:s}}t.d(s,{R:()=>i})},37442(e,s,t){t.d(s,{},{X:{mode:"desktop-browser"}})},81736(e,s,t){t.r(s),t.d(s,{component:()=>e8});var a=t(72361),r=t(6702),n=t(45021),i=t(68413),l=t(20598),o=t(73280),d=t(42115),c=t(85718);let u={enable:"User enabled successfully",disable:"User disabled successfully",promote:"User promoted to admin successfully",demote:"User demoted to regular user successfully",promote_ops:"User promoted to ops successfully",demote_ops:"User demoted to regular user successfully",delete:"User deleted successfully",add_quota:"Quota adjusted successfully"};var m=t(46006),p=t(25732),h=t(10552),x=t(33271),y=t(89795);let g=p.Ik({username:p.Yj().min(1,"Username is required").refine(e=>Array.from(e).length<=50,{message:"Username must be at most 50 characters"}),display_name:p.Yj().optional(),password:p.Yj().optional(),role:p.ai().optional(),quota_dollars:p.ai().min(0).optional(),group:p.Yj().optional(),remark:p.Yj().optional(),phone:p.Yj().max(32).optional(),admin_permissions:p.g1(p.Yj(),p.g1(p.Yj(),p.zM())).optional()}),j={username:"",display_name:"",password:"",role:1,quota_dollars:0,group:c.wK,remark:"",phone:"",admin_permissions:{}};function f(e){return{username:e.username,display_name:e.display_name,password:"",role:e.role,quota_dollars:(0,x.Sh)(e.quota),group:e.group||c.wK,remark:e.remark||"",phone:e.phone||"",admin_permissions:e.admin_permissions??{}}}var b=t(20687);let _=i.createContext(null);function v(e){let{children:s}=e,[t,r]=(0,b.Ay)(null),[n,l]=(0,i.useState)(null),[o,d]=(0,i.useState)(0);return(0,a.jsx)(_,{value:{open:t,setOpen:r,currentRow:n,setCurrentRow:l,refreshTrigger:o,triggerRefresh:()=>d(e=>e+1)},children:s})}let w=()=>{let e=i.useContext(_);if(!e)throw Error("useUsers has to be used within <UsersContext>");return e};function N(){let{t:e}=(0,r.Bd)(),{open:s,setOpen:t,currentRow:n,triggerRefresh:p}=w(),[h,x]=(0,i.useState)(!1),y=async()=>
2{if(n){x(!0);try{let s=await (0,d.hG)(n.id);s.success?(l.oR.success(e(u.delete)),t(null),p()):l.oR.error(s.message||e(c.UU.DELETE_FAILED))}catch(u){var s,a;let t,r,n,i,o,d;l.oR.error((r=!(t=(0,m.AH)(u))||t===u&&u instanceof Error?null:t,n="string"==typeof(s=r?.message)?s.trim():"",i=(0,m.I5)(u),o=Array.isArray(a=r?.blockers)?a.filter(e=>"string"==typeof e&&e.length>0):[],d=[n],i&&d.push(e(i)),o.length>0&&d.push(`${e("Blockers")}: ${o.join(", ")}`),d.map(e=>e.trim()).filter(e=>e.length>0).join(" ")||e(c.UU.DELETE_FAILED)))}finally{x(!1)}}};return(0,a.jsx)(o.T,{open:"delete"===s,onOpenChange:e=>!e&&t(null),title:e("Are you sure?"),desc:(0,a.jsxs)(a.Fragment,{children:[e("This will permanently delete user")," ",(0,a.jsx)("span",{className:"font-semibold",children:n?.username}),e(". This action cannot be undone.")]}),confirmText:h?e("Deleting..."):e("Delete"),destructive:!0,isLoading:h,handleConfirm:y})}var k=t(48367),S=t(53540),C=t(65277),A=t(86832),I=t(47029),R=t(72868),E=t(82655),$=t(36710),D=t(1738),z=t(11728),F=t(88288),q=t(74559),T=t(70954),U=t(43459),M=t(52523),P=t(60641),O=t(56275);function H(e){let{t:s}=(0,r.Bd)(),[t,n]=(0,i.useState)("add"),[o,c]=(0,i.useState)(""),[u,m]=(0,i.useState)(!1),{meta:p}=(0,U.cw)(),h=(0,U.yz)(),y="tokens"===p.kind,g=parseFloat(o)||0,j=(0,x.dD)(Math.abs(g)),f=async()=>{if((o||"override"===t)&&(!(j<=0)||"override"===t)){m(!0);try{let a="override"===t?(0,x.dD)(g):j,r=await (0,d.Xw)({id:e.userId,action:"add_quota",mode:t,value:"override"===t?a:Math.abs(a)});r.success?(l.oR.success(s("Quota adjusted successfully")),c(""),n("add"),e.onOpenChange(!1),e.onSuccess()):l.oR.error(r.message||s("Failed to adjust quota"))}catch(e){l.oR.error(e instanceof Error?e.message:s("Failed to adjust quota"))}finally{m(!1)}}},b=y?s("Enter amount in tokens"):s("Enter amount in {{currency}}",{currency:h});return(0,a.jsx)(P.l,{open:e.open,onOpenChange:e.onOpenChange,title:s("Adjust Quota"),description:s("Select an operation mode and enter the amount"),contentHeight:"auto",bodyClassName:"space-y-4",footer:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(R.$,{variant:"outline",onClick:()=>{c(""),n("add"),e.onOpenChange(!1)},children:s("Cancel")}),(0,a.jsx)(R.$,{onClick:f,disabled:u,children:u?s("Processing..."):s("Confirm")})]}),children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("div",{className:"text-muted-foreground text-sm",children:(()=>{let a=e.currentQuota;switch(t){case"add":return`${s("Current quota")}: ${(0,x.eN)(a)}  +${(0,x.eN)(j)} = ${(0,x.eN)(a+j)}`;case"subtract":return`${s("Current quota")}: ${(0,x.eN)(a)}  -${(0,x.eN)(j)} = ${(0,x.eN)(a-j)}`;case"override":{let e=(0,x.dD)(g);return`${s("Current quota")}: ${(0,x.eN)(a)} → ${(0,x.eN)(e)}`}default:return""}})()}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(z.J,{children:s("Mode")}),(0,a.jsx)("div",{className:"flex gap-1",children:["add","subtract","override"].map(e=>(0,a.jsx)(R.$,{type:"button",variant:"outline",size:"sm",className:(0,O.cn)(t===e&&"bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground"),onClick:()=>{n(e),c("")},children:"add"===e?s("Add"):"subtract"===e?s("Subtract"):s("Override")},e))})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)(z.J,{children:[s("Amount")," (",h,")"]}),(0,a.jsx)(D.p,{type:"number",step:y?1:1e-6,min:"override"===t?void 0:0,placeholder:b,value:o,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&f()}})]})]})})}function B(e){let{open:s,onOpenChange:t,currentRow:n}=e,{t:o}=(0,r.Bd)(),u=!!n,{triggerRefresh:m}=w(),p=(0,M.n)(e=>e.auth.user),[b,_]=(0,i.useState)(!1),[v,N]=(0,i.useState)(!1),{data:P}=(0,S.I)({queryKey:["groups"],queryFn:d.f,staleTime:3e5}),O=P?.data||[],{data:B=h.sJ}=(0,S.I)({queryKey:["admin-permission-catalog"],queryFn:d.PQ,staleTime:3e5}),L=(0,A.mN)({resolver:(0,k.u)(g),defaultValues:j});(0,i.useEffect)(()=>{s&&u&&n?(0,d.wz)(n.id).then(e=>{e.success&&e.data&&L.reset(f(e.data))}):s&&!u&&L.reset(j)},[s,u,n,L]);let{meta:K}=(0,U.cw)(),V=(0,U.yz)(),W="tokens"===K.kind,Y=L.watch("quota_dollars")||0,J=L.watch("role"),Q=p?.role===y.z7.SUPER_ADMIN,X=(J??n?.role??0)>=y.z7.ADMIN,G=async e=>{if(!u){let s=e.password?.length||0;if(s<8||s>20)return void L.setError("password",{type:"manual",message:o("Password must be between 8 and 20 characters")})}_(!0);try{var s;let a,r,i=(s=n?.id,a={username:e.username,display_name:e.display_name||e.username,password:e.password||void 0},(r=void 0===s?e.role||1:e.role??0)>=y.z7.ADMIN&&B&&(a.admin_permissions=(0,h.v$)(e.admin_permissions,B)),void 0===s?a.role=r:(a.group=e.group,a.remark=e.remark||void 0,a.phone=e.phone,a.id=s),a),p=u?await (0,d.TK)(i):await (0,d.kg)(i);p.success?(l.oR.success(u?o(c.PL.USER_UPDATED):o(c.PL.USER_CREATED)),t(!1),m()):l.oR.error(p.message||(u?o(c.UU.UPDATE_FAILED):o(c.UU.CREATE_FAILED)))}catch(e){l.oR.error(o(c.UU.UNEXPECTED))}finally{_(!1)}},Z=async()=>
2{if(!n)return;let e=await (0,d.wz)(n.id);e.success&&e.data&&L.reset(f(e.data)),m()};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(q.cj,{open:s,onOpenChange:e=>{t(e),e||L.reset()},children:(0,a.jsxs)(q.h,{className:(0,I.jW)("sm:max-w-[600px]"),children:[(0,a.jsxs)(q.Fm,{className:(0,I.Dt)(),children:[(0,a.jsxs)(q.qp,{children:[u?o("Update"):o("Create")," ",o("User")]}),(0,a.jsx)(q.Qs,{children:u?o("Update the user by providing necessary info."):o("Add a new user by providing necessary info.")})]}),(0,a.jsx)($.lV,{...L,children:(0,a.jsxs)("form",{id:"user-form",onSubmit:L.handleSubmit(G),className:(0,I.e)(),children:[(0,a.jsxs)(I.y5,{children:[(0,a.jsx)("h3",{className:"text-sm font-medium",children:o("Basic Information")}),(0,a.jsx)($.zB,{control:L.control,name:"username",render:e=>{let{field:s}=e;return(0,a.jsxs)($.eI,{children:[(0,a.jsx)($.lR,{children:o("Username")}),(0,a.jsx)($.MJ,{children:(0,a.jsx)(D.p,{...s,placeholder:o("Enter username"),maxLength:50,disabled:u})}),(0,a.jsx)($.C5,{})]})}}),!u&&(0,a.jsx)($.zB,{control:L.control,name:"role",render:e=>{let{field:s}=e;return(0,a.jsxs)($.eI,{children:[(0,a.jsx)($.lR,{children:o("Role")}),(0,a.jsxs)(F.l6,{items:[{value:"1",label:o("Common User")},{value:"10",label:o("Admin")}],onValueChange:e=>null!==e&&s.onChange(parseInt(e)),value:String(s.value),children:[(0,a.jsx)($.MJ,{children:(0,a.jsx)(F.bq,{children:(0,a.jsx)(F.yv,{placeholder:o("Select a role")})})}),(0,a.jsx)(F.gC,{alignItemWithTrigger:!1,children:(0,a.jsxs)(F.s3,{children:[(0,a.jsx)(F.eb,{value:"1",children:o("Common User")}),(0,a.jsx)(F.eb,{value:"10",children:o("Admin")})]})})]}),(0,a.jsx)($.Rr,{children:o("Set the user's role (cannot be Root)")}),(0,a.jsx)($.C5,{})]})}}),(0,a.jsx)($.zB,{control:L.control,name:"display_name",render:e=>{let{field:s}=e;return(0,a.jsxs)($.eI,{children:[(0,a.jsx)($.lR,{children:o("Display Name")}),(0,a.jsx)($.MJ,{children:(0,a.jsx)(D.p,{...s,placeholder:o("Enter display name")})}),(0,a.jsx)($.Rr,{children:o("Leave empty to use username")}),(0,a.jsx)($.C5,{})]})}}),(0,a.jsx)($.zB,{control:L.control,name:"password",render:e=>{let{field:s}=e;return(0,a.jsxs)($.eI,{children:[(0,a.jsx)($.lR,{children:o("Password")}),(0,a.jsx)($.MJ,{children:(0,a.jsx)(D.p,{...s,type:"password",placeholder:u?o("Leave empty to keep unchanged"):o("Enter password (8-20 characters)")})}),(0,a.jsx)($.C5,{})]})}})]}),u&&(0,a.jsxs)(I.y5,{children:[(0,a.jsx)("h3",{className:"text-sm font-medium",children:o("Group & Quota")}),(0,a.jsx)($.zB,{control:L.control,name:"group",render:e=>{let{field:s}=e;return(0,a.jsxs)($.eI,{children:[(0,a.jsx)($.lR,{children:o("Group")}),(0,a.jsxs)(F.l6,{items:[...O.map(e=>({value:e,label:e}))],onValueChange:s.onChange,value:s.value,children:[(0,a.jsx)($.MJ,{children:(0,a.jsx)(F.bq,{children:(0,a.jsx)(F.yv,{placeholder:o("Select a group")})})}),(0,a.jsx)(F.gC,{alignItemWithTrigger:!1,children:(0,a.jsx)(F.s3,{children:O.map(e=>(0,a.jsx)(F.eb,{value:e,children:e},e))})})]}),(0,a.jsx)($.C5,{})]})}}),(0,a.jsx)($.zB,{control:L.control,name:"quota_dollars",render:e=>{let{field:s}=e;return(0,a.jsxs)($.eI,{children:[(0,a.jsx)($.lR,{children:o("Remaining Quota ({{currency}})",{currency:V})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)($.MJ,{children:(0,a.jsx)(D.p,{value:W?String(s.value||0):(s.value||0).toFixed(6),readOnly:!0,className:"flex-1"})}),(0,a.jsxs)(R.$,{type:"button",variant:"outline",onClick:()=>N(!0),children:[(0,a.jsx)(C.A,{className:"mr-1 h-4 w-4"}),o("Adjust Quota")]})]}),(0,a.jsx)($.Rr,{children:(0,x.eN)((0,x.dD)(s.value||0))}),(0,a.jsx)($.C5,{})]})}}),(0,a.jsx)($.zB,{control:L.control,name:"remark",render:e=>{let{field:s}=e;return(0,a.jsxs)($.eI,{children:[(0,a.jsx)($.lR,{children:o("Remark")}),(0,a.jsx)($.MJ,{children:(0,a.jsx)(T.T,{...s,placeholder:o("Admin notes (only visible to admins)"),rows:3})}),(0,a.jsx)($.C5,{})]})}}),(0,a.jsx)($.zB,{control:L.control,name:"phone",render:e=>{let{field:s}=e;return(0,a.jsxs)($.eI,{children:[(0,a.jsx)($.lR,{children:o("Phone")}),(0,a.jsx)($.MJ,{children:(0,a.jsx)(D.p,{...s,type:"tel",placeholder:o("Phone number")})}),(0,a.jsx)($.C5,{})]})}})]}),Q&&X&&B.resources.length>0&&(0,a.jsxs)(I.y5,{children:[(0,a.jsx)("h3",{className:"text-sm font-medium",children:o("Admin Permissions")}),(0,a.jsx)("p",{className:"text-muted-foreground text-xs",children:o("Default administrator permissions can be overridden for this user.")}),(0,a.jsx)($.zB,{control:L.control,name:"admin_permissions",render:e=>{let{field:s}=e,t=(0,h.v$)(s.value,B);return(0,a.jsxs)($.eI,{children:[(0,a.jsx)("div",{className:"space-y-3",children:B.resources.map(e=>(0,a.jsxs)("div",{className:"space-y-2 rounded-md border p-3",children:[(0,a.jsx)("div",{className:"text-sm font-medium",children:o(e.label_key)}),(0,a.jsx)("div",{className:"space-y-2",children:e.actions.map(r=>(0,a.jsxs)("label",{className:"flex items-start gap-3",children:[(0,a.jsx)(E.S,{checked:t[e.resource]?.[r.action]===!0,onCheckedChange:a=>{s.onChange({...t,[e.resource]:{...t[e.resource],[r.action]:!0===a}})}}),(0,a.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:o(r.label_key)}),(0,a.jsx)("span",{className:"text-muted-foreground text-xs",children:o(r.description_key)})]})]},r.action))})]},e.resource))}),(0,a.jsx)($.C5,{})]})}}),p&&(0,a.jsx)("p",{className:"text-muted-foreground text-xs",children:(0,h._m)(p,h.kB.CHANNEL,h.YG.SENSITIVE_WRITE)?o("Your account can edit sensitive channel settings."):o("Your account cannot edit sensitive channel settings.")})]}),u&&(0,a.jsxs)(I.y5,{children:[(0,a.jsx)("h3",{className:"text-sm font-medium",children:o("Binding Information")}),(0,a.jsx)("p",{className:"text-muted-foreground text-xs",children:o("Third-party account bindings (read-only, managed by user in profile settings)")}),(0,a.jsx)("div",{className:"flex flex-col gap-3",children:c.wU.map(e=>{let{key:s,label:t}=e;return(0,a.jsxs)("div",{children:[(0,a.jsx)(z.J,{className:"text-muted-foreground text-xs",children:o(t)}),(0,a.jsx)(D.p,{value:n?.[s]||"-",disabled:!0,className:"mt-1"})]},s)})})]})]})}),(0,a.jsxs)(q.XW,{className:(0,I.Jx)(),children:[(0,a.jsx)(q.kN,{render:(0,a.jsx)(R.$,{variant:"outline"}),children:o("Close")}),(0,a.jsx)(R.$,{form:"user-form",type:"submit",disabled:b,children:b?o("Saving..."):o("Save changes")}
2)]})]})}),n&&(0,a.jsx)(H,{open:v,onOpenChange:N,userId:n.id,currentQuota:(0,x.dD)(Y||0),onSuccess:Z})]})}var L=t(2718),K=t(33834),V=t(66002),W=t(56923);function Y(e,s){if(e.length>0)return{ids:e};let t={};return s.keyword&&(t.keyword=s.keyword),s.group&&(t.group=s.group),t}let J=(0,L.GY)("/_authenticated/users/");function Q(){let{t:e}=(0,r.Bd)(),{setOpen:s,setCurrentRow:t}=w(),n=J.useSearch(),[o,c]=(0,i.useState)(!1),u=(0,M.n)(e=>e.auth.user?.role);if(!(0,W.q)(u))return null;let m=async()=>{c(!0);try{let e=Y([],{keyword:n.filter??"",group:n.group??""}),{blob:s,filename:t}=await (0,d.bV)(e),a=URL.createObjectURL(s),r=document.createElement("a");r.href=a,r.download=t||"users.csv",r.click(),URL.revokeObjectURL(a)}catch(t){let s=t instanceof Error?t.message:"";l.oR.error(s||e("Failed to export users"))}finally{c(!1)}};return(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)(R.$,{size:"sm",variant:"outline",onClick:m,disabled:o,children:[(0,a.jsx)(K.A,{"aria-hidden":"true",className:"h-4 w-4"}),e("Export All")]}),(0,a.jsxs)(R.$,{size:"sm",onClick:()=>{t(null),s("create")},children:[(0,a.jsx)(V.A,{className:"h-4 w-4"}),e("Add User")]})]})}var X=t(92279),G=t(7579),Z=t(8803);function ee(e){let{table:s}=e,{t}=(0,r.Bd)(),[n,o]=(0,i.useState)(!1),c=(0,M.n)(e=>e.auth.user?.role);if(!(0,W.q)(c))return null;let u=async()=>{let e=s.getSelectedRowModel().rows.map(e=>e.original.id);if(0!==e.length){o(!0);try{let s=Y(e,{keyword:"",group:""}),{blob:t,filename:a}=await (0,d.bV)(s),r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download=a||"users.csv",n.click(),URL.revokeObjectURL(r)}catch(s){let e=s instanceof Error?s.message:"";l.oR.error(e||t("Failed to export users"))}finally{o(!1)}}};return(0,a.jsx)(X.Of,{table:s,entityName:"user",children:(0,a.jsxs)(R.$,{size:"sm",variant:"outline",onClick:u,disabled:n,children:[(0,a.jsx)(K.A,{"aria-hidden":"true",className:"h-4 w-4"}),t("Export Selected")]})})}var es=t(98622),et=t(42817),ea=t(28079),er=t(47303),en=t(36001),ei=t(6201),el=t(45666),eo=t(43641),ed=t(80792),ec=t(9781);let eu=(0,ec.A)("user-minus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);var em=t(59735),ep=t(97808),eh=t(55989);let ex=(0,ec.A)("chart-column-big",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);var ey=t(47296),eg=t(18100),ej=t(14653),ef=t(43494),eb=t(84368),e_=t(23921);let ev=(0,ec.A)("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]);var ew=t(87212),eN=t(90114),ek=t(27985);function eS(e){let s=Date.now()/1e3,t=(e.sub.end_time||0)>0&&e.sub.end_time<s;return"active"!==e.sub.status||t?"cancelled"===e.sub.status?(0,a.jsx)(et.Wh,{label:e.t("Invalidated"),variant:"neutral",copyable:!1}):(0,a.jsx)(et.Wh,{label:e.t("Expired"),variant:"neutral",copyable:!1}):(0,a.jsx)(et.Wh,{label:e.t("Active"),variant:"success",copyable:!1})}function eC(e){let{t:s}=(0,r.Bd)(),[t,n]=(0,i.useState)(!1),[d,c]=(0,i.useState)(!1),[u,m]=(0,i.useState)([]),[p,h]=(0,i.useState)([]),[y,g]=(0,i.useState)(""),[j,f]=(0,i.useState)(!1),[b,_]=(0,i.useState)(!0),[v,w]=(0,i.useState)(null),[N,k]=(0,i.useState)(null),S=(0,i.useMemo)(()=>{let e=new Map;return u.forEach(s=>{s.plan.id&&e.set(s.plan.id,s.plan.title||`#${s.plan.id}`)}),e},[u]),C=(0,i.useCallback)(async()=>{if(e.user?.id){n(!0);try{let[s,t]=await Promise.all([(0,eN.OX)(),(0,eN.qL)(e.user.id)]);s.success&&m(s.data||[]),t.success&&h(t.data||[])}catch{l.oR.error(s("Loading failed"))}finally{n(!1)}}},[e.user?.id,s]);(0,i.useEffect)(()=>{e.open&&e.user?.id&&(g(""),C())},[e.open,e.user?.id,C]);let A=async()=>{if(!e.user?.id||!y)return void l.oR.error(s("Please select a subscription plan"));c(!0);try{let t=await (0,eN.l7)(e.user.id,{plan_id:Number(y)});t.success&&(l.oR.success(t.data?.message||s("Added successfully")),g(""),await C(),e.onSuccess?.())}catch{l.oR.error(s("Request failed"))}finally{c(!1)}},E=async()=>
2{if(N)try{if("invalidate"===N.type){let t=await (0,eN.gY)(N.subId);t.success&&(l.oR.success(t.data?.message||s("Has been invalidated")),await C(),e.onSuccess?.())}else(await (0,eN.eW)(N.subId)).success&&(l.oR.success(s("Deleted")),await C(),e.onSuccess?.())}catch{l.oR.error(s("Operation failed"))}finally{k(null)}},$=async()=>{if(e.user?.id&&v){f(!0);try{let t=await (0,eN.PV)(e.user.id,{plan_id:v.planId,advance_reset_time:b});t.success&&(l.oR.success(s("Reset {{count}} active subscriptions",{count:t.data?.reset_count||0})),await C(),e.onSuccess?.())}catch{l.oR.error(s("Operation failed"))}finally{f(!1),w(null)}}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(q.cj,{open:e.open,onOpenChange:e.onOpenChange,children:(0,a.jsxs)(q.h,{className:(0,I.jW)("sm:max-w-2xl"),children:[(0,a.jsxs)(q.Fm,{className:(0,I.Dt)(),children:[(0,a.jsx)(q.qp,{children:s("User Subscription Management")}),(0,a.jsxs)(q.Qs,{children:[e.user?.username||"-"," (ID: ",e.user?.id||"-",")"]})]}),(0,a.jsxs)("div",{className:(0,I.e)(),children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)(F.l6,{items:u.map(e=>({value:String(e.plan.id),label:(0,a.jsxs)(a.Fragment,{children:[e.plan.title,"($",Number(e.plan.price_amount||0).toFixed(2),")"]})})),value:y,onValueChange:e=>null!==e&&g(e),children:[(0,a.jsx)(F.bq,{className:"flex-1",children:(0,a.jsx)(F.yv,{placeholder:s("Select subscription plan")})}),(0,a.jsx)(F.gC,{alignItemWithTrigger:!1,children:(0,a.jsx)(F.s3,{children:u.map(e=>(0,a.jsxs)(F.eb,{value:String(e.plan.id),children:[e.plan.title," ($",Number(e.plan.price_amount||0).toFixed(2),")"]},e.plan.id))})})]}),(0,a.jsxs)(R.$,{onClick:A,disabled:d||!y,children:[(0,a.jsx)(V.A,{className:"mr-1 h-4 w-4"}),s("Add subscription")]})]}),(0,a.jsx)(X.hm,{data:t?[]:p,getRowKey:e=>e.subscription.id,emptyClassName:t?"py-8":"text-muted-foreground py-8",emptyContent:t?s("Loading..."):s("No subscription records"),columns:[{id:"id",header:s("ID"),cell:e=>(0,a.jsx)(ea.C,{value:e.subscription.id})},{id:"plan",header:s("Plan"),cell:e=>{let t=e.subscription;return(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"font-medium",children:S.get(t.plan_id)||`#${t.plan_id}`}),(0,a.jsxs)("div",{className:"text-muted-foreground text-sm",children:[s("Source"),": ",t.source||"-"]})]})}},{id:"status",header:s("Status"),cell:e=>(0,a.jsx)(eS,{sub:e.subscription,t:s})},{id:"validity",header:s("Validity"),cell:e=>{let t=e.subscription;return(0,a.jsxs)("div",{className:"text-sm",children:[(0,a.jsxs)("div",{children:[s("Start"),": ",(0,ek.Ey)(t.start_time)]}),(0,a.jsxs)("div",{children:[s("End"),": ",(0,ek.Ey)(t.end_time)]})]})}},{id:"quota",header:s("Total Quota"),cell:e=>{let t=e.subscription,a=Number(t.amount_total||0),r=Number(t.amount_used||0);return a>0?`${(0,x.eN)(r)}/${(0,x.eN)(a)}`:s("Unlimited")}},{id:"actions",header:s("Actions"),className:"text-right",cellClassName:"text-right",cell:e=>{let t=e.subscription,r=Date.now()/1e3,n=(t.end_time||0)>0&&t.end_time<r,i="active"===t.status&&!n;return(0,a.jsxs)(X.CY,{ariaLabel:s("Actions"),children:[(0,a.jsxs)(eb._2,{disabled:!i,onClick:()=>{_(!0),w({planId:t.plan_id,planTitle:S.get(t.plan_id)||`#${t.plan_id}`})},children:[s("Reset quota"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(e_.A,{size:16})})]}),(0,a.jsxs)(eb._2,{disabled:!i,onClick:()=>k({type:"invalidate",subId:t.id}),children:[s("Invalidate"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(ev,{size:16})})]}),(0,a.jsx)(eb.mB,{}),(0,a.jsxs)(eb._2,{variant:"destructive",onClick:()=>k({type:"delete",subId:t.id}),children:[s("Delete"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(ej.A,{size:16})})]})]})}}]})]})]})}),N&&(0,a.jsx)(o.T,{open:!0,onOpenChange:e=>!e&&k(null),title:"invalidate"===N.type?s("Confirm invalidate"):s("Confirm delete"),desc:"invalidate"===N.type?s("After invalidating, this subscription will be immediately deactivated. Historical records are not affected. Continue?"):s("Deleting will permanently remove this subscription record (including benefit details). Continue?"),handleConfirm:E,destructive:"delete"===N.type}),v&&(0,a.jsx)(o.T,{open:!0,onOpenChange:e=>!e&&w(null),title:s("Reset subscription quota"),desc:s("Reset active {{plan}} subscriptions for this user?",{plan:v.planTitle}),confirmText:s("Reset quota"),handleConfirm:$,isLoading:j,children:(0,a.jsxs)("label",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2 text-sm",children:[(0,a.jsx)("span",{children:s("Advance next reset time")}
2),(0,a.jsx)(ew.d,{checked:b,onCheckedChange:e=>_(!!e),"aria-label":s("Advance next reset time")})]})})]})}var eA=t(20103);let eI=(0,ec.A)("message-circle",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]]);var eR=t(67733),eE=t(38384),e$=t(55724),eD=t(92429),ez=t(5333),eF=t(57335),eq=t(6433),eT=t(15161),eU=t(38939),eM=t(4834),eP=t(47697);let eO=[{key:"email",field:"email",label:"Email",icon:(0,a.jsx)(eA.A,{className:"h-4 w-4"}),statusKey:null},{key:"github",field:"github_id",label:"GitHub",icon:(0,a.jsx)(eq.SiGithub,{className:"h-4 w-4"}),statusKey:"github_oauth"},{key:"discord",field:"discord_id",label:"Discord",icon:(0,a.jsx)(eq.SiDiscord,{className:"h-4 w-4"}),statusKey:"discord_oauth"},{key:"wechat",field:"wechat_id",label:"WeChat",icon:(0,a.jsx)(eI,{className:"h-4 w-4"}),statusKey:"wechat_login"},{key:"oidc",field:"oidc_id",label:"OIDC",icon:(0,a.jsx)(eR.A,{className:"h-4 w-4"}),statusKey:"oidc_enabled"},{key:"telegram",field:"telegram_id",label:"Telegram",icon:(0,a.jsx)(eE.A,{className:"h-4 w-4"}),statusKey:"telegram_oauth"},{key:"linuxdo",field:"linux_do_id",label:"LinuxDO",icon:(0,a.jsx)(eR.A,{className:"h-4 w-4"}),statusKey:"linuxdo_oauth"}];function eH(e){return e.iconUrl?(0,a.jsx)("img",{src:e.iconUrl,alt:"",className:"h-4 w-4 rounded-sm object-contain",onError:e=>{e.currentTarget.style.display="none"}}):(0,a.jsx)(em.A,{className:"h-4 w-4"})}function eB(e){let{t:s}=(0,r.Bd)(),[t,n]=(0,i.useState)(null),[c,u]=(0,i.useState)([]),[m,p]=(0,i.useState)({}),[h,x]=(0,i.useState)(!1),[y,g]=(0,i.useState)(!0),[j,f]=(0,i.useState)(null),[b,_]=(0,i.useState)(!1),v=(0,i.useCallback)(async()=>{if(e.userId){x(!0);try{let[s,t,a]=await Promise.all([(0,d.wz)(e.userId),(0,d.XD)(e.userId).catch(()=>({success:!1,data:[]})),eM.FH.get("/api/status").then(e=>e.data).catch(()=>({success:!1,data:{}}))]);s.success&&s.data&&n(s.data),t.success&&t.data&&u(t.data),a.success&&a.data&&p(a.data)}catch{l.oR.error(s("Failed to load"))}finally{x(!1)}}},[e.userId,s]);(0,i.useEffect)(()=>{e.open&&e.userId?(g(!0),v()):(n(null),u([]),p({}))},[e.open,e.userId,v]);let w=(0,i.useMemo)(()=>{let e=[];for(let s of eO){let a=t?String(t[s.field]||""):"",r=!!a,n=null==s.statusKey||!!m[s.statusKey];e.push({key:s.key,label:s.label,icon:s.icon,value:r?a:"",type:"builtin",isBound:r,isEnabled:n})}let s=(0,eP.N2)(c),r=m.custom_oauth_providers||[],n=new Set;for(let t of r){n.add(t.id);let r=s.get(t.id);e.push({key:`oauth_${t.id}`,label:t.name||String(t.id),icon:(0,a.jsx)(eH,{iconUrl:t.icon}),value:r?.provider_user_id||"",type:"custom",providerId:t.id,isBound:!!r,isEnabled:!0})}for(let s of c)n.has(s.provider_id)||e.push({key:`oauth_${s.provider_id}`,label:s.provider_name||String(s.provider_id),icon:(0,a.jsx)(em.A,{className:"h-4 w-4"}),value:s.provider_user_id||"-",type:"custom",providerId:s.provider_id,isBound:!0,isEnabled:!1});return e},[t,c,m]),N=y?w.filter(e=>e.isBound):w,k=w.filter(e=>e.isBound).length,S=async()=>{if(j&&e.userId){_(!0);try{let t;"builtin"===j.type?t=await (0,d.zm)(e.userId,j.key):j.providerId&&(t=await (0,d.OP)(e.userId,j.providerId)),t?.success?(l.oR.success(s("Unbound {{provider}}",{provider:j.label})),await v(),e.onUnbindSuccess?.()):l.oR.error(t?.message||s("Unbind failed"))}catch{l.oR.error(s("Unbind failed"))}finally{_(!1),f(null)}}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(P.l,{open:e.open,onOpenChange:e.onOpenChange,title:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(em.A,{className:"h-5 w-5"}),s("Account Binding Management")]}),description:s("Manage account bindings for this user"),contentClassName:"sm:max-w-lg",titleClassName:"flex items-center gap-2",descriptionClassName:"sr-only",contentHeight:"auto",bodyClassName:"space-y-4",children:h?(0,a.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,a.jsx)(e$.A,{className:"text-muted-foreground h-6 w-6 animate-spin"})}):(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[t&&(0,a.jsxs)("p",{className:"text-muted-foreground text-sm",children:[t.username," (ID: ",t.id,")"]}),(0,a.jsx)(er.Bc,{children:(0,a.jsxs)(er.m_,{children:[(0,a.jsxs)(er.k$,{render:(0,a.jsx)(R.$,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>g(e=>!e)}),children:[y?(0,a.jsx)(eD.A,{className:"h-3.5 w-3.5"}):(0,a.jsx)(ez.A,{className:"h-3.5 w-3.5"}),y?s("Show All"):s("Bound Only")]}),(0,a.jsx)(er.ZI,{children:y?s("Show all providers including unbound"):s("Show only bound providers")})]})})]}),(0,a.jsx)(eU.w,{}),(0,a.jsx)(eT.F,{className:"max-h-[50vh]",children:0===N.length?(0,a.jsx)("p",{className:"text-muted-foreground py-4 text-center text-sm",children:y?s("This user has no bindings"):s("No providers available")}):(0,a.jsx)("div",{className:"grid grid-cols-1 gap-2 pr-3 lg:grid-cols-2",children:N.map(e=>(0,a.jsxs)("div",{className:`flex items-center justify-between rounded-md border px-3 py-2.5 ${!e.isBound?"opacity-50":""}`,children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,a.jsx)("div",{className:"text-muted-foreground shrink-0",children:e.icon}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:e.label}),!e.isEnabled&&(0,a.jsx)(et.Wh,{variant:"neutral",label:s("Disabled"),copyable:!1,size:"sm"})]}),(0,a.jsx)("p",{className:"text-muted-foreground max-w-[140px] truncate text-xs",children:e.isBound?e.value:s("Not bound")})]})]}),e.isBound&&(0,a.jsx)(R.$,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive h-7 w-7 shrink-0 p-0",onClick:()=>f(e),children:(0,a.jsx)(eF.A,{className:"h-3.5 w-3.5"})})]},e.key))})}),(0,a.jsxs)("p",{className:"text-muted-foreground text-xs",children:[s("Bound"),": ",k," / ",w.length]})]})}),(0,a.jsx)(o.T,{open:!!j,onOpenChange:e=>!e&&f(null),title:s("Confirm Unbind"),desc:s("Are you sure you want to unbind {{provider}} for this user? The user will no longer be able to log in via this method.",{provider:j?.label||""}),confirmText:s("Confirm Unbind"),destructive:!0,handleConfirm:S,isLoading:b})]})}var eL=t(49302);function eK(e){let s,{open:t,onOpenChange:n,userId:l,username:o}=e,{t:u}=(0,r.Bd)(),[m,p]=(0,i.useState)([]),[h,g]=(0,i.useState)(0),[j,f]=(0,i.useState)(1),[b,_]=(0,i.useState)(!1),[v,w]=(0,i.useState)(""),N=(0,i.useCallback)(async e=>{_(!0),w("");try{let s=await (0,d.FM)(l,{p:e,page_size:10});s.success&&s.data?(p(s.data.items),g(s.data.total)):w(s.message||u("Failed to load"))}catch{w(u("Failed to load"))}finally{_(!1)}},[l,u]);(0,i.useEffect)(()=>{t?(f(1),N(1)):(p([]),g(0),f(1),w(""))},[t,N]);let k=Math.max(1,Math.ceil(h/10));return s=b?(0,a.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,a.jsx)(e$.A,{className:"text-muted-foreground h-6 w-6 animate-spin"})}):v?(0,a.jsx)("p",{className:"text-destructive py-4 text-center text-sm",children:v}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eT.F,{className:"max-h-[50vh]",children:0===m.length?(0,a.jsx)("p",{className:"text-muted-foreground py-4 text-center text-sm",children:u("No invitees yet")}
2):(0,a.jsxs)(eL.XI,{children:[(0,a.jsx)(eL.A0,{children:(0,a.jsxs)(eL.Hj,{children:[(0,a.jsx)(eL.nd,{children:u("Username")}),(0,a.jsx)(eL.nd,{children:u("Email")}),(0,a.jsx)(eL.nd,{children:u("Phone")}),(0,a.jsx)(eL.nd,{children:u("Status")}),(0,a.jsx)(eL.nd,{children:u("Group")}),(0,a.jsx)(eL.nd,{children:u("Role")}),(0,a.jsx)(eL.nd,{children:u("Created At")})]})}),(0,a.jsx)(eL.BF,{children:m.map(e=>(0,a.jsxs)(eL.Hj,{children:[(0,a.jsx)(eL.nA,{children:e.username}),(0,a.jsx)(eL.nA,{children:e.email||"-"}),(0,a.jsx)(eL.nA,{children:e.phone||"-"}),(0,a.jsx)(eL.nA,{children:e.status===c.HJ.ENABLED?u("Enabled"):u("Disabled")}),(0,a.jsx)(eL.nA,{children:e.group}),(0,a.jsx)(eL.nA,{children:u((0,y.d9)(e.role))}),(0,a.jsx)(eL.nA,{children:e.created_at?(0,x.Ey)(e.created_at):"-"})]},e.id))})]})}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)(R.$,{variant:"outline",size:"sm",disabled:j<=1,onClick:()=>{let e=j-1;f(e),N(e)},children:u("Previous")}),(0,a.jsxs)("span",{className:"text-muted-foreground text-xs",children:[j," / ",k]}),(0,a.jsx)(R.$,{variant:"outline",size:"sm",disabled:j>=k,onClick:()=>{let e=j+1;f(e),N(e)},children:u("Next")})]})]}),(0,a.jsx)(P.l,{open:t,onOpenChange:n,title:u("Invitees"),description:`${o} (ID: ${l})`,contentClassName:"sm:max-w-2xl",contentHeight:"auto",bodyClassName:"space-y-4",children:s})}var eV=t(58246),eW=t(20726),eY=t(88921),eJ=t(12944),eQ=t(37442);let eX=[{days:7,labelKey:"7 days"},{days:14,labelKey:"14 days"},{days:30,labelKey:"30 days"}];function eG(e){let{open:s,onOpenChange:t,userId:n,username:o}=e,{t:c}=(0,r.Bd)(),{resolvedTheme:u,themeReady:m}=(0,eJ.R)(),[p,h]=(0,i.useState)(null),[y,g]=(0,i.useState)([]),[j,f]=(0,i.useState)(7),[b,_]=(0,i.useState)(!1),v=(0,i.useRef)(0),w=(0,i.useCallback)(async e=>{let s=++v.current;_(!0);try{let t=Math.floor(Date.now()/1e3),a=await (0,d.l0)(n,{start_timestamp:t-86400*e,end_timestamp:t});if(s!==v.current)return;a.success&&a.data?(h(a.data.user),g(a.data.dates)):(h(null),g([]),l.oR.error(a.message||c("Failed to load dashboard")))}catch{if(s!==v.current)return;h(null),g([]),l.oR.error(c("Failed to load dashboard"))}finally{s===v.current&&_(!1)}},[n,c]);(0,i.useEffect)(()=>{s?(f(7),w(7)):(v.current++,h(null),g([]))},[s,w]);let N=(0,i.useMemo)(()=>{let e=(0,eW.Le)(y.length||1),s=new Map;for(let e of y){let t=s.get(e.created_at)??{quota:0,tokens:0};t.quota+=e.quota??0,t.tokens+=e.token_used??0,s.set(e.created_at,t)}let t=[...s.entries()].sort((e,s)=>e[0]-s[0]).map(e=>{let[s,t]=e;return{Time:(0,eY.Hc)(s,"day"),rawQuota:t.quota,Tokens:t.tokens}});return{type:"common",data:[{id:"quotaTrendData",values:t}],series:[{type:"bar",xField:"Time",yField:"rawQuota"},{type:"line",xField:"Time",yField:"Tokens"}],axes:[{orient:"bottom",type:"band"},{orient:"left",type:"linear"}],title:{visible:!0,text:c("Quota Usage Trend"),subtext:0===t.length?c("No data available"):void 0},color:{type:"ordinal",range:e},background:{fill:"transparent"}}},[y,c]);return(0,a.jsxs)(P.l,{open:s,onOpenChange:t,title:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ex,{className:"h-5 w-5"}),c("Data Dashboard")]}),description:c("{{username}} (ID: {{id}})",{username:o,id:n}),contentClassName:"sm:max-w-2xl",contentHeight:"auto",bodyClassName:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)("div",{className:"flex gap-2",children:eX.map(e=>(0,a.jsx)(R.$,{variant:j===e.days?"default":"outline",size:"sm","aria-pressed":j===e.days,onClick:()=>{f(e.days),w(e.days)},children:c(e.labelKey)},e.days))}),p&&(0,a.jsxs)("p",{className:"text-muted-foreground text-xs",children:[c("Quota"),": ",(0,x.eN)(p.quota)," · ",c("Used Quota"),":"," ",(0,x.eN)(p.used_quota)," · ",c("Request Count"),":"," ",p.request_count]})]}),(0,a.jsxs)("div",{className:"relative h-[300px]",children:[b&&(0,a.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:(0,a.jsx)(e$.A,{className:"text-muted-foreground h-6 w-6 animate-spin"})}),m&&(0,a.jsx)(eV.F,{spec:{...N,theme:"dark"===u?"dark":"light",background:"transparent"},option:eQ.X},`user-dashboard-${u}`)]})]})}function eZ(e){let{row:s}=e,{t}=(0,r.Bd)(),n=s.original,{setOpen:m,setCurrentRow:p,triggerRefresh:h}=w(),[x,y]=(0,i.useState)(!1),[g,j]=(0,i.useState)(!1),[f,b]=(0,i.useState)(!1),[_,v]=(0,i.useState)(!1),[N,k]=(0,i.useState)(!1),[S,A]=(0,i.useState)(!1),[I,E]=(0,i.useState)(!1),[$,D]=(0,i.useState)(!1),z=async e=>{try{let s=await (0,d.ZC)(n.id,e);s.success?(l.oR.success(t(u[e])),h()):l.oR.error(s.message||t("Failed to {{action}} user",{action:e}))}catch{l.oR.error(t(c.UU.UNEXPECTED))}},F=async()=>{try{let e=await (0,d.tg)(n.id);e.success?(l.oR.success(t("Passkey reset successfully")),h()):l.oR.error(e.message||t("Failed to reset Passkey"))}catch{l.oR.error(t(c.UU.UNEXPECTED))}finally{y(!1)}},q=async()=>{try{let e=await (0,d.S$)(n.id);e.success?(l.oR.success(t("Two-factor authentication reset")),h()):l.oR.error(e.message||t("Failed to reset 2FA"))}catch{l.oR.error(t(c.UU.UNEXPECTED))}finally{j(!1)}},T=n.status===c.HJ.DISABLED,U=n.role>=c.tX.ADMIN,P=n.role===c.tX.ROOT,O=(0,M.n)(e=>e.auth.user?.role);return!(0,W.q)(O)||(0,c.h$)(n)?null:(0,a.jsxs)("div",{className:"-ml-1.5 flex items-center gap-1",children:[(0,a.jsxs)(er.m_,{children:[(0,a.jsx)(er.k$,{render:(0,a.jsx)(R.$,{variant:"ghost",size:"icon-sm",onClick:()=>{p(n),m("update")},"aria-label":t("Edit")}),children:(0,a.jsx)(C.A,{})}),(0,a.jsx)(er.ZI,{children:t("Edit")})]}),(0,a.jsxs)(ef.C,{ariaLabel:t("Open menu"),contentClassName:"w-48",children:[T?(0,a.jsxs)(eb._2,{onClick:()=>
2z("enable"),children:[t("Enable"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(en.A,{size:16})})]}):(0,a.jsxs)(eb._2,{onClick:()=>z("disable"),disabled:P,children:[t("Disable"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(ei.A,{size:16})})]}),U&&!P&&(0,a.jsxs)(eb._2,{onClick:()=>z("demote"),children:[t("Demote"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(el.A,{size:16})})]}),!U&&(0,a.jsxs)(eb._2,{onClick:()=>z("promote"),children:[t("Promote"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(eo.A,{size:16})})]}),n.role<c.tX.OPS&&(0,a.jsxs)(eb._2,{onSelect:e=>{e.preventDefault(),E(!0)},children:[t("Promote to Ops"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(ed.A,{size:16})})]}),n.role===c.tX.OPS&&(0,a.jsxs)(eb._2,{onSelect:e=>{e.preventDefault(),D(!0)},children:[t("Demote from Ops"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(eu,{size:16})})]}),(0,a.jsxs)(eb._2,{onSelect:e=>{e.preventDefault(),b(!0)},children:[t("Manage Bindings"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(em.A,{size:16})})]}),(0,a.jsxs)(eb._2,{onSelect:e=>{e.preventDefault(),v(!0)},children:[t("Manage Subscriptions"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(ep.A,{size:16})})]}),(0,a.jsxs)(eb._2,{onSelect:e=>{e.preventDefault(),k(!0)},children:[t("Invitees"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(eh.A,{size:16})})]}),(0,a.jsxs)(eb._2,{onSelect:e=>{e.preventDefault(),A(!0)},children:[t("Data Dashboard"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(ex,{size:16})})]}),(0,a.jsx)(eb.mB,{}),(0,a.jsxs)(eb._2,{onSelect:e=>{e.preventDefault(),y(!0)},disabled:P,children:[t("Reset Passkey"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(ey.A,{size:16})})]}),(0,a.jsxs)(eb._2,{onSelect:e=>{e.preventDefault(),j(!0)},disabled:P,children:[t("Reset 2FA"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(eg.A,{size:16})})]}),(0,a.jsx)(eb.mB,{}),(0,a.jsxs)(eb._2,{onClick:()=>{p(n),m("delete")},className:"text-destructive focus:text-destructive",disabled:P,children:[t("Delete"),(0,a.jsx)(eb.V0,{children:(0,a.jsx)(ej.A,{size:16})})]})]}),(0,a.jsx)(o.T,{open:x,onOpenChange:y,title:t("Reset Passkey"),desc:t("Reset Passkey for {{username}}? The user will need to register a new Passkey before using passwordless login.",{username:n.username}),confirmText:t("Reset Passkey"),handleConfirm:F}),(0,a.jsx)(o.T,{open:g,onOpenChange:j,title:t("Reset Two-Factor Authentication"),desc:t("Reset 2FA for {{username}}? The user must set up 2FA again to continue using it.",{username:n.username}),confirmText:t("Reset 2FA"),handleConfirm:q}),(0,a.jsx)(o.T,{open:I,onOpenChange:E,title:t("Promote to Ops"),desc:t("Promote {{username}} to Ops? They will get read-only access to their invitees and invitation campaigns.",{username:n.username}),confirmText:t("Promote to Ops"),handleConfirm:()=>z("promote_ops")}),(0,a.jsx)(o.T,{open:$,onOpenChange:D,title:t("Demote from Ops"),desc:t("Demote {{username}} from Ops? They will lose access to the ops pages.",{username:n.username}),confirmText:t("Demote from Ops"),handleConfirm:()=>z("demote_ops")}),(0,a.jsx)(eB,{open:f,onOpenChange:b,userId:n.id,onUnbindSuccess:h}),(0,a.jsx)(eC,{open:_,onOpenChange:v,user:{id:n.id,username:n.username},onSuccess:h}),(0,a.jsx)(eK,{open:N,onOpenChange:k,userId:n.id,username:n.username}),(0,a.jsx)(eG,{open:S,onOpenChange:A,userId:n.id,username:n.username})]})}var e0=t(56929),e1=t(18847),e2=function(e){let{user:s}=e,{t}=(0,r.Bd)(),n=(0,M.n)(e=>e.auth.user?.role)??0,[l,o]=(0,i.useState)(!1),d=n===c.tX.ROOT||n>s.role,u=s.display_name,m=s.remark;return(0,a.jsxs)("div",{className:"flex min-w-[160px] flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(R.$,{variant:"link",className:"h-auto max-w-[140px] p-0",disabled:!d,title:t("Data Dashboard"),onClick:()=>o(!0),children:(0,a.jsx)(e1.W,{className:"font-medium",children:s.username})}),m&&(0,a.jsxs)(er.m_,{children:[(0,a.jsx)(er.k$,{render:(0,a.jsx)(et.Wh,{variant:"success",copyable:!1}),children:(0,a.jsx)(e1.W,{className:"max-w-[80px]",children:m})}),(0,a.jsx)(er.ZI,{children:(0,a.jsx)("p",{className:"text-xs",children:m})})]})]}),u&&u!==s.username&&(0,a.jsx)(e1.W,{className:"text-muted-foreground max-w-[180px] text-xs",children:u}),(0,a.jsx)(eG,{open:l,onOpenChange:o,userId:s.id,username:s.username})]})},e4=t(65451);let e5=(0,L.GY)("/_authenticated/users/"),e6=new Set(["id","username","quota","group","created_at","last_login_at"]);function e3(){let{t:e}=(0,r.Bd)(),s=function(){let{t:e}=(0,r.Bd)();return[{id:"select",header:e=>{let{table:s}=e;return(0,a.jsx)(E.S,{checked:s.getIsAllPageRowsSelected(),indeterminate:s.getIsSomePageRowsSelected(),onCheckedChange:e=>s.toggleAllPageRowsSelected(!!e),"aria-label":"Select all",className:"translate-y-[2px]"})},cell:e=>{let{row:s}=e;return(0,a.jsx)(E.S,{checked:s.getIsSelected(),onCheckedChange:e=>s.toggleSelected(!!e),"aria-label":"Select row",className:"translate-y-[2px]"})},enableSorting:!1,enableHiding:!1,size:40},{accessorKey:"id",header:e("ID"),cell:e=>{let{row:s}=e;return(0,a.jsx)(ea.C,{value:s.getValue("id"),className:"w-[60px] text-sm"})},size:80,meta:{mobileOrder:10}},{accessorKey:"username",header:e("Username"),cell:e=>{let{row:s}=e;return(0,a.jsx)(e2,{user:s.original})},enableHiding:!1,size:220,meta:{mobileTitle:!0}},{accessorKey:"status",header:e("Status"),cell:s=>{let{row:t}
2=s,r=t.original,n=r.request_count,i=(0,c.h$)(r)?c.x4[c.HJ.DELETED]:c.x4[r.status];return i?(0,a.jsxs)(er.m_,{children:[(0,a.jsx)(er.k$,{render:(0,a.jsx)("div",{className:"-ml-1.5 cursor-help"}),children:(0,a.jsx)(et.Wh,{label:e(i.labelKey),variant:i.variant,copyable:!1})}),(0,a.jsx)(er.ZI,{children:(0,a.jsxs)("p",{className:"text-xs",children:[e("Requests:")," ",n.toLocaleString()]})})]}):null},filterFn:(e,s,t)=>t.includes(String(e.getValue(s))),enableSorting:!1,size:120,meta:{mobileBadge:!0}},{id:"quota",accessorKey:"quota",header:e("Remaining/Total Quota"),cell:e=>{let{row:s}=e,t=s.original;return(0,a.jsx)(e4.q,{used:t.used_quota,remaining:t.quota})},size:300,minSize:260,meta:{mobileOrder:40}},{accessorKey:"subscription_remain_value",header:e("Subscription Balance"),cell:e=>{let{row:s}=e,t=s.original;return(0,a.jsx)(e0._,{remainValue:t.subscription_remain_value||0,remaining:t.subscription_remain_quota||0,used:t.subscription_used_quota||0,total:t.subscription_total_quota||0,unlimited:t.subscription_unlimited})},size:170,meta:{mobileOrder:50}},{accessorKey:"group",header:e("Group"),cell:e=>{let{row:s}=e,t=s.getValue("group");return(0,a.jsx)(X.ak,{children:(0,a.jsx)(es.d,{group:t})})},filterFn:(s,t,a)=>{let r=String(s.getValue(t)||e("User Group")).toLowerCase(),n=String(a).toLowerCase();return r.includes(n)},size:140,meta:{mobileOrder:30}},{accessorKey:"role",header:e("Role"),cell:s=>{let{row:t}=s,r=t.getValue("role"),n=c.iK[r];return n?(0,a.jsxs)("div",{className:"flex items-center gap-x-2",children:[n.icon&&(0,a.jsx)(n.icon,{size:16,className:"text-muted-foreground"}),(0,a.jsx)("span",{className:"text-sm",children:e(n.labelKey)})]}):null},filterFn:(e,s,t)=>t.includes(String(e.getValue(s))),enableSorting:!1,size:120,meta:{mobileOrder:20}},{id:"invite_info",header:e("Invite Info"),cell:s=>{let{row:t}=s,r=t.original,n=r.aff_count||0,i=r.aff_history_quota||0,l=r.inviter_id||0;return(0,a.jsxs)("div",{className:"flex max-w-full min-w-0 flex-wrap items-center gap-1 overflow-hidden",children:[(0,a.jsxs)(er.m_,{children:[(0,a.jsx)(er.k$,{render:(0,a.jsx)(et.Wh,{label:`${e("Invited")}: ${n}`,variant:"neutral",copyable:!1,className:"cursor-help"})}),(0,a.jsx)(er.ZI,{children:(0,a.jsx)("p",{className:"text-xs",children:e("Number of users invited")})})]}),(0,a.jsxs)(er.m_,{children:[(0,a.jsx)(er.k$,{render:(0,a.jsx)(et.Wh,{label:`${e("Revenue")}: ${(0,x.eN)(i)}`,variant:"neutral",copyable:!1,className:"cursor-help"})}),(0,a.jsx)(er.ZI,{children:(0,a.jsx)("p",{className:"text-xs",children:e("Total invitation revenue")})})]}),l>0&&(0,a.jsxs)(er.m_,{children:[(0,a.jsx)(er.k$,{render:(0,a.jsx)(et.Wh,{label:`${e("Inviter")}: ${l}`,variant:"neutral",copyable:!1,className:"cursor-help"})}),(0,a.jsx)(er.ZI,{children:(0,a.jsxs)("p",{className:"text-xs",children:[e("Invited by user ID")," ",l]})})]}),0===l&&(0,a.jsx)(et.Wh,{label:e("No Inviter"),variant:"neutral",copyable:!1})]})},size:240,enableSorting:!1,meta:{mobileHidden:!0}},{accessorKey:"created_at",header:e("Created At"),cell:e=>{let{row:s}=e,t=s.getValue("created_at");return(0,a.jsx)("span",{className:"text-muted-foreground text-sm",children:t?(0,x.Ey)(t):"-"})},size:180,meta:{mobileHidden:!0}},{accessorKey:"last_login_at",header:e("Last Login"),cell:e=>{let{row:s}=e,t=s.getValue("last_login_at");return(0,a.jsx)("span",{className:"text-muted-foreground text-sm",children:t?(0,x.Ey)(t):"-"})},size:180,meta:{mobileHidden:!0}},{id:"actions",header:()=>e("Actions"),cell:e=>{let{row:s}=e;return(0,a.jsx)(eZ,{row:s})},meta:{pinned:"right"}}]}(),{refreshTrigger:t}=w(),n=(0,G.Ub)("(max-width: 640px)"),[o,u]=(0,i.useState)([]),{globalFilter:m,onGlobalFilterChange:p,columnFilters:h,onColumnFiltersChange:y,pagination:g,onPaginationChange:j,ensurePageInRange:f}=(0,Z.c)({search:e5.useSearch(),navigate:e5.useNavigate(),pagination:{defaultPage:1,defaultPageSize:n?10:20},globalFilter:{enabled:!0,key:"filter"}
2,columnFilters:[{columnId:"status",searchKey:"status",type:"array"},{columnId:"role",searchKey:"role",type:"array"},{columnId:"group",searchKey:"group",type:"string"}]}),b=h.find(e=>"status"===e.id)?.value??[],_=h.find(e=>"role"===e.id)?.value??[],v=h.find(e=>"group"===e.id)?.value??"",N=(0,i.useMemo)(()=>{let e=o[0];return e&&e6.has(e.id)?{sort_by:e.id,sort_order:e.desc?"desc":"asc"}:{}},[o]),{data:k,isLoading:C,isFetching:A}=(0,S.I)({queryKey:["users",g.pageIndex+1,g.pageSize,m,b,_,v,N,t],queryFn:async()=>{let e=m?.trim(),s=b.length>0||_.length>0||!!v,t={p:g.pageIndex+1,page_size:g.pageSize,...N},a=e||s?await (0,d.x5)({...t,keyword:m,status:b[0]??"",role:_[0]??"",group:v}):await (0,d.lo)(t);return a.success?{items:a.data?.items||[],total:a.data?.total||0}:(l.oR.error(a.message||`Failed to ${e?"search":"load"} users`),{items:[],total:0})},placeholderData:e=>e}),I=k?.items||[],{table:R}=(0,X.uI)({data:I,columns:s,enableRowSelection:!0,columnFilters:h,globalFilter:m,pagination:g,sorting:o,globalFilterFn:(e,s,t)=>{let a=String(t).toLowerCase();return[e.getValue("username"),e.original.display_name,e.original.email].some(e=>String(e||"").toLowerCase().includes(a))},onPaginationChange:j,onGlobalFilterChange:p,onColumnFiltersChange:y,onSortingChange:e=>{u(e),g.pageIndex>0&&j({...g,pageIndex:0})},manualPagination:!0,manualFiltering:!0,manualSorting:!0,totalCount:k?.total||0,ensurePageInRange:f,columnVisibilityStorageKey:"users:column-visibility"});return(0,a.jsx)(X.cx,{table:R,columns:s,isLoading:C,isFetching:A,emptyTitle:e("No Users Found"),emptyDescription:e("No users available. Try adjusting your search or filters."),skeletonKeyPrefix:"users-skeleton",applyHeaderSize:!0,toolbarProps:{searchPlaceholder:e("Filter by username, name or email..."),searchDebounceMs:500,filters:[{columnId:"status",title:e("Status"),options:(0,c.Qj)(e),singleSelect:!0},{columnId:"role",title:e("Role"),options:(0,c.Ac)(e),singleSelect:!0}]},getRowClassName:(e,s)=>{var t;let{isMobile:a}=s;return(t=e.original,(0,c.h$)(t)||t.status===c.HJ.DISABLED)?a?X.Z0:X.JM:void 0},bulkActions:(0,a.jsx)(ee,{table:R})})}function e7(){let{t:e}=(0,r.Bd)(),{open:s,setOpen:t,currentRow:i}=w();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(n.Ni,{fixedContent:!0,children:[(0,a.jsx)(n.Ni.Title,{children:e("Users")}),(0,a.jsx)(n.Ni.Actions,{children:(0,a.jsx)(Q,{})}),(0,a.jsx)(n.Ni.Content,{children:(0,a.jsx)(e3,{})})]}),(0,a.jsx)(B,{open:"create"===s||"update"===s,onOpenChange:e=>!e&&t(null),currentRow:"update"===s&&i||void 0}),(0,a.jsx)(N,{})]})}let e8=function(){return(0,a.jsx)(v,{children:(0,a.jsx)(e7,{})})}},33834(e,s,t){let a=(0,t(9781).A)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);t.d(s,{},{A:a})},67733(e,s,t){let a=(0,t(9781).A)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);t.d(s,{},{A:a})},59735(e,s,t){let a=(0,t(9781).A)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);t.d(s,{},{A:a})},20103(e,s,t){let a=(0,t(9781).A)("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);t.d(s,{},{A:a})},6201(e,s,t){let a=(0,t(9781).A)("power-off",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);t.d(s,{},{A:a})},36001(e,s,t){let a=(0,t(9781).A)("power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);t.d(s,{},{A:a})},38384(e,s,t){let a=(0,t(9781).A)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);t.d(s,{},{A:a})},57335(e,s,t){let a=(0,t(9781).A)("unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]);t.d(s,{},{A:a})},80792(e,s,t){let a=(0,t(9781).A)("user-plus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);t.d(s,{},{A:a})},55989(e,s,t){let a=(0,t(9781).A)("users-round",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]);t.d(s,{},{A:a})}}]);

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.