@shumai-one/shumai 0.5.2 → 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 (146) hide show
  1. package/bin/{chunk-qxscgcn9.js → chunk-01ym2agz.js} +1 -1
  2. package/bin/{chunk-ae6zgjhd.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-19q13a80.js → chunk-0fbgfgxv.js} +5 -5
  6. package/bin/{chunk-jt6v15wx.js → chunk-0nnqha4f.js} +1 -1
  7. package/bin/chunk-0tvggyy4.js +1 -0
  8. package/bin/{chunk-zckxc8m6.js → chunk-113baw0m.js} +2 -2
  9. package/bin/{chunk-mneeg71d.js → chunk-1dbjyarc.js} +2 -2
  10. package/bin/{chunk-951r2rx1.js → chunk-1qre79kf.js} +1 -1
  11. package/bin/chunk-27v3yepb.js +1 -0
  12. package/bin/{chunk-5vqbzsjv.js → chunk-2rq3w8sg.js} +1 -1
  13. package/bin/{chunk-v034sfw8.js → chunk-3020am4q.js} +2 -2
  14. package/bin/{chunk-zdzkjp4q.js → chunk-3fjgf7eb.js} +2 -2
  15. package/bin/chunk-3pwwg1xm.js +1 -0
  16. package/bin/{chunk-19jpn3r6.js → chunk-3sfb63fp.js} +1 -1
  17. package/bin/{chunk-wwkhskce.js → chunk-3tg10kwz.js} +2 -2
  18. package/bin/{chunk-0y4zq3y4.js → chunk-4g4pxmef.js} +1 -1
  19. package/bin/{chunk-2pw7xcrn.js → chunk-4jj92zwa.js} +1 -1
  20. package/bin/{chunk-bpxw19ez.js → chunk-4yhvexzk.js} +1 -1
  21. package/bin/chunk-58cbk6e8.js +1 -0
  22. package/bin/{chunk-eqr0znmc.js → chunk-59t9s2jh.js} +1 -1
  23. package/bin/{chunk-n76w2wcr.js → chunk-5e7r7a9d.js} +1 -1
  24. package/bin/{chunk-8tzfcqtb.js → chunk-5m51b7af.js} +1 -1
  25. package/bin/{chunk-m6v8vt2b.js → chunk-65t6rm5d.js} +2 -2
  26. package/bin/chunk-6bed0rz4.js +1 -0
  27. package/bin/{chunk-1nvj833s.js → chunk-6smn0q1n.js} +5 -5
  28. package/bin/{chunk-r249n1xe.js → chunk-6zerk0em.js} +2 -2
  29. package/bin/{chunk-gvas3xkp.js → chunk-7bbsv8g0.js} +1 -1
  30. package/bin/chunk-83bdgs2c.js +1 -0
  31. package/bin/{chunk-93p27bbm.js → chunk-86qtjd30.js} +5 -5
  32. package/bin/{chunk-b5r0be06.js → chunk-8rekh4h9.js} +1 -1
  33. package/bin/{chunk-d2dgazjj.js → chunk-8s9fehda.js} +1 -1
  34. package/bin/{chunk-r776bhsg.js → chunk-8sf2hf31.js} +1 -1
  35. package/bin/{chunk-mn108p93.js → chunk-9d3w678j.js} +1 -1
  36. package/bin/{chunk-xr2v0d6y.js → chunk-9gftd4f7.js} +4 -4
  37. package/bin/{chunk-n9vp9nbg.js → chunk-9rcg8zgs.js} +32 -32
  38. package/bin/{chunk-6jkjx0n2.js → chunk-a23q1kc4.js} +3 -3
  39. package/bin/{chunk-81dawvn4.js → chunk-a6cdt85k.js} +2 -2
  40. package/bin/chunk-a76h3ehe.js +1 -0
  41. package/bin/{chunk-rmvhyqyb.js → chunk-b1bkd2p4.js} +8 -8
  42. package/bin/{chunk-wnqxyqrg.js → chunk-bf5m8f6t.js} +2 -2
  43. package/bin/chunk-cf57fk11.js +2 -0
  44. package/bin/{chunk-0v9srsdz.js → chunk-cv5xx81e.js} +1 -1
  45. package/bin/{chunk-3q5qkfkc.js → chunk-czybv3vy.js} +1 -1
  46. package/bin/{chunk-ggfx2b0f.js → chunk-d4sbcvpa.js} +1 -1
  47. package/bin/{chunk-9ggwc289.js → chunk-d6xezgrg.js} +1 -1
  48. package/bin/{chunk-bbcmhcvc.js → chunk-da86fpjt.js} +2 -2
  49. package/bin/chunk-dzjmwat0.js +14 -0
  50. package/bin/{chunk-rza95y4z.js → chunk-eex8sjfs.js} +2 -2
  51. package/bin/{chunk-9zgqjdx1.js → chunk-emgyjhmx.js} +2 -2
  52. package/bin/{chunk-k3prp6c6.js → chunk-exmwerag.js} +5 -5
  53. package/bin/{chunk-kzr6ecke.js → chunk-f38xyahm.js} +1 -1
  54. package/bin/{chunk-ffj9cq9y.js → chunk-fb1bes2h.js} +1 -1
  55. package/bin/chunk-fbvak7q2.js +1 -0
  56. package/bin/{chunk-15w79661.js → chunk-fg9sr6r9.js} +1 -1
  57. package/bin/{chunk-dppfek34.js → chunk-fyb6t7ct.js} +2 -2
  58. package/bin/chunk-g2ptqqm3.js +3 -0
  59. package/bin/{chunk-t1yamxgk.js → chunk-ggwqxn95.js} +1 -1
  60. package/bin/chunk-ghk54h71.js +13 -0
  61. package/bin/{chunk-kvwec0p3.js → chunk-h1fbev9c.js} +2 -2
  62. package/bin/{chunk-f5z3096k.js → chunk-h9akn41s.js} +2 -2
  63. package/bin/{chunk-asy868kq.js → chunk-hdansxny.js} +1 -1
  64. package/bin/{chunk-grjek810.js → chunk-hjwpd09v.js} +2 -2
  65. package/bin/{chunk-zf5cyxnt.js → chunk-hjzbw975.js} +1 -1
  66. package/bin/{chunk-jgfye6nf.js → chunk-j4p3eqtd.js} +1 -1
  67. package/bin/chunk-jtkxeat4.js +2 -0
  68. package/bin/{chunk-8zgq5sav.js → chunk-jw4g9628.js} +3 -3
  69. package/bin/{chunk-0ge2mm8j.js → chunk-jxebakyq.js} +1 -1
  70. package/bin/{chunk-0asthrjf.js → chunk-kfewyax2.js} +2 -2
  71. package/bin/chunk-kk3m4za5.js +1 -0
  72. package/bin/{chunk-vzdgsfkf.js → chunk-m7tnj47b.js} +1 -1
  73. package/bin/{chunk-w73v578p.js → chunk-maw5ah8t.js} +2 -2
  74. package/bin/{chunk-8ny7wvzb.js → chunk-n0wwtjwv.js} +1 -1
  75. package/bin/{chunk-e439kt05.js → chunk-nahdd2t9.js} +1 -1
  76. package/bin/{chunk-04avc4fn.js → chunk-nv7tztvh.js} +32 -32
  77. package/bin/{chunk-mn208vrv.js → chunk-nyjwdxyj.js} +2 -2
  78. package/bin/{chunk-qmrg2jhs.js → chunk-p0yfxt5e.js} +5 -5
  79. package/bin/{chunk-p0j4wpa5.js → chunk-q27qn367.js} +2 -2
  80. package/bin/{chunk-j53sjkxt.js → chunk-q36sdt2w.js} +1 -1
  81. package/bin/{chunk-vm2pz2hm.js → chunk-q7t5zs7n.js} +2 -2
  82. package/bin/{chunk-cpj562n6.js → chunk-qbj5pe8t.js} +1 -1
  83. package/bin/chunk-qj0bxb1m.js +2 -0
  84. package/bin/{chunk-9bakwac0.js → chunk-qk5hsn6e.js} +4 -4
  85. package/bin/{chunk-6rn094yj.js → chunk-qnyqtaf0.js} +1 -1
  86. package/bin/{chunk-ypkkfwfb.js → chunk-qqkr6h07.js} +2 -2
  87. package/bin/chunk-qyqc5j3a.css +1 -0
  88. package/bin/chunk-qzaf6bre.js +2 -0
  89. package/bin/{chunk-cx32wsa1.js → chunk-r1e59gf0.js} +1 -1
  90. package/bin/chunk-ra5csbkr.js +2 -0
  91. package/bin/{chunk-rtaya5wc.js → chunk-rh8dy99a.js} +2 -2
  92. package/bin/{chunk-ryepy5er.js → chunk-rx9g95wk.js} +4 -4
  93. package/bin/{chunk-2w6gve12.js → chunk-rxyy37wa.js} +3 -3
  94. package/bin/{chunk-7qvvf0yd.js → chunk-scez7ppq.js} +2 -2
  95. package/bin/{chunk-twpc640e.js → chunk-t2a1vq34.js} +1 -1
  96. package/bin/chunk-t879v3b7.js +1 -0
  97. package/bin/{chunk-a8bymrv1.js → chunk-tjavzarz.js} +2 -2
  98. package/bin/{chunk-ce0bhc72.js → chunk-treyx8em.js} +1 -1
  99. package/bin/{chunk-dche0gy0.js → chunk-v3z4z04s.js} +1 -1
  100. package/bin/{chunk-5bk16qdp.js → chunk-v3z63tpw.js} +2 -2
  101. package/bin/{chunk-5rzxekn4.js → chunk-v9bes1fv.js} +1 -1
  102. package/bin/{chunk-d5hbzp7t.js → chunk-vjyget8s.js} +1 -1
  103. package/bin/{chunk-4zksqvwj.js → chunk-vmm9m3nv.js} +2 -2
  104. package/bin/chunk-vvr8tnse.js +211 -0
  105. package/bin/{chunk-tvkekn4z.js → chunk-w3stry4v.js} +1 -1
  106. package/bin/{chunk-3pm6q6kg.js → chunk-w89czwjj.js} +1 -1
  107. package/bin/{chunk-rw5h0n0s.js → chunk-wk0hk00z.js} +1 -1
  108. package/bin/{chunk-15vsw36h.js → chunk-ww9qq8yq.js} +5 -5
  109. package/bin/chunk-x4q082e6.js +2 -0
  110. package/bin/{chunk-98mg3dpd.js → chunk-x6rf77jm.js} +4 -4
  111. package/bin/chunk-x7dyj53k.js +2 -0
  112. package/bin/{chunk-y2dhf3p0.js → chunk-xbw7ffrz.js} +2 -2
  113. package/bin/{chunk-5nqvqvqp.js → chunk-xcrd0y8v.js} +3 -3
  114. package/bin/{chunk-0j22699g.js → chunk-z0z0jn5h.js} +2 -2
  115. package/bin/{chunk-w9z27p0m.js → chunk-zasjhrwc.js} +1 -1
  116. package/bin/chunk-zefds5gg.js +1 -0
  117. package/bin/{chunk-8ayz61rc.js → chunk-zzzgk1d5.js} +3 -3
  118. package/bin/shumai-app.html +1 -1
  119. package/bin/shumai-app.js +390 -373
  120. package/package.json +8 -11
  121. package/prisma/migrations/20261014054332_add_embedding_768/migration.sql +8 -0
  122. package/prisma/schema.prisma +10 -8
  123. package/bin/chunk-2gf95tj0.js +0 -1
  124. package/bin/chunk-2tk5w3jc.js +0 -1
  125. package/bin/chunk-301e7g3z.js +0 -2
  126. package/bin/chunk-3kmjbc3m.js +0 -2
  127. package/bin/chunk-3td60k1m.js +0 -2
  128. package/bin/chunk-42hrvk6k.js +0 -211
  129. package/bin/chunk-8abhmarc.js +0 -2
  130. package/bin/chunk-965102pf.js +0 -3
  131. package/bin/chunk-acn3r2m2.js +0 -1
  132. package/bin/chunk-ce75dw3k.css +0 -1
  133. package/bin/chunk-d9qpgkek.js +0 -2
  134. package/bin/chunk-dv6p6n5e.js +0 -1
  135. package/bin/chunk-gnt9gewm.js +0 -2
  136. package/bin/chunk-k97axrc4.js +0 -13
  137. package/bin/chunk-qb178ntp.js +0 -2
  138. package/bin/chunk-s4r6e6ms.js +0 -1
  139. package/bin/chunk-syjjke3f.js +0 -1
  140. package/bin/chunk-tgfxe0sb.js +0 -1
  141. package/bin/chunk-tjretpx8.js +0 -1
  142. package/bin/chunk-w4yjgez6.js +0 -14
  143. package/bin/chunk-wjcebkpb.js +0 -1
  144. package/bin/chunk-ws71fg50.js +0 -2
  145. package/bin/chunk-yfp3q4da.js +0 -1
  146. package/bin/chunk-z8e4wc59.js +0 -1
@@ -1 +0,0 @@
1
- import{t,ze}from"./chunk-42hrvk6k.js";import"./chunk-w4yjgez6.js";import"./chunk-w9z27p0m.js";import"./chunk-ffj9cq9y.js";import"./chunk-04avc4fn.js";import"./chunk-wnqxyqrg.js";import"./chunk-5bk16qdp.js";import"./chunk-0asthrjf.js";import"./chunk-8ayz61rc.js";import"./chunk-6jkjx0n2.js";import"./chunk-ryepy5er.js";import"./chunk-mneeg71d.js";import"./chunk-bpxw19ez.js";import{Ci}from"./chunk-4zksqvwj.js";import"./chunk-wwkhskce.js";import"./chunk-zf5cyxnt.js";import"./chunk-8tzfcqtb.js";import"./chunk-9zgqjdx1.js";import"./chunk-qxscgcn9.js";import"./chunk-grjek810.js";import"./chunk-d2dgazjj.js";function p(){let{shareId:a,fileId:s}=e.useParams(),{start:n,version:o,compare:r,cmpLeft:i,cmpRight:l,cmpActive:c}=e.useSearch();return t(Ci,{shareId:a,initialFileId:s,startTime:n,versionId:o,compare:r,compareLeftId:i,compareRightId:l,compareActiveSide:c})}var e=ze("/share/$shareId/files/$fileId")({component:p});export{e as Route};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Tc,Mc,ju}from"./chunk-gvas3xkp.js";export{Tc as ENV_KEY,Mc as ENV_SECRET,ju as fromEnv};
@@ -1 +0,0 @@
1
- import{m,S,t,Z,ze,A,ut,Ct,rm}from"./chunk-42hrvk6k.js";import"./chunk-04avc4fn.js";import"./chunk-w4yjgez6.js";import"./chunk-w9z27p0m.js";import"./chunk-ffj9cq9y.js";import"./chunk-wnqxyqrg.js";import"./chunk-ryepy5er.js";import"./chunk-zckxc8m6.js";import"./chunk-rza95y4z.js";import"./chunk-5bk16qdp.js";import"./chunk-0asthrjf.js";import"./chunk-8ayz61rc.js";import"./chunk-6jkjx0n2.js";import"./chunk-bpxw19ez.js";import{Qn}from"./chunk-ce0bhc72.js";import{nr}from"./chunk-qb178ntp.js";import"./chunk-wwkhskce.js";import"./chunk-15w79661.js";import"./chunk-zf5cyxnt.js";import"./chunk-8tzfcqtb.js";import"./chunk-9zgqjdx1.js";import"./chunk-qxscgcn9.js";import"./chunk-grjek810.js";import"./chunk-d2dgazjj.js";S();function l(){let{projectId:o}=c.useParams(),{teamId:r,ensureTeamIdForProject:a}=ut();m(()=>{a(o)},[o,a]);let{data:s}=nr(rm(o)),e=s?.rootFolder,{data:i}=Z({queryKey:["folders",e],queryFn:async()=>{let n=await A.api.folders[":folderId"].$get({param:{folderId:e}});if(!n.ok)throw Error("failed to fetch folder");return await n.json()},enabled:!!e});if(!r||!e||!i)return t(Ct,{});return t(Qn,{teamId:r,projectId:o,projectName:s.name??"",assetId:e,rootFolderId:e})}var c=ze("/projects/$projectId/")({component:l});export{c as Route};
@@ -1 +0,0 @@
1
- import{m,_,u,S,L,t,o,V,Ta,Z,B,Re,An,ze,A,O,tr,E,C,De,ct,jc,qc,ab,Ad,Da,iv,Fh,Zo,FC,Gn,Xe,et,tt,rt,nt,ot,st,it,ue,ae,pe,qe,le,z,ut,Nt,M,dn,jr,$t,ur,_r,Bo,ZA}from"./chunk-42hrvk6k.js";import"./chunk-w9z27p0m.js";import"./chunk-ffj9cq9y.js";import{Lr}from"./chunk-wnqxyqrg.js";import"./chunk-ryepy5er.js";import{Ii}from"./chunk-zckxc8m6.js";import{ts,Gl,ns,Ss}from"./chunk-04avc4fn.js";import{jl,ql}from"./chunk-mneeg71d.js";import"./chunk-8ayz61rc.js";import{Mi}from"./chunk-6jkjx0n2.js";import{Ir}from"./chunk-bpxw19ez.js";import"./chunk-15w79661.js";import"./chunk-zf5cyxnt.js";import"./chunk-8tzfcqtb.js";import"./chunk-9zgqjdx1.js";import"./chunk-grjek810.js";import"./chunk-d2dgazjj.js";S();var At=({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(tr,{className:"w-5 h-5 text-muted-foreground"})})},Me=({projectId:n,currentAssetId:s,parentFolderId:w,initialFiles:d,initialNextCursor:F})=>{let{ref:a,inView:R}=Nt({threshold:0,rootMargin:"200px"}),x=_(null),N=_(!0),[c,p]=u(d),[f,U]=u(F),[W,Y]=u(!!F),[q,h]=u(!1);return m(()=>{p(d),U(F),Y(!!F),N.current=!0},[d,F]),m(()=>{(async()=>{if(!f||q||!R||!W)return;h(!0);try{let y=await A.api.folders[":folderId"].search.$post({param:{folderId:w},json:{assetType:"file",after:f,first:200,recursively:!1,conditions:[]}});if(!y.ok)throw Error("Failed to fetch next page");let P=await y.json(),X=P.data||[];p((G)=>[...G,...X]),U(P.pageInfo?.cursor||void 0),Y(!!P.pageInfo?.cursor&&X.length>0)}catch(y){console.error("Error fetching next page:",y)}finally{h(!1)}})()},[R,f,W,q,w]),m(()=>{if(c.some((y)=>y?.id===s)&&x.current)if(N.current)x.current.scrollIntoView({block:"center",inline:"center",behavior:"auto"}),N.current=!1;else x.current.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})},[c,s]),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:[c.map((g)=>{if(!g)return null;let y=g.id===s;return t("div",{ref:g.id===s?x:null,className:"flex-shrink-0",children:o(An,{to:"/projects/$projectId/files/$fileId",params:{projectId:n,fileId:g.id},search:{version:void 0},className:E("rounded-lg border overflow-hidden flex items-center justify-center transition-all bg-muted/30 block relative",y?"w-[62px] h-[62px] opacity-100":"w-[52px] h-[52px] opacity-60 hover:opacity-100"),children:[t(At,{item:g}),g.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:g.agent.name,"data-testid":"carousel-agent-badge",children:"AI"})]})},g.id)}),W&&t("div",{ref:a,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:q&&t(O,{className:"h-5 w-5 animate-spin text-muted-foreground"})})]})})};S();function jt(){let{projectId:n,fileId:s}=Ne.useParams(),w=Ne.useSearch(),{version:d,start:F}=w,a=d||s,{cmpLeft:R,cmpRight:x}=w,N=w.cmpActive??"left",c=!!w.compare&&!!R&&!!x,p=_(null),{teamId:f,ensureTeamIdForProject:U}=ut(),[W,Y]=u(360),[q,h]=u([]),{fileViewRightSidebarCollapsed:g}=$t(),{isChatbotOpen:y}=ur(),P=_r((e)=>Boolean(e.metadata["appearance.hideAgent"])),[X,G]=u(0),[he,T]=u(null),[ge,Le]=u(null),[Ee,ye]=u(void 0),[K,ne]=u({show:!1,files:[],nextCursor:void 0,folderId:void 0}),Ve=A.api.files[":fileId"].metadata.$patch,{mutate:Pe}=B({mutationFn:async(e)=>{let r=await Ve(e);if(!r.ok)throw Error("Failed to patch metadata");return await r.json()}}),J=V(),{members:_e,fetchProjectMembers:Ie}=jr(),Ke=Bo();m(()=>{U(n)},[n,U]),m(()=>{if(n)Ie(n,!0)},[n,Ie]),m(()=>{if(n&&s)A.api.projects[":projectId"].recents.view.$post({param:{projectId:n},json:{assetId:s}}).catch(()=>{})},[n,s]);let{data:ve,isLoading:Oe,isError:He,isFetching:Qe}=Z({queryKey:["files",s],queryFn:async()=>{let e=await A.api.files[":fileId"].$get({param:{fileId:s}});if(!e.ok)throw Error("Failed to fetch stack");return await e.json()},enabled:!!f,placeholderData:Ta}),{data:Be,isLoading:Ue,isError:We,isFetching:Ge}=Z({queryKey:["files",d],queryFn:async()=>{let e=await A.api.files[":fileId"].$get({param:{fileId:d}});if(!e.ok)throw Error("Failed to fetch version");return await e.json()},enabled:!!f&&!!d,placeholderData:Ta}),{data:Je}=Z({queryKey:["version_stacks",s,"versions"],queryFn:async()=>{let e=await A.api.version_stacks[":stackId"].versions.$get({param:{stackId:s}});if(!e.ok)throw Error("Failed to fetch versions");return await e.json()},enabled:!!n&&!!s&&(!!d||c)}),{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=Re(),{setProjectState:we,clearProjectState:xe}=dn(),Ye=Oe||!!d&&Ue,Ze=He||!!d&&We,at=Qe||!!d&&Ge,i=Be||ve,b=d?Je:ve?.versionStack?.versions,l=i?.ancestorFolders?.[0]?.id??k?.rootFolder??"",[re,ee]=u(!1),[te,be]=u(""),se=_(null),ie=_(!1),[lt,ce]=u(!1),dt=A.api.files[":fileId"].$put,{mutate:ft,mutateAsync:pt,isPending:Fe}=B({mutationFn:async(e)=>{let r=await dt(e);if(!r.ok)throw Error("Failed to rename file");return await r.json()},onSuccess:()=>{J.invalidateQueries({queryKey:["files"]}),J.invalidateQueries({queryKey:["version_stacks"]}),M.success(FC?.()||"Renamed successfully"),ee(!1)},onError:()=>{M.error(iv?.()||"Failed to rename")}}),mt=A.api.files.$delete,{mutate:ht,mutateAsync:gt,isPending:ke}=B({mutationFn:async(e)=>{if(!(await mt(e)).ok)throw Error("Failed to delete file")},onSuccess:()=>{if(J.invalidateQueries({queryKey:["files"]}),J.invalidateQueries({queryKey:["version_stacks"]}),M.success(ab?.()||"Deleted"),ce(!1),l&&l!==k?.rootFolder)I({to:"/projects/$projectId/folders/$folderId",params:{projectId:n,folderId:l}});else I({to:"/projects/$projectId",params:{projectId:n}})},onError:()=>{M.error(Da?.()||"Failed to delete")}}),yt=(e)=>{if(e?.preventDefault(),!te.trim()||!a)return;ft({param:{fileId:a},json:{name:te.trim()}})},It=()=>{if(!a)return;ht({json:{ids:[a]}})};m(()=>{if(i&&k&&f)we({teamId:f,projectId:n,projectName:k.name??"",ancestorFolders:i.ancestorFolders??[],currentAsset:{id:a||s,name:i.name,type:"file",version:b?b.find((e)=>e.id===a)?.version??b.length:void 0,proxyType:i.proxyType},isRootFolder:!1,fileId:s,downloadInfo:{originalKey:i.media?.original?.key,videoTranscodes:i.media?.videoTranscodes?.map((e)=>({key:e.key,width:e.width,height:e.height,resolution:e.resolution,hdr:e.hdr}))},versions:b,compareMode:c,canCompareVersions:(b?.length??0)>=2,onCompareVersions:()=>{let e=Gl(b);if(!e)return;I({to:"/projects/$projectId/files/$fileId",params:{projectId:n,fileId:s},search:(r)=>({...r,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:()=>{ie.current=!1,be(i?.name??""),ee(!0)},onDelete:()=>{ce(!0)}});return()=>xe()},[f,n,k,i,b,a,s,c,we,xe,I]),m(()=>{if(!re)return;let e=setTimeout(()=>{ie.current=!0},1000);return()=>clearTimeout(e)},[re]);let vt=()=>{if(ie.current)return;setTimeout(()=>{if(se.current)Ss(se.current)},0)};if(m(()=>{if(!l||!a)return;if(K.folderId===l)return;let e=!0;return(async()=>{try{let v="",j=!1,D=[],fe=void 0;for(let Se=0;Se<5;Se++){let Te=await A.api.folders[":folderId"].search.$post({param:{folderId:l},json:{assetType:"file",after:v,first:200,recursively:!1,conditions:[]}});if(!Te.ok)throw Error("Failed to search parent folder for carousel");let Q=await Te.json(),me=Q.data||[];if(D.push(...me),me.some((oe)=>oe.id===a)){if(j=!0,fe=Q.pageInfo?.cursor||void 0,Q.pageInfo?.cursor)try{let oe=await A.api.folders[":folderId"].search.$post({param:{folderId:l},json:{assetType:"file",after:Q.pageInfo.cursor,first:200,recursively:!1,conditions:[]}});if(oe.ok){let $e=await oe.json(),kt=$e.data||[];D.push(...kt),fe=$e.pageInfo?.cursor||void 0}}catch{}break}if(!Q.pageInfo?.cursor||me.length<200)break;v=Q.pageInfo.cursor}if(e)if(j)ne({show:!0,files:D,nextCursor:fe,folderId:l});else ne({show:!1,files:[],nextCursor:void 0,folderId:l})}catch(v){if(console.error(v),e)ne({show:!1,files:[],nextCursor:void 0,folderId:l})}})(),()=>{e=!1}},[l,a,K.folderId]),m(()=>{G(0),T(null),h([])},[i?.id]),m(()=>{T(null),h([])},[ge?.id]),m(()=>{Lr.getState().reset(),Lr.getState().setIsDrawing(!1),h([]),T(null)},[a]),Ye&&!i)return t(ZA,{});if(Ze||!i||!k||!f)return t("div",{children:Fh()});let H=c?ge:i,Ae=H?.id??a,je=(e,r)=>{if(!f)return;Pe({param:{fileId:Ae},json:[{key:e,value:r}]},{onSuccess:()=>{J.invalidateQueries({queryKey:["files",Ae]})}})},de=(e)=>{I({to:"/projects/$projectId/files/$fileId",params:{projectId:n,fileId:s},search:(r)=>({...r,...e})})},wt=()=>{de({compare:void 0,cmpLeft:void 0,cmpRight:void 0,cmpActive:void 0,version:N==="left"?R:x})},xt=(e)=>{T(e.id||null);let r=e.annotations;if(r&&r.length>0)h(r);else h([]);if(c){if(e.second!==null&&e.second!==void 0)ye({second:e.second,nonce:Date.now()});return}if(e.second!==null&&e.second!==void 0)p.current?.seekTo(e.second),p.current?.pause();else if(r&&r.length>0)p.current?.pause()},bt=(e)=>{T(e.id||null);let v=e.details,j=v?.annotations;if(j&&j.length>0)h(j);else h([]);let D=v?.position?.type==="time"?v.position.seconds:v?.position?.type==="page"?v.position.page:void 0;if(c){if(D!==void 0)ye({second:D,nonce:Date.now()});return}if(D!==void 0)p.current?.seekTo(D),p.current?.pause();else if(j&&j.length>0)p.current?.pause()},Ce=()=>{h([]),T(null)},Ft=()=>{h([]),T(null)};if(Ke&&!c)return t(jl,{projectId:n,teamId:f,fileId:s,file:i,projectInfo:k,ancestorFolders:i.ancestorFolders??[],parentFolderId:l,versions:b,activeFileId:a,startTime:F,siblingFiles:K.files,onNavigateToFile:(e)=>{I({to:"/projects/$projectId/files/$fileId",params:{projectId:n,fileId:e}})},onNavigateBack:()=>{if(l&&l!==k?.rootFolder)I({to:"/projects/$projectId/folders/$folderId",params:{projectId:n,folderId:l}});else I({to:"/projects/$projectId",params:{projectId:n}})},onSelectVersion:(e)=>{I({to:"/projects/$projectId/files/$fileId",params:{projectId:n,fileId:s},search:(r)=>({...r,version:e})})},onRenameFile:async(e)=>{await pt({param:{fileId:a},json:{name:e}})},onDeleteFile:async()=>{await gt({json:{ids:[a]}})},onSaveField:je});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:[at&&!c&&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"})}),c&&R&&x?t(ql,{versions:b??[],leftId:R,rightId:x,activeSide:N,annotations:q,seekRequest:Ee,onActiveSideChange:(e)=>de({cmpActive:e}),onSwitchVersion:(e,r)=>de(e==="left"?{cmpLeft:r}:{cmpRight:r}),onExit:wt,onActiveAssetChange:Le,onPlay:Ce,onTimeUpdate:G}):t(ns,{file:i,mediaControllerRef:p,onPlay:Ce,onTimeUpdate:G,onSeek:Ft,annotations:q,startTime:F,children:K.show&&t(Me,{projectId:n,currentAssetId:a,parentFolderId:l,initialFiles:K.files,initialNextCursor:K.nextCursor})})]}),(!g||y&&!P)&&o(L,{children:[t(Ir,{onResize:(e)=>{Y((r)=>Math.max(300,Math.min(600,r-e)))},className:"hidden md:block"}),t("div",{style:{width:W},className:"flex-shrink-0 bg-background flex flex-col",children:y&&!P?t(Ii,{projectId:n,contextAssetId:a,file:H,currentTime:X,frameRate:H?.media?.metadata?.frameRate||30,startTimecode:H?.media?.metadata?.startTimecode,onTyping:()=>{if(c)return;p.current?.pause()},onSelectMessage:bt,selectedMessageId:he}):t(Mi,{teamId:f,projectId:n,file:H,onSaveField:je,members:_e,onCommentSelect:xt,currentTime:X,onTyping:()=>{if(c)return;p.current?.pause()},selectedCommentId:he,hideAnnotationControl:H?.proxyType==="audio"})})]})]}),t(ue,{open:re,onOpenChange:ee,children:t(ae,{children:o("form",{onSubmit:yt,children:[t(pe,{children:t(le,{children:Zo()})}),t("div",{className:"py-4",children:t(z,{ref:se,value:te,onChange:(e)=>be(e.target.value),placeholder:Ad?.()||"Enter new name",onFocus:vt,autoFocus:!0})}),o(qe,{children:[t(C,{type:"button",variant:"outline",onClick:()=>ee(!1),children:De()}),o(C,{type:"submit",disabled:Fe||!te.trim(),children:[Fe&&t(O,{className:"mr-2 h-4 w-4 animate-spin"}),Gn()]})]})]})})}),t(Xe,{open:lt,onOpenChange:ce,children:o(et,{children:[o(tt,{children:[t(nt,{children:qc?.()||"Delete Asset?"}),t(ot,{children:jc?.()||"Deleted items can be recovered for 30 days before being permanently deleted."})]}),o(rt,{children:[t(it,{children:De()}),o(st,{onClick:It,disabled:ke,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[ke&&t(O,{className:"mr-2 h-4 w-4 animate-spin"}),ct()]})]})]})})]})}var Ne=ze("/projects/$projectId/files/$fileId")({component:jt});export{Ne as Route};