@shumai-one/shumai 0.6.2 → 0.6.4
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-mcj1xpcc.js → chunk-01vx2chc.js} +2 -2
- package/bin/chunk-0epkrexd.js +2 -0
- package/bin/chunk-0h5239kt.js +2 -0
- package/bin/{chunk-jt0ykktx.js → chunk-0jnstdgf.js} +1 -1
- package/bin/{chunk-x03jwaga.js → chunk-0njsjy6x.js} +4 -4
- package/bin/{chunk-7naa7tpn.js → chunk-13rq2gtr.js} +2 -2
- package/bin/chunk-1aqs9sdh.js +3 -0
- package/bin/{chunk-m0q2cgfg.js → chunk-22jbsrka.js} +1 -1
- package/bin/chunk-2qknebmd.js +1 -0
- package/bin/{chunk-a411xhmm.js → chunk-2qzmh3ae.js} +4 -4
- package/bin/{chunk-2nhgdqdg.js → chunk-2tt0b8ym.js} +2 -2
- package/bin/{chunk-p3f5aevs.js → chunk-2zm7czk6.js} +1 -1
- package/bin/{chunk-p4s95471.js → chunk-396tfwdx.js} +1 -1
- package/bin/chunk-3mx4trvh.js +10 -0
- package/bin/{chunk-b5rhvzv9.js → chunk-45pb3kzz.js} +2 -2
- package/bin/{chunk-q83h0hkx.js → chunk-47fmhzwv.js} +2 -2
- package/bin/chunk-4awk4xhq.js +2 -0
- package/bin/{chunk-2cdxm1cp.js → chunk-4b2x2qba.js} +23 -23
- package/bin/{chunk-knj2s8mg.js → chunk-4rjy7ybr.js} +8 -8
- package/bin/{chunk-q8w4mbw4.js → chunk-598x693h.js} +2 -2
- package/bin/chunk-5c7ztqs7.js +1 -0
- package/bin/{chunk-2jj4j8cn.js → chunk-65dh7x4c.js} +2 -2
- package/bin/{chunk-hnkcgvcj.js → chunk-66e2vrky.js} +1 -1
- package/bin/{chunk-g22wmpk1.js → chunk-6j3beg6n.js} +2 -2
- package/bin/{chunk-cgmebxx6.js → chunk-6ke13k69.js} +1 -1
- package/bin/{chunk-7sgrtxbt.js → chunk-6rqakmg0.js} +2 -2
- package/bin/{chunk-4mws03es.js → chunk-6ty4tfmf.js} +3 -3
- package/bin/chunk-7e9ws6dh.js +129 -0
- package/bin/chunk-7mdddkfc.js +1 -0
- package/bin/{chunk-q2bew2vc.js → chunk-7q4mgd5x.js} +2 -2
- package/bin/chunk-7yv7shad.js +1 -0
- package/bin/{chunk-qwpkcp8d.js → chunk-81b8rfv7.js} +2 -2
- package/bin/{chunk-atfz7g7e.js → chunk-8a7ymmd4.js} +2 -2
- package/bin/chunk-8ac9at5y.js +2 -0
- package/bin/{chunk-gxepkvt2.js → chunk-8zcfgz9c.js} +1 -1
- package/bin/{chunk-mcw198kg.js → chunk-955kf5kc.js} +8 -8
- package/bin/{chunk-jzgbxqdg.js → chunk-978rm9a9.js} +2 -2
- package/bin/{chunk-jt02kpfc.js → chunk-9qzbrp4d.js} +2 -2
- package/bin/{chunk-tekwpkjf.js → chunk-a283dh05.js} +2 -2
- package/bin/chunk-aa2a06cc.js +1 -0
- package/bin/{chunk-8cjet7pp.js → chunk-ajr1w3vq.js} +6 -6
- package/bin/chunk-akafypge.js +218 -0
- package/bin/chunk-amk373q2.js +2 -0
- package/bin/chunk-apq2gvvp.js +4 -0
- package/bin/chunk-av2w1sez.js +2 -0
- package/bin/{chunk-5wapd171.js → chunk-b6kmj34z.js} +12 -12
- package/bin/chunk-bkzaw9p8.js +1 -0
- package/bin/{chunk-zezje74z.js → chunk-bssb9tar.js} +3 -3
- package/bin/chunk-bwvj1aqc.js +1 -0
- package/bin/chunk-by9esjn7.js +3 -0
- package/bin/chunk-bywk8mbc.js +2 -0
- package/bin/{chunk-9xhjy897.js → chunk-c61g9hfa.js} +4 -4
- package/bin/{chunk-zrszykjf.js → chunk-cdcgjh8k.js} +1 -1
- package/bin/{chunk-yk12hydf.js → chunk-d277evce.js} +4 -4
- package/bin/{chunk-55h9ze53.js → chunk-d3brvxh7.js} +2 -2
- package/bin/{chunk-9t3p4xp6.js → chunk-dcb1nzf1.js} +1 -1
- package/bin/{chunk-mzsw9var.js → chunk-dfbzatq9.js} +2 -2
- package/bin/chunk-e0bckx12.js +2 -0
- package/bin/{chunk-3ckkwdjx.js → chunk-e2p4s2pj.js} +3 -3
- package/bin/chunk-e8zzg57c.js +2 -0
- package/bin/{chunk-vp3czaeh.js → chunk-edfaqwaq.js} +2 -2
- package/bin/chunk-ehgrp0f9.js +1 -0
- package/bin/chunk-evs2aaav.js +12 -0
- package/bin/{chunk-s9ksftq2.js → chunk-f5bhcjhw.js} +1 -1
- package/bin/{chunk-ns33grgx.js → chunk-fb9dedm2.js} +2 -2
- package/bin/{chunk-srxp5jav.js → chunk-ff0mh9p3.js} +32 -32
- package/bin/chunk-fpfby5tz.js +1 -0
- package/bin/{chunk-eyjfhdp9.js → chunk-gd3b5akr.js} +2 -2
- package/bin/{chunk-1wfg56z3.js → chunk-gm1fy3hm.js} +5 -5
- package/bin/{chunk-9n1w5dw1.js → chunk-gqkjx7rz.js} +3 -3
- package/bin/{chunk-1nvd90g2.js → chunk-h7f5370s.js} +1 -1
- package/bin/chunk-hcyhsn8e.js +2 -0
- package/bin/{chunk-vcrmjtcz.js → chunk-jxm0gzmf.js} +2 -2
- package/bin/{chunk-b7bnp021.js → chunk-k3ggy3xk.js} +2 -2
- package/bin/{chunk-257dcd2f.js → chunk-k9vjs21p.js} +2 -2
- package/bin/chunk-ka40gv72.js +1 -0
- package/bin/chunk-km70p970.js +2 -0
- package/bin/{chunk-e4yscwen.js → chunk-m6v8rb39.js} +8 -8
- package/bin/chunk-m8spagwp.js +4 -0
- package/bin/{chunk-y241cxff.js → chunk-mfh7mg5b.js} +1 -1
- package/bin/chunk-n0cn0218.js +2 -0
- package/bin/chunk-n54ftsdx.js +2 -0
- package/bin/{chunk-02fvcrej.js → chunk-n7cvj15k.js} +7 -7
- package/bin/chunk-na5fh7er.js +2 -0
- package/bin/chunk-neazdbxy.js +1 -0
- package/bin/chunk-nk24qw3m.js +1 -0
- package/bin/{chunk-73yncv54.js → chunk-nsbbseff.js} +2 -2
- package/bin/chunk-nseef85h.js +1 -0
- package/bin/chunk-p35ztj2z.js +3 -0
- package/bin/chunk-pcjc9ygv.js +2 -0
- package/bin/{chunk-167z646e.js → chunk-pemmtd8q.js} +1 -1
- package/bin/{chunk-82tps5n1.js → chunk-pzrqnnpg.js} +1 -1
- package/bin/{chunk-a74g6h8a.js → chunk-q43m934j.js} +2 -2
- package/bin/{chunk-r1xer8gn.js → chunk-q57m34h0.js} +3 -3
- package/bin/chunk-q5k72jz9.js +3 -0
- package/bin/chunk-q9fsxakd.js +2 -0
- package/bin/chunk-qadpe0ct.js +2 -0
- package/bin/chunk-qeypjv4f.css +1 -0
- package/bin/chunk-qw92z3wf.js +2 -0
- package/bin/chunk-r0byfq1t.js +1 -0
- package/bin/chunk-r0q88qw3.js +2 -0
- package/bin/chunk-rjhczkh3.js +2 -0
- package/bin/{chunk-mwktrwtx.js → chunk-s0wxbybf.js} +1 -1
- package/bin/{chunk-q5vkxee3.js → chunk-s4hkcw24.js} +2 -2
- package/bin/chunk-szta50g1.js +1 -0
- package/bin/chunk-t6cb99gp.js +2 -0
- package/bin/chunk-tcr080b9.js +1 -0
- package/bin/{chunk-yq32evnn.js → chunk-v4nqx084.js} +5 -5
- package/bin/{chunk-ympbfzz4.js → chunk-v7jzc3ye.js} +1 -1
- package/bin/{chunk-9zsv6d2f.js → chunk-vbe8wred.js} +1 -1
- package/bin/{chunk-hpbn0k9n.js → chunk-vf9s8b5t.js} +2 -2
- package/bin/{chunk-m9adtgzk.js → chunk-vk3eqr65.js} +1 -1
- package/bin/{chunk-hpwv4am3.js → chunk-vm9bbk97.js} +4 -4
- package/bin/{chunk-v05rrxp5.js → chunk-w4gqg27w.js} +2 -2
- package/bin/{chunk-x8mjh387.js → chunk-w6ym7tsd.js} +4 -4
- package/bin/{chunk-hzkjgcre.js → chunk-ways29d1.js} +1 -1
- package/bin/chunk-wesg7tg9.js +1 -0
- package/bin/chunk-wmrrapwv.js +2 -0
- package/bin/chunk-wnwsjgj8.js +2 -0
- package/bin/{chunk-hw6czrya.js → chunk-wrb4xq9v.js} +1 -1
- package/bin/{chunk-v5cn90cf.js → chunk-wzrzc07t.js} +2 -2
- package/bin/chunk-xd1axsdv.js +2 -0
- package/bin/{chunk-cwat1jwx.js → chunk-xk0jmx4s.js} +2 -2
- package/bin/{chunk-g6sdezec.js → chunk-y545vfn0.js} +1 -1
- package/bin/{chunk-fatmqnp1.js → chunk-y6h885fs.js} +1 -1
- package/bin/{chunk-cz13a82m.js → chunk-yncmfr39.js} +2 -2
- package/bin/{chunk-01052ssf.js → chunk-yxnz4ypt.js} +11 -11
- package/bin/chunk-zc1asygg.js +2 -0
- package/bin/{chunk-m82tkhaa.js → chunk-zc7wzcvh.js} +7 -7
- package/bin/chunk-zdvhh8mk.js +2 -0
- package/bin/{chunk-kvhf12b4.js → chunk-zg0b902x.js} +2 -2
- package/bin/{chunk-7v7mypc6.js → chunk-zhq7a7hs.js} +2 -2
- package/bin/{chunk-f25fe9th.js → chunk-zmnvskn7.js} +11 -11
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +470 -389
- package/package.json +7 -7
- package/prisma/migrations/20261102032402_add_archive_storage/migration.sql +25 -0
- package/prisma/schema.prisma +12 -6
- package/bin/chunk-0bj887zm.js +0 -2
- package/bin/chunk-1ktk6764.js +0 -10
- package/bin/chunk-26qn7fek.js +0 -2
- package/bin/chunk-2ne2b54t.js +0 -2
- package/bin/chunk-2vbeqczj.js +0 -1
- package/bin/chunk-37p6bcx2.js +0 -1
- package/bin/chunk-3knfx6dm.js +0 -1
- package/bin/chunk-3z85zxkn.js +0 -1
- package/bin/chunk-54tbfvya.js +0 -2
- package/bin/chunk-56kh5fxc.js +0 -1
- package/bin/chunk-576nj64j.js +0 -2
- package/bin/chunk-6cnqjngz.js +0 -1
- package/bin/chunk-7g46e1wy.js +0 -3
- package/bin/chunk-84x8p7v5.js +0 -1
- package/bin/chunk-88jg9dq5.js +0 -2
- package/bin/chunk-8fyg9dy4.js +0 -2
- package/bin/chunk-8gtfgkrn.js +0 -2
- package/bin/chunk-8mqbztj8.js +0 -2
- package/bin/chunk-8qdtvfx3.css +0 -1
- package/bin/chunk-8xb6yz11.js +0 -2
- package/bin/chunk-8yjsmr7g.js +0 -2
- package/bin/chunk-91rb0jpb.js +0 -2
- package/bin/chunk-96qpjght.js +0 -2
- package/bin/chunk-9f1xk1nt.js +0 -1
- package/bin/chunk-9mk9cvbk.js +0 -1
- package/bin/chunk-9nw5w8vh.js +0 -1
- package/bin/chunk-ah8fjb6f.js +0 -2
- package/bin/chunk-cf5axr8c.js +0 -1
- package/bin/chunk-dk42gf7v.js +0 -2
- package/bin/chunk-e4f56spj.js +0 -4
- package/bin/chunk-eb7mzbfm.js +0 -1
- package/bin/chunk-er14d498.js +0 -3
- package/bin/chunk-f6avg5qe.js +0 -129
- package/bin/chunk-fvx9k1dc.js +0 -2
- package/bin/chunk-gtf19jc1.js +0 -2
- package/bin/chunk-h1n7jqnw.js +0 -1
- package/bin/chunk-hfm82066.js +0 -2
- package/bin/chunk-j2s311yc.js +0 -3
- package/bin/chunk-kj6h5j5a.js +0 -4
- package/bin/chunk-km4gn6b6.js +0 -1
- package/bin/chunk-ny1kbmxt.js +0 -2
- package/bin/chunk-p3j6ydk1.js +0 -1
- package/bin/chunk-pk406dgy.js +0 -2
- package/bin/chunk-s1e4qy3q.js +0 -14
- package/bin/chunk-swtwaaqe.js +0 -1
- package/bin/chunk-tagdrg7p.js +0 -1
- package/bin/chunk-twtxnzbv.js +0 -2
- package/bin/chunk-v5mcjwxy.js +0 -2
- package/bin/chunk-vkzasgxw.js +0 -2
- package/bin/chunk-x342vzdx.js +0 -2
- package/bin/chunk-xc54vhfz.js +0 -2
- package/bin/chunk-xvkwbczx.js +0 -3
- package/bin/chunk-z1p13dnc.js +0 -2
- package/bin/chunk-zarz3sqn.js +0 -211
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{ce,G,S,nt,Q,M,w,Ri,L,W,a,g,ae,ee,X,Td,Je,R,j,Wt,Ar,Eo,Wr,V,Dr,Ht,qe,Be,qt,dr,Xn,eo,pa,rs,Re,or,Ue,Zs,Ke,U,si,N,$e,He,Qe,De,Ne,Fe,se,rr,c,Vl,dh,fh,kv,Rv,ph,Mv,Ep,Dv,Nv,GA,VA,Lv,Zv,jv,qv,$v,Hv,Gv,Vv,Kv,Wv,Jv,Yv,eb,tb,rb,nb,ob,JA,sb,YA,ib,XA,ab,e_,lb,t_,cb,ub,db,r_,fb,pb,mb,n_,hb,o_,gb,Ab,_b,yb,vb,s_,bb,wb,Eb,xb,Cb,Sb,Ib,Tb,kb,i_,Rb,a_,Mb,Ob,Pb,Db,Nb,l_,Fb,Lb,Zb,c_,Bb,u_,Ub,zb,jb,d_,f_,p_,m_,qb,$b,Wb,Jb,tw,sw,Cp,Sp,A_,iw,aw,__,lw,cw,uw,dw,fw,y_,pw,gh,v_,b_,mw,Aw,_w,yw,vw,bw,ww,Ew,xw,Cw,Sw,Iw,w_,Tw,Ip,Pw,Dw,Nw,qw,$w,Hw,Qw,Gw,Vw,Kw,Ww,Jw,Yw,Xw,x_,eE,tE,cE,uE,dE,fE,C_,mE,hE,gE,AE,_E,yE,Ge,bE,EE,xE,SE,TE,Wl,NE,FE,LE,ZE,T_,UE,zE,QE,VE,tu,D_,Fd,Ex,Tx,kx,Rx,Ox,Rp,Nx,Lx,Qx,Gx,Dt,Vx,Kx,Xx,eC,tC,oC,Ch,z_,aC,ru,mC,hC,Ih,AC,_C,j_,H_,wC,Q_,EC,xC,Th,IC,G_,TC,V_,kC,OC,PC,DC,NC,LC,kh,BC,zC,K_,$C,HC,Zi,as,oS,iS,Y_,Yl,Lp,cS,uS,X_,dS,gS,Mh,ry,ny,nu,_S,Zp,oy,iy,vS,bS,wS,Bp,CS,SS,NS,FS,WS,JS,YS,dy,XS,eI,rI,nI,fy,jp,py,dI,fI,pI,mI,hI,gI,AI,_I,yI,vI,EI,xI,CI,SI,II,TI,RI,MI,OI,PI,DI,NI,LI,hy,BI,UI,zI,Ay,jI,GI,VI,KI,WI,JI,YI,oT,lT,pT,mT,gT,AT,Hh,_T,yT,yy,vT,bT,wT,ET,xT,vy,by,CT,ST,IT,TT,wy,kT,Ey,RT,MT,xy,zd,$p,OT,PT,Cy,DT,NT,FT,LT,ZT,BT,UT,zT,jT,$T,HT,Qh,Gh,Vh,JT,YT,Ty,XT,e1,t1,r1,n1,Hp,o1,i1,a1,l1,c1,d1,su,f1,m1,h1,g1,A1,_1,C1,S1,R1,Zy,M1,Uy,zy,Gp,L1,Z1,B1,eg,tg,q1,$1,G1,J1,Y1,qy,X1,tk,yk,$y,vk,wk,Qy,Ek,xk,Ck,Ik,Dk,Nk,tc,rc,nc,Fk,Lk,Zk,Uk,$k,Hk,Vk,e0,sR,iR,aR,lR,n0,o0,s0,i0,cR,a0,l0,c0,u0,uR,dR,mR,gR,p0,ug,_R,vR,bR,ER,dg,fg,pg,mg,IR,Yp,Xp,em,tm,rm,kR,RR,nm,MR,om,OR,sm,PR,hg,du,gg,DR,NR,UR,zR,im,Ag,fu,b0,w0,aM,dM,fM,mo,pM,zi,C0,Eg,T0,k0,PM,R0,M0,DM,LM,ZM,P0,UM,jM,D0,GM,N0,VM,KM,WM,JM,oc,Ig,Z0,cO,uO,B0,dO,fO,pO,mO,hO,gO,AO,_O,yO,vO,bO,wO,EO,xO,CO,OO,FO,LO,ZO,BO,UO,zO,jO,qO,$O,HO,QO,GO,VO,KO,WO,JO,YO,XO,eP,tP,rP,nP,lP,fP,yP,bP,wP,EP,xP,CP,X0,IP,ev,PP,DP,tv,FP,LP,ZP,zP,fm,nv,qP,$P,HP,QP,GP,VP,KP,WP,JP,YP,sv,sD,fD,pD,mD,hD,lv,gD,xD,CD,SD,ID,TD,kD,RD,MD,PD,ct,ut,dt,ft,pt,mt,ht,gt,Se,xe,ke,ot,Ce,Nt,re,Ie,er,B,x,pe,q,at,Uo,Xd,ef,dv,tf,hl,fv,ji,pv,lc,mv,rf,ho,go,Xr,_n,ge,wt,Et,xt,Sa,fe,Ve,Ye,Xe,et,tt,be,Ir,kr,Br,st,Ct,St,Zt,_t,di}from"./chunk-akafypge.js";import{Ss}from"./chunk-fb9dedm2.js";import{ds,Ur}from"./chunk-7q4mgd5x.js";import{bu,wu}from"./chunk-a283dh05.js";import{$i,no,_l,xs,oo,Eu,uc,ka,xu}from"./chunk-598x693h.js";import{cs}from"./chunk-vf9s8b5t.js";import{zn,jn,qn,Rr,bt,yt}from"./chunk-bywk8mbc.js";import{Hi,Iu}from"./chunk-nsbbseff.js";import{bl}from"./chunk-rjhczkh3.js";import{xl}from"./chunk-av2w1sez.js";import{us}from"./chunk-km70p970.js";import{$o}from"./chunk-8a7ymmd4.js";import{Ba}from"./chunk-n54ftsdx.js";import{$n}from"./chunk-qw92z3wf.js";import{Ho}from"./chunk-zg0b902x.js";import{Hn}from"./chunk-81b8rfv7.js";import{ko}from"./chunk-8ac9at5y.js";import{zr}from"./chunk-wzrzc07t.js";var Xs=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],ia=j("circle-x",Xs);var Ys=[["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"}]],Ua=j("at-sign",Ys);var Js=[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]],za=j("blocks",Js);var tr=[["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"}]],Ha=j("film",tr);var ar=[["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"}]],na=j("globe",ar);var sr=[["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"}]],Na=j("layout-dashboard",sr);var ir=[["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=j("maximize-2",ir);var nr=[["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"}]],Wa=j("message-circle",nr);var lr=[["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"}]],Za=j("move",lr);var cr=[["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"}]],vt=j("puzzle",cr);var mr=[["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"}]],la=j("refresh-cw",mr);var ur=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Xa=j("send",ur);var pr=[["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"}]],da=j("video",pr);var fr=[["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"}]],Lt=j("zap",fr);var gr=[["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"}]],Ya=j("zoom-in",gr);var hr=[["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"}]],Ja=j("zoom-out",hr);L();L();var vr=si("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 _e({className:e,orientation:r="vertical",...t}){return a("div",{role:"group","data-slot":"field","data-orientation":r,className:U(vr({orientation:r}),e),...t})}function ye({className:e,...r}){return a(fe,{"data-slot":"field-label",className:U("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 Jt({className:e,...r}){return a("p",{"data-slot":"field-description",className:U("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 Me({className:e,children:r,errors:t,...i}){let s=Q(()=>{if(r)return r;if(!t?.length)return null;let n=[...new Map(t.map((l)=>[l?.message,l])).values()];if(n?.length==1)return n[0]?.message;return a("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:n.map((l,u)=>l?.message&&a("li",{children:l.message},u))})},[r,t]);if(!s)return null;return a("div",{role:"alert","data-slot":"field-error",className:U("text-sm font-normal text-destructive",e),...i,children:s})}function es({update:e,notify:r,unwatched:t}){return{link:i,unlink:s,propagate:n,checkDirty:l,shallowPropagate:u};function i(m,f,v){let d=f.depsTail;if(d!==void 0&&d.dep===m)return;let o=d!==void 0?d.nextDep:f.deps;if(o!==void 0&&o.dep===m){o.version=v,f.depsTail=o;return}let b=m.subsTail;if(b!==void 0&&b.version===v&&b.sub===f)return;let p=f.depsTail=m.subsTail={version:v,dep:m,sub:f,prevDep:d,nextDep:o,prevSub:b,nextSub:void 0};if(o!==void 0)o.prevDep=p;if(d!==void 0)d.nextDep=p;else f.deps=p;if(b!==void 0)b.nextSub=p;else m.subs=p}function s(m,f=m.sub){let{dep:v,prevDep:d,nextDep:o,nextSub:b,prevSub:p}=m;if(o!==void 0)o.prevDep=d;else f.depsTail=d;if(d!==void 0)d.nextDep=o;else f.deps=o;if(b!==void 0)b.prevSub=p;else v.subsTail=p;if(p!==void 0)p.nextSub=b;else if((v.subs=b)===void 0)t(v);return o}function n(m){let f=m.nextSub,v;e:do{let d=m.sub,o=d.flags;if(!(o&60))d.flags=o|32;else if(!(o&12))o=0;else if(!(o&4))d.flags=o&-9|32;else if(!(o&48)&&h(m,d))d.flags=o|40,o&=1;else o=0;if(o&2)r(d);if(o&1){let b=d.subs;if(b!==void 0){let p=(m=b).nextSub;if(p!==void 0)v={value:f,prev:v},f=p;continue}}if((m=f)!==void 0){f=m.nextSub;continue}while(v!==void 0)if(m=v.value,v=v.prev,m!==void 0){f=m.nextSub;continue e}break}while(!0)}function l(m,f){let v,d=0,o=!1;e:do{let b=m.dep,p=b.flags;if(f.flags&16)o=!0;else if((p&17)===17){if(e(b)){let _=b.subs;if(_.nextSub!==void 0)u(_);o=!0}}else if((p&33)===33){if(m.nextSub!==void 0||m.prevSub!==void 0)v={value:m,prev:v};m=b.deps,f=b,++d;continue}if(!o){let _=m.nextDep;if(_!==void 0){m=_;continue}}while(d--){let _=f.subs,F=_.nextSub!==void 0;if(F)m=v.value,v=v.prev;else m=_;if(o){if(e(f)){if(F)u(_);f=m.sub;continue}o=!1}else f.flags&=-33;f=m.sub;let D=m.nextDep;if(D!==void 0){m=D;continue e}}return o}while(!0)}function u(m){do{let f=m.sub,v=f.flags;if((v&48)===32){if(f.flags=v|16,(v&6)===2)r(f)}}while((m=m.nextSub)!==void 0)}function h(m,f){let v=f.depsTail;while(v!==void 0){if(v===m)return!0;v=v.prevDep}return!1}}function ea(e,r,t){let i=typeof e==="object",s=i?e:void 0;return{next:(i?e.next:e)?.bind(s),error:(i?e.error:r)?.bind(s),complete:(i?e.complete:t)?.bind(s)}}var Ca=[],ma=0,{link:ts,unlink:br,propagate:_r,checkDirty:os,shallowPropagate:ss}=es({update(e){return e._update()},notify(e){Ca[Ma++]=e,e.flags&=-3},unwatched(e){if(e.depsTail!==void 0)e.depsTail=void 0,e.flags=17,ua(e)}}),ca=0,Ma=0,kt,Fa=0;function we(e){try{++Fa,e()}finally{if(!--Fa)Da()}}function ua(e){let r=e.depsTail,t=r!==void 0?r.nextDep:e.deps;while(t!==void 0)t=br(t,e)}function Da(){if(Fa>0)return;while(ca<Ma){let e=Ca[ca];Ca[ca++]=void 0,e.notify()}ca=0,Ma=0}function fa(e,r){let t=typeof e==="function",i=e,s={_snapshot:t?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:t?0:1,get(){if(kt!==void 0)ts(s,kt,ma);return s._snapshot},subscribe(n){let l=ea(n),u={current:!1},h=yr(()=>{if(s.get(),!u.current)u.current=!0;else l.next?.(s._snapshot)});return{unsubscribe:()=>{h.stop()}}},_update(n){let l=kt,u=r?.compare??Object.is;if(t)kt=s,++ma,s.depsTail=void 0;else if(n===void 0)return!1;if(t)s.flags=5;try{let h=s._snapshot,m=typeof n==="function"?n(h):n===void 0&&t?i(h):n;if(h===void 0||!u(h,m))return s._snapshot=m,!0;return!1}finally{if(kt=l,t)s.flags&=-5;ua(s)}}};if(t)s.flags=17,s.get=function(){let n=s.flags;if(n&16||n&32&&os(s.deps,s)){if(s._update()){let l=s.subs;if(l!==void 0)ss(l)}}else if(n&32)s.flags=n&-33;if(kt!==void 0)ts(s,kt,ma);return s._snapshot};else s.set=function(n){if(s._update(n)){let l=s.subs;if(l!==void 0)_r(l),ss(l),Da()}};return s}function yr(e){let r=()=>{let i=kt;kt=t,++ma,t.depsTail=void 0,t.flags=6;try{return e()}finally{kt=i,t.flags&=-5,ua(t)}},t={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let i=this.flags;if(i&16||i&32&&os(this.deps,this))r();else this.flags=2},stop(){this.flags=0,this.depsTail=void 0,ua(this)}};return r(),t}var Aa=class{constructor(e,r){if(this.atom=fa(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(ea(e))}},is=class{constructor(e){this.atom=fa(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(ea(e))}};function Mt(e,r){if(typeof e==="function")return new is(e);if(r)return new Aa(e,r);return new Aa(e)}var ns=class{constructor(e,r){if(this.fn=e,this.options=r,this.lastExecutionTime=0,this.isPending=!1,this.maybeExecute=(...t)=>{let i=Date.now()-this.lastExecutionTime;if(this.options.leading&&i>=this.options.wait)this.execute(...t);else if(this.lastArgs=t,!this.timeoutId&&this.options.trailing){let s=this.options.wait-i;this.isPending=!0,this.timeoutId=setTimeout(()=>{if(this.lastArgs!==void 0)this.execute(...this.lastArgs)},s)}},this.execute=(...t)=>{this.fn(...t),this.options.onExecute?.(t,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 ns(e,r).maybeExecute}var Ta=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:t=!0,reconnectEveryMs:i=300}){this.#t=e,this.#o=t,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=i}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 t=new Event(e,{detail:r});this.#e().dispatchEvent(t)}catch(t){this.debugLog("Failed to dispatch shim event")}}dispatchCustomEvent(e,r){try{this.#e().dispatchEvent(new CustomEvent(e,{detail:r}))}catch(t){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,t){let i=t?.withEventTarget??!1,s=`${this.#t}:${e}`;if(i){if(!this.#r)this.#r=new EventTarget;this.#r.addEventListener(s,(l)=>{r(l.detail)})}if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event",s),()=>{};let n=(l)=>{this.debugLog("Received event from bus",l.detail),r(l.detail)};return this.#e().addEventListener(s,n),this.debugLog("Registered event to bus",s),()=>{if(i)this.#r?.removeEventListener(s,n);this.#e().removeEventListener(s,n)}}onAll(e){if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event"),()=>{};let r=(t)=>{let i=t.detail;e(i)};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=(t)=>{let i=t.detail;if(this.#t&&i.pluginId!==this.#t)return;e(i)};return this.#e().addEventListener("tanstack-devtools-global",r),()=>this.#e().removeEventListener("tanstack-devtools-global",r)}};class ls extends Ta{constructor(){super({pluginId:"form-devtools",reconnectEveryMs:1000})}}var We=new ls;function Ft(e,r){return typeof e==="function"?e(r):e}function zt(e,r){return va(r).reduce((i,s)=>{if(i===null)return null;if(typeof i<"u")return i[s];return},e)}function Qt(e,r,t){let i=va(r);function s(n){if(!i.length)return Ft(t,n);let l=i.shift();if(typeof l==="string"||typeof l==="number"&&!Array.isArray(n)){if(typeof n==="object"){if(n===null)n={};return{...n,[l]:s(n[l])}}return{[l]:s()}}if(Array.isArray(n)&&typeof l==="number"){let u=n.slice(0,l);return[...u.length?u:Array(l),s(n[l]),...n.slice(l+1)]}return[...Array(l),s()]}return s(e)}function La(e,r){let t=va(r);function i(s){if(!s)return;if(t.length===1){let l=t[0];if(Array.isArray(s)&&typeof l==="number")return s.filter((m,f)=>f!==l);let{[l]:u,...h}=s;return h}let n=t.shift();if(typeof n==="string"||typeof n==="number"&&!Array.isArray(s)){if(typeof s==="object")return{...s,[n]:i(s[n])}}if(typeof n==="number"){if(Array.isArray(s)){if(n>=s.length)return s;let l=s.slice(0,n);return[...l.length?l:Array(n),i(s[n]),...s.slice(n+1)]}}throw Error("It seems we have created an infinite loop in deleteBy. ")}return i(e)}var ms=46,Ea=91,Va=93,ps=48,xr=57;function va(e){if(Array.isArray(e))return[...e];if(typeof e!=="string")throw Error("Path must be a string.");let r=e.length,t=[],i=r>0&&e.charCodeAt(0)===Ea?1:0,s=!0,n=-1;for(let l=i;l<=r;l++){let u=l<r?e.charCodeAt(l):-1;if(l===r||u===ms||u===Ea||u===Va){let h=l-i;if(h>0){let m=s&&(h===1||e.charCodeAt(i)!==ps),f=e.slice(i,l);if(m){let v=parseInt(f,10);if(h<=15||String(v)===f)t.push(v);else t.push(f)}else t.push(f)}else if(n!==Va&&!(n===-1&&u===Va)&&!(n===u&&(u===ms||u===Ea)))t.push("");i=l+1,s=!0}else if(u<ps||u>xr)s=!1;n=u}if(!t.length)t.push("");return t}function Pa(e){return!(Array.isArray(e)&&e.length===0)}function It(e,r){let t=(i)=>i.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:t})}function Tt(e,r){let{asyncDebounceMs:t}=r,{onBlurAsyncDebounceMs:i,onChangeAsyncDebounceMs:s,onDynamicAsyncDebounceMs:n}=r.validators||{},l=t??0,u=(h)=>h.validators.filter(Boolean).map((m)=>{let f=m?.cause||e,v=l;switch(f){case"change":v=s??l;break;case"blur":v=i??l;break;case"dynamic":v=n??l;break;case"submit":v=0;break}if(e==="submit")v=0;return{cause:f,validate:m.fn,debounceMs:v}});return r.validationLogic({form:r.form,group:r.group,validators:r.validators,event:{type:e,fieldName:r.fieldName,async:!0},runValidation:u})}var Gt=(e)=>!!e&&typeof e==="object"&&("fields"in e);function Ze(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,n]of e)if(!r.has(s)||!Object.is(n,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 t=Object.keys(e),i=Object.keys(r);if(t.length!==i.length)return!1;if(t.length===0&&!Array.isArray(e)&&!Array.isArray(r)&&(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(r)!==Object.prototype))return!1;for(let s of t)if(!i.includes(s)||!Ze(e[s],r[s]))return!1;return!0}var Xt=({newFormValidatorError:e,isPreviousErrorFromFormValidator:r,previousErrorValue:t})=>{if(e)return{newErrorValue:e,newSource:"form"};if(r)return{newErrorValue:void 0,newSource:void 0};if(t)return{newErrorValue:t,newSource:"field"};return{newErrorValue:void 0,newSource:void 0}},Kt=({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 je(e,r){if(e===void 0||e===null)return r;return{...e,...r}}var Ot=256,ha=[],ga;while(Ot--)ha[Ot]=(Ot+256).toString(16).substring(1);function ta(){let e=0,r,t="";if(!ga||Ot+16>256){ga=Array(256),e=256;while(e--)ga[e]=256*Math.random()|0;e=0,Ot=0}for(;e<16;e++){if(r=ga[Ot+e],e===6)t+=ha[r&15|64];else if(e===8)t+=ha[r&63|128];else t+=ha[r];if(e&1&&e>1&&e<11)t+="-"}return Ot++,t}var Ra=Ia((e)=>We.emit("form-state",{id:e.formId,state:e.store.state}),{wait:300});function $t(e){if(e===null||typeof e!=="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let t=[];for(let i=0;i<e.length;i++)t[i]=$t(e[i]);return t}if(e instanceof Map){let t=new Map;return e.forEach((i,s)=>{t.set(s,$t(i))}),t}if(e instanceof Set){let t=new Set;return e.forEach((i)=>{t.add($t(i))}),t}let r={};for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))r[t]=$t(e[t]);return r}function it(e,r){return r===e||r.startsWith(`${e}.`)||r.startsWith(`${e}[`)}var rt=(e)=>{if(!e.validators)return e.runValidation({validators:[],form:e.form});let r=e.event.async,t=r?void 0:{fn:e.validators.onMount,cause:"mount"},i={fn:r?e.validators.onChangeAsync:e.validators.onChange,cause:"change"},s={fn:r?e.validators.onBlurAsync:e.validators.onBlur,cause:"blur"},n={fn:r?e.validators.onSubmitAsync:e.validators.onSubmit,cause:"submit"},l=r?void 0:{fn:()=>{return},cause:"server"};switch(e.event.type){case"mount":return e.runValidation({validators:[t],form:e.form});case"submit":return e.runValidation({validators:[i,s,n,l],form:e.form});case"server":return e.runValidation({validators:[],form:e.form});case"blur":return e.runValidation({validators:[s,l],form:e.form});case"change":return e.runValidation({validators:[i,l],form:e.form});default:throw Error(`Unknown validation event type: ${e.event.type}`)}};function wr(e,r){let t=new Map;for(let i of e){let s=i.path??[],n=r,l="";for(let u=0;u<s.length;u++){let h=s[u];if(h===void 0)continue;let m=typeof h==="object"?h.key:h,f=Number(m);if(Array.isArray(n)&&!Number.isNaN(f))l+=`[${f}]`;else l+=(u>0?".":"")+String(m);if(typeof n==="object"&&n!==null)n=n[m];else n=void 0}t.set(l,(t.get(l)??[]).concat(i))}return Object.fromEntries(t)}var fs=(e,r)=>{let t=wr(e,r);return{form:t,fields:t}},At={validate({value:e,validationSource:r},t){let i=t["~standard"].validate(e);if(i instanceof Promise)throw Error("async function passed to sync validator");if(!i.issues)return;if(r==="field")return i.issues;return fs(i.issues,e)},async validateAsync({value:e,validationSource:r},t){let i=await t["~standard"].validate(e);if(!i.issues)return;if(r==="field")return i.issues;return fs(i.issues,e)}},Yt=(e)=>!!e&&("~standard"in e);var Oe={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{},_arrayVersion:0,_pendingValidationsCount:0};function Vt(e){function r(v){let d=e.getFieldMeta(v)??Oe;e.setFieldMeta(v,{...d,_arrayVersion:(d._arrayVersion||0)+1})}function t(v,d,o){r(v);let b=u(v,d,"move",o),p=Math.min(d,o),_=Math.max(d,o);for(let D=p;D<=_;D++)b.push(l(v,D));let F=Object.keys(e.fieldInfo).reduce((D,A)=>{if(A.startsWith(l(v,d)))D.set(A,e.getFieldMeta(A));return D},new Map);m(b,d<o?"up":"down"),Object.keys(e.fieldInfo).filter((D)=>D.startsWith(l(v,o))).forEach((D)=>{let A=D.replace(l(v,o),l(v,d)),Y=F.get(A);if(Y)e.setFieldMeta(D,Y)})}function i(v,d){r(v);let o=u(v,d,"remove");m(o,"up")}function s(v,d,o){r(v),u(v,d,"swap",o).forEach((p)=>{if(!p.toString().startsWith(l(v,d)))return;let _=p.toString().replace(l(v,d),l(v,o)),[F,D]=[e.getFieldMeta(p),e.getFieldMeta(_)];if(F)e.setFieldMeta(_,F);if(D)e.setFieldMeta(p,D)})}function n(v,d){r(v);let o=u(v,d,"insert");m(o,"down"),o.forEach((b)=>{if(b.toString().startsWith(l(v,d)))e.setFieldMeta(b,f())})}function l(v,d){return`${v}[${d}]`}function u(v,d,o,b){let p=[l(v,d)];switch(o){case"swap":p.push(l(v,b));break;case"move":{let[_,F]=[Math.min(d,b),Math.max(d,b)];for(let D=_;D<=F;D++)p.push(l(v,D));break}default:{let _=e.getFieldValue(v),F=Array.isArray(_)?_.length:0;for(let D=d+1;D<F;D++)p.push(l(v,D));break}}return Object.keys(e.fieldInfo).filter((_)=>p.some((F)=>_.startsWith(F)))}function h(v,d){return v.replace(/\[(\d+)\]/,(o,b)=>{let p=parseInt(b,10);return`[${d==="up"?p+1:Math.max(0,p-1)}]`})}function m(v,d){(d==="up"?v:[...v].reverse()).forEach((b)=>{let p=h(b.toString(),d),_=e.getFieldMeta(p);if(_)e.setFieldMeta(b,_);else e.setFieldMeta(b,f())})}let f=()=>Oe;return{bumpArrayVersion:r,handleArrayMove:t,handleArrayRemove:i,handleArraySwap:s,handleArrayInsert:n}}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 sa{constructor(e){this.options={},this.fieldInfo={},this.formGroupApis=new Set,this.mount=()=>{let s=this.store.subscribe(()=>{Ra(this)}),n=We.on("request-form-state",(f)=>{if(f.payload.id===this._formId)We.emit("form-api",{id:this._formId,state:this.store.state,options:this.options})}),l=We.on("request-form-reset",(f)=>{if(f.payload.id===this._formId)this.reset()}),u=We.on("request-form-force-submit",(f)=>{if(f.payload.id===this._formId)this._devtoolsSubmissionOverride=!0,this.handleSubmit(),this._devtoolsSubmissionOverride=!1}),h=()=>{u(),l(),n(),s.unsubscribe(),We.emit("form-unmounted",{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});let{onMount:m}=this.options.validators||{};if(We.emit("form-api",{id:this._formId,state:this.store.state,options:this.options}),!m)return h;return this.validateSync("mount"),h},this.update=(s)=>{if(!s)return;let n=this.options;this.options=s;let l=s.defaultValues&&!Ze(s.defaultValues,n.defaultValues)&&!this.state.isTouched,u=!Ze(s.defaultState,n.defaultState)&&!this.state.isTouched;if(!l&&!u)return;if(we(()=>{this.baseStore.setState(()=>qa(Object.assign({},this.state,u?s.defaultState:{},l?{values:s.defaultValues}:{})))}),l){let h=Vt(this);for(let m of Object.keys(this.fieldInfo))if(Array.isArray(this.getFieldValue(m)))h.bumpArrayVersion(m)}We.emit("form-api",{id:this._formId,state:this.store.state,options:this.options})},this.reset=(s,n)=>{let{fieldMeta:l}=this.state,u=this.resetFieldMeta(l);if(s&&!n?.keepDefaultValues)this.options={...this.options,defaultValues:s};this.baseStore.setState(()=>{let h=s??this.options.defaultValues??this.options.defaultState?.values;if(!s)Object.values(this.fieldInfo).forEach((m)=>{if(m.instance&&m.instance.options.defaultValue!==void 0)h=Qt(h,m.instance.name,m.instance.options.defaultValue)});return qa({...this.options.defaultState,values:h,fieldMetaBase:u})})},this.validateAllFields=async(s)=>{let n=[];return we(()=>{Object.values(this.fieldInfo).forEach((u)=>{if(!u.instance)return;let h=u.instance;if(n.push(Promise.resolve().then(()=>h.validate(s,{skipFormValidation:!0,skipGroupValidation:!0}))),!u.instance.store.state.meta.isTouched)u.instance.setMeta((m)=>({...m,isTouched:!0}))})}),(await Promise.all(n)).flat()},this.validateArrayFieldsStartingFrom=async(s,n,l)=>{let u=this.getFieldValue(s),h=Array.isArray(u)?Math.max(u.length-1,0):null,m=[`${s}[${n}]`];for(let o=n+1;o<=(h??0);o++)m.push(`${s}[${o}]`);let f=Object.keys(this.fieldInfo).filter((o)=>m.some((b)=>o.startsWith(b))),v=[];return we(()=>{f.forEach((o)=>{v.push(Promise.resolve().then(()=>this.validateField(o,l)))})}),(await Promise.all(v)).flat()},this.validateField=(s,n)=>{let l=this.fieldInfo[s]?.instance;if(!l){let{hasErrored:u}=this.validateSync(n);if(u&&!this.options.asyncAlways)return this.getFieldMeta(s)?.errors??[];return this.validateAsync(n).then(()=>this.getFieldMeta(s)?.errors??[])}if(!l.store.state.meta.isTouched)l.setMeta((u)=>({...u,isTouched:!0}));return l.validate(n)},this.validateSync=(s,n)=>{let l=It(s,{...this.options,form:this,group:n?.group,validationLogic:this.options.validationLogic||rt}),u=!1,h={};return we(()=>{for(let v of l){if(!v.validate)continue;let d=this.runValidator({validate:v.validate,value:{value:this.state.values,formApi:this,validationSource:"form"},type:"validate"}),{formError:o,fieldErrors:b}=ba(d),p=aa(v.cause),_=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(b||{})]);if(n?.filterFieldNames)_=new Set([..._].filter(n.filterFieldNames));for(let F of _){if(this.baseStore.state.fieldMetaBase[F]===void 0&&!b?.[F])continue;let D=this.getFieldMeta(F)??Oe,{errorMap:A,errorSourceMap:Y}=D,K=b?.[F],{newErrorValue:C,newSource:k}=Xt({newFormValidatorError:K,isPreviousErrorFromFormValidator:Y?.[p]==="form",previousErrorValue:A?.[p]});if(k==="form")h[F]={...h[F],[p]:K};if(A?.[p]!==C)this.setFieldMeta(F,(I=Oe)=>({...I,errorMap:{...I.errorMap,[p]:C},errorSourceMap:{...I.errorSourceMap,[p]:k}}))}if(!n?.dontUpdateFormErrorMap){if(this.state.errorMap?.[p]!==o)this.baseStore.setState((F)=>({...F,errorMap:{...F.errorMap,[p]:o}}))}if(o||b)u=!0}if(n?.dontUpdateFormErrorMap)return;let m=aa("submit");if(this.state.errorMap?.[m]&&s!=="submit"&&!u)this.baseStore.setState((v)=>({...v,errorMap:{...v.errorMap,[m]:void 0}}));let f=aa("server");if(this.state.errorMap?.[f]&&s!=="server"&&!u)this.baseStore.setState((v)=>({...v,errorMap:{...v.errorMap,[f]:void 0}}))}),{hasErrored:u,fieldsErrorMap:h}},this.validateAsync=async(s,n)=>{let l=Tt(s,{...this.options,form:this,group:n?.group,validationLogic:this.options.validationLogic||rt});if(!this.state.isFormValidating)this.baseStore.setState((v)=>({...v,isFormValidating:!0}));let u=[],h;for(let v of l){if(!v.validate)continue;let d=aa(v.cause);this.state.validationMetaMap[d]?.lastAbortController.abort();let b=new AbortController;this.state.validationMetaMap[d]={lastAbortController:b},u.push(new Promise(async(p)=>{let _;try{_=await new Promise((C,k)=>{setTimeout(async()=>{if(b.signal.aborted)return C(void 0);try{C(await this.runValidator({validate:v.validate,value:{value:this.state.values,formApi:this,validationSource:"form",signal:b.signal},type:"validateAsync"}))}catch(I){k(I)}},v.debounceMs)})}catch(C){_=C}let{formError:F,fieldErrors:D}=ba(_);if(D)h=h?{...h,...D}:D;let A=aa(v.cause),Y=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(h||{})]),K=Array.from(Y);if(n?.filterFieldNames)K=K.filter(n.filterFieldNames);for(let C of K){if(this.baseStore.state.fieldMetaBase[C]===void 0&&!h?.[C])continue;let k=this.getFieldMeta(C)??Oe,{errorMap:I,errorSourceMap:P}=k,y=h?.[C],{newErrorValue:O,newSource:ie}=Xt({newFormValidatorError:y,isPreviousErrorFromFormValidator:P?.[A]==="form",previousErrorValue:I?.[A]});if(I?.[A]!==O)this.setFieldMeta(C,(oe=Oe)=>({...oe,errorMap:{...oe.errorMap,[A]:O},errorSourceMap:{...oe.errorSourceMap,[A]:ie}}))}if(!n?.dontUpdateFormErrorMap)this.baseStore.setState((C)=>({...C,errorMap:{...C.errorMap,[A]:F}}));p(h?{fieldErrors:h,errorMapKey:A}:void 0)}))}let m=[],f={};if(u.length){m=await Promise.all(u);for(let v of m)if(v?.fieldErrors){let{errorMapKey:d}=v;for(let[o,b]of Object.entries(v.fieldErrors)){let _={...f[o]||{},[d]:b};f[o]=_}}}return this.baseStore.setState((v)=>({...v,isFormValidating:!1})),f},this.validate=(s,n)=>{let{hasErrored:l,fieldsErrorMap:u}=this.validateSync(s,n);if(l&&!this.options.asyncAlways)return u;return this.validateAsync(s,n)},this._handleSubmit=async(s)=>{this.baseStore.setState((u)=>({...u,isSubmitted:!1,submissionAttempts:u.submissionAttempts+1,isSubmitSuccessful:!1})),we(()=>{Object.values(this.fieldInfo).forEach((u)=>{if(!u.instance)return;if(!u.instance.store.state.meta.isTouched)u.instance.setMeta((h)=>({...h,isTouched:!0}))})});let n=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:n});return}}this.baseStore.setState((u)=>({...u,isSubmitting:!0}));let l=()=>{this.baseStore.setState((u)=>({...u,isSubmitting:!1}))};if(await this.validateAllFields("submit"),!this.state.isFieldsValid){l(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:n}),We.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"validateAllFields",errors:Object.values(this.state.fieldMeta).map((u)=>u.errors).flat()});return}if(await this.validate("submit"),!this.state.isValid){l(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:n}),We.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"validate",errors:this.state.errors});return}we(()=>{Object.values(this.fieldInfo).forEach((u)=>{u.instance?.triggerOnSubmitListener()})}),this.options.listeners?.onSubmit?.({formApi:this,meta:n});try{await this.options.onSubmit?.({value:this.state.values,formApi:this,meta:n}),we(()=>{this.baseStore.setState((u)=>({...u,isSubmitted:!0,isSubmitSuccessful:!0})),We.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),l()})}catch(u){throw this.baseStore.setState((h)=>({...h,isSubmitSuccessful:!1})),We.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"inflight",onError:u}),l(),u}},this.getFieldValue=(s)=>zt(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,n)=>{this.baseStore.setState((l)=>({...l,fieldMetaBase:{...l.fieldMetaBase,[s]:Ft(n,l.fieldMetaBase[s])}}))},this.resetFieldMeta=(s)=>Object.keys(s).reduce((n,l)=>{let u=l;return n[u]=Oe,n},{}),this.setFieldValue=(s,n,l)=>{let u=l?.dontUpdateMeta??!1,h=l?.dontRunListeners??!1,m=l?.dontValidate??!1;if(we(()=>{if(!u)this.setFieldMeta(s,(f)=>({...f,isTouched:!0,isDirty:!0,errorMap:{...f?.errorMap,onMount:void 0}}));this.baseStore.setState((f)=>({...f,values:Qt(f.values,s,n)}))}),!h)this.getFieldInfo(s).instance?.triggerOnChangeListener();if(!m)this.validateField(s,"change")},this.deleteField=(s)=>{let l=[...Object.keys(this.fieldInfo).filter((u)=>{let h=s.toString();return u.startsWith(`${h}.`)||u.startsWith(`${h}[`)}),s];this.baseStore.setState((u)=>{let h={...u};return l.forEach((m)=>{h.values=La(h.values,m),delete this.fieldInfo[m],delete h.fieldMetaBase[m]}),h})},this.pushFieldValue=(s,n,l)=>{this.setFieldValue(s,(u)=>[...Array.isArray(u)?u:[],n],l),Vt(this).bumpArrayVersion(s)},this.insertFieldValue=async(s,n,l,u)=>{this.setFieldValue(s,(m)=>[...m.slice(0,n),l,...m.slice(n)],je(u,{dontValidate:!0}));let h=u?.dontValidate??!1;if(!h)await this.validateField(s,"change");if(Vt(this).handleArrayInsert(s,n),!h)await this.validateArrayFieldsStartingFrom(s,n,"change")},this.replaceFieldValue=async(s,n,l,u)=>{if(this.setFieldValue(s,(m)=>m.map((f,v)=>v===n?l:f),je(u,{dontValidate:!0})),Vt(this).bumpArrayVersion(s),!(u?.dontValidate??!1))await this.validateField(s,"change"),await this.validateArrayFieldsStartingFrom(s,n,"change")},this.removeFieldValue=async(s,n,l)=>{let u=this.getFieldValue(s),h=Array.isArray(u)?Math.max(u.length-1,0):null;if(this.setFieldValue(s,(f)=>f.filter((v,d)=>d!==n),je(l,{dontValidate:!0})),Vt(this).handleArrayRemove(s,n),h!==null){let f=`${s}[${h}]`;this.deleteField(f)}if(!(l?.dontValidate??!1))await this.validateField(s,"change"),await this.validateArrayFieldsStartingFrom(s,n,"change")},this.swapFieldValues=(s,n,l,u)=>{if(this.setFieldValue(s,(m)=>{let f=m[n],v=m[l];return Qt(Qt(m,`${n}`,v),`${l}`,f)},je(u,{dontValidate:!0})),Vt(this).handleArraySwap(s,n,l),!(u?.dontValidate??!1))this.validateField(s,"change"),this.validateField(`${s}[${n}]`,"change"),this.validateField(`${s}[${l}]`,"change")},this.moveFieldValues=(s,n,l,u)=>{if(this.setFieldValue(s,(m)=>{let f=[...m];return f.splice(l,0,f.splice(n,1)[0]),f},je(u,{dontValidate:!0})),Vt(this).handleArrayMove(s,n,l),!(u?.dontValidate??!1))this.validateField(s,"change"),this.validateField(`${s}[${n}]`,"change"),this.validateField(`${s}[${l}]`,"change")},this.clearFieldValues=(s,n)=>{let l=this.getFieldValue(s),u=Array.isArray(l)?Math.max(l.length-1,0):null;if(this.setFieldValue(s,[],je(n,{dontValidate:!0})),Vt(this).bumpArrayVersion(s),u!==null)for(let m=0;m<=u;m++){let f=`${s}[${m}]`;this.deleteField(f)}if(!(n?.dontValidate??!1))this.validateField(s,"change")},this.resetField=(s)=>{this.baseStore.setState((n)=>{let l=this.getFieldInfo(s).instance?.options.defaultValue,u=zt(this.options.defaultValues,s),h=l??u;return{...n,fieldMetaBase:{...n.fieldMetaBase,[s]:Oe},values:h!==void 0?Qt(n.values,s,h):n.values}})},this.setErrorMap=(s)=>{we(()=>{Object.entries(s).forEach(([n,l])=>{let u=n;if(Gt(l)){let{formError:h,fieldErrors:m}=ba(l);for(let f of Object.keys(this.fieldInfo)){if(!this.getFieldMeta(f))continue;this.setFieldMeta(f,(d)=>({...d,errorMap:{...d.errorMap,[u]:m?.[f]},errorSourceMap:{...d.errorSourceMap,[u]:"form"}}))}this.baseStore.setState((f)=>({...f,errorMap:{...f.errorMap,[u]:h}}))}else this.baseStore.setState((h)=>({...h,errorMap:{...h.errorMap,[u]:l}}))})})},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((s,[n,l])=>{if(Object.keys(l).length&&l.errors.length)s[n]={errors:l.errors,errorMap:l.errorMap};return s},{})}),this.parseValuesWithSchema=(s)=>At.validate({value:this.state.values,validationSource:"form"},s),this.parseValuesWithSchemaAsync=(s)=>At.validateAsync({value:this.state.values,validationSource:"form"},s),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??ta(),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 n=r.errorMap[s];if(n===void 0||!Gt(n))continue;for(let l of Object.keys(n.fields)){let u=n.fields[l];if(u===void 0)continue;let h=r.fieldMetaBase[l];r.fieldMetaBase[l]={isTouched:!1,isValidating:!1,isBlurred:!1,isDirty:!1,_arrayVersion:0,_pendingValidationsCount:0,...h??{},errorSourceMap:{...h?.errorSourceMap??{},onChange:"form"},errorMap:{...h?.errorMap??{},[s]:u}}}}}this.baseStore=Mt(r);let t=void 0;this.fieldMetaDerived=Mt((s)=>{let n=this.baseStore.get(),l=0,u={};for(let h of Object.keys(n.fieldMetaBase)){let m=n.fieldMetaBase[h],f=t?.fieldMetaBase[h],v=s?.[h],d=zt(n.values,h),o=v?.errors;if(!f||m.errorMap!==f.errorMap){o=Object.values(m.errorMap??{}).filter((D)=>D!==void 0);let F=this.getFieldInfo(h)?.instance;if(!F||!F.options.disableErrorFlat)o=o.flat(1)}let b=!Pa(o),p=!m.isDirty,_=Ze(d,this.getFieldInfo(h)?.instance?.options.defaultValue??zt(this.options.defaultValues,h));if(v&&v.isPristine===p&&v.isValid===b&&v.isDefaultValue===_&&v.errors===o&&m===f){u[h]=v,l++;continue}u[h]={...m,errors:o??[],isPristine:p,isValid:b,isDefaultValue:_}}if(!Object.keys(n.fieldMetaBase).length)return u;if(s&&l===Object.keys(n.fieldMetaBase).length)return s;return t=this.baseStore.get(),u}),this.formGroupMetaDerived=Mt((s)=>{let n=this.baseStore.get(),l=this.fieldMetaDerived.get(),u={};for(let h of this.formGroupApis){let m=h.name,f=n.formGroupStateBase[m]??{isSubmitted:!1,isSubmitting:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1},v=l[m],d=!1,o=!0,b=!1,p=!1,_=!0,F=!1;for(let me in l){if(me===m)continue;if(!it(m,me))continue;let ue=l[me];if(!ue)continue;if(ue.isValidating)d=!0;if(!ue.isValid)o=!1;if(ue.isTouched)b=!0;if(ue.isBlurred)p=!0;if(!ue.isDefaultValue)_=!1;if(ue.isDirty)F=!0}let D=!F,A=!!d||f.isValidating,Y=v?.errorMap??{},K=v?.errorSourceMap??{},C=Boolean(Y.onMount||Object.entries(l).some(([me,ue])=>ue&&me!==m&&it(m,me)&&ue.errorMap.onMount)),k=s?.[m],I=k?.errors??[];if(!k||k.__srcErrorMap!==Y)I=Object.values(Y).reduce((me,ue)=>{if(ue===void 0)return me;if(ue&&typeof ue==="object"&&"fields"in ue){let H=ue.group;if(H!==void 0)me.push(H);return me}return me.push(ue),me},[]);let P=I.length===0,y=o&&P,O=h.options.canSubmitWhenInvalid??!1,ie=f.submissionAttempts===0&&!b&&!C||!A&&!f.isSubmitting&&y||O;if(k&&k.errorMap===Y&&k.errorSourceMap===K&&k.errors===I&&k.isFieldsValidating===d&&k.isFieldsValid===o&&k.isGroupValid===P&&k.isValid===y&&k.canSubmit===ie&&k.isTouched===b&&k.isBlurred===p&&k.isPristine===D&&k.isDefaultValue===_&&k.isDirty===F&&k.isValidating===A&&k.isSubmitting===f.isSubmitting&&k.isSubmitted===f.isSubmitted&&k.submissionAttempts===f.submissionAttempts&&k.isSubmitSuccessful===f.isSubmitSuccessful){u[m]=k;continue}let oe={...f,errorMap:Y,errorSourceMap:K,_arrayVersion:v?._arrayVersion??0,isTouched:b,isBlurred:p,isDirty:F,isPristine:D,isDefaultValue:_,isValid:y,errors:I,isValidating:A,isFieldsValidating:d,isFieldsValid:o,isGroupValid:P,canSubmit:ie};Object.defineProperty(oe,"__srcErrorMap",{value:Y,enumerable:!1,configurable:!0}),u[m]=oe}return u});let i=void 0;this.store=Mt((s)=>{let n=this.baseStore.get(),l=this.fieldMetaDerived.get(),u=Object.values(l).filter(Boolean),h=u.some((P)=>P.isValidating),m=u.every((P)=>P.isValid),f=u.some((P)=>P.isTouched),v=u.some((P)=>P.isBlurred),d=u.every((P)=>P.isDefaultValue),o=f&&n.errorMap?.onMount,b=u.some((P)=>P.isDirty),p=!b,_=Boolean(n.errorMap?.onMount||u.some((P)=>P?.errorMap?.onMount)),F=!!h,D=s?.errors??[];if(!i||n.errorMap!==i.errorMap)D=Object.values(n.errorMap).reduce((P,y)=>{if(y===void 0)return P;if(y&&Gt(y))return P.push(y.form),P;return P.push(y),P},[]);let A=D.length===0,Y=m&&A,K=this.options.canSubmitWhenInvalid??!1,C=n.submissionAttempts===0&&!f&&!_||!F&&!n.isSubmitting&&Y||K,k=n.errorMap;if(o)D=D.filter((P)=>P!==n.errorMap.onMount),k=Object.assign(k,{onMount:void 0});if(s&&i&&s.errorMap===k&&s.fieldMeta===this.fieldMetaDerived.state&&s.errors===D&&s.isFieldsValidating===h&&s.isFieldsValid===m&&s.isFormValid===A&&s.isValid===Y&&s.canSubmit===C&&s.isTouched===f&&s.isBlurred===v&&s.isPristine===p&&s.isDefaultValue===d&&s.isDirty===b&&Ze(i,n))return s;let I={...n,errorMap:k,fieldMeta:this.fieldMetaDerived.state,errors:D,isFieldsValidating:h,isFieldsValid:m,isFormValid:A,isValid:Y,canSubmit:C,isTouched:f,isBlurred:v,isPristine:p,isDefaultValue:d,isDirty:b};return i=this.baseStore.get(),I}),this.handleSubmit=this.handleSubmit.bind(this),this.update(e||{})}get state(){return this.store.state}get formId(){return this._formId}runValidator(e){if(Yt(e.validate))return At[e.type](e.value,e.validate);return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}}function ba(e){if(e){if(Gt(e)){let r=ba(e.form).formError,t=e.fields;return{formError:r,fieldErrors:t}}return{formError:e}}return{formError:void 0}}function aa(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 Pt{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:t}=this.options.validators||{};if(t){let i=this.runValidator({validate:t,value:{value:this.state.value,fieldApi:this,validationSource:"field"},type:"validate"});if(i)this.setMeta((s)=>({...s,errorMap:{...s?.errorMap,onMount:i},errorSourceMap:{...s?.errorSourceMap,onMount:"field"}}))}return this.options.listeners?.onMount?.({value:this.state.value,fieldApi:this}),()=>{for(let[s,n]of Object.entries(this.timeoutIds.validations))if(n)clearTimeout(n),this.timeoutIds.validations[s]=null;for(let[s,n]of Object.entries(this.timeoutIds.listeners))if(n)clearTimeout(n),this.timeoutIds.listeners[s]=null;for(let[s,n]of Object.entries(this.timeoutIds.formListeners))if(n)clearTimeout(n),this.timeoutIds.formListeners[s]=null;let i=this.form.fieldInfo[this.name];if(!i)return;if(i.instance!==this)return;for(let[s,n]of Object.entries(i.validationMetaMap))n?.lastAbortController.abort(),i.validationMetaMap[s]=void 0;this.form.baseStore.setState((s)=>({...s,fieldMetaBase:{...s.fieldMetaBase,[this.name]:{...Oe,isTouched:s.fieldMetaBase[this.name]?.isTouched??Oe.isTouched,isBlurred:s.fieldMetaBase[this.name]?.isBlurred??Oe.isBlurred,isDirty:s.fieldMetaBase[this.name]?.isDirty??Oe.isDirty}}})),i.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 t=this.form.getFieldValue(this.name);if(!Ze(t,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,t)=>{if(this.form.setFieldValue(this.name,r,je(t,{dontRunListeners:!0,dontValidate:!0})),!t?.dontRunListeners)this.triggerOnChangeListener();if(!t?.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,t)=>{if(this.form.pushFieldValue(this.name,r,je(t,{dontRunListeners:!0})),!t?.dontRunListeners)this.triggerOnChangeListener()},this.insertValue=(r,t,i)=>{if(this.form.insertFieldValue(this.name,r,t,je(i,{dontRunListeners:!0})),!i?.dontRunListeners)this.triggerOnChangeListener()},this.replaceValue=(r,t,i)=>{if(this.form.replaceFieldValue(this.name,r,t,je(i,{dontRunListeners:!0})),!i?.dontRunListeners)this.triggerOnChangeListener()},this.removeValue=(r,t)=>{if(this.form.removeFieldValue(this.name,r,je(t,{dontRunListeners:!0})),!t?.dontRunListeners)this.triggerOnChangeListener()},this.swapValues=(r,t,i)=>{if(this.form.swapFieldValues(this.name,r,t,je(i,{dontRunListeners:!0})),!i?.dontRunListeners)this.triggerOnChangeListener()},this.moveValue=(r,t,i)=>{if(this.form.moveFieldValues(this.name,r,t,je(i,{dontRunListeners:!0})),!i?.dontRunListeners)this.triggerOnChangeListener()},this.clearValues=(r)=>{if(this.form.clearFieldValues(this.name,je(r,{dontRunListeners:!0})),!r?.dontRunListeners)this.triggerOnChangeListener()},this.getLinkedFields=(r)=>{let t=Object.values(this.form.fieldInfo),i=[];for(let s of t){if(!s.instance)continue;if(!(s.instance instanceof Pt))continue;let{onChangeListenTo:n,onBlurListenTo:l}=s.instance.options.validators||{};if(r==="change"&&n?.includes(this.name))i.push(s.instance);if(r==="blur"&&l?.includes(this.name))i.push(s.instance)}return i},this.validateSync=(r,t)=>{let i=It(r,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||rt}),n=this.getLinkedFields(r).reduce((h,m)=>{let f=It(r,{...m.options,form:m.form,fieldName:m.name,validationLogic:m.form.options.validationLogic||rt});return f.forEach((v)=>{v.field=m}),h.concat(f)},[]),l=!1;we(()=>{let h=(m,f)=>{let v=ra(f.cause),d=f.validate?gs(m.runValidator({validate:f.validate,value:{value:m.store.state.value,validationSource:"field",fieldApi:m},type:"validate"})):void 0,o=t[v],{newErrorValue:b,newSource:p}=Kt({formLevelError:o,fieldLevelError:d});if(m.state.meta.errorMap?.[v]!==b)m.setMeta((_)=>({..._,errorMap:{..._.errorMap,[v]:b},errorSourceMap:{..._.errorSourceMap,[v]:p}}));if(b)l=!0};for(let m of i)h(this,m);for(let m of n){if(!m.validate)continue;h(m.field,m)}});let u=ra("submit");if(this.state.meta.errorMap?.[u]&&r!=="submit"&&!l)this.setMeta((h)=>({...h,errorMap:{...h.errorMap,[u]:void 0},errorSourceMap:{...h.errorSourceMap,[u]:void 0}}));return{hasErrored:l}},this.validateAsync=async(r,t)=>{let i=Tt(r,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||rt}),s=await t,l=this.getLinkedFields(r).reduce((o,b)=>{let p=Tt(r,{...b.options,form:b.form,fieldName:b.name,validationLogic:b.form.options.validationLogic||rt});return p.forEach((_)=>{_.field=b}),o.concat(p)},[]),u=[],h=[],m=i.some((o)=>o.validate),f=Array.from(new Set(l.filter((o)=>o.validate).map((o)=>o.field)));we(()=>{if(m)this.startValidation();for(let o of f)o.startValidation()});let v=(o,b,p)=>{let _=ra(b.cause),F=o.getInfo();F.validationMetaMap[_]?.lastAbortController.abort();let A=new AbortController;F.validationMetaMap[_]={lastAbortController:A},p.push(new Promise(async(Y)=>{let K;try{K=await new Promise((y,O)=>{if(o.timeoutIds.validations[b.cause])clearTimeout(o.timeoutIds.validations[b.cause]),o.endValidation();o.timeoutIds.validations[b.cause]=setTimeout(async()=>{if(A.signal.aborted)return y(void 0);try{y(await this.runValidator({validate:b.validate,value:{value:o.store.state.value,fieldApi:o,signal:A.signal,validationSource:"field"},type:"validateAsync"}))}catch(ie){O(ie)}},b.debounceMs)})}catch(y){K=y}if(A.signal.aborted)return Y(void 0);let C=gs(K),k=s[o.name]?.[_],{newErrorValue:I,newSource:P}=Kt({formLevelError:k,fieldLevelError:C});if(o.getInfo().instance!==o)return Y(void 0);o.setMeta((y)=>({...y,errorMap:{...y?.errorMap,[_]:I},errorSourceMap:{...y.errorSourceMap,[_]:P}})),Y(I)}))};for(let o of i){if(!o.validate)continue;v(this,o,u)}for(let o of l){if(!o.validate)continue;v(o.field,o,h)}let d=[];if(u.length||h.length)d=await Promise.all(u),await Promise.all(h);return we(()=>{if(m)this.endValidation();for(let o of f)o.endValidation()}),d.filter(Boolean)},this.validate=(r,t)=>{if(!this.state.meta.isTouched)return[];let i=t?.skipGroupValidation?[]:Array.from(this.form.formGroupApis).filter((v)=>this.name.startsWith(v.name)),n=((t?.skipFormValidation)?{fieldsErrorMap:{}}:this.form.validateSync(r)).fieldsErrorMap[this.name]??{};if(!t?.skipFormValidation)for(let v of i){if(v.state.meta.submissionAttempts===0)continue;let{fieldsErrorMap:d}=this.form.validateSync(r,{group:v,dontUpdateFormErrorMap:!0,filterFieldNames:(o)=>it(v.name,o)});n={...n,...d[this.name]??{}}}let{hasErrored:l}=this.validateSync(r,n),u=new WeakMap;for(let v of i){let{hasErrored:d}=v.validateSync(r,{},{skipRelatedFieldValidation:!0});u.set(v,d)}if(l&&!this.options.asyncAlways){this.getInfo().validationMetaMap[ra(r)]?.lastAbortController.abort();let v=[];for(let d of i)d.getInfo().validationMetaMap[ra(r)]?.lastAbortController.abort(),v.push(d.state.meta.errors);return[...this.state.meta.errors,...v.flat()]}let h=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(r),m=this.validateAsync(r,h),f=[];for(let v of i){if(u.get(v)&&!v.options.asyncAlways)continue;f.push(v.validateAsync(r,h,{skipRelatedFieldValidation:!0}))}if(f.length===0)return m;return Promise.all([m,...f]).then((v)=>v.flat())},this.handleChange=(r)=>{this.setValue(r)},this.handleBlur=()=>{if(!this.state.meta.isTouched)this.setMeta((t)=>({...t,isTouched:!0}));if(!this.state.meta.isBlurred)this.setMeta((t)=>({...t,isBlurred:!0}));this.validate("blur"),this.triggerOnBlurListener()},this.setErrorMap=(r)=>{this.setMeta((t)=>({...t,errorMap:{...t.errorMap,...r}}))},this.parseValueWithSchema=(r)=>At.validate({value:this.state.value,validationSource:"field"},r),this.parseValueWithSchemaAsync=(r)=>At.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 t=this.options.listeners?.onBlurDebounceMs;if(t&&t>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})},t)}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 t=this.options.listeners?.onChangeDebounceMs;if(t&&t>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})},t)}else this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this});for(let i of this.form.formGroupApis)if(it(i.name,this.name))i.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=Mt((r)=>{this.form.store.get();let t=this.form.getFieldMeta(this.name)??{...Oe,...e.defaultMeta},i=this.form.getFieldValue(this.name);if(!t.isTouched&&i===void 0&&this.options.defaultValue!==void 0&&!Ze(i,this.options.defaultValue))i=this.options.defaultValue;if(r&&r.value===i&&r.meta===t)return r;return{value:i,meta:t}})}get state(){return this.store.state}runValidator(e){if(Yt(e.validate))return At[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 gs(e){if(e)return e;return}function ra(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 vs(e){return{...Oe,...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 Ut{constructor(e){this.options={},this.setFormGroupState=(r)=>{this.form.baseStore.setState((t)=>{let i=t.formGroupStateBase[this.name]??ja({});return{...t,formGroupStateBase:{...t.formGroupStateBase,[this.name]:r(i)}}})},this._lastDistributedFieldNames={},this.update=(r)=>{if(this.options=r,this.name=r.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0){let t=this.form.getFieldValue(this.name);if(!Ze(t,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,{...Oe,...this.options.defaultMeta})},this.mount=()=>{this.update(this.options),this.form.formGroupApis.add(this),this.fieldInfo.instance=this,this.form.baseStore.setState((t)=>({...t,formGroupStateBase:{...t.formGroupStateBase,[this.name]:t.formGroupStateBase[this.name]??ja({...this.options.defaultState})}}));let{onMount:r}=this.options.validators||{};if(r){let t=this.runValidator({validate:r,value:{value:this.state.value,groupApi:this,validationSource:"form"},type:"validate"}),i=t,s=void 0;if($a(t))i=t.group,s=t.fields;let n=Oa(i);if(n)this.setMeta((l)=>({...l,errorMap:{...l.errorMap,onMount:n},errorSourceMap:{...l.errorSourceMap,onMount:"field"}}));this.distributeFieldErrors("onMount",s)}return this.options.listeners?.onMount?.({value:this.state.value,groupApi:this}),()=>{for(let[t,i]of Object.entries(this.timeoutIds.validations))if(i)clearTimeout(i),this.timeoutIds.validations[t]=null;for(let[t,i]of Object.entries(this.timeoutIds.listeners))if(i)clearTimeout(i),this.timeoutIds.listeners[t]=null;for(let[t,i]of Object.entries(this.timeoutIds.formListeners))if(i)clearTimeout(i),this.timeoutIds.formListeners[t]=null;if(this.fieldInfo.instance!==this)return;for(let[t,i]of Object.entries(this.fieldInfo.validationMetaMap))i?.lastAbortController.abort(),this.fieldInfo.validationMetaMap[t]=void 0;this.form.formGroupApis.delete(this),this.form.baseStore.setState((t)=>({...t,formGroupStateBase:{...t.formGroupStateBase,[this.name]:ja({})}})),this.fieldInfo.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,groupApi:this})}},this.setValue=(r,t)=>{if(this.form.setFieldValue(this.name,r,je(t,{dontRunListeners:!0,dontValidate:!0})),!t?.dontRunListeners)this.triggerOnChangeListener();if(!t?.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),t=[];for(let i of r){if(!i.instance)continue;if(!(i.instance instanceof Pt))continue;if(i.instance.name.startsWith(this.name))t.push(i.instance)}return t},this.getRelatedFieldMetasDerived=()=>{let r=Object.entries(this.form.fieldMetaDerived.state),t=[];for(let[i,s]of r){if(i===this.name)continue;if(it(this.name,i))t.push({...s,name:i})}return t},this.buildChildFieldName=(r)=>{if(r==="")return this.name;if(r.startsWith("["))return`${this.name}${r}`;return`${this.name}.${r}`},this.distributeFieldErrors=(r,t)=>{let i=this._lastDistributedFieldNames[r]??new Set,s=new Set;if(t)for(let[u,h]of Object.entries(t)){if(h===void 0||h===null||h===!1)continue;s.add(this.buildChildFieldName(u))}let n=new Set([...i,...s]),l=!1;for(let u of n){let h=u.startsWith(this.name+"[")?u.slice(this.name.length):u.slice(this.name.length+1),m=t?.[h],f=this.form.getFieldMeta(u);if(!f&&!m)continue;let v=f?.errorMap[r],d=f?.errorSourceMap[r]==="form",{newErrorValue:o,newSource:b}=Xt({newFormValidatorError:m,isPreviousErrorFromFormValidator:d,previousErrorValue:v});if(o)l=!0;if(v===o&&f?.errorSourceMap[r]===b)continue;this.form.setFieldMeta(u,(p=Oe)=>({...p,errorMap:{...p.errorMap,[r]:o},errorSourceMap:{...p.errorSourceMap,[r]:b}}))}return this._lastDistributedFieldNames[r]=s,l},this.validateSync=(r,t,i={})=>{let s=It(r,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||rt}),l=(i.skipRelatedFieldValidation?[]:this.getRelatedFields()).reduce((m,f)=>{let v=It(r,{...f.options,form:f.form,validationLogic:f.form.options.validationLogic||rt});return v.forEach((d)=>{d.field=f}),m.concat(v)},[]),u=!1;we(()=>{let m=(f,v)=>{let d=_a(v.cause),o=f===this,b=void 0;if(v.validate)b=f.runValidator({validate:v.validate,value:{value:f.store.state.value,validationSource:o?"form":"field",...f instanceof Ut?{groupApi:f}:{fieldApi:f}},type:"validate"});let p=b,_=void 0;if(o&&$a(b))p=b.group,_=b.fields;let F=Oa(p),D=t[d],{newErrorValue:A,newSource:Y}=Kt({formLevelError:D,fieldLevelError:F});if(f.state.meta.errorMap?.[d]!==A)f.setMeta((K)=>({...K,errorMap:{...K.errorMap,[d]:A},errorSourceMap:{...K.errorSourceMap,[d]:Y}}));if(A)u=!0;if(o){if(this.distributeFieldErrors(d,_))u=!0}};for(let f of s)m(this,f);for(let f of l){if(!f.validate)continue;m(f.field,f)}});let h=_a("submit");if(this.state.meta.errorMap?.[h]&&r!=="submit"&&!u)this.setMeta((m)=>({...m,errorMap:{...m.errorMap,[h]:void 0},errorSourceMap:{...m.errorSourceMap,[h]:void 0}}));return{hasErrored:u}},this.validateAsync=async(r,t,i={})=>{let s=Tt(r,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||rt}),n=await t,l=i.skipRelatedFieldValidation?[]:this.getRelatedFields(),u=l.reduce((o,b)=>{let p=Tt(r,{...b.options,form:b.form,validationLogic:b.form.options.validationLogic||rt});return p.forEach((_)=>{_.field=b}),o.concat(p)},[]),h=[],m=[],f=s.some((o)=>o.validate)||u.some((o)=>o.validate);if(f){if(!this.state.meta.isValidating)this.setMeta((o)=>({...o,isValidating:!0}));for(let o of l)o.setMeta((b)=>({...b,isValidating:!0}))}let v=(o,b,p)=>{let _=_a(b.cause),F=o.getInfo();F.validationMetaMap[_]?.lastAbortController.abort();let A=new AbortController;F.validationMetaMap[_]={lastAbortController:A};let Y=o===this;p.push(new Promise(async(K)=>{let C;try{C=await new Promise((oe,me)=>{if(o.timeoutIds.validations[b.cause])clearTimeout(o.timeoutIds.validations[b.cause]);o.timeoutIds.validations[b.cause]=setTimeout(async()=>{if(A.signal.aborted)return oe(void 0);try{oe(await this.runValidator({validate:b.validate,value:{value:o.store.state.value,signal:A.signal,validationSource:Y?"form":"field",...o instanceof Ut?{groupApi:o}:{fieldApi:o}},type:"validateAsync"}))}catch(ue){me(ue)}},b.debounceMs)})}catch(oe){C=oe}if(A.signal.aborted)return K(void 0);let k=C,I=void 0;if(Y&&$a(C))k=C.group,I=C.fields;let P=Oa(k),y=n[o.name]?.[_],{newErrorValue:O,newSource:ie}=Kt({formLevelError:y,fieldLevelError:P});if(o.getInfo().instance!==o)return K(void 0);if(o.setMeta((oe)=>({...oe,errorMap:{...oe?.errorMap,[_]:O},errorSourceMap:{...oe.errorSourceMap,[_]:ie}})),Y)this.distributeFieldErrors(_,I);K(O)}))};for(let o of s){if(!o.validate)continue;v(this,o,h)}for(let o of u){if(!o.validate)continue;v(o.field,o,m)}let d=[];if(h.length||m.length)d=await Promise.all(h),await Promise.all(m);if(f){this.setMeta((o)=>({...o,isValidating:!1}));for(let o of l)o.setMeta((b)=>({...b,isValidating:!1}))}return d.filter(Boolean)},this.validateAllFields=async(r)=>{let t=[];return we(()=>{Object.values(this.getRelatedFields()).forEach((s)=>{if(t.push(Promise.resolve().then(()=>s.validate(r,{skipFormValidation:!0,skipGroupValidation:!0}))),!s.store.state.meta.isTouched)s.setMeta((n)=>({...n,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=(r,t,i)=>this.form.validateArrayFieldsStartingFrom(r,t,i),this.validateField=(r,t)=>this.form.validateField(r,t),this.getFieldValue=(r)=>this.form.getFieldValue(r),this.getFieldMeta=(r)=>this.form.getFieldMeta(r),this.setFieldMeta=(r,t)=>this.form.setFieldMeta(r,t),this.setFieldValue=(r,t)=>this.form.setFieldValue(r,t),this.deleteField=(r)=>this.form.deleteField(r),this.pushFieldValue=(r,t)=>this.form.pushFieldValue(r,t),this.insertFieldValue=(r,t,i)=>this.form.insertFieldValue(r,t,i),this.replaceFieldValue=(r,t,i)=>this.form.replaceFieldValue(r,t,i),this.swapFieldValues=(r,t,i)=>this.form.swapFieldValues(r,t,i),this.moveFieldValues=(r,t,i)=>this.form.moveFieldValues(r,t,i),this.clearFieldValues=(r)=>this.form.clearFieldValues(r),this.resetField=(r)=>this.form.resetField(r),this.removeFieldValue=(r,t)=>this.form.removeFieldValue(r,t),this.areRelatedFieldsValid=()=>Object.values(this.getRelatedFields()).every((r)=>r.state.meta.isValid),this.validate=(r,t)=>{let{fieldsErrorMap:i}=t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(r,{dontUpdateFormErrorMap:!0,filterFieldNames:(l)=>it(this.name,l)}),{hasErrored:s}=this.validateSync(r,i[this.name]??{},{skipRelatedFieldValidation:t?.skipRelatedFieldValidation});if(s&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[_a(r)]?.lastAbortController.abort(),this.state.meta.errors;let n=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(r,{dontUpdateFormErrorMap:!0,filterFieldNames:(l)=>it(this.name,l)});return this.validateAsync(r,n,{skipRelatedFieldValidation:t?.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 t=this.options.listeners?.onChangeDebounceMs;if(t&&t>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})},t)}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})),we(()=>{Object.values(this.getRelatedFields()).forEach((s)=>{if(!s.state.meta.isTouched)s.setMeta((n)=>({...n,isTouched:!0}))})});let t=r??this.options.onSubmitMeta;this.setFormGroupState((s)=>({...s,isSubmitting:!0}));let i=()=>{this.setFormGroupState((s)=>({...s,isSubmitting:!1}))};if(await this.validateAllFields("submit"),!this.areRelatedFieldsValid()){i(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}if(await this.validate("submit",{skipRelatedFieldValidation:!0}),!this.areRelatedFieldsValid()||!this.state.meta.isValid){i(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}we(()=>{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:t}),we(()=>{this.setFormGroupState((s)=>({...s,isSubmitted:!0,isSubmitSuccessful:!0})),i()})}catch(s){throw this.setFormGroupState((n)=>({...n,isSubmitSuccessful:!1})),i(),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=Mt((r)=>{this.form.formGroupMetaDerived.get(),this.form.baseStore.get();let t=this.form.getFormGroupMeta(this.name)??vs(e.defaultMeta),i=this.form.getFieldValue(this.name);if(!t.isTouched&&i===void 0&&this.options.defaultValue!==void 0&&!Ze(i,this.options.defaultValue))i=this.options.defaultValue;if(r&&r.value===i&&r.meta===t)return r;return{value:i,meta:t}}),this.handleSubmit=this.handleSubmit.bind(this)}get state(){return this.store.state}runValidator(e){if(Yt(e.validate)){let r=At[e.type](e.value,e.validate);if(e.type==="validate")return hs(r);return r.then(hs)}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 hs(e){if(!e||typeof e!=="object")return e;if(!("form"in e)&&!("fields"in e))return e;let{form:r,fields:t,...i}=e;return{...i,group:r,fields:t}}function _a(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 Qa(e,r){if(!r)return;let t=Object.assign({},e,{state:$t(e.state)});if(r(t),t.fieldInfo!==e.fieldInfo)e.fieldInfo=t.fieldInfo;if(t.options!==e.options)e.options=t.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((n,l)=>{if(e.state[l]!==t.state[l])n[l]=t.state[l];return n},{});return we(()=>{if(Object.keys(s).length)e.baseStore.setState((n)=>({...n,...s}));if(t.state.errorMap!==e.state.errorMap)e.setErrorMap(t.state.errorMap)}),t}L();function Nr(e,r){return e===r}function he(e,r=(i)=>i,t){let i=t?.compare??Nr,s=G((l)=>{let{unsubscribe:u}=e.subscribe(l);return u},[e]),n=G(()=>e.get(),[e]);return Td(s,n,n,r,i)}var oa=(e,r=(i)=>i,t)=>he(e,r,{compare:t});L();L();L();var lt=typeof window<"u"?nt:S;function Cr(e){let[r,t]=w(()=>({form:e.form,name:e.name})),[i,s]=w(()=>new Pt({...e})),n=i;if(r.form!==e.form||r.name!==e.name)n=new Pt({...e}),s(n),t({form:e.form,name:e.name});let l=he(n.store,e.mode==="array"?(b)=>b.meta._arrayVersion||0:(b)=>b.value),u=he(n.store,(b)=>b.meta.isTouched),h=he(n.store,(b)=>b.meta.isBlurred),m=he(n.store,(b)=>b.meta.isDirty),f=he(n.store,(b)=>b.meta.errorMap),v=he(n.store,(b)=>b.meta.errorSourceMap),d=he(n.store,(b)=>b.meta.isValidating),o=Q(()=>({...n,get state(){return{value:e.mode==="array"?n.state.value:l,get meta(){return{...n.state.meta,isTouched:u,isBlurred:h,isDirty:m,errorMap:f,errorSourceMap:v,isValidating:d}}}}}),[n,e.mode,l,u,h,m,f,v,d]);return lt(n.mount,[n]),lt(()=>{n.update(e)}),o}var bs=({children:e,...r})=>{let t=Cr(r),i=Q(()=>Ft(e,t),[e,t]);return a(W,{children:i})};L();L();function _s(){return w(()=>ta())[0]}var Sr=ce,ys=Ri.split(".")[0]==="17"?_s:Sr.useId;L();function Mr(e){let[r,t]=w(()=>({form:e.form,name:e.name})),[i,s]=w(()=>new Ut({...e}));if(r.form!==e.form||r.name!==e.name)s(new Ut({...e})),t({form:e.form,name:e.name});let n=he(i.store,(C)=>C.value),l=he(i.store,(C)=>C.meta.isTouched),u=he(i.store,(C)=>C.meta.isBlurred),h=he(i.store,(C)=>C.meta.isDirty),m=he(i.store,(C)=>C.meta.errorMap),f=he(i.store,(C)=>C.meta.errorSourceMap),v=he(i.store,(C)=>C.meta.isValidating),d=he(i.store,(C)=>C.meta.isSubmitting),o=he(i.store,(C)=>C.meta.isSubmitted),b=he(i.store,(C)=>C.meta.submissionAttempts),p=he(i.store,(C)=>C.meta.isSubmitSuccessful),_=he(i.store,(C)=>C.meta.canSubmit),F=he(i.store,(C)=>C.meta.isValid),D=he(i.store,(C)=>C.meta.isFieldsValid),A=he(i.store,(C)=>C.meta.isFieldsValidating),Y=he(i.store,(C)=>C.meta.isGroupValid),K=Q(()=>({...i,handleSubmit:(...I)=>i._handleSubmit(...I),get state(){return{...i.state,value:n,get meta(){return{...i.state.meta,isTouched:l,isBlurred:u,isDirty:h,errorMap:m,errorSourceMap:f,isValidating:v,isSubmitting:d,isSubmitted:o,submissionAttempts:b,isSubmitSuccessful:p,canSubmit:_,isValid:F,isFieldsValid:D,isFieldsValidating:A,isGroupValid:Y}}}}}),[i,n,l,u,h,m,f,v,d,o,b,p,_,F,D,A,Y]);return lt(i.mount,[i]),lt(()=>{i.update(e)}),K}var ws=({children:e,...r})=>{let t=Mr(r),i=Q(()=>Ft(e,t),[e,t]);return a(W,{children:i})};function Fr({form:e,selector:r=(i)=>i,children:t}){let i=he(e.store,r);return a(W,{children:Ft(t,i)})}function Rt(e){let r=ys(),[t,i]=w(e?.formId),[s,n]=w(()=>new sa({...e,formId:e?.formId??r}));if(t!==e?.formId){let h=e?.formId??r;n(new sa({...e,formId:h})),i(h)}let l=Q(()=>{let h={...s,handleSubmit:(...m)=>s._handleSubmit(...m),get formId(){return s._formId},get state(){return s.store.state}};return h.Field=function(f){return a(bs,{...f,form:s})},h.FormGroup=function(f){return a(ws,{...f,form:s})},h.Subscribe=function(f){return a(Fr,{form:s,selector:f.selector,children:f.children})},h},[s]);lt(s.mount,[]),lt(()=>{s.update(e)});let u=M(!1);return lt(()=>{if(!u.current)return;if(!e?.transform)return;Qa(s,e.transform)},[s,e?.transform]),lt(()=>{u.current=!0}),l}L();var Tr=q({name:x().min(1,f1()),type:at(["chat","autofill","embedding"]),permission:at(["owner","editor","reviewer"]),avatar:x().optional(),providerId:x().optional(),modelId:x().optional(),soul:x().optional(),thinkingLevel:ef.optional(),systemPrompt:x().optional(),skills:pe(x()).optional(),mcpServerIds:pe(x()).optional(),deniedTools:pe(x()).optional()}),Er=[{id:"bash",name:()=>nb(),description:()=>rb()},{id:"read_skill",name:()=>Ob(),description:()=>Mb()},{id:"read_asset",name:()=>a_(),description:()=>Rb()},{id:"get_asset_render",name:()=>Ab(),description:()=>gb()},{id:"list_projects",name:()=>Sb(),description:()=>Cb()},{id:"list_assets",name:()=>s_(),description:()=>vb()},{id:"create_folder",name:()=>e_(),description:()=>ab()},{id:"create_file",name:()=>XA(),description:()=>ib()},{id:"create_version",name:()=>t_(),description:()=>lb()},{id:"download_asset",name:()=>pb(),description:()=>fb()},{id:"generate_image",name:()=>n_(),description:()=>mb()},{id:"generate_video",name:()=>o_(),description:()=>hb()},{id:"rename_asset",name:()=>l_(),description:()=>Nb()},{id:"move_assets",name:()=>i_(),description:()=>kb()},{id:"delete_asset",name:()=>r_(),description:()=>db()},{id:"search_assets",name:()=>c_(),description:()=>Zb()},{id:"copy_assets",name:()=>JA(),description:()=>ob()},{id:"get_folder_instructions",name:()=>yb(),description:()=>_b()},{id:"list_comments",name:()=>wb(),description:()=>bb()},{id:"create_comment",name:()=>YA(),description:()=>sb()},{id:"resolve_comment",name:()=>Lb(),description:()=>Fb()},{id:"list_metadata_fields",name:()=>xb(),description:()=>Eb()},{id:"update_asset_metadata",name:()=>u_(),description:()=>Bb()},{id:"create_version_stack",name:()=>ub(),description:()=>cb()},{id:"list_versions",name:()=>Tb(),description:()=>Ib()},{id:"remove_version",name:()=>Db(),description:()=>Pb()}];function Cs({isOpen:e,onClose:r,teamId:t,type:i,initialValues:s,title:n,readOnly:l=!1}){let u=ae(),{canAdmin:h}=er(),{data:m}=ee({queryKey:["teams",t,"providers"],queryFn:async()=>{let E=await R.api.teams[":teamId"].providers.$get({param:{teamId:t}});if(!E.ok)throw Error("Failed to fetch providers");return await E.json()},enabled:e}),{data:f}=ee({queryKey:["teams",t,"skills"],queryFn:async()=>{let E=await R.api.teams[":teamId"].skills.$get({param:{teamId:t}});if(!E.ok)throw Error("Failed to fetch skills");return await E.json()},enabled:e}),v=f?.skills||[],{data:d}=ee({queryKey:["teams",t,"mcp","servers"],queryFn:async()=>{let E=await R.api.teams[":teamId"].mcp.servers.$get({param:{teamId:t}});if(!E.ok)throw Error("Failed to fetch MCP servers");return await E.json()},enabled:e}),o=d?.servers||[],b=Q(()=>Tr.superRefine((E,Z)=>{if(E.type==="chat"||E.type==="autofill"){if(!E.providerId)Z.addIssue({code:Uo.custom,message:lR(),path:["providerId"]});if(!E.modelId)Z.addIssue({code:Uo.custom,message:t1(),path:["modelId"]})}}),[]),p=Rt({defaultValues:{name:s?.name||"",type:s?.type||i||"chat",permission:s?.permission||"reviewer",avatar:s?.avatarPreset||s?.avatar||Xd[0].id,providerId:s?.providerId||"",modelId:s?.modelId||"",soul:s?.soul||"",thinkingLevel:s?.thinkingLevel||"off",systemPrompt:s?.systemPrompt||"",skills:s?.skills?.map((E)=>E.skillId)||[],mcpServerIds:s?.mcpServerIds||[],deniedTools:s?.deniedTools??[...dv]},validators:{onChange:b},onSubmit:async({value:E})=>{try{if(s?.id)await H.mutateAsync({id:s.id,values:E});else await ue.mutateAsync(E)}catch{}}}),_=oa(p.store,(E)=>E.values.providerId),{data:F,isLoading:D}=ee({queryKey:["teams",t,"providers",_,"models"],queryFn:async()=>{let E=await R.api.providers[":id"].models.$get({param:{id:_}});if(!E.ok)throw Error("Failed to fetch models");return await E.json()},enabled:!!_&&e}),[A,Y]=w(""),[K,C]=w(!1),k=Q(()=>{if(!m)return[];return[...m].sort((E,Z)=>E.name.toLowerCase().localeCompare(Z.name.toLowerCase()))},[m]),I=Q(()=>{if(!A.trim())return k;let E=A.toLowerCase();return k.filter((Z)=>Z.name.toLowerCase().includes(E))},[k,A]),[P,y]=w(""),[O,ie]=w(!1),oe=Q(()=>{if(!F)return[];return[...F].sort((E,Z)=>{let J=(E.name||E.modelId).toLowerCase(),te=(Z.name||Z.modelId).toLowerCase();return J.localeCompare(te)})},[F]),me=Q(()=>{if(!P.trim())return oe;let E=P.toLowerCase();return oe.filter((Z)=>Z.modelId.toLowerCase().includes(E)||Z.name&&Z.name.toLowerCase().includes(E))},[oe,P]),ue=X({mutationFn:async(E)=>{let Z=await R.api.teams[":teamId"].agents.$post({param:{teamId:t},json:E});if(!Z.ok)throw Error("Failed to create agent");return await Z.json()},onSuccess:()=>{r(),u.invalidateQueries({queryKey:["agents",t]}),B.success($v())},onError:(E)=>{B.error(Zi({message:E.message}))}}),H=X({mutationFn:async({id:E,values:Z})=>{let J=await R.api.agents[":agentId"].$put({param:{agentId:E},json:Z});if(!J.ok)throw Error("Failed to update agent");return await J.json()},onSuccess:()=>{r(),u.invalidateQueries({queryKey:["agents",t]}),B.success(m_())},onError:(E)=>{B.error(Zi({message:E.message}))}});S(()=>{if(e)p.reset(),Y(""),C(!1),y(""),ie(!1)},[e,s,i]);let le=oa(p.store,(E)=>E.values.type),ve=le==="chat"||le==="autofill",Ae=le==="chat",Le=(E)=>E.map((Z)=>{if(typeof Z==="string")return{message:Z};if(Z&&typeof Z==="object"&&"message"in Z)return{message:String(Z.message)};return{message:String(Z||"")}});return a(Se,{open:e,onOpenChange:r,children:g(xe,{className:"sm:max-w-3xl h-[90vh] flex flex-col p-0 overflow-hidden",children:[g(ke,{className:"p-6 pb-2 flex-shrink-0",children:[a(Ce,{children:n}),a(Nt,{children:ZE()})]}),g("form",{onSubmit:(E)=>{E.preventDefault(),E.stopPropagation(),p.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[a(Ie,{className:"flex-1 min-h-0",children:g("div",{className:"p-6 pt-2 space-y-6",children:[l&&a("div",{className:"p-3 bg-muted text-muted-foreground text-sm rounded-lg border border-border",children:Gv()}),g("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[a(p.Field,{name:"name",children:(E)=>{let Z=!!E.state.meta.errors.length&&E.state.meta.isTouched;return g(_e,{"data-invalid":Z,children:[a(ye,{children:Vv()}),a(re,{value:E.state.value,onBlur:E.handleBlur,onChange:(J)=>E.handleChange(J.target.value),placeholder:Kv(),"aria-invalid":Z,disabled:l}),Z&&a(Me,{errors:Le(E.state.meta.errors)})]})}}),a(p.Field,{name:"type",children:(E)=>g(_e,{children:[a(ye,{children:jb()}),g(Ye,{value:E.state.value,onValueChange:(Z)=>E.handleChange(Z),disabled:!0,children:[a(et,{className:"bg-muted/50",children:a(Xe,{})}),g(tt,{children:[a(be,{value:"chat",children:f_()}),a(be,{value:"autofill",children:d_()}),a(be,{value:"embedding",children:p_()})]})]})]})}),Ae&&a(p.Field,{name:"permission",children:(E)=>g(_e,{children:[a(ye,{children:Ig()}),g(Ye,{value:E.state.value||"reviewer",onValueChange:(Z)=>E.handleChange(Z),disabled:l||!h,children:[a(et,{children:a(Xe,{})}),g(tt,{children:[a(be,{value:"reviewer",children:tc()}),a(be,{value:"editor",children:rc()}),a(be,{value:"owner",children:nc()})]})]})]})}),a(p.Field,{name:"avatar",children:(E)=>g(_e,{className:"md:col-span-2",children:[a(ye,{children:qv()}),g("div",{className:"flex flex-wrap gap-4 mt-2",children:[Xd.map((Z)=>{let J=E.state.value===Z.id;return a("button",{type:"button",disabled:l,onClick:()=>!l&&E.handleChange(Z.id),className:U("relative w-14 h-14 rounded-full overflow-hidden border-2 transition-all",!l&&"hover:scale-105",J?"border-primary ring-2 ring-primary ring-offset-2":"border-border hover:border-muted-foreground",l&&"cursor-default opacity-80"),children:a("img",{src:Z.preview,className:"w-full h-full object-cover",alt:$k()})},Z.id)}),E.state.value&&!Xd.some((Z)=>Z.id===E.state.value)&&a("button",{type:"button",disabled:!0,className:"relative w-14 h-14 rounded-full overflow-hidden border-2 border-primary ring-2 ring-primary ring-offset-2 scale-105 cursor-default",children:a("img",{src:E.state.value,className:"w-full h-full object-cover",alt:Nx()})})]})]})})]}),ve&&g(W,{children:[g("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 p-4 bg-muted/50 rounded-xl border border-border",children:[a(p.Field,{name:"providerId",children:(E)=>{let Z=!!E.state.meta.errors.length&&E.state.meta.isTouched,J=m?.find((te)=>te.id===E.state.value);return g(_e,{"data-invalid":Z,children:[a(ye,{children:sR()}),g(wt,{open:K,onOpenChange:(te)=>{if(C(te),!te)Y("")},modal:!0,children:[a(Et,{asChild:!0,children:g(N,{type:"button",variant:"outline",role:"combobox","aria-expanded":K,"aria-invalid":Z,className:U("w-full justify-between font-normal h-10 px-3 bg-background border-border hover:bg-accent/50",Z&&"border-destructive ring-destructive"),children:[a("span",{className:"truncate",children:J?a("span",{className:"font-medium text-foreground truncate",children:J.name}):a("span",{className:"text-muted-foreground",children:ZM()})}),a(Be,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),g(xt,{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:(te)=>te.stopPropagation(),children:[g("div",{className:"relative p-2 pb-1.5 border-b border-border shrink-0",children:[a(or,{className:"absolute left-4.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),a(re,{placeholder:T0(),value:A,onChange:(te)=>Y(te.target.value),className:"pl-8 h-8 text-xs bg-muted/40",autoFocus:!0})]}),a(Ie,{className:"w-full p-1",style:{height:I.length===0?"96px":`${Math.min(I.length*38+8,256)}px`},onWheel:(te)=>te.stopPropagation(),children:I.length===0?a("div",{className:"flex items-center justify-center h-full py-6 text-xs text-muted-foreground",children:B1()}):a("div",{className:"space-y-0.5 pr-2",children:I.map((te)=>{let Pe=E.state.value===te.id;return g("div",{onClick:()=>{E.handleChange(te.id),p.setFieldValue("modelId",""),y(""),C(!1),Y("")},className:U("flex items-center justify-between px-2.5 py-2 rounded-md text-xs cursor-pointer transition-colors",Pe?"bg-accent text-accent-foreground font-medium":"hover:bg-muted/60 text-foreground"),children:[a("span",{className:"truncate flex-1 pr-2",children:te.name}),Pe&&a(qe,{className:"w-4 h-4 text-primary shrink-0"})]},te.id)})})})]})]}),Z&&a(Me,{errors:Le(E.state.meta.errors)})]})}}),a(p.Field,{name:"modelId",children:(E)=>{let Z=!!E.state.meta.errors.length&&E.state.meta.isTouched,J=F?.find((te)=>te.id===E.state.value);return g(_e,{"data-invalid":Z,children:[g(ye,{className:"flex items-center gap-2",children:[Vh(),D&&a(V,{className:"w-3 h-3 animate-spin"})]}),g(wt,{open:O,onOpenChange:(te)=>{if(ie(te),!te)y("")},modal:!0,children:[a(Et,{asChild:!0,children:g(N,{type:"button",variant:"outline",role:"combobox","aria-expanded":O,"aria-invalid":Z,disabled:!_||D,className:U("w-full justify-between font-normal h-10 px-3 bg-background border-border hover:bg-accent/50",Z&&"border-destructive ring-destructive"),children:[a("span",{className:"truncate flex items-center gap-2",children:J?g(W,{children:[a("span",{className:"truncate font-medium text-foreground",children:J.name||J.modelId}),J.name&&J.name!==J.modelId&&a(ge,{variant:"secondary",className:"font-mono text-[10px] px-1.5 py-0 shrink-0",children:J.modelId})]}):a("span",{className:"text-muted-foreground",children:DM()})}),a(Be,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),g(xt,{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:(te)=>te.stopPropagation(),children:[g("div",{className:"relative p-2 pb-1.5 border-b border-border shrink-0",children:[a(or,{className:"absolute left-4.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),a(re,{placeholder:Eg(),value:P,onChange:(te)=>y(te.target.value),className:"pl-8 h-8 text-xs bg-muted/40",autoFocus:!0})]}),a(Ie,{className:"w-full p-1",style:{height:me.length===0?"96px":`${Math.min(me.length*38+8,256)}px`},onWheel:(te)=>te.stopPropagation(),children:me.length===0?a("div",{className:"flex items-center justify-center h-full py-6 text-xs text-muted-foreground",children:Gp()}):a("div",{className:"space-y-0.5 pr-2",children:me.map((te)=>{let Pe=E.state.value===te.id;return g("div",{onClick:()=>{E.handleChange(te.id),ie(!1),y("")},className:U("flex items-center justify-between px-2.5 py-2 rounded-md text-xs cursor-pointer transition-colors",Pe?"bg-accent text-accent-foreground font-medium":"hover:bg-muted/60 text-foreground"),children:[a("div",{className:"min-w-0 flex-1 pr-2",children:g("div",{className:"flex items-center gap-2",children:[a("span",{className:"truncate",children:te.name||te.modelId}),te.name&&te.name!==te.modelId&&g("span",{className:"font-mono text-[10px] text-muted-foreground truncate",children:["(",te.modelId,")"]}),te.config?.reasoning&&a(ge,{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:a(Lt,{className:"w-2.5 h-2.5"})})]})}),Pe&&a(qe,{className:"w-4 h-4 text-primary shrink-0"})]},te.id)})})})]})]}),Z&&a(Me,{errors:Le(E.state.meta.errors)})]})}}),a("div",{className:"md:col-span-2",children:a(p.Field,{name:"thinkingLevel",children:(E)=>{let Z={off:bP(),low:xP(),medium:CP(),high:wP()};return g(_e,{children:[a(ye,{children:EP()}),g(Ye,{value:E.state.value,onValueChange:(J)=>E.handleChange(J),children:[a(et,{children:a(Xe,{})}),a(tt,{children:ef.options.map((J)=>a(be,{value:J,children:Z[J]||J},J))})]})]})}})})]}),a(p.Field,{name:"soul",children:(E)=>g(_e,{children:[a(ye,{children:eb()}),a(Sa,{value:E.state.value,onBlur:E.handleBlur,onChange:(Z)=>E.handleChange(Z.target.value),placeholder:tb(),className:"min-h-[120px]"})]})}),g("div",{className:"space-y-4",children:[g(fe,{className:"text-base font-bold flex items-center gap-2",children:[a(vt,{className:"w-5 h-5 text-primary"}),Z0()]}),a("div",{className:"space-y-2",children:a(p.Field,{name:"skills",children:(E)=>g(W,{children:[v.map((Z)=>{let J=E.state.value?.includes(Z.id)||!1;return g("div",{className:"flex items-center justify-between p-3 bg-muted/30 border border-border rounded-lg",children:[g("div",{className:"flex items-center gap-3",children:[a(vt,{className:"w-4 h-4 text-muted-foreground"}),g("div",{className:"flex flex-col",children:[a("span",{className:"text-sm font-medium",children:Z.name}),Z.description&&a("span",{className:"text-[10px] text-muted-foreground line-clamp-1",children:Z.description})]})]}),g("div",{className:"flex items-center gap-2",children:[a("span",{className:"text-xs text-muted-foreground",children:J?kh():Ih()}),a(Ve,{checked:J,onCheckedChange:(te)=>{if(te)E.handleChange([...E.state.value||[],Z.id]);else E.handleChange((E.state.value||[]).filter((Pe)=>Pe!==Z.id))}})]})]},Z.id)}),v.length===0&&a("div",{className:"text-center py-8 border-2 border-dashed border-border rounded-xl",children:a("p",{className:"text-sm text-muted-foreground",children:q1()})})]})})})]}),g("div",{className:"space-y-4 border-t border-border pt-6",children:[g(fe,{className:"text-base font-bold flex items-center gap-2",children:[a(oo,{className:"w-5 h-5 text-primary"}),zd()]}),a("div",{className:"space-y-2",children:a(p.Field,{name:"mcpServerIds",children:(E)=>g(W,{children:[o.map((Z)=>{let J=E.state.value?.includes(Z.id)||!1,te=Z.status==="needs_auth"||!Z.hasCredential&&Z.authType==="oauth";return g("div",{className:"flex items-center justify-between p-3 bg-muted/30 border border-border rounded-lg",children:[g("div",{className:"flex items-center gap-3",children:[a(oo,{className:"w-4 h-4 text-muted-foreground"}),g("div",{className:"flex flex-col",children:[g("div",{className:"flex items-center gap-2",children:[a("span",{className:"text-sm font-medium",children:Z.name}),g(ge,{variant:"outline",className:"text-[10px]",children:[Z.toolCount??0," tools"]}),te&&a(ge,{variant:"secondary",className:"text-[10px] bg-amber-500/10 text-amber-600 border-amber-500/20",children:Cy()})]}),a("span",{className:"text-[10px] font-mono text-muted-foreground line-clamp-1",children:Z.url})]})]}),g("div",{className:"flex items-center gap-2",children:[a("span",{className:"text-xs text-muted-foreground",children:J?kh():Ih()}),a(Ve,{checked:J,onCheckedChange:(Pe)=>{if(Pe)E.handleChange([...E.state.value||[],Z.id]);else E.handleChange((E.state.value||[]).filter((z)=>z!==Z.id))}})]})]},Z.id)}),o.length===0&&a("div",{className:"text-center py-6 border-2 border-dashed border-border rounded-xl",children:a("p",{className:"text-xs text-muted-foreground",children:zy()})})]})})})]}),g("div",{className:"space-y-4 border-t border-border pt-6",children:[g(fe,{className:"text-base font-bold flex items-center gap-2",children:[a(us,{className:"w-5 h-5 text-primary"}),Ub()]}),a("p",{className:"text-xs text-muted-foreground",children:zb()}),a("div",{className:"space-y-2",children:a(p.Field,{name:"deniedTools",children:(E)=>{let Z=E.state.value||[];return a(W,{children:Er.map((J)=>{let te=!Z.includes(J.id);return g("div",{className:"flex items-center justify-between p-3 bg-muted/30 border border-border rounded-lg",children:[g("div",{className:"flex items-center gap-3",children:[a(us,{className:"w-4 h-4 text-muted-foreground"}),g("div",{className:"flex flex-col",children:[a("span",{className:"text-sm font-medium",children:J.name()}),a("span",{className:"text-[10px] text-muted-foreground line-clamp-1",children:J.description()})]})]}),g("div",{className:"flex items-center gap-2",children:[a("span",{className:"text-xs text-muted-foreground",children:te?kh():Ih()}),a(Ve,{checked:te,disabled:!h,onCheckedChange:(Pe)=>{if(Pe)E.handleChange(Z.filter((z)=>z!==J.id));else E.handleChange([...Z,J.id])}})]})]},J.id)})})}})})]})]})]})}),a(ot,{className:"p-6 pt-4 border-t border-border flex-shrink-0",children:l?a(N,{variant:"outline",onClick:r,type:"button",children:Wl()}):g(W,{children:[a(N,{variant:"outline",onClick:r,type:"button",children:Ge()}),a(p.Subscribe,{selector:(E)=>[E.canSubmit,E.isSubmitting],children:([E,Z])=>g(N,{type:"submit",className:"bg-primary hover:bg-primary/90 text-primary-foreground min-w-[120px]",disabled:!E||Z||ue.isPending||H.isPending,children:[(Z||ue.isPending||H.isPending)&&a(V,{className:"w-4 h-4 animate-spin mr-2"}),s?zi():Ex()]})})]})})]})]})})}var Vr=[{type:"chat",label:"Chat",icon:rs},{type:"autofill",label:"Autofill",icon:Lt},{type:"embedding",label:"Embedding",icon:no}];function ks({teamId:e}){let r=ae(),{canAdmin:t}=er(),[i,s]=w(!1),[n,l]=w("chat"),[u,h]=w(null),[m,f]=w(null),[v,d]=w(!1),[o,b]=w({chat:!0,autofill:!0,embedding:!0}),p=(C)=>{if(C==="chat")return f_();if(C==="autofill")return d_();return p_()},{data:_=[],isLoading:F}=ee({queryKey:["agents",e],queryFn:async()=>{let C=await R.api.teams[":teamId"].agents.$get({param:{teamId:e}});if(!C.ok)throw Error("failed to fetch agents");return[...await C.json()].sort((I,P)=>P.id.localeCompare(I.id))}}),D=X({mutationFn:async(C)=>{if(!(await R.api.agents[":agentId"].$delete({param:{agentId:C}})).ok)throw Error("failed to delete agent")},onSuccess:()=>{d(!1),r.invalidateQueries({queryKey:["agents",e]}),B.success(Hv())},onError:(C)=>{B.error(C.message)}}),A=X({mutationFn:async({agentId:C,permission:k})=>{let I=await R.api.agents[":agentId"].permission.$patch({param:{agentId:C},json:{permission:k}});if(!I.ok)throw Error(nu());return I.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["agents",e]})},onError:(C)=>{B.error(C.message||nu())}}),Y=X({mutationFn:async(C)=>{let k=await R.api.agents[":agentId"].$put({param:{agentId:C.agentId},json:{name:C.name,type:C.type,enabled:C.enabled,avatar:C.avatar,providerId:C.providerId,modelId:C.modelId,thinkingLevel:C.thinkingLevel,systemPrompt:C.systemPrompt,soul:C.soul,skills:C.skills,deniedTools:C.deniedTools}});if(!k.ok)throw Error("failed to update agent");return k.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["agents",e]}),B.success(m_())},onError:(C)=>{B.error(C.message)}}),K=(C)=>{b((k)=>({...k,[C]:!k[C]}))};return g(W,{children:[(i||u)&&a(Cs,{isOpen:!0,readOnly:u?.readOnly,title:u?H_({name:u.name}):Ox({type:p(n)}),onClose:()=>{s(!1),h(null)},teamId:e,type:n,initialValues:u||void 0}),a(ct,{open:v,onOpenChange:d,children:g(ut,{children:[g(dt,{children:[a(pt,{children:Ip()}),a(mt,{children:Kx({name:m?.name??""})})]}),g(ft,{children:[a(gt,{children:Ge()}),a(ht,{className:"bg-destructive hover:bg-destructive/90 text-white",onClick:(C)=>{if(D.isPending){C.preventDefault();return}if(m)D.mutate(m.id)},children:D.isPending?a(V,{className:"w-4 h-4 animate-spin"}):Vx()})]})]})}),F&&_.length===0?a("div",{className:"flex items-center justify-center p-12",children:a(V,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):g("div",{className:"space-y-6 max-w-5xl mx-auto relative",children:[F&&a("div",{className:"absolute top-0 right-0 p-2",children:a(V,{className:"w-4 h-4 animate-spin text-muted-foreground"})}),Vr.map((C)=>{let k=_.filter((y)=>y.type===C.type),I=C.icon,P=C.type==="autofill"||C.type==="embedding";return g("div",{className:"bg-card rounded-xl border border-border overflow-hidden",children:[g("div",{className:U("px-6 py-4 flex items-center justify-between",!P&&"cursor-pointer hover:bg-muted/50 transition-colors"),onClick:!P?()=>K(C.type):void 0,children:[g("div",{className:"flex items-center gap-2",children:[a("h3",{className:"font-semibold text-foreground",children:C.type==="chat"?EE():C.type==="autofill"?tE():kC()}),!P&&a(ge,{variant:"secondary",className:"h-5 px-1.5 min-w-[1.25rem] text-[10px]",children:k.length})]}),g("div",{className:"flex items-center gap-2",children:[!(P&&k.length>0)&&a(N,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full bg-primary/10 text-primary hover:bg-primary/20",onClick:(y)=>{y.stopPropagation(),l(C.type),s(!0)},children:a(Re,{className:"w-4 h-4"})}),!P&&a(Be,{className:U("w-5 h-5 text-muted-foreground transition-transform duration-200",o[C.type]?"rotate-180":"")})]})]}),(P||o[C.type])&&a("div",{className:"px-6 pb-6 pt-2 space-y-3",children:g("div",{className:"grid grid-cols-1 gap-4",children:[k.map((y)=>a(st,{className:"group relative overflow-hidden border-border hover:border-primary/50 transition-all duration-200 cursor-pointer pb-1 pt-1",onClick:()=>h(y),children:g(_t,{className:"p-4 flex flex-col gap-3",children:[g("div",{className:"flex items-center justify-between",children:[g("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a("div",{className:"w-10 h-10 rounded-full bg-muted flex items-center justify-center overflow-hidden",children:y.avatar?a("img",{src:y.avatar,className:"w-full h-full object-cover",alt:""}):a(Ht,{className:"w-6 h-6 text-muted-foreground"})}),g("div",{className:"min-w-0 flex-1",children:[a("span",{className:"font-bold text-foreground block truncate",children:y.name}),a("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:g("span",{className:"flex items-center gap-1",children:[a(vt,{className:"w-3 h-3"}),cO({count:y.skills?.length||0})]})})]})]}),y.readOnly?a(ge,{variant:"outline",className:"text-xs text-muted-foreground border-border",children:Wv()}):g(De,{modal:!1,children:[a(Ne,{asChild:!0,onClick:(O)=>O.stopPropagation(),children:a(N,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:a(Wr,{className:"w-4 h-4"})})}),a(Fe,{align:"end",className:"w-32",children:g(se,{onClick:(O)=>{O.stopPropagation(),f(y),d(!0)},className:"text-red-500 focus:text-red-500 gap-2 cursor-pointer",children:[a(Ue,{className:"w-4 h-4"})," ",Dt()]})})]})]}),g("div",{className:"flex items-center justify-between gap-2 pt-2 border-t border-border/50",children:[a("div",{children:y.type==="chat"?a("div",{onClick:(O)=>O.stopPropagation(),children:g(Ye,{value:y.permission||"reviewer",onValueChange:(O)=>{A.mutate({agentId:y.id,permission:O})},disabled:!t,children:[a(et,{className:"h-7 text-xs px-2 bg-background border-border w-[140px]",children:a(Xe,{children:y.permission==="reviewer"?tc():y.permission==="editor"?rc():nc()})}),g(tt,{align:"start",children:[a(be,{value:"reviewer",children:tc()}),a(be,{value:"editor",children:rc()}),a(be,{value:"owner",children:nc()})]})]})}):a("div",{})}),a("div",{onClick:(O)=>O.stopPropagation(),children:a(Ve,{checked:y.enabled,disabled:y.readOnly,onCheckedChange:(O)=>{Y.mutate({teamId:e,agentId:y.id,name:y.name,type:y.type,enabled:O,avatar:y.avatar,providerId:y.providerId,modelId:y.modelId,thinkingLevel:y.thinkingLevel,systemPrompt:y.systemPrompt,soul:y.soul,skills:y.skills?.map((ie)=>ie.skillId),deniedTools:y.deniedTools})}})})]})]})},y.id)),k.length===0&&g("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:[a("div",{className:"w-10 h-10 rounded-full bg-card flex items-center justify-center shadow-sm mb-3",children:a(I,{className:"w-5 h-5 text-muted-foreground"})}),a("p",{className:"text-sm text-muted-foreground",children:C1({type:p(C.type)})}),a(N,{variant:"link",size:"sm",className:"text-primary font-medium h-auto p-0 mt-1",onClick:()=>{l(C.type),s(!0)},children:Tx()})]})]})})]},C.type)})]})]})}L();L();function ya({isOpen:e,onClose:r,onSubmit:t,initialValues:i,title:s,isLoading:n=!1,defaultApi:l,existingModelIds:u=[]}){let h=Q(()=>fv.extend({modelId:x().min(1,Ty()).refine((d)=>{if(i?.modelId===d)return!0;return!u.includes(d)},{message:XT()})}),[u,i]),m=()=>i||{modelId:"",name:"",config:{api:l,reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},f=Rt({defaultValues:m(),validators:{onSubmit:h},onSubmit:async({value:d})=>{t(d)}});S(()=>{if(e)f.reset(m())},[e,i,l,f]);let v=(d)=>d.map((o)=>{if(typeof o==="string")return{message:o};if(o&&typeof o==="object"&&"message"in o)return{message:String(o.message)};return{message:String(o||"")}});return a(Se,{open:e,onOpenChange:r,children:g(xe,{className:"sm:max-w-xl h-[85vh] max-h-[700px] flex flex-col p-0 overflow-hidden",children:[a(ke,{className:"p-6 pb-2 shrink-0",children:a(Ce,{className:"text-xl",children:s})}),g("form",{onSubmit:(d)=>{d.preventDefault(),d.stopPropagation(),f.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[a("div",{className:"flex-1 min-h-0",children:a(Ie,{className:"h-full",children:g("div",{className:"p-6 pt-2 space-y-6 pr-6",children:[g("div",{className:"space-y-4",children:[a(f.Field,{name:"modelId",children:(d)=>{let o=!!d.state.meta.errors.length&&d.state.meta.isTouched;return g(_e,{"data-invalid":o,children:[a(ye,{htmlFor:d.name,children:Ty()}),a(re,{id:d.name,name:d.name,value:d.state.value,onBlur:d.handleBlur,onChange:(b)=>d.handleChange(b.target.value),placeholder:e1(),"aria-invalid":o}),o&&a(Me,{errors:v(d.state.meta.errors)})]})}}),a(f.Field,{name:"name",children:(d)=>{let o=!!d.state.meta.errors.length&&d.state.meta.isTouched;return g(_e,{"data-invalid":o,children:[a(ye,{htmlFor:d.name,children:AC()}),a(re,{id:d.name,name:d.name,value:d.state.value||"",onBlur:d.handleBlur,onChange:(b)=>d.handleChange(b.target.value),placeholder:r1(),"aria-invalid":o}),o&&a(Me,{errors:v(d.state.meta.errors)})]})}})]}),g("div",{className:"space-y-4 pt-2 border-t border-border",children:[a("h4",{className:"text-sm font-semibold text-foreground",children:Ik()}),a(f.Field,{name:"config.reasoning",children:(d)=>g(_e,{orientation:"horizontal",className:"rounded-lg border border-border p-3 shadow-sm bg-muted/40 justify-between flex items-center",children:[a(ye,{htmlFor:d.name,className:"cursor-pointer",children:Ag()}),a(Ve,{id:d.name,checked:d.state.value,onCheckedChange:d.handleChange})]})}),g("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[a(f.Field,{name:"config.contextWindow",children:(d)=>{let o=!!d.state.meta.errors.length&&d.state.meta.isTouched;return g(_e,{"data-invalid":o,children:[a(ye,{htmlFor:d.name,className:"text-xs",children:QE()}),a(re,{id:d.name,name:d.name,type:"number",value:d.state.value,onBlur:d.handleBlur,onChange:(b)=>d.handleChange(parseInt(b.target.value)||0),"aria-invalid":o}),o&&a(Me,{errors:v(d.state.meta.errors)})]})}}),a(f.Field,{name:"config.maxTokens",children:(d)=>{let o=!!d.state.meta.errors.length&&d.state.meta.isTouched;return g(_e,{"data-invalid":o,children:[a(ye,{htmlFor:d.name,className:"text-xs",children:pT()}),a(re,{id:d.name,name:d.name,type:"number",value:d.state.value,onBlur:d.handleBlur,onChange:(b)=>d.handleChange(parseInt(b.target.value)||0),"aria-invalid":o}),o&&a(Me,{errors:v(d.state.meta.errors)})]})}})]})]}),g("div",{className:"space-y-4 pt-2 border-t border-border",children:[g("h4",{className:"text-sm font-semibold text-foreground flex items-center gap-1.5",children:[a(_l,{className:"w-4 h-4 text-primary"}),Hk()]}),g("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[a(f.Field,{name:"config.cost.input",children:(d)=>{let o=!!d.state.meta.errors.length&&d.state.meta.isTouched;return g(_e,{"data-invalid":o,children:[a(ye,{htmlFor:d.name,className:"text-xs",children:UI()}),a(re,{id:d.name,name:d.name,type:"number",step:"0.0001",value:d.state.value,onBlur:d.handleBlur,onChange:(b)=>d.handleChange(parseFloat(b.target.value)||0),"aria-invalid":o}),o&&a(Me,{errors:v(d.state.meta.errors)})]})}}),a(f.Field,{name:"config.cost.output",children:(d)=>{let o=!!d.state.meta.errors.length&&d.state.meta.isTouched;return g(_e,{"data-invalid":o,children:[a(ye,{htmlFor:d.name,className:"text-xs",children:wk()}),a(re,{id:d.name,name:d.name,type:"number",step:"0.0001",value:d.state.value,onBlur:d.handleBlur,onChange:(b)=>d.handleChange(parseFloat(b.target.value)||0),"aria-invalid":o}),o&&a(Me,{errors:v(d.state.meta.errors)})]})}}),a(f.Field,{name:"config.cost.cacheRead",children:(d)=>{let o=!!d.state.meta.errors.length&&d.state.meta.isTouched;return g(_e,{"data-invalid":o,children:[a(ye,{htmlFor:d.name,className:"text-xs",children:_E()}),a(re,{id:d.name,name:d.name,type:"number",step:"0.0001",value:d.state.value,onBlur:d.handleBlur,onChange:(b)=>d.handleChange(parseFloat(b.target.value)||0),"aria-invalid":o}),o&&a(Me,{errors:v(d.state.meta.errors)})]})}}),a(f.Field,{name:"config.cost.cacheWrite",children:(d)=>{let o=!!d.state.meta.errors.length&&d.state.meta.isTouched;return g(_e,{"data-invalid":o,children:[a(ye,{htmlFor:d.name,className:"text-xs",children:yE()}),a(re,{id:d.name,name:d.name,type:"number",step:"0.0001",value:d.state.value,onBlur:d.handleBlur,onChange:(b)=>d.handleChange(parseFloat(b.target.value)||0),"aria-invalid":o}),o&&a(Me,{errors:v(d.state.meta.errors)})]})}})]})]})]})})}),g(ot,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[a(N,{type:"button",variant:"outline",onClick:r,disabled:n,children:Ge()}),a(f.Subscribe,{selector:(d)=>[d.canSubmit,d.isSubmitting],children:([d,o])=>a(N,{type:"submit",className:"min-w-[100px]",disabled:!d||o||n,children:o||n?a(V,{className:"w-4 h-4 animate-spin"}):zi()})})]})]})]})})}L();function Ms({isOpen:e,onClose:r,teamId:t,syncData:i,onSuccess:s}){let[n,l]=w(""),[u,h]=w(()=>new Set(i?.providers.map((k)=>k.name)||[])),[m,f]=w(()=>{let k=new Set;return i?.providers.forEach((I)=>{I.models.forEach((P)=>{k.add(`${I.name}:${P.modelId}`)})}),k});S(()=>{if(i){h(new Set(i.providers.map((I)=>I.name)));let k=new Set;i.providers.forEach((I)=>{I.models.forEach((P)=>{k.add(`${I.name}:${P.modelId}`)})}),f(k)}},[i]);let v=Q(()=>{if(!i)return[];let k=n.trim().toLowerCase();if(!k)return i.providers;return i.providers.map((I)=>{let P=I.name.toLowerCase().includes(k),y=I.models.filter((O)=>P||O.modelId.toLowerCase().includes(k)||O.name.toLowerCase().includes(k));if(y.length>0)return{...I,models:y};return null}).filter((I)=>I!==null)},[i,n]),d=m.size,o=Q(()=>{if(!i)return 0;let k=0;for(let I of i.providers)if(I.models.some((y)=>m.has(`${I.name}:${y.modelId}`)))k++;return k},[i,m]),b=(k)=>{h((I)=>{let P=new Set(I);if(P.has(k))P.delete(k);else P.add(k);return P})},p=()=>{if(!i)return;h(new Set(i.providers.map((k)=>k.name)))},_=()=>{h(new Set)},F=(k,I)=>{let P=`${k}:${I}`;f((y)=>{let O=new Set(y);if(O.has(P))O.delete(P);else O.add(P);return O})},D=(k)=>{let I=i?.providers.find((y)=>y.name===k);if(!I||I.models.length===0)return;let P=I.models.every((y)=>m.has(`${k}:${y.modelId}`));f((y)=>{let O=new Set(y);return I.models.forEach((ie)=>{let oe=`${k}:${ie.modelId}`;if(P)O.delete(oe);else O.add(oe)}),O})},A=()=>{if(!i)return;let k=new Set;i.providers.forEach((I)=>{I.models.forEach((P)=>{k.add(`${I.name}:${P.modelId}`)})}),f(k)},Y=()=>{f(new Set)},K=X({mutationFn:async(k)=>{let I=await R.api.teams[":teamId"].providers["sync-apply"].$post({param:{teamId:t},json:k});if(!I.ok){let P=await I.json().catch(()=>({message:"Failed to apply sync"}));throw Error(P.message||"Failed to apply sync")}return await I.json()},onSuccess:(k)=>{B.success(rP({modelCount:k.addedModels,providerCount:k.addedProviders})),s(),r()},onError:(k)=>{B.error(k.message)}}),C=async()=>{if(!i||d===0)return;let k=[];for(let I of i.providers){let P=I.models.filter((y)=>m.has(`${I.name}:${y.modelId}`));if(P.length>0)k.push({name:I.name,isNewProvider:I.isNewProvider,config:I.config,models:P})}if(k.length===0)return;await K.mutateAsync({providers:k})};return a(Se,{open:e,onOpenChange:(k)=>!k&&r(),children:g(xe,{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:[g(ke,{className:"p-6 pb-4 shrink-0",children:[g(Ce,{className:"flex items-center gap-2 text-xl font-semibold",children:[a(Hn,{className:"w-5 h-5 text-primary"}),GO()]}),a(Nt,{className:"text-xs text-muted-foreground leading-relaxed mt-1.5",children:QO()})]}),a("div",{className:"px-6 pb-3 shrink-0",children:g("div",{className:"flex items-center justify-between gap-3",children:[g("div",{className:"relative flex-1",children:[a(or,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),a(re,{value:n,onChange:(k)=>l(k.target.value),placeholder:XO(),className:"pl-8 h-8 text-xs bg-background"})]}),g("div",{className:"flex items-center gap-1.5",children:[a(N,{type:"button",variant:"outline",size:"sm",onClick:p,className:"h-8 text-xs px-2.5",children:KO()}),a(N,{type:"button",variant:"outline",size:"sm",onClick:_,className:"h-8 text-xs px-2.5",children:qO()}),a("div",{className:"w-px h-4 bg-border mx-1"}),a(N,{type:"button",variant:"outline",size:"sm",onClick:A,className:"h-8 text-xs px-2.5",children:eP()}),a(N,{type:"button",variant:"outline",size:"sm",onClick:Y,className:"h-8 text-xs px-2.5",children:HO()})]})]})}),a("div",{className:"flex-1 min-h-0 px-6 overflow-hidden",children:a(Ie,{className:"h-full border border-border/60 rounded-md bg-muted/20",children:a("div",{className:"p-3 space-y-3",children:v.length===0?a("div",{className:"py-8 text-center text-sm text-muted-foreground",children:Uy()}):v.map((k)=>{let I=u.has(k.name),P=k.isNewProvider,y=k.models.filter((oe)=>m.has(`${k.name}:${oe.modelId}`)).length,O=y===k.models.length,ie=y>0&&!O;return g("div",{className:"border border-border/50 rounded-lg bg-background overflow-hidden",children:[g("div",{className:"flex items-center justify-between px-3 py-2 bg-card hover:bg-muted/40 transition-colors",children:[g("div",{className:"flex items-center gap-2.5",children:[a("button",{type:"button",onClick:()=>b(k.name),className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",children:I?a(Be,{className:"w-4 h-4"}):a(qt,{className:"w-4 h-4"})}),a(Ir,{checked:O?!0:ie?"indeterminate":!1,onCheckedChange:()=>D(k.name),id:`provider-check-${k.name}`}),g("label",{htmlFor:`provider-check-${k.name}`,className:"font-medium text-sm text-foreground flex items-center gap-2 cursor-pointer select-none",children:[a(no,{className:"w-4 h-4 text-muted-foreground"}),a("span",{children:k.name})]})]}),g("div",{className:"flex items-center gap-2",children:[P?a(ge,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-primary/10 text-primary border-primary/20",children:JO()}):a(ge,{variant:"outline",className:"text-[10px] px-1.5 py-0 text-muted-foreground",children:VO()}),a("span",{className:"text-xs text-muted-foreground",children:WO({count:k.models.length})})]})]}),I&&a("div",{className:"border-t border-border/40 divide-y divide-border/30 bg-muted/10",children:k.models.map((oe)=>{let me=m.has(`${k.name}:${oe.modelId}`);return g("div",{className:"flex items-center justify-between pl-9 pr-3 py-2 hover:bg-muted/30 transition-colors",children:[g("div",{className:"flex items-center gap-2.5 min-w-0",children:[a(Ir,{checked:me,onCheckedChange:()=>F(k.name,oe.modelId),id:`model-check-${k.name}-${oe.modelId}`}),g("label",{htmlFor:`model-check-${k.name}-${oe.modelId}`,className:"text-xs font-medium text-foreground cursor-pointer select-none truncate",children:[oe.name||oe.modelId,a("span",{className:"ml-1.5 text-[11px] text-muted-foreground font-mono font-normal",children:oe.modelId})]})]}),g("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[oe.config.reasoning&&a(ge,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-normal border-amber-500/30 text-amber-600 dark:text-amber-400",children:YO()}),a("span",{className:"text-[11px] text-muted-foreground font-mono",children:$O({count:Math.round(oe.config.contextWindow/1000)})})]})]},oe.modelId)})})]},k.name)})})})}),g(ot,{className:"p-6 pt-3 shrink-0 border-t border-border flex items-center justify-between sm:justify-between w-full",children:[a("div",{className:"text-xs text-muted-foreground",children:tP({modelCount:d,providerCount:o})}),g("div",{className:"flex items-center gap-2",children:[a(N,{type:"button",variant:"outline",onClick:r,disabled:K.isPending,children:Ge()}),a(N,{type:"button",onClick:C,disabled:d===0||K.isPending,className:"gap-2",children:K.isPending?g(W,{children:[a(V,{className:"w-4 h-4 animate-spin"}),zO()]}):UO({count:d})})]})]})]})})}var Fs={"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 Ds({teamId:e}){let r=ae(),[t,i]=w(null),[s,n]=w(!1),[l,u]=w(""),[h,m]=w(!1),[f,v]=w(null),[d,o]=w(!1),[b,p]=w(null),_=X({mutationFn:async()=>{let I=await R.api.teams[":teamId"].providers["sync-check"].$post({param:{teamId:e}});if(!I.ok){let P=await I.json().catch(()=>({message:"Failed to check updates"}));throw Error(P.message||"Failed to check updates")}return await I.json()},onSuccess:(I)=>{if(I.totalNewModels===0&&I.totalNewProviders===0){B.info(nP());return}p(I),o(!0)},onError:(I)=>{B.error(I.message)}}),{data:F,isLoading:D}=ee({queryKey:["teams",e,"providers"],queryFn:async()=>{let I=await R.api.teams[":teamId"].providers.$get({param:{teamId:e}});if(!I.ok)throw Error("Failed to fetch providers");return await I.json()}}),A=Q(()=>F?.find((I)=>I.id===t)||null,[F,t]),Y=Q(()=>F?.map((I)=>I.name)||[],[F]),K=Q(()=>{if(!F)return[];if(!l.trim())return F;let I=l.toLowerCase();return F.filter((P)=>P.name.toLowerCase().includes(I))},[F,l]),C=X({mutationFn:async(I)=>{let P=await R.api.teams[":teamId"].providers.$post({param:{teamId:e},json:{name:I.name,config:I.config,models:I.models}});if(!P.ok)throw Error("Failed to create provider");return await P.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"providers"]}),n(!1),B.success(iR())},onError:(I)=>{B.error(Zi({message:I.message}))}}),k=X({mutationFn:async(I)=>{let P=await R.api.providers[":id"].$delete({param:{id:I}});if(!P.ok)throw Error("Failed to delete provider");return await P.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"providers"]}),i(null),m(!1),v(null),B.success(aR())},onError:(I)=>{B.error(Zi({message:I.message}))}});if(D)return a("div",{className:"flex h-64 items-center justify-center",children:a(V,{className:"h-8 w-8 animate-spin text-primary"})});return g("div",{className:"h-full flex flex-col space-y-0",children:[g("div",{className:"flex-none space-y-4 pb-4",children:[g("div",{className:"flex items-center justify-between",children:[g("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[a(no,{className:"w-5 h-5 text-primary"}),zE()]}),g("div",{className:"flex items-center gap-2",children:[a(N,{variant:"outline",onClick:()=>_.mutate(),disabled:_.isPending,className:"gap-2",children:_.isPending?g(W,{children:[a(V,{className:"w-4 h-4 animate-spin"}),jO()]}):g(W,{children:[a(la,{className:"w-4 h-4"}),BO()]})}),g(N,{onClick:()=>n(!0),className:"bg-primary hover:bg-primary/90 text-primary-foreground gap-2",children:[a(Re,{className:"w-4 h-4"}),GA()]})]})]}),g("div",{className:"relative px-0.5",children:[a(or,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),a(re,{placeholder:T0(),value:l,onChange:(I)=>u(I.target.value),className:"pl-10 bg-card border-border focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-0"})]})]}),a(Ie,{className:"flex-1 min-h-0",children:g("div",{className:"pr-4 py-2 grid grid-cols-1 gap-4",children:[K.map((I)=>a(st,{className:"group cursor-pointer hover:border-primary/50 transition-all hover:shadow-md overflow-hidden",onClick:()=>i(I.id),children:g(_t,{className:"p-5 flex items-center justify-between gap-4",children:[g("div",{className:"flex items-center gap-4 min-w-0 flex-1",children:[a("div",{className:"flex-none p-3 bg-muted rounded-xl group-hover:bg-primary/10 transition-colors",children:a(na,{className:"w-6 h-6 text-muted-foreground group-hover:text-primary"})}),g("div",{className:"min-w-0 flex-1",children:[a("div",{className:"flex items-center gap-2",children:a("span",{className:"font-bold text-foreground truncate",children:I.name})}),g("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-muted-foreground mt-1",children:[g("span",{className:"flex items-center gap-1 flex-none",children:[a(Lt,{className:"w-3 h-3"}),I.config.api]}),I.config.baseUrl&&g("span",{className:"flex items-center gap-1 min-w-0",children:[a("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/30 flex-none"}),a(eo,{className:"w-3 h-3 flex-none"}),a("span",{className:"truncate max-w-[200px] md:max-w-[300px]",children:I.config.baseUrl})]}),g("span",{className:"flex items-center gap-1 flex-none",children:[a("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/30 flex-none"}),a(Ga,{className:"w-3 h-3"}),d1({count:I.modelsCount})]})]})]})]}),g("div",{className:"flex items-center gap-1",children:[g(De,{modal:!1,children:[a(Ne,{asChild:!0,onClick:(P)=>P.stopPropagation(),children:a(N,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:a(Wr,{className:"w-4 h-4"})})}),a(Fe,{align:"end",className:"w-32",children:g(se,{onClick:(P)=>{P.stopPropagation(),v(I),m(!0)},className:"text-destructive focus:text-destructive gap-2 cursor-pointer",children:[a(Ue,{className:"w-4 h-4"})," ",Dt()]})})]}),a(qt,{className:"flex-none w-5 h-5 text-muted-foreground/50 group-hover:text-primary transition-colors"})]})]})},I.id)),F?.length===0&&g("div",{className:"text-center py-12 bg-muted/30 rounded-2xl border-2 border-dashed border-border",children:[a(no,{className:"w-12 h-12 text-muted-foreground/50 mx-auto mb-4"}),a("h4",{className:"text-foreground font-medium",children:Z1()}),a("p",{className:"text-sm text-muted-foreground mt-1",children:Rv()})]}),F&&F.length>0&&K.length===0&&g("div",{className:"text-center py-12",children:[a(or,{className:"w-12 h-12 text-muted-foreground/50 mx-auto mb-4"}),a("h4",{className:"text-foreground font-medium",children:Uy()}),a("p",{className:"text-sm text-muted-foreground mt-1",children:zP({query:l})}),a(N,{variant:"ghost",size:"sm",onClick:()=>u(""),className:"mt-4 text-primary hover:text-primary/90 hover:bg-primary/10",children:TE()})]})]})}),a(Lr,{isOpen:s,onClose:()=>n(!1),onSubmit:(I)=>C.mutate(I),isLoading:C.isPending,existingProviderNames:Y}),A&&a(Pr,{isOpen:!!A,onClose:()=>i(null),provider:A,teamId:e,existingProviderNames:Y}),a(ct,{open:h,onOpenChange:m,children:g(ut,{children:[g(dt,{children:[a(pt,{children:Ip()}),a(mt,{children:oC({name:f?.name??""})})]}),g(ft,{children:[a(gt,{onClick:()=>v(null),children:Ge()}),g(ht,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(f)k.mutate(f.id)},children:[k.isPending?a(V,{className:"w-4 h-4 animate-spin mr-2"}):a(Ue,{className:"w-4 h-4 mr-2"}),Dt()]})]})]})}),a(Ms,{isOpen:d,onClose:()=>o(!1),teamId:e,syncData:b,onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"providers"]})}})]})}function Lr({isOpen:e,onClose:r,onSubmit:t,isLoading:i,existingProviderNames:s}){let[n,l]=w([]),[u,h]=w(!1),[m,f]=w(null),v=Q(()=>q({name:x().min(1,o0()).refine((p)=>!s.includes(p),{message:s0()}),config:hl}),[s]),d=Rt({defaultValues:{name:"",config:{api:"openai-completions",baseUrl:"",apiKey:""}},validators:{onSubmit:v},onSubmit:async({value:p})=>{t({name:p.name,config:p.config,models:n})}});S(()=>{if(e)d.reset(),l([]),h(!1),f(null)},[e,d]);let o=(p)=>p.map((_)=>{if(typeof _==="string")return{message:_};if(_&&typeof _==="object"&&"message"in _)return{message:String(_.message)};return{message:String(_||"")}}),b=(p)=>{if(m!==null)l((_)=>_.map((F,D)=>D===m?p:F)),f(null);else l((_)=>[p,..._]),h(!1)};return a(Se,{open:e,onOpenChange:r,children:g(xe,{className:"sm:max-w-2xl h-[85vh] flex flex-col p-0 overflow-hidden",children:[g(ke,{className:"p-6 pb-2 shrink-0",children:[a(Ce,{className:"text-xl",children:Dv()}),a(Nt,{children:T_()})]}),g("form",{onSubmit:(p)=>{p.preventDefault(),p.stopPropagation(),d.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[a("div",{className:"flex-1 min-h-0",children:a(Ie,{className:"h-full",children:g("div",{className:"p-6 pt-2 space-y-6 pr-6",children:[g("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-5 rounded-2xl border bg-muted/20",children:[a(d.Field,{name:"name",children:(p)=>{let _=!!p.state.meta.errors.length&&p.state.meta.isTouched;return g(_e,{"data-invalid":_,children:[a(ye,{htmlFor:p.name,children:n0()}),a(re,{id:p.name,name:p.name,value:p.state.value,onBlur:p.handleBlur,onChange:(F)=>p.handleChange(F.target.value),placeholder:i0(),"aria-invalid":_}),_&&a(Me,{errors:o(p.state.meta.errors)})]})}}),a(d.Field,{name:"config.api",children:(p)=>{let _=!!p.state.meta.errors.length&&p.state.meta.isTouched;return g(_e,{"data-invalid":_,children:[a(ye,{htmlFor:p.name,children:fy()}),g(Ye,{onValueChange:p.handleChange,value:p.state.value,children:[a(et,{id:p.name,"aria-invalid":_,children:a(Xe,{placeholder:k0()})}),a(tt,{children:tf.map((F)=>a(be,{value:F,children:Fs[F]},F))})]}),_&&a(Me,{errors:o(p.state.meta.errors)})]})}}),a("div",{className:"md:col-span-2",children:a(d.Field,{name:"config.baseUrl",children:(p)=>{let _=!!p.state.meta.errors.length&&p.state.meta.isTouched;return g(_e,{"data-invalid":_,children:[a(ye,{htmlFor:p.name,children:C_()}),a(re,{id:p.name,name:p.name,value:p.state.value||"",onBlur:p.handleBlur,onChange:(F)=>p.handleChange(F.target.value),placeholder:"https://api.openai.com/v1","aria-invalid":_}),a(Jt,{children:Qy()}),_&&a(Me,{errors:o(p.state.meta.errors)})]})}})}),a("div",{className:"md:col-span-2",children:a(d.Field,{name:"config.apiKey",children:(p)=>{let _=!!p.state.meta.errors.length&&p.state.meta.isTouched;return g(_e,{"data-invalid":_,children:[a(ye,{htmlFor:p.name,children:Sp()}),a(re,{id:p.name,name:p.name,type:"text",value:p.state.value||"",onBlur:p.handleBlur,onChange:(F)=>p.handleChange(F.target.value),placeholder:__(),"aria-invalid":_}),a(Jt,{className:"text-xs mt-1",children:A_()}),_&&a(Me,{errors:o(p.state.meta.errors)})]})}})})]}),g("div",{className:"space-y-3",children:[g("div",{className:"flex items-center justify-between",children:[g("div",{children:[a(fe,{className:"text-base font-semibold",children:Hp()}),a("p",{className:"text-xs text-muted-foreground mt-0.5",children:o1()})]}),g(N,{type:"button",variant:"outline",size:"sm",onClick:()=>h(!0),className:"gap-1.5",children:[a(Re,{className:"w-4 h-4"}),Ep()]})]}),n.length===0?a("div",{className:"text-center py-8 rounded-xl border border-dashed text-muted-foreground text-sm",children:Gp()}):a("div",{className:"space-y-2",children:n.map((p,_)=>g("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:()=>f(_),children:[g("div",{className:"min-w-0 flex-1",children:[g("div",{className:"flex items-center gap-2",children:[a("span",{className:"font-semibold text-foreground truncate",children:p.name||p.modelId}),a(ge,{variant:"secondary",className:"font-mono text-[10px]",children:p.modelId}),p.config.reasoning&&g(ge,{variant:"outline",className:"text-[10px] gap-1 bg-primary/10 text-primary border-primary/20",children:[a(Lt,{className:"w-2.5 h-2.5"})," ",Ag()]})]}),g("div",{className:"text-xs text-muted-foreground mt-1 flex items-center gap-2",children:[g("span",{children:[p.config.contextWindow?.toLocaleString()," ",tv()]}),a("span",{children:"·"}),a("span",{children:D_({input:p.config.cost?.input??0,output:p.config.cost?.output??0})})]})]}),a("div",{className:"flex items-center gap-1 ml-2",children:a(N,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:(F)=>{F.stopPropagation(),l((D)=>D.filter((A,Y)=>Y!==_))},children:a(Ue,{className:"w-3.5 h-3.5"})})})]},p.modelId+_))})]})]})})}),g(ot,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[a(N,{type:"button",variant:"outline",onClick:r,disabled:i,children:Ge()}),a(d.Subscribe,{selector:(p)=>[p.canSubmit,p.isSubmitting],children:([p,_])=>a(N,{type:"submit",className:"min-w-[120px]",disabled:!p||_||i,children:_||i?a(V,{className:"w-4 h-4 animate-spin"}):GA()})})]})]}),(u||m!==null)&&a(ya,{isOpen:!0,onClose:()=>{h(!1),f(null)},onSubmit:b,title:m!==null?Q_():Ep(),initialValues:m!==null?n[m]:null,defaultApi:d.getFieldValue("config.api"),existingModelIds:n.filter((p,_)=>_!==m).map((p)=>p.modelId)},m!==null?`edit-${m}-${n[m]?.modelId}`:"add")]})})}function Pr({isOpen:e,onClose:r,provider:t,teamId:i,existingProviderNames:s}){let n=ae(),[l,u]=w("general"),[h,m]=w(""),[f,v]=w(!1),[d,o]=w(null),[b,p]=w(null),{data:_=[],isLoading:F}=ee({queryKey:["teams",i,"providers",t.id,"models"],queryFn:async()=>{let y=await R.api.providers[":id"].models.$get({param:{id:t.id}});if(!y.ok)throw Error("Failed to fetch models");return await y.json()},enabled:e}),D=X({mutationFn:async(y)=>{let O=await R.api.providers[":id"].$put({param:{id:t.id},json:{name:y.name,config:y.config}});if(!O.ok)throw Error("Failed to update provider");return await O.json()},onSuccess:()=>{n.invalidateQueries({queryKey:["teams",i,"providers"]}),B.success(u0())},onError:(y)=>{B.error(Zi({message:y.message}))}}),A=X({mutationFn:async(y)=>{let O=await R.api.providers[":id"].models.$post({param:{id:t.id},json:y});if(!O.ok)throw Error("Failed to create model");return await O.json()},onSuccess:()=>{n.invalidateQueries({queryKey:["teams",i,"providers",t.id,"models"]}),n.invalidateQueries({queryKey:["teams",i,"providers"]}),v(!1),B.success(JT())},onError:(y)=>{B.error(Zi({message:y.message}))}}),Y=X({mutationFn:async({modelDbId:y,values:O})=>{let ie=await R.api.providers[":id"].models[":modelDbId"].$put({param:{id:t.id,modelDbId:y},json:O});if(!ie.ok)throw Error("Failed to update model");return await ie.json()},onSuccess:()=>{n.invalidateQueries({queryKey:["teams",i,"providers",t.id,"models"]}),o(null),B.success(n1())},onError:(y)=>{B.error(Zi({message:y.message}))}}),K=X({mutationFn:async(y)=>{let O=await R.api.providers[":id"].models[":modelDbId"].$delete({param:{id:t.id,modelDbId:y}});if(!O.ok)throw Error("Failed to delete model");return await O.json()},onSuccess:()=>{n.invalidateQueries({queryKey:["teams",i,"providers",t.id,"models"]}),n.invalidateQueries({queryKey:["teams",i,"providers"]}),p(null),B.success(YT())},onError:(y)=>{B.error(Zi({message:y.message}))}}),C=Q(()=>q({name:x().min(1,o0()).refine((y)=>{if(t.name===y)return!0;return!s.includes(y)},{message:s0()}),config:hl}),[s,t.name]),k=Rt({defaultValues:{name:t.name,config:t.config},validators:{onSubmit:C},onSubmit:async({value:y})=>{D.mutate({name:y.name,config:y.config})}});S(()=>{if(e)k.reset(),u("general"),m("")},[e,k]);let I=(y)=>y.map((O)=>{if(typeof O==="string")return{message:O};if(O&&typeof O==="object"&&"message"in O)return{message:String(O.message)};return{message:String(O||"")}}),P=Q(()=>{if(!h.trim())return _;let y=h.toLowerCase();return _.filter((O)=>O.modelId.toLowerCase().includes(y)||O.name?.toLowerCase().includes(y))},[_,h]);return a(Se,{open:e,onOpenChange:r,children:g(xe,{className:"sm:max-w-3xl h-[88vh] flex flex-col p-0 overflow-hidden",children:[g(ke,{className:"p-6 pb-2 shrink-0",children:[a(Ce,{className:"text-xl",children:H_({name:t.name})}),a(Nt,{children:T_()})]}),g(ho,{value:l,onValueChange:(y)=>u(y),className:"flex-1 flex flex-col min-h-0",children:[a("div",{className:"px-6 pb-2 shrink-0",children:g(go,{className:"grid w-full grid-cols-2",children:[a(Xr,{value:"general",children:dy()}),g(Xr,{value:"models",className:"gap-2",children:[Hp(),a(ge,{variant:"secondary",className:"h-5 px-1.5 text-[11px]",children:_.length})]})]})}),a(_n,{value:"general",className:"flex-1 flex flex-col min-h-0 m-0",children:g("form",{onSubmit:(y)=>{y.preventDefault(),y.stopPropagation(),k.handleSubmit()},className:"flex-1 flex flex-col min-h-0",children:[a("div",{className:"flex-1 min-h-0",children:a(Ie,{className:"h-full",children:a("div",{className:"p-6 space-y-6 pr-6",children:g("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5 p-5 rounded-2xl border bg-muted/10",children:[a(k.Field,{name:"name",children:(y)=>{let O=!!y.state.meta.errors.length&&y.state.meta.isTouched;return g(_e,{"data-invalid":O,children:[a(ye,{htmlFor:y.name,children:n0()}),a(re,{id:y.name,name:y.name,value:y.state.value,onBlur:y.handleBlur,onChange:(ie)=>y.handleChange(ie.target.value),placeholder:i0(),"aria-invalid":O}),O&&a(Me,{errors:I(y.state.meta.errors)})]})}}),a(k.Field,{name:"config.api",children:(y)=>{let O=!!y.state.meta.errors.length&&y.state.meta.isTouched;return g(_e,{"data-invalid":O,children:[a(ye,{htmlFor:y.name,children:fy()}),g(Ye,{onValueChange:y.handleChange,value:y.state.value,children:[a(et,{id:y.name,"aria-invalid":O,children:a(Xe,{placeholder:k0()})}),a(tt,{children:tf.map((ie)=>a(be,{value:ie,children:Fs[ie]},ie))})]}),O&&a(Me,{errors:I(y.state.meta.errors)})]})}}),a("div",{className:"md:col-span-2",children:a(k.Field,{name:"config.baseUrl",children:(y)=>{let O=!!y.state.meta.errors.length&&y.state.meta.isTouched;return g(_e,{"data-invalid":O,children:[a(ye,{htmlFor:y.name,children:C_()}),a(re,{id:y.name,name:y.name,value:y.state.value||"",onBlur:y.handleBlur,onChange:(ie)=>y.handleChange(ie.target.value),placeholder:"https://api.openai.com/v1","aria-invalid":O}),a(Jt,{children:Qy()}),O&&a(Me,{errors:I(y.state.meta.errors)})]})}})}),a("div",{className:"md:col-span-2",children:a(k.Field,{name:"config.apiKey",children:(y)=>{let O=!!y.state.meta.errors.length&&y.state.meta.isTouched;return g(_e,{"data-invalid":O,children:[a(ye,{htmlFor:y.name,children:Sp()}),a(re,{id:y.name,name:y.name,type:"text",value:y.state.value||"",onBlur:y.handleBlur,onChange:(ie)=>y.handleChange(ie.target.value),placeholder:__(),"aria-invalid":O}),a(Jt,{className:"text-xs mt-1",children:A_()}),O&&a(Me,{errors:I(y.state.meta.errors)})]})}})})]})})})}),g(ot,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[a(N,{type:"button",variant:"outline",onClick:r,children:Ge()}),a(k.Subscribe,{selector:(y)=>[y.canSubmit,y.isSubmitting],children:([y,O])=>a(N,{type:"submit",className:"min-w-[120px]",disabled:!y||O||D.isPending,children:O||D.isPending?a(V,{className:"w-4 h-4 animate-spin"}):zi()})})]})]})}),g(_n,{value:"models",className:"flex-1 flex flex-col min-h-0 m-0",children:[g("div",{className:"p-6 pb-3 flex items-center justify-between gap-3 shrink-0",children:[g("div",{className:"relative flex-1 max-w-sm",children:[a(or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),a(re,{placeholder:Eg(),value:h,onChange:(y)=>m(y.target.value),className:"pl-9 h-9"})]}),g(N,{size:"sm",onClick:()=>v(!0),className:"gap-1.5 shrink-0",children:[a(Re,{className:"w-4 h-4"}),Ep()]})]}),a("div",{className:"flex-1 min-h-0 px-6",children:a(Ie,{className:"h-full pr-4",children:F?a("div",{className:"flex h-48 items-center justify-center",children:a(V,{className:"h-6 w-6 animate-spin text-primary"})}):P.length===0?a("div",{className:"text-center py-12 border border-dashed rounded-xl text-muted-foreground text-sm",children:Gp()}):a("div",{className:"space-y-2 pb-4",children:P.map((y)=>g("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:()=>o(y),children:[g("div",{className:"min-w-0 flex-1 pr-3",children:[g("div",{className:"flex items-center gap-2 flex-wrap",children:[a("span",{className:"font-semibold text-foreground text-sm",children:y.name||y.modelId}),a(ge,{variant:"secondary",className:"font-mono text-[10px] px-1.5 py-0.5",children:y.modelId}),y.config?.reasoning&&g(ge,{variant:"outline",className:"text-[10px] gap-1 bg-primary/10 text-primary border-primary/20 h-5",children:[a(Lt,{className:"w-2.5 h-2.5"})," ",Ag()]})]}),g("div",{className:"text-xs text-muted-foreground mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1",children:[g("span",{children:[y.config?.contextWindow?.toLocaleString()," ",tv()]}),a("span",{children:"·"}),a("span",{children:mT({count:y.config?.maxTokens?.toLocaleString()??"0"})}),a("span",{children:"·"}),a("span",{children:D_({input:y.config?.cost?.input??0,output:y.config?.cost?.output??0})})]})]}),a("div",{className:"flex items-center gap-1 shrink-0",children:a(N,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:(O)=>{O.stopPropagation(),p(y)},children:a(Ue,{className:"w-3.5 h-3.5"})})})]},y.id))})})})]})]}),f&&a(ya,{isOpen:f,onClose:()=>v(!1),onSubmit:(y)=>A.mutate(y),title:Ep(),isLoading:A.isPending,defaultApi:t.config.api,existingModelIds:_.map((y)=>y.modelId)}),d&&a(ya,{isOpen:!!d,onClose:()=>o(null),onSubmit:(y)=>Y.mutate({modelDbId:d.id,values:y}),title:Q_(),isLoading:Y.isPending,initialValues:{modelId:d.modelId,name:d.name,config:d.config},defaultApi:t.config.api,existingModelIds:_.filter((y)=>y.id!==d.id).map((y)=>y.modelId)}),a(ct,{open:!!b,onOpenChange:(y)=>!y&&p(null),children:g(ut,{children:[g(dt,{children:[a(pt,{children:Ip()}),a(mt,{children:tC({name:b?.name||b?.modelId||""})})]}),g(ft,{children:[a(gt,{onClick:()=>p(null),children:Ge()}),g(ht,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(b)K.mutate(b.id)},children:[K.isPending?a(V,{className:"w-4 h-4 animate-spin mr-2"}):a(Ue,{className:"w-4 h-4 mr-2"}),Dt()]})]})]})})]})})}L();function As({teamId:e}){let r=ae(),[t,i]=w(""),{data:s,isLoading:n}=ee({queryKey:["teams",e,"sandbox"],queryFn:async()=>{let b=await R.api.teams[":teamId"].sandbox.$get({param:{teamId:e}});if(!b.ok)throw Error(as());return await b.json()}}),{mutate:l,isPending:u}=X({mutationFn:async(b)=>{let p=await R.api.teams[":teamId"].sandbox.$put({param:{teamId:e},json:b});if(!p.ok)throw Error(oy());return await p.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"sandbox"]}),B.success(fM())},onError:(b)=>{B.error(b instanceof Error?b.message:oy())}}),h=(b)=>{l({networkSandboxEnabled:b})},m=(b)=>{if(b.preventDefault(),!t.trim())return;if(s?.allowedDomains.includes(t.trim())){B.error(_C());return}let p=[...s?.allowedDomains||[],t.trim()],_=s?.pendingDomains||[];l({allowedDomains:p,pendingDomains:_}),i("")},f=(b)=>{let p=(s?.allowedDomains||[]).filter((F)=>F!==b),_=s?.pendingDomains||[];l({allowedDomains:p,pendingDomains:_})},v=(b)=>{let p=[...s?.allowedDomains||[],b],_=(s?.pendingDomains||[]).filter((F)=>F!==b);l({allowedDomains:p,pendingDomains:_})},d=(b)=>{let p=(s?.pendingDomains||[]).filter((_)=>_!==b);l({allowedDomains:s?.allowedDomains||[],pendingDomains:p})};if(n)return a("div",{className:"flex items-center justify-center p-8",children:a(V,{className:"h-8 w-8 animate-spin text-muted-foreground"})});let o=!!s?.networkSandboxEnabled;return a(Ie,{className:"h-full",children:g("div",{className:"space-y-6 pr-4 pb-8",children:[g(st,{children:[g(Ct,{children:[g("div",{className:"flex items-center gap-2",children:[a(na,{className:"w-5 h-5 text-primary"}),a(St,{children:h1()})]}),a(Zt,{children:g1()})]}),g(_t,{children:[g("div",{className:"flex items-center justify-between p-4 mb-6 rounded-lg border border-border bg-muted/30",children:[g("div",{className:"space-y-0.5 pr-4",children:[a("label",{htmlFor:"network-sandbox-switch",className:"text-sm font-medium text-foreground cursor-pointer",children:LC()}),a("p",{className:"text-xs text-muted-foreground",children:_1()})]}),a(Ve,{id:"network-sandbox-switch",checked:o,onCheckedChange:h,disabled:u})]}),!o&&g("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:[a(eo,{className:"w-4 h-4 mt-0.5 shrink-0"}),a("span",{children:A1()})]}),g("form",{onSubmit:m,className:"flex gap-2 mb-6",children:[a(re,{placeholder:"e.g. api.openai.com",value:t,onChange:(b)=>i(b.target.value),disabled:u||!o}),g(N,{type:"submit",disabled:u||!o,children:[u?a(V,{className:"w-4 h-4 animate-spin"}):a(Re,{className:"w-4 h-4 mr-2"}),kv()]})]}),g("div",{className:"space-y-2",children:[a("h4",{className:"text-sm font-medium text-muted-foreground mb-3",children:sw()}),g("div",{className:"flex flex-wrap gap-2",children:[s?.allowedDomains.map((b)=>g("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:[a("span",{className:"font-medium text-foreground",children:b}),a("button",{onClick:()=>f(b),className:"ml-1 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50 disabled:cursor-not-allowed",disabled:u||!o,children:a(Ke,{className:"w-3.5 h-3.5"})})]},b)),s?.allowedDomains.length===0&&a("div",{className:"text-sm text-muted-foreground italic",children:R1()})]})]})]})]}),g(st,{className:"border-orange-500/20 bg-orange-500/5",children:[g(Ct,{children:[g("div",{className:"flex items-center gap-2",children:[a(Eu,{className:"w-5 h-5 text-orange-500"}),a(St,{children:Dk()})]}),a(Zt,{children:Nk()})]}),a(_t,{children:a("div",{className:"space-y-3",children:s?.pendingDomains&&s.pendingDomains.length>0?a("div",{className:"divide-y divide-border",children:s.pendingDomains.map((b)=>g("div",{className:"flex items-center justify-between py-2.5 first:pt-0 last:pb-0",children:[a("span",{className:"font-mono text-sm text-foreground bg-muted px-2 py-1 rounded break-all",children:b}),g("div",{className:"flex items-center gap-2",children:[g(N,{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:()=>v(b),disabled:u||!o,children:[a(qe,{className:"w-4 h-4 mr-1.5"}),Aw()]}),g(N,{size:"sm",variant:"outline",className:"h-8 border-destructive/20 text-destructive hover:bg-destructive/10",onClick:()=>d(b),disabled:u||!o,children:[a(Ue,{className:"w-4 h-4 mr-1.5"}),Dt()]})]})]},b))}):a("div",{className:"text-sm text-muted-foreground italic py-2",children:L1()})})})]}),a(st,{children:g(Ct,{children:[a(St,{children:NS()}),a(Zt,{children:FS()})]})})]})})}L();var qr=(e)=>g("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:[a("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"}),a("path",{d:"M9 18c-4.51 2-5-2-7-2"})]}),Is=({teamId:e})=>{let r=ae(),{canAdmin:t}=er(),[i,s]=w(!1),[n,l]=w(!1),[u,h]=w(!1),[m,f]=w(null),{data:v,isLoading:d}=ee({queryKey:["teams",e,"skills"],queryFn:async()=>{let _=await R.api.teams[":teamId"].skills.$get({param:{teamId:e}});if(!_.ok)throw Error(as());return await _.json()}}),o=X({mutationFn:async(_)=>{if(!(await R.api.skills[":id"].$delete({param:{id:_}})).ok)throw Error(Yl())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"skills"]}),h(!1)}}),b=X({mutationFn:async({id:_,permission:F})=>{if(!(await R.api.skills[":id"].permission.$patch({param:{id:_},json:{permission:F}})).ok)throw Error(nu())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"skills"]})},onError:(_)=>{alert(_.message||nu())}}),p=v?.skills||[];return g(st,{children:[g(Ct,{className:"flex flex-row items-center justify-between space-y-0 pb-7",children:[g("div",{className:"flex items-center gap-3",children:[a("div",{className:"p-2 bg-primary/10 text-primary rounded-lg",children:a(vt,{className:"w-6 h-6"})}),g("div",{children:[a(St,{className:"text-xl font-bold",children:B0()}),a(Zt,{children:dO()})]})]}),g(N,{onClick:()=>s(!0),className:"gap-2",children:[a(Re,{className:"w-4 h-4"})," ",Lv()]})]}),a(_t,{children:d?a("div",{className:"flex justify-center py-10",children:a(V,{className:"w-8 h-8 animate-spin text-primary"})}):p.length===0?g("div",{className:"text-center py-12 border-2 border-dashed border-border rounded-xl",children:[a("div",{className:"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4 text-muted-foreground",children:a(vt,{className:"w-6 h-6"})}),a("h3",{className:"text-lg font-medium text-foreground",children:$1()}),a("p",{className:"text-muted-foreground mt-1 max-w-xs mx-auto",children:Zv()})]}):a("div",{className:"space-y-4",children:p.map((_)=>a(jr,{skill:_,canAdmin:t,onDelete:()=>{f(_),h(!0)},onConfigure:()=>{f(_),l(!0)},onPermissionChange:(F)=>b.mutate({id:_.id,permission:F})},_.id))})}),a(Or,{open:i,onOpenChange:s,teamId:e}),m&&a($r,{open:n,onOpenChange:(_)=>{if(l(_),!_)setTimeout(()=>{document.body.style.pointerEvents="auto"},100)},teamId:e,skill:m}),a(ct,{open:u,onOpenChange:h,children:g(ut,{children:[g(dt,{children:[a(pt,{children:Ip()}),a(mt,{children:aC({name:m?.name??""})})]}),g(ft,{children:[a(gt,{children:Ge()}),g(ht,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(m)o.mutate(m.id)},children:[o.isPending?a(V,{className:"w-4 h-4 animate-spin mr-2"}):a(Ue,{className:"w-4 h-4 mr-2"}),Dt()]})]})]})})]})},jr=({skill:e,canAdmin:r,onDelete:t,onConfigure:i,onPermissionChange:s})=>g("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:i,children:[g("div",{children:[g("div",{className:"flex items-start justify-between mb-2",children:[a("h4",{className:"font-bold text-foreground flex items-center gap-2",children:e.name}),g(De,{children:[a(Ne,{asChild:!0,onClick:(n)=>n.stopPropagation(),children:a(N,{variant:"ghost",size:"icon",className:"h-8 w-8",children:a(Wr,{className:"w-4 h-4"})})}),a(Fe,{align:"end",className:"w-32",children:g(se,{onClick:(n)=>{n.stopPropagation(),t()},className:"text-destructive focus:text-destructive gap-2 cursor-pointer",children:[a(Ue,{className:"w-4 h-4"})," ",Dt()]})})]})]}),a("p",{className:"text-sm text-muted-foreground line-clamp-2",children:e.description||Zy()})]}),g("div",{className:"mt-4 flex items-center justify-between gap-2 pt-2 border-t border-border/50 text-xs",children:[g("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider font-semibold",children:[sv()," ",new Date(e.updatedAt).toLocaleDateString()]}),a("div",{className:"flex items-center gap-2",onClick:(n)=>n.stopPropagation(),children:g(Ye,{value:e.permission||"reviewer",onValueChange:(n)=>s(n),disabled:!r,children:[a(et,{className:"h-7 text-xs px-2 bg-background border-border w-[140px]",children:a(Xe,{placeholder:Ig()})}),g(tt,{align:"end",children:[a(be,{value:"reviewer",children:tc()}),a(be,{value:"editor",children:rc()}),a(be,{value:"owner",children:nc()})]})]})})]})]}),Or=({open:e,onOpenChange:r,teamId:t})=>{let i=ae(),[s,n]=w(""),[l,u]=w(!1),h=M(null),{data:m}=ee({queryKey:["teams",t,"projects"],queryFn:async()=>{let d=await R.api.teams[":teamId"].projects.$get({param:{teamId:t},query:{first:"1"}});if(!d.ok)throw Error("Failed to fetch projects");return await d.json()},enabled:e}),f=async(d)=>{u(!0);try{let o=await R.api.teams[":teamId"].skills.$post({param:{teamId:t},json:d});if(o.status===409){let b=await o.json();if(window.confirm(`${b.error}
|
|
2
|
+
|
|
3
|
+
${Ek()}`)){await f({...d,override:!0});return}}else if(!o.ok){let b=await o.json().catch(()=>({}));throw Error(b.error||uS())}else i.invalidateQueries({queryKey:["teams",t,"skills"]}),r(!1),n("")}catch(o){if(o instanceof Error)alert(o.message);else alert(Cp())}finally{u(!1)}},v=async(d)=>{if(!d||d.length===0)return;let o=m?.data?.[0]?.id;if(!o){alert(m1());return}let b=d[0];if(!b.name.toLowerCase().endsWith(".zip")){alert(tk());return}u(!0);try{let p=b.name,_=b.type||"application/zip",F=await R.api.projects[":projectId"].attachments.$post({param:{projectId:o},json:{fileName:p,size:b.size,contentType:_}});if(!F.ok)throw Error("Failed to get upload URL");let{id:D,uploadUrl:A}=await F.json();if(!(await fetch(A,{method:"PUT",body:b,headers:{"Content-Type":_}})).ok)throw Error("Failed to upload file to storage");await f({assetId:D})}catch(p){if(p instanceof Error)alert(p.message);else alert(Cp())}finally{u(!1)}};return a(Se,{open:e,onOpenChange:r,children:g(xe,{className:"sm:max-w-[450px]",children:[g(ke,{children:[a(Ce,{children:Nv()}),a(Nt,{children:BI()})]}),g("div",{className:"space-y-6 pt-4",children:[g("div",{className:"space-y-3",children:[a(fe,{children:xk()}),g("div",{onClick:()=>!l&&h.current?.click(),className:U("group relative h-32 border-2 border-dashed rounded-xl flex flex-col items-center justify-center transition-all cursor-pointer",l?"opacity-50 cursor-not-allowed bg-muted/50 border-border":"hover:bg-primary/5 hover:border-primary/50 border-border"),children:[a("input",{type:"file",ref:h,className:"hidden",accept:".zip",onChange:(d)=>v(d.target.files)}),a("div",{className:"p-3 bg-muted rounded-full group-hover:bg-primary/10 transition-colors",children:a(Ho,{className:"w-6 h-6 text-muted-foreground group-hover:text-primary"})}),g("div",{className:"mt-3 text-center",children:[a("p",{className:"text-sm font-medium text-foreground",children:jM()}),a("p",{className:"text-[10px] text-muted-foreground mt-1 uppercase tracking-wider font-semibold",children:Ck()})]})]}),l&&!s&&g("div",{className:"flex items-center gap-2 text-sm text-primary justify-center bg-primary/10 py-2 rounded-lg animate-pulse",children:[a(V,{className:"w-4 h-4 animate-spin"}),Vk()]})]}),g("div",{className:"relative",children:[a("div",{className:"absolute inset-0 flex items-center",children:a("span",{className:"w-full border-t border-border"})}),a("div",{className:"relative flex justify-center text-xs uppercase",children:a("span",{className:"bg-background px-2 text-muted-foreground font-bold",children:$y()})})]}),a("div",{className:"space-y-4",children:g("div",{className:"space-y-2",children:[a(fe,{htmlFor:"githubUrl",children:rI()}),g("div",{className:"flex gap-2",children:[g("div",{className:"relative flex-1",children:[a(qr,{className:"absolute left-3 top-2.5 w-4 h-4 text-muted-foreground"}),a(re,{id:"githubUrl",placeholder:"https://github.com/owner/repo",value:s,onChange:(d)=>n(d.target.value),disabled:l,className:"pl-9"})]}),a(N,{onClick:()=>f({githubUrl:s}),disabled:!s||l,className:"px-6",children:l&&s?a(V,{className:"w-4 h-4 animate-spin"}):zI()})]}),a("p",{className:"text-[10px] text-muted-foreground italic",children:nI()})]})})]})]})})},$r=({open:e,onOpenChange:r,teamId:t,skill:i})=>{let s=ae(),[n,l]=w({...i.config||{},environmentVariables:i.config?.environmentVariables||[]}),[u,h]=w(!1),m=(p,_)=>{let F=[...n.environmentVariables];F[p]={...F[p],default:_},l({...n,environmentVariables:F})},f=(p,_)=>{let F=[...n.environmentVariables];F[p]={...F[p],name:_},l({...n,environmentVariables:F})},v=()=>{l({...n,environmentVariables:[...n.environmentVariables,{name:"",default:""}]})},d=(p)=>{let _=[...n.environmentVariables];_.splice(p,1),l({...n,environmentVariables:_})},o=async()=>{let p=n.environmentVariables.filter((F)=>F.name.trim()!==""),_={...n,environmentVariables:p};h(!0);try{let F=await R.api.skills[":id"].config.$patch({param:{id:i.id},json:{config:_}});if(!F.ok){let D=await F.json().catch(()=>({}));throw Error(D.error||"Failed to update config")}s.invalidateQueries({queryKey:["teams",t,"skills"]}),r(!1)}catch(F){if(F instanceof Error)alert(F.message);else alert(Cp())}finally{h(!1)}},b=n?.environmentVariables||[];return a(Se,{open:e,onOpenChange:r,children:g(xe,{className:"sm:max-w-[500px]",children:[g(ke,{children:[a("div",{className:"flex items-center justify-between",children:g(Ce,{className:"flex items-center gap-2",children:[a(Ba,{className:"w-5 h-5 text-primary"}),UE({name:i.name})]})}),a(Nt,{children:lT()})]}),a(Ie,{className:"max-h-[60vh]",children:a("div",{className:"py-4 space-y-4 pr-4",children:b.length===0?a("div",{className:"text-center py-10 bg-muted/50 rounded-xl border border-dashed border-border",children:a("p",{className:"text-muted-foreground text-sm italic",children:M1()})}):b.map((p,_)=>g("div",{className:"p-4 bg-muted/50 rounded-xl border border-border space-y-3 relative group",children:[a("button",{onClick:()=>d(_),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:a(Ke,{className:"w-4 h-4"})}),g("div",{className:"space-y-1.5",children:[a(fe,{className:"text-[10px] uppercase tracking-wider font-bold text-muted-foreground",children:fD()}),a(re,{value:p.name,onChange:(F)=>f(_,F.target.value),placeholder:"e.g. API_KEY",className:"h-8 bg-background border-border text-sm font-mono"})]}),g("div",{className:"space-y-1.5",children:[a(fe,{className:"text-[10px] uppercase tracking-wider font-bold text-muted-foreground",children:Gx()}),a(re,{value:p.default||"",onChange:(F)=>m(_,F.target.value),placeholder:yk(),className:"h-8 bg-background border-border text-sm"}),a("p",{className:"text-[10px] text-muted-foreground italic",children:HC()})]})]},_))})}),g(ot,{className:"flex items-center justify-between sm:justify-between w-full pt-2 border-t border-border",children:[g(N,{variant:"ghost",size:"sm",onClick:v,className:"h-8 gap-1.5 text-primary hover:text-primary hover:bg-primary/10",children:[a(Re,{className:"w-3.5 h-3.5"})," ",jv()]}),g("div",{className:"flex gap-2",children:[a(N,{variant:"ghost",onClick:()=>r(!1),children:Ge()}),g(N,{onClick:o,disabled:u,className:"px-8",children:[u?a(V,{className:"w-4 h-4 animate-spin mr-2"}):null,zi()]})]})]})]})})};L();L();var Ts=({isOpen:e,onClose:r,teamId:t,server:i})=>{let s=ae(),n=!!i,[l,u]=w(""),[h,m]=w("streamable_http"),[f,v]=w("reviewer"),[d,o]=w("auto"),[b,p]=w(""),[_,F]=w(""),[D,A]=w(""),[Y,K]=w(""),[C,k]=w("authorization_code"),[I,P]=w([]),[y,O]=w([]),[ie,oe]=w({}),[me,ue]=w(!1);S(()=>{if(i)u(i.url),m(i.transport||"streamable_http"),v(i.permission||"reviewer"),o(i.authType||"auto"),P(Array.isArray(i.config?.directTools)?i.config.directTools:[]),O(i.config?.excludeTools??[]),oe({}),ue(!1);else u(""),m("streamable_http"),v("reviewer"),o("auto"),p(""),F(""),A(""),K(""),k("authorization_code"),P([]),O([]),oe({}),ue(!1)},[i,e]);let H=()=>{if(d==="none")return{type:"none"};if(d==="bearer")return{type:"bearer",bearerToken:b||void 0};if(d==="oauth")return{type:"oauth",oauth:{grantType:C,clientId:_||void 0,clientSecret:D||void 0,scope:Y||void 0}};return},{data:le,isLoading:ve,refetch:Ae}=ee({queryKey:["mcp","servers",i?.id,"tools"],queryFn:async()=>{if(!i?.id)return{tools:[]};let T=await R.api.mcp.servers[":id"].tools.$get({param:{id:i.id}});if(!T.ok)throw Error("Failed to fetch tools");return await T.json()},enabled:e&&n&&!!i?.id}),Le=X({mutationFn:async()=>{if(!i?.id)return;let T=await R.api.mcp.servers[":id"].refresh.$post({param:{id:i.id}});if(!T.ok){let ne=await T.json().catch(()=>({}));throw Error(ne.error||"Failed to refresh server")}return await T.json()},onSuccess:()=>{B.success(kT()),Ae(),s.invalidateQueries({queryKey:["teams",t,"mcp","servers"]})},onError:(T)=>{B.error(T.message)}}),E=X({mutationFn:async()=>{let T={directTools:I.length>0?I:void 0,excludeTools:y.length>0?y:void 0};if(n&&i){let ne={transport:h,permission:f,authConfig:H(),config:T},de=await R.api.mcp.servers[":id"].$patch({param:{id:i.id},json:ne});if(!de.ok){let ze=await de.json().catch(()=>({}));throw Error(ze.error||nu())}return await de.json()}else{let ne={url:l.trim()},de=await R.api.teams[":teamId"].mcp.servers.$post({param:{teamId:t},json:ne});if(!de.ok){let Bt=await de.json().catch(()=>({}));throw Error(Bt.error||Cp())}return await de.json()}},onSuccess:()=>{B.success(n?e0():zd()),s.invalidateQueries({queryKey:["teams",t,"mcp","servers"]}),r()},onError:(T)=>{B.error(T.message)}}),Z=(T)=>{if(T.preventDefault(),!l.trim())return;E.mutate()},J=le?.tools??[],te=(T)=>{if(y.includes(T))return"off";if(I.includes(T))return"direct";return"on"},Pe=(T,ne)=>{if(ne==="off")O((de)=>de.includes(T)?de:[...de,T]),P((de)=>de.filter((ze)=>ze!==T));else if(ne==="on")O((de)=>de.filter((ze)=>ze!==T)),P((de)=>de.filter((ze)=>ze!==T));else if(ne==="direct")O((de)=>de.filter((ze)=>ze!==T)),P((de)=>de.includes(T)?de:[...de,T])},z=(T)=>{let ne=J.map((de)=>de.name);if(T==="off")O(ne),P([]);else if(T==="on")O([]),P([]);else if(T==="direct")O([]),P(ne)},Te=(T)=>{oe((ne)=>({...ne,[T]:!ne[T]}))};return a(Se,{open:e,onOpenChange:(T)=>!T&&r(),children:n&&i?g(xe,{className:"sm:max-w-2xl h-[85vh] flex flex-col p-0 overflow-hidden",children:[Le.isPending&&g("div",{className:"absolute inset-0 bg-background/60 backdrop-blur-[1px] flex flex-col items-center justify-center z-50 rounded-lg",children:[a(V,{className:"w-8 h-8 animate-spin text-primary mb-2"}),g("span",{className:"text-xs font-medium text-muted-foreground",children:[wy(),"..."]})]}),g(ke,{className:"p-6 pb-4 border-b border-border flex-shrink-0",children:[g(Ce,{className:"flex items-center gap-2 text-xl font-bold",children:[a(oo,{className:"w-5 h-5 text-primary"}),wC()]}),a(Nt,{children:$p()})]}),g("form",{onSubmit:Z,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[a(Ie,{className:"flex-1 min-h-0",children:g("div",{className:"p-6 space-y-5",children:[g("div",{className:"grid grid-cols-1 gap-3 p-3 bg-muted/30 border border-border rounded-lg",children:[g("div",{className:"flex flex-col",children:[a("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:MT()}),a("span",{className:"text-sm font-medium",children:i.name})]}),g("div",{className:"flex flex-col",children:[a("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:xy()}),a("span",{className:"text-sm font-mono text-foreground break-all",children:i.url})]}),i.description&&g("div",{className:"flex flex-col",children:[a("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:ru()}),a("span",{className:"text-sm text-foreground",children:i.description})]}),g("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1.5",children:[a(eo,{className:"w-3 h-3"}),Ey()]})]}),i.instructions&&g("div",{className:"p-3 bg-muted/20 border border-border rounded-lg space-y-1",children:[a("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold block",children:RT()}),a("p",{onClick:()=>ue((T)=>!T),className:`text-xs text-muted-foreground whitespace-pre-wrap leading-relaxed cursor-pointer transition-all ${me?"":"line-clamp-2"}`,title:me?void 0:"Click to expand instructions",children:i.instructions})]}),g("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 pt-3 border-t border-border",children:[g("div",{className:"space-y-1.5",children:[a(fe,{className:"text-xs",children:zT()}),g(Ye,{value:h,onValueChange:(T)=>m(T),children:[a(et,{className:"h-9 text-xs",children:a(Xe,{})}),g(tt,{children:[a(be,{value:"streamable_http",children:"Streamable HTTP"}),a(be,{value:"sse",children:"Server-Sent Events (SSE)"})]})]})]}),g("div",{className:"space-y-1.5",children:[a(fe,{className:"text-xs",children:Ig()}),g(Ye,{value:f,onValueChange:(T)=>v(T),children:[a(et,{className:"h-9 text-xs",children:a(Xe,{})}),g(tt,{children:[a(be,{value:"reviewer",children:tc()}),a(be,{value:"editor",children:rc()}),a(be,{value:"owner",children:nc()})]})]})]})]}),g("div",{className:"space-y-3 pt-3 border-t border-border",children:[g("div",{className:"space-y-1.5",children:[a(fe,{className:"text-xs",children:vT()}),g(Ye,{value:d,onValueChange:(T)=>o(T),children:[a(et,{className:"h-9 text-xs",children:a(Xe,{})}),g(tt,{children:[a(be,{value:"auto",children:gT()}),a(be,{value:"none",children:_T()}),a(be,{value:"bearer",children:AT()}),a(be,{value:"oauth",children:yT()})]})]})]}),d==="bearer"&&g("div",{className:"space-y-1.5",children:[a(fe,{className:"text-xs",children:bT()}),a(re,{className:"h-9 text-xs font-mono",type:"password",value:b,onChange:(T)=>p(T.target.value),placeholder:"Enter token string"})]}),d==="oauth"&&g("div",{className:"p-3 bg-muted/20 border border-border rounded-lg space-y-3",children:[g("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[g("div",{className:"space-y-1.5",children:[a(fe,{className:"text-xs",children:IT()}),g(Ye,{value:C,onValueChange:(T)=>k(T),children:[a(et,{className:"h-9 text-xs",children:a(Xe,{})}),g(tt,{children:[a(be,{value:"authorization_code",children:"Authorization Code"}),a(be,{value:"client_credentials",children:"Client Credentials"})]})]})]}),g("div",{className:"space-y-1.5",children:[a(fe,{className:"text-xs",children:CT()}),a(re,{className:"h-9 text-xs",value:_,onChange:(T)=>F(T.target.value),placeholder:"Optional Client ID"})]})]}),g("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[g("div",{className:"space-y-1.5",children:[a(fe,{className:"text-xs",children:ST()}),a(re,{className:"h-9 text-xs",type:"password",value:D,onChange:(T)=>A(T.target.value),placeholder:"Optional Secret"})]}),g("div",{className:"space-y-1.5",children:[a(fe,{className:"text-xs",children:TT()}),a(re,{className:"h-9 text-xs",value:Y,onChange:(T)=>K(T.target.value),placeholder:"Optional scope"})]})]})]})]}),g("div",{className:"space-y-3 pt-3 border-t border-border",children:[g("div",{className:"space-y-2.5",children:[g(fe,{className:"text-xs font-semibold flex items-center gap-1.5",children:[a(cs,{className:"w-3.5 h-3.5"}),ZT()," (",J.length,")"]}),a("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:UT()}),J.length>0&&g("div",{className:"flex items-center gap-1.5 pt-0.5",children:[a(N,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>z("off"),disabled:Le.isPending||ve,children:ET()}),a(N,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>z("on"),disabled:Le.isPending||ve,children:xT()}),a(N,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>z("direct"),disabled:Le.isPending||ve,children:wT()})]})]}),a("div",{className:"space-y-2",children:ve?a("div",{className:"flex justify-center py-8",children:a(V,{className:"w-6 h-6 animate-spin text-primary"})}):J.length===0?a("div",{className:"text-center py-6 text-muted-foreground text-xs",children:G1()}):J.map((T)=>{let ne=te(T.name),de=!!ie[T.name],ze=T.inputSchema,Bt=ze?.properties&&Object.keys(ze.properties).length>0;return g("div",{className:`border border-border rounded-lg p-3 transition-colors ${ne!=="off"?"bg-card":"bg-muted/30 opacity-70"}`,children:[g("div",{className:"flex items-start justify-between gap-3",children:[g("div",{className:"flex items-start gap-2 flex-1 min-w-0 cursor-pointer",onClick:()=>Bt&&Te(T.name),children:[Bt?de?a(Be,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}):a(qt,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}):a("div",{className:"w-4 h-4 shrink-0"}),g("div",{className:"min-w-0 flex-1",children:[g("div",{className:"flex items-center gap-2 flex-wrap",children:[a("span",{className:"font-mono text-xs font-bold text-foreground break-all",children:T.name}),T.title&&a(ge,{variant:"outline",className:"text-[10px]",children:T.title})]}),T.description&&a("p",{className:"text-xs text-muted-foreground mt-1 break-words line-clamp-3",children:T.description})]})]}),a("div",{className:"flex items-center gap-2 shrink-0",children:g(ds,{type:"single",value:ne,onValueChange:(jt)=>{if(jt)Pe(T.name,jt)},size:"sm",variant:"outline",disabled:Le.isPending||ve,children:[a(Ur,{value:"off",className:"text-[11px] px-2 h-7",children:FT()}),a(Ur,{value:"on",className:"text-[11px] px-2 h-7",children:LT()}),a(Ur,{value:"direct",className:"text-[11px] px-2 h-7",children:NT()})]})})]}),de&&Bt&&g("div",{className:"mt-3 pt-3 border-t border-border/60 pl-6 space-y-2",children:[a("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:FP()}),a("div",{className:"grid grid-cols-1 gap-1.5",children:Object.entries(ze.properties).map(([jt,wa])=>{let Ws=ze.required?.includes(jt);return g("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:[g("div",{className:"flex items-center gap-1.5 flex-wrap min-w-0",children:[a("span",{className:"font-mono font-semibold break-all",children:jt}),Ws&&a("span",{className:"text-[10px] text-red-500 font-bold",children:"*"}),a(ge,{variant:"secondary",className:"text-[9px] px-1 py-0",children:wa.type||"any"})]}),wa.description&&a("span",{className:"text-[11px] text-muted-foreground break-words sm:max-w-[320px]",children:wa.description})]},jt)})})]})]},T.name)})})]})]})}),g(ot,{className:"p-6 pt-4 border-t border-border flex-shrink-0",children:[g(N,{type:"button",variant:"outline",onClick:()=>Le.mutate(),disabled:Le.isPending||ve||E.isPending,className:"gap-1.5 mr-auto",children:[a(la,{className:`w-4 h-4 ${Le.isPending?"animate-spin":""}`}),wy()]}),a(N,{type:"button",variant:"outline",onClick:r,children:Ge()}),g(N,{type:"submit",disabled:E.isPending||!l,children:[E.isPending&&a(V,{className:"w-4 h-4 mr-2 animate-spin"}),zi()]})]})]})]}):g(xe,{className:"sm:max-w-md",children:[g(ke,{children:[g(Ce,{className:"flex items-center gap-2 text-xl font-bold",children:[a(oo,{className:"w-5 h-5 text-primary"}),ph()]}),a(Nt,{children:$p()})]}),g("form",{onSubmit:Z,className:"space-y-4",children:[g("div",{className:"space-y-2",children:[a(fe,{className:"text-xs font-semibold",children:xy()}),a(re,{value:l,onChange:(T)=>u(T.target.value),placeholder:"https://mcp.example.com/mcp",type:"url",required:!0}),g("p",{className:"text-[11px] text-muted-foreground flex items-center gap-1.5",children:[a(eo,{className:"w-3.5 h-3.5"}),Ey()]})]}),g(ot,{children:[a(N,{type:"button",variant:"outline",onClick:r,children:Ge()}),g(N,{type:"submit",disabled:E.isPending||!l,children:[E.isPending&&a(V,{className:"w-4 h-4 mr-2 animate-spin"}),Fd()]})]})]})]})})};var Es=({teamId:e})=>{let r=ae(),{canAdmin:t}=er(),[i,s]=w(!1),[n,l]=w(null),[u,h]=w(null),[m,f]=w(null),{data:v,isLoading:d}=ee({queryKey:["teams",e,"mcp","servers"],queryFn:async()=>{let A=await R.api.teams[":teamId"].mcp.servers.$get({param:{teamId:e}});if(!A.ok)throw Error(as());return await A.json()}}),o=X({mutationFn:async(A)=>{if(!(await R.api.mcp.servers[":id"].$delete({param:{id:A}})).ok)throw Error(Yl())},onSuccess:()=>{B.success(Dt()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]}),h(null)},onError:(A)=>{B.error(A.message)}}),b=X({mutationFn:async({id:A,permission:Y})=>{if(!(await R.api.mcp.servers[":id"].permission.$patch({param:{id:A},json:{permission:Y}})).ok)throw Error(nu())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},onError:(A)=>{B.error(A.message)}}),p=X({mutationFn:async(A)=>{if(!(await R.api.mcp.servers[":id"].auth.$delete({param:{id:A}})).ok)throw Error("Failed to disconnect auth")},onSuccess:()=>{B.success(by()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},onError:(A)=>{B.error(A.message)}}),_=async(A)=>{f(A);try{let Y=await R.api.mcp.servers[":id"].auth.start.$post({param:{id:A}});if(!Y.ok){let C=await Y.json().catch(()=>({}));throw Error(C.error||Hh())}let K=await Y.json();if(K.status==="authenticated"){B.success(yy()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]}),f(null);return}if(K.authorizationUrl){let I=window.screenX+(window.outerWidth-600)/2,P=window.screenY+(window.outerHeight-700)/2,y=window.open(K.authorizationUrl,"mcp_oauth_popup",`width=600,height=700,left=${I},top=${P},scrollbars=yes`),O=(oe)=>{if(oe.data?.type==="mcp-oauth-callback")if(window.removeEventListener("message",O),f(null),oe.data.ok)B.success(yy()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]});else B.error(oe.data.message||Hh())};window.addEventListener("message",O);let ie=setInterval(()=>{if(!y||y.closed)clearInterval(ie),window.removeEventListener("message",O),f(null),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},1000)}}catch(Y){B.error(Y instanceof Error?Y.message:Hh()),f(null)}},F=v?.servers||[],D=(A)=>{switch(A.status){case"connected":return g(ge,{variant:"secondary",className:"gap-1 bg-emerald-500/10 text-emerald-600 border-emerald-500/20 text-[10px]",children:[a(Ar,{className:"w-3 h-3"}),OT()]});case"needs_auth":return g(ge,{variant:"secondary",className:"gap-1 bg-amber-500/10 text-amber-600 border-amber-500/20 text-[10px]",children:[a(Hi,{className:"w-3 h-3"}),Cy()]});case"failed":return g(ge,{variant:"secondary",className:"gap-1 bg-red-500/10 text-red-600 border-red-500/20 text-[10px]",children:[a(Wt,{className:"w-3 h-3"}),PT()]});default:return g(ge,{variant:"outline",className:"gap-1 text-[10px]",children:[a(dr,{className:"w-3 h-3 text-muted-foreground"}),DT()]})}};return g(st,{children:[g(Ct,{className:"flex flex-row items-center justify-between space-y-0 pb-7",children:[g("div",{className:"flex items-center gap-3",children:[a("div",{className:"p-2 bg-primary/10 text-primary rounded-lg",children:a(oo,{className:"w-6 h-6"})}),g("div",{children:[a(St,{className:"text-xl font-bold",children:zd()}),a(Zt,{children:$p()})]})]}),t&&g(N,{onClick:()=>s(!0),className:"gap-2",children:[a(Re,{className:"w-4 h-4"})," ",ph()]})]}),a(_t,{children:d?a("div",{className:"flex justify-center py-10",children:a(V,{className:"w-8 h-8 animate-spin text-primary"})}):F.length===0?g("div",{className:"text-center py-12 border-2 border-dashed border-border rounded-xl",children:[a("div",{className:"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4 text-muted-foreground",children:a(oo,{className:"w-6 h-6"})}),a("h3",{className:"text-base font-semibold",children:zy()}),a("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm mx-auto",children:Mv()}),t&&g(N,{onClick:()=>s(!0),className:"mt-4 gap-2",variant:"outline",children:[a(Re,{className:"w-4 h-4"})," ",ph()]})]}):a("div",{className:"space-y-4",children:F.map((A)=>{let Y=m===A.id,K=A.status==="needs_auth"||!A.hasCredential&&A.authType!=="none";return g("div",{onClick:()=>t&&l(A),className:`p-4 bg-card rounded-xl border border-border flex flex-col justify-between hover:shadow-md transition-all group ${t?"cursor-pointer":""}`,children:[g("div",{className:"flex items-start justify-between gap-2 mb-2",children:[g("h4",{className:"font-bold text-foreground flex items-center gap-2 min-w-0",children:[a(oo,{className:"w-4 h-4 text-muted-foreground shrink-0"}),a("span",{className:"truncate",children:A.name}),a(ge,{variant:"outline",className:"text-[10px] uppercase shrink-0",children:A.transport})]}),t&&g(De,{modal:!1,children:[a(Ne,{asChild:!0,onClick:(C)=>C.stopPropagation(),children:a(N,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:a(Wr,{className:"w-4 h-4"})})}),g(Fe,{align:"end",children:[A.status!=="connected"&&(A.authType!=="none"||A.hasCredential)?g(se,{onClick:(C)=>{C.stopPropagation(),_(A.id)},children:[a(Hi,{className:"w-4 h-4 mr-2"}),vy()]}):null,A.hasCredential&&g(se,{onClick:(C)=>{C.stopPropagation(),p.mutate(A.id)},className:"text-amber-600",children:[a(Iu,{className:"w-4 h-4 mr-2"}),by()]}),(A.status!=="connected"&&(A.authType!=="none"||A.hasCredential)||A.hasCredential)&&a(rr,{}),g(se,{onClick:(C)=>{C.stopPropagation(),h(A)},className:"text-red-600",children:[a(Ue,{className:"w-4 h-4 mr-2"}),Dt()]})]})]})]}),g("div",{className:"space-y-1",children:[a("p",{className:"text-sm text-muted-foreground line-clamp-2",children:A.description||Zy()}),a("p",{className:"font-mono text-[10px] text-muted-foreground/70 truncate",children:A.url}),A.lastError&&a("p",{className:"text-[10px] text-red-500/90 truncate font-mono",children:A.lastError})]}),g("div",{className:"mt-4 flex items-center justify-between gap-2 pt-2 border-t border-border/50 text-xs",children:[g("div",{className:"flex items-center gap-2 min-w-0",children:[D(A),g(ge,{variant:"outline",className:"text-[10px] gap-1 shrink-0",children:[a(cs,{className:"w-3 h-3 text-muted-foreground"}),BT({count:A.toolCount})]}),g("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider font-semibold whitespace-nowrap",children:[sv()," ",new Date(A.updatedAt).toLocaleDateString()]})]}),g("div",{className:"flex items-center gap-2 shrink-0",onClick:(C)=>C.stopPropagation(),children:[t?g(Ye,{value:A.permission,onValueChange:(C)=>b.mutate({id:A.id,permission:C}),children:[a(et,{className:"h-7 text-xs px-2 bg-background border-border w-[130px]",children:a(Xe,{})}),g(tt,{align:"end",children:[a(be,{value:"reviewer",children:tc()}),a(be,{value:"editor",children:rc()}),a(be,{value:"owner",children:nc()})]})]}):a(ge,{variant:"outline",className:"text-[10px]",children:A.permission==="reviewer"?tc():A.permission==="editor"?rc():nc()}),K&&t&&g(N,{size:"sm",variant:"default",onClick:(C)=>{C.stopPropagation(),_(A.id)},disabled:Y,className:"gap-1.5 bg-amber-600 hover:bg-amber-700 text-white text-xs",children:[Y?a(V,{className:"w-3.5 h-3.5 animate-spin"}):a(Hi,{className:"w-3.5 h-3.5"}),vy()]})]})]})]},A.id)})})}),a(Ts,{isOpen:i||!!n,onClose:()=>{s(!1),l(null)},teamId:e,server:n}),a(ct,{open:!!u,onOpenChange:(A)=>!A&&h(null),children:g(ut,{children:[g(dt,{children:[a(pt,{children:Xx()}),a(mt,{children:eC({name:u?.name||""})})]}),g(ft,{children:[a(gt,{children:Ge()}),g(ht,{onClick:()=>u&&o.mutate(u.id),className:"bg-red-600 hover:bg-red-700 text-white",children:[o.isPending&&a(V,{className:"w-4 h-4 mr-2 animate-spin"}),Dt()]})]})]})})]})};function Vs({teamId:e}){let r=ae(),{data:t,isLoading:i}=ee({queryKey:["teams",e,"notification-settings"],queryFn:async()=>{let u=await R.api.teams[":teamId"].notifications.settings.$get({param:{teamId:e}});if(!u.ok)throw Error(as());return await u.json()}}),{mutate:s,isPending:n}=X({mutationFn:async(u)=>{let h=await R.api.teams[":teamId"].notifications.settings.$post({param:{teamId:e},json:u});if(!h.ok)throw Error(ny());return await h.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"notification-settings"]}),r.invalidateQueries({queryKey:["teams",e,"notifications"]}),B.success(Y1())},onError:(u)=>{B.error(u instanceof Error?u.message:ny())}}),l=(u)=>{if(!t)return;let h={...t,[u]:!t[u]};s(h)};if(i)return a("div",{className:"flex items-center justify-center p-8",children:a(V,{className:"h-8 w-8 animate-spin text-muted-foreground"})});return a(Ie,{className:"h-full",children:g("div",{className:"space-y-6 pr-4 pb-8",children:[g(st,{className:"overflow-hidden gap-0 py-0",children:[g(Ct,{className:"border-b border-border bg-muted/30 py-5",children:[g("div",{className:"flex items-center gap-2",children:[a(rs,{className:"w-5 h-5 text-primary"}),a(St,{className:"text-lg",children:FE()})]}),a(Zt,{children:LE()})]}),g(_t,{className:"divide-y divide-border p-0",children:[g("div",{className:"flex items-center justify-between p-6",children:[g("div",{className:"flex gap-4",children:[a("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:a(rs,{className:"w-4 h-4"})}),g("div",{className:"space-y-0.5",children:[a("h4",{className:"text-sm font-semibold text-foreground",children:YS()}),a("p",{className:"text-sm text-muted-foreground",children:TD()})]})]}),a(Ve,{checked:t?.comments??!0,onCheckedChange:()=>l("comments"),disabled:n})]}),g("div",{className:"flex items-center justify-between p-6",children:[g("div",{className:"flex gap-4",children:[a("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:a(Wa,{className:"w-4 h-4"})}),g("div",{className:"space-y-0.5",children:[a("h4",{className:"text-sm font-semibold text-foreground",children:NE()}),a("p",{className:"text-sm text-muted-foreground",children:RD()})]})]}),a(Ve,{checked:t?.replies??!0,onCheckedChange:()=>l("replies"),disabled:n})]}),g("div",{className:"flex items-center justify-between p-6",children:[g("div",{className:"flex gap-4",children:[a("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:a(Ua,{className:"w-4 h-4"})}),g("div",{className:"space-y-0.5",children:[a("h4",{className:"text-sm font-semibold text-foreground",children:Nw()}),a("p",{className:"text-sm text-muted-foreground",children:kD()})]})]}),a(Ve,{checked:t?.mentions??!0,onCheckedChange:()=>l("mentions"),disabled:n})]})]})]}),g(st,{className:"overflow-hidden gap-0 py-0",children:[g(Ct,{className:"border-b border-border bg-muted/30 py-5",children:[g("div",{className:"flex items-center gap-2",children:[a(Eo,{className:"w-5 h-5 text-primary"}),a(St,{className:"text-lg",children:Pw()})]}),a(Zt,{children:Dw()})]}),g(_t,{className:"divide-y divide-border p-0",children:[g("div",{className:"flex items-center justify-between p-6",children:[g("div",{className:"flex gap-4",children:[a("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:a(bl,{className:"w-4 h-4"})}),g("div",{className:"space-y-0.5",children:[a("h4",{className:"text-sm font-semibold text-foreground",children:PD()}),a("p",{className:"text-sm text-muted-foreground",children:MD()})]})]}),a(Ve,{checked:t?.yourUploads??!1,onCheckedChange:()=>l("yourUploads"),disabled:n})]}),g("div",{className:"flex items-center justify-between p-6",children:[g("div",{className:"flex gap-4",children:[a("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:a(Eo,{className:"w-4 h-4"})}),g("div",{className:"space-y-0.5",children:[a("h4",{className:"text-sm font-semibold text-foreground",children:vk()}),a("p",{className:"text-sm text-muted-foreground",children:SD()})]})]}),a(Ve,{checked:t?.otherUploads??!0,onCheckedChange:()=>l("otherUploads"),disabled:n})]}),g("div",{className:"flex items-center justify-between p-6",children:[g("div",{className:"flex gap-4",children:[a("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:a($i,{className:"w-4 h-4"})}),g("div",{className:"space-y-0.5",children:[a("h4",{className:"text-sm font-semibold text-foreground",children:OO()}),a("p",{className:"text-sm text-muted-foreground",children:ID()})]})]}),a(Ve,{checked:t?.statusUpdates??!0,onCheckedChange:()=>l("statusUpdates"),disabled:n})]})]})]}),g(st,{className:"overflow-hidden gap-0 py-0",children:[g(Ct,{className:"border-b border-border bg-muted/30 py-5",children:[g("div",{className:"flex items-center gap-2",children:[a(Na,{className:"w-5 h-5 text-primary"}),a(St,{className:"text-lg",children:KI()})]}),a(Zt,{children:VI()})]}),g(_t,{className:"divide-y divide-border p-0",children:[g("div",{className:"flex items-center justify-between p-6",children:[g("div",{className:"flex gap-4",children:[a("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:a(Na,{className:"w-4 h-4"})}),g("div",{className:"space-y-0.5",children:[a("h4",{className:"text-sm font-semibold text-foreground",children:WI()}),a("p",{className:"text-sm text-muted-foreground",children:CD()})]})]}),a(Ve,{checked:t?.kanbanTasks??!0,onCheckedChange:()=>l("kanbanTasks"),disabled:n})]}),g("div",{className:"flex items-center justify-between p-6",children:[g("div",{className:"flex gap-4",children:[a("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:a(rs,{className:"w-4 h-4"})}),g("div",{className:"space-y-0.5",children:[a("h4",{className:"text-sm font-semibold text-foreground",children:GI()}),a("p",{className:"text-sm text-muted-foreground",children:xD()})]})]}),a(Ve,{checked:t?.kanbanComments??!0,onCheckedChange:()=>l("kanbanComments"),disabled:n})]})]})]})]})})}L();function Ls({teamId:e}){let r=ae(),[t,i]=w(""),[s,n]=w(null),[l,u]=w(!1),{data:h,isLoading:m}=ee({queryKey:["teams",e,"api-tokens"],queryFn:async()=>{let p=await R.api.teams[":teamId"]["api-tokens"].$get({param:{teamId:e}});if(!p.ok)throw Error("Failed to fetch API tokens");return await p.json()}}),{mutate:f,isPending:v}=X({mutationFn:async(p)=>{let _=await R.api.teams[":teamId"]["api-tokens"].$post({param:{teamId:e},json:{name:p}});if(!_.ok)throw Error("Failed to create API token");return await _.json()},onSuccess:(p)=>{r.invalidateQueries({queryKey:["teams",e,"api-tokens"]}),i(""),u(!1),n(p),B.success(uw())},onError:(p)=>{B.error(p instanceof Error?p.message:cS())}}),{mutate:d}=X({mutationFn:async(p)=>{let _=await R.api.teams[":teamId"]["api-tokens"][":tokenId"].$delete({param:{teamId:e,tokenId:p}});if(!_.ok)throw Error("Failed to delete API token");return await _.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"api-tokens"]}),B.success(fw())},onError:(p)=>{B.error(p instanceof Error?p.message:gS())}}),o=(p)=>{if(p.preventDefault(),!t.trim())return;f(t.trim())},b=async(p)=>{await ko(p),u(!0),B.success(VE()),setTimeout(()=>u(!1),2000)};if(m)return a("div",{className:"flex justify-center items-center p-8",children:a(V,{className:"w-8 h-8 animate-spin text-muted-foreground"})});return g("div",{className:"space-y-6",children:[g(st,{children:[g(Ct,{children:[a(St,{children:y_()}),a(Zt,{children:pw()})]}),g(_t,{className:"space-y-6",children:[g("form",{onSubmit:o,className:"flex gap-4 items-end max-w-md",children:[g("div",{className:"flex-1 space-y-2",children:[a("label",{htmlFor:"tokenName",className:"text-sm font-medium text-muted-foreground",children:PP()}),a(re,{id:"tokenName",value:t,onChange:(p)=>i(p.target.value),placeholder:DP(),required:!0})]}),g(N,{type:"submit",disabled:v||!t.trim(),children:[v?a(V,{className:"w-4 h-4 animate-spin mr-2"}):a(Re,{className:"w-4 h-4 mr-2"}),eI()]})]}),a("div",{className:"border rounded-lg overflow-hidden",children:g(zn,{children:[a(jn,{children:g(Rr,{children:[a(bt,{children:su()}),a(bt,{children:ev()}),a(bt,{children:Rp()}),a(bt,{className:"w-[100px] text-right",children:dh()})]})}),a(qn,{children:!h||h.length===0?a(Rr,{children:a(yt,{colSpan:4,className:"text-center py-6 text-muted-foreground text-sm",children:S1()})}):h.map((p)=>g(Rr,{children:[a(yt,{className:"font-medium",children:p.name}),g(yt,{className:"font-mono text-sm text-muted-foreground",children:["…",p.tokenHint]}),a(yt,{className:"text-muted-foreground",children:new Date(p.createdAt).toLocaleDateString()}),a(yt,{className:"text-right",children:a(N,{variant:"ghost",size:"icon",className:"h-8 w-8 text-red-500 hover:text-red-600 hover:bg-red-50",onClick:()=>d(p.id),children:a(Ue,{className:"h-4 w-4"})})})]},p.id))})]})}),a("p",{className:"text-xs text-muted-foreground",children:dw()})]})]}),a(Se,{open:s!==null,onOpenChange:(p)=>{if(!p)n(null)},children:g(xe,{children:[g(ke,{children:[a(Ce,{children:cw()}),a(Nt,{children:lw()})]}),s&&g("div",{className:"flex items-center gap-2",children:[a(re,{readOnly:!0,value:s.token,"aria-label":ev(),className:"font-mono text-sm",onFocus:(p)=>p.currentTarget.select()}),a(N,{variant:"outline",size:"icon","aria-label":tu(),onClick:()=>b(s.token),children:l?a(qe,{className:"h-4 w-4"}):a(zr,{className:"h-4 w-4"})})]}),a(ot,{children:a(N,{onClick:()=>n(null),children:j_()})})]})})]})}L();L();var Qr=[{value:"read_asset",label:()=>a_()},{value:"list_assets",label:()=>s_()},{value:"create_folder",label:()=>e_()},{value:"create_file",label:()=>XA()},{value:"create_version",label:()=>t_()},{value:"generate_image",label:()=>n_()},{value:"generate_video",label:()=>o_()},{value:"rename_asset",label:()=>l_()},{value:"move_assets",label:()=>i_()},{value:"delete_asset",label:()=>r_()},{value:"search_assets",label:()=>c_()},{value:"copy_assets",label:()=>JA()},{value:"create_comment",label:()=>YA()},{value:"update_asset_metadata",label:()=>u_()}],Ka={agent_total_tokens:{label:()=>rm(),icon:no,unit:"tokens",defaultLimit:1e5},agent_cost:{label:()=>Xp(),icon:_l,unit:"$",defaultLimit:10},agent_mcp_call_count:{label:()=>em(),icon:oo,unit:"calls",defaultLimit:100},agent_bash_call_count:{label:()=>Yp(),icon:us,unit:"calls",defaultLimit:50},agent_tool_call_count:{label:()=>tm(),icon:cs,unit:"calls",defaultLimit:100}},Ps=({open:e,onOpenChange:r,teamId:t,rule:i,onSuccess:s})=>{let n=ae(),l=!!i,[u,h]=w("each_member"),[m,f]=w("team"),[v,d]=w([]),[o,b]=w("agent_total_tokens"),[p,_]=w(""),[F,D]=w("*"),[A,Y]=w("read_asset"),[K,C]=w(1e5),[k,I]=w("1day"),[P,y]=w(!0),[O,ie]=w(!1),[oe,me]=w(""),{data:ue=[]}=ee({queryKey:["teams",t,"members"],queryFn:async()=>{let z=await R.api.teams[":teamId"].members.$get({param:{teamId:t},query:{}});if(!z.ok)return[];return await z.json()},enabled:e}),{data:H}=ee({queryKey:["teams",t,"mcp","servers"],queryFn:async()=>{let z=await R.api.teams[":teamId"].mcp.servers.$get({param:{teamId:t}});if(!z.ok)return{servers:[]};return await z.json()},enabled:e&&o==="agent_mcp_call_count"}),le=H?.servers||[];S(()=>{if(i){h(i.scopeMode),f(i.role||"team"),d(i.userIds||[]),b(i.resource);let z=i.resourceData||{};_(typeof z.id==="string"?z.id:""),D(typeof z.match==="string"?z.match:"*"),Y(typeof z.name==="string"?z.name:typeof z.toolName==="string"?z.toolName:"read_asset"),C(i.limit),I(rf(i.period)),y(i.enabled)}else h("each_member"),f("team"),d([]),b("agent_total_tokens"),_(""),D("*"),Y("read_asset"),C(Ka.agent_total_tokens.defaultLimit),I("1day"),y(!0)},[i,e]);let ve=(z)=>{if(b(z),!l)C(Ka[z]?.defaultLimit||100)},Ae=X({mutationFn:async()=>{let z={};if(o==="agent_mcp_call_count")z.id=p;else if(o==="agent_bash_call_count")z.match=F.trim()||"*";else if(o==="agent_tool_call_count")z.name=A||"read_asset";let Te=await R.api.teams[":teamId"].quotas.$post({param:{teamId:t},json:{scopeMode:u,role:u!=="selected_members"&&m!=="team"?m:null,userIds:u==="selected_members"?v:null,resource:o,resourceData:Object.keys(z).length>0?z:null,limit:Number(K),period:k,enabled:P}});if(!Te.ok){let T=await Te.json().catch(()=>({}));throw Error(T?.message||Y_())}return await Te.json()},onSuccess:()=>{n.invalidateQueries({queryKey:["teams",t,"quotas"]}),B.success(gR()),r(!1),s?.()},onError:(z)=>{console.error("CREATE MUTATION ERROR:",z),B.error(z instanceof Error?z.message:Y_())}}),Le=X({mutationFn:async()=>{if(!i)return;let z={};if(o==="agent_mcp_call_count")z.id=p;else if(o==="agent_bash_call_count")z.match=F.trim()||"*";else if(o==="agent_tool_call_count")z.name=A||"read_asset";let Te=await R.api.teams[":teamId"].quotas[":id"].$put({param:{teamId:t,id:i.id},json:{scopeMode:u,role:u!=="selected_members"&&m!=="team"?m:null,userIds:u==="selected_members"?v:null,resource:o,resourceData:Object.keys(z).length>0?z:null,limit:Number(K),period:k,enabled:P}});if(!Te.ok){let T=await Te.json().catch(()=>({}));throw Error(T?.message||Zp())}return await Te.json()},onSuccess:()=>{n.invalidateQueries({queryKey:["teams",t,"quotas"]}),B.success(zR()),r(!1),s?.()},onError:(z)=>{B.error(z instanceof Error?z.message:Zp())}}),E=X({mutationFn:async()=>{if(!i)return;if(!(await R.api.teams[":teamId"].quotas[":id"].$delete({param:{teamId:t,id:i.id}})).ok)throw Error(Lp())},onSuccess:()=>{n.invalidateQueries({queryKey:["teams",t,"quotas"]}),B.success(p0()),ie(!1),r(!1),s?.()},onError:(z)=>{B.error(z instanceof Error?z.message:Lp())}}),Z=(z)=>{if(z.preventDefault(),u==="selected_members"&&v.length===0){B.error(UM());return}if(o==="agent_mcp_call_count"&&!p.trim()){B.error(K_());return}if(K<=0){B.error("Limit must be greater than 0");return}if(l)Le.mutate();else Ae.mutate()},J=Ae.isPending||Le.isPending||E.isPending,te=ue.filter((z)=>{if(!oe.trim())return!0;let Te=oe.toLowerCase();return z.name.toLowerCase().includes(Te)||z.email&&z.email.toLowerCase().includes(Te)}),Pe=(z)=>{d((Te)=>Te.includes(z)?Te.filter((T)=>T!==z):[...Te,z])};return g(W,{children:[a(Se,{open:e,onOpenChange:r,children:g(xe,{className:"sm:max-w-[540px] max-h-[90vh] flex flex-col p-0 overflow-hidden",children:[g(ke,{className:"p-6 pb-4 border-b border-border/60 shrink-0",children:[a(Ce,{className:"text-xl font-bold",children:l?EC():kx()}),a(Nt,{className:"text-sm text-muted-foreground",children:l?xC():Rx()})]}),g("form",{onSubmit:Z,noValidate:!0,className:"flex-1 overflow-y-auto min-h-0 p-6 space-y-5",children:[g("div",{className:"space-y-2",children:[a(fe,{className:"text-sm font-semibold",children:RR()}),g("div",{className:"grid grid-cols-3 gap-2",children:[g(N,{type:"button",variant:u==="each_member"?"default":"outline",size:"sm",disabled:l||J,onClick:()=>h("each_member"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[a($n,{className:"w-4 h-4"}),a("span",{className:"font-semibold",children:om()})]}),g(N,{type:"button",variant:u==="all_members"?"default":"outline",size:"sm",disabled:l||J,onClick:()=>h("all_members"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[a($o,{className:"w-4 h-4"}),a("span",{className:"font-semibold",children:nm()})]}),g(N,{type:"button",variant:u==="selected_members"?"default":"outline",size:"sm",disabled:l||J,onClick:()=>h("selected_members"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[a(Zs,{className:"w-4 h-4"}),a("span",{className:"font-semibold",children:sm()})]})]}),g("p",{className:"text-xs text-muted-foreground pt-0.5",children:[u==="each_member"&&OR(),u==="all_members"&&MR(),u==="selected_members"&&PR()]})]}),u!=="selected_members"?g("div",{className:"space-y-2",children:[a(fe,{htmlFor:"quota-role-scope",className:"text-sm font-semibold",children:kR()}),g(Ye,{value:m,onValueChange:f,disabled:l||J,children:[a(et,{id:"quota-role-scope",className:"w-full",children:a(Xe,{})}),g(tt,{children:[a(be,{value:"team",children:du()}),g(be,{value:"owner",children:[hg(),": Owner"]}),g(be,{value:"editor",children:[hg(),": Editor"]}),g(be,{value:"reviewer",children:[hg(),": Reviewer"]})]})]})]}):g("div",{className:"space-y-2",children:[a(fe,{className:"text-sm font-semibold",children:M0()}),g(wt,{children:[a(Et,{asChild:!0,children:g(N,{variant:"outline",role:"combobox",disabled:J,className:"w-full justify-between text-left font-normal h-10",children:[a("span",{className:"truncate",children:v.length===0?M0():DR({count:v.length})}),a(Be,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),a(xt,{className:"w-[320px] p-2",align:"start",children:g("div",{className:"space-y-2",children:[g("div",{className:"relative",children:[a(or,{className:"w-3.5 h-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),a(re,{placeholder:gg(),value:oe,onChange:(z)=>me(z.target.value),className:"h-8 pl-8 text-xs"})]}),a(Ie,{className:"h-48",children:a("div",{className:"space-y-1 pr-2",children:te.map((z)=>{let Te=v.includes(z.id);return g("div",{onClick:()=>Pe(z.id),className:"flex items-center gap-2 p-1.5 rounded-lg hover:bg-muted/60 cursor-pointer text-xs",children:[a(Ir,{checked:Te,onCheckedChange:()=>Pe(z.id)}),g($e,{className:"w-5 h-5",children:[a(He,{src:z.image||void 0}),a(Qe,{className:"text-[10px]",children:z.name?.[0]?.toUpperCase()||"U"})]}),g("div",{className:"truncate flex-1",children:[a("span",{className:"font-medium text-foreground block truncate",children:z.name}),z.email&&a("span",{className:"text-[10px] text-muted-foreground block truncate",children:z.email})]})]},z.id)})})})]})})]})]}),g("div",{className:"space-y-2",children:[a(fe,{htmlFor:"quota-resource",className:"text-sm font-semibold",children:IR()}),g(Ye,{value:o,onValueChange:(z)=>ve(z),disabled:l||J,children:[a(et,{id:"quota-resource",className:"w-full",children:a(Xe,{})}),g(tt,{children:[a(be,{value:"agent_total_tokens",children:g("div",{className:"flex items-center gap-2",children:[a(no,{className:"w-4 h-4 text-primary"}),a("span",{children:rm()})]})}),a(be,{value:"agent_cost",children:g("div",{className:"flex items-center gap-2",children:[a(_l,{className:"w-4 h-4 text-emerald-500"}),a("span",{children:Xp()})]})}),a(be,{value:"agent_mcp_call_count",children:g("div",{className:"flex items-center gap-2",children:[a(oo,{className:"w-4 h-4 text-blue-500"}),a("span",{children:em()})]})}),a(be,{value:"agent_bash_call_count",children:g("div",{className:"flex items-center gap-2",children:[a(us,{className:"w-4 h-4 text-purple-500"}),a("span",{children:Yp()})]})}),a(be,{value:"agent_tool_call_count",children:g("div",{className:"flex items-center gap-2",children:[a(cs,{className:"w-4 h-4 text-cyan-500"}),a("span",{children:tm()})]})})]})]})]}),o==="agent_mcp_call_count"&&g("div",{className:"space-y-2",children:[a(fe,{htmlFor:"quota-mcp",className:"text-sm font-semibold",children:R0()}),le.length>0?g(Ye,{value:p,onValueChange:_,disabled:l||J,children:[a(et,{id:"quota-mcp",className:"w-full",children:a(Xe,{placeholder:R0()})}),a(tt,{children:le.map((z)=>g(be,{value:z.id,children:[z.name," (",z.id,")"]},z.id))})]}):a(re,{id:"quota-mcp",value:p,onChange:(z)=>_(z.target.value),placeholder:K_(),disabled:l||J})]}),o==="agent_bash_call_count"&&g("div",{className:"space-y-1.5",children:[a(fe,{htmlFor:"quota-bash",className:"text-sm font-semibold",children:mE()}),a(re,{id:"quota-bash",value:F,onChange:(z)=>D(z.target.value),placeholder:hE(),disabled:J}),a("p",{className:"text-xs text-muted-foreground",children:mR()})]}),o==="agent_tool_call_count"&&g("div",{className:"space-y-2",children:[a(fe,{htmlFor:"quota-tool",className:"text-sm font-semibold",children:P0()}),g(Ye,{value:A,onValueChange:Y,disabled:l||J,children:[a(et,{id:"quota-tool",className:"w-full",children:a(Xe,{placeholder:P0()})}),a(tt,{children:Qr.map((z)=>a(be,{value:z.value,children:z.label()},z.value))})]}),a("p",{className:"text-xs text-muted-foreground",children:UR()})]}),g("div",{className:"grid grid-cols-2 gap-4",children:[g("div",{className:"space-y-2",children:[g(fe,{htmlFor:"quota-limit",className:"text-sm font-semibold",children:[vR()," (",Ka[o]?.unit||"",")"]}),a(re,{id:"quota-limit",type:"number",min:"0.01",step:o==="agent_cost"?"0.01":"1",value:K,onChange:(z)=>C(Number(z.target.value)),placeholder:bR(),disabled:J,required:!0})]}),g("div",{className:"space-y-2",children:[a(fe,{htmlFor:"quota-period",className:"text-sm font-semibold",children:ER()}),g(Ye,{value:k,onValueChange:(z)=>I(z),disabled:J,children:[a(et,{id:"quota-period",className:"w-full",children:a(Xe,{})}),g(tt,{children:[a(be,{value:"1hour",children:g("div",{className:"flex items-center gap-2",children:[a(dr,{className:"w-3.5 h-3.5 text-muted-foreground"}),a("span",{children:fg()})]})}),a(be,{value:"5hour",children:g("div",{className:"flex items-center gap-2",children:[a(dr,{className:"w-3.5 h-3.5 text-muted-foreground"}),a("span",{children:pg()})]})}),a(be,{value:"1day",children:g("div",{className:"flex items-center gap-2",children:[a(dr,{className:"w-3.5 h-3.5 text-muted-foreground"}),a("span",{children:dg()})]})}),a(be,{value:"7day",children:g("div",{className:"flex items-center gap-2",children:[a(dr,{className:"w-3.5 h-3.5 text-muted-foreground"}),a("span",{children:mg()})]})})]})]})]})]}),g("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/20",children:[g("div",{className:"space-y-0.5",children:[a(fe,{htmlFor:"quota-enabled",className:"text-sm font-medium cursor-pointer",children:P?_R():ug()}),a("p",{className:"text-xs text-muted-foreground",children:P?"Active and enforcing limits":"Inactive, requests will bypass this quota"})]}),a(Ve,{id:"quota-enabled",checked:P,onCheckedChange:y,disabled:J})]}),g(ot,{className:"pt-4 flex items-center justify-between gap-2 sm:justify-between border-t border-border/60",children:[l?g(N,{type:"button",variant:"destructive",size:"sm",onClick:()=>ie(!0),disabled:J,className:"gap-1.5",children:[a(Ue,{className:"w-4 h-4"}),a("span",{children:Ch()})]}):a("div",{}),g("div",{className:"flex items-center gap-2",children:[a(N,{type:"button",variant:"outline",onClick:()=>r(!1),disabled:J,children:Ge()}),g(N,{type:"submit",disabled:J,className:"gap-2",children:[J&&a(V,{className:"w-4 h-4 animate-spin"}),l?mo():Fd()]})]})]})]})]})}),a(ct,{open:O,onOpenChange:ie,children:g(ut,{children:[g(dt,{children:[a(pt,{children:Ch()}),a(mt,{children:z_()})]}),g(ft,{children:[a(gt,{disabled:J,children:Ge()}),g(ht,{onClick:(z)=>{z.preventDefault(),E.mutate()},disabled:J,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[J&&a(V,{className:"w-4 h-4 animate-spin mr-2"}),Dt()]})]})]})})]})};var Rs=({teamId:e})=>{let r=ae(),[t,i]=w(!1),[s,n]=w(null),[l,u]=w(null),{data:h,isLoading:m}=ee({queryKey:["teams",e,"quotas"],queryFn:async()=>{let o=await R.api.teams[":teamId"].quotas.$get({param:{teamId:e}});if(!o.ok)throw Error(as());return await o.json()}}),f=X({mutationFn:async({id:o,enabled:b})=>{let p=await R.api.teams[":teamId"].quotas[":id"].$put({param:{teamId:e,id:o},json:{enabled:b}});if(!p.ok)throw Error(Zp());return await p.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"quotas"]}),B.success(NR())},onError:(o)=>{B.error(o instanceof Error?o.message:Zp())}}),v=X({mutationFn:async(o)=>{if(!(await R.api.teams[":teamId"].quotas[":id"].$delete({param:{teamId:e,id:o}})).ok)throw Error(Lp())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"quotas"]}),B.success(p0()),u(null)},onError:(o)=>{B.error(o instanceof Error?o.message:Lp())}}),d=h?.rules||[];return g(Ie,{className:"h-full",children:[a("div",{className:"space-y-6 pr-4 pb-10",children:g(st,{children:[g(Ct,{className:"flex flex-row items-center justify-between space-y-0 pb-6",children:[g("div",{className:"flex items-center gap-3",children:[a("div",{className:"p-2 bg-primary/10 text-primary rounded-lg",children:a(xs,{className:"w-6 h-6"})}),g("div",{children:[a(St,{className:"text-xl font-bold",children:b0()}),a(Zt,{children:w0()})]})]}),g(N,{onClick:()=>i(!0),className:"gap-2",children:[a(Re,{className:"w-4 h-4"})," ",VA()]})]}),a(_t,{children:m?a("div",{className:"flex justify-center py-12",children:a(V,{className:"w-8 h-8 animate-spin text-primary"})}):d.length===0?g("div",{className:"text-center py-12 border-2 border-dashed border-border rounded-xl",children:[a("div",{className:"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4 text-muted-foreground",children:a(xs,{className:"w-6 h-6"})}),a("h3",{className:"text-base font-semibold text-foreground mb-1",children:tg()}),a("p",{className:"text-sm text-muted-foreground max-w-md mx-auto mb-6",children:eg()}),g(N,{onClick:()=>i(!0),className:"gap-2",children:[a(Re,{className:"w-4 h-4"})," ",VA()]})]}):a("div",{className:"flex flex-col gap-4",children:d.map((o)=>{let b=uc[o.resource],p=o.resourceData||{};return a("div",{onClick:()=>n(o),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 ${!o.enabled?"opacity-60 bg-muted/20":""}`,children:g("div",{className:"space-y-3",children:[g("div",{className:"flex items-start justify-between gap-2",children:[g("div",{children:[a("div",{className:"font-semibold text-base text-foreground group-hover:text-primary transition-colors flex items-center gap-2",children:a("span",{children:b?.label?b.label():o.resource})}),g("div",{className:"text-xs text-muted-foreground line-clamp-1",children:[o.resource==="agent_mcp_call_count"&&g("span",{children:["Server: ",String(p.id||"")]}),o.resource==="agent_bash_call_count"&&g("span",{children:["Match: ",String(p.match||"*")]}),o.resource==="agent_tool_call_count"&&g("span",{children:["Tool: ",String(p.name||p.toolName||"*")]})]})]}),g("div",{className:"flex items-center gap-2",onClick:(_)=>_.stopPropagation(),children:[a(Ve,{checked:o.enabled,onCheckedChange:(_)=>f.mutate({id:o.id,enabled:_}),disabled:f.isPending}),g(De,{modal:!1,children:[a(Ne,{asChild:!0,children:a(N,{variant:"ghost",size:"icon","aria-label":"Quota actions",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:a(Wr,{className:"w-4 h-4"})})}),a(Fe,{align:"end",children:g(se,{onClick:()=>u(o),className:"text-destructive focus:text-destructive",children:[a(Ue,{className:"w-4 h-4 mr-2"}),Dt()]})})]})]})]}),a("div",{className:"flex flex-wrap items-center gap-2 pt-2 border-t border-border/50",children:g("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.scopeMode==="all_members"&&g(ge,{variant:"secondary",className:"gap-1 text-xs",children:[a($o,{className:"w-3 h-3"}),g("span",{children:[nm(),o.role?` (${o.role})`:` (${du()})`]})]}),o.scopeMode==="each_member"&&g(ge,{variant:"secondary",className:"gap-1 text-xs",children:[a($n,{className:"w-3 h-3"}),g("span",{children:[om(),o.role?` (${o.role})`:` (${du()})`]})]}),o.scopeMode==="selected_members"&&g(ge,{variant:"secondary",className:"gap-1 text-xs",children:[a(Zs,{className:"w-3 h-3"}),g("span",{children:[sm()," (",o.userIds?.length||0,")"]})]}),g(ge,{variant:"outline",className:"gap-1 text-xs",children:[a(dr,{className:"w-3 h-3"}),g("span",{children:[ka(o.resource,o.limit)," ",b?.unit," /"," ",xu(o.period)]})]})]})})]})},o.id)})})})]})}),(t||!!s)&&a(Ps,{open:t||!!s,onOpenChange:(o)=>{if(!o)i(!1),n(null)},teamId:e,rule:s}),a(ct,{open:!!l,onOpenChange:(o)=>{if(!o)u(null)},children:g(ut,{children:[g(dt,{children:[a(pt,{children:Ch()}),a(mt,{children:z_()})]}),g(ft,{children:[a(gt,{disabled:v.isPending,children:Ge()}),g(ht,{onClick:(o)=>{if(o.preventDefault(),l)v.mutate(l.id)},disabled:v.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[v.isPending&&a(V,{className:"w-4 h-4 animate-spin mr-2"}),Dt()]})]})]})})]})};function Bs({teamId:e}){let r=ae(),{data:t,isLoading:i}=ee({queryKey:["teams",e,"settings"],queryFn:async()=>{let h=await R.api.teams[":teamId"].settings.$get({param:{teamId:e}});if(!h.ok)throw Error(as());return await h.json()},enabled:!!e}),{mutate:s,isPending:n}=X({mutationFn:async(h)=>{let m=await R.api.teams[":teamId"].settings.$patch({param:{teamId:e},json:{key:"appearance.hideAgent",value:h}});if(!m.ok)throw Error(iy());return await m.json()},onSuccess:async(h,m)=>{if(r.invalidateQueries({queryKey:["teams",e,"settings"]}),await Br.getState().fetchMetadata(e),m)kr.getState().setIsChatbotOpen(!1);B.success(mw())},onError:(h)=>{B.error(h instanceof Error?h.message:iy())}}),l=Boolean(t?.appearance?.hideAgent),u=(h)=>{s(h)};if(i)return a("div",{className:"flex items-center justify-center p-8",children:a(V,{className:"h-6 w-6 animate-spin text-muted-foreground"})});return a("div",{className:"h-full overflow-y-auto pr-1",children:g(st,{children:[g(Ct,{children:[a(St,{children:v_()}),a(Zt,{children:b_()})]}),a(_t,{className:"space-y-6",children:g("div",{className:"flex items-center justify-between space-x-4 rounded-lg border border-border p-4",children:[g("div",{className:"space-y-1",children:[a("label",{htmlFor:"hide-agent-switch",className:"text-sm font-medium leading-none cursor-pointer",children:RI()}),a("p",{className:"text-xs text-muted-foreground",children:MI()})]}),a(Ve,{id:"hide-agent-switch",checked:l,onCheckedChange:u,disabled:n})]})})]})})}L();L();function qs({isOpen:e,onClose:r,teamId:t,defaultFrom:i=""}){let[s,n]=w(i);S(()=>{if(e)n(i)},[i,e]);let{mutateAsync:l,isPending:u}=X({mutationFn:async(m)=>{let f=await R.api.teams[":teamId"].notifications.email.test.$post({param:{teamId:t},json:{from:m}});if(!f.ok){let v=await f.json().catch(()=>null);throw Error(v?.message||ry())}return await f.json()}}),h=async()=>{if(!s.trim()){B.error(WS());return}try{await l(s.trim()),B.success(yP()),r()}catch(m){B.error(m instanceof Error?m.message:ry())}};return a(Se,{open:e,onOpenChange:(m)=>!m&&r(),children:g(xe,{className:"sm:max-w-md",children:[g(ke,{children:[g("div",{className:"flex items-center gap-2",children:[a(Xa,{className:"w-5 h-5 text-primary"}),a(Ce,{children:D0()})]}),a(Nt,{children:GM()})]}),a("div",{className:"space-y-4 py-2",children:g("div",{className:"space-y-2",children:[a("label",{htmlFor:"test-dialog-from-input",className:"text-sm font-medium text-foreground",children:N0()}),a(re,{id:"test-dialog-from-input",value:s,onChange:(m)=>n(m.target.value),placeholder:"Shumai <noreply@example.com>",disabled:u,autoFocus:!0})]})}),g(ot,{className:"gap-2 sm:gap-0",children:[a(N,{variant:"outline",onClick:r,disabled:u,children:Ge()}),g(N,{onClick:h,disabled:u,children:[u&&a(V,{className:"w-4 h-4 animate-spin mr-2"}),D0()]})]})]})})}function js({teamId:e}){let r=ae(),[t,i]=w({enabled:!1,host:"",port:587,username:"",password:"",smtps:!1,ignoreCert:!1,from:"",replyTo:""}),[s,n]=w(!1),{data:l,isLoading:u,error:h}=ee({queryKey:["teams",e,"email-settings"],queryFn:async()=>{let o=await R.api.teams[":teamId"].notifications.email.$get({param:{teamId:e}});if(!o.ok)throw Error(X_());return await o.json()},enabled:!!e});S(()=>{if(l)i({enabled:l.enabled??!1,host:l.host??"",port:l.port??587,username:l.username??"",password:"",smtps:l.smtps??!1,ignoreCert:l.ignoreCert??!1,from:l.from??"",replyTo:l.replyTo??""})},[l]);let{mutateAsync:m,isPending:f}=X({mutationFn:async(o)=>{let b=await R.api.teams[":teamId"].notifications.email.$put({param:{teamId:e},json:{enabled:o.enabled,host:o.host,port:o.port,username:o.username||"",password:o.password||"",smtps:o.smtps,ignoreCert:o.ignoreCert,from:o.from,replyTo:o.replyTo||""}});if(!b.ok){let p=await b.json().catch(()=>null);throw Error(p?.message||Mh())}return await b.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"email-settings"]}),r.invalidateQueries({queryKey:["teams",e,"settings"]})}}),v=async()=>{try{await m(t),B.success(V_())}catch(o){B.error(o instanceof Error?o.message:Mh())}},d=async()=>{if(!t.host.trim()){B.error(mO());return}try{await m(t),B.success(V_()),n(!0)}catch(o){B.error(o instanceof Error?o.message:Mh())}};if(u)return a("div",{className:"flex items-center justify-center p-8",children:a(V,{className:"h-6 w-6 animate-spin text-muted-foreground"})});if(h)return a("div",{className:"p-8 text-center text-destructive",children:h instanceof Error?h.message:X_()});return g(W,{children:[a(Ie,{className:"h-full",children:a("div",{className:"space-y-6 pr-4 pb-8",children:g(st,{children:[g(_t,{className:"space-y-6 pt-6",children:[g("div",{className:"flex items-center justify-between space-x-4 rounded-lg border border-border p-4",children:[g("div",{className:"space-y-1",children:[a("label",{htmlFor:"enable-email-switch",className:"text-sm font-medium leading-none cursor-pointer",children:DC()}),a("p",{className:"text-xs text-muted-foreground",children:NC()})]}),a(Ve,{id:"enable-email-switch",checked:t.enabled,onCheckedChange:(o)=>i({...t,enabled:o})})]}),g("div",{className:"space-y-4 pt-2",children:[a("h4",{className:"text-sm font-semibold text-foreground",children:EO()}),g("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[g("div",{className:"space-y-2 md:col-span-2",children:[a("label",{htmlFor:"smtp-host-input",className:"text-sm font-medium text-foreground",children:fO()}),a(re,{id:"smtp-host-input",value:t.host,onChange:(o)=>i({...t,host:o.target.value}),placeholder:pO(),disabled:!t.enabled})]}),g("div",{className:"space-y-2",children:[a("label",{htmlFor:"smtp-port-input",className:"text-sm font-medium text-foreground",children:vO()}),a(re,{id:"smtp-port-input",type:"number",value:t.port,onChange:(o)=>i({...t,port:parseInt(o.target.value,10)||587}),disabled:!t.enabled})]})]}),g("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[g("div",{className:"space-y-2",children:[a("label",{htmlFor:"smtp-username-input",className:"text-sm font-medium text-foreground",children:xO()}),a(re,{id:"smtp-username-input",value:t.username||"",onChange:(o)=>i({...t,username:o.target.value}),placeholder:CO(),disabled:!t.enabled,autoComplete:"off"})]}),g("div",{className:"space-y-2",children:[a("label",{htmlFor:"smtp-password-input",className:"text-sm font-medium text-foreground",children:AO()}),a(re,{id:"smtp-password-input",type:"password",value:t.password||"",onChange:(o)=>i({...t,password:o.target.value}),placeholder:l?.password?_O():yO(),disabled:!t.enabled,autoComplete:"new-password"})]})]}),g("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 pt-2",children:[g("div",{className:"flex items-center justify-between space-x-4 rounded-lg border border-border p-4",children:[g("div",{className:"space-y-1",children:[a("label",{htmlFor:"smtps-switch",className:"text-sm font-medium leading-none cursor-pointer",children:bO()}),a("p",{className:"text-xs text-muted-foreground",children:wO()})]}),a(Ve,{id:"smtps-switch",checked:t.smtps,onCheckedChange:(o)=>i({...t,smtps:o}),disabled:!t.enabled})]}),g("div",{className:"flex items-center justify-between space-x-4 rounded-lg border border-border p-4",children:[g("div",{className:"space-y-1",children:[a("label",{htmlFor:"ignore-cert-switch",className:"text-sm font-medium leading-none cursor-pointer",children:hO()}),a("p",{className:"text-xs text-muted-foreground",children:gO()})]}),a(Ve,{id:"ignore-cert-switch",checked:t.ignoreCert,onCheckedChange:(o)=>i({...t,ignoreCert:o}),disabled:!t.enabled})]})]})]}),g("div",{className:"space-y-4 pt-4 border-t border-border",children:[a("h4",{className:"text-sm font-semibold text-foreground",children:JM()}),g("div",{className:"space-y-2",children:[a("label",{htmlFor:"sender-from-input",className:"text-sm font-medium text-foreground",children:N0()}),a(re,{id:"sender-from-input",value:t.from,onChange:(o)=>i({...t,from:o.target.value}),placeholder:"Shumai <noreply@example.com>",disabled:!t.enabled}),a("p",{className:"text-xs text-muted-foreground",children:VM()})]}),g("div",{className:"space-y-2",children:[a("label",{htmlFor:"sender-reply-to-input",className:"text-sm font-medium text-foreground",children:KM()}),a(re,{id:"sender-reply-to-input",value:t.replyTo||"",onChange:(o)=>i({...t,replyTo:o.target.value}),placeholder:"noreply@example.com",disabled:!t.enabled}),a("p",{className:"text-xs text-muted-foreground",children:WM()})]})]})]}),g(di,{className:"flex flex-col sm:flex-row items-center justify-end gap-3 border-t border-border p-6 bg-muted/20",children:[g(N,{variant:"outline",onClick:v,disabled:f,children:[f&&a(V,{className:"w-4 h-4 animate-spin mr-2"}),mo()]}),g(N,{onClick:d,disabled:f||!t.enabled,children:[f&&a(V,{className:"w-4 h-4 animate-spin mr-2"}),pM()]})]})]})})}),a(qs,{isOpen:s,onClose:()=>n(!1),teamId:e,defaultFrom:t.from})]})}L();var Os={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 $s({teamId:e}){let r=ae(),[t,i]=w(null),{data:s,isLoading:n}=ee({queryKey:["teams",e,"media-generation"],queryFn:async()=>{let m=await R.api.teams[":teamId"]["media-generation"].$get({param:{teamId:e}});if(!m.ok)throw Error("Failed to fetch media generation settings");return await m.json()}}),l=s?.providers||[],u=s?.enabledModels||[],h=Q(()=>{if(!t)return null;return l.find((m)=>m.provider===t.provider)||t},[t,l]);if(n)return a("div",{className:"flex h-64 items-center justify-center",children:a(V,{className:"h-8 w-8 animate-spin text-muted-foreground"})});return g("div",{className:"flex flex-col h-full min-w-0 w-full",children:[a(Ie,{className:"h-full pr-1 [&>div>div]:block!",children:a("div",{className:"pb-12 min-w-0 w-full",children:g(st,{className:"border-border min-w-0 w-full",children:[g(Ct,{children:[a(St,{className:"text-base font-semibold",children:$T()}),a(Zt,{children:HT()})]}),a(_t,{className:"min-w-0",children:a("div",{className:"space-y-2.5 min-w-0",children:l.map((m)=>{let f=Os[m.provider]||m.provider,v=m.status==="configured_custom",d=m.status==="configured_env",o=u.filter((p)=>p.provider===m.provider&&p.type==="image").length,b=u.filter((p)=>p.provider===m.provider&&p.type==="video").length;return g("div",{onClick:()=>i(m),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:[g("div",{className:"flex flex-col gap-1.5 min-w-0 flex-1",children:[g("div",{className:"flex items-center gap-2.5 min-w-0",children:[a("span",{className:"font-semibold text-sm text-foreground truncate",children:f}),a("span",{className:"text-xs text-muted-foreground font-mono opacity-60 truncate",title:m.customApiKeyOrEnv||m.defaultEnvKey,children:m.customApiKeyOrEnv||m.defaultEnvKey})]}),g("div",{className:"flex flex-wrap items-center gap-2 min-w-0",children:[v&&g(ge,{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:[a(Ar,{className:"w-3 h-3"}),a0()]}),d&&g(ge,{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:[a(Ar,{className:"w-3 h-3"}),l0()]}),!v&&!d&&a(ge,{variant:"outline",className:"bg-muted text-muted-foreground border-border text-[10px] shrink-0 font-normal",children:c0()}),m.supportedTypes.includes("image")&&g("span",{className:U("inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded border shrink-0 font-normal transition-colors",o>0?"bg-primary/10 text-primary border-primary/20":"bg-muted/50 text-muted-foreground border-border/60"),children:[a(Xn,{className:"w-3 h-3"}),LI({count:o})]}),m.supportedTypes.includes("video")&&g("span",{className:U("inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded border shrink-0 font-normal transition-colors",b>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:[a(da,{className:"w-3 h-3"}),pD({count:b})]})]})]}),a(qt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors shrink-0"})]},m.provider)})})})]})})}),h&&a(Kr,{isOpen:!!h,onClose:()=>i(null),provider:h,teamId:e,enabledModels:u,onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"media-generation"]})}})]})}function Kr({isOpen:e,onClose:r,provider:t,teamId:i,enabledModels:s,onSuccess:n}){let[l,u]=w(()=>t.apiKeyConfigured?"models":"api-key"),[h,m]=w(t.customApiKeyOrEnv||""),[f,v]=w(()=>s.filter((H)=>H.provider===t.provider).map((H)=>({type:H.type,modelId:H.modelId,name:H.name}))),[d,o]=w(""),[b,p]=w("all"),[_,F]=w(""),[D,A]=w(t.supportedTypes[0]||"image");S(()=>{u(t.apiKeyConfigured?"models":"api-key"),m(t.customApiKeyOrEnv||""),v(s.filter((H)=>H.provider===t.provider).map((H)=>({type:H.type,modelId:H.modelId,name:H.name}))),o(""),p("all"),F(""),A(t.supportedTypes[0]||"image")},[t.provider,t.customApiKeyOrEnv,t.apiKeyConfigured,s]);let{data:Y=[],isLoading:K}=ee({queryKey:["teams",i,"media-generation","curated",t.provider],queryFn:async()=>{let H=await R.api.teams[":teamId"]["media-generation"].models.curated.$get({param:{teamId:i},query:{provider:t.provider}});if(!H.ok)return[];return await H.json()},enabled:e}),{mutate:C,isPending:k}=X({mutationFn:async()=>{let H=await R.api.teams[":teamId"]["media-generation"].providers[":provider"].$put({param:{teamId:i,provider:t.provider},json:{apiKey:h.trim(),models:f.map((le)=>({type:le.type,modelId:le.modelId,name:le.name||le.modelId}))}});if(!H.ok){let le=await H.json().catch(()=>({}));throw Error(le?.message||"Failed to update provider")}return await H.json()},onSuccess:()=>{B.success(u0()),n(),r()},onError:(H)=>{B.error(H instanceof Error?H.message:_S())}}),I=Q(()=>new Set(Y.map((H)=>H.modelId)),[Y]),P=Q(()=>f.filter((H)=>!I.has(H.modelId)),[f,I]),y=Q(()=>{let H=[];for(let le of Y){let ve=f.some((Ae)=>Ae.modelId===le.modelId&&Ae.type===le.type);H.push({type:le.type,modelId:le.modelId,name:le.name,isCustom:!1,isToggledOn:ve})}for(let le of P)H.push({type:le.type,modelId:le.modelId,name:le.name||le.modelId,isCustom:!0,isToggledOn:!0});return H},[Y,f,P]),O=Q(()=>y.filter((H)=>{if(b!=="all"&&H.type!==b)return!1;if(d.trim()){let le=d.toLowerCase(),ve=H.name.toLowerCase().includes(le),Ae=H.modelId.toLowerCase().includes(le);if(!ve&&!Ae)return!1}return!0}),[y,b,d]),ie=(H,le)=>{if(le)v((ve)=>[...ve,{type:H.type,modelId:H.modelId,name:H.name,isCustom:H.isCustom}]);else v((ve)=>ve.filter((Ae)=>!(Ae.modelId===H.modelId&&Ae.type===H.type)))},oe=(H,le)=>{v((ve)=>ve.filter((Ae)=>!(Ae.modelId===H&&Ae.type===le)))},me=()=>{let H=_.trim();if(!H)return;if(f.some((ve)=>ve.modelId===H&&ve.type===D)){B.error(iS());return}v((ve)=>[...ve,{type:D,modelId:H,name:H,isCustom:!0}]),F("")},ue=Os[t.provider]||t.provider;return a(Se,{open:e,onOpenChange:(H)=>!H&&r(),children:g(xe,{className:"sm:max-w-2xl md:max-w-3xl h-[88vh] flex flex-col p-0 overflow-hidden",children:[g(ke,{className:"p-6 pb-2 shrink-0",children:[g(Ce,{className:"flex items-center gap-2 text-xl",children:[a("span",{children:ue}),t.status==="configured_custom"&&a(ge,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 text-[10px] font-normal",children:a0()}),t.status==="configured_env"&&a(ge,{variant:"outline",className:"bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/20 text-[10px] font-normal",children:l0()})]}),a(Nt,{children:Qx({envKey:t.defaultEnvKey})})]}),g(ho,{value:l,onValueChange:(H)=>u(H),className:"flex-1 flex flex-col min-h-0",children:[a("div",{className:"px-6 pb-2 shrink-0",children:g(go,{className:"grid w-full grid-cols-2",children:[a(Xr,{value:"api-key",onClick:()=>u("api-key"),children:Sp()}),g(Xr,{value:"models",onClick:()=>u("models"),children:[Hp()," (",f.length,")"]})]})}),a(_n,{value:"api-key",className:"flex-1 flex flex-col min-h-0 m-0",children:a("div",{className:"flex-1 min-h-0",children:a(Ie,{className:"h-full",children:a("div",{className:"p-6 space-y-4 pr-6",children:g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a("label",{htmlFor:"provider-api-key",className:"text-xs font-medium text-foreground",children:Sp()}),h&&g(N,{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:()=>m(""),children:[a(Ue,{className:"w-3.5 h-3.5"}),SE()]})]}),a(re,{id:"provider-api-key",type:"text",value:h,onChange:(H)=>m(H.target.value),placeholder:aw({envKey:t.defaultEnvKey}),className:"font-mono text-sm"}),a("p",{className:"text-xs text-muted-foreground mt-1",children:iw({envKey:t.defaultEnvKey})})]})})})})}),g(_n,{value:"models",className:"flex-1 flex flex-col min-h-0 m-0",children:[!t.apiKeyConfigured&&!h&&a("div",{className:"px-6 pb-2 shrink-0",children:g("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:[a(Wt,{className:"w-4 h-4 shrink-0 mt-0.5"}),g("div",{children:[a("p",{className:"font-medium",children:c0()}),a("p",{className:"text-[11px] opacity-90 mt-0.5",children:cR()})]})]})}),g("div",{className:"px-6 pb-3 flex items-center justify-between gap-3 shrink-0",children:[g("div",{className:"relative flex-1",children:[a(or,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),a(re,{type:"text",placeholder:Eg(),value:d,onChange:(H)=>o(H.target.value),className:"pl-9 h-9 text-xs"})]}),t.supportedTypes.length>1&&g("div",{className:"flex rounded-md border border-border overflow-hidden shrink-0 h-9",children:[a("button",{type:"button",onClick:()=>p("all"),className:U("px-3 text-xs transition-colors",b==="all"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:tw()}),g("button",{type:"button",onClick:()=>p("image"),className:U("px-3 text-xs transition-colors flex items-center gap-1.5",b==="image"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:[a(Xn,{className:"w-3.5 h-3.5"}),Qh()]}),g("button",{type:"button",onClick:()=>p("video"),className:U("px-3 text-xs transition-colors flex items-center gap-1.5",b==="video"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:[a(da,{className:"w-3.5 h-3.5"}),Gh()]})]})]}),a("div",{className:"flex-1 min-h-0 px-6",children:a(Ie,{className:"h-full pr-4",children:K?g("div",{className:"flex h-48 items-center justify-center gap-2 text-muted-foreground",children:[a(V,{className:"h-5 w-5 animate-spin"}),a("span",{className:"text-xs",children:oT()})]}):O.length===0?a("div",{className:"text-center py-12 border border-dashed rounded-xl text-muted-foreground text-sm",children:Gp()}):a("div",{className:"space-y-2 pb-4",children:O.map((H)=>g("div",{className:U("flex items-center justify-between p-3 rounded-xl border transition-all text-xs",H.isToggledOn?"border-primary/40 bg-primary/5":"border-border bg-card hover:border-primary/30"),children:[g("div",{className:"flex items-center gap-2.5 min-w-0 flex-1 mr-3",children:[g(ge,{variant:"outline",className:U("text-[10px] px-1.5 py-0.5 gap-1 shrink-0 font-normal",H.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:[H.type==="image"?a(Xn,{className:"w-3 h-3"}):a(da,{className:"w-3 h-3"}),H.type==="image"?Qh():Gh()]}),g("div",{className:"min-w-0 flex-1",children:[g("div",{className:"font-semibold text-foreground text-sm truncate flex items-center gap-1.5",children:[a("span",{className:"truncate",children:H.name}),H.isCustom&&a(ge,{variant:"secondary",className:"text-[10px] h-4 px-1 font-normal shrink-0",children:Lx().replace("...","")})]}),a("p",{className:"font-mono text-[11px] text-muted-foreground truncate mt-0.5",children:H.modelId})]})]}),g("div",{className:"flex items-center gap-2 shrink-0",children:[H.isCustom&&a(N,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>oe(H.modelId,H.type),title:Dt(),children:a(Ue,{className:"w-3.5 h-3.5"})}),a(Ve,{checked:H.isToggledOn,onCheckedChange:(le)=>ie(H,le),"aria-label":`Toggle ${H.name}`})]})]},`${H.type}-${H.modelId}`))})})}),a("div",{className:"px-6 py-3 border-t border-border shrink-0 bg-muted/10",children:g("div",{className:"flex items-center gap-2",children:[t.supportedTypes.length>1&&g("div",{className:"flex rounded-md border border-border overflow-hidden shrink-0 h-8",children:[a("button",{type:"button",onClick:()=>A("image"),className:U("px-2.5 py-1 text-xs transition-colors",D==="image"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:Qh()}),a("button",{type:"button",onClick:()=>A("video"),className:U("px-2.5 py-1 text-xs transition-colors",D==="video"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:Gh()})]}),a(re,{type:"text",value:_,onChange:(H)=>F(H.target.value),placeholder:zC(),className:"font-mono text-xs h-8 flex-1",onKeyDown:(H)=>{if(H.key==="Enter")H.preventDefault(),me()}}),g(N,{type:"button",size:"sm",variant:"outline",className:"h-8 text-xs shrink-0 gap-1",onClick:me,disabled:!_.trim(),children:[a(Re,{className:"w-3.5 h-3.5"}),fh()]})]})})]})]}),g(ot,{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:[g("div",{className:"text-xs text-muted-foreground",children:[f.length," ",Hp().toLowerCase()]}),g("div",{className:"flex items-center gap-2",children:[a(N,{type:"button",variant:"outline",size:"sm",onClick:r,disabled:k,children:Ge()}),g(N,{type:"button",size:"sm",onClick:()=>C(),disabled:k,children:[k&&a(V,{className:"w-4 h-4 mr-1.5 animate-spin"}),mo()]})]})]})]})})}L();var Qs=({teamId:e})=>{let r=ae(),[t,i]=w(""),[s,n]=w(""),[l,u]=w(""),[h,m]=w(null),[f,v]=w(!1),{data:d,isLoading:o}=ee({queryKey:["teams",e,"turntable-settings"],queryFn:async()=>{let D=await R.api.teams[":teamId"]["turntable-settings"].$get({param:{teamId:e}});if(!D.ok)throw Error("Failed to load turntable settings");return await D.json()},enabled:!!e});S(()=>{if(d)i(d.url||""),n(d.username||""),u(""),m(null)},[d]);let{mutateAsync:b,isPending:p}=X({mutationFn:async()=>{let D=await R.api.teams[":teamId"]["turntable-settings"].$put({param:{teamId:e},json:{url:t.trim(),username:s.trim()||void 0,password:l||void 0}});if(!D.ok){let A=await D.json().catch(()=>({}));throw Error(A.message||"Failed to update turntable settings")}return await D.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"turntable-settings"]}),r.invalidateQueries({queryKey:["teams",e,"settings"]}),B.success(oc())},onError:(D)=>{B.error(D.message||Bp())}}),_=async()=>{v(!0),m(null);try{let D=await R.api.teams[":teamId"]["turntable-settings"].test.$post({param:{teamId:e},json:{url:t||void 0,username:s||void 0,password:l||void 0}});if(!D.ok){let K=(await D.json().catch(()=>({}))).message||"Request failed";m({ok:!1,error:K}),B.error(fm());return}let A=await D.json();if(m(A),A.ok)B.success(nv());else B.error(A.error||fm())}catch(D){let A=D instanceof Error?D.message:String(D);m({ok:!1,error:A}),B.error(fm())}finally{v(!1)}},F=Boolean(d?.isEnvConfigured);return g(st,{children:[g(Ct,{children:[g("div",{className:"flex items-center justify-between",children:[a(St,{children:VP()}),F&&g(ge,{variant:"secondary",className:"gap-1",children:[a(eo,{className:"w-3 h-3"}),qP()]})]}),a(Zt,{children:KP()})]}),a(_t,{className:"space-y-4",children:o?a("div",{className:"flex items-center justify-center py-6",children:a(V,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):g(W,{children:[g("div",{className:"space-y-1.5",children:[a("label",{htmlFor:"turntable-url",className:"text-sm font-medium",children:QP()}),a(re,{id:"turntable-url",value:t,onChange:(D)=>i(D.target.value),placeholder:GP(),disabled:F||p})]}),g("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[g("div",{className:"space-y-1.5",children:[a("label",{htmlFor:"turntable-username",className:"text-sm font-medium",children:YP()}),a(re,{id:"turntable-username",value:s,onChange:(D)=>n(D.target.value),placeholder:"admin",disabled:F||p})]}),g("div",{className:"space-y-1.5",children:[a("label",{htmlFor:"turntable-password",className:"text-sm font-medium",children:$P()}),a(re,{id:"turntable-password",type:"password",value:l,onChange:(D)=>u(D.target.value),placeholder:d?.hasPassword?HP():"••••••••",disabled:F||p})]})]}),h&&a("div",{className:`flex items-center gap-2 p-3 rounded-lg border text-sm ${h.ok?"border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"border-destructive/30 bg-destructive/10 text-destructive"}`,children:h.ok?g(W,{children:[a(Ar,{className:"w-4 h-4 shrink-0"}),g("span",{children:[nv()," (v",h.version||"unknown",h.blender?`, Blender ${h.blender}`:"",")"]})]}):g(W,{children:[a(ia,{className:"w-4 h-4 shrink-0"}),g("span",{children:[fm(),": ",h.error]})]})})]})}),g(di,{className:"flex justify-between border-t border-border pt-4",children:[g(N,{type:"button",variant:"outline",onClick:_,disabled:o||f||!t.trim(),children:[f&&a(V,{className:"w-4 h-4 mr-2 animate-spin"}),f?JP():WP()]}),g(N,{type:"button",onClick:()=>b(),disabled:F||p||o,children:[p&&a(V,{className:"w-4 h-4 mr-2 animate-spin"}),mo()]})]})]})};L();var Ks=({teamId:e})=>{let r=ae(),[t,i]=w(""),[s,n]=w(""),[l,u]=w(""),[h,m]=w(null),[f,v]=w(!1),{data:d,isLoading:o}=ee({queryKey:["teams",e,"gotenberg-settings"],queryFn:async()=>{let D=await R.api.teams[":teamId"]["gotenberg-settings"].$get({param:{teamId:e}});if(!D.ok)throw Error("Failed to load gotenberg settings");return await D.json()},enabled:!!e});S(()=>{if(d)i(d.url||""),n(d.username||""),u(""),m(null)},[d]);let{mutateAsync:b,isPending:p}=X({mutationFn:async()=>{let D=await R.api.teams[":teamId"]["gotenberg-settings"].$put({param:{teamId:e},json:{url:t.trim(),username:s.trim()||void 0,password:l||void 0}});if(!D.ok){let A=await D.json().catch(()=>({}));throw Error(A.message||"Failed to update gotenberg settings")}return await D.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"gotenberg-settings"]}),r.invalidateQueries({queryKey:["teams",e,"settings"]}),B.success(oc())},onError:(D)=>{B.error(D.message||Bp())}}),_=async()=>{v(!0),m(null);try{let D=await R.api.teams[":teamId"]["gotenberg-settings"].test.$post({param:{teamId:e},json:{url:t.trim()||void 0,username:s.trim()||void 0,password:l||void 0}});if(!D.ok){let K=(await D.json().catch(()=>({}))).message||"Request failed";m({ok:!1,error:K}),B.error(jp());return}let A=await D.json();if(m(A),A.ok)B.success(py());else B.error(A.error||jp())}catch(D){let A=D instanceof Error?D.message:String(D);m({ok:!1,error:A}),B.error(jp())}finally{v(!1)}},F=Boolean(d?.isEnvConfigured);return g(st,{children:[g(Ct,{children:[g("div",{className:"flex items-center justify-between",children:[a(St,{children:gI()}),F&&g(ge,{variant:"secondary",className:"gap-1",children:[a(eo,{className:"w-3 h-3"}),dI()]})]}),a(Zt,{children:AI()})]}),a(_t,{className:"space-y-4",children:o?a("div",{className:"flex items-center justify-center py-6",children:a(V,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):g(W,{children:[g("div",{className:"space-y-1.5",children:[a("label",{htmlFor:"gotenberg-url",className:"text-sm font-medium",children:mI()}),a(re,{id:"gotenberg-url",value:t,onChange:(D)=>i(D.target.value),placeholder:hI(),disabled:F||p})]}),g("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[g("div",{className:"space-y-1.5",children:[a("label",{htmlFor:"gotenberg-username",className:"text-sm font-medium",children:vI()}),a(re,{id:"gotenberg-username",value:s,onChange:(D)=>n(D.target.value),placeholder:"admin",disabled:F||p})]}),g("div",{className:"space-y-1.5",children:[a("label",{htmlFor:"gotenberg-password",className:"text-sm font-medium",children:fI()}),a(re,{id:"gotenberg-password",type:"password",value:l,onChange:(D)=>u(D.target.value),placeholder:d?.hasPassword?pI():"••••••••",disabled:F||p})]})]}),h&&a("div",{className:`flex items-center gap-2 p-3 rounded-lg border text-sm ${h.ok?"border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"border-destructive/30 bg-destructive/10 text-destructive"}`,children:h.ok?g(W,{children:[a(Ar,{className:"w-4 h-4 shrink-0"}),g("span",{children:[py(),h.version?` (v${h.version})`:""]})]}):g(W,{children:[a(ia,{className:"w-4 h-4 shrink-0"}),g("span",{children:[jp(),": ",h.error]})]})})]})}),g(di,{className:"flex justify-between border-t border-border pt-4",children:[g(N,{type:"button",variant:"outline",onClick:_,disabled:o||f||!t.trim(),children:[f&&a(V,{className:"w-4 h-4 mr-2 animate-spin"}),f?yI():_I()]}),g(N,{type:"button",onClick:()=>b(),disabled:F||p||o,children:[p&&a(V,{className:"w-4 h-4 mr-2 animate-spin"}),mo()]})]})]})};L();function xa(e,r=30){let t=typeof e==="number"?e:parseInt(e,10);if(isNaN(t))return r;return Math.min(3650,Math.max(1,t))}var Us=({teamId:e})=>{let r=ae(),{data:t,isLoading:i,isError:s,error:n,refetch:l}=ee({queryKey:["teams",e,"settings"],queryFn:async()=>{let K=await R.api.teams[":teamId"].settings.$get({param:{teamId:e}});if(!K.ok)throw Error(as());return await K.json()},enabled:!!e}),[u,h]=w(!1),[m,f]=w("not_updated"),[v,d]=w("30"),[o,b]=w("30"),[p,_]=w(!1);S(()=>{if(t?.autoArchive&&!p)h(t.autoArchive.enabled??!1),f(t.autoArchive.method??"not_updated"),d(String(t.autoArchive.days??30)),b(String(t.autoArchive.postRestoreGraceDays??30))},[t?.autoArchive,p]);let F=t?.archiveStorage,D=Boolean(F?.enabled),{mutate:A,isPending:Y}=X({mutationFn:async()=>{let K=xa(v,30),C=xa(o,30),k=await R.api.teams[":teamId"].settings.$patch({param:{teamId:e},json:{key:"autoArchive",value:{enabled:u,method:m,days:K,postRestoreGraceDays:C}}});if(!k.ok){let I=await k.json().catch(()=>null);throw Error(I?.message||x_())}return await k.json()},onSuccess:()=>{_(!1),r.invalidateQueries({queryKey:["teams",e,"settings"]}),B.success(eE())},onError:(K)=>{B.error(K instanceof Error?K.message:x_())}});if(i)return a("div",{className:"flex items-center justify-center p-8",children:a(V,{className:"h-6 w-6 animate-spin text-muted-foreground"})});if(s)return a("div",{className:"h-full overflow-y-auto space-y-6 pr-1",children:g(st,{className:"border-destructive/50",children:[g(Ct,{children:[g(St,{className:"text-destructive flex items-center gap-2",children:[a(Wt,{className:"w-5 h-5"}),dS()]}),a(Zt,{children:n instanceof Error?n.message:as()})]}),a(di,{children:a(N,{variant:"outline",onClick:()=>l(),children:aM()})})]})});return g("div",{className:"h-full overflow-y-auto space-y-6 pr-1",children:[g(st,{children:[a(Ct,{children:g("div",{className:"flex items-center justify-between",children:[g("div",{className:"space-y-1",children:[g(St,{className:"flex items-center gap-2",children:[a(xl,{className:"h-5 w-5 text-primary"}),ww()]}),a(Zt,{children:Ew()})]}),D?g(ge,{variant:"outline",className:"text-emerald-600 border-emerald-300 bg-emerald-50 dark:bg-emerald-950/40 dark:border-emerald-800 dark:text-emerald-400 flex items-center gap-1.5",children:[a(Ar,{className:"w-3.5 h-3.5"}),xw()]}):g(ge,{variant:"outline",className:"text-amber-600 border-amber-300 bg-amber-50 dark:bg-amber-950/40 dark:border-amber-800 dark:text-amber-400 flex items-center gap-1.5",children:[a(Dr,{className:"w-3.5 h-3.5"}),w_()]})]})}),a(_t,{className:"space-y-4",children:!D?g("div",{className:"rounded-lg border border-amber-200 bg-amber-50/50 p-4 dark:border-amber-900/50 dark:bg-amber-950/20 text-sm text-amber-800 dark:text-amber-300 flex items-start gap-3",children:[a(Dr,{className:"w-5 h-5 flex-shrink-0 mt-0.5"}),g("div",{children:[a("p",{className:"font-medium",children:w_()}),a("p",{className:"text-xs text-amber-700 dark:text-amber-400 mt-1",children:Tw()})]})]}):g("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[g("div",{className:"space-y-1 rounded-lg border border-border p-3",children:[a("label",{className:"text-xs text-muted-foreground uppercase tracking-wider font-semibold",children:_w()}),a("p",{className:"text-sm font-medium",children:F?.backend==="s3"?vw():yw()})]}),F?.backend==="s3"?g(W,{children:[g("div",{className:"space-y-1 rounded-lg border border-border p-3",children:[a("label",{className:"text-xs text-muted-foreground uppercase tracking-wider font-semibold",children:bw()}),a("p",{className:"text-sm font-medium font-mono",children:F?.bucket||"-"})]}),g("div",{className:"space-y-1 rounded-lg border border-border p-3 md:col-span-2",children:[a("label",{className:"text-xs text-muted-foreground uppercase tracking-wider font-semibold",children:Sw()}),a("p",{className:"text-sm font-medium font-mono",children:F?.endpoint||Cw()})]})]}):g("div",{className:"space-y-1 rounded-lg border border-border p-3 md:col-span-2",children:[a("label",{className:"text-xs text-muted-foreground uppercase tracking-wider font-semibold",children:Iw()}),a("p",{className:"text-sm font-medium font-mono",children:F?.localRoot||"-"})]})]})})]}),g(st,{children:[g(Ct,{children:[a(St,{children:qw()}),a(Zt,{children:$w()})]}),g(_t,{className:"space-y-6",children:[!D&&g("div",{className:"rounded-lg border border-border bg-muted/40 p-3 text-xs text-muted-foreground flex items-center gap-2",children:[a(eo,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),a("span",{children:Gw()})]}),g("div",{className:"flex items-center justify-between space-x-4 rounded-lg border border-border p-4",children:[g("div",{className:"space-y-1",children:[a("label",{htmlFor:"enable-auto-archive-switch",className:"text-sm font-medium leading-none cursor-pointer",children:OC()}),a("p",{className:"text-xs text-muted-foreground",children:PC()})]}),a(Ve,{id:"enable-auto-archive-switch",checked:u,onCheckedChange:(K)=>{_(!0),h(K)},disabled:!D||Y})]}),g("div",{className:"space-y-4 rounded-lg border border-border p-4",children:[g("div",{className:"space-y-2",children:[a("label",{className:"text-sm font-medium",children:Vw()}),g(Ye,{value:m,onValueChange:(K)=>{_(!0),f(K)},disabled:!D||Y,children:[a(et,{id:"auto-archive-method-trigger",children:a(Xe,{})}),g(tt,{children:[a(be,{value:"not_updated",children:Jw()}),a(be,{value:"after_created",children:Kw()})]})]}),a("p",{className:"text-xs text-muted-foreground",children:Ww()})]}),g("div",{className:"space-y-2",children:[a("label",{htmlFor:"auto-archive-days-input",className:"text-sm font-medium",children:Hw()}),a(re,{id:"auto-archive-days-input",type:"number",min:1,max:3650,value:v,onChange:(K)=>{_(!0),d(K.target.value)},onBlur:()=>{d(String(xa(v,30)))},disabled:!D||Y,className:"w-full md:w-64"}),a("p",{className:"text-xs text-muted-foreground",children:Qw()})]}),m==="after_created"&&g("div",{className:"space-y-2",children:[a("label",{htmlFor:"auto-archive-post-restore-grace-days-input",className:"text-sm font-medium",children:Yw()}),a(re,{id:"auto-archive-post-restore-grace-days-input",type:"number",min:1,max:3650,value:o,onChange:(K)=>{_(!0),b(K.target.value)},onBlur:()=>{b(String(xa(o,30)))},disabled:!D||Y,className:"w-full md:w-64"}),a("p",{className:"text-xs text-muted-foreground",children:Xw()})]})]})]}),a(di,{className:"flex justify-end border-t border-border pt-4",children:g(N,{onClick:()=>A(),disabled:!D||Y,children:[Y&&a(V,{className:"mr-2 h-4 w-4 animate-spin"}),mo()]})})]})]})};L();L();function zs({isOpen:e,onClose:r,imageSrc:t,onConfirm:i}){let[s,n]=w(1),[l,u]=w({x:0,y:0}),[h,m]=w(!1),[f,v]=w(!1),d=M({x:0,y:0}),o=M(null),b=M(null),p=250;S(()=>{if(e)n(1),u({x:0,y:0}),v(!1)},[e,t]);let _=(C)=>{C.preventDefault(),m(!0),d.current={x:C.clientX-l.x,y:C.clientY-l.y}},F=(C)=>{if(!h)return;u({x:C.clientX-d.current.x,y:C.clientY-d.current.y})},D=()=>{m(!1)},A=(C)=>{if(C.touches.length!==1)return;m(!0);let k=C.touches[0];d.current={x:k.clientX-l.x,y:k.clientY-l.y}},Y=(C)=>{if(!h||C.touches.length!==1)return;let k=C.touches[0];u({x:k.clientX-d.current.x,y:k.clientY-d.current.y})},K=async()=>{let C=o.current,k=b.current;if(!C||!k)return;v(!0);try{let I=C.getBoundingClientRect(),P=512,y=document.createElement("canvas");y.width=512,y.height=512;let O=y.getContext("2d");if(O){O.clearRect(0,0,512,512);let ie=2.048,oe=I.width/s,me=I.height/s,ue=256+l.x*ie,H=256+l.y*ie;O.translate(ue,H),O.scale(s*ie,s*ie),O.drawImage(C,-oe/2,-me/2,oe,me);let le=await new Promise((ve)=>{y.toBlob((Ae)=>ve(Ae),"image/jpeg",0.9)});if(le)await i(le)}}catch(I){console.error("Failed to crop image",I)}finally{v(!1)}};return a(Se,{open:e,onOpenChange:(C)=>!C&&r(),children:g(xe,{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:[a(ke,{className:"p-6 border-b border-border/40 bg-gradient-to-br from-primary/5 to-transparent",children:g(Ce,{className:"text-xl font-bold flex items-center gap-2",children:[a(Za,{className:"w-5 h-5 text-primary"}),Uk()]})}),g("div",{className:"p-6 flex flex-col items-center gap-6",children:[g("div",{ref:b,className:"relative overflow-hidden bg-muted select-none border border-border/40 rounded-xl cursor-move shadow-inner",style:{width:250,height:250},onMouseDown:_,onMouseMove:F,onMouseUp:D,onMouseLeave:D,onTouchStart:A,onTouchMove:Y,onTouchEnd:D,children:[t&&a("img",{ref:o,src:t,alt:dE(),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(${l.x}px, ${l.y}px) scale(${s})`,maxHeight:"100%"}}),a("div",{className:"absolute inset-0 pointer-events-none border-[3px] border-primary/90 rounded-full"}),a("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)"}})]}),g("div",{className:"w-full flex items-center gap-3 px-2",children:[a(Ja,{className:"w-4 h-4 text-muted-foreground"}),a("input",{type:"range",min:"1.0",max:"3.0",step:"0.01",value:s,onChange:(C)=>n(parseFloat(C.target.value)),className:"flex-1 h-1.5 bg-muted rounded-lg appearance-none cursor-pointer accent-primary focus:outline-none"}),a(Ya,{className:"w-4 h-4 text-muted-foreground"})]})]}),g(ot,{className:"p-6 border-t border-border/40 bg-muted/20 flex flex-row justify-end gap-3",children:[a(N,{variant:"outline",onClick:r,disabled:f,children:Ge()}),a(N,{onClick:K,disabled:f||!t,className:"min-w-[80px]",children:f?g(W,{children:[a(V,{className:"w-4 h-4 animate-spin mr-2"}),C0()]}):mo()})]})]})})}var Hr=["general","transcode","quotas","appearance","email","integrations","storage","skills","mcp","providers","image-video","agents","sandbox","notifications","developer"],Gr=["480p","720p","1080p","1440p","2160p"],Zr=["480p","720p","1080p","1440p","2160p"];function Hs({teamId:e,settingKey:r,field:t,serverResolutions:i,defaultResolutions:s}){let n=ae(),l=M(null),[u,h]=w(null),m=M(Promise.resolve()),f=M(!1);return S(()=>{if(!f.current)l.current=null,h(null)},[i]),{currentResolutions:u??i??s,handleToggle:(o)=>{let b=l.current??u??i??s;if(b.includes(o)&&b.length===1)return;let p=b.includes(o)?b.filter((_)=>_!==o):[...b,o];if(p.length===0)return;l.current=p,h(p),n.setQueryData(["teams",e,"settings"],(_)=>{if(!_)return _;return{..._,transcode:{..._.transcode,[t]:p}}}),f.current=!0,m.current=m.current.then(async()=>{let _=l.current;if(!_)return;let F=await R.api.teams[":teamId"].settings.$patch({param:{teamId:e},json:{key:r,value:_}});if(!F.ok)throw Error("Failed to update settings");if(await F.json(),l.current===_)l.current=null,f.current=!1,h(null),await n.invalidateQueries({queryKey:["teams",e,"settings"]}),B.success(oc())}).catch((_)=>{console.error(_),l.current=null,f.current=!1,h(null),n.invalidateQueries({queryKey:["teams",e,"settings"]}),B.error(Bp())})}}}function Gs(){if(typeof window>"u")return"general";let e=window.location.hash.replace(/^#/,"");return Hr.includes(e)?e:"general"}function Yr(){let{teamId:e}=Jr.useParams(),r=ae(),[t,i]=w(Gs),s=(T)=>{i(T);let ne=T==="general"?"":`#${T}`;if(window.location.hash!==ne)window.history.replaceState(null,"",window.location.pathname+window.location.search+ne)};S(()=>{let T=()=>{i(Gs())};return window.addEventListener("hashchange",T),()=>window.removeEventListener("hashchange",T)},[]);let[n,l]=w(""),[u,h]=w(!1),[m,f]=w(null),v=M(null),[d,o]=w(!1),{setMetadata:b,getMetadata:p}=Br(),_=p("locale")||c(),F=async(T)=>{if(T==="en"||T==="zh")try{await b(e,"locale",T),Vl(T),B.success(YI())}catch(ne){console.error(ne),B.error(bS())}},{data:D,isLoading:A,error:Y}=ee({queryKey:["teams",e,"settings"],queryFn:async()=>{let T=await R.api.teams[":teamId"].settings.$get({param:{teamId:e}});if(!T.ok)throw Error("Failed to fetch settings");return await T.json()}}),{data:K,isLoading:C}=ee({queryKey:["teams",e,"me"],queryFn:async()=>{let T=await R.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!T.ok)throw Error("Failed to fetch me");return await T.json()},enabled:!!e});S(()=>{if(K?.name)l(K.name)},[K]),S(()=>{let T=["transcode","quotas","appearance","email","integrations","storage","providers","image-video","skills","mcp","agents","sandbox"];if(K&&K.role!=="owner"&&T.includes(t))s("general")},[K,t]);let k=(T)=>{if(!T)return"U";let ne=T.split(" ");if(ne.length>1)return`${ne[0][0]}${ne[ne.length-1][0]}`.toUpperCase();return T.substring(0,2).toUpperCase()},I=(T)=>{let ne=T.target.files?.[0];if(ne){let de=new FileReader;de.onload=()=>{f(de.result),h(!0)},de.readAsDataURL(ne),T.target.value=""}},P=async(T)=>{o(!0);try{let ne=new File([T],"avatar.jpg",{type:"image/jpeg"}),de=await R.api.teams[":teamId"].files.$post({param:{teamId:e},form:{file:ne}});if(!de.ok)throw Error("Failed to upload avatar");let Bt=(await de.json()).key;if(!(await R.api.teams[":teamId"].me.$patch({param:{teamId:e},json:{imageKey:Bt}})).ok)throw Error("Failed to save profile");B.success(fE()),r.invalidateQueries({queryKey:["teams",e,"me"]}),h(!1)}catch(ne){console.error(ne),B.error(vS())}finally{o(!1)}},y=async()=>{o(!0);try{if(!(await R.api.teams[":teamId"].me.$patch({param:{teamId:e},json:{imageKey:null}})).ok)throw Error("Failed to remove avatar");B.success(uE()),r.invalidateQueries({queryKey:["teams",e,"me"]})}catch(T){console.error(T),B.error(oS())}finally{o(!1)}},O=async()=>{if(!n.trim())return;o(!0);try{if(!(await R.api.teams[":teamId"].me.$patch({param:{teamId:e},json:{name:n.trim()}})).ok)throw Error("Failed to update name");B.success(e0()),r.invalidateQueries({queryKey:["teams",e,"me"]})}catch(T){console.error(T),B.error(wS())}finally{o(!1)}},{mutate:ie}=X({mutationFn:async(T)=>{let ne=await R.api.teams[":teamId"].settings.$patch({param:{teamId:T.teamId},json:T.data});if(!ne.ok)throw Error("Failed to update settings");return await ne.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"settings"]}),B.success(oc())},onError:()=>{B.error(Bp())}}),oe=(T)=>{ie({teamId:e,data:{key:"transcode.videoStrategy",value:T}})},{currentResolutions:me,handleToggle:ue}=Hs({teamId:e,settingKey:"transcode.videoResolutions",field:"videoResolutions",serverResolutions:D?.transcode?.videoResolutions,defaultResolutions:pv}),{currentResolutions:H,handleToggle:le}=Hs({teamId:e,settingKey:"transcode.hlsResolutions",field:"hlsResolutions",serverResolutions:D?.transcode?.hlsResolutions,defaultResolutions:mv}),ve=(T)=>{ie({teamId:e,data:{key:"transcode.hardwareAcceleration",value:T}})},[Ae,Le]=w(null),E=D?.transcode?.threads??0;S(()=>{Le(null)},[E]);let Z=(T)=>{ie({teamId:e,data:{key:"transcode.threads",value:T}})},J=(T)=>{ie({teamId:e,data:{key:"transcode.hlsEnabled",value:T}})};if(A||C)return a("div",{className:"flex h-screen items-center justify-center",children:a(V,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(Y)return a("div",{className:"p-8 text-center text-red-500",children:as()});let te=D?.transcode?.videoStrategy||ji.best_match;if(te==="single"||te==="disable")te=ji.best_match;else if(te==="full"||te==="all"||te==="multi")te=ji.multi;let Pe=D?.transcode?.hardwareAcceleration||lc.off,z=Ae??E,Te=D?.transcode?.hlsEnabled??!1;return a("div",{className:"h-full bg-background font-sans selection:bg-primary/20 transition-colors duration-300",children:g("div",{className:"flex flex-col md:flex-row h-full",children:[a("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:g("nav",{className:"p-4 space-y-1 mt-4",children:[a("div",{className:"mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider",children:Zk()}),g("button",{onClick:()=>s("general"),className:U("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="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:[a($n,{className:"w-5 h-5"}),JS(),t==="general"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("notifications"),className:U("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="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:[a(bl,{className:"w-5 h-5"}),qy(),t==="notifications"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("developer"),className:U("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="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:[a(Hi,{className:"w-5 h-5"}),y_(),t==="developer"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),K?.role==="owner"&&g(W,{children:[a("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:fP()}),g("button",{onClick:()=>s("transcode"),className:U("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="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:[a(Ha,{className:"w-5 h-5"}),lv(),t==="transcode"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("quotas"),className:U("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="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:[a(xs,{className:"w-5 h-5"}),im(),t==="quotas"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("appearance"),className:U("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="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:[a(bu,{className:"w-5 h-5"}),gh(),t==="appearance"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("email"),className:U("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="email"?"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:[a(pa,{className:"w-5 h-5"}),G_(),t==="email"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("integrations"),className:U("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="integrations"?"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:[a(za,{className:"w-5 h-5"}),Ay(),t==="integrations"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("storage"),className:U("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="storage"?"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:[a(xl,{className:"w-5 h-5"}),FO(),t==="storage"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]}),K?.role==="owner"&&g(W,{children:[a("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:lP()}),g("button",{onClick:()=>s("providers"),className:U("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="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:[a(no,{className:"w-5 h-5"}),uR(),t==="providers"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("image-video"),className:U("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="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:[a(Hn,{className:"w-5 h-5"}),hy(),t==="image-video"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("skills"),className:U("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="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:[a(vt,{className:"w-5 h-5"}),Z0(),t==="skills"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("mcp"),className:U("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="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:[a(oo,{className:"w-5 h-5"}),zd(),t==="mcp"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("agents"),className:U("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="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:[a(Ht,{className:"w-5 h-5"}),qb(),t==="agents"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("sandbox"),className:U("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="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:[a(wu,{className:"w-5 h-5"}),Jv(),t==="sandbox"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]})]})}),a("main",{className:"flex-1 bg-background/50 h-full flex flex-col transition-colors duration-300 overflow-y-hidden",children:g("div",{className:"flex-1 flex flex-col max-w-4xl w-full mx-auto p-6 md:p-10 overflow-hidden",children:[a("div",{className:"flex-none flex items-center justify-between mb-6",children:g("div",{children:[g("h2",{className:"text-2xl font-bold text-foreground",children:[t==="general"&&dy(),t==="transcode"&&lv(),t==="quotas"&&b0(),t==="appearance"&&v_(),t==="email"&&G_(),t==="integrations"&&Ay(),t==="storage"&&LO(),t==="skills"&&B0(),t==="mcp"&&zd(),t==="providers"&&Jb(),t==="image-video"&&hy(),t==="agents"&&Wb(),t==="sandbox"&&Yv(),t==="notifications"&&J1(),t==="developer"&&hC()]}),g("p",{className:"text-sm text-muted-foreground mt-1",children:[t==="general"&&XS(),t==="transcode"&&gD(),t==="quotas"&&w0(),t==="appearance"&&b_(),t==="email"&&TC(),t==="integrations"&&jI(),t==="storage"&&ZO(),t==="skills"&&uO(),t==="mcp"&&$p(),t==="providers"&&dR(),t==="image-video"&&jT(),t==="agents"&&$b(),t==="sandbox"&&dM(),t==="notifications"&&X1(),t==="developer"&&mC()]})]})}),g("div",{className:"flex-1 overflow-hidden animate-in fade-in slide-in-from-bottom-4 duration-500",children:[t==="general"&&g("div",{className:"h-full overflow-y-auto space-y-6 pr-1",children:[g(st,{children:[g(Ct,{children:[a(St,{children:Fk()}),a(Zt,{children:Lk()})]}),a(_t,{className:"space-y-6",children:g("div",{className:"flex flex-col md:flex-row gap-8 items-start",children:[g("div",{className:"flex flex-col items-center gap-3",children:[a("span",{className:"text-sm font-medium text-muted-foreground",children:cE()}),g("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:()=>v.current?.click(),children:[g($e,{className:"w-24 h-24",children:[K?.image&&a(He,{src:K.image,alt:K.name,className:"object-cover w-24 h-24"}),a(Qe,{className:"text-2xl bg-primary/40 text-foreground",children:k(K?.name)})]}),a("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:a("span",{className:"text-white text-xs font-semibold",children:bE()})})]}),g("div",{className:"flex gap-2",children:[a(N,{variant:"outline",size:"sm",onClick:()=>v.current?.click(),children:sD()}),K?.image&&a(N,{variant:"ghost",size:"sm",className:"text-red-500 hover:text-red-600",onClick:y,children:fu()})]}),a("input",{type:"file",ref:v,className:"hidden",accept:"image/*",onChange:I})]}),g("div",{className:"flex-1 space-y-4 w-full",children:[g("div",{className:"space-y-2",children:[a("label",{className:"text-sm font-medium text-muted-foreground",children:su()}),a(re,{value:n,onChange:(T)=>l(T.target.value),placeholder:$C(),className:"max-w-md"})]}),g("div",{className:"space-y-2",children:[a("label",{className:"text-sm font-medium text-muted-foreground",children:Th()}),a(re,{value:K?.email||"",disabled:!0,className:"max-w-md bg-muted/50 cursor-not-allowed"}),a("p",{className:"text-xs text-muted-foreground",children:IC()})]}),g(N,{onClick:O,disabled:d||!n.trim(),className:"mt-2",children:[d&&a(V,{className:"w-4 h-4 animate-spin mr-2"}),zi()]})]})]})})]}),g(st,{className:"border border-slate-200 dark:border-slate-800 mt-6",children:[g(Ct,{children:[a(St,{children:JI()}),a(Zt,{children:LM()})]}),a(_t,{className:"space-y-4",children:a("div",{className:"max-w-xs",children:g(Ye,{value:_,onValueChange:F,children:[a(et,{children:a(Xe,{placeholder:PM()})}),g(tt,{children:[a(be,{value:"en",children:BC()}),a(be,{value:"zh",children:xE()})]})]})})})]}),a(zs,{isOpen:u,onClose:()=>h(!1),imageSrc:m,onConfirm:P})]}),t==="transcode"&&g("div",{className:"h-full overflow-y-auto space-y-6 pr-1 pb-8",children:[g(st,{children:[g(Ct,{children:[a(St,{children:LP()}),a(Zt,{children:ZP()})]}),g(_t,{className:"space-y-6",children:[g("div",{className:"space-y-4",children:[g("div",{className:"space-y-0.5",children:[a("h3",{className:"text-lg font-medium",children:i1()}),a("p",{className:"text-sm text-muted-foreground",children:a1()})]}),g("div",{className:"space-y-3",children:[g("div",{className:U("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",te===ji.best_match?"border-primary bg-primary/5":"border-border"),onClick:()=>oe(ji.best_match),children:[a("div",{className:"font-semibold",children:gE()}),a("div",{className:"text-sm text-muted-foreground",children:AE()})]}),g("div",{className:U("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",te===ji.multi?"border-primary bg-primary/5":"border-border"),onClick:()=>oe(ji.multi),children:[a("div",{className:"font-semibold",children:l1()}),a("div",{className:"text-sm text-muted-foreground",children:c1()})]}),te===ji.multi&&g("div",{className:"space-y-3 pt-2 pl-1",children:[g("div",{className:"space-y-1",children:[a("h4",{className:"text-sm font-medium",children:mD()}),a("p",{className:"text-xs text-muted-foreground",children:hD()})]}),a("div",{className:"flex flex-wrap gap-4 pt-1",children:Gr.map((T)=>{let ne=me.includes(T),de=ne&&me.length===1;return g("label",{className:U("flex items-center space-x-2 text-sm",de?"cursor-not-allowed opacity-50":"cursor-pointer"),children:[a(Ir,{checked:ne,disabled:de,onCheckedChange:()=>ue(T)}),a("span",{children:T})]},T)})})]})]})]}),g("div",{className:"space-y-4 pt-6 border-t border-border",children:[g("div",{className:"flex items-center justify-between",children:[g("div",{className:"space-y-0.5",children:[a("h3",{className:"text-lg font-medium",children:DI()}),a("p",{className:"text-sm text-muted-foreground",children:NI()})]}),a(Ve,{checked:Te,onCheckedChange:J})]}),Te&&g("div",{className:"space-y-3 pt-2 pl-1",children:[g("div",{className:"space-y-1",children:[a("h4",{className:"text-sm font-medium",children:OI()}),a("p",{className:"text-xs text-muted-foreground",children:PI()})]}),a("div",{className:"flex flex-wrap gap-4 pt-1",children:Zr.map((T)=>{let ne=H.includes(T),de=ne&&H.length===1;return g("label",{className:U("flex items-center space-x-2 text-sm",de?"cursor-not-allowed opacity-50":"cursor-pointer"),children:[a(Ir,{checked:ne,disabled:de,onCheckedChange:()=>le(T)}),a("span",{children:T})]},T)})})]})]})]})]}),g(st,{children:[g(Ct,{children:[a(St,{children:EI()}),a(Zt,{children:TI()})]}),g(_t,{className:"space-y-3",children:[g("div",{className:U("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",Pe===lc.off?"border-primary bg-primary/5":"border-border"),onClick:()=>ve(lc.off),children:[a("div",{className:"font-semibold",children:SI()}),a("div",{className:"text-sm text-muted-foreground",children:II()})]}),g("div",{className:U("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",Pe===lc.auto?"border-primary bg-primary/5":"border-border"),onClick:()=>ve(lc.auto),children:[a("div",{className:"font-semibold",children:xI()}),a("div",{className:"text-sm text-muted-foreground",children:CI()})]})]})]}),g(st,{children:[a(Ct,{children:g("div",{className:"flex items-center justify-between",children:[g("div",{children:[a(St,{children:CS()}),a(Zt,{className:"mt-1.5",children:SS()})]}),a("span",{className:"font-mono text-sm font-semibold px-2.5 py-1 rounded bg-muted text-foreground border border-border",children:z===0?X0():IP({count:z})})]})}),a(_t,{children:g("div",{className:"pt-2 px-1",children:[a(Ss,{value:[z],min:0,max:32,step:1,onValueChange:([T])=>Le(T),onValueCommit:([T])=>{Le(T),Z(T)}}),g("div",{className:"flex justify-between text-xs text-muted-foreground mt-2",children:[g("span",{children:[X0()," (0)"]}),a("span",{children:"16"}),a("span",{children:"32"})]})]})})]})]}),t==="skills"&&a("div",{className:"h-full overflow-y-auto pr-1",children:a(Is,{teamId:e})}),t==="mcp"&&a("div",{className:"h-full overflow-y-auto pr-1",children:a(Es,{teamId:e})}),t==="providers"&&a(Ds,{teamId:e}),t==="image-video"&&a($s,{teamId:e}),t==="agents"&&a("div",{className:"h-full overflow-y-auto pr-1",children:a(ks,{teamId:e})}),t==="sandbox"&&a("div",{className:"h-full overflow-y-auto pr-1",children:a(As,{teamId:e})}),t==="notifications"&&a(Vs,{teamId:e}),t==="developer"&&a(Ls,{teamId:e}),t==="quotas"&&a(Rs,{teamId:e}),t==="appearance"&&a(Bs,{teamId:e}),t==="email"&&a(js,{teamId:e}),t==="integrations"&&g("div",{className:"h-full overflow-y-auto space-y-6 pr-1",children:[a(Qs,{teamId:e}),a(Ks,{teamId:e})]}),t==="storage"&&a(Us,{teamId:e})]})]})})]})})}var Jr=Je("/teams/$teamId/settings")({component:Yr});export{Jr as Route};
|