@shumai-one/shumai 0.2.2 → 0.2.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.
Files changed (41) hide show
  1. package/bin/{chunk-fd5a3pdd.js → chunk-2a9n3dhx.js} +1 -1
  2. package/bin/{chunk-4e3jbp84.js → chunk-3hzj13pj.js} +1 -1
  3. package/bin/{chunk-fa2g2wge.js → chunk-3n1rezd0.js} +1 -1
  4. package/bin/{chunk-ry33f2qk.js → chunk-3qks722n.js} +1 -1
  5. package/bin/{chunk-sd86v1e6.js → chunk-5vkf99sk.js} +1 -1
  6. package/bin/{chunk-qqk51620.js → chunk-6xg65n5y.js} +1 -1
  7. package/bin/{chunk-h0ytx8zc.js → chunk-6zascpcz.js} +1 -1
  8. package/bin/{chunk-jf3vn5c3.js → chunk-898q6x3q.js} +1 -1
  9. package/bin/chunk-8dqq1fk0.js +2 -0
  10. package/bin/{chunk-xyjw8w3r.js → chunk-b73ktdmd.js} +1 -1
  11. package/bin/{chunk-szzff7gd.js → chunk-carknytp.js} +1 -1
  12. package/bin/chunk-chkx04mw.js +1 -0
  13. package/bin/{chunk-pq18zenh.js → chunk-crt1e1w1.js} +1 -1
  14. package/bin/{chunk-5m9be8an.js → chunk-dgat7wqv.js} +1 -1
  15. package/bin/{chunk-wg98cacx.js → chunk-dm2w12rc.js} +1 -1
  16. package/bin/{chunk-de99643r.js → chunk-g21jxrt9.js} +1 -1
  17. package/bin/{chunk-4jk0y1w1.js → chunk-hnhq0dh9.js} +1 -1
  18. package/bin/{chunk-y2qp11v9.js → chunk-j0c7d9y1.js} +1 -1
  19. package/bin/chunk-jqh8kavv.js +2 -0
  20. package/bin/{chunk-5r8858hx.js → chunk-js9yf457.js} +1 -1
  21. package/bin/{chunk-f14sqw1d.js → chunk-jyzegph4.js} +1 -1
  22. package/bin/{chunk-fepymbka.js → chunk-mnfqdxms.js} +1 -1
  23. package/bin/{chunk-7e06b2zb.js → chunk-nhsqp8jc.js} +1 -1
  24. package/bin/chunk-nnkkem25.js +3 -0
  25. package/bin/{chunk-92xxys10.js → chunk-qwg2e3wr.js} +2 -2
  26. package/bin/{chunk-tspps87j.js → chunk-se8rgwp8.js} +1 -1
  27. package/bin/{chunk-pmswtfe3.css → chunk-tm6z4hkd.css} +1 -1
  28. package/bin/chunk-wckjyvtb.js +5 -0
  29. package/bin/{chunk-q24epdh8.js → chunk-wfx81mfv.js} +1 -1
  30. package/bin/chunk-wtjc4565.js +1 -0
  31. package/bin/{chunk-r0w920zb.js → chunk-y79r28gd.js} +1 -1
  32. package/bin/{chunk-8mkfgcvb.js → chunk-yj4x7tpw.js} +1 -1
  33. package/bin/shumai-app.html +1 -1
  34. package/bin/shumai-app.js +2 -2
  35. package/package.json +8 -8
  36. package/bin/chunk-2g12s6mc.js +0 -2
  37. package/bin/chunk-54tr7y2x.js +0 -3
  38. package/bin/chunk-byqc8tzq.js +0 -1
  39. package/bin/chunk-ccw7mjgq.js +0 -5
  40. package/bin/chunk-f7sbkfmk.js +0 -2
  41. package/bin/chunk-g6zzg6v2.js +0 -1
@@ -1,2 +1,2 @@
1
- import{Sa as BK,Ua as gJ}from"./chunk-srn8t0v7.js";import{Wa as ZJ}from"./chunk-kfhtk3eh.js";import{$a as _K,_a as ZK,ab as $K,bb as GK,cb as zK,db as QK,eb as HK,fb as UK}from"./chunk-0xbf8bcg.js";import{og as $J}from"./chunk-fa2g2wge.js";import{Qg as N,Rg as QJ,Tg as HJ,Ug as UJ,Vg as w,Zg as KK,ch as WK,dh as XK,eh as TJ,fh as RJ,gh as SJ,hh as fJ,ih as hJ,jh as YK}from"./chunk-gswbc6y9.js";import{$h as zJ,Ah as h,Ai as XJ,Bh as GJ,Bi as YJ,Cj as uJ,Di as tJ,Ji as DJ,Pi as eJ,Qh as z,Sh as U,Wi as kJ,ai as p,ei as nJ,gi as aJ,gk as O,mh as NK,mk as W,nh as iJ,oh as J,oj as wJ,ph as X,pi as rJ,qh as lJ,uj as JK,vh as v,wh as _J,wi as oJ,yi as sJ,zh as dJ}from"./chunk-nyhqy6q2.js";import{Vk as vK}from"./chunk-0qkj838r.js";var _=vK(NK(),1);function cK({teamId:B,projectId:Z,projectName:$,rootFolderId:P,dragState:b,onSelect:M,selectedFolderId:A,hideCollections:m,hideShares:C,ancestorFolders:D}){let q=GJ(),Q=lJ(),{canEdit:V}=WK(Z),j=dJ({from:"/projects/$projectId/recently-deleted",shouldThrow:!1}),[L,r]=_.useState(!0),[T,BJ]=_.useState(!0),[u,bJ]=_.useState(!0),{data:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:R}=_J({queryKey:["shares",Z],queryFn:async({pageParam:K})=>{let Y=await U.api.projects[":projectId"].shares.$get({param:{projectId:Z},query:{first:"20",after:K}});if(!Y.ok)throw Error(W.failed_fetch_share_links());return await Y.json()},initialPageParam:"",getNextPageParam:(K)=>K.pageInfo?.cursor||void 0,enabled:!!Z}),{data:l,fetchNextPage:o,hasNextPage:d,isFetchingNextPage:n}=_J({queryKey:["collections",Z],queryFn:async({pageParam:K})=>{let Y=await U.api.projects[":projectId"].collections.$get({param:{projectId:Z},query:{first:"20",after:K}});if(!Y.ok)throw Error(W.failed_fetch_collections());return await Y.json()},initialPageParam:"",getNextPageParam:(K)=>K.pageInfo?.cursor||void 0,enabled:!!Z}),{ref:qJ,inView:s}=$J(),{ref:VJ,inView:t}=$J();_.useEffect(()=>{if(s&&d&&!n)o()},[s,d,n,o]),_.useEffect(()=>{if(t&&g&&!R)i()},[t,g,R,i]);let AJ=_.useMemo(()=>l?.pages.flatMap((K)=>K.data)||[],[l]),OJ=_.useMemo(()=>c?.pages.flatMap((K)=>K.data)||[],[c]),{mutate:PJ}=v({mutationFn:async()=>{let K=await U.api.projects[":projectId"].collections.$post({param:{projectId:Z},json:{name:W.untitled_collection(),filter:{sourceFolderId:P,searchFilter:{conditions:[],recursively:!0}}}});if(!K.ok)throw Error(W.failed_create_collection());return await K.json()},onSuccess:(K)=>{Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_created()),q({to:"/projects/$projectId/collections/$collectionId",params:{projectId:Z,collectionId:K.id}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:MJ}=v({mutationFn:async()=>{let K=await U.api.projects[":projectId"].shares.$post({param:{projectId:Z},json:{name:new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}});if(!K.ok)throw Error(W.failed_create_share_link());return await K.json()},onSuccess:(K)=>{Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_created()),q({to:"/projects/$projectId/shares/$shareId",params:{projectId:Z,shareId:K.id}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),e=h({from:"/projects/$projectId/collections/$collectionId",shouldThrow:!1}),LJ=h({from:"/projects/$projectId/shares/$shareId",shouldThrow:!1}),G=h({from:"/projects/$projectId/folders/$folderId",shouldThrow:!1}),[y,yJ]=_.useState(null),[F,EJ]=_.useState("collection"),[E,JJ]=_.useState(""),[qK,k]=_.useState(!1),[vJ,NJ]=_.useState(null),[S,CJ]=_.useState("collection"),[VK,f]=_.useState(!1),{mutate:IJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.folders[":folderId"].$put({param:{folderId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_folder());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["search",B]}),Q.invalidateQueries({queryKey:["folders"]}),z.success(W.folder_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:AK}=v({mutationFn:async(K)=>{if(!(await U.api.folders.$delete({json:{ids:[K]}})).ok)throw Error(W.failed_delete_folder());return K},onSuccess:(K)=>{if(Q.invalidateQueries({queryKey:["search",B]}),Q.invalidateQueries({queryKey:["folders"]}),z.success(W.folder_deleted()),f(!1),G?.folderId===K)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),[OK,a]=_.useState(!1),[KJ,xJ]=_.useState(!1),[FJ,pJ]=_.useState([]),PK=async(K)=>{a(!0),xJ(!0),pJ([]);try{let Y=await U.api.files["download-links"].$post({json:{ids:[K]}});if(!Y.ok)throw Error(W.failed_to_prepare_download_links());let H=await Y.json();pJ(H.files)}catch(Y){z.error(W.failed_to_prepare_download_links()),a(!1),console.error(Y)}finally{xJ(!1)}},MK=()=>{let K=[...FJ];if(a(!1),K.length===0)return;z.info(W.starting_download_files({count:K.length}),{duration:5000});let Y=(WJ)=>new Promise((I)=>setTimeout(I,WJ));(async()=>{for(let I=0;I<K.length;I+=5){let EK=K.slice(I,I+5);for(let cJ of EK){let x=document.createElement("a");x.href=cJ.url,x.download=cJ.name,x.target="_blank",document.body.appendChild(x),x.click(),x.remove()}await Y(1000)}})().catch((WJ)=>{console.error("Background downloads failed:",WJ),z.error(W.some_downloads_failed())})},{mutate:mJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.collections[":collectionId"].$patch({param:{collectionId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_collection());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:LK}=v({mutationFn:async(K)=>{let Y=await U.api.collections[":collectionId"].$delete({param:{collectionId:K}});if(!Y.ok)throw Error(W.failed_delete_collection());return await Y.json()},onSuccess:(K,Y)=>{if(Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_deleted()),f(!1),e?.collectionId===Y)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:jJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.shares[":shareId"].$put({param:{shareId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_share_link());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:yK}=v({mutationFn:async(K)=>{if(!(await U.api.shares[":shareId"].$delete({param:{shareId:K}})).ok)throw Error(W.failed_delete_share_link());return K},onSuccess:(K)=>{if(Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_deleted()),f(!1),LJ?.shareId===K)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}});return X("div",{className:"flex flex-col h-full overflow-hidden p-3 gap-4 bg-background",children:[X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out border-b border-border pb-4",L?"flex-1 min-h-[50%] h-full":"flex-none h-[44px] max-h-[44px]"),children:[J("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>r(!L),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.folder_tree_assets()}),L?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]})}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",L?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[J(bK,{teamId:B,projectId:Z,folder:{id:P,name:$,type:"folder",sizeByte:0,fileCount:0,status:"processed",createdAt:"",updatedAt:""},level:0,isRoot:!0,dragState:b,onSelect:M,selectedFolderId:A,canEdit:V,onRenameTrigger:(K,Y)=>{yJ(K),EJ("folder"),JJ(Y),k(!0)},onDeleteTrigger:(K)=>{NJ(K),CJ("folder"),f(!0)},onDownloadTrigger:(K)=>{PK(K)},ancestorFolders:D},P),V&&X("div",{className:O("group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",j&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),onClick:()=>q({to:"/projects/$projectId/recently-deleted",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(uJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.recently_deleted()})]})]})})]}),!m&&X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out border-b border-border pb-4",T?"flex-1 min-h-0 h-full":"flex-none h-[44px] max-h-[44px]"),children:[X("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:[X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>BJ(!T),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.collections()}),T?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]}),V&&J("button",{onClick:()=>PJ(),className:"text-muted-foreground hover:text-foreground flex-none",children:J(wJ,{className:"h-3.5 w-3.5"})})]}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",T?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[X("div",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>q({to:"/projects/$projectId/collections",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(kJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.all_collections_count({count:l?.pages[0]?.pageInfo?.total||0})})]}),AJ.map((K)=>{let Y=e?.collectionId===K.id;return X("div",{className:O("group flex cursor-pointer items-center justify-between rounded-md px-2 py-1 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",Y&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),onClick:()=>q({to:"/projects/$projectId/collections/$collectionId",params:{projectId:Z,collectionId:K.id}}),children:[X("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[J("div",{className:"flex h-4 w-4 items-center justify-center shrink-0",children:J(rJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"truncate text-sidebar-foreground flex-1",children:K.name})]}),V&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(H)=>H.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[J(w,{onClick:()=>{yJ(K.id),EJ("collection"),JJ(K.name),k(!0)},children:W.rename()}),J(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{NJ(K.id),CJ("collection"),f(!0)},children:W.delete()})]})]})})]},K.id)}),J("div",{ref:qJ,className:"h-1"}),n&&J("div",{className:"flex justify-center p-2",children:J(p,{className:"h-4 w-4 animate-spin text-muted-foreground"})})]})})]}),!C&&X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out",u?"flex-1 min-h-0 h-full":"flex-none h-[44px] max-h-[44px]"),children:[X("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:[X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>bJ(!u),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.share_links()}),u?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]}),V&&J("div",{className:"flex items-center gap-1 flex-none",children:J("button",{onClick:()=>MJ(),className:"text-muted-foreground hover:text-foreground",children:J(wJ,{className:"h-3.5 w-3.5"})})})]}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",u?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[X("div",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>q({to:"/projects/$projectId/shares",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(kJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.all_share_links_count({count:c?.pages[0]?.pageInfo?.total||0})})]}),OJ.map((K)=>J(CK,{link:K,projectId:Z,dragState:b,canEdit:V,onRenameTrigger:(Y,H)=>{yJ(Y),EJ("share"),JJ(H),k(!0)},onDeleteTrigger:(Y)=>{NJ(Y),CJ("share"),f(!0)}},K.id)),J("div",{ref:VJ,className:"h-1"}),R&&J("div",{className:"flex justify-center p-2",children:J(p,{className:"h-4 w-4 animate-spin text-muted-foreground"})})]})})]}),J(TJ,{open:qK,onOpenChange:k,children:X(RJ,{onClick:(K)=>K.stopPropagation(),children:[J(SJ,{children:J(hJ,{children:F==="collection"?W.rename_collection():F==="share"?W.rename_share_link():W.rename_folder()})}),J("div",{className:"py-4",children:J(XK,{value:E,onChange:(K)=>JJ(K.target.value),placeholder:W.enter_new_name(),onKeyDown:(K)=>{if(K.key==="Enter"&&E.trim()){if(F==="collection")mJ({id:y,name:E});else if(F==="share")jJ({id:y,name:E});else if(F==="folder")IJ({id:y,name:E})}}})}),X(fJ,{children:[J(N,{variant:"ghost",onClick:()=>k(!1),children:W.cancel()}),J(N,{disabled:!E.trim(),onClick:()=>{if(F==="collection")mJ({id:y,name:E});else if(F==="share")jJ({id:y,name:E});else if(F==="folder")IJ({id:y,name:E})},children:W.rename()})]})]})}),J(ZK,{open:VK,onOpenChange:f,children:X(_K,{onClick:(K)=>K.stopPropagation(),children:[X($K,{children:[J(zK,{children:S==="collection"?W.delete_collection_confirm():S==="share"?W.delete_share_link_confirm():W.delete_folder_confirm()}),J(QK,{children:W.delete_confirm_description({type:S==="collection"?W.collection():S==="share"?W.share_link():W.folder().toLowerCase()})})]}),X(GK,{children:[J(UK,{children:W.cancel()}),J(HK,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{if(S==="collection")LK(vJ);else if(S==="share")yK(vJ);else if(S==="folder")AK(vJ)},children:W.delete()})]})]})}),J(TJ,{open:OK,onOpenChange:a,children:X(RJ,{className:"sm:max-w-md",children:[X(SJ,{children:[J(hJ,{children:KJ?W.preparing_download():W.confirm_download()}),J(YK,{children:KJ?W.resolving_files_wait():W.folder_files_download_description()})]}),KJ?X("div",{className:"space-y-4 py-6 flex flex-col items-center justify-center",children:[J(p,{className:"h-8 w-8 animate-spin text-primary"}),J("span",{className:"text-sm font-medium text-muted-foreground mt-2",children:W.preparing_download_links()})]}):X("div",{className:"space-y-4 py-2",children:[J("div",{className:"text-sm text-muted-foreground",children:W.download_includes_files({count:FJ.length})}),X("div",{className:"flex items-start gap-3 p-3 text-sm rounded-lg bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 border border-amber-200 dark:border-amber-900/30",children:[J(aJ,{className:"h-5 w-5 shrink-0 mt-0.5"}),X("div",{children:[J("p",{className:"font-semibold",children:W.no_folder_structure()}),J("p",{className:"mt-0.5 text-xs text-amber-700/90 dark:text-amber-400/90",children:W.folder_structure_warning()})]})]})]}),J(fJ,{children:!KJ?X(iJ,{children:[J(N,{variant:"outline",onClick:()=>a(!1),children:W.cancel()}),X(N,{onClick:MK,className:"gap-2",disabled:FJ.length===0,children:[J(DJ,{className:"h-4 w-4"}),W.start_download()]})]}):J(N,{disabled:!0,variant:"outline",children:W.cancel()})})]})})]})}function CK({link:B,projectId:Z,dragState:$,canEdit:P,onRenameTrigger:b,onDeleteTrigger:M}){let A=GJ(),C=h({from:"/projects/$projectId/shares/$shareId",shouldThrow:!1})?.shareId===B.id,{ref:D,isDropTarget:q}=gJ({id:`share:${B.id}`,data:{type:"share-link",id:B.id}}),Q=!!$?.isActive;return X("div",{ref:D,className:O("group flex cursor-pointer items-center justify-between rounded-md px-2 py-1 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",C&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium",q&&Q&&"bg-sidebar-accent ring-2 ring-primary ring-inset"),onClick:()=>A({to:"/projects/$projectId/shares/$shareId",params:{projectId:Z,shareId:B.id}}),children:[X("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[J("div",{className:"flex h-4 w-4 items-center justify-center shrink-0",children:J(JK,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"truncate text-sidebar-foreground flex-1",children:B.name})]}),P&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(V)=>V.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[J(w,{onClick:()=>{b(B.id,B.name)},children:W.rename()}),J(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{M(B.id)},children:W.delete()})]})]})})]})}function bK({teamId:B,projectId:Z,folder:$,level:P,isRoot:b,dragState:M,onSelect:A,selectedFolderId:m,canEdit:C,onRenameTrigger:D,onDeleteTrigger:q,onDownloadTrigger:Q,ancestorFolders:V}){let j=_.useMemo(()=>{return V?.some((G)=>G.id===$.id)??!1},[V,$.id]),[L,r]=_.useState(b||j);_.useEffect(()=>{if(j)r(!0)},[j]);let T=GJ(),BJ=h({from:"/projects/$projectId/folders/$folderId",select:(G)=>({folderId:G.folderId}),shouldThrow:!1}),u=h({from:"/projects/$projectId/",shouldThrow:!1}),bJ=b?!!u:BJ?.folderId===$.id,{data:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:R,isLoading:l}=_J({queryKey:["folders",$.id,"children",{assetType:"folder"}],queryFn:async({pageParam:G})=>{let y=await U.api.folders[":folderId"].children.$get({param:{folderId:$.id},query:{assetType:"folder",after:G,first:"20"}});if(!y.ok)throw Error(W.failed_to_fetch_folder_children());return await y.json()},initialPageParam:"",getNextPageParam:(G)=>{return G.pageInfo?.cursor||void 0},enabled:L||!!b}),{ref:o,inView:d}=$J();_.useEffect(()=>{if(d&&g&&!R)i()},[d,g,R,i]);let n=c?.pages.flatMap((G)=>G.data??[])??[],qJ=(G)=>{G.stopPropagation(),r(!L)},s=()=>{if(A){A($);return}if(b)T({to:"/projects/$projectId",params:{projectId:Z}});else T({to:"/projects/$projectId/folders/$folderId",params:{projectId:Z,folderId:$.id}})},{ref:VJ,isDragging:t}=BK({id:`tree:${$.id}`,data:{type:"folder",item:$},disabled:!!b||!!A||!C}),{ref:AJ,isDropTarget:OJ}=gJ({id:`tree:${$.id}`,data:{type:"folder",item:$},disabled:M?.draggedIds.has($.id)||!!A||!C}),PJ=(G)=>{VJ(G),AJ(G)},MJ=_.useMemo(()=>{if(A)return!1;if(!M?.isActive)return!1;if(M.draggedIds.has($.id))return!1;return!0},[M,$.id,A]),e=OJ&&MJ,LJ=m===$.id;return X("div",{children:[X("div",{ref:PJ,className:O("group flex cursor-pointer items-center gap-1 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",(bJ||LJ)&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium",t&&"opacity-50",e&&"bg-sidebar-accent ring-2 ring-primary ring-inset"),style:{...b?{}:{paddingLeft:`${P*12+8}px`}},onClick:s,children:[!b&&J("button",{onClick:qJ,className:"flex h-4 w-4 items-center justify-center shrink-0",children:L?J(oJ,{className:"h-3 w-3"}):J(sJ,{className:"h-3 w-3"})}),b?J(tJ,{className:"h-4 w-4 text-sidebar-primary shrink-0"}):J(eJ,{className:"h-4 w-4 text-sidebar-primary shrink-0"}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:$.name}),C&&!b&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(G)=>G.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[X(w,{onClick:()=>{D($.id,$.name)},children:[J(nJ,{className:"mr-2 h-4 w-4"}),W.rename()]}),X(w,{onClick:()=>{Q($.id)},children:[J(DJ,{className:"mr-2 h-4 w-4"}),W.download()]}),J(KK,{}),X(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{q($.id)},children:[J(uJ,{className:"mr-2 h-4 w-4"}),W.delete()]})]})]})})]}),L&&X("div",{children:[l&&J("div",{className:"flex items-center justify-center p-2",style:{paddingLeft:`${(P+1)*12+8}px`},children:J(p,{className:"h-4 w-4 animate-spin"})}),n.map((G)=>J(bK,{teamId:B,projectId:Z,folder:G,level:P+1,dragState:M,onSelect:A,selectedFolderId:m,canEdit:C,onRenameTrigger:D,onDeleteTrigger:q,onDownloadTrigger:Q,ancestorFolders:V},G.id)),g&&J("div",{ref:o,className:"flex items-center justify-center p-2",style:{paddingLeft:`${(P+1)*12+8}px`},children:R&&J(p,{className:"h-4 w-4 animate-spin"})})]})]})}
1
+ import{Sa as BK,Ua as gJ}from"./chunk-srn8t0v7.js";import{Wa as ZJ}from"./chunk-kfhtk3eh.js";import{$a as _K,_a as ZK,ab as $K,bb as GK,cb as zK,db as QK,eb as HK,fb as UK}from"./chunk-0xbf8bcg.js";import{og as $J}from"./chunk-3n1rezd0.js";import{Qg as N,Rg as QJ,Tg as HJ,Ug as UJ,Vg as w,Zg as KK,ch as WK,dh as XK,eh as TJ,fh as RJ,gh as SJ,hh as fJ,ih as hJ,jh as YK}from"./chunk-gswbc6y9.js";import{$h as zJ,Ah as h,Ai as XJ,Bh as GJ,Bi as YJ,Cj as uJ,Di as tJ,Ji as DJ,Pi as eJ,Qh as z,Sh as U,Wi as kJ,ai as p,ei as nJ,gi as aJ,gk as O,mh as NK,mk as W,nh as iJ,oh as J,oj as wJ,ph as X,pi as rJ,qh as lJ,uj as JK,vh as v,wh as _J,wi as oJ,yi as sJ,zh as dJ}from"./chunk-nyhqy6q2.js";import{Vk as vK}from"./chunk-0qkj838r.js";var _=vK(NK(),1);function cK({teamId:B,projectId:Z,projectName:$,rootFolderId:P,dragState:b,onSelect:M,selectedFolderId:A,hideCollections:m,hideShares:C,ancestorFolders:D}){let q=GJ(),Q=lJ(),{canEdit:V}=WK(Z),j=dJ({from:"/projects/$projectId/recently-deleted",shouldThrow:!1}),[L,r]=_.useState(!0),[T,BJ]=_.useState(!0),[u,bJ]=_.useState(!0),{data:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:R}=_J({queryKey:["shares",Z],queryFn:async({pageParam:K})=>{let Y=await U.api.projects[":projectId"].shares.$get({param:{projectId:Z},query:{first:"20",after:K}});if(!Y.ok)throw Error(W.failed_fetch_share_links());return await Y.json()},initialPageParam:"",getNextPageParam:(K)=>K.pageInfo?.cursor||void 0,enabled:!!Z}),{data:l,fetchNextPage:o,hasNextPage:d,isFetchingNextPage:n}=_J({queryKey:["collections",Z],queryFn:async({pageParam:K})=>{let Y=await U.api.projects[":projectId"].collections.$get({param:{projectId:Z},query:{first:"20",after:K}});if(!Y.ok)throw Error(W.failed_fetch_collections());return await Y.json()},initialPageParam:"",getNextPageParam:(K)=>K.pageInfo?.cursor||void 0,enabled:!!Z}),{ref:qJ,inView:s}=$J(),{ref:VJ,inView:t}=$J();_.useEffect(()=>{if(s&&d&&!n)o()},[s,d,n,o]),_.useEffect(()=>{if(t&&g&&!R)i()},[t,g,R,i]);let AJ=_.useMemo(()=>l?.pages.flatMap((K)=>K.data)||[],[l]),OJ=_.useMemo(()=>c?.pages.flatMap((K)=>K.data)||[],[c]),{mutate:PJ}=v({mutationFn:async()=>{let K=await U.api.projects[":projectId"].collections.$post({param:{projectId:Z},json:{name:W.untitled_collection(),filter:{sourceFolderId:P,searchFilter:{conditions:[],recursively:!0}}}});if(!K.ok)throw Error(W.failed_create_collection());return await K.json()},onSuccess:(K)=>{Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_created()),q({to:"/projects/$projectId/collections/$collectionId",params:{projectId:Z,collectionId:K.id}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:MJ}=v({mutationFn:async()=>{let K=await U.api.projects[":projectId"].shares.$post({param:{projectId:Z},json:{name:new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}});if(!K.ok)throw Error(W.failed_create_share_link());return await K.json()},onSuccess:(K)=>{Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_created()),q({to:"/projects/$projectId/shares/$shareId",params:{projectId:Z,shareId:K.id}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),e=h({from:"/projects/$projectId/collections/$collectionId",shouldThrow:!1}),LJ=h({from:"/projects/$projectId/shares/$shareId",shouldThrow:!1}),G=h({from:"/projects/$projectId/folders/$folderId",shouldThrow:!1}),[y,yJ]=_.useState(null),[F,EJ]=_.useState("collection"),[E,JJ]=_.useState(""),[qK,k]=_.useState(!1),[vJ,NJ]=_.useState(null),[S,CJ]=_.useState("collection"),[VK,f]=_.useState(!1),{mutate:IJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.folders[":folderId"].$put({param:{folderId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_folder());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["search",B]}),Q.invalidateQueries({queryKey:["folders"]}),z.success(W.folder_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:AK}=v({mutationFn:async(K)=>{if(!(await U.api.folders.$delete({json:{ids:[K]}})).ok)throw Error(W.failed_delete_folder());return K},onSuccess:(K)=>{if(Q.invalidateQueries({queryKey:["search",B]}),Q.invalidateQueries({queryKey:["folders"]}),z.success(W.folder_deleted()),f(!1),G?.folderId===K)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),[OK,a]=_.useState(!1),[KJ,xJ]=_.useState(!1),[FJ,pJ]=_.useState([]),PK=async(K)=>{a(!0),xJ(!0),pJ([]);try{let Y=await U.api.files["download-links"].$post({json:{ids:[K]}});if(!Y.ok)throw Error(W.failed_to_prepare_download_links());let H=await Y.json();pJ(H.files)}catch(Y){z.error(W.failed_to_prepare_download_links()),a(!1),console.error(Y)}finally{xJ(!1)}},MK=()=>{let K=[...FJ];if(a(!1),K.length===0)return;z.info(W.starting_download_files({count:K.length}),{duration:5000});let Y=(WJ)=>new Promise((I)=>setTimeout(I,WJ));(async()=>{for(let I=0;I<K.length;I+=5){let EK=K.slice(I,I+5);for(let cJ of EK){let x=document.createElement("a");x.href=cJ.url,x.download=cJ.name,x.target="_blank",document.body.appendChild(x),x.click(),x.remove()}await Y(1000)}})().catch((WJ)=>{console.error("Background downloads failed:",WJ),z.error(W.some_downloads_failed())})},{mutate:mJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.collections[":collectionId"].$patch({param:{collectionId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_collection());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:LK}=v({mutationFn:async(K)=>{let Y=await U.api.collections[":collectionId"].$delete({param:{collectionId:K}});if(!Y.ok)throw Error(W.failed_delete_collection());return await Y.json()},onSuccess:(K,Y)=>{if(Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_deleted()),f(!1),e?.collectionId===Y)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:jJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.shares[":shareId"].$put({param:{shareId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_share_link());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:yK}=v({mutationFn:async(K)=>{if(!(await U.api.shares[":shareId"].$delete({param:{shareId:K}})).ok)throw Error(W.failed_delete_share_link());return K},onSuccess:(K)=>{if(Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_deleted()),f(!1),LJ?.shareId===K)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}});return X("div",{className:"flex flex-col h-full overflow-hidden p-3 gap-4 bg-background",children:[X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out border-b border-border pb-4",L?"flex-1 min-h-[50%] h-full":"flex-none h-[44px] max-h-[44px]"),children:[J("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>r(!L),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.folder_tree_assets()}),L?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]})}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",L?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[J(bK,{teamId:B,projectId:Z,folder:{id:P,name:$,type:"folder",sizeByte:0,fileCount:0,status:"processed",createdAt:"",updatedAt:""},level:0,isRoot:!0,dragState:b,onSelect:M,selectedFolderId:A,canEdit:V,onRenameTrigger:(K,Y)=>{yJ(K),EJ("folder"),JJ(Y),k(!0)},onDeleteTrigger:(K)=>{NJ(K),CJ("folder"),f(!0)},onDownloadTrigger:(K)=>{PK(K)},ancestorFolders:D},P),V&&X("div",{className:O("group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",j&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),onClick:()=>q({to:"/projects/$projectId/recently-deleted",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(uJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.recently_deleted()})]})]})})]}),!m&&X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out border-b border-border pb-4",T?"flex-1 min-h-0 h-full":"flex-none h-[44px] max-h-[44px]"),children:[X("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:[X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>BJ(!T),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.collections()}),T?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]}),V&&J("button",{onClick:()=>PJ(),className:"text-muted-foreground hover:text-foreground flex-none",children:J(wJ,{className:"h-3.5 w-3.5"})})]}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",T?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[X("div",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>q({to:"/projects/$projectId/collections",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(kJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.all_collections_count({count:l?.pages[0]?.pageInfo?.total||0})})]}),AJ.map((K)=>{let Y=e?.collectionId===K.id;return X("div",{className:O("group flex cursor-pointer items-center justify-between rounded-md px-2 py-1 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",Y&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),onClick:()=>q({to:"/projects/$projectId/collections/$collectionId",params:{projectId:Z,collectionId:K.id}}),children:[X("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[J("div",{className:"flex h-4 w-4 items-center justify-center shrink-0",children:J(rJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"truncate text-sidebar-foreground flex-1",children:K.name})]}),V&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(H)=>H.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[J(w,{onClick:()=>{yJ(K.id),EJ("collection"),JJ(K.name),k(!0)},children:W.rename()}),J(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{NJ(K.id),CJ("collection"),f(!0)},children:W.delete()})]})]})})]},K.id)}),J("div",{ref:qJ,className:"h-1"}),n&&J("div",{className:"flex justify-center p-2",children:J(p,{className:"h-4 w-4 animate-spin text-muted-foreground"})})]})})]}),!C&&X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out",u?"flex-1 min-h-0 h-full":"flex-none h-[44px] max-h-[44px]"),children:[X("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:[X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>bJ(!u),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.share_links()}),u?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]}),V&&J("div",{className:"flex items-center gap-1 flex-none",children:J("button",{onClick:()=>MJ(),className:"text-muted-foreground hover:text-foreground",children:J(wJ,{className:"h-3.5 w-3.5"})})})]}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",u?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[X("div",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>q({to:"/projects/$projectId/shares",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(kJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.all_share_links_count({count:c?.pages[0]?.pageInfo?.total||0})})]}),OJ.map((K)=>J(CK,{link:K,projectId:Z,dragState:b,canEdit:V,onRenameTrigger:(Y,H)=>{yJ(Y),EJ("share"),JJ(H),k(!0)},onDeleteTrigger:(Y)=>{NJ(Y),CJ("share"),f(!0)}},K.id)),J("div",{ref:VJ,className:"h-1"}),R&&J("div",{className:"flex justify-center p-2",children:J(p,{className:"h-4 w-4 animate-spin text-muted-foreground"})})]})})]}),J(TJ,{open:qK,onOpenChange:k,children:X(RJ,{onClick:(K)=>K.stopPropagation(),children:[J(SJ,{children:J(hJ,{children:F==="collection"?W.rename_collection():F==="share"?W.rename_share_link():W.rename_folder()})}),J("div",{className:"py-4",children:J(XK,{value:E,onChange:(K)=>JJ(K.target.value),placeholder:W.enter_new_name(),onKeyDown:(K)=>{if(K.key==="Enter"&&E.trim()){if(F==="collection")mJ({id:y,name:E});else if(F==="share")jJ({id:y,name:E});else if(F==="folder")IJ({id:y,name:E})}}})}),X(fJ,{children:[J(N,{variant:"ghost",onClick:()=>k(!1),children:W.cancel()}),J(N,{disabled:!E.trim(),onClick:()=>{if(F==="collection")mJ({id:y,name:E});else if(F==="share")jJ({id:y,name:E});else if(F==="folder")IJ({id:y,name:E})},children:W.rename()})]})]})}),J(ZK,{open:VK,onOpenChange:f,children:X(_K,{onClick:(K)=>K.stopPropagation(),children:[X($K,{children:[J(zK,{children:S==="collection"?W.delete_collection_confirm():S==="share"?W.delete_share_link_confirm():W.delete_folder_confirm()}),J(QK,{children:W.delete_confirm_description({type:S==="collection"?W.collection():S==="share"?W.share_link():W.folder().toLowerCase()})})]}),X(GK,{children:[J(UK,{children:W.cancel()}),J(HK,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{if(S==="collection")LK(vJ);else if(S==="share")yK(vJ);else if(S==="folder")AK(vJ)},children:W.delete()})]})]})}),J(TJ,{open:OK,onOpenChange:a,children:X(RJ,{className:"sm:max-w-md",children:[X(SJ,{children:[J(hJ,{children:KJ?W.preparing_download():W.confirm_download()}),J(YK,{children:KJ?W.resolving_files_wait():W.folder_files_download_description()})]}),KJ?X("div",{className:"space-y-4 py-6 flex flex-col items-center justify-center",children:[J(p,{className:"h-8 w-8 animate-spin text-primary"}),J("span",{className:"text-sm font-medium text-muted-foreground mt-2",children:W.preparing_download_links()})]}):X("div",{className:"space-y-4 py-2",children:[J("div",{className:"text-sm text-muted-foreground",children:W.download_includes_files({count:FJ.length})}),X("div",{className:"flex items-start gap-3 p-3 text-sm rounded-lg bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 border border-amber-200 dark:border-amber-900/30",children:[J(aJ,{className:"h-5 w-5 shrink-0 mt-0.5"}),X("div",{children:[J("p",{className:"font-semibold",children:W.no_folder_structure()}),J("p",{className:"mt-0.5 text-xs text-amber-700/90 dark:text-amber-400/90",children:W.folder_structure_warning()})]})]})]}),J(fJ,{children:!KJ?X(iJ,{children:[J(N,{variant:"outline",onClick:()=>a(!1),children:W.cancel()}),X(N,{onClick:MK,className:"gap-2",disabled:FJ.length===0,children:[J(DJ,{className:"h-4 w-4"}),W.start_download()]})]}):J(N,{disabled:!0,variant:"outline",children:W.cancel()})})]})})]})}function CK({link:B,projectId:Z,dragState:$,canEdit:P,onRenameTrigger:b,onDeleteTrigger:M}){let A=GJ(),C=h({from:"/projects/$projectId/shares/$shareId",shouldThrow:!1})?.shareId===B.id,{ref:D,isDropTarget:q}=gJ({id:`share:${B.id}`,data:{type:"share-link",id:B.id}}),Q=!!$?.isActive;return X("div",{ref:D,className:O("group flex cursor-pointer items-center justify-between rounded-md px-2 py-1 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",C&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium",q&&Q&&"bg-sidebar-accent ring-2 ring-primary ring-inset"),onClick:()=>A({to:"/projects/$projectId/shares/$shareId",params:{projectId:Z,shareId:B.id}}),children:[X("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[J("div",{className:"flex h-4 w-4 items-center justify-center shrink-0",children:J(JK,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"truncate text-sidebar-foreground flex-1",children:B.name})]}),P&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(V)=>V.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[J(w,{onClick:()=>{b(B.id,B.name)},children:W.rename()}),J(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{M(B.id)},children:W.delete()})]})]})})]})}function bK({teamId:B,projectId:Z,folder:$,level:P,isRoot:b,dragState:M,onSelect:A,selectedFolderId:m,canEdit:C,onRenameTrigger:D,onDeleteTrigger:q,onDownloadTrigger:Q,ancestorFolders:V}){let j=_.useMemo(()=>{return V?.some((G)=>G.id===$.id)??!1},[V,$.id]),[L,r]=_.useState(b||j);_.useEffect(()=>{if(j)r(!0)},[j]);let T=GJ(),BJ=h({from:"/projects/$projectId/folders/$folderId",select:(G)=>({folderId:G.folderId}),shouldThrow:!1}),u=h({from:"/projects/$projectId/",shouldThrow:!1}),bJ=b?!!u:BJ?.folderId===$.id,{data:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:R,isLoading:l}=_J({queryKey:["folders",$.id,"children",{assetType:"folder"}],queryFn:async({pageParam:G})=>{let y=await U.api.folders[":folderId"].children.$get({param:{folderId:$.id},query:{assetType:"folder",after:G,first:"20"}});if(!y.ok)throw Error(W.failed_to_fetch_folder_children());return await y.json()},initialPageParam:"",getNextPageParam:(G)=>{return G.pageInfo?.cursor||void 0},enabled:L||!!b}),{ref:o,inView:d}=$J();_.useEffect(()=>{if(d&&g&&!R)i()},[d,g,R,i]);let n=c?.pages.flatMap((G)=>G.data??[])??[],qJ=(G)=>{G.stopPropagation(),r(!L)},s=()=>{if(A){A($);return}if(b)T({to:"/projects/$projectId",params:{projectId:Z}});else T({to:"/projects/$projectId/folders/$folderId",params:{projectId:Z,folderId:$.id}})},{ref:VJ,isDragging:t}=BK({id:`tree:${$.id}`,data:{type:"folder",item:$},disabled:!!b||!!A||!C}),{ref:AJ,isDropTarget:OJ}=gJ({id:`tree:${$.id}`,data:{type:"folder",item:$},disabled:M?.draggedIds.has($.id)||!!A||!C}),PJ=(G)=>{VJ(G),AJ(G)},MJ=_.useMemo(()=>{if(A)return!1;if(!M?.isActive)return!1;if(M.draggedIds.has($.id))return!1;return!0},[M,$.id,A]),e=OJ&&MJ,LJ=m===$.id;return X("div",{children:[X("div",{ref:PJ,className:O("group flex cursor-pointer items-center gap-1 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",(bJ||LJ)&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium",t&&"opacity-50",e&&"bg-sidebar-accent ring-2 ring-primary ring-inset"),style:{...b?{}:{paddingLeft:`${P*12+8}px`}},onClick:s,children:[!b&&J("button",{onClick:qJ,className:"flex h-4 w-4 items-center justify-center shrink-0",children:L?J(oJ,{className:"h-3 w-3"}):J(sJ,{className:"h-3 w-3"})}),b?J(tJ,{className:"h-4 w-4 text-sidebar-primary shrink-0"}):J(eJ,{className:"h-4 w-4 text-sidebar-primary shrink-0"}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:$.name}),C&&!b&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(G)=>G.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[X(w,{onClick:()=>{D($.id,$.name)},children:[J(nJ,{className:"mr-2 h-4 w-4"}),W.rename()]}),X(w,{onClick:()=>{Q($.id)},children:[J(DJ,{className:"mr-2 h-4 w-4"}),W.download()]}),J(KK,{}),X(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{q($.id)},children:[J(uJ,{className:"mr-2 h-4 w-4"}),W.delete()]})]})]})})]}),L&&X("div",{children:[l&&J("div",{className:"flex items-center justify-center p-2",style:{paddingLeft:`${(P+1)*12+8}px`},children:J(p,{className:"h-4 w-4 animate-spin"})}),n.map((G)=>J(bK,{teamId:B,projectId:Z,folder:G,level:P+1,dragState:M,onSelect:A,selectedFolderId:m,canEdit:C,onRenameTrigger:D,onDeleteTrigger:q,onDownloadTrigger:Q,ancestorFolders:V},G.id)),g&&J("div",{ref:o,className:"flex items-center justify-center p-2",style:{paddingLeft:`${(P+1)*12+8}px`},children:R&&J(p,{className:"h-4 w-4 animate-spin"})})]})]})}
2
2
  export{cK as fa};
@@ -0,0 +1,3 @@
1
+ import{Kh as O,Lh as R,Qh as $,Sh as D,mh as x,th as v}from"./chunk-nyhqy6q2.js";import{Vk as b}from"./chunk-0qkj838r.js";var E=null,I=R((p)=>({projectState:null,setProjectState:(c)=>{if(E)clearTimeout(E),E=null;p({projectState:c})},clearProjectState:()=>{if(E)clearTimeout(E);E=setTimeout(()=>{p({projectState:null}),E=null},10)}}));var H=R((p)=>({isChatbotOpen:!1,setIsChatbotOpen:(c)=>p({isChatbotOpen:c}),isHistoryMode:!1,setIsHistoryMode:(c)=>p({isHistoryMode:c}),currentSessionId:null,setCurrentSessionId:(c)=>p({currentSessionId:c}),chatAssets:[],addAssets:(c)=>p((j)=>{let f=new Set(j.chatAssets.map((T)=>T.id)),F=c.filter((T)=>!f.has(T.id));return{chatAssets:[...j.chatAssets,...F]}}),removeAsset:(c)=>p((j)=>({chatAssets:j.chatAssets.filter((f)=>f.id!==c)})),clearAssets:()=>p({chatAssets:[]}),messages:[],setMessages:(c)=>p({messages:c}),historySessions:[],setHistorySessions:(c)=>p({historySessions:c}),isStreaming:!1,setIsStreaming:(c)=>p({isStreaming:c}),selectedAgentId:null,setSelectedAgentId:(c)=>p({selectedAgentId:c}),scrollTop:0,isAtBottom:!0,setScrollState:(c,j)=>p({scrollTop:c,isAtBottom:j}),fetchHistorySessions:async(c)=>{try{let j=await D.api.teams[":teamId"].chat.sessions.$get({param:{teamId:c},query:{first:"50"}});if(j.ok){let f=await j.json();p({historySessions:f.data||[]})}}catch(j){console.error("Failed to fetch history sessions:",j)}},loadSession:async(c,j)=>{try{let f=await D.api.teams[":teamId"].chat.sessions[":sessionId"].messages.$get({param:{teamId:c,sessionId:j}});if(f.ok){let F=await f.json(),P=H.getState().historySessions.find((J)=>J.id===j)?.agentId||null;p({currentSessionId:j,messages:F,isHistoryMode:!1,scrollTop:0,isAtBottom:!0,...P?{selectedAgentId:P}:{}})}else throw Error("Failed to load session messages")}catch(f){let F=f instanceof Error?f.message:"Failed to load session";$.error(F)}},deleteSession:async(c,j)=>{try{if((await D.api.teams[":teamId"].chat.sessions[":sessionId"].$delete({param:{teamId:c,sessionId:j}})).ok)$.success("Session deleted successfully"),p((F)=>({historySessions:F.historySessions.filter((T)=>T.id!==j),currentSessionId:F.currentSessionId===j?null:F.currentSessionId,messages:F.currentSessionId===j?[]:F.messages}));else throw Error("Failed to delete session")}catch(f){let F=f instanceof Error?f.message:"Failed to delete session";$.error(F)}},startNewSession:()=>{p({currentSessionId:null,messages:[],chatAssets:[],scrollTop:0,isAtBottom:!0})},sendMessage:async(c,j,f,F,T)=>{let P=H.getState();if(P.isStreaming)return;let J=`temp-${Date.now()}`,C={id:J,role:"user",content:[{type:"text",text:j}],timestamp:Date.now()},V=[...P.messages];if(P.chatAssets.length>0){let G={id:`temp-context-${Date.now()}`,role:"custom",customType:"context_display_info",details:{assets:P.chatAssets.map((k)=>({id:k.id,name:k.name,type:k.type}))},timestamp:Date.now()-1};V.push(G)}V.push(C),p({messages:V,isStreaming:!0,chatAssets:[],isAtBottom:!0});let A=P.chatAssets.map((K)=>K.id),_=P.selectedAgentId;if(!_){$.error("No agent selected");return}try{let K=await D.api.teams[":teamId"].chat.$post({param:{teamId:c},json:{agentId:_,textPrompt:j,assetIds:A,sessionId:P.currentSessionId||void 0,contextAssetId:F,projectId:f}});if(!K.ok)throw Error("Failed to start chat");let G=K.headers.get("x-session-id");if(G&&!P.currentSessionId)p({currentSessionId:G});let k=K.body?.getReader();if(!k)throw Error("No stream body");let W=new TextDecoder,X="";while(!0){let{done:M,value:S}=await k.read();if(M)break;X+=W.decode(S,{stream:!0});let h=X.split(`
2
+ `);X=h.pop()||"";for(let u of h){let Y=u.trim();if(!Y)continue;if(Y.startsWith("data: ")){let y=Y.slice(6);try{let Q=JSON.parse(y);if(Q.type==="session"){if(!H.getState().currentSessionId)p({currentSessionId:Q.sessionId})}else if(Q.type==="entry"){let w=Q.entry,L=w;if(L.role==="toolResult"&&typeof L.toolName==="string"&&["create_file","create_folder","create_version"].includes(L.toolName)&&!L.isError)T?.();p((N)=>{let z=N.messages.some((q)=>q.id===w.id),Z=N.messages.filter((q)=>{if(w.role==="user"&&!z)return!(q.id.startsWith("temp-")&&!q.id.startsWith("temp-context-"));if(w.role==="custom"&&w.customType==="context_display_info"&&!z)return!q.id.startsWith("temp-context-");return!0}),B=Z.findIndex((q)=>q.id===w.id);if(B!==-1){let q=[...Z];return q[B]=w,{messages:q}}else return{messages:[...Z,w]}})}else if(Q.type==="done"){if(Q.status==="failed")$.error(Q.error||"Workflow failed")}}catch(Q){console.error("Error parsing SSE line:",Q)}}}}H.getState().fetchHistorySessions(c)}catch(K){let G=K instanceof Error?K.message:"Failed to send message";$.error(G),p((k)=>({messages:k.messages.filter((W)=>W.id!==J)}))}finally{p({isStreaming:!1})}},abortActiveSession:async(c)=>{let{currentSessionId:j,isStreaming:f}=H.getState();if(!j||!f)return;try{if((await D.api.teams[":teamId"].chat.sessions[":sessionId"].abort.$post({param:{teamId:c,sessionId:j}})).ok)$.success("Agent execution stopped");else throw Error("Failed to abort agent execution")}catch(F){let T=F instanceof Error?F.message:"Failed to abort execution";$.error(T)}}}));var U=b(x(),1);function l(p){let c=p.match(/teams\/([^/]+)/);if(c)return{teamId:c[1]};let j=p.match(/projects\/([^/]+)/);if(j)return{projectId:j[1]};return{}}function s(){let[p,c]=U.useState(),j=O({select:(P)=>P.location.pathname}),{teamId:f,projectId:F}=l(j),{data:T}=v({queryKey:["projects",F,"team"],queryFn:async()=>{let P=await D.api.projects[":projectId"].team.$get({param:{projectId:F}});if(!P.ok)throw Error("failed to fetch project team");return await P.json()},enabled:!!F});return U.useEffect(()=>{if(f)c(f);else if(T?.teamId)c(T.teamId)},[f,T]),p}
3
+ export{s as gg,I as hg,H as ig};