PageSourceSearch

https://xyc.ai/static/js/async/7599.7cb5a5cb25.js

js xyc.ai collected 2026-10-05 14:40:42 UTC 16,467 bytes, 1 lines download raw bytes

1"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[7599],{62254(e,s,a){a.d(s,{w:()=>o});var t=a(72361);a(68413);var n=a(81204);let r="96px",i="52px",l="12px",c=`polygon(0 0, calc(100% - ${r}) 0, calc(100% - ${i}) ${l}, 100% ${l}, 100% 100%, 0 100%)`,d=`polygon(0 0, calc(100% - ${r} + 1.5px) 0, calc(100% - ${i} + 0.5px) calc(${l} - 0.5px), 100% calc(${l} - 0.5px), 100% 100%, 0 100%)`;function o(e){let{title:s,className:a,children:r,...i}=e;return(0,t.jsxs)("div",{"data-slot":"cut-corner-card",className:(0,n.cn)("relative isolate",a),...i,children:[(0,t.jsx)("span",{"aria-hidden":!0,className:"bg-border-strong absolute inset-0 -z-10",style:{clipPath:c}}),(0,t.jsx)("span",{"aria-hidden":!0,className:"bg-background absolute inset-px -z-10",style:{clipPath:d}}),(0,t.jsxs)("div",{className:"px-4 pt-3 pb-3.5",children:[null!=s&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("h3",{className:"text-foreground pr-24 text-sm font-medium",children:s}),(0,t.jsx)("div",{className:"border-border-strong mt-2.5 mb-2.5 border-t border-dotted"})]}),r]})]})}},99170(e,s,a){a.d(s,{H:()=>r});var t=a(68413),n=a(38610);function r(e){let{systemName:s}=(0,n.R)();(0,t.useEffect)(()=>{let a=document.title;return document.title=s?`${e} - ${s}`:e,()=>{document.title=a}},[e,s])}},90642(e,s,a){a.r(s),a.d(s,{component:()=>M});var t=a(72361),n=a(68413),r=a(6702),i=a(20598),l=a(3642),c=a(61631),d=a(81204),o=a(99170),m=a(46775),u=a(62254),x=a(1951),p=a(67267),h=a(54023),j=a(64577);async function y(){return(await j.FH.get("/api/team/mine")).data}async function b(e,s,a){return(await j.FH.get("/api/team/search",{params:{keyword:e,p:s,page_size:a}})).data}async function f(e){return(await j.FH.post("/api/team",{name:e})).data}async function g(e){return(await j.FH.post("/api/team/join",{team_id:e})).data}async function v(e){return(await j.FH.post("/api/team/requests/approve",{member_user_id:e})).data}async function N(e){return(await j.FH.post("/api/team/requests/reject",{member_user_id:e})).data}async function w(e){return(await j.FH.post("/api/team/members/remove",{member_user_id:e})).data}async function C(e,s){return(await j.FH.post("/api/team/members/cap",{member_user_id:e,spend_cap:s})).data}async function _(){return(await j.FH.post("/api/team/disband",{})).data}async function F(e){return(await j.FH.post("/api/team/transfer",{quota:e})).data}async function R(e){return(await j.FH.post("/api/team/billing-toggle",{use_team_balance:e})).data}var S=a(53540),k=a(96962),q=a(55667),z=a(20032);let $=["team-mine"];async function T(){try{let e=await (0,j.Ng)();e?.success&&e.data&&z.n.getState().auth.setUser(e.data)}catch{}}function P(e){let s,a,{pending:l}=e,{t:d}=(0,r.Bd)(),o=(s=(0,k.jE)(),(0,q.n)({mutationFn:e=>f(e),onSuccess:()=>void s.invalidateQueries({queryKey:$})})),x=(a=(0,k.jE)(),(0,q.n)({mutationFn:e=>g(e),onSuccess:()=>void a.invalidateQueries({queryKey:$})}
1)),[p,j]=(0,n.useState)(""),[y,v]=(0,n.useState)(""),[N,w]=(0,n.useState)([]),[C,_]=(0,n.useState)(!1),[F,R]=(0,n.useState)(!1),S=l&&1===l.status,z=async()=>{if(!p.trim())return void i.oR.error(d("Please enter a team name"));let e=await o.mutateAsync(p.trim());e?.success?(i.oR.success(d("Team created")),j("")):i.oR.error(e?.message||d("Failed to create team"))},T=async()=>{R(!0);try{let e=await b(y.trim(),1,20);w(e?.data?.items??[]),_(!0)}finally{R(!1)}},P=async e=>{let s=await x.mutateAsync(e);s?.success?i.oR.success(d("Join request sent")):i.oR.error(s?.message||d("Failed to send join request"))};return S?(0,t.jsx)(u.w,{title:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(c.zWC,{className:"text-primary size-4"}),d("Pending approval")]}),children:(0,t.jsx)("p",{className:"text-text-secondary text-sm",children:d("Your join request has been submitted and is awaiting approval by the team owner.")})}):(0,t.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[(0,t.jsxs)(u.w,{title:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(c.ypN,{className:"text-primary size-4"}),d("Create a team")]}),children:[(0,t.jsx)("p",{className:"text-text-secondary mb-3 text-[13px] leading-relaxed",children:d("Create a team to share balance with members. Team names are unique.")}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(h.p,{value:p,maxLength:32,placeholder:d("Team name"),onChange:e=>j(e.target.value),onKeyDown:e=>"Enter"===e.key&&z()}),(0,t.jsx)(m.$,{onClick:z,disabled:o.isPending,children:d("Create")})]})]}),(0,t.jsxs)(u.w,{title:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(c.vji,{className:"text-icon size-4"}),d("Join a team")]}),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(h.p,{value:y,placeholder:d("Search teams"),onChange:e=>v(e.target.value),onKeyDown:e=>"Enter"===e.key&&T()}),(0,t.jsx)(m.$,{variant:"outline",onClick:T,disabled:F,children:d("Search")})]}),(0,t.jsxs)("div",{className:"mt-3 space-y-2",children:[C&&0===N.length&&(0,t.jsx)("p",{className:"text-text-secondary py-3 text-center text-sm",children:d("No teams found")}),N.map(e=>(0,t.jsxs)("div",{className:"border-border flex items-center justify-between gap-2 rounded-lg border p-2.5",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-foreground truncate text-sm font-medium",children:e.name}),(0,t.jsx)("p",{className:"text-text-secondary text-xs",children:d("{{count}} members",{count:e.member_count??0})})]}),(0,t.jsx)(m.$,{size:"sm",onClick:()=>P(e.id),disabled:x.isPending,children:d("Request to join")})]},e.id))]})]})]})}var E=a(63742),A=a(1755),H=a(61309),K=a(24993);function O(e){return e.display_name||e.username||`#${e.user_id}`}function Q(e){let s,a,d,o,x,{members:p,pendingRequests:j}=e,{t:y}=(0,r.Bd)(),b=(s=(0,k.jE)(),(0,q.n)({mutationFn:e=>v(e),onSuccess:()=>void s.invalidateQueries({queryKey:$})})),f=(a=(0,k.jE)(),(0,q.n)({mutationFn:e=>N(e),onSuccess:()=>void a.invalidateQueries({queryKey:$})})),g=(d=(0,k.jE)(),(0,q.n)({mutationFn:e=>w(e),onSuccess:()=>void d.invalidateQueries({queryKey:$})})),F=(o=(0,k.jE)(),(0,q.n)({mutationFn:e=>C(e.memberUserId,e.spendCap),onSuccess:()=>void o.invalidateQueries({queryKey:$})})),R=(x=(0,k.jE)(),(0,q.n)({mutationFn:()=>_(),onSuccess:async()=>{await T(),x.invalidateQueries({queryKey:$})}})),[S,z]=(0,n.useState)(null),[P,Q]=(0,n.useState)(""),[U,B]=(0,n.useState)(null),[M,D]=(0,n.useState)(!1),L=async()=>{if(!S)return;let e=0,s=P.trim();if(""!==s){let a=Number.parseFloat(s);if(!Number.isFinite(a)||a<0)return void i.oR.error(y("Please enter a valid amount"));e=(0,l.dD)(a)}let a=await F.mutateAsync({memberUserId:S.user_id,spendCap:e});a?.success?(i.oR.success(y("Spending cap updated")),z(null)):i.oR.error(a?.message||y("Update failed"))},J=async e=>{let s=await b.mutateAsync(e.user_id);s?.success?i.oR.success(y("Approved")):i.oR.error(s?.message||y("Operation failed"))},W=async e=>{let s=await f.mutateAsync(e.user_id);s?.success?i.oR.success(y("Rejected")):i.oR.error(s?.message||y("Operation failed"))},I=async()=>
1{if(!U)return;let e=await g.mutateAsync(U.user_id);e?.success?i.oR.success(y("Member removed")):i.oR.error(e?.message||y("Operation failed")),B(null)},G=async()=>{let e=await R.mutateAsync();e?.success?i.oR.success(y("Team disbanded")):i.oR.error(e?.message||y("Operation failed")),D(!1)};return(0,t.jsxs)(t.Fragment,{children:[j.length>0&&(0,t.jsx)(u.w,{title:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(c.zWC,{className:"text-primary size-4"}),y("Pending approval"),(0,t.jsx)(E.E,{variant:"secondary",children:j.length})]}),children:(0,t.jsx)("ul",{className:"space-y-2",children:j.map(e=>(0,t.jsxs)("li",{className:"border-border flex items-center justify-between gap-2 rounded-lg border p-2.5",children:[(0,t.jsx)("span",{className:"text-foreground truncate text-sm",children:O(e)}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsxs)(m.$,{size:"sm",onClick:()=>J(e),disabled:b.isPending,children:[(0,t.jsx)(c.Jlk,{className:"size-3.5"}),y("Approve")]}),(0,t.jsxs)(m.$,{size:"sm",variant:"outline",onClick:()=>W(e),disabled:f.isPending,children:[(0,t.jsx)(c.X,{className:"size-3.5"}),y("Reject")]})]})]},e.id))})}),(0,t.jsxs)(u.w,{title:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(c.ZKV,{className:"text-icon size-4"}),y("Members"),(0,t.jsx)(E.E,{variant:"secondary",children:p.length})]}),children:[(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full min-w-[520px] border-collapse text-sm",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"border-border/70 text-text-secondary border-b text-left text-[13px]",children:[(0,t.jsx)("th",{className:"py-2 pr-4 font-medium",children:y("Member")}),(0,t.jsx)("th",{className:"py-2 pr-4 font-medium",children:y("Role")}),(0,t.jsx)("th",{className:"py-2 pr-4 font-medium",children:y("Cumulative spent")}),(0,t.jsx)("th",{className:"py-2 pr-4 font-medium",children:y("Spending cap")}),(0,t.jsx)("th",{className:"py-2 font-medium",children:y("Actions")})]})}),(0,t.jsx)("tbody",{children:p.map(e=>{let s=1===e.role;return(0,t.jsxs)("tr",{className:"border-border/60 border-b last:border-b-0",children:[(0,t.jsx)("td",{className:"py-2.5 pr-4",children:O(e)}),(0,t.jsx)("td",{className:"py-2.5 pr-4",children:s?(0,t.jsx)(E.E,{variant:"default",children:y("Owner")}):(0,t.jsx)(E.E,{variant:"secondary",children:y("Member")})}),(0,t.jsx)("td",{className:"py-2.5 pr-4 font-mono tabular-nums",children:(0,l.eN)(e.spent_quota)}),(0,t.jsx)("td",{className:"py-2.5 pr-4 font-mono tabular-nums",children:e.spend_cap>0?(0,l.eN)(e.spend_cap):y("Unlimited")}),(0,t.jsx)("td",{className:"py-2.5",children:!s&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(m.$,{size:"sm",variant:"outline",onClick:()=>{z(e),Q(e.spend_cap>0?String(e.spend_cap):"")},children:y("Set cap")}),(0,t.jsx)(m.$,{size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>B(e),children:(0,t.jsx)(c.TBR,{className:"size-3.5"})})]})})]},e.id)})})]})}),(0,t.jsx)("div",{className:"mt-4 flex justify-end",children:(0,t.jsxs)(m.$,{variant:"destructive",size:"sm",onClick:()=>D(!0),children:[(0,t.jsx)(c.TBR,{className:"size-3.5"}),y("Disband team")]})})]}),(0,t.jsx)(A.lG,{open:null!==S,onOpenChange:e=>!e&&z(null),children:(0,t.jsxs)(A.Cf,{children:[(0,t.jsx)(A.c7,{children:(0,t.jsxs)(A.L3,{children:[y("Spending cap"),S?` \xb7 ${O(S)}`:""]})}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(H.J,{htmlFor:"cap-value",children:y("Cumulative cap from team balance (leave empty = unlimited)")}),(0,t.jsx)(h.p,{id:"cap-value",type:"number",min:0,value:P,placeholder:y("Unlimited"),onChange:e=>Q(e.target.value)})]}),(0,t.jsxs)(A.Es,{children:[(0,t.jsx)(m.$,{variant:"outline",onClick:()=>z(null),disabled:F.isPending,children:y("Cancel")}),(0,t.jsx)(m.$,{onClick:L,disabled:F.isPending,children:y("Save")})]})]})}),(0,t.jsx)(K.T,{open:null!==U,onOpenChange:e=>!e&&B(null),title:y("Remove member"),desc:U?y("Remove {{name}} from the team?",{name:O(U)}):"",destructive:!0,confirmText:y("Remove"),isLoading:g.isPending,handleConfirm:I}),(0,t.jsx)(K.T,{open:M,onOpenChange:D,title:y("Disband team"),desc:y("This will disband the team and return the remaining team balance to your personal balance. This cannot be undone."),destructive:!0,confirmText:y("Disband team"),isLoading:R.isPending,handleConfirm:G})]})}function U(e){let s,{open:a,onOpenChange:c,personalQuota:d}=e,{t:o}
1=(0,r.Bd)(),[u,x]=(0,n.useState)(""),p=(s=(0,k.jE)(),(0,q.n)({mutationFn:e=>F(e),onSuccess:async()=>{await T(),s.invalidateQueries({queryKey:$})}})),j=(0,n.useMemo)(()=>{let e=Number.parseFloat(u);return!Number.isFinite(e)||e<=0?0:(0,l.dD)(e)},[u]),y=async()=>{if(j<=0)return void i.oR.error(o("Please enter a valid amount"));if(j>d)return void i.oR.error(o("The amount exceeds your personal balance"));let e=await p.mutateAsync(j);e?.success?(i.oR.success(o("Transferred to team balance")),x(""),c(!1)):i.oR.error(e?.message||o("Transfer failed"))};return(0,t.jsx)(A.lG,{open:a,onOpenChange:c,children:(0,t.jsxs)(A.Cf,{children:[(0,t.jsxs)(A.c7,{children:[(0,t.jsx)(A.L3,{children:o("Transfer to team")}),(0,t.jsx)(A.rr,{children:o("Move quota from your personal balance into the shared team pool.")})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"text-text-secondary flex items-center justify-between text-sm",children:[(0,t.jsx)("span",{children:o("Personal balance")}),(0,t.jsx)("span",{className:"font-mono tabular-nums",children:(0,l.eN)(d)})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(H.J,{htmlFor:"transfer-amount",children:o("Amount")}),(0,t.jsx)(h.p,{id:"transfer-amount",type:"number",min:0,value:u,placeholder:"0.00",onChange:e=>x(e.target.value)})]})]}),(0,t.jsxs)(A.Es,{children:[(0,t.jsx)(m.$,{variant:"outline",onClick:()=>c(!1),disabled:p.isPending,children:o("Cancel")}),(0,t.jsx)(m.$,{onClick:y,disabled:p.isPending,children:o("Confirm")})]})]})})}function B(e){let{useTeamBalance:s,onToggle:a,disabled:n}=e,{t:i}=(0,r.Bd)();return(0,t.jsxs)("div",{className:(0,d.cn)("flex items-center justify-between gap-4 rounded-lg border p-3.5",s?"border-primary/40 bg-primary/5":"border-border bg-background-secondary"),children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(c.uWV,{className:(0,d.cn)("mt-0.5 size-5 shrink-0",s?"text-primary":"text-icon")}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("p",{className:"text-foreground text-sm font-medium",children:[i("Current status"),":"," ",i(s?"Use team balance":"Use personal balance")]}),(0,t.jsx)("p",{className:"text-text-secondary mt-0.5 text-[13px] leading-relaxed",children:i("When enabled, all API calls from this account are billed from the shared team balance instead of your personal balance.")})]})]}),(0,t.jsx)(x.d,{checked:s,disabled:n,onCheckedChange:a})]})}let M=function(){let e,{t:s}=(0,r.Bd)();(0,o.H)(s("My Team"));let{data:a,isLoading:d}=function(){let{data:e,isLoading:s,error:a}=(0,S.I)({queryKey:$,queryFn:y,staleTime:15e3});return{data:e?.data,isLoading:s,error:a}}(),x=(e=(0,k.jE)(),(0,q.n)({mutationFn:e=>R(e),onSuccess:()=>void e.invalidateQueries({queryKey:$})})),[h,j]=(0,n.useState)(!1),b=async e=>{let a=await x.mutateAsync(e);a?.success?i.oR.success(e?s("Now billing from team balance"):s("Now billing from personal balance")):i.oR.error(a?.message||s("Operation failed"))},f=a?.team??null,g=a?.membership??null,v=g?.role===1,N=a?.personal_quota??0;return(0,t.jsx)(p.Ni,{children:(0,t.jsx)(p.Ni.Content,{children:(0,t.jsxs)("div",{className:"mx-auto w-full max-w-4xl space-y-4 pt-3 sm:pt-5",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-foreground text-lg font-medium tracking-tight",children:s("My Team")}),(0,t.jsx)("p",{className:"text-text-secondary mt-0.5 text-sm",children:s("Create or join a team to share balance with members")})]}),d?(0,t.jsx)("p",{className:"text-text-secondary py-10 text-center text-sm",children:s("Loading...")}):f&&g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(u.w,{title:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(c.zWC,{className:"text-primary size-4"}),f.name,v&&(0,t.jsxs)("span",{className:"text-primary text-xs",children:["· ",s("Owner")]})]}),children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-text-secondary text-[13px]",children:s("Shared balance")}),(0,t.jsx)("p",{className:"text-primary mt-0.5 font-mono text-2xl font-semibold tabular-nums",children:(0,l.eN)(f.quota)})]}),(0,t.jsxs)(m.$,{variant:"outline",size:"sm",onClick:()=>j(!0),children:[(0,t.jsx)(c.nFs,{className:"size-3.5"}),s("Transfer to team")]})]}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(B,{useTeamBalance:a?.use_team_balance??!1,disabled:x.isPending,onToggle:b})}),g&&(0,t.jsxs)("div",{className:"text-text-secondary mt-3 flex items-center justify-between text-[13px]",children:[(0,t.jsx)("span",{children:s("Your cumulative spent")}),(0,t.jsxs)("span",{className:"font-mono tabular-nums",children:[(0,l.eN)(g.spent_quota)," / ",g.spend_cap>0?(0,l.eN)(g.spend_cap):s("Unlimited")]})]})]}),v&&(0,t.jsx)(Q,{members:a?.members??[],pendingRequests:a?.pending_requests??[]})]}):(0,t.jsx)(P,{pending:a?.pending??null}),(0,t.jsx)(U,{open:h,onOpenChange:j,personalQuota:N})]})})})}}}]);

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.