@shumai-one/shumai 0.6.2 → 0.6.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-02b5bcmc.js +1 -0
- package/bin/{chunk-m0q2cgfg.js → chunk-09mj32d7.js} +1 -1
- package/bin/{chunk-b7bnp021.js → chunk-09mpcg9x.js} +2 -2
- package/bin/{chunk-257dcd2f.js → chunk-0a298n62.js} +2 -2
- package/bin/{chunk-cz13a82m.js → chunk-0rgbxp24.js} +2 -2
- package/bin/{chunk-mwktrwtx.js → chunk-19zbh4fr.js} +1 -1
- package/bin/{chunk-v05rrxp5.js → chunk-1e1q1hyg.js} +2 -2
- package/bin/{chunk-fatmqnp1.js → chunk-1ja2zw4w.js} +1 -1
- package/bin/chunk-1tar0x8s.js +7 -0
- package/bin/{chunk-1nvd90g2.js → chunk-1y6h4vge.js} +1 -1
- package/bin/{chunk-tekwpkjf.js → chunk-20bamhwa.js} +2 -2
- package/bin/{chunk-8mqbztj8.js → chunk-20w1w9x7.js} +2 -2
- package/bin/{chunk-qwpkcp8d.js → chunk-25npafhz.js} +2 -2
- package/bin/{chunk-km4gn6b6.js → chunk-2qgagdb7.js} +1 -1
- package/bin/chunk-2t6g3pny.js +3 -0
- package/bin/{chunk-ns33grgx.js → chunk-34f64q0q.js} +1 -1
- package/bin/{chunk-1wfg56z3.js → chunk-3hgrw1m0.js} +4 -4
- package/bin/{chunk-p3f5aevs.js → chunk-3s2ga6mt.js} +1 -1
- package/bin/{chunk-hzkjgcre.js → chunk-3vpz5nat.js} +1 -1
- package/bin/{chunk-2jj4j8cn.js → chunk-4p31kxjh.js} +2 -2
- package/bin/{chunk-9t3p4xp6.js → chunk-4vjgdj0h.js} +1 -1
- package/bin/{chunk-96qpjght.js → chunk-50pfmxt1.js} +2 -2
- package/bin/{chunk-2cdxm1cp.js → chunk-5ddg5ezb.js} +9 -9
- package/bin/chunk-5ngftxjb.js +218 -0
- package/bin/{chunk-r1xer8gn.js → chunk-6f3zhq64.js} +3 -3
- package/bin/chunk-6nqqe7w9.js +1 -0
- package/bin/{chunk-h1n7jqnw.js → chunk-6t525bmg.js} +1 -1
- package/bin/{chunk-01052ssf.js → chunk-7546ptwg.js} +11 -11
- package/bin/{chunk-82tps5n1.js → chunk-7jz3cmq6.js} +1 -1
- package/bin/{chunk-v5cn90cf.js → chunk-7kah3zb5.js} +2 -2
- package/bin/{chunk-73yncv54.js → chunk-7mawxsk3.js} +2 -2
- package/bin/chunk-8ww98y1m.js +2 -0
- package/bin/{chunk-55h9ze53.js → chunk-9405hzv2.js} +2 -2
- package/bin/{chunk-cgmebxx6.js → chunk-95b4mwyq.js} +1 -1
- package/bin/chunk-9vxmgvc8.js +2 -0
- package/bin/{chunk-knj2s8mg.js → chunk-9x42vgeq.js} +5 -5
- package/bin/{chunk-7sgrtxbt.js → chunk-a859y4e1.js} +2 -2
- package/bin/{chunk-y241cxff.js → chunk-addssm8d.js} +1 -1
- package/bin/{chunk-f6avg5qe.js → chunk-ajq9sxg0.js} +33 -33
- package/bin/chunk-amp9h878.js +2 -0
- package/bin/{chunk-yk12hydf.js → chunk-atdfqdkj.js} +4 -4
- package/bin/{chunk-5wapd171.js → chunk-atpt99h4.js} +10 -10
- package/bin/chunk-awshe30f.js +1 -0
- package/bin/chunk-b3t7gbhm.js +2 -0
- package/bin/{chunk-e4f56spj.js → chunk-bbxwyhz3.js} +3 -3
- package/bin/{chunk-a411xhmm.js → chunk-bd3v8mp1.js} +4 -4
- package/bin/{chunk-167z646e.js → chunk-brgns7hv.js} +1 -1
- package/bin/{chunk-576nj64j.js → chunk-c02727j9.js} +2 -2
- package/bin/{chunk-8yjsmr7g.js → chunk-c1wvs81k.js} +1 -1
- package/bin/chunk-c8frmqsk.js +2 -0
- package/bin/{chunk-xc54vhfz.js → chunk-cagzye3j.js} +1 -1
- package/bin/{chunk-s9ksftq2.js → chunk-cp96e9pq.js} +1 -1
- package/bin/{chunk-q5vkxee3.js → chunk-d55138xx.js} +2 -2
- package/bin/{chunk-7v7mypc6.js → chunk-ddmf9gqv.js} +2 -2
- package/bin/chunk-djb65frk.js +1 -0
- package/bin/{chunk-q83h0hkx.js → chunk-dkhdn92k.js} +2 -2
- package/bin/chunk-dx9f5wab.js +1 -0
- package/bin/{chunk-f25fe9th.js → chunk-dygj751y.js} +11 -11
- package/bin/{chunk-m9adtgzk.js → chunk-e55sgg8t.js} +1 -1
- package/bin/{chunk-q8w4mbw4.js → chunk-enax4303.js} +2 -2
- package/bin/{chunk-vcrmjtcz.js → chunk-erfkd3z9.js} +2 -2
- package/bin/{chunk-8cjet7pp.js → chunk-esj0kwe5.js} +5 -5
- package/bin/{chunk-atfz7g7e.js → chunk-etrm28sy.js} +1 -1
- package/bin/chunk-ex3174e3.js +2 -0
- package/bin/{chunk-9n1w5dw1.js → chunk-ezjxx44x.js} +3 -3
- package/bin/{chunk-cf5axr8c.js → chunk-f4xnx4n6.js} +1 -1
- package/bin/{chunk-7naa7tpn.js → chunk-f8hgy69t.js} +2 -2
- package/bin/chunk-fakph5jp.js +1 -0
- package/bin/{chunk-kvhf12b4.js → chunk-femnbfkj.js} +1 -1
- package/bin/{chunk-ah8fjb6f.js → chunk-ffjdkdcv.js} +2 -2
- package/bin/{chunk-vkzasgxw.js → chunk-gd016e9p.js} +2 -2
- package/bin/{chunk-ympbfzz4.js → chunk-gyv3yrhj.js} +1 -1
- package/bin/{chunk-jzgbxqdg.js → chunk-h2bphev9.js} +2 -2
- package/bin/chunk-h3atwgx2.js +1 -0
- package/bin/chunk-h7xny3de.js +2 -0
- package/bin/{chunk-m82tkhaa.js → chunk-hg3rkp41.js} +5 -5
- package/bin/{chunk-3z85zxkn.js → chunk-hpzk9k55.js} +1 -1
- package/bin/{chunk-9zsv6d2f.js → chunk-hsyfrzdd.js} +1 -1
- package/bin/chunk-hvyy8vct.js +3 -0
- package/bin/{chunk-b5rhvzv9.js → chunk-j2txsbxz.js} +2 -2
- package/bin/chunk-j6x53e33.js +1 -0
- package/bin/chunk-jacanzp7.js +1 -0
- package/bin/{chunk-g6sdezec.js → chunk-jc7dycy6.js} +1 -1
- package/bin/{chunk-cwat1jwx.js → chunk-k7vbk8v4.js} +1 -1
- package/bin/{chunk-zrszykjf.js → chunk-mn0kt3p6.js} +1 -1
- package/bin/chunk-mn71dffh.js +4 -0
- package/bin/{chunk-vp3czaeh.js → chunk-npeapp7e.js} +2 -2
- package/bin/{chunk-2nhgdqdg.js → chunk-p2vsdnd1.js} +2 -2
- package/bin/chunk-pdw77q09.js +2 -0
- package/bin/{chunk-zezje74z.js → chunk-pq6kdp83.js} +3 -3
- package/bin/chunk-ptcz4ed3.js +2 -0
- package/bin/{chunk-z1p13dnc.js → chunk-q1fzgqsv.js} +2 -2
- package/bin/chunk-q4ny4hpt.js +2 -0
- package/bin/{chunk-mzsw9var.js → chunk-q5x0yywj.js} +2 -2
- package/bin/{chunk-g22wmpk1.js → chunk-q8xr1a8j.js} +2 -2
- package/bin/chunk-q8ysc5ex.js +1 -0
- package/bin/{chunk-1ktk6764.js → chunk-qm50g4n5.js} +4 -4
- package/bin/{chunk-q2bew2vc.js → chunk-qvp24w0q.js} +2 -2
- package/bin/{chunk-9xhjy897.js → chunk-r6t0j0jx.js} +3 -3
- package/bin/chunk-s1j4v33x.js +2 -0
- package/bin/{chunk-yq32evnn.js → chunk-s6pk2zyg.js} +5 -5
- package/bin/{chunk-hnkcgvcj.js → chunk-s74g9vsk.js} +1 -1
- package/bin/{chunk-gxepkvt2.js → chunk-sz19nn1x.js} +1 -1
- package/bin/{chunk-hpbn0k9n.js → chunk-sz5zawfw.js} +1 -1
- package/bin/chunk-t68y25gf.js +1 -0
- package/bin/{chunk-mcw198kg.js → chunk-te484xtb.js} +8 -8
- package/bin/{chunk-jt0ykktx.js → chunk-tfrevef9.js} +1 -1
- package/bin/chunk-thpw6tcj.js +2 -0
- package/bin/{chunk-02fvcrej.js → chunk-v0yevesp.js} +7 -7
- package/bin/chunk-vj4gamdn.js +2 -0
- package/bin/{chunk-p4s95471.js → chunk-vmwys2ch.js} +1 -1
- package/bin/{chunk-e4yscwen.js → chunk-vnmggrd6.js} +7 -7
- package/bin/{chunk-hpwv4am3.js → chunk-vv0m0m2f.js} +4 -4
- package/bin/{chunk-x03jwaga.js → chunk-w6g84d59.js} +4 -4
- package/bin/{chunk-3ckkwdjx.js → chunk-wgvgtttc.js} +3 -3
- package/bin/chunk-xy9qpn6b.js +1 -0
- package/bin/{chunk-mcj1xpcc.js → chunk-y3haqtr8.js} +2 -2
- package/bin/chunk-y5dv67mg.js +2 -0
- package/bin/{chunk-4mws03es.js → chunk-yb4mzqrd.js} +2 -2
- package/bin/{chunk-x8mjh387.js → chunk-z0de127n.js} +4 -4
- package/bin/chunk-z8t6e0ee.js +1 -0
- package/bin/chunk-zfg4yy3c.js +2 -0
- package/bin/{chunk-hw6czrya.js → chunk-zkvezz89.js} +1 -1
- package/bin/chunk-zrrnvdxq.js +3 -0
- package/bin/{chunk-srxp5jav.js → chunk-zx1c4vm5.js} +30 -30
- package/bin/chunk-zzqse5qc.js +2 -0
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +328 -328
- package/package.json +7 -7
- package/bin/chunk-0bj887zm.js +0 -2
- package/bin/chunk-26qn7fek.js +0 -2
- package/bin/chunk-2ne2b54t.js +0 -2
- package/bin/chunk-2vbeqczj.js +0 -1
- package/bin/chunk-37p6bcx2.js +0 -1
- package/bin/chunk-3knfx6dm.js +0 -1
- package/bin/chunk-54tbfvya.js +0 -2
- package/bin/chunk-56kh5fxc.js +0 -1
- package/bin/chunk-6cnqjngz.js +0 -1
- package/bin/chunk-7g46e1wy.js +0 -3
- package/bin/chunk-84x8p7v5.js +0 -1
- package/bin/chunk-8fyg9dy4.js +0 -2
- package/bin/chunk-8gtfgkrn.js +0 -2
- package/bin/chunk-8xb6yz11.js +0 -2
- package/bin/chunk-91rb0jpb.js +0 -2
- package/bin/chunk-9f1xk1nt.js +0 -1
- package/bin/chunk-9mk9cvbk.js +0 -1
- package/bin/chunk-9nw5w8vh.js +0 -1
- package/bin/chunk-dk42gf7v.js +0 -2
- package/bin/chunk-eb7mzbfm.js +0 -1
- package/bin/chunk-er14d498.js +0 -3
- package/bin/chunk-fvx9k1dc.js +0 -2
- package/bin/chunk-gtf19jc1.js +0 -2
- package/bin/chunk-hfm82066.js +0 -2
- package/bin/chunk-kj6h5j5a.js +0 -4
- package/bin/chunk-ny1kbmxt.js +0 -2
- package/bin/chunk-p3j6ydk1.js +0 -1
- package/bin/chunk-pk406dgy.js +0 -2
- package/bin/chunk-s1e4qy3q.js +0 -14
- package/bin/chunk-swtwaaqe.js +0 -1
- package/bin/chunk-tagdrg7p.js +0 -1
- package/bin/chunk-twtxnzbv.js +0 -2
- package/bin/chunk-v5mcjwxy.js +0 -2
- package/bin/chunk-x342vzdx.js +0 -2
- package/bin/chunk-xvkwbczx.js +0 -3
- package/bin/chunk-zarz3sqn.js +0 -211
|
@@ -1 +1 @@
|
|
|
1
|
-
import{J,Q,S,G,M,w,Mo,Z,Y,a,g,ie,Lf,Zf,jr,cd,Ga,Yo,ir,ks,Bf,Uf,zf,jf,ud,qf,X,ee,Tt,Je,R,z,wr,K,tn,$t,qe,Be,cr,On,rr,Rs,Ge,B,Ut,Le,pe,Gt,Vr,er,we,Cr,F,$e,He,Qe,$y,Hy,Bm,Ab,vb,bb,zb,Qm,Kb,XA,Ke,xw,Tw,kw,Ya,s_,cE,cp,_d,c_,Mi,Ms,S_,zx,I_,dh,mC,hC,gC,AC,rS,z_,yS,bI,wI,Eh,eT,kh,Rh,mT,wT,IT,VT,g0,xd,s1,S0,Ip,L0,z1,q1,Bh,H1,V1,B0,W1,J1,U0,Y1,ek,Pp,Dp,Np,Kc,Hh,lk,ck,uk,dk,Fp,yk,Pi,Pk,Vk,Jk,uR,eg,fR,ER,xR,SR,IR,TR,kR,ay,RR,ly,py,oM,sM,iM,TM,gy,_y,kM,by,zp,OM,FM,JM,nO,Sy,Jn,pg,SO,OO,PO,Rd,BO,Ag,eP,_t,yt,vt,bt,wt,Et,xt,Ct,Se,xe,ke,Ce,Ot,re,Ie,Vt,j,$l,Hl,tu,nn,vg,co,uo,Wr,gn,ve,pt,mt,ht,Sr,on,rm,lt,Nt,Ft,Ht,St}from"./chunk-zarz3sqn.js";import{os,Lr}from"./chunk-q2bew2vc.js";import{_u}from"./chunk-zezje74z.js";import{Li,eo,gs,iu,Vl,ya,au}from"./chunk-q8w4mbw4.js";import"./chunk-hpbn0k9n.js";import{Bn,Un,zn,Tr,ft,ct}from"./chunk-576nj64j.js";import"./chunk-8yjsmr7g.js";import{Uo}from"./chunk-atfz7g7e.js";import{yu}from"./chunk-91rb0jpb.js";import{jn}from"./chunk-fvx9k1dc.js";import{Zr}from"./chunk-v5cn90cf.js";Z();function de(e,t){let s=new Set(t);return e.filter((i)=>!s.has(i))}var me=class extends Yo{#r;#e;#o;#a;#t;#s;#i;#n;#l;#d=[];constructor(e,t,s){super();this.#r=e,this.#a=s,this.#o=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){if(this.listeners.size===1)this.#t.forEach((e)=>{e.subscribe((t)=>{this.#p(e,t)})})}onUnsubscribe(){if(!this.listeners.size)this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach((e)=>{e.destroy()})}setQueries(e,t){this.#o=e,this.#a=t,ir.batch(()=>{let s=this.#t,i=this.#u(this.#o);i.forEach((p)=>p.observer.setOptions(p.defaultedQueryOptions));let n=i.map((p)=>p.observer),r=n.map((p)=>p.getCurrentResult()),c=s.length!==n.length,u=n.some((p,b)=>p!==s[b]),f=c||u,v=f?!0:r.some((p,b)=>{let h=this.#e[b];return!h||!Ga(p,h)});if(!f&&!v)return;if(f)this.#d=i,this.#t=n;if(this.#e=r,!this.hasListeners())return;if(f)de(s,n).forEach((p)=>{p.destroy()}),de(n,s).forEach((p)=>{p.subscribe((b)=>{this.#p(p,b)})});this.#f()})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map((e)=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){let s=this.#u(e),i=s.map((r)=>r.observer.getOptimisticResult(r.defaultedQueryOptions)),n=s.map((r)=>r.defaultedQueryOptions.queryHash);return[i,(r)=>this.#c(r??i,t,n),()=>this.#m(i,s)]}#m(e,t){let s=new Set;return t.map((i,n)=>{let r=e[n];return!i.defaultedQueryOptions.notifyOnChangeProps?i.observer.trackResult(r,(c)=>{if(!s.has(c))s.add(c),t.forEach((u)=>{u.observer.trackProp(c)})}):r})}#c(e,t,s){if(t){let i=this.#l,n=s!==void 0&&i!==void 0&&(i.length!==s.length||s.some((r,c)=>r!==i[c]));if(this.#e!==this.#n||n||t!==this.#i){if(this.#i=t,this.#n=this.#e,s!==void 0)this.#l=s;this.#s=cd(this.#s,t(e))}return this.#s}return e}#g(){return!this.#a?.combine||this.#t.some((e,t)=>e.options.suspense&&this.#e[t]?.data===void 0)}#u(e){let t=new Map;this.#t.forEach((i)=>{let n=i.options.queryHash;if(!n)return;let r=t.get(n);if(r)r.push(i);else t.set(n,[i])});let s=[];return e.forEach((i)=>{let n=this.#r.defaultQueryOptions(i),r=t.get(n.queryHash)?.shift()??new ks(this.#r,n);s.push({defaultedQueryOptions:n,observer:r})}),s}#p(e,t){let s=this.#t.indexOf(e);if(s!==-1)this.#e=this.#e.slice(),this.#e[s]=t,this.#f()}#f(){if(this.hasListeners()){let e=this.#g(),t=this.#s,s=e?t:this.#c(this.#m(this.#e,this.#d),this.#a?.combine);if(e||t!==s)ir.batch(()=>{this.listeners.forEach((i)=>{i(this.#e)})})}}};Z();function ce({queries:e,...t},s){let i=ie(s),n=Lf(),r=Zf(),c=t.subscribed!==!1,u=G(()=>e.map((m)=>{let x=i.defaultQueryOptions(m);return x._optimisticResults=n?"isRestoring":c?"optimistic":void 0,x}),[e,i,n,c]);u.forEach((m)=>{jf(m);let x=i.getQueryCache().get(m.queryHash);Bf(m,r,x)}),Uf(r);let[f]=w(()=>new me(i,u,t)),[v,p,b]=f.getOptimisticResult(u,t.combine),h=!n&&c;Mo(Q((m)=>h?f.subscribe(ir.batchCalls(m)):jr,[f,h]),()=>f.getCurrentResult(),()=>f.getCurrentResult()),S(()=>{f.setQueries(u,t)},[u,t,f]);let l=v.some((m,x)=>ud(u[x],m))?v.flatMap((m,x)=>{let T=u[x];if(T&&ud(T,m)){let k=new ks(i,T);return qf(T,k,r)}return[]}):[];if(l.length>0)throw Promise.all(l);let C=v.find((m,x)=>{let T=u[x];return T&&zf({result:m,errorResetBoundary:r,throwOnError:T.throwOnError,query:i.getQueryCache().get(T.queryHash),suspense:T.suspense})});if(C)throw C.error;return p(b())}Z();Z();var je=Object.defineProperty,O=(e,t)=>je(e,"name",{value:t,configurable:!0}),se="Collapsible",[Fe,da]=Ut(se),[We,oe]=Fe(se),ze=J(O(function(t,s){let{__scopeCollapsible:i,open:n,defaultOpen:r,disabled:c,onOpenChange:u,...f}=t,[v,p]=er({prop:n,defaultProp:r??!1,onChange:u,caller:se});return a(We,{scope:i,disabled:c,contentId:Vr(),open:v,onOpenToggle:Q(()=>p((b)=>!b),[p]),children:a(we.div,{"data-state":te(v),"data-disabled":c?"":void 0,...f,ref:s})})},"Collapsible")),Ue="CollapsibleTrigger",Ve=J(O(function(t,s){let{__scopeCollapsible:i,...n}=t,r=oe(Ue,i);return a(we.button,{type:"button","aria-controls":r.open?r.contentId:void 0,"aria-expanded":r.open||!1,"data-state":te(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...n,ref:s,onClick:pe(t.onClick,r.onOpenToggle)})},"CollapsibleTrigger")),ue="CollapsibleContent",Xe=J(O(function(t,s){let{forceMount:i,...n}=t,r=oe(ue,t.__scopeCollapsible);return a(Cr,{present:i||r.open,children:({present:c})=>a(Ye,{...n,ref:s,present:c})})},"CollapsibleContent")),Ye=J(O(function(t,s){let{__scopeCollapsible:i,present:n,children:r,...c}=t,u=oe(ue,i),[f,v]=w(n),p=M(null),b=Le(s,p),h=M(0),l=h.current,C=M(0),m=C.current,x=u.open||f,T=M(x),k=M(void 0);return S(()=>{let _=requestAnimationFrame(()=>T.current=!1);return()=>cancelAnimationFrame(_)},[]),Gt(()=>{let _=p.current;if(_){k.current=k.current||{transitionDuration:_.style.transitionDuration,animationName:_.style.animationName},_.style.transitionDuration="0s",_.style.animationName="none";let q=_.getBoundingClientRect();if(h.current=q.height,C.current=q.width,!T.current)_.style.transitionDuration=k.current.transitionDuration,_.style.animationName=k.current.animationName;v(n)}},[u.open,n]),a(we.div,{"data-state":te(u.open),"data-disabled":u.disabled?"":void 0,id:u.contentId,hidden:!x,...c,ref:b,style:{["--radix-collapsible-content-height"]:l?`${l}px`:void 0,["--radix-collapsible-content-width"]:m?`${m}px`:void 0,...t.style},children:x&&r})},"CollapsibleContentImpl"));function te(e){return e?"open":"closed"}O(te,"getState");var Ze=ze;var tt=[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V3",key:"1lcnhd"}],["path",{d:"M19 21V9",key:"unv183"}]],fe=z("chart-no-axes-column",tt);var at=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],P=z("funnel",at);var st=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],ge=z("eye",st);var rt=[["path",{d:"M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z",key:"1n2ejm"}],["path",{d:"M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1",key:"1qfcsi"}]],W=z("messages-square",rt);var ot=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],be=z("rotate-cw",ot);var it=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],ae=z("workflow",it);function he({teamId:e}){let[t,s]=w("team"),[i,n]=w("1h"),{data:r,isLoading:c}=X({queryKey:["teams",e,"ai-usage",i,"team"],queryFn:async()=>{let m=await R.api.teams[":teamId"]["ai-usage"].$get({param:{teamId:e},query:{timeframe:i}});if(!m.ok)throw Error("Failed to fetch team AI usage");return await m.json()},enabled:!!e&&t==="team"}),{data:u,isLoading:f}=X({queryKey:["teams",e,"members"],queryFn:async()=>{let m=await R.api.teams[":teamId"].members.$get({param:{teamId:e},query:{}});if(!m.ok)throw Error("Failed to fetch team members");return await m.json()},enabled:!!e&&t==="members"}),v=ce({queries:(u||[]).map((m)=>({queryKey:["teams",e,"ai-usage",i,m.id],queryFn:async()=>{let x=await R.api.teams[":teamId"]["ai-usage"].$get({param:{teamId:e},query:{timeframe:i,userId:m.id}});if(!x.ok)throw Error(`Failed to fetch AI usage for member ${m.id}`);return await x.json()},enabled:!!e&&t==="members"}))}),p=f||v.some((m)=>m.isLoading),b=(m)=>{if(!m)return"U";let x=m.split(" ");if(x.length>1)return`${x[0][0]}${x[x.length-1][0]}`.toUpperCase();return m.substring(0,2).toUpperCase()},h=(m)=>{if(!m)return"";switch(m.toLowerCase()){case"owner":return xd();case"editor":return Mi();case"reviewer":return Pi();default:return m}},l=(m)=>(m??0).toLocaleString(),C=(m)=>`$${(m??0).toFixed(6)}`;return g(lt,{className:"border-border/60 shadow-sm",children:[g(Nt,{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between pb-6",children:[g("div",{children:[a(Ft,{className:"text-xl font-semibold tracking-tight",children:vb()}),a(Ht,{className:"text-sm text-muted-foreground mt-1",children:bb()})]}),g("div",{className:"flex flex-wrap items-center gap-3",children:[g(os,{type:"single",value:t,onValueChange:(m)=>{if(m)s(m)},className:"border rounded-lg p-1 bg-muted/30",children:[a(Lr,{value:"team",className:"px-3 py-1.5 text-xs font-medium",children:FM()}),a(Lr,{value:"members",className:"px-3 py-1.5 text-xs font-medium",children:wI()})]}),g(os,{type:"single",value:i,onValueChange:(m)=>{if(m)n(m)},className:"border rounded-lg p-1 bg-muted/30",children:[a(Lr,{value:"1h",className:"px-2.5 py-1.5 text-xs font-medium",children:"1h"}),a(Lr,{value:"24h",className:"px-2.5 py-1.5 text-xs font-medium",children:"24h"}),a(Lr,{value:"7d",className:"px-2.5 py-1.5 text-xs font-medium",children:"7d"}),a(Lr,{value:"30d",className:"px-2.5 py-1.5 text-xs font-medium",children:"30d"})]})]})]}),a(St,{children:t==="team"?c?a("div",{className:"flex h-48 items-center justify-center",children:a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):a("div",{className:"rounded-md border",children:g(Bn,{children:[a(Un,{children:g(Tr,{children:[a(ft,{children:zp()}),a(ft,{className:"text-right",children:z_()}),a(ft,{className:"text-right",children:g0()}),a(ft,{className:"text-right",children:XA()}),a(ft,{className:"text-right",children:Sy()}),a(ft,{className:"text-right",children:s_()})]})}),a(zn,{children:g(Tr,{children:[a(ct,{className:"font-medium",children:zp()}),a(ct,{className:"text-right",children:l(r?.team?.inputTokens)}),a(ct,{className:"text-right",children:l(r?.team?.outputTokens)}),a(ct,{className:"text-right",children:l(r?.team?.cacheReadTokens)}),a(ct,{className:"text-right font-medium",children:l(r?.team?.totalTokens)}),a(ct,{className:"text-right font-medium",children:C(r?.team?.cost)})]})})]})}):p?a("div",{className:"flex h-48 items-center justify-center",children:a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):a("div",{className:"rounded-md border",children:g(Bn,{children:[a(Un,{children:g(Tr,{children:[a(ft,{children:bI()}),a(ft,{children:Pk()}),a(ft,{className:"text-right",children:z_()}),a(ft,{className:"text-right",children:g0()}),a(ft,{className:"text-right",children:XA()}),a(ft,{className:"text-right",children:Sy()}),a(ft,{className:"text-right",children:s_()})]})}),a(zn,{children:(u||[]).map((m,x)=>{let T=v[x]?.data?.member;return g(Tr,{children:[a(ct,{children:g("div",{className:"flex items-center gap-3",children:[g($e,{className:"h-8 w-8 rounded-full",children:[m.image&&a(He,{src:m.image,alt:m.name,className:"object-cover"}),a(Qe,{className:"bg-primary/20 text-xs",children:b(m.name)})]}),g("div",{className:"flex flex-col",children:[a("span",{className:"text-sm font-medium leading-none",children:m.name}),a("span",{className:"text-xs text-muted-foreground mt-0.5",children:m.email})]})]})}),a(ct,{className:"text-xs text-muted-foreground",children:h(m.role)}),a(ct,{className:"text-right",children:l(T?.inputTokens)}),a(ct,{className:"text-right",children:l(T?.outputTokens)}),a(ct,{className:"text-right",children:l(T?.cacheReadTokens)}),a(ct,{className:"text-right font-medium",children:l(T?.totalTokens)}),a(ct,{className:"text-right font-medium",children:C(T?.cost)})]},m.id)})})]})})})]})}Z();function Ne({teamId:e}){let[t,s]=w(null),{ref:i,inView:n}=Vt(),{data:r,isLoading:c,isError:u,fetchNextPage:f,hasNextPage:v,isFetchingNextPage:p}=Tt({queryKey:["teams",e,"agent-sessions"],queryFn:async({pageParam:l})=>{let C=await R.api.teams[":teamId"]["agent-sessions"].$get({param:{teamId:e},query:{first:"20",after:l?String(l):void 0}});if(!C.ok)throw Error("Failed to fetch agent sessions");return await C.json()},initialPageParam:"",getNextPageParam:(l)=>l.pageInfo.cursor||void 0,enabled:!!e});S(()=>{if(n&&v&&!p)f()},[n,v,p,f]);let b=r?.pages.flatMap((l)=>l.data).filter((l)=>l.id!=="pending")||[],h=(l)=>{switch(l){case"comment":return a(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20",children:TR()});case"chat":return a(ve,{variant:"outline",className:"bg-violet-500/10 text-violet-600 dark:text-violet-400 border-violet-500/20",children:IR()});case"naming":return a(ve,{variant:"outline",className:"bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20",children:kR()});default:return a(ve,{variant:"outline",className:"bg-muted text-muted-foreground border-border",children:l})}};return g("div",{className:"space-y-6",children:[g(lt,{className:"border border-border/50 shadow-xs",children:[a(Nt,{className:"pb-4",children:a("div",{className:"flex items-center justify-between",children:g("div",{children:[g(Ft,{className:"text-xl font-bold flex items-center gap-2",children:[a(W,{className:"w-5 h-5 text-violet-500"}),ay()]}),a(Ht,{className:"mt-1 text-sm text-muted-foreground",children:RR()})]})})}),a(St,{children:c?a("div",{className:"flex h-64 items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):u?a("div",{className:"flex h-64 items-center justify-center text-destructive",children:"Failed to load agent sessions."}):b.length===0?g("div",{className:"flex flex-col items-center justify-center py-12 text-center text-muted-foreground",children:[a(W,{className:"w-10 h-10 text-muted-foreground/40 mb-3"}),a("p",{className:"text-base font-medium",children:mT()})]}):g("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[g(Bn,{children:[a(Un,{className:"bg-muted/40",children:g(Tr,{children:[a(ft,{children:xR()}),a(ft,{children:_d()}),a(ft,{children:SR()}),a(ft,{className:"text-right",children:cE()})]})}),a(zn,{children:b.map((l)=>g(Tr,{onClick:()=>s(l.id),className:"cursor-pointer hover:bg-muted/50 transition-colors",children:[a(ct,{className:"font-medium",children:g("div",{className:"flex flex-col",children:[a("span",{className:"text-sm font-semibold text-foreground",children:l.name||pg()}),a("span",{className:"text-xs font-mono text-muted-foreground/70",children:l.id})]})}),a(ct,{children:g("div",{className:"flex items-center gap-2",children:[g($e,{className:"h-6 w-6",children:[a(He,{src:l.creator?.image||void 0}),a(Qe,{className:"text-[10px]",children:l.creator?.name?.[0]?.toUpperCase()||"?"})]}),a("span",{className:"text-sm text-foreground/90",children:l.creator?.name||"System / Agent"})]})}),a(ct,{children:h(l.type)}),a(ct,{className:"text-right text-xs text-muted-foreground",children:nn(l.createdAt)})]},l.id))})]}),a("div",{ref:i,className:"py-4 flex justify-center",children:p&&a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})})]}),a(_u,{sessionId:t,open:!!t,onOpenChange:(l)=>{if(!l)s(null)}})]})}Z();function ye({...e}){return a(Ze,{"data-slot":"collapsible",...e})}function Te({...e}){return a(Ve,{"data-slot":"collapsible-trigger",...e})}function _e({...e}){return a(Xe,{"data-slot":"collapsible-content",...e})}function ne(e){switch(e.toLowerCase()){case"owner":return xd();case"editor":return Mi();case"reviewer":return Pi();default:return e}}function nt(e,t){if(typeof e==="object"&&e!==null&&"message"in e){let s=e.message;if(typeof s==="string")return s}return t}function dt({rule:e}){let t=e.resourceData??{};if(e.resource==="agent_mcp_call_count")return a("span",{children:ck({value:String(t.id??"")})});if(e.resource==="agent_bash_call_count")return a("span",{children:lk({value:String(t.match??"*")})});if(e.resource==="agent_tool_call_count")return a("span",{children:uk({value:String(t.name??t.toolName??"*")})});return null}function ut({rule:e}){if(e.scopeMode==="all_members")return g(ve,{variant:"secondary",className:"gap-1 text-xs",children:[a(Uo,{className:"h-3 w-3"}),g("span",{children:[Pp(),e.role?` (${ne(e.role)})`:` (${Kc()})`]})]});if(e.scopeMode==="each_member")return g(ve,{variant:"secondary",className:"gap-1 text-xs",children:[a(jn,{className:"h-3 w-3"}),g("span",{children:[Dp(),e.role?` (${ne(e.role)})`:` (${Kc()})`]})]});return g(ve,{variant:"secondary",className:"gap-1 text-xs",children:[a(Rs,{className:"h-3 w-3"}),g("span",{children:[Np()," (",e.userIds?.length||0,")"]})]})}function gt({teamId:e,rule:t,record:s}){let i=ie(),[n,r]=w(!1),[c,u]=w(()=>new Date),f=Vl[t.resource],v=t.scopeMode==="all_members",p=s.percent>=100,b=v?t.role?`${ek()}: ${ne(t.role)}`:dk():s.user?.name||s.userId||Jn();S(()=>{if(!s.isWindowActive||!s.periodEnd)return;let l=window.setInterval(()=>u(new Date),60000);return()=>window.clearInterval(l)},[s.isWindowActive,s.periodEnd]);let h=ee({mutationFn:async()=>{let l=await R.api.teams[":teamId"].quotas[":id"].records.reset.$post({param:{teamId:e,id:t.id},json:{userId:s.userId??null}});if(!l.ok){let C=await l.json().catch(()=>null);throw Error(nt(C,I_()))}return await l.json()},onSuccess:()=>{i.invalidateQueries({queryKey:["teams",e,"quotas",t.id,"records"]}),i.invalidateQueries({queryKey:["teams",e,"quotas"]}),r(!1),j.success(J1())},onError:(l)=>{let C=l instanceof Error?l.message:I_();r(!1),j.error(C)}});return g(Y,{children:[g("div",{className:"space-y-3 rounded-xl border border-border/70 bg-card p-4 text-card-foreground shadow-2xs",children:[g("div",{className:"flex items-center justify-between gap-3",children:[g("div",{className:"flex min-w-0 items-center gap-3",children:[v?a("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:a(Uo,{className:"h-5 w-5"})}):g($e,{className:"h-9 w-9 shrink-0 border border-border/50",children:[a(He,{src:s.user?.image||void 0}),a(Qe,{className:"text-xs font-semibold",children:s.user?.name?.[0]?.toUpperCase()||"U"})]}),g("div",{className:"min-w-0",children:[a("div",{className:"truncate text-sm font-semibold text-foreground",children:b}),!v&&s.user?.email&&a("div",{className:"truncate text-xs text-muted-foreground",children:s.user.email})]})]}),g("div",{className:"flex shrink-0 items-center gap-2",children:[s.isWindowActive&&s.periodEnd?g(ve,{variant:"outline",className:"hidden gap-1 border-primary/30 bg-primary/5 text-xs text-primary sm:flex",children:[a(cr,{className:"h-3 w-3"}),a("span",{children:B0({time:vg(s.periodEnd,c)})})]}):g(ve,{variant:"secondary",className:"hidden gap-1 text-xs text-muted-foreground sm:flex",children:[a(wr,{className:"h-3 w-3 text-primary"}),a("span",{children:L0()})]}),g(F,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>r(!0),disabled:h.isPending,children:[h.isPending?a(K,{className:"h-3.5 w-3.5 animate-spin"}):a(Li,{className:"h-3.5 w-3.5"}),U0()]})]})]}),g("div",{className:"space-y-1.5 pt-1",children:[a(rm,{value:Math.min(100,Math.max(0,s.percent)),className:"h-2"}),g("div",{className:"flex items-center justify-between gap-2 text-xs font-medium",children:[g("span",{className:p?"font-bold text-destructive":"text-foreground",children:[ya(t.resource,s.consumed)," /"," ",ya(t.resource,t.limit)," ",f?.unit]}),g("span",{className:p?"font-bold text-destructive":"text-muted-foreground",children:[s.percent,"%"]})]})]}),g("div",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground sm:hidden",children:[s.isWindowActive&&s.periodEnd?g("span",{className:"flex items-center gap-1 text-primary",children:[a(cr,{className:"h-3 w-3"}),B0({time:vg(s.periodEnd,c)})]}):g("span",{className:"flex items-center gap-1",children:[a(wr,{className:"h-3 w-3 text-primary"}),L0()]}),g("span",{children:[W1(),": ",ya(t.resource,s.remaining)," ",f?.unit]})]})]}),a(_t,{open:n,onOpenChange:r,children:g(yt,{children:[g(vt,{children:[a(wt,{children:U0()}),a(Et,{children:Y1({target:b})})]}),g(bt,{children:[a(Ct,{disabled:h.isPending,children:Ke()}),g(xt,{onClick:(l)=>{l.preventDefault(),h.mutate()},disabled:h.isPending,children:[h.isPending&&a(K,{className:"mr-2 h-4 w-4 animate-spin"}),Ya()]})]})]})})]})}function kt({teamId:e,rule:t}){let[s,i]=w(!1),[n,r]=w(""),c=Vl[t.resource],u=c?.icon||gs,{data:f,isLoading:v,isError:p}=X({queryKey:["teams",e,"quotas",t.id,"records"],queryFn:async()=>{let l=await R.api.teams[":teamId"].quotas[":id"].records.$get({param:{teamId:e,id:t.id}});if(!l.ok)throw Error(S_());return await l.json()},enabled:s,refetchInterval:s?1e4:!1}),b=f?.records??[],h=b.filter((l)=>{if(!n.trim())return!0;let C=n.toLowerCase();return l.user?.name.toLowerCase().includes(C)||l.user?.email.toLowerCase().includes(C)});return g(ye,{open:s,onOpenChange:i,className:"rounded-xl border border-border/70",children:[a(Te,{asChild:!0,children:g("button",{type:"button","aria-label":s?z1():H1(),className:"flex w-full items-center justify-between gap-4 p-4 text-left transition-colors hover:bg-muted/40",children:[g("div",{className:"flex min-w-0 items-start gap-3",children:[a("div",{className:"mt-0.5 rounded-lg bg-primary/10 p-2 text-primary",children:a(u,{className:"h-5 w-5"})}),g("div",{className:"min-w-0",children:[g("div",{className:"flex flex-wrap items-center gap-2",children:[a("span",{className:"font-semibold text-foreground",children:c?.label()||t.resource}),!t.enabled&&a(ve,{variant:"secondary",children:Bh()})]}),g("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[a(ut,{rule:t}),g(ve,{variant:"outline",className:"gap-1 text-xs",children:[a(cr,{className:"h-3 w-3"}),ya(t.resource,t.limit)," ",c?.unit," /"," ",au(t.period)]}),a(dt,{rule:t})]})]})]}),a(Be,{className:`h-5 w-5 shrink-0 text-muted-foreground transition-transform ${s?"rotate-180":""}`})]})}),a(_e,{children:g("div",{className:"space-y-3 border-t border-border/60 bg-muted/10 p-4",children:[t.scopeMode!=="all_members"&&b.length>3&&g("div",{className:"relative",children:[a(rr,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),a(re,{value:n,onChange:(l)=>r(l.target.value),placeholder:Hh(),className:"h-9 pl-9 text-sm"})]}),v?a("div",{className:"flex justify-center py-10",children:a(K,{className:"h-7 w-7 animate-spin text-primary"})}):p?a("div",{className:"py-8 text-center text-sm text-destructive",children:S_()}):h.length===0?a("div",{className:"py-8 text-center text-sm text-muted-foreground",children:V1()}):h.map((l,C)=>a(gt,{teamId:e,rule:t,record:l},l.id||l.userId||`record-${C}`))]})})]})}function Ae({teamId:e}){let{data:t,isLoading:s,isError:i}=X({queryKey:["teams",e,"quotas"],queryFn:async()=>{let r=await R.api.teams[":teamId"].quotas.$get({param:{teamId:e}});if(!r.ok)throw Error(Ms());return await r.json()},enabled:!!e}),n=t?.rules??[];return g(lt,{className:"border-border/60 shadow-sm",children:[g(Nt,{children:[g(Ft,{className:"flex items-center gap-2 text-xl font-semibold tracking-tight",children:[a(gs,{className:"h-5 w-5 text-primary"}),Fp()]}),a(Ht,{children:q1()})]}),a(St,{children:s?a("div",{className:"flex h-48 items-center justify-center",children:a(K,{className:"h-7 w-7 animate-spin text-muted-foreground"})}):i?a("div",{className:"py-10 text-center text-sm text-destructive",children:Ms()}):n.length===0?g("div",{className:"flex flex-col items-center justify-center rounded-xl border-2 border-dashed border-border py-12 text-center",children:[a(gs,{className:"mb-3 h-10 w-10 text-muted-foreground/50"}),a("p",{className:"text-base font-medium text-foreground",children:Rh()}),a("p",{className:"mt-1 max-w-md text-sm text-muted-foreground",children:kh()})]}):a("div",{className:"space-y-3",children:n.map((r)=>a(kt,{teamId:e,rule:r},r.id))})})]})}Z();var At=Object.values(tu);function Re({teamId:e}){let[t,s]=w([]),[i,n]=w([]),[r,c]=w(""),{ref:u,inView:f}=Vt(),{data:v}=X({queryKey:["teams",e,"members"],queryFn:async()=>{let d=await R.api.teams[":teamId"].members.$get({param:{teamId:e},query:{}});if(!d.ok)return[];return await d.json()},enabled:!!e}),p=v||[],{data:b,isLoading:h,isError:l,fetchNextPage:C,hasNextPage:m,isFetchingNextPage:x}=Tt({queryKey:["teams",e,"audit-logs",t,i,r],queryFn:async({pageParam:d})=>{let N=await R.api.teams[":teamId"]["audit-logs"].$get({param:{teamId:e},query:{first:"20",after:d?String(d):void 0,actions:t.length>0?t:void 0,userIds:i.length>0?i:void 0,itemId:r.trim()||void 0}});if(!N.ok)throw Error("Failed to fetch audit logs");return await N.json()},initialPageParam:"",getNextPageParam:(d)=>d.pageInfo.endCursor||void 0,enabled:!!e});S(()=>{if(f&&m&&!x)C()},[f,m,x,C]);let T=b?.pages.flatMap((d)=>d.nodes)||[],k=b?.pages[0]?.total??0,_=(d)=>{s((N)=>N.includes(d)?N.filter((D)=>D!==d):[...N,d])},q=(d)=>{n((N)=>N.includes(d)?N.filter((D)=>D!==d):[...N,d])},I=(d)=>{if(d.includes("delete")||d.includes("remove")||d.includes("revoke"))return a(ve,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 font-mono text-xs",children:d});if(d.includes("create")||d.includes("add"))return a(ve,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 font-mono text-xs",children:d});if(d.includes("update")||d.includes("reparent")||d.includes("copy"))return a(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 font-mono text-xs",children:d});return a(ve,{variant:"outline",className:"bg-muted text-muted-foreground border-border font-mono text-xs",children:d})},U=new Map(p.map((d)=>[d.userId||d.id,d]));return a("div",{className:"space-y-6",children:g(lt,{className:"border border-border/50 shadow-xs",children:[g(Nt,{className:"pb-4",children:[g("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[g("div",{children:[g(Ft,{className:"text-xl font-bold flex items-center gap-2",children:[a(Li,{className:"h-5 w-5 text-primary"}),Qm()]}),a(Ht,{className:"mt-1",children:Kb()})]}),k>0&&g(ve,{variant:"secondary",className:"w-fit text-xs font-normal",children:[k," ",Qm()]})]}),g("div",{className:"mt-4 flex flex-wrap items-center gap-3 pt-4 border-t border-border/40",children:[g(pt,{children:[a(mt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),mC(),t.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:t.length})]})}),g(ht,{className:"w-64 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:Jk()}),a("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:At.map((d)=>g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:t.includes(d),onCheckedChange:()=>_(d)}),a("span",{className:"font-mono",children:d})]},d))}),t.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>s([]),children:"Clear Actions"})]})]}),g(pt,{children:[a(mt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),AC(),i.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:i.length})]})}),g(ht,{className:"w-64 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:fR()}),a("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:p.map((d)=>{let N=d.userId||d.user?.id||d.id,D=d.user?.name||d.name||N,E=d.user?.image||d.image;return g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:i.includes(N),onCheckedChange:()=>q(N)}),g($e,{className:"h-5 w-5",children:[a(He,{src:E||void 0}),a(Qe,{className:"text-[10px]",children:D.slice(0,2).toUpperCase()})]}),a("span",{className:"truncate",children:D})]},N)})}),i.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>n([]),children:"Clear Users"})]})]}),g("div",{className:"relative flex-1 min-w-[200px] max-w-xs",children:[a(rr,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),a(re,{type:"text",placeholder:Vk(),value:r,onChange:(d)=>c(d.target.value),className:"pl-8 pr-8 h-9 text-xs"}),r&&a("button",{onClick:()=>c(""),className:"absolute right-2.5 top-2.5 text-muted-foreground hover:text-foreground",children:a(Ge,{className:"h-4 w-4"})})]}),(t.length>0||i.length>0||r)&&a(F,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{s([]),n([]),c("")},children:"Clear all"})]})]}),g(St,{className:"p-0",children:[h?a("div",{className:"flex h-64 items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):l?a("div",{className:"p-8 text-center text-sm text-destructive",children:"Failed to load audit logs."}):T.length===0?a("div",{className:"p-12 text-center text-sm text-muted-foreground",children:eT()}):g(Bn,{children:[a(Un,{children:g(Tr,{className:"hover:bg-transparent border-b border-border/50",children:[a(ft,{className:"w-[180px] pl-6 text-xs font-semibold",children:Hy()}),a(ft,{className:"w-[200px] px-4 text-xs font-semibold",children:PO()}),a(ft,{className:"px-4 text-xs font-semibold",children:yS()}),a(ft,{className:"px-4 text-xs font-semibold",children:S0()}),a(ft,{className:"w-[160px] pr-6 text-right text-xs font-semibold",children:JM()})]})}),a(zn,{children:T.map((d)=>{let N=d.userId?U.get(d.userId):null,D=N?.user?.name||N?.name||d.userId||"System",E=N?.user?.image||N?.image;return g(Tr,{className:"hover:bg-muted/40 transition-colors",children:[a(ct,{className:"py-3 pl-6 font-medium",children:I(d.action)}),a(ct,{className:"py-3 px-4",children:g("div",{className:"flex items-center gap-2",children:[g($e,{className:"h-6 w-6",children:[a(He,{src:E||void 0}),a(Qe,{className:"text-[10px]",children:D.slice(0,2).toUpperCase()})]}),a("span",{className:"text-xs font-medium text-foreground truncate max-w-[160px]",children:d.agent?Rd({user:D,agent:d.agent.name}):D}),d.agent&&a($t,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]})}),a(ct,{className:"py-3 px-4 text-xs font-mono text-muted-foreground",children:d.itemId||"-"}),a(ct,{className:"py-3 px-4 text-xs font-mono text-muted-foreground",children:d.projectId||"-"}),a(ct,{className:"py-3 pr-6 text-right text-xs text-muted-foreground",children:nn(d.createdAt)})]},d.id)})})]}),a("div",{ref:u,className:"py-4 flex justify-center",children:x&&a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]})})}Z();Z();function De({task:e,open:t,onOpenChange:s}){let[i,n]=w(null);if(!e)return null;let r=(u,f)=>{navigator.clipboard.writeText(u),n(f),setTimeout(()=>{n(null)},2000)},c=(u)=>{switch(u){case"completed":return a(ve,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 text-xs font-mono",children:"completed"});case"processing":return a(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 text-xs font-mono",children:"processing"});case"pending":return a(ve,{variant:"outline",className:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 border-yellow-500/20 text-xs font-mono",children:"pending"});case"failed":return a(ve,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 text-xs font-mono",children:"failed"});default:return a(ve,{variant:"outline",className:"text-xs font-mono",children:u||"unknown"})}};return a(Se,{open:t,onOpenChange:s,children:g(xe,{className:"max-w-2xl max-h-[90vh] flex flex-col p-6",children:[g(ke,{className:"pb-2 border-b border-border/50",children:[g("div",{className:"flex items-center justify-between gap-2 pr-6",children:[g("div",{className:"flex items-center gap-2",children:[a(On,{className:"h-5 w-5 text-primary"}),a(Ce,{className:"text-lg font-bold",children:TM()})]}),g("div",{className:"flex items-center gap-2",children:[c(e.status),e.type&&a(ve,{variant:"secondary",className:"font-mono text-xs",children:e.type})]})]}),g(Ot,{className:"text-xs text-muted-foreground mt-1 flex items-center gap-2",children:[g("span",{children:[gy(),": ",a("span",{className:"font-mono text-foreground",children:e.id})]}),a(F,{variant:"ghost",size:"icon",className:"h-5 w-5 text-muted-foreground hover:text-foreground",onClick:()=>r(e.id,"task_id"),children:i==="task_id"?a(qe,{className:"h-3 w-3 text-emerald-500"}):a(Zr,{className:"h-3 w-3"})})]})]}),g("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 py-3 text-xs border-b border-border/40",children:[g("div",{children:[a("div",{className:"text-muted-foreground",children:dh()}),a("div",{className:"truncate font-medium text-foreground mt-0.5",title:e.fileName||"-",children:e.fileName||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:ly()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.fileSize!==null&&e.fileSize!==void 0?on(e.fileSize):"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:Ip()}),a("div",{className:"truncate font-medium text-foreground mt-0.5",title:e.projectName||"-",children:e.projectName||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:zb()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.assetId||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:S0()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.projectId||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:cp()}),g("div",{className:"font-medium text-foreground mt-0.5 flex items-center gap-1",children:[a(cr,{className:"h-3 w-3 text-muted-foreground"}),nn(e.createdAt)]})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:SO()}),a("div",{className:"font-medium text-foreground mt-0.5",children:nn(e.updatedAt)})]}),e.heartbeat&&g("div",{children:[a("div",{className:"text-muted-foreground",children:rS()}),a("div",{className:"font-medium text-foreground mt-0.5",children:nn(e.heartbeat)})]}),e.model&&g("div",{children:[a("div",{className:"text-muted-foreground",children:Eh()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.model})]}),(e.inputTokens>0||e.outputTokens>0)&&g("div",{children:[g("div",{className:"text-muted-foreground flex items-center gap-1",children:[a(eo,{className:"h-3 w-3"})," ",nO()]}),g("div",{className:"font-medium text-foreground mt-0.5 font-mono",children:[e.inputTokens.toLocaleString()," in / ",e.outputTokens.toLocaleString()," out"]})]}),e.sessionId&&g("div",{className:"col-span-2",children:[a("div",{className:"text-muted-foreground",children:ER()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.sessionId})]})]}),a("div",{className:"flex-1 min-h-0 pt-3",children:g(co,{defaultValue:"payload",className:"w-full h-full flex flex-col",children:[g(uo,{className:"grid w-full grid-cols-2",children:[a(Wr,{value:"payload",children:s1()}),a(Wr,{value:"output",children:VT()})]}),a(gn,{value:"payload",className:"flex-1 mt-2 min-h-0",children:a(Ie,{className:"h-64 w-full rounded-md border border-border/50 bg-muted/30 p-3 font-mono text-xs",children:a("pre",{className:"whitespace-pre-wrap break-all text-foreground/90",children:e.payload?JSON.stringify(e.payload,null,2):"null"})})}),a(gn,{value:"output",className:"flex-1 mt-2 min-h-0",children:a(Ie,{className:"h-64 w-full rounded-md border border-border/50 bg-muted/30 p-3 font-mono text-xs",children:a("pre",{className:"whitespace-pre-wrap break-all text-foreground/90",children:e.output?JSON.stringify(e.output,null,2):"null"})})})]})})]})})}var Rt=Object.values($l),Dt=Object.values(Hl);function Pe({teamId:e}){let t=ie(),[s,i]=w([]),[n,r]=w([]),[c,u]=w(null),[f,v]=w(null),{ref:p,inView:b}=Vt(),h=G(()=>["teams",e,"workflow-tasks",s,n],[e,s,n]),{data:l,isLoading:C,isError:m,fetchNextPage:x,hasNextPage:T,isFetchingNextPage:k,refetch:_,isRefetching:q}=Tt({queryKey:h,queryFn:async({pageParam:o})=>{let y=await R.api.teams[":teamId"]["workflow-tasks"].$get({param:{teamId:e},query:{first:"20",after:o?String(o):void 0,status:s.length>0?s:void 0,types:n.length>0?n:void 0}});if(!y.ok)throw Error("Failed to fetch workflow tasks");return await y.json()},initialPageParam:"",getNextPageParam:(o)=>o.pageInfo.endCursor||void 0,enabled:!!e});S(()=>{if(b&&T&&!k)x()},[b,T,k,x]);let I=G(()=>l?.pages.flatMap((o)=>o.nodes)||[],[l]),U=l?.pages[0]?.total??0,d=G(()=>I.filter((o)=>o.status==="pending"||o.status==="processing").map((o)=>o.id),[I]);X({queryKey:["teams",e,"workflow-tasks","batch-status",d],queryFn:async()=>{if(d.length===0)return null;let o=await R.api.teams[":teamId"]["workflow-tasks"]["batch-status"].$post({param:{teamId:e},json:{taskIds:d}});if(!o.ok)return null;let y=await o.json();if(y.tasks&&y.tasks.length>0)t.setQueryData(h,(A)=>{if(!A)return A;let V=new Map(y.tasks.map((L)=>[L.id,L]));return{...A,pages:A.pages.map((L)=>({...L,nodes:L.nodes.map((le)=>V.get(le.id)||le)}))}});return y},enabled:d.length>0,refetchInterval:6000});let N=ee({mutationFn:async(o)=>{let y=await R.api.teams[":teamId"]["workflow-tasks"][":taskId"].stop.$post({param:{teamId:e,taskId:o}});if(!y.ok){let A=await y.json().catch(()=>({message:"Failed to stop task"}));throw Error(A.message||"Failed to stop task")}return await y.json()},onSuccess:(o)=>{j.success(kM()),t.setQueryData(h,(y)=>{if(!y)return y;return{...y,pages:y.pages.map((A)=>({...A,nodes:A.nodes.map((V)=>V.id===o.task.id?o.task:V)}))}}),u(null)},onError:(o)=>{j.error(o.message||"Failed to stop task")}}),D=(o)=>{i((y)=>y.includes(o)?y.filter((A)=>A!==o):[...y,o])},E=(o)=>{r((y)=>y.includes(o)?y.filter((A)=>A!==o):[...y,o])},Ee=(o)=>{switch(o){case"completed":return a(ve,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 font-mono text-xs",children:"completed"});case"processing":return g(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 font-mono text-xs gap-1.5",children:[a(K,{className:"h-3 w-3 animate-spin"}),"processing"]});case"pending":return a(ve,{variant:"outline",className:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 border-yellow-500/20 font-mono text-xs",children:"pending"});case"failed":return a(ve,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 font-mono text-xs",children:"failed"});default:return a(ve,{variant:"outline",className:"font-mono text-xs",children:o||"-"})}},Oe=(o)=>{if(!o)return a(ve,{variant:"outline",children:"-"});if(o.startsWith("transcode"))return a(ve,{variant:"outline",className:"bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20 font-mono text-xs",children:o});if(o.startsWith("ai_")||o==="chat")return a(ve,{variant:"outline",className:"bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 border-indigo-500/20 font-mono text-xs",children:o});return a(ve,{variant:"secondary",className:"font-mono text-xs",children:o})};return g("div",{className:"space-y-6",children:[g(lt,{className:"border border-border/50 shadow-xs",children:[g(Nt,{className:"pb-4",children:[g("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[g("div",{children:[g(Ft,{className:"text-xl font-bold flex items-center gap-2",children:[a(ae,{className:"h-5 w-5 text-primary"}),Ag()]}),a(Ht,{className:"mt-1",children:eP()})]}),g("div",{className:"flex items-center gap-3",children:[U>0&&g(ve,{variant:"secondary",className:"w-fit text-xs font-normal",children:[U," ",Ag()]}),g(F,{variant:"outline",size:"sm",className:"h-9 gap-1.5 text-xs",onClick:()=>_(),disabled:q,children:[a(be,{className:`h-3.5 w-3.5 ${q?"animate-spin":""}`}),yk()]})]})]}),g("div",{className:"mt-4 flex flex-wrap items-center gap-3 pt-4 border-t border-border/40",children:[g(pt,{children:[a(mt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),hC(),s.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:s.length})]})}),g(ht,{className:"w-56 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:uR()}),a("div",{className:"space-y-1",children:Dt.map((o)=>g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:s.includes(o),onCheckedChange:()=>D(o)}),a("span",{className:"font-mono",children:o})]},o))}),s.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>i([]),children:Tw()})]})]}),g(pt,{children:[a(mt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),gC(),n.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:n.length})]})}),g(ht,{className:"w-64 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:eg()}),a("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:Rt.map((o)=>g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:n.includes(o),onCheckedChange:()=>E(o)}),a("span",{className:"font-mono truncate",children:o})]},o))}),n.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>r([]),children:kw()})]})]}),(s.length>0||n.length>0)&&a(F,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{i([]),r([])},children:xw()})]})]}),g(St,{className:"p-0",children:[C?a("div",{className:"flex h-64 items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):m?a("div",{className:"p-8 text-center text-sm text-destructive",children:zx()}):I.length===0?a("div",{className:"p-12 text-center text-sm text-muted-foreground",children:wT()}):g(Bn,{children:[a(Un,{children:g(Tr,{className:"hover:bg-transparent border-b border-border/50",children:[a(ft,{className:"w-[170px] pl-6 text-xs font-semibold",children:by()}),a(ft,{className:"w-[130px] px-4 text-xs font-semibold",children:_y()}),a(ft,{className:"min-w-[180px] px-4 text-xs font-semibold",children:dh()}),a(ft,{className:"w-[110px] px-4 text-xs font-semibold",children:ly()}),a(ft,{className:"w-[160px] px-4 text-xs font-semibold",children:Ip()}),a(ft,{className:"w-[130px] px-4 text-right text-xs font-semibold",children:cp()}),a(ft,{className:"w-[120px] pr-6 text-right text-xs font-semibold",children:Bm()})]})}),a(zn,{children:I.map((o)=>{let y=o.status==="pending"||o.status==="processing";return g(Tr,{className:"hover:bg-muted/40 transition-colors",children:[a(ct,{className:"py-3 pl-6 font-medium",children:Oe(o.type)}),a(ct,{className:"py-3 px-4 font-medium",children:Ee(o.status)}),a(ct,{className:"py-3 px-4 text-xs font-medium",children:a("span",{className:"truncate block max-w-[220px]",title:o.fileName||o.assetId||"-",children:o.fileName||o.assetId||"-"})}),a(ct,{className:"py-3 px-4 text-xs font-mono text-muted-foreground",children:o.fileSize!==null&&o.fileSize!==void 0?on(o.fileSize):"-"}),a(ct,{className:"py-3 px-4 text-xs text-muted-foreground",children:a("span",{className:"truncate block max-w-[160px]",title:o.projectName||o.projectId||"-",children:o.projectName||o.projectId||"-"})}),a(ct,{className:"py-3 px-4 text-right text-xs text-muted-foreground whitespace-nowrap",children:nn(o.createdAt)}),a(ct,{className:"py-3 pr-6 text-right",children:g("div",{className:"flex items-center justify-end gap-1",children:[a(F,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",onClick:()=>v(o),title:BO(),children:a(ge,{className:"h-4 w-4"})}),y&&g(F,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs border-destructive/30 text-destructive hover:bg-destructive/10",onClick:()=>u(o),disabled:N.isPending,children:[a(yu,{className:"h-3 w-3 mr-1 fill-current"}),py()]})]})})]},o.id)})})]}),a("div",{ref:p,className:"py-4 flex justify-center",children:k&&a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]}),a(_t,{open:!!c,onOpenChange:(o)=>{if(!o)u(null)},children:g(yt,{children:[g(vt,{children:[g("div",{className:"flex items-center gap-2",children:[a(tn,{className:"h-5 w-5 text-destructive"}),a(wt,{children:sM()})]}),a(Et,{className:"pt-2 text-sm text-muted-foreground",children:oM()}),c&&g("div",{className:"mt-3 p-2.5 rounded-md bg-muted/50 border border-border/40 font-mono text-xs space-y-1",children:[g("div",{children:[gy(),": ",c.id]}),c.fileName&&g("div",{className:"font-sans",children:[dh(),":"," ",a("span",{className:"font-medium text-foreground",children:c.fileName})]}),g("div",{children:[by(),": ",c.type||"unknown"]}),g("div",{children:[_y(),": ",c.status]})]})]}),g(bt,{children:[a(Ct,{disabled:N.isPending,children:Ke()}),a(xt,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",disabled:N.isPending,onClick:()=>{if(c)N.mutate(c.id)},children:N.isPending?g(Y,{children:[a(K,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}),iM()]}):py()})]})]})}),a(De,{task:f,open:!!f,onOpenChange:(o)=>{if(!o)v(null)}})]})}function qt(){let{teamId:e}=It.useParams(),[t,s]=w("audit-logs"),{data:i,isLoading:n}=X({queryKey:["teams",e,"me"],queryFn:async()=>{let r=await R.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!r.ok)throw Error("Failed to fetch me");return await r.json()},enabled:!!e});if(n)return a("div",{className:"flex h-screen items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(i?.role?.toLowerCase()!=="owner")return g("div",{className:"flex h-full flex-col items-center justify-center p-8 text-center",children:[a(iu,{className:"h-12 w-12 text-destructive mb-4"}),a("h2",{className:"text-xl font-bold tracking-tight mb-2",children:$y()}),a("p",{className:"text-sm text-muted-foreground max-w-md",children:IT()})]});return a("div",{className:"h-full bg-background font-sans selection:bg-primary/20 transition-colors duration-300",children:g("div",{className:"flex flex-col md:flex-row h-full",children:[a("div",{className:"w-full h-full md:w-72 bg-sidebar border-b md:border-b-0 md:border-r border-sidebar-border z-10 md:left-16 overflow-y-auto transition-colors duration-300",children:g("nav",{className:"p-4 space-y-1 mt-4",children:[a("div",{className:"mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider",children:c_()}),a("div",{className:"mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:OM()}),g("button",{onClick:()=>s("audit-logs"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="audit-logs"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(Li,{className:"w-5 h-5"}),Qm(),t==="audit-logs"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("workflow-tasks"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="workflow-tasks"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(ae,{className:"w-5 h-5"}),Ag(),t==="workflow-tasks"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("quotas"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="quotas"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(gs,{className:"w-5 h-5"}),Fp(),t==="quotas"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),a("div",{className:"mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:Ab()}),g("button",{onClick:()=>s("ai-usage"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="ai-usage"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(fe,{className:"w-5 h-5"}),OO(),t==="ai-usage"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("ai-sessions"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="ai-sessions"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(W,{className:"w-5 h-5"}),ay(),t==="ai-sessions"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]})}),a("div",{className:"flex-1 overflow-y-auto p-4 md:p-8",children:g("div",{className:"max-w-6xl mx-auto space-y-8",children:[t==="audit-logs"&&a(Re,{teamId:e}),t==="workflow-tasks"&&a(Pe,{teamId:e}),t==="ai-usage"&&a(he,{teamId:e}),t==="ai-sessions"&&a(Ne,{teamId:e}),t==="quotas"&&a(Ae,{teamId:e})]})})]})})}var It=Je("/teams/$teamId/dashboard")({component:qt});export{It as Route};
|
|
1
|
+
import{Y,G,S,Q,M,w,Mo,L,W,a,g,ie,Zf,Bf,qr,dd,Va,Yo,ar,ks,Uf,zf,jf,qf,fd,$f,X,ee,Tt,Je,R,z,wr,K,rn,$t,qe,Be,ur,Pn,nr,Rs,Ge,B,Ut,Le,pe,Gt,Kr,tr,we,Cr,F,$e,He,Qe,Wy,Jy,zm,Eb,Sb,Ib,Gb,Vm,tw,t_,Ve,Rw,Dw,Nw,Xa,a_,hE,up,vd,d_,Mi,Ms,T_,Gx,k_,ph,yC,vC,bC,wC,aS,$_,xS,SI,II,Ch,sT,Mh,Oh,yT,IT,OT,XT,y0,Cd,u1,k0,Tp,U0,Q1,V1,zh,W1,X1,j0,tk,rk,q0,nk,sk,Dp,Np,Fp,Wc,Gh,pk,mk,hk,gk,Lp,xk,Pi,Zk,Xk,rR,hR,rg,AR,TR,kR,MR,OR,PR,DR,uy,NR,dy,Ay,cM,uM,dM,PM,vy,wy,DM,Cy,jp,LM,zM,rO,lO,Ry,Yn,hg,MO,LO,ZO,Rd,$O,yg,sP,dt,ft,pt,mt,ht,gt,At,_t,Se,xe,ke,Ce,Ot,re,Ie,Vt,j,Hl,Ql,nu,on,wg,co,uo,Jr,gn,ve,bt,wt,Et,Sr,Fr,om,ct,Nt,Ft,Ht,St}from"./chunk-5ngftxjb.js";import{os,Zr}from"./chunk-qvp24w0q.js";import{vu}from"./chunk-pq6kdp83.js";import{Li,eo,gs,lu,Kl,va,cu}from"./chunk-enax4303.js";import"./chunk-sz5zawfw.js";import{Un,zn,jn,Tr,vt,ut}from"./chunk-c02727j9.js";import"./chunk-c1wvs81k.js";import{Uo}from"./chunk-etrm28sy.js";import{bu}from"./chunk-s1j4v33x.js";import{qn}from"./chunk-pdw77q09.js";import{Br}from"./chunk-7kah3zb5.js";L();function de(e,t){let s=new Set(t);return e.filter((i)=>!s.has(i))}var me=class extends Yo{#r;#e;#o;#a;#t;#s;#i;#n;#l;#d=[];constructor(e,t,s){super();this.#r=e,this.#a=s,this.#o=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){if(this.listeners.size===1)this.#t.forEach((e)=>{e.subscribe((t)=>{this.#p(e,t)})})}onUnsubscribe(){if(!this.listeners.size)this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach((e)=>{e.destroy()})}setQueries(e,t){this.#o=e,this.#a=t,ar.batch(()=>{let s=this.#t,i=this.#u(this.#o);i.forEach((p)=>p.observer.setOptions(p.defaultedQueryOptions));let n=i.map((p)=>p.observer),r=n.map((p)=>p.getCurrentResult()),c=s.length!==n.length,u=n.some((p,b)=>p!==s[b]),f=c||u,v=f?!0:r.some((p,b)=>{let h=this.#e[b];return!h||!Va(p,h)});if(!f&&!v)return;if(f)this.#d=i,this.#t=n;if(this.#e=r,!this.hasListeners())return;if(f)de(s,n).forEach((p)=>{p.destroy()}),de(n,s).forEach((p)=>{p.subscribe((b)=>{this.#p(p,b)})});this.#f()})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map((e)=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){let s=this.#u(e),i=s.map((r)=>r.observer.getOptimisticResult(r.defaultedQueryOptions)),n=s.map((r)=>r.defaultedQueryOptions.queryHash);return[i,(r)=>this.#c(r??i,t,n),()=>this.#m(i,s)]}#m(e,t){let s=new Set;return t.map((i,n)=>{let r=e[n];return!i.defaultedQueryOptions.notifyOnChangeProps?i.observer.trackResult(r,(c)=>{if(!s.has(c))s.add(c),t.forEach((u)=>{u.observer.trackProp(c)})}):r})}#c(e,t,s){if(t){let i=this.#l,n=s!==void 0&&i!==void 0&&(i.length!==s.length||s.some((r,c)=>r!==i[c]));if(this.#e!==this.#n||n||t!==this.#i){if(this.#i=t,this.#n=this.#e,s!==void 0)this.#l=s;this.#s=dd(this.#s,t(e))}return this.#s}return e}#g(){return!this.#a?.combine||this.#t.some((e,t)=>e.options.suspense&&this.#e[t]?.data===void 0)}#u(e){let t=new Map;this.#t.forEach((i)=>{let n=i.options.queryHash;if(!n)return;let r=t.get(n);if(r)r.push(i);else t.set(n,[i])});let s=[];return e.forEach((i)=>{let n=this.#r.defaultQueryOptions(i),r=t.get(n.queryHash)?.shift()??new ks(this.#r,n);s.push({defaultedQueryOptions:n,observer:r})}),s}#p(e,t){let s=this.#t.indexOf(e);if(s!==-1)this.#e=this.#e.slice(),this.#e[s]=t,this.#f()}#f(){if(this.hasListeners()){let e=this.#g(),t=this.#s,s=e?t:this.#c(this.#m(this.#e,this.#d),this.#a?.combine);if(e||t!==s)ar.batch(()=>{this.listeners.forEach((i)=>{i(this.#e)})})}}};L();function ce({queries:e,...t},s){let i=ie(s),n=Zf(),r=Bf(),c=t.subscribed!==!1,u=Q(()=>e.map((m)=>{let x=i.defaultQueryOptions(m);return x._optimisticResults=n?"isRestoring":c?"optimistic":void 0,x}),[e,i,n,c]);u.forEach((m)=>{qf(m);let x=i.getQueryCache().get(m.queryHash);Uf(m,r,x)}),zf(r);let[f]=w(()=>new me(i,u,t)),[v,p,b]=f.getOptimisticResult(u,t.combine),h=!n&&c;Mo(G((m)=>h?f.subscribe(ar.batchCalls(m)):qr,[f,h]),()=>f.getCurrentResult(),()=>f.getCurrentResult()),S(()=>{f.setQueries(u,t)},[u,t,f]);let l=v.some((m,x)=>fd(u[x],m))?v.flatMap((m,x)=>{let T=u[x];if(T&&fd(T,m)){let k=new ks(i,T);return $f(T,k,r)}return[]}):[];if(l.length>0)throw Promise.all(l);let C=v.find((m,x)=>{let T=u[x];return T&&jf({result:m,errorResetBoundary:r,throwOnError:T.throwOnError,query:i.getQueryCache().get(T.queryHash),suspense:T.suspense})});if(C)throw C.error;return p(b())}L();L();var je=Object.defineProperty,U=(e,t)=>je(e,"name",{value:t,configurable:!0}),se="Collapsible",[Fe,da]=Ut(se),[We,oe]=Fe(se),ze=Y(U(function(t,s){let{__scopeCollapsible:i,open:n,defaultOpen:r,disabled:c,onOpenChange:u,...f}=t,[v,p]=tr({prop:n,defaultProp:r??!1,onChange:u,caller:se});return a(We,{scope:i,disabled:c,contentId:Kr(),open:v,onOpenToggle:G(()=>p((b)=>!b),[p]),children:a(we.div,{"data-state":te(v),"data-disabled":c?"":void 0,...f,ref:s})})},"Collapsible")),Ue="CollapsibleTrigger",Ke=Y(U(function(t,s){let{__scopeCollapsible:i,...n}=t,r=oe(Ue,i);return a(we.button,{type:"button","aria-controls":r.open?r.contentId:void 0,"aria-expanded":r.open||!1,"data-state":te(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...n,ref:s,onClick:pe(t.onClick,r.onOpenToggle)})},"CollapsibleTrigger")),ue="CollapsibleContent",Xe=Y(U(function(t,s){let{forceMount:i,...n}=t,r=oe(ue,t.__scopeCollapsible);return a(Cr,{present:i||r.open,children:({present:c})=>a(Ye,{...n,ref:s,present:c})})},"CollapsibleContent")),Ye=Y(U(function(t,s){let{__scopeCollapsible:i,present:n,children:r,...c}=t,u=oe(ue,i),[f,v]=w(n),p=M(null),b=Le(s,p),h=M(0),l=h.current,C=M(0),m=C.current,x=u.open||f,T=M(x),k=M(void 0);return S(()=>{let _=requestAnimationFrame(()=>T.current=!1);return()=>cancelAnimationFrame(_)},[]),Gt(()=>{let _=p.current;if(_){k.current=k.current||{transitionDuration:_.style.transitionDuration,animationName:_.style.animationName},_.style.transitionDuration="0s",_.style.animationName="none";let q=_.getBoundingClientRect();if(h.current=q.height,C.current=q.width,!T.current)_.style.transitionDuration=k.current.transitionDuration,_.style.animationName=k.current.animationName;v(n)}},[u.open,n]),a(we.div,{"data-state":te(u.open),"data-disabled":u.disabled?"":void 0,id:u.contentId,hidden:!x,...c,ref:b,style:{["--radix-collapsible-content-height"]:l?`${l}px`:void 0,["--radix-collapsible-content-width"]:m?`${m}px`:void 0,...t.style},children:x&&r})},"CollapsibleContentImpl"));function te(e){return e?"open":"closed"}U(te,"getState");var Ze=ze;var tt=[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V3",key:"1lcnhd"}],["path",{d:"M19 21V9",key:"unv183"}]],fe=z("chart-no-axes-column",tt);var at=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],P=z("funnel",at);var st=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],ge=z("eye",st);var rt=[["path",{d:"M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z",key:"1n2ejm"}],["path",{d:"M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1",key:"1qfcsi"}]],V=z("messages-square",rt);var ot=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],be=z("rotate-cw",ot);var it=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],ae=z("workflow",it);function he({teamId:e}){let[t,s]=w("team"),[i,n]=w("1h"),{data:r,isLoading:c}=X({queryKey:["teams",e,"ai-usage",i,"team"],queryFn:async()=>{let m=await R.api.teams[":teamId"]["ai-usage"].$get({param:{teamId:e},query:{timeframe:i}});if(!m.ok)throw Error("Failed to fetch team AI usage");return await m.json()},enabled:!!e&&t==="team"}),{data:u,isLoading:f}=X({queryKey:["teams",e,"members"],queryFn:async()=>{let m=await R.api.teams[":teamId"].members.$get({param:{teamId:e},query:{}});if(!m.ok)throw Error("Failed to fetch team members");return await m.json()},enabled:!!e&&t==="members"}),v=ce({queries:(u||[]).map((m)=>({queryKey:["teams",e,"ai-usage",i,m.id],queryFn:async()=>{let x=await R.api.teams[":teamId"]["ai-usage"].$get({param:{teamId:e},query:{timeframe:i,userId:m.id}});if(!x.ok)throw Error(`Failed to fetch AI usage for member ${m.id}`);return await x.json()},enabled:!!e&&t==="members"}))}),p=f||v.some((m)=>m.isLoading),b=(m)=>{if(!m)return"U";let x=m.split(" ");if(x.length>1)return`${x[0][0]}${x[x.length-1][0]}`.toUpperCase();return m.substring(0,2).toUpperCase()},h=(m)=>{if(!m)return"";switch(m.toLowerCase()){case"owner":return Cd();case"editor":return Mi();case"reviewer":return Pi();default:return m}},l=(m)=>(m??0).toLocaleString(),C=(m)=>`$${(m??0).toFixed(6)}`;return g(ct,{className:"border-border/60 shadow-sm",children:[g(Nt,{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between pb-6",children:[g("div",{children:[a(Ft,{className:"text-xl font-semibold tracking-tight",children:Sb()}),a(Ht,{className:"text-sm text-muted-foreground mt-1",children:Ib()})]}),g("div",{className:"flex flex-wrap items-center gap-3",children:[g(os,{type:"single",value:t,onValueChange:(m)=>{if(m)s(m)},className:"border rounded-lg p-1 bg-muted/30",children:[a(Zr,{value:"team",className:"px-3 py-1.5 text-xs font-medium",children:zM()}),a(Zr,{value:"members",className:"px-3 py-1.5 text-xs font-medium",children:II()})]}),g(os,{type:"single",value:i,onValueChange:(m)=>{if(m)n(m)},className:"border rounded-lg p-1 bg-muted/30",children:[a(Zr,{value:"1h",className:"px-2.5 py-1.5 text-xs font-medium",children:"1h"}),a(Zr,{value:"24h",className:"px-2.5 py-1.5 text-xs font-medium",children:"24h"}),a(Zr,{value:"7d",className:"px-2.5 py-1.5 text-xs font-medium",children:"7d"}),a(Zr,{value:"30d",className:"px-2.5 py-1.5 text-xs font-medium",children:"30d"})]})]})]}),a(St,{children:t==="team"?c?a("div",{className:"flex h-48 items-center justify-center",children:a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):a("div",{className:"rounded-md border",children:g(Un,{children:[a(zn,{children:g(Tr,{children:[a(vt,{children:jp()}),a(vt,{className:"text-right",children:$_()}),a(vt,{className:"text-right",children:y0()}),a(vt,{className:"text-right",children:t_()}),a(vt,{className:"text-right",children:Ry()}),a(vt,{className:"text-right",children:a_()})]})}),a(jn,{children:g(Tr,{children:[a(ut,{className:"font-medium",children:jp()}),a(ut,{className:"text-right",children:l(r?.team?.inputTokens)}),a(ut,{className:"text-right",children:l(r?.team?.outputTokens)}),a(ut,{className:"text-right",children:l(r?.team?.cacheReadTokens)}),a(ut,{className:"text-right font-medium",children:l(r?.team?.totalTokens)}),a(ut,{className:"text-right font-medium",children:C(r?.team?.cost)})]})})]})}):p?a("div",{className:"flex h-48 items-center justify-center",children:a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):a("div",{className:"rounded-md border",children:g(Un,{children:[a(zn,{children:g(Tr,{children:[a(vt,{children:SI()}),a(vt,{children:Zk()}),a(vt,{className:"text-right",children:$_()}),a(vt,{className:"text-right",children:y0()}),a(vt,{className:"text-right",children:t_()}),a(vt,{className:"text-right",children:Ry()}),a(vt,{className:"text-right",children:a_()})]})}),a(jn,{children:(u||[]).map((m,x)=>{let T=v[x]?.data?.member;return g(Tr,{children:[a(ut,{children:g("div",{className:"flex items-center gap-3",children:[g($e,{className:"h-8 w-8 rounded-full",children:[m.image&&a(He,{src:m.image,alt:m.name,className:"object-cover"}),a(Qe,{className:"bg-primary/20 text-xs",children:b(m.name)})]}),g("div",{className:"flex flex-col",children:[a("span",{className:"text-sm font-medium leading-none",children:m.name}),a("span",{className:"text-xs text-muted-foreground mt-0.5",children:m.email})]})]})}),a(ut,{className:"text-xs text-muted-foreground",children:h(m.role)}),a(ut,{className:"text-right",children:l(T?.inputTokens)}),a(ut,{className:"text-right",children:l(T?.outputTokens)}),a(ut,{className:"text-right",children:l(T?.cacheReadTokens)}),a(ut,{className:"text-right font-medium",children:l(T?.totalTokens)}),a(ut,{className:"text-right font-medium",children:C(T?.cost)})]},m.id)})})]})})})]})}L();function Ne({teamId:e}){let[t,s]=w(null),{ref:i,inView:n}=Vt(),{data:r,isLoading:c,isError:u,fetchNextPage:f,hasNextPage:v,isFetchingNextPage:p}=Tt({queryKey:["teams",e,"agent-sessions"],queryFn:async({pageParam:l})=>{let C=await R.api.teams[":teamId"]["agent-sessions"].$get({param:{teamId:e},query:{first:"20",after:l?String(l):void 0}});if(!C.ok)throw Error("Failed to fetch agent sessions");return await C.json()},initialPageParam:"",getNextPageParam:(l)=>l.pageInfo.cursor||void 0,enabled:!!e});S(()=>{if(n&&v&&!p)f()},[n,v,p,f]);let b=r?.pages.flatMap((l)=>l.data).filter((l)=>l.id!=="pending")||[],h=(l)=>{switch(l){case"comment":return a(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20",children:PR()});case"chat":return a(ve,{variant:"outline",className:"bg-violet-500/10 text-violet-600 dark:text-violet-400 border-violet-500/20",children:OR()});case"naming":return a(ve,{variant:"outline",className:"bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20",children:DR()});default:return a(ve,{variant:"outline",className:"bg-muted text-muted-foreground border-border",children:l})}};return g("div",{className:"space-y-6",children:[g(ct,{className:"border border-border/50 shadow-xs",children:[a(Nt,{className:"pb-4",children:a("div",{className:"flex items-center justify-between",children:g("div",{children:[g(Ft,{className:"text-xl font-bold flex items-center gap-2",children:[a(V,{className:"w-5 h-5 text-violet-500"}),uy()]}),a(Ht,{className:"mt-1 text-sm text-muted-foreground",children:NR()})]})})}),a(St,{children:c?a("div",{className:"flex h-64 items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):u?a("div",{className:"flex h-64 items-center justify-center text-destructive",children:"Failed to load agent sessions."}):b.length===0?g("div",{className:"flex flex-col items-center justify-center py-12 text-center text-muted-foreground",children:[a(V,{className:"w-10 h-10 text-muted-foreground/40 mb-3"}),a("p",{className:"text-base font-medium",children:yT()})]}):g("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[g(Un,{children:[a(zn,{className:"bg-muted/40",children:g(Tr,{children:[a(vt,{children:kR()}),a(vt,{children:vd()}),a(vt,{children:MR()}),a(vt,{className:"text-right",children:hE()})]})}),a(jn,{children:b.map((l)=>g(Tr,{onClick:()=>s(l.id),className:"cursor-pointer hover:bg-muted/50 transition-colors",children:[a(ut,{className:"font-medium",children:g("div",{className:"flex flex-col",children:[a("span",{className:"text-sm font-semibold text-foreground",children:l.name||hg()}),a("span",{className:"text-xs font-mono text-muted-foreground/70",children:l.id})]})}),a(ut,{children:g("div",{className:"flex items-center gap-2",children:[g($e,{className:"h-6 w-6",children:[a(He,{src:l.creator?.image||void 0}),a(Qe,{className:"text-[10px]",children:l.creator?.name?.[0]?.toUpperCase()||"?"})]}),a("span",{className:"text-sm text-foreground/90",children:l.creator?.name||"System / Agent"})]})}),a(ut,{children:h(l.type)}),a(ut,{className:"text-right text-xs text-muted-foreground",children:on(l.createdAt)})]},l.id))})]}),a("div",{ref:i,className:"py-4 flex justify-center",children:p&&a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})})]}),a(vu,{sessionId:t,open:!!t,onOpenChange:(l)=>{if(!l)s(null)}})]})}L();function ye({...e}){return a(Ze,{"data-slot":"collapsible",...e})}function Te({...e}){return a(Ke,{"data-slot":"collapsible-trigger",...e})}function _e({...e}){return a(Xe,{"data-slot":"collapsible-content",...e})}function ne(e){switch(e.toLowerCase()){case"owner":return Cd();case"editor":return Mi();case"reviewer":return Pi();default:return e}}function nt(e,t){if(typeof e==="object"&&e!==null&&"message"in e){let s=e.message;if(typeof s==="string")return s}return t}function lt({rule:e}){let t=e.resourceData??{};if(e.resource==="agent_mcp_call_count")return a("span",{children:mk({value:String(t.id??"")})});if(e.resource==="agent_bash_call_count")return a("span",{children:pk({value:String(t.match??"*")})});if(e.resource==="agent_tool_call_count")return a("span",{children:hk({value:String(t.name??t.toolName??"*")})});return null}function xt({rule:e}){if(e.scopeMode==="all_members")return g(ve,{variant:"secondary",className:"gap-1 text-xs",children:[a(Uo,{className:"h-3 w-3"}),g("span",{children:[Dp(),e.role?` (${ne(e.role)})`:` (${Wc()})`]})]});if(e.scopeMode==="each_member")return g(ve,{variant:"secondary",className:"gap-1 text-xs",children:[a(qn,{className:"h-3 w-3"}),g("span",{children:[Np(),e.role?` (${ne(e.role)})`:` (${Wc()})`]})]});return g(ve,{variant:"secondary",className:"gap-1 text-xs",children:[a(Rs,{className:"h-3 w-3"}),g("span",{children:[Fp()," (",e.userIds?.length||0,")"]})]})}function yt({teamId:e,rule:t,record:s}){let i=ie(),[n,r]=w(!1),[c,u]=w(()=>new Date),f=Kl[t.resource],v=t.scopeMode==="all_members",p=s.percent>=100,b=v?t.role?`${sk()}: ${ne(t.role)}`:gk():s.user?.name||s.userId||Yn();S(()=>{if(!s.isWindowActive||!s.periodEnd)return;let l=window.setInterval(()=>u(new Date),60000);return()=>window.clearInterval(l)},[s.isWindowActive,s.periodEnd]);let h=ee({mutationFn:async()=>{let l=await R.api.teams[":teamId"].quotas[":id"].records.reset.$post({param:{teamId:e,id:t.id},json:{userId:s.userId??null}});if(!l.ok){let C=await l.json().catch(()=>null);throw Error(nt(C,k_()))}return await l.json()},onSuccess:()=>{i.invalidateQueries({queryKey:["teams",e,"quotas",t.id,"records"]}),i.invalidateQueries({queryKey:["teams",e,"quotas"]}),r(!1),j.success(rk())},onError:(l)=>{let C=l instanceof Error?l.message:k_();r(!1),j.error(C)}});return g(W,{children:[g("div",{className:"space-y-3 rounded-xl border border-border/70 bg-card p-4 text-card-foreground shadow-2xs",children:[g("div",{className:"flex items-center justify-between gap-3",children:[g("div",{className:"flex min-w-0 items-center gap-3",children:[v?a("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:a(Uo,{className:"h-5 w-5"})}):g($e,{className:"h-9 w-9 shrink-0 border border-border/50",children:[a(He,{src:s.user?.image||void 0}),a(Qe,{className:"text-xs font-semibold",children:s.user?.name?.[0]?.toUpperCase()||"U"})]}),g("div",{className:"min-w-0",children:[a("div",{className:"truncate text-sm font-semibold text-foreground",children:b}),!v&&s.user?.email&&a("div",{className:"truncate text-xs text-muted-foreground",children:s.user.email})]})]}),g("div",{className:"flex shrink-0 items-center gap-2",children:[s.isWindowActive&&s.periodEnd?g(ve,{variant:"outline",className:"hidden gap-1 border-primary/30 bg-primary/5 text-xs text-primary sm:flex",children:[a(ur,{className:"h-3 w-3"}),a("span",{children:j0({time:wg(s.periodEnd,c)})})]}):g(ve,{variant:"secondary",className:"hidden gap-1 text-xs text-muted-foreground sm:flex",children:[a(wr,{className:"h-3 w-3 text-primary"}),a("span",{children:U0()})]}),g(F,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>r(!0),disabled:h.isPending,children:[h.isPending?a(K,{className:"h-3.5 w-3.5 animate-spin"}):a(Li,{className:"h-3.5 w-3.5"}),q0()]})]})]}),g("div",{className:"space-y-1.5 pt-1",children:[a(om,{value:Math.min(100,Math.max(0,s.percent)),className:"h-2"}),g("div",{className:"flex items-center justify-between gap-2 text-xs font-medium",children:[g("span",{className:p?"font-bold text-destructive":"text-foreground",children:[va(t.resource,s.consumed)," /"," ",va(t.resource,t.limit)," ",f?.unit]}),g("span",{className:p?"font-bold text-destructive":"text-muted-foreground",children:[s.percent,"%"]})]})]}),g("div",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground sm:hidden",children:[s.isWindowActive&&s.periodEnd?g("span",{className:"flex items-center gap-1 text-primary",children:[a(ur,{className:"h-3 w-3"}),j0({time:wg(s.periodEnd,c)})]}):g("span",{className:"flex items-center gap-1",children:[a(wr,{className:"h-3 w-3 text-primary"}),U0()]}),g("span",{children:[tk(),": ",va(t.resource,s.remaining)," ",f?.unit]})]})]}),a(dt,{open:n,onOpenChange:r,children:g(ft,{children:[g(pt,{children:[a(ht,{children:q0()}),a(gt,{children:nk({target:b})})]}),g(mt,{children:[a(_t,{disabled:h.isPending,children:Ve()}),g(At,{onClick:(l)=>{l.preventDefault(),h.mutate()},disabled:h.isPending,children:[h.isPending&&a(K,{className:"mr-2 h-4 w-4 animate-spin"}),Xa()]})]})]})})]})}function Ct({teamId:e,rule:t}){let[s,i]=w(!1),[n,r]=w(""),c=Kl[t.resource],u=c?.icon||gs,{data:f,isLoading:v,isError:p}=X({queryKey:["teams",e,"quotas",t.id,"records"],queryFn:async()=>{let l=await R.api.teams[":teamId"].quotas[":id"].records.$get({param:{teamId:e,id:t.id}});if(!l.ok)throw Error(T_());return await l.json()},enabled:s,refetchInterval:s?1e4:!1}),b=f?.records??[],h=b.filter((l)=>{if(!n.trim())return!0;let C=n.toLowerCase();return l.user?.name.toLowerCase().includes(C)||l.user?.email.toLowerCase().includes(C)});return g(ye,{open:s,onOpenChange:i,className:"rounded-xl border border-border/70",children:[a(Te,{asChild:!0,children:g("button",{type:"button","aria-label":s?Q1():W1(),className:"flex w-full items-center justify-between gap-4 p-4 text-left transition-colors hover:bg-muted/40",children:[g("div",{className:"flex min-w-0 items-start gap-3",children:[a("div",{className:"mt-0.5 rounded-lg bg-primary/10 p-2 text-primary",children:a(u,{className:"h-5 w-5"})}),g("div",{className:"min-w-0",children:[g("div",{className:"flex flex-wrap items-center gap-2",children:[a("span",{className:"font-semibold text-foreground",children:c?.label()||t.resource}),!t.enabled&&a(ve,{variant:"secondary",children:zh()})]}),g("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[a(xt,{rule:t}),g(ve,{variant:"outline",className:"gap-1 text-xs",children:[a(ur,{className:"h-3 w-3"}),va(t.resource,t.limit)," ",c?.unit," /"," ",cu(t.period)]}),a(lt,{rule:t})]})]})]}),a(Be,{className:`h-5 w-5 shrink-0 text-muted-foreground transition-transform ${s?"rotate-180":""}`})]})}),a(_e,{children:g("div",{className:"space-y-3 border-t border-border/60 bg-muted/10 p-4",children:[t.scopeMode!=="all_members"&&b.length>3&&g("div",{className:"relative",children:[a(nr,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),a(re,{value:n,onChange:(l)=>r(l.target.value),placeholder:Gh(),className:"h-9 pl-9 text-sm"})]}),v?a("div",{className:"flex justify-center py-10",children:a(K,{className:"h-7 w-7 animate-spin text-primary"})}):p?a("div",{className:"py-8 text-center text-sm text-destructive",children:T_()}):h.length===0?a("div",{className:"py-8 text-center text-sm text-muted-foreground",children:X1()}):h.map((l,C)=>a(yt,{teamId:e,rule:t,record:l},l.id||l.userId||`record-${C}`))]})})]})}function Ae({teamId:e}){let{data:t,isLoading:s,isError:i}=X({queryKey:["teams",e,"quotas"],queryFn:async()=>{let r=await R.api.teams[":teamId"].quotas.$get({param:{teamId:e}});if(!r.ok)throw Error(Ms());return await r.json()},enabled:!!e}),n=t?.rules??[];return g(ct,{className:"border-border/60 shadow-sm",children:[g(Nt,{children:[g(Ft,{className:"flex items-center gap-2 text-xl font-semibold tracking-tight",children:[a(gs,{className:"h-5 w-5 text-primary"}),Lp()]}),a(Ht,{children:V1()})]}),a(St,{children:s?a("div",{className:"flex h-48 items-center justify-center",children:a(K,{className:"h-7 w-7 animate-spin text-muted-foreground"})}):i?a("div",{className:"py-10 text-center text-sm text-destructive",children:Ms()}):n.length===0?g("div",{className:"flex flex-col items-center justify-center rounded-xl border-2 border-dashed border-border py-12 text-center",children:[a(gs,{className:"mb-3 h-10 w-10 text-muted-foreground/50"}),a("p",{className:"text-base font-medium text-foreground",children:Oh()}),a("p",{className:"mt-1 max-w-md text-sm text-muted-foreground",children:Mh()})]}):a("div",{className:"space-y-3",children:n.map((r)=>a(Ct,{teamId:e,rule:r},r.id))})})]})}L();var kt=Object.values(nu);function Re({teamId:e}){let[t,s]=w([]),[i,n]=w([]),[r,c]=w(""),{ref:u,inView:f}=Vt(),{data:v}=X({queryKey:["teams",e,"members"],queryFn:async()=>{let d=await R.api.teams[":teamId"].members.$get({param:{teamId:e},query:{}});if(!d.ok)return[];return await d.json()},enabled:!!e}),p=v||[],{data:b,isLoading:h,isError:l,fetchNextPage:C,hasNextPage:m,isFetchingNextPage:x}=Tt({queryKey:["teams",e,"audit-logs",t,i,r],queryFn:async({pageParam:d})=>{let N=await R.api.teams[":teamId"]["audit-logs"].$get({param:{teamId:e},query:{first:"20",after:d?String(d):void 0,actions:t.length>0?t:void 0,userIds:i.length>0?i:void 0,itemId:r.trim()||void 0}});if(!N.ok)throw Error("Failed to fetch audit logs");return await N.json()},initialPageParam:"",getNextPageParam:(d)=>d.pageInfo.endCursor||void 0,enabled:!!e});S(()=>{if(f&&m&&!x)C()},[f,m,x,C]);let T=b?.pages.flatMap((d)=>d.nodes)||[],k=b?.pages[0]?.total??0,_=(d)=>{s((N)=>N.includes(d)?N.filter((D)=>D!==d):[...N,d])},q=(d)=>{n((N)=>N.includes(d)?N.filter((D)=>D!==d):[...N,d])},I=(d)=>{if(d.includes("delete")||d.includes("remove")||d.includes("revoke"))return a(ve,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 font-mono text-xs",children:d});if(d.includes("create")||d.includes("add"))return a(ve,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 font-mono text-xs",children:d});if(d.includes("update")||d.includes("reparent")||d.includes("copy"))return a(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 font-mono text-xs",children:d});return a(ve,{variant:"outline",className:"bg-muted text-muted-foreground border-border font-mono text-xs",children:d})},J=new Map(p.map((d)=>[d.userId||d.id,d]));return a("div",{className:"space-y-6",children:g(ct,{className:"border border-border/50 shadow-xs",children:[g(Nt,{className:"pb-4",children:[g("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[g("div",{children:[g(Ft,{className:"text-xl font-bold flex items-center gap-2",children:[a(Li,{className:"h-5 w-5 text-primary"}),Vm()]}),a(Ht,{className:"mt-1",children:tw()})]}),k>0&&g(ve,{variant:"secondary",className:"w-fit text-xs font-normal",children:[k," ",Vm()]})]}),g("div",{className:"mt-4 flex flex-wrap items-center gap-3 pt-4 border-t border-border/40",children:[g(bt,{children:[a(wt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),yC(),t.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:t.length})]})}),g(Et,{className:"w-64 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:rR()}),a("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:kt.map((d)=>g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:t.includes(d),onCheckedChange:()=>_(d)}),a("span",{className:"font-mono",children:d})]},d))}),t.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>s([]),children:"Clear Actions"})]})]}),g(bt,{children:[a(wt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),wC(),i.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:i.length})]})}),g(Et,{className:"w-64 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:AR()}),a("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:p.map((d)=>{let N=d.userId||d.user?.id||d.id,D=d.user?.name||d.name||N,E=d.user?.image||d.image;return g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:i.includes(N),onCheckedChange:()=>q(N)}),g($e,{className:"h-5 w-5",children:[a(He,{src:E||void 0}),a(Qe,{className:"text-[10px]",children:D.slice(0,2).toUpperCase()})]}),a("span",{className:"truncate",children:D})]},N)})}),i.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>n([]),children:"Clear Users"})]})]}),g("div",{className:"relative flex-1 min-w-[200px] max-w-xs",children:[a(nr,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),a(re,{type:"text",placeholder:Xk(),value:r,onChange:(d)=>c(d.target.value),className:"pl-8 pr-8 h-9 text-xs"}),r&&a("button",{onClick:()=>c(""),className:"absolute right-2.5 top-2.5 text-muted-foreground hover:text-foreground",children:a(Ge,{className:"h-4 w-4"})})]}),(t.length>0||i.length>0||r)&&a(F,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{s([]),n([]),c("")},children:"Clear all"})]})]}),g(St,{className:"p-0",children:[h?a("div",{className:"flex h-64 items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):l?a("div",{className:"p-8 text-center text-sm text-destructive",children:"Failed to load audit logs."}):T.length===0?a("div",{className:"p-12 text-center text-sm text-muted-foreground",children:sT()}):g(Un,{children:[a(zn,{children:g(Tr,{className:"hover:bg-transparent border-b border-border/50",children:[a(vt,{className:"w-[180px] pl-6 text-xs font-semibold",children:Jy()}),a(vt,{className:"w-[200px] px-4 text-xs font-semibold",children:ZO()}),a(vt,{className:"px-4 text-xs font-semibold",children:xS()}),a(vt,{className:"px-4 text-xs font-semibold",children:k0()}),a(vt,{className:"w-[160px] pr-6 text-right text-xs font-semibold",children:rO()})]})}),a(jn,{children:T.map((d)=>{let N=d.userId?J.get(d.userId):null,D=N?.user?.name||N?.name||d.userId||"System",E=N?.user?.image||N?.image;return g(Tr,{className:"hover:bg-muted/40 transition-colors",children:[a(ut,{className:"py-3 pl-6 font-medium",children:I(d.action)}),a(ut,{className:"py-3 px-4",children:g("div",{className:"flex items-center gap-2",children:[g($e,{className:"h-6 w-6",children:[a(He,{src:E||void 0}),a(Qe,{className:"text-[10px]",children:D.slice(0,2).toUpperCase()})]}),a("span",{className:"text-xs font-medium text-foreground truncate max-w-[160px]",children:d.agent?Rd({user:D,agent:d.agent.name}):D}),d.agent&&a($t,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]})}),a(ut,{className:"py-3 px-4 text-xs font-mono text-muted-foreground",children:d.itemId||"-"}),a(ut,{className:"py-3 px-4 text-xs font-mono text-muted-foreground",children:d.projectId||"-"}),a(ut,{className:"py-3 pr-6 text-right text-xs text-muted-foreground",children:on(d.createdAt)})]},d.id)})})]}),a("div",{ref:u,className:"py-4 flex justify-center",children:x&&a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]})})}L();L();function De({task:e,open:t,onOpenChange:s}){let[i,n]=w(null);if(!e)return null;let r=(u,f)=>{navigator.clipboard.writeText(u),n(f),setTimeout(()=>{n(null)},2000)},c=(u)=>{switch(u){case"completed":return a(ve,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 text-xs font-mono",children:"completed"});case"processing":return a(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 text-xs font-mono",children:"processing"});case"pending":return a(ve,{variant:"outline",className:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 border-yellow-500/20 text-xs font-mono",children:"pending"});case"failed":return a(ve,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 text-xs font-mono",children:"failed"});default:return a(ve,{variant:"outline",className:"text-xs font-mono",children:u||"unknown"})}};return a(Se,{open:t,onOpenChange:s,children:g(xe,{className:"max-w-2xl max-h-[90vh] flex flex-col p-6",children:[g(ke,{className:"pb-2 border-b border-border/50",children:[g("div",{className:"flex items-center justify-between gap-2 pr-6",children:[g("div",{className:"flex items-center gap-2",children:[a(Pn,{className:"h-5 w-5 text-primary"}),a(Ce,{className:"text-lg font-bold",children:PM()})]}),g("div",{className:"flex items-center gap-2",children:[c(e.status),e.type&&a(ve,{variant:"secondary",className:"font-mono text-xs",children:e.type})]})]}),g(Ot,{className:"text-xs text-muted-foreground mt-1 flex items-center gap-2",children:[g("span",{children:[vy(),": ",a("span",{className:"font-mono text-foreground",children:e.id})]}),a(F,{variant:"ghost",size:"icon",className:"h-5 w-5 text-muted-foreground hover:text-foreground",onClick:()=>r(e.id,"task_id"),children:i==="task_id"?a(qe,{className:"h-3 w-3 text-emerald-500"}):a(Br,{className:"h-3 w-3"})})]})]}),g("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 py-3 text-xs border-b border-border/40",children:[g("div",{children:[a("div",{className:"text-muted-foreground",children:ph()}),a("div",{className:"truncate font-medium text-foreground mt-0.5",title:e.fileName||"-",children:e.fileName||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:dy()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.fileSize!==null&&e.fileSize!==void 0?Fr(e.fileSize):"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:Tp()}),a("div",{className:"truncate font-medium text-foreground mt-0.5",title:e.projectName||"-",children:e.projectName||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:Gb()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.assetId||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:k0()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.projectId||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:up()}),g("div",{className:"font-medium text-foreground mt-0.5 flex items-center gap-1",children:[a(ur,{className:"h-3 w-3 text-muted-foreground"}),on(e.createdAt)]})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:MO()}),a("div",{className:"font-medium text-foreground mt-0.5",children:on(e.updatedAt)})]}),e.heartbeat&&g("div",{children:[a("div",{className:"text-muted-foreground",children:aS()}),a("div",{className:"font-medium text-foreground mt-0.5",children:on(e.heartbeat)})]}),e.model&&g("div",{children:[a("div",{className:"text-muted-foreground",children:Ch()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.model})]}),(e.inputTokens>0||e.outputTokens>0)&&g("div",{children:[g("div",{className:"text-muted-foreground flex items-center gap-1",children:[a(eo,{className:"h-3 w-3"})," ",lO()]}),g("div",{className:"font-medium text-foreground mt-0.5 font-mono",children:[e.inputTokens.toLocaleString()," in / ",e.outputTokens.toLocaleString()," out"]})]}),e.sessionId&&g("div",{className:"col-span-2",children:[a("div",{className:"text-muted-foreground",children:TR()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.sessionId})]})]}),a("div",{className:"flex-1 min-h-0 pt-3",children:g(co,{defaultValue:"payload",className:"w-full h-full flex flex-col",children:[g(uo,{className:"grid w-full grid-cols-2",children:[a(Jr,{value:"payload",children:u1()}),a(Jr,{value:"output",children:XT()})]}),a(gn,{value:"payload",className:"flex-1 mt-2 min-h-0",children:a(Ie,{className:"h-64 w-full rounded-md border border-border/50 bg-muted/30 p-3 font-mono text-xs",children:a("pre",{className:"whitespace-pre-wrap break-all text-foreground/90",children:e.payload?JSON.stringify(e.payload,null,2):"null"})})}),a(gn,{value:"output",className:"flex-1 mt-2 min-h-0",children:a(Ie,{className:"h-64 w-full rounded-md border border-border/50 bg-muted/30 p-3 font-mono text-xs",children:a("pre",{className:"whitespace-pre-wrap break-all text-foreground/90",children:e.output?JSON.stringify(e.output,null,2):"null"})})})]})})]})})}var Rt=Object.values(Hl),Dt=Object.values(Ql);function Pe({teamId:e}){let t=ie(),[s,i]=w([]),[n,r]=w([]),[c,u]=w(null),[f,v]=w(null),{ref:p,inView:b}=Vt(),h=Q(()=>["teams",e,"workflow-tasks",s,n],[e,s,n]),{data:l,isLoading:C,isError:m,fetchNextPage:x,hasNextPage:T,isFetchingNextPage:k,refetch:_,isRefetching:q}=Tt({queryKey:h,queryFn:async({pageParam:o})=>{let y=await R.api.teams[":teamId"]["workflow-tasks"].$get({param:{teamId:e},query:{first:"20",after:o?String(o):void 0,status:s.length>0?s:void 0,types:n.length>0?n:void 0}});if(!y.ok)throw Error("Failed to fetch workflow tasks");return await y.json()},initialPageParam:"",getNextPageParam:(o)=>o.pageInfo.endCursor||void 0,enabled:!!e});S(()=>{if(b&&T&&!k)x()},[b,T,k,x]);let I=Q(()=>l?.pages.flatMap((o)=>o.nodes)||[],[l]),J=l?.pages[0]?.total??0,d=Q(()=>I.filter((o)=>o.status==="pending"||o.status==="processing").map((o)=>o.id),[I]);X({queryKey:["teams",e,"workflow-tasks","batch-status",d],queryFn:async()=>{if(d.length===0)return null;let o=await R.api.teams[":teamId"]["workflow-tasks"]["batch-status"].$post({param:{teamId:e},json:{taskIds:d}});if(!o.ok)return null;let y=await o.json();if(y.tasks&&y.tasks.length>0)t.setQueryData(h,(A)=>{if(!A)return A;let Z=new Map(y.tasks.map((O)=>[O.id,O]));return{...A,pages:A.pages.map((O)=>({...O,nodes:O.nodes.map((le)=>Z.get(le.id)||le)}))}});return y},enabled:d.length>0,refetchInterval:6000});let N=ee({mutationFn:async(o)=>{let y=await R.api.teams[":teamId"]["workflow-tasks"][":taskId"].stop.$post({param:{teamId:e,taskId:o}});if(!y.ok){let A=await y.json().catch(()=>({message:"Failed to stop task"}));throw Error(A.message||"Failed to stop task")}return await y.json()},onSuccess:(o)=>{j.success(DM()),t.setQueryData(h,(y)=>{if(!y)return y;return{...y,pages:y.pages.map((A)=>({...A,nodes:A.nodes.map((Z)=>Z.id===o.task.id?o.task:Z)}))}}),u(null)},onError:(o)=>{j.error(o.message||"Failed to stop task")}}),D=(o)=>{i((y)=>y.includes(o)?y.filter((A)=>A!==o):[...y,o])},E=(o)=>{r((y)=>y.includes(o)?y.filter((A)=>A!==o):[...y,o])},Ee=(o)=>{switch(o){case"completed":return a(ve,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 font-mono text-xs",children:"completed"});case"processing":return g(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 font-mono text-xs gap-1.5",children:[a(K,{className:"h-3 w-3 animate-spin"}),"processing"]});case"pending":return a(ve,{variant:"outline",className:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 border-yellow-500/20 font-mono text-xs",children:"pending"});case"failed":return a(ve,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 font-mono text-xs",children:"failed"});default:return a(ve,{variant:"outline",className:"font-mono text-xs",children:o||"-"})}},Oe=(o)=>{if(!o)return a(ve,{variant:"outline",children:"-"});if(o.startsWith("transcode"))return a(ve,{variant:"outline",className:"bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20 font-mono text-xs",children:o});if(o.startsWith("ai_")||o==="chat")return a(ve,{variant:"outline",className:"bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 border-indigo-500/20 font-mono text-xs",children:o});return a(ve,{variant:"secondary",className:"font-mono text-xs",children:o})};return g("div",{className:"space-y-6",children:[g(ct,{className:"border border-border/50 shadow-xs",children:[g(Nt,{className:"pb-4",children:[g("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[g("div",{children:[g(Ft,{className:"text-xl font-bold flex items-center gap-2",children:[a(ae,{className:"h-5 w-5 text-primary"}),yg()]}),a(Ht,{className:"mt-1",children:sP()})]}),g("div",{className:"flex items-center gap-3",children:[J>0&&g(ve,{variant:"secondary",className:"w-fit text-xs font-normal",children:[J," ",yg()]}),g(F,{variant:"outline",size:"sm",className:"h-9 gap-1.5 text-xs",onClick:()=>_(),disabled:q,children:[a(be,{className:`h-3.5 w-3.5 ${q?"animate-spin":""}`}),xk()]})]})]}),g("div",{className:"mt-4 flex flex-wrap items-center gap-3 pt-4 border-t border-border/40",children:[g(bt,{children:[a(wt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),vC(),s.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:s.length})]})}),g(Et,{className:"w-56 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:hR()}),a("div",{className:"space-y-1",children:Dt.map((o)=>g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:s.includes(o),onCheckedChange:()=>D(o)}),a("span",{className:"font-mono",children:o})]},o))}),s.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>i([]),children:Dw()})]})]}),g(bt,{children:[a(wt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),bC(),n.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:n.length})]})}),g(Et,{className:"w-64 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:rg()}),a("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:Rt.map((o)=>g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:n.includes(o),onCheckedChange:()=>E(o)}),a("span",{className:"font-mono truncate",children:o})]},o))}),n.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>r([]),children:Nw()})]})]}),(s.length>0||n.length>0)&&a(F,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{i([]),r([])},children:Rw()})]})]}),g(St,{className:"p-0",children:[C?a("div",{className:"flex h-64 items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):m?a("div",{className:"p-8 text-center text-sm text-destructive",children:Gx()}):I.length===0?a("div",{className:"p-12 text-center text-sm text-muted-foreground",children:IT()}):g(Un,{children:[a(zn,{children:g(Tr,{className:"hover:bg-transparent border-b border-border/50",children:[a(vt,{className:"w-[170px] pl-6 text-xs font-semibold",children:Cy()}),a(vt,{className:"w-[130px] px-4 text-xs font-semibold",children:wy()}),a(vt,{className:"min-w-[180px] px-4 text-xs font-semibold",children:ph()}),a(vt,{className:"w-[110px] px-4 text-xs font-semibold",children:dy()}),a(vt,{className:"w-[160px] px-4 text-xs font-semibold",children:Tp()}),a(vt,{className:"w-[130px] px-4 text-right text-xs font-semibold",children:up()}),a(vt,{className:"w-[120px] pr-6 text-right text-xs font-semibold",children:zm()})]})}),a(jn,{children:I.map((o)=>{let y=o.status==="pending"||o.status==="processing";return g(Tr,{className:"hover:bg-muted/40 transition-colors",children:[a(ut,{className:"py-3 pl-6 font-medium",children:Oe(o.type)}),a(ut,{className:"py-3 px-4 font-medium",children:Ee(o.status)}),a(ut,{className:"py-3 px-4 text-xs font-medium",children:a("span",{className:"truncate block max-w-[220px]",title:o.fileName||o.assetId||"-",children:o.fileName||o.assetId||"-"})}),a(ut,{className:"py-3 px-4 text-xs font-mono text-muted-foreground",children:o.fileSize!==null&&o.fileSize!==void 0?Fr(o.fileSize):"-"}),a(ut,{className:"py-3 px-4 text-xs text-muted-foreground",children:a("span",{className:"truncate block max-w-[160px]",title:o.projectName||o.projectId||"-",children:o.projectName||o.projectId||"-"})}),a(ut,{className:"py-3 px-4 text-right text-xs text-muted-foreground whitespace-nowrap",children:on(o.createdAt)}),a(ut,{className:"py-3 pr-6 text-right",children:g("div",{className:"flex items-center justify-end gap-1",children:[a(F,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",onClick:()=>v(o),title:$O(),children:a(ge,{className:"h-4 w-4"})}),y&&g(F,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs border-destructive/30 text-destructive hover:bg-destructive/10",onClick:()=>u(o),disabled:N.isPending,children:[a(bu,{className:"h-3 w-3 mr-1 fill-current"}),Ay()]})]})})]},o.id)})})]}),a("div",{ref:p,className:"py-4 flex justify-center",children:k&&a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]}),a(dt,{open:!!c,onOpenChange:(o)=>{if(!o)u(null)},children:g(ft,{children:[g(pt,{children:[g("div",{className:"flex items-center gap-2",children:[a(rn,{className:"h-5 w-5 text-destructive"}),a(ht,{children:uM()})]}),a(gt,{className:"pt-2 text-sm text-muted-foreground",children:cM()}),c&&g("div",{className:"mt-3 p-2.5 rounded-md bg-muted/50 border border-border/40 font-mono text-xs space-y-1",children:[g("div",{children:[vy(),": ",c.id]}),c.fileName&&g("div",{className:"font-sans",children:[ph(),":"," ",a("span",{className:"font-medium text-foreground",children:c.fileName})]}),g("div",{children:[Cy(),": ",c.type||"unknown"]}),g("div",{children:[wy(),": ",c.status]})]})]}),g(mt,{children:[a(_t,{disabled:N.isPending,children:Ve()}),a(At,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",disabled:N.isPending,onClick:()=>{if(c)N.mutate(c.id)},children:N.isPending?g(W,{children:[a(K,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}),dM()]}):Ay()})]})]})}),a(De,{task:f,open:!!f,onOpenChange:(o)=>{if(!o)v(null)}})]})}function qt(){let{teamId:e}=It.useParams(),[t,s]=w("audit-logs"),{data:i,isLoading:n}=X({queryKey:["teams",e,"me"],queryFn:async()=>{let r=await R.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!r.ok)throw Error("Failed to fetch me");return await r.json()},enabled:!!e});if(n)return a("div",{className:"flex h-screen items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(i?.role?.toLowerCase()!=="owner")return g("div",{className:"flex h-full flex-col items-center justify-center p-8 text-center",children:[a(lu,{className:"h-12 w-12 text-destructive mb-4"}),a("h2",{className:"text-xl font-bold tracking-tight mb-2",children:Wy()}),a("p",{className:"text-sm text-muted-foreground max-w-md",children:OT()})]});return a("div",{className:"h-full bg-background font-sans selection:bg-primary/20 transition-colors duration-300",children:g("div",{className:"flex flex-col md:flex-row h-full",children:[a("div",{className:"w-full h-full md:w-72 bg-sidebar border-b md:border-b-0 md:border-r border-sidebar-border z-10 md:left-16 overflow-y-auto transition-colors duration-300",children:g("nav",{className:"p-4 space-y-1 mt-4",children:[a("div",{className:"mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider",children:d_()}),a("div",{className:"mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:LM()}),g("button",{onClick:()=>s("audit-logs"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="audit-logs"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(Li,{className:"w-5 h-5"}),Vm(),t==="audit-logs"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("workflow-tasks"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="workflow-tasks"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(ae,{className:"w-5 h-5"}),yg(),t==="workflow-tasks"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("quotas"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="quotas"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(gs,{className:"w-5 h-5"}),Lp(),t==="quotas"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),a("div",{className:"mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:Eb()}),g("button",{onClick:()=>s("ai-usage"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="ai-usage"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(fe,{className:"w-5 h-5"}),LO(),t==="ai-usage"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("ai-sessions"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="ai-sessions"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(V,{className:"w-5 h-5"}),uy(),t==="ai-sessions"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]})}),a("div",{className:"flex-1 overflow-y-auto p-4 md:p-8",children:g("div",{className:"max-w-6xl mx-auto space-y-8",children:[t==="audit-logs"&&a(Re,{teamId:e}),t==="workflow-tasks"&&a(Pe,{teamId:e}),t==="ai-usage"&&a(he,{teamId:e}),t==="ai-sessions"&&a(Ne,{teamId:e}),t==="quotas"&&a(Ae,{teamId:e})]})})]})})}var It=Je("/teams/$teamId/dashboard")({component:qt});export{It as Route};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{w,
|
|
1
|
+
import{w,L,W,a,g,Je,Gr,K,qe,Ge,F,rp,qb,rw,nw,ow,sw,s_,WE,JE,ZS,GS,Dk,ya}from"./chunk-5ngftxjb.js";import{Zi,pu}from"./chunk-7mawxsk3.js";import{qn}from"./chunk-pdw77q09.js";L();var p=Je("/consent")({component:x});function x(){let r=p.useSearch(),o=Gr((e)=>e.user),n=o&&typeof o==="object"?o:null,[s,d]=w(null),[m,i]=w(null),c=r.client_id||"MCP Client",u=r.scope?r.scope.split(" "):["mcp"],l=async(e)=>{d(e?"accept":"deny"),i(null);try{let t=await rp.oauth2.consent({accept:e});if(t.data?.url)window.location.href=t.data.url;else if(t.error)i(t.error.message||s_()),d(null)}catch(t){i(t instanceof Error?t.message:s_()),d(null)}};return g(ya,{children:[g("div",{className:"mb-6",children:[g("div",{className:"flex items-center gap-2 mb-2 text-primary",children:[a(pu,{className:"w-6 h-6"}),a("h1",{className:"text-2xl font-bold tracking-tight text-foreground",children:nw()})]}),a("p",{className:"text-muted-foreground text-sm",children:ow()})]}),m&&a("div",{className:"mb-6 p-3 bg-destructive/10 border border-destructive/20 text-destructive rounded-xl text-sm text-center font-medium",children:m}),g("div",{className:"space-y-4 rounded-xl border border-border bg-card p-4 mb-6 shadow-xs",children:[g("div",{className:"flex items-center justify-between text-sm pb-3 border-b border-border",children:[g("span",{className:"text-muted-foreground flex items-center gap-1.5",children:[a(Zi,{className:"w-4 h-4"}),qb()]}),a("span",{className:"font-mono font-medium text-foreground text-xs bg-muted px-2 py-0.5 rounded",children:c})]}),n&&g("div",{className:"flex items-center justify-between text-sm pb-3 border-b border-border",children:[g("span",{className:"text-muted-foreground flex items-center gap-1.5",children:[a(qn,{className:"w-4 h-4"}),ZS()]}),a("span",{className:"font-medium text-foreground text-xs",children:n.email||n.name})]}),g("div",{className:"pt-1",children:[a("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground block mb-2",children:Dk()}),a("div",{className:"space-y-2",children:g("div",{className:"flex items-start gap-2 text-sm bg-muted/50 p-2.5 rounded-lg border border-border/50",children:[a(qe,{className:"w-4 h-4 text-emerald-500 mt-0.5 shrink-0"}),g("div",{children:[a("p",{className:"font-medium text-foreground text-xs",children:GS()}),a("div",{className:"flex flex-wrap gap-1 mt-1",children:u.map((e)=>a("span",{className:"font-mono text-[10px] text-muted-foreground bg-background px-1.5 py-0.5 rounded border border-border",children:e},e))})]})]})})]})]}),g("div",{className:"flex gap-3",children:[a(F,{type:"button",variant:"outline",className:"flex-1 h-11 rounded-xl cursor-pointer",disabled:s!==null,onClick:()=>l(!1),children:s==="deny"?g(W,{children:[a(K,{className:"w-4 h-4 animate-spin mr-2"}),JE()]}):g(W,{children:[a(Ge,{className:"w-4 h-4 mr-1.5"}),WE()]})}),a(F,{type:"button",className:"flex-1 h-11 bg-primary text-primary-foreground font-semibold rounded-xl shadow-xs cursor-pointer",disabled:s!==null,onClick:()=>l(!0),children:s==="accept"?g(W,{children:[a(K,{className:"w-4 h-4 animate-spin mr-2"}),sw()]}):g(W,{children:[a(qe,{className:"w-4 h-4 mr-1.5"}),rw()]})})]})]})}export{p as Route};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{z}from"./chunk-
|
|
2
|
-
export{
|
|
1
|
+
import{z}from"./chunk-5ngftxjb.js";var a=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],ll=z("save",a);
|
|
2
|
+
export{ll};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S,L,a,X,Je,R,Pt,qt,Ng}from"./chunk-5ngftxjb.js";import"./chunk-9405hzv2.js";import"./chunk-qm50g4n5.js";import"./chunk-ffjdkdcv.js";import"./chunk-d55138xx.js";import{Wl}from"./chunk-zx1c4vm5.js";import"./chunk-j2txsbxz.js";import"./chunk-c8frmqsk.js";import"./chunk-a859y4e1.js";import"./chunk-sz5zawfw.js";import{Ar}from"./chunk-b3t7gbhm.js";import"./chunk-0a298n62.js";import"./chunk-s1j4v33x.js";L();function m(){let{projectId:e,folderId:s}=c.useParams(),{teamId:r,ensureTeamIdForProject:t}=Pt();S(()=>{t(e)},[e,t]);let{data:d}=Ar(Ng(e)),o=d?.rootFolder,{data:f}=X({queryKey:["folders",o],queryFn:async()=>{let n=await R.api.folders[":folderId"].$get({param:{folderId:o}});if(!n.ok)throw Error("failed to fetch folder");return await n.json()},enabled:!!o});if(!r||!o||!f)return a(qt,{});return a(Wl,{teamId:r,projectId:e,projectName:d.name??"",assetId:s,rootFolderId:o,isRoot:!1})}var c=Je("/projects/$projectId/folders/$folderId_/agentsmd")({component:m});export{c as Route};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{G,S,Q,M,w,L,W,a,g,ie,X,ee,Tt,Je,R,z,K,qe,On,jt,Do,No,ps,Re,Ue,Ge,F,De,Ne,Fe,de,xn,dr,jm,wA,$m,Mb,Ob,Qm,Gm,Ve,Bw,Xa,tE,nE,c_,Mt,nh,cx,xx,x_,Mx,Nx,Fx,Lx,Zx,Bx,Ll,pa,ma,uh,Zl,hC,CC,XC,mS,gS,OS,DS,NS,bp,LI,xT,ST,DT,FT,Fh,b0,Lh,_1,y1,Jc,kk,Uk,wo,Hk,tR,oR,iy,ql,Sd,Yc,sg,ig,ag,Xc,Id,Td,lg,cg,kd,jM,qM,$M,HM,GM,Yn,_g,NO,FO,tu,Ly,QO,GO,VO,KO,WO,Se,xe,ke,ot,Ce,re,Ie,Pt,an,Xn,Eo,Md,j,$r,Bn,fe,Ke,Xe,et,tt,rt,be,_a,lr,Lr,qt,Og}from"./chunk-5ngftxjb.js";import{tc}from"./chunk-ajq9sxg0.js";import{Bd,Ea}from"./chunk-1tar0x8s.js";import{_s}from"./chunk-34f64q0q.js";import"./chunk-qvp24w0q.js";import"./chunk-9405hzv2.js";import"./chunk-20w1w9x7.js";import{Yr}from"./chunk-d55138xx.js";import{al,uu}from"./chunk-50pfmxt1.js";import{iu,au}from"./chunk-20bamhwa.js";import{ll}from"./chunk-j2txsbxz.js";import{fu}from"./chunk-f8hgy69t.js";import{Ar}from"./chunk-b3t7gbhm.js";import{mu}from"./chunk-y5dv67mg.js";import"./chunk-etrm28sy.js";import"./chunk-0a298n62.js";import"./chunk-pdw77q09.js";import{zo}from"./chunk-femnbfkj.js";import"./chunk-25npafhz.js";import{jo}from"./chunk-88jg9dq5.js";import{Br}from"./chunk-7kah3zb5.js";L();var bt=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],it=z("folder-open",bt);var yt=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],lt=z("list-filter",yt);L();function Nt({ratio:t}){switch(t){case"16:9":return a("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"});case"9:16":return a("span",{className:"inline-block w-2.5 h-4 border border-current rounded-[1px] shrink-0"});case"4:3":return a("span",{className:"inline-block w-3.5 h-2.5 border border-current rounded-[1px] shrink-0"});case"3:4":return a("span",{className:"inline-block w-2.5 h-3.5 border border-current rounded-[1px] shrink-0"});case"1:1":return a("span",{className:"inline-block w-3 h-3 border border-current rounded-[1px] shrink-0"});default:return a("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"})}}function at(){return Math.random().toString(36).substring(2,9)}function dt(){return{id:at(),type:"text",text:"CONFIDENTIAL",x:0.5,y:0.5,size:0.05,color:"#999999",opacity:0.5,rotation:-30}}function kt(){return{id:at(),type:"image",imageAssetKey:"",x:0.5,y:0.5,size:0.15,opacity:0.5,rotation:0}}var Ze=[{id:"dark",label:"Dark Slate",bg:"#1e293b",dot:"#475569"},{id:"black",label:"Black",bg:"#000000",dot:"#404040"},{id:"gray",label:"Slate Gray",bg:"#64748b",dot:"#cbd5e1"},{id:"white",label:"White",bg:"#ffffff",dot:"#94a3b8"},{id:"green",label:"Chroma Green",bg:"#059669",dot:"#047857"}],St={"16:9":1.7777777777777777,"9:16":0.5625,"4:3":1.3333333333333333,"3:4":0.75,"1:1":1};function mt({open:t,onOpenChange:b,initialConfig:f,shareId:m,teamId:y,onSaveSuccess:x}){let D=ie(),[l,v]=w([]),[d,p]=w(null),[B,E]=w(null),[N,oe]=w("16:9"),[le,ce]=w("grid"),[ge,U]=w(!1),[ne,te]=w("new"),[se,V]=w(""),[H,Y]=w(null),k=M(null),J=M(null),[Z,ve]=w({w:0,h:0}),[_,A]=w(!1),s=G((e)=>{if(J.current=e,!e)return;let i=()=>{let{clientWidth:C,clientHeight:h}=e;if(C<=0||h<=0)return;let P=St[N],Ye=C,Te=Ye/P;if(Te>h)Te=h,Ye=Te*P;ve({w:Math.round(Ye),h:Math.round(Te)})};i();let o=new ResizeObserver(i);return o.observe(e),()=>{o.disconnect(),J.current=null}},[N]),q=Pt((e)=>e.teamId),me=y||q,[Ee,ye]=w(!1),[O,he]=w({}),ae=M(null),ue=R.api.teams[":teamId"].files.$post,we=async(e,i)=>{let o=e.target.files?.[0];if(!o)return;if(o.size>1048576){if(j.error(hC()),ae.current)ae.current.value="";return}if(!me){j.error(ma());return}ye(!0);let C=URL.createObjectURL(o);he((h)=>({...h,[i]:C}));try{let h=await ue({param:{teamId:me},form:{file:o}});if(!h.ok)throw Error(ma());let P=await h.json();I(i,{imageAssetKey:P.key,imageAssetUrl:P.url})}catch(h){let P=h instanceof Error?h.message:ma();j.error(P)}finally{if(ye(!1),ae.current)ae.current.value=""}};S(()=>{if(t){if(f?.blocks&&f.blocks.length>0)v(f.blocks),p(f.blocks[0].id);else{let e=dt();v([e]),p(e.id)}E(null)}},[t,f]);let{data:T=[]}=X({queryKey:["watermark-templates",y],queryFn:async()=>{let e=await R.api["watermark-templates"].$get({query:y?{teamId:y}:{}});if(!e.ok)return[];return await e.json()},enabled:t}),_e=R.api.shares[":shareId"].watermark.$put,{mutate:pe,isPending:Ae}=ee({mutationFn:async(e)=>{let i=await _e({param:{shareId:m},json:{enabled:!0,config:e}});if(!i.ok){let o=await i.json().catch(()=>null);throw Error(o?.error||pa())}return await i.json()},onSuccess:()=>{D.invalidateQueries({queryKey:["share",m]}),D.invalidateQueries({queryKey:["shares"]}),j.success(WO()),b(!1),x?.()},onError:(e)=>{j.error(e.message||pa())}}),We=R.api["watermark-templates"].$post,{mutate:ze,isPending:Le}=ee({mutationFn:async({name:e,config:i})=>{let o=await We({json:{name:e,teamId:y||void 0,config:i}});if(!o.ok)throw Error(pa());return await o.json()},onSuccess:(e)=>{D.invalidateQueries({queryKey:["watermark-templates"]}),E(e.id),U(!1),j.success($M())},onError:()=>{j.error(pa())}}),$e=R.api["watermark-templates"][":templateId"].$put,{mutate:Me,isPending:Oe}=ee({mutationFn:async({templateId:e,config:i})=>{let o=await $e({param:{templateId:e},json:{config:i}});if(!o.ok)throw Error(pa());return await o.json()},onSuccess:()=>{D.invalidateQueries({queryKey:["watermark-templates"]}),U(!1),j.success(HM())},onError:()=>{j.error(pa())}}),r=R.api["watermark-templates"][":templateId"].$delete,{mutate:c}=ee({mutationFn:async(e)=>{if(!(await r({param:{templateId:e}})).ok)throw Error(Ll())},onSuccess:(e,i)=>{if(D.invalidateQueries({queryKey:["watermark-templates"]}),B===i)E(null);j.success(jM())},onError:()=>{j.error(Ll())}}),u=l.findIndex((e)=>e.id===d),n=u>=0?l[u]:null,Be=()=>{let e=dt();v((i)=>[...i,e]),p(e.id)},pt=()=>{let e=kt();v((i)=>[...i,e]),p(e.id)},nt=(e)=>{if(!e)return;v((i)=>{let o=i.filter((C)=>C.id!==e);if(d===e)p(o.length>0?o[Math.max(0,u-1)].id:null);return o})},I=(e,i)=>{v((o)=>o.map((C)=>C.id===e?{...C,...i}:C))},ft=()=>{if(l.length===0)return;let e=(u-1+l.length)%l.length;p(l[e].id)},gt=()=>{if(l.length===0)return;let e=(u+1)%l.length;p(l[e].id)},xt=(e,i)=>{e.stopPropagation(),p(i),A(!0)},Qe=G((e)=>{if(!_||!d||!k.current)return;let i=k.current.getBoundingClientRect(),o=(e.clientX-i.left)/i.width,C=(e.clientY-i.top)/i.height,h=Math.max(0,Math.min(1,Math.round(o*100)/100)),P=Math.max(0,Math.min(1,Math.round(C*100)/100));I(d,{x:h,y:P})},[_,d]),He=G(()=>{A(!1)},[]);S(()=>{if(_)window.addEventListener("mousemove",Qe),window.addEventListener("mouseup",He);return()=>{window.removeEventListener("mousemove",Qe),window.removeEventListener("mouseup",He)}},[_,Qe,He]),S(()=>{let e=(i)=>{if(!t||!d)return;let o=i.target?.tagName?.toLowerCase();if(o==="input"||o==="textarea"||o==="select")return;if(i.key==="Delete"||i.key==="Backspace")i.preventDefault(),nt(d)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,d,u]);let vt=(e)=>{if(e.config?.blocks&&e.config.blocks.length>0){let i=e.config.blocks.map((o)=>({...o,id:at()}));v(i),p(i[0].id),E(e.id)}},ht=()=>{if(l.length===0){j.error(ST());return}pe({blocks:l})},wt=()=>{if(ne==="new"){if(!se.trim()){j.error(x_());return}ze({name:se.trim(),config:{blocks:l}})}else{let e=H||B;if(!e){j.error(iy());return}Me({templateId:e,config:{blocks:l}})}};return g(W,{children:[a(Se,{open:t,onOpenChange:b,children:g(xe,{showCloseButton:!1,className:"sm:max-w-[1400px] max-w-[95vw] w-[95vw] h-[88vh] flex flex-col p-0 gap-0 overflow-hidden",onPointerDownOutside:(e)=>e.preventDefault(),children:[g("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border bg-card",children:[a("div",{className:"flex items-center gap-3",children:a(Ce,{className:"text-base font-semibold",children:GO()})}),g("div",{className:"flex items-center gap-2",children:[g(De,{modal:!1,children:[a(Ne,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"gap-2 text-xs",children:[a(it,{className:"h-4 w-4 text-muted-foreground"}),VO()]})}),g(Fe,{align:"end",className:"w-56",children:[a(xn,{className:"text-xs font-semibold text-muted-foreground",children:NS()}),T.length===0?a("div",{className:"px-2 py-1.5 text-xs text-muted-foreground italic",children:xT()}):T.map((e)=>g(de,{onClick:()=>vt(e),className:"flex items-center justify-between text-xs cursor-pointer",children:[a("span",{className:"truncate flex-1",children:e.name}),B===e.id&&a(qe,{className:"h-3.5 w-3.5 text-primary ml-2 flex-shrink-0"}),a(F,{variant:"ghost",size:"icon",className:"h-5 w-5 hover:bg-destructive/10 hover:text-destructive ml-1",onClick:(i)=>{i.stopPropagation(),c(e.id)},children:a(Ue,{className:"h-3 w-3"})})]},e.id)),a(dr,{}),g(de,{onClick:()=>{te("new"),V(""),U(!0)},className:"text-xs gap-2 cursor-pointer",children:[a(Re,{className:"h-3.5 w-3.5 text-primary"}),c_()]}),T.length>0&&g(de,{onClick:()=>{te("overwrite"),Y(B||T[0].id),U(!0)},className:"text-xs gap-2 cursor-pointer",children:[a(ll,{className:"h-3.5 w-3.5 text-muted-foreground"}),b0()]})]})]}),a(F,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>b(!1),children:Ve()}),g(F,{size:"sm",className:"text-xs bg-primary hover:bg-primary/90 text-primary-foreground gap-1.5",disabled:Ae,onClick:ht,children:[a(ll,{className:"h-3.5 w-3.5"}),Hk()]})]})]}),g("div",{className:"flex-1 flex overflow-hidden",children:[g("div",{className:"w-[65%] flex flex-col p-4 bg-muted/20 border-r border-border overflow-hidden select-none",children:[g("div",{className:"flex items-center justify-between mb-3",children:[a("div",{className:"flex items-center gap-1 bg-muted/60 p-1 rounded-md border border-border/60",children:["16:9","9:16","4:3","3:4","1:1"].map((e)=>g(F,{variant:N===e?"secondary":"ghost",size:"sm",className:Pe("h-7 px-2.5 text-xs gap-1.5 font-mono transition-all",N===e?"bg-background shadow-xs font-semibold text-foreground border border-border/50":"text-muted-foreground hover:text-foreground"),onClick:()=>oe(e),children:[a(Nt,{ratio:e}),a("span",{children:e})]},e))}),a("div",{className:"flex items-center gap-1.5 bg-background border border-border/60 rounded-md p-1",children:Ze.map((e)=>a("button",{type:"button",onClick:()=>ce(e.id),style:{backgroundColor:e.bg},className:Pe("w-5 h-5 rounded-full border border-border/80 transition-all cursor-pointer relative",le===e.id?"ring-2 ring-primary ring-offset-1 scale-110":"hover:scale-105 opacity-80 hover:opacity-100"),title:e.label},e.id))})]}),a("div",{ref:s,className:"flex-1 flex items-center justify-center overflow-hidden",children:(()=>{let e=Ze.find((o)=>o.id===le)||Ze[0],i=Z.w>0&&Z.h>0;return a("div",{ref:k,onClick:()=>p(null),style:{backgroundColor:e.bg,backgroundImage:`radial-gradient(${e.dot} 1px, transparent 1px)`,backgroundSize:"16px 16px",...i?{width:Z.w,height:Z.h}:{}},className:Pe("relative rounded-lg border border-border overflow-hidden shadow-inner transition-all",N==="16:9"&&"aspect-[16/9] w-full max-h-full",N==="9:16"&&"aspect-[9/16] h-full max-w-full",N==="4:3"&&"aspect-[4/3] w-full max-h-full",N==="3:4"&&"aspect-[3/4] h-full max-w-full",N==="1:1"&&"aspect-square h-full max-w-full"),children:l.map((o)=>{let C=o.id===d,h=o.size*(Z.w||640);return a("div",{onMouseDown:(P)=>xt(P,o.id),onClick:(P)=>{P.stopPropagation(),p(o.id)},style:{left:`${o.x*100}%`,top:`${o.y*100}%`,transform:`translate(-50%, -50%) rotate(${o.rotation}deg)`,opacity:o.opacity},className:Pe("absolute cursor-move select-none transition-shadow rounded p-1.5 flex items-center justify-center",C?"ring-2 ring-primary ring-offset-2 ring-offset-background/80 bg-primary/10":"hover:ring-1 hover:ring-muted-foreground/50"),children:o.type==="text"?a("span",{style:{fontSize:`${h}px`,color:o.color,lineHeight:1,whiteSpace:"nowrap",fontWeight:700,textShadow:"0 1px 3px rgba(0,0,0,0.5)"},children:o.text||"Text"}):a("div",{style:{width:`${h}px`,height:`${h}px`},className:"bg-primary/20 border border-primary/40 rounded flex items-center justify-center p-1 overflow-hidden",children:O[o.id]||o.imageAssetUrl?a("img",{src:O[o.id]||o.imageAssetUrl,alt:"Watermark logo",className:"w-full h-full object-contain pointer-events-none"}):a(Do,{className:"h-1/2 w-1/2 opacity-70 text-primary"})})},o.id)})})})()})]}),g("div",{className:"w-[35%] flex flex-col bg-card overflow-hidden border-l border-border",children:[a("div",{className:"p-4 border-b border-border bg-muted/10 flex items-center justify-between",children:g("div",{className:"flex items-center gap-2",children:[a(No,{className:"h-4 w-4 text-muted-foreground"}),a("span",{className:"text-xs font-semibold",children:Ly()})]})}),g("div",{className:"p-3 border-b border-border bg-background flex items-center justify-between gap-2",children:[g("div",{className:"flex items-center gap-1",children:[a(F,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:l.length<=1,onClick:ft,children:a(On,{className:"h-4 w-4"})}),g(De,{modal:!1,children:[a(Ne,{asChild:!0,children:a(F,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs font-mono",children:l.length===0?"0 / 0":`${u+1} / ${l.length}`})}),a(Fe,{align:"start",className:"w-48",children:l.map((e,i)=>g(de,{onClick:()=>p(e.id),className:"text-xs flex items-center justify-between cursor-pointer",children:[g("span",{className:"flex items-center gap-2 truncate",children:[e.type==="text"?a(tc,{className:"h-3.5 w-3.5 text-muted-foreground"}):a(Do,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.type==="text"?e.text||"Text":e.imageAssetKey||"Image"]}),g("span",{className:"text-[10px] font-mono text-muted-foreground ml-2",children:["#",i+1]})]},e.id))})]}),a(F,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:l.length<=1,onClick:gt,children:a(jt,{className:"h-4 w-4"})})]}),g("div",{className:"flex items-center gap-1",children:[n&&a(F,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10",title:Mt(),onClick:()=>nt(n.id),children:a(Ue,{className:"h-4 w-4"})}),g(De,{modal:!1,children:[a(Ne,{asChild:!0,children:g(F,{size:"sm",className:"h-7 text-xs gap-1",children:[a(Re,{className:"h-3.5 w-3.5"}),jm()]})}),g(Fe,{align:"end",children:[g(de,{onClick:Be,className:"text-xs gap-2 cursor-pointer",children:[a(tc,{className:"h-3.5 w-3.5"}),$m()]}),g(de,{onClick:pt,className:"text-xs gap-2 cursor-pointer",children:[a(Do,{className:"h-3.5 w-3.5"}),wA()]})]})]})]})]}),a(Ie,{className:"flex-1 min-h-0 p-4",children:n?g("div",{className:"space-y-5 text-xs",children:[g("div",{className:"flex items-center justify-between pb-2 border-b border-border",children:[g("span",{className:"font-semibold text-muted-foreground flex items-center gap-1.5",children:[n.type==="text"?a(tc,{className:"h-4 w-4 text-primary"}):a(Do,{className:"h-4 w-4 text-primary"}),n.type==="text"?$m():wA()]}),g("span",{className:"text-[10px] font-mono text-muted-foreground",children:["ID: ",n.id.slice(0,6)]})]}),n.type==="text"&&g("div",{className:"space-y-2",children:[a(fe,{className:"text-xs",children:GM()}),a(re,{type:"text",value:n.text,onChange:(e)=>I(n.id,{text:e.target.value}),className:"text-xs h-8"})]}),n.type==="image"&&g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:mS()}),n.imageAssetKey&&g("button",{type:"button",onClick:()=>I(n.id,{imageAssetKey:"",imageAssetUrl:void 0}),className:"text-xs text-muted-foreground hover:text-destructive flex items-center gap-1 font-medium transition-colors cursor-pointer",children:[a(Ge,{className:"w-3.5 h-3.5"}),Jc?Jc():"Remove"]})]}),a("input",{type:"file",ref:ae,className:"hidden",accept:"image/*",onChange:(e)=>we(e,n.id)}),g("div",{onClick:()=>ae.current?.click(),className:"relative aspect-square w-full rounded-xl border border-dashed border-border flex items-center justify-center cursor-pointer overflow-hidden group shadow-inner bg-muted/20 hover:border-primary/50 hover:bg-muted/40 transition-all p-2",children:[Ee&&a("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-xs flex flex-col items-center justify-center gap-2 z-20",children:g("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-background border rounded-full shadow-lg",children:[a(K,{className:"w-4 h-4 animate-spin text-primary"}),a("span",{className:"text-xs font-semibold",children:tu()})]})}),O[n.id]||n.imageAssetUrl?g(W,{children:[a("img",{src:O[n.id]||n.imageAssetUrl,alt:"Uploaded logo preview",className:"max-w-full max-h-full object-contain transition-transform duration-300 group-hover:scale-105"}),g("div",{className:"absolute inset-0 bg-black/45 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col items-center justify-center gap-1 text-white z-10",children:[a(zo,{className:"w-5 h-5 transform translate-y-1 group-hover:translate-y-0 transition-transform duration-300"}),a("span",{className:"text-xs font-semibold",children:_g()})]})]}):g("div",{className:"flex flex-col items-center gap-1.5 text-center p-3",children:[a("div",{className:"p-2 rounded-full bg-background border shadow-xs group-hover:scale-110 transition-transform duration-300",children:a(zo,{className:"w-4 h-4 text-muted-foreground"})}),g("div",{children:[a("p",{className:"text-xs font-medium text-foreground",children:NO()}),a("p",{className:"text-[10px] text-muted-foreground mt-0.5 max-w-[150px] mx-auto leading-normal",children:FO()})]})]})]})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:n.type==="text"?CC():gS()}),g("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(n.size*100),"%"]})]}),g("div",{className:"flex items-center gap-3",children:[a(_s,{min:n.type==="text"?0.01:0.02,max:n.type==="text"?0.12:0.5,step:0.005,value:[n.size],onValueChange:([e])=>I(n.id,{size:e}),className:"flex-1"}),a(re,{type:"number",min:1,max:100,value:Math.round(n.size*100),onChange:(e)=>I(n.id,{size:Math.min(1,Math.max(0.001,Number(e.target.value)/100))}),className:"w-16 h-7 text-xs font-mono text-right"})]})]}),n.type==="text"&&g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Bw()}),a("span",{className:"font-mono text-[11px] text-muted-foreground uppercase",children:n.color})]}),g("div",{className:"flex items-center gap-2",children:[a("input",{type:"color",value:n.color,onChange:(e)=>I(n.id,{color:e.target.value}),className:"w-8 h-8 rounded border border-border cursor-pointer bg-transparent p-0"}),a(re,{type:"text",value:n.color,onChange:(e)=>I(n.id,{color:e.target.value}),className:"flex-1 h-8 text-xs font-mono"})]}),a("div",{className:"flex items-center gap-1.5 pt-1",children:["#FFFFFF","#000000","#999999","#EF4444","#3B82F6","#10B981","#F59E0B"].map((e)=>a("button",{type:"button",onClick:()=>I(n.id,{color:e}),style:{backgroundColor:e},className:"w-5 h-5 rounded-full border border-border hover:scale-110 transition-transform"},e))})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:DT()}),g("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(n.opacity*100),"%"]})]}),a(_s,{min:0,max:1,step:0.01,value:[n.opacity],onValueChange:([e])=>I(n.id,{opacity:e})})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Uk()}),g("span",{className:"font-mono text-[11px] text-muted-foreground",children:[n.rotation,"°"]})]}),a(_s,{min:-180,max:180,step:1,value:[n.rotation],onValueChange:([e])=>I(n.id,{rotation:e})}),a("div",{className:"flex items-center gap-1.5 pt-1",children:[-45,-30,0,30,45].map((e)=>g(F,{variant:"outline",size:"sm",className:"h-6 text-[10px] flex-1 px-1 font-mono",onClick:()=>I(n.id,{rotation:e}),children:[e,"°"]},e))})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:_1()}),g("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(n.x*100),"%"]})]}),a(_s,{min:0,max:1,step:0.01,value:[n.x],onValueChange:([e])=>I(n.id,{x:e})})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:y1()}),g("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(n.y*100),"%"]})]}),a(_s,{min:0,max:1,step:0.01,value:[n.y],onValueChange:([e])=>I(n.id,{y:e})})]})]}):g("div",{className:"py-12 text-center text-xs text-muted-foreground space-y-3",children:[a("p",{children:oR()}),g(F,{size:"sm",variant:"outline",onClick:Be,children:[a(Re,{className:"h-3.5 w-3.5 mr-1"}),$m()]})]})})]})]})]})}),a(Se,{open:ge,onOpenChange:U,children:g(xe,{className:"max-w-md",children:[a(ke,{children:a(Ce,{className:"text-sm font-semibold",children:ne==="new"?c_():b0()})}),a("div",{className:"py-3 space-y-4 text-xs",children:ne==="new"?g("div",{className:"space-y-2",children:[a(fe,{children:qM()}),a(re,{type:"text",value:se,onChange:(e)=>V(e.target.value),placeholder:x_(),className:"text-xs"})]}):g("div",{className:"space-y-2",children:[a(fe,{children:iy()}),a("select",{value:H||"",onChange:(e)=>Y(e.target.value),className:"w-full h-9 rounded-md border border-input bg-background px-3 text-xs",children:T.map((e)=>a("option",{value:e.id,children:e.name},e.id))})]})}),g(ot,{children:[a(F,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>U(!1),children:Ve()}),a(F,{size:"sm",className:"text-xs",disabled:Le||Oe,onClick:wt,children:Xa()})]})]})})]})}function Pe(...t){return t.filter(Boolean).join(" ")}L();function ut({shareLink:t,viewMode:b,onViewModeChange:f,defaultSortOrder:m,onSortOrderChange:y}){let x=ie(),[D,l]=w(t.password||""),[v,d]=w(t.expireAt?new Date(t.expireAt):void 0),[p,B]=w(!1);S(()=>{l(t.password||"")},[t.password]);let[E,N]=w(t.hasPassword),[oe,le]=w(!!t.expireAt),{data:ce,refetch:ge}=X({queryKey:["share-watermark",t.id],queryFn:async()=>{let s=await R.api.shares[":shareId"].watermark.$get({param:{shareId:t.id}});if(!s.ok)return null;return await s.json()},refetchInterval:(s)=>(s.state.data?.watermarkStatus||t.watermarkStatus)==="processing"?3000:!1}),U=R.api.shares[":shareId"].watermark.$put,{mutate:ne}=ee({mutationFn:async()=>{let s=await U({param:{shareId:t.id},json:{enabled:!1}});if(!s.ok)throw Error(pa());return await s.json()},onSuccess:()=>{x.invalidateQueries({queryKey:["shares",t.projectId]}),x.invalidateQueries({queryKey:["share",t.id]}),x.invalidateQueries({queryKey:["share-watermark",t.id]}),j.success(QO())}}),te=ce?.watermarkStatus??t.watermarkStatus??(t.watermarkConfigId?"ready":"disabled"),se=ce?.watermarkConfig?.config??t.watermarkConfig?.config??null,V=se!==null&&te!=="disabled",{data:H}=X({queryKey:["fields",t.projectId],queryFn:async()=>{let s=await R.api.projects[":projectId"].fields.$get({param:{projectId:t.projectId}});if(!s.ok)throw Error(Nx());return await s.json()},enabled:!!t.projectId}),Y=R.api.shares[":shareId"].$put,{mutate:k}=ee({mutationFn:async(s)=>{let q=await Y({param:{shareId:t.id},json:s});if(!q.ok)throw Error(pa());return await q.json()},onSuccess:()=>{x.invalidateQueries({queryKey:["shares",t.projectId]}),x.invalidateQueries({queryKey:["share",t.id]}),j.success(ql())}}),J=`${window.location.origin}/share/${t.id}`,Z=async(s)=>{if(await jo(s))j.success(tE())},ve=(s)=>{let q=t.fieldVisibility||{},me={...q,[s]:!q[s]};k({fieldVisibility:me})},_="index",A="asc";if(m){let s=m.split(":");_=s[0],A=s[1]||"asc"}return g("div",{className:"flex flex-col h-full bg-background border-l border-border",children:[a("div",{className:"flex-1 overflow-y-auto",children:g("div",{className:"p-4 space-y-6",children:[g("div",{className:"space-y-4",children:[g("div",{className:"flex items-center justify-between",children:[a("h3",{className:"text-sm font-medium",children:OS()}),a(Ke,{checked:!t.isDisabled,onCheckedChange:(s)=>k({isDisabled:!s})})]}),g("div",{className:"relative w-full",children:[a(re,{value:J,readOnly:!0,className:"pr-10 bg-muted/50 text-xs"}),a(F,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full",onClick:()=>Z(J),children:a(Br,{className:"h-4 w-4"})})]})]}),g("div",{className:"space-y-1",children:[a(je,{title:tR(),icon:a(au,{className:"h-4 w-4"}),children:g("div",{className:"p-3 space-y-4 pt-2",children:[g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Lh()}),a(Ke,{checked:E,onCheckedChange:(s)=>{if(N(s),!s)k({password:null})}})]}),E&&g("div",{className:"flex gap-2 animate-in fade-in slide-in-from-top-1 duration-200",children:[a(re,{type:"text",value:D,onChange:(s)=>l(s.target.value),placeholder:xx(),className:"text-xs"}),a(F,{size:"sm",onClick:()=>k({password:D}),children:wo()})]})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Mx()}),a(Ke,{checked:oe,onCheckedChange:(s)=>{if(le(s),!s)d(void 0),k({expireAt:null})}})]}),oe&&a("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:a(_a,{value:v,onChange:(s)=>{d(s),k({expireAt:s?s.toISOString():null})},className:"text-xs"})})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Mb()}),a(Ke,{checked:t.allowDownload,onCheckedChange:(s)=>k({allowDownload:s})})]}),a("p",{className:"text-xs text-muted-foreground",children:Ob()})]}),g("div",{className:"space-y-2 pt-2 border-t border-border/50",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Ly()}),a(Ke,{checked:V,disabled:te==="processing",onCheckedChange:(s)=>{if(!s)ne();else B(!0)}})]}),V&&te==="processing"&&g("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 font-medium py-1 animate-pulse",children:[a(K,{className:"h-3.5 w-3.5 animate-spin"}),a("span",{children:KO()})]}),V&&te!=="processing"&&a(F,{variant:"outline",size:"sm",className:"w-full text-xs gap-1.5 mt-1",onClick:()=>B(!0),children:cx()})]})]})}),a(je,{title:Qm(),icon:a(iu,{className:"h-4 w-4"}),children:g("div",{className:"p-3 space-y-3 pt-2 flex gap-2",children:[g(F,{variant:b==="card"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>f("card"),children:[a(No,{className:"h-4 w-4"}),XC()]}),g(F,{variant:b==="list"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>f("list"),children:[a(ps,{className:"h-4 w-4"}),DS()]})]})}),a(je,{title:Zl(),icon:a(lt,{className:"h-4 w-4"}),children:a("div",{className:"p-3 space-y-3 pt-2",children:H?.map((s)=>g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:s.config?.name}),a(Ke,{checked:t.fieldVisibility?.[s.id]??!1,onCheckedChange:()=>ve(s.id)})]},s.id))})}),a(je,{title:Yc(),icon:a(mu,{className:"h-4 w-4"}),children:g("div",{className:"p-3 space-y-4 pt-2",children:[g("div",{className:"space-y-2",children:[a(fe,{className:"text-xs text-muted-foreground",children:uh()}),g(Xe,{value:_,onValueChange:(s)=>{if(s==="index")y(null);else y(`${s}:${A}`)},children:[a(tt,{className:"w-full text-xs h-9",children:a(et,{})}),g(rt,{children:[a(be,{value:"index",children:sg()}),a(be,{value:"name",children:Xc()}),a(be,{value:"createdAt",children:ig()}),a(be,{value:"size",children:lg()})]})]})]}),g("div",{className:"space-y-2",children:[a(fe,{className:"text-xs text-muted-foreground",children:Fh()}),g(F,{variant:"outline",className:"w-full justify-between font-normal text-xs h-9",disabled:_==="index",onClick:()=>{y(`${_}:${A==="asc"?"desc":"asc"}`)},children:[a("span",{children:_==="name"?A==="asc"?Sd():kd():_==="createdAt"?A==="asc"?Td():Id():_==="size"?A==="asc"?cg():ag():A==="asc"?Gm():nh()}),a(Bd,{className:"h-4 w-4 opacity-50"})]})]})]})})]})]})}),g("div",{className:"p-4 border-t border-border space-y-2",children:[g(F,{variant:"outline",className:"w-full justify-center",onClick:()=>window.open(J,"_blank"),children:[a(fu,{className:"h-4 w-4 mr-2"}),FT()]}),g(F,{className:"w-full justify-center bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>Z(J),children:[a(Br,{className:"h-4 w-4 mr-2"}),nE()]})]}),a(mt,{open:p,onOpenChange:B,initialConfig:se,shareId:t.id,onSaveSuccess:()=>{ge(),x.invalidateQueries({queryKey:["share",t.id]}),x.invalidateQueries({queryKey:["shares",t.projectId]})}})]})}function je({title:t,icon:b,children:f}){let[m,y]=w(!1);return g("div",{className:"border-b border-border last:border-0",children:[g("button",{onClick:()=>y(!m),className:"w-full flex items-center justify-between py-3 px-2 hover:bg-muted/50 transition-colors",children:[g("div",{className:"flex items-center gap-3",children:[b,a("span",{className:"text-sm font-medium",children:t})]}),a(jt,{className:_t("h-4 w-4 transition-transform",m&&"rotate-90")})]}),m&&f&&a("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:f})]})}function _t(...t){return t.filter(Boolean).join(" ")}function st({teamId:t,projectId:b,projectName:f,shareId:m,rootFolderId:y}){let x=ie(),{fetchMetadata:D}=Lr();S(()=>{if(t)D(t)},[t,D]);let{data:l}=X({queryKey:["share",m],queryFn:async()=>{let r=await R.api.shares[":shareId"].$get({param:{shareId:m}});if(!r.ok)throw Error(Zx());return await r.json()}}),v=l?.rootFolderId,[d,p]=w(null),[B,E]=w([]);S(()=>{if(v)p(v),E([]),T(new Set)},[v,m]);let N=Bn((r)=>r.setProjectState),oe=Bn((r)=>r.clearProjectState),le=(r)=>{if(r===d)return;if(r===v)p(v),E([]);else{let c=B.findIndex((u)=>u.id===r);if(c!==-1)p(r),E(B.slice(c+1))}T(new Set)},[ce,ge]=w(240),[U,ne]=w(360),{shareConfigLeftSidebarCollapsed:te,shareConfigRightSidebarCollapsed:se}=lr(),V=l?.defaultSortOrder||null,H,Y;if(V){let r=V.split(":");H=r[0],Y=r[1]}let k=l?.viewMode??"card",{data:J,fetchNextPage:Z,hasNextPage:ve,isFetchingNextPage:_,isLoading:A}=Tt({queryKey:["folder-children",t,d,"folder",H,Y],queryFn:async({pageParam:r})=>{let c=await R.api.folders[":folderId"].children.$get({param:{folderId:d},query:{assetType:"folder",after:r,sort:H,order:Y}});if(!c.ok)throw Error(Lx());return await c.json()},enabled:!!d,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),{data:s,fetchNextPage:q,hasNextPage:me,isFetchingNextPage:Ee,isLoading:ye}=Tt({queryKey:["folder-children",t,d,"file",H,Y],queryFn:async({pageParam:r})=>{let c=await R.api.folders[":folderId"].children.$get({param:{folderId:d},query:{assetType:"file",after:r,sort:H,order:Y}});if(!c.ok)throw Error(Fx());return await c.json()},enabled:!!d,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),O=Q(()=>J?.pages.flatMap((r)=>r.data??[])??[],[J]),he=Q(()=>s?.pages.flatMap((r)=>r.data??[])??[],[s]);S(()=>{if(l)N({teamId:t,projectId:b,projectName:f,ancestorFolders:B,currentAsset:{name:d===v?l.name:O.find((r)=>r.id===d)?.name||l.name,type:"folder"},isRootFolder:!1,shareId:m,onFolderClick:le});return()=>oe()},[t,b,f,B,d,v,l,m,O,N,oe]);let[ae,ue]=w(null),[we,T]=w(new Set),_e=()=>{T(new Set),ue(null)},{dragState:pe,handleDragStart:Ae,handleDragEnd:We}=uu({teamId:t,projectId:b,assetId:d||"",folders:O,files:he,selectedIds:we,onClearSelection:_e}),ze=R.api.shares[":shareId"].assets[":assetId"].$delete,{mutate:Le}=ee({mutationFn:async(r)=>{if(!(await ze({param:{shareId:m,assetId:r}})).ok)throw Error(Bx())},onSuccess:()=>{x.invalidateQueries({queryKey:["folder-children",t,d]}),j.success(kk())}}),$e=R.api.shares[":shareId"].$put,{mutate:Me}=ee({mutationFn:async(r)=>{let c=await $e({param:{shareId:m},json:r});if(!c.ok)throw Error(pa());return await c.json()},onSuccess:()=>{x.invalidateQueries({queryKey:["share",m]}),j.success(ql())}}),Oe=(r)=>{if(r.type==="folder"||r.targetType==="folder"){let c=d===v?l?.name||"":O.find((u)=>u.id===d)?.name||Yn();E((u)=>[{id:d,name:c},...u]),p(r.id),T(new Set)}};if(!l)return a("div",{children:bp()});return g(Eo,{modifiers:[al.configure({anchor:{x:0,y:0}})],sensors:[Xn.configure({activationConstraints:[new an.Distance({value:10})]})],onDragStart:Ae,onDragEnd:We,children:[a("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:g("div",{className:"flex flex-1 overflow-hidden relative",children:[!te&&g(W,{children:[a("div",{className:"bg-background",style:{width:ce},children:a($r,{teamId:t,projectId:b,projectName:f,rootFolderId:y,dragState:pe})}),a(Yr,{onResize:(r)=>ge((c)=>Math.max(180,Math.min(400,c+r)))})]}),a(Ea,{teamId:t,projectId:b,assetId:d||"",folders:O,files:he,selectedItem:ae,selectedIds:we,onItemSelect:(r,c)=>{if(c.metaKey||c.ctrlKey){let u=new Set(we);if(u.has(r.id)){if(u.delete(r.id),T(u),ae?.id===r.id){let n=[...O,...he].find((Be)=>u.has(Be.id));ue(n||null)}}else u.add(r.id),T(u),ue(r)}else T(new Set([r.id])),ue(r)},onItemDoubleClick:Oe,onSaveField:()=>{},displayStyle:k,onClearSelection:_e,fetchNextFoldersPage:Z,hasNextFoldersPage:ve,isFetchingNextFoldersPage:_,fetchNextFilesPage:q,hasNextFilesPage:me,isFetchingNextFilesPage:Ee,isLoading:A||ye,filterConditions:[],onFilterChange:()=>{},dragState:pe,isShareView:!0,onRemoveFromShare:(r)=>{r.forEach((c)=>Le(c.id))},fieldVisibility:l.fieldVisibility}),!se&&g(W,{children:[a(Yr,{onResize:(r)=>ne((c)=>Math.max(240,Math.min(600,c-r)))}),a("div",{style:{width:U},className:"flex-shrink-0 h-full",children:a(ut,{shareLink:l,viewMode:k,onViewModeChange:(r)=>Me({viewMode:r}),defaultSortOrder:V,onSortOrderChange:(r)=>Me({defaultSortOrder:r})})})]})]})}),a(Md,{children:pe?.isActive?a("div",{className:"flex items-center gap-2 rounded-md bg-popover px-3 py-2 text-sm font-medium shadow-md",children:LI({count:pe.itemCount})}):null})]})}L();function It(){let{projectId:t,shareId:b}=Ct.useParams(),{teamId:f,ensureTeamIdForProject:m}=Pt();S(()=>{m(t)},[t,m]);let{data:y}=Ar(Og(t)),x=y?.rootFolder,{data:D}=X({queryKey:["folders",x],queryFn:async()=>{let l=await R.api.folders[":folderId"].$get({param:{folderId:x}});if(!l.ok)throw Error("Failed to fetch folder");return await l.json()},enabled:!!x});if(!f||!x||!D)return a(qt,{});return a(st,{teamId:f,projectId:t,projectName:y.name??"",shareId:b,rootFolderId:x})}var Ct=Je("/projects/$projectId/shares/$shareId")({component:It});export{Ct as Route};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Yt}from"./chunk-
|
|
2
|
+
import{Yt}from"./chunk-r6t0j0jx.js";import{at}from"./chunk-vnmggrd6.js";import{se}from"./chunk-4p31kxjh.js";var f=se(at());var N=se(at());var m=se(Yt()),l=se(at());var E=se(Yt()),d=se(at()),P=(e,t,r)=>{let o={EcsContainer:async(s)=>{let{fromHttp:i}=await import("./chunk-npeapp7e.js"),{fromContainerMetadata:n}=await import("./chunk-mn0kt3p6.js");return r?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer"),async()=>d.chain(i(s??{}),n(s))().then(_)},Ec2InstanceMetadata:async(s)=>{r?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");let{fromInstanceMetadata:i}=await import("./chunk-mn0kt3p6.js");return async()=>i(s)().then(_)},Environment:async(s)=>{r?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");let{fromEnv:i}=await import("./chunk-q4ny4hpt.js");return async()=>i(s)().then(_)}};if(e in o)return o[e];else throw new d.CredentialsProviderError(`Unsupported credential source in profile ${t}. Got ${e}, expected EcsContainer or Ec2InstanceMetadata or Environment.`,{logger:r})},_=(e)=>E.setCredentialFeature(e,"CREDENTIALS_PROFILE_NAMED_PROVIDER","p");var v=(e,{profile:t="default",logger:r}={})=>Boolean(e)&&typeof e==="object"&&typeof e.role_arn==="string"&&["undefined","string"].indexOf(typeof e.role_session_name)>-1&&["undefined","string"].indexOf(typeof e.external_id)>-1&&["undefined","string"].indexOf(typeof e.mfa_serial)>-1&&(K(e,{profile:t,logger:r})||G(e,{profile:t,logger:r})),K=(e,{profile:t,logger:r})=>{let o=typeof e.source_profile==="string"&&typeof e.credential_source>"u";if(o)r?.debug?.(` ${t} isAssumeRoleWithSourceProfile source_profile=${e.source_profile}`);return o},G=(e,{profile:t,logger:r})=>{let o=typeof e.credential_source==="string"&&typeof e.source_profile>"u";if(o)r?.debug?.(` ${t} isCredentialSourceProfile credential_source=${e.credential_source}`);return o},I=async(e,t,r,o,s={},i)=>{r.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");let n=t[e],{source_profile:a,region:j}=n;if(!r.roleAssumer){let{getDefaultRoleAssumer:c}=await import("./chunk-3vpz5nat.js");r.roleAssumer=c({...r.clientConfig,credentialProviderLogger:r.logger,parentClientConfig:{...o,...r?.parentClientConfig,region:j??r?.parentClientConfig?.region??o?.region}},r.clientPlugins)}if(a&&a in s)throw new l.CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${l.getProfileName(r)}. Profiles visited: `+Object.keys(s).join(", "),{logger:r.logger});r.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${a?`source_profile=[${a}]`:`profile=[${e}]`}`);let w=a?i(a,t,r,o,{...s,[a]:!0},S(t[a]??{})):(await P(n.credential_source,e,r.logger)(r))();if(S(n))return w.then((c)=>m.setCredentialFeature(c,"CREDENTIALS_PROFILE_SOURCE_PROFILE","o"));else{let c={RoleArn:n.role_arn,RoleSessionName:n.role_session_name||`aws-sdk-js-${Date.now()}`,ExternalId:n.external_id,DurationSeconds:parseInt(n.duration_seconds||"3600",10)},{mfa_serial:u}=n;if(u){if(!r.mfaCodeProvider)throw new l.CredentialsProviderError(`Profile ${e} requires multi-factor authentication, but no MFA code callback was provided.`,{logger:r.logger,tryNextLink:!1});c.SerialNumber=u,c.TokenCode=await r.mfaCodeProvider(u)}let M=await w;return r.roleAssumer(M,c).then((B)=>m.setCredentialFeature(B,"CREDENTIALS_PROFILE_SOURCE_PROFILE","o"))}},S=(e)=>!e.role_arn&&!!e.credential_source;var R=se(Yt()),A=(e)=>Boolean(e&&e.login_session),L=async(e,t,r)=>{let{fromLoginCredentials:o}=await import("./chunk-09mj32d7.js"),s=await o({...t,profile:e})({callerClientConfig:r});return R.setCredentialFeature(s,"CREDENTIALS_PROFILE_LOGIN","AC")};var O=se(Yt()),b=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.credential_process==="string",x=async(e,t)=>{let{fromProcess:r}=await import("./chunk-95b4mwyq.js"),o=await r({...e,profile:t})();return O.setCredentialFeature(o,"CREDENTIALS_PROFILE_PROCESS","v")};var p=se(Yt()),k=async(e,t,r={},o)=>{let{fromSSO:s}=await import("./chunk-s74g9vsk.js");return s({profile:e,logger:r.logger,parentClientConfig:r.parentClientConfig,clientConfig:r.clientConfig})({callerClientConfig:o}).then((i)=>{if(t.sso_session)return p.setCredentialFeature(i,"CREDENTIALS_PROFILE_SSO","r");else return p.setCredentialFeature(i,"CREDENTIALS_PROFILE_SSO_LEGACY","t")})},F=(e)=>e&&(typeof e.sso_start_url==="string"||typeof e.sso_account_id==="string"||typeof e.sso_session==="string"||typeof e.sso_region==="string"||typeof e.sso_role_name==="string");var h=se(Yt()),C=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.aws_access_key_id==="string"&&typeof e.aws_secret_access_key==="string"&&["undefined","string"].indexOf(typeof e.aws_session_token)>-1&&["undefined","string"].indexOf(typeof e.aws_account_id)>-1,y=async(e,t)=>{t?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");let r={accessKeyId:e.aws_access_key_id,secretAccessKey:e.aws_secret_access_key,sessionToken:e.aws_session_token,...e.aws_credential_scope&&{credentialScope:e.aws_credential_scope},...e.aws_account_id&&{accountId:e.aws_account_id}};return h.setCredentialFeature(r,"CREDENTIALS_PROFILE","n")};var D=se(Yt()),T=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.web_identity_token_file==="string"&&typeof e.role_arn==="string"&&["undefined","string"].indexOf(typeof e.role_session_name)>-1,W=async(e,t,r)=>{let{fromTokenFile:o}=await import("./chunk-gyv3yrhj.js"),s=await o({webIdentityTokenFile:e.web_identity_token_file,roleArn:e.role_arn,roleSessionName:e.role_session_name,roleAssumerWithWebIdentity:t.roleAssumerWithWebIdentity,logger:t.logger,parentClientConfig:t.parentClientConfig})({callerClientConfig:r});return D.setCredentialFeature(s,"CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN","q")};var g=async(e,t,r,o,s={},i=!1)=>{let n=t[e];if(Object.keys(s).length>0&&C(n))return y(n,r);if(i||v(n,{profile:e,logger:r.logger}))return I(e,t,r,o,s,g);if(C(n))return y(n,r);if(T(n))return W(n,r,o);if(b(n))return x(r,e);if(F(n))return await k(e,n,r,o);if(A(n))return L(e,r,o);throw new N.CredentialsProviderError(`Could not resolve credentials using profile: [${e}] in configuration/credentials file(s).`,{logger:r.logger})};var U=(e={})=>async({callerClientConfig:t}={})=>{e.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");let r=await f.parseKnownFiles(e);return g(f.getProfileName({profile:e.profile??t?.profile}),r,e,t)};export{U as fromIni};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ae}from"./chunk-
|
|
2
|
+
import{ae}from"./chunk-4p31kxjh.js";var n=null;function c(e){if(typeof process>"u"||!process.versions?.bun||Object.keys(process.env).length>0)return;if(n===null){n=new Map;try{let{readFileSync:t}=ae("fs"),s=t("/proc/self/environ","utf-8");for(let r of s.split("\x00")){let o=r.indexOf("=");if(o>0)n.set(r.slice(0,o),r.slice(o+1))}}catch{}}return n.get(e)}function kr(e,t){return t?.[e]||(typeof process<"u"?process.env[e]:void 0)||c(e)||void 0}
|
|
3
3
|
export{kr};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{at,
|
|
2
|
+
import{at,ir}from"./chunk-vnmggrd6.js";import{se}from"./chunk-4p31kxjh.js";var _=se(at());var N=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.AccessKeyId==="string"&&typeof e.SecretAccessKey==="string"&&typeof e.Token==="string"&&typeof e.Expiration==="string",h=(e)=>({accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretAccessKey,sessionToken:e.Token,expiration:new Date(e.Expiration),...e.AccountId&&{accountId:e.AccountId}});var C=({maxRetries:e=0,timeout:t=1000})=>({maxRetries:e,timeout:t});var v=se(at());import R from"http";function E(e){return new Promise((t,n)=>{let o=R.request({method:"GET",...e,hostname:e.hostname?.replace(/^\[(.+)\]$/,"$1")});o.on("error",(r)=>{n(Object.assign(new v.ProviderError("Unable to connect to instance metadata service"),r)),o.destroy()}),o.on("timeout",()=>{n(new v.ProviderError("TimeoutError from instance metadata service")),o.destroy()}),o.on("response",(r)=>{let{statusCode:a=400}=r;if(a<200||300<=a)n(Object.assign(new v.ProviderError("Error response received from instance metadata service"),{statusCode:a})),o.destroy();let p=[];r.on("data",(s)=>{p.push(s)}),r.on("end",()=>{t(Buffer.concat(p)),o.destroy()})}),o.end()})}var T=(e,t)=>{let n=e();for(let o=0;o<t;o++)n=n.catch(e);return n};var A="AWS_CONTAINER_CREDENTIALS_FULL_URI",g="AWS_CONTAINER_CREDENTIALS_RELATIVE_URI",D="AWS_CONTAINER_AUTHORIZATION_TOKEN",G=(e={})=>{let{timeout:t,maxRetries:n}=C(e);return()=>T(async()=>{let o=await J({logger:e.logger}),r=JSON.parse(await H(t,o));if(!N(r))throw new _.CredentialsProviderError("Invalid response received from instance metadata service.",{logger:e.logger});return h(r)},n)},H=async(e,t)=>{if(process.env[D])t.headers={...t.headers,Authorization:process.env[D]};return(await E({...t,timeout:e})).toString()},q="169.254.170.2",Y=new Set(["localhost","127.0.0.1"]),j=new Set(["http:","https:"]),J=async({logger:e})=>{if(process.env[g])return{hostname:q,path:process.env[g]};if(process.env[A]){let t;try{t=new URL(process.env[A])}catch{throw new _.CredentialsProviderError(`${process.env[A]} is not a valid container metadata service URL`,{tryNextLink:!1,logger:e})}if(!t.hostname||!Y.has(t.hostname))throw new _.CredentialsProviderError(`${t.hostname} is not a valid container metadata service hostname`,{tryNextLink:!1,logger:e});if(!t.protocol||!j.has(t.protocol))throw new _.CredentialsProviderError(`${t.protocol} is not a valid container metadata service protocol`,{tryNextLink:!1,logger:e});return{protocol:t.protocol,hostname:t.hostname,path:t.pathname+t.search,port:t.port?parseInt(t.port,10):void 0}}throw new _.CredentialsProviderError(`The container metadata credential provider cannot be used unless the ${g} or ${A} environment variable is set`,{tryNextLink:!1,logger:e})};var u=se(at());var y=se(at());class O extends y.CredentialsProviderError{tryNextLink;name="InstanceMetadataV1FallbackError";constructor(e,t=!0){super(e,t);this.tryNextLink=t,Object.setPrototypeOf(this,O.prototype)}}var w=se(at()),F=se(ir());var S;(function(e){e.IPv4="http://169.254.169.254",e.IPv6="http://[fd00:ec2::254]"})(S||(S={}));var P={environmentVariableSelector:(e)=>e.AWS_EC2_METADATA_SERVICE_ENDPOINT,configFileSelector:(e)=>e.ec2_metadata_service_endpoint,default:void 0};var l;(function(e){e.IPv4="IPv4",e.IPv6="IPv6"})(l||(l={}));var X="AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE",z="ec2_metadata_service_endpoint_mode",L={environmentVariableSelector:(e)=>e[X],configFileSelector:(e)=>e[z],default:l.IPv4};var b=async()=>F.parseUrl(await Z()||await Q()),Z=async()=>w.loadConfig(P)(),Q=async()=>{let e=await w.loadConfig(L)();switch(e){case l.IPv4:return S.IPv4;case l.IPv6:return S.IPv6;default:throw Error(`Unsupported endpoint mode: ${e}. Select from ${Object.values(l)}`)}};var M=(e,t)=>{let n=300+Math.floor(Math.random()*300),o=new Date(Date.now()+n*1000);t.warn(`Attempting credential expiration extension due to a credential service availability issue. A refresh of these credentials will be attempted after ${new Date(o)}.
|
|
3
3
|
For more information, please visit: https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html`);let r=e.originalExpiration??e.expiration;return{...e,...r?{originalExpiration:r}:{},expiration:o}};var V=(e,t={})=>{let n=t?.logger||console,o;return async()=>{let r;try{if(r=await e(),r.expiration&&r.expiration.getTime()<Date.now())r=M(r,n)}catch(a){if(o)n.warn("Credential renew failed: ",a),r=M(o,n);else throw a}return o=r,r}};var W="/latest/meta-data/iam/security-credentials/",ee="/latest/api/token",x="AWS_EC2_METADATA_V1_DISABLED",k="ec2_metadata_v1_disabled",U="x-aws-ec2-metadata-token",te=(e={})=>V(oe(e),{logger:e.logger}),oe=(e={})=>{let t=!1,{logger:n,profile:o}=e,{timeout:r,maxRetries:a}=C(e),p=async(s,m)=>{if(t||m.headers?.[U]==null){let i=!1,c=!1,B=await u.loadConfig({environmentVariableSelector:(d)=>{let f=d[x];if(c=!!f&&f!=="false",f===void 0)throw new u.CredentialsProviderError(`${x} not set in env, checking config file next.`,{logger:e.logger});return c},configFileSelector:(d)=>{let f=d[k];return i=!!f&&f!=="false",i},default:!1},{profile:o})();if(e.ec2MetadataV1Disabled||B){let d=[];if(e.ec2MetadataV1Disabled)d.push("credential provider initialization (runtime option ec2MetadataV1Disabled)");if(i)d.push(`config file profile (${k})`);if(c)d.push(`process environment variable (${x})`);throw new O(`AWS EC2 Metadata v1 fallback has been blocked by AWS SDK configuration in the following: [${d.join(", ")}].`)}}let K=(await T(async()=>{let i;try{i=await ne(m)}catch(c){if(c.statusCode===401)t=!1;throw c}return i},s)).trim();return T(async()=>{let i;try{i=await ae(K,m,e)}catch(c){if(c.statusCode===401)t=!1;throw c}return i},s)};return async()=>{let s=await b();if(t)return n?.debug("AWS SDK Instance Metadata","using v1 fallback (no token fetch)"),p(a,{...s,timeout:r});else{let m;try{m=(await re({...s,timeout:r})).toString()}catch(I){if(I?.statusCode===400)throw Object.assign(I,{message:"EC2 Metadata token request returned error"});else if(I.message==="TimeoutError"||[403,404,405].includes(I.statusCode))t=!0;return n?.debug("AWS SDK Instance Metadata","using v1 fallback (initial)"),p(a,{...s,timeout:r})}return p(a,{...s,headers:{[U]:m},timeout:r})}}},re=async(e)=>E({...e,path:ee,method:"PUT",headers:{"x-aws-ec2-metadata-token-ttl-seconds":"21600"}}),ne=async(e)=>(await E({...e,path:W})).toString(),ae=async(e,t,n)=>{let o=JSON.parse((await E({...t,path:W+e})).toString());if(!N(o))throw new u.CredentialsProviderError("Invalid response received from instance metadata service.",{logger:n.logger});return h(o)};export{A as ENV_CMDS_FULL_URI,g as ENV_CMDS_RELATIVE_URI,G as fromContainerMetadata,te as fromInstanceMetadata};
|