@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.
- package/bin/{chunk-qxscgcn9.js → chunk-01ym2agz.js} +1 -1
- package/bin/{chunk-ae6zgjhd.js → chunk-047n9gfs.js} +2 -2
- package/bin/chunk-0a4ahz7r.js +2 -0
- package/bin/{chunk-v5hz09a1.js → chunk-0awcpx0a.js} +2 -2
- package/bin/{chunk-19q13a80.js → chunk-0fbgfgxv.js} +5 -5
- package/bin/{chunk-jt6v15wx.js → chunk-0nnqha4f.js} +1 -1
- package/bin/chunk-0tvggyy4.js +1 -0
- package/bin/{chunk-zckxc8m6.js → chunk-113baw0m.js} +2 -2
- package/bin/{chunk-mneeg71d.js → chunk-1dbjyarc.js} +2 -2
- package/bin/{chunk-951r2rx1.js → chunk-1qre79kf.js} +1 -1
- package/bin/chunk-27v3yepb.js +1 -0
- package/bin/{chunk-5vqbzsjv.js → chunk-2rq3w8sg.js} +1 -1
- package/bin/{chunk-v034sfw8.js → chunk-3020am4q.js} +2 -2
- package/bin/{chunk-zdzkjp4q.js → chunk-3fjgf7eb.js} +2 -2
- package/bin/chunk-3pwwg1xm.js +1 -0
- package/bin/{chunk-19jpn3r6.js → chunk-3sfb63fp.js} +1 -1
- package/bin/{chunk-wwkhskce.js → chunk-3tg10kwz.js} +2 -2
- package/bin/{chunk-0y4zq3y4.js → chunk-4g4pxmef.js} +1 -1
- package/bin/{chunk-2pw7xcrn.js → chunk-4jj92zwa.js} +1 -1
- package/bin/{chunk-bpxw19ez.js → chunk-4yhvexzk.js} +1 -1
- package/bin/chunk-58cbk6e8.js +1 -0
- package/bin/{chunk-eqr0znmc.js → chunk-59t9s2jh.js} +1 -1
- package/bin/{chunk-n76w2wcr.js → chunk-5e7r7a9d.js} +1 -1
- package/bin/{chunk-8tzfcqtb.js → chunk-5m51b7af.js} +1 -1
- package/bin/{chunk-m6v8vt2b.js → chunk-65t6rm5d.js} +2 -2
- package/bin/chunk-6bed0rz4.js +1 -0
- package/bin/{chunk-1nvj833s.js → chunk-6smn0q1n.js} +5 -5
- package/bin/{chunk-r249n1xe.js → chunk-6zerk0em.js} +2 -2
- package/bin/{chunk-gvas3xkp.js → chunk-7bbsv8g0.js} +1 -1
- package/bin/chunk-83bdgs2c.js +1 -0
- package/bin/{chunk-93p27bbm.js → chunk-86qtjd30.js} +5 -5
- package/bin/{chunk-b5r0be06.js → chunk-8rekh4h9.js} +1 -1
- package/bin/{chunk-d2dgazjj.js → chunk-8s9fehda.js} +1 -1
- package/bin/{chunk-r776bhsg.js → chunk-8sf2hf31.js} +1 -1
- package/bin/{chunk-mn108p93.js → chunk-9d3w678j.js} +1 -1
- package/bin/{chunk-xr2v0d6y.js → chunk-9gftd4f7.js} +4 -4
- package/bin/{chunk-n9vp9nbg.js → chunk-9rcg8zgs.js} +32 -32
- package/bin/{chunk-6jkjx0n2.js → chunk-a23q1kc4.js} +3 -3
- package/bin/{chunk-81dawvn4.js → chunk-a6cdt85k.js} +2 -2
- package/bin/chunk-a76h3ehe.js +1 -0
- package/bin/{chunk-rmvhyqyb.js → chunk-b1bkd2p4.js} +8 -8
- package/bin/{chunk-wnqxyqrg.js → chunk-bf5m8f6t.js} +2 -2
- package/bin/chunk-cf57fk11.js +2 -0
- package/bin/{chunk-0v9srsdz.js → chunk-cv5xx81e.js} +1 -1
- package/bin/{chunk-3q5qkfkc.js → chunk-czybv3vy.js} +1 -1
- package/bin/{chunk-ggfx2b0f.js → chunk-d4sbcvpa.js} +1 -1
- package/bin/{chunk-9ggwc289.js → chunk-d6xezgrg.js} +1 -1
- package/bin/{chunk-bbcmhcvc.js → chunk-da86fpjt.js} +2 -2
- package/bin/chunk-dzjmwat0.js +14 -0
- package/bin/{chunk-rza95y4z.js → chunk-eex8sjfs.js} +2 -2
- package/bin/{chunk-9zgqjdx1.js → chunk-emgyjhmx.js} +2 -2
- package/bin/{chunk-k3prp6c6.js → chunk-exmwerag.js} +5 -5
- package/bin/{chunk-kzr6ecke.js → chunk-f38xyahm.js} +1 -1
- package/bin/{chunk-ffj9cq9y.js → chunk-fb1bes2h.js} +1 -1
- package/bin/chunk-fbvak7q2.js +1 -0
- package/bin/{chunk-15w79661.js → chunk-fg9sr6r9.js} +1 -1
- package/bin/{chunk-dppfek34.js → chunk-fyb6t7ct.js} +2 -2
- package/bin/chunk-g2ptqqm3.js +3 -0
- package/bin/{chunk-t1yamxgk.js → chunk-ggwqxn95.js} +1 -1
- package/bin/chunk-ghk54h71.js +13 -0
- package/bin/{chunk-kvwec0p3.js → chunk-h1fbev9c.js} +2 -2
- package/bin/{chunk-f5z3096k.js → chunk-h9akn41s.js} +2 -2
- package/bin/{chunk-asy868kq.js → chunk-hdansxny.js} +1 -1
- package/bin/{chunk-grjek810.js → chunk-hjwpd09v.js} +2 -2
- package/bin/{chunk-zf5cyxnt.js → chunk-hjzbw975.js} +1 -1
- package/bin/{chunk-jgfye6nf.js → chunk-j4p3eqtd.js} +1 -1
- package/bin/chunk-jtkxeat4.js +2 -0
- package/bin/{chunk-8zgq5sav.js → chunk-jw4g9628.js} +3 -3
- package/bin/{chunk-0ge2mm8j.js → chunk-jxebakyq.js} +1 -1
- package/bin/{chunk-0asthrjf.js → chunk-kfewyax2.js} +2 -2
- package/bin/chunk-kk3m4za5.js +1 -0
- package/bin/{chunk-vzdgsfkf.js → chunk-m7tnj47b.js} +1 -1
- package/bin/{chunk-w73v578p.js → chunk-maw5ah8t.js} +2 -2
- package/bin/{chunk-8ny7wvzb.js → chunk-n0wwtjwv.js} +1 -1
- package/bin/{chunk-e439kt05.js → chunk-nahdd2t9.js} +1 -1
- package/bin/{chunk-04avc4fn.js → chunk-nv7tztvh.js} +32 -32
- package/bin/{chunk-mn208vrv.js → chunk-nyjwdxyj.js} +2 -2
- package/bin/{chunk-qmrg2jhs.js → chunk-p0yfxt5e.js} +5 -5
- package/bin/{chunk-p0j4wpa5.js → chunk-q27qn367.js} +2 -2
- package/bin/{chunk-j53sjkxt.js → chunk-q36sdt2w.js} +1 -1
- package/bin/{chunk-vm2pz2hm.js → chunk-q7t5zs7n.js} +2 -2
- package/bin/{chunk-cpj562n6.js → chunk-qbj5pe8t.js} +1 -1
- package/bin/chunk-qj0bxb1m.js +2 -0
- package/bin/{chunk-9bakwac0.js → chunk-qk5hsn6e.js} +4 -4
- package/bin/{chunk-6rn094yj.js → chunk-qnyqtaf0.js} +1 -1
- package/bin/{chunk-ypkkfwfb.js → chunk-qqkr6h07.js} +2 -2
- package/bin/chunk-qyqc5j3a.css +1 -0
- package/bin/chunk-qzaf6bre.js +2 -0
- package/bin/{chunk-cx32wsa1.js → chunk-r1e59gf0.js} +1 -1
- package/bin/chunk-ra5csbkr.js +2 -0
- package/bin/{chunk-rtaya5wc.js → chunk-rh8dy99a.js} +2 -2
- package/bin/{chunk-ryepy5er.js → chunk-rx9g95wk.js} +4 -4
- package/bin/{chunk-2w6gve12.js → chunk-rxyy37wa.js} +3 -3
- package/bin/{chunk-7qvvf0yd.js → chunk-scez7ppq.js} +2 -2
- package/bin/{chunk-twpc640e.js → chunk-t2a1vq34.js} +1 -1
- package/bin/chunk-t879v3b7.js +1 -0
- package/bin/{chunk-a8bymrv1.js → chunk-tjavzarz.js} +2 -2
- package/bin/{chunk-ce0bhc72.js → chunk-treyx8em.js} +1 -1
- package/bin/{chunk-dche0gy0.js → chunk-v3z4z04s.js} +1 -1
- package/bin/{chunk-5bk16qdp.js → chunk-v3z63tpw.js} +2 -2
- package/bin/{chunk-5rzxekn4.js → chunk-v9bes1fv.js} +1 -1
- package/bin/{chunk-d5hbzp7t.js → chunk-vjyget8s.js} +1 -1
- package/bin/{chunk-4zksqvwj.js → chunk-vmm9m3nv.js} +2 -2
- package/bin/chunk-vvr8tnse.js +211 -0
- package/bin/{chunk-tvkekn4z.js → chunk-w3stry4v.js} +1 -1
- package/bin/{chunk-3pm6q6kg.js → chunk-w89czwjj.js} +1 -1
- package/bin/{chunk-rw5h0n0s.js → chunk-wk0hk00z.js} +1 -1
- package/bin/{chunk-15vsw36h.js → chunk-ww9qq8yq.js} +5 -5
- package/bin/chunk-x4q082e6.js +2 -0
- package/bin/{chunk-98mg3dpd.js → chunk-x6rf77jm.js} +4 -4
- package/bin/chunk-x7dyj53k.js +2 -0
- package/bin/{chunk-y2dhf3p0.js → chunk-xbw7ffrz.js} +2 -2
- package/bin/{chunk-5nqvqvqp.js → chunk-xcrd0y8v.js} +3 -3
- package/bin/{chunk-0j22699g.js → chunk-z0z0jn5h.js} +2 -2
- package/bin/{chunk-w9z27p0m.js → chunk-zasjhrwc.js} +1 -1
- package/bin/chunk-zefds5gg.js +1 -0
- package/bin/{chunk-8ayz61rc.js → chunk-zzzgk1d5.js} +3 -3
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +390 -373
- package/package.json +8 -11
- package/prisma/migrations/20261014054332_add_embedding_768/migration.sql +8 -0
- package/prisma/schema.prisma +10 -8
- package/bin/chunk-2gf95tj0.js +0 -1
- package/bin/chunk-2tk5w3jc.js +0 -1
- package/bin/chunk-301e7g3z.js +0 -2
- package/bin/chunk-3kmjbc3m.js +0 -2
- package/bin/chunk-3td60k1m.js +0 -2
- package/bin/chunk-42hrvk6k.js +0 -211
- package/bin/chunk-8abhmarc.js +0 -2
- package/bin/chunk-965102pf.js +0 -3
- package/bin/chunk-acn3r2m2.js +0 -1
- package/bin/chunk-ce75dw3k.css +0 -1
- package/bin/chunk-d9qpgkek.js +0 -2
- package/bin/chunk-dv6p6n5e.js +0 -1
- package/bin/chunk-gnt9gewm.js +0 -2
- package/bin/chunk-k97axrc4.js +0 -13
- package/bin/chunk-qb178ntp.js +0 -2
- package/bin/chunk-s4r6e6ms.js +0 -1
- package/bin/chunk-syjjke3f.js +0 -1
- package/bin/chunk-tgfxe0sb.js +0 -1
- package/bin/chunk-tjretpx8.js +0 -1
- package/bin/chunk-w4yjgez6.js +0 -14
- package/bin/chunk-wjcebkpb.js +0 -1
- package/bin/chunk-ws71fg50.js +0 -2
- package/bin/chunk-yfp3q4da.js +0 -1
- package/bin/chunk-z8e4wc59.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{I,
|
|
2
|
-
export{
|
|
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
|
+
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};
|