PageSourceSearch

https://git-hub-new-api.hf.space/static/js/async/36.a9e873d738.js

js git-hub-new-api.hf.space collected 2026-10-03 16:54:06 UTC 50,208 bytes, 2 lines download raw bytes

1/*! LICENSE: 36.a9e873d738.js.LICENSE.txt */
2"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[36],{72744(e,s,a){var t=a(79015),r=a(89077),n=a(47801),i=a(32483);function l(e){var s;let{t:a}=(0,r.Bd)(),{group:l,label:o,ratio:d,copyable:c=!1,showDot:u,className:m,...p}=e,h=l?.trim(),x="auto"===h,g=!h,j=x||g,y=(s={labelOverride:o,groupName:h,isAutoGroup:x,isEmptyGroup:g,t:a}).labelOverride?s.labelOverride:s.isEmptyGroup?s.t("User Group"):s.isAutoGroup?s.t("Auto"):s.groupName??"",f=(0,t.jsx)(i.Wh,{...p,copyable:c,label:y,showDot:u??(!j&&void 0),variant:j?"neutral":void 0,autoColor:j?void 0:h,className:(0,n.cn)("min-w-0 shrink overflow-hidden",m)});return null==d?f:(0,t.jsxs)("span",{className:"inline-flex max-w-full min-w-0 items-center gap-2 text-xs",children:[(0,t.jsx)("span",{className:"max-w-full min-w-0 overflow-hidden",children:f}),(0,t.jsx)("span",{className:(0,n.cn)("inline-flex h-5 shrink-0 items-center rounded-full px-1.5 font-mono text-xs leading-none font-medium tabular-nums",d>1?"bg-warning/10 text-warning":d<1?"bg-info/10 text-info":"bg-muted text-muted-foreground"),children:(0,t.jsxs)("span",{children:[d,"x"]})})]})}a.d(s,{d:()=>l})},41645(e,s,a){var t=a(79015),r=a(47801);function n(e){return(0,t.jsx)("span",{className:(0,r.cn)("text-muted-foreground inline-block font-mono tabular-nums",e.className),children:e.value})}a.d(s,{C:()=>n})},55079(e,s,a){var t=a(63228);async function r(){return(await t.FH.get("/api/subscription/admin/plans")).data}async function n(e){return(await t.FH.post("/api/subscription/admin/plans",e)).data}async function i(e,s){return(await t.FH.put(`/api/subscription/admin/plans/${e}`,s)).data}async function l(e,s){return(await t.FH.patch(`/api/subscription/admin/plans/${e}`,{enabled:s})).data}async function o(e){return(await t.FH.get(`/api/subscription/admin/users/${e}/subscriptions`)).data}async function d(e,s){return(await t.FH.post(`/api/subscription/admin/users/${e}/subscriptions`,s)).data}async function c(e){return(await t.FH.post(`/api/subscription/admin/user_subscriptions/${e}/invalidate`)).data}async function u(e){return(await t.FH.delete(`/api/subscription/admin/user_subscriptions/${e}`)).data}async function m(e,s){return(await t.FH.post(`/api/subscription/admin/users/${e}/subscriptions/reset`,s)).data}async function p(e,s){return(await t.FH.post(`/api/subscription/admin/plans/${e}/subscriptions/reset`,s)).data}async function h(e){return(await t.FH.post("/api/subscription/stripe/pay",e)).data}async function x(e){return(await t.FH.post("/api/subscription/creem/pay",e)).data}async function g(e){return(await t.FH.post("/api/subscription/waffo-pancake/pay",e)).data}async function j(e){return(await t.FH.post("/api/subscription/balance/pay",e)).data}async function y(e){return(await t.FH.post("/api/option/waffo-pancake/subscription-product",e)).data}async function f(){return(await t.FH.get("/api/option/waffo-pancake/subscription-product-options")).data}async function b(e){let s=await t.FH.post("/api/subscription/epay/pay",e);return{...s.data,url:s.data.url||s.url}}async function v(){return(await t.FH.get("/api/subscription/self")).data}async function _(){return(await t.FH.get("/api/subscription/plans")).data}async function w(e){return(await t.FH.put("/api/subscription/self/preference",{billing_preference:e})).data}async function N(){return(await t.FH.get("/api/group")).data}a.d(s,{Ax:()=>j,Ay:()=>_,DG:()=>y,OX:()=>r,PV:()=>m,S$:()=>w,dW:()=>h,dh:()=>b,eW:()=>u,f:()=>N,gY:()=>c,l7:()=>d,mB:()=>x,oV:()=>l,pK:()=>v,qL:()=>o,qT:()=>n,td:()=>i,vS:()=>p,y8:()=>g,zE:()=>f})},68539(e,s,a){a.d(s,{sX:()=>u,Hc:()=>p,a3:()=>r,ak:()=>n,Ey:()=>i,vD:()=>c,jy:()=>m});var t=a(97569);function r(e,s){let a=e?.duration_unit||"month",t=e?.duration_value||1,r={year:s("years"),month:s("months"),day:s("days"),hour:s("hours"),custom:s("Custom (seconds)")};if("custom"===a){let a=e?.custom_seconds||0;return a>=86400?`${Math.floor(a/86400)} ${s("days")}`:a>=3600?`${Math.floor(a/3600)} ${s("hours")}`:`${a} ${s("seconds")}`}return`${t} ${r[a]||a}`}function n(e,s){let a=e?.quota_reset_period||"never";if("daily"===a)return s("Daily");if("weekly"===a)return s("Weekly");if("monthly"===a)return s("Monthly");if("custom"===a){let a=Number(e?.quota_reset_custom_seconds||0);return a>=86400?`${Math.floor(a/86400)} ${s("days")}`:a>=3600?`${Math.floor(a/3600)} ${s("hours")}`:a>=60?`${Math.floor(a/60)} ${s("minutes")}`:`${a} ${s("seconds")}`}return s("No Reset")}function i(e){return e?(0,t.A)(1e3*e).format("YYYY-MM-DD HH:mm:ss"):"-"}var l=a(25589),o=a(92097),d=a(77577);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()})}
2let 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||""}}}},10625(e,s,a){var t=a(65311);let r="page-size";function n(e){let{search:s,navigate:a,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,t.useMemo)(()=>{let e=[];for(let a of l){let t=s[a.searchKey],r=a.deserialize??(e=>e);if("string"===a.type){let s=r(t)??"";"string"==typeof s&&""!==s.trim()&&e.push({id:a.columnId,value:s})}else{let s=r(t)??[];Array.isArray(s)&&s.length>0&&e.push({id:a.columnId,value:s})}}return e},[l,s]),[g,j]=(0,t.useState)(x);(0,t.useEffect)(()=>{j(x)},[s]);let y=(0,t.useMemo)(()=>{let e=s[o],a=s[d];return{pageIndex:Math.max(0,("number"==typeof e?e:c)-1),pageSize:"number"==typeof a?a: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,t.useState)(()=>{if(!p)return;let e=s[m];return"string"==typeof e?e:""}),v=p?e=>{let s="function"==typeof e?e(f??""):e,t=h?s.trim():s;b(t),a({search:e=>({...e,[o]:void 0,[m]:t||void 0})})}:void 0;return{globalFilter:p?f??"":void 0,onGlobalFilterChange:v,columnFilters:g,onColumnFiltersChange:e=>{let s="function"==typeof e?e(g):e;j(s);let t={};for(let e of l){let a=s.find(s=>s.id===e.columnId),r=e.serialize??(e=>e);if("string"===e.type){let s="string"==typeof a?.value?a.value:"";t[e.searchKey]=""!==s.trim()?r(s):void 0}else{let s=Array.isArray(a?.value)?a.value:[];t[e.searchKey]=s.length>0?r(s):void 0}}a({search:e=>({...e,[o]:void 0,...t})})},pagination:y,onPaginationChange:e=>{let s="function"==typeof e?e(y):e,t=s.pageIndex+1,n=s.pageSize;n!==y.pageSize&&function(e){try{localStorage.setItem(r,String(e))}catch{}}(n),a({search:e=>({...e,[o]:t<=c?void 0:t,[d]:n})})},ensurePageInRange:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{resetTo:"first"},r=s[o],n="number"==typeof r?r:c;e>0&&n>e&&a({replace:!0,search:s=>({...s,[o]:"last"===t.resetTo?e:void 0})})}}}a.d(s,{c:()=>n})}
2,62646(e,s,a){var t=a(48041);function r(e,s,a){return!!e&&(e.role===t.z7.SUPER_ADMIN||e.permissions?.admin_permissions?.[s]?.[a]===!0)}function n(e,s){let a=s.roles.find(e=>"admin"===e.key)?.grants??{},t={};for(let r of s.resources){let s={};for(let t of r.actions)s[t.action]=e?.[r.resource]?.[t.action]??a[r.resource]?.[t.action]??!1;t[r.resource]=s}return t}a.d(s,{_m:()=>r,v$:()=>n},{YG:{READ:"read",OPERATE:"operate",WRITE:"write",SENSITIVE_WRITE:"sensitive_write",SECRET_VIEW:"secret_view"},kB:{CHANNEL:"channel"},sJ:{resources:[],roles:[]}})},34943(e,s,a){a.r(s),a.d(s,{component:()=>eG});var t=a(79015),r=a(89077),n=a(51571),i=a(65311),l=a(26028),o=a(73406),d=a(86465),c=a(38701),u=a(77108),m=a(95535);let p={1:{labelKey:"Enabled",variant:"success",value:1},2:{labelKey:"Disabled",variant:"neutral",value:2},[-1]:{labelKey:"Deleted",variant:"danger",value:-1}},h={1:{labelKey:"User",value:1,icon:c.A},10:{labelKey:"Admin",value:10,icon:u.A},100:{labelKey:"Root",value:100,icon:m.A}},x="default",g=[{key:"github_id",label:"GitHub ID"},{key:"discord_id",label:"Discord ID"},{key:"oidc_id",label:"OIDC ID"},{key:"wechat_id",label:"WeChat ID"},{key:"email",label:"Email"},{key:"telegram_id",label:"Telegram ID"}],j="An unexpected error occurred",y={enable:"User enabled successfully",disable:"User disabled successfully",promote:"User promoted to admin successfully",demote:"User demoted to regular user successfully",delete:"User deleted successfully",add_quota:"Quota adjusted successfully"};var f=a(25589),b=a(62646),v=a(77577),_=a(48041);let w=f.Ik({username:f.Yj().min(1,"Username is required"),display_name:f.Yj().optional(),password:f.Yj().optional(),role:f.ai().optional(),quota_dollars:f.ai().min(0).optional(),group:f.Yj().optional(),remark:f.Yj().optional(),admin_permissions:f.g1(f.Yj(),f.g1(f.Yj(),f.zM())).optional()}),N={username:"",display_name:"",password:"",role:1,quota_dollars:0,group:x,remark:"",admin_permissions:{}};function k(e){return{username:e.username,display_name:e.display_name,password:"",role:e.role,quota_dollars:(0,v.Sh)(e.quota),group:e.group||x,remark:e.remark||"",admin_permissions:e.admin_permissions??{}}}var S=a(77477);let C=i.createContext(null);function A(e){let{children:s}=e,[a,r]=(0,S.Ay)(null),[n,l]=(0,i.useState)(null),[o,d]=(0,i.useState)(0);return(0,t.jsx)(C,{value:{open:a,setOpen:r,currentRow:n,setCurrentRow:l,refreshTrigger:o,triggerRefresh:()=>d(e=>e+1)},children:s})}let I=()=>{let e=i.useContext(C);if(!e)throw Error("useUsers has to be used within <UsersContext>");return e};function R(){let{t:e}=(0,r.Bd)(),{open:s,setOpen:a,currentRow:n,triggerRefresh:c}=I(),[u,m]=(0,i.useState)(!1),p=async()=>{if(n){m(!0);try{let s=await (0,d.hG)(n.id);s.success?(l.oR.success(e(y.delete)),a(null),c()):l.oR.error(s.message||e("Failed to delete user"))}catch{l.oR.error(e(j))}finally{m(!1)}}};return(0,t.jsx)(o.T,{open:"delete"===s,onOpenChange:e=>!e&&a(null),title:e("Are you sure?"),desc:(0,t.jsxs)(t.Fragment,{children:[e("This will permanently delete user")," ",(0,t.jsx)("span",{className:"font-semibold",children:n?.username}),e(". This action cannot be undone.")]}),confirmText:u?e("Deleting..."):e("Delete"),destructive:!0,isLoading:u,handleConfirm:p})}var $=a(99435),F=a(43866),z=a(9079),D=a(27606),q=a(49583),M=a(73178),E=a(95085),T=a(1996),H=a(62724),B=a(62978),K=a(50010),U=a(9273),O=a(32512),P=a(78373),V=a(65965),W=a(31155),Y=a(47801);function L(e){let{t:s}=(0,r.Bd)(),[a,n]=(0,i.useState)("add"),[o,c]=(0,i.useState)(""),[u,m]=(0,i.useState)(!1),{meta:p}=(0,P.cw)(),h=(0,P.yz)(),x="tokens"===p.kind,g=parseFloat(o)||0,j=(0,v.dD)(Math.abs(g)),y=async()=>{if((o||"override"===a)&&(!(j<=0)||"override"===a)){m(!0);try{let t="override"===a?(0,v.dD)(g):j,r=await (0,d.Xw)({id:e.userId,action:"add_quota",mode:a,value:"override"===a?t:Math.abs(t)});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)}}},f=x?s("Enter amount in tokens"):s("Enter amount in {{currency}}",{currency:h});return(0,t.jsx)(W.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,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(M.$,{variant:"outline",onClick:()=>{c(""),n("add"),e.onOpenChange(!1)},children:s("Cancel")}),(0,t.jsx)(M.$,{onClick:y,disabled:u,children:u?s("Processing..."):s("Confirm")})]}),children:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("div",{className:"text-muted-foreground text-sm",children:(()=>{let t=e.currentQuota;switch(a){case"add":return`${s("Current quota")}: ${(0,v.eN)(t)}  +${(0,v.eN)(j)} = ${(0,v.eN)(t+j)}`;case"subtract":return`${s("Current quota")}: ${(0,v.eN)(t)}  -${(0,v.eN)(j)} = ${(0,v.eN)(t-j)}`;case"override":{let e=(0,v.dD)(g);return`${s("Current quota")}: ${(0,v.eN)(t)} → ${(0,v.eN)(e)}`}default:return""}})()}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(B.J,{children:s("Mode")}),(0,t.jsx)("div",{className:"flex gap-1",children:["add","subtract","override"].map(e=>(0,t.jsx)(M.$,{type:"button",variant:"outline",size:"sm",className:(0,Y.cn)(a===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,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)(B.J,{children:[s("Amount")," (",h,")"]}),(0,t.jsx)(H.p,{type:"number",step:x?1:1e-6,min:"override"===a?void 0:0,placeholder:f,value:o,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&y()}})]})]})})}function G(e){let{open:s,onOpenChange:a,currentRow:n}=e,{t:o}=(0,r.Bd)(),c=!!n,{triggerRefresh:u}=I(),m=(0,V.n)(e=>e.auth.user),[p,h]=(0,i.useState)(!1),[x,y]=(0,i.useState)(!1),{data:f}=(0,F.I)({queryKey:["groups"],queryFn:d.f,staleTime:3e5}),S=f?.data||[],{data:C=b.sJ}=(0,F.I)({queryKey:["admin-permission-catalog"],queryFn:d.PQ,staleTime:3e5}),A=(0,D.mN)({resolver:(0,$.u)(w),defaultValues:N});(0,i.useEffect)(()=>{s&&c&&n?(0,d.wz)(n.id).then(e=>{e.success&&e.data&&A.reset(k(e.data))}):s&&!c&&A.reset(N)},[s,c,n,A]);let{meta:R}=(0,P.cw)(),W=(0,P.yz)(),Y="tokens"===R.kind,G=A.watch("quota_dollars")||0,J=A.watch("role"),Q=m?.role===_.z7.SUPER_ADMIN,Z=(J??n?.role??0)>=_.z7.ADMIN,X=async e=>{if(!c){let s=e.password?.length||0;if(s<8||s>20)return void A.setError("password",{type:"manual",message:o("Password must be between 8 and 20 characters")})}h(!0);try{var s;let t,r,i=(s=n?.id,t={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)>=_.z7.ADMIN&&C&&(t.admin_permissions=(0,b.v$)(e.admin_permissions,C)),void 0===s?t.role=r:(t.group=e.group,t.remark=e.remark||void 0,t.id=s),t),m=c?await (0,d.TK)(i):await (0,d.kg)(i);m.success?(l.oR.success(c?o("User updated successfully"):o("User created successfully")),a(!1),u()):l.oR.error(m.message||(c?o("Failed to update user"):o("Failed to create user")))}catch(e){l.oR.error(o(j))}finally{h(!1)}},ee=async()=>
2{if(!n)return;let e=await (0,d.wz)(n.id);e.success&&e.data&&A.reset(k(e.data)),u()};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U.cj,{open:s,onOpenChange:e=>{a(e),e||A.reset()},children:(0,t.jsxs)(U.h,{className:(0,q.jW)("sm:max-w-[600px]"),children:[(0,t.jsxs)(U.Fm,{className:(0,q.Dt)(),children:[(0,t.jsxs)(U.qp,{children:[c?o("Update"):o("Create")," ",o("User")]}),(0,t.jsx)(U.Qs,{children:c?o("Update the user by providing necessary info."):o("Add a new user by providing necessary info.")})]}),(0,t.jsx)(T.lV,{...A,children:(0,t.jsxs)("form",{id:"user-form",onSubmit:A.handleSubmit(X),className:(0,q.e)(),children:[(0,t.jsxs)(q.y5,{children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:o("Basic Information")}),(0,t.jsx)(T.zB,{control:A.control,name:"username",render:e=>{let{field:s}=e;return(0,t.jsxs)(T.eI,{children:[(0,t.jsx)(T.lR,{children:o("Username")}),(0,t.jsx)(T.MJ,{children:(0,t.jsx)(H.p,{...s,placeholder:o("Enter username"),disabled:c})}),(0,t.jsx)(T.C5,{})]})}}),!c&&(0,t.jsx)(T.zB,{control:A.control,name:"role",render:e=>{let{field:s}=e;return(0,t.jsxs)(T.eI,{children:[(0,t.jsx)(T.lR,{children:o("Role")}),(0,t.jsxs)(K.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,t.jsx)(T.MJ,{children:(0,t.jsx)(K.bq,{children:(0,t.jsx)(K.yv,{placeholder:o("Select a role")})})}),(0,t.jsx)(K.gC,{alignItemWithTrigger:!1,children:(0,t.jsxs)(K.s3,{children:[(0,t.jsx)(K.eb,{value:"1",children:o("Common User")}),(0,t.jsx)(K.eb,{value:"10",children:o("Admin")})]})})]}),(0,t.jsx)(T.Rr,{children:o("Set the user's role (cannot be Root)")}),(0,t.jsx)(T.C5,{})]})}}),(0,t.jsx)(T.zB,{control:A.control,name:"display_name",render:e=>{let{field:s}=e;return(0,t.jsxs)(T.eI,{children:[(0,t.jsx)(T.lR,{children:o("Display Name")}),(0,t.jsx)(T.MJ,{children:(0,t.jsx)(H.p,{...s,placeholder:o("Enter display name")})}),(0,t.jsx)(T.Rr,{children:o("Leave empty to use username")}),(0,t.jsx)(T.C5,{})]})}}),(0,t.jsx)(T.zB,{control:A.control,name:"password",render:e=>{let{field:s}=e;return(0,t.jsxs)(T.eI,{children:[(0,t.jsx)(T.lR,{children:o("Password")}),(0,t.jsx)(T.MJ,{children:(0,t.jsx)(H.p,{...s,type:"password",placeholder:c?o("Leave empty to keep unchanged"):o("Enter password (8-20 characters)")})}),(0,t.jsx)(T.C5,{})]})}})]}),c&&(0,t.jsxs)(q.y5,{children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:o("Group & Quota")}),(0,t.jsx)(T.zB,{control:A.control,name:"group",render:e=>{let{field:s}=e;return(0,t.jsxs)(T.eI,{children:[(0,t.jsx)(T.lR,{children:o("Group")}),(0,t.jsxs)(K.l6,{items:[...S.map(e=>({value:e,label:e}))],onValueChange:s.onChange,value:s.value,children:[(0,t.jsx)(T.MJ,{children:(0,t.jsx)(K.bq,{children:(0,t.jsx)(K.yv,{placeholder:o("Select a group")})})}),(0,t.jsx)(K.gC,{alignItemWithTrigger:!1,children:(0,t.jsx)(K.s3,{children:S.map(e=>(0,t.jsx)(K.eb,{value:e,children:e},e))})})]}),(0,t.jsx)(T.C5,{})]})}}),(0,t.jsx)(T.zB,{control:A.control,name:"quota_dollars",render:e=>{let{field:s}=e;return(0,t.jsxs)(T.eI,{children:[(0,t.jsx)(T.lR,{children:o("Remaining Quota ({{currency}})",{currency:W})}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(T.MJ,{children:(0,t.jsx)(H.p,{value:Y?String(s.value||0):(s.value||0).toFixed(6),readOnly:!0,className:"flex-1"})}),(0,t.jsxs)(M.$,{type:"button",variant:"outline",onClick:()=>y(!0),children:[(0,t.jsx)(z.A,{className:"mr-1 h-4 w-4"}),o("Adjust Quota")]})]}),(0,t.jsx)(T.Rr,{children:(0,v.eN)((0,v.dD)(s.value||0))}),(0,t.jsx)(T.C5,{})]})}}),(0,t.jsx)(T.zB,{control:A.control,name:"remark",render:e=>{let{field:s}=e;return(0,t.jsxs)(T.eI,{children:[(0,t.jsx)(T.lR,{children:o("Remark")}),(0,t.jsx)(T.MJ,{children:(0,t.jsx)(O.T,{...s,placeholder:o("Admin notes (only visible to admins)"),rows:3})}),(0,t.jsx)(T.C5,{})]})}})]}),Q&&Z&&C.resources.length>0&&(0,t.jsxs)(q.y5,{children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:o("Admin Permissions")}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:o("Default administrator permissions can be overridden for this user.")}),(0,t.jsx)(T.zB,{control:A.control,name:"admin_permissions",render:e=>{let{field:s}=e,a=(0,b.v$)(s.value,C);return(0,t.jsxs)(T.eI,{children:[(0,t.jsx)("div",{className:"space-y-3",children:C.resources.map(e=>(0,t.jsxs)("div",{className:"space-y-2 rounded-md border p-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:o(e.label_key)}),(0,t.jsx)("div",{className:"space-y-2",children:e.actions.map(r=>(0,t.jsxs)("label",{className:"flex items-start gap-3",children:[(0,t.jsx)(E.S,{checked:a[e.resource]?.[r.action]===!0,onCheckedChange:t=>{s.onChange({...a,[e.resource]:{...a[e.resource],[r.action]:!0===t}})}}),(0,t.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:o(r.label_key)}),(0,t.jsx)("span",{className:"text-muted-foreground text-xs",children:o(r.description_key)})]})]},r.action))})]},e.resource))}),(0,t.jsx)(T.C5,{})]})}}),m&&(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:(0,b._m)(m,b.kB.CHANNEL,b.YG.SENSITIVE_WRITE)?o("Your account can edit sensitive channel settings."):o("Your account cannot edit sensitive channel settings.")})]}),c&&(0,t.jsxs)(q.y5,{children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:o("Binding Information")}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:o("Third-party account bindings (read-only, managed by user in profile settings)")}),(0,t.jsx)("div",{className:"flex flex-col gap-3",children:g.map(e=>{let{key:s,label:a}=e;return(0,t.jsxs)("div",{children:[(0,t.jsx)(B.J,{className:"text-muted-foreground text-xs",children:o(a)}),(0,t.jsx)(H.p,{value:n?.[s]||"-",disabled:!0,className:"mt-1"})]},s)})})]})]})}),(0,t.jsxs)(U.XW,{className:(0,q.Jx)(),children:[(0,t.jsx)(U.kN,{render:(0,t.jsx)(M.$,{variant:"outline"}),children:o("Close")}),(0,t.jsx)(M.$,{form:"user-form",type:"submit",disabled:p,children:p?o("Saving..."):o("Save changes")}
2)]})]})}),n&&(0,t.jsx)(L,{open:x,onOpenChange:y,userId:n.id,currentQuota:(0,v.dD)(G||0),onSuccess:ee})]})}var J=a(57736);function Q(){let{t:e}=(0,r.Bd)(),{setOpen:s,setCurrentRow:a}=I();return(0,t.jsx)("div",{className:"flex gap-2",children:(0,t.jsxs)(M.$,{size:"sm",onClick:()=>{a(null),s("create")},children:[(0,t.jsx)(J.A,{className:"h-4 w-4"}),e("Add User")]})})}var Z=a(28585),X=a(13595),ee=a(70085),es=a(10625);function ea(e){let{table:s}=e;return(0,t.jsx)(X.Of,{table:s,entityName:"user",children:(0,t.jsx)(t.Fragment,{})})}var et=a(72744),er=a(7803),en=a(52909);function ei(e){let{children:s,className:a="",contentClassName:r=""}=e,n=(0,i.useRef)(null),[l,o]=(0,i.useState)(!1);return((0,i.useEffect)(()=>{el(n.current)?o(!0):o(!1)},[]),l)?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"hidden sm:block",children:(0,t.jsx)(en.Bc,{delay:0,children:(0,t.jsxs)(en.m_,{children:[(0,t.jsx)(en.k$,{render:(0,t.jsx)("div",{ref:n,className:(0,Y.cn)("truncate",a)}),children:s}),(0,t.jsx)(en.ZI,{children:(0,t.jsx)("p",{className:r,children:s})})]})})}),(0,t.jsx)("div",{className:"sm:hidden",children:(0,t.jsxs)(er.AM,{children:[(0,t.jsx)(er.Wv,{render:(0,t.jsx)("div",{ref:n,className:(0,Y.cn)("truncate",a)}),children:s}),(0,t.jsx)(er.hl,{className:(0,Y.cn)("w-fit",r),children:(0,t.jsx)("p",{children:s})})]})})]}):(0,t.jsx)("div",{ref:n,className:(0,Y.cn)("truncate",a),children:s})}let el=e=>!!e&&(e.offsetHeight<e.scrollHeight||e.offsetWidth<e.scrollWidth);var eo=a(32483),ed=a(41645),ec=a(18875),eu=a(48531),em=a(68815),ep=a(10200),eh=a(36363),ex=a(6197),eg=a(10854),ej=a(68758),ey=a(37902),ef=a(30935),eb=a(63408),ev=a(30218),e_=a(62711),ew=a(40946);let eN=(0,ew.A)("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]);var ek=a(14826),eS=a(55079),eC=a(68539);function eA(e){let s=Date.now()/1e3,a=(e.sub.end_time||0)>0&&e.sub.end_time<s;return"active"!==e.sub.status||a?"cancelled"===e.sub.status?(0,t.jsx)(eo.Wh,{label:e.t("Invalidated"),variant:"neutral",copyable:!1}):(0,t.jsx)(eo.Wh,{label:e.t("Expired"),variant:"neutral",copyable:!1}):(0,t.jsx)(eo.Wh,{label:e.t("Active"),variant:"success",copyable:!1})}function eI(e){let{t:s}=(0,r.Bd)(),[a,n]=(0,i.useState)(!1),[d,c]=(0,i.useState)(!1),[u,m]=(0,i.useState)([]),[p,h]=(0,i.useState)([]),[x,g]=(0,i.useState)(""),[j,y]=(0,i.useState)(!1),[f,b]=(0,i.useState)(!0),[_,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,a]=await Promise.all([(0,eS.OX)(),(0,eS.qL)(e.user.id)]);s.success&&m(s.data||[]),a.success&&h(a.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||!x)return void l.oR.error(s("Please select a subscription plan"));c(!0);try{let a=await (0,eS.l7)(e.user.id,{plan_id:Number(x)});a.success&&(l.oR.success(a.data?.message||s("Added successfully")),g(""),await C(),e.onSuccess?.())}catch{l.oR.error(s("Request failed"))}finally{c(!1)}},I=async()=>{if(N)try{if("invalidate"===N.type){let a=await (0,eS.gY)(N.subId);a.success&&(l.oR.success(a.data?.message||s("Has been invalidated")),await C(),e.onSuccess?.())}else(await (0,eS.eW)(N.subId)).success&&(l.oR.success(s("Deleted")),await C(),e.onSuccess?.())}catch{l.oR.error(s("Operation failed"))}finally{k(null)}},R=async()=>{if(e.user?.id&&_){y(!0);try{let a=await (0,eS.PV)(e.user.id,{plan_id:_.planId,advance_reset_time:f});a.success&&(l.oR.success(s("Reset {{count}} active subscriptions",{count:a.data?.reset_count||0})),await C(),e.onSuccess?.())}catch{l.oR.error(s("Operation failed"))}finally{y(!1),w(null)}}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U.cj,{open:e.open,onOpenChange:e.onOpenChange,children:(0,t.jsxs)(U.h,{className:(0,q.jW)("sm:max-w-2xl"),children:[(0,t.jsxs)(U.Fm,{className:(0,q.Dt)(),children:[(0,t.jsx)(U.qp,{children:s("User Subscription Management")}),(0,t.jsxs)(U.Qs,{children:[e.user?.username||"-"," (ID: ",e.user?.id||"-",")"]})]}),(0,t.jsxs)("div",{className:(0,q.e)(),children:[(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)(K.l6,{items:u.map(e=>
2({value:String(e.plan.id),label:(0,t.jsxs)(t.Fragment,{children:[e.plan.title,"($",Number(e.plan.price_amount||0).toFixed(2),")"]})})),value:x,onValueChange:e=>null!==e&&g(e),children:[(0,t.jsx)(K.bq,{className:"flex-1",children:(0,t.jsx)(K.yv,{placeholder:s("Select subscription plan")})}),(0,t.jsx)(K.gC,{alignItemWithTrigger:!1,children:(0,t.jsx)(K.s3,{children:u.map(e=>(0,t.jsxs)(K.eb,{value:String(e.plan.id),children:[e.plan.title," ($",Number(e.plan.price_amount||0).toFixed(2),")"]},e.plan.id))})})]}),(0,t.jsxs)(M.$,{onClick:A,disabled:d||!x,children:[(0,t.jsx)(J.A,{className:"mr-1 h-4 w-4"}),s("Add subscription")]})]}),(0,t.jsx)(X.hm,{data:a?[]:p,getRowKey:e=>e.subscription.id,emptyClassName:a?"py-8":"text-muted-foreground py-8",emptyContent:a?s("Loading..."):s("No subscription records"),columns:[{id:"id",header:s("ID"),cell:e=>(0,t.jsx)(ed.C,{value:e.subscription.id})},{id:"plan",header:s("Plan"),cell:e=>{let a=e.subscription;return(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"font-medium",children:S.get(a.plan_id)||`#${a.plan_id}`}),(0,t.jsxs)("div",{className:"text-muted-foreground text-sm",children:[s("Source"),": ",a.source||"-"]})]})}},{id:"status",header:s("Status"),cell:e=>(0,t.jsx)(eA,{sub:e.subscription,t:s})},{id:"validity",header:s("Validity"),cell:e=>{let a=e.subscription;return(0,t.jsxs)("div",{className:"text-sm",children:[(0,t.jsxs)("div",{children:[s("Start"),": ",(0,eC.Ey)(a.start_time)]}),(0,t.jsxs)("div",{children:[s("End"),": ",(0,eC.Ey)(a.end_time)]})]})}},{id:"quota",header:s("Total Quota"),cell:e=>{let a=e.subscription,t=Number(a.amount_total||0),r=Number(a.amount_used||0);return t>0?`${(0,v.eN)(r)}/${(0,v.eN)(t)}`:s("Unlimited")}},{id:"actions",header:s("Actions"),className:"text-right",cellClassName:"text-right",cell:e=>{let a=e.subscription,r=Date.now()/1e3,n=(a.end_time||0)>0&&a.end_time<r,i="active"===a.status&&!n;return(0,t.jsxs)(X.CY,{ariaLabel:s("Actions"),children:[(0,t.jsxs)(ev._2,{disabled:!i,onClick:()=>{b(!0),w({planId:a.plan_id,planTitle:S.get(a.plan_id)||`#${a.plan_id}`})},children:[s("Reset quota"),(0,t.jsx)(ev.V0,{children:(0,t.jsx)(e_.A,{size:16})})]}),(0,t.jsxs)(ev._2,{disabled:!i,onClick:()=>k({type:"invalidate",subId:a.id}),children:[s("Invalidate"),(0,t.jsx)(ev.V0,{children:(0,t.jsx)(eN,{size:16})})]}),(0,t.jsx)(ev.mB,{}),(0,t.jsxs)(ev._2,{variant:"destructive",onClick:()=>k({type:"delete",subId:a.id}),children:[s("Delete"),(0,t.jsx)(ev.V0,{children:(0,t.jsx)(ef.A,{size:16})})]})]})}}]})]})]})}),N&&(0,t.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:I,destructive:"delete"===N.type}),_&&(0,t.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:_.planTitle}),confirmText:s("Reset quota"),handleConfirm:R,isLoading:j,children:(0,t.jsxs)("label",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2 text-sm",children:[(0,t.jsx)("span",{children:s("Advance next reset time")}
2),(0,t.jsx)(ek.d,{checked:f,onCheckedChange:e=>b(!!e),"aria-label":s("Advance next reset time")})]})})]})}var eR=a(66065);let e$=(0,ew.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 eF=a(41948),ez=a(30754),eD=a(70326),eq=a(71451),eM=a(6487),eE=a(97597),eT=a(50831),eH=a(68603),eB=a(78017),eK=a(63228);let eU=[{key:"email",field:"email",label:"Email",icon:(0,t.jsx)(eR.A,{className:"h-4 w-4"}),statusKey:null},{key:"github_id",field:"github_id",label:"GitHub",icon:(0,t.jsx)(eT.SiGithub,{className:"h-4 w-4"}),statusKey:"github_oauth"},{key:"discord_id",field:"discord_id",label:"Discord",icon:(0,t.jsx)(eT.SiDiscord,{className:"h-4 w-4"}),statusKey:"discord_oauth"},{key:"wechat_id",field:"wechat_id",label:"WeChat",icon:(0,t.jsx)(e$,{className:"h-4 w-4"}),statusKey:"wechat_login"},{key:"oidc_id",field:"oidc_id",label:"OIDC",icon:(0,t.jsx)(eF.A,{className:"h-4 w-4"}),statusKey:"oidc_enabled"},{key:"telegram_id",field:"telegram_id",label:"Telegram",icon:(0,t.jsx)(ez.A,{className:"h-4 w-4"}),statusKey:"telegram_oauth"},{key:"linux_do_id",field:"linux_do_id",label:"LinuxDO",icon:(0,t.jsx)(eF.A,{className:"h-4 w-4"}),statusKey:"linuxdo_oauth"}];function eO(e){return e.iconUrl?(0,t.jsx)("img",{src:e.iconUrl,alt:"",className:"h-4 w-4 rounded-sm object-contain",onError:e=>{e.currentTarget.style.display="none"}}):(0,t.jsx)(ex.A,{className:"h-4 w-4"})}function eP(e){let{t:s}=(0,r.Bd)(),[a,n]=(0,i.useState)(null),[c,u]=(0,i.useState)([]),[m,p]=(0,i.useState)({}),[h,x]=(0,i.useState)(!1),[g,j]=(0,i.useState)(!0),[y,f]=(0,i.useState)(null),[b,v]=(0,i.useState)(!1),_=(0,i.useCallback)(async()=>{if(e.userId){x(!0);try{let[s,a,t]=await Promise.all([(0,d.wz)(e.userId),(0,d.XD)(e.userId).catch(()=>({success:!1,data:[]})),eK.FH.get("/api/status").then(e=>e.data).catch(()=>({success:!1,data:{}}))]);s.success&&s.data&&n(s.data),a.success&&a.data&&u(a.data),t.success&&t.data&&p(t.data)}catch{l.oR.error(s("Failed to load"))}finally{x(!1)}}},[e.userId,s]);(0,i.useEffect)(()=>{e.open&&e.userId?(j(!0),_()):(n(null),u([]),p({}))},[e.open,e.userId,_]);let w=(0,i.useMemo)(()=>{let e=[];for(let s of eU){let t=a?String(a[s.field]||""):"",r=!!t,n=null==s.statusKey||!!m[s.statusKey];e.push({key:s.key,label:s.label,icon:s.icon,value:r?t:"",type:"builtin",isBound:r,isEnabled:n})}let s=new Map(c.map(e=>[String(e.provider_id),e])),r=m.custom_oauth_providers||[],n=new Set;for(let a of r){n.add(String(a.id));let r=s.get(String(a.id));e.push({key:`oauth_${a.id}`,label:a.name||a.id,icon:(0,t.jsx)(eO,{iconUrl:a.icon}),value:r?.external_id||"",type:"custom",providerId:String(a.id),isBound:!!r,isEnabled:!0})}for(let s of c)n.has(String(s.provider_id))||e.push({key:`oauth_${s.provider_id}`,label:s.provider_name||s.provider_id,icon:(0,t.jsx)(ex.A,{className:"h-4 w-4"}),value:s.external_id||"-",type:"custom",providerId:String(s.provider_id),isBound:!0,isEnabled:!1});return e},[a,c,m]),N=g?w.filter(e=>e.isBound):w,k=w.filter(e=>e.isBound).length,S=async()=>{if(y&&e.userId){v(!0);try{let a;"builtin"===y.type?a=await (0,d.zm)(e.userId,y.key):y.providerId&&(a=await (0,d.OP)(e.userId,y.providerId)),a?.success?(l.oR.success(s("Unbound {{provider}}",{provider:y.label})),await _(),e.onUnbindSuccess?.()):l.oR.error(a?.message||s("Unbind failed"))}catch{l.oR.error(s("Unbind failed"))}finally{v(!1),f(null)}}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(W.l,{open:e.open,onOpenChange:e.onOpenChange,title:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ex.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,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsx)(eD.A,{className:"text-muted-foreground h-6 w-6 animate-spin"})}):(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[a&&(0,t.jsxs)("p",{className:"text-muted-foreground text-sm",children:[a.username," (ID: ",a.id,")"]}),(0,t.jsx)(en.Bc,{children:(0,t.jsxs)(en.m_,{children:[(0,t.jsxs)(en.k$,{render:(0,t.jsx)(M.$,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>j(e=>!e)}),children:[g?(0,t.jsx)(eq.A,{className:"h-3.5 w-3.5"}):(0,t.jsx)(eM.A,{className:"h-3.5 w-3.5"}),g?s("Show All"):s("Bound Only")]}),(0,t.jsx)(en.ZI,{children:g?s("Show all providers including unbound"):s("Show only bound providers")})]})})]}),(0,t.jsx)(eB.w,{}),(0,t.jsx)(eH.F,{className:"max-h-[50vh]",children:0===N.length?(0,t.jsx)("p",{className:"text-muted-foreground py-4 text-center text-sm",children:g?s("This user has no bindings"):s("No providers available")}):(0,t.jsx)("div",{className:"grid grid-cols-1 gap-2 pr-3 lg:grid-cols-2",children:N.map(e=>(0,t.jsxs)("div",{className:`flex items-center justify-between rounded-md border px-3 py-2.5 ${!e.isBound?"opacity-50":""}`,children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,t.jsx)("div",{className:"text-muted-foreground shrink-0",children:e.icon}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.label}),!e.isEnabled&&(0,t.jsx)(eo.Wh,{variant:"neutral",label:s("Disabled"),copyable:!1,size:"sm"})]}),(0,t.jsx)("p",{className:"text-muted-foreground max-w-[140px] truncate text-xs",children:e.isBound?e.value:s("Not bound")})]})]}),e.isBound&&(0,t.jsx)(M.$,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive h-7 w-7 shrink-0 p-0",onClick:()=>f(e),children:(0,t.jsx)(eE.A,{className:"h-3.5 w-3.5"})})]},e.key))})}),(0,t.jsxs)("p",{className:"text-muted-foreground text-xs",children:[s("Bound"),": ",k," / ",w.length]})]})}),(0,t.jsx)(o.T,{open:!!y,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:y?.label||""}),confirmText:s("Confirm Unbind"),destructive:!0,handleConfirm:S,isLoading:b})]})}function eV(e){let{row:s}=e,{t:a}=(0,r.Bd)(),n=s.original,{setOpen:c,setCurrentRow:u,triggerRefresh:m}=I(),[p,h]=(0,i.useState)(!1),[x,g]=(0,i.useState)(!1),[f,b]=(0,i.useState)(!1),[v,_]=(0,i.useState)(!1),w=async e=>{try{let s=await (0,d.ZC)(n.id,e);s.success?(l.oR.success(a(y[e])),m()):l.oR.error(s.message||a("Failed to {{action}} user",{action:e}))}catch{l.oR.error(a(j))}},N=async()=>{try{let e=await (0,d.tg)(n.id);e.success?(l.oR.success(a("Passkey reset successfully")),m()):l.oR.error(e.message||a("Failed to reset Passkey"))}catch{l.oR.error(a(j))}finally{h(!1)}},k=async()=>{try{let e=await (0,d.S$)(n.id);e.success?(l.oR.success(a("Two-factor authentication reset")),m()):l.oR.error(e.message||a("Failed to reset 2FA"))}catch{l.oR.error(a(j))}finally{g(!1)}},S=2===n.status,C=n.role>=10,A=100===n.role;return null!=n.DeletedAt?null:(0,t.jsxs)("div",{className:"-ml-1.5 flex items-center gap-1",children:[(0,t.jsxs)(en.m_,{children:[(0,t.jsx)(en.k$,{render:(0,t.jsx)(M.$,{variant:"ghost",size:"icon-sm",onClick:()=>{u(n),c("update")},"aria-label":a("Edit")}),children:(0,t.jsx)(z.A,{})}),(0,t.jsx)(en.ZI,{children:a("Edit")})]}),(0,t.jsxs)(eb.C,{ariaLabel:a("Open menu"),contentClassName:"w-48",children:[S?(0,t.jsxs)(ev._2,{onClick:()=>
2w("enable"),children:[a("Enable"),(0,t.jsx)(ev.V0,{children:(0,t.jsx)(eu.A,{size:16})})]}):(0,t.jsxs)(ev._2,{onClick:()=>w("disable"),disabled:A,children:[a("Disable"),(0,t.jsx)(ev.V0,{children:(0,t.jsx)(em.A,{size:16})})]}),C&&!A&&(0,t.jsxs)(ev._2,{onClick:()=>w("demote"),children:[a("Demote"),(0,t.jsx)(ev.V0,{children:(0,t.jsx)(ep.A,{size:16})})]}),!C&&(0,t.jsxs)(ev._2,{onClick:()=>w("promote"),children:[a("Promote"),(0,t.jsx)(ev.V0,{children:(0,t.jsx)(eh.A,{size:16})})]}),(0,t.jsxs)(ev._2,{onSelect:e=>{e.preventDefault(),b(!0)},children:[a("Manage Bindings"),(0,t.jsx)(ev.V0,{children:(0,t.jsx)(ex.A,{size:16})})]}),(0,t.jsxs)(ev._2,{onSelect:e=>{e.preventDefault(),_(!0)},children:[a("Manage Subscriptions"),(0,t.jsx)(ev.V0,{children:(0,t.jsx)(eg.A,{size:16})})]}),(0,t.jsx)(ev.mB,{}),(0,t.jsxs)(ev._2,{onSelect:e=>{e.preventDefault(),h(!0)},disabled:A,children:[a("Reset Passkey"),(0,t.jsx)(ev.V0,{children:(0,t.jsx)(ej.A,{size:16})})]}),(0,t.jsxs)(ev._2,{onSelect:e=>{e.preventDefault(),g(!0)},disabled:A,children:[a("Reset 2FA"),(0,t.jsx)(ev.V0,{children:(0,t.jsx)(ey.A,{size:16})})]}),(0,t.jsx)(ev.mB,{}),(0,t.jsxs)(ev._2,{onClick:()=>{u(n),c("delete")},className:"text-destructive focus:text-destructive",disabled:A,children:[a("Delete"),(0,t.jsx)(ev.V0,{children:(0,t.jsx)(ef.A,{size:16})})]})]}),(0,t.jsx)(o.T,{open:p,onOpenChange:h,title:a("Reset Passkey"),desc:a("Reset Passkey for {{username}}? The user will need to register a new Passkey before using passwordless login.",{username:n.username}),confirmText:a("Reset Passkey"),handleConfirm:N}),(0,t.jsx)(o.T,{open:x,onOpenChange:g,title:a("Reset Two-Factor Authentication"),desc:a("Reset 2FA for {{username}}? The user must set up 2FA again to continue using it.",{username:n.username}),confirmText:a("Reset 2FA"),handleConfirm:k}),(0,t.jsx)(eP,{open:f,onOpenChange:b,userId:n.id,onUnbindSuccess:m}),(0,t.jsx)(eI,{open:v,onOpenChange:_,user:{id:n.id,username:n.username},onSuccess:m})]})}let eW=(0,Z.GY)("/_authenticated/users/");function eY(){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,t.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,t.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,t.jsx)(ed.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,a=s.getValue("username"),r=s.original.display_name,n=s.original.remark;return(0,t.jsxs)("div",{className:"flex min-w-[160px] flex-col gap-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(ei,{className:"max-w-[140px] font-medium",children:a}),n&&(0,t.jsxs)(en.m_,{children:[(0,t.jsx)(en.k$,{render:(0,t.jsx)(eo.Wh,{variant:"success",copyable:!1}),children:(0,t.jsx)(ei,{className:"max-w-[80px]",children:n})}),(0,t.jsx)(en.ZI,{children:(0,t.jsx)("p",{className:"text-xs",children:n})})]})]}),r&&r!==a&&(0,t.jsx)(ei,{className:"text-muted-foreground max-w-[180px] text-xs",children:r})]})},enableHiding:!1,size:220,meta:{mobileTitle:!0}},{accessorKey:"status",header:e("Status"),cell:s=>{let{row:a}=s,r=a.original,n=r.request_count,i=null!=r.DeletedAt?p[-1]:p[r.status];return i?(0,t.jsxs)(en.m_,{children:[(0,t.jsx)(en.k$,{render:(0,t.jsx)("div",{className:"-ml-1.5 cursor-help"}),children:(0,t.jsx)(eo.Wh,{label:e(i.labelKey),variant:i.variant,copyable:!1})}),(0,t.jsx)(en.ZI,{children:(0,t.jsxs)("p",{className:"text-xs",children:[e("Requests:")," ",n.toLocaleString()]})})]}):null},filterFn:(e,s,a)=>a.includes(String(e.getValue(s))),enableSorting:!1,size:120,meta:{mobileBadge:!0}},{id:"quota",accessorKey:"quota",header:e("Quota"),cell:s=>{let{row:a}=s,r=a.original,n=r.used_quota,i=r.quota,l=n+i,o=l>0?i/l*100:0;
2return 0===l?(0,t.jsx)(eo.Wh,{label:e("No Quota"),variant:"neutral",copyable:!1,className:"-ml-1.5"}):(0,t.jsxs)(en.m_,{children:[(0,t.jsxs)(en.k$,{render:(0,t.jsx)("div",{className:"w-[150px] cursor-help space-y-1"}),children:[(0,t.jsxs)("div",{className:"flex justify-between text-xs",children:[(0,t.jsx)("span",{className:"font-medium tabular-nums",children:(0,v.eN)(i)}),(0,t.jsx)("span",{className:"text-muted-foreground tabular-nums",children:(0,v.eN)(l)})]}),(0,t.jsx)(ec.ke,{value:o,className:(0,Y.cn)("h-1.5",o<=10?"[&_[data-slot=progress-indicator]]:bg-rose-500":o<=30?"[&_[data-slot=progress-indicator]]:bg-amber-500":"[&_[data-slot=progress-indicator]]:bg-emerald-500")})]}),(0,t.jsx)(en.ZI,{children:(0,t.jsxs)("div",{className:"space-y-1 text-xs",children:[(0,t.jsxs)("div",{children:[e("Used:")," ",(0,v.eN)(n)]}),(0,t.jsxs)("div",{children:[e("Remaining:")," ",(0,v.eN)(i)]}),(0,t.jsxs)("div",{children:[e("Total:")," ",(0,v.eN)(l)]}),(0,t.jsxs)("div",{children:[e("Percentage:")," ",o.toFixed(1),"%"]})]})})]})},size:170,meta:{mobileOrder:40}},{accessorKey:"group",header:e("Group"),cell:e=>{let{row:s}=e,a=s.getValue("group");return(0,t.jsx)(X.ak,{children:(0,t.jsx)(et.d,{group:a})})},filterFn:(s,a,t)=>{let r=String(s.getValue(a)||e("User Group")).toLowerCase(),n=String(t).toLowerCase();return r.includes(n)},size:140,meta:{mobileOrder:30}},{accessorKey:"role",header:e("Role"),cell:s=>{let{row:a}=s,r=h[a.getValue("role")];return r?(0,t.jsxs)("div",{className:"flex items-center gap-x-2",children:[r.icon&&(0,t.jsx)(r.icon,{size:16,className:"text-muted-foreground"}),(0,t.jsx)("span",{className:"text-sm",children:e(r.labelKey)})]}):null},filterFn:(e,s,a)=>a.includes(String(e.getValue(s))),enableSorting:!1,size:120,meta:{mobileOrder:20}},{id:"invite_info",header:e("Invite Info"),cell:s=>{let{row:a}=s,r=a.original,n=r.aff_count||0,i=r.aff_history_quota||0,l=r.inviter_id||0;return(0,t.jsxs)("div",{className:"flex max-w-full min-w-0 flex-wrap items-center gap-1 overflow-hidden",children:[(0,t.jsxs)(en.m_,{children:[(0,t.jsx)(en.k$,{render:(0,t.jsx)(eo.Wh,{label:`${e("Invited")}: ${n}`,variant:"neutral",copyable:!1,className:"cursor-help"})}),(0,t.jsx)(en.ZI,{children:(0,t.jsx)("p",{className:"text-xs",children:e("Number of users invited")})})]}),(0,t.jsxs)(en.m_,{children:[(0,t.jsx)(en.k$,{render:(0,t.jsx)(eo.Wh,{label:`${e("Revenue")}: ${(0,v.eN)(i)}`,variant:"neutral",copyable:!1,className:"cursor-help"})}),(0,t.jsx)(en.ZI,{children:(0,t.jsx)("p",{className:"text-xs",children:e("Total invitation revenue")})})]}),l>0&&(0,t.jsxs)(en.m_,{children:[(0,t.jsx)(en.k$,{render:(0,t.jsx)(eo.Wh,{label:`${e("Inviter")}: ${l}`,variant:"neutral",copyable:!1,className:"cursor-help"})}),(0,t.jsx)(en.ZI,{children:(0,t.jsxs)("p",{className:"text-xs",children:[e("Invited by user ID")," ",l]})})]}),0===l&&(0,t.jsx)(eo.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,a=s.getValue("created_at");return(0,t.jsx)("span",{className:"text-muted-foreground text-sm",children:a?(0,v.Ey)(a):"-"})},size:180,meta:{mobileHidden:!0}},{accessorKey:"last_login_at",header:e("Last Login"),cell:e=>{let{row:s}=e,a=s.getValue("last_login_at");return(0,t.jsx)("span",{className:"text-muted-foreground text-sm",children:a?(0,v.Ey)(a):"-"})},size:180,meta:{mobileHidden:!0}},{id:"actions",header:()=>e("Actions"),cell:e=>{let{row:s}=e;return(0,t.jsx)(eV,{row:s})},meta:{pinned:"right"}}]}(),{refreshTrigger:a}=I(),n=(0,ee.Ub)("(max-width: 640px)"),{globalFilter:i,onGlobalFilterChange:o,columnFilters:x,onColumnFiltersChange:g,pagination:j,onPaginationChange:y,ensurePageInRange:f}=(0,es.c)({search:eW.useSearch(),navigate:eW.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=x.find(e=>"status"===e.id)?.value??[],_=x.find(e=>"role"===e.id)?.value??[],w=x.find(e=>"group"===e.id)?.value??"",{data:N,isLoading:k,isFetching:S}=(0,F.I)({queryKey:["users",j.pageIndex+1,j.pageSize,i,b,_,w,a],queryFn:async()=>{let e=i?.trim(),s=b.length>0||_.length>0||!!w,a={p:j.pageIndex+1,page_size:j.pageSize},t=e||s?await (0,d.x5)({...a,keyword:i,status:b[0]??"",role:_[0]??"",group:w}):await (0,d.lo)(a);return t.success?{items:t.data?.items||[],total:t.data?.total||0}:(l.oR.error(t.message||`Failed to ${e?"search":"load"} users`),{items:[],total:0})},placeholderData:e=>e}),C=N?.items||[],{table:A}=(0,X.uI)({data:C,columns:s,enableRowSelection:!0,columnFilters:x,globalFilter:i,pagination:j,globalFilterFn:(e,s,a)=>{let t=String(a).toLowerCase();return[e.getValue("username"),e.original.display_name,e.original.email].some(e=>String(e||"").toLowerCase().includes(t))},onPaginationChange:y,onGlobalFilterChange:o,onColumnFiltersChange:g,manualPagination:!0,manualFiltering:!0,totalCount:N?.total||0,ensurePageInRange:f});return(0,t.jsx)(X.cx,{table:A,columns:s,isLoading:k,isFetching:S,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..."),filters:[{columnId:"status",title:e("Status"),options:[{label:e("Enabled"),value:String(1)},{label:e("Disabled"),value:String(2)},{label:e("Deleted"),value:String(-1)}],singleSelect:!0},{columnId:"role",title:e("Role"),options:[{label:e("User"),value:String(1),icon:c.A},{label:e("Admin"),value:String(10),icon:u.A},{label:e("Root"),value:String(100),icon:m.A}],singleSelect:!0}]},getRowClassName:(e,s)=>{var a;let{isMobile:t}=s;return null==(a=e.original).DeletedAt&&2!==a.status?void 0:t?X.Z0:X.JM},bulkActions:(0,t.jsx)(ea,{table:A})})}function eL(){let{t:e}=(0,r.Bd)(),{open:s,setOpen:a,currentRow:i}=I();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(n.Ni,{fixedContent:!0,children:[(0,t.jsx)(n.Ni.Title,{children:e("Users")}),(0,t.jsx)(n.Ni.Actions,{children:(0,t.jsx)(Q,{})}),(0,t.jsx)(n.Ni.Content,{children:(0,t.jsx)(eY,{})})]}),(0,t.jsx)(G,{open:"create"===s||"update"===s,onOpenChange:e=>!e&&a(null),currentRow:"update"===s&&i||void 0}),(0,t.jsx)(R,{})]})}let eG=function(){return(0,t.jsx)(A,{children:(0,t.jsx)(eL,{})})}},41948(e,s,a){let t=(0,a(40946).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"}]]);a.d(s,{},{A:t})},68758(e,s,a){let t=(0,a(40946).A)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);a.d(s,{},{A:t})},6197(e,s,a){let t=(0,a(40946).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"}]]);a.d(s,{},{A:t})},66065(e,s,a){let t=(0,a(40946).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"}]]);a.d(s,{},{A:t})},68815(e,s,a){let t=(0,a(40946).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"}]]);a.d(s,{},{A:t})},48531(e,s,a){let t=(0,a(40946).A)("power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);a.d(s,{},{A:t})},30754(e,s,a){let t=(0,a(40946).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"}]]);a.d(s,{},{A:t})},97597(e,s,a){let t=(0,a(40946).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"}]]);a.d(s,{},{A:t})}}]);

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.