@shumai-one/shumai 0.4.2 → 0.4.3
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-adekdctx.css → chunk-0ccg9ddn.css} +1 -1
- package/bin/chunk-0e4wawpq.js +2 -0
- package/bin/chunk-185qefn1.js +2 -0
- package/bin/chunk-1kw2mbqb.js +1 -0
- package/bin/chunk-1wm6ptdx.js +1 -0
- package/bin/chunk-1yacmegc.js +2 -0
- package/bin/chunk-2291ehh5.js +3 -0
- package/bin/chunk-2520aq8j.js +2 -0
- package/bin/chunk-29zdp63z.js +3 -0
- package/bin/chunk-2yxj593j.js +2 -0
- package/bin/chunk-32pcmaqm.js +3 -0
- package/bin/chunk-3a13dcs1.js +1 -0
- package/bin/chunk-3cyrcgm5.js +13 -0
- package/bin/chunk-3swpwb9v.js +1 -0
- package/bin/chunk-3wmcx2bv.js +2 -0
- package/bin/chunk-4r81ghg8.js +2 -0
- package/bin/chunk-4v5n0ayb.js +2 -0
- package/bin/chunk-5a8nt4me.js +1 -0
- package/bin/chunk-66hsjnw6.js +2 -0
- package/bin/chunk-6bhn1p8v.js +211 -0
- package/bin/chunk-6gg1ymer.js +2 -0
- package/bin/chunk-70c3xrgd.js +2 -0
- package/bin/chunk-7esm0hqb.js +2 -0
- package/bin/chunk-7fst8kdw.js +12 -0
- package/bin/chunk-83e12sjg.js +3 -0
- package/bin/chunk-87zxtf66.js +3 -0
- package/bin/chunk-8fmy5jtp.js +2 -0
- package/bin/chunk-8zqgaxvv.js +1 -0
- package/bin/chunk-9t1ne8xr.js +2 -0
- package/bin/chunk-a32vreya.js +2 -0
- package/bin/chunk-a3dmtt2j.js +1 -0
- package/bin/chunk-abt0azmv.js +2 -0
- package/bin/chunk-ag6p3mbf.js +2 -0
- package/bin/chunk-aqbrzx9z.js +1 -0
- package/bin/chunk-av1a8fqp.js +3 -0
- package/bin/chunk-awfwk64v.js +2 -0
- package/bin/chunk-b235azv4.js +45 -0
- package/bin/chunk-b9yrw9et.js +10 -0
- package/bin/chunk-bay038pj.js +2 -0
- package/bin/chunk-c007p0t8.js +299 -0
- package/bin/chunk-cak32x57.js +2 -0
- package/bin/chunk-ce8m4zeg.js +3 -0
- package/bin/chunk-ck8azecb.js +12 -0
- package/bin/chunk-cnxwmycy.js +6 -0
- package/bin/chunk-cqb415s6.js +5 -0
- package/bin/chunk-e2mvmq2m.js +1 -0
- package/bin/chunk-e7mqtkzn.js +2 -0
- package/bin/chunk-e99dv20z.js +3 -0
- package/bin/chunk-ea79xnn3.js +2 -0
- package/bin/chunk-ehc9adfz.js +2 -0
- package/bin/chunk-ejbvfj4r.js +1 -0
- package/bin/chunk-ekfem7kf.js +1 -0
- package/bin/chunk-etwkk0xh.js +1 -0
- package/bin/chunk-evrdd32b.js +2 -0
- package/bin/chunk-f15qyp41.js +1 -0
- package/bin/chunk-f3ehv01n.js +54 -0
- package/bin/chunk-fm6p03ad.js +2 -0
- package/bin/chunk-fxswt9hc.js +3 -0
- package/bin/chunk-fyha3r13.js +2 -0
- package/bin/chunk-g0vs7k2x.js +1 -0
- package/bin/chunk-g84z2w7v.js +16 -0
- package/bin/chunk-gk3eqd50.js +2 -0
- package/bin/chunk-h3tbf521.js +2 -0
- package/bin/chunk-h837fyed.js +2 -0
- package/bin/chunk-hfh0c082.js +2 -0
- package/bin/chunk-j20e0qsw.js +7 -0
- package/bin/chunk-j8fxp8ej.js +2 -0
- package/bin/chunk-jje8nj8h.js +3 -0
- package/bin/chunk-jy006gcv.js +7 -0
- package/bin/chunk-k7hss0bd.js +4 -0
- package/bin/chunk-m7m9d4fb.js +2 -0
- package/bin/chunk-n1jwdb0a.js +1 -0
- package/bin/chunk-p5gf1zdm.js +4 -0
- package/bin/chunk-pb1zf0vb.js +2 -0
- package/bin/chunk-pfgxggaj.js +11 -0
- package/bin/chunk-q16490pv.js +2 -0
- package/bin/chunk-q2bvyv39.js +8 -0
- package/bin/chunk-qf24e71w.js +2 -0
- package/bin/chunk-qh81zhg1.js +1 -0
- package/bin/chunk-qwp3kwbz.js +2 -0
- package/bin/chunk-qwqvt9v6.js +2 -0
- package/bin/chunk-qydeqgyj.js +5 -0
- package/bin/chunk-r7dty1tg.js +2 -0
- package/bin/chunk-rbj4fad9.js +32 -0
- package/bin/chunk-rhdxwebf.js +2 -0
- package/bin/chunk-rhh716z0.js +42 -0
- package/bin/chunk-rpywcvg1.js +3 -0
- package/bin/chunk-rza4ae5z.js +3 -0
- package/bin/chunk-sfx2588q.js +3 -0
- package/bin/chunk-sk4e6rb1.js +1 -0
- package/bin/chunk-t2n1dbgx.js +4 -0
- package/bin/chunk-tf28796q.js +2 -0
- package/bin/chunk-twdxayky.js +3 -0
- package/bin/chunk-v9b3w8q5.js +3 -0
- package/bin/chunk-v9w25rp2.js +2 -0
- package/bin/chunk-vgn5zcpv.js +3 -0
- package/bin/chunk-wfzqnpc1.js +3 -0
- package/bin/chunk-wry2hvrq.js +24 -0
- package/bin/chunk-x8f4defx.js +3 -0
- package/bin/chunk-xp59apdb.js +2 -0
- package/bin/chunk-xtf3c29c.css +1 -0
- package/bin/chunk-z3gkt8w1.js +3 -0
- package/bin/chunk-zehyn6vd.js +2 -0
- package/bin/chunk-zh6fqq44.js +1 -0
- package/bin/chunk-zmv8cg4s.js +8 -0
- package/bin/chunk-zqv0zhfb.js +3 -0
- package/bin/{pdf.worker.min-szxdj13d.mjs → pdf.worker.min-vf48er29.mjs} +14423 -13889
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +626 -460
- package/package.json +18 -18
- package/prisma/migrations/20260904022457_add_agent_id_to_assets_and_audit_logs/migration.sql +17 -0
- package/prisma/migrations/20260906081230_default_denied_tools_delete_asset/migration.sql +15 -0
- package/prisma/schema.prisma +9 -0
- package/bin/chunk-07h4b77v.js +0 -2
- package/bin/chunk-0t4n4d5w.js +0 -4
- package/bin/chunk-1611z9jg.js +0 -2
- package/bin/chunk-1phqxp6z.js +0 -3
- package/bin/chunk-23hckrrz.js +0 -2
- package/bin/chunk-30z44j1g.js +0 -2
- package/bin/chunk-3j463k1g.js +0 -1
- package/bin/chunk-4181tdds.js +0 -14
- package/bin/chunk-480jtqng.js +0 -4
- package/bin/chunk-4c3g146q.js +0 -2
- package/bin/chunk-4ca0zt5e.js +0 -1
- package/bin/chunk-4d9bgmf2.js +0 -2
- package/bin/chunk-4ev56fss.js +0 -9
- package/bin/chunk-4gk52tjq.js +0 -45
- package/bin/chunk-4mdqkj4d.js +0 -1
- package/bin/chunk-4r91fggc.js +0 -2
- package/bin/chunk-50fb1x3w.js +0 -1
- package/bin/chunk-59gj1njz.js +0 -1
- package/bin/chunk-5pr0t7fb.js +0 -2
- package/bin/chunk-5vewxmz7.js +0 -3
- package/bin/chunk-62zx96pe.js +0 -2
- package/bin/chunk-63y0eb07.js +0 -2
- package/bin/chunk-6d5xrgfx.js +0 -2
- package/bin/chunk-6gbtz5bf.js +0 -67
- package/bin/chunk-6gjg5egq.js +0 -3
- package/bin/chunk-6m4jz9s1.js +0 -44
- package/bin/chunk-6s4x525w.js +0 -2
- package/bin/chunk-6w2wmvqs.js +0 -3
- package/bin/chunk-77d23vcn.js +0 -2
- package/bin/chunk-77m5p188.js +0 -2
- package/bin/chunk-7bvx087f.js +0 -1
- package/bin/chunk-7pfjfrjg.js +0 -5
- package/bin/chunk-7q10s127.js +0 -4
- package/bin/chunk-7thx8ctx.js +0 -3
- package/bin/chunk-8t4s91gh.js +0 -2
- package/bin/chunk-98ey5p2e.js +0 -3
- package/bin/chunk-9amndcyh.js +0 -6
- package/bin/chunk-9bk23g9x.js +0 -1
- package/bin/chunk-9mkcfy43.js +0 -1
- package/bin/chunk-9t3nsq5n.js +0 -2
- package/bin/chunk-9tjq99ds.js +0 -2
- package/bin/chunk-9wm9rwh1.js +0 -2
- package/bin/chunk-ab16fyg4.js +0 -4
- package/bin/chunk-arv0g2av.js +0 -1
- package/bin/chunk-aytj4zxg.js +0 -3
- package/bin/chunk-b1ypjqgp.js +0 -2
- package/bin/chunk-bdjv0ykq.js +0 -2
- package/bin/chunk-c1k86mfa.js +0 -10
- package/bin/chunk-caa96dgd.js +0 -2
- package/bin/chunk-ce4v2yjy.js +0 -1
- package/bin/chunk-cqh60y54.js +0 -3
- package/bin/chunk-cvq7zgw7.js +0 -1
- package/bin/chunk-d9mjbtp2.js +0 -2
- package/bin/chunk-dn7sbjws.js +0 -3
- package/bin/chunk-dxyq9h8n.js +0 -3
- package/bin/chunk-e3cabksx.js +0 -3
- package/bin/chunk-egcrbj94.js +0 -2
- package/bin/chunk-ev17v1mv.js +0 -2
- package/bin/chunk-evtpwg71.js +0 -2
- package/bin/chunk-f3e0nsv2.js +0 -2
- package/bin/chunk-f40gjqpq.js +0 -2
- package/bin/chunk-fe7822ak.js +0 -299
- package/bin/chunk-g8tkhw9j.js +0 -2
- package/bin/chunk-g9r0p4t8.js +0 -2
- package/bin/chunk-gbjyh9ms.js +0 -1
- package/bin/chunk-gtbsb39v.js +0 -3
- package/bin/chunk-gytz1q13.js +0 -13
- package/bin/chunk-h0fxysxs.js +0 -7
- package/bin/chunk-h8bdvsqt.js +0 -2
- package/bin/chunk-hag024w8.js +0 -2
- package/bin/chunk-hc6w5nw4.js +0 -7
- package/bin/chunk-j69dqc48.js +0 -2
- package/bin/chunk-jbtw1zym.js +0 -8
- package/bin/chunk-jc1vb7rj.js +0 -5
- package/bin/chunk-jdv78w9r.js +0 -2
- package/bin/chunk-jjs70y9v.js +0 -3
- package/bin/chunk-jmdar2gz.js +0 -2
- package/bin/chunk-jvwz10n4.js +0 -2
- package/bin/chunk-k47md1g4.js +0 -2
- package/bin/chunk-k4v0brcb.js +0 -2
- package/bin/chunk-k6n7c07e.js +0 -1
- package/bin/chunk-kk2cstsg.js +0 -2
- package/bin/chunk-knz4h56q.js +0 -12
- package/bin/chunk-kqqtt6bd.js +0 -3
- package/bin/chunk-kvyp1t4j.js +0 -7
- package/bin/chunk-kxskpgsq.js +0 -5
- package/bin/chunk-m6srbjcs.js +0 -2
- package/bin/chunk-mcc1scxs.js +0 -12
- package/bin/chunk-mq83a0kk.js +0 -2
- package/bin/chunk-mxm8g4q0.js +0 -1
- package/bin/chunk-nhpgdqq5.js +0 -2
- package/bin/chunk-nne496aa.js +0 -2
- package/bin/chunk-nqpb0r9h.js +0 -11
- package/bin/chunk-ns0zww9g.js +0 -2
- package/bin/chunk-ps4xfp23.js +0 -2
- package/bin/chunk-pz2ec6xt.js +0 -2
- package/bin/chunk-q163k309.js +0 -2
- package/bin/chunk-q1da61ps.js +0 -1
- package/bin/chunk-qrf0ady6.js +0 -68
- package/bin/chunk-qy28f25e.js +0 -2
- package/bin/chunk-r7s4ypw1.js +0 -2
- package/bin/chunk-ran23vm9.js +0 -1
- package/bin/chunk-rfvdc4n0.js +0 -2
- package/bin/chunk-rgthkvgx.js +0 -3
- package/bin/chunk-s39n3yw3.js +0 -2
- package/bin/chunk-s7wdd0g7.js +0 -8
- package/bin/chunk-s88ha5kx.js +0 -3
- package/bin/chunk-sf91bt9m.js +0 -2
- package/bin/chunk-sjwbjf9j.js +0 -2
- package/bin/chunk-t62076pv.js +0 -1
- package/bin/chunk-tbbwss3v.js +0 -3
- package/bin/chunk-tjcc7a6y.js +0 -24
- package/bin/chunk-tp6ab26e.js +0 -2
- package/bin/chunk-v2wxk9p5.js +0 -4
- package/bin/chunk-vbk6y4hk.js +0 -2
- package/bin/chunk-vfgfg5fk.js +0 -2
- package/bin/chunk-vm6c3xx9.js +0 -2
- package/bin/chunk-vsx96mt6.js +0 -3
- package/bin/chunk-wbyw1shz.js +0 -6
- package/bin/chunk-whh2vh50.css +0 -1
- package/bin/chunk-wjkcq65s.js +0 -2
- package/bin/chunk-wkefwkfp.js +0 -41
- package/bin/chunk-x7bsnk1e.js +0 -2
- package/bin/chunk-xbhw6bpz.js +0 -3
- package/bin/chunk-xg5yrcj5.js +0 -2
- package/bin/chunk-xg9xscqz.js +0 -1
- package/bin/chunk-xw2gpcsh.js +0 -3
- package/bin/chunk-ycq8ank7.js +0 -2
- package/bin/chunk-yp9hvkc5.js +0 -73
- package/bin/chunk-ytypyfkc.js +0 -65
- package/bin/chunk-z1kjmf60.js +0 -2
- package/bin/chunk-z36bx86r.js +0 -2
- package/bin/chunk-z7hdnecp.js +0 -3
- package/bin/chunk-zeby1cq7.js +0 -2
- package/bin/chunk-zs5e8z1w.js +0 -1
- package/bin/chunk-zxnyefg5.js +0 -2
- /package/bin/{chunk-24ke0th1.css → chunk-kegybs91.css} +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{H,N,h,He,O,v,u,fa,C,B,t,o,Q,L,U,ac,Ue,A,T,gr,kn,Ar,Z,bt,Te,_e,ft,ur,Hn,Zo,lo,de,Lt,ve,Oe,E,Qo,S,Ce,Ee,Ie,he,ge,Ae,V,qt,n,ui,Ug,jd,Gg,$g,qd,Qg,ku,Wg,Yg,Qp,Vp,Jg,Xg,nA,oA,aA,sA,lA,cA,uA,dA,pA,mA,hA,gA,AA,Yp,yA,Jp,_A,Xp,bA,em,vA,tm,wA,rm,xA,nm,SA,om,CA,am,EA,IA,TA,sm,MA,RA,kA,im,lm,cm,um,PA,NA,UA,zA,FA,$A,QA,VA,JA,Nu,Ou,pm,XA,ey,mm,ty,ry,hm,ny,sy,Du,uy,dy,fy,gy,Sy,Cy,Ey,Iy,Am,My,Ry,ky,Py,Ny,Oy,Re,Zy,By,Uy,zy,jy,Qy,Vy,Ky,Wy,bm,Jy,Xy,o0,s0,Sm,fc,h0,b0,v0,w0,S0,C0,T0,R0,U0,z0,at,F0,j0,$0,Q0,V0,Y0,Xd,Rm,e_,Wi,a_,s_,tf,l_,c_,Nm,p_,Om,m_,h_,rf,y_,__,x_,nf,C_,I_,Dm,R_,k_,_a,Ko,q_,G_,Bm,di,ju,Q_,V_,J_,Fm,Yi,eb,qu,jm,tb,rb,nb,mb,hb,Sb,Cb,Vm,Eb,Ib,Mb,Rb,Km,zb,Fb,jb,qb,Hb,$b,Ym,Vb,Kb,Wb,tv,rv,nv,ov,av,sv,fv,hv,vv,wv,xv,Sv,yf,Cv,Ev,eh,Iv,Tv,Mv,Rv,kv,th,rh,Pv,Nv,Ov,Dv,nh,Zv,oh,Lv,Bv,ah,Ac,Qu,Uv,zv,sh,Fv,jv,qv,Hv,Gv,$v,Qv,Vv,Kv,ih,Wv,Yv,_f,bf,nw,ow,aw,lh,sw,iw,lw,cw,uw,Vu,dw,Aw,Xi,yw,bw,vw,ww,xw,Sw,kw,Pw,Zw,mh,Lw,gh,Ah,Wu,qw,Hw,Gw,Cf,Ef,Kw,Ww,Xw,rx,nx,_h,ox,sx,Sx,Cx,Ex,Ix,vh,Tx,Mx,Rx,Px,Lx,Bx,pi,mi,hi,Ux,zx,Fx,qx,$x,Qx,Kx,Th,lS,cS,uS,dS,Rh,kh,Ph,Nh,fS,Oh,Dh,Zh,Lh,pS,mS,AS,_S,zh,Df,vS,xS,SS,ES,Zf,Lf,Bf,Uf,RS,Xu,ed,td,rd,nd,PS,NS,od,OS,ad,DS,sd,ZS,zf,al,Ff,LS,BS,qS,HS,id,jf,sl,Vh,Kh,lC,cC,So,va,Jh,Vf,tg,rg,TC,ng,og,MC,PC,NC,sg,DC,LC,Yf,cg,XC,eE,ug,tE,lE,cE,uE,dE,fE,pE,mE,hE,gE,AE,yE,_E,bE,vE,wE,xE,SE,CE,EE,IE,NE,FE,jE,qE,HE,GE,JE,XE,eI,_g,tI,vg,rI,nI,aI,xg,fI,_I,bI,vI,TI,MI,RI,kI,PI,NI,OI,DI,ZI,We,Ye,Je,Xe,et,tt,rt,nt,fe,ce,pe,qe,ue,It,q,se,Rt,R,uo,fo,Hr,_n,be,ht,gt,At,p,te,P,ot,Qn,Ic,Tc,Ig,Mc,Us,Tg,Ya,yi,Rc,Xa,G,je,De,Ze,Le,Be,re,Mr,Eo,St,kt,Pt,Ft,Mt}from"./chunk-6bhn1p8v.js";import{go,lr}from"./chunk-ehc9adfz.js";import{_l}from"./chunk-70c3xrgd.js";import{bl}from"./chunk-evrdd32b.js";import{Hs}from"./chunk-abt0azmv.js";import{xa,Wn,Gs,Io,on,vl,$s,vi,rs,wl}from"./chunk-v9w25rp2.js";import{bn,vn,wn,hr,_t,pt}from"./chunk-66hsjnw6.js";import{Yn}from"./chunk-ag6p3mbf.js";import{Jn}from"./chunk-a32vreya.js";import{Er}from"./chunk-9t1ne8xr.js";import{Yr}from"./chunk-m7m9d4fb.js";import{mo}from"./chunk-1yacmegc.js";import{ho}from"./chunk-r7dty1tg.js";import{Ln,Xn}from"./chunk-2yxj593j.js";import{an}from"./chunk-ea79xnn3.js";var qs=[["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=T("at-sign",qs);var js=[["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"}]],Ga=T("film",js);var Os=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],da=T("globe",Os);var zs=[["path",{d:"m2 21 9.6-9.6",key:"9l79m3"}],["path",{d:"m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19",key:"fw8biw"}],["circle",{cx:"15.5",cy:"7.5",r:"5.5",key:"4wxmhb"}]],Zt=T("key",zs);var Qs=[["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"}]],Ma=T("layout-dashboard",Qs);var Ks=[["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"}]],Ha=T("maximize-2",Ks);var Ws=[["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=T("message-circle",Ws);var Zs=[["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=T("move",Zs);var Xs=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],wt=T("puzzle",Xs);var Ys=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],ca=T("refresh-cw",Ys);var Js=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ja=T("shield-check",Js);var er=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],ma=T("video",er);var tr=[["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"}]],Ot=T("zap",tr);var ar=[["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"}]],es=T("zoom-in",ar);var sr=[["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"}]],ts=T("zoom-out",sr);C();C();var rr=Qo("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 Pe({className:e,orientation:s="vertical",...a}){return t("div",{role:"group","data-slot":"field","data-orientation":s,className:E(rr({orientation:s}),e),...a})}function $e({className:e,...s}){return t(G,{"data-slot":"field-label",className:E("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),...s})}function aa({className:e,...s}){return t("p",{"data-slot":"field-description",className:E("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),...s})}function Qe({className:e,children:s,errors:a,...l}){let r=O(()=>{if(s)return s;if(!a?.length)return null;let d=[...new Map(a.map((c)=>[c?.message,c])).values()];if(d?.length==1)return d[0]?.message;return t("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:d.map((c,f)=>c?.message&&t("li",{children:c.message},f))})},[s,a]);if(!r)return null;return t("div",{role:"alert","data-slot":"field-error",className:E("text-sm font-normal text-destructive",e),...l,children:r})}function as({update:e,notify:s,unwatched:a}){return{link:l,unlink:r,propagate:d,checkDirty:c,shallowPropagate:f};function l(g,y,x){let m=y.depsTail;if(m!==void 0&&m.dep===g)return;let i=m!==void 0?m.nextDep:y.deps;if(i!==void 0&&i.dep===g){i.version=x,y.depsTail=i;return}let b=g.subsTail;if(b!==void 0&&b.version===x&&b.sub===y)return;let _=y.depsTail=g.subsTail={version:x,dep:g,sub:y,prevDep:m,nextDep:i,prevSub:b,nextSub:void 0};if(i!==void 0)i.prevDep=_;if(m!==void 0)m.nextDep=_;else y.deps=_;if(b!==void 0)b.nextSub=_;else g.subs=_}function r(g,y=g.sub){let{dep:x,prevDep:m,nextDep:i,nextSub:b,prevSub:_}=g;if(i!==void 0)i.prevDep=m;else y.depsTail=m;if(m!==void 0)m.nextDep=i;else y.deps=i;if(b!==void 0)b.prevSub=_;else x.subsTail=_;if(_!==void 0)_.nextSub=b;else if((x.subs=b)===void 0)a(x);return i}function d(g){let y=g.nextSub,x;e:do{let m=g.sub,i=m.flags;if(!(i&60))m.flags=i|32;else if(!(i&12))i=0;else if(!(i&4))m.flags=i&-9|32;else if(!(i&48)&&w(g,m))m.flags=i|40,i&=1;else i=0;if(i&2)s(m);if(i&1){let b=m.subs;if(b!==void 0){let _=(g=b).nextSub;if(_!==void 0)x={value:y,prev:x},y=_;continue}}if((g=y)!==void 0){y=g.nextSub;continue}while(x!==void 0)if(g=x.value,x=x.prev,g!==void 0){y=g.nextSub;continue e}break}while(!0)}function c(g,y){let x,m=0,i=!1;e:do{let b=g.dep,_=b.flags;if(y.flags&16)i=!0;else if((_&17)===17){if(e(b)){let M=b.subs;if(M.nextSub!==void 0)f(M);i=!0}}else if((_&33)===33){if(g.nextSub!==void 0||g.prevSub!==void 0)x={value:g,prev:x};g=b.deps,y=b,++m;continue}if(!i){let M=g.nextDep;if(M!==void 0){g=M;continue}}while(m--){let M=y.subs,j=M.nextSub!==void 0;if(j)g=x.value,x=x.prev;else g=M;if(i){if(e(y)){if(j)f(M);y=g.sub;continue}i=!1}else y.flags&=-33;y=g.sub;let Y=g.nextDep;if(Y!==void 0){g=Y;continue e}}return i}while(!0)}function f(g){do{let y=g.sub,x=y.flags;if((x&48)===32){if(y.flags=x|16,(x&6)===2)s(y)}}while((g=g.nextSub)!==void 0)}function w(g,y){let x=y.depsTail;while(x!==void 0){if(x===g)return!0;x=x.prevDep}return!1}}function sa(e,s,a){let l=typeof e==="object",r=l?e:void 0;return{next:(l?e.next:e)?.bind(r),error:(l?e.error:s)?.bind(r),complete:(l?e.complete:a)?.bind(r)}}var Fa=[],pa=0,{link:ss,unlink:or,propagate:ir,checkDirty:is,shallowPropagate:os}=as({update(e){return e._update()},notify(e){Fa[Da++]=e,e.flags&=-3},unwatched(e){if(e.depsTail!==void 0)e.depsTail=void 0,e.flags=17,ga(e)}}),ua=0,Da=0,Nt,Aa=0;function ze(e){try{++Aa,e()}finally{if(!--Aa)Ia()}}function ga(e){let s=e.depsTail,a=s!==void 0?s.nextDep:e.deps;while(a!==void 0)a=or(a,e)}function Ia(){if(Aa>0)return;while(ua<Da){let e=Fa[ua];Fa[ua++]=void 0,e.notify()}ua=0,Da=0}function ha(e,s){let a=typeof e==="function",l=e,r={_snapshot:a?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:a?0:1,get(){if(Nt!==void 0)ss(r,Nt,pa);return r._snapshot},subscribe(d){let c=sa(d),f={current:!1},w=nr(()=>{if(r.get(),!f.current)f.current=!0;else c.next?.(r._snapshot)});return{unsubscribe:()=>{w.stop()}}},_update(d){let c=Nt,f=s?.compare??Object.is;if(a)Nt=r,++pa,r.depsTail=void 0;else if(d===void 0)return!1;if(a)r.flags=5;try{let w=r._snapshot,g=typeof d==="function"?d(w):d===void 0&&a?l(w):d;if(w===void 0||!f(w,g))return r._snapshot=g,!0;return!1}finally{if(Nt=c,a)r.flags&=-5;ga(r)}}};if(a)r.flags=17,r.get=function(){let d=r.flags;if(d&16||d&32&&is(r.deps,r)){if(r._update()){let c=r.subs;if(c!==void 0)os(c)}}else if(d&32)r.flags=d&-33;if(Nt!==void 0)ss(r,Nt,pa);return r._snapshot};else r.set=function(d){if(r._update(d)){let c=r.subs;if(c!==void 0)ir(c),os(c),Ia()}};return r}function nr(e){let s=()=>{let l=Nt;Nt=a,++pa,a.depsTail=void 0,a.flags=6;try{return e()}finally{Nt=l,a.flags&=-5,ga(a)}},a={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let l=this.flags;if(l&16||l&32&&is(this.deps,this))s();else this.flags=2},stop(){this.flags=0,this.depsTail=void 0,ga(this)}};return s(),a}var Ea=class{constructor(e,s){if(this.atom=ha(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),s)this.actions=s(this)}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(sa(e))}},ns=class{constructor(e){this.atom=ha(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(sa(e))}};function Ct(e,s){if(typeof e==="function")return new ns(e);if(s)return new Ea(e,s);return new Ea(e)}var ls=class{constructor(e,s){if(this.fn=e,this.options=s,this.lastExecutionTime=0,this.isPending=!1,this.maybeExecute=(...a)=>{let l=Date.now()-this.lastExecutionTime;if(this.options.leading&&l>=this.options.wait)this.execute(...a);else if(this.lastArgs=a,!this.timeoutId&&this.options.trailing){let r=this.options.wait-l;this.isPending=!0,this.timeoutId=setTimeout(()=>{if(this.lastArgs!==void 0)this.execute(...this.lastArgs)},r)}},this.execute=(...a)=>{this.fn(...a),this.options.onExecute?.(a,this),this.lastExecutionTime=Date.now(),this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.flush=()=>{if(this.isPending&&this.lastArgs)this.execute(...this.lastArgs)},this.cancel=()=>{this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.clearTimeout=()=>{if(this.timeoutId)clearTimeout(this.timeoutId),this.timeoutId=void 0},this.options.leading===void 0&&this.options.trailing===void 0)this.options.leading=!0,this.options.trailing=!0}};function Ta(e,s){return new ls(e,s).maybeExecute}var Va=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:s=!1,enabled:a=!0,reconnectEveryMs:l=300}){this.#t=e,this.#o=a,this.#e=this.getGlobalTarget,this.#m=s,this.debugLog(" Initializing event subscription for plugin",this.#t),this.#a=[],this.#n=!1,this.#d=!1,this.#s=null,this.#l=l}startConnectLoop(){if(this.#s!==null||this.#n)return;this.debugLog(`Starting connect loop (every ${this.#l}ms)`),this.#s=setInterval(this.#c,this.#l)}stopConnectLoop(){if(this.#i=!1,this.#s===null)return;clearInterval(this.#s),this.#s=null,this.#a=[],this.debugLog("Stopped connect loop")}debugLog(...e){if(this.#m)console.log(`\uD83C\uDF34 [tanstack-devtools:${this.#t}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<"u"&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog("Using global event target"),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<"u"&&typeof window.addEventListener<"u")return this.debugLog("Using window as event target"),window;let e=typeof EventTarget<"u"?new EventTarget:void 0;if(typeof e>"u"||typeof e.addEventListener>"u")return this.debugLog("No event mechanism available, running in non-web environment"),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1};return this.debugLog("Using new EventTarget as fallback"),e}getPluginId(){return this.#t}dispatchCustomEventShim(e,s){try{let a=new Event(e,{detail:s});this.#e().dispatchEvent(a)}catch(a){this.debugLog("Failed to dispatch shim event")}}dispatchCustomEvent(e,s){try{this.#e().dispatchEvent(new CustomEvent(e,{detail:s}))}catch(a){this.dispatchCustomEventShim(e,s)}}emitEventToBus(e){this.debugLog("Emitting event to client bus",e),this.dispatchCustomEvent("tanstack-dispatch-event",e)}createEventPayload(e,s){return{type:`${this.#t}:${e}`,payload:s,pluginId:this.#t}}emit(e,s){if(!this.#o){this.debugLog("Event bus client is disabled, not emitting event",e,s);return}if(this.#r)this.debugLog("Emitting event to internal event target",e,s),this.#r.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,s)}));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,s)),typeof CustomEvent<"u"&&!this.#i)this.#g(),this.startConnectLoop();return}return this.emitEventToBus(this.createEventPayload(e,s))}on(e,s,a){let l=a?.withEventTarget??!1,r=`${this.#t}:${e}`;if(l){if(!this.#r)this.#r=new EventTarget;this.#r.addEventListener(r,(c)=>{s(c.detail)})}if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event",r),()=>{};let d=(c)=>{this.debugLog("Received event from bus",c.detail),s(c.detail)};return this.#e().addEventListener(r,d),this.debugLog("Registered event to bus",r),()=>{if(l)this.#r?.removeEventListener(r,d);this.#e().removeEventListener(r,d)}}onAll(e){if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event"),()=>{};let s=(a)=>{let l=a.detail;e(l)};return this.#e().addEventListener("tanstack-devtools-global",s),()=>this.#e().removeEventListener("tanstack-devtools-global",s)}onAllPluginEvents(e){if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event"),()=>{};let s=(a)=>{let l=a.detail;if(this.#t&&l.pluginId!==this.#t)return;e(l)};return this.#e().addEventListener("tanstack-devtools-global",s),()=>this.#e().removeEventListener("tanstack-devtools-global",s)}};class ds extends Va{constructor(){super({pluginId:"form-devtools",reconnectEveryMs:1000})}}var mt=new ds;function Dt(e,s){return typeof e==="function"?e(s):e}function Xt(e,s){return wa(s).reduce((l,r)=>{if(l===null)return null;if(typeof l<"u")return l[r];return},e)}function Ut(e,s,a){let l=wa(s);function r(d){if(!l.length)return Dt(a,d);let c=l.shift();if(typeof c==="string"||typeof c==="number"&&!Array.isArray(d)){if(typeof d==="object"){if(d===null)d={};return{...d,[c]:r(d[c])}}return{[c]:r()}}if(Array.isArray(d)&&typeof c==="number"){let f=d.slice(0,c);return[...f.length?f:Array(c),r(d[c]),...d.slice(c+1)]}return[...Array(c),r()]}return r(e)}function Ba(e,s){let a=wa(s);function l(r){if(!r)return;if(a.length===1){let c=a[0];if(Array.isArray(r)&&typeof c==="number")return r.filter((g,y)=>y!==c);let{[c]:f,...w}=r;return w}let d=a.shift();if(typeof d==="string"||typeof d==="number"&&!Array.isArray(r)){if(typeof r==="object")return{...r,[d]:l(r[d])}}if(typeof d==="number"){if(Array.isArray(r)){if(d>=r.length)return r;let c=r.slice(0,d);return[...c.length?c:Array(d),l(r[d]),...r.slice(d+1)]}}throw Error("It seems we have created an infinite loop in deleteBy. ")}return l(e)}var cs=46,La=91,Pa=93,ms=48,dr=57;function wa(e){if(Array.isArray(e))return[...e];if(typeof e!=="string")throw Error("Path must be a string.");let s=e.length,a=[],l=s>0&&e.charCodeAt(0)===La?1:0,r=!0,d=-1;for(let c=l;c<=s;c++){let f=c<s?e.charCodeAt(c):-1;if(c===s||f===cs||f===La||f===Pa){let w=c-l;if(w>0){let g=r&&(w===1||e.charCodeAt(l)!==ms),y=e.slice(l,c);if(g){let x=parseInt(y,10);if(w<=15||String(x)===y)a.push(x);else a.push(y)}else a.push(y)}else if(d!==Pa&&!(d===-1&&f===Pa)&&!(d===f&&(f===cs||f===La)))a.push("");l=c+1,r=!0}else if(f<ms||f>dr)r=!1;d=f}if(!a.length)a.push("");return a}function Ra(e){return!(Array.isArray(e)&&e.length===0)}function Tt(e,s){let a=(l)=>l.validators.filter(Boolean).map((r)=>({cause:r.cause,validate:r.fn}));return s.validationLogic({form:s.form,group:s.group,validators:s.validators,event:{type:e,fieldName:s.fieldName,async:!1},runValidation:a})}function Vt(e,s){let{asyncDebounceMs:a}=s,{onBlurAsyncDebounceMs:l,onChangeAsyncDebounceMs:r,onDynamicAsyncDebounceMs:d}=s.validators||{},c=a??0,f=(w)=>w.validators.filter(Boolean).map((g)=>{let y=g?.cause||e,x=c;switch(y){case"change":x=r??c;break;case"blur":x=l??c;break;case"dynamic":x=d??c;break;case"submit":x=0;break}if(e==="submit")x=0;return{cause:y,validate:g.fn,debounceMs:x}});return s.validationLogic({form:s.form,group:s.group,validators:s.validators,event:{type:e,fieldName:s.fieldName,async:!0},runValidation:f})}var Yt=(e)=>!!e&&typeof e==="object"&&("fields"in e);function ut(e,s){if(Object.is(e,s))return!0;if(typeof e!=="object"||e===null||typeof s!=="object"||s===null)return!1;if(e instanceof Date&&s instanceof Date)return e.getTime()===s.getTime();if(e instanceof Map&&s instanceof Map){if(e.size!==s.size)return!1;for(let[r,d]of e)if(!s.has(r)||!Object.is(d,s.get(r)))return!1;return!0}if(e instanceof Set&&s instanceof Set){if(e.size!==s.size)return!1;for(let r of e)if(!s.has(r))return!1;return!0}let a=Object.keys(e),l=Object.keys(s);if(a.length!==l.length)return!1;if(a.length===0&&!Array.isArray(e)&&!Array.isArray(s)&&(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(s)!==Object.prototype))return!1;for(let r of a)if(!l.includes(r)||!ut(e[r],s[r]))return!1;return!0}var Jt=({newFormValidatorError:e,isPreviousErrorFromFormValidator:s,previousErrorValue:a})=>{if(e)return{newErrorValue:e,newSource:"form"};if(s)return{newErrorValue:void 0,newSource:void 0};if(a)return{newErrorValue:a,newSource:"field"};return{newErrorValue:void 0,newSource:void 0}},Gt=({formLevelError:e,fieldLevelError:s})=>{if(s)return{newErrorValue:s,newSource:"field"};if(e)return{newErrorValue:e,newSource:"form"};return{newErrorValue:void 0,newSource:void 0}};function Ke(e,s){if(e===void 0||e===null)return s;return{...e,...s}}var Qt=256,ya=[],ba;while(Qt--)ya[Qt]=(Qt+256).toString(16).substring(1);function ra(){let e=0,s,a="";if(!ba||Qt+16>256){ba=Array(256),e=256;while(e--)ba[e]=256*Math.random()|0;e=0,Qt=0}for(;e<16;e++){if(s=ba[Qt+e],e===6)a+=ya[s&15|64];else if(e===8)a+=ya[s&63|128];else a+=ya[s];if(e&1&&e>1&&e<11)a+="-"}return Qt++,a}var qa=Ta((e)=>mt.emit("form-state",{id:e.formId,state:e.store.state}),{wait:300});function Kt(e){if(e===null||typeof e!=="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let a=[];for(let l=0;l<e.length;l++)a[l]=Kt(e[l]);return a}if(e instanceof Map){let a=new Map;return e.forEach((l,r)=>{a.set(r,Kt(l))}),a}if(e instanceof Set){let a=new Set;return e.forEach((l)=>{a.add(Kt(l))}),a}let s={};for(let a in e)if(Object.prototype.hasOwnProperty.call(e,a))s[a]=Kt(e[a]);return s}function yt(e,s){return s===e||s.startsWith(`${e}.`)||s.startsWith(`${e}[`)}var vt=(e)=>{if(!e.validators)return e.runValidation({validators:[],form:e.form});let s=e.event.async,a=s?void 0:{fn:e.validators.onMount,cause:"mount"},l={fn:s?e.validators.onChangeAsync:e.validators.onChange,cause:"change"},r={fn:s?e.validators.onBlurAsync:e.validators.onBlur,cause:"blur"},d={fn:s?e.validators.onSubmitAsync:e.validators.onSubmit,cause:"submit"},c=s?void 0:{fn:()=>{return},cause:"server"};switch(e.event.type){case"mount":return e.runValidation({validators:[a],form:e.form});case"submit":return e.runValidation({validators:[l,r,d,c],form:e.form});case"server":return e.runValidation({validators:[],form:e.form});case"blur":return e.runValidation({validators:[r,c],form:e.form});case"change":return e.runValidation({validators:[l,c],form:e.form});default:throw Error(`Unknown validation event type: ${e.event.type}`)}};function cr(e,s){let a=new Map;for(let l of e){let r=l.path??[],d=s,c="";for(let f=0;f<r.length;f++){let w=r[f];if(w===void 0)continue;let g=typeof w==="object"?w.key:w,y=Number(g);if(Array.isArray(d)&&!Number.isNaN(y))c+=`[${y}]`;else c+=(f>0?".":"")+String(g);if(typeof d==="object"&&d!==null)d=d[g];else d=void 0}a.set(c,(a.get(c)??[]).concat(l))}return Object.fromEntries(a)}var us=(e,s)=>{let a=cr(e,s);return{form:a,fields:a}},Et={validate({value:e,validationSource:s},a){let l=a["~standard"].validate(e);if(l instanceof Promise)throw Error("async function passed to sync validator");if(!l.issues)return;if(s==="field")return l.issues;return us(l.issues,e)},async validateAsync({value:e,validationSource:s},a){let l=await a["~standard"].validate(e);if(!l.issues)return;if(s==="field")return l.issues;return us(l.issues,e)}},ea=(e)=>!!e&&("~standard"in e);var Ge={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{},_arrayVersion:0,_pendingValidationsCount:0};function Bt(e){function s(x){let m=e.getFieldMeta(x)??Ge;e.setFieldMeta(x,{...m,_arrayVersion:(m._arrayVersion||0)+1})}function a(x,m,i){s(x);let b=f(x,m,"move",i),_=Math.min(m,i),M=Math.max(m,i);for(let Y=_;Y<=M;Y++)b.push(c(x,Y));let j=Object.keys(e.fieldInfo).reduce((Y,z)=>{if(z.startsWith(c(x,m)))Y.set(z,e.getFieldMeta(z));return Y},new Map);g(b,m<i?"up":"down"),Object.keys(e.fieldInfo).filter((Y)=>Y.startsWith(c(x,i))).forEach((Y)=>{let z=Y.replace(c(x,i),c(x,m)),ne=j.get(z);if(ne)e.setFieldMeta(Y,ne)})}function l(x,m){s(x);let i=f(x,m,"remove");g(i,"up")}function r(x,m,i){s(x),f(x,m,"swap",i).forEach((_)=>{if(!_.toString().startsWith(c(x,m)))return;let M=_.toString().replace(c(x,m),c(x,i)),[j,Y]=[e.getFieldMeta(_),e.getFieldMeta(M)];if(j)e.setFieldMeta(M,j);if(Y)e.setFieldMeta(_,Y)})}function d(x,m){s(x);let i=f(x,m,"insert");g(i,"down"),i.forEach((b)=>{if(b.toString().startsWith(c(x,m)))e.setFieldMeta(b,y())})}function c(x,m){return`${x}[${m}]`}function f(x,m,i,b){let _=[c(x,m)];switch(i){case"swap":_.push(c(x,b));break;case"move":{let[M,j]=[Math.min(m,b),Math.max(m,b)];for(let Y=M;Y<=j;Y++)_.push(c(x,Y));break}default:{let M=e.getFieldValue(x),j=Array.isArray(M)?M.length:0;for(let Y=m+1;Y<j;Y++)_.push(c(x,Y));break}}return Object.keys(e.fieldInfo).filter((M)=>_.some((j)=>M.startsWith(j)))}function w(x,m){return x.replace(/\[(\d+)\]/,(i,b)=>{let _=parseInt(b,10);return`[${m==="up"?_+1:Math.max(0,_-1)}]`})}function g(x,m){(m==="up"?x:[...x].reverse()).forEach((b)=>{let _=w(b.toString(),m),M=e.getFieldMeta(_);if(M)e.setFieldMeta(b,M);else e.setFieldMeta(b,y())})}let y=()=>Ge;return{bumpArrayVersion:s,handleArrayMove:a,handleArrayRemove:l,handleArraySwap:r,handleArrayInsert:d}}function ja(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},formGroupStateBase:e.formGroupStateBase??{},isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}}}class ia{constructor(e){this.options={},this.fieldInfo={},this.formGroupApis=new Set,this.mount=()=>{let r=this.store.subscribe(()=>{qa(this)}),d=mt.on("request-form-state",(y)=>{if(y.payload.id===this._formId)mt.emit("form-api",{id:this._formId,state:this.store.state,options:this.options})}),c=mt.on("request-form-reset",(y)=>{if(y.payload.id===this._formId)this.reset()}),f=mt.on("request-form-force-submit",(y)=>{if(y.payload.id===this._formId)this._devtoolsSubmissionOverride=!0,this.handleSubmit(),this._devtoolsSubmissionOverride=!1}),w=()=>{f(),c(),d(),r.unsubscribe(),mt.emit("form-unmounted",{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});let{onMount:g}=this.options.validators||{};if(mt.emit("form-api",{id:this._formId,state:this.store.state,options:this.options}),!g)return w;return this.validateSync("mount"),w},this.update=(r)=>{if(!r)return;let d=this.options;this.options=r;let c=r.defaultValues&&!ut(r.defaultValues,d.defaultValues)&&!this.state.isTouched,f=!ut(r.defaultState,d.defaultState)&&!this.state.isTouched;if(!c&&!f)return;if(ze(()=>{this.baseStore.setState(()=>ja(Object.assign({},this.state,f?r.defaultState:{},c?{values:r.defaultValues}:{})))}),c){let w=Bt(this);for(let g of Object.keys(this.fieldInfo))if(Array.isArray(this.getFieldValue(g)))w.bumpArrayVersion(g)}mt.emit("form-api",{id:this._formId,state:this.store.state,options:this.options})},this.reset=(r,d)=>{let{fieldMeta:c}=this.state,f=this.resetFieldMeta(c);if(r&&!d?.keepDefaultValues)this.options={...this.options,defaultValues:r};this.baseStore.setState(()=>{let w=r??this.options.defaultValues??this.options.defaultState?.values;if(!r)Object.values(this.fieldInfo).forEach((g)=>{if(g.instance&&g.instance.options.defaultValue!==void 0)w=Ut(w,g.instance.name,g.instance.options.defaultValue)});return ja({...this.options.defaultState,values:w,fieldMetaBase:f})})},this.validateAllFields=async(r)=>{let d=[];return ze(()=>{Object.values(this.fieldInfo).forEach((f)=>{if(!f.instance)return;let w=f.instance;if(d.push(Promise.resolve().then(()=>w.validate(r,{skipFormValidation:!0,skipGroupValidation:!0}))),!f.instance.store.state.meta.isTouched)f.instance.setMeta((g)=>({...g,isTouched:!0}))})}),(await Promise.all(d)).flat()},this.validateArrayFieldsStartingFrom=async(r,d,c)=>{let f=this.getFieldValue(r),w=Array.isArray(f)?Math.max(f.length-1,0):null,g=[`${r}[${d}]`];for(let i=d+1;i<=(w??0);i++)g.push(`${r}[${i}]`);let y=Object.keys(this.fieldInfo).filter((i)=>g.some((b)=>i.startsWith(b))),x=[];return ze(()=>{y.forEach((i)=>{x.push(Promise.resolve().then(()=>this.validateField(i,c)))})}),(await Promise.all(x)).flat()},this.validateField=(r,d)=>{let c=this.fieldInfo[r]?.instance;if(!c){let{hasErrored:f}=this.validateSync(d);if(f&&!this.options.asyncAlways)return this.getFieldMeta(r)?.errors??[];return this.validateAsync(d).then(()=>this.getFieldMeta(r)?.errors??[])}if(!c.store.state.meta.isTouched)c.setMeta((f)=>({...f,isTouched:!0}));return c.validate(d)},this.validateSync=(r,d)=>{let c=Tt(r,{...this.options,form:this,group:d?.group,validationLogic:this.options.validationLogic||vt}),f=!1,w={};return ze(()=>{for(let x of c){if(!x.validate)continue;let m=this.runValidator({validate:x.validate,value:{value:this.state.values,formApi:this,validationSource:"form"},type:"validate"}),{formError:i,fieldErrors:b}=Na(m),_=oa(x.cause),M=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(b||{})]);if(d?.filterFieldNames)M=new Set([...M].filter(d.filterFieldNames));for(let j of M){if(this.baseStore.state.fieldMetaBase[j]===void 0&&!b?.[j])continue;let Y=this.getFieldMeta(j)??Ge,{errorMap:z,errorSourceMap:ne}=Y,ie=b?.[j],{newErrorValue:F,newSource:D}=Jt({newFormValidatorError:ie,isPreviousErrorFromFormValidator:ne?.[_]==="form",previousErrorValue:z?.[_]});if(D==="form")w[j]={...w[j],[_]:ie};if(z?.[_]!==F)this.setFieldMeta(j,(I=Ge)=>({...I,errorMap:{...I.errorMap,[_]:F},errorSourceMap:{...I.errorSourceMap,[_]:D}}))}if(!d?.dontUpdateFormErrorMap){if(this.state.errorMap?.[_]!==i)this.baseStore.setState((j)=>({...j,errorMap:{...j.errorMap,[_]:i}}))}if(i||b)f=!0}if(d?.dontUpdateFormErrorMap)return;let g=oa("submit");if(this.state.errorMap?.[g]&&r!=="submit"&&!f)this.baseStore.setState((x)=>({...x,errorMap:{...x.errorMap,[g]:void 0}}));let y=oa("server");if(this.state.errorMap?.[y]&&r!=="server"&&!f)this.baseStore.setState((x)=>({...x,errorMap:{...x.errorMap,[y]:void 0}}))}),{hasErrored:f,fieldsErrorMap:w}},this.validateAsync=async(r,d)=>{let c=Vt(r,{...this.options,form:this,group:d?.group,validationLogic:this.options.validationLogic||vt});if(!this.state.isFormValidating)this.baseStore.setState((x)=>({...x,isFormValidating:!0}));let f=[],w;for(let x of c){if(!x.validate)continue;let m=oa(x.cause);this.state.validationMetaMap[m]?.lastAbortController.abort();let b=new AbortController;this.state.validationMetaMap[m]={lastAbortController:b},f.push(new Promise(async(_)=>{let M;try{M=await new Promise((F,D)=>{setTimeout(async()=>{if(b.signal.aborted)return F(void 0);try{F(await this.runValidator({validate:x.validate,value:{value:this.state.values,formApi:this,validationSource:"form",signal:b.signal},type:"validateAsync"}))}catch(I){D(I)}},x.debounceMs)})}catch(F){M=F}let{formError:j,fieldErrors:Y}=Na(M);if(Y)w=w?{...w,...Y}:Y;let z=oa(x.cause),ne=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(w||{})]),ie=Array.from(ne);if(d?.filterFieldNames)ie=ie.filter(d.filterFieldNames);for(let F of ie){if(this.baseStore.state.fieldMetaBase[F]===void 0&&!w?.[F])continue;let D=this.getFieldMeta(F)??Ge,{errorMap:I,errorSourceMap:W}=D,k=w?.[F],{newErrorValue:X,newSource:xe}=Jt({newFormValidatorError:k,isPreviousErrorFromFormValidator:W?.[z]==="form",previousErrorValue:I?.[z]});if(I?.[z]!==X)this.setFieldMeta(F,(ye=Ge)=>({...ye,errorMap:{...ye.errorMap,[z]:X},errorSourceMap:{...ye.errorSourceMap,[z]:xe}}))}if(!d?.dontUpdateFormErrorMap)this.baseStore.setState((F)=>({...F,errorMap:{...F.errorMap,[z]:j}}));_(w?{fieldErrors:w,errorMapKey:z}:void 0)}))}let g=[],y={};if(f.length){g=await Promise.all(f);for(let x of g)if(x?.fieldErrors){let{errorMapKey:m}=x;for(let[i,b]of Object.entries(x.fieldErrors)){let M={...y[i]||{},[m]:b};y[i]=M}}}return this.baseStore.setState((x)=>({...x,isFormValidating:!1})),y},this.validate=(r,d)=>{let{hasErrored:c,fieldsErrorMap:f}=this.validateSync(r,d);if(c&&!this.options.asyncAlways)return f;return this.validateAsync(r,d)},this._handleSubmit=async(r)=>{this.baseStore.setState((f)=>({...f,isSubmitted:!1,submissionAttempts:f.submissionAttempts+1,isSubmitSuccessful:!1})),ze(()=>{Object.values(this.fieldInfo).forEach((f)=>{if(!f.instance)return;if(!f.instance.store.state.meta.isTouched)f.instance.setMeta((w)=>({...w,isTouched:!0}))})});let d=r??this.options.onSubmitMeta;if(!this.state.canSubmit&&!this._devtoolsSubmissionOverride){if(this.baseStore.state.submissionAttempts<=1){this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:d});return}}this.baseStore.setState((f)=>({...f,isSubmitting:!0}));let c=()=>{this.baseStore.setState((f)=>({...f,isSubmitting:!1}))};if(await this.validateAllFields("submit"),!this.state.isFieldsValid){c(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:d}),mt.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"validateAllFields",errors:Object.values(this.state.fieldMeta).map((f)=>f.errors).flat()});return}if(await this.validate("submit"),!this.state.isValid){c(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:d}),mt.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"validate",errors:this.state.errors});return}ze(()=>{Object.values(this.fieldInfo).forEach((f)=>{f.instance?.triggerOnSubmitListener()})}),this.options.listeners?.onSubmit?.({formApi:this,meta:d});try{await this.options.onSubmit?.({value:this.state.values,formApi:this,meta:d}),ze(()=>{this.baseStore.setState((f)=>({...f,isSubmitted:!0,isSubmitSuccessful:!0})),mt.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),c()})}catch(f){throw this.baseStore.setState((w)=>({...w,isSubmitSuccessful:!1})),mt.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"inflight",onError:f}),c(),f}},this.getFieldValue=(r)=>Xt(this.state.values,r),this.getFieldMeta=(r)=>this.state.fieldMeta[r],this.getFormGroupMeta=(r)=>this.formGroupMetaDerived.state[r],this.getFieldInfo=(r)=>this.fieldInfo[r]||={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.setFieldMeta=(r,d)=>{this.baseStore.setState((c)=>({...c,fieldMetaBase:{...c.fieldMetaBase,[r]:Dt(d,c.fieldMetaBase[r])}}))},this.resetFieldMeta=(r)=>Object.keys(r).reduce((d,c)=>{let f=c;return d[f]=Ge,d},{}),this.setFieldValue=(r,d,c)=>{let f=c?.dontUpdateMeta??!1,w=c?.dontRunListeners??!1,g=c?.dontValidate??!1;if(ze(()=>{if(!f)this.setFieldMeta(r,(y)=>({...y,isTouched:!0,isDirty:!0,errorMap:{...y?.errorMap,onMount:void 0}}));this.baseStore.setState((y)=>({...y,values:Ut(y.values,r,d)}))}),!w)this.getFieldInfo(r).instance?.triggerOnChangeListener();if(!g)this.validateField(r,"change")},this.deleteField=(r)=>{let c=[...Object.keys(this.fieldInfo).filter((f)=>{let w=r.toString();return f.startsWith(`${w}.`)||f.startsWith(`${w}[`)}),r];this.baseStore.setState((f)=>{let w={...f};return c.forEach((g)=>{w.values=Ba(w.values,g),delete this.fieldInfo[g],delete w.fieldMetaBase[g]}),w})},this.pushFieldValue=(r,d,c)=>{this.setFieldValue(r,(f)=>[...Array.isArray(f)?f:[],d],c),Bt(this).bumpArrayVersion(r)},this.insertFieldValue=async(r,d,c,f)=>{this.setFieldValue(r,(g)=>[...g.slice(0,d),c,...g.slice(d)],Ke(f,{dontValidate:!0}));let w=f?.dontValidate??!1;if(!w)await this.validateField(r,"change");if(Bt(this).handleArrayInsert(r,d),!w)await this.validateArrayFieldsStartingFrom(r,d,"change")},this.replaceFieldValue=async(r,d,c,f)=>{if(this.setFieldValue(r,(g)=>g.map((y,x)=>x===d?c:y),Ke(f,{dontValidate:!0})),Bt(this).bumpArrayVersion(r),!(f?.dontValidate??!1))await this.validateField(r,"change"),await this.validateArrayFieldsStartingFrom(r,d,"change")},this.removeFieldValue=async(r,d,c)=>{let f=this.getFieldValue(r),w=Array.isArray(f)?Math.max(f.length-1,0):null;if(this.setFieldValue(r,(y)=>y.filter((x,m)=>m!==d),Ke(c,{dontValidate:!0})),Bt(this).handleArrayRemove(r,d),w!==null){let y=`${r}[${w}]`;this.deleteField(y)}if(!(c?.dontValidate??!1))await this.validateField(r,"change"),await this.validateArrayFieldsStartingFrom(r,d,"change")},this.swapFieldValues=(r,d,c,f)=>{if(this.setFieldValue(r,(g)=>{let y=g[d],x=g[c];return Ut(Ut(g,`${d}`,x),`${c}`,y)},Ke(f,{dontValidate:!0})),Bt(this).handleArraySwap(r,d,c),!(f?.dontValidate??!1))this.validateField(r,"change"),this.validateField(`${r}[${d}]`,"change"),this.validateField(`${r}[${c}]`,"change")},this.moveFieldValues=(r,d,c,f)=>{if(this.setFieldValue(r,(g)=>{let y=[...g];return y.splice(c,0,y.splice(d,1)[0]),y},Ke(f,{dontValidate:!0})),Bt(this).handleArrayMove(r,d,c),!(f?.dontValidate??!1))this.validateField(r,"change"),this.validateField(`${r}[${d}]`,"change"),this.validateField(`${r}[${c}]`,"change")},this.clearFieldValues=(r,d)=>{let c=this.getFieldValue(r),f=Array.isArray(c)?Math.max(c.length-1,0):null;if(this.setFieldValue(r,[],Ke(d,{dontValidate:!0})),Bt(this).bumpArrayVersion(r),f!==null)for(let g=0;g<=f;g++){let y=`${r}[${g}]`;this.deleteField(y)}if(!(d?.dontValidate??!1))this.validateField(r,"change")},this.resetField=(r)=>{this.baseStore.setState((d)=>{let c=this.getFieldInfo(r).instance?.options.defaultValue,f=Xt(this.options.defaultValues,r),w=c??f;return{...d,fieldMetaBase:{...d.fieldMetaBase,[r]:Ge},values:w!==void 0?Ut(d.values,r,w):d.values}})},this.setErrorMap=(r)=>{ze(()=>{Object.entries(r).forEach(([d,c])=>{let f=d;if(Yt(c)){let{formError:w,fieldErrors:g}=Na(c);for(let y of Object.keys(this.fieldInfo)){if(!this.getFieldMeta(y))continue;this.setFieldMeta(y,(m)=>({...m,errorMap:{...m.errorMap,[f]:g?.[y]},errorSourceMap:{...m.errorSourceMap,[f]:"form"}}))}this.baseStore.setState((y)=>({...y,errorMap:{...y.errorMap,[f]:w}}))}else this.baseStore.setState((w)=>({...w,errorMap:{...w.errorMap,[f]:c}}))})})},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((r,[d,c])=>{if(Object.keys(c).length&&c.errors.length)r[d]={errors:c.errors,errorMap:c.errorMap};return r},{})}),this.parseValuesWithSchema=(r)=>Et.validate({value:this.state.values,validationSource:"form"},r),this.parseValuesWithSchemaAsync=(r)=>Et.validateAsync({value:this.state.values,validationSource:"form"},r),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??ra(),this._devtoolsSubmissionOverride=!1;let s=ja({...e?.defaultState,values:e?.defaultValues??e?.defaultState?.values});if(e?.transform){s=e.transform({state:s}).state;for(let r of Object.keys(s.errorMap)){let d=s.errorMap[r];if(d===void 0||!Yt(d))continue;for(let c of Object.keys(d.fields)){let f=d.fields[c];if(f===void 0)continue;let w=s.fieldMetaBase[c];s.fieldMetaBase[c]={isTouched:!1,isValidating:!1,isBlurred:!1,isDirty:!1,_arrayVersion:0,_pendingValidationsCount:0,...w??{},errorSourceMap:{...w?.errorSourceMap??{},onChange:"form"},errorMap:{...w?.errorMap??{},[r]:f}}}}}this.baseStore=Ct(s);let a=void 0;this.fieldMetaDerived=Ct((r)=>{let d=this.baseStore.get(),c=0,f={};for(let w of Object.keys(d.fieldMetaBase)){let g=d.fieldMetaBase[w],y=a?.fieldMetaBase[w],x=r?.[w],m=Xt(d.values,w),i=x?.errors;if(!y||g.errorMap!==y.errorMap){i=Object.values(g.errorMap??{}).filter((Y)=>Y!==void 0);let j=this.getFieldInfo(w)?.instance;if(!j||!j.options.disableErrorFlat)i=i.flat(1)}let b=!Ra(i),_=!g.isDirty,M=ut(m,this.getFieldInfo(w)?.instance?.options.defaultValue??Xt(this.options.defaultValues,w));if(x&&x.isPristine===_&&x.isValid===b&&x.isDefaultValue===M&&x.errors===i&&g===y){f[w]=x,c++;continue}f[w]={...g,errors:i??[],isPristine:_,isValid:b,isDefaultValue:M}}if(!Object.keys(d.fieldMetaBase).length)return f;if(r&&c===Object.keys(d.fieldMetaBase).length)return r;return a=this.baseStore.get(),f}),this.formGroupMetaDerived=Ct((r)=>{let d=this.baseStore.get(),c=this.fieldMetaDerived.get(),f={};for(let w of this.formGroupApis){let g=w.name,y=d.formGroupStateBase[g]??{isSubmitted:!1,isSubmitting:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1},x=c[g],m=!1,i=!0,b=!1,_=!1,M=!0,j=!1;for(let ke in c){if(ke===g)continue;if(!yt(g,ke))continue;let Se=c[ke];if(!Se)continue;if(Se.isValidating)m=!0;if(!Se.isValid)i=!1;if(Se.isTouched)b=!0;if(Se.isBlurred)_=!0;if(!Se.isDefaultValue)M=!1;if(Se.isDirty)j=!0}let Y=!j,z=!!m||y.isValidating,ne=x?.errorMap??{},ie=x?.errorSourceMap??{},F=Boolean(ne.onMount||Object.entries(c).some(([ke,Se])=>Se&&ke!==g&&yt(g,ke)&&Se.errorMap.onMount)),D=r?.[g],I=D?.errors??[];if(!D||D.__srcErrorMap!==ne)I=Object.values(ne).reduce((ke,Se)=>{if(Se===void 0)return ke;if(Se&&typeof Se==="object"&&"fields"in Se){let ee=Se.group;if(ee!==void 0)ke.push(ee);return ke}return ke.push(Se),ke},[]);let W=I.length===0,k=i&&W,X=w.options.canSubmitWhenInvalid??!1,xe=y.submissionAttempts===0&&!b&&!F||!z&&!y.isSubmitting&&k||X;if(D&&D.errorMap===ne&&D.errorSourceMap===ie&&D.errors===I&&D.isFieldsValidating===m&&D.isFieldsValid===i&&D.isGroupValid===W&&D.isValid===k&&D.canSubmit===xe&&D.isTouched===b&&D.isBlurred===_&&D.isPristine===Y&&D.isDefaultValue===M&&D.isDirty===j&&D.isValidating===z&&D.isSubmitting===y.isSubmitting&&D.isSubmitted===y.isSubmitted&&D.submissionAttempts===y.submissionAttempts&&D.isSubmitSuccessful===y.isSubmitSuccessful){f[g]=D;continue}let ye={...y,errorMap:ne,errorSourceMap:ie,_arrayVersion:x?._arrayVersion??0,isTouched:b,isBlurred:_,isDirty:j,isPristine:Y,isDefaultValue:M,isValid:k,errors:I,isValidating:z,isFieldsValidating:m,isFieldsValid:i,isGroupValid:W,canSubmit:xe};Object.defineProperty(ye,"__srcErrorMap",{value:ne,enumerable:!1,configurable:!0}),f[g]=ye}return f});let l=void 0;this.store=Ct((r)=>{let d=this.baseStore.get(),c=this.fieldMetaDerived.get(),f=Object.values(c).filter(Boolean),w=f.some((W)=>W.isValidating),g=f.every((W)=>W.isValid),y=f.some((W)=>W.isTouched),x=f.some((W)=>W.isBlurred),m=f.every((W)=>W.isDefaultValue),i=y&&d.errorMap?.onMount,b=f.some((W)=>W.isDirty),_=!b,M=Boolean(d.errorMap?.onMount||f.some((W)=>W?.errorMap?.onMount)),j=!!w,Y=r?.errors??[];if(!l||d.errorMap!==l.errorMap)Y=Object.values(d.errorMap).reduce((W,k)=>{if(k===void 0)return W;if(k&&Yt(k))return W.push(k.form),W;return W.push(k),W},[]);let z=Y.length===0,ne=g&&z,ie=this.options.canSubmitWhenInvalid??!1,F=d.submissionAttempts===0&&!y&&!M||!j&&!d.isSubmitting&&ne||ie,D=d.errorMap;if(i)Y=Y.filter((W)=>W!==d.errorMap.onMount),D=Object.assign(D,{onMount:void 0});if(r&&l&&r.errorMap===D&&r.fieldMeta===this.fieldMetaDerived.state&&r.errors===Y&&r.isFieldsValidating===w&&r.isFieldsValid===g&&r.isFormValid===z&&r.isValid===ne&&r.canSubmit===F&&r.isTouched===y&&r.isBlurred===x&&r.isPristine===_&&r.isDefaultValue===m&&r.isDirty===b&&ut(l,d))return r;let I={...d,errorMap:D,fieldMeta:this.fieldMetaDerived.state,errors:Y,isFieldsValidating:w,isFieldsValid:g,isFormValid:z,isValid:ne,canSubmit:F,isTouched:y,isBlurred:x,isPristine:_,isDefaultValue:m,isDirty:b};return l=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(ea(e.validate))return Et[e.type](e.value,e.validate);return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}}function Na(e){if(e){if(Yt(e)){let s=Na(e.form).formError,a=e.fields;return{formError:s,fieldErrors:a}}return{formError:e}}return{formError:void 0}}function oa(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"dynamic":return"onDynamic";case"change":default:return"onChange"}}class $t{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 s=this.getInfo();s.instance=this,this.update(this.options);let{onMount:a}=this.options.validators||{};if(a){let l=this.runValidator({validate:a,value:{value:this.state.value,fieldApi:this,validationSource:"field"},type:"validate"});if(l)this.setMeta((r)=>({...r,errorMap:{...r?.errorMap,onMount:l},errorSourceMap:{...r?.errorSourceMap,onMount:"field"}}))}return this.options.listeners?.onMount?.({value:this.state.value,fieldApi:this}),()=>{for(let[r,d]of Object.entries(this.timeoutIds.validations))if(d)clearTimeout(d),this.timeoutIds.validations[r]=null;for(let[r,d]of Object.entries(this.timeoutIds.listeners))if(d)clearTimeout(d),this.timeoutIds.listeners[r]=null;for(let[r,d]of Object.entries(this.timeoutIds.formListeners))if(d)clearTimeout(d),this.timeoutIds.formListeners[r]=null;let l=this.form.fieldInfo[this.name];if(!l)return;if(l.instance!==this)return;for(let[r,d]of Object.entries(l.validationMetaMap))d?.lastAbortController.abort(),l.validationMetaMap[r]=void 0;this.form.baseStore.setState((r)=>({...r,fieldMetaBase:{...r.fieldMetaBase,[this.name]:{...Ge,isTouched:r.fieldMetaBase[this.name]?.isTouched??Ge.isTouched,isBlurred:r.fieldMetaBase[this.name]?.isBlurred??Ge.isBlurred,isDirty:r.fieldMetaBase[this.name]?.isDirty??Ge.isDirty}}})),l.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,fieldApi:this}),this.form.options.listeners?.onFieldUnmount?.({formApi:this.form,fieldApi:this})}},this.update=(s)=>{if(this.options=s,this.name=s.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0){let a=this.form.getFieldValue(this.name);if(!ut(a,s.defaultValue))this.form.setFieldValue(this.name,s.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=(s,a)=>{if(this.form.setFieldValue(this.name,s,Ke(a,{dontRunListeners:!0,dontValidate:!0})),!a?.dontRunListeners)this.triggerOnChangeListener();if(!a?.dontValidate)this.validate("change")},this.getMeta=()=>this.store.state.meta,this.setMeta=(s)=>this.form.setFieldMeta(this.name,s),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(s,a)=>{if(this.form.pushFieldValue(this.name,s,Ke(a,{dontRunListeners:!0})),!a?.dontRunListeners)this.triggerOnChangeListener()},this.insertValue=(s,a,l)=>{if(this.form.insertFieldValue(this.name,s,a,Ke(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.replaceValue=(s,a,l)=>{if(this.form.replaceFieldValue(this.name,s,a,Ke(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.removeValue=(s,a)=>{if(this.form.removeFieldValue(this.name,s,Ke(a,{dontRunListeners:!0})),!a?.dontRunListeners)this.triggerOnChangeListener()},this.swapValues=(s,a,l)=>{if(this.form.swapFieldValues(this.name,s,a,Ke(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.moveValue=(s,a,l)=>{if(this.form.moveFieldValues(this.name,s,a,Ke(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.clearValues=(s)=>{if(this.form.clearFieldValues(this.name,Ke(s,{dontRunListeners:!0})),!s?.dontRunListeners)this.triggerOnChangeListener()},this.getLinkedFields=(s)=>{let a=Object.values(this.form.fieldInfo),l=[];for(let r of a){if(!r.instance)continue;if(!(r.instance instanceof $t))continue;let{onChangeListenTo:d,onBlurListenTo:c}=r.instance.options.validators||{};if(s==="change"&&d?.includes(this.name))l.push(r.instance);if(s==="blur"&&c?.includes(this.name))l.push(r.instance)}return l},this.validateSync=(s,a)=>{let l=Tt(s,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||vt}),d=this.getLinkedFields(s).reduce((w,g)=>{let y=Tt(s,{...g.options,form:g.form,fieldName:g.name,validationLogic:g.form.options.validationLogic||vt});return y.forEach((x)=>{x.field=g}),w.concat(y)},[]),c=!1;ze(()=>{let w=(g,y)=>{let x=na(y.cause),m=y.validate?ps(g.runValidator({validate:y.validate,value:{value:g.store.state.value,validationSource:"field",fieldApi:g},type:"validate"})):void 0,i=a[x],{newErrorValue:b,newSource:_}=Gt({formLevelError:i,fieldLevelError:m});if(g.state.meta.errorMap?.[x]!==b)g.setMeta((M)=>({...M,errorMap:{...M.errorMap,[x]:b},errorSourceMap:{...M.errorSourceMap,[x]:_}}));if(b)c=!0};for(let g of l)w(this,g);for(let g of d){if(!g.validate)continue;w(g.field,g)}});let f=na("submit");if(this.state.meta.errorMap?.[f]&&s!=="submit"&&!c)this.setMeta((w)=>({...w,errorMap:{...w.errorMap,[f]:void 0},errorSourceMap:{...w.errorSourceMap,[f]:void 0}}));return{hasErrored:c}},this.validateAsync=async(s,a)=>{let l=Vt(s,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||vt}),r=await a,c=this.getLinkedFields(s).reduce((i,b)=>{let _=Vt(s,{...b.options,form:b.form,fieldName:b.name,validationLogic:b.form.options.validationLogic||vt});return _.forEach((M)=>{M.field=b}),i.concat(_)},[]),f=[],w=[],g=l.some((i)=>i.validate),y=Array.from(new Set(c.filter((i)=>i.validate).map((i)=>i.field)));ze(()=>{if(g)this.startValidation();for(let i of y)i.startValidation()});let x=(i,b,_)=>{let M=na(b.cause),j=i.getInfo();j.validationMetaMap[M]?.lastAbortController.abort();let z=new AbortController;j.validationMetaMap[M]={lastAbortController:z},_.push(new Promise(async(ne)=>{let ie;try{ie=await new Promise((k,X)=>{if(i.timeoutIds.validations[b.cause])clearTimeout(i.timeoutIds.validations[b.cause]),i.endValidation();i.timeoutIds.validations[b.cause]=setTimeout(async()=>{if(z.signal.aborted)return k(void 0);try{k(await this.runValidator({validate:b.validate,value:{value:i.store.state.value,fieldApi:i,signal:z.signal,validationSource:"field"},type:"validateAsync"}))}catch(xe){X(xe)}},b.debounceMs)})}catch(k){ie=k}if(z.signal.aborted)return ne(void 0);let F=ps(ie),D=r[i.name]?.[M],{newErrorValue:I,newSource:W}=Gt({formLevelError:D,fieldLevelError:F});if(i.getInfo().instance!==i)return ne(void 0);i.setMeta((k)=>({...k,errorMap:{...k?.errorMap,[M]:I},errorSourceMap:{...k.errorSourceMap,[M]:W}})),ne(I)}))};for(let i of l){if(!i.validate)continue;x(this,i,f)}for(let i of c){if(!i.validate)continue;x(i.field,i,w)}let m=[];if(f.length||w.length)m=await Promise.all(f),await Promise.all(w);return ze(()=>{if(g)this.endValidation();for(let i of y)i.endValidation()}),m.filter(Boolean)},this.validate=(s,a)=>{if(!this.state.meta.isTouched)return[];let l=a?.skipGroupValidation?[]:Array.from(this.form.formGroupApis).filter((x)=>this.name.startsWith(x.name)),d=((a?.skipFormValidation)?{fieldsErrorMap:{}}:this.form.validateSync(s)).fieldsErrorMap[this.name]??{};if(!a?.skipFormValidation)for(let x of l){if(x.state.meta.submissionAttempts===0)continue;let{fieldsErrorMap:m}=this.form.validateSync(s,{group:x,dontUpdateFormErrorMap:!0,filterFieldNames:(i)=>yt(x.name,i)});d={...d,...m[this.name]??{}}}let{hasErrored:c}=this.validateSync(s,d),f=new WeakMap;for(let x of l){let{hasErrored:m}=x.validateSync(s,{},{skipRelatedFieldValidation:!0});f.set(x,m)}if(c&&!this.options.asyncAlways){this.getInfo().validationMetaMap[na(s)]?.lastAbortController.abort();let x=[];for(let m of l)m.getInfo().validationMetaMap[na(s)]?.lastAbortController.abort(),x.push(m.state.meta.errors);return[...this.state.meta.errors,...x.flat()]}let w=a?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(s),g=this.validateAsync(s,w),y=[];for(let x of l){if(f.get(x)&&!x.options.asyncAlways)continue;y.push(x.validateAsync(s,w,{skipRelatedFieldValidation:!0}))}if(y.length===0)return g;return Promise.all([g,...y]).then((x)=>x.flat())},this.handleChange=(s)=>{this.setValue(s)},this.handleBlur=()=>{if(!this.state.meta.isTouched)this.setMeta((a)=>({...a,isTouched:!0}));if(!this.state.meta.isBlurred)this.setMeta((a)=>({...a,isBlurred:!0}));this.validate("blur"),this.triggerOnBlurListener()},this.setErrorMap=(s)=>{this.setMeta((a)=>({...a,errorMap:{...a.errorMap,...s}}))},this.parseValueWithSchema=(s)=>Et.validate({value:this.state.value,validationSource:"field"},s),this.parseValueWithSchemaAsync=(s)=>Et.validateAsync({value:this.state.value,validationSource:"field"},s),this.triggerOnBlurListener=()=>{let s=this.form.options.listeners?.onBlurDebounceMs;if(s&&s>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})},s)}else this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this});let a=this.options.listeners?.onBlurDebounceMs;if(a&&a>0){if(this.timeoutIds.listeners.blur)clearTimeout(this.timeoutIds.listeners.blur);this.timeoutIds.listeners.blur=setTimeout(()=>{this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},a)}else this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},this.triggerOnChangeListener=()=>{let s=this.form.options.listeners?.onChangeDebounceMs;if(s&&s>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})},s)}else this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this});let a=this.options.listeners?.onChangeDebounceMs;if(a&&a>0){if(this.timeoutIds.listeners.change)clearTimeout(this.timeoutIds.listeners.change);this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this})},a)}else this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this});for(let l of this.form.formGroupApis)if(yt(l.name,this.name))l.triggerOnChangeListener()},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,fieldApi:this})},this.form=e.form,this.name=e.name,this.options=e,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=Ct((s)=>{this.form.store.get();let a=this.form.getFieldMeta(this.name)??{...Ge,...e.defaultMeta},l=this.form.getFieldValue(this.name);if(!a.isTouched&&l===void 0&&this.options.defaultValue!==void 0&&!ut(l,this.options.defaultValue))l=this.options.defaultValue;if(s&&s.value===l&&s.meta===a)return s;return{value:l,meta:a}})}get state(){return this.store.state}runValidator(e){if(ea(e.validate))return Et[e.type](e.value,e.validate);return e.validate(e.value)}startValidation(){this.setMeta((e)=>{let s=e._pendingValidationsCount+1;return{...e,_pendingValidationsCount:s,isValidating:s>0&&!e.isValidating?!0:e.isValidating}})}endValidation(){this.setMeta((e)=>{let s=Math.max(0,e._pendingValidationsCount-1);return{...e,_pendingValidationsCount:s,isValidating:s===0&&e.isValidating?!1:e.isValidating}})}}function ps(e){if(e)return e;return}function na(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"dynamic":return"onDynamic";case"change":default:return"onChange"}}function Oa(e){return{isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1}}function gs(e){return{...Ge,...e,errors:[],isPristine:!0,isValid:!0,isDefaultValue:!0,isFieldsValidating:!1,isFieldsValid:!0,isGroupValid:!0,canSubmit:!0,isSubmitting:!1,isSubmitted:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1}}class Ht{constructor(e){this.options={},this.setFormGroupState=(s)=>{this.form.baseStore.setState((a)=>{let l=a.formGroupStateBase[this.name]??Oa({});return{...a,formGroupStateBase:{...a.formGroupStateBase,[this.name]:s(l)}}})},this._lastDistributedFieldNames={},this.update=(s)=>{if(this.options=s,this.name=s.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0){let a=this.form.getFieldValue(this.name);if(!ut(a,s.defaultValue))this.form.setFieldValue(this.name,s.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})}if(!this.form.getFieldMeta(this.name))this.form.setFieldMeta(this.name,{...Ge,...this.options.defaultMeta})},this.mount=()=>{this.update(this.options),this.form.formGroupApis.add(this),this.fieldInfo.instance=this,this.form.baseStore.setState((a)=>({...a,formGroupStateBase:{...a.formGroupStateBase,[this.name]:a.formGroupStateBase[this.name]??Oa({...this.options.defaultState})}}));let{onMount:s}=this.options.validators||{};if(s){let a=this.runValidator({validate:s,value:{value:this.state.value,groupApi:this,validationSource:"form"},type:"validate"}),l=a,r=void 0;if(za(a))l=a.group,r=a.fields;let d=$a(l);if(d)this.setMeta((c)=>({...c,errorMap:{...c.errorMap,onMount:d},errorSourceMap:{...c.errorSourceMap,onMount:"field"}}));this.distributeFieldErrors("onMount",r)}return this.options.listeners?.onMount?.({value:this.state.value,groupApi:this}),()=>{for(let[a,l]of Object.entries(this.timeoutIds.validations))if(l)clearTimeout(l),this.timeoutIds.validations[a]=null;for(let[a,l]of Object.entries(this.timeoutIds.listeners))if(l)clearTimeout(l),this.timeoutIds.listeners[a]=null;for(let[a,l]of Object.entries(this.timeoutIds.formListeners))if(l)clearTimeout(l),this.timeoutIds.formListeners[a]=null;if(this.fieldInfo.instance!==this)return;for(let[a,l]of Object.entries(this.fieldInfo.validationMetaMap))l?.lastAbortController.abort(),this.fieldInfo.validationMetaMap[a]=void 0;this.form.formGroupApis.delete(this),this.form.baseStore.setState((a)=>({...a,formGroupStateBase:{...a.formGroupStateBase,[this.name]:Oa({})}})),this.fieldInfo.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,groupApi:this})}},this.setValue=(s,a)=>{if(this.form.setFieldValue(this.name,s,Ke(a,{dontRunListeners:!0,dontValidate:!0})),!a?.dontRunListeners)this.triggerOnChangeListener();if(!a?.dontValidate)this.validate("change")},this.getMeta=()=>this.store.state.meta,this.setMeta=(s)=>this.form.setFieldMeta(this.name,s),this.getInfo=()=>this.fieldInfo,this.getRelatedFields=()=>{let s=Object.values(this.form.fieldInfo),a=[];for(let l of s){if(!l.instance)continue;if(!(l.instance instanceof $t))continue;if(l.instance.name.startsWith(this.name))a.push(l.instance)}return a},this.getRelatedFieldMetasDerived=()=>{let s=Object.entries(this.form.fieldMetaDerived.state),a=[];for(let[l,r]of s){if(l===this.name)continue;if(yt(this.name,l))a.push({...r,name:l})}return a},this.buildChildFieldName=(s)=>{if(s==="")return this.name;if(s.startsWith("["))return`${this.name}${s}`;return`${this.name}.${s}`},this.distributeFieldErrors=(s,a)=>{let l=this._lastDistributedFieldNames[s]??new Set,r=new Set;if(a)for(let[f,w]of Object.entries(a)){if(w===void 0||w===null||w===!1)continue;r.add(this.buildChildFieldName(f))}let d=new Set([...l,...r]),c=!1;for(let f of d){let w=f.startsWith(this.name+"[")?f.slice(this.name.length):f.slice(this.name.length+1),g=a?.[w],y=this.form.getFieldMeta(f);if(!y&&!g)continue;let x=y?.errorMap[s],m=y?.errorSourceMap[s]==="form",{newErrorValue:i,newSource:b}=Jt({newFormValidatorError:g,isPreviousErrorFromFormValidator:m,previousErrorValue:x});if(i)c=!0;if(x===i&&y?.errorSourceMap[s]===b)continue;this.form.setFieldMeta(f,(_=Ge)=>({..._,errorMap:{..._.errorMap,[s]:i},errorSourceMap:{..._.errorSourceMap,[s]:b}}))}return this._lastDistributedFieldNames[s]=r,c},this.validateSync=(s,a,l={})=>{let r=Tt(s,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||vt}),c=(l.skipRelatedFieldValidation?[]:this.getRelatedFields()).reduce((g,y)=>{let x=Tt(s,{...y.options,form:y.form,validationLogic:y.form.options.validationLogic||vt});return x.forEach((m)=>{m.field=y}),g.concat(x)},[]),f=!1;ze(()=>{let g=(y,x)=>{let m=Sa(x.cause),i=y===this,b=void 0;if(x.validate)b=y.runValidator({validate:x.validate,value:{value:y.store.state.value,validationSource:i?"form":"field",...y instanceof Ht?{groupApi:y}:{fieldApi:y}},type:"validate"});let _=b,M=void 0;if(i&&za(b))_=b.group,M=b.fields;let j=$a(_),Y=a[m],{newErrorValue:z,newSource:ne}=Gt({formLevelError:Y,fieldLevelError:j});if(y.state.meta.errorMap?.[m]!==z)y.setMeta((ie)=>({...ie,errorMap:{...ie.errorMap,[m]:z},errorSourceMap:{...ie.errorSourceMap,[m]:ne}}));if(z)f=!0;if(i){if(this.distributeFieldErrors(m,M))f=!0}};for(let y of r)g(this,y);for(let y of c){if(!y.validate)continue;g(y.field,y)}});let w=Sa("submit");if(this.state.meta.errorMap?.[w]&&s!=="submit"&&!f)this.setMeta((g)=>({...g,errorMap:{...g.errorMap,[w]:void 0},errorSourceMap:{...g.errorSourceMap,[w]:void 0}}));return{hasErrored:f}},this.validateAsync=async(s,a,l={})=>{let r=Vt(s,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||vt}),d=await a,c=l.skipRelatedFieldValidation?[]:this.getRelatedFields(),f=c.reduce((i,b)=>{let _=Vt(s,{...b.options,form:b.form,validationLogic:b.form.options.validationLogic||vt});return _.forEach((M)=>{M.field=b}),i.concat(_)},[]),w=[],g=[],y=r.some((i)=>i.validate)||f.some((i)=>i.validate);if(y){if(!this.state.meta.isValidating)this.setMeta((i)=>({...i,isValidating:!0}));for(let i of c)i.setMeta((b)=>({...b,isValidating:!0}))}let x=(i,b,_)=>{let M=Sa(b.cause),j=i.getInfo();j.validationMetaMap[M]?.lastAbortController.abort();let z=new AbortController;j.validationMetaMap[M]={lastAbortController:z};let ne=i===this;_.push(new Promise(async(ie)=>{let F;try{F=await new Promise((ye,ke)=>{if(i.timeoutIds.validations[b.cause])clearTimeout(i.timeoutIds.validations[b.cause]);i.timeoutIds.validations[b.cause]=setTimeout(async()=>{if(z.signal.aborted)return ye(void 0);try{ye(await this.runValidator({validate:b.validate,value:{value:i.store.state.value,signal:z.signal,validationSource:ne?"form":"field",...i instanceof Ht?{groupApi:i}:{fieldApi:i}},type:"validateAsync"}))}catch(Se){ke(Se)}},b.debounceMs)})}catch(ye){F=ye}if(z.signal.aborted)return ie(void 0);let D=F,I=void 0;if(ne&&za(F))D=F.group,I=F.fields;let W=$a(D),k=d[i.name]?.[M],{newErrorValue:X,newSource:xe}=Gt({formLevelError:k,fieldLevelError:W});if(i.getInfo().instance!==i)return ie(void 0);if(i.setMeta((ye)=>({...ye,errorMap:{...ye?.errorMap,[M]:X},errorSourceMap:{...ye.errorSourceMap,[M]:xe}})),ne)this.distributeFieldErrors(M,I);ie(X)}))};for(let i of r){if(!i.validate)continue;x(this,i,w)}for(let i of f){if(!i.validate)continue;x(i.field,i,g)}let m=[];if(w.length||g.length)m=await Promise.all(w),await Promise.all(g);if(y){this.setMeta((i)=>({...i,isValidating:!1}));for(let i of c)i.setMeta((b)=>({...b,isValidating:!1}))}return m.filter(Boolean)},this.validateAllFields=async(s)=>{let a=[];return ze(()=>{Object.values(this.getRelatedFields()).forEach((r)=>{if(a.push(Promise.resolve().then(()=>r.validate(s,{skipFormValidation:!0,skipGroupValidation:!0}))),!r.store.state.meta.isTouched)r.setMeta((d)=>({...d,isTouched:!0}))})}),(await Promise.all(a)).flat()},this.validateArrayFieldsStartingFrom=(s,a,l)=>this.form.validateArrayFieldsStartingFrom(s,a,l),this.validateField=(s,a)=>this.form.validateField(s,a),this.getFieldValue=(s)=>this.form.getFieldValue(s),this.getFieldMeta=(s)=>this.form.getFieldMeta(s),this.setFieldMeta=(s,a)=>this.form.setFieldMeta(s,a),this.setFieldValue=(s,a)=>this.form.setFieldValue(s,a),this.deleteField=(s)=>this.form.deleteField(s),this.pushFieldValue=(s,a)=>this.form.pushFieldValue(s,a),this.insertFieldValue=(s,a,l)=>this.form.insertFieldValue(s,a,l),this.replaceFieldValue=(s,a,l)=>this.form.replaceFieldValue(s,a,l),this.swapFieldValues=(s,a,l)=>this.form.swapFieldValues(s,a,l),this.moveFieldValues=(s,a,l)=>this.form.moveFieldValues(s,a,l),this.clearFieldValues=(s)=>this.form.clearFieldValues(s),this.resetField=(s)=>this.form.resetField(s),this.removeFieldValue=(s,a)=>this.form.removeFieldValue(s,a),this.areRelatedFieldsValid=()=>Object.values(this.getRelatedFields()).every((s)=>s.state.meta.isValid),this.validate=(s,a)=>{let{fieldsErrorMap:l}=a?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(s,{dontUpdateFormErrorMap:!0,filterFieldNames:(c)=>yt(this.name,c)}),{hasErrored:r}=this.validateSync(s,l[this.name]??{},{skipRelatedFieldValidation:a?.skipRelatedFieldValidation});if(r&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[Sa(s)]?.lastAbortController.abort(),this.state.meta.errors;let d=a?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(s,{dontUpdateFormErrorMap:!0,filterFieldNames:(c)=>yt(this.name,c)});return this.validateAsync(s,d,{skipRelatedFieldValidation:a?.skipRelatedFieldValidation})},this.triggerOnChangeListener=()=>{let s=this.form.options.listeners?.onChangeGroupDebounceMs;if(s&&s>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})},s)}else this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this});let a=this.options.listeners?.onChangeDebounceMs;if(a&&a>0){if(this.timeoutIds.listeners.change)clearTimeout(this.timeoutIds.listeners.change);this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},a)}else this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,groupApi:this})},this._handleSubmit=async(s)=>{this.setFormGroupState((r)=>({...r,isSubmitted:!1,submissionAttempts:r.submissionAttempts+1,isSubmitSuccessful:!1})),ze(()=>{Object.values(this.getRelatedFields()).forEach((r)=>{if(!r.state.meta.isTouched)r.setMeta((d)=>({...d,isTouched:!0}))})});let a=s??this.options.onSubmitMeta;this.setFormGroupState((r)=>({...r,isSubmitting:!0}));let l=()=>{this.setFormGroupState((r)=>({...r,isSubmitting:!1}))};if(await this.validateAllFields("submit"),!this.areRelatedFieldsValid()){l(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:a});return}if(await this.validate("submit",{skipRelatedFieldValidation:!0}),!this.areRelatedFieldsValid()||!this.state.meta.isValid){l(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:a});return}ze(()=>{Object.values(this.getRelatedFields()).forEach((r)=>{r.options.listeners?.onGroupSubmit?.({value:r.state.value,fieldApi:r})})}),this.options.listeners?.onSubmit?.({groupApi:this,value:this.state.value});try{await this.options.onGroupSubmit?.({value:this.state.value,groupApi:this,meta:a}),ze(()=>{this.setFormGroupState((r)=>({...r,isSubmitted:!0,isSubmitSuccessful:!0})),l()})}catch(r){throw this.setFormGroupState((d)=>({...d,isSubmitSuccessful:!1})),l(),r}},this.form=e.form,this.name=e.name,this.options=e,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.fieldInfo={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.store=Ct((s)=>{this.form.formGroupMetaDerived.get(),this.form.baseStore.get();let a=this.form.getFormGroupMeta(this.name)??gs(e.defaultMeta),l=this.form.getFieldValue(this.name);if(!a.isTouched&&l===void 0&&this.options.defaultValue!==void 0&&!ut(l,this.options.defaultValue))l=this.options.defaultValue;if(s&&s.value===l&&s.meta===a)return s;return{value:l,meta:a}}),this.handleSubmit=this.handleSubmit.bind(this)}get state(){return this.store.state}runValidator(e){if(ea(e.validate)){let s=Et[e.type](e.value,e.validate);if(e.type==="validate")return fs(s);return s.then(fs)}return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}}function $a(e){if(e)return e;return}function za(e){return!!e&&typeof e==="object"&&"fields"in e}function fs(e){if(!e||typeof e!=="object")return e;if(!("form"in e)&&!("fields"in e))return e;let{form:s,fields:a,...l}=e;return{...l,group:s,fields:a}}function Sa(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,s){if(!s)return;let a=Object.assign({},e,{state:Kt(e.state)});if(s(a),a.fieldInfo!==e.fieldInfo)e.fieldInfo=a.fieldInfo;if(a.options!==e.options)e.options=a.options;let r=Object.keys({values:null,validationMetaMap:null,fieldMetaBase:null,formGroupStateBase:null,isSubmitting:null,isSubmitted:null,isValidating:null,submissionAttempts:null,isSubmitSuccessful:null,_force_re_eval:null}).reduce((d,c)=>{if(e.state[c]!==a.state[c])d[c]=a.state[c];return d},{});return ze(()=>{if(Object.keys(r).length)e.baseStore.setState((d)=>({...d,...r}));if(a.state.errorMap!==e.state.errorMap)e.setErrorMap(a.state.errorMap)}),a}C();function mr(e,s){return e===s}function Me(e,s=(l)=>l,a){let l=a?.compare??mr,r=N((c)=>{let{unsubscribe:f}=e.subscribe(c);return f},[e]),d=N(()=>e.get(),[e]);return ac(r,d,d,s,l)}var la=(e,s=(l)=>l,a)=>Me(e,s,{compare:a});C();C();C();var xt=typeof window<"u"?He:h;function pr(e){let[s,a]=u(()=>({form:e.form,name:e.name})),[l,r]=u(()=>new $t({...e})),d=l;if(s.form!==e.form||s.name!==e.name)d=new $t({...e}),r(d),a({form:e.form,name:e.name});let c=Me(d.store,e.mode==="array"?(b)=>b.meta._arrayVersion||0:(b)=>b.value),f=Me(d.store,(b)=>b.meta.isTouched),w=Me(d.store,(b)=>b.meta.isBlurred),g=Me(d.store,(b)=>b.meta.isDirty),y=Me(d.store,(b)=>b.meta.errorMap),x=Me(d.store,(b)=>b.meta.errorSourceMap),m=Me(d.store,(b)=>b.meta.isValidating),i=O(()=>({...d,get state(){return{value:e.mode==="array"?d.state.value:c,get meta(){return{...d.state.meta,isTouched:f,isBlurred:w,isDirty:g,errorMap:y,errorSourceMap:x,isValidating:m}}}}}),[d,e.mode,c,f,w,g,y,x,m]);return xt(d.mount,[d]),xt(()=>{d.update(e)}),i}var hs=({children:e,...s})=>{let a=pr(s),l=O(()=>Dt(e,a),[e,a]);return t(B,{children:l})};C();C();function vs(){return u(()=>ra())[0]}var fr=H,bs=fa.split(".")[0]==="17"?vs:fr.useId;C();function vr(e){let[s,a]=u(()=>({form:e.form,name:e.name})),[l,r]=u(()=>new Ht({...e}));if(s.form!==e.form||s.name!==e.name)r(new Ht({...e})),a({form:e.form,name:e.name});let d=Me(l.store,(F)=>F.value),c=Me(l.store,(F)=>F.meta.isTouched),f=Me(l.store,(F)=>F.meta.isBlurred),w=Me(l.store,(F)=>F.meta.isDirty),g=Me(l.store,(F)=>F.meta.errorMap),y=Me(l.store,(F)=>F.meta.errorSourceMap),x=Me(l.store,(F)=>F.meta.isValidating),m=Me(l.store,(F)=>F.meta.isSubmitting),i=Me(l.store,(F)=>F.meta.isSubmitted),b=Me(l.store,(F)=>F.meta.submissionAttempts),_=Me(l.store,(F)=>F.meta.isSubmitSuccessful),M=Me(l.store,(F)=>F.meta.canSubmit),j=Me(l.store,(F)=>F.meta.isValid),Y=Me(l.store,(F)=>F.meta.isFieldsValid),z=Me(l.store,(F)=>F.meta.isFieldsValidating),ne=Me(l.store,(F)=>F.meta.isGroupValid),ie=O(()=>({...l,handleSubmit:(...I)=>l._handleSubmit(...I),get state(){return{...l.state,value:d,get meta(){return{...l.state.meta,isTouched:c,isBlurred:f,isDirty:w,errorMap:g,errorSourceMap:y,isValidating:x,isSubmitting:m,isSubmitted:i,submissionAttempts:b,isSubmitSuccessful:_,canSubmit:M,isValid:j,isFieldsValid:Y,isFieldsValidating:z,isGroupValid:ne}}}}}),[l,d,c,f,w,g,y,x,m,i,b,_,M,j,Y,z,ne]);return xt(l.mount,[l]),xt(()=>{l.update(e)}),ie}var ys=({children:e,...s})=>{let a=vr(s),l=O(()=>Dt(e,a),[e,a]);return t(B,{children:l})};function br({form:e,selector:s=(l)=>l,children:a}){let l=Me(e.store,s);return t(B,{children:Dt(a,l)})}function zt(e){let s=bs(),[a,l]=u(e?.formId),[r,d]=u(()=>new ia({...e,formId:e?.formId??s}));if(a!==e?.formId){let w=e?.formId??s;d(new ia({...e,formId:w})),l(w)}let c=O(()=>{let w={...r,handleSubmit:(...g)=>r._handleSubmit(...g),get formId(){return r._formId},get state(){return r.store.state}};return w.Field=function(y){return t(hs,{...y,form:r})},w.FormGroup=function(y){return t(ys,{...y,form:r})},w.Subscribe=function(y){return t(br,{form:r,selector:y.selector,children:y.children})},w},[r]);xt(r.mount,[]),xt(()=>{r.update(e)});let f=v(!1);return xt(()=>{if(!f.current)return;if(!e?.transform)return;Qa(r,e.transform)},[r,e?.transform]),xt(()=>{f.current=!0}),c}C();var yr=P({name:p().min(1,yw()),type:ot(["chat","autofill","embedding"]),permission:ot(["owner","editor","reviewer"]),avatar:p().optional(),providerId:p().optional(),modelId:p().optional(),soul:p().optional(),thinkingLevel:Tc.optional(),systemPrompt:p().optional(),skills:te(p()).optional(),mcpServerIds:te(p()).optional(),deniedTools:te(p()).optional()}),xr=[{id:"bash",name:()=>gA(),description:()=>hA()},{id:"read_skill",name:()=>IA(),description:()=>EA()},{id:"read_asset",name:()=>am(),description:()=>CA()},{id:"list_assets",name:()=>nm(),description:()=>xA()},{id:"create_folder",name:()=>Jp(),description:()=>yA()},{id:"create_file",name:()=>Yp(),description:()=>AA()},{id:"create_version",name:()=>Xp(),description:()=>_A()},{id:"generate_image",name:()=>tm(),description:()=>vA()},{id:"generate_video",name:()=>rm(),description:()=>wA()},{id:"rename_asset",name:()=>sm(),description:()=>TA()},{id:"move_assets",name:()=>om(),description:()=>SA()},{id:"delete_asset",name:()=>em(),description:()=>bA()}];function _s({isOpen:e,onClose:s,teamId:a,type:l,initialValues:r,title:d}){let c=Q(),{canAdmin:f}=Rt(),{data:w}=L({queryKey:["teams",a,"providers"],queryFn:async()=>{let K=await A.api.teams[":teamId"].providers.$get({param:{teamId:a}});if(!K.ok)throw Error("Failed to fetch providers");return await K.json()},enabled:e}),{data:g}=L({queryKey:["teams",a,"skills"],queryFn:async()=>{let K=await A.api.teams[":teamId"].skills.$get({param:{teamId:a}});if(!K.ok)throw Error("Failed to fetch skills");return await K.json()},enabled:e}),y=g?.skills||[],{data:x}=L({queryKey:["teams",a,"mcp","servers"],queryFn:async()=>{let K=await A.api.teams[":teamId"].mcp.servers.$get({param:{teamId:a}});if(!K.ok)throw Error("Failed to fetch MCP servers");return await K.json()},enabled:e}),m=x?.servers||[],i=O(()=>yr.superRefine((K,J)=>{if(K.type==="chat"||K.type==="autofill"){if(!K.providerId)J.addIssue({code:Qn.custom,message:dS(),path:["providerId"]});if(!K.modelId)J.addIssue({code:Qn.custom,message:lw(),path:["modelId"]})}}),[]),b=zt({defaultValues:{name:r?.name||"",type:r?.type||l||"chat",permission:r?.permission||"reviewer",avatar:r?.avatarPreset||r?.avatar||Ic[0].id,providerId:r?.providerId||"",modelId:r?.modelId||"",soul:r?.soul||"",thinkingLevel:r?.thinkingLevel||"off",systemPrompt:r?.systemPrompt||"",skills:r?.skills?.map((K)=>K.skillId)||[],mcpServerIds:r?.mcpServerIds||[],deniedTools:r?.deniedTools??[...Ig]},validators:{onChange:i},onSubmit:async({value:K})=>{try{if(r?.id)await Se.mutateAsync({id:r.id,values:K});else await ke.mutateAsync(K)}catch{}}}),_=la(b.store,(K)=>K.values.providerId),{data:M,isLoading:j}=L({queryKey:["teams",a,"providers",_,"models"],queryFn:async()=>{let K=await A.api.providers[":id"].models.$get({param:{id:_}});if(!K.ok)throw Error("Failed to fetch models");return await K.json()},enabled:!!_&&e}),[Y,z]=u(""),[ne,ie]=u(!1),F=O(()=>{if(!w)return[];return[...w].sort((K,J)=>K.name.toLowerCase().localeCompare(J.name.toLowerCase()))},[w]),D=O(()=>{if(!Y.trim())return F;let K=Y.toLowerCase();return F.filter((J)=>J.name.toLowerCase().includes(K))},[F,Y]),[I,W]=u(""),[k,X]=u(!1),xe=O(()=>{if(!M)return[];return[...M].sort((K,J)=>{let Ne=(K.name||K.modelId).toLowerCase(),le=(J.name||J.modelId).toLowerCase();return Ne.localeCompare(le)})},[M]),ye=O(()=>{if(!I.trim())return xe;let K=I.toLowerCase();return xe.filter((J)=>J.modelId.toLowerCase().includes(K)||J.name&&J.name.toLowerCase().includes(K))},[xe,I]),ke=U({mutationFn:async(K)=>{let J=await A.api.teams[":teamId"].agents.$post({param:{teamId:a},json:K});if(!J.ok)throw Error("Failed to create agent");return await J.json()},onSuccess:()=>{s(),c.invalidateQueries({queryKey:["agents",a]}),R.success(aA())},onError:(K)=>{R.error(_a({message:K.message}))}}),Se=U({mutationFn:async({id:K,values:J})=>{let Ne=await A.api.agents[":agentId"].$put({param:{agentId:K},json:J});if(!Ne.ok)throw Error("Failed to update agent");return await Ne.json()},onSuccess:()=>{s(),c.invalidateQueries({queryKey:["agents",a]}),R.success(um())},onError:(K)=>{R.error(_a({message:K.message}))}});h(()=>{if(e)b.reset(),z(""),ie(!1),W(""),X(!1)},[e,r,l]);let ee=la(b.store,(K)=>K.values.type),oe=ee==="chat"||ee==="autofill",we=ee==="chat",Fe=(K)=>K.map((J)=>{if(typeof J==="string")return{message:J};if(J&&typeof J==="object"&&"message"in J)return{message:String(J.message)};return{message:String(J||"")}});return t(fe,{open:e,onOpenChange:s,children:o(ce,{className:"sm:max-w-3xl h-[90vh] flex flex-col p-0 overflow-hidden",children:[o(pe,{className:"p-6 pb-2 flex-shrink-0",children:[t(ue,{children:d}),t(It,{children:Wy()})]}),o("form",{onSubmit:(K)=>{K.preventDefault(),K.stopPropagation(),b.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t(se,{className:"flex-1 min-h-0",children:o("div",{className:"p-6 pt-2 space-y-6",children:[o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[t(b.Field,{name:"name",children:(K)=>{let J=!!K.state.meta.errors.length&&K.state.meta.isTouched;return o(Pe,{"data-invalid":J,children:[t($e,{children:lA()}),t(q,{value:K.state.value,onBlur:K.handleBlur,onChange:(Ne)=>K.handleChange(Ne.target.value),placeholder:cA(),"aria-invalid":J}),J&&t(Qe,{errors:Fe(K.state.meta.errors)})]})}}),t(b.Field,{name:"type",children:(K)=>o(Pe,{children:[t($e,{children:kA()}),o(De,{value:K.state.value,onValueChange:(J)=>K.handleChange(J),disabled:!0,children:[t(Le,{className:"bg-muted/50",children:t(Ze,{})}),o(Be,{children:[t(re,{value:"chat",children:lm()}),t(re,{value:"autofill",children:im()}),t(re,{value:"embedding",children:cm()})]})]})]})}),we&&t(b.Field,{name:"permission",children:(K)=>o(Pe,{children:[t($e,{children:Yf()}),o(De,{value:K.state.value||"reviewer",onValueChange:(J)=>K.handleChange(J),disabled:!f,children:[t(Le,{children:t(Ze,{})}),o(Be,{children:[t(re,{value:"reviewer",children:pi()}),t(re,{value:"editor",children:mi()}),t(re,{value:"owner",children:hi()})]})]})]})}),t(b.Field,{name:"avatar",children:(K)=>o(Pe,{className:"md:col-span-2",children:[t($e,{children:oA()}),o("div",{className:"flex flex-wrap gap-4 mt-2",children:[Ic.map((J)=>{let Ne=K.state.value===J.id;return t("button",{type:"button",onClick:()=>K.handleChange(J.id),className:E("relative w-14 h-14 rounded-full overflow-hidden border-2 transition-all hover:scale-105",Ne?"border-primary ring-2 ring-primary ring-offset-2":"border-border hover:border-muted-foreground"),children:t("img",{src:J.preview,className:"w-full h-full object-cover",alt:$x()})},J.id)}),K.state.value&&!Ic.some((J)=>J.id===K.state.value)&&t("button",{type:"button",className:"relative w-14 h-14 rounded-full overflow-hidden border-2 border-primary ring-2 ring-primary ring-offset-2 scale-105",children:t("img",{src:K.state.value,className:"w-full h-full object-cover",alt:T0()})})]})]})})]}),oe&&o(B,{children:[o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 p-4 bg-muted/50 rounded-xl border border-border",children:[t(b.Field,{name:"providerId",children:(K)=>{let J=!!K.state.meta.errors.length&&K.state.meta.isTouched,Ne=w?.find((le)=>le.id===K.state.value);return o(Pe,{"data-invalid":J,children:[t($e,{children:lS()}),o(ht,{open:ne,onOpenChange:(le)=>{if(ie(le),!le)z("")},modal:!0,children:[t(gt,{asChild:!0,children:o(S,{type:"button",variant:"outline",role:"combobox","aria-expanded":ne,"aria-invalid":J,className:E("w-full justify-between font-normal h-10 px-3 bg-background border-border hover:bg-accent/50",J&&"border-destructive ring-destructive"),children:[t("span",{className:"truncate",children:Ne?t("span",{className:"font-medium text-foreground truncate",children:Ne.name}):t("span",{className:"text-muted-foreground",children:NC()})}),t(_e,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),o(At,{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:(le)=>le.stopPropagation(),children:[o("div",{className:"relative p-2 pb-1.5 border-b border-border shrink-0",children:[t(Lt,{className:"absolute left-4.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),t(q,{placeholder:tg(),value:Y,onChange:(le)=>z(le.target.value),className:"pl-8 h-8 text-xs bg-muted/40",autoFocus:!0})]}),t(se,{className:"w-full p-1",style:{height:D.length===0?"96px":`${Math.min(D.length*38+8,256)}px`},onWheel:(le)=>le.stopPropagation(),children:D.length===0?t("div",{className:"flex items-center justify-center h-full py-6 text-xs text-muted-foreground",children:Gw()}):t("div",{className:"space-y-0.5 pr-2",children:D.map((le)=>{let lt=K.state.value===le.id;return o("div",{onClick:()=>{K.handleChange(le.id),b.setFieldValue("modelId",""),W(""),ie(!1),z("")},className:E("flex items-center justify-between px-2.5 py-2 rounded-md text-xs cursor-pointer transition-colors",lt?"bg-accent text-accent-foreground font-medium":"hover:bg-muted/60 text-foreground"),children:[t("span",{className:"truncate flex-1 pr-2",children:le.name}),lt&&t(Te,{className:"w-4 h-4 text-primary shrink-0"})]},le.id)})})})]})]}),J&&t(Qe,{errors:Fe(K.state.meta.errors)})]})}}),t(b.Field,{name:"modelId",children:(K)=>{let J=!!K.state.meta.errors.length&&K.state.meta.isTouched,Ne=M?.find((le)=>le.id===K.state.value);return o(Pe,{"data-invalid":J,children:[o($e,{className:"flex items-center gap-2",children:[nw(),j&&t(Z,{className:"w-3 h-3 animate-spin"})]}),o(ht,{open:k,onOpenChange:(le)=>{if(X(le),!le)W("")},modal:!0,children:[t(gt,{asChild:!0,children:o(S,{type:"button",variant:"outline",role:"combobox","aria-expanded":k,"aria-invalid":J,disabled:!_||j,className:E("w-full justify-between font-normal h-10 px-3 bg-background border-border hover:bg-accent/50",J&&"border-destructive ring-destructive"),children:[t("span",{className:"truncate flex items-center gap-2",children:Ne?o(B,{children:[t("span",{className:"truncate font-medium text-foreground",children:Ne.name||Ne.modelId}),Ne.name&&Ne.name!==Ne.modelId&&t(be,{variant:"secondary",className:"font-mono text-[10px] px-1.5 py-0 shrink-0",children:Ne.modelId})]}):t("span",{className:"text-muted-foreground",children:MC()})}),t(_e,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),o(At,{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:(le)=>le.stopPropagation(),children:[o("div",{className:"relative p-2 pb-1.5 border-b border-border shrink-0",children:[t(Lt,{className:"absolute left-4.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),t(q,{placeholder:Vf(),value:I,onChange:(le)=>W(le.target.value),className:"pl-8 h-8 text-xs bg-muted/40",autoFocus:!0})]}),t(se,{className:"w-full p-1",style:{height:ye.length===0?"96px":`${Math.min(ye.length*38+8,256)}px`},onWheel:(le)=>le.stopPropagation(),children:ye.length===0?t("div",{className:"flex items-center justify-center h-full py-6 text-xs text-muted-foreground",children:Wu()}):t("div",{className:"space-y-0.5 pr-2",children:ye.map((le)=>{let lt=K.state.value===le.id;return o("div",{onClick:()=>{K.handleChange(le.id),X(!1),W("")},className:E("flex items-center justify-between px-2.5 py-2 rounded-md text-xs cursor-pointer transition-colors",lt?"bg-accent text-accent-foreground font-medium":"hover:bg-muted/60 text-foreground"),children:[t("div",{className:"min-w-0 flex-1 pr-2",children:o("div",{className:"flex items-center gap-2",children:[t("span",{className:"truncate",children:le.name||le.modelId}),le.name&&le.name!==le.modelId&&o("span",{className:"font-mono text-[10px] text-muted-foreground truncate",children:["(",le.modelId,")"]}),le.config?.reasoning&&t(be,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 gap-0.5 bg-primary/10 text-primary border-primary/20 shrink-0",children:t(Ot,{className:"w-2.5 h-2.5"})})]})}),lt&&t(Te,{className:"w-4 h-4 text-primary shrink-0"})]},le.id)})})})]})]}),J&&t(Qe,{errors:Fe(K.state.meta.errors)})]})}}),t("div",{className:"md:col-span-2",children:t(b.Field,{name:"thinkingLevel",children:(K)=>{let J={off:FE(),low:HE(),medium:GE(),high:jE()};return o(Pe,{children:[t($e,{children:qE()}),o(De,{value:K.state.value,onValueChange:(Ne)=>K.handleChange(Ne),children:[t(Le,{children:t(Ze,{})}),t(Be,{children:Tc.options.map((Ne)=>t(re,{value:Ne,children:J[Ne]||Ne},Ne))})]})]})}})})]}),t(b.Field,{name:"soul",children:(K)=>o(Pe,{children:[t($e,{children:pA()}),t(Xa,{value:K.state.value,onBlur:K.handleBlur,onChange:(J)=>K.handleChange(J.target.value),placeholder:mA(),className:"min-h-[120px]"})]})}),o("div",{className:"space-y-4",children:[o(G,{className:"text-base font-bold flex items-center gap-2",children:[t(wt,{className:"w-5 h-5 text-primary"}),cg()]}),t("div",{className:"space-y-2",children:t(b.Field,{name:"skills",children:(K)=>o(B,{children:[y.map((J)=>{let Ne=K.state.value?.includes(J.id)||!1;return o("div",{className:"flex items-center justify-between p-3 bg-muted/30 border border-border rounded-lg",children:[o("div",{className:"flex items-center gap-3",children:[t(wt,{className:"w-4 h-4 text-muted-foreground"}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium",children:J.name}),J.description&&t("span",{className:"text-[10px] text-muted-foreground line-clamp-1",children:J.description})]})]}),o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-xs text-muted-foreground",children:Ne?nf():tf()}),t(je,{checked:Ne,onCheckedChange:(le)=>{if(le)K.handleChange([...K.state.value||[],J.id]);else K.handleChange((K.state.value||[]).filter((lt)=>lt!==J.id))}})]})]},J.id)}),y.length===0&&t("div",{className:"text-center py-8 border-2 border-dashed border-border rounded-xl",children:t("p",{className:"text-sm text-muted-foreground",children:Kw()})})]})})})]}),o("div",{className:"space-y-4 border-t border-border pt-6",children:[o(G,{className:"text-base font-bold flex items-center gap-2",children:[t(on,{className:"w-5 h-5 text-primary"}),Ac()]}),t("div",{className:"space-y-2",children:t(b.Field,{name:"mcpServerIds",children:(K)=>o(B,{children:[m.map((J)=>{let Ne=K.state.value?.includes(J.id)||!1,le=J.status==="needs_auth"||!J.hasCredential&&J.authType==="oauth";return o("div",{className:"flex items-center justify-between p-3 bg-muted/30 border border-border rounded-lg",children:[o("div",{className:"flex items-center gap-3",children:[t(on,{className:"w-4 h-4 text-muted-foreground"}),o("div",{className:"flex flex-col",children:[o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-sm font-medium",children:J.name}),o(be,{variant:"outline",className:"text-[10px]",children:[J.toolCount??0," tools"]}),le&&t(be,{variant:"secondary",className:"text-[10px] bg-amber-500/10 text-amber-600 border-amber-500/20",children:sh()})]}),t("span",{className:"text-[10px] font-mono text-muted-foreground line-clamp-1",children:J.url})]})]}),o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-xs text-muted-foreground",children:Ne?nf():tf()}),t(je,{checked:Ne,onCheckedChange:(lt)=>{if(lt)K.handleChange([...K.state.value||[],J.id]);else K.handleChange((K.state.value||[]).filter((jt)=>jt!==J.id))}})]})]},J.id)}),m.length===0&&t("div",{className:"text-center py-6 border-2 border-dashed border-border rounded-xl",children:t("p",{className:"text-xs text-muted-foreground",children:Ah()})})]})})})]}),o("div",{className:"space-y-4 border-t border-border pt-6",children:[o(G,{className:"text-base font-bold flex items-center gap-2",children:[t(ho,{className:"w-5 h-5 text-primary"}),MA()]}),t("p",{className:"text-xs text-muted-foreground",children:RA()}),t("div",{className:"space-y-2",children:t(b.Field,{name:"deniedTools",children:(K)=>{let J=K.state.value||[];return t(B,{children:xr.map((Ne)=>{let le=!J.includes(Ne.id);return o("div",{className:"flex items-center justify-between p-3 bg-muted/30 border border-border rounded-lg",children:[o("div",{className:"flex items-center gap-3",children:[t(ho,{className:"w-4 h-4 text-muted-foreground"}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium",children:Ne.name()}),t("span",{className:"text-[10px] text-muted-foreground line-clamp-1",children:Ne.description()})]})]}),o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-xs text-muted-foreground",children:le?nf():tf()}),t(je,{checked:le,disabled:!f,onCheckedChange:(lt)=>{if(lt)K.handleChange(J.filter((jt)=>jt!==Ne.id));else K.handleChange([...J,Ne.id])}})]})]},Ne.id)})})}})})]})]})]})}),o(qe,{className:"p-6 pt-4 border-t border-border flex-shrink-0",children:[t(S,{variant:"outline",onClick:s,type:"button",children:Re()}),t(b.Subscribe,{selector:(K)=>[K.canSubmit,K.isSubmitting],children:([K,J])=>o(S,{type:"submit",className:"bg-primary hover:bg-primary/90 text-primary-foreground min-w-[120px]",disabled:!K||J||ke.isPending||Se.isPending,children:[(J||ke.isPending||Se.isPending)&&t(Z,{className:"w-4 h-4 animate-spin mr-2"}),r?va():h0()]})})]})]})]})})}var _r=[{type:"chat",label:"Chat",icon:lo},{type:"autofill",label:"Autofill",icon:Ot},{type:"embedding",label:"Embedding",icon:Wn}];function ws({teamId:e}){let s=Q(),{canAdmin:a}=Rt(),[l,r]=u(!1),[d,c]=u("chat"),[f,w]=u(null),[g,y]=u(null),[x,m]=u(!1),[i,b]=u({chat:!0,autofill:!0,embedding:!0}),_=(F)=>{if(F==="chat")return lm();if(F==="autofill")return im();return cm()},{data:M=[],isLoading:j}=L({queryKey:["agents",e],queryFn:async()=>{let F=await A.api.teams[":teamId"].agents.$get({param:{teamId:e}});if(!F.ok)throw Error("failed to fetch agents");return[...await F.json()].sort((I,W)=>W.id.localeCompare(I.id))}}),Y=U({mutationFn:async(F)=>{if(!(await A.api.agents[":agentId"].$delete({param:{agentId:F}})).ok)throw Error("failed to delete agent")},onSuccess:()=>{m(!1),s.invalidateQueries({queryKey:["agents",e]}),R.success(sA())},onError:(F)=>{R.error(F.message)}}),z=U({mutationFn:async({agentId:F,permission:D})=>{let I=await A.api.agents[":agentId"].permission.$patch({param:{agentId:F},json:{permission:D}});if(!I.ok)throw Error(Yi());return I.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["agents",e]})},onError:(F)=>{R.error(F.message||Yi())}}),ne=U({mutationFn:async(F)=>{let D=await A.api.agents[":agentId"].$put({param:{agentId:F.agentId},json:{name:F.name,type:F.type,enabled:F.enabled,avatar:F.avatar,providerId:F.providerId,modelId:F.modelId,thinkingLevel:F.thinkingLevel,systemPrompt:F.systemPrompt,soul:F.soul,skills:F.skills,deniedTools:F.deniedTools}});if(!D.ok)throw Error("failed to update agent");return D.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["agents",e]}),R.success(um())},onError:(F)=>{R.error(F.message)}}),ie=(F)=>{b((D)=>({...D,[F]:!D[F]}))};return o(B,{children:[(l||f)&&t(_s,{isOpen:!0,title:f?Nm({name:f.name}):S0({type:_(d)}),onClose:()=>{r(!1),w(null)},teamId:e,type:d,initialValues:f||void 0}),t(We,{open:x,onOpenChange:m,children:o(Ye,{children:[o(Je,{children:[t(et,{children:Du()}),t(tt,{children:j0({name:g?.name??""})})]}),o(Xe,{children:[t(nt,{children:Re()}),t(rt,{className:"bg-destructive hover:bg-destructive/90 text-white",onClick:(F)=>{if(Y.isPending){F.preventDefault();return}if(g)Y.mutate(g.id)},children:Y.isPending?t(Z,{className:"w-4 h-4 animate-spin"}):F0()})]})]})}),j&&M.length===0?t("div",{className:"flex items-center justify-center p-12",children:t(Z,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):o("div",{className:"space-y-6 max-w-5xl mx-auto relative",children:[j&&t("div",{className:"absolute top-0 right-0 p-2",children:t(Z,{className:"w-4 h-4 animate-spin text-muted-foreground"})}),_r.map((F)=>{let D=M.filter((k)=>k.type===F.type),I=F.icon,W=F.type==="autofill"||F.type==="embedding";return o("div",{className:"bg-card rounded-xl border border-border overflow-hidden",children:[o("div",{className:E("px-6 py-4 flex items-center justify-between",!W&&"cursor-pointer hover:bg-muted/50 transition-colors"),onClick:!W?()=>ie(F.type):void 0,children:[o("div",{className:"flex items-center gap-2",children:[t("h3",{className:"font-semibold text-foreground",children:F.type==="chat"?By():F.type==="autofill"?gy():__()}),!W&&t(be,{variant:"secondary",className:"h-5 px-1.5 min-w-[1.25rem] text-[10px]",children:D.length})]}),o("div",{className:"flex items-center gap-2",children:[!(W&&D.length>0)&&t(S,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full bg-primary/10 text-primary hover:bg-primary/20",onClick:(k)=>{k.stopPropagation(),c(F.type),r(!0)},children:t(de,{className:"w-4 h-4"})}),!W&&t(_e,{className:E("w-5 h-5 text-muted-foreground transition-transform duration-200",i[F.type]?"rotate-180":"")})]})]}),(W||i[F.type])&&t("div",{className:"px-6 pb-6 pt-2 space-y-3",children:o("div",{className:"grid grid-cols-1 gap-4",children:[D.map((k)=>t(St,{className:"group relative overflow-hidden border-border hover:border-primary/50 transition-all duration-200 cursor-pointer pb-1 pt-1",onClick:()=>w(k),children:o(Mt,{className:"p-4 flex flex-col gap-3",children:[o("div",{className:"flex items-center justify-between",children:[o("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[t("div",{className:"w-10 h-10 rounded-full bg-muted flex items-center justify-center overflow-hidden",children:k.avatar?t("img",{src:k.avatar,className:"w-full h-full object-cover",alt:""}):t(bt,{className:"w-6 h-6 text-muted-foreground"})}),o("div",{className:"min-w-0 flex-1",children:[t("span",{className:"font-bold text-foreground block truncate",children:k.name}),t("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:o("span",{className:"flex items-center gap-1",children:[t(wt,{className:"w-3 h-3"}),XC({count:k.skills?.length||0})]})})]})]}),o(he,{modal:!1,children:[t(ge,{asChild:!0,onClick:(X)=>X.stopPropagation(),children:t(S,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:t(Ar,{className:"w-4 h-4"})})}),t(Ae,{align:"end",className:"w-32",children:o(V,{onClick:(X)=>{X.stopPropagation(),y(k),m(!0)},className:"text-red-500 focus:text-red-500 gap-2 cursor-pointer",children:[t(ve,{className:"w-4 h-4"})," ",at()]})})]})]}),o("div",{className:"flex items-center justify-between gap-2 pt-2 border-t border-border/50",children:[t("div",{children:k.type==="chat"?t("div",{onClick:(X)=>X.stopPropagation(),children:o(De,{value:k.permission||"reviewer",onValueChange:(X)=>{z.mutate({agentId:k.id,permission:X})},disabled:!a,children:[t(Le,{className:"h-7 text-xs px-2 bg-background border-border w-[140px]",children:t(Ze,{children:k.permission==="reviewer"?pi():k.permission==="editor"?mi():hi()})}),o(Be,{align:"start",children:[t(re,{value:"reviewer",children:pi()}),t(re,{value:"editor",children:mi()}),t(re,{value:"owner",children:hi()})]})]})}):t("div",{})}),t("div",{onClick:(X)=>X.stopPropagation(),children:t(je,{checked:k.enabled,onCheckedChange:(X)=>{ne.mutate({teamId:e,agentId:k.id,name:k.name,type:k.type,enabled:X,avatar:k.avatar,providerId:k.providerId,modelId:k.modelId,thinkingLevel:k.thinkingLevel,systemPrompt:k.systemPrompt,soul:k.soul,skills:k.skills?.map((xe)=>xe.skillId),deniedTools:k.deniedTools})}})})]})]})},k.id)),D.length===0&&o("div",{className:"col-span-full py-8 flex flex-col items-center justify-center border-2 border-dashed border-border rounded-xl bg-muted/30",children:[t("div",{className:"w-10 h-10 rounded-full bg-card flex items-center justify-center shadow-sm mb-3",children:t(I,{className:"w-5 h-5 text-muted-foreground"})}),t("p",{className:"text-sm text-muted-foreground",children:kw({type:_(F.type)})}),t(S,{variant:"link",size:"sm",className:"text-primary font-medium h-auto p-0 mt-1",onClick:()=>{c(F.type),r(!0)},children:b0()})]})]})})]},F.type)})]})]})}C();C();function Ca({isOpen:e,onClose:s,onSubmit:a,initialValues:l,title:r,isLoading:d=!1,defaultApi:c,existingModelIds:f=[]}){let w=O(()=>Tg.extend({modelId:p().min(1,lh()).refine((m)=>{if(l?.modelId===m)return!0;return!f.includes(m)},{message:sw()})}),[f,l]),g=()=>l||{modelId:"",name:"",config:{api:c,reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},y=zt({defaultValues:g(),validators:{onSubmit:w},onSubmit:async({value:m})=>{a(m)}});h(()=>{if(e)y.reset(g())},[e,l,c,y]);let x=(m)=>m.map((i)=>{if(typeof i==="string")return{message:i};if(i&&typeof i==="object"&&"message"in i)return{message:String(i.message)};return{message:String(i||"")}});return t(fe,{open:e,onOpenChange:s,children:o(ce,{className:"sm:max-w-xl h-[85vh] max-h-[700px] flex flex-col p-0 overflow-hidden",children:[t(pe,{className:"p-6 pb-2 shrink-0",children:t(ue,{className:"text-xl",children:r})}),o("form",{onSubmit:(m)=>{m.preventDefault(),m.stopPropagation(),y.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t("div",{className:"flex-1 min-h-0",children:t(se,{className:"h-full",children:o("div",{className:"p-6 pt-2 space-y-6 pr-6",children:[o("div",{className:"space-y-4",children:[t(y.Field,{name:"modelId",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Pe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,children:lh()}),t(q,{id:m.name,name:m.name,value:m.state.value,onBlur:m.handleBlur,onChange:(b)=>m.handleChange(b.target.value),placeholder:iw(),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}}),t(y.Field,{name:"name",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Pe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,children:l_()}),t(q,{id:m.name,name:m.name,value:m.state.value||"",onBlur:m.handleBlur,onChange:(b)=>m.handleChange(b.target.value),placeholder:cw(),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}})]}),o("div",{className:"space-y-4 pt-2 border-t border-border",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:Px()}),t(y.Field,{name:"config.reasoning",children:(m)=>o(Pe,{orientation:"horizontal",className:"rounded-lg border border-border p-3 shadow-sm bg-muted/40 justify-between flex items-center",children:[t($e,{htmlFor:m.name,className:"cursor-pointer",children:jf()}),t(je,{id:m.name,checked:m.state.value,onCheckedChange:m.handleChange})]})}),o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t(y.Field,{name:"config.contextWindow",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Pe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:o0()}),t(q,{id:m.name,name:m.name,type:"number",value:m.state.value,onBlur:m.handleBlur,onChange:(b)=>m.handleChange(parseInt(b.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}}),t(y.Field,{name:"config.maxTokens",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Pe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:vv()}),t(q,{id:m.name,name:m.name,type:"number",value:m.state.value,onBlur:m.handleBlur,onChange:(b)=>m.handleChange(parseInt(b.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}})]})]}),o("div",{className:"space-y-4 pt-2 border-t border-border",children:[o("h4",{className:"text-sm font-semibold text-foreground flex items-center gap-1.5",children:[t(Gs,{className:"w-4 h-4 text-primary"}),Qx()]}),o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t(y.Field,{name:"config.cost.input",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Pe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:Kb()}),t(q,{id:m.name,name:m.name,type:"number",step:"0.0001",value:m.state.value,onBlur:m.handleBlur,onChange:(b)=>m.handleChange(parseFloat(b.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}}),t(y.Field,{name:"config.cost.output",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Pe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:Ix()}),t(q,{id:m.name,name:m.name,type:"number",step:"0.0001",value:m.state.value,onBlur:m.handleBlur,onChange:(b)=>m.handleChange(parseFloat(b.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}}),t(y.Field,{name:"config.cost.cacheRead",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Pe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:Ny()}),t(q,{id:m.name,name:m.name,type:"number",step:"0.0001",value:m.state.value,onBlur:m.handleBlur,onChange:(b)=>m.handleChange(parseFloat(b.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}}),t(y.Field,{name:"config.cost.cacheWrite",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Pe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:Oy()}),t(q,{id:m.name,name:m.name,type:"number",step:"0.0001",value:m.state.value,onBlur:m.handleBlur,onChange:(b)=>m.handleChange(parseFloat(b.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:x(m.state.meta.errors)})]})}})]})]})]})})}),o(qe,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[t(S,{type:"button",variant:"outline",onClick:s,disabled:d,children:Re()}),t(y.Subscribe,{selector:(m)=>[m.canSubmit,m.isSubmitting],children:([m,i])=>t(S,{type:"submit",className:"min-w-[100px]",disabled:!m||i||d,children:i||d?t(Z,{className:"w-4 h-4 animate-spin"}):va()})})]})]})]})})}C();function Ns({isOpen:e,onClose:s,teamId:a,syncData:l,onSuccess:r}){let[d,c]=u(""),[f,w]=u(()=>new Set(l?.providers.map((D)=>D.name)||[])),[g,y]=u(()=>{let D=new Set;return l?.providers.forEach((I)=>{I.models.forEach((W)=>{D.add(`${I.name}:${W.modelId}`)})}),D});h(()=>{if(l){w(new Set(l.providers.map((I)=>I.name)));let D=new Set;l.providers.forEach((I)=>{I.models.forEach((W)=>{D.add(`${I.name}:${W.modelId}`)})}),y(D)}},[l]);let x=O(()=>{if(!l)return[];let D=d.trim().toLowerCase();if(!D)return l.providers;return l.providers.map((I)=>{let W=I.name.toLowerCase().includes(D),k=I.models.filter((X)=>W||X.modelId.toLowerCase().includes(D)||X.name.toLowerCase().includes(D));if(k.length>0)return{...I,models:k};return null}).filter((I)=>I!==null)},[l,d]),m=g.size,i=O(()=>{if(!l)return 0;let D=0;for(let I of l.providers)if(I.models.some((k)=>g.has(`${I.name}:${k.modelId}`)))D++;return D},[l,g]),b=(D)=>{w((I)=>{let W=new Set(I);if(W.has(D))W.delete(D);else W.add(D);return W})},_=()=>{if(!l)return;w(new Set(l.providers.map((D)=>D.name)))},M=()=>{w(new Set)},j=(D,I)=>{let W=`${D}:${I}`;y((k)=>{let X=new Set(k);if(X.has(W))X.delete(W);else X.add(W);return X})},Y=(D)=>{let I=l?.providers.find((k)=>k.name===D);if(!I||I.models.length===0)return;let W=I.models.every((k)=>g.has(`${D}:${k.modelId}`));y((k)=>{let X=new Set(k);return I.models.forEach((xe)=>{let ye=`${D}:${xe.modelId}`;if(W)X.delete(ye);else X.add(ye)}),X})},z=()=>{if(!l)return;let D=new Set;l.providers.forEach((I)=>{I.models.forEach((W)=>{D.add(`${I.name}:${W.modelId}`)})}),y(D)},ne=()=>{y(new Set)},ie=U({mutationFn:async(D)=>{let I=await A.api.teams[":teamId"].providers["sync-apply"].$post({param:{teamId:a},json:D});if(!I.ok){let W=await I.json().catch(()=>({message:"Failed to apply sync"}));throw Error(W.message||"Failed to apply sync")}return await I.json()},onSuccess:(D)=>{R.success(EE({modelCount:D.addedModels,providerCount:D.addedProviders})),r(),s()},onError:(D)=>{R.error(D.message)}}),F=async()=>{if(!l||m===0)return;let D=[];for(let I of l.providers){let W=I.models.filter((k)=>g.has(`${I.name}:${k.modelId}`));if(W.length>0)D.push({name:I.name,isNewProvider:I.isNewProvider,config:I.config,models:W})}if(D.length===0)return;await ie.mutateAsync({providers:D})};return t(fe,{open:e,onOpenChange:(D)=>!D&&s(),children:o(ce,{className:"sm:max-w-3xl md:max-w-4xl w-full h-[85vh] max-h-[85vh] flex flex-col p-0 overflow-hidden gap-0",children:[o(pe,{className:"p-6 pb-4 shrink-0",children:[o(ue,{className:"flex items-center gap-2 text-xl font-semibold",children:[t(Yr,{className:"w-5 h-5 text-primary"}),AE()]}),t(It,{className:"text-xs text-muted-foreground leading-relaxed mt-1.5",children:gE()})]}),t("div",{className:"px-6 pb-3 shrink-0",children:o("div",{className:"flex items-center justify-between gap-3",children:[o("div",{className:"relative flex-1",children:[t(Lt,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),t(q,{value:d,onChange:(D)=>c(D.target.value),placeholder:xE(),className:"pl-8 h-8 text-xs bg-background"})]}),o("div",{className:"flex items-center gap-1.5",children:[t(S,{type:"button",variant:"outline",size:"sm",onClick:_,className:"h-8 text-xs px-2.5",children:_E()}),t(S,{type:"button",variant:"outline",size:"sm",onClick:M,className:"h-8 text-xs px-2.5",children:pE()}),t("div",{className:"w-px h-4 bg-border mx-1"}),t(S,{type:"button",variant:"outline",size:"sm",onClick:z,className:"h-8 text-xs px-2.5",children:SE()}),t(S,{type:"button",variant:"outline",size:"sm",onClick:ne,className:"h-8 text-xs px-2.5",children:hE()})]})]})}),t("div",{className:"flex-1 min-h-0 px-6 overflow-hidden",children:t(se,{className:"h-full border border-border/60 rounded-md bg-muted/20",children:t("div",{className:"p-3 space-y-3",children:x.length===0?t("div",{className:"py-8 text-center text-sm text-muted-foreground",children:gh()}):x.map((D)=>{let I=f.has(D.name),W=D.isNewProvider,k=D.models.filter((ye)=>g.has(`${D.name}:${ye.modelId}`)).length,X=k===D.models.length,xe=k>0&&!X;return o("div",{className:"border border-border/50 rounded-lg bg-background overflow-hidden",children:[o("div",{className:"flex items-center justify-between px-3 py-2 bg-card hover:bg-muted/40 transition-colors",children:[o("div",{className:"flex items-center gap-2.5",children:[t("button",{type:"button",onClick:()=>b(D.name),className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",children:I?t(_e,{className:"w-4 h-4"}):t(ft,{className:"w-4 h-4"})}),t(Mr,{checked:X?!0:xe?"indeterminate":!1,onCheckedChange:()=>Y(D.name),id:`provider-check-${D.name}`}),o("label",{htmlFor:`provider-check-${D.name}`,className:"font-medium text-sm text-foreground flex items-center gap-2 cursor-pointer select-none",children:[t(Wn,{className:"w-4 h-4 text-muted-foreground"}),t("span",{children:D.name})]})]}),o("div",{className:"flex items-center gap-2",children:[W?t(be,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-primary/10 text-primary border-primary/20",children:vE()}):t(be,{variant:"outline",className:"text-[10px] px-1.5 py-0 text-muted-foreground",children:yE()}),t("span",{className:"text-xs text-muted-foreground",children:bE({count:D.models.length})})]})]}),I&&t("div",{className:"border-t border-border/40 divide-y divide-border/30 bg-muted/10",children:D.models.map((ye)=>{let ke=g.has(`${D.name}:${ye.modelId}`);return o("div",{className:"flex items-center justify-between pl-9 pr-3 py-2 hover:bg-muted/30 transition-colors",children:[o("div",{className:"flex items-center gap-2.5 min-w-0",children:[t(Mr,{checked:ke,onCheckedChange:()=>j(D.name,ye.modelId),id:`model-check-${D.name}-${ye.modelId}`}),o("label",{htmlFor:`model-check-${D.name}-${ye.modelId}`,className:"text-xs font-medium text-foreground cursor-pointer select-none truncate",children:[ye.name||ye.modelId,t("span",{className:"ml-1.5 text-[11px] text-muted-foreground font-mono font-normal",children:ye.modelId})]})]}),o("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[ye.config.reasoning&&t(be,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-normal border-amber-500/30 text-amber-600 dark:text-amber-400",children:wE()}),t("span",{className:"text-[11px] text-muted-foreground font-mono",children:mE({count:Math.round(ye.config.contextWindow/1000)})})]})]},ye.modelId)})})]},D.name)})})})}),o(qe,{className:"p-6 pt-3 shrink-0 border-t border-border flex items-center justify-between sm:justify-between w-full",children:[t("div",{className:"text-xs text-muted-foreground",children:CE({modelCount:m,providerCount:i})}),o("div",{className:"flex items-center gap-2",children:[t(S,{type:"button",variant:"outline",onClick:s,disabled:ie.isPending,children:Re()}),t(S,{type:"button",onClick:F,disabled:m===0||ie.isPending,className:"gap-2",children:ie.isPending?o(B,{children:[t(Z,{className:"w-4 h-4 animate-spin"}),dE()]}):uE({count:m})})]})]})]})})}var Ss={"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 Cs({teamId:e}){let s=Q(),[a,l]=u(null),[r,d]=u(!1),[c,f]=u(""),[w,g]=u(!1),[y,x]=u(null),[m,i]=u(!1),[b,_]=u(null),M=U({mutationFn:async()=>{let I=await A.api.teams[":teamId"].providers["sync-check"].$post({param:{teamId:e}});if(!I.ok){let W=await I.json().catch(()=>({message:"Failed to check updates"}));throw Error(W.message||"Failed to check updates")}return await I.json()},onSuccess:(I)=>{if(I.totalNewModels===0&&I.totalNewProviders===0){R.info(IE());return}_(I),i(!0)},onError:(I)=>{R.error(I.message)}}),{data:j,isLoading:Y}=L({queryKey:["teams",e,"providers"],queryFn:async()=>{let I=await A.api.teams[":teamId"].providers.$get({param:{teamId:e}});if(!I.ok)throw Error("Failed to fetch providers");return await I.json()}}),z=O(()=>j?.find((I)=>I.id===a)||null,[j,a]),ne=O(()=>j?.map((I)=>I.name)||[],[j]),ie=O(()=>{if(!j)return[];if(!c.trim())return j;let I=c.toLowerCase();return j.filter((W)=>W.name.toLowerCase().includes(I))},[j,c]),F=U({mutationFn:async(I)=>{let W=await A.api.teams[":teamId"].providers.$post({param:{teamId:e},json:{name:I.name,config:I.config,models:I.models}});if(!W.ok)throw Error("Failed to create provider");return await W.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"providers"]}),d(!1),R.success(cS())},onError:(I)=>{R.error(_a({message:I.message}))}}),D=U({mutationFn:async(I)=>{let W=await A.api.providers[":id"].$delete({param:{id:I}});if(!W.ok)throw Error("Failed to delete provider");return await W.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"providers"]}),l(null),g(!1),x(null),R.success(uS())},onError:(I)=>{R.error(_a({message:I.message}))}});if(Y)return t("div",{className:"flex h-64 items-center justify-center",children:t(Z,{className:"h-8 w-8 animate-spin text-primary"})});return o("div",{className:"h-full flex flex-col space-y-0",children:[o("div",{className:"flex-none space-y-4 pb-4",children:[o("div",{className:"flex items-center justify-between",children:[o("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[t(Wn,{className:"w-5 h-5 text-primary"}),Xy()]}),o("div",{className:"flex items-center gap-2",children:[t(S,{variant:"outline",onClick:()=>M.mutate(),disabled:M.isPending,className:"gap-2",children:M.isPending?o(B,{children:[t(Z,{className:"w-4 h-4 animate-spin"}),fE()]}):o(B,{children:[t(ca,{className:"w-4 h-4"}),cE()]})}),o(S,{onClick:()=>d(!0),className:"bg-primary hover:bg-primary/90 text-primary-foreground gap-2",children:[t(de,{className:"w-4 h-4"}),Qp()]})]})]}),o("div",{className:"relative px-0.5",children:[t(Lt,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t(q,{placeholder:tg(),value:c,onChange:(I)=>f(I.target.value),className:"pl-10 bg-card border-border focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-0"})]})]}),t(se,{className:"flex-1 min-h-0",children:o("div",{className:"pr-4 py-2 grid grid-cols-1 gap-4",children:[ie.map((I)=>t(St,{className:"group cursor-pointer hover:border-primary/50 transition-all hover:shadow-md overflow-hidden",onClick:()=>l(I.id),children:o(Mt,{className:"p-5 flex items-center justify-between gap-4",children:[o("div",{className:"flex items-center gap-4 min-w-0 flex-1",children:[t("div",{className:"flex-none p-3 bg-muted rounded-xl group-hover:bg-primary/10 transition-colors",children:t(da,{className:"w-6 h-6 text-muted-foreground group-hover:text-primary"})}),o("div",{className:"min-w-0 flex-1",children:[t("div",{className:"flex items-center gap-2",children:t("span",{className:"font-bold text-foreground truncate",children:I.name})}),o("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-muted-foreground mt-1",children:[o("span",{className:"flex items-center gap-1 flex-none",children:[t(Ot,{className:"w-3 h-3"}),I.config.api]}),I.config.baseUrl&&o("span",{className:"flex items-center gap-1 min-w-0",children:[t("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/30 flex-none"}),t(Zo,{className:"w-3 h-3 flex-none"}),t("span",{className:"truncate max-w-[200px] md:max-w-[300px]",children:I.config.baseUrl})]}),o("span",{className:"flex items-center gap-1 flex-none",children:[t("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/30 flex-none"}),t(Ha,{className:"w-3 h-3"}),Aw({count:I.modelsCount})]})]})]})]}),o("div",{className:"flex items-center gap-1",children:[o(he,{modal:!1,children:[t(ge,{asChild:!0,onClick:(W)=>W.stopPropagation(),children:t(S,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:t(Ar,{className:"w-4 h-4"})})}),t(Ae,{align:"end",className:"w-32",children:o(V,{onClick:(W)=>{W.stopPropagation(),x(I),g(!0)},className:"text-destructive focus:text-destructive gap-2 cursor-pointer",children:[t(ve,{className:"w-4 h-4"})," ",at()]})})]}),t(ft,{className:"flex-none w-5 h-5 text-muted-foreground/50 group-hover:text-primary transition-colors"})]})]})},I.id)),j?.length===0&&o("div",{className:"text-center py-12 bg-muted/30 rounded-2xl border-2 border-dashed border-border",children:[t(Wn,{className:"w-12 h-12 text-muted-foreground/50 mx-auto mb-4"}),t("h4",{className:"text-foreground font-medium",children:Hw()}),t("p",{className:"text-sm text-muted-foreground mt-1",children:$g()})]}),j&&j.length>0&&ie.length===0&&o("div",{className:"text-center py-12",children:[t(Lt,{className:"w-12 h-12 text-muted-foreground/50 mx-auto mb-4"}),t("h4",{className:"text-foreground font-medium",children:gh()}),t("p",{className:"text-sm text-muted-foreground mt-1",children:aI({query:c})}),t(S,{variant:"ghost",size:"sm",onClick:()=>f(""),className:"mt-4 text-primary hover:text-primary/90 hover:bg-primary/10",children:jy()})]})]})}),t(wr,{isOpen:r,onClose:()=>d(!1),onSubmit:(I)=>F.mutate(I),isLoading:F.isPending,existingProviderNames:ne}),z&&t(Nr,{isOpen:!!z,onClose:()=>l(null),provider:z,teamId:e,existingProviderNames:ne}),t(We,{open:w,onOpenChange:g,children:o(Ye,{children:[o(Je,{children:[t(et,{children:Du()}),t(tt,{children:Y0({name:y?.name??""})})]}),o(Xe,{children:[t(nt,{onClick:()=>x(null),children:Re()}),o(rt,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(y)D.mutate(y.id)},children:[D.isPending?t(Z,{className:"w-4 h-4 animate-spin mr-2"}):t(ve,{className:"w-4 h-4 mr-2"}),at()]})]})]})}),t(Ns,{isOpen:m,onClose:()=>i(!1),teamId:e,syncData:b,onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"providers"]})}})]})}function wr({isOpen:e,onClose:s,onSubmit:a,isLoading:l,existingProviderNames:r}){let[d,c]=u([]),[f,w]=u(!1),[g,y]=u(null),x=O(()=>P({name:p().min(1,kh()).refine((_)=>!r.includes(_),{message:Ph()}),config:Us}),[r]),m=zt({defaultValues:{name:"",config:{api:"openai-completions",baseUrl:"",apiKey:""}},validators:{onSubmit:x},onSubmit:async({value:_})=>{a({name:_.name,config:_.config,models:d})}});h(()=>{if(e)m.reset(),c([]),w(!1),y(null)},[e,m]);let i=(_)=>_.map((M)=>{if(typeof M==="string")return{message:M};if(M&&typeof M==="object"&&"message"in M)return{message:String(M.message)};return{message:String(M||"")}}),b=(_)=>{if(g!==null)c((M)=>M.map((j,Y)=>Y===g?_:j)),y(null);else c((M)=>[_,...M]),w(!1)};return t(fe,{open:e,onOpenChange:s,children:o(ce,{className:"sm:max-w-2xl h-[85vh] flex flex-col p-0 overflow-hidden",children:[o(pe,{className:"p-6 pb-2 shrink-0",children:[t(ue,{className:"text-xl",children:Wg()}),t(It,{children:bm()})]}),o("form",{onSubmit:(_)=>{_.preventDefault(),_.stopPropagation(),m.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t("div",{className:"flex-1 min-h-0",children:t(se,{className:"h-full",children:o("div",{className:"p-6 pt-2 space-y-6 pr-6",children:[o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-5 rounded-2xl border bg-muted/20",children:[t(m.Field,{name:"name",children:(_)=>{let M=!!_.state.meta.errors.length&&_.state.meta.isTouched;return o(Pe,{"data-invalid":M,children:[t($e,{htmlFor:_.name,children:Rh()}),t(q,{id:_.name,name:_.name,value:_.state.value,onBlur:_.handleBlur,onChange:(j)=>_.handleChange(j.target.value),placeholder:Nh(),"aria-invalid":M}),M&&t(Qe,{errors:i(_.state.meta.errors)})]})}}),t(m.Field,{name:"config.api",children:(_)=>{let M=!!_.state.meta.errors.length&&_.state.meta.isTouched;return o(Pe,{"data-invalid":M,children:[t($e,{htmlFor:_.name,children:Km()}),o(De,{onValueChange:_.handleChange,value:_.state.value,children:[t(Le,{id:_.name,"aria-invalid":M,children:t(Ze,{placeholder:rg()})}),t(Be,{children:Mc.map((j)=>t(re,{value:j,children:Ss[j]},j))})]}),M&&t(Qe,{errors:i(_.state.meta.errors)})]})}}),t("div",{className:"md:col-span-2",children:t(m.Field,{name:"config.baseUrl",children:(_)=>{let M=!!_.state.meta.errors.length&&_.state.meta.isTouched;return o(Pe,{"data-invalid":M,children:[t($e,{htmlFor:_.name,children:Am()}),t(q,{id:_.name,name:_.name,value:_.state.value||"",onBlur:_.handleBlur,onChange:(j)=>_.handleChange(j.target.value),placeholder:"https://api.openai.com/v1","aria-invalid":M}),t(aa,{children:vh()}),M&&t(Qe,{errors:i(_.state.meta.errors)})]})}})}),t("div",{className:"md:col-span-2",children:t(m.Field,{name:"config.apiKey",children:(_)=>{let M=!!_.state.meta.errors.length&&_.state.meta.isTouched;return o(Pe,{"data-invalid":M,children:[t($e,{htmlFor:_.name,children:Ou()}),t(q,{id:_.name,name:_.name,type:"text",value:_.state.value||"",onBlur:_.handleBlur,onChange:(j)=>_.handleChange(j.target.value),placeholder:mm(),"aria-invalid":M}),t(aa,{className:"text-xs mt-1",children:pm()}),M&&t(Qe,{errors:i(_.state.meta.errors)})]})}})})]}),o("div",{className:"space-y-3",children:[o("div",{className:"flex items-center justify-between",children:[o("div",{children:[t(G,{className:"text-base font-semibold",children:Vu()}),t("p",{className:"text-xs text-muted-foreground mt-0.5",children:dw()})]}),o(S,{type:"button",variant:"outline",size:"sm",onClick:()=>w(!0),className:"gap-1.5",children:[t(de,{className:"w-4 h-4"}),ku()]})]}),d.length===0?t("div",{className:"text-center py-8 rounded-xl border border-dashed text-muted-foreground text-sm",children:Wu()}):t("div",{className:"space-y-2",children:d.map((_,M)=>o("div",{className:"group cursor-pointer flex items-center justify-between p-3 rounded-xl border bg-card hover:border-primary/50 transition-all shadow-none hover:shadow-sm",onClick:()=>y(M),children:[o("div",{className:"min-w-0 flex-1",children:[o("div",{className:"flex items-center gap-2",children:[t("span",{className:"font-semibold text-foreground truncate",children:_.name||_.modelId}),t(be,{variant:"secondary",className:"font-mono text-[10px]",children:_.modelId}),_.config.reasoning&&o(be,{variant:"outline",className:"text-[10px] gap-1 bg-primary/10 text-primary border-primary/20",children:[t(Ot,{className:"w-2.5 h-2.5"})," ",jf()]})]}),o("div",{className:"text-xs text-muted-foreground mt-1 flex items-center gap-2",children:[o("span",{children:[_.config.contextWindow?.toLocaleString()," ",_g()]}),t("span",{children:"·"}),t("span",{children:Sm({input:_.config.cost?.input??0,output:_.config.cost?.output??0})})]})]}),t("div",{className:"flex items-center gap-1 ml-2",children:t(S,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:(j)=>{j.stopPropagation(),c((Y)=>Y.filter((z,ne)=>ne!==M))},children:t(ve,{className:"w-3.5 h-3.5"})})})]},_.modelId+M))})]})]})})}),o(qe,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[t(S,{type:"button",variant:"outline",onClick:s,disabled:l,children:Re()}),t(m.Subscribe,{selector:(_)=>[_.canSubmit,_.isSubmitting],children:([_,M])=>t(S,{type:"submit",className:"min-w-[120px]",disabled:!_||M||l,children:M||l?t(Z,{className:"w-4 h-4 animate-spin"}):Qp()})})]})]}),(f||g!==null)&&t(Ca,{isOpen:!0,onClose:()=>{w(!1),y(null)},onSubmit:b,title:g!==null?Om():ku(),initialValues:g!==null?d[g]:null,defaultApi:m.getFieldValue("config.api"),existingModelIds:d.filter((_,M)=>M!==g).map((_)=>_.modelId)},g!==null?`edit-${g}-${d[g]?.modelId}`:"add")]})})}function Nr({isOpen:e,onClose:s,provider:a,teamId:l,existingProviderNames:r}){let d=Q(),[c,f]=u("general"),[w,g]=u(""),[y,x]=u(!1),[m,i]=u(null),[b,_]=u(null),{data:M=[],isLoading:j}=L({queryKey:["teams",l,"providers",a.id,"models"],queryFn:async()=>{let k=await A.api.providers[":id"].models.$get({param:{id:a.id}});if(!k.ok)throw Error("Failed to fetch models");return await k.json()},enabled:e}),Y=U({mutationFn:async(k)=>{let X=await A.api.providers[":id"].$put({param:{id:a.id},json:{name:k.name,config:k.config}});if(!X.ok)throw Error("Failed to update provider");return await X.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers"]}),R.success(Lh())},onError:(k)=>{R.error(_a({message:k.message}))}}),z=U({mutationFn:async(k)=>{let X=await A.api.providers[":id"].models.$post({param:{id:a.id},json:k});if(!X.ok)throw Error("Failed to create model");return await X.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers",a.id,"models"]}),d.invalidateQueries({queryKey:["teams",l,"providers"]}),x(!1),R.success(ow())},onError:(k)=>{R.error(_a({message:k.message}))}}),ne=U({mutationFn:async({modelDbId:k,values:X})=>{let xe=await A.api.providers[":id"].models[":modelDbId"].$put({param:{id:a.id,modelDbId:k},json:X});if(!xe.ok)throw Error("Failed to update model");return await xe.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers",a.id,"models"]}),i(null),R.success(uw())},onError:(k)=>{R.error(_a({message:k.message}))}}),ie=U({mutationFn:async(k)=>{let X=await A.api.providers[":id"].models[":modelDbId"].$delete({param:{id:a.id,modelDbId:k}});if(!X.ok)throw Error("Failed to delete model");return await X.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers",a.id,"models"]}),d.invalidateQueries({queryKey:["teams",l,"providers"]}),_(null),R.success(aw())},onError:(k)=>{R.error(_a({message:k.message}))}}),F=O(()=>P({name:p().min(1,kh()).refine((k)=>{if(a.name===k)return!0;return!r.includes(k)},{message:Ph()}),config:Us}),[r,a.name]),D=zt({defaultValues:{name:a.name,config:a.config},validators:{onSubmit:F},onSubmit:async({value:k})=>{Y.mutate({name:k.name,config:k.config})}});h(()=>{if(e)D.reset(),f("general"),g("")},[e,D]);let I=(k)=>k.map((X)=>{if(typeof X==="string")return{message:X};if(X&&typeof X==="object"&&"message"in X)return{message:String(X.message)};return{message:String(X||"")}}),W=O(()=>{if(!w.trim())return M;let k=w.toLowerCase();return M.filter((X)=>X.modelId.toLowerCase().includes(k)||X.name?.toLowerCase().includes(k))},[M,w]);return t(fe,{open:e,onOpenChange:s,children:o(ce,{className:"sm:max-w-3xl h-[88vh] flex flex-col p-0 overflow-hidden",children:[o(pe,{className:"p-6 pb-2 shrink-0",children:[t(ue,{className:"text-xl",children:Nm({name:a.name})}),t(It,{children:bm()})]}),o(uo,{value:c,onValueChange:(k)=>f(k),className:"flex-1 flex flex-col min-h-0",children:[t("div",{className:"px-6 pb-2 shrink-0",children:o(fo,{className:"grid w-full grid-cols-2",children:[t(Hr,{value:"general",children:Vm()}),o(Hr,{value:"models",className:"gap-2",children:[Vu(),t(be,{variant:"secondary",className:"h-5 px-1.5 text-[11px]",children:M.length})]})]})}),t(_n,{value:"general",className:"flex-1 flex flex-col min-h-0 m-0",children:o("form",{onSubmit:(k)=>{k.preventDefault(),k.stopPropagation(),D.handleSubmit()},className:"flex-1 flex flex-col min-h-0",children:[t("div",{className:"flex-1 min-h-0",children:t(se,{className:"h-full",children:t("div",{className:"p-6 space-y-6 pr-6",children:o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5 p-5 rounded-2xl border bg-muted/10",children:[t(D.Field,{name:"name",children:(k)=>{let X=!!k.state.meta.errors.length&&k.state.meta.isTouched;return o(Pe,{"data-invalid":X,children:[t($e,{htmlFor:k.name,children:Rh()}),t(q,{id:k.name,name:k.name,value:k.state.value,onBlur:k.handleBlur,onChange:(xe)=>k.handleChange(xe.target.value),placeholder:Nh(),"aria-invalid":X}),X&&t(Qe,{errors:I(k.state.meta.errors)})]})}}),t(D.Field,{name:"config.api",children:(k)=>{let X=!!k.state.meta.errors.length&&k.state.meta.isTouched;return o(Pe,{"data-invalid":X,children:[t($e,{htmlFor:k.name,children:Km()}),o(De,{onValueChange:k.handleChange,value:k.state.value,children:[t(Le,{id:k.name,"aria-invalid":X,children:t(Ze,{placeholder:rg()})}),t(Be,{children:Mc.map((xe)=>t(re,{value:xe,children:Ss[xe]},xe))})]}),X&&t(Qe,{errors:I(k.state.meta.errors)})]})}}),t("div",{className:"md:col-span-2",children:t(D.Field,{name:"config.baseUrl",children:(k)=>{let X=!!k.state.meta.errors.length&&k.state.meta.isTouched;return o(Pe,{"data-invalid":X,children:[t($e,{htmlFor:k.name,children:Am()}),t(q,{id:k.name,name:k.name,value:k.state.value||"",onBlur:k.handleBlur,onChange:(xe)=>k.handleChange(xe.target.value),placeholder:"https://api.openai.com/v1","aria-invalid":X}),t(aa,{children:vh()}),X&&t(Qe,{errors:I(k.state.meta.errors)})]})}})}),t("div",{className:"md:col-span-2",children:t(D.Field,{name:"config.apiKey",children:(k)=>{let X=!!k.state.meta.errors.length&&k.state.meta.isTouched;return o(Pe,{"data-invalid":X,children:[t($e,{htmlFor:k.name,children:Ou()}),t(q,{id:k.name,name:k.name,type:"text",value:k.state.value||"",onBlur:k.handleBlur,onChange:(xe)=>k.handleChange(xe.target.value),placeholder:mm(),"aria-invalid":X}),t(aa,{className:"text-xs mt-1",children:pm()}),X&&t(Qe,{errors:I(k.state.meta.errors)})]})}})})]})})})}),o(qe,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[t(S,{type:"button",variant:"outline",onClick:s,children:Re()}),t(D.Subscribe,{selector:(k)=>[k.canSubmit,k.isSubmitting],children:([k,X])=>t(S,{type:"submit",className:"min-w-[120px]",disabled:!k||X||Y.isPending,children:X||Y.isPending?t(Z,{className:"w-4 h-4 animate-spin"}):va()})})]})]})}),o(_n,{value:"models",className:"flex-1 flex flex-col min-h-0 m-0",children:[o("div",{className:"p-6 pb-3 flex items-center justify-between gap-3 shrink-0",children:[o("div",{className:"relative flex-1 max-w-sm",children:[t(Lt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t(q,{placeholder:Vf(),value:w,onChange:(k)=>g(k.target.value),className:"pl-9 h-9"})]}),o(S,{size:"sm",onClick:()=>x(!0),className:"gap-1.5 shrink-0",children:[t(de,{className:"w-4 h-4"}),ku()]})]}),t("div",{className:"flex-1 min-h-0 px-6",children:t(se,{className:"h-full pr-4",children:j?t("div",{className:"flex h-48 items-center justify-center",children:t(Z,{className:"h-6 w-6 animate-spin text-primary"})}):W.length===0?t("div",{className:"text-center py-12 border border-dashed rounded-xl text-muted-foreground text-sm",children:Wu()}):t("div",{className:"space-y-2 pb-4",children:W.map((k)=>o("div",{className:"group cursor-pointer flex items-center justify-between p-3.5 rounded-xl border bg-card hover:border-primary/50 transition-all shadow-none hover:shadow-sm",onClick:()=>i(k),children:[o("div",{className:"min-w-0 flex-1 pr-3",children:[o("div",{className:"flex items-center gap-2 flex-wrap",children:[t("span",{className:"font-semibold text-foreground text-sm",children:k.name||k.modelId}),t(be,{variant:"secondary",className:"font-mono text-[10px] px-1.5 py-0.5",children:k.modelId}),k.config?.reasoning&&o(be,{variant:"outline",className:"text-[10px] gap-1 bg-primary/10 text-primary border-primary/20 h-5",children:[t(Ot,{className:"w-2.5 h-2.5"})," ",jf()]})]}),o("div",{className:"text-xs text-muted-foreground mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1",children:[o("span",{children:[k.config?.contextWindow?.toLocaleString()," ",_g()]}),t("span",{children:"·"}),t("span",{children:wv({count:k.config?.maxTokens?.toLocaleString()??"0"})}),t("span",{children:"·"}),t("span",{children:Sm({input:k.config?.cost?.input??0,output:k.config?.cost?.output??0})})]})]}),t("div",{className:"flex items-center gap-1 shrink-0",children:t(S,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:(X)=>{X.stopPropagation(),_(k)},children:t(ve,{className:"w-3.5 h-3.5"})})})]},k.id))})})})]})]}),y&&t(Ca,{isOpen:y,onClose:()=>x(!1),onSubmit:(k)=>z.mutate(k),title:ku(),isLoading:z.isPending,defaultApi:a.config.api,existingModelIds:M.map((k)=>k.modelId)}),m&&t(Ca,{isOpen:!!m,onClose:()=>i(null),onSubmit:(k)=>ne.mutate({modelDbId:m.id,values:k}),title:Om(),isLoading:ne.isPending,initialValues:{modelId:m.modelId,name:m.name,config:m.config},defaultApi:a.config.api,existingModelIds:M.filter((k)=>k.id!==m.id).map((k)=>k.modelId)}),t(We,{open:!!b,onOpenChange:(k)=>!k&&_(null),children:o(Ye,{children:[o(Je,{children:[t(et,{children:Du()}),t(tt,{children:V0({name:b?.name||b?.modelId||""})})]}),o(Xe,{children:[t(nt,{onClick:()=>_(null),children:Re()}),o(rt,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(b)ie.mutate(b.id)},children:[ie.isPending?t(Z,{className:"w-4 h-4 animate-spin mr-2"}):t(ve,{className:"w-4 h-4 mr-2"}),at()]})]})]})})]})})}C();function ks({teamId:e}){let s=Q(),[a,l]=u(""),{data:r,isLoading:d}=L({queryKey:["teams",e,"sandbox"],queryFn:async()=>{let b=await A.api.teams[":teamId"].sandbox.$get({param:{teamId:e}});if(!b.ok)throw Error(Ko());return await b.json()}}),{mutate:c,isPending:f}=U({mutationFn:async(b)=>{let _=await A.api.teams[":teamId"].sandbox.$put({param:{teamId:e},json:b});if(!_.ok)throw Error(jm());return await _.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"sandbox"]}),R.success(cC())},onError:(b)=>{R.error(b instanceof Error?b.message:jm())}}),w=(b)=>{c({networkSandboxEnabled:b})},g=(b)=>{if(b.preventDefault(),!a.trim())return;if(r?.allowedDomains.includes(a.trim())){R.error(c_());return}let _=[...r?.allowedDomains||[],a.trim()],M=r?.pendingDomains||[];c({allowedDomains:_,pendingDomains:M}),l("")},y=(b)=>{let _=(r?.allowedDomains||[]).filter((j)=>j!==b),M=r?.pendingDomains||[];c({allowedDomains:_,pendingDomains:M})},x=(b)=>{let _=[...r?.allowedDomains||[],b],M=(r?.pendingDomains||[]).filter((j)=>j!==b);c({allowedDomains:_,pendingDomains:M})},m=(b)=>{let _=(r?.pendingDomains||[]).filter((M)=>M!==b);c({allowedDomains:r?.allowedDomains||[],pendingDomains:_})};if(d)return t("div",{className:"flex items-center justify-center p-8",children:t(Z,{className:"h-8 w-8 animate-spin text-muted-foreground"})});let i=!!r?.networkSandboxEnabled;return t(se,{className:"h-full",children:o("div",{className:"space-y-6 pr-4 pb-8",children:[o(St,{children:[o(kt,{children:[o("div",{className:"flex items-center gap-2",children:[t(da,{className:"w-5 h-5 text-primary"}),t(Pt,{children:vw()})]}),t(Ft,{children:ww()})]}),o(Mt,{children:[o("div",{className:"flex items-center justify-between p-4 mb-6 rounded-lg border border-border bg-muted/30",children:[o("div",{className:"space-y-0.5 pr-4",children:[t("label",{htmlFor:"network-sandbox-switch",className:"text-sm font-medium text-foreground cursor-pointer",children:x_()}),t("p",{className:"text-xs text-muted-foreground",children:Sw()})]}),t(je,{id:"network-sandbox-switch",checked:i,onCheckedChange:w,disabled:f})]}),!i&&o("div",{className:"flex items-start gap-2.5 p-3.5 mb-6 rounded-lg bg-amber-500/10 border border-amber-500/20 text-amber-700 dark:text-amber-300 text-sm",children:[t(Zo,{className:"w-4 h-4 mt-0.5 shrink-0"}),t("span",{children:xw()})]}),o("form",{onSubmit:g,className:"flex gap-2 mb-6",children:[t(q,{placeholder:"e.g. api.openai.com",value:a,onChange:(b)=>l(b.target.value),disabled:f||!i}),o(S,{type:"submit",disabled:f||!i,children:[f?t(Z,{className:"w-4 h-4 animate-spin"}):t(de,{className:"w-4 h-4 mr-2"}),Gg()]})]}),o("div",{className:"space-y-2",children:[t("h4",{className:"text-sm font-medium text-muted-foreground mb-3",children:JA()}),o("div",{className:"flex flex-wrap gap-2",children:[r?.allowedDomains.map((b)=>o("div",{className:"flex items-center gap-1 px-3 py-1.5 bg-muted rounded-full text-sm border border-border transition-all hover:border-muted-foreground/50",children:[t("span",{className:"font-medium text-foreground",children:b}),t("button",{onClick:()=>y(b),className:"ml-1 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50 disabled:cursor-not-allowed",disabled:f||!i,children:t(Oe,{className:"w-3.5 h-3.5"})})]},b)),r?.allowedDomains.length===0&&t("div",{className:"text-sm text-muted-foreground italic",children:Zw()})]})]})]})]}),o(St,{className:"border-orange-500/20 bg-orange-500/5",children:[o(kt,{children:[o("div",{className:"flex items-center gap-2",children:[t(vl,{className:"w-5 h-5 text-orange-500"}),t(Pt,{children:Lx()})]}),t(Ft,{children:Bx()})]}),t(Mt,{children:t("div",{className:"space-y-3",children:r?.pendingDomains&&r.pendingDomains.length>0?t("div",{className:"divide-y divide-border",children:r.pendingDomains.map((b)=>o("div",{className:"flex items-center justify-between py-2.5 first:pt-0 last:pb-0",children:[t("span",{className:"font-mono text-sm text-foreground bg-muted px-2 py-1 rounded break-all",children:b}),o("div",{className:"flex items-center gap-2",children:[o(S,{size:"sm",variant:"outline",className:"h-8 border-emerald-500/20 text-emerald-600 hover:bg-emerald-500/10 hover:text-emerald-600 dark:text-emerald-400 dark:hover:bg-emerald-500/20",onClick:()=>x(b),disabled:f||!i,children:[t(Te,{className:"w-4 h-4 mr-1.5"}),sy()]}),o(S,{size:"sm",variant:"outline",className:"h-8 border-destructive/20 text-destructive hover:bg-destructive/10",onClick:()=>m(b),disabled:f||!i,children:[t(ve,{className:"w-4 h-4 mr-1.5"}),at()]})]})]},b))}):t("div",{className:"text-sm text-muted-foreground italic py-2",children:qw()})})})]}),t(St,{children:o(kt,{children:[t(Pt,{children:mb()}),t(Ft,{children:hb()})]})})]})})}C();var Sr=(e)=>o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[t("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),t("path",{d:"M9 18c-4.51 2-5-2-7-2"})]}),Ms=({teamId:e})=>{let s=Q(),{canAdmin:a}=Rt(),[l,r]=u(!1),[d,c]=u(!1),[f,w]=u(!1),[g,y]=u(null),{data:x,isLoading:m}=L({queryKey:["teams",e,"skills"],queryFn:async()=>{let M=await A.api.teams[":teamId"].skills.$get({param:{teamId:e}});if(!M.ok)throw Error(Ko());return await M.json()}}),i=U({mutationFn:async(M)=>{if(!(await A.api.skills[":id"].$delete({param:{id:M}})).ok)throw Error(di())},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"skills"]}),w(!1)}}),b=U({mutationFn:async({id:M,permission:j})=>{if(!(await A.api.skills[":id"].permission.$patch({param:{id:M},json:{permission:j}})).ok)throw Error(Yi())},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"skills"]})},onError:(M)=>{alert(M.message||Yi())}}),_=x?.skills||[];return o(St,{children:[o(kt,{className:"flex flex-row items-center justify-between space-y-0 pb-7",children:[o("div",{className:"flex items-center gap-3",children:[t("div",{className:"p-2 bg-primary/10 text-primary rounded-lg",children:t(wt,{className:"w-6 h-6"})}),o("div",{children:[t(Pt,{className:"text-xl font-bold",children:ug()}),t(Ft,{children:tE()})]})]}),o(S,{onClick:()=>r(!0),className:"gap-2",children:[t(de,{className:"w-4 h-4"})," ",Jg()]})]}),t(Mt,{children:m?t("div",{className:"flex justify-center py-10",children:t(Z,{className:"w-8 h-8 animate-spin text-primary"})}):_.length===0?o("div",{className:"text-center py-12 border-2 border-dashed border-border rounded-xl",children:[t("div",{className:"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4 text-muted-foreground",children:t(wt,{className:"w-6 h-6"})}),t("h3",{className:"text-lg font-medium text-foreground",children:Ww()}),t("p",{className:"text-muted-foreground mt-1 max-w-xs mx-auto",children:Xg()})]}):t("div",{className:"space-y-4",children:_.map((M)=>t(Cr,{skill:M,canAdmin:a,onDelete:()=>{y(M),w(!0)},onConfigure:()=>{y(M),c(!0)},onPermissionChange:(j)=>b.mutate({id:M.id,permission:j})},M.id))})}),t(kr,{open:l,onOpenChange:r,teamId:e}),g&&t(Fr,{open:d,onOpenChange:(M)=>{if(c(M),!M)setTimeout(()=>{document.body.style.pointerEvents="auto"},100)},teamId:e,skill:g}),t(We,{open:f,onOpenChange:w,children:o(Ye,{children:[o(Je,{children:[t(et,{children:Du()}),t(tt,{children:e_({name:g?.name??""})})]}),o(Xe,{children:[t(nt,{children:Re()}),o(rt,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(g)i.mutate(g.id)},children:[i.isPending?t(Z,{className:"w-4 h-4 animate-spin mr-2"}):t(ve,{className:"w-4 h-4 mr-2"}),at()]})]})]})})]})},Cr=({skill:e,canAdmin:s,onDelete:a,onConfigure:l,onPermissionChange:r})=>o("div",{className:"p-4 bg-card rounded-xl border border-border flex flex-col justify-between hover:shadow-md transition-all group cursor-pointer",onClick:l,children:[o("div",{children:[o("div",{className:"flex items-start justify-between mb-2",children:[t("h4",{className:"font-bold text-foreground flex items-center gap-2",children:e.name}),o(he,{children:[t(ge,{asChild:!0,onClick:(d)=>d.stopPropagation(),children:t(S,{variant:"ghost",size:"icon",className:"h-8 w-8",children:t(Ar,{className:"w-4 h-4"})})}),t(Ae,{align:"end",className:"w-32",children:o(V,{onClick:(d)=>{d.stopPropagation(),a()},className:"text-destructive focus:text-destructive gap-2 cursor-pointer",children:[t(ve,{className:"w-4 h-4"})," ",at()]})})]})]}),t("p",{className:"text-sm text-muted-foreground line-clamp-2",children:e.description||mh()})]}),o("div",{className:"mt-4 flex items-center justify-between gap-2 pt-2 border-t border-border/50 text-xs",children:[o("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider font-semibold",children:[xg()," ",new Date(e.updatedAt).toLocaleDateString()]}),t("div",{className:"flex items-center gap-2",onClick:(d)=>d.stopPropagation(),children:o(De,{value:e.permission||"reviewer",onValueChange:(d)=>r(d),disabled:!s,children:[t(Le,{className:"h-7 text-xs px-2 bg-background border-border w-[140px]",children:t(Ze,{placeholder:Yf()})}),o(Be,{align:"end",children:[t(re,{value:"reviewer",children:pi()}),t(re,{value:"editor",children:mi()}),t(re,{value:"owner",children:hi()})]})]})})]})]}),kr=({open:e,onOpenChange:s,teamId:a})=>{let l=Q(),[r,d]=u(""),[c,f]=u(!1),w=v(null),{data:g}=L({queryKey:["teams",a,"projects"],queryFn:async()=>{let m=await A.api.teams[":teamId"].projects.$get({param:{teamId:a},query:{first:"1"}});if(!m.ok)throw Error("Failed to fetch projects");return await m.json()},enabled:e}),y=async(m)=>{f(!0);try{let i=await A.api.teams[":teamId"].skills.$post({param:{teamId:a},json:m});if(i.status===409){let b=await i.json();if(window.confirm(`${b.error}
|
|
2
|
+
|
|
3
|
+
${Tx()}`)){await y({...m,override:!0});return}}else if(!i.ok){let b=await i.json().catch(()=>({}));throw Error(b.error||V_())}else l.invalidateQueries({queryKey:["teams",a,"skills"]}),s(!1),d("")}catch(i){if(i instanceof Error)alert(i.message);else alert(Nu())}finally{f(!1)}},x=async(m)=>{if(!m||m.length===0)return;let i=g?.data?.[0]?.id;if(!i){alert(bw());return}let b=m[0];if(!b.name.toLowerCase().endsWith(".zip")){alert(sx());return}f(!0);try{let _=b.name,M=b.type||"application/zip",j=await A.api.projects[":projectId"].attachments.$post({param:{projectId:i},json:{fileName:_,size:b.size,contentType:M}});if(!j.ok)throw Error("Failed to get upload URL");let{id:Y,uploadUrl:z}=await j.json();if(!(await fetch(z,{method:"PUT",body:b,headers:{"Content-Type":M}})).ok)throw Error("Failed to upload file to storage");await y({assetId:Y})}catch(_){if(_ instanceof Error)alert(_.message);else alert(Nu())}finally{f(!1)}};return t(fe,{open:e,onOpenChange:s,children:o(ce,{className:"sm:max-w-[450px]",children:[o(pe,{children:[t(ue,{children:Yg()}),t(It,{children:Vb()})]}),o("div",{className:"space-y-6 pt-4",children:[o("div",{className:"space-y-3",children:[t(G,{children:Mx()}),o("div",{onClick:()=>!c&&w.current?.click(),className:E("group relative h-32 border-2 border-dashed rounded-xl flex flex-col items-center justify-center transition-all cursor-pointer",c?"opacity-50 cursor-not-allowed bg-muted/50 border-border":"hover:bg-primary/5 hover:border-primary/50 border-border"),children:[t("input",{type:"file",ref:w,className:"hidden",accept:".zip",onChange:(m)=>x(m.target.files)}),t("div",{className:"p-3 bg-muted rounded-full group-hover:bg-primary/10 transition-colors",children:t(Yn,{className:"w-6 h-6 text-muted-foreground group-hover:text-primary"})}),o("div",{className:"mt-3 text-center",children:[t("p",{className:"text-sm font-medium text-foreground",children:LC()}),t("p",{className:"text-[10px] text-muted-foreground mt-1 uppercase tracking-wider font-semibold",children:Rx()})]})]}),c&&!r&&o("div",{className:"flex items-center gap-2 text-sm text-primary justify-center bg-primary/10 py-2 rounded-lg animate-pulse",children:[t(Z,{className:"w-4 h-4 animate-spin"}),Kx()]})]}),o("div",{className:"relative",children:[t("div",{className:"absolute inset-0 flex items-center",children:t("span",{className:"w-full border-t border-border"})}),t("div",{className:"relative flex justify-center text-xs uppercase",children:t("span",{className:"bg-background px-2 text-muted-foreground font-bold",children:Cx()})})]}),t("div",{className:"space-y-4",children:o("div",{className:"space-y-2",children:[t(G,{htmlFor:"githubUrl",children:Mb()}),o("div",{className:"flex gap-2",children:[o("div",{className:"relative flex-1",children:[t(Sr,{className:"absolute left-3 top-2.5 w-4 h-4 text-muted-foreground"}),t(q,{id:"githubUrl",placeholder:"https://github.com/owner/repo",value:r,onChange:(m)=>d(m.target.value),disabled:c,className:"pl-9"})]}),t(S,{onClick:()=>y({githubUrl:r}),disabled:!r||c,className:"px-6",children:c&&r?t(Z,{className:"w-4 h-4 animate-spin"}):Wb()})]}),t("p",{className:"text-[10px] text-muted-foreground italic",children:Rb()})]})})]})]})})},Fr=({open:e,onOpenChange:s,teamId:a,skill:l})=>{let r=Q(),[d,c]=u({...l.config||{},environmentVariables:l.config?.environmentVariables||[]}),[f,w]=u(!1),g=(_,M)=>{let j=[...d.environmentVariables];j[_]={...j[_],default:M},c({...d,environmentVariables:j})},y=(_,M)=>{let j=[...d.environmentVariables];j[_]={...j[_],name:M},c({...d,environmentVariables:j})},x=()=>{c({...d,environmentVariables:[...d.environmentVariables,{name:"",default:""}]})},m=(_)=>{let M=[...d.environmentVariables];M.splice(_,1),c({...d,environmentVariables:M})},i=async()=>{let _=d.environmentVariables.filter((j)=>j.name.trim()!==""),M={...d,environmentVariables:_};w(!0);try{let j=await A.api.skills[":id"].config.$patch({param:{id:l.id},json:{config:M}});if(!j.ok){let Y=await j.json().catch(()=>({}));throw Error(Y.error||"Failed to update config")}r.invalidateQueries({queryKey:["teams",a,"skills"]}),s(!1)}catch(j){if(j instanceof Error)alert(j.message);else alert(Nu())}finally{w(!1)}},b=d?.environmentVariables||[];return t(fe,{open:e,onOpenChange:s,children:o(ce,{className:"sm:max-w-[500px]",children:[o(pe,{children:[t("div",{className:"flex items-center justify-between",children:o(ue,{className:"flex items-center gap-2",children:[t(_l,{className:"w-5 h-5 text-primary"}),Jy({name:l.name})]})}),t(It,{children:hv()})]}),t(se,{className:"max-h-[60vh]",children:t("div",{className:"py-4 space-y-4 pr-4",children:b.length===0?t("div",{className:"text-center py-10 bg-muted/50 rounded-xl border border-dashed border-border",children:t("p",{className:"text-muted-foreground text-sm italic",children:Lw()})}):b.map((_,M)=>o("div",{className:"p-4 bg-muted/50 rounded-xl border border-border space-y-3 relative group",children:[t("button",{onClick:()=>m(M),className:"absolute top-2 right-2 p-1 text-muted-foreground hover:text-destructive hover:bg-destructive/10 rounded-md transition-colors opacity-0 group-hover:opacity-100",children:t(Oe,{className:"w-4 h-4"})}),o("div",{className:"space-y-1.5",children:[t(G,{className:"text-[10px] uppercase tracking-wider font-bold text-muted-foreground",children:_I()}),t(q,{value:_.name,onChange:(j)=>y(M,j.target.value),placeholder:"e.g. API_KEY",className:"h-8 bg-background border-border text-sm font-mono"})]}),o("div",{className:"space-y-1.5",children:[t(G,{className:"text-[10px] uppercase tracking-wider font-bold text-muted-foreground",children:z0()}),t(q,{value:_.default||"",onChange:(j)=>g(M,j.target.value),placeholder:Sx(),className:"h-8 bg-background border-border text-sm"}),t("p",{className:"text-[10px] text-muted-foreground italic",children:k_()})]})]},M))})}),o(qe,{className:"flex items-center justify-between sm:justify-between w-full pt-2 border-t border-border",children:[o(S,{variant:"ghost",size:"sm",onClick:x,className:"h-8 gap-1.5 text-primary hover:text-primary hover:bg-primary/10",children:[t(de,{className:"w-3.5 h-3.5"})," ",nA()]}),o("div",{className:"flex gap-2",children:[t(S,{variant:"ghost",onClick:()=>s(!1),children:Re()}),o(S,{onClick:i,disabled:f,className:"px-8",children:[f?t(Z,{className:"w-4 h-4 animate-spin mr-2"}):null,va()]})]})]})]})})};C();C();var Fs=({isOpen:e,onClose:s,teamId:a,server:l})=>{let r=Q(),d=!!l,[c,f]=u(""),[w,g]=u("streamable_http"),[y,x]=u("reviewer"),[m,i]=u("auto"),[b,_]=u(""),[M,j]=u(""),[Y,z]=u(""),[ne,ie]=u(""),[F,D]=u("authorization_code"),[I,W]=u([]),[k,X]=u([]),[xe,ye]=u({}),[ke,Se]=u(!1);h(()=>{if(l)f(l.url),g(l.transport||"streamable_http"),x(l.permission||"reviewer"),i(l.authType||"auto"),W(Array.isArray(l.config?.directTools)?l.config.directTools:[]),X(l.config?.excludeTools??[]),ye({}),Se(!1);else f(""),g("streamable_http"),x("reviewer"),i("auto"),_(""),j(""),z(""),ie(""),D("authorization_code"),W([]),X([]),ye({}),Se(!1)},[l,e]);let ee=()=>{if(m==="none")return{type:"none"};if(m==="bearer")return{type:"bearer",bearerToken:b||void 0};if(m==="oauth")return{type:"oauth",oauth:{grantType:F,clientId:M||void 0,clientSecret:Y||void 0,scope:ne||void 0}};return},{data:oe,isLoading:we,refetch:Fe}=L({queryKey:["mcp","servers",l?.id,"tools"],queryFn:async()=>{if(!l?.id)return{tools:[]};let me=await A.api.mcp.servers[":id"].tools.$get({param:{id:l.id}});if(!me.ok)throw Error("Failed to fetch tools");return await me.json()},enabled:e&&d&&!!l?.id}),K=U({mutationFn:async()=>{if(!l?.id)return;let me=await A.api.mcp.servers[":id"].refresh.$post({param:{id:l.id}});if(!me.ok){let it=await me.json().catch(()=>({}));throw Error(it.error||"Failed to refresh server")}return await me.json()},onSuccess:()=>{R.success(Zv()),Fe(),r.invalidateQueries({queryKey:["teams",a,"mcp","servers"]})},onError:(me)=>{R.error(me.message)}}),J=U({mutationFn:async()=>{let me={directTools:I.length>0?I:void 0,excludeTools:k.length>0?k:void 0};if(d&&l){let it={transport:w,permission:y,authConfig:ee(),config:me},Ve=await A.api.mcp.servers[":id"].$patch({param:{id:l.id},json:it});if(!Ve.ok){let dt=await Ve.json().catch(()=>({}));throw Error(dt.error||Yi())}return await Ve.json()}else{let it={url:c.trim()},Ve=await A.api.teams[":teamId"].mcp.servers.$post({param:{teamId:a},json:it});if(!Ve.ok){let ta=await Ve.json().catch(()=>({}));throw Error(ta.error||Nu())}return await Ve.json()}},onSuccess:()=>{R.success(d?Th():Ac()),r.invalidateQueries({queryKey:["teams",a,"mcp","servers"]}),s()},onError:(me)=>{R.error(me.message)}}),Ne=(me)=>{if(me.preventDefault(),!c.trim())return;J.mutate()},le=oe?.tools??[],lt=(me)=>{if(k.includes(me))return"off";if(I.includes(me))return"direct";return"on"},jt=(me,it)=>{if(it==="off")X((Ve)=>Ve.includes(me)?Ve:[...Ve,me]),W((Ve)=>Ve.filter((dt)=>dt!==me));else if(it==="on")X((Ve)=>Ve.filter((dt)=>dt!==me)),W((Ve)=>Ve.filter((dt)=>dt!==me));else if(it==="direct")X((Ve)=>Ve.filter((dt)=>dt!==me)),W((Ve)=>Ve.includes(me)?Ve:[...Ve,me])},ae=(me)=>{let it=le.map((Ve)=>Ve.name);if(me==="off")X(it),W([]);else if(me==="on")X([]),W([]);else if(me==="direct")X([]),W(it)},st=(me)=>{ye((it)=>({...it,[me]:!it[me]}))};return t(fe,{open:e,onOpenChange:(me)=>!me&&s(),children:d&&l?o(ce,{className:"sm:max-w-2xl h-[85vh] flex flex-col p-0 overflow-hidden",children:[K.isPending&&o("div",{className:"absolute inset-0 bg-background/60 backdrop-blur-[1px] flex flex-col items-center justify-center z-50 rounded-lg",children:[t(Z,{className:"w-8 h-8 animate-spin text-primary mb-2"}),o("span",{className:"text-xs font-medium text-muted-foreground",children:[nh(),"..."]})]}),o(pe,{className:"p-6 pb-4 border-b border-border flex-shrink-0",children:[o(ue,{className:"flex items-center gap-2 text-xl font-bold",children:[t(on,{className:"w-5 h-5 text-primary"}),p_()]}),t(It,{children:Qu()})]}),o("form",{onSubmit:Ne,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t(se,{className:"flex-1 min-h-0",children:o("div",{className:"p-6 space-y-5",children:[o("div",{className:"grid grid-cols-1 gap-3 p-3 bg-muted/30 border border-border rounded-lg",children:[o("div",{className:"flex flex-col",children:[t("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:Bv()}),t("span",{className:"text-sm font-medium",children:l.name})]}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:ah()}),t("span",{className:"text-sm font-mono text-foreground break-all",children:l.url})]}),l.description&&o("div",{className:"flex flex-col",children:[t("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:Wi()}),t("span",{className:"text-sm text-foreground",children:l.description})]}),o("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1.5",children:[t(Zo,{className:"w-3 h-3"}),oh()]})]}),l.instructions&&o("div",{className:"p-3 bg-muted/20 border border-border rounded-lg space-y-1",children:[t("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold block",children:Lv()}),t("p",{onClick:()=>Se((me)=>!me),className:`text-xs text-muted-foreground whitespace-pre-wrap leading-relaxed cursor-pointer transition-all ${ke?"":"line-clamp-2"}`,title:ke?void 0:"Click to expand instructions",children:l.instructions})]}),o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 pt-3 border-t border-border",children:[o("div",{className:"space-y-1.5",children:[t(G,{className:"text-xs",children:Vv()}),o(De,{value:w,onValueChange:(me)=>g(me),children:[t(Le,{className:"h-9 text-xs",children:t(Ze,{})}),o(Be,{children:[t(re,{value:"streamable_http",children:"Streamable HTTP"}),t(re,{value:"sse",children:"Server-Sent Events (SSE)"})]})]})]}),o("div",{className:"space-y-1.5",children:[t(G,{className:"text-xs",children:Yf()}),o(De,{value:y,onValueChange:(me)=>x(me),children:[t(Le,{className:"h-9 text-xs",children:t(Ze,{})}),o(Be,{children:[t(re,{value:"reviewer",children:pi()}),t(re,{value:"editor",children:mi()}),t(re,{value:"owner",children:hi()})]})]})]})]}),o("div",{className:"space-y-3 pt-3 border-t border-border",children:[o("div",{className:"space-y-1.5",children:[t(G,{className:"text-xs",children:Iv()}),o(De,{value:m,onValueChange:(me)=>i(me),children:[t(Le,{className:"h-9 text-xs",children:t(Ze,{})}),o(Be,{children:[t(re,{value:"auto",children:xv()}),t(re,{value:"none",children:Cv()}),t(re,{value:"bearer",children:Sv()}),t(re,{value:"oauth",children:Ev()})]})]})]}),m==="bearer"&&o("div",{className:"space-y-1.5",children:[t(G,{className:"text-xs",children:Tv()}),t(q,{className:"h-9 text-xs font-mono",type:"password",value:b,onChange:(me)=>_(me.target.value),placeholder:"Enter token string"})]}),m==="oauth"&&o("div",{className:"p-3 bg-muted/20 border border-border rounded-lg space-y-3",children:[o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[o("div",{className:"space-y-1.5",children:[t(G,{className:"text-xs",children:Ov()}),o(De,{value:F,onValueChange:(me)=>D(me),children:[t(Le,{className:"h-9 text-xs",children:t(Ze,{})}),o(Be,{children:[t(re,{value:"authorization_code",children:"Authorization Code"}),t(re,{value:"client_credentials",children:"Client Credentials"})]})]})]}),o("div",{className:"space-y-1.5",children:[t(G,{className:"text-xs",children:Pv()}),t(q,{className:"h-9 text-xs",value:M,onChange:(me)=>j(me.target.value),placeholder:"Optional Client ID"})]})]}),o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[o("div",{className:"space-y-1.5",children:[t(G,{className:"text-xs",children:Nv()}),t(q,{className:"h-9 text-xs",type:"password",value:Y,onChange:(me)=>z(me.target.value),placeholder:"Optional Secret"})]}),o("div",{className:"space-y-1.5",children:[t(G,{className:"text-xs",children:Dv()}),t(q,{className:"h-9 text-xs",value:ne,onChange:(me)=>ie(me.target.value),placeholder:"Optional scope"})]})]})]})]}),o("div",{className:"space-y-3 pt-3 border-t border-border",children:[o("div",{className:"space-y-2.5",children:[o(G,{className:"text-xs font-semibold flex items-center gap-1.5",children:[t(mo,{className:"w-3.5 h-3.5"}),Gv()," (",le.length,")"]}),t("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:Qv()}),le.length>0&&o("div",{className:"flex items-center gap-1.5 pt-0.5",children:[t(S,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>ae("off"),disabled:K.isPending||we,children:Rv()}),t(S,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>ae("on"),disabled:K.isPending||we,children:kv()}),t(S,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>ae("direct"),disabled:K.isPending||we,children:Mv()})]})]}),t("div",{className:"space-y-2",children:we?t("div",{className:"flex justify-center py-8",children:t(Z,{className:"w-6 h-6 animate-spin text-primary"})}):le.length===0?t("div",{className:"text-center py-6 text-muted-foreground text-xs",children:Xw()}):le.map((me)=>{let it=lt(me.name),Ve=!!xe[me.name],dt=me.inputSchema,ta=dt?.properties&&Object.keys(dt.properties).length>0;return o("div",{className:`border border-border rounded-lg p-3 transition-colors ${it!=="off"?"bg-card":"bg-muted/30 opacity-70"}`,children:[o("div",{className:"flex items-start justify-between gap-3",children:[o("div",{className:"flex items-start gap-2 flex-1 min-w-0 cursor-pointer",onClick:()=>ta&&st(me.name),children:[ta?Ve?t(_e,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}):t(ft,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}):t("div",{className:"w-4 h-4 shrink-0"}),o("div",{className:"min-w-0 flex-1",children:[o("div",{className:"flex items-center gap-2 flex-wrap",children:[t("span",{className:"font-mono text-xs font-bold text-foreground break-all",children:me.name}),me.title&&t(be,{variant:"outline",className:"text-[10px]",children:me.title})]}),me.description&&t("p",{className:"text-xs text-muted-foreground mt-1 break-words line-clamp-3",children:me.description})]})]}),t("div",{className:"flex items-center gap-2 shrink-0",children:o(go,{type:"single",value:it,onValueChange:(Wt)=>{if(Wt)jt(me.name,Wt)},size:"sm",variant:"outline",disabled:K.isPending||we,children:[t(lr,{value:"off",className:"text-[11px] px-2 h-7",children:qv()}),t(lr,{value:"on",className:"text-[11px] px-2 h-7",children:Hv()}),t(lr,{value:"direct",className:"text-[11px] px-2 h-7",children:jv()})]})})]}),Ve&&ta&&o("div",{className:"mt-3 pt-3 border-t border-border/60 pl-6 space-y-2",children:[t("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:tI()}),t("div",{className:"grid grid-cols-1 gap-1.5",children:Object.entries(dt.properties).map(([Wt,ka])=>{let Rs=dt.required?.includes(Wt);return o("div",{className:"flex flex-col sm:flex-row sm:items-baseline justify-between gap-1 sm:gap-2 p-2 bg-muted/20 rounded text-xs min-w-0",children:[o("div",{className:"flex items-center gap-1.5 flex-wrap min-w-0",children:[t("span",{className:"font-mono font-semibold break-all",children:Wt}),Rs&&t("span",{className:"text-[10px] text-red-500 font-bold",children:"*"}),t(be,{variant:"secondary",className:"text-[9px] px-1 py-0",children:ka.type||"any"})]}),ka.description&&t("span",{className:"text-[11px] text-muted-foreground break-words sm:max-w-[320px]",children:ka.description})]},Wt)})})]})]},me.name)})})]})]})}),o(qe,{className:"p-6 pt-4 border-t border-border flex-shrink-0",children:[o(S,{type:"button",variant:"outline",onClick:()=>K.mutate(),disabled:K.isPending||we||J.isPending,className:"gap-1.5 mr-auto",children:[t(ca,{className:`w-4 h-4 ${K.isPending?"animate-spin":""}`}),nh()]}),t(S,{type:"button",variant:"outline",onClick:s,children:Re()}),o(S,{type:"submit",disabled:J.isPending||!c,children:[J.isPending&&t(Z,{className:"w-4 h-4 mr-2 animate-spin"}),va()]})]})]})]}):o(ce,{className:"sm:max-w-md",children:[o(pe,{children:[o(ue,{className:"flex items-center gap-2 text-xl font-bold",children:[t(on,{className:"w-5 h-5 text-primary"}),qd()]}),t(It,{children:Qu()})]}),o("form",{onSubmit:Ne,className:"space-y-4",children:[o("div",{className:"space-y-2",children:[t(G,{className:"text-xs font-semibold",children:ah()}),t(q,{value:c,onChange:(me)=>f(me.target.value),placeholder:"https://mcp.example.com/mcp",type:"url",required:!0}),o("p",{className:"text-[11px] text-muted-foreground flex items-center gap-1.5",children:[t(Zo,{className:"w-3.5 h-3.5"}),oh()]})]}),o(qe,{children:[t(S,{type:"button",variant:"outline",onClick:s,children:Re()}),o(S,{type:"submit",disabled:J.isPending||!c,children:[J.isPending&&t(Z,{className:"w-4 h-4 mr-2 animate-spin"}),fc()]})]})]})]})})};var Ds=({teamId:e})=>{let s=Q(),{canAdmin:a}=Rt(),[l,r]=u(!1),[d,c]=u(null),[f,w]=u(null),[g,y]=u(null),{data:x,isLoading:m}=L({queryKey:["teams",e,"mcp","servers"],queryFn:async()=>{let z=await A.api.teams[":teamId"].mcp.servers.$get({param:{teamId:e}});if(!z.ok)throw Error(Ko());return await z.json()}}),i=U({mutationFn:async(z)=>{if(!(await A.api.mcp.servers[":id"].$delete({param:{id:z}})).ok)throw Error(di())},onSuccess:()=>{R.success(at()),s.invalidateQueries({queryKey:["teams",e,"mcp","servers"]}),w(null)},onError:(z)=>{R.error(z.message)}}),b=U({mutationFn:async({id:z,permission:ne})=>{if(!(await A.api.mcp.servers[":id"].permission.$patch({param:{id:z},json:{permission:ne}})).ok)throw Error(Yi())},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},onError:(z)=>{R.error(z.message)}}),_=U({mutationFn:async(z)=>{if(!(await A.api.mcp.servers[":id"].auth.$delete({param:{id:z}})).ok)throw Error("Failed to disconnect auth")},onSuccess:()=>{R.success(rh()),s.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},onError:(z)=>{R.error(z.message)}}),M=async(z)=>{y(z);try{let ne=await A.api.mcp.servers[":id"].auth.start.$post({param:{id:z}});if(!ne.ok){let F=await ne.json().catch(()=>({}));throw Error(F.error||yf())}let ie=await ne.json();if(ie.status==="authenticated"){R.success(eh()),s.invalidateQueries({queryKey:["teams",e,"mcp","servers"]}),y(null);return}if(ie.authorizationUrl){let I=window.screenX+(window.outerWidth-600)/2,W=window.screenY+(window.outerHeight-700)/2,k=window.open(ie.authorizationUrl,"mcp_oauth_popup",`width=600,height=700,left=${I},top=${W},scrollbars=yes`),X=(ye)=>{if(ye.data?.type==="mcp-oauth-callback")if(window.removeEventListener("message",X),y(null),ye.data.ok)R.success(eh()),s.invalidateQueries({queryKey:["teams",e,"mcp","servers"]});else R.error(ye.data.message||yf())};window.addEventListener("message",X);let xe=setInterval(()=>{if(!k||k.closed)clearInterval(xe),window.removeEventListener("message",X),y(null),s.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},1000)}}catch(ne){R.error(ne instanceof Error?ne.message:yf()),y(null)}},j=x?.servers||[],Y=(z)=>{switch(z.status){case"connected":return o(be,{variant:"secondary",className:"gap-1 bg-emerald-500/10 text-emerald-600 border-emerald-500/20 text-[10px]",children:[t(gr,{className:"w-3 h-3"}),Uv()]});case"needs_auth":return o(be,{variant:"secondary",className:"gap-1 bg-amber-500/10 text-amber-600 border-amber-500/20 text-[10px]",children:[t(Zt,{className:"w-3 h-3"}),sh()]});case"failed":return o(be,{variant:"secondary",className:"gap-1 bg-red-500/10 text-red-600 border-red-500/20 text-[10px]",children:[t(an,{className:"w-3 h-3"}),zv()]});default:return o(be,{variant:"outline",className:"gap-1 text-[10px]",children:[t(ur,{className:"w-3 h-3 text-muted-foreground"}),Fv()]})}};return o(St,{children:[o(kt,{className:"flex flex-row items-center justify-between space-y-0 pb-7",children:[o("div",{className:"flex items-center gap-3",children:[t("div",{className:"p-2 bg-primary/10 text-primary rounded-lg",children:t(on,{className:"w-6 h-6"})}),o("div",{children:[t(Pt,{className:"text-xl font-bold",children:Ac()}),t(Ft,{children:Qu()})]})]}),a&&o(S,{onClick:()=>r(!0),className:"gap-2",children:[t(de,{className:"w-4 h-4"})," ",qd()]})]}),t(Mt,{children:m?t("div",{className:"flex justify-center py-10",children:t(Z,{className:"w-8 h-8 animate-spin text-primary"})}):j.length===0?o("div",{className:"text-center py-12 border-2 border-dashed border-border rounded-xl",children:[t("div",{className:"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4 text-muted-foreground",children:t(on,{className:"w-6 h-6"})}),t("h3",{className:"text-base font-semibold",children:Ah()}),t("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm mx-auto",children:Qg()}),a&&o(S,{onClick:()=>r(!0),className:"mt-4 gap-2",variant:"outline",children:[t(de,{className:"w-4 h-4"})," ",qd()]})]}):t("div",{className:"space-y-4",children:j.map((z)=>{let ne=g===z.id,ie=z.status==="needs_auth"||!z.hasCredential&&z.authType!=="none";return o("div",{onClick:()=>a&&c(z),className:`p-4 bg-card rounded-xl border border-border flex flex-col justify-between hover:shadow-md transition-all group ${a?"cursor-pointer":""}`,children:[o("div",{className:"flex items-start justify-between gap-2 mb-2",children:[o("h4",{className:"font-bold text-foreground flex items-center gap-2 min-w-0",children:[t(on,{className:"w-4 h-4 text-muted-foreground shrink-0"}),t("span",{className:"truncate",children:z.name}),t(be,{variant:"outline",className:"text-[10px] uppercase shrink-0",children:z.transport})]}),a&&o(he,{modal:!1,children:[t(ge,{asChild:!0,onClick:(F)=>F.stopPropagation(),children:t(S,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:t(Ar,{className:"w-4 h-4"})})}),o(Ae,{align:"end",children:[z.status!=="connected"&&(z.authType!=="none"||z.hasCredential)?o(V,{onClick:(F)=>{F.stopPropagation(),M(z.id)},children:[t(Zt,{className:"w-4 h-4 mr-2"}),th()]}):null,z.hasCredential&&o(V,{onClick:(F)=>{F.stopPropagation(),_.mutate(z.id)},className:"text-amber-600",children:[t(Ja,{className:"w-4 h-4 mr-2"}),rh()]}),(z.status!=="connected"&&(z.authType!=="none"||z.hasCredential)||z.hasCredential)&&t(qt,{}),o(V,{onClick:(F)=>{F.stopPropagation(),w(z)},className:"text-red-600",children:[t(ve,{className:"w-4 h-4 mr-2"}),at()]})]})]})]}),o("div",{className:"space-y-1",children:[t("p",{className:"text-sm text-muted-foreground line-clamp-2",children:z.description||mh()}),t("p",{className:"font-mono text-[10px] text-muted-foreground/70 truncate",children:z.url}),z.lastError&&t("p",{className:"text-[10px] text-red-500/90 truncate font-mono",children:z.lastError})]}),o("div",{className:"mt-4 flex items-center justify-between gap-2 pt-2 border-t border-border/50 text-xs",children:[o("div",{className:"flex items-center gap-2 min-w-0",children:[Y(z),o(be,{variant:"outline",className:"text-[10px] gap-1 shrink-0",children:[t(mo,{className:"w-3 h-3 text-muted-foreground"}),$v({count:z.toolCount})]}),o("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider font-semibold whitespace-nowrap",children:[xg()," ",new Date(z.updatedAt).toLocaleDateString()]})]}),o("div",{className:"flex items-center gap-2 shrink-0",onClick:(F)=>F.stopPropagation(),children:[a?o(De,{value:z.permission,onValueChange:(F)=>b.mutate({id:z.id,permission:F}),children:[t(Le,{className:"h-7 text-xs px-2 bg-background border-border w-[130px]",children:t(Ze,{})}),o(Be,{align:"end",children:[t(re,{value:"reviewer",children:pi()}),t(re,{value:"editor",children:mi()}),t(re,{value:"owner",children:hi()})]})]}):t(be,{variant:"outline",className:"text-[10px]",children:z.permission==="reviewer"?pi():z.permission==="editor"?mi():hi()}),ie&&a&&o(S,{size:"sm",variant:"default",onClick:(F)=>{F.stopPropagation(),M(z.id)},disabled:ne,className:"gap-1.5 bg-amber-600 hover:bg-amber-700 text-white text-xs",children:[ne?t(Z,{className:"w-3.5 h-3.5 animate-spin"}):t(Zt,{className:"w-3.5 h-3.5"}),th()]})]})]})]},z.id)})})}),t(Fs,{isOpen:l||!!d,onClose:()=>{r(!1),c(null)},teamId:e,server:d}),t(We,{open:!!f,onOpenChange:(z)=>!z&&w(null),children:o(Ye,{children:[o(Je,{children:[t(et,{children:$0()}),t(tt,{children:Q0({name:f?.name||""})})]}),o(Xe,{children:[t(nt,{children:Re()}),o(rt,{onClick:()=>f&&i.mutate(f.id),className:"bg-red-600 hover:bg-red-700 text-white",children:[i.isPending&&t(Z,{className:"w-4 h-4 mr-2 animate-spin"}),at()]})]})]})})]})};function As({teamId:e}){let s=Q(),{data:a,isLoading:l}=L({queryKey:["teams",e,"notification-settings"],queryFn:async()=>{let f=await A.api.teams[":teamId"].notifications.settings.$get({param:{teamId:e}});if(!f.ok)throw Error(Ko());return await f.json()}}),{mutate:r,isPending:d}=U({mutationFn:async(f)=>{let w=await A.api.teams[":teamId"].notifications.settings.$post({param:{teamId:e},json:f});if(!w.ok)throw Error(Fm());return await w.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"notification-settings"]}),s.invalidateQueries({queryKey:["teams",e,"notifications"]}),R.success(nx())},onError:(f)=>{R.error(f instanceof Error?f.message:Fm())}}),c=(f)=>{if(!a)return;let w={...a,[f]:!a[f]};r(w)};if(l)return t("div",{className:"flex items-center justify-center p-8",children:t(Z,{className:"h-8 w-8 animate-spin text-muted-foreground"})});return t(se,{className:"h-full",children:o("div",{className:"space-y-6 pr-4 pb-8",children:[o(St,{className:"overflow-hidden gap-0 py-0",children:[o(kt,{className:"border-b border-border bg-muted/30 py-5",children:[o("div",{className:"flex items-center gap-2",children:[t(lo,{className:"w-5 h-5 text-primary"}),t(Pt,{className:"text-lg",children:Vy()})]}),t(Ft,{children:Ky()})]}),o(Mt,{className:"divide-y divide-border p-0",children:[o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(lo,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:Cb()}),t("p",{className:"text-sm text-muted-foreground",children:PI()})]})]}),t(je,{checked:a?.comments??!0,onCheckedChange:()=>c("comments"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(Wa,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:Qy()}),t("p",{className:"text-sm text-muted-foreground",children:OI()})]})]}),t(je,{checked:a?.replies??!0,onCheckedChange:()=>c("replies"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(Ua,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:fy()}),t("p",{className:"text-sm text-muted-foreground",children:NI()})]})]}),t(je,{checked:a?.mentions??!0,onCheckedChange:()=>c("mentions"),disabled:d})]})]})]}),o(St,{className:"overflow-hidden gap-0 py-0",children:[o(kt,{className:"border-b border-border bg-muted/30 py-5",children:[o("div",{className:"flex items-center gap-2",children:[t(kn,{className:"w-5 h-5 text-primary"}),t(Pt,{className:"text-lg",children:uy()})]}),t(Ft,{children:dy()})]}),o(Mt,{className:"divide-y divide-border p-0",children:[o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(Hs,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:ZI()}),t("p",{className:"text-sm text-muted-foreground",children:DI()})]})]}),t(je,{checked:a?.yourUploads??!1,onCheckedChange:()=>c("yourUploads"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(kn,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:Ex()}),t("p",{className:"text-sm text-muted-foreground",children:RI()})]})]}),t(je,{checked:a?.otherUploads??!0,onCheckedChange:()=>c("otherUploads"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(xa,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:lE()}),t("p",{className:"text-sm text-muted-foreground",children:kI()})]})]}),t(je,{checked:a?.statusUpdates??!0,onCheckedChange:()=>c("statusUpdates"),disabled:d})]})]})]}),o(St,{className:"overflow-hidden gap-0 py-0",children:[o(kt,{className:"border-b border-border bg-muted/30 py-5",children:[o("div",{className:"flex items-center gap-2",children:[t(Ma,{className:"w-5 h-5 text-primary"}),t(Pt,{className:"text-lg",children:nv()})]}),t(Ft,{children:rv()})]}),o(Mt,{className:"divide-y divide-border p-0",children:[o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(Ma,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:ov()}),t("p",{className:"text-sm text-muted-foreground",children:MI()})]})]}),t(je,{checked:a?.kanbanTasks??!0,onCheckedChange:()=>c("kanbanTasks"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(lo,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:tv()}),t("p",{className:"text-sm text-muted-foreground",children:TI()})]})]}),t(je,{checked:a?.kanbanComments??!0,onCheckedChange:()=>c("kanbanComments"),disabled:d})]})]})]})]})})}C();function Is({teamId:e}){let s=Q(),[a,l]=u(""),[r,d]=u(null),{data:c,isLoading:f}=L({queryKey:["teams",e,"api-tokens"],queryFn:async()=>{let i=await A.api.teams[":teamId"]["api-tokens"].$get({param:{teamId:e}});if(!i.ok)throw Error("Failed to fetch API tokens");return await i.json()}}),{mutate:w,isPending:g}=U({mutationFn:async(i)=>{let b=await A.api.teams[":teamId"]["api-tokens"].$post({param:{teamId:e},json:{name:i}});if(!b.ok)throw Error("Failed to create API token");return await b.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"api-tokens"]}),l(""),R.success(ty())},onError:(i)=>{R.error(i instanceof Error?i.message:Q_())}}),{mutate:y}=U({mutationFn:async(i)=>{let b=await A.api.teams[":teamId"]["api-tokens"][":tokenId"].$delete({param:{teamId:e,tokenId:i}});if(!b.ok)throw Error("Failed to delete API token");return await b.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"api-tokens"]}),R.success(ry())},onError:(i)=>{R.error(i instanceof Error?i.message:J_())}}),x=(i)=>{if(i.preventDefault(),!a.trim())return;w(a.trim())},m=async(i,b)=>{await Jn(b),d(i),R.success(s0()),setTimeout(()=>d(null),2000)};if(f)return t("div",{className:"flex justify-center items-center p-8",children:t(Z,{className:"w-8 h-8 animate-spin text-muted-foreground"})});return t("div",{className:"space-y-6",children:o(St,{children:[o(kt,{children:[t(Pt,{children:hm()}),t(Ft,{children:ny()})]}),o(Mt,{className:"space-y-6",children:[o("form",{onSubmit:x,className:"flex gap-4 items-end max-w-md",children:[o("div",{className:"flex-1 space-y-2",children:[t("label",{htmlFor:"tokenName",className:"text-sm font-medium text-muted-foreground",children:XE()}),t(q,{id:"tokenName",value:a,onChange:(i)=>l(i.target.value),placeholder:eI(),required:!0})]}),o(S,{type:"submit",disabled:g||!a.trim(),children:[g?t(Z,{className:"w-4 h-4 animate-spin mr-2"}):t(de,{className:"w-4 h-4 mr-2"}),Ib()]})]}),t("div",{className:"border rounded-lg overflow-hidden",children:o(bn,{children:[t(vn,{children:o(hr,{children:[t(_t,{children:Xi()}),t(_t,{children:JE()}),t(_t,{children:C0()}),t(_t,{className:"w-[100px] text-right",children:Ug()})]})}),t(wn,{children:!c||c.length===0?t(hr,{children:t(pt,{colSpan:4,className:"text-center py-6 text-muted-foreground text-sm",children:Pw()})}):c.map((i)=>o(hr,{children:[t(pt,{className:"font-medium",children:i.name}),t(pt,{className:"font-mono text-sm max-w-[200px] truncate",children:o("div",{className:"flex items-center gap-2",children:[o("span",{children:[i.token.substring(0,8),"..."]}),t(S,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>m(i.id,i.token),children:r===i.id?t(Te,{className:"h-3.5 w-3.5 text-green-500"}):t(Er,{className:"h-3.5 w-3.5"})})]})}),t(pt,{className:"text-muted-foreground",children:new Date(i.createdAt).toLocaleDateString()}),t(pt,{className:"text-right",children:t(S,{variant:"ghost",size:"icon",className:"h-8 w-8 text-red-500 hover:text-red-600 hover:bg-red-50",onClick:()=>y(i.id),children:t(ve,{className:"h-4 w-4"})})})]},i.id))})]})})]})]})})}C();C();var Dr=[{value:"read_asset",label:()=>am()},{value:"list_assets",label:()=>nm()},{value:"create_folder",label:()=>Jp()},{value:"create_file",label:()=>Yp()},{value:"create_version",label:()=>Xp()},{value:"generate_image",label:()=>tm()},{value:"generate_video",label:()=>rm()},{value:"rename_asset",label:()=>sm()},{value:"move_assets",label:()=>om()},{value:"delete_asset",label:()=>em()}],Ka={agent_total_tokens:{label:()=>nd(),icon:Wn,unit:"tokens",defaultLimit:1e5},agent_cost:{label:()=>ed(),icon:Gs,unit:"$",defaultLimit:10},agent_mcp_call_count:{label:()=>td(),icon:on,unit:"calls",defaultLimit:100},agent_bash_call_count:{label:()=>Xu(),icon:ho,unit:"calls",defaultLimit:50},agent_tool_call_count:{label:()=>rd(),icon:mo,unit:"calls",defaultLimit:100}},Es=({open:e,onOpenChange:s,teamId:a,rule:l,onSuccess:r})=>{let d=Q(),c=!!l,[f,w]=u("each_member"),[g,y]=u("team"),[x,m]=u([]),[i,b]=u("agent_total_tokens"),[_,M]=u(""),[j,Y]=u("*"),[z,ne]=u("read_asset"),[ie,F]=u(1e5),[D,I]=u("1day"),[W,k]=u(!0),[X,xe]=u(!1),[ye,ke]=u(""),{data:Se=[]}=L({queryKey:["teams",a,"members"],queryFn:async()=>{let ae=await A.api.teams[":teamId"].members.$get({param:{teamId:a},query:{}});if(!ae.ok)return[];return await ae.json()},enabled:e}),{data:ee}=L({queryKey:["teams",a,"mcp","servers"],queryFn:async()=>{let ae=await A.api.teams[":teamId"].mcp.servers.$get({param:{teamId:a}});if(!ae.ok)return{servers:[]};return await ae.json()},enabled:e&&i==="agent_mcp_call_count"}),oe=ee?.servers||[];h(()=>{if(l){w(l.scopeMode),y(l.role||"team"),m(l.userIds||[]),b(l.resource);let ae=l.resourceData||{};M(typeof ae.id==="string"?ae.id:""),Y(typeof ae.match==="string"?ae.match:"*"),ne(typeof ae.name==="string"?ae.name:typeof ae.toolName==="string"?ae.toolName:"read_asset"),F(l.limit),I(Rc(l.period)),k(l.enabled)}else w("each_member"),y("team"),m([]),b("agent_total_tokens"),M(""),Y("*"),ne("read_asset"),F(Ka.agent_total_tokens.defaultLimit),I("1day"),k(!0)},[l,e]);let we=(ae)=>{if(b(ae),!c)F(Ka[ae]?.defaultLimit||100)},Fe=U({mutationFn:async()=>{let ae={};if(i==="agent_mcp_call_count")ae.id=_;else if(i==="agent_bash_call_count")ae.match=j.trim()||"*";else if(i==="agent_tool_call_count")ae.name=z||"read_asset";let st=await A.api.teams[":teamId"].quotas.$post({param:{teamId:a},json:{scopeMode:f,role:f!=="selected_members"&&g!=="team"?g:null,userIds:f==="selected_members"?x:null,resource:i,resourceData:Object.keys(ae).length>0?ae:null,limit:Number(ie),period:D,enabled:W}});if(!st.ok){let me=await st.json().catch(()=>({}));throw Error(me?.message||Bm())}return await st.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",a,"quotas"]}),R.success(_S()),s(!1),r?.()},onError:(ae)=>{console.error("CREATE MUTATION ERROR:",ae),R.error(ae instanceof Error?ae.message:Bm())}}),K=U({mutationFn:async()=>{if(!l)return;let ae={};if(i==="agent_mcp_call_count")ae.id=_;else if(i==="agent_bash_call_count")ae.match=j.trim()||"*";else if(i==="agent_tool_call_count")ae.name=z||"read_asset";let st=await A.api.teams[":teamId"].quotas[":id"].$put({param:{teamId:a,id:l.id},json:{scopeMode:f,role:f!=="selected_members"&&g!=="team"?g:null,userIds:f==="selected_members"?x:null,resource:i,resourceData:Object.keys(ae).length>0?ae:null,limit:Number(ie),period:D,enabled:W}});if(!st.ok){let me=await st.json().catch(()=>({}));throw Error(me?.message||qu())}return await st.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",a,"quotas"]}),R.success(HS()),s(!1),r?.()},onError:(ae)=>{R.error(ae instanceof Error?ae.message:qu())}}),J=U({mutationFn:async()=>{if(!l)return;if(!(await A.api.teams[":teamId"].quotas[":id"].$delete({param:{teamId:a,id:l.id}})).ok)throw Error(ju())},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",a,"quotas"]}),R.success(zh()),xe(!1),s(!1),r?.()},onError:(ae)=>{R.error(ae instanceof Error?ae.message:ju())}}),Ne=(ae)=>{if(ae.preventDefault(),f==="selected_members"&&x.length===0){R.error(DC());return}if(i==="agent_mcp_call_count"&&!_.trim()){R.error(Dm());return}if(ie<=0){R.error("Limit must be greater than 0");return}if(c)K.mutate();else Fe.mutate()},le=Fe.isPending||K.isPending||J.isPending,lt=Se.filter((ae)=>{if(!ye.trim())return!0;let st=ye.toLowerCase();return ae.name.toLowerCase().includes(st)||ae.email&&ae.email.toLowerCase().includes(st)}),jt=(ae)=>{m((st)=>st.includes(ae)?st.filter((me)=>me!==ae):[...st,ae])};return o(B,{children:[t(fe,{open:e,onOpenChange:s,children:o(ce,{className:"sm:max-w-[540px] max-h-[90vh] flex flex-col p-0 overflow-hidden",children:[o(pe,{className:"p-6 pb-4 border-b border-border/60 shrink-0",children:[t(ue,{className:"text-xl font-bold",children:c?m_():v0()}),t(It,{className:"text-sm text-muted-foreground",children:c?h_():w0()})]}),o("form",{onSubmit:Ne,noValidate:!0,className:"flex-1 overflow-y-auto min-h-0 p-6 space-y-5",children:[o("div",{className:"space-y-2",children:[t(G,{className:"text-sm font-semibold",children:NS()}),o("div",{className:"grid grid-cols-3 gap-2",children:[o(S,{type:"button",variant:f==="each_member"?"default":"outline",size:"sm",disabled:c||le,onClick:()=>w("each_member"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[t(Ln,{className:"w-4 h-4"}),t("span",{className:"font-semibold",children:ad()})]}),o(S,{type:"button",variant:f==="all_members"?"default":"outline",size:"sm",disabled:c||le,onClick:()=>w("all_members"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[t(Xn,{className:"w-4 h-4"}),t("span",{className:"font-semibold",children:od()})]}),o(S,{type:"button",variant:f==="selected_members"?"default":"outline",size:"sm",disabled:c||le,onClick:()=>w("selected_members"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[t($s,{className:"w-4 h-4"}),t("span",{className:"font-semibold",children:sd()})]})]}),o("p",{className:"text-xs text-muted-foreground pt-0.5",children:[f==="each_member"&&DS(),f==="all_members"&&OS(),f==="selected_members"&&ZS()]})]}),f!=="selected_members"?o("div",{className:"space-y-2",children:[t(G,{htmlFor:"quota-role-scope",className:"text-sm font-semibold",children:PS()}),o(De,{value:g,onValueChange:y,disabled:c||le,children:[t(Le,{id:"quota-role-scope",className:"w-full",children:t(Ze,{})}),o(Be,{children:[t(re,{value:"team",children:al()}),o(re,{value:"owner",children:[zf(),": Owner"]}),o(re,{value:"editor",children:[zf(),": Editor"]}),o(re,{value:"reviewer",children:[zf(),": Reviewer"]})]})]})]}):o("div",{className:"space-y-2",children:[t(G,{className:"text-sm font-semibold",children:og()}),o(ht,{children:[t(gt,{asChild:!0,children:o(S,{variant:"outline",role:"combobox",disabled:le,className:"w-full justify-between text-left font-normal h-10",children:[t("span",{className:"truncate",children:x.length===0?og():LS({count:x.length})}),t(_e,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t(At,{className:"w-[320px] p-2",align:"start",children:o("div",{className:"space-y-2",children:[o("div",{className:"relative",children:[t(Lt,{className:"w-3.5 h-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),t(q,{placeholder:Ff(),value:ye,onChange:(ae)=>ke(ae.target.value),className:"h-8 pl-8 text-xs"})]}),t(se,{className:"h-48",children:t("div",{className:"space-y-1 pr-2",children:lt.map((ae)=>{let st=x.includes(ae.id);return o("div",{onClick:()=>jt(ae.id),className:"flex items-center gap-2 p-1.5 rounded-lg hover:bg-muted/60 cursor-pointer text-xs",children:[t(Mr,{checked:st,onCheckedChange:()=>jt(ae.id)}),o(Ce,{className:"w-5 h-5",children:[t(Ee,{src:ae.image||void 0}),t(Ie,{className:"text-[10px]",children:ae.name?.[0]?.toUpperCase()||"U"})]}),o("div",{className:"truncate flex-1",children:[t("span",{className:"font-medium text-foreground block truncate",children:ae.name}),ae.email&&t("span",{className:"text-[10px] text-muted-foreground block truncate",children:ae.email})]})]},ae.id)})})})]})})]})]}),o("div",{className:"space-y-2",children:[t(G,{htmlFor:"quota-resource",className:"text-sm font-semibold",children:RS()}),o(De,{value:i,onValueChange:(ae)=>we(ae),disabled:c||le,children:[t(Le,{id:"quota-resource",className:"w-full",children:t(Ze,{})}),o(Be,{children:[t(re,{value:"agent_total_tokens",children:o("div",{className:"flex items-center gap-2",children:[t(Wn,{className:"w-4 h-4 text-primary"}),t("span",{children:nd()})]})}),t(re,{value:"agent_cost",children:o("div",{className:"flex items-center gap-2",children:[t(Gs,{className:"w-4 h-4 text-emerald-500"}),t("span",{children:ed()})]})}),t(re,{value:"agent_mcp_call_count",children:o("div",{className:"flex items-center gap-2",children:[t(on,{className:"w-4 h-4 text-blue-500"}),t("span",{children:td()})]})}),t(re,{value:"agent_bash_call_count",children:o("div",{className:"flex items-center gap-2",children:[t(ho,{className:"w-4 h-4 text-purple-500"}),t("span",{children:Xu()})]})}),t(re,{value:"agent_tool_call_count",children:o("div",{className:"flex items-center gap-2",children:[t(mo,{className:"w-4 h-4 text-cyan-500"}),t("span",{children:rd()})]})})]})]})]}),i==="agent_mcp_call_count"&&o("div",{className:"space-y-2",children:[t(G,{htmlFor:"quota-mcp",className:"text-sm font-semibold",children:ng()}),oe.length>0?o(De,{value:_,onValueChange:M,disabled:c||le,children:[t(Le,{id:"quota-mcp",className:"w-full",children:t(Ze,{placeholder:ng()})}),t(Be,{children:oe.map((ae)=>o(re,{value:ae.id,children:[ae.name," (",ae.id,")"]},ae.id))})]}):t(q,{id:"quota-mcp",value:_,onChange:(ae)=>M(ae.target.value),placeholder:Dm(),disabled:c||le})]}),i==="agent_bash_call_count"&&o("div",{className:"space-y-1.5",children:[t(G,{htmlFor:"quota-bash",className:"text-sm font-semibold",children:My()}),t(q,{id:"quota-bash",value:j,onChange:(ae)=>Y(ae.target.value),placeholder:Ry(),disabled:le}),t("p",{className:"text-xs text-muted-foreground",children:AS()})]}),i==="agent_tool_call_count"&&o("div",{className:"space-y-2",children:[t(G,{htmlFor:"quota-tool",className:"text-sm font-semibold",children:sg()}),o(De,{value:z,onValueChange:ne,disabled:c||le,children:[t(Le,{id:"quota-tool",className:"w-full",children:t(Ze,{placeholder:sg()})}),t(Be,{children:Dr.map((ae)=>t(re,{value:ae.value,children:ae.label()},ae.value))})]}),t("p",{className:"text-xs text-muted-foreground",children:qS()})]}),o("div",{className:"grid grid-cols-2 gap-4",children:[o("div",{className:"space-y-2",children:[o(G,{htmlFor:"quota-limit",className:"text-sm font-semibold",children:[xS()," (",Ka[i]?.unit||"",")"]}),t(q,{id:"quota-limit",type:"number",min:"0.01",step:i==="agent_cost"?"0.01":"1",value:ie,onChange:(ae)=>F(Number(ae.target.value)),placeholder:SS(),disabled:le,required:!0})]}),o("div",{className:"space-y-2",children:[t(G,{htmlFor:"quota-period",className:"text-sm font-semibold",children:ES()}),o(De,{value:D,onValueChange:(ae)=>I(ae),disabled:le,children:[t(Le,{id:"quota-period",className:"w-full",children:t(Ze,{})}),o(Be,{children:[t(re,{value:"1hour",children:o("div",{className:"flex items-center gap-2",children:[t(ur,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:Lf()})]})}),t(re,{value:"5hour",children:o("div",{className:"flex items-center gap-2",children:[t(ur,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:Bf()})]})}),t(re,{value:"1day",children:o("div",{className:"flex items-center gap-2",children:[t(ur,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:Zf()})]})}),t(re,{value:"7day",children:o("div",{className:"flex items-center gap-2",children:[t(ur,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:Uf()})]})})]})]})]})]}),o("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/20",children:[o("div",{className:"space-y-0.5",children:[t(G,{htmlFor:"quota-enabled",className:"text-sm font-medium cursor-pointer",children:W?vS():Df()}),t("p",{className:"text-xs text-muted-foreground",children:W?"Active and enforcing limits":"Inactive, requests will bypass this quota"})]}),t(je,{id:"quota-enabled",checked:W,onCheckedChange:k,disabled:le})]}),o(qe,{className:"pt-4 flex items-center justify-between gap-2 sm:justify-between border-t border-border/60",children:[c?o(S,{type:"button",variant:"destructive",size:"sm",onClick:()=>xe(!0),disabled:le,className:"gap-1.5",children:[t(ve,{className:"w-4 h-4"}),t("span",{children:Xd()})]}):t("div",{}),o("div",{className:"flex items-center gap-2",children:[t(S,{type:"button",variant:"outline",onClick:()=>s(!1),disabled:le,children:Re()}),o(S,{type:"submit",disabled:le,className:"gap-2",children:[le&&t(Z,{className:"w-4 h-4 animate-spin"}),c?So():fc()]})]})]})]})]})}),t(We,{open:X,onOpenChange:xe,children:o(Ye,{children:[o(Je,{children:[t(et,{children:Xd()}),t(tt,{children:Rm()})]}),o(Xe,{children:[t(nt,{disabled:le,children:Re()}),o(rt,{onClick:(ae)=>{ae.preventDefault(),J.mutate()},disabled:le,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[le&&t(Z,{className:"w-4 h-4 animate-spin mr-2"}),at()]})]})]})})]})};var Ts=({teamId:e})=>{let s=Q(),[a,l]=u(!1),[r,d]=u(null),[c,f]=u(null),{data:w,isLoading:g}=L({queryKey:["teams",e,"quotas"],queryFn:async()=>{let i=await A.api.teams[":teamId"].quotas.$get({param:{teamId:e}});if(!i.ok)throw Error(Ko());return await i.json()}}),y=U({mutationFn:async({id:i,enabled:b})=>{let _=await A.api.teams[":teamId"].quotas[":id"].$put({param:{teamId:e,id:i},json:{enabled:b}});if(!_.ok)throw Error(qu());return await _.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"quotas"]}),R.success(BS())},onError:(i)=>{R.error(i instanceof Error?i.message:qu())}}),x=U({mutationFn:async(i)=>{if(!(await A.api.teams[":teamId"].quotas[":id"].$delete({param:{teamId:e,id:i}})).ok)throw Error(ju())},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"quotas"]}),R.success(zh()),f(null)},onError:(i)=>{R.error(i instanceof Error?i.message:ju())}}),m=w?.rules||[];return o(se,{className:"h-full",children:[t("div",{className:"space-y-6 pr-4 pb-10",children:o(St,{children:[o(kt,{className:"flex flex-row items-center justify-between space-y-0 pb-6",children:[o("div",{className:"flex items-center gap-3",children:[t("div",{className:"p-2 bg-primary/10 text-primary rounded-lg",children:t(Io,{className:"w-6 h-6"})}),o("div",{children:[t(Pt,{className:"text-xl font-bold",children:Vh()}),t(Ft,{children:Kh()})]})]}),o(S,{onClick:()=>l(!0),className:"gap-2",children:[t(de,{className:"w-4 h-4"})," ",Vp()]})]}),t(Mt,{children:g?t("div",{className:"flex justify-center py-12",children:t(Z,{className:"w-8 h-8 animate-spin text-primary"})}):m.length===0?o("div",{className:"text-center py-12 border-2 border-dashed border-border rounded-xl",children:[t("div",{className:"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4 text-muted-foreground",children:t(Io,{className:"w-6 h-6"})}),t("h3",{className:"text-base font-semibold text-foreground mb-1",children:Ef()}),t("p",{className:"text-sm text-muted-foreground max-w-md mx-auto mb-6",children:Cf()}),o(S,{onClick:()=>l(!0),className:"gap-2",children:[t(de,{className:"w-4 h-4"})," ",Vp()]})]}):t("div",{className:"flex flex-col gap-4",children:m.map((i)=>{let b=vi[i.resource],_=i.resourceData||{};return t("div",{onClick:()=>d(i),className:`group relative flex flex-col justify-between p-5 rounded-xl border bg-card text-card-foreground shadow-2xs transition-all hover:border-primary/40 hover:shadow-xs cursor-pointer ${!i.enabled?"opacity-60 bg-muted/20":""}`,children:o("div",{className:"space-y-3",children:[o("div",{className:"flex items-start justify-between gap-2",children:[o("div",{children:[t("div",{className:"font-semibold text-base text-foreground group-hover:text-primary transition-colors flex items-center gap-2",children:t("span",{children:b?.label?b.label():i.resource})}),o("div",{className:"text-xs text-muted-foreground line-clamp-1",children:[i.resource==="agent_mcp_call_count"&&o("span",{children:["Server: ",String(_.id||"")]}),i.resource==="agent_bash_call_count"&&o("span",{children:["Match: ",String(_.match||"*")]}),i.resource==="agent_tool_call_count"&&o("span",{children:["Tool: ",String(_.name||_.toolName||"*")]})]})]}),o("div",{className:"flex items-center gap-2",onClick:(M)=>M.stopPropagation(),children:[t(je,{checked:i.enabled,onCheckedChange:(M)=>y.mutate({id:i.id,enabled:M}),disabled:y.isPending}),o(he,{modal:!1,children:[t(ge,{asChild:!0,children:t(S,{variant:"ghost",size:"icon","aria-label":"Quota actions",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:t(Ar,{className:"w-4 h-4"})})}),t(Ae,{align:"end",children:o(V,{onClick:()=>f(i),className:"text-destructive focus:text-destructive",children:[t(ve,{className:"w-4 h-4 mr-2"}),at()]})})]})]})]}),t("div",{className:"flex flex-wrap items-center gap-2 pt-2 border-t border-border/50",children:o("div",{className:"flex flex-wrap items-center gap-1.5",children:[i.scopeMode==="all_members"&&o(be,{variant:"secondary",className:"gap-1 text-xs",children:[t(Xn,{className:"w-3 h-3"}),o("span",{children:[od(),i.role?` (${i.role})`:` (${al()})`]})]}),i.scopeMode==="each_member"&&o(be,{variant:"secondary",className:"gap-1 text-xs",children:[t(Ln,{className:"w-3 h-3"}),o("span",{children:[ad(),i.role?` (${i.role})`:` (${al()})`]})]}),i.scopeMode==="selected_members"&&o(be,{variant:"secondary",className:"gap-1 text-xs",children:[t($s,{className:"w-3 h-3"}),o("span",{children:[sd()," (",i.userIds?.length||0,")"]})]}),o(be,{variant:"outline",className:"gap-1 text-xs",children:[t(ur,{className:"w-3 h-3"}),o("span",{children:[rs(i.resource,i.limit)," ",b?.unit," /"," ",wl(i.period)]})]})]})})]})},i.id)})})})]})}),(a||!!r)&&t(Es,{open:a||!!r,onOpenChange:(i)=>{if(!i)l(!1),d(null)},teamId:e,rule:r}),t(We,{open:!!c,onOpenChange:(i)=>{if(!i)f(null)},children:o(Ye,{children:[o(Je,{children:[t(et,{children:Xd()}),t(tt,{children:Rm()})]}),o(Xe,{children:[t(nt,{disabled:x.isPending,children:Re()}),o(rt,{onClick:(i)=>{if(i.preventDefault(),c)x.mutate(c.id)},disabled:x.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[x.isPending&&t(Z,{className:"w-4 h-4 animate-spin mr-2"}),at()]})]})]})})]})};C();var Vs={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 Ls({teamId:e}){let s=Q(),[a,l]=u(null),{data:r,isLoading:d}=L({queryKey:["teams",e,"media-generation"],queryFn:async()=>{let g=await A.api.teams[":teamId"]["media-generation"].$get({param:{teamId:e}});if(!g.ok)throw Error("Failed to fetch media generation settings");return await g.json()}}),c=r?.providers||[],f=r?.enabledModels||[],w=O(()=>{if(!a)return null;return c.find((g)=>g.provider===a.provider)||a},[a,c]);if(d)return t("div",{className:"flex h-64 items-center justify-center",children:t(Z,{className:"h-8 w-8 animate-spin text-muted-foreground"})});return o("div",{className:"flex flex-col h-full min-w-0 w-full",children:[t(se,{className:"h-full pr-1 [&>div>div]:block!",children:t("div",{className:"pb-12 min-w-0 w-full",children:o(St,{className:"border-border min-w-0 w-full",children:[o(kt,{children:[t(Pt,{className:"text-base font-semibold",children:Wv()}),t(Ft,{children:Yv()})]}),t(Mt,{className:"min-w-0",children:t("div",{className:"space-y-2.5 min-w-0",children:c.map((g)=>{let y=Vs[g.provider]||g.provider,x=g.status==="configured_custom",m=g.status==="configured_env",i=f.filter((_)=>_.provider===g.provider&&_.type==="image").length,b=f.filter((_)=>_.provider===g.provider&&_.type==="video").length;return o("div",{onClick:()=>l(g),className:"group cursor-pointer flex items-center justify-between gap-4 p-3.5 rounded-xl border border-border bg-card/50 hover:bg-card/80 hover:border-primary/50 transition-all shadow-none hover:shadow-xs min-w-0",children:[o("div",{className:"flex flex-col gap-1.5 min-w-0 flex-1",children:[o("div",{className:"flex items-center gap-2.5 min-w-0",children:[t("span",{className:"font-semibold text-sm text-foreground truncate",children:y}),t("span",{className:"text-xs text-muted-foreground font-mono opacity-60 truncate",title:g.customApiKeyOrEnv||g.defaultEnvKey,children:g.customApiKeyOrEnv||g.defaultEnvKey})]}),o("div",{className:"flex flex-wrap items-center gap-2 min-w-0",children:[x&&o(be,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 text-[10px] shrink-0 font-normal gap-1",children:[t(gr,{className:"w-3 h-3"}),Oh()]}),m&&o(be,{variant:"outline",className:"bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/20 text-[10px] shrink-0 font-normal gap-1",children:[t(gr,{className:"w-3 h-3"}),Dh()]}),!x&&!m&&t(be,{variant:"outline",className:"bg-muted text-muted-foreground border-border text-[10px] shrink-0 font-normal",children:Zh()}),g.supportedTypes.includes("image")&&o("span",{className:E("inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded border shrink-0 font-normal transition-colors",i>0?"bg-primary/10 text-primary border-primary/20":"bg-muted/50 text-muted-foreground border-border/60"),children:[t(Hn,{className:"w-3 h-3"}),$b({count:i})]}),g.supportedTypes.includes("video")&&o("span",{className:E("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:[t(ma,{className:"w-3 h-3"}),bI({count:b})]})]})]}),t(ft,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors shrink-0"})]},g.provider)})})})]})})}),w&&t(Ir,{isOpen:!!w,onClose:()=>l(null),provider:w,teamId:e,enabledModels:f,onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"media-generation"]})}})]})}function Ir({isOpen:e,onClose:s,provider:a,teamId:l,enabledModels:r,onSuccess:d}){let[c,f]=u(()=>a.apiKeyConfigured?"models":"api-key"),[w,g]=u(a.customApiKeyOrEnv||""),[y,x]=u(()=>r.filter((ee)=>ee.provider===a.provider).map((ee)=>({type:ee.type,modelId:ee.modelId,name:ee.name}))),[m,i]=u(""),[b,_]=u("all"),[M,j]=u(""),[Y,z]=u(a.supportedTypes[0]||"image");h(()=>{f(a.apiKeyConfigured?"models":"api-key"),g(a.customApiKeyOrEnv||""),x(r.filter((ee)=>ee.provider===a.provider).map((ee)=>({type:ee.type,modelId:ee.modelId,name:ee.name}))),i(""),_("all"),j(""),z(a.supportedTypes[0]||"image")},[a.provider,a.customApiKeyOrEnv,a.apiKeyConfigured,r]);let{data:ne=[],isLoading:ie}=L({queryKey:["teams",l,"media-generation","curated",a.provider],queryFn:async()=>{let ee=await A.api.teams[":teamId"]["media-generation"].models.curated.$get({param:{teamId:l},query:{provider:a.provider}});if(!ee.ok)return[];return await ee.json()},enabled:e}),{mutate:F,isPending:D}=U({mutationFn:async()=>{let ee=await A.api.teams[":teamId"]["media-generation"].providers[":provider"].$put({param:{teamId:l,provider:a.provider},json:{apiKey:w.trim(),models:y.map((oe)=>({type:oe.type,modelId:oe.modelId,name:oe.name||oe.modelId}))}});if(!ee.ok){let oe=await ee.json().catch(()=>({}));throw Error(oe?.message||"Failed to update provider")}return await ee.json()},onSuccess:()=>{R.success(Lh()),d(),s()},onError:(ee)=>{R.error(ee instanceof Error?ee.message:eb())}}),I=O(()=>new Set(ne.map((ee)=>ee.modelId)),[ne]),W=O(()=>y.filter((ee)=>!I.has(ee.modelId)),[y,I]),k=O(()=>{let ee=[];for(let oe of ne){let we=y.some((Fe)=>Fe.modelId===oe.modelId&&Fe.type===oe.type);ee.push({type:oe.type,modelId:oe.modelId,name:oe.name,isCustom:!1,isToggledOn:we})}for(let oe of W)ee.push({type:oe.type,modelId:oe.modelId,name:oe.name||oe.modelId,isCustom:!0,isToggledOn:!0});return ee},[ne,y,W]),X=O(()=>k.filter((ee)=>{if(b!=="all"&&ee.type!==b)return!1;if(m.trim()){let oe=m.toLowerCase(),we=ee.name.toLowerCase().includes(oe),Fe=ee.modelId.toLowerCase().includes(oe);if(!we&&!Fe)return!1}return!0}),[k,b,m]),xe=(ee,oe)=>{if(oe)x((we)=>[...we,{type:ee.type,modelId:ee.modelId,name:ee.name,isCustom:ee.isCustom}]);else x((we)=>we.filter((Fe)=>!(Fe.modelId===ee.modelId&&Fe.type===ee.type)))},ye=(ee,oe)=>{x((we)=>we.filter((Fe)=>!(Fe.modelId===ee&&Fe.type===oe)))},ke=()=>{let ee=M.trim();if(!ee)return;if(y.some((we)=>we.modelId===ee&&we.type===Y)){R.error(G_());return}x((we)=>[...we,{type:Y,modelId:ee,name:ee,isCustom:!0}]),j("")},Se=Vs[a.provider]||a.provider;return t(fe,{open:e,onOpenChange:(ee)=>!ee&&s(),children:o(ce,{className:"sm:max-w-2xl md:max-w-3xl h-[88vh] flex flex-col p-0 overflow-hidden",children:[o(pe,{className:"p-6 pb-2 shrink-0",children:[o(ue,{className:"flex items-center gap-2 text-xl",children:[t("span",{children:Se}),a.status==="configured_custom"&&t(be,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 text-[10px] font-normal",children:Oh()}),a.status==="configured_env"&&t(be,{variant:"outline",className:"bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/20 text-[10px] font-normal",children:Dh()})]}),t(It,{children:U0({envKey:a.defaultEnvKey})})]}),o(uo,{value:c,onValueChange:(ee)=>f(ee),className:"flex-1 flex flex-col min-h-0",children:[t("div",{className:"px-6 pb-2 shrink-0",children:o(fo,{className:"grid w-full grid-cols-2",children:[t(Hr,{value:"api-key",onClick:()=>f("api-key"),children:Ou()}),o(Hr,{value:"models",onClick:()=>f("models"),children:[Vu()," (",y.length,")"]})]})}),t(_n,{value:"api-key",className:"flex-1 flex flex-col min-h-0 m-0",children:t("div",{className:"flex-1 min-h-0",children:t(se,{className:"h-full",children:t("div",{className:"p-6 space-y-4 pr-6",children:o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t("label",{htmlFor:"provider-api-key",className:"text-xs font-medium text-foreground",children:Ou()}),w&&o(S,{type:"button",variant:"ghost",size:"sm",className:"text-xs h-7 text-destructive hover:bg-destructive/10 hover:text-destructive gap-1 px-2",onClick:()=>g(""),children:[t(ve,{className:"w-3.5 h-3.5"}),zy()]})]}),t(q,{id:"provider-api-key",type:"text",value:w,onChange:(ee)=>g(ee.target.value),placeholder:ey({envKey:a.defaultEnvKey}),className:"font-mono text-sm"}),t("p",{className:"text-xs text-muted-foreground mt-1",children:XA({envKey:a.defaultEnvKey})})]})})})})}),o(_n,{value:"models",className:"flex-1 flex flex-col min-h-0 m-0",children:[!a.apiKeyConfigured&&!w&&t("div",{className:"px-6 pb-2 shrink-0",children:o("div",{className:"flex items-start gap-2.5 p-3 rounded-lg bg-amber-500/10 border border-amber-500/20 text-amber-600 dark:text-amber-400 text-xs",children:[t(an,{className:"w-4 h-4 shrink-0 mt-0.5"}),o("div",{children:[t("p",{className:"font-medium",children:Zh()}),t("p",{className:"text-[11px] opacity-90 mt-0.5",children:fS()})]})]})}),o("div",{className:"px-6 pb-3 flex items-center justify-between gap-3 shrink-0",children:[o("div",{className:"relative flex-1",children:[t(Lt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t(q,{type:"text",placeholder:Vf(),value:m,onChange:(ee)=>i(ee.target.value),className:"pl-9 h-9 text-xs"})]}),a.supportedTypes.length>1&&o("div",{className:"flex rounded-md border border-border overflow-hidden shrink-0 h-9",children:[t("button",{type:"button",onClick:()=>_("all"),className:E("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:$A()}),o("button",{type:"button",onClick:()=>_("image"),className:E("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:[t(Hn,{className:"w-3.5 h-3.5"}),_f()]}),o("button",{type:"button",onClick:()=>_("video"),className:E("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:[t(ma,{className:"w-3.5 h-3.5"}),bf()]})]})]}),t("div",{className:"flex-1 min-h-0 px-6",children:t(se,{className:"h-full pr-4",children:ie?o("div",{className:"flex h-48 items-center justify-center gap-2 text-muted-foreground",children:[t(Z,{className:"h-5 w-5 animate-spin"}),t("span",{className:"text-xs",children:fv()})]}):X.length===0?t("div",{className:"text-center py-12 border border-dashed rounded-xl text-muted-foreground text-sm",children:Wu()}):t("div",{className:"space-y-2 pb-4",children:X.map((ee)=>o("div",{className:E("flex items-center justify-between p-3 rounded-xl border transition-all text-xs",ee.isToggledOn?"border-primary/40 bg-primary/5":"border-border bg-card hover:border-primary/30"),children:[o("div",{className:"flex items-center gap-2.5 min-w-0 flex-1 mr-3",children:[o(be,{variant:"outline",className:E("text-[10px] px-1.5 py-0.5 gap-1 shrink-0 font-normal",ee.type==="image"?"bg-primary/10 text-primary border-primary/20":"bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20"),children:[ee.type==="image"?t(Hn,{className:"w-3 h-3"}):t(ma,{className:"w-3 h-3"}),ee.type==="image"?_f():bf()]}),o("div",{className:"min-w-0 flex-1",children:[o("div",{className:"font-semibold text-foreground text-sm truncate flex items-center gap-1.5",children:[t("span",{className:"truncate",children:ee.name}),ee.isCustom&&t(be,{variant:"secondary",className:"text-[10px] h-4 px-1 font-normal shrink-0",children:R0().replace("...","")})]}),t("p",{className:"font-mono text-[11px] text-muted-foreground truncate mt-0.5",children:ee.modelId})]})]}),o("div",{className:"flex items-center gap-2 shrink-0",children:[ee.isCustom&&t(S,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>ye(ee.modelId,ee.type),title:at(),children:t(ve,{className:"w-3.5 h-3.5"})}),t(je,{checked:ee.isToggledOn,onCheckedChange:(oe)=>xe(ee,oe),"aria-label":`Toggle ${ee.name}`})]})]},`${ee.type}-${ee.modelId}`))})})}),t("div",{className:"px-6 py-3 border-t border-border shrink-0 bg-muted/10",children:o("div",{className:"flex items-center gap-2",children:[a.supportedTypes.length>1&&o("div",{className:"flex rounded-md border border-border overflow-hidden shrink-0 h-8",children:[t("button",{type:"button",onClick:()=>z("image"),className:E("px-2.5 py-1 text-xs transition-colors",Y==="image"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:_f()}),t("button",{type:"button",onClick:()=>z("video"),className:E("px-2.5 py-1 text-xs transition-colors",Y==="video"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:bf()})]}),t(q,{type:"text",value:M,onChange:(ee)=>j(ee.target.value),placeholder:I_(),className:"font-mono text-xs h-8 flex-1",onKeyDown:(ee)=>{if(ee.key==="Enter")ee.preventDefault(),ke()}}),o(S,{type:"button",size:"sm",variant:"outline",className:"h-8 text-xs shrink-0 gap-1",onClick:ke,disabled:!M.trim(),children:[t(de,{className:"w-3.5 h-3.5"}),jd()]})]})})]})]}),o(qe,{className:"px-6 py-4 border-t border-border shrink-0 flex items-center justify-between sm:justify-between w-full m-0 bg-card",children:[o("div",{className:"text-xs text-muted-foreground",children:[y.length," ",Vu().toLowerCase()]}),o("div",{className:"flex items-center gap-2",children:[t(S,{type:"button",variant:"outline",size:"sm",onClick:s,disabled:D,children:Re()}),o(S,{type:"button",size:"sm",onClick:()=>F(),disabled:D,children:[D&&t(Z,{className:"w-4 h-4 mr-1.5 animate-spin"}),So()]})]})]})]})})}C();C();function Ps({isOpen:e,onClose:s,imageSrc:a,onConfirm:l}){let[r,d]=u(1),[c,f]=u({x:0,y:0}),[w,g]=u(!1),[y,x]=u(!1),m=v({x:0,y:0}),i=v(null),b=v(null),_=250;h(()=>{if(e)d(1),f({x:0,y:0}),x(!1)},[e,a]);let M=(F)=>{F.preventDefault(),g(!0),m.current={x:F.clientX-c.x,y:F.clientY-c.y}},j=(F)=>{if(!w)return;f({x:F.clientX-m.current.x,y:F.clientY-m.current.y})},Y=()=>{g(!1)},z=(F)=>{if(F.touches.length!==1)return;g(!0);let D=F.touches[0];m.current={x:D.clientX-c.x,y:D.clientY-c.y}},ne=(F)=>{if(!w||F.touches.length!==1)return;let D=F.touches[0];f({x:D.clientX-m.current.x,y:D.clientY-m.current.y})},ie=async()=>{let F=i.current,D=b.current;if(!F||!D)return;x(!0);try{let I=F.getBoundingClientRect(),W=512,k=document.createElement("canvas");k.width=512,k.height=512;let X=k.getContext("2d");if(X){X.clearRect(0,0,512,512);let xe=2.048,ye=I.width/r,ke=I.height/r,Se=256+c.x*xe,ee=256+c.y*xe;X.translate(Se,ee),X.scale(r*xe,r*xe),X.drawImage(F,-ye/2,-ke/2,ye,ke);let oe=await new Promise((we)=>{k.toBlob((Fe)=>we(Fe),"image/jpeg",0.9)});if(oe)await l(oe)}}catch(I){console.error("Failed to crop image",I)}finally{x(!1)}};return t(fe,{open:e,onOpenChange:(F)=>!F&&s(),children:o(ce,{className:"sm:max-w-[420px] rounded-2xl border border-border bg-background/95 backdrop-blur-md shadow-2xl p-0 overflow-hidden gap-0",children:[t(pe,{className:"p-6 border-b border-border/40 bg-gradient-to-br from-primary/5 to-transparent",children:o(ue,{className:"text-xl font-bold flex items-center gap-2",children:[t(Za,{className:"w-5 h-5 text-primary"}),qx()]})}),o("div",{className:"p-6 flex flex-col items-center gap-6",children:[o("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:M,onMouseMove:j,onMouseUp:Y,onMouseLeave:Y,onTouchStart:z,onTouchMove:ne,onTouchEnd:Y,children:[a&&t("img",{ref:i,src:a,alt:Ey(),crossOrigin:"anonymous",className:"absolute origin-center max-w-none pointer-events-none transition-transform duration-75 select-none",style:{top:"50%",left:"50%",transform:`translate(-50%, -50%) translate(${c.x}px, ${c.y}px) scale(${r})`,maxHeight:"100%"}}),t("div",{className:"absolute inset-0 pointer-events-none border-[3px] border-primary/90 rounded-full"}),t("div",{className:"absolute inset-0 pointer-events-none bg-black/40",style:{clipPath:"polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)",maskImage:"radial-gradient(circle, transparent 122px, black 123px)",WebkitMaskImage:"radial-gradient(circle, transparent 122px, black 123px)"}})]}),o("div",{className:"w-full flex items-center gap-3 px-2",children:[t(ts,{className:"w-4 h-4 text-muted-foreground"}),t("input",{type:"range",min:"1.0",max:"3.0",step:"0.01",value:r,onChange:(F)=>d(parseFloat(F.target.value)),className:"flex-1 h-1.5 bg-muted rounded-lg appearance-none cursor-pointer accent-primary focus:outline-none"}),t(es,{className:"w-4 h-4 text-muted-foreground"})]})]}),o(qe,{className:"p-6 border-t border-border/40 bg-muted/20 flex flex-row justify-end gap-3",children:[t(S,{variant:"outline",onClick:s,disabled:y,children:Re()}),t(S,{onClick:ie,disabled:y||!a,className:"min-w-[80px]",children:y?o(B,{children:[t(Z,{className:"w-4 h-4 animate-spin mr-2"}),Jh()]}):So()})]})]})})}var Tr=["general","transcode","quotas","skills","mcp","providers","image-video","agents","sandbox","notifications","developer"];function Bs(){if(typeof window>"u")return"general";let e=window.location.hash.replace(/^#/,"");return Tr.includes(e)?e:"general"}function Vr(){let{teamId:e}=Lr.useParams(),s=Q(),[a,l]=u(Bs),r=(oe)=>{l(oe);let we=oe==="general"?"":`#${oe}`;if(window.location.hash!==we)window.history.replaceState(null,"",window.location.pathname+window.location.search+we)};h(()=>{let oe=()=>{l(Bs())};return window.addEventListener("hashchange",oe),()=>window.removeEventListener("hashchange",oe)},[]);let[d,c]=u(""),[f,w]=u(!1),[g,y]=u(null),x=v(null),[m,i]=u(!1),{setMetadata:b,getMetadata:_}=Eo(),M=_("locale")||n(),j=async(oe)=>{if(oe==="en"||oe==="zh")try{await b(e,"locale",oe),ui(oe),R.success(sv())}catch(we){console.error(we),R.error(rb())}},{data:Y,isLoading:z,error:ne}=L({queryKey:["teams",e,"settings"],queryFn:async()=>{let oe=await A.api.teams[":teamId"].settings.$get({param:{teamId:e}});if(!oe.ok)throw Error("Failed to fetch settings");return await oe.json()}}),{data:ie,isLoading:F}=L({queryKey:["teams",e,"me"],queryFn:async()=>{let oe=await A.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!oe.ok)throw Error("Failed to fetch me");return await oe.json()},enabled:!!e});h(()=>{if(ie?.name)c(ie.name)},[ie]),h(()=>{let oe=["transcode","quotas","providers","image-video","skills","mcp","agents","sandbox"];if(ie&&ie.role!=="owner"&&oe.includes(a))r("general")},[ie,a]);let D=(oe)=>{if(!oe)return"U";let we=oe.split(" ");if(we.length>1)return`${we[0][0]}${we[we.length-1][0]}`.toUpperCase();return oe.substring(0,2).toUpperCase()},I=(oe)=>{let we=oe.target.files?.[0];if(we){let Fe=new FileReader;Fe.onload=()=>{y(Fe.result),w(!0)},Fe.readAsDataURL(we),oe.target.value=""}},W=async(oe)=>{i(!0);try{let we=new File([oe],"avatar.jpg",{type:"image/jpeg"}),Fe=await A.api.teams[":teamId"].files.$post({param:{teamId:e},form:{file:we}});if(!Fe.ok)throw Error("Failed to upload avatar");let J=(await Fe.json()).key;if(!(await A.api.teams[":teamId"].me.$patch({param:{teamId:e},json:{imageKey:J}})).ok)throw Error("Failed to save profile");R.success(Iy()),s.invalidateQueries({queryKey:["teams",e,"me"]}),w(!1)}catch(we){console.error(we),R.error(tb())}finally{i(!1)}},k=async()=>{i(!0);try{if(!(await A.api.teams[":teamId"].me.$patch({param:{teamId:e},json:{imageKey:null}})).ok)throw Error("Failed to remove avatar");R.success(Cy()),s.invalidateQueries({queryKey:["teams",e,"me"]})}catch(oe){console.error(oe),R.error(q_())}finally{i(!1)}},X=async()=>{if(!d.trim())return;i(!0);try{if(!(await A.api.teams[":teamId"].me.$patch({param:{teamId:e},json:{name:d.trim()}})).ok)throw Error("Failed to update name");R.success(Th()),s.invalidateQueries({queryKey:["teams",e,"me"]})}catch(oe){console.error(oe),R.error(nb())}finally{i(!1)}},{mutate:xe}=U({mutationFn:async(oe)=>{let we=await A.api.teams[":teamId"].settings.$patch({param:{teamId:oe.teamId},json:oe.data});if(!we.ok)throw Error("Failed to update settings");return await we.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"settings"]})}}),ye=(oe)=>{xe({teamId:e,data:{key:"transcode.videoStrategy",value:oe}})},ke=(oe)=>{xe({teamId:e,data:{key:"transcode.hardwareAcceleration",value:oe}})};if(z||F)return t("div",{className:"flex h-screen items-center justify-center",children:t(Z,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(ne)return t("div",{className:"p-8 text-center text-red-500",children:Ko()});let Se=Y?.transcode?.videoStrategy||Ya.best_match;if(Se==="single"||Se==="disable")Se=Ya.best_match;else if(Se==="full")Se=Ya.all;let ee=Y?.transcode?.hardwareAcceleration||yi.off;return t("div",{className:"h-full bg-background font-sans selection:bg-primary/20 transition-colors duration-300",children:o("div",{className:"flex flex-col md:flex-row h-full",children:[t("div",{className:"w-full h-full md:w-72 bg-sidebar border-b md:border-b-0 md:border-r border-sidebar-border z-10 md:left-16 overflow-y-auto transition-colors duration-300",children:o("nav",{className:"p-4 space-y-1 mt-4",children:[t("div",{className:"mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider",children:Fx()}),o("button",{onClick:()=>r("general"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="general"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Ln,{className:"w-5 h-5"}),Sb(),a==="general"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("notifications"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="notifications"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Hs,{className:"w-5 h-5"}),_h(),a==="notifications"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("developer"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="developer"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Zt,{className:"w-5 h-5"}),hm(),a==="developer"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),ie?.role==="owner"&&o(B,{children:[t("div",{className:"mt-6 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:NE()}),o("button",{onClick:()=>r("transcode"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="transcode"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Ga,{className:"w-5 h-5"}),ih(),a==="transcode"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("quotas"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="quotas"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Io,{className:"w-5 h-5"}),id(),a==="quotas"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]}),ie?.role==="owner"&&o(B,{children:[t("div",{className:"mt-6 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:FA()}),o("button",{onClick:()=>r("providers"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="providers"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Wn,{className:"w-5 h-5"}),pS(),a==="providers"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("image-video"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="image-video"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Yr,{className:"w-5 h-5"}),Ym(),a==="image-video"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("skills"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="skills"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(wt,{className:"w-5 h-5"}),cg(),a==="skills"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("mcp"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="mcp"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(on,{className:"w-5 h-5"}),Ac(),a==="mcp"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("agents"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="agents"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(bt,{className:"w-5 h-5"}),PA(),a==="agents"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("sandbox"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="sandbox"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(bl,{className:"w-5 h-5"}),uA(),a==="sandbox"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]})]})}),t("main",{className:"flex-1 bg-background/50 h-full flex flex-col transition-colors duration-300 overflow-y-hidden",children:o("div",{className:"flex-1 flex flex-col max-w-4xl w-full mx-auto p-6 md:p-10 overflow-hidden",children:[t("div",{className:"flex-none flex items-center justify-between mb-6",children:o("div",{children:[o("h2",{className:"text-2xl font-bold text-foreground",children:[a==="general"&&Vm(),a==="transcode"&&ih(),a==="quotas"&&Vh(),a==="skills"&&ug(),a==="mcp"&&Ac(),a==="providers"&&zA(),a==="image-video"&&Ym(),a==="agents"&&UA(),a==="sandbox"&&dA(),a==="notifications"&&rx(),a==="developer"&&s_()]}),o("p",{className:"text-sm text-muted-foreground mt-1",children:[a==="general"&&Eb(),a==="transcode"&&vg(),a==="quotas"&&Kh(),a==="skills"&&eE(),a==="mcp"&&Qu(),a==="providers"&&mS(),a==="image-video"&&Kv(),a==="agents"&&NA(),a==="sandbox"&&lC(),a==="notifications"&&ox(),a==="developer"&&a_()]})]})}),o("div",{className:"flex-1 overflow-hidden animate-in fade-in slide-in-from-bottom-4 duration-500",children:[a==="general"&&o("div",{className:"h-full overflow-y-auto space-y-6 pr-1",children:[o(St,{children:[o(kt,{children:[t(Pt,{children:Ux()}),t(Ft,{children:zx()})]}),t(Mt,{className:"space-y-6",children:o("div",{className:"flex flex-col md:flex-row gap-8 items-start",children:[o("div",{className:"flex flex-col items-center gap-3",children:[t("span",{className:"text-sm font-medium text-muted-foreground",children:Sy()}),o("div",{className:"group relative cursor-pointer overflow-hidden rounded-full w-24 h-24 border border-border/60 shadow-md transition-all hover:opacity-90",onClick:()=>x.current?.click(),children:[o(Ce,{className:"w-24 h-24",children:[ie?.image&&t(Ee,{src:ie.image,alt:ie.name,className:"object-cover w-24 h-24"}),t(Ie,{className:"text-2xl bg-primary/40 text-foreground",children:D(ie?.name)})]}),t("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:t("span",{className:"text-white text-xs font-semibold",children:Zy()})})]}),o("div",{className:"flex gap-2",children:[t(S,{variant:"outline",size:"sm",onClick:()=>x.current?.click(),children:fI()}),ie?.image&&t(S,{variant:"ghost",size:"sm",className:"text-red-500 hover:text-red-600",onClick:k,children:sl()})]}),t("input",{type:"file",ref:x,className:"hidden",accept:"image/*",onChange:I})]}),o("div",{className:"flex-1 space-y-4 w-full",children:[o("div",{className:"space-y-2",children:[t("label",{className:"text-sm font-medium text-muted-foreground",children:Xi()}),t(q,{value:d,onChange:(oe)=>c(oe.target.value),placeholder:R_(),className:"max-w-md"})]}),o("div",{className:"space-y-2",children:[t("label",{className:"text-sm font-medium text-muted-foreground",children:rf()}),t(q,{value:ie?.email||"",disabled:!0,className:"max-w-md bg-muted/50 cursor-not-allowed"}),t("p",{className:"text-xs text-muted-foreground",children:y_()})]}),o(S,{onClick:X,disabled:m||!d.trim(),className:"mt-2",children:[m&&t(Z,{className:"w-4 h-4 animate-spin mr-2"}),va()]})]})]})})]}),o(St,{className:"border border-slate-200 dark:border-slate-800 mt-6",children:[o(kt,{children:[t(Pt,{children:av()}),t(Ft,{children:PC()})]}),t(Mt,{className:"space-y-4",children:t("div",{className:"max-w-xs",children:o(De,{value:M,onValueChange:j,children:[t(Le,{children:t(Ze,{placeholder:TC()})}),o(Be,{children:[t(re,{value:"en",children:C_()}),t(re,{value:"zh",children:Uy()})]})]})})})]}),t(Ps,{isOpen:f,onClose:()=>w(!1),imageSrc:g,onConfirm:W})]}),a==="transcode"&&t("div",{className:"h-full overflow-y-auto pr-1",children:o(St,{children:[o(kt,{children:[t(Pt,{children:rI()}),o(Ft,{children:[t("span",{className:"block mb-2",children:vg()}),t("span",{className:"block",children:nI()})]})]}),o(Mt,{className:"space-y-6",children:[o("div",{className:"space-y-3",children:[t("h3",{className:"text-lg font-medium",children:vI()}),o("div",{className:"space-y-3",children:[o("div",{className:E("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",Se===Ya.best_match?"border-primary bg-primary/5":"border-border"),onClick:()=>ye(Ya.best_match),children:[t("div",{className:"font-semibold",children:ky()}),t("div",{className:"text-sm text-muted-foreground",children:Py()})]}),o("div",{className:E("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",Se===Ya.all?"border-primary bg-primary/5":"border-border"),onClick:()=>ye(Ya.all),children:[t("div",{className:"font-semibold",children:QA()}),t("div",{className:"text-sm text-muted-foreground",children:VA()})]})]})]}),o("div",{className:"space-y-3 pt-6 border-t border-border",children:[t("h3",{className:"text-lg font-medium",children:zb()}),o("div",{className:"space-y-3",children:[o("div",{className:E("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",ee===yi.off?"border-primary bg-primary/5":"border-border"),onClick:()=>ke(yi.off),children:[t("div",{className:"font-semibold",children:qb()}),t("div",{className:"text-sm text-muted-foreground",children:Hb()})]}),o("div",{className:E("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",ee===yi.auto?"border-primary bg-primary/5":"border-border"),onClick:()=>ke(yi.auto),children:[t("div",{className:"font-semibold",children:Fb()}),t("div",{className:"text-sm text-muted-foreground",children:jb()})]})]})]})]})]})}),a==="skills"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(Ms,{teamId:e})}),a==="mcp"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(Ds,{teamId:e})}),a==="providers"&&t(Cs,{teamId:e}),a==="image-video"&&t(Ls,{teamId:e}),a==="agents"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(ws,{teamId:e})}),a==="sandbox"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(ks,{teamId:e})}),a==="notifications"&&t(As,{teamId:e}),a==="developer"&&t(Is,{teamId:e}),a==="quotas"&&t(Ts,{teamId:e})]})]})})]})})}var Lr=Ue("/teams/$teamId/settings")({component:Vr});export{Lr as Route};
|