@shumai-one/shumai 0.4.4 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/{chunk-snhsjs4x.js → chunk-07jszkhj.js} +62 -62
- package/bin/chunk-0c67210c.js +1 -0
- package/bin/{chunk-kswvyqq1.js → chunk-0wvhahzh.js} +2 -2
- package/bin/chunk-161rxeq2.js +2 -0
- package/bin/{chunk-trveq4wg.js → chunk-1bgsphyz.js} +2 -2
- package/bin/{chunk-vap4k11j.js → chunk-1dqsf5qj.js} +6 -6
- package/bin/{chunk-zxk7q0zk.js → chunk-1jybg56e.js} +1 -1
- package/bin/chunk-1kt5dzjv.js +2 -0
- package/bin/{chunk-drepsbb4.js → chunk-1t51fp6n.js} +1 -1
- package/bin/{chunk-cbgq517y.js → chunk-2jrjwaqr.js} +2 -2
- package/bin/chunk-2qjfpmcf.js +2 -0
- package/bin/{chunk-wjyaezs7.js → chunk-2vzzd0q6.js} +1 -1
- package/bin/chunk-2yr5k567.js +2 -0
- package/bin/chunk-2z1pnt7h.js +2 -0
- package/bin/{chunk-0zv3bks2.js → chunk-3d5rm1d1.js} +1 -1
- package/bin/{chunk-w4ghe71n.js → chunk-3d9tfxp4.js} +1 -1
- package/bin/{chunk-0qjfahk9.js → chunk-3dgahs95.js} +1 -1
- package/bin/{chunk-dqxeztfa.js → chunk-3j5njrpr.js} +2 -2
- package/bin/{chunk-ryzz5fht.js → chunk-3n4224c0.js} +1 -1
- package/bin/{chunk-914bp49r.js → chunk-3tg39jx7.js} +3 -3
- package/bin/chunk-3vmapyk9.js +1 -0
- package/bin/{chunk-g3fpmyyn.js → chunk-46wfxyd7.js} +2 -2
- package/bin/{chunk-4hkkdm2q.js → chunk-47tn3vtg.js} +1 -1
- package/bin/{chunk-1zwajpwf.js → chunk-4syt6rn0.js} +3 -3
- package/bin/chunk-5kvc1gp2.js +1 -0
- package/bin/{chunk-xa18z1py.js → chunk-5vvvgjvz.js} +2 -2
- package/bin/{chunk-5nm2jvg5.js → chunk-6vxzkrsj.js} +11 -11
- package/bin/{chunk-ytdwk2fq.js → chunk-6y4xkcte.js} +2 -2
- package/bin/{chunk-fpc4p0j8.js → chunk-7e5z637e.js} +2 -2
- package/bin/chunk-7nvk7waw.js +1 -0
- package/bin/{chunk-rq0n0vcc.js → chunk-80qz30dc.js} +2 -2
- package/bin/chunk-886pnknh.js +3 -0
- package/bin/{chunk-6ghcj4a9.js → chunk-8cn7fx40.js} +1 -1
- package/bin/chunk-908pypkr.js +1 -0
- package/bin/chunk-952qwf17.js +2 -0
- package/bin/chunk-988casfy.js +1 -0
- package/bin/chunk-9a2tf0mh.js +2 -0
- package/bin/{chunk-nkdk229f.js → chunk-9d0thqcy.js} +1 -1
- package/bin/{chunk-s2k4qntr.js → chunk-9nvymwqj.js} +2 -2
- package/bin/{chunk-mz0yjra0.js → chunk-9trnkbtr.js} +4 -4
- package/bin/{chunk-t2hy6tj9.js → chunk-a4056d0r.js} +1 -1
- package/bin/{chunk-ze20rm02.js → chunk-a796sgcw.js} +4 -4
- package/bin/{chunk-kpgfqkp0.js → chunk-afnzb9ne.js} +2 -2
- package/bin/chunk-apfrw0wd.js +3 -0
- package/bin/{chunk-wndm3px3.js → chunk-axmd242s.js} +1 -1
- package/bin/{chunk-nr20tvnw.js → chunk-b3aqmcps.js} +2 -2
- package/bin/chunk-b6q287d1.js +2 -0
- package/bin/{chunk-j1tkmcae.js → chunk-b9hyc0a1.js} +2 -2
- package/bin/chunk-ba33nf0q.js +4 -0
- package/bin/chunk-batadmvr.js +2 -0
- package/bin/{chunk-1t167cvj.js → chunk-brwbhbmc.js} +7 -7
- package/bin/chunk-bvdvp192.js +1 -0
- package/bin/{chunk-fahk9h62.js → chunk-crja7whq.js} +2 -2
- package/bin/{chunk-98715kc3.js → chunk-d7fwggt6.js} +2 -2
- package/bin/chunk-db1msmdh.js +2 -0
- package/bin/{chunk-97f2af6d.js → chunk-dbw8c1jj.js} +5 -5
- package/bin/{chunk-7gmdnsdg.js → chunk-dj5a6kkh.js} +1 -1
- package/bin/chunk-dkx3pmdz.js +1 -0
- package/bin/{chunk-071x515q.js → chunk-dmvvt8va.js} +2 -2
- package/bin/{chunk-3tedzb2j.js → chunk-dpc11hpd.js} +9 -9
- package/bin/{chunk-ks8xzc95.js → chunk-dscq4a4k.js} +2 -2
- package/bin/{chunk-jmpb5633.js → chunk-dz076sh7.js} +1 -1
- package/bin/chunk-edqd8evk.js +2 -0
- package/bin/{chunk-0qaq0sp8.js → chunk-ehpfg3km.js} +2 -2
- package/bin/chunk-ey3h4sct.js +2 -0
- package/bin/{chunk-vm5fx7td.js → chunk-ga3pahzf.js} +1 -1
- package/bin/chunk-gc6m7agb.js +3 -0
- package/bin/{chunk-7bcxj1jd.js → chunk-gcjsw9yp.js} +1 -1
- package/bin/chunk-gqr5hxhj.js +2 -0
- package/bin/{chunk-jrjnqx78.js → chunk-gsfcpcye.js} +1 -1
- package/bin/chunk-h9mka9br.js +2 -0
- package/bin/chunk-hacyjx1s.js +1 -0
- package/bin/chunk-hd6dnnyg.js +2 -0
- package/bin/chunk-he5nvmqw.js +1 -0
- package/bin/{chunk-reyxk4bw.js → chunk-hnhdq2wd.js} +1 -1
- package/bin/{chunk-gt4csat6.js → chunk-hs2r9qaw.js} +2 -2
- package/bin/{chunk-fb40xxz3.js → chunk-hxyg5q2a.js} +2 -2
- package/bin/chunk-hyr1vtfp.js +1 -0
- package/bin/{chunk-zw86wnwe.js → chunk-j9ks8bd7.js} +2 -2
- package/bin/{chunk-1gvscz88.js → chunk-jg2v25d2.js} +2 -2
- package/bin/chunk-jh8q3885.js +211 -0
- package/bin/chunk-jzbrt2vk.js +1 -0
- package/bin/chunk-k6avge95.js +10 -0
- package/bin/{chunk-msfw3jmc.js → chunk-kg8eg9z3.js} +2 -2
- package/bin/chunk-kk42xhgz.js +1 -0
- package/bin/{chunk-3ttrhqy3.js → chunk-kmbjp5kp.js} +2 -2
- package/bin/{chunk-jgs8an3h.js → chunk-md5pcq46.js} +8 -8
- package/bin/{chunk-xarsrs08.js → chunk-mtb9fpj2.js} +1 -1
- package/bin/chunk-n3xjwszr.js +2 -0
- package/bin/chunk-nqym3zbs.js +1 -0
- package/bin/{chunk-579e4wv4.js → chunk-p75f5pgq.js} +2 -2
- package/bin/{chunk-hm0dkzed.js → chunk-pdh9bnyj.js} +2 -2
- package/bin/{chunk-rhvv1vvk.js → chunk-pgj2kjnn.js} +2 -2
- package/bin/{chunk-hmpwg5za.js → chunk-pvg3msgw.js} +8 -8
- package/bin/{chunk-4991gz3y.js → chunk-pwkby9h7.js} +6 -6
- package/bin/{chunk-fnmwksnb.js → chunk-qbqym9m6.js} +2 -2
- package/bin/{chunk-4wy87hwd.js → chunk-qgkbxw1k.js} +2 -2
- package/bin/{chunk-1j27fzy1.js → chunk-qs7855cz.js} +2 -2
- package/bin/{chunk-7jtmwt5a.js → chunk-radcwage.js} +2 -2
- package/bin/{chunk-gk2q9a3f.js → chunk-rmzcarv9.js} +2 -2
- package/bin/{chunk-s2fnfyn9.js → chunk-rp4pc6kz.js} +1 -1
- package/bin/{chunk-5adsx8x4.js → chunk-rsd164d9.js} +2 -2
- package/bin/{chunk-hk5rc6cd.js → chunk-s05cdax2.js} +4 -4
- package/bin/{chunk-pazjhrnf.js → chunk-sab7tjxw.js} +5 -5
- package/bin/chunk-sebbjvgv.css +1 -0
- package/bin/{chunk-bkr5zm4h.js → chunk-t350k3s1.js} +1 -1
- package/bin/{chunk-4v41a1r9.js → chunk-t7bvde99.js} +3 -3
- package/bin/chunk-t8gv2ekj.js +14 -0
- package/bin/chunk-teqprbd8.js +2 -0
- package/bin/chunk-tgr86ac4.js +2 -0
- package/bin/{chunk-5hg6kcfz.js → chunk-v8v8vdf7.js} +9 -9
- package/bin/chunk-vm5tn0zm.js +2 -0
- package/bin/chunk-vzj2j11x.js +2 -0
- package/bin/chunk-w1wxzqqb.js +2 -0
- package/bin/chunk-wmjp8dcm.js +1 -0
- package/bin/chunk-wy8dkyxj.js +1 -0
- package/bin/{chunk-a6gx7f5q.js → chunk-y1b3ck7m.js} +1 -1
- package/bin/{chunk-1xh34aew.js → chunk-y20sbaz5.js} +2 -2
- package/bin/{chunk-qsr1a0rp.js → chunk-y56yvezn.js} +1 -1
- package/bin/{chunk-9t8n2des.js → chunk-yfr0hzb7.js} +2 -2
- package/bin/chunk-ysv80zyb.js +5 -0
- package/bin/chunk-z08bqvkc.js +42 -0
- package/bin/{chunk-5tcdwep5.js → chunk-z6jpt0h6.js} +4 -4
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +605 -370
- package/package.json +7 -7
- package/prisma/migrations/20260913130237_add_asset_comment_asset_id_idx/migration.sql +2 -0
- package/prisma/migrations/20260914024424_add_asset_comment_reactions/migration.sql +22 -0
- package/prisma/migrations/20260914064432_limit_reaction_code_length/migration.sql +8 -0
- package/prisma/migrations/20260914092940_add_jpeg_preview_flags/migration.sql +5 -0
- package/prisma/schema.prisma +22 -0
- package/bin/chunk-0cmx7k4c.js +0 -1
- package/bin/chunk-16xax8kk.js +0 -1
- package/bin/chunk-2w5xqhjm.js +0 -1
- package/bin/chunk-3zkasqb8.js +0 -1
- package/bin/chunk-453ykvaw.js +0 -2
- package/bin/chunk-4mjywsj8.js +0 -3
- package/bin/chunk-5vzrpz50.js +0 -2
- package/bin/chunk-77fmkpdz.js +0 -10
- package/bin/chunk-7kjgvxqa.js +0 -2
- package/bin/chunk-7pw1550a.js +0 -2
- package/bin/chunk-7rhz2gze.js +0 -211
- package/bin/chunk-837fky18.js +0 -3
- package/bin/chunk-84as6x83.js +0 -1
- package/bin/chunk-8e28hcny.js +0 -2
- package/bin/chunk-9ccw540k.js +0 -2
- package/bin/chunk-9ybt6vbm.js +0 -1
- package/bin/chunk-avwgktxb.js +0 -2
- package/bin/chunk-d27mm390.js +0 -1
- package/bin/chunk-dj92fss9.js +0 -2
- package/bin/chunk-f6svp4dp.js +0 -2
- package/bin/chunk-fsyzs0tf.js +0 -1
- package/bin/chunk-fxecgp5k.js +0 -1
- package/bin/chunk-gc5sbfa5.js +0 -2
- package/bin/chunk-gdm6yfqq.js +0 -2
- package/bin/chunk-gye8gabk.js +0 -2
- package/bin/chunk-j2bvj2yn.js +0 -2
- package/bin/chunk-jffktpqg.js +0 -1
- package/bin/chunk-k2k9vjq6.js +0 -1
- package/bin/chunk-m9pr03kn.js +0 -2
- package/bin/chunk-mfn9qjm4.js +0 -2
- package/bin/chunk-nbdw8fen.js +0 -1
- package/bin/chunk-q806pqeh.js +0 -1
- package/bin/chunk-qka4mkmj.js +0 -2
- package/bin/chunk-rchsme43.js +0 -3
- package/bin/chunk-rqf7999q.js +0 -42
- package/bin/chunk-rssgmj7x.js +0 -2
- package/bin/chunk-t7nsgg5k.js +0 -4
- package/bin/chunk-tm7f32c7.js +0 -14
- package/bin/chunk-vy8gntez.js +0 -1
- package/bin/chunk-vyzptrea.js +0 -2
- package/bin/chunk-wdsf44hs.js +0 -2
- package/bin/chunk-x5jwwvs0.js +0 -1
- package/bin/chunk-x92cq59c.js +0 -1
- package/bin/chunk-xtf3c29c.css +0 -1
- package/bin/chunk-xx337zcw.js +0 -2
- package/bin/chunk-xz6713tj.js +0 -2
- package/bin/chunk-yfnem6se.js +0 -2
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{V,P,h,He,D,b,u,Rs,S,Z,t,o,K,L,B,Ic,Ue,A,I,vr,zn,wr,F,St,ke,ve,bt,_r,eo,Ko,vo,pe,Bt,we,Re,C,us,E,Ce,Ie,Te,he,ge,Ae,W,Vt,n,Mi,_A,mf,SA,EA,hf,CA,td,MA,kA,vm,wm,NA,DA,LA,ZA,BA,UA,jA,qA,HA,$A,VA,QA,KA,WA,YA,Em,JA,Cm,XA,Im,e0,Tm,t0,Mm,r0,km,n0,Rm,o0,Nm,s0,Dm,a0,i0,l0,Pm,c0,u0,d0,Om,Fm,Lm,Zm,f0,p0,y0,b0,v0,E0,C0,I0,R0,nd,od,zm,N0,D0,jm,P0,O0,qm,F0,_f,Hm,$m,L0,B0,sd,q0,H0,$0,K0,n_,o_,s_,a_,Vm,l_,c_,u_,d_,f_,p_,Ne,h_,A_,__,y_,v_,C_,I_,T_,M_,Wm,R_,N_,L_,B_,eh,Pc,Q_,X_,ey,ty,ny,oy,iy,cy,_y,yy,it,by,vy,Ey,Cy,Iy,ky,If,ah,Dy,hl,Zy,By,Mf,zy,jy,ch,Gy,uh,Vy,Qy,kf,Yy,Jy,rb,Rf,ob,ab,dh,cb,ub,Zs,Wo,xb,Eb,mh,ki,fd,Tb,Mb,Db,Ah,gl,Ob,pd,_h,yh,Fb,Lb,Zb,Kb,Wb,sv,av,Eh,iv,lv,uv,dv,Ch,vv,wv,xv,Sv,Ev,Cv,Iv,Mv,Th,Rv,Nv,Dv,Zv,Bv,Uv,zv,jv,qv,Kv,Jv,ow,sw,aw,iw,$f,lw,cw,Rh,uw,dw,fw,pw,mw,Nh,Dh,hw,gw,Aw,_w,Ph,yw,Oh,bw,vw,Fh,Bc,Ad,ww,xw,Lh,Sw,Ew,Cw,Iw,Tw,Mw,kw,Rw,Nw,Zh,Dw,Pw,Gf,Vf,Uw,zw,jw,Bh,qw,Hw,$w,Gw,Vw,_d,Qw,Yw,_l,Jw,ex,tx,rx,nx,ox,dx,fx,gx,Vh,Ax,Kh,Wh,bd,xx,Sx,Ex,Xf,ep,Mx,kx,Dx,Fx,Lx,Jh,Zx,Ux,oS,sS,aS,iS,eg,lS,cS,uS,fS,AS,_S,Ni,Di,Pi,yS,bS,vS,xS,CS,IS,MS,ig,jS,qS,HS,$S,cg,ug,dg,fg,GS,pg,mg,hg,gg,VS,QS,YS,XS,yg,cp,tE,nE,oE,aE,up,dp,fp,pp,uE,xd,Sd,Ed,Cd,Id,fE,pE,Td,mE,Md,hE,kd,gE,mp,Sl,hp,AE,_E,xE,SE,Rd,gp,El,Ig,Tg,$E,GE,Fo,Us,Rg,wp,Pg,Og,fC,Fg,Lg,pC,gC,AC,Bg,yC,vC,Ep,jg,LC,ZC,qg,BC,GC,VC,QC,KC,WC,YC,JC,XC,e1,t1,r1,n1,o1,s1,a1,i1,l1,c1,u1,d1,A1,E1,C1,I1,T1,M1,F1,L1,Z1,Jg,B1,eA,U1,z1,q1,rA,W1,nI,oI,sI,fI,pI,mI,hI,gI,AI,_I,yI,bI,Je,Xe,et,tt,rt,nt,ot,st,ue,ie,me,Ge,le,Tt,H,ce,Pt,k,xo,So,Qr,kn,be,mt,ht,gt,p,te,R,Ve,no,Kc,Wc,aA,Yc,ri,iA,ga,Li,Jc,_a,Q,je,Fe,Le,Ze,Be,ne,Pr,ir,hr,Et,kt,Rt,Ut,Mt}from"./chunk-jh8q3885.js";import{To,gr}from"./chunk-w1wxzqqb.js";import{Hl,$l}from"./chunk-n3xjwszr.js";import{Hs,ao,ui,Bo,bn,Gl,di,Hi,Ra,Vl}from"./chunk-3j5njrpr.js";import{Ql}from"./chunk-gqr5hxhj.js";import{Rn,Nn,Dn,br,xt,_t}from"./chunk-b6q287d1.js";import{fi}from"./chunk-teqprbd8.js";import{Co}from"./chunk-rsd164d9.js";import{Io}from"./chunk-tgr86ac4.js";import{Vn,io}from"./chunk-2jrjwaqr.js";import{vn}from"./chunk-rmzcarv9.js";import{lo}from"./chunk-yfr0hzb7.js";import{sn}from"./chunk-6y4xkcte.js";import{co}from"./chunk-80qz30dc.js";import{Rr}from"./chunk-3d5rm1d1.js";var Bs=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],Ka=I("at-sign",Bs);var qs=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],Ua=I("film",qs);var js=[["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"}]],da=I("globe",js);var Os=[["path",{d:"m2 21 9.6-9.6",key:"9l79m3"}],["path",{d:"m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19",key:"fw8biw"}],["circle",{cx:"15.5",cy:"7.5",r:"5.5",key:"4wxmhb"}]],Zt=I("key",Os);var $s=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Ca=I("layout-dashboard",$s);var zs=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Ga=I("maximize-2",zs);var Qs=[["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"}]],Ha=I("message-circle",Qs);var Ks=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],Wa=I("move",Ks);var Gs=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],wt=I("puzzle",Gs);var Ws=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],ca=I("refresh-cw",Ws);var Xs=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Za=I("shield-check",Xs);var Ys=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],ma=I("video",Ys);var Js=[["path",{d:"M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z",key:"1v7up4"}]],jt=I("zap",Js);var er=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Xa=I("zoom-in",er);var tr=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Ya=I("zoom-out",tr);S();S();var ar=us("group/field flex w-full gap-3 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],horizontal:["flex-row items-center","[&>[data-slot=field-label]]:flex-auto","has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"],responsive:["flex-col @md/field-group:flex-row @md/field-group:items-center [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto","@md/field-group:[&>[data-slot=field-label]]:flex-auto","@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"]}},defaultVariants:{orientation:"vertical"}});function Oe({className:e,orientation:r="vertical",...a}){return t("div",{role:"group","data-slot":"field","data-orientation":r,className:C(ar({orientation:r}),e),...a})}function $e({className:e,...r}){return t(Q,{"data-slot":"field-label",className:C("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4","has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10",e),...r})}function aa({className:e,...r}){return t("p",{"data-slot":"field-description",className:C("text-sm leading-normal font-normal text-muted-foreground group-has-[[data-orientation=horizontal]]/field:text-balance","last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5","[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",e),...r})}function Qe({className:e,children:r,errors:a,...l}){let s=D(()=>{if(r)return r;if(!a?.length)return null;let d=[...new Map(a.map((c)=>[c?.message,c])).values()];if(d?.length==1)return d[0]?.message;return t("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:d.map((c,f)=>c?.message&&t("li",{children:c.message},f))})},[r,a]);if(!s)return null;return t("div",{role:"alert","data-slot":"field-error",className:C("text-sm font-normal text-destructive",e),...l,children:s})}function Ja({update:e,notify:r,unwatched:a}){return{link:l,unlink:s,propagate:d,checkDirty:c,shallowPropagate:f};function l(g,y,x){let m=y.depsTail;if(m!==void 0&&m.dep===g)return;let i=m!==void 0?m.nextDep:y.deps;if(i!==void 0&&i.dep===g){i.version=x,y.depsTail=i;return}let v=g.subsTail;if(v!==void 0&&v.version===x&&v.sub===y)return;let w=y.depsTail=g.subsTail={version:x,dep:g,sub:y,prevDep:m,nextDep:i,prevSub:v,nextSub:void 0};if(i!==void 0)i.prevDep=w;if(m!==void 0)m.nextDep=w;else y.deps=w;if(v!==void 0)v.nextSub=w;else g.subs=w}function s(g,y=g.sub){let{dep:x,prevDep:m,nextDep:i,nextSub:v,prevSub:w}=g;if(i!==void 0)i.prevDep=m;else y.depsTail=m;if(m!==void 0)m.nextDep=i;else y.deps=i;if(v!==void 0)v.prevSub=w;else x.subsTail=w;if(w!==void 0)w.nextSub=v;else if((x.subs=v)===void 0)a(x);return i}function d(g){let y=g.nextSub,x;e:do{let m=g.sub,i=m.flags;if(!(i&60))m.flags=i|32;else if(!(i&12))i=0;else if(!(i&4))m.flags=i&-9|32;else if(!(i&48)&&_(g,m))m.flags=i|40,i&=1;else i=0;if(i&2)r(m);if(i&1){let v=m.subs;if(v!==void 0){let w=(g=v).nextSub;if(w!==void 0)x={value:y,prev:x},y=w;continue}}if((g=y)!==void 0){y=g.nextSub;continue}while(x!==void 0)if(g=x.value,x=x.prev,g!==void 0){y=g.nextSub;continue e}break}while(!0)}function c(g,y){let x,m=0,i=!1;e:do{let v=g.dep,w=v.flags;if(y.flags&16)i=!0;else if((w&17)===17){if(e(v)){let M=v.subs;if(M.nextSub!==void 0)f(M);i=!0}}else if((w&33)===33){if(g.nextSub!==void 0||g.prevSub!==void 0)x={value:g,prev:x};g=v.deps,y=v,++m;continue}if(!i){let M=g.nextDep;if(M!==void 0){g=M;continue}}while(m--){let M=y.subs,O=M.nextSub!==void 0;if(O)g=x.value,x=x.prev;else g=M;if(i){if(e(y)){if(O)f(M);y=g.sub;continue}i=!1}else y.flags&=-33;y=g.sub;let Y=g.nextDep;if(Y!==void 0){g=Y;continue e}}return i}while(!0)}function f(g){do{let y=g.sub,x=y.flags;if((x&48)===32){if(y.flags=x|16,(x&6)===2)r(y)}}while((g=g.nextSub)!==void 0)}function _(g,y){let x=y.depsTail;while(x!==void 0){if(x===g)return!0;x=x.prevDep}return!1}}function sa(e,r,a){let l=typeof e==="object",s=l?e:void 0;return{next:(l?e.next:e)?.bind(s),error:(l?e.error:r)?.bind(s),complete:(l?e.complete:a)?.bind(s)}}var ka=[],pa=0,{link:es,unlink:sr,propagate:rr,checkDirty:as,shallowPropagate:ts}=Ja({update(e){return e._update()},notify(e){ka[Ma++]=e,e.flags&=-3},unwatched(e){if(e.depsTail!==void 0)e.depsTail=void 0,e.flags=17,fa(e)}}),ua=0,Ma=0,Nt,Fa=0;function ze(e){try{++Fa,e()}finally{if(!--Fa)Da()}}function fa(e){let r=e.depsTail,a=r!==void 0?r.nextDep:e.deps;while(a!==void 0)a=sr(a,e)}function Da(){if(Fa>0)return;while(ua<Ma){let e=ka[ua];ka[ua++]=void 0,e.notify()}ua=0,Ma=0}function ha(e,r){let a=typeof e==="function",l=e,s={_snapshot:a?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:a?0:1,get(){if(Nt!==void 0)es(s,Nt,pa);return s._snapshot},subscribe(d){let c=sa(d),f={current:!1},_=or(()=>{if(s.get(),!f.current)f.current=!0;else c.next?.(s._snapshot)});return{unsubscribe:()=>{_.stop()}}},_update(d){let c=Nt,f=r?.compare??Object.is;if(a)Nt=s,++pa,s.depsTail=void 0;else if(d===void 0)return!1;if(a)s.flags=5;try{let _=s._snapshot,g=typeof d==="function"?d(_):d===void 0&&a?l(_):d;if(_===void 0||!f(_,g))return s._snapshot=g,!0;return!1}finally{if(Nt=c,a)s.flags&=-5;fa(s)}}};if(a)s.flags=17,s.get=function(){let d=s.flags;if(d&16||d&32&&as(s.deps,s)){if(s._update()){let c=s.subs;if(c!==void 0)ts(c)}}else if(d&32)s.flags=d&-33;if(Nt!==void 0)es(s,Nt,pa);return s._snapshot};else s.set=function(d){if(s._update(d)){let c=s.subs;if(c!==void 0)rr(c),ts(c),Da()}};return s}function or(e){let r=()=>{let l=Nt;Nt=a,++pa,a.depsTail=void 0,a.flags=6;try{return e()}finally{Nt=l,a.flags&=-5,fa(a)}},a={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let l=this.flags;if(l&16||l&32&&as(this.deps,this))r();else this.flags=2},stop(){this.flags=0,this.depsTail=void 0,fa(this)}};return r(),a}var Aa=class{constructor(e,r){if(this.atom=ha(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),r)this.actions=r(this)}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(sa(e))}},ss=class{constructor(e){this.atom=ha(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(sa(e))}};function Ct(e,r){if(typeof e==="function")return new ss(e);if(r)return new Aa(e,r);return new Aa(e)}var rs=class{constructor(e,r){if(this.fn=e,this.options=r,this.lastExecutionTime=0,this.isPending=!1,this.maybeExecute=(...a)=>{let l=Date.now()-this.lastExecutionTime;if(this.options.leading&&l>=this.options.wait)this.execute(...a);else if(this.lastArgs=a,!this.timeoutId&&this.options.trailing){let s=this.options.wait-l;this.isPending=!0,this.timeoutId=setTimeout(()=>{if(this.lastArgs!==void 0)this.execute(...this.lastArgs)},s)}},this.execute=(...a)=>{this.fn(...a),this.options.onExecute?.(a,this),this.lastExecutionTime=Date.now(),this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.flush=()=>{if(this.isPending&&this.lastArgs)this.execute(...this.lastArgs)},this.cancel=()=>{this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.clearTimeout=()=>{if(this.timeoutId)clearTimeout(this.timeoutId),this.timeoutId=void 0},this.options.leading===void 0&&this.options.trailing===void 0)this.options.leading=!0,this.options.trailing=!0}};function Ia(e,r){return new rs(e,r).maybeExecute}var Ea=class{#o=!0;#t;#e;#m;#a;#n;#s;#l;#u=0;#f=5;#i=!1;#d=!1;#r=null;#p=()=>{this.debugLog("Connected to event bus"),this.#n=!0,this.#i=!1,this.debugLog("Emitting queued events",this.#a),this.#a.forEach((e)=>this.emitEventToBus(e)),this.#a=[],this.stopConnectLoop(),this.#e().removeEventListener("tanstack-connect-success",this.#p)};#c=()=>{if(this.#u<this.#f){this.#u++,this.dispatchCustomEvent("tanstack-connect",{});return}this.#e().removeEventListener("tanstack-connect",this.#c),this.#d=!0,this.debugLog("Max retries reached, giving up on connection"),this.stopConnectLoop()};#g=()=>{if(this.#i)return;this.#i=!0,this.#e().addEventListener("tanstack-connect-success",this.#p),this.#c()};constructor({pluginId:e,debug:r=!1,enabled:a=!0,reconnectEveryMs:l=300}){this.#t=e,this.#o=a,this.#e=this.getGlobalTarget,this.#m=r,this.debugLog(" Initializing event subscription for plugin",this.#t),this.#a=[],this.#n=!1,this.#d=!1,this.#s=null,this.#l=l}startConnectLoop(){if(this.#s!==null||this.#n)return;this.debugLog(`Starting connect loop (every ${this.#l}ms)`),this.#s=setInterval(this.#c,this.#l)}stopConnectLoop(){if(this.#i=!1,this.#s===null)return;clearInterval(this.#s),this.#s=null,this.#a=[],this.debugLog("Stopped connect loop")}debugLog(...e){if(this.#m)console.log(`\uD83C\uDF34 [tanstack-devtools:${this.#t}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<"u"&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog("Using global event target"),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<"u"&&typeof window.addEventListener<"u")return this.debugLog("Using window as event target"),window;let e=typeof EventTarget<"u"?new EventTarget:void 0;if(typeof e>"u"||typeof e.addEventListener>"u")return this.debugLog("No event mechanism available, running in non-web environment"),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1};return this.debugLog("Using new EventTarget as fallback"),e}getPluginId(){return this.#t}dispatchCustomEventShim(e,r){try{let a=new Event(e,{detail:r});this.#e().dispatchEvent(a)}catch(a){this.debugLog("Failed to dispatch shim event")}}dispatchCustomEvent(e,r){try{this.#e().dispatchEvent(new CustomEvent(e,{detail:r}))}catch(a){this.dispatchCustomEventShim(e,r)}}emitEventToBus(e){this.debugLog("Emitting event to client bus",e),this.dispatchCustomEvent("tanstack-dispatch-event",e)}createEventPayload(e,r){return{type:`${this.#t}:${e}`,payload:r,pluginId:this.#t}}emit(e,r){if(!this.#o){this.debugLog("Event bus client is disabled, not emitting event",e,r);return}if(this.#r)this.debugLog("Emitting event to internal event target",e,r),this.#r.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,r)}));if(this.#d){this.debugLog("Previously failed to connect, not emitting to bus");return}if(!this.#n){if(this.debugLog("Bus not available, will be pushed as soon as connected"),this.#a.push(this.createEventPayload(e,r)),typeof CustomEvent<"u"&&!this.#i)this.#g(),this.startConnectLoop();return}return this.emitEventToBus(this.createEventPayload(e,r))}on(e,r,a){let l=a?.withEventTarget??!1,s=`${this.#t}:${e}`;if(l){if(!this.#r)this.#r=new EventTarget;this.#r.addEventListener(s,(c)=>{r(c.detail)})}if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event",s),()=>{};let d=(c)=>{this.debugLog("Received event from bus",c.detail),r(c.detail)};return this.#e().addEventListener(s,d),this.debugLog("Registered event to bus",s),()=>{if(l)this.#r?.removeEventListener(s,d);this.#e().removeEventListener(s,d)}}onAll(e){if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event"),()=>{};let r=(a)=>{let l=a.detail;e(l)};return this.#e().addEventListener("tanstack-devtools-global",r),()=>this.#e().removeEventListener("tanstack-devtools-global",r)}onAllPluginEvents(e){if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event"),()=>{};let r=(a)=>{let l=a.detail;if(this.#t&&l.pluginId!==this.#t)return;e(l)};return this.#e().addEventListener("tanstack-devtools-global",r),()=>this.#e().removeEventListener("tanstack-devtools-global",r)}};class os extends Ea{constructor(){super({pluginId:"form-devtools",reconnectEveryMs:1000})}}var ut=new os;function Ft(e,r){return typeof e==="function"?e(r):e}function Xt(e,r){return ya(r).reduce((l,s)=>{if(l===null)return null;if(typeof l<"u")return l[s];return},e)}function Kt(e,r,a){let l=ya(r);function s(d){if(!l.length)return Ft(a,d);let c=l.shift();if(typeof c==="string"||typeof c==="number"&&!Array.isArray(d)){if(typeof d==="object"){if(d===null)d={};return{...d,[c]:s(d[c])}}return{[c]:s()}}if(Array.isArray(d)&&typeof c==="number"){let f=d.slice(0,c);return[...f.length?f:Array(c),s(d[c]),...d.slice(c+1)]}return[...Array(c),s()]}return s(e)}function La(e,r){let a=ya(r);function l(s){if(!s)return;if(a.length===1){let c=a[0];if(Array.isArray(s)&&typeof c==="number")return s.filter((g,y)=>y!==c);let{[c]:f,..._}=s;return _}let d=a.shift();if(typeof d==="string"||typeof d==="number"&&!Array.isArray(s)){if(typeof s==="object")return{...s,[d]:l(s[d])}}if(typeof d==="number"){if(Array.isArray(s)){if(d>=s.length)return s;let c=s.slice(0,d);return[...c.length?c:Array(d),l(s[d]),...s.slice(d+1)]}}throw Error("It seems we have created an infinite loop in deleteBy. ")}return l(e)}var is=46,Ta=91,Va=93,ns=48,nr=57;function ya(e){if(Array.isArray(e))return[...e];if(typeof e!=="string")throw Error("Path must be a string.");let r=e.length,a=[],l=r>0&&e.charCodeAt(0)===Ta?1:0,s=!0,d=-1;for(let c=l;c<=r;c++){let f=c<r?e.charCodeAt(c):-1;if(c===r||f===is||f===Ta||f===Va){let _=c-l;if(_>0){let g=s&&(_===1||e.charCodeAt(l)!==ns),y=e.slice(l,c);if(g){let x=parseInt(y,10);if(_<=15||String(x)===y)a.push(x);else a.push(y)}else a.push(y)}else if(d!==Va&&!(d===-1&&f===Va)&&!(d===f&&(f===is||f===Ta)))a.push("");l=c+1,s=!0}else if(f<ns||f>nr)s=!1;d=f}if(!a.length)a.push("");return a}function Pa(e){return!(Array.isArray(e)&&e.length===0)}function At(e,r){let a=(l)=>l.validators.filter(Boolean).map((s)=>({cause:s.cause,validate:s.fn}));return r.validationLogic({form:r.form,group:r.group,validators:r.validators,event:{type:e,fieldName:r.fieldName,async:!1},runValidation:a})}function It(e,r){let{asyncDebounceMs:a}=r,{onBlurAsyncDebounceMs:l,onChangeAsyncDebounceMs:s,onDynamicAsyncDebounceMs:d}=r.validators||{},c=a??0,f=(_)=>_.validators.filter(Boolean).map((g)=>{let y=g?.cause||e,x=c;switch(y){case"change":x=s??c;break;case"blur":x=l??c;break;case"dynamic":x=d??c;break;case"submit":x=0;break}if(e==="submit")x=0;return{cause:y,validate:g.fn,debounceMs:x}});return r.validationLogic({form:r.form,group:r.group,validators:r.validators,event:{type:e,fieldName:r.fieldName,async:!0},runValidation:f})}var Yt=(e)=>!!e&&typeof e==="object"&&("fields"in e);function pt(e,r){if(Object.is(e,r))return!0;if(typeof e!=="object"||e===null||typeof r!=="object"||r===null)return!1;if(e instanceof Date&&r instanceof Date)return e.getTime()===r.getTime();if(e instanceof Map&&r instanceof Map){if(e.size!==r.size)return!1;for(let[s,d]of e)if(!r.has(s)||!Object.is(d,r.get(s)))return!1;return!0}if(e instanceof Set&&r instanceof Set){if(e.size!==r.size)return!1;for(let s of e)if(!r.has(s))return!1;return!0}let a=Object.keys(e),l=Object.keys(r);if(a.length!==l.length)return!1;if(a.length===0&&!Array.isArray(e)&&!Array.isArray(r)&&(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(r)!==Object.prototype))return!1;for(let s of a)if(!l.includes(s)||!pt(e[s],r[s]))return!1;return!0}var Jt=({newFormValidatorError:e,isPreviousErrorFromFormValidator:r,previousErrorValue:a})=>{if(e)return{newErrorValue:e,newSource:"form"};if(r)return{newErrorValue:void 0,newSource:void 0};if(a)return{newErrorValue:a,newSource:"field"};return{newErrorValue:void 0,newSource:void 0}},Gt=({formLevelError:e,fieldLevelError:r})=>{if(r)return{newErrorValue:r,newSource:"field"};if(e)return{newErrorValue:e,newSource:"form"};return{newErrorValue:void 0,newSource:void 0}};function Ke(e,r){if(e===void 0||e===null)return r;return{...e,...r}}var zt=256,ba=[],va;while(zt--)ba[zt]=(zt+256).toString(16).substring(1);function ra(){let e=0,r,a="";if(!va||zt+16>256){va=Array(256),e=256;while(e--)va[e]=256*Math.random()|0;e=0,zt=0}for(;e<16;e++){if(r=va[zt+e],e===6)a+=ba[r&15|64];else if(e===8)a+=ba[r&63|128];else a+=ba[r];if(e&1&&e>1&&e<11)a+="-"}return zt++,a}var Ba=Ia((e)=>ut.emit("form-state",{id:e.formId,state:e.store.state}),{wait:300});function Qt(e){if(e===null||typeof e!=="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let a=[];for(let l=0;l<e.length;l++)a[l]=Qt(e[l]);return a}if(e instanceof Map){let a=new Map;return e.forEach((l,s)=>{a.set(s,Qt(l))}),a}if(e instanceof Set){let a=new Set;return e.forEach((l)=>{a.add(Qt(l))}),a}let r={};for(let a in e)if(Object.prototype.hasOwnProperty.call(e,a))r[a]=Qt(e[a]);return r}function vt(e,r){return r===e||r.startsWith(`${e}.`)||r.startsWith(`${e}[`)}var ft=(e)=>{if(!e.validators)return e.runValidation({validators:[],form:e.form});let r=e.event.async,a=r?void 0:{fn:e.validators.onMount,cause:"mount"},l={fn:r?e.validators.onChangeAsync:e.validators.onChange,cause:"change"},s={fn:r?e.validators.onBlurAsync:e.validators.onBlur,cause:"blur"},d={fn:r?e.validators.onSubmitAsync:e.validators.onSubmit,cause:"submit"},c=r?void 0:{fn:()=>{return},cause:"server"};switch(e.event.type){case"mount":return e.runValidation({validators:[a],form:e.form});case"submit":return e.runValidation({validators:[l,s,d,c],form:e.form});case"server":return e.runValidation({validators:[],form:e.form});case"blur":return e.runValidation({validators:[s,c],form:e.form});case"change":return e.runValidation({validators:[l,c],form:e.form});default:throw Error(`Unknown validation event type: ${e.event.type}`)}};function lr(e,r){let a=new Map;for(let l of e){let s=l.path??[],d=r,c="";for(let f=0;f<s.length;f++){let _=s[f];if(_===void 0)continue;let g=typeof _==="object"?_.key:_,y=Number(g);if(Array.isArray(d)&&!Number.isNaN(y))c+=`[${y}]`;else c+=(f>0?".":"")+String(g);if(typeof d==="object"&&d!==null)d=d[g];else d=void 0}a.set(c,(a.get(c)??[]).concat(l))}return Object.fromEntries(a)}var ls=(e,r)=>{let a=lr(e,r);return{form:a,fields:a}},Dt={validate({value:e,validationSource:r},a){let l=a["~standard"].validate(e);if(l instanceof Promise)throw Error("async function passed to sync validator");if(!l.issues)return;if(r==="field")return l.issues;return ls(l.issues,e)},async validateAsync({value:e,validationSource:r},a){let l=await a["~standard"].validate(e);if(!l.issues)return;if(r==="field")return l.issues;return ls(l.issues,e)}},ea=(e)=>!!e&&("~standard"in e);var We={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{},_arrayVersion:0,_pendingValidationsCount:0};function Lt(e){function r(x){let m=e.getFieldMeta(x)??We;e.setFieldMeta(x,{...m,_arrayVersion:(m._arrayVersion||0)+1})}function a(x,m,i){r(x);let v=f(x,m,"move",i),w=Math.min(m,i),M=Math.max(m,i);for(let Y=w;Y<=M;Y++)v.push(c(x,Y));let O=Object.keys(e.fieldInfo).reduce((Y,z)=>{if(z.startsWith(c(x,m)))Y.set(z,e.getFieldMeta(z));return Y},new Map);g(v,m<i?"up":"down"),Object.keys(e.fieldInfo).filter((Y)=>Y.startsWith(c(x,i))).forEach((Y)=>{let z=Y.replace(c(x,i),c(x,m)),oe=O.get(z);if(oe)e.setFieldMeta(Y,oe)})}function l(x,m){r(x);let i=f(x,m,"remove");g(i,"up")}function s(x,m,i){r(x),f(x,m,"swap",i).forEach((w)=>{if(!w.toString().startsWith(c(x,m)))return;let M=w.toString().replace(c(x,m),c(x,i)),[O,Y]=[e.getFieldMeta(w),e.getFieldMeta(M)];if(O)e.setFieldMeta(M,O);if(Y)e.setFieldMeta(w,Y)})}function d(x,m){r(x);let i=f(x,m,"insert");g(i,"down"),i.forEach((v)=>{if(v.toString().startsWith(c(x,m)))e.setFieldMeta(v,y())})}function c(x,m){return`${x}[${m}]`}function f(x,m,i,v){let w=[c(x,m)];switch(i){case"swap":w.push(c(x,v));break;case"move":{let[M,O]=[Math.min(m,v),Math.max(m,v)];for(let Y=M;Y<=O;Y++)w.push(c(x,Y));break}default:{let M=e.getFieldValue(x),O=Array.isArray(M)?M.length:0;for(let Y=m+1;Y<O;Y++)w.push(c(x,Y));break}}return Object.keys(e.fieldInfo).filter((M)=>w.some((O)=>M.startsWith(O)))}function _(x,m){return x.replace(/\[(\d+)\]/,(i,v)=>{let w=parseInt(v,10);return`[${m==="up"?w+1:Math.max(0,w-1)}]`})}function g(x,m){(m==="up"?x:[...x].reverse()).forEach((v)=>{let w=_(v.toString(),m),M=e.getFieldMeta(w);if(M)e.setFieldMeta(v,M);else e.setFieldMeta(v,y())})}let y=()=>We;return{bumpArrayVersion:r,handleArrayMove:a,handleArrayRemove:l,handleArraySwap:s,handleArrayInsert:d}}function qa(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},formGroupStateBase:e.formGroupStateBase??{},isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}}}class ia{constructor(e){this.options={},this.fieldInfo={},this.formGroupApis=new Set,this.mount=()=>{let s=this.store.subscribe(()=>{Ba(this)}),d=ut.on("request-form-state",(y)=>{if(y.payload.id===this._formId)ut.emit("form-api",{id:this._formId,state:this.store.state,options:this.options})}),c=ut.on("request-form-reset",(y)=>{if(y.payload.id===this._formId)this.reset()}),f=ut.on("request-form-force-submit",(y)=>{if(y.payload.id===this._formId)this._devtoolsSubmissionOverride=!0,this.handleSubmit(),this._devtoolsSubmissionOverride=!1}),_=()=>{f(),c(),d(),s.unsubscribe(),ut.emit("form-unmounted",{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});let{onMount:g}=this.options.validators||{};if(ut.emit("form-api",{id:this._formId,state:this.store.state,options:this.options}),!g)return _;return this.validateSync("mount"),_},this.update=(s)=>{if(!s)return;let d=this.options;this.options=s;let c=s.defaultValues&&!pt(s.defaultValues,d.defaultValues)&&!this.state.isTouched,f=!pt(s.defaultState,d.defaultState)&&!this.state.isTouched;if(!c&&!f)return;if(ze(()=>{this.baseStore.setState(()=>qa(Object.assign({},this.state,f?s.defaultState:{},c?{values:s.defaultValues}:{})))}),c){let _=Lt(this);for(let g of Object.keys(this.fieldInfo))if(Array.isArray(this.getFieldValue(g)))_.bumpArrayVersion(g)}ut.emit("form-api",{id:this._formId,state:this.store.state,options:this.options})},this.reset=(s,d)=>{let{fieldMeta:c}=this.state,f=this.resetFieldMeta(c);if(s&&!d?.keepDefaultValues)this.options={...this.options,defaultValues:s};this.baseStore.setState(()=>{let _=s??this.options.defaultValues??this.options.defaultState?.values;if(!s)Object.values(this.fieldInfo).forEach((g)=>{if(g.instance&&g.instance.options.defaultValue!==void 0)_=Kt(_,g.instance.name,g.instance.options.defaultValue)});return qa({...this.options.defaultState,values:_,fieldMetaBase:f})})},this.validateAllFields=async(s)=>{let d=[];return ze(()=>{Object.values(this.fieldInfo).forEach((f)=>{if(!f.instance)return;let _=f.instance;if(d.push(Promise.resolve().then(()=>_.validate(s,{skipFormValidation:!0,skipGroupValidation:!0}))),!f.instance.store.state.meta.isTouched)f.instance.setMeta((g)=>({...g,isTouched:!0}))})}),(await Promise.all(d)).flat()},this.validateArrayFieldsStartingFrom=async(s,d,c)=>{let f=this.getFieldValue(s),_=Array.isArray(f)?Math.max(f.length-1,0):null,g=[`${s}[${d}]`];for(let i=d+1;i<=(_??0);i++)g.push(`${s}[${i}]`);let y=Object.keys(this.fieldInfo).filter((i)=>g.some((v)=>i.startsWith(v))),x=[];return ze(()=>{y.forEach((i)=>{x.push(Promise.resolve().then(()=>this.validateField(i,c)))})}),(await Promise.all(x)).flat()},this.validateField=(s,d)=>{let c=this.fieldInfo[s]?.instance;if(!c){let{hasErrored:f}=this.validateSync(d);if(f&&!this.options.asyncAlways)return this.getFieldMeta(s)?.errors??[];return this.validateAsync(d).then(()=>this.getFieldMeta(s)?.errors??[])}if(!c.store.state.meta.isTouched)c.setMeta((f)=>({...f,isTouched:!0}));return c.validate(d)},this.validateSync=(s,d)=>{let c=At(s,{...this.options,form:this,group:d?.group,validationLogic:this.options.validationLogic||ft}),f=!1,_={};return ze(()=>{for(let x of c){if(!x.validate)continue;let m=this.runValidator({validate:x.validate,value:{value:this.state.values,formApi:this,validationSource:"form"},type:"validate"}),{formError:i,fieldErrors:v}=xa(m),w=oa(x.cause),M=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(v||{})]);if(d?.filterFieldNames)M=new Set([...M].filter(d.filterFieldNames));for(let O of M){if(this.baseStore.state.fieldMetaBase[O]===void 0&&!v?.[O])continue;let Y=this.getFieldMeta(O)??We,{errorMap:z,errorSourceMap:oe}=Y,re=v?.[O],{newErrorValue:T,newSource:q}=Jt({newFormValidatorError:re,isPreviousErrorFromFormValidator:oe?.[w]==="form",previousErrorValue:z?.[w]});if(q==="form")_[O]={..._[O],[w]:re};if(z?.[w]!==T)this.setFieldMeta(O,(j=We)=>({...j,errorMap:{...j.errorMap,[w]:T},errorSourceMap:{...j.errorSourceMap,[w]:q}}))}if(!d?.dontUpdateFormErrorMap){if(this.state.errorMap?.[w]!==i)this.baseStore.setState((O)=>({...O,errorMap:{...O.errorMap,[w]:i}}))}if(i||v)f=!0}if(d?.dontUpdateFormErrorMap)return;let g=oa("submit");if(this.state.errorMap?.[g]&&s!=="submit"&&!f)this.baseStore.setState((x)=>({...x,errorMap:{...x.errorMap,[g]:void 0}}));let y=oa("server");if(this.state.errorMap?.[y]&&s!=="server"&&!f)this.baseStore.setState((x)=>({...x,errorMap:{...x.errorMap,[y]:void 0}}))}),{hasErrored:f,fieldsErrorMap:_}},this.validateAsync=async(s,d)=>{let c=It(s,{...this.options,form:this,group:d?.group,validationLogic:this.options.validationLogic||ft});if(!this.state.isFormValidating)this.baseStore.setState((x)=>({...x,isFormValidating:!0}));let f=[],_;for(let x of c){if(!x.validate)continue;let m=oa(x.cause);this.state.validationMetaMap[m]?.lastAbortController.abort();let v=new AbortController;this.state.validationMetaMap[m]={lastAbortController:v},f.push(new Promise(async(w)=>{let M;try{M=await new Promise((T,q)=>{setTimeout(async()=>{if(v.signal.aborted)return T(void 0);try{T(await this.runValidator({validate:x.validate,value:{value:this.state.values,formApi:this,validationSource:"form",signal:v.signal},type:"validateAsync"}))}catch(j){q(j)}},x.debounceMs)})}catch(T){M=T}let{formError:O,fieldErrors:Y}=xa(M);if(Y)_=_?{..._,...Y}:Y;let z=oa(x.cause),oe=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(_||{})]),re=Array.from(oe);if(d?.filterFieldNames)re=re.filter(d.filterFieldNames);for(let T of re){if(this.baseStore.state.fieldMetaBase[T]===void 0&&!_?.[T])continue;let q=this.getFieldMeta(T)??We,{errorMap:j,errorSourceMap:G}=q,N=_?.[T],{newErrorValue:X,newSource:xe}=Jt({newFormValidatorError:N,isPreviousErrorFromFormValidator:G?.[z]==="form",previousErrorValue:j?.[z]});if(j?.[z]!==X)this.setFieldMeta(T,(ye=We)=>({...ye,errorMap:{...ye.errorMap,[z]:X},errorSourceMap:{...ye.errorSourceMap,[z]:xe}}))}if(!d?.dontUpdateFormErrorMap)this.baseStore.setState((T)=>({...T,errorMap:{...T.errorMap,[z]:O}}));w(_?{fieldErrors:_,errorMapKey:z}:void 0)}))}let g=[],y={};if(f.length){g=await Promise.all(f);for(let x of g)if(x?.fieldErrors){let{errorMapKey:m}=x;for(let[i,v]of Object.entries(x.fieldErrors)){let M={...y[i]||{},[m]:v};y[i]=M}}}return this.baseStore.setState((x)=>({...x,isFormValidating:!1})),y},this.validate=(s,d)=>{let{hasErrored:c,fieldsErrorMap:f}=this.validateSync(s,d);if(c&&!this.options.asyncAlways)return f;return this.validateAsync(s,d)},this._handleSubmit=async(s)=>{this.baseStore.setState((f)=>({...f,isSubmitted:!1,submissionAttempts:f.submissionAttempts+1,isSubmitSuccessful:!1})),ze(()=>{Object.values(this.fieldInfo).forEach((f)=>{if(!f.instance)return;if(!f.instance.store.state.meta.isTouched)f.instance.setMeta((_)=>({..._,isTouched:!0}))})});let d=s??this.options.onSubmitMeta;if(!this.state.canSubmit&&!this._devtoolsSubmissionOverride){if(this.baseStore.state.submissionAttempts<=1){this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:d});return}}this.baseStore.setState((f)=>({...f,isSubmitting:!0}));let c=()=>{this.baseStore.setState((f)=>({...f,isSubmitting:!1}))};if(await this.validateAllFields("submit"),!this.state.isFieldsValid){c(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:d}),ut.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"validateAllFields",errors:Object.values(this.state.fieldMeta).map((f)=>f.errors).flat()});return}if(await this.validate("submit"),!this.state.isValid){c(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:d}),ut.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"validate",errors:this.state.errors});return}ze(()=>{Object.values(this.fieldInfo).forEach((f)=>{f.instance?.triggerOnSubmitListener()})}),this.options.listeners?.onSubmit?.({formApi:this,meta:d});try{await this.options.onSubmit?.({value:this.state.values,formApi:this,meta:d}),ze(()=>{this.baseStore.setState((f)=>({...f,isSubmitted:!0,isSubmitSuccessful:!0})),ut.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),c()})}catch(f){throw this.baseStore.setState((_)=>({..._,isSubmitSuccessful:!1})),ut.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"inflight",onError:f}),c(),f}},this.getFieldValue=(s)=>Xt(this.state.values,s),this.getFieldMeta=(s)=>this.state.fieldMeta[s],this.getFormGroupMeta=(s)=>this.formGroupMetaDerived.state[s],this.getFieldInfo=(s)=>this.fieldInfo[s]||={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.setFieldMeta=(s,d)=>{this.baseStore.setState((c)=>({...c,fieldMetaBase:{...c.fieldMetaBase,[s]:Ft(d,c.fieldMetaBase[s])}}))},this.resetFieldMeta=(s)=>Object.keys(s).reduce((d,c)=>{let f=c;return d[f]=We,d},{}),this.setFieldValue=(s,d,c)=>{let f=c?.dontUpdateMeta??!1,_=c?.dontRunListeners??!1,g=c?.dontValidate??!1;if(ze(()=>{if(!f)this.setFieldMeta(s,(y)=>({...y,isTouched:!0,isDirty:!0,errorMap:{...y?.errorMap,onMount:void 0}}));this.baseStore.setState((y)=>({...y,values:Kt(y.values,s,d)}))}),!_)this.getFieldInfo(s).instance?.triggerOnChangeListener();if(!g)this.validateField(s,"change")},this.deleteField=(s)=>{let c=[...Object.keys(this.fieldInfo).filter((f)=>{let _=s.toString();return f.startsWith(`${_}.`)||f.startsWith(`${_}[`)}),s];this.baseStore.setState((f)=>{let _={...f};return c.forEach((g)=>{_.values=La(_.values,g),delete this.fieldInfo[g],delete _.fieldMetaBase[g]}),_})},this.pushFieldValue=(s,d,c)=>{this.setFieldValue(s,(f)=>[...Array.isArray(f)?f:[],d],c),Lt(this).bumpArrayVersion(s)},this.insertFieldValue=async(s,d,c,f)=>{this.setFieldValue(s,(g)=>[...g.slice(0,d),c,...g.slice(d)],Ke(f,{dontValidate:!0}));let _=f?.dontValidate??!1;if(!_)await this.validateField(s,"change");if(Lt(this).handleArrayInsert(s,d),!_)await this.validateArrayFieldsStartingFrom(s,d,"change")},this.replaceFieldValue=async(s,d,c,f)=>{if(this.setFieldValue(s,(g)=>g.map((y,x)=>x===d?c:y),Ke(f,{dontValidate:!0})),Lt(this).bumpArrayVersion(s),!(f?.dontValidate??!1))await this.validateField(s,"change"),await this.validateArrayFieldsStartingFrom(s,d,"change")},this.removeFieldValue=async(s,d,c)=>{let f=this.getFieldValue(s),_=Array.isArray(f)?Math.max(f.length-1,0):null;if(this.setFieldValue(s,(y)=>y.filter((x,m)=>m!==d),Ke(c,{dontValidate:!0})),Lt(this).handleArrayRemove(s,d),_!==null){let y=`${s}[${_}]`;this.deleteField(y)}if(!(c?.dontValidate??!1))await this.validateField(s,"change"),await this.validateArrayFieldsStartingFrom(s,d,"change")},this.swapFieldValues=(s,d,c,f)=>{if(this.setFieldValue(s,(g)=>{let y=g[d],x=g[c];return Kt(Kt(g,`${d}`,x),`${c}`,y)},Ke(f,{dontValidate:!0})),Lt(this).handleArraySwap(s,d,c),!(f?.dontValidate??!1))this.validateField(s,"change"),this.validateField(`${s}[${d}]`,"change"),this.validateField(`${s}[${c}]`,"change")},this.moveFieldValues=(s,d,c,f)=>{if(this.setFieldValue(s,(g)=>{let y=[...g];return y.splice(c,0,y.splice(d,1)[0]),y},Ke(f,{dontValidate:!0})),Lt(this).handleArrayMove(s,d,c),!(f?.dontValidate??!1))this.validateField(s,"change"),this.validateField(`${s}[${d}]`,"change"),this.validateField(`${s}[${c}]`,"change")},this.clearFieldValues=(s,d)=>{let c=this.getFieldValue(s),f=Array.isArray(c)?Math.max(c.length-1,0):null;if(this.setFieldValue(s,[],Ke(d,{dontValidate:!0})),Lt(this).bumpArrayVersion(s),f!==null)for(let g=0;g<=f;g++){let y=`${s}[${g}]`;this.deleteField(y)}if(!(d?.dontValidate??!1))this.validateField(s,"change")},this.resetField=(s)=>{this.baseStore.setState((d)=>{let c=this.getFieldInfo(s).instance?.options.defaultValue,f=Xt(this.options.defaultValues,s),_=c??f;return{...d,fieldMetaBase:{...d.fieldMetaBase,[s]:We},values:_!==void 0?Kt(d.values,s,_):d.values}})},this.setErrorMap=(s)=>{ze(()=>{Object.entries(s).forEach(([d,c])=>{let f=d;if(Yt(c)){let{formError:_,fieldErrors:g}=xa(c);for(let y of Object.keys(this.fieldInfo)){if(!this.getFieldMeta(y))continue;this.setFieldMeta(y,(m)=>({...m,errorMap:{...m.errorMap,[f]:g?.[y]},errorSourceMap:{...m.errorSourceMap,[f]:"form"}}))}this.baseStore.setState((y)=>({...y,errorMap:{...y.errorMap,[f]:_}}))}else this.baseStore.setState((_)=>({..._,errorMap:{..._.errorMap,[f]:c}}))})})},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((s,[d,c])=>{if(Object.keys(c).length&&c.errors.length)s[d]={errors:c.errors,errorMap:c.errorMap};return s},{})}),this.parseValuesWithSchema=(s)=>Dt.validate({value:this.state.values,validationSource:"form"},s),this.parseValuesWithSchemaAsync=(s)=>Dt.validateAsync({value:this.state.values,validationSource:"form"},s),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??ra(),this._devtoolsSubmissionOverride=!1;let r=qa({...e?.defaultState,values:e?.defaultValues??e?.defaultState?.values});if(e?.transform){r=e.transform({state:r}).state;for(let s of Object.keys(r.errorMap)){let d=r.errorMap[s];if(d===void 0||!Yt(d))continue;for(let c of Object.keys(d.fields)){let f=d.fields[c];if(f===void 0)continue;let _=r.fieldMetaBase[c];r.fieldMetaBase[c]={isTouched:!1,isValidating:!1,isBlurred:!1,isDirty:!1,_arrayVersion:0,_pendingValidationsCount:0,..._??{},errorSourceMap:{..._?.errorSourceMap??{},onChange:"form"},errorMap:{..._?.errorMap??{},[s]:f}}}}}this.baseStore=Ct(r);let a=void 0;this.fieldMetaDerived=Ct((s)=>{let d=this.baseStore.get(),c=0,f={};for(let _ of Object.keys(d.fieldMetaBase)){let g=d.fieldMetaBase[_],y=a?.fieldMetaBase[_],x=s?.[_],m=Xt(d.values,_),i=x?.errors;if(!y||g.errorMap!==y.errorMap){i=Object.values(g.errorMap??{}).filter((Y)=>Y!==void 0);let O=this.getFieldInfo(_)?.instance;if(!O||!O.options.disableErrorFlat)i=i.flat(1)}let v=!Pa(i),w=!g.isDirty,M=pt(m,this.getFieldInfo(_)?.instance?.options.defaultValue??Xt(this.options.defaultValues,_));if(x&&x.isPristine===w&&x.isValid===v&&x.isDefaultValue===M&&x.errors===i&&g===y){f[_]=x,c++;continue}f[_]={...g,errors:i??[],isPristine:w,isValid:v,isDefaultValue:M}}if(!Object.keys(d.fieldMetaBase).length)return f;if(s&&c===Object.keys(d.fieldMetaBase).length)return s;return a=this.baseStore.get(),f}),this.formGroupMetaDerived=Ct((s)=>{let d=this.baseStore.get(),c=this.fieldMetaDerived.get(),f={};for(let _ of this.formGroupApis){let g=_.name,y=d.formGroupStateBase[g]??{isSubmitted:!1,isSubmitting:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1},x=c[g],m=!1,i=!0,v=!1,w=!1,M=!0,O=!1;for(let De in c){if(De===g)continue;if(!vt(g,De))continue;let Me=c[De];if(!Me)continue;if(Me.isValidating)m=!0;if(!Me.isValid)i=!1;if(Me.isTouched)v=!0;if(Me.isBlurred)w=!0;if(!Me.isDefaultValue)M=!1;if(Me.isDirty)O=!0}let Y=!O,z=!!m||y.isValidating,oe=x?.errorMap??{},re=x?.errorSourceMap??{},T=Boolean(oe.onMount||Object.entries(c).some(([De,Me])=>Me&&De!==g&&vt(g,De)&&Me.errorMap.onMount)),q=s?.[g],j=q?.errors??[];if(!q||q.__srcErrorMap!==oe)j=Object.values(oe).reduce((De,Me)=>{if(Me===void 0)return De;if(Me&&typeof Me==="object"&&"fields"in Me){let ee=Me.group;if(ee!==void 0)De.push(ee);return De}return De.push(Me),De},[]);let G=j.length===0,N=i&&G,X=_.options.canSubmitWhenInvalid??!1,xe=y.submissionAttempts===0&&!v&&!T||!z&&!y.isSubmitting&&N||X;if(q&&q.errorMap===oe&&q.errorSourceMap===re&&q.errors===j&&q.isFieldsValidating===m&&q.isFieldsValid===i&&q.isGroupValid===G&&q.isValid===N&&q.canSubmit===xe&&q.isTouched===v&&q.isBlurred===w&&q.isPristine===Y&&q.isDefaultValue===M&&q.isDirty===O&&q.isValidating===z&&q.isSubmitting===y.isSubmitting&&q.isSubmitted===y.isSubmitted&&q.submissionAttempts===y.submissionAttempts&&q.isSubmitSuccessful===y.isSubmitSuccessful){f[g]=q;continue}let ye={...y,errorMap:oe,errorSourceMap:re,_arrayVersion:x?._arrayVersion??0,isTouched:v,isBlurred:w,isDirty:O,isPristine:Y,isDefaultValue:M,isValid:N,errors:j,isValidating:z,isFieldsValidating:m,isFieldsValid:i,isGroupValid:G,canSubmit:xe};Object.defineProperty(ye,"__srcErrorMap",{value:oe,enumerable:!1,configurable:!0}),f[g]=ye}return f});let l=void 0;this.store=Ct((s)=>{let d=this.baseStore.get(),c=this.fieldMetaDerived.get(),f=Object.values(c).filter(Boolean),_=f.some((G)=>G.isValidating),g=f.every((G)=>G.isValid),y=f.some((G)=>G.isTouched),x=f.some((G)=>G.isBlurred),m=f.every((G)=>G.isDefaultValue),i=y&&d.errorMap?.onMount,v=f.some((G)=>G.isDirty),w=!v,M=Boolean(d.errorMap?.onMount||f.some((G)=>G?.errorMap?.onMount)),O=!!_,Y=s?.errors??[];if(!l||d.errorMap!==l.errorMap)Y=Object.values(d.errorMap).reduce((G,N)=>{if(N===void 0)return G;if(N&&Yt(N))return G.push(N.form),G;return G.push(N),G},[]);let z=Y.length===0,oe=g&&z,re=this.options.canSubmitWhenInvalid??!1,T=d.submissionAttempts===0&&!y&&!M||!O&&!d.isSubmitting&&oe||re,q=d.errorMap;if(i)Y=Y.filter((G)=>G!==d.errorMap.onMount),q=Object.assign(q,{onMount:void 0});if(s&&l&&s.errorMap===q&&s.fieldMeta===this.fieldMetaDerived.state&&s.errors===Y&&s.isFieldsValidating===_&&s.isFieldsValid===g&&s.isFormValid===z&&s.isValid===oe&&s.canSubmit===T&&s.isTouched===y&&s.isBlurred===x&&s.isPristine===w&&s.isDefaultValue===m&&s.isDirty===v&&pt(l,d))return s;let j={...d,errorMap:q,fieldMeta:this.fieldMetaDerived.state,errors:Y,isFieldsValidating:_,isFieldsValid:g,isFormValid:z,isValid:oe,canSubmit:T,isTouched:y,isBlurred:x,isPristine:w,isDefaultValue:m,isDirty:v};return l=this.baseStore.get(),j}),this.handleSubmit=this.handleSubmit.bind(this),this.update(e||{})}get state(){return this.store.state}get formId(){return this._formId}runValidator(e){if(ea(e.validate))return Dt[e.type](e.value,e.validate);return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}}function xa(e){if(e){if(Yt(e)){let r=xa(e.form).formError,a=e.fields;return{formError:r,fieldErrors:a}}return{formError:e}}return{formError:void 0}}function oa(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"dynamic":return"onDynamic";case"change":default:return"onChange"}}class Ot{constructor(e){this.options={},this.mount=()=>{if(this.options.defaultValue!==void 0&&!this.getMeta().isTouched)this.form.setFieldValue(this.name,this.options.defaultValue,{dontUpdateMeta:!0});let r=this.getInfo();r.instance=this,this.update(this.options);let{onMount:a}=this.options.validators||{};if(a){let l=this.runValidator({validate:a,value:{value:this.state.value,fieldApi:this,validationSource:"field"},type:"validate"});if(l)this.setMeta((s)=>({...s,errorMap:{...s?.errorMap,onMount:l},errorSourceMap:{...s?.errorSourceMap,onMount:"field"}}))}return this.options.listeners?.onMount?.({value:this.state.value,fieldApi:this}),()=>{for(let[s,d]of Object.entries(this.timeoutIds.validations))if(d)clearTimeout(d),this.timeoutIds.validations[s]=null;for(let[s,d]of Object.entries(this.timeoutIds.listeners))if(d)clearTimeout(d),this.timeoutIds.listeners[s]=null;for(let[s,d]of Object.entries(this.timeoutIds.formListeners))if(d)clearTimeout(d),this.timeoutIds.formListeners[s]=null;let l=this.form.fieldInfo[this.name];if(!l)return;if(l.instance!==this)return;for(let[s,d]of Object.entries(l.validationMetaMap))d?.lastAbortController.abort(),l.validationMetaMap[s]=void 0;this.form.baseStore.setState((s)=>({...s,fieldMetaBase:{...s.fieldMetaBase,[this.name]:{...We,isTouched:s.fieldMetaBase[this.name]?.isTouched??We.isTouched,isBlurred:s.fieldMetaBase[this.name]?.isBlurred??We.isBlurred,isDirty:s.fieldMetaBase[this.name]?.isDirty??We.isDirty}}})),l.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,fieldApi:this}),this.form.options.listeners?.onFieldUnmount?.({formApi:this.form,fieldApi:this})}},this.update=(r)=>{if(this.options=r,this.name=r.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0){let a=this.form.getFieldValue(this.name);if(!pt(a,r.defaultValue))this.form.setFieldValue(this.name,r.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})}if(!this.form.getFieldMeta(this.name))this.form.setFieldMeta(this.name,this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(r,a)=>{if(this.form.setFieldValue(this.name,r,Ke(a,{dontRunListeners:!0,dontValidate:!0})),!a?.dontRunListeners)this.triggerOnChangeListener();if(!a?.dontValidate)this.validate("change")},this.getMeta=()=>this.store.state.meta,this.setMeta=(r)=>this.form.setFieldMeta(this.name,r),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(r,a)=>{if(this.form.pushFieldValue(this.name,r,Ke(a,{dontRunListeners:!0})),!a?.dontRunListeners)this.triggerOnChangeListener()},this.insertValue=(r,a,l)=>{if(this.form.insertFieldValue(this.name,r,a,Ke(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.replaceValue=(r,a,l)=>{if(this.form.replaceFieldValue(this.name,r,a,Ke(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.removeValue=(r,a)=>{if(this.form.removeFieldValue(this.name,r,Ke(a,{dontRunListeners:!0})),!a?.dontRunListeners)this.triggerOnChangeListener()},this.swapValues=(r,a,l)=>{if(this.form.swapFieldValues(this.name,r,a,Ke(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.moveValue=(r,a,l)=>{if(this.form.moveFieldValues(this.name,r,a,Ke(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.clearValues=(r)=>{if(this.form.clearFieldValues(this.name,Ke(r,{dontRunListeners:!0})),!r?.dontRunListeners)this.triggerOnChangeListener()},this.getLinkedFields=(r)=>{let a=Object.values(this.form.fieldInfo),l=[];for(let s of a){if(!s.instance)continue;if(!(s.instance instanceof Ot))continue;let{onChangeListenTo:d,onBlurListenTo:c}=s.instance.options.validators||{};if(r==="change"&&d?.includes(this.name))l.push(s.instance);if(r==="blur"&&c?.includes(this.name))l.push(s.instance)}return l},this.validateSync=(r,a)=>{let l=At(r,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||ft}),d=this.getLinkedFields(r).reduce((_,g)=>{let y=At(r,{...g.options,form:g.form,fieldName:g.name,validationLogic:g.form.options.validationLogic||ft});return y.forEach((x)=>{x.field=g}),_.concat(y)},[]),c=!1;ze(()=>{let _=(g,y)=>{let x=na(y.cause),m=y.validate?ds(g.runValidator({validate:y.validate,value:{value:g.store.state.value,validationSource:"field",fieldApi:g},type:"validate"})):void 0,i=a[x],{newErrorValue:v,newSource:w}=Gt({formLevelError:i,fieldLevelError:m});if(g.state.meta.errorMap?.[x]!==v)g.setMeta((M)=>({...M,errorMap:{...M.errorMap,[x]:v},errorSourceMap:{...M.errorSourceMap,[x]:w}}));if(v)c=!0};for(let g of l)_(this,g);for(let g of d){if(!g.validate)continue;_(g.field,g)}});let f=na("submit");if(this.state.meta.errorMap?.[f]&&r!=="submit"&&!c)this.setMeta((_)=>({..._,errorMap:{..._.errorMap,[f]:void 0},errorSourceMap:{..._.errorSourceMap,[f]:void 0}}));return{hasErrored:c}},this.validateAsync=async(r,a)=>{let l=It(r,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||ft}),s=await a,c=this.getLinkedFields(r).reduce((i,v)=>{let w=It(r,{...v.options,form:v.form,fieldName:v.name,validationLogic:v.form.options.validationLogic||ft});return w.forEach((M)=>{M.field=v}),i.concat(w)},[]),f=[],_=[],g=l.some((i)=>i.validate),y=Array.from(new Set(c.filter((i)=>i.validate).map((i)=>i.field)));ze(()=>{if(g)this.startValidation();for(let i of y)i.startValidation()});let x=(i,v,w)=>{let M=na(v.cause),O=i.getInfo();O.validationMetaMap[M]?.lastAbortController.abort();let z=new AbortController;O.validationMetaMap[M]={lastAbortController:z},w.push(new Promise(async(oe)=>{let re;try{re=await new Promise((N,X)=>{if(i.timeoutIds.validations[v.cause])clearTimeout(i.timeoutIds.validations[v.cause]),i.endValidation();i.timeoutIds.validations[v.cause]=setTimeout(async()=>{if(z.signal.aborted)return N(void 0);try{N(await this.runValidator({validate:v.validate,value:{value:i.store.state.value,fieldApi:i,signal:z.signal,validationSource:"field"},type:"validateAsync"}))}catch(xe){X(xe)}},v.debounceMs)})}catch(N){re=N}if(z.signal.aborted)return oe(void 0);let T=ds(re),q=s[i.name]?.[M],{newErrorValue:j,newSource:G}=Gt({formLevelError:q,fieldLevelError:T});if(i.getInfo().instance!==i)return oe(void 0);i.setMeta((N)=>({...N,errorMap:{...N?.errorMap,[M]:j},errorSourceMap:{...N.errorSourceMap,[M]:G}})),oe(j)}))};for(let i of l){if(!i.validate)continue;x(this,i,f)}for(let i of c){if(!i.validate)continue;x(i.field,i,_)}let m=[];if(f.length||_.length)m=await Promise.all(f),await Promise.all(_);return ze(()=>{if(g)this.endValidation();for(let i of y)i.endValidation()}),m.filter(Boolean)},this.validate=(r,a)=>{if(!this.state.meta.isTouched)return[];let l=a?.skipGroupValidation?[]:Array.from(this.form.formGroupApis).filter((x)=>this.name.startsWith(x.name)),d=((a?.skipFormValidation)?{fieldsErrorMap:{}}:this.form.validateSync(r)).fieldsErrorMap[this.name]??{};if(!a?.skipFormValidation)for(let x of l){if(x.state.meta.submissionAttempts===0)continue;let{fieldsErrorMap:m}=this.form.validateSync(r,{group:x,dontUpdateFormErrorMap:!0,filterFieldNames:(i)=>vt(x.name,i)});d={...d,...m[this.name]??{}}}let{hasErrored:c}=this.validateSync(r,d),f=new WeakMap;for(let x of l){let{hasErrored:m}=x.validateSync(r,{},{skipRelatedFieldValidation:!0});f.set(x,m)}if(c&&!this.options.asyncAlways){this.getInfo().validationMetaMap[na(r)]?.lastAbortController.abort();let x=[];for(let m of l)m.getInfo().validationMetaMap[na(r)]?.lastAbortController.abort(),x.push(m.state.meta.errors);return[...this.state.meta.errors,...x.flat()]}let _=a?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(r),g=this.validateAsync(r,_),y=[];for(let x of l){if(f.get(x)&&!x.options.asyncAlways)continue;y.push(x.validateAsync(r,_,{skipRelatedFieldValidation:!0}))}if(y.length===0)return g;return Promise.all([g,...y]).then((x)=>x.flat())},this.handleChange=(r)=>{this.setValue(r)},this.handleBlur=()=>{if(!this.state.meta.isTouched)this.setMeta((a)=>({...a,isTouched:!0}));if(!this.state.meta.isBlurred)this.setMeta((a)=>({...a,isBlurred:!0}));this.validate("blur"),this.triggerOnBlurListener()},this.setErrorMap=(r)=>{this.setMeta((a)=>({...a,errorMap:{...a.errorMap,...r}}))},this.parseValueWithSchema=(r)=>Dt.validate({value:this.state.value,validationSource:"field"},r),this.parseValueWithSchemaAsync=(r)=>Dt.validateAsync({value:this.state.value,validationSource:"field"},r),this.triggerOnBlurListener=()=>{let r=this.form.options.listeners?.onBlurDebounceMs;if(r&&r>0){if(this.timeoutIds.formListeners.blur)clearTimeout(this.timeoutIds.formListeners.blur);this.timeoutIds.formListeners.blur=setTimeout(()=>{this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this})},r)}else this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this});let a=this.options.listeners?.onBlurDebounceMs;if(a&&a>0){if(this.timeoutIds.listeners.blur)clearTimeout(this.timeoutIds.listeners.blur);this.timeoutIds.listeners.blur=setTimeout(()=>{this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},a)}else this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},this.triggerOnChangeListener=()=>{let r=this.form.options.listeners?.onChangeDebounceMs;if(r&&r>0){if(this.timeoutIds.formListeners.change)clearTimeout(this.timeoutIds.formListeners.change);this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this})},r)}else this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this});let a=this.options.listeners?.onChangeDebounceMs;if(a&&a>0){if(this.timeoutIds.listeners.change)clearTimeout(this.timeoutIds.listeners.change);this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this})},a)}else this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this});for(let l of this.form.formGroupApis)if(vt(l.name,this.name))l.triggerOnChangeListener()},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,fieldApi:this})},this.form=e.form,this.name=e.name,this.options=e,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=Ct((r)=>{this.form.store.get();let a=this.form.getFieldMeta(this.name)??{...We,...e.defaultMeta},l=this.form.getFieldValue(this.name);if(!a.isTouched&&l===void 0&&this.options.defaultValue!==void 0&&!pt(l,this.options.defaultValue))l=this.options.defaultValue;if(r&&r.value===l&&r.meta===a)return r;return{value:l,meta:a}})}get state(){return this.store.state}runValidator(e){if(ea(e.validate))return Dt[e.type](e.value,e.validate);return e.validate(e.value)}startValidation(){this.setMeta((e)=>{let r=e._pendingValidationsCount+1;return{...e,_pendingValidationsCount:r,isValidating:r>0&&!e.isValidating?!0:e.isValidating}})}endValidation(){this.setMeta((e)=>{let r=Math.max(0,e._pendingValidationsCount-1);return{...e,_pendingValidationsCount:r,isValidating:r===0&&e.isValidating?!1:e.isValidating}})}}function ds(e){if(e)return e;return}function na(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"dynamic":return"onDynamic";case"change":default:return"onChange"}}function ja(e){return{isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1}}function ms(e){return{...We,...e,errors:[],isPristine:!0,isValid:!0,isDefaultValue:!0,isFieldsValidating:!1,isFieldsValid:!0,isGroupValid:!0,canSubmit:!0,isSubmitting:!1,isSubmitted:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1}}class Ht{constructor(e){this.options={},this.setFormGroupState=(r)=>{this.form.baseStore.setState((a)=>{let l=a.formGroupStateBase[this.name]??ja({});return{...a,formGroupStateBase:{...a.formGroupStateBase,[this.name]:r(l)}}})},this._lastDistributedFieldNames={},this.update=(r)=>{if(this.options=r,this.name=r.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0){let a=this.form.getFieldValue(this.name);if(!pt(a,r.defaultValue))this.form.setFieldValue(this.name,r.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})}if(!this.form.getFieldMeta(this.name))this.form.setFieldMeta(this.name,{...We,...this.options.defaultMeta})},this.mount=()=>{this.update(this.options),this.form.formGroupApis.add(this),this.fieldInfo.instance=this,this.form.baseStore.setState((a)=>({...a,formGroupStateBase:{...a.formGroupStateBase,[this.name]:a.formGroupStateBase[this.name]??ja({...this.options.defaultState})}}));let{onMount:r}=this.options.validators||{};if(r){let a=this.runValidator({validate:r,value:{value:this.state.value,groupApi:this,validationSource:"form"},type:"validate"}),l=a,s=void 0;if($a(a))l=a.group,s=a.fields;let d=Oa(l);if(d)this.setMeta((c)=>({...c,errorMap:{...c.errorMap,onMount:d},errorSourceMap:{...c.errorSourceMap,onMount:"field"}}));this.distributeFieldErrors("onMount",s)}return this.options.listeners?.onMount?.({value:this.state.value,groupApi:this}),()=>{for(let[a,l]of Object.entries(this.timeoutIds.validations))if(l)clearTimeout(l),this.timeoutIds.validations[a]=null;for(let[a,l]of Object.entries(this.timeoutIds.listeners))if(l)clearTimeout(l),this.timeoutIds.listeners[a]=null;for(let[a,l]of Object.entries(this.timeoutIds.formListeners))if(l)clearTimeout(l),this.timeoutIds.formListeners[a]=null;if(this.fieldInfo.instance!==this)return;for(let[a,l]of Object.entries(this.fieldInfo.validationMetaMap))l?.lastAbortController.abort(),this.fieldInfo.validationMetaMap[a]=void 0;this.form.formGroupApis.delete(this),this.form.baseStore.setState((a)=>({...a,formGroupStateBase:{...a.formGroupStateBase,[this.name]:ja({})}})),this.fieldInfo.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,groupApi:this})}},this.setValue=(r,a)=>{if(this.form.setFieldValue(this.name,r,Ke(a,{dontRunListeners:!0,dontValidate:!0})),!a?.dontRunListeners)this.triggerOnChangeListener();if(!a?.dontValidate)this.validate("change")},this.getMeta=()=>this.store.state.meta,this.setMeta=(r)=>this.form.setFieldMeta(this.name,r),this.getInfo=()=>this.fieldInfo,this.getRelatedFields=()=>{let r=Object.values(this.form.fieldInfo),a=[];for(let l of r){if(!l.instance)continue;if(!(l.instance instanceof Ot))continue;if(l.instance.name.startsWith(this.name))a.push(l.instance)}return a},this.getRelatedFieldMetasDerived=()=>{let r=Object.entries(this.form.fieldMetaDerived.state),a=[];for(let[l,s]of r){if(l===this.name)continue;if(vt(this.name,l))a.push({...s,name:l})}return a},this.buildChildFieldName=(r)=>{if(r==="")return this.name;if(r.startsWith("["))return`${this.name}${r}`;return`${this.name}.${r}`},this.distributeFieldErrors=(r,a)=>{let l=this._lastDistributedFieldNames[r]??new Set,s=new Set;if(a)for(let[f,_]of Object.entries(a)){if(_===void 0||_===null||_===!1)continue;s.add(this.buildChildFieldName(f))}let d=new Set([...l,...s]),c=!1;for(let f of d){let _=f.startsWith(this.name+"[")?f.slice(this.name.length):f.slice(this.name.length+1),g=a?.[_],y=this.form.getFieldMeta(f);if(!y&&!g)continue;let x=y?.errorMap[r],m=y?.errorSourceMap[r]==="form",{newErrorValue:i,newSource:v}=Jt({newFormValidatorError:g,isPreviousErrorFromFormValidator:m,previousErrorValue:x});if(i)c=!0;if(x===i&&y?.errorSourceMap[r]===v)continue;this.form.setFieldMeta(f,(w=We)=>({...w,errorMap:{...w.errorMap,[r]:i},errorSourceMap:{...w.errorSourceMap,[r]:v}}))}return this._lastDistributedFieldNames[r]=s,c},this.validateSync=(r,a,l={})=>{let s=At(r,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||ft}),c=(l.skipRelatedFieldValidation?[]:this.getRelatedFields()).reduce((g,y)=>{let x=At(r,{...y.options,form:y.form,validationLogic:y.form.options.validationLogic||ft});return x.forEach((m)=>{m.field=y}),g.concat(x)},[]),f=!1;ze(()=>{let g=(y,x)=>{let m=wa(x.cause),i=y===this,v=void 0;if(x.validate)v=y.runValidator({validate:x.validate,value:{value:y.store.state.value,validationSource:i?"form":"field",...y instanceof Ht?{groupApi:y}:{fieldApi:y}},type:"validate"});let w=v,M=void 0;if(i&&$a(v))w=v.group,M=v.fields;let O=Oa(w),Y=a[m],{newErrorValue:z,newSource:oe}=Gt({formLevelError:Y,fieldLevelError:O});if(y.state.meta.errorMap?.[m]!==z)y.setMeta((re)=>({...re,errorMap:{...re.errorMap,[m]:z},errorSourceMap:{...re.errorSourceMap,[m]:oe}}));if(z)f=!0;if(i){if(this.distributeFieldErrors(m,M))f=!0}};for(let y of s)g(this,y);for(let y of c){if(!y.validate)continue;g(y.field,y)}});let _=wa("submit");if(this.state.meta.errorMap?.[_]&&r!=="submit"&&!f)this.setMeta((g)=>({...g,errorMap:{...g.errorMap,[_]:void 0},errorSourceMap:{...g.errorSourceMap,[_]:void 0}}));return{hasErrored:f}},this.validateAsync=async(r,a,l={})=>{let s=It(r,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||ft}),d=await a,c=l.skipRelatedFieldValidation?[]:this.getRelatedFields(),f=c.reduce((i,v)=>{let w=It(r,{...v.options,form:v.form,validationLogic:v.form.options.validationLogic||ft});return w.forEach((M)=>{M.field=v}),i.concat(w)},[]),_=[],g=[],y=s.some((i)=>i.validate)||f.some((i)=>i.validate);if(y){if(!this.state.meta.isValidating)this.setMeta((i)=>({...i,isValidating:!0}));for(let i of c)i.setMeta((v)=>({...v,isValidating:!0}))}let x=(i,v,w)=>{let M=wa(v.cause),O=i.getInfo();O.validationMetaMap[M]?.lastAbortController.abort();let z=new AbortController;O.validationMetaMap[M]={lastAbortController:z};let oe=i===this;w.push(new Promise(async(re)=>{let T;try{T=await new Promise((ye,De)=>{if(i.timeoutIds.validations[v.cause])clearTimeout(i.timeoutIds.validations[v.cause]);i.timeoutIds.validations[v.cause]=setTimeout(async()=>{if(z.signal.aborted)return ye(void 0);try{ye(await this.runValidator({validate:v.validate,value:{value:i.store.state.value,signal:z.signal,validationSource:oe?"form":"field",...i instanceof Ht?{groupApi:i}:{fieldApi:i}},type:"validateAsync"}))}catch(Me){De(Me)}},v.debounceMs)})}catch(ye){T=ye}if(z.signal.aborted)return re(void 0);let q=T,j=void 0;if(oe&&$a(T))q=T.group,j=T.fields;let G=Oa(q),N=d[i.name]?.[M],{newErrorValue:X,newSource:xe}=Gt({formLevelError:N,fieldLevelError:G});if(i.getInfo().instance!==i)return re(void 0);if(i.setMeta((ye)=>({...ye,errorMap:{...ye?.errorMap,[M]:X},errorSourceMap:{...ye.errorSourceMap,[M]:xe}})),oe)this.distributeFieldErrors(M,j);re(X)}))};for(let i of s){if(!i.validate)continue;x(this,i,_)}for(let i of f){if(!i.validate)continue;x(i.field,i,g)}let m=[];if(_.length||g.length)m=await Promise.all(_),await Promise.all(g);if(y){this.setMeta((i)=>({...i,isValidating:!1}));for(let i of c)i.setMeta((v)=>({...v,isValidating:!1}))}return m.filter(Boolean)},this.validateAllFields=async(r)=>{let a=[];return ze(()=>{Object.values(this.getRelatedFields()).forEach((s)=>{if(a.push(Promise.resolve().then(()=>s.validate(r,{skipFormValidation:!0,skipGroupValidation:!0}))),!s.store.state.meta.isTouched)s.setMeta((d)=>({...d,isTouched:!0}))})}),(await Promise.all(a)).flat()},this.validateArrayFieldsStartingFrom=(r,a,l)=>this.form.validateArrayFieldsStartingFrom(r,a,l),this.validateField=(r,a)=>this.form.validateField(r,a),this.getFieldValue=(r)=>this.form.getFieldValue(r),this.getFieldMeta=(r)=>this.form.getFieldMeta(r),this.setFieldMeta=(r,a)=>this.form.setFieldMeta(r,a),this.setFieldValue=(r,a)=>this.form.setFieldValue(r,a),this.deleteField=(r)=>this.form.deleteField(r),this.pushFieldValue=(r,a)=>this.form.pushFieldValue(r,a),this.insertFieldValue=(r,a,l)=>this.form.insertFieldValue(r,a,l),this.replaceFieldValue=(r,a,l)=>this.form.replaceFieldValue(r,a,l),this.swapFieldValues=(r,a,l)=>this.form.swapFieldValues(r,a,l),this.moveFieldValues=(r,a,l)=>this.form.moveFieldValues(r,a,l),this.clearFieldValues=(r)=>this.form.clearFieldValues(r),this.resetField=(r)=>this.form.resetField(r),this.removeFieldValue=(r,a)=>this.form.removeFieldValue(r,a),this.areRelatedFieldsValid=()=>Object.values(this.getRelatedFields()).every((r)=>r.state.meta.isValid),this.validate=(r,a)=>{let{fieldsErrorMap:l}=a?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(r,{dontUpdateFormErrorMap:!0,filterFieldNames:(c)=>vt(this.name,c)}),{hasErrored:s}=this.validateSync(r,l[this.name]??{},{skipRelatedFieldValidation:a?.skipRelatedFieldValidation});if(s&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[wa(r)]?.lastAbortController.abort(),this.state.meta.errors;let d=a?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(r,{dontUpdateFormErrorMap:!0,filterFieldNames:(c)=>vt(this.name,c)});return this.validateAsync(r,d,{skipRelatedFieldValidation:a?.skipRelatedFieldValidation})},this.triggerOnChangeListener=()=>{let r=this.form.options.listeners?.onChangeGroupDebounceMs;if(r&&r>0){if(this.timeoutIds.formListeners.change)clearTimeout(this.timeoutIds.formListeners.change);this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this})},r)}else this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this});let a=this.options.listeners?.onChangeDebounceMs;if(a&&a>0){if(this.timeoutIds.listeners.change)clearTimeout(this.timeoutIds.listeners.change);this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},a)}else this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,groupApi:this})},this._handleSubmit=async(r)=>{this.setFormGroupState((s)=>({...s,isSubmitted:!1,submissionAttempts:s.submissionAttempts+1,isSubmitSuccessful:!1})),ze(()=>{Object.values(this.getRelatedFields()).forEach((s)=>{if(!s.state.meta.isTouched)s.setMeta((d)=>({...d,isTouched:!0}))})});let a=r??this.options.onSubmitMeta;this.setFormGroupState((s)=>({...s,isSubmitting:!0}));let l=()=>{this.setFormGroupState((s)=>({...s,isSubmitting:!1}))};if(await this.validateAllFields("submit"),!this.areRelatedFieldsValid()){l(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:a});return}if(await this.validate("submit",{skipRelatedFieldValidation:!0}),!this.areRelatedFieldsValid()||!this.state.meta.isValid){l(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:a});return}ze(()=>{Object.values(this.getRelatedFields()).forEach((s)=>{s.options.listeners?.onGroupSubmit?.({value:s.state.value,fieldApi:s})})}),this.options.listeners?.onSubmit?.({groupApi:this,value:this.state.value});try{await this.options.onGroupSubmit?.({value:this.state.value,groupApi:this,meta:a}),ze(()=>{this.setFormGroupState((s)=>({...s,isSubmitted:!0,isSubmitSuccessful:!0})),l()})}catch(s){throw this.setFormGroupState((d)=>({...d,isSubmitSuccessful:!1})),l(),s}},this.form=e.form,this.name=e.name,this.options=e,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.fieldInfo={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.store=Ct((r)=>{this.form.formGroupMetaDerived.get(),this.form.baseStore.get();let a=this.form.getFormGroupMeta(this.name)??ms(e.defaultMeta),l=this.form.getFieldValue(this.name);if(!a.isTouched&&l===void 0&&this.options.defaultValue!==void 0&&!pt(l,this.options.defaultValue))l=this.options.defaultValue;if(r&&r.value===l&&r.meta===a)return r;return{value:l,meta:a}}),this.handleSubmit=this.handleSubmit.bind(this)}get state(){return this.store.state}runValidator(e){if(ea(e.validate)){let r=Dt[e.type](e.value,e.validate);if(e.type==="validate")return cs(r);return r.then(cs)}return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}}function Oa(e){if(e)return e;return}function $a(e){return!!e&&typeof e==="object"&&"fields"in e}function cs(e){if(!e||typeof e!=="object")return e;if(!("form"in e)&&!("fields"in e))return e;let{form:r,fields:a,...l}=e;return{...l,group:r,fields:a}}function wa(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"dynamic":return"onDynamic";case"change":default:return"onChange"}}function za(e,r){if(!r)return;let a=Object.assign({},e,{state:Qt(e.state)});if(r(a),a.fieldInfo!==e.fieldInfo)e.fieldInfo=a.fieldInfo;if(a.options!==e.options)e.options=a.options;let s=Object.keys({values:null,validationMetaMap:null,fieldMetaBase:null,formGroupStateBase:null,isSubmitting:null,isSubmitted:null,isValidating:null,submissionAttempts:null,isSubmitSuccessful:null,_force_re_eval:null}).reduce((d,c)=>{if(e.state[c]!==a.state[c])d[c]=a.state[c];return d},{});return ze(()=>{if(Object.keys(s).length)e.baseStore.setState((d)=>({...d,...s}));if(a.state.errorMap!==e.state.errorMap)e.setErrorMap(a.state.errorMap)}),a}S();function dr(e,r){return e===r}function Ee(e,r=(l)=>l,a){let l=a?.compare??dr,s=P((c)=>{let{unsubscribe:f}=e.subscribe(c);return f},[e]),d=P(()=>e.get(),[e]);return Ic(s,d,d,r,l)}var la=(e,r=(l)=>l,a)=>Ee(e,r,{compare:a});S();S();S();var yt=typeof window<"u"?He:h;function cr(e){let[r,a]=u(()=>({form:e.form,name:e.name})),[l,s]=u(()=>new Ot({...e})),d=l;if(r.form!==e.form||r.name!==e.name)d=new Ot({...e}),s(d),a({form:e.form,name:e.name});let c=Ee(d.store,e.mode==="array"?(v)=>v.meta._arrayVersion||0:(v)=>v.value),f=Ee(d.store,(v)=>v.meta.isTouched),_=Ee(d.store,(v)=>v.meta.isBlurred),g=Ee(d.store,(v)=>v.meta.isDirty),y=Ee(d.store,(v)=>v.meta.errorMap),x=Ee(d.store,(v)=>v.meta.errorSourceMap),m=Ee(d.store,(v)=>v.meta.isValidating),i=D(()=>({...d,get state(){return{value:e.mode==="array"?d.state.value:c,get meta(){return{...d.state.meta,isTouched:f,isBlurred:_,isDirty:g,errorMap:y,errorSourceMap:x,isValidating:m}}}}}),[d,e.mode,c,f,_,g,y,x,m]);return yt(d.mount,[d]),yt(()=>{d.update(e)}),i}var ps=({children:e,...r})=>{let a=cr(r),l=D(()=>Ft(e,a),[e,a]);return t(Z,{children:l})};S();S();function fs(){return u(()=>ra())[0]}var mr=V,gs=Rs.split(".")[0]==="17"?fs:mr.useId;S();function ur(e){let[r,a]=u(()=>({form:e.form,name:e.name})),[l,s]=u(()=>new Ht({...e}));if(r.form!==e.form||r.name!==e.name)s(new Ht({...e})),a({form:e.form,name:e.name});let d=Ee(l.store,(T)=>T.value),c=Ee(l.store,(T)=>T.meta.isTouched),f=Ee(l.store,(T)=>T.meta.isBlurred),_=Ee(l.store,(T)=>T.meta.isDirty),g=Ee(l.store,(T)=>T.meta.errorMap),y=Ee(l.store,(T)=>T.meta.errorSourceMap),x=Ee(l.store,(T)=>T.meta.isValidating),m=Ee(l.store,(T)=>T.meta.isSubmitting),i=Ee(l.store,(T)=>T.meta.isSubmitted),v=Ee(l.store,(T)=>T.meta.submissionAttempts),w=Ee(l.store,(T)=>T.meta.isSubmitSuccessful),M=Ee(l.store,(T)=>T.meta.canSubmit),O=Ee(l.store,(T)=>T.meta.isValid),Y=Ee(l.store,(T)=>T.meta.isFieldsValid),z=Ee(l.store,(T)=>T.meta.isFieldsValidating),oe=Ee(l.store,(T)=>T.meta.isGroupValid),re=D(()=>({...l,handleSubmit:(...j)=>l._handleSubmit(...j),get state(){return{...l.state,value:d,get meta(){return{...l.state.meta,isTouched:c,isBlurred:f,isDirty:_,errorMap:g,errorSourceMap:y,isValidating:x,isSubmitting:m,isSubmitted:i,submissionAttempts:v,isSubmitSuccessful:w,canSubmit:M,isValid:O,isFieldsValid:Y,isFieldsValidating:z,isGroupValid:oe}}}}}),[l,d,c,f,_,g,y,x,m,i,v,w,M,O,Y,z,oe]);return yt(l.mount,[l]),yt(()=>{l.update(e)}),re}var hs=({children:e,...r})=>{let a=ur(r),l=D(()=>Ft(e,a),[e,a]);return t(Z,{children:l})};function pr({form:e,selector:r=(l)=>l,children:a}){let l=Ee(e.store,r);return t(Z,{children:Ft(a,l)})}function $t(e){let r=gs(),[a,l]=u(e?.formId),[s,d]=u(()=>new ia({...e,formId:e?.formId??r}));if(a!==e?.formId){let _=e?.formId??r;d(new ia({...e,formId:_})),l(_)}let c=D(()=>{let _={...s,handleSubmit:(...g)=>s._handleSubmit(...g),get formId(){return s._formId},get state(){return s.store.state}};return _.Field=function(y){return t(ps,{...y,form:s})},_.FormGroup=function(y){return t(hs,{...y,form:s})},_.Subscribe=function(y){return t(pr,{form:s,selector:y.selector,children:y.children})},_},[s]);yt(s.mount,[]),yt(()=>{s.update(e)});let f=b(!1);return yt(()=>{if(!f.current)return;if(!e?.transform)return;za(s,e.transform)},[s,e?.transform]),yt(()=>{f.current=!0}),c}S();var fr=R({name:p().min(1,Jw()),type:Ve(["chat","autofill","embedding"]),permission:Ve(["owner","editor","reviewer"]),avatar:p().optional(),providerId:p().optional(),modelId:p().optional(),soul:p().optional(),thinkingLevel:Wc.optional(),systemPrompt:p().optional(),skills:te(p()).optional(),mcpServerIds:te(p()).optional(),deniedTools:te(p()).optional()}),yr=[{id:"bash",name:()=>WA(),description:()=>KA()},{id:"read_skill",name:()=>i0(),description:()=>a0()},{id:"read_asset",name:()=>Dm(),description:()=>s0()},{id:"list_assets",name:()=>Rm(),description:()=>n0()},{id:"create_folder",name:()=>Cm(),description:()=>JA()},{id:"create_file",name:()=>Em(),description:()=>YA()},{id:"create_version",name:()=>Im(),description:()=>XA()},{id:"generate_image",name:()=>Mm(),description:()=>t0()},{id:"generate_video",name:()=>km(),description:()=>r0()},{id:"rename_asset",name:()=>Pm(),description:()=>l0()},{id:"move_assets",name:()=>Nm(),description:()=>o0()},{id:"delete_asset",name:()=>Tm(),description:()=>e0()}];function bs({isOpen:e,onClose:r,teamId:a,type:l,initialValues:s,title:d}){let c=K(),{canAdmin:f}=Pt(),{data:_}=L({queryKey:["teams",a,"providers"],queryFn:async()=>{let U=await A.api.teams[":teamId"].providers.$get({param:{teamId:a}});if(!U.ok)throw Error("Failed to fetch providers");return await U.json()},enabled:e}),{data:g}=L({queryKey:["teams",a,"skills"],queryFn:async()=>{let U=await A.api.teams[":teamId"].skills.$get({param:{teamId:a}});if(!U.ok)throw Error("Failed to fetch skills");return await U.json()},enabled:e}),y=g?.skills||[],{data:x}=L({queryKey:["teams",a,"mcp","servers"],queryFn:async()=>{let U=await A.api.teams[":teamId"].mcp.servers.$get({param:{teamId:a}});if(!U.ok)throw Error("Failed to fetch MCP servers");return await U.json()},enabled:e}),m=x?.servers||[],i=D(()=>fr.superRefine((U,J)=>{if(U.type==="chat"||U.type==="autofill"){if(!U.providerId)J.addIssue({code:no.custom,message:$S(),path:["providerId"]});if(!U.modelId)J.addIssue({code:no.custom,message:$w(),path:["modelId"]})}}),[]),v=$t({defaultValues:{name:s?.name||"",type:s?.type||l||"chat",permission:s?.permission||"reviewer",avatar:s?.avatarPreset||s?.avatar||Kc[0].id,providerId:s?.providerId||"",modelId:s?.modelId||"",soul:s?.soul||"",thinkingLevel:s?.thinkingLevel||"off",systemPrompt:s?.systemPrompt||"",skills:s?.skills?.map((U)=>U.skillId)||[],mcpServerIds:s?.mcpServerIds||[],deniedTools:s?.deniedTools??[...aA]},validators:{onChange:i},onSubmit:async({value:U})=>{try{if(s?.id)await Me.mutateAsync({id:s.id,values:U});else await De.mutateAsync(U)}catch{}}}),w=la(v.store,(U)=>U.values.providerId),{data:M,isLoading:O}=L({queryKey:["teams",a,"providers",w,"models"],queryFn:async()=>{let U=await A.api.providers[":id"].models.$get({param:{id:w}});if(!U.ok)throw Error("Failed to fetch models");return await U.json()},enabled:!!w&&e}),[Y,z]=u(""),[oe,re]=u(!1),T=D(()=>{if(!_)return[];return[..._].sort((U,J)=>U.name.toLowerCase().localeCompare(J.name.toLowerCase()))},[_]),q=D(()=>{if(!Y.trim())return T;let U=Y.toLowerCase();return T.filter((J)=>J.name.toLowerCase().includes(U))},[T,Y]),[j,G]=u(""),[N,X]=u(!1),xe=D(()=>{if(!M)return[];return[...M].sort((U,J)=>{let Se=(U.name||U.modelId).toLowerCase(),de=(J.name||J.modelId).toLowerCase();return Se.localeCompare(de)})},[M]),ye=D(()=>{if(!j.trim())return xe;let U=j.toLowerCase();return xe.filter((J)=>J.modelId.toLowerCase().includes(U)||J.name&&J.name.toLowerCase().includes(U))},[xe,j]),De=B({mutationFn:async(U)=>{let J=await A.api.teams[":teamId"].agents.$post({param:{teamId:a},json:U});if(!J.ok)throw Error("Failed to create agent");return await J.json()},onSuccess:()=>{r(),c.invalidateQueries({queryKey:["agents",a]}),k.success(BA())},onError:(U)=>{k.error(Zs({message:U.message}))}}),Me=B({mutationFn:async({id:U,values:J})=>{let Se=await A.api.agents[":agentId"].$put({param:{agentId:U},json:J});if(!Se.ok)throw Error("Failed to update agent");return await Se.json()},onSuccess:()=>{r(),c.invalidateQueries({queryKey:["agents",a]}),k.success(Zm())},onError:(U)=>{k.error(Zs({message:U.message}))}});h(()=>{if(e)v.reset(),z(""),re(!1),G(""),X(!1)},[e,s,l]);let ee=la(v.store,(U)=>U.values.type),se=ee==="chat"||ee==="autofill",_e=ee==="chat",Pe=(U)=>U.map((J)=>{if(typeof J==="string")return{message:J};if(J&&typeof J==="object"&&"message"in J)return{message:String(J.message)};return{message:String(J||"")}});return t(ue,{open:e,onOpenChange:r,children:o(ie,{className:"sm:max-w-3xl h-[90vh] flex flex-col p-0 overflow-hidden",children:[o(me,{className:"p-6 pb-2 flex-shrink-0",children:[t(le,{children:d}),t(Tt,{children:M_()})]}),o("form",{onSubmit:(U)=>{U.preventDefault(),U.stopPropagation(),v.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t(ce,{className:"flex-1 min-h-0",children:o("div",{className:"p-6 pt-2 space-y-6",children:[o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[t(v.Field,{name:"name",children:(U)=>{let J=!!U.state.meta.errors.length&&U.state.meta.isTouched;return o(Oe,{"data-invalid":J,children:[t($e,{children:jA()}),t(H,{value:U.state.value,onBlur:U.handleBlur,onChange:(Se)=>U.handleChange(Se.target.value),placeholder:qA(),"aria-invalid":J}),J&&t(Qe,{errors:Pe(U.state.meta.errors)})]})}}),t(v.Field,{name:"type",children:(U)=>o(Oe,{children:[t($e,{children:d0()}),o(Fe,{value:U.state.value,onValueChange:(J)=>U.handleChange(J),disabled:!0,children:[t(Ze,{className:"bg-muted/50",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"chat",children:Fm()}),t(ne,{value:"autofill",children:Om()}),t(ne,{value:"embedding",children:Lm()})]})]})]})}),_e&&t(v.Field,{name:"permission",children:(U)=>o(Oe,{children:[t($e,{children:Ep()}),o(Fe,{value:U.state.value||"reviewer",onValueChange:(J)=>U.handleChange(J),disabled:!f,children:[t(Ze,{children:t(Le,{})}),o(Be,{children:[t(ne,{value:"reviewer",children:Ni()}),t(ne,{value:"editor",children:Di()}),t(ne,{value:"owner",children:Pi()})]})]})]})}),t(v.Field,{name:"avatar",children:(U)=>o(Oe,{className:"md:col-span-2",children:[t($e,{children:ZA()}),o("div",{className:"flex flex-wrap gap-4 mt-2",children:[Kc.map((J)=>{let Se=U.state.value===J.id;return t("button",{type:"button",onClick:()=>U.handleChange(J.id),className:C("relative w-14 h-14 rounded-full overflow-hidden border-2 transition-all hover:scale-105",Se?"border-primary ring-2 ring-primary ring-offset-2":"border-border hover:border-muted-foreground"),children:t("img",{src:J.preview,className:"w-full h-full object-cover",alt:CS()})},J.id)}),U.state.value&&!Kc.some((J)=>J.id===U.state.value)&&t("button",{type:"button",className:"relative w-14 h-14 rounded-full overflow-hidden border-2 border-primary ring-2 ring-primary ring-offset-2 scale-105",children:t("img",{src:U.state.value,className:"w-full h-full object-cover",alt:iy()})})]})]})})]}),se&&o(Z,{children:[o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 p-4 bg-muted/50 rounded-xl border border-border",children:[t(v.Field,{name:"providerId",children:(U)=>{let J=!!U.state.meta.errors.length&&U.state.meta.isTouched,Se=_?.find((de)=>de.id===U.state.value);return o(Oe,{"data-invalid":J,children:[t($e,{children:jS()}),o(mt,{open:oe,onOpenChange:(de)=>{if(re(de),!de)z("")},modal:!0,children:[t(ht,{asChild:!0,children:o(E,{type:"button",variant:"outline",role:"combobox","aria-expanded":oe,"aria-invalid":J,className:C("w-full justify-between font-normal h-10 px-3 bg-background border-border hover:bg-accent/50",J&&"border-destructive ring-destructive"),children:[t("span",{className:"truncate",children:Se?t("span",{className:"font-medium text-foreground truncate",children:Se.name}):t("span",{className:"text-muted-foreground",children:AC()})}),t(ve,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),o(gt,{className:"w-[--radix-popover-trigger-width] min-w-[320px] max-h-[360px] p-0 flex flex-col overflow-hidden",align:"start",side:"bottom",sideOffset:4,onWheel:(de)=>de.stopPropagation(),children:[o("div",{className:"relative p-2 pb-1.5 border-b border-border shrink-0",children:[t(Bt,{className:"absolute left-4.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),t(H,{placeholder:Pg(),value:Y,onChange:(de)=>z(de.target.value),className:"pl-8 h-8 text-xs bg-muted/40",autoFocus:!0})]}),t(ce,{className:"w-full p-1",style:{height:q.length===0?"96px":`${Math.min(q.length*38+8,256)}px`},onWheel:(de)=>de.stopPropagation(),children:q.length===0?t("div",{className:"flex items-center justify-center h-full py-6 text-xs text-muted-foreground",children:Ex()}):t("div",{className:"space-y-0.5 pr-2",children:q.map((de)=>{let dt=U.state.value===de.id;return o("div",{onClick:()=>{U.handleChange(de.id),v.setFieldValue("modelId",""),G(""),re(!1),z("")},className:C("flex items-center justify-between px-2.5 py-2 rounded-md text-xs cursor-pointer transition-colors",dt?"bg-accent text-accent-foreground font-medium":"hover:bg-muted/60 text-foreground"),children:[t("span",{className:"truncate flex-1 pr-2",children:de.name}),dt&&t(ke,{className:"w-4 h-4 text-primary shrink-0"})]},de.id)})})})]})]}),J&&t(Qe,{errors:Pe(U.state.meta.errors)})]})}}),t(v.Field,{name:"modelId",children:(U)=>{let J=!!U.state.meta.errors.length&&U.state.meta.isTouched,Se=M?.find((de)=>de.id===U.state.value);return o(Oe,{"data-invalid":J,children:[o($e,{className:"flex items-center gap-2",children:[Uw(),O&&t(F,{className:"w-3 h-3 animate-spin"})]}),o(mt,{open:N,onOpenChange:(de)=>{if(X(de),!de)G("")},modal:!0,children:[t(ht,{asChild:!0,children:o(E,{type:"button",variant:"outline",role:"combobox","aria-expanded":N,"aria-invalid":J,disabled:!w||O,className:C("w-full justify-between font-normal h-10 px-3 bg-background border-border hover:bg-accent/50",J&&"border-destructive ring-destructive"),children:[t("span",{className:"truncate flex items-center gap-2",children:Se?o(Z,{children:[t("span",{className:"truncate font-medium text-foreground",children:Se.name||Se.modelId}),Se.name&&Se.name!==Se.modelId&&t(be,{variant:"secondary",className:"font-mono text-[10px] px-1.5 py-0 shrink-0",children:Se.modelId})]}):t("span",{className:"text-muted-foreground",children:pC()})}),t(ve,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),o(gt,{className:"w-[--radix-popover-trigger-width] min-w-[320px] max-h-[360px] p-0 flex flex-col overflow-hidden",align:"start",side:"bottom",sideOffset:4,onWheel:(de)=>de.stopPropagation(),children:[o("div",{className:"relative p-2 pb-1.5 border-b border-border shrink-0",children:[t(Bt,{className:"absolute left-4.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),t(H,{placeholder:wp(),value:j,onChange:(de)=>G(de.target.value),className:"pl-8 h-8 text-xs bg-muted/40",autoFocus:!0})]}),t(ce,{className:"w-full p-1",style:{height:ye.length===0?"96px":`${Math.min(ye.length*38+8,256)}px`},onWheel:(de)=>de.stopPropagation(),children:ye.length===0?t("div",{className:"flex items-center justify-center h-full py-6 text-xs text-muted-foreground",children:bd()}):t("div",{className:"space-y-0.5 pr-2",children:ye.map((de)=>{let dt=U.state.value===de.id;return o("div",{onClick:()=>{U.handleChange(de.id),X(!1),G("")},className:C("flex items-center justify-between px-2.5 py-2 rounded-md text-xs cursor-pointer transition-colors",dt?"bg-accent text-accent-foreground font-medium":"hover:bg-muted/60 text-foreground"),children:[t("div",{className:"min-w-0 flex-1 pr-2",children:o("div",{className:"flex items-center gap-2",children:[t("span",{className:"truncate",children:de.name||de.modelId}),de.name&&de.name!==de.modelId&&o("span",{className:"font-mono text-[10px] text-muted-foreground truncate",children:["(",de.modelId,")"]}),de.config?.reasoning&&t(be,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 gap-0.5 bg-primary/10 text-primary border-primary/20 shrink-0",children:t(jt,{className:"w-2.5 h-2.5"})})]})}),dt&&t(ke,{className:"w-4 h-4 text-primary shrink-0"})]},de.id)})})})]})]}),J&&t(Qe,{errors:Pe(U.state.meta.errors)})]})}}),t("div",{className:"md:col-span-2",children:t(v.Field,{name:"thinkingLevel",children:(U)=>{let J={off:E1(),low:T1(),medium:M1(),high:C1()};return o(Oe,{children:[t($e,{children:I1()}),o(Fe,{value:U.state.value,onValueChange:(Se)=>U.handleChange(Se),children:[t(Ze,{children:t(Le,{})}),t(Be,{children:Wc.options.map((Se)=>t(ne,{value:Se,children:J[Se]||Se},Se))})]})]})}})})]}),t(v.Field,{name:"soul",children:(U)=>o(Oe,{children:[t($e,{children:VA()}),t(_a,{value:U.state.value,onBlur:U.handleBlur,onChange:(J)=>U.handleChange(J.target.value),placeholder:QA(),className:"min-h-[120px]"})]})}),o("div",{className:"space-y-4",children:[o(Q,{className:"text-base font-bold flex items-center gap-2",children:[t(wt,{className:"w-5 h-5 text-primary"}),jg()]}),t("div",{className:"space-y-2",children:t(v.Field,{name:"skills",children:(U)=>o(Z,{children:[y.map((J)=>{let Se=U.state.value?.includes(J.id)||!1;return o("div",{className:"flex items-center justify-between p-3 bg-muted/30 border border-border rounded-lg",children:[o("div",{className:"flex items-center gap-3",children:[t(wt,{className:"w-4 h-4 text-muted-foreground"}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium",children:J.name}),J.description&&t("span",{className:"text-[10px] text-muted-foreground line-clamp-1",children:J.description})]})]}),o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-xs text-muted-foreground",children:Se?Rf():Mf()}),t(je,{checked:Se,onCheckedChange:(de)=>{if(de)U.handleChange([...U.state.value||[],J.id]);else U.handleChange((U.state.value||[]).filter((dt)=>dt!==J.id))}})]})]},J.id)}),y.length===0&&t("div",{className:"text-center py-8 border-2 border-dashed border-border rounded-xl",children:t("p",{className:"text-sm text-muted-foreground",children:Mx()})})]})})})]}),o("div",{className:"space-y-4 border-t border-border pt-6",children:[o(Q,{className:"text-base font-bold flex items-center gap-2",children:[t(bn,{className:"w-5 h-5 text-primary"}),Bc()]}),t("div",{className:"space-y-2",children:t(v.Field,{name:"mcpServerIds",children:(U)=>o(Z,{children:[m.map((J)=>{let Se=U.state.value?.includes(J.id)||!1,de=J.status==="needs_auth"||!J.hasCredential&&J.authType==="oauth";return o("div",{className:"flex items-center justify-between p-3 bg-muted/30 border border-border rounded-lg",children:[o("div",{className:"flex items-center gap-3",children:[t(bn,{className:"w-4 h-4 text-muted-foreground"}),o("div",{className:"flex flex-col",children:[o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-sm font-medium",children:J.name}),o(be,{variant:"outline",className:"text-[10px]",children:[J.toolCount??0," tools"]}),de&&t(be,{variant:"secondary",className:"text-[10px] bg-amber-500/10 text-amber-600 border-amber-500/20",children:Lh()})]}),t("span",{className:"text-[10px] font-mono text-muted-foreground line-clamp-1",children:J.url})]})]}),o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-xs text-muted-foreground",children:Se?Rf():Mf()}),t(je,{checked:Se,onCheckedChange:(dt)=>{if(dt)U.handleChange([...U.state.value||[],J.id]);else U.handleChange((U.state.value||[]).filter((qt)=>qt!==J.id))}})]})]},J.id)}),m.length===0&&t("div",{className:"text-center py-6 border-2 border-dashed border-border rounded-xl",children:t("p",{className:"text-xs text-muted-foreground",children:Wh()})})]})})})]}),o("div",{className:"space-y-4 border-t border-border pt-6",children:[o(Q,{className:"text-base font-bold flex items-center gap-2",children:[t(Io,{className:"w-5 h-5 text-primary"}),c0()]}),t("p",{className:"text-xs text-muted-foreground",children:u0()}),t("div",{className:"space-y-2",children:t(v.Field,{name:"deniedTools",children:(U)=>{let J=U.state.value||[];return t(Z,{children:yr.map((Se)=>{let de=!J.includes(Se.id);return o("div",{className:"flex items-center justify-between p-3 bg-muted/30 border border-border rounded-lg",children:[o("div",{className:"flex items-center gap-3",children:[t(Io,{className:"w-4 h-4 text-muted-foreground"}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium",children:Se.name()}),t("span",{className:"text-[10px] text-muted-foreground line-clamp-1",children:Se.description()})]})]}),o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-xs text-muted-foreground",children:de?Rf():Mf()}),t(je,{checked:de,disabled:!f,onCheckedChange:(dt)=>{if(dt)U.handleChange(J.filter((qt)=>qt!==Se.id));else U.handleChange([...J,Se.id])}})]})]},Se.id)})})}})})]})]})]})}),o(Ge,{className:"p-6 pt-4 border-t border-border flex-shrink-0",children:[t(E,{variant:"outline",onClick:r,type:"button",children:Ne()}),t(v.Subscribe,{selector:(U)=>[U.canSubmit,U.isSubmitting],children:([U,J])=>o(E,{type:"submit",className:"bg-primary hover:bg-primary/90 text-primary-foreground min-w-[120px]",disabled:!U||J||De.isPending||Me.isPending,children:[(J||De.isPending||Me.isPending)&&t(F,{className:"w-4 h-4 animate-spin mr-2"}),s?Us():Q_()]})})]})]})]})})}var xr=[{type:"chat",label:"Chat",icon:vo},{type:"autofill",label:"Autofill",icon:jt},{type:"embedding",label:"Embedding",icon:ao}];function ys({teamId:e}){let r=K(),{canAdmin:a}=Pt(),[l,s]=u(!1),[d,c]=u("chat"),[f,_]=u(null),[g,y]=u(null),[x,m]=u(!1),[i,v]=u({chat:!0,autofill:!0,embedding:!0}),w=(T)=>{if(T==="chat")return Fm();if(T==="autofill")return Om();return Lm()},{data:M=[],isLoading:O}=L({queryKey:["agents",e],queryFn:async()=>{let T=await A.api.teams[":teamId"].agents.$get({param:{teamId:e}});if(!T.ok)throw Error("failed to fetch agents");return[...await T.json()].sort((j,G)=>G.id.localeCompare(j.id))}}),Y=B({mutationFn:async(T)=>{if(!(await A.api.agents[":agentId"].$delete({param:{agentId:T}})).ok)throw Error("failed to delete agent")},onSuccess:()=>{m(!1),r.invalidateQueries({queryKey:["agents",e]}),k.success(UA())},onError:(T)=>{k.error(T.message)}}),z=B({mutationFn:async({agentId:T,permission:q})=>{let j=await A.api.agents[":agentId"].permission.$patch({param:{agentId:T},json:{permission:q}});if(!j.ok)throw Error(gl());return j.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["agents",e]})},onError:(T)=>{k.error(T.message||gl())}}),oe=B({mutationFn:async(T)=>{let q=await A.api.agents[":agentId"].$put({param:{agentId:T.agentId},json:{name:T.name,type:T.type,enabled:T.enabled,avatar:T.avatar,providerId:T.providerId,modelId:T.modelId,thinkingLevel:T.thinkingLevel,systemPrompt:T.systemPrompt,soul:T.soul,skills:T.skills,deniedTools:T.deniedTools}});if(!q.ok)throw Error("failed to update agent");return q.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["agents",e]}),k.success(Zm())},onError:(T)=>{k.error(T.message)}}),re=(T)=>{v((q)=>({...q,[T]:!q[T]}))};return o(Z,{children:[(l||f)&&t(bs,{isOpen:!0,title:f?ch({name:f.name}):ny({type:w(d)}),onClose:()=>{s(!1),_(null)},teamId:e,type:d,initialValues:f||void 0}),t(Je,{open:x,onOpenChange:m,children:o(Xe,{children:[o(et,{children:[t(rt,{children:sd()}),t(nt,{children:vy({name:g?.name??""})})]}),o(tt,{children:[t(st,{children:Ne()}),t(ot,{className:"bg-destructive hover:bg-destructive/90 text-white",onClick:(T)=>{if(Y.isPending){T.preventDefault();return}if(g)Y.mutate(g.id)},children:Y.isPending?t(F,{className:"w-4 h-4 animate-spin"}):by()})]})]})}),O&&M.length===0?t("div",{className:"flex items-center justify-center p-12",children:t(F,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):o("div",{className:"space-y-6 max-w-5xl mx-auto relative",children:[O&&t("div",{className:"absolute top-0 right-0 p-2",children:t(F,{className:"w-4 h-4 animate-spin text-muted-foreground"})}),xr.map((T)=>{let q=M.filter((N)=>N.type===T.type),j=T.icon,G=T.type==="autofill"||T.type==="embedding";return o("div",{className:"bg-card rounded-xl border border-border overflow-hidden",children:[o("div",{className:C("px-6 py-4 flex items-center justify-between",!G&&"cursor-pointer hover:bg-muted/50 transition-colors"),onClick:!G?()=>re(T.type):void 0,children:[o("div",{className:"flex items-center gap-2",children:[t("h3",{className:"font-semibold text-foreground",children:T.type==="chat"?A_():T.type==="autofill"?K0():Jy()}),!G&&t(be,{variant:"secondary",className:"h-5 px-1.5 min-w-[1.25rem] text-[10px]",children:q.length})]}),o("div",{className:"flex items-center gap-2",children:[!(G&&q.length>0)&&t(E,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full bg-primary/10 text-primary hover:bg-primary/20",onClick:(N)=>{N.stopPropagation(),c(T.type),s(!0)},children:t(pe,{className:"w-4 h-4"})}),!G&&t(ve,{className:C("w-5 h-5 text-muted-foreground transition-transform duration-200",i[T.type]?"rotate-180":"")})]})]}),(G||i[T.type])&&t("div",{className:"px-6 pb-6 pt-2 space-y-3",children:o("div",{className:"grid grid-cols-1 gap-4",children:[q.map((N)=>t(Et,{className:"group relative overflow-hidden border-border hover:border-primary/50 transition-all duration-200 cursor-pointer pb-1 pt-1",onClick:()=>_(N),children:o(Mt,{className:"p-4 flex flex-col gap-3",children:[o("div",{className:"flex items-center justify-between",children:[o("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[t("div",{className:"w-10 h-10 rounded-full bg-muted flex items-center justify-center overflow-hidden",children:N.avatar?t("img",{src:N.avatar,className:"w-full h-full object-cover",alt:""}):t(St,{className:"w-6 h-6 text-muted-foreground"})}),o("div",{className:"min-w-0 flex-1",children:[t("span",{className:"font-bold text-foreground block truncate",children:N.name}),t("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:o("span",{className:"flex items-center gap-1",children:[t(wt,{className:"w-3 h-3"}),LC({count:N.skills?.length||0})]})})]})]}),o(he,{modal:!1,children:[t(ge,{asChild:!0,onClick:(X)=>X.stopPropagation(),children:t(E,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:t(wr,{className:"w-4 h-4"})})}),t(Ae,{align:"end",className:"w-32",children:o(W,{onClick:(X)=>{X.stopPropagation(),y(N),m(!0)},className:"text-red-500 focus:text-red-500 gap-2 cursor-pointer",children:[t(we,{className:"w-4 h-4"})," ",it()]})})]})]}),o("div",{className:"flex items-center justify-between gap-2 pt-2 border-t border-border/50",children:[t("div",{children:N.type==="chat"?t("div",{onClick:(X)=>X.stopPropagation(),children:o(Fe,{value:N.permission||"reviewer",onValueChange:(X)=>{z.mutate({agentId:N.id,permission:X})},disabled:!a,children:[t(Ze,{className:"h-7 text-xs px-2 bg-background border-border w-[140px]",children:t(Le,{children:N.permission==="reviewer"?Ni():N.permission==="editor"?Di():Pi()})}),o(Be,{align:"start",children:[t(ne,{value:"reviewer",children:Ni()}),t(ne,{value:"editor",children:Di()}),t(ne,{value:"owner",children:Pi()})]})]})}):t("div",{})}),t("div",{onClick:(X)=>X.stopPropagation(),children:t(je,{checked:N.enabled,onCheckedChange:(X)=>{oe.mutate({teamId:e,agentId:N.id,name:N.name,type:N.type,enabled:X,avatar:N.avatar,providerId:N.providerId,modelId:N.modelId,thinkingLevel:N.thinkingLevel,systemPrompt:N.systemPrompt,soul:N.soul,skills:N.skills?.map((xe)=>xe.skillId),deniedTools:N.deniedTools})}})})]})]})},N.id)),q.length===0&&o("div",{className:"col-span-full py-8 flex flex-col items-center justify-center border-2 border-dashed border-border rounded-xl bg-muted/30",children:[t("div",{className:"w-10 h-10 rounded-full bg-card flex items-center justify-center shadow-sm mb-3",children:t(j,{className:"w-5 h-5 text-muted-foreground"})}),t("p",{className:"text-sm text-muted-foreground",children:dx({type:w(T.type)})}),t(E,{variant:"link",size:"sm",className:"text-primary font-medium h-auto p-0 mt-1",onClick:()=>{c(T.type),s(!0)},children:X_()})]})]})})]},T.type)})]})]})}S();S();function Na({isOpen:e,onClose:r,onSubmit:a,initialValues:l,title:s,isLoading:d=!1,defaultApi:c,existingModelIds:f=[]}){let _=D(()=>iA.extend({modelId:p().min(1,Bh()).refine((m)=>{if(l?.modelId===m)return!0;return!f.includes(m)},{message:qw()})}),[f,l]),g=()=>l||{modelId:"",name:"",config:{api:c,reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},y=$t({defaultValues:g(),validators:{onSubmit:_},onSubmit:async({value:m})=>{a(m)}});h(()=>{if(e)y.reset(g())},[e,l,c,y]);let x=(m)=>m.map((i)=>{if(typeof i==="string")return{message:i};if(i&&typeof i==="object"&&"message"in i)return{message:String(i.message)};return{message:String(i||"")}});return t(ue,{open:e,onOpenChange:r,children:o(ie,{className:"sm:max-w-xl h-[85vh] max-h-[700px] flex flex-col p-0 overflow-hidden",children:[t(me,{className:"p-6 pb-2 shrink-0",children:t(le,{className:"text-xl",children:s})}),o("form",{onSubmit:(m)=>{m.preventDefault(),m.stopPropagation(),y.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t("div",{className:"flex-1 min-h-0",children:t(ce,{className:"h-full",children:o("div",{className:"p-6 pt-2 space-y-6 pr-6",children:[o("div",{className:"space-y-4",children:[t(y.Field,{name:"modelId",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,children:Bh()}),t(H,{id:m.name,name:m.name,value:m.state.value,onBlur:m.handleBlur,onChange:(v)=>m.handleChange(v.target.value),placeholder:Hw(),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}}),t(y.Field,{name:"name",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,children:zy()}),t(H,{id:m.name,name:m.name,value:m.state.value||"",onBlur:m.handleBlur,onChange:(v)=>m.handleChange(v.target.value),placeholder:Gw(),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}})]}),o("div",{className:"space-y-4 pt-2 border-t border-border",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:fS()}),t(y.Field,{name:"config.reasoning",children:(m)=>o(Oe,{orientation:"horizontal",className:"rounded-lg border border-border p-3 shadow-sm bg-muted/40 justify-between flex items-center",children:[t($e,{htmlFor:m.name,className:"cursor-pointer",children:gp()}),t(je,{id:m.name,checked:m.state.value,onCheckedChange:m.handleChange})]})}),o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t(y.Field,{name:"config.contextWindow",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:L_()}),t(H,{id:m.name,name:m.name,type:"number",value:m.state.value,onBlur:m.handleBlur,onChange:(v)=>m.handleChange(parseInt(v.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}}),t(y.Field,{name:"config.maxTokens",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:ow()}),t(H,{id:m.name,name:m.name,type:"number",value:m.state.value,onBlur:m.handleBlur,onChange:(v)=>m.handleChange(parseInt(v.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}})]})]}),o("div",{className:"space-y-4 pt-2 border-t border-border",children:[o("h4",{className:"text-sm font-semibold text-foreground flex items-center gap-1.5",children:[t(ui,{className:"w-4 h-4 text-primary"}),IS()]}),o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t(y.Field,{name:"config.cost.input",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:Nv()}),t(H,{id:m.name,name:m.name,type:"number",step:"0.0001",value:m.state.value,onBlur:m.handleBlur,onChange:(v)=>m.handleChange(parseFloat(v.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}}),t(y.Field,{name:"config.cost.output",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:iS()}),t(H,{id:m.name,name:m.name,type:"number",step:"0.0001",value:m.state.value,onBlur:m.handleBlur,onChange:(v)=>m.handleChange(parseFloat(v.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}}),t(y.Field,{name:"config.cost.cacheRead",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:f_()}),t(H,{id:m.name,name:m.name,type:"number",step:"0.0001",value:m.state.value,onBlur:m.handleBlur,onChange:(v)=>m.handleChange(parseFloat(v.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}}),t(y.Field,{name:"config.cost.cacheWrite",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:p_()}),t(H,{id:m.name,name:m.name,type:"number",step:"0.0001",value:m.state.value,onBlur:m.handleBlur,onChange:(v)=>m.handleChange(parseFloat(v.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}})]})]})]})})}),o(Ge,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[t(E,{type:"button",variant:"outline",onClick:r,disabled:d,children:Ne()}),t(y.Subscribe,{selector:(m)=>[m.canSubmit,m.isSubmitting],children:([m,i])=>t(E,{type:"submit",className:"min-w-[100px]",disabled:!m||i||d,children:i||d?t(F,{className:"w-4 h-4 animate-spin"}):Us()})})]})]})]})})}S();function xs({isOpen:e,onClose:r,teamId:a,syncData:l,onSuccess:s}){let[d,c]=u(""),[f,_]=u(()=>new Set(l?.providers.map((q)=>q.name)||[])),[g,y]=u(()=>{let q=new Set;return l?.providers.forEach((j)=>{j.models.forEach((G)=>{q.add(`${j.name}:${G.modelId}`)})}),q});h(()=>{if(l){_(new Set(l.providers.map((j)=>j.name)));let q=new Set;l.providers.forEach((j)=>{j.models.forEach((G)=>{q.add(`${j.name}:${G.modelId}`)})}),y(q)}},[l]);let x=D(()=>{if(!l)return[];let q=d.trim().toLowerCase();if(!q)return l.providers;return l.providers.map((j)=>{let G=j.name.toLowerCase().includes(q),N=j.models.filter((X)=>G||X.modelId.toLowerCase().includes(q)||X.name.toLowerCase().includes(q));if(N.length>0)return{...j,models:N};return null}).filter((j)=>j!==null)},[l,d]),m=g.size,i=D(()=>{if(!l)return 0;let q=0;for(let j of l.providers)if(j.models.some((N)=>g.has(`${j.name}:${N.modelId}`)))q++;return q},[l,g]),v=(q)=>{_((j)=>{let G=new Set(j);if(G.has(q))G.delete(q);else G.add(q);return G})},w=()=>{if(!l)return;_(new Set(l.providers.map((q)=>q.name)))},M=()=>{_(new Set)},O=(q,j)=>{let G=`${q}:${j}`;y((N)=>{let X=new Set(N);if(X.has(G))X.delete(G);else X.add(G);return X})},Y=(q)=>{let j=l?.providers.find((N)=>N.name===q);if(!j||j.models.length===0)return;let G=j.models.every((N)=>g.has(`${q}:${N.modelId}`));y((N)=>{let X=new Set(N);return j.models.forEach((xe)=>{let ye=`${q}:${xe.modelId}`;if(G)X.delete(ye);else X.add(ye)}),X})},z=()=>{if(!l)return;let q=new Set;l.providers.forEach((j)=>{j.models.forEach((G)=>{q.add(`${j.name}:${G.modelId}`)})}),y(q)},oe=()=>{y(new Set)},re=B({mutationFn:async(q)=>{let j=await A.api.teams[":teamId"].providers["sync-apply"].$post({param:{teamId:a},json:q});if(!j.ok){let G=await j.json().catch(()=>({message:"Failed to apply sync"}));throw Error(G.message||"Failed to apply sync")}return await j.json()},onSuccess:(q)=>{k.success(u1({modelCount:q.addedModels,providerCount:q.addedProviders})),s(),r()},onError:(q)=>{k.error(q.message)}}),T=async()=>{if(!l||m===0)return;let q=[];for(let j of l.providers){let G=j.models.filter((N)=>g.has(`${j.name}:${N.modelId}`));if(G.length>0)q.push({name:j.name,isNewProvider:j.isNewProvider,config:j.config,models:G})}if(q.length===0)return;await re.mutateAsync({providers:q})};return t(ue,{open:e,onOpenChange:(q)=>!q&&r(),children:o(ie,{className:"sm:max-w-3xl md:max-w-4xl w-full h-[85vh] max-h-[85vh] flex flex-col p-0 overflow-hidden gap-0",children:[o(me,{className:"p-6 pb-4 shrink-0",children:[o(le,{className:"flex items-center gap-2 text-xl font-semibold",children:[t(sn,{className:"w-5 h-5 text-primary"}),t1()]}),t(Tt,{className:"text-xs text-muted-foreground leading-relaxed mt-1.5",children:e1()})]}),t("div",{className:"px-6 pb-3 shrink-0",children:o("div",{className:"flex items-center justify-between gap-3",children:[o("div",{className:"relative flex-1",children:[t(Bt,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),t(H,{value:d,onChange:(q)=>c(q.target.value),placeholder:i1(),className:"pl-8 h-8 text-xs bg-background"})]}),o("div",{className:"flex items-center gap-1.5",children:[t(E,{type:"button",variant:"outline",size:"sm",onClick:w,className:"h-8 text-xs px-2.5",children:n1()}),t(E,{type:"button",variant:"outline",size:"sm",onClick:M,className:"h-8 text-xs px-2.5",children:YC()}),t("div",{className:"w-px h-4 bg-border mx-1"}),t(E,{type:"button",variant:"outline",size:"sm",onClick:z,className:"h-8 text-xs px-2.5",children:l1()}),t(E,{type:"button",variant:"outline",size:"sm",onClick:oe,className:"h-8 text-xs px-2.5",children:XC()})]})]})}),t("div",{className:"flex-1 min-h-0 px-6 overflow-hidden",children:t(ce,{className:"h-full border border-border/60 rounded-md bg-muted/20",children:t("div",{className:"p-3 space-y-3",children:x.length===0?t("div",{className:"py-8 text-center text-sm text-muted-foreground",children:Kh()}):x.map((q)=>{let j=f.has(q.name),G=q.isNewProvider,N=q.models.filter((ye)=>g.has(`${q.name}:${ye.modelId}`)).length,X=N===q.models.length,xe=N>0&&!X;return o("div",{className:"border border-border/50 rounded-lg bg-background overflow-hidden",children:[o("div",{className:"flex items-center justify-between px-3 py-2 bg-card hover:bg-muted/40 transition-colors",children:[o("div",{className:"flex items-center gap-2.5",children:[t("button",{type:"button",onClick:()=>v(q.name),className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",children:j?t(ve,{className:"w-4 h-4"}):t(bt,{className:"w-4 h-4"})}),t(Pr,{checked:X?!0:xe?"indeterminate":!1,onCheckedChange:()=>Y(q.name),id:`provider-check-${q.name}`}),o("label",{htmlFor:`provider-check-${q.name}`,className:"font-medium text-sm text-foreground flex items-center gap-2 cursor-pointer select-none",children:[t(ao,{className:"w-4 h-4 text-muted-foreground"}),t("span",{children:q.name})]})]}),o("div",{className:"flex items-center gap-2",children:[G?t(be,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-primary/10 text-primary border-primary/20",children:s1()}):t(be,{variant:"outline",className:"text-[10px] px-1.5 py-0 text-muted-foreground",children:r1()}),t("span",{className:"text-xs text-muted-foreground",children:o1({count:q.models.length})})]})]}),j&&t("div",{className:"border-t border-border/40 divide-y divide-border/30 bg-muted/10",children:q.models.map((ye)=>{let De=g.has(`${q.name}:${ye.modelId}`);return o("div",{className:"flex items-center justify-between pl-9 pr-3 py-2 hover:bg-muted/30 transition-colors",children:[o("div",{className:"flex items-center gap-2.5 min-w-0",children:[t(Pr,{checked:De,onCheckedChange:()=>O(q.name,ye.modelId),id:`model-check-${q.name}-${ye.modelId}`}),o("label",{htmlFor:`model-check-${q.name}-${ye.modelId}`,className:"text-xs font-medium text-foreground cursor-pointer select-none truncate",children:[ye.name||ye.modelId,t("span",{className:"ml-1.5 text-[11px] text-muted-foreground font-mono font-normal",children:ye.modelId})]})]}),o("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[ye.config.reasoning&&t(be,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-normal border-amber-500/30 text-amber-600 dark:text-amber-400",children:a1()}),t("span",{className:"text-[11px] text-muted-foreground font-mono",children:JC({count:Math.round(ye.config.contextWindow/1000)})})]})]},ye.modelId)})})]},q.name)})})})}),o(Ge,{className:"p-6 pt-3 shrink-0 border-t border-border flex items-center justify-between sm:justify-between w-full",children:[t("div",{className:"text-xs text-muted-foreground",children:c1({modelCount:m,providerCount:i})}),o("div",{className:"flex items-center gap-2",children:[t(E,{type:"button",variant:"outline",onClick:r,disabled:re.isPending,children:Ne()}),t(E,{type:"button",onClick:T,disabled:m===0||re.isPending,className:"gap-2",children:re.isPending?o(Z,{children:[t(F,{className:"w-4 h-4 animate-spin"}),KC()]}):QC({count:m})})]})]})]})})}var _s={"openai-completions":"OpenAI Completions","mistral-conversations":"Mistral Conversations","openai-responses":"OpenAI Responses","azure-openai-responses":"Azure OpenAI Responses","openai-codex-responses":"OpenAI Codex Responses","anthropic-messages":"Anthropic Messages","bedrock-converse-stream":"AWS Bedrock","google-generative-ai":"Google Generative AI","google-vertex":"Google Vertex"};function ws({teamId:e}){let r=K(),[a,l]=u(null),[s,d]=u(!1),[c,f]=u(""),[_,g]=u(!1),[y,x]=u(null),[m,i]=u(!1),[v,w]=u(null),M=B({mutationFn:async()=>{let j=await A.api.teams[":teamId"].providers["sync-check"].$post({param:{teamId:e}});if(!j.ok){let G=await j.json().catch(()=>({message:"Failed to check updates"}));throw Error(G.message||"Failed to check updates")}return await j.json()},onSuccess:(j)=>{if(j.totalNewModels===0&&j.totalNewProviders===0){k.info(d1());return}w(j),i(!0)},onError:(j)=>{k.error(j.message)}}),{data:O,isLoading:Y}=L({queryKey:["teams",e,"providers"],queryFn:async()=>{let j=await A.api.teams[":teamId"].providers.$get({param:{teamId:e}});if(!j.ok)throw Error("Failed to fetch providers");return await j.json()}}),z=D(()=>O?.find((j)=>j.id===a)||null,[O,a]),oe=D(()=>O?.map((j)=>j.name)||[],[O]),re=D(()=>{if(!O)return[];if(!c.trim())return O;let j=c.toLowerCase();return O.filter((G)=>G.name.toLowerCase().includes(j))},[O,c]),T=B({mutationFn:async(j)=>{let G=await A.api.teams[":teamId"].providers.$post({param:{teamId:e},json:{name:j.name,config:j.config,models:j.models}});if(!G.ok)throw Error("Failed to create provider");return await G.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"providers"]}),d(!1),k.success(qS())},onError:(j)=>{k.error(Zs({message:j.message}))}}),q=B({mutationFn:async(j)=>{let G=await A.api.providers[":id"].$delete({param:{id:j}});if(!G.ok)throw Error("Failed to delete provider");return await G.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"providers"]}),l(null),g(!1),x(null),k.success(HS())},onError:(j)=>{k.error(Zs({message:j.message}))}});if(Y)return t("div",{className:"flex h-64 items-center justify-center",children:t(F,{className:"h-8 w-8 animate-spin text-primary"})});return o("div",{className:"h-full flex flex-col space-y-0",children:[o("div",{className:"flex-none space-y-4 pb-4",children:[o("div",{className:"flex items-center justify-between",children:[o("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[t(ao,{className:"w-5 h-5 text-primary"}),N_()]}),o("div",{className:"flex items-center gap-2",children:[t(E,{variant:"outline",onClick:()=>M.mutate(),disabled:M.isPending,className:"gap-2",children:M.isPending?o(Z,{children:[t(F,{className:"w-4 h-4 animate-spin"}),WC()]}):o(Z,{children:[t(ca,{className:"w-4 h-4"}),VC()]})}),o(E,{onClick:()=>d(!0),className:"bg-primary hover:bg-primary/90 text-primary-foreground gap-2",children:[t(pe,{className:"w-4 h-4"}),vm()]})]})]}),o("div",{className:"relative px-0.5",children:[t(Bt,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t(H,{placeholder:Pg(),value:c,onChange:(j)=>f(j.target.value),className:"pl-10 bg-card border-border focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-0"})]})]}),t(ce,{className:"flex-1 min-h-0",children:o("div",{className:"pr-4 py-2 grid grid-cols-1 gap-4",children:[re.map((j)=>t(Et,{className:"group cursor-pointer hover:border-primary/50 transition-all hover:shadow-md overflow-hidden",onClick:()=>l(j.id),children:o(Mt,{className:"p-5 flex items-center justify-between gap-4",children:[o("div",{className:"flex items-center gap-4 min-w-0 flex-1",children:[t("div",{className:"flex-none p-3 bg-muted rounded-xl group-hover:bg-primary/10 transition-colors",children:t(da,{className:"w-6 h-6 text-muted-foreground group-hover:text-primary"})}),o("div",{className:"min-w-0 flex-1",children:[t("div",{className:"flex items-center gap-2",children:t("span",{className:"font-bold text-foreground truncate",children:j.name})}),o("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-muted-foreground mt-1",children:[o("span",{className:"flex items-center gap-1 flex-none",children:[t(jt,{className:"w-3 h-3"}),j.config.api]}),j.config.baseUrl&&o("span",{className:"flex items-center gap-1 min-w-0",children:[t("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/30 flex-none"}),t(Ko,{className:"w-3 h-3 flex-none"}),t("span",{className:"truncate max-w-[200px] md:max-w-[300px]",children:j.config.baseUrl})]}),o("span",{className:"flex items-center gap-1 flex-none",children:[t("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/30 flex-none"}),t(Ga,{className:"w-3 h-3"}),Yw({count:j.modelsCount})]})]})]})]}),o("div",{className:"flex items-center gap-1",children:[o(he,{modal:!1,children:[t(ge,{asChild:!0,onClick:(G)=>G.stopPropagation(),children:t(E,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:t(wr,{className:"w-4 h-4"})})}),t(Ae,{align:"end",className:"w-32",children:o(W,{onClick:(G)=>{G.stopPropagation(),x(j),g(!0)},className:"text-destructive focus:text-destructive gap-2 cursor-pointer",children:[t(we,{className:"w-4 h-4"})," ",it()]})})]}),t(bt,{className:"flex-none w-5 h-5 text-muted-foreground/50 group-hover:text-primary transition-colors"})]})]})},j.id)),O?.length===0&&o("div",{className:"text-center py-12 bg-muted/30 rounded-2xl border-2 border-dashed border-border",children:[t(ao,{className:"w-12 h-12 text-muted-foreground/50 mx-auto mb-4"}),t("h4",{className:"text-foreground font-medium",children:Sx()}),t("p",{className:"text-sm text-muted-foreground mt-1",children:EA()})]}),O&&O.length>0&&re.length===0&&o("div",{className:"text-center py-12",children:[t(Bt,{className:"w-12 h-12 text-muted-foreground/50 mx-auto mb-4"}),t("h4",{className:"text-foreground font-medium",children:Kh()}),t("p",{className:"text-sm text-muted-foreground mt-1",children:q1({query:c})}),t(E,{variant:"ghost",size:"sm",onClick:()=>f(""),className:"mt-4 text-primary hover:text-primary/90 hover:bg-primary/10",children:v_()})]})]})}),t(Nr,{isOpen:s,onClose:()=>d(!1),onSubmit:(j)=>T.mutate(j),isLoading:T.isPending,existingProviderNames:oe}),z&&t(Sr,{isOpen:!!z,onClose:()=>l(null),provider:z,teamId:e,existingProviderNames:oe}),t(Je,{open:_,onOpenChange:g,children:o(Xe,{children:[o(et,{children:[t(rt,{children:sd()}),t(nt,{children:ky({name:y?.name??""})})]}),o(tt,{children:[t(st,{onClick:()=>x(null),children:Ne()}),o(ot,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(y)q.mutate(y.id)},children:[q.isPending?t(F,{className:"w-4 h-4 animate-spin mr-2"}):t(we,{className:"w-4 h-4 mr-2"}),it()]})]})]})}),t(xs,{isOpen:m,onClose:()=>i(!1),teamId:e,syncData:v,onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"providers"]})}})]})}function Nr({isOpen:e,onClose:r,onSubmit:a,isLoading:l,existingProviderNames:s}){let[d,c]=u([]),[f,_]=u(!1),[g,y]=u(null),x=D(()=>R({name:p().min(1,ug()).refine((w)=>!s.includes(w),{message:dg()}),config:ri}),[s]),m=$t({defaultValues:{name:"",config:{api:"openai-completions",baseUrl:"",apiKey:""}},validators:{onSubmit:x},onSubmit:async({value:w})=>{a({name:w.name,config:w.config,models:d})}});h(()=>{if(e)m.reset(),c([]),_(!1),y(null)},[e,m]);let i=(w)=>w.map((M)=>{if(typeof M==="string")return{message:M};if(M&&typeof M==="object"&&"message"in M)return{message:String(M.message)};return{message:String(M||"")}}),v=(w)=>{if(g!==null)c((M)=>M.map((O,Y)=>Y===g?w:O)),y(null);else c((M)=>[w,...M]),_(!1)};return t(ue,{open:e,onOpenChange:r,children:o(ie,{className:"sm:max-w-2xl h-[85vh] flex flex-col p-0 overflow-hidden",children:[o(me,{className:"p-6 pb-2 shrink-0",children:[t(le,{className:"text-xl",children:MA()}),t(Tt,{children:Wm()})]}),o("form",{onSubmit:(w)=>{w.preventDefault(),w.stopPropagation(),m.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t("div",{className:"flex-1 min-h-0",children:t(ce,{className:"h-full",children:o("div",{className:"p-6 pt-2 space-y-6 pr-6",children:[o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-5 rounded-2xl border bg-muted/20",children:[t(m.Field,{name:"name",children:(w)=>{let M=!!w.state.meta.errors.length&&w.state.meta.isTouched;return o(Oe,{"data-invalid":M,children:[t($e,{htmlFor:w.name,children:cg()}),t(H,{id:w.name,name:w.name,value:w.state.value,onBlur:w.handleBlur,onChange:(O)=>w.handleChange(O.target.value),placeholder:fg(),"aria-invalid":M}),M&&t(Qe,{errors:i(w.state.meta.errors)})]})}}),t(m.Field,{name:"config.api",children:(w)=>{let M=!!w.state.meta.errors.length&&w.state.meta.isTouched;return o(Oe,{"data-invalid":M,children:[t($e,{htmlFor:w.name,children:Ch()}),o(Fe,{onValueChange:w.handleChange,value:w.state.value,children:[t(Ze,{id:w.name,"aria-invalid":M,children:t(Le,{placeholder:Og()})}),t(Be,{children:Yc.map((O)=>t(ne,{value:O,children:_s[O]},O))})]}),M&&t(Qe,{errors:i(w.state.meta.errors)})]})}}),t("div",{className:"md:col-span-2",children:t(m.Field,{name:"config.baseUrl",children:(w)=>{let M=!!w.state.meta.errors.length&&w.state.meta.isTouched;return o(Oe,{"data-invalid":M,children:[t($e,{htmlFor:w.name,children:Vm()}),t(H,{id:w.name,name:w.name,value:w.state.value||"",onBlur:w.handleBlur,onChange:(O)=>w.handleChange(O.target.value),placeholder:"https://api.openai.com/v1","aria-invalid":M}),t(aa,{children:eg()}),M&&t(Qe,{errors:i(w.state.meta.errors)})]})}})}),t("div",{className:"md:col-span-2",children:t(m.Field,{name:"config.apiKey",children:(w)=>{let M=!!w.state.meta.errors.length&&w.state.meta.isTouched;return o(Oe,{"data-invalid":M,children:[t($e,{htmlFor:w.name,children:od()}),t(H,{id:w.name,name:w.name,type:"text",value:w.state.value||"",onBlur:w.handleBlur,onChange:(O)=>w.handleChange(O.target.value),placeholder:jm(),"aria-invalid":M}),t(aa,{className:"text-xs mt-1",children:zm()}),M&&t(Qe,{errors:i(w.state.meta.errors)})]})}})})]}),o("div",{className:"space-y-3",children:[o("div",{className:"flex items-center justify-between",children:[o("div",{children:[t(Q,{className:"text-base font-semibold",children:_d()}),t("p",{className:"text-xs text-muted-foreground mt-0.5",children:Qw()})]}),o(E,{type:"button",variant:"outline",size:"sm",onClick:()=>_(!0),className:"gap-1.5",children:[t(pe,{className:"w-4 h-4"}),td()]})]}),d.length===0?t("div",{className:"text-center py-8 rounded-xl border border-dashed text-muted-foreground text-sm",children:bd()}):t("div",{className:"space-y-2",children:d.map((w,M)=>o("div",{className:"group cursor-pointer flex items-center justify-between p-3 rounded-xl border bg-card hover:border-primary/50 transition-all shadow-none hover:shadow-sm",onClick:()=>y(M),children:[o("div",{className:"min-w-0 flex-1",children:[o("div",{className:"flex items-center gap-2",children:[t("span",{className:"font-semibold text-foreground truncate",children:w.name||w.modelId}),t(be,{variant:"secondary",className:"font-mono text-[10px]",children:w.modelId}),w.config.reasoning&&o(be,{variant:"outline",className:"text-[10px] gap-1 bg-primary/10 text-primary border-primary/20",children:[t(jt,{className:"w-2.5 h-2.5"})," ",gp()]})]}),o("div",{className:"text-xs text-muted-foreground mt-1 flex items-center gap-2",children:[o("span",{children:[w.config.contextWindow?.toLocaleString()," ",Jg()]}),t("span",{children:"·"}),t("span",{children:eh({input:w.config.cost?.input??0,output:w.config.cost?.output??0})})]})]}),t("div",{className:"flex items-center gap-1 ml-2",children:t(E,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:(O)=>{O.stopPropagation(),c((Y)=>Y.filter((z,oe)=>oe!==M))},children:t(we,{className:"w-3.5 h-3.5"})})})]},w.modelId+M))})]})]})})}),o(Ge,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[t(E,{type:"button",variant:"outline",onClick:r,disabled:l,children:Ne()}),t(m.Subscribe,{selector:(w)=>[w.canSubmit,w.isSubmitting],children:([w,M])=>t(E,{type:"submit",className:"min-w-[120px]",disabled:!w||M||l,children:M||l?t(F,{className:"w-4 h-4 animate-spin"}):vm()})})]})]}),(f||g!==null)&&t(Na,{isOpen:!0,onClose:()=>{_(!1),y(null)},onSubmit:v,title:g!==null?uh():td(),initialValues:g!==null?d[g]:null,defaultApi:m.getFieldValue("config.api"),existingModelIds:d.filter((w,M)=>M!==g).map((w)=>w.modelId)},g!==null?`edit-${g}-${d[g]?.modelId}`:"add")]})})}function Sr({isOpen:e,onClose:r,provider:a,teamId:l,existingProviderNames:s}){let d=K(),[c,f]=u("general"),[_,g]=u(""),[y,x]=u(!1),[m,i]=u(null),[v,w]=u(null),{data:M=[],isLoading:O}=L({queryKey:["teams",l,"providers",a.id,"models"],queryFn:async()=>{let N=await A.api.providers[":id"].models.$get({param:{id:a.id}});if(!N.ok)throw Error("Failed to fetch models");return await N.json()},enabled:e}),Y=B({mutationFn:async(N)=>{let X=await A.api.providers[":id"].$put({param:{id:a.id},json:{name:N.name,config:N.config}});if(!X.ok)throw Error("Failed to update provider");return await X.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers"]}),k.success(gg())},onError:(N)=>{k.error(Zs({message:N.message}))}}),z=B({mutationFn:async(N)=>{let X=await A.api.providers[":id"].models.$post({param:{id:a.id},json:N});if(!X.ok)throw Error("Failed to create model");return await X.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers",a.id,"models"]}),d.invalidateQueries({queryKey:["teams",l,"providers"]}),x(!1),k.success(zw())},onError:(N)=>{k.error(Zs({message:N.message}))}}),oe=B({mutationFn:async({modelDbId:N,values:X})=>{let xe=await A.api.providers[":id"].models[":modelDbId"].$put({param:{id:a.id,modelDbId:N},json:X});if(!xe.ok)throw Error("Failed to update model");return await xe.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers",a.id,"models"]}),i(null),k.success(Vw())},onError:(N)=>{k.error(Zs({message:N.message}))}}),re=B({mutationFn:async(N)=>{let X=await A.api.providers[":id"].models[":modelDbId"].$delete({param:{id:a.id,modelDbId:N}});if(!X.ok)throw Error("Failed to delete model");return await X.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers",a.id,"models"]}),d.invalidateQueries({queryKey:["teams",l,"providers"]}),w(null),k.success(jw())},onError:(N)=>{k.error(Zs({message:N.message}))}}),T=D(()=>R({name:p().min(1,ug()).refine((N)=>{if(a.name===N)return!0;return!s.includes(N)},{message:dg()}),config:ri}),[s,a.name]),q=$t({defaultValues:{name:a.name,config:a.config},validators:{onSubmit:T},onSubmit:async({value:N})=>{Y.mutate({name:N.name,config:N.config})}});h(()=>{if(e)q.reset(),f("general"),g("")},[e,q]);let j=(N)=>N.map((X)=>{if(typeof X==="string")return{message:X};if(X&&typeof X==="object"&&"message"in X)return{message:String(X.message)};return{message:String(X||"")}}),G=D(()=>{if(!_.trim())return M;let N=_.toLowerCase();return M.filter((X)=>X.modelId.toLowerCase().includes(N)||X.name?.toLowerCase().includes(N))},[M,_]);return t(ue,{open:e,onOpenChange:r,children:o(ie,{className:"sm:max-w-3xl h-[88vh] flex flex-col p-0 overflow-hidden",children:[o(me,{className:"p-6 pb-2 shrink-0",children:[t(le,{className:"text-xl",children:ch({name:a.name})}),t(Tt,{children:Wm()})]}),o(xo,{value:c,onValueChange:(N)=>f(N),className:"flex-1 flex flex-col min-h-0",children:[t("div",{className:"px-6 pb-2 shrink-0",children:o(So,{className:"grid w-full grid-cols-2",children:[t(Qr,{value:"general",children:Eh()}),o(Qr,{value:"models",className:"gap-2",children:[_d(),t(be,{variant:"secondary",className:"h-5 px-1.5 text-[11px]",children:M.length})]})]})}),t(kn,{value:"general",className:"flex-1 flex flex-col min-h-0 m-0",children:o("form",{onSubmit:(N)=>{N.preventDefault(),N.stopPropagation(),q.handleSubmit()},className:"flex-1 flex flex-col min-h-0",children:[t("div",{className:"flex-1 min-h-0",children:t(ce,{className:"h-full",children:t("div",{className:"p-6 space-y-6 pr-6",children:o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5 p-5 rounded-2xl border bg-muted/10",children:[t(q.Field,{name:"name",children:(N)=>{let X=!!N.state.meta.errors.length&&N.state.meta.isTouched;return o(Oe,{"data-invalid":X,children:[t($e,{htmlFor:N.name,children:cg()}),t(H,{id:N.name,name:N.name,value:N.state.value,onBlur:N.handleBlur,onChange:(xe)=>N.handleChange(xe.target.value),placeholder:fg(),"aria-invalid":X}),X&&t(Qe,{errors:j(N.state.meta.errors)})]})}}),t(q.Field,{name:"config.api",children:(N)=>{let X=!!N.state.meta.errors.length&&N.state.meta.isTouched;return o(Oe,{"data-invalid":X,children:[t($e,{htmlFor:N.name,children:Ch()}),o(Fe,{onValueChange:N.handleChange,value:N.state.value,children:[t(Ze,{id:N.name,"aria-invalid":X,children:t(Le,{placeholder:Og()})}),t(Be,{children:Yc.map((xe)=>t(ne,{value:xe,children:_s[xe]},xe))})]}),X&&t(Qe,{errors:j(N.state.meta.errors)})]})}}),t("div",{className:"md:col-span-2",children:t(q.Field,{name:"config.baseUrl",children:(N)=>{let X=!!N.state.meta.errors.length&&N.state.meta.isTouched;return o(Oe,{"data-invalid":X,children:[t($e,{htmlFor:N.name,children:Vm()}),t(H,{id:N.name,name:N.name,value:N.state.value||"",onBlur:N.handleBlur,onChange:(xe)=>N.handleChange(xe.target.value),placeholder:"https://api.openai.com/v1","aria-invalid":X}),t(aa,{children:eg()}),X&&t(Qe,{errors:j(N.state.meta.errors)})]})}})}),t("div",{className:"md:col-span-2",children:t(q.Field,{name:"config.apiKey",children:(N)=>{let X=!!N.state.meta.errors.length&&N.state.meta.isTouched;return o(Oe,{"data-invalid":X,children:[t($e,{htmlFor:N.name,children:od()}),t(H,{id:N.name,name:N.name,type:"text",value:N.state.value||"",onBlur:N.handleBlur,onChange:(xe)=>N.handleChange(xe.target.value),placeholder:jm(),"aria-invalid":X}),t(aa,{className:"text-xs mt-1",children:zm()}),X&&t(Qe,{errors:j(N.state.meta.errors)})]})}})})]})})})}),o(Ge,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[t(E,{type:"button",variant:"outline",onClick:r,children:Ne()}),t(q.Subscribe,{selector:(N)=>[N.canSubmit,N.isSubmitting],children:([N,X])=>t(E,{type:"submit",className:"min-w-[120px]",disabled:!N||X||Y.isPending,children:X||Y.isPending?t(F,{className:"w-4 h-4 animate-spin"}):Us()})})]})]})}),o(kn,{value:"models",className:"flex-1 flex flex-col min-h-0 m-0",children:[o("div",{className:"p-6 pb-3 flex items-center justify-between gap-3 shrink-0",children:[o("div",{className:"relative flex-1 max-w-sm",children:[t(Bt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t(H,{placeholder:wp(),value:_,onChange:(N)=>g(N.target.value),className:"pl-9 h-9"})]}),o(E,{size:"sm",onClick:()=>x(!0),className:"gap-1.5 shrink-0",children:[t(pe,{className:"w-4 h-4"}),td()]})]}),t("div",{className:"flex-1 min-h-0 px-6",children:t(ce,{className:"h-full pr-4",children:O?t("div",{className:"flex h-48 items-center justify-center",children:t(F,{className:"h-6 w-6 animate-spin text-primary"})}):G.length===0?t("div",{className:"text-center py-12 border border-dashed rounded-xl text-muted-foreground text-sm",children:bd()}):t("div",{className:"space-y-2 pb-4",children:G.map((N)=>o("div",{className:"group cursor-pointer flex items-center justify-between p-3.5 rounded-xl border bg-card hover:border-primary/50 transition-all shadow-none hover:shadow-sm",onClick:()=>i(N),children:[o("div",{className:"min-w-0 flex-1 pr-3",children:[o("div",{className:"flex items-center gap-2 flex-wrap",children:[t("span",{className:"font-semibold text-foreground text-sm",children:N.name||N.modelId}),t(be,{variant:"secondary",className:"font-mono text-[10px] px-1.5 py-0.5",children:N.modelId}),N.config?.reasoning&&o(be,{variant:"outline",className:"text-[10px] gap-1 bg-primary/10 text-primary border-primary/20 h-5",children:[t(jt,{className:"w-2.5 h-2.5"})," ",gp()]})]}),o("div",{className:"text-xs text-muted-foreground mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1",children:[o("span",{children:[N.config?.contextWindow?.toLocaleString()," ",Jg()]}),t("span",{children:"·"}),t("span",{children:sw({count:N.config?.maxTokens?.toLocaleString()??"0"})}),t("span",{children:"·"}),t("span",{children:eh({input:N.config?.cost?.input??0,output:N.config?.cost?.output??0})})]})]}),t("div",{className:"flex items-center gap-1 shrink-0",children:t(E,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:(X)=>{X.stopPropagation(),w(N)},children:t(we,{className:"w-3.5 h-3.5"})})})]},N.id))})})})]})]}),y&&t(Na,{isOpen:y,onClose:()=>x(!1),onSubmit:(N)=>z.mutate(N),title:td(),isLoading:z.isPending,defaultApi:a.config.api,existingModelIds:M.map((N)=>N.modelId)}),m&&t(Na,{isOpen:!!m,onClose:()=>i(null),onSubmit:(N)=>oe.mutate({modelDbId:m.id,values:N}),title:uh(),isLoading:oe.isPending,initialValues:{modelId:m.modelId,name:m.name,config:m.config},defaultApi:a.config.api,existingModelIds:M.filter((N)=>N.id!==m.id).map((N)=>N.modelId)}),t(Je,{open:!!v,onOpenChange:(N)=>!N&&w(null),children:o(Xe,{children:[o(et,{children:[t(rt,{children:sd()}),t(nt,{children:Iy({name:v?.name||v?.modelId||""})})]}),o(tt,{children:[t(st,{onClick:()=>w(null),children:Ne()}),o(ot,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(v)re.mutate(v.id)},children:[re.isPending?t(F,{className:"w-4 h-4 animate-spin mr-2"}):t(we,{className:"w-4 h-4 mr-2"}),it()]})]})]})})]})})}S();function Ns({teamId:e}){let r=K(),[a,l]=u(""),{data:s,isLoading:d}=L({queryKey:["teams",e,"sandbox"],queryFn:async()=>{let v=await A.api.teams[":teamId"].sandbox.$get({param:{teamId:e}});if(!v.ok)throw Error(Wo());return await v.json()}}),{mutate:c,isPending:f}=B({mutationFn:async(v)=>{let w=await A.api.teams[":teamId"].sandbox.$put({param:{teamId:e},json:v});if(!w.ok)throw Error(_h());return await w.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"sandbox"]}),k.success(GE())},onError:(v)=>{k.error(v instanceof Error?v.message:_h())}}),_=(v)=>{c({networkSandboxEnabled:v})},g=(v)=>{if(v.preventDefault(),!a.trim())return;if(s?.allowedDomains.includes(a.trim())){k.error(jy());return}let w=[...s?.allowedDomains||[],a.trim()],M=s?.pendingDomains||[];c({allowedDomains:w,pendingDomains:M}),l("")},y=(v)=>{let w=(s?.allowedDomains||[]).filter((O)=>O!==v),M=s?.pendingDomains||[];c({allowedDomains:w,pendingDomains:M})},x=(v)=>{let w=[...s?.allowedDomains||[],v],M=(s?.pendingDomains||[]).filter((O)=>O!==v);c({allowedDomains:w,pendingDomains:M})},m=(v)=>{let w=(s?.pendingDomains||[]).filter((M)=>M!==v);c({allowedDomains:s?.allowedDomains||[],pendingDomains:w})};if(d)return t("div",{className:"flex items-center justify-center p-8",children:t(F,{className:"h-8 w-8 animate-spin text-muted-foreground"})});let i=!!s?.networkSandboxEnabled;return t(ce,{className:"h-full",children:o("div",{className:"space-y-6 pr-4 pb-8",children:[o(Et,{children:[o(kt,{children:[o("div",{className:"flex items-center gap-2",children:[t(da,{className:"w-5 h-5 text-primary"}),t(Rt,{children:tx()})]}),t(Ut,{children:rx()})]}),o(Mt,{children:[o("div",{className:"flex items-center justify-between p-4 mb-6 rounded-lg border border-border bg-muted/30",children:[o("div",{className:"space-y-0.5 pr-4",children:[t("label",{htmlFor:"network-sandbox-switch",className:"text-sm font-medium text-foreground cursor-pointer",children:rb()}),t("p",{className:"text-xs text-muted-foreground",children:ox()})]}),t(je,{id:"network-sandbox-switch",checked:i,onCheckedChange:_,disabled:f})]}),!i&&o("div",{className:"flex items-start gap-2.5 p-3.5 mb-6 rounded-lg bg-amber-500/10 border border-amber-500/20 text-amber-700 dark:text-amber-300 text-sm",children:[t(Ko,{className:"w-4 h-4 mt-0.5 shrink-0"}),t("span",{children:nx()})]}),o("form",{onSubmit:g,className:"flex gap-2 mb-6",children:[t(H,{placeholder:"e.g. api.openai.com",value:a,onChange:(v)=>l(v.target.value),disabled:f||!i}),o(E,{type:"submit",disabled:f||!i,children:[f?t(F,{className:"w-4 h-4 animate-spin"}):t(pe,{className:"w-4 h-4 mr-2"}),SA()]})]}),o("div",{className:"space-y-2",children:[t("h4",{className:"text-sm font-medium text-muted-foreground mb-3",children:R0()}),o("div",{className:"flex flex-wrap gap-2",children:[s?.allowedDomains.map((v)=>o("div",{className:"flex items-center gap-1 px-3 py-1.5 bg-muted rounded-full text-sm border border-border transition-all hover:border-muted-foreground/50",children:[t("span",{className:"font-medium text-foreground",children:v}),t("button",{onClick:()=>y(v),className:"ml-1 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50 disabled:cursor-not-allowed",disabled:f||!i,children:t(Re,{className:"w-3.5 h-3.5"})})]},v)),s?.allowedDomains.length===0&&t("div",{className:"text-sm text-muted-foreground italic",children:gx()})]})]})]})]}),o(Et,{className:"border-orange-500/20 bg-orange-500/5",children:[o(kt,{children:[o("div",{className:"flex items-center gap-2",children:[t(Gl,{className:"w-5 h-5 text-orange-500"}),t(Rt,{children:AS()})]}),t(Ut,{children:_S()})]}),t(Mt,{children:t("div",{className:"space-y-3",children:s?.pendingDomains&&s.pendingDomains.length>0?t("div",{className:"divide-y divide-border",children:s.pendingDomains.map((v)=>o("div",{className:"flex items-center justify-between py-2.5 first:pt-0 last:pb-0",children:[t("span",{className:"font-mono text-sm text-foreground bg-muted px-2 py-1 rounded break-all",children:v}),o("div",{className:"flex items-center gap-2",children:[o(E,{size:"sm",variant:"outline",className:"h-8 border-emerald-500/20 text-emerald-600 hover:bg-emerald-500/10 hover:text-emerald-600 dark:text-emerald-400 dark:hover:bg-emerald-500/20",onClick:()=>x(v),disabled:f||!i,children:[t(ke,{className:"w-4 h-4 mr-1.5"}),B0()]}),o(E,{size:"sm",variant:"outline",className:"h-8 border-destructive/20 text-destructive hover:bg-destructive/10",onClick:()=>m(v),disabled:f||!i,children:[t(we,{className:"w-4 h-4 mr-1.5"}),it()]})]})]},v))}):t("div",{className:"text-sm text-muted-foreground italic py-2",children:xx()})})})]}),t(Et,{children:o(kt,{children:[t(Rt,{children:Kb()}),t(Ut,{children:Wb()})]})})]})})}S();var Cr=(e)=>o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[t("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),t("path",{d:"M9 18c-4.51 2-5-2-7-2"})]}),Ss=({teamId:e})=>{let r=K(),{canAdmin:a}=Pt(),[l,s]=u(!1),[d,c]=u(!1),[f,_]=u(!1),[g,y]=u(null),{data:x,isLoading:m}=L({queryKey:["teams",e,"skills"],queryFn:async()=>{let M=await A.api.teams[":teamId"].skills.$get({param:{teamId:e}});if(!M.ok)throw Error(Wo());return await M.json()}}),i=B({mutationFn:async(M)=>{if(!(await A.api.skills[":id"].$delete({param:{id:M}})).ok)throw Error(ki())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"skills"]}),_(!1)}}),v=B({mutationFn:async({id:M,permission:O})=>{if(!(await A.api.skills[":id"].permission.$patch({param:{id:M},json:{permission:O}})).ok)throw Error(gl())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"skills"]})},onError:(M)=>{alert(M.message||gl())}}),w=x?.skills||[];return o(Et,{children:[o(kt,{className:"flex flex-row items-center justify-between space-y-0 pb-7",children:[o("div",{className:"flex items-center gap-3",children:[t("div",{className:"p-2 bg-primary/10 text-primary rounded-lg",children:t(wt,{className:"w-6 h-6"})}),o("div",{children:[t(Rt,{className:"text-xl font-bold",children:qg()}),t(Ut,{children:BC()})]})]}),o(E,{onClick:()=>s(!0),className:"gap-2",children:[t(pe,{className:"w-4 h-4"})," ",NA()]})]}),t(Mt,{children:m?t("div",{className:"flex justify-center py-10",children:t(F,{className:"w-8 h-8 animate-spin text-primary"})}):w.length===0?o("div",{className:"text-center py-12 border-2 border-dashed border-border rounded-xl",children:[t("div",{className:"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4 text-muted-foreground",children:t(wt,{className:"w-6 h-6"})}),t("h3",{className:"text-lg font-medium text-foreground",children:kx()}),t("p",{className:"text-muted-foreground mt-1 max-w-xs mx-auto",children:DA()})]}):t("div",{className:"space-y-4",children:w.map((M)=>t(kr,{skill:M,canAdmin:a,onDelete:()=>{y(M),_(!0)},onConfigure:()=>{y(M),c(!0)},onPermissionChange:(O)=>v.mutate({id:M.id,permission:O})},M.id))})}),t(Mr,{open:l,onOpenChange:s,teamId:e}),g&&t(Fr,{open:d,onOpenChange:(M)=>{if(c(M),!M)setTimeout(()=>{document.body.style.pointerEvents="auto"},100)},teamId:e,skill:g}),t(Je,{open:f,onOpenChange:_,children:o(Xe,{children:[o(et,{children:[t(rt,{children:sd()}),t(nt,{children:Dy({name:g?.name??""})})]}),o(tt,{children:[t(st,{children:Ne()}),o(ot,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(g)i.mutate(g.id)},children:[i.isPending?t(F,{className:"w-4 h-4 animate-spin mr-2"}):t(we,{className:"w-4 h-4 mr-2"}),it()]})]})]})})]})},kr=({skill:e,canAdmin:r,onDelete:a,onConfigure:l,onPermissionChange:s})=>o("div",{className:"p-4 bg-card rounded-xl border border-border flex flex-col justify-between hover:shadow-md transition-all group cursor-pointer",onClick:l,children:[o("div",{children:[o("div",{className:"flex items-start justify-between mb-2",children:[t("h4",{className:"font-bold text-foreground flex items-center gap-2",children:e.name}),o(he,{children:[t(ge,{asChild:!0,onClick:(d)=>d.stopPropagation(),children:t(E,{variant:"ghost",size:"icon",className:"h-8 w-8",children:t(wr,{className:"w-4 h-4"})})}),t(Ae,{align:"end",className:"w-32",children:o(W,{onClick:(d)=>{d.stopPropagation(),a()},className:"text-destructive focus:text-destructive gap-2 cursor-pointer",children:[t(we,{className:"w-4 h-4"})," ",it()]})})]})]}),t("p",{className:"text-sm text-muted-foreground line-clamp-2",children:e.description||Vh()})]}),o("div",{className:"mt-4 flex items-center justify-between gap-2 pt-2 border-t border-border/50 text-xs",children:[o("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider font-semibold",children:[rA()," ",new Date(e.updatedAt).toLocaleDateString()]}),t("div",{className:"flex items-center gap-2",onClick:(d)=>d.stopPropagation(),children:o(Fe,{value:e.permission||"reviewer",onValueChange:(d)=>s(d),disabled:!r,children:[t(Ze,{className:"h-7 text-xs px-2 bg-background border-border w-[140px]",children:t(Le,{placeholder:Ep()})}),o(Be,{align:"end",children:[t(ne,{value:"reviewer",children:Ni()}),t(ne,{value:"editor",children:Di()}),t(ne,{value:"owner",children:Pi()})]})]})})]})]}),Mr=({open:e,onOpenChange:r,teamId:a})=>{let l=K(),[s,d]=u(""),[c,f]=u(!1),_=b(null),{data:g}=L({queryKey:["teams",a,"projects"],queryFn:async()=>{let m=await A.api.teams[":teamId"].projects.$get({param:{teamId:a},query:{first:"1"}});if(!m.ok)throw Error("Failed to fetch projects");return await m.json()},enabled:e}),y=async(m)=>{f(!0);try{let i=await A.api.teams[":teamId"].skills.$post({param:{teamId:a},json:m});if(i.status===409){let v=await i.json();if(window.confirm(`${v.error}
|
|
2
|
+
|
|
3
|
+
${lS()}`)){await y({...m,override:!0});return}}else if(!i.ok){let v=await i.json().catch(()=>({}));throw Error(v.error||Mb())}else l.invalidateQueries({queryKey:["teams",a,"skills"]}),r(!1),d("")}catch(i){if(i instanceof Error)alert(i.message);else alert(nd())}finally{f(!1)}},x=async(m)=>{if(!m||m.length===0)return;let i=g?.data?.[0]?.id;if(!i){alert(ex());return}let v=m[0];if(!v.name.toLowerCase().endsWith(".zip")){alert(Ux());return}f(!0);try{let w=v.name,M=v.type||"application/zip",O=await A.api.projects[":projectId"].attachments.$post({param:{projectId:i},json:{fileName:w,size:v.size,contentType:M}});if(!O.ok)throw Error("Failed to get upload URL");let{id:Y,uploadUrl:z}=await O.json();if(!(await fetch(z,{method:"PUT",body:v,headers:{"Content-Type":M}})).ok)throw Error("Failed to upload file to storage");await y({assetId:Y})}catch(w){if(w instanceof Error)alert(w.message);else alert(nd())}finally{f(!1)}};return t(ue,{open:e,onOpenChange:r,children:o(ie,{className:"sm:max-w-[450px]",children:[o(me,{children:[t(le,{children:kA()}),t(Tt,{children:Rv()})]}),o("div",{className:"space-y-6 pt-4",children:[o("div",{className:"space-y-3",children:[t(Q,{children:cS()}),o("div",{onClick:()=>!c&&_.current?.click(),className:C("group relative h-32 border-2 border-dashed rounded-xl flex flex-col items-center justify-center transition-all cursor-pointer",c?"opacity-50 cursor-not-allowed bg-muted/50 border-border":"hover:bg-primary/5 hover:border-primary/50 border-border"),children:[t("input",{type:"file",ref:_,className:"hidden",accept:".zip",onChange:(m)=>x(m.target.files)}),t("div",{className:"p-3 bg-muted rounded-full group-hover:bg-primary/10 transition-colors",children:t(lo,{className:"w-6 h-6 text-muted-foreground group-hover:text-primary"})}),o("div",{className:"mt-3 text-center",children:[t("p",{className:"text-sm font-medium text-foreground",children:vC()}),t("p",{className:"text-[10px] text-muted-foreground mt-1 uppercase tracking-wider font-semibold",children:uS()})]})]}),c&&!s&&o("div",{className:"flex items-center gap-2 text-sm text-primary justify-center bg-primary/10 py-2 rounded-lg animate-pulse",children:[t(F,{className:"w-4 h-4 animate-spin"}),MS()]})]}),o("div",{className:"relative",children:[t("div",{className:"absolute inset-0 flex items-center",children:t("span",{className:"w-full border-t border-border"})}),t("div",{className:"relative flex justify-center text-xs uppercase",children:t("span",{className:"bg-background px-2 text-muted-foreground font-bold",children:sS()})})]}),t("div",{className:"space-y-4",children:o("div",{className:"space-y-2",children:[t(Q,{htmlFor:"githubUrl",children:uv()}),o("div",{className:"flex gap-2",children:[o("div",{className:"relative flex-1",children:[t(Cr,{className:"absolute left-3 top-2.5 w-4 h-4 text-muted-foreground"}),t(H,{id:"githubUrl",placeholder:"https://github.com/owner/repo",value:s,onChange:(m)=>d(m.target.value),disabled:c,className:"pl-9"})]}),t(E,{onClick:()=>y({githubUrl:s}),disabled:!s||c,className:"px-6",children:c&&s?t(F,{className:"w-4 h-4 animate-spin"}):Dv()})]}),t("p",{className:"text-[10px] text-muted-foreground italic",children:dv()})]})})]})]})})},Fr=({open:e,onOpenChange:r,teamId:a,skill:l})=>{let s=K(),[d,c]=u({...l.config||{},environmentVariables:l.config?.environmentVariables||[]}),[f,_]=u(!1),g=(w,M)=>{let O=[...d.environmentVariables];O[w]={...O[w],default:M},c({...d,environmentVariables:O})},y=(w,M)=>{let O=[...d.environmentVariables];O[w]={...O[w],name:M},c({...d,environmentVariables:O})},x=()=>{c({...d,environmentVariables:[...d.environmentVariables,{name:"",default:""}]})},m=(w)=>{let M=[...d.environmentVariables];M.splice(w,1),c({...d,environmentVariables:M})},i=async()=>{let w=d.environmentVariables.filter((O)=>O.name.trim()!==""),M={...d,environmentVariables:w};_(!0);try{let O=await A.api.skills[":id"].config.$patch({param:{id:l.id},json:{config:M}});if(!O.ok){let Y=await O.json().catch(()=>({}));throw Error(Y.error||"Failed to update config")}s.invalidateQueries({queryKey:["teams",a,"skills"]}),r(!1)}catch(O){if(O instanceof Error)alert(O.message);else alert(nd())}finally{_(!1)}},v=d?.environmentVariables||[];return t(ue,{open:e,onOpenChange:r,children:o(ie,{className:"sm:max-w-[500px]",children:[o(me,{children:[t("div",{className:"flex items-center justify-between",children:o(le,{className:"flex items-center gap-2",children:[t(Ql,{className:"w-5 h-5 text-primary"}),R_({name:l.name})]})}),t(Tt,{children:Jv()})]}),t(ce,{className:"max-h-[60vh]",children:t("div",{className:"py-4 space-y-4 pr-4",children:v.length===0?t("div",{className:"text-center py-10 bg-muted/50 rounded-xl border border-dashed border-border",children:t("p",{className:"text-muted-foreground text-sm italic",children:Ax()})}):v.map((w,M)=>o("div",{className:"p-4 bg-muted/50 rounded-xl border border-border space-y-3 relative group",children:[t("button",{onClick:()=>m(M),className:"absolute top-2 right-2 p-1 text-muted-foreground hover:text-destructive hover:bg-destructive/10 rounded-md transition-colors opacity-0 group-hover:opacity-100",children:t(Re,{className:"w-4 h-4"})}),o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-[10px] uppercase tracking-wider font-bold text-muted-foreground",children:nI()}),t(H,{value:w.name,onChange:(O)=>y(M,O.target.value),placeholder:"e.g. API_KEY",className:"h-8 bg-background border-border text-sm font-mono"})]}),o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-[10px] uppercase tracking-wider font-bold text-muted-foreground",children:yy()}),t(H,{value:w.default||"",onChange:(O)=>g(M,O.target.value),placeholder:oS(),className:"h-8 bg-background border-border text-sm"}),t("p",{className:"text-[10px] text-muted-foreground italic",children:ub()})]})]},M))})}),o(Ge,{className:"flex items-center justify-between sm:justify-between w-full pt-2 border-t border-border",children:[o(E,{variant:"ghost",size:"sm",onClick:x,className:"h-8 gap-1.5 text-primary hover:text-primary hover:bg-primary/10",children:[t(pe,{className:"w-3.5 h-3.5"})," ",LA()]}),o("div",{className:"flex gap-2",children:[t(E,{variant:"ghost",onClick:()=>r(!1),children:Ne()}),o(E,{onClick:i,disabled:f,className:"px-8",children:[f?t(F,{className:"w-4 h-4 animate-spin mr-2"}):null,Us()]})]})]})]})})};S();S();var Cs=({isOpen:e,onClose:r,teamId:a,server:l})=>{let s=K(),d=!!l,[c,f]=u(""),[_,g]=u("streamable_http"),[y,x]=u("reviewer"),[m,i]=u("auto"),[v,w]=u(""),[M,O]=u(""),[Y,z]=u(""),[oe,re]=u(""),[T,q]=u("authorization_code"),[j,G]=u([]),[N,X]=u([]),[xe,ye]=u({}),[De,Me]=u(!1);h(()=>{if(l)f(l.url),g(l.transport||"streamable_http"),x(l.permission||"reviewer"),i(l.authType||"auto"),G(Array.isArray(l.config?.directTools)?l.config.directTools:[]),X(l.config?.excludeTools??[]),ye({}),Me(!1);else f(""),g("streamable_http"),x("reviewer"),i("auto"),w(""),O(""),z(""),re(""),q("authorization_code"),G([]),X([]),ye({}),Me(!1)},[l,e]);let ee=()=>{if(m==="none")return{type:"none"};if(m==="bearer")return{type:"bearer",bearerToken:v||void 0};if(m==="oauth")return{type:"oauth",oauth:{grantType:T,clientId:M||void 0,clientSecret:Y||void 0,scope:oe||void 0}};return},{data:se,isLoading:_e,refetch:Pe}=L({queryKey:["mcp","servers",l?.id,"tools"],queryFn:async()=>{if(!l?.id)return{tools:[]};let fe=await A.api.mcp.servers[":id"].tools.$get({param:{id:l.id}});if(!fe.ok)throw Error("Failed to fetch tools");return await fe.json()},enabled:e&&d&&!!l?.id}),U=B({mutationFn:async()=>{if(!l?.id)return;let fe=await A.api.mcp.servers[":id"].refresh.$post({param:{id:l.id}});if(!fe.ok){let at=await fe.json().catch(()=>({}));throw Error(at.error||"Failed to refresh server")}return await fe.json()},onSuccess:()=>{k.success(yw()),Pe(),s.invalidateQueries({queryKey:["teams",a,"mcp","servers"]})},onError:(fe)=>{k.error(fe.message)}}),J=B({mutationFn:async()=>{let fe={directTools:j.length>0?j:void 0,excludeTools:N.length>0?N:void 0};if(d&&l){let at={transport:_,permission:y,authConfig:ee(),config:fe},qe=await A.api.mcp.servers[":id"].$patch({param:{id:l.id},json:at});if(!qe.ok){let ct=await qe.json().catch(()=>({}));throw Error(ct.error||gl())}return await qe.json()}else{let at={url:c.trim()},qe=await A.api.teams[":teamId"].mcp.servers.$post({param:{teamId:a},json:at});if(!qe.ok){let ta=await qe.json().catch(()=>({}));throw Error(ta.error||nd())}return await qe.json()}},onSuccess:()=>{k.success(d?ig():Bc()),s.invalidateQueries({queryKey:["teams",a,"mcp","servers"]}),r()},onError:(fe)=>{k.error(fe.message)}}),Se=(fe)=>{if(fe.preventDefault(),!c.trim())return;J.mutate()},de=se?.tools??[],dt=(fe)=>{if(N.includes(fe))return"off";if(j.includes(fe))return"direct";return"on"},qt=(fe,at)=>{if(at==="off")X((qe)=>qe.includes(fe)?qe:[...qe,fe]),G((qe)=>qe.filter((ct)=>ct!==fe));else if(at==="on")X((qe)=>qe.filter((ct)=>ct!==fe)),G((qe)=>qe.filter((ct)=>ct!==fe));else if(at==="direct")X((qe)=>qe.filter((ct)=>ct!==fe)),G((qe)=>qe.includes(fe)?qe:[...qe,fe])},ae=(fe)=>{let at=de.map((qe)=>qe.name);if(fe==="off")X(at),G([]);else if(fe==="on")X([]),G([]);else if(fe==="direct")X([]),G(at)},Ye=(fe)=>{ye((at)=>({...at,[fe]:!at[fe]}))};return t(ue,{open:e,onOpenChange:(fe)=>!fe&&r(),children:d&&l?o(ie,{className:"sm:max-w-2xl h-[85vh] flex flex-col p-0 overflow-hidden",children:[U.isPending&&o("div",{className:"absolute inset-0 bg-background/60 backdrop-blur-[1px] flex flex-col items-center justify-center z-50 rounded-lg",children:[t(F,{className:"w-8 h-8 animate-spin text-primary mb-2"}),o("span",{className:"text-xs font-medium text-muted-foreground",children:[Ph(),"..."]})]}),o(me,{className:"p-6 pb-4 border-b border-border flex-shrink-0",children:[o(le,{className:"flex items-center gap-2 text-xl font-bold",children:[t(bn,{className:"w-5 h-5 text-primary"}),Gy()]}),t(Tt,{children:Ad()})]}),o("form",{onSubmit:Se,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t(ce,{className:"flex-1 min-h-0",children:o("div",{className:"p-6 space-y-5",children:[o("div",{className:"grid grid-cols-1 gap-3 p-3 bg-muted/30 border border-border rounded-lg",children:[o("div",{className:"flex flex-col",children:[t("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:vw()}),t("span",{className:"text-sm font-medium",children:l.name})]}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:Fh()}),t("span",{className:"text-sm font-mono text-foreground break-all",children:l.url})]}),l.description&&o("div",{className:"flex flex-col",children:[t("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:hl()}),t("span",{className:"text-sm text-foreground",children:l.description})]}),o("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1.5",children:[t(Ko,{className:"w-3 h-3"}),Oh()]})]}),l.instructions&&o("div",{className:"p-3 bg-muted/20 border border-border rounded-lg space-y-1",children:[t("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold block",children:bw()}),t("p",{onClick:()=>Me((fe)=>!fe),className:`text-xs text-muted-foreground whitespace-pre-wrap leading-relaxed cursor-pointer transition-all ${De?"":"line-clamp-2"}`,title:De?void 0:"Click to expand instructions",children:l.instructions})]}),o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 pt-3 border-t border-border",children:[o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs",children:Rw()}),o(Fe,{value:_,onValueChange:(fe)=>g(fe),children:[t(Ze,{className:"h-9 text-xs",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"streamable_http",children:"Streamable HTTP"}),t(ne,{value:"sse",children:"Server-Sent Events (SSE)"})]})]})]}),o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs",children:Ep()}),o(Fe,{value:y,onValueChange:(fe)=>x(fe),children:[t(Ze,{className:"h-9 text-xs",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"reviewer",children:Ni()}),t(ne,{value:"editor",children:Di()}),t(ne,{value:"owner",children:Pi()})]})]})]})]}),o("div",{className:"space-y-3 pt-3 border-t border-border",children:[o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs",children:uw()}),o(Fe,{value:m,onValueChange:(fe)=>i(fe),children:[t(Ze,{className:"h-9 text-xs",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"auto",children:aw()}),t(ne,{value:"none",children:lw()}),t(ne,{value:"bearer",children:iw()}),t(ne,{value:"oauth",children:cw()})]})]})]}),m==="bearer"&&o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs",children:dw()}),t(H,{className:"h-9 text-xs font-mono",type:"password",value:v,onChange:(fe)=>w(fe.target.value),placeholder:"Enter token string"})]}),m==="oauth"&&o("div",{className:"p-3 bg-muted/20 border border-border rounded-lg space-y-3",children:[o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs",children:Aw()}),o(Fe,{value:T,onValueChange:(fe)=>q(fe),children:[t(Ze,{className:"h-9 text-xs",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"authorization_code",children:"Authorization Code"}),t(ne,{value:"client_credentials",children:"Client Credentials"})]})]})]}),o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs",children:hw()}),t(H,{className:"h-9 text-xs",value:M,onChange:(fe)=>O(fe.target.value),placeholder:"Optional Client ID"})]})]}),o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs",children:gw()}),t(H,{className:"h-9 text-xs",type:"password",value:Y,onChange:(fe)=>z(fe.target.value),placeholder:"Optional Secret"})]}),o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs",children:_w()}),t(H,{className:"h-9 text-xs",value:oe,onChange:(fe)=>re(fe.target.value),placeholder:"Optional scope"})]})]})]})]}),o("div",{className:"space-y-3 pt-3 border-t border-border",children:[o("div",{className:"space-y-2.5",children:[o(Q,{className:"text-xs font-semibold flex items-center gap-1.5",children:[t(Co,{className:"w-3.5 h-3.5"}),Tw()," (",de.length,")"]}),t("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:kw()}),de.length>0&&o("div",{className:"flex items-center gap-1.5 pt-0.5",children:[t(E,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>ae("off"),disabled:U.isPending||_e,children:pw()}),t(E,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>ae("on"),disabled:U.isPending||_e,children:mw()}),t(E,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>ae("direct"),disabled:U.isPending||_e,children:fw()})]})]}),t("div",{className:"space-y-2",children:_e?t("div",{className:"flex justify-center py-8",children:t(F,{className:"w-6 h-6 animate-spin text-primary"})}):de.length===0?t("div",{className:"text-center py-6 text-muted-foreground text-xs",children:Dx()}):de.map((fe)=>{let at=dt(fe.name),qe=!!xe[fe.name],ct=fe.inputSchema,ta=ct?.properties&&Object.keys(ct.properties).length>0;return o("div",{className:`border border-border rounded-lg p-3 transition-colors ${at!=="off"?"bg-card":"bg-muted/30 opacity-70"}`,children:[o("div",{className:"flex items-start justify-between gap-3",children:[o("div",{className:"flex items-start gap-2 flex-1 min-w-0 cursor-pointer",onClick:()=>ta&&Ye(fe.name),children:[ta?qe?t(ve,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}):t(bt,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}):t("div",{className:"w-4 h-4 shrink-0"}),o("div",{className:"min-w-0 flex-1",children:[o("div",{className:"flex items-center gap-2 flex-wrap",children:[t("span",{className:"font-mono text-xs font-bold text-foreground break-all",children:fe.name}),fe.title&&t(be,{variant:"outline",className:"text-[10px]",children:fe.title})]}),fe.description&&t("p",{className:"text-xs text-muted-foreground mt-1 break-words line-clamp-3",children:fe.description})]})]}),t("div",{className:"flex items-center gap-2 shrink-0",children:o(To,{type:"single",value:at,onValueChange:(Wt)=>{if(Wt)qt(fe.name,Wt)},size:"sm",variant:"outline",disabled:U.isPending||_e,children:[t(gr,{value:"off",className:"text-[11px] px-2 h-7",children:Cw()}),t(gr,{value:"on",className:"text-[11px] px-2 h-7",children:Iw()}),t(gr,{value:"direct",className:"text-[11px] px-2 h-7",children:Ew()})]})})]}),qe&&ta&&o("div",{className:"mt-3 pt-3 border-t border-border/60 pl-6 space-y-2",children:[t("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:B1()}),t("div",{className:"grid grid-cols-1 gap-1.5",children:Object.entries(ct.properties).map(([Wt,Sa])=>{let Ps=ct.required?.includes(Wt);return o("div",{className:"flex flex-col sm:flex-row sm:items-baseline justify-between gap-1 sm:gap-2 p-2 bg-muted/20 rounded text-xs min-w-0",children:[o("div",{className:"flex items-center gap-1.5 flex-wrap min-w-0",children:[t("span",{className:"font-mono font-semibold break-all",children:Wt}),Ps&&t("span",{className:"text-[10px] text-red-500 font-bold",children:"*"}),t(be,{variant:"secondary",className:"text-[9px] px-1 py-0",children:Sa.type||"any"})]}),Sa.description&&t("span",{className:"text-[11px] text-muted-foreground break-words sm:max-w-[320px]",children:Sa.description})]},Wt)})})]})]},fe.name)})})]})]})}),o(Ge,{className:"p-6 pt-4 border-t border-border flex-shrink-0",children:[o(E,{type:"button",variant:"outline",onClick:()=>U.mutate(),disabled:U.isPending||_e||J.isPending,className:"gap-1.5 mr-auto",children:[t(ca,{className:`w-4 h-4 ${U.isPending?"animate-spin":""}`}),Ph()]}),t(E,{type:"button",variant:"outline",onClick:r,children:Ne()}),o(E,{type:"submit",disabled:J.isPending||!c,children:[J.isPending&&t(F,{className:"w-4 h-4 mr-2 animate-spin"}),Us()]})]})]})]}):o(ie,{className:"sm:max-w-md",children:[o(me,{children:[o(le,{className:"flex items-center gap-2 text-xl font-bold",children:[t(bn,{className:"w-5 h-5 text-primary"}),hf()]}),t(Tt,{children:Ad()})]}),o("form",{onSubmit:Se,className:"space-y-4",children:[o("div",{className:"space-y-2",children:[t(Q,{className:"text-xs font-semibold",children:Fh()}),t(H,{value:c,onChange:(fe)=>f(fe.target.value),placeholder:"https://mcp.example.com/mcp",type:"url",required:!0}),o("p",{className:"text-[11px] text-muted-foreground flex items-center gap-1.5",children:[t(Ko,{className:"w-3.5 h-3.5"}),Oh()]})]}),o(Ge,{children:[t(E,{type:"button",variant:"outline",onClick:r,children:Ne()}),o(E,{type:"submit",disabled:J.isPending||!c,children:[J.isPending&&t(F,{className:"w-4 h-4 mr-2 animate-spin"}),Pc()]})]})]})]})})};var ks=({teamId:e})=>{let r=K(),{canAdmin:a}=Pt(),[l,s]=u(!1),[d,c]=u(null),[f,_]=u(null),[g,y]=u(null),{data:x,isLoading:m}=L({queryKey:["teams",e,"mcp","servers"],queryFn:async()=>{let z=await A.api.teams[":teamId"].mcp.servers.$get({param:{teamId:e}});if(!z.ok)throw Error(Wo());return await z.json()}}),i=B({mutationFn:async(z)=>{if(!(await A.api.mcp.servers[":id"].$delete({param:{id:z}})).ok)throw Error(ki())},onSuccess:()=>{k.success(it()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]}),_(null)},onError:(z)=>{k.error(z.message)}}),v=B({mutationFn:async({id:z,permission:oe})=>{if(!(await A.api.mcp.servers[":id"].permission.$patch({param:{id:z},json:{permission:oe}})).ok)throw Error(gl())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},onError:(z)=>{k.error(z.message)}}),w=B({mutationFn:async(z)=>{if(!(await A.api.mcp.servers[":id"].auth.$delete({param:{id:z}})).ok)throw Error("Failed to disconnect auth")},onSuccess:()=>{k.success(Dh()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},onError:(z)=>{k.error(z.message)}}),M=async(z)=>{y(z);try{let oe=await A.api.mcp.servers[":id"].auth.start.$post({param:{id:z}});if(!oe.ok){let T=await oe.json().catch(()=>({}));throw Error(T.error||$f())}let re=await oe.json();if(re.status==="authenticated"){k.success(Rh()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]}),y(null);return}if(re.authorizationUrl){let j=window.screenX+(window.outerWidth-600)/2,G=window.screenY+(window.outerHeight-700)/2,N=window.open(re.authorizationUrl,"mcp_oauth_popup",`width=600,height=700,left=${j},top=${G},scrollbars=yes`),X=(ye)=>{if(ye.data?.type==="mcp-oauth-callback")if(window.removeEventListener("message",X),y(null),ye.data.ok)k.success(Rh()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]});else k.error(ye.data.message||$f())};window.addEventListener("message",X);let xe=setInterval(()=>{if(!N||N.closed)clearInterval(xe),window.removeEventListener("message",X),y(null),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},1000)}}catch(oe){k.error(oe instanceof Error?oe.message:$f()),y(null)}},O=x?.servers||[],Y=(z)=>{switch(z.status){case"connected":return o(be,{variant:"secondary",className:"gap-1 bg-emerald-500/10 text-emerald-600 border-emerald-500/20 text-[10px]",children:[t(vr,{className:"w-3 h-3"}),ww()]});case"needs_auth":return o(be,{variant:"secondary",className:"gap-1 bg-amber-500/10 text-amber-600 border-amber-500/20 text-[10px]",children:[t(Zt,{className:"w-3 h-3"}),Lh()]});case"failed":return o(be,{variant:"secondary",className:"gap-1 bg-red-500/10 text-red-600 border-red-500/20 text-[10px]",children:[t(vn,{className:"w-3 h-3"}),xw()]});default:return o(be,{variant:"outline",className:"gap-1 text-[10px]",children:[t(_r,{className:"w-3 h-3 text-muted-foreground"}),Sw()]})}};return o(Et,{children:[o(kt,{className:"flex flex-row items-center justify-between space-y-0 pb-7",children:[o("div",{className:"flex items-center gap-3",children:[t("div",{className:"p-2 bg-primary/10 text-primary rounded-lg",children:t(bn,{className:"w-6 h-6"})}),o("div",{children:[t(Rt,{className:"text-xl font-bold",children:Bc()}),t(Ut,{children:Ad()})]})]}),a&&o(E,{onClick:()=>s(!0),className:"gap-2",children:[t(pe,{className:"w-4 h-4"})," ",hf()]})]}),t(Mt,{children:m?t("div",{className:"flex justify-center py-10",children:t(F,{className:"w-8 h-8 animate-spin text-primary"})}):O.length===0?o("div",{className:"text-center py-12 border-2 border-dashed border-border rounded-xl",children:[t("div",{className:"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4 text-muted-foreground",children:t(bn,{className:"w-6 h-6"})}),t("h3",{className:"text-base font-semibold",children:Wh()}),t("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm mx-auto",children:CA()}),a&&o(E,{onClick:()=>s(!0),className:"mt-4 gap-2",variant:"outline",children:[t(pe,{className:"w-4 h-4"})," ",hf()]})]}):t("div",{className:"space-y-4",children:O.map((z)=>{let oe=g===z.id,re=z.status==="needs_auth"||!z.hasCredential&&z.authType!=="none";return o("div",{onClick:()=>a&&c(z),className:`p-4 bg-card rounded-xl border border-border flex flex-col justify-between hover:shadow-md transition-all group ${a?"cursor-pointer":""}`,children:[o("div",{className:"flex items-start justify-between gap-2 mb-2",children:[o("h4",{className:"font-bold text-foreground flex items-center gap-2 min-w-0",children:[t(bn,{className:"w-4 h-4 text-muted-foreground shrink-0"}),t("span",{className:"truncate",children:z.name}),t(be,{variant:"outline",className:"text-[10px] uppercase shrink-0",children:z.transport})]}),a&&o(he,{modal:!1,children:[t(ge,{asChild:!0,onClick:(T)=>T.stopPropagation(),children:t(E,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:t(wr,{className:"w-4 h-4"})})}),o(Ae,{align:"end",children:[z.status!=="connected"&&(z.authType!=="none"||z.hasCredential)?o(W,{onClick:(T)=>{T.stopPropagation(),M(z.id)},children:[t(Zt,{className:"w-4 h-4 mr-2"}),Nh()]}):null,z.hasCredential&&o(W,{onClick:(T)=>{T.stopPropagation(),w.mutate(z.id)},className:"text-amber-600",children:[t(Za,{className:"w-4 h-4 mr-2"}),Dh()]}),(z.status!=="connected"&&(z.authType!=="none"||z.hasCredential)||z.hasCredential)&&t(Vt,{}),o(W,{onClick:(T)=>{T.stopPropagation(),_(z)},className:"text-red-600",children:[t(we,{className:"w-4 h-4 mr-2"}),it()]})]})]})]}),o("div",{className:"space-y-1",children:[t("p",{className:"text-sm text-muted-foreground line-clamp-2",children:z.description||Vh()}),t("p",{className:"font-mono text-[10px] text-muted-foreground/70 truncate",children:z.url}),z.lastError&&t("p",{className:"text-[10px] text-red-500/90 truncate font-mono",children:z.lastError})]}),o("div",{className:"mt-4 flex items-center justify-between gap-2 pt-2 border-t border-border/50 text-xs",children:[o("div",{className:"flex items-center gap-2 min-w-0",children:[Y(z),o(be,{variant:"outline",className:"text-[10px] gap-1 shrink-0",children:[t(Co,{className:"w-3 h-3 text-muted-foreground"}),Mw({count:z.toolCount})]}),o("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider font-semibold whitespace-nowrap",children:[rA()," ",new Date(z.updatedAt).toLocaleDateString()]})]}),o("div",{className:"flex items-center gap-2 shrink-0",onClick:(T)=>T.stopPropagation(),children:[a?o(Fe,{value:z.permission,onValueChange:(T)=>v.mutate({id:z.id,permission:T}),children:[t(Ze,{className:"h-7 text-xs px-2 bg-background border-border w-[130px]",children:t(Le,{})}),o(Be,{align:"end",children:[t(ne,{value:"reviewer",children:Ni()}),t(ne,{value:"editor",children:Di()}),t(ne,{value:"owner",children:Pi()})]})]}):t(be,{variant:"outline",className:"text-[10px]",children:z.permission==="reviewer"?Ni():z.permission==="editor"?Di():Pi()}),re&&a&&o(E,{size:"sm",variant:"default",onClick:(T)=>{T.stopPropagation(),M(z.id)},disabled:oe,className:"gap-1.5 bg-amber-600 hover:bg-amber-700 text-white text-xs",children:[oe?t(F,{className:"w-3.5 h-3.5 animate-spin"}):t(Zt,{className:"w-3.5 h-3.5"}),Nh()]})]})]})]},z.id)})})}),t(Cs,{isOpen:l||!!d,onClose:()=>{s(!1),c(null)},teamId:e,server:d}),t(Je,{open:!!f,onOpenChange:(z)=>!z&&_(null),children:o(Xe,{children:[o(et,{children:[t(rt,{children:Ey()}),t(nt,{children:Cy({name:f?.name||""})})]}),o(tt,{children:[t(st,{children:Ne()}),o(ot,{onClick:()=>f&&i.mutate(f.id),className:"bg-red-600 hover:bg-red-700 text-white",children:[i.isPending&&t(F,{className:"w-4 h-4 mr-2 animate-spin"}),it()]})]})]})})]})};function Ms({teamId:e}){let r=K(),{data:a,isLoading:l}=L({queryKey:["teams",e,"notification-settings"],queryFn:async()=>{let f=await A.api.teams[":teamId"].notifications.settings.$get({param:{teamId:e}});if(!f.ok)throw Error(Wo());return await f.json()}}),{mutate:s,isPending:d}=B({mutationFn:async(f)=>{let _=await A.api.teams[":teamId"].notifications.settings.$post({param:{teamId:e},json:f});if(!_.ok)throw Error(Ah());return await _.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"notification-settings"]}),r.invalidateQueries({queryKey:["teams",e,"notifications"]}),k.success(Lx())},onError:(f)=>{k.error(f instanceof Error?f.message:Ah())}}),c=(f)=>{if(!a)return;let _={...a,[f]:!a[f]};s(_)};if(l)return t("div",{className:"flex items-center justify-center p-8",children:t(F,{className:"h-8 w-8 animate-spin text-muted-foreground"})});return t(ce,{className:"h-full",children:o("div",{className:"space-y-6 pr-4 pb-8",children:[o(Et,{className:"overflow-hidden gap-0 py-0",children:[o(kt,{className:"border-b border-border bg-muted/30 py-5",children:[o("div",{className:"flex items-center gap-2",children:[t(vo,{className:"w-5 h-5 text-primary"}),t(Rt,{className:"text-lg",children:I_()})]}),t(Ut,{children:T_()})]}),o(Mt,{className:"divide-y divide-border p-0",children:[o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(vo,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:av()}),t("p",{className:"text-sm text-muted-foreground",children:gI()})]})]}),t(je,{checked:a?.comments??!0,onCheckedChange:()=>c("comments"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(Ha,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:C_()}),t("p",{className:"text-sm text-muted-foreground",children:_I()})]})]}),t(je,{checked:a?.replies??!0,onCheckedChange:()=>c("replies"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(Ka,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:$0()}),t("p",{className:"text-sm text-muted-foreground",children:AI()})]})]}),t(je,{checked:a?.mentions??!0,onCheckedChange:()=>c("mentions"),disabled:d})]})]})]}),o(Et,{className:"overflow-hidden gap-0 py-0",children:[o(kt,{className:"border-b border-border bg-muted/30 py-5",children:[o("div",{className:"flex items-center gap-2",children:[t(zn,{className:"w-5 h-5 text-primary"}),t(Rt,{className:"text-lg",children:q0()})]}),t(Ut,{children:H0()})]}),o(Mt,{className:"divide-y divide-border p-0",children:[o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(fi,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:bI()}),t("p",{className:"text-sm text-muted-foreground",children:yI()})]})]}),t(je,{checked:a?.yourUploads??!1,onCheckedChange:()=>c("yourUploads"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(zn,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:aS()}),t("p",{className:"text-sm text-muted-foreground",children:mI()})]})]}),t(je,{checked:a?.otherUploads??!0,onCheckedChange:()=>c("otherUploads"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(Hs,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:GC()}),t("p",{className:"text-sm text-muted-foreground",children:hI()})]})]}),t(je,{checked:a?.statusUpdates??!0,onCheckedChange:()=>c("statusUpdates"),disabled:d})]})]})]}),o(Et,{className:"overflow-hidden gap-0 py-0",children:[o(kt,{className:"border-b border-border bg-muted/30 py-5",children:[o("div",{className:"flex items-center gap-2",children:[t(Ca,{className:"w-5 h-5 text-primary"}),t(Rt,{className:"text-lg",children:Uv()})]}),t(Ut,{children:Bv()})]}),o(Mt,{className:"divide-y divide-border p-0",children:[o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(Ca,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:zv()}),t("p",{className:"text-sm text-muted-foreground",children:pI()})]})]}),t(je,{checked:a?.kanbanTasks??!0,onCheckedChange:()=>c("kanbanTasks"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(vo,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:Zv()}),t("p",{className:"text-sm text-muted-foreground",children:fI()})]})]}),t(je,{checked:a?.kanbanComments??!0,onCheckedChange:()=>c("kanbanComments"),disabled:d})]})]})]})]})})}S();function Fs({teamId:e}){let r=K(),[a,l]=u(""),[s,d]=u(null),{data:c,isLoading:f}=L({queryKey:["teams",e,"api-tokens"],queryFn:async()=>{let i=await A.api.teams[":teamId"]["api-tokens"].$get({param:{teamId:e}});if(!i.ok)throw Error("Failed to fetch API tokens");return await i.json()}}),{mutate:_,isPending:g}=B({mutationFn:async(i)=>{let v=await A.api.teams[":teamId"]["api-tokens"].$post({param:{teamId:e},json:{name:i}});if(!v.ok)throw Error("Failed to create API token");return await v.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"api-tokens"]}),l(""),k.success(P0())},onError:(i)=>{k.error(i instanceof Error?i.message:Tb())}}),{mutate:y}=B({mutationFn:async(i)=>{let v=await A.api.teams[":teamId"]["api-tokens"][":tokenId"].$delete({param:{teamId:e,tokenId:i}});if(!v.ok)throw Error("Failed to delete API token");return await v.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"api-tokens"]}),k.success(O0())},onError:(i)=>{k.error(i instanceof Error?i.message:Db())}}),x=(i)=>{if(i.preventDefault(),!a.trim())return;_(a.trim())},m=async(i,v)=>{await co(v),d(i),k.success(B_()),setTimeout(()=>d(null),2000)};if(f)return t("div",{className:"flex justify-center items-center p-8",children:t(F,{className:"w-8 h-8 animate-spin text-muted-foreground"})});return t("div",{className:"space-y-6",children:o(Et,{children:[o(kt,{children:[t(Rt,{children:qm()}),t(Ut,{children:F0()})]}),o(Mt,{className:"space-y-6",children:[o("form",{onSubmit:x,className:"flex gap-4 items-end max-w-md",children:[o("div",{className:"flex-1 space-y-2",children:[t("label",{htmlFor:"tokenName",className:"text-sm font-medium text-muted-foreground",children:L1()}),t(H,{id:"tokenName",value:a,onChange:(i)=>l(i.target.value),placeholder:Z1(),required:!0})]}),o(E,{type:"submit",disabled:g||!a.trim(),children:[g?t(F,{className:"w-4 h-4 animate-spin mr-2"}):t(pe,{className:"w-4 h-4 mr-2"}),lv()]})]}),t("div",{className:"border rounded-lg overflow-hidden",children:o(Rn,{children:[t(Nn,{children:o(br,{children:[t(xt,{children:_l()}),t(xt,{children:F1()}),t(xt,{children:oy()}),t(xt,{className:"w-[100px] text-right",children:_A()})]})}),t(Dn,{children:!c||c.length===0?t(br,{children:t(_t,{colSpan:4,className:"text-center py-6 text-muted-foreground text-sm",children:fx()})}):c.map((i)=>o(br,{children:[t(_t,{className:"font-medium",children:i.name}),t(_t,{className:"font-mono text-sm max-w-[200px] truncate",children:o("div",{className:"flex items-center gap-2",children:[o("span",{children:[i.token.substring(0,8),"..."]}),t(E,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>m(i.id,i.token),children:s===i.id?t(ke,{className:"h-3.5 w-3.5 text-green-500"}):t(Rr,{className:"h-3.5 w-3.5"})})]})}),t(_t,{className:"text-muted-foreground",children:new Date(i.createdAt).toLocaleDateString()}),t(_t,{className:"text-right",children:t(E,{variant:"ghost",size:"icon",className:"h-8 w-8 text-red-500 hover:text-red-600 hover:bg-red-50",onClick:()=>y(i.id),children:t(we,{className:"h-4 w-4"})})})]},i.id))})]})})]})]})})}S();S();var Dr=[{value:"read_asset",label:()=>Dm()},{value:"list_assets",label:()=>Rm()},{value:"create_folder",label:()=>Cm()},{value:"create_file",label:()=>Em()},{value:"create_version",label:()=>Im()},{value:"generate_image",label:()=>Mm()},{value:"generate_video",label:()=>km()},{value:"rename_asset",label:()=>Pm()},{value:"move_assets",label:()=>Nm()},{value:"delete_asset",label:()=>Tm()}],Qa={agent_total_tokens:{label:()=>Id(),icon:ao,unit:"tokens",defaultLimit:1e5},agent_cost:{label:()=>Sd(),icon:ui,unit:"$",defaultLimit:10},agent_mcp_call_count:{label:()=>Ed(),icon:bn,unit:"calls",defaultLimit:100},agent_bash_call_count:{label:()=>xd(),icon:Io,unit:"calls",defaultLimit:50},agent_tool_call_count:{label:()=>Cd(),icon:Co,unit:"calls",defaultLimit:100}},Ds=({open:e,onOpenChange:r,teamId:a,rule:l,onSuccess:s})=>{let d=K(),c=!!l,[f,_]=u("each_member"),[g,y]=u("team"),[x,m]=u([]),[i,v]=u("agent_total_tokens"),[w,M]=u(""),[O,Y]=u("*"),[z,oe]=u("read_asset"),[re,T]=u(1e5),[q,j]=u("1day"),[G,N]=u(!0),[X,xe]=u(!1),[ye,De]=u(""),{data:Me=[]}=L({queryKey:["teams",a,"members"],queryFn:async()=>{let ae=await A.api.teams[":teamId"].members.$get({param:{teamId:a},query:{}});if(!ae.ok)return[];return await ae.json()},enabled:e}),{data:ee}=L({queryKey:["teams",a,"mcp","servers"],queryFn:async()=>{let ae=await A.api.teams[":teamId"].mcp.servers.$get({param:{teamId:a}});if(!ae.ok)return{servers:[]};return await ae.json()},enabled:e&&i==="agent_mcp_call_count"}),se=ee?.servers||[];h(()=>{if(l){_(l.scopeMode),y(l.role||"team"),m(l.userIds||[]),v(l.resource);let ae=l.resourceData||{};M(typeof ae.id==="string"?ae.id:""),Y(typeof ae.match==="string"?ae.match:"*"),oe(typeof ae.name==="string"?ae.name:typeof ae.toolName==="string"?ae.toolName:"read_asset"),T(l.limit),j(Jc(l.period)),N(l.enabled)}else _("each_member"),y("team"),m([]),v("agent_total_tokens"),M(""),Y("*"),oe("read_asset"),T(Qa.agent_total_tokens.defaultLimit),j("1day"),N(!0)},[l,e]);let _e=(ae)=>{if(v(ae),!c)T(Qa[ae]?.defaultLimit||100)},Pe=B({mutationFn:async()=>{let ae={};if(i==="agent_mcp_call_count")ae.id=w;else if(i==="agent_bash_call_count")ae.match=O.trim()||"*";else if(i==="agent_tool_call_count")ae.name=z||"read_asset";let Ye=await A.api.teams[":teamId"].quotas.$post({param:{teamId:a},json:{scopeMode:f,role:f!=="selected_members"&&g!=="team"?g:null,userIds:f==="selected_members"?x:null,resource:i,resourceData:Object.keys(ae).length>0?ae:null,limit:Number(re),period:q,enabled:G}});if(!Ye.ok){let fe=await Ye.json().catch(()=>({}));throw Error(fe?.message||mh())}return await Ye.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",a,"quotas"]}),k.success(XS()),r(!1),s?.()},onError:(ae)=>{console.error("CREATE MUTATION ERROR:",ae),k.error(ae instanceof Error?ae.message:mh())}}),U=B({mutationFn:async()=>{if(!l)return;let ae={};if(i==="agent_mcp_call_count")ae.id=w;else if(i==="agent_bash_call_count")ae.match=O.trim()||"*";else if(i==="agent_tool_call_count")ae.name=z||"read_asset";let Ye=await A.api.teams[":teamId"].quotas[":id"].$put({param:{teamId:a,id:l.id},json:{scopeMode:f,role:f!=="selected_members"&&g!=="team"?g:null,userIds:f==="selected_members"?x:null,resource:i,resourceData:Object.keys(ae).length>0?ae:null,limit:Number(re),period:q,enabled:G}});if(!Ye.ok){let fe=await Ye.json().catch(()=>({}));throw Error(fe?.message||pd())}return await Ye.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",a,"quotas"]}),k.success(SE()),r(!1),s?.()},onError:(ae)=>{k.error(ae instanceof Error?ae.message:pd())}}),J=B({mutationFn:async()=>{if(!l)return;if(!(await A.api.teams[":teamId"].quotas[":id"].$delete({param:{teamId:a,id:l.id}})).ok)throw Error(fd())},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",a,"quotas"]}),k.success(yg()),xe(!1),r(!1),s?.()},onError:(ae)=>{k.error(ae instanceof Error?ae.message:fd())}}),Se=(ae)=>{if(ae.preventDefault(),f==="selected_members"&&x.length===0){k.error(yC());return}if(i==="agent_mcp_call_count"&&!w.trim()){k.error(dh());return}if(re<=0){k.error("Limit must be greater than 0");return}if(c)U.mutate();else Pe.mutate()},de=Pe.isPending||U.isPending||J.isPending,dt=Me.filter((ae)=>{if(!ye.trim())return!0;let Ye=ye.toLowerCase();return ae.name.toLowerCase().includes(Ye)||ae.email&&ae.email.toLowerCase().includes(Ye)}),qt=(ae)=>{m((Ye)=>Ye.includes(ae)?Ye.filter((fe)=>fe!==ae):[...Ye,ae])};return o(Z,{children:[t(ue,{open:e,onOpenChange:r,children:o(ie,{className:"sm:max-w-[540px] max-h-[90vh] flex flex-col p-0 overflow-hidden",children:[o(me,{className:"p-6 pb-4 border-b border-border/60 shrink-0",children:[t(le,{className:"text-xl font-bold",children:c?Vy():ey()}),t(Tt,{className:"text-sm text-muted-foreground",children:c?Qy():ty()})]}),o("form",{onSubmit:Se,noValidate:!0,className:"flex-1 overflow-y-auto min-h-0 p-6 space-y-5",children:[o("div",{className:"space-y-2",children:[t(Q,{className:"text-sm font-semibold",children:pE()}),o("div",{className:"grid grid-cols-3 gap-2",children:[o(E,{type:"button",variant:f==="each_member"?"default":"outline",size:"sm",disabled:c||de,onClick:()=>_("each_member"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[t(Vn,{className:"w-4 h-4"}),t("span",{className:"font-semibold",children:Md()})]}),o(E,{type:"button",variant:f==="all_members"?"default":"outline",size:"sm",disabled:c||de,onClick:()=>_("all_members"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[t(io,{className:"w-4 h-4"}),t("span",{className:"font-semibold",children:Td()})]}),o(E,{type:"button",variant:f==="selected_members"?"default":"outline",size:"sm",disabled:c||de,onClick:()=>_("selected_members"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[t(di,{className:"w-4 h-4"}),t("span",{className:"font-semibold",children:kd()})]})]}),o("p",{className:"text-xs text-muted-foreground pt-0.5",children:[f==="each_member"&&hE(),f==="all_members"&&mE(),f==="selected_members"&&gE()]})]}),f!=="selected_members"?o("div",{className:"space-y-2",children:[t(Q,{htmlFor:"quota-role-scope",className:"text-sm font-semibold",children:fE()}),o(Fe,{value:g,onValueChange:y,disabled:c||de,children:[t(Ze,{id:"quota-role-scope",className:"w-full",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"team",children:Sl()}),o(ne,{value:"owner",children:[mp(),": Owner"]}),o(ne,{value:"editor",children:[mp(),": Editor"]}),o(ne,{value:"reviewer",children:[mp(),": Reviewer"]})]})]})]}):o("div",{className:"space-y-2",children:[t(Q,{className:"text-sm font-semibold",children:Lg()}),o(mt,{children:[t(ht,{asChild:!0,children:o(E,{variant:"outline",role:"combobox",disabled:de,className:"w-full justify-between text-left font-normal h-10",children:[t("span",{className:"truncate",children:x.length===0?Lg():AE({count:x.length})}),t(ve,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t(gt,{className:"w-[320px] p-2",align:"start",children:o("div",{className:"space-y-2",children:[o("div",{className:"relative",children:[t(Bt,{className:"w-3.5 h-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),t(H,{placeholder:hp(),value:ye,onChange:(ae)=>De(ae.target.value),className:"h-8 pl-8 text-xs"})]}),t(ce,{className:"h-48",children:t("div",{className:"space-y-1 pr-2",children:dt.map((ae)=>{let Ye=x.includes(ae.id);return o("div",{onClick:()=>qt(ae.id),className:"flex items-center gap-2 p-1.5 rounded-lg hover:bg-muted/60 cursor-pointer text-xs",children:[t(Pr,{checked:Ye,onCheckedChange:()=>qt(ae.id)}),o(Ce,{className:"w-5 h-5",children:[t(Ie,{src:ae.image||void 0}),t(Te,{className:"text-[10px]",children:ae.name?.[0]?.toUpperCase()||"U"})]}),o("div",{className:"truncate flex-1",children:[t("span",{className:"font-medium text-foreground block truncate",children:ae.name}),ae.email&&t("span",{className:"text-[10px] text-muted-foreground block truncate",children:ae.email})]})]},ae.id)})})})]})})]})]}),o("div",{className:"space-y-2",children:[t(Q,{htmlFor:"quota-resource",className:"text-sm font-semibold",children:uE()}),o(Fe,{value:i,onValueChange:(ae)=>_e(ae),disabled:c||de,children:[t(Ze,{id:"quota-resource",className:"w-full",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"agent_total_tokens",children:o("div",{className:"flex items-center gap-2",children:[t(ao,{className:"w-4 h-4 text-primary"}),t("span",{children:Id()})]})}),t(ne,{value:"agent_cost",children:o("div",{className:"flex items-center gap-2",children:[t(ui,{className:"w-4 h-4 text-emerald-500"}),t("span",{children:Sd()})]})}),t(ne,{value:"agent_mcp_call_count",children:o("div",{className:"flex items-center gap-2",children:[t(bn,{className:"w-4 h-4 text-blue-500"}),t("span",{children:Ed()})]})}),t(ne,{value:"agent_bash_call_count",children:o("div",{className:"flex items-center gap-2",children:[t(Io,{className:"w-4 h-4 text-purple-500"}),t("span",{children:xd()})]})}),t(ne,{value:"agent_tool_call_count",children:o("div",{className:"flex items-center gap-2",children:[t(Co,{className:"w-4 h-4 text-cyan-500"}),t("span",{children:Cd()})]})})]})]})]}),i==="agent_mcp_call_count"&&o("div",{className:"space-y-2",children:[t(Q,{htmlFor:"quota-mcp",className:"text-sm font-semibold",children:Fg()}),se.length>0?o(Fe,{value:w,onValueChange:M,disabled:c||de,children:[t(Ze,{id:"quota-mcp",className:"w-full",children:t(Le,{placeholder:Fg()})}),t(Be,{children:se.map((ae)=>o(ne,{value:ae.id,children:[ae.name," (",ae.id,")"]},ae.id))})]}):t(H,{id:"quota-mcp",value:w,onChange:(ae)=>M(ae.target.value),placeholder:dh(),disabled:c||de})]}),i==="agent_bash_call_count"&&o("div",{className:"space-y-1.5",children:[t(Q,{htmlFor:"quota-bash",className:"text-sm font-semibold",children:l_()}),t(H,{id:"quota-bash",value:O,onChange:(ae)=>Y(ae.target.value),placeholder:c_(),disabled:de}),t("p",{className:"text-xs text-muted-foreground",children:YS()})]}),i==="agent_tool_call_count"&&o("div",{className:"space-y-2",children:[t(Q,{htmlFor:"quota-tool",className:"text-sm font-semibold",children:Bg()}),o(Fe,{value:z,onValueChange:oe,disabled:c||de,children:[t(Ze,{id:"quota-tool",className:"w-full",children:t(Le,{placeholder:Bg()})}),t(Be,{children:Dr.map((ae)=>t(ne,{value:ae.value,children:ae.label()},ae.value))})]}),t("p",{className:"text-xs text-muted-foreground",children:xE()})]}),o("div",{className:"grid grid-cols-2 gap-4",children:[o("div",{className:"space-y-2",children:[o(Q,{htmlFor:"quota-limit",className:"text-sm font-semibold",children:[nE()," (",Qa[i]?.unit||"",")"]}),t(H,{id:"quota-limit",type:"number",min:"0.01",step:i==="agent_cost"?"0.01":"1",value:re,onChange:(ae)=>T(Number(ae.target.value)),placeholder:oE(),disabled:de,required:!0})]}),o("div",{className:"space-y-2",children:[t(Q,{htmlFor:"quota-period",className:"text-sm font-semibold",children:aE()}),o(Fe,{value:q,onValueChange:(ae)=>j(ae),disabled:de,children:[t(Ze,{id:"quota-period",className:"w-full",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"1hour",children:o("div",{className:"flex items-center gap-2",children:[t(_r,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:dp()})]})}),t(ne,{value:"5hour",children:o("div",{className:"flex items-center gap-2",children:[t(_r,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:fp()})]})}),t(ne,{value:"1day",children:o("div",{className:"flex items-center gap-2",children:[t(_r,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:up()})]})}),t(ne,{value:"7day",children:o("div",{className:"flex items-center gap-2",children:[t(_r,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:pp()})]})})]})]})]})]}),o("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/20",children:[o("div",{className:"space-y-0.5",children:[t(Q,{htmlFor:"quota-enabled",className:"text-sm font-medium cursor-pointer",children:G?tE():cp()}),t("p",{className:"text-xs text-muted-foreground",children:G?"Active and enforcing limits":"Inactive, requests will bypass this quota"})]}),t(je,{id:"quota-enabled",checked:G,onCheckedChange:N,disabled:de})]}),o(Ge,{className:"pt-4 flex items-center justify-between gap-2 sm:justify-between border-t border-border/60",children:[c?o(E,{type:"button",variant:"destructive",size:"sm",onClick:()=>xe(!0),disabled:de,className:"gap-1.5",children:[t(we,{className:"w-4 h-4"}),t("span",{children:If()})]}):t("div",{}),o("div",{className:"flex items-center gap-2",children:[t(E,{type:"button",variant:"outline",onClick:()=>r(!1),disabled:de,children:Ne()}),o(E,{type:"submit",disabled:de,className:"gap-2",children:[de&&t(F,{className:"w-4 h-4 animate-spin"}),c?Fo():Pc()]})]})]})]})]})}),t(Je,{open:X,onOpenChange:xe,children:o(Xe,{children:[o(et,{children:[t(rt,{children:If()}),t(nt,{children:ah()})]}),o(tt,{children:[t(st,{disabled:de,children:Ne()}),o(ot,{onClick:(ae)=>{ae.preventDefault(),J.mutate()},disabled:de,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[de&&t(F,{className:"w-4 h-4 animate-spin mr-2"}),it()]})]})]})})]})};var As=({teamId:e})=>{let r=K(),[a,l]=u(!1),[s,d]=u(null),[c,f]=u(null),{data:_,isLoading:g}=L({queryKey:["teams",e,"quotas"],queryFn:async()=>{let i=await A.api.teams[":teamId"].quotas.$get({param:{teamId:e}});if(!i.ok)throw Error(Wo());return await i.json()}}),y=B({mutationFn:async({id:i,enabled:v})=>{let w=await A.api.teams[":teamId"].quotas[":id"].$put({param:{teamId:e,id:i},json:{enabled:v}});if(!w.ok)throw Error(pd());return await w.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"quotas"]}),k.success(_E())},onError:(i)=>{k.error(i instanceof Error?i.message:pd())}}),x=B({mutationFn:async(i)=>{if(!(await A.api.teams[":teamId"].quotas[":id"].$delete({param:{teamId:e,id:i}})).ok)throw Error(fd())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"quotas"]}),k.success(yg()),f(null)},onError:(i)=>{k.error(i instanceof Error?i.message:fd())}}),m=_?.rules||[];return o(ce,{className:"h-full",children:[t("div",{className:"space-y-6 pr-4 pb-10",children:o(Et,{children:[o(kt,{className:"flex flex-row items-center justify-between space-y-0 pb-6",children:[o("div",{className:"flex items-center gap-3",children:[t("div",{className:"p-2 bg-primary/10 text-primary rounded-lg",children:t(Bo,{className:"w-6 h-6"})}),o("div",{children:[t(Rt,{className:"text-xl font-bold",children:Ig()}),t(Ut,{children:Tg()})]})]}),o(E,{onClick:()=>l(!0),className:"gap-2",children:[t(pe,{className:"w-4 h-4"})," ",wm()]})]}),t(Mt,{children:g?t("div",{className:"flex justify-center py-12",children:t(F,{className:"w-8 h-8 animate-spin text-primary"})}):m.length===0?o("div",{className:"text-center py-12 border-2 border-dashed border-border rounded-xl",children:[t("div",{className:"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4 text-muted-foreground",children:t(Bo,{className:"w-6 h-6"})}),t("h3",{className:"text-base font-semibold text-foreground mb-1",children:ep()}),t("p",{className:"text-sm text-muted-foreground max-w-md mx-auto mb-6",children:Xf()}),o(E,{onClick:()=>l(!0),className:"gap-2",children:[t(pe,{className:"w-4 h-4"})," ",wm()]})]}):t("div",{className:"flex flex-col gap-4",children:m.map((i)=>{let v=Hi[i.resource],w=i.resourceData||{};return t("div",{onClick:()=>d(i),className:`group relative flex flex-col justify-between p-5 rounded-xl border bg-card text-card-foreground shadow-2xs transition-all hover:border-primary/40 hover:shadow-xs cursor-pointer ${!i.enabled?"opacity-60 bg-muted/20":""}`,children:o("div",{className:"space-y-3",children:[o("div",{className:"flex items-start justify-between gap-2",children:[o("div",{children:[t("div",{className:"font-semibold text-base text-foreground group-hover:text-primary transition-colors flex items-center gap-2",children:t("span",{children:v?.label?v.label():i.resource})}),o("div",{className:"text-xs text-muted-foreground line-clamp-1",children:[i.resource==="agent_mcp_call_count"&&o("span",{children:["Server: ",String(w.id||"")]}),i.resource==="agent_bash_call_count"&&o("span",{children:["Match: ",String(w.match||"*")]}),i.resource==="agent_tool_call_count"&&o("span",{children:["Tool: ",String(w.name||w.toolName||"*")]})]})]}),o("div",{className:"flex items-center gap-2",onClick:(M)=>M.stopPropagation(),children:[t(je,{checked:i.enabled,onCheckedChange:(M)=>y.mutate({id:i.id,enabled:M}),disabled:y.isPending}),o(he,{modal:!1,children:[t(ge,{asChild:!0,children:t(E,{variant:"ghost",size:"icon","aria-label":"Quota actions",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:t(wr,{className:"w-4 h-4"})})}),t(Ae,{align:"end",children:o(W,{onClick:()=>f(i),className:"text-destructive focus:text-destructive",children:[t(we,{className:"w-4 h-4 mr-2"}),it()]})})]})]})]}),t("div",{className:"flex flex-wrap items-center gap-2 pt-2 border-t border-border/50",children:o("div",{className:"flex flex-wrap items-center gap-1.5",children:[i.scopeMode==="all_members"&&o(be,{variant:"secondary",className:"gap-1 text-xs",children:[t(io,{className:"w-3 h-3"}),o("span",{children:[Td(),i.role?` (${i.role})`:` (${Sl()})`]})]}),i.scopeMode==="each_member"&&o(be,{variant:"secondary",className:"gap-1 text-xs",children:[t(Vn,{className:"w-3 h-3"}),o("span",{children:[Md(),i.role?` (${i.role})`:` (${Sl()})`]})]}),i.scopeMode==="selected_members"&&o(be,{variant:"secondary",className:"gap-1 text-xs",children:[t(di,{className:"w-3 h-3"}),o("span",{children:[kd()," (",i.userIds?.length||0,")"]})]}),o(be,{variant:"outline",className:"gap-1 text-xs",children:[t(_r,{className:"w-3 h-3"}),o("span",{children:[Ra(i.resource,i.limit)," ",v?.unit," /"," ",Vl(i.period)]})]})]})})]})},i.id)})})})]})}),(a||!!s)&&t(Ds,{open:a||!!s,onOpenChange:(i)=>{if(!i)l(!1),d(null)},teamId:e,rule:s}),t(Je,{open:!!c,onOpenChange:(i)=>{if(!i)f(null)},children:o(Xe,{children:[o(et,{children:[t(rt,{children:If()}),t(nt,{children:ah()})]}),o(tt,{children:[t(st,{disabled:x.isPending,children:Ne()}),o(ot,{onClick:(i)=>{if(i.preventDefault(),c)x.mutate(c.id)},disabled:x.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[x.isPending&&t(F,{className:"w-4 h-4 animate-spin mr-2"}),it()]})]})]})})]})};function Is({teamId:e}){let r=K(),{data:a,isLoading:l}=L({queryKey:["teams",e,"settings"],queryFn:async()=>{let _=await A.api.teams[":teamId"].settings.$get({param:{teamId:e}});if(!_.ok)throw Error(Wo());return await _.json()},enabled:!!e}),{mutate:s,isPending:d}=B({mutationFn:async(_)=>{let g=await A.api.teams[":teamId"].settings.$patch({param:{teamId:e},json:{key:"appearance.hideAgent",value:_}});if(!g.ok)throw Error(yh());return await g.json()},onSuccess:async(_,g)=>{if(r.invalidateQueries({queryKey:["teams",e,"settings"]}),await hr.getState().fetchMetadata(e),g)ir.getState().setIsChatbotOpen(!1);k.success(L0())},onError:(_)=>{k.error(_ instanceof Error?_.message:yh())}}),c=Boolean(a?.appearance?.hideAgent),f=(_)=>{s(_)};if(l)return t("div",{className:"flex items-center justify-center p-8",children:t(F,{className:"h-6 w-6 animate-spin text-muted-foreground"})});return t("div",{className:"h-full overflow-y-auto pr-1",children:o(Et,{children:[o(kt,{children:[t(Rt,{children:Hm()}),t(Ut,{children:$m()})]}),t(Mt,{className:"space-y-6",children:o("div",{className:"flex items-center justify-between space-x-4 rounded-lg border border-border p-4",children:[o("div",{className:"space-y-1",children:[t("label",{htmlFor:"hide-agent-switch",className:"text-sm font-medium leading-none cursor-pointer",children:Cv()}),t("p",{className:"text-xs text-muted-foreground",children:Iv()})]}),t(je,{id:"hide-agent-switch",checked:c,onCheckedChange:f,disabled:d})]})})]})})}S();var Es={openai:"OpenAI",google:"Google","google-vertex":"Google Vertex AI",xai:"xAI",fal:"Fal",replicate:"Replicate","black-forest-labs":"Black Forest Labs",klingai:"Kling AI",togetherai:"Together AI",fireworks:"Fireworks AI",deepinfra:"DeepInfra",luma:"Luma","amazon-bedrock":"Amazon Bedrock",alibaba:"Alibaba",bytedance:"ByteDance",minimax:"MiniMax",prodia:"Prodia",azure:"Azure OpenAI"};function Ts({teamId:e}){let r=K(),[a,l]=u(null),{data:s,isLoading:d}=L({queryKey:["teams",e,"media-generation"],queryFn:async()=>{let g=await A.api.teams[":teamId"]["media-generation"].$get({param:{teamId:e}});if(!g.ok)throw Error("Failed to fetch media generation settings");return await g.json()}}),c=s?.providers||[],f=s?.enabledModels||[],_=D(()=>{if(!a)return null;return c.find((g)=>g.provider===a.provider)||a},[a,c]);if(d)return t("div",{className:"flex h-64 items-center justify-center",children:t(F,{className:"h-8 w-8 animate-spin text-muted-foreground"})});return o("div",{className:"flex flex-col h-full min-w-0 w-full",children:[t(ce,{className:"h-full pr-1 [&>div>div]:block!",children:t("div",{className:"pb-12 min-w-0 w-full",children:o(Et,{className:"border-border min-w-0 w-full",children:[o(kt,{children:[t(Rt,{className:"text-base font-semibold",children:Dw()}),t(Ut,{children:Pw()})]}),t(Mt,{className:"min-w-0",children:t("div",{className:"space-y-2.5 min-w-0",children:c.map((g)=>{let y=Es[g.provider]||g.provider,x=g.status==="configured_custom",m=g.status==="configured_env",i=f.filter((w)=>w.provider===g.provider&&w.type==="image").length,v=f.filter((w)=>w.provider===g.provider&&w.type==="video").length;return o("div",{onClick:()=>l(g),className:"group cursor-pointer flex items-center justify-between gap-4 p-3.5 rounded-xl border border-border bg-card/50 hover:bg-card/80 hover:border-primary/50 transition-all shadow-none hover:shadow-xs min-w-0",children:[o("div",{className:"flex flex-col gap-1.5 min-w-0 flex-1",children:[o("div",{className:"flex items-center gap-2.5 min-w-0",children:[t("span",{className:"font-semibold text-sm text-foreground truncate",children:y}),t("span",{className:"text-xs text-muted-foreground font-mono opacity-60 truncate",title:g.customApiKeyOrEnv||g.defaultEnvKey,children:g.customApiKeyOrEnv||g.defaultEnvKey})]}),o("div",{className:"flex flex-wrap items-center gap-2 min-w-0",children:[x&&o(be,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 text-[10px] shrink-0 font-normal gap-1",children:[t(vr,{className:"w-3 h-3"}),pg()]}),m&&o(be,{variant:"outline",className:"bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/20 text-[10px] shrink-0 font-normal gap-1",children:[t(vr,{className:"w-3 h-3"}),mg()]}),!x&&!m&&t(be,{variant:"outline",className:"bg-muted text-muted-foreground border-border text-[10px] shrink-0 font-normal",children:hg()}),g.supportedTypes.includes("image")&&o("span",{className:C("inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded border shrink-0 font-normal transition-colors",i>0?"bg-primary/10 text-primary border-primary/20":"bg-muted/50 text-muted-foreground border-border/60"),children:[t(eo,{className:"w-3 h-3"}),Mv({count:i})]}),g.supportedTypes.includes("video")&&o("span",{className:C("inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded border shrink-0 font-normal transition-colors",v>0?"bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20":"bg-muted/50 text-muted-foreground border-border/60"),children:[t(ma,{className:"w-3 h-3"}),oI({count:v})]})]})]}),t(bt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors shrink-0"})]},g.provider)})})})]})})}),_&&t(Ar,{isOpen:!!_,onClose:()=>l(null),provider:_,teamId:e,enabledModels:f,onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"media-generation"]})}})]})}function Ar({isOpen:e,onClose:r,provider:a,teamId:l,enabledModels:s,onSuccess:d}){let[c,f]=u(()=>a.apiKeyConfigured?"models":"api-key"),[_,g]=u(a.customApiKeyOrEnv||""),[y,x]=u(()=>s.filter((ee)=>ee.provider===a.provider).map((ee)=>({type:ee.type,modelId:ee.modelId,name:ee.name}))),[m,i]=u(""),[v,w]=u("all"),[M,O]=u(""),[Y,z]=u(a.supportedTypes[0]||"image");h(()=>{f(a.apiKeyConfigured?"models":"api-key"),g(a.customApiKeyOrEnv||""),x(s.filter((ee)=>ee.provider===a.provider).map((ee)=>({type:ee.type,modelId:ee.modelId,name:ee.name}))),i(""),w("all"),O(""),z(a.supportedTypes[0]||"image")},[a.provider,a.customApiKeyOrEnv,a.apiKeyConfigured,s]);let{data:oe=[],isLoading:re}=L({queryKey:["teams",l,"media-generation","curated",a.provider],queryFn:async()=>{let ee=await A.api.teams[":teamId"]["media-generation"].models.curated.$get({param:{teamId:l},query:{provider:a.provider}});if(!ee.ok)return[];return await ee.json()},enabled:e}),{mutate:T,isPending:q}=B({mutationFn:async()=>{let ee=await A.api.teams[":teamId"]["media-generation"].providers[":provider"].$put({param:{teamId:l,provider:a.provider},json:{apiKey:_.trim(),models:y.map((se)=>({type:se.type,modelId:se.modelId,name:se.name||se.modelId}))}});if(!ee.ok){let se=await ee.json().catch(()=>({}));throw Error(se?.message||"Failed to update provider")}return await ee.json()},onSuccess:()=>{k.success(gg()),d(),r()},onError:(ee)=>{k.error(ee instanceof Error?ee.message:Ob())}}),j=D(()=>new Set(oe.map((ee)=>ee.modelId)),[oe]),G=D(()=>y.filter((ee)=>!j.has(ee.modelId)),[y,j]),N=D(()=>{let ee=[];for(let se of oe){let _e=y.some((Pe)=>Pe.modelId===se.modelId&&Pe.type===se.type);ee.push({type:se.type,modelId:se.modelId,name:se.name,isCustom:!1,isToggledOn:_e})}for(let se of G)ee.push({type:se.type,modelId:se.modelId,name:se.name||se.modelId,isCustom:!0,isToggledOn:!0});return ee},[oe,y,G]),X=D(()=>N.filter((ee)=>{if(v!=="all"&&ee.type!==v)return!1;if(m.trim()){let se=m.toLowerCase(),_e=ee.name.toLowerCase().includes(se),Pe=ee.modelId.toLowerCase().includes(se);if(!_e&&!Pe)return!1}return!0}),[N,v,m]),xe=(ee,se)=>{if(se)x((_e)=>[..._e,{type:ee.type,modelId:ee.modelId,name:ee.name,isCustom:ee.isCustom}]);else x((_e)=>_e.filter((Pe)=>!(Pe.modelId===ee.modelId&&Pe.type===ee.type)))},ye=(ee,se)=>{x((_e)=>_e.filter((Pe)=>!(Pe.modelId===ee&&Pe.type===se)))},De=()=>{let ee=M.trim();if(!ee)return;if(y.some((_e)=>_e.modelId===ee&&_e.type===Y)){k.error(Eb());return}x((_e)=>[..._e,{type:Y,modelId:ee,name:ee,isCustom:!0}]),O("")},Me=Es[a.provider]||a.provider;return t(ue,{open:e,onOpenChange:(ee)=>!ee&&r(),children:o(ie,{className:"sm:max-w-2xl md:max-w-3xl h-[88vh] flex flex-col p-0 overflow-hidden",children:[o(me,{className:"p-6 pb-2 shrink-0",children:[o(le,{className:"flex items-center gap-2 text-xl",children:[t("span",{children:Me}),a.status==="configured_custom"&&t(be,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 text-[10px] font-normal",children:pg()}),a.status==="configured_env"&&t(be,{variant:"outline",className:"bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/20 text-[10px] font-normal",children:mg()})]}),t(Tt,{children:_y({envKey:a.defaultEnvKey})})]}),o(xo,{value:c,onValueChange:(ee)=>f(ee),className:"flex-1 flex flex-col min-h-0",children:[t("div",{className:"px-6 pb-2 shrink-0",children:o(So,{className:"grid w-full grid-cols-2",children:[t(Qr,{value:"api-key",onClick:()=>f("api-key"),children:od()}),o(Qr,{value:"models",onClick:()=>f("models"),children:[_d()," (",y.length,")"]})]})}),t(kn,{value:"api-key",className:"flex-1 flex flex-col min-h-0 m-0",children:t("div",{className:"flex-1 min-h-0",children:t(ce,{className:"h-full",children:t("div",{className:"p-6 space-y-4 pr-6",children:o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t("label",{htmlFor:"provider-api-key",className:"text-xs font-medium text-foreground",children:od()}),_&&o(E,{type:"button",variant:"ghost",size:"sm",className:"text-xs h-7 text-destructive hover:bg-destructive/10 hover:text-destructive gap-1 px-2",onClick:()=>g(""),children:[t(we,{className:"w-3.5 h-3.5"}),y_()]})]}),t(H,{id:"provider-api-key",type:"text",value:_,onChange:(ee)=>g(ee.target.value),placeholder:D0({envKey:a.defaultEnvKey}),className:"font-mono text-sm"}),t("p",{className:"text-xs text-muted-foreground mt-1",children:N0({envKey:a.defaultEnvKey})})]})})})})}),o(kn,{value:"models",className:"flex-1 flex flex-col min-h-0 m-0",children:[!a.apiKeyConfigured&&!_&&t("div",{className:"px-6 pb-2 shrink-0",children:o("div",{className:"flex items-start gap-2.5 p-3 rounded-lg bg-amber-500/10 border border-amber-500/20 text-amber-600 dark:text-amber-400 text-xs",children:[t(vn,{className:"w-4 h-4 shrink-0 mt-0.5"}),o("div",{children:[t("p",{className:"font-medium",children:hg()}),t("p",{className:"text-[11px] opacity-90 mt-0.5",children:GS()})]})]})}),o("div",{className:"px-6 pb-3 flex items-center justify-between gap-3 shrink-0",children:[o("div",{className:"relative flex-1",children:[t(Bt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t(H,{type:"text",placeholder:wp(),value:m,onChange:(ee)=>i(ee.target.value),className:"pl-9 h-9 text-xs"})]}),a.supportedTypes.length>1&&o("div",{className:"flex rounded-md border border-border overflow-hidden shrink-0 h-9",children:[t("button",{type:"button",onClick:()=>w("all"),className:C("px-3 text-xs transition-colors",v==="all"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:E0()}),o("button",{type:"button",onClick:()=>w("image"),className:C("px-3 text-xs transition-colors flex items-center gap-1.5",v==="image"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:[t(eo,{className:"w-3.5 h-3.5"}),Gf()]}),o("button",{type:"button",onClick:()=>w("video"),className:C("px-3 text-xs transition-colors flex items-center gap-1.5",v==="video"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:[t(ma,{className:"w-3.5 h-3.5"}),Vf()]})]})]}),t("div",{className:"flex-1 min-h-0 px-6",children:t(ce,{className:"h-full pr-4",children:re?o("div",{className:"flex h-48 items-center justify-center gap-2 text-muted-foreground",children:[t(F,{className:"h-5 w-5 animate-spin"}),t("span",{className:"text-xs",children:Kv()})]}):X.length===0?t("div",{className:"text-center py-12 border border-dashed rounded-xl text-muted-foreground text-sm",children:bd()}):t("div",{className:"space-y-2 pb-4",children:X.map((ee)=>o("div",{className:C("flex items-center justify-between p-3 rounded-xl border transition-all text-xs",ee.isToggledOn?"border-primary/40 bg-primary/5":"border-border bg-card hover:border-primary/30"),children:[o("div",{className:"flex items-center gap-2.5 min-w-0 flex-1 mr-3",children:[o(be,{variant:"outline",className:C("text-[10px] px-1.5 py-0.5 gap-1 shrink-0 font-normal",ee.type==="image"?"bg-primary/10 text-primary border-primary/20":"bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20"),children:[ee.type==="image"?t(eo,{className:"w-3 h-3"}):t(ma,{className:"w-3 h-3"}),ee.type==="image"?Gf():Vf()]}),o("div",{className:"min-w-0 flex-1",children:[o("div",{className:"font-semibold text-foreground text-sm truncate flex items-center gap-1.5",children:[t("span",{className:"truncate",children:ee.name}),ee.isCustom&&t(be,{variant:"secondary",className:"text-[10px] h-4 px-1 font-normal shrink-0",children:cy().replace("...","")})]}),t("p",{className:"font-mono text-[11px] text-muted-foreground truncate mt-0.5",children:ee.modelId})]})]}),o("div",{className:"flex items-center gap-2 shrink-0",children:[ee.isCustom&&t(E,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>ye(ee.modelId,ee.type),title:it(),children:t(we,{className:"w-3.5 h-3.5"})}),t(je,{checked:ee.isToggledOn,onCheckedChange:(se)=>xe(ee,se),"aria-label":`Toggle ${ee.name}`})]})]},`${ee.type}-${ee.modelId}`))})})}),t("div",{className:"px-6 py-3 border-t border-border shrink-0 bg-muted/10",children:o("div",{className:"flex items-center gap-2",children:[a.supportedTypes.length>1&&o("div",{className:"flex rounded-md border border-border overflow-hidden shrink-0 h-8",children:[t("button",{type:"button",onClick:()=>z("image"),className:C("px-2.5 py-1 text-xs transition-colors",Y==="image"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:Gf()}),t("button",{type:"button",onClick:()=>z("video"),className:C("px-2.5 py-1 text-xs transition-colors",Y==="video"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:Vf()})]}),t(H,{type:"text",value:M,onChange:(ee)=>O(ee.target.value),placeholder:ab(),className:"font-mono text-xs h-8 flex-1",onKeyDown:(ee)=>{if(ee.key==="Enter")ee.preventDefault(),De()}}),o(E,{type:"button",size:"sm",variant:"outline",className:"h-8 text-xs shrink-0 gap-1",onClick:De,disabled:!M.trim(),children:[t(pe,{className:"w-3.5 h-3.5"}),mf()]})]})})]})]}),o(Ge,{className:"px-6 py-4 border-t border-border shrink-0 flex items-center justify-between sm:justify-between w-full m-0 bg-card",children:[o("div",{className:"text-xs text-muted-foreground",children:[y.length," ",_d().toLowerCase()]}),o("div",{className:"flex items-center gap-2",children:[t(E,{type:"button",variant:"outline",size:"sm",onClick:r,disabled:q,children:Ne()}),o(E,{type:"button",size:"sm",onClick:()=>T(),disabled:q,children:[q&&t(F,{className:"w-4 h-4 mr-1.5 animate-spin"}),Fo()]})]})]})]})})}S();S();function Vs({isOpen:e,onClose:r,imageSrc:a,onConfirm:l}){let[s,d]=u(1),[c,f]=u({x:0,y:0}),[_,g]=u(!1),[y,x]=u(!1),m=b({x:0,y:0}),i=b(null),v=b(null),w=250;h(()=>{if(e)d(1),f({x:0,y:0}),x(!1)},[e,a]);let M=(T)=>{T.preventDefault(),g(!0),m.current={x:T.clientX-c.x,y:T.clientY-c.y}},O=(T)=>{if(!_)return;f({x:T.clientX-m.current.x,y:T.clientY-m.current.y})},Y=()=>{g(!1)},z=(T)=>{if(T.touches.length!==1)return;g(!0);let q=T.touches[0];m.current={x:q.clientX-c.x,y:q.clientY-c.y}},oe=(T)=>{if(!_||T.touches.length!==1)return;let q=T.touches[0];f({x:q.clientX-m.current.x,y:q.clientY-m.current.y})},re=async()=>{let T=i.current,q=v.current;if(!T||!q)return;x(!0);try{let j=T.getBoundingClientRect(),G=512,N=document.createElement("canvas");N.width=512,N.height=512;let X=N.getContext("2d");if(X){X.clearRect(0,0,512,512);let xe=2.048,ye=j.width/s,De=j.height/s,Me=256+c.x*xe,ee=256+c.y*xe;X.translate(Me,ee),X.scale(s*xe,s*xe),X.drawImage(T,-ye/2,-De/2,ye,De);let se=await new Promise((_e)=>{N.toBlob((Pe)=>_e(Pe),"image/jpeg",0.9)});if(se)await l(se)}}catch(j){console.error("Failed to crop image",j)}finally{x(!1)}};return t(ue,{open:e,onOpenChange:(T)=>!T&&r(),children:o(ie,{className:"sm:max-w-[420px] rounded-2xl border border-border bg-background/95 backdrop-blur-md shadow-2xl p-0 overflow-hidden gap-0",children:[t(me,{className:"p-6 border-b border-border/40 bg-gradient-to-br from-primary/5 to-transparent",children:o(le,{className:"text-xl font-bold flex items-center gap-2",children:[t(Wa,{className:"w-5 h-5 text-primary"}),xS()]})}),o("div",{className:"p-6 flex flex-col items-center gap-6",children:[o("div",{ref:v,className:"relative overflow-hidden bg-muted select-none border border-border/40 rounded-xl cursor-move shadow-inner",style:{width:250,height:250},onMouseDown:M,onMouseMove:O,onMouseUp:Y,onMouseLeave:Y,onTouchStart:z,onTouchMove:oe,onTouchEnd:Y,children:[a&&t("img",{ref:i,src:a,alt:s_(),crossOrigin:"anonymous",className:"absolute origin-center max-w-none pointer-events-none transition-transform duration-75 select-none",style:{top:"50%",left:"50%",transform:`translate(-50%, -50%) translate(${c.x}px, ${c.y}px) scale(${s})`,maxHeight:"100%"}}),t("div",{className:"absolute inset-0 pointer-events-none border-[3px] border-primary/90 rounded-full"}),t("div",{className:"absolute inset-0 pointer-events-none bg-black/40",style:{clipPath:"polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)",maskImage:"radial-gradient(circle, transparent 122px, black 123px)",WebkitMaskImage:"radial-gradient(circle, transparent 122px, black 123px)"}})]}),o("div",{className:"w-full flex items-center gap-3 px-2",children:[t(Ya,{className:"w-4 h-4 text-muted-foreground"}),t("input",{type:"range",min:"1.0",max:"3.0",step:"0.01",value:s,onChange:(T)=>d(parseFloat(T.target.value)),className:"flex-1 h-1.5 bg-muted rounded-lg appearance-none cursor-pointer accent-primary focus:outline-none"}),t(Xa,{className:"w-4 h-4 text-muted-foreground"})]})]}),o(Ge,{className:"p-6 border-t border-border/40 bg-muted/20 flex flex-row justify-end gap-3",children:[t(E,{variant:"outline",onClick:r,disabled:y,children:Ne()}),t(E,{onClick:re,disabled:y||!a,className:"min-w-[80px]",children:y?o(Z,{children:[t(F,{className:"w-4 h-4 animate-spin mr-2"}),Rg()]}):Fo()})]})]})})}var Ir=["general","transcode","quotas","appearance","skills","mcp","providers","image-video","agents","sandbox","notifications","developer"];function Ls(){if(typeof window>"u")return"general";let e=window.location.hash.replace(/^#/,"");return Ir.includes(e)?e:"general"}function Er(){let{teamId:e}=Tr.useParams(),r=K(),[a,l]=u(Ls),s=(se)=>{l(se);let _e=se==="general"?"":`#${se}`;if(window.location.hash!==_e)window.history.replaceState(null,"",window.location.pathname+window.location.search+_e)};h(()=>{let se=()=>{l(Ls())};return window.addEventListener("hashchange",se),()=>window.removeEventListener("hashchange",se)},[]);let[d,c]=u(""),[f,_]=u(!1),[g,y]=u(null),x=b(null),[m,i]=u(!1),{setMetadata:v,getMetadata:w}=hr(),M=w("locale")||n(),O=async(se)=>{if(se==="en"||se==="zh")try{await v(e,"locale",se),Mi(se),k.success(qv())}catch(_e){console.error(_e),k.error(Lb())}},{data:Y,isLoading:z,error:oe}=L({queryKey:["teams",e,"settings"],queryFn:async()=>{let se=await A.api.teams[":teamId"].settings.$get({param:{teamId:e}});if(!se.ok)throw Error("Failed to fetch settings");return await se.json()}}),{data:re,isLoading:T}=L({queryKey:["teams",e,"me"],queryFn:async()=>{let se=await A.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!se.ok)throw Error("Failed to fetch me");return await se.json()},enabled:!!e});h(()=>{if(re?.name)c(re.name)},[re]),h(()=>{let se=["transcode","quotas","appearance","providers","image-video","skills","mcp","agents","sandbox"];if(re&&re.role!=="owner"&&se.includes(a))s("general")},[re,a]);let q=(se)=>{if(!se)return"U";let _e=se.split(" ");if(_e.length>1)return`${_e[0][0]}${_e[_e.length-1][0]}`.toUpperCase();return se.substring(0,2).toUpperCase()},j=(se)=>{let _e=se.target.files?.[0];if(_e){let Pe=new FileReader;Pe.onload=()=>{y(Pe.result),_(!0)},Pe.readAsDataURL(_e),se.target.value=""}},G=async(se)=>{i(!0);try{let _e=new File([se],"avatar.jpg",{type:"image/jpeg"}),Pe=await A.api.teams[":teamId"].files.$post({param:{teamId:e},form:{file:_e}});if(!Pe.ok)throw Error("Failed to upload avatar");let J=(await Pe.json()).key;if(!(await A.api.teams[":teamId"].me.$patch({param:{teamId:e},json:{imageKey:J}})).ok)throw Error("Failed to save profile");k.success(a_()),r.invalidateQueries({queryKey:["teams",e,"me"]}),_(!1)}catch(_e){console.error(_e),k.error(Fb())}finally{i(!1)}},N=async()=>{i(!0);try{if(!(await A.api.teams[":teamId"].me.$patch({param:{teamId:e},json:{imageKey:null}})).ok)throw Error("Failed to remove avatar");k.success(o_()),r.invalidateQueries({queryKey:["teams",e,"me"]})}catch(se){console.error(se),k.error(xb())}finally{i(!1)}},X=async()=>{if(!d.trim())return;i(!0);try{if(!(await A.api.teams[":teamId"].me.$patch({param:{teamId:e},json:{name:d.trim()}})).ok)throw Error("Failed to update name");k.success(ig()),r.invalidateQueries({queryKey:["teams",e,"me"]})}catch(se){console.error(se),k.error(Zb())}finally{i(!1)}},{mutate:xe}=B({mutationFn:async(se)=>{let _e=await A.api.teams[":teamId"].settings.$patch({param:{teamId:se.teamId},json:se.data});if(!_e.ok)throw Error("Failed to update settings");return await _e.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"settings"]})}}),ye=(se)=>{xe({teamId:e,data:{key:"transcode.videoStrategy",value:se}})},De=(se)=>{xe({teamId:e,data:{key:"transcode.hardwareAcceleration",value:se}})};if(z||T)return t("div",{className:"flex h-screen items-center justify-center",children:t(F,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(oe)return t("div",{className:"p-8 text-center text-red-500",children:Wo()});let Me=Y?.transcode?.videoStrategy||ga.best_match;if(Me==="single"||Me==="disable")Me=ga.best_match;else if(Me==="full")Me=ga.all;let ee=Y?.transcode?.hardwareAcceleration||Li.off;return t("div",{className:"h-full bg-background font-sans selection:bg-primary/20 transition-colors duration-300",children:o("div",{className:"flex flex-col md:flex-row h-full",children:[t("div",{className:"w-full h-full md:w-72 bg-sidebar border-b md:border-b-0 md:border-r border-sidebar-border z-10 md:left-16 overflow-y-auto transition-colors duration-300",children:o("nav",{className:"p-4 space-y-1 mt-4",children:[t("div",{className:"mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider",children:vS()}),o("button",{onClick:()=>s("general"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="general"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Vn,{className:"w-5 h-5"}),sv(),a==="general"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("notifications"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="notifications"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(fi,{className:"w-5 h-5"}),Jh(),a==="notifications"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("developer"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="developer"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Zt,{className:"w-5 h-5"}),qm(),a==="developer"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),re?.role==="owner"&&o(Z,{children:[t("div",{className:"mt-6 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:A1()}),o("button",{onClick:()=>s("transcode"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="transcode"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Ua,{className:"w-5 h-5"}),Zh(),a==="transcode"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("quotas"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="quotas"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Bo,{className:"w-5 h-5"}),Rd(),a==="quotas"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("appearance"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="appearance"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Hl,{className:"w-5 h-5"}),_f(),a==="appearance"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]}),re?.role==="owner"&&o(Z,{children:[t("div",{className:"mt-6 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:v0()}),o("button",{onClick:()=>s("providers"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="providers"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(ao,{className:"w-5 h-5"}),VS(),a==="providers"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("image-video"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="image-video"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(sn,{className:"w-5 h-5"}),Th(),a==="image-video"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("skills"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="skills"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(wt,{className:"w-5 h-5"}),jg(),a==="skills"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("mcp"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="mcp"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(bn,{className:"w-5 h-5"}),Bc(),a==="mcp"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("agents"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="agents"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(St,{className:"w-5 h-5"}),f0(),a==="agents"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("sandbox"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="sandbox"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t($l,{className:"w-5 h-5"}),HA(),a==="sandbox"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]})]})}),t("main",{className:"flex-1 bg-background/50 h-full flex flex-col transition-colors duration-300 overflow-y-hidden",children:o("div",{className:"flex-1 flex flex-col max-w-4xl w-full mx-auto p-6 md:p-10 overflow-hidden",children:[t("div",{className:"flex-none flex items-center justify-between mb-6",children:o("div",{children:[o("h2",{className:"text-2xl font-bold text-foreground",children:[a==="general"&&Eh(),a==="transcode"&&Zh(),a==="quotas"&&Ig(),a==="appearance"&&Hm(),a==="skills"&&qg(),a==="mcp"&&Bc(),a==="providers"&&b0(),a==="image-video"&&Th(),a==="agents"&&y0(),a==="sandbox"&&$A(),a==="notifications"&&Fx(),a==="developer"&&By()]}),o("p",{className:"text-sm text-muted-foreground mt-1",children:[a==="general"&&iv(),a==="transcode"&&eA(),a==="quotas"&&Tg(),a==="appearance"&&$m(),a==="skills"&&ZC(),a==="mcp"&&Ad(),a==="providers"&&QS(),a==="image-video"&&Nw(),a==="agents"&&p0(),a==="sandbox"&&$E(),a==="notifications"&&Zx(),a==="developer"&&Zy()]})]})}),o("div",{className:"flex-1 overflow-hidden animate-in fade-in slide-in-from-bottom-4 duration-500",children:[a==="general"&&o("div",{className:"h-full overflow-y-auto space-y-6 pr-1",children:[o(Et,{children:[o(kt,{children:[t(Rt,{children:yS()}),t(Ut,{children:bS()})]}),t(Mt,{className:"space-y-6",children:o("div",{className:"flex flex-col md:flex-row gap-8 items-start",children:[o("div",{className:"flex flex-col items-center gap-3",children:[t("span",{className:"text-sm font-medium text-muted-foreground",children:n_()}),o("div",{className:"group relative cursor-pointer overflow-hidden rounded-full w-24 h-24 border border-border/60 shadow-md transition-all hover:opacity-90",onClick:()=>x.current?.click(),children:[o(Ce,{className:"w-24 h-24",children:[re?.image&&t(Ie,{src:re.image,alt:re.name,className:"object-cover w-24 h-24"}),t(Te,{className:"text-2xl bg-primary/40 text-foreground",children:q(re?.name)})]}),t("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:t("span",{className:"text-white text-xs font-semibold",children:h_()})})]}),o("div",{className:"flex gap-2",children:[t(E,{variant:"outline",size:"sm",onClick:()=>x.current?.click(),children:W1()}),re?.image&&t(E,{variant:"ghost",size:"sm",className:"text-red-500 hover:text-red-600",onClick:N,children:El()})]}),t("input",{type:"file",ref:x,className:"hidden",accept:"image/*",onChange:j})]}),o("div",{className:"flex-1 space-y-4 w-full",children:[o("div",{className:"space-y-2",children:[t("label",{className:"text-sm font-medium text-muted-foreground",children:_l()}),t(H,{value:d,onChange:(se)=>c(se.target.value),placeholder:cb(),className:"max-w-md"})]}),o("div",{className:"space-y-2",children:[t("label",{className:"text-sm font-medium text-muted-foreground",children:kf()}),t(H,{value:re?.email||"",disabled:!0,className:"max-w-md bg-muted/50 cursor-not-allowed"}),t("p",{className:"text-xs text-muted-foreground",children:Yy()})]}),o(E,{onClick:X,disabled:m||!d.trim(),className:"mt-2",children:[m&&t(F,{className:"w-4 h-4 animate-spin mr-2"}),Us()]})]})]})})]}),o(Et,{className:"border border-slate-200 dark:border-slate-800 mt-6",children:[o(kt,{children:[t(Rt,{children:jv()}),t(Ut,{children:gC()})]}),t(Mt,{className:"space-y-4",children:t("div",{className:"max-w-xs",children:o(Fe,{value:M,onValueChange:O,children:[t(Ze,{children:t(Le,{placeholder:fC()})}),o(Be,{children:[t(ne,{value:"en",children:ob()}),t(ne,{value:"zh",children:__()})]})]})})})]}),t(Vs,{isOpen:f,onClose:()=>_(!1),imageSrc:g,onConfirm:G})]}),a==="transcode"&&t("div",{className:"h-full overflow-y-auto pr-1",children:o(Et,{children:[o(kt,{children:[t(Rt,{children:U1()}),o(Ut,{children:[t("span",{className:"block mb-2",children:eA()}),t("span",{className:"block",children:z1()})]})]}),o(Mt,{className:"space-y-6",children:[o("div",{className:"space-y-3",children:[t("h3",{className:"text-lg font-medium",children:sI()}),o("div",{className:"space-y-3",children:[o("div",{className:C("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",Me===ga.best_match?"border-primary bg-primary/5":"border-border"),onClick:()=>ye(ga.best_match),children:[t("div",{className:"font-semibold",children:u_()}),t("div",{className:"text-sm text-muted-foreground",children:d_()})]}),o("div",{className:C("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",Me===ga.all?"border-primary bg-primary/5":"border-border"),onClick:()=>ye(ga.all),children:[t("div",{className:"font-semibold",children:C0()}),t("div",{className:"text-sm text-muted-foreground",children:I0()})]})]})]}),o("div",{className:"space-y-3 pt-6 border-t border-border",children:[t("h3",{className:"text-lg font-medium",children:vv()}),o("div",{className:"space-y-3",children:[o("div",{className:C("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",ee===Li.off?"border-primary bg-primary/5":"border-border"),onClick:()=>De(Li.off),children:[t("div",{className:"font-semibold",children:Sv()}),t("div",{className:"text-sm text-muted-foreground",children:Ev()})]}),o("div",{className:C("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",ee===Li.auto?"border-primary bg-primary/5":"border-border"),onClick:()=>De(Li.auto),children:[t("div",{className:"font-semibold",children:wv()}),t("div",{className:"text-sm text-muted-foreground",children:xv()})]})]})]})]})]})}),a==="skills"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(Ss,{teamId:e})}),a==="mcp"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(ks,{teamId:e})}),a==="providers"&&t(ws,{teamId:e}),a==="image-video"&&t(Ts,{teamId:e}),a==="agents"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(ys,{teamId:e})}),a==="sandbox"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(Ns,{teamId:e})}),a==="notifications"&&t(Ms,{teamId:e}),a==="developer"&&t(Fs,{teamId:e}),a==="quotas"&&t(As,{teamId:e}),a==="appearance"&&t(Is,{teamId:e})]})]})})]})})}var Tr=Ue("/teams/$teamId/settings")({component:Er});export{Tr as Route};
|