@shumai-one/shumai 0.5.3 → 0.6.0

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.
Files changed (135) hide show
  1. package/bin/{chunk-wbmqbpgm.js → chunk-01ym2agz.js} +1 -1
  2. package/bin/{chunk-ncv8v6mj.js → chunk-047n9gfs.js} +2 -2
  3. package/bin/chunk-0a4ahz7r.js +2 -0
  4. package/bin/{chunk-v5hz09a1.js → chunk-0awcpx0a.js} +2 -2
  5. package/bin/{chunk-bcyvxp1c.js → chunk-0fbgfgxv.js} +4 -4
  6. package/bin/{chunk-jt6v15wx.js → chunk-0nnqha4f.js} +1 -1
  7. package/bin/chunk-0tvggyy4.js +1 -0
  8. package/bin/{chunk-s9sf37dv.js → chunk-113baw0m.js} +1 -1
  9. package/bin/{chunk-axeq2pq5.js → chunk-1dbjyarc.js} +1 -1
  10. package/bin/{chunk-d1q1tn36.js → chunk-1qre79kf.js} +1 -1
  11. package/bin/chunk-27v3yepb.js +1 -0
  12. package/bin/{chunk-gvcjqcjf.js → chunk-2rq3w8sg.js} +1 -1
  13. package/bin/{chunk-wperd2h9.js → chunk-3020am4q.js} +1 -1
  14. package/bin/chunk-3pwwg1xm.js +1 -0
  15. package/bin/{chunk-scvepfv8.js → chunk-3sfb63fp.js} +1 -1
  16. package/bin/{chunk-y6xyc4wp.js → chunk-3tg10kwz.js} +1 -1
  17. package/bin/{chunk-hsx4pns6.js → chunk-4g4pxmef.js} +1 -1
  18. package/bin/{chunk-9fyb95r5.js → chunk-4jj92zwa.js} +1 -1
  19. package/bin/{chunk-6pwf7qa6.js → chunk-4yhvexzk.js} +1 -1
  20. package/bin/chunk-58cbk6e8.js +1 -0
  21. package/bin/{chunk-59ayg5am.js → chunk-59t9s2jh.js} +1 -1
  22. package/bin/{chunk-5y3kx4kk.js → chunk-5e7r7a9d.js} +1 -1
  23. package/bin/{chunk-4nkwe7dz.js → chunk-5m51b7af.js} +1 -1
  24. package/bin/{chunk-fnkkwna8.js → chunk-65t6rm5d.js} +1 -1
  25. package/bin/chunk-6bed0rz4.js +1 -0
  26. package/bin/{chunk-w4adkd0a.js → chunk-6smn0q1n.js} +4 -4
  27. package/bin/{chunk-b3tkvdfk.js → chunk-6zerk0em.js} +1 -1
  28. package/bin/{chunk-t6myw0jf.js → chunk-7bbsv8g0.js} +1 -1
  29. package/bin/chunk-83bdgs2c.js +1 -0
  30. package/bin/{chunk-zpk87b33.js → chunk-86qtjd30.js} +5 -5
  31. package/bin/{chunk-b5r0be06.js → chunk-8rekh4h9.js} +1 -1
  32. package/bin/{chunk-68xsb3t8.js → chunk-8s9fehda.js} +1 -1
  33. package/bin/{chunk-srv5kvm4.js → chunk-8sf2hf31.js} +1 -1
  34. package/bin/{chunk-2rrcdhkj.js → chunk-9d3w678j.js} +1 -1
  35. package/bin/{chunk-ppb4aj0y.js → chunk-9gftd4f7.js} +2 -2
  36. package/bin/{chunk-6hs63sva.js → chunk-9rcg8zgs.js} +32 -32
  37. package/bin/{chunk-xfmnfcv2.js → chunk-a23q1kc4.js} +2 -2
  38. package/bin/{chunk-eshwjf91.js → chunk-a6cdt85k.js} +1 -1
  39. package/bin/chunk-a76h3ehe.js +1 -0
  40. package/bin/{chunk-3wcvema0.js → chunk-b1bkd2p4.js} +7 -7
  41. package/bin/{chunk-np39aknv.js → chunk-bf5m8f6t.js} +1 -1
  42. package/bin/{chunk-24nx3krz.js → chunk-cf57fk11.js} +1 -1
  43. package/bin/{chunk-929abwgr.js → chunk-cv5xx81e.js} +1 -1
  44. package/bin/{chunk-fpjvr3qw.js → chunk-czybv3vy.js} +1 -1
  45. package/bin/{chunk-fsr83nb1.js → chunk-d4sbcvpa.js} +1 -1
  46. package/bin/{chunk-b6dbqs39.js → chunk-d6xezgrg.js} +1 -1
  47. package/bin/{chunk-hy5ncvpf.js → chunk-da86fpjt.js} +1 -1
  48. package/bin/{chunk-me3zmpj5.js → chunk-dzjmwat0.js} +7 -7
  49. package/bin/{chunk-909h3qzp.js → chunk-eex8sjfs.js} +1 -1
  50. package/bin/{chunk-qqapw198.js → chunk-emgyjhmx.js} +1 -1
  51. package/bin/{chunk-y5h5d5gx.js → chunk-exmwerag.js} +4 -4
  52. package/bin/{chunk-fznchvm7.js → chunk-f38xyahm.js} +1 -1
  53. package/bin/{chunk-cqnected.js → chunk-fb1bes2h.js} +1 -1
  54. package/bin/chunk-fbvak7q2.js +1 -0
  55. package/bin/{chunk-tqdde9bj.js → chunk-fg9sr6r9.js} +1 -1
  56. package/bin/{chunk-m41tbrvt.js → chunk-fyb6t7ct.js} +2 -2
  57. package/bin/{chunk-cfqny70c.js → chunk-g2ptqqm3.js} +2 -2
  58. package/bin/{chunk-k3ds96cb.js → chunk-ggwqxn95.js} +1 -1
  59. package/bin/chunk-ghk54h71.js +13 -0
  60. package/bin/{chunk-40tmh04g.js → chunk-h1fbev9c.js} +1 -1
  61. package/bin/{chunk-6sq6dfa1.js → chunk-h9akn41s.js} +1 -1
  62. package/bin/{chunk-zq5j9wsc.js → chunk-hdansxny.js} +1 -1
  63. package/bin/{chunk-zsg61vr0.js → chunk-hjwpd09v.js} +1 -1
  64. package/bin/{chunk-03zkxckm.js → chunk-hjzbw975.js} +1 -1
  65. package/bin/{chunk-mzme3m82.js → chunk-j4p3eqtd.js} +1 -1
  66. package/bin/chunk-jtkxeat4.js +2 -0
  67. package/bin/{chunk-5ebb2pdf.js → chunk-jw4g9628.js} +3 -3
  68. package/bin/{chunk-hbnpx0a5.js → chunk-jxebakyq.js} +1 -1
  69. package/bin/{chunk-d1rjpbgv.js → chunk-kfewyax2.js} +1 -1
  70. package/bin/chunk-kk3m4za5.js +1 -0
  71. package/bin/{chunk-24da4wg9.js → chunk-m7tnj47b.js} +1 -1
  72. package/bin/{chunk-b88tdt79.js → chunk-maw5ah8t.js} +2 -2
  73. package/bin/{chunk-hn2g40r6.js → chunk-n0wwtjwv.js} +1 -1
  74. package/bin/{chunk-qcpeefhr.js → chunk-nahdd2t9.js} +1 -1
  75. package/bin/{chunk-fa9yq17g.js → chunk-nv7tztvh.js} +28 -28
  76. package/bin/{chunk-srmx5z3v.js → chunk-nyjwdxyj.js} +2 -2
  77. package/bin/{chunk-t1h12r3q.js → chunk-p0yfxt5e.js} +5 -5
  78. package/bin/{chunk-4bc3gqmn.js → chunk-q27qn367.js} +2 -2
  79. package/bin/{chunk-9ca8a5f2.js → chunk-q36sdt2w.js} +1 -1
  80. package/bin/{chunk-zzbn0b6c.js → chunk-qbj5pe8t.js} +1 -1
  81. package/bin/chunk-qj0bxb1m.js +2 -0
  82. package/bin/{chunk-xdrpahym.js → chunk-qk5hsn6e.js} +1 -1
  83. package/bin/{chunk-qjdvs1s5.js → chunk-qnyqtaf0.js} +1 -1
  84. package/bin/{chunk-3ahax79y.js → chunk-qqkr6h07.js} +2 -2
  85. package/bin/chunk-qyqc5j3a.css +1 -0
  86. package/bin/chunk-qzaf6bre.js +2 -0
  87. package/bin/{chunk-nmd1901j.js → chunk-r1e59gf0.js} +1 -1
  88. package/bin/chunk-ra5csbkr.js +2 -0
  89. package/bin/{chunk-2w2bknn2.js → chunk-rx9g95wk.js} +3 -3
  90. package/bin/{chunk-04nqnkzs.js → chunk-rxyy37wa.js} +3 -3
  91. package/bin/{chunk-bn0taqr3.js → chunk-scez7ppq.js} +2 -2
  92. package/bin/{chunk-26am2rzm.js → chunk-t2a1vq34.js} +1 -1
  93. package/bin/chunk-t879v3b7.js +1 -0
  94. package/bin/{chunk-a8bymrv1.js → chunk-tjavzarz.js} +2 -2
  95. package/bin/{chunk-n08h1jgx.js → chunk-treyx8em.js} +1 -1
  96. package/bin/{chunk-p7zw53ep.js → chunk-v3z4z04s.js} +1 -1
  97. package/bin/{chunk-461gcgrs.js → chunk-v3z63tpw.js} +1 -1
  98. package/bin/{chunk-s0vfj06y.js → chunk-v9bes1fv.js} +1 -1
  99. package/bin/{chunk-vsnq4381.js → chunk-vjyget8s.js} +1 -1
  100. package/bin/{chunk-s6g2mzpn.js → chunk-vmm9m3nv.js} +1 -1
  101. package/bin/{chunk-qx553512.js → chunk-vvr8tnse.js} +36 -36
  102. package/bin/{chunk-hgy9rqt1.js → chunk-w3stry4v.js} +1 -1
  103. package/bin/{chunk-8ts3xkme.js → chunk-w89czwjj.js} +1 -1
  104. package/bin/{chunk-157axqz1.js → chunk-wk0hk00z.js} +1 -1
  105. package/bin/{chunk-pwq6dbb5.js → chunk-ww9qq8yq.js} +1 -1
  106. package/bin/{chunk-q1gfypy3.js → chunk-x4q082e6.js} +1 -1
  107. package/bin/{chunk-cvfznrnt.js → chunk-x6rf77jm.js} +1 -1
  108. package/bin/chunk-x7dyj53k.js +2 -0
  109. package/bin/{chunk-j420aqk8.js → chunk-xcrd0y8v.js} +3 -3
  110. package/bin/{chunk-q4qqmes7.js → chunk-z0z0jn5h.js} +2 -2
  111. package/bin/{chunk-1tesbv8w.js → chunk-zasjhrwc.js} +1 -1
  112. package/bin/chunk-zefds5gg.js +1 -0
  113. package/bin/{chunk-2pt9h882.js → chunk-zzzgk1d5.js} +2 -2
  114. package/bin/shumai-app.html +1 -1
  115. package/bin/shumai-app.js +364 -364
  116. package/package.json +8 -11
  117. package/bin/chunk-45p7d22e.js +0 -2
  118. package/bin/chunk-87secbzy.js +0 -1
  119. package/bin/chunk-8pykp70z.js +0 -1
  120. package/bin/chunk-cb37q6t0.js +0 -1
  121. package/bin/chunk-g2z0c39g.js +0 -1
  122. package/bin/chunk-gnt9gewm.js +0 -2
  123. package/bin/chunk-hk659cg2.css +0 -1
  124. package/bin/chunk-k97axrc4.js +0 -13
  125. package/bin/chunk-m9f21ye9.js +0 -1
  126. package/bin/chunk-md7pgk86.js +0 -2
  127. package/bin/chunk-mg6sybt0.js +0 -1
  128. package/bin/chunk-r3s1x5wp.js +0 -1
  129. package/bin/chunk-sjbvt3wa.js +0 -2
  130. package/bin/chunk-t8jfp3vx.js +0 -1
  131. package/bin/chunk-vk9ecq8n.js +0 -2
  132. package/bin/chunk-xhngtwn9.js +0 -1
  133. package/bin/chunk-xjnehexk.js +0 -2
  134. package/bin/chunk-xzb0t8mx.js +0 -1
  135. package/bin/chunk-zts21ft7.js +0 -1
@@ -1,2 +1,2 @@
1
- import{I,wp,xp,Sp,Ep,Pd,Nd,Dd,Od,Fd,lu}from"./chunk-qx553512.js";import{Mo}from"./chunk-tqdde9bj.js";import{ko}from"./chunk-03zkxckm.js";var o=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ys=I("activity",o);var a=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],lo=I("cpu",a);var r=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],zo=I("gauge",r);var c=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],wn=I("server",c);var n=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],tc=I("shield-alert",n);var i=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],ha=I("dollar-sign",i);var Xa={agent_total_tokens:{label:()=>Fd(),icon:lo,unit:"tokens"},agent_cost:{label:()=>Nd(),icon:ha,unit:"$"},agent_mcp_call_count:{label:()=>Dd(),icon:wn,unit:"calls"},agent_bash_call_count:{label:()=>Pd(),icon:ko,unit:"calls"},agent_tool_call_count:{label:()=>Od(),icon:Mo,unit:"calls"}};function Oi(e,t){if(e==="agent_cost")return`$${t.toFixed(2)}`;return t.toLocaleString()}function rc(e){switch(lu(e)){case"1hour":return xp();case"5hour":return Sp();case"1day":return wp();case"7day":return Ep();default:return e}}
1
+ import{I,xp,Sp,Ep,Cp,Pd,Nd,Dd,Od,Fd,lu}from"./chunk-vvr8tnse.js";import{Mo}from"./chunk-fg9sr6r9.js";import{ko}from"./chunk-hjzbw975.js";var o=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ys=I("activity",o);var a=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],lo=I("cpu",a);var r=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],zo=I("gauge",r);var c=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],wn=I("server",c);var n=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],tc=I("shield-alert",n);var i=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],ha=I("dollar-sign",i);var Xa={agent_total_tokens:{label:()=>Fd(),icon:lo,unit:"tokens"},agent_cost:{label:()=>Nd(),icon:ha,unit:"$"},agent_mcp_call_count:{label:()=>Dd(),icon:wn,unit:"calls"},agent_bash_call_count:{label:()=>Pd(),icon:ko,unit:"calls"},agent_tool_call_count:{label:()=>Od(),icon:Mo,unit:"calls"}};function Oi(e,t){if(e==="agent_cost")return`$${t.toFixed(2)}`;return t.toLocaleString()}function rc(e){switch(lu(e)){case"1hour":return Sp();case"5hour":return Ep();case"1day":return xp();case"7day":return Cp();default:return e}}
2
2
  export{Ys,lo,ha,zo,wn,tc,Xa,Oi,rc};
@@ -0,0 +1 @@
1
+ import{m,_,u,S,L,t,o,G,Ta,Z,B,ke,gn,Ue,A,O,ar,E,C,Ne,ct,Hc,$c,lb,Ad,Oa,av,Bh,Zo,FC,Gn,Xe,et,tt,rt,nt,ot,st,it,de,le,me,qe,ce,z,ut,Nt,M,un,jr,$t,ur,_r,Bo,ae,lf}from"./chunk-vvr8tnse.js";import"./chunk-zasjhrwc.js";import"./chunk-fb1bes2h.js";import{Lr}from"./chunk-bf5m8f6t.js";import"./chunk-rx9g95wk.js";import{Ti}from"./chunk-113baw0m.js";import{ts,Kl,ns,Ss}from"./chunk-nv7tztvh.js";import{$l,Gl}from"./chunk-1dbjyarc.js";import"./chunk-zzzgk1d5.js";import{ki}from"./chunk-a23q1kc4.js";import{Ir}from"./chunk-4yhvexzk.js";import"./chunk-fg9sr6r9.js";import"./chunk-hjzbw975.js";import"./chunk-5m51b7af.js";import"./chunk-emgyjhmx.js";import"./chunk-hjwpd09v.js";import"./chunk-8s9fehda.js";S();var St=({item:n})=>{if(n.preview?.thumbnailUrl)return t("img",{src:n.preview.thumbnailUrl,alt:"Preview",className:"w-full h-full object-cover"});if(n.preview?.proxyType==="audio"||n.proxyType==="audio")return t("div",{className:"w-full h-full flex items-center justify-center bg-muted",children:t(ts,{className:"w-5 h-5 text-muted-foreground"})});return t("div",{className:"w-full h-full flex items-center justify-center bg-muted",children:t(ar,{className:"w-5 h-5 text-muted-foreground"})})},Le=({projectId:n,currentAssetId:r,parentFolderId:x,initialFiles:p,initialNextCursor:F,isLoading:i=!1})=>{let{ref:N,inView:D}=Nt({threshold:0,rootMargin:"200px"}),R=_(null),l=_(!0),[d,y]=u(p),[V,J]=u(F),[Q,U]=u(!!F),[h,Y]=u(!1);return m(()=>{y(p),J(F),U(!!F),l.current=!0},[p,F]),m(()=>{(async()=>{if(!V||h||!D||!Q)return;Y(!0);try{let g=await A.api.folders[":folderId"].search.$post({param:{folderId:x},json:{assetType:"file",after:V,first:200,recursively:!1,conditions:[]}});if(!g.ok)throw Error("Failed to fetch next page");let q=await g.json(),P=q.data||[];y((ee)=>[...ee,...P]),J(q.pageInfo?.cursor||void 0),U(!!q.pageInfo?.cursor&&P.length>0)}catch(g){console.error("Error fetching next page:",g)}finally{Y(!1)}})()},[D,V,Q,h,x]),m(()=>{if(d.some((g)=>g?.id===r)&&R.current)if(l.current)R.current.scrollIntoView({block:"center",inline:"center",behavior:"auto"}),l.current=!1;else R.current.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})},[d,r]),t("div",{className:"h-24 md:h-full w-full md:w-24 bg-gray-100 dark:bg-gray-950 flex flex-row md:flex-col flex-shrink-0 select-none",children:o("div",{className:"flex-1 overflow-x-auto overflow-y-hidden md:overflow-y-auto md:overflow-x-hidden px-4 md:px-0 py-2 md:py-4 flex flex-row md:flex-col items-center gap-3 no-scrollbar",children:[i&&d.length===0?Array.from({length:6}).map((f,g)=>t(ae,{className:"w-[52px] h-[52px] rounded-lg shrink-0","data-testid":"carousel-skeleton-item"},g)):d.map((f)=>{if(!f)return null;let g=f.id===r;return t("div",{ref:f.id===r?R:null,className:"flex-shrink-0",children:o(gn,{to:"/projects/$projectId/files/$fileId",params:{projectId:n,fileId:f.id},search:{version:void 0},className:E("rounded-lg border overflow-hidden flex items-center justify-center transition-all bg-muted/30 block relative",g?"w-[62px] h-[62px] opacity-100":"w-[52px] h-[52px] opacity-60 hover:opacity-100"),children:[t(St,{item:f}),f.agent&&t("span",{className:"absolute top-1 right-1 z-10 pointer-events-none select-none rounded bg-black/60 px-1 py-0.5 text-[10px] font-medium leading-none text-white",title:f.agent.name,"data-testid":"carousel-agent-badge",children:"AI"})]})},f.id)}),!i&&Q&&t("div",{ref:N,className:"px-2 md:px-0 py-2 md:py-4 flex justify-center items-center h-full md:w-full flex-shrink-0",children:h&&t(O,{className:"h-5 w-5 animate-spin text-muted-foreground"})})]})})};S();function Dt(){let{projectId:n,fileId:r}=Ee.useParams(),x=Ee.useSearch(),{version:p,start:F}=x,i=p||r,{cmpLeft:N,cmpRight:D}=x,R=x.cmpActive??"left",l=!!x.compare&&!!N&&!!D,d=_(null),{teamId:y,ensureTeamIdForProject:V}=ut(),[J,Q]=u(360),[U,h]=u([]),{fileViewRightSidebarCollapsed:Y}=$t(),{isChatbotOpen:f}=ur(),g=_r((e)=>Boolean(e.metadata["appearance.hideAgent"])),[q,P]=u(0),[ee,T]=u(null),[we,Ve]=u(null),[Pe,ve]=u(void 0),[W,xe]=u({show:!0,files:[],nextCursor:void 0,folderId:void 0}),[ze,se]=u(!0),_e=A.api.files[":fileId"].metadata.$patch,{mutate:Ke}=B({mutationFn:async(e)=>{let s=await _e(e);if(!s.ok)throw Error("Failed to patch metadata");return await s.json()}}),X=G(),{members:Oe,fetchProjectMembers:be}=jr(),He=Bo();m(()=>{V(n)},[n,V]),m(()=>{if(n)be(n,!0)},[n,be]),m(()=>{if(n&&r)A.api.projects[":projectId"].recents.view.$post({param:{projectId:n},json:{assetId:r}}).catch(()=>{})},[n,r]);let{data:Fe,isLoading:Qe,isError:Be,isFetching:We}=Z({queryKey:["files",r],queryFn:async()=>{let e=await A.api.files[":fileId"].$get({param:{fileId:r}});if(!e.ok)throw Error("Failed to fetch stack");return await e.json()},enabled:!!y,placeholderData:Ta}),{data:Ge,isLoading:Je,isError:Ye,isFetching:Ze}=Z({queryKey:["files",p],queryFn:async()=>{let e=await A.api.files[":fileId"].$get({param:{fileId:p}});if(!e.ok)throw Error("Failed to fetch version");return await e.json()},enabled:!!y&&!!p,placeholderData:Ta}),{data:at}=Z({queryKey:["version_stacks",r,"versions"],queryFn:async()=>{let e=await A.api.version_stacks[":stackId"].versions.$get({param:{stackId:r}});if(!e.ok)throw Error("Failed to fetch versions");return await e.json()},enabled:!!n&&!!r&&(!!p||l)}),{data:k}=Z({queryKey:["projects",n],queryFn:async()=>{let e=await A.api.projects[":projectId"].$get({param:{projectId:n}});if(!e.ok)throw Error("Failed to fetch project");return await e.json()}}),I=ke(),{setProjectState:Ae,clearProjectState:je}=un(),lt=Qe||!!p&&Je,dt=Be||!!p&&Ye,ft=We||!!p&&Ze,a=Ge||Fe,b=p?at:Fe?.versionStack?.versions,c=a?.ancestorFolders?.[0]?.id??k?.rootFolder??"",[re,te]=u(!1),[oe,Ce]=u(""),ie=_(null),fe=_(!1),[pt,ue]=u(!1),mt=A.api.files[":fileId"].$put,{mutate:ht,mutateAsync:gt,isPending:Se}=B({mutationFn:async(e)=>{let s=await mt(e);if(!s.ok)throw Error("Failed to rename file");return await s.json()},onSuccess:()=>{X.invalidateQueries({queryKey:["files"]}),X.invalidateQueries({queryKey:["version_stacks"]}),M.success(FC?.()||"Renamed successfully"),te(!1)},onError:()=>{M.error(av?.()||"Failed to rename")}}),yt=A.api.files.$delete,{mutate:It,mutateAsync:wt,isPending:De}=B({mutationFn:async(e)=>{if(!(await yt(e)).ok)throw Error("Failed to delete file")},onSuccess:()=>{if(X.invalidateQueries({queryKey:["files"]}),X.invalidateQueries({queryKey:["version_stacks"]}),M.success(lb?.()||"Deleted"),ue(!1),c&&c!==k?.rootFolder)I({to:"/projects/$projectId/folders/$folderId",params:{projectId:n,folderId:c}});else I({to:"/projects/$projectId",params:{projectId:n}})},onError:()=>{M.error(Oa?.()||"Failed to delete")}}),vt=(e)=>{if(e?.preventDefault(),!oe.trim()||!i)return;ht({param:{fileId:i},json:{name:oe.trim()}})},xt=()=>{if(!i)return;It({json:{ids:[i]}})};m(()=>{if(a&&k&&y)Ae({teamId:y,projectId:n,projectName:k.name??"",ancestorFolders:a.ancestorFolders??[],currentAsset:{id:i||r,name:a.name,type:"file",version:b?b.find((e)=>e.id===i)?.version??b.length:void 0,proxyType:a.proxyType},isRootFolder:!1,fileId:r,downloadInfo:{originalKey:a.media?.original?.key,videoTranscodes:a.media?.videoTranscodes?.map((e)=>({key:e.key,width:e.width,height:e.height,resolution:e.resolution,hdr:e.hdr}))},versions:b,compareMode:l,canCompareVersions:(b?.length??0)>=2,onCompareVersions:()=>{let e=Kl(b);if(!e)return;I({to:"/projects/$projectId/files/$fileId",params:{projectId:n,fileId:r},search:(s)=>({...s,version:void 0,compare:!0,cmpLeft:e.left.id,cmpRight:e.right.id,cmpActive:"left"})})},onFolderClick:(e)=>{I({to:"/projects/$projectId/folders/$folderId",params:{projectId:n,folderId:e}})},onRename:()=>{fe.current=!1,Ce(a?.name??""),te(!0)},onDelete:()=>{ue(!0)}});return()=>je()},[y,n,k,a,b,i,r,l,Ae,je,I]),m(()=>{if(!re)return;let e=setTimeout(()=>{fe.current=!0},1000);return()=>clearTimeout(e)},[re]);let bt=()=>{if(fe.current)return;setTimeout(()=>{if(ie.current)Ss(ie.current)},0)};if(m(()=>{if(!c||!i)return;if(W.folderId===c){se(!1);return}se(!0);let e=!0;return(async()=>{try{let w="",v=!1,j=[],he=void 0;for(let ge=0;ge<5;ge++){let ye=await A.api.folders[":folderId"].search.$post({param:{folderId:c},json:{assetType:"file",after:w,first:200,recursively:!1,conditions:[]}});if(!ye.ok)throw Error("Failed to search parent folder for carousel");let H=await ye.json(),Ie=H.data||[];if(j.push(...Ie),Ie.some((ne)=>ne.id===i)){if(v=!0,he=H.pageInfo?.cursor||void 0,H.pageInfo?.cursor)try{let ne=await A.api.folders[":folderId"].search.$post({param:{folderId:c},json:{assetType:"file",after:H.pageInfo.cursor,first:200,recursively:!1,conditions:[]}});if(ne.ok){let Me=await ne.json(),Ct=Me.data||[];j.push(...Ct),he=Me.pageInfo?.cursor||void 0}}catch{}break}if(!H.pageInfo?.cursor||Ie.length<200)break;w=H.pageInfo.cursor}if(e)xe({show:!0,files:v?j:a?[a]:[],nextCursor:v?he:void 0,folderId:c})}catch(w){if(console.error(w),e)xe({show:!0,files:a?[a]:[],nextCursor:void 0,folderId:c})}finally{if(e)se(!1)}})(),()=>{e=!1}},[c,i,W.folderId,a]),m(()=>{P(0),T(null),h([])},[a?.id]),m(()=>{T(null),h([])},[we?.id]),m(()=>{Lr.getState().reset(),Lr.getState().setIsDrawing(!1),h([]),T(null)},[i]),lt&&!a)return t(lf,{});if(dt||!a||!k||!y)return t("div",{children:Bh()});let K=l?we:a,Re=K?.id??i,Te=(e,s)=>{if(!y)return;Ke({param:{fileId:Re},json:[{key:e,value:s}]},{onSuccess:()=>{X.invalidateQueries({queryKey:["files",Re]})}})},pe=(e)=>{I({to:"/projects/$projectId/files/$fileId",params:{projectId:n,fileId:r},search:(s)=>({...s,...e})})},Ft=()=>{pe({compare:void 0,cmpLeft:void 0,cmpRight:void 0,cmpActive:void 0,version:R==="left"?N:D})},kt=(e)=>{T(e.id||null);let s=e.annotations;if(s&&s.length>0)h(s);else h([]);if(l){if(e.second!==null&&e.second!==void 0)ve({second:e.second,nonce:Date.now()});return}if(e.second!==null&&e.second!==void 0)d.current?.seekTo(e.second),d.current?.pause();else if(s&&s.length>0)d.current?.pause()},At=(e)=>{T(e.id||null);let w=e.details,v=w?.annotations;if(v&&v.length>0)h(v);else h([]);let j=w?.position?.type==="time"?w.position.seconds:w?.position?.type==="page"?w.position.page:void 0;if(l){if(j!==void 0)ve({second:j,nonce:Date.now()});return}if(j!==void 0)d.current?.seekTo(j),d.current?.pause();else if(v&&v.length>0)d.current?.pause()},$e=()=>{h([]),T(null)},jt=()=>{h([]),T(null)};if(He&&!l)return t($l,{projectId:n,teamId:y,fileId:r,file:a,projectInfo:k,ancestorFolders:a.ancestorFolders??[],parentFolderId:c,versions:b,activeFileId:i,startTime:F,siblingFiles:W.files,onNavigateToFile:(e)=>{I({to:"/projects/$projectId/files/$fileId",params:{projectId:n,fileId:e}})},onNavigateBack:()=>{if(c&&c!==k?.rootFolder)I({to:"/projects/$projectId/folders/$folderId",params:{projectId:n,folderId:c}});else I({to:"/projects/$projectId",params:{projectId:n}})},onSelectVersion:(e)=>{I({to:"/projects/$projectId/files/$fileId",params:{projectId:n,fileId:r},search:(s)=>({...s,version:e})})},onRenameFile:async(e)=>{await gt({param:{fileId:i},json:{name:e}})},onDeleteFile:async()=>{await wt({json:{ids:[i]}})},onSaveField:Te});return o("div",{className:"h-full flex flex-1 flex-col bg-background",children:[o("div",{className:"h-full flex flex-1 overflow-hidden",children:[o("div",{className:"flex-1 relative",children:[ft&&!l&&t("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/50",children:t(O,{className:"h-8 w-8 animate-spin text-foreground"})}),l&&N&&D?t(Gl,{versions:b??[],leftId:N,rightId:D,activeSide:R,annotations:U,seekRequest:Pe,onActiveSideChange:(e)=>pe({cmpActive:e}),onSwitchVersion:(e,s)=>pe(e==="left"?{cmpLeft:s}:{cmpRight:s}),onExit:Ft,onActiveAssetChange:Ve,onPlay:$e,onTimeUpdate:P}):t(ns,{file:a,mediaControllerRef:d,onPlay:$e,onTimeUpdate:P,onSeek:jt,annotations:U,startTime:F,children:t(Le,{projectId:n,currentAssetId:i,parentFolderId:c,initialFiles:W.files,initialNextCursor:W.nextCursor,isLoading:ze})})]}),(!Y||f&&!g)&&o(L,{children:[t(Ir,{onResize:(e)=>{Q((s)=>Math.max(300,Math.min(600,s-e)))},className:"hidden md:block"}),t("div",{style:{width:J},className:"flex-shrink-0 bg-background flex flex-col",children:f&&!g?t(Ti,{projectId:n,contextAssetId:i,file:K,currentTime:q,frameRate:K?.media?.metadata?.frameRate||30,startTimecode:K?.media?.metadata?.startTimecode,onTyping:()=>{if(l)return;d.current?.pause()},onSelectMessage:At,selectedMessageId:ee}):t(ki,{teamId:y,projectId:n,file:K,onSaveField:Te,members:Oe,onCommentSelect:kt,currentTime:q,onTyping:()=>{if(l)return;d.current?.pause()},selectedCommentId:ee,hideAnnotationControl:K?.proxyType==="audio"})})]})]}),t(de,{open:re,onOpenChange:te,children:t(le,{children:o("form",{onSubmit:vt,children:[t(me,{children:t(ce,{children:Zo()})}),t("div",{className:"py-4",children:t(z,{ref:ie,value:oe,onChange:(e)=>Ce(e.target.value),placeholder:Ad?.()||"Enter new name",onFocus:bt,autoFocus:!0})}),o(qe,{children:[t(C,{type:"button",variant:"outline",onClick:()=>te(!1),children:Ne()}),o(C,{type:"submit",disabled:Se||!oe.trim(),children:[Se&&t(O,{className:"mr-2 h-4 w-4 animate-spin"}),Gn()]})]})]})})}),t(Xe,{open:pt,onOpenChange:ue,children:o(et,{children:[o(tt,{children:[t(nt,{children:$c?.()||"Delete Asset?"}),t(ot,{children:Hc?.()||"Deleted items can be recovered for 30 days before being permanently deleted."})]}),o(rt,{children:[t(it,{children:Ne()}),o(st,{onClick:xt,disabled:De,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[De&&t(O,{className:"mr-2 h-4 w-4 animate-spin"}),ct()]})]})]})})]})}var Ee=Ue("/projects/$projectId/files/$fileId")({component:Dt});export{Ee as Route};