@shumai-one/shumai 0.3.7 → 0.3.8

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 (151) hide show
  1. package/bin/{chunk-9nyhmtp9.js → chunk-0mmw31pj.js} +2 -2
  2. package/bin/{chunk-gjn3w26y.js → chunk-0pm8c9bq.js} +2 -2
  3. package/bin/{chunk-50keqtz9.js → chunk-0qpz48vc.js} +1 -1
  4. package/bin/{chunk-zjj9qj6y.js → chunk-0zbwpfsk.js} +2 -2
  5. package/bin/chunk-15jsnygy.js +5 -0
  6. package/bin/chunk-16s5kfy8.css +1 -0
  7. package/bin/{chunk-hqkmdp31.js → chunk-21rp4vzr.js} +2 -2
  8. package/bin/chunk-24ke0th1.css +1 -0
  9. package/bin/{chunk-260wywfb.js → chunk-28n8xqhm.js} +1 -1
  10. package/bin/{chunk-7hnw6y6d.js → chunk-2dxd0bar.js} +2 -2
  11. package/bin/{chunk-3dx0p1ge.js → chunk-2ejky9qv.js} +1 -1
  12. package/bin/{chunk-dej1gq35.js → chunk-2em77vjv.js} +1 -1
  13. package/bin/{chunk-zg60j9x2.js → chunk-2q26gz0p.js} +1 -1
  14. package/bin/{chunk-9s02m95j.js → chunk-2t0asg3w.js} +2 -2
  15. package/bin/{chunk-rfyaphas.js → chunk-2xaq1y16.js} +2 -2
  16. package/bin/{chunk-qmpph1gt.js → chunk-33r4w0yv.js} +2 -2
  17. package/bin/{chunk-1xzc6z02.js → chunk-3bm3be9d.js} +1 -1
  18. package/bin/{chunk-1sqz0va1.js → chunk-3mx22sn7.js} +2 -2
  19. package/bin/chunk-4cmw4qmt.js +1 -0
  20. package/bin/chunk-4d3wm83a.js +2 -0
  21. package/bin/{chunk-0jkqmbcx.js → chunk-4g4g02e0.js} +1 -1
  22. package/bin/{chunk-tpp9qf5m.js → chunk-5386brz2.js} +2 -2
  23. package/bin/{chunk-98j2z6he.js → chunk-5f9fk8x0.js} +3 -3
  24. package/bin/chunk-5fj5w0gg.js +2 -0
  25. package/bin/chunk-61bxmjd9.js +2 -0
  26. package/bin/{chunk-ptw49k86.js → chunk-6pcs8810.js} +1 -1
  27. package/bin/{chunk-x3ynjbt5.js → chunk-6pmsknnk.js} +2 -2
  28. package/bin/{chunk-9xhnmnnb.js → chunk-6vwqg1ra.js} +2 -2
  29. package/bin/{chunk-2mqqghrz.js → chunk-75segwsp.js} +2 -2
  30. package/bin/{chunk-ftc48rbb.js → chunk-7c85cyn0.js} +3 -3
  31. package/bin/chunk-7eyg2kgv.js +1 -0
  32. package/bin/chunk-7r22vcjy.js +2 -0
  33. package/bin/{chunk-0ycwr0kb.js → chunk-80g5kcm0.js} +1 -1
  34. package/bin/{chunk-5gtew41y.js → chunk-8bhsdk1v.js} +1 -1
  35. package/bin/{chunk-1khzycf9.js → chunk-8fsrs7mh.js} +1 -1
  36. package/bin/chunk-8jfm1j41.js +1 -0
  37. package/bin/chunk-8n6segk5.js +1 -0
  38. package/bin/chunk-99f9r6xm.js +2 -0
  39. package/bin/{chunk-2086rsb2.js → chunk-9acfydwy.js} +1 -1
  40. package/bin/{chunk-vxpnp4xg.js → chunk-9ntwrvhz.js} +2 -2
  41. package/bin/{chunk-s0hgykza.js → chunk-agdza65r.js} +2 -2
  42. package/bin/{chunk-6zs49mef.js → chunk-antsxrw9.js} +1 -1
  43. package/bin/chunk-bapy3qv8.js +1 -0
  44. package/bin/chunk-bc2bf144.js +2 -0
  45. package/bin/{chunk-v8w2nxew.js → chunk-bznz6h19.js} +1 -1
  46. package/bin/{chunk-qcqw7wnv.js → chunk-c24an5j3.js} +1 -1
  47. package/bin/chunk-cm74nd4n.js +1 -0
  48. package/bin/{chunk-87wqbn4g.js → chunk-cynjx7ha.js} +2 -2
  49. package/bin/chunk-cyq3m4qz.js +1 -0
  50. package/bin/chunk-ddff7vm3.js +2 -0
  51. package/bin/{chunk-br5xkaf7.js → chunk-djqs6m7w.js} +3 -3
  52. package/bin/{chunk-60hpa5kf.js → chunk-dn8k5ef5.js} +1 -1
  53. package/bin/chunk-dqdqs0d9.js +1 -0
  54. package/bin/chunk-drjaw6a5.js +14 -0
  55. package/bin/chunk-drvwchyn.js +2 -0
  56. package/bin/{chunk-esrtafz0.js → chunk-e4se9q6n.js} +1 -1
  57. package/bin/chunk-eb551xw7.js +1 -0
  58. package/bin/{chunk-nvjp2rnh.js → chunk-en96pr5c.js} +2 -2
  59. package/bin/{chunk-r5dv0rfv.js → chunk-ep138kb3.js} +2 -2
  60. package/bin/{chunk-jszpvg8e.js → chunk-eqf7k7ax.js} +2 -2
  61. package/bin/{chunk-f2j2cqd1.js → chunk-f3rqamey.js} +2 -2
  62. package/bin/{chunk-3kqdgddm.js → chunk-fvwz4mgw.js} +2 -2
  63. package/bin/chunk-g3p6h6sw.js +68 -0
  64. package/bin/{chunk-81tb4v5v.js → chunk-h9f55mjv.js} +2 -2
  65. package/bin/{chunk-n4gghgrj.js → chunk-jfjjh86p.js} +2 -2
  66. package/bin/{chunk-83k0wa5k.js → chunk-jg31cnqc.js} +2 -2
  67. package/bin/chunk-jk87gxbb.js +2 -0
  68. package/bin/{chunk-4bn9eb9h.js → chunk-jqzvazsf.js} +1 -1
  69. package/bin/chunk-jyk483r4.js +1 -0
  70. package/bin/{chunk-48nzw50r.js → chunk-k0ysbh3h.js} +1 -1
  71. package/bin/{chunk-fcs4v6jq.js → chunk-k5yxntns.js} +2 -2
  72. package/bin/chunk-khjybf4y.js +1 -0
  73. package/bin/{chunk-38g3s1f3.js → chunk-kmt9fj1z.js} +2 -2
  74. package/bin/{chunk-503qq6sa.js → chunk-m49ar48r.js} +2 -2
  75. package/bin/{chunk-a0k1b4sq.js → chunk-m7d52gfe.js} +1 -1
  76. package/bin/{chunk-x6532q76.js → chunk-mjxay7yv.js} +1 -1
  77. package/bin/{chunk-zqg4f56h.js → chunk-mp5etccz.js} +1 -1
  78. package/bin/{chunk-9gzy30zm.js → chunk-n8pas7tj.js} +2 -2
  79. package/bin/{chunk-b8v7jvkb.js → chunk-nc632fxz.js} +2 -2
  80. package/bin/{chunk-6fv38qdc.js → chunk-nffrjwb7.js} +2 -2
  81. package/bin/{chunk-7k3ccca6.js → chunk-p1rrkrn4.js} +1 -1
  82. package/bin/chunk-p6ep6grv.js +1 -0
  83. package/bin/{chunk-p4c4z0f2.js → chunk-ph43tgr6.js} +1 -1
  84. package/bin/{chunk-3xzgddev.js → chunk-pqtwzb3s.js} +1 -1
  85. package/bin/chunk-q0xv46wa.js +2 -0
  86. package/bin/{chunk-qh9rz2ee.js → chunk-qhxznkjk.js} +5 -5
  87. package/bin/chunk-qmja7bsr.js +2 -0
  88. package/bin/{chunk-v98e3gex.js → chunk-qyegjbzd.js} +1 -1
  89. package/bin/{chunk-gjdmnfms.js → chunk-r5rf62aa.js} +1 -1
  90. package/bin/{chunk-2xmsrq7f.js → chunk-rjkj0dr9.js} +2 -2
  91. package/bin/chunk-rjr8c8be.js +3 -0
  92. package/bin/{chunk-af6wbhkv.js → chunk-rq4h4p2g.js} +2 -2
  93. package/bin/{chunk-zwgf211t.js → chunk-scmhhrte.js} +2 -2
  94. package/bin/chunk-sjr6mvgm.js +78 -0
  95. package/bin/{chunk-t9t9evan.js → chunk-ssz62jfs.js} +2 -2
  96. package/bin/{chunk-g60v3jc1.js → chunk-ta02azkp.js} +1 -1
  97. package/bin/{chunk-tzt4c1dm.js → chunk-tfnh9sk9.js} +2 -2
  98. package/bin/{chunk-cqq8e3hc.js → chunk-thqahbva.js} +2 -2
  99. package/bin/chunk-tvzfm7g8.js +2 -0
  100. package/bin/{chunk-k48y9e5s.js → chunk-twm329fs.js} +1 -1
  101. package/bin/{chunk-0t8q76ac.js → chunk-ve826t5r.js} +1 -1
  102. package/bin/chunk-vpfj3q7r.js +1 -0
  103. package/bin/chunk-vqakgjsf.js +1 -0
  104. package/bin/chunk-wgjghs54.js +7 -0
  105. package/bin/chunk-wy1ytxw7.js +41 -0
  106. package/bin/{chunk-t3tp9trj.js → chunk-x788nk6z.js} +2 -2
  107. package/bin/{chunk-b3jh3hf1.js → chunk-x8ksced7.js} +2 -2
  108. package/bin/{chunk-qdycy714.js → chunk-xexxh1zq.js} +1 -1
  109. package/bin/{chunk-6v39c8eg.js → chunk-xktnqktj.js} +2 -2
  110. package/bin/{chunk-7872prvg.js → chunk-xpce3j7g.js} +1 -1
  111. package/bin/{chunk-karn564z.js → chunk-xyzsmjtk.js} +2 -2
  112. package/bin/chunk-y03s8bkz.js +1 -0
  113. package/bin/{chunk-kpn9d97x.js → chunk-y5g2ge6f.js} +1 -1
  114. package/bin/{chunk-qy93r7tm.js → chunk-ygcmv04c.js} +2 -2
  115. package/bin/{chunk-ytzk81tr.js → chunk-ykarhcph.js} +1 -1
  116. package/bin/{chunk-bancgvrc.js → chunk-yr8a8nzv.js} +2 -2
  117. package/bin/chunk-yxtb7xn8.js +2 -0
  118. package/bin/{chunk-n76r6s9k.js → chunk-zaft3sfe.js} +2 -2
  119. package/bin/shumai-app.html +1 -1
  120. package/bin/shumai-app.js +237 -215
  121. package/package.json +7 -7
  122. package/prisma/migrations/20260814090300_add_asset_agentmd/migration.sql +2 -0
  123. package/prisma/migrations/20260814125921_create_asset_agentmd_table/migration.sql +21 -0
  124. package/prisma/schema.prisma +12 -0
  125. package/bin/chunk-0xern7e4.js +0 -1
  126. package/bin/chunk-0yngn45x.js +0 -2
  127. package/bin/chunk-4egayx81.js +0 -2
  128. package/bin/chunk-4rbzswqs.js +0 -71
  129. package/bin/chunk-69tt1pvr.js +0 -2
  130. package/bin/chunk-815ezj20.js +0 -1
  131. package/bin/chunk-85eg9xqx.js +0 -1
  132. package/bin/chunk-86aagej8.js +0 -1
  133. package/bin/chunk-8y1v9dm9.js +0 -2
  134. package/bin/chunk-9gq9782d.js +0 -1
  135. package/bin/chunk-bv88se28.css +0 -1
  136. package/bin/chunk-dv1zpd2p.js +0 -15
  137. package/bin/chunk-eetrc0j1.js +0 -3
  138. package/bin/chunk-eztggp8r.js +0 -1
  139. package/bin/chunk-gf5ds9r9.js +0 -2
  140. package/bin/chunk-h9emz0zb.js +0 -2
  141. package/bin/chunk-h9k2atte.js +0 -1
  142. package/bin/chunk-kkq4wvnc.js +0 -1
  143. package/bin/chunk-ksx113sp.js +0 -1
  144. package/bin/chunk-m6a4rzdt.js +0 -62
  145. package/bin/chunk-mw8f8ngt.js +0 -7
  146. package/bin/chunk-rvspnthy.js +0 -1
  147. package/bin/chunk-sjjndwt4.js +0 -2
  148. package/bin/chunk-tvg9gvqs.js +0 -1
  149. package/bin/chunk-xp4dcyk3.js +0 -1
  150. package/bin/chunk-y8aehqr8.js +0 -2
  151. package/bin/chunk-yvxt48r4.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{ia as Zz,ja as _z,ka as $z,la as Kz,ma as Uz}from"./chunk-0mmw31pj.js";import{na as p}from"./chunk-drjaw6a5.js";import{Tf as v}from"./chunk-rjr8c8be.js";import{Gg as Yz}from"./chunk-g3p6h6sw.js";import{Ig as A}from"./chunk-2xaq1y16.js";import{kh as Jz}from"./chunk-75segwsp.js";import{Bh as Xz}from"./chunk-jfjjh86p.js";import{$k as Y,Ei as t,Fh as Bz,Gh as B,Gi as e,Hh as z,Ih as J,Jh as a,Mh as n,Ni as M,Oi as s,Ti as b,Uj as zz,Wk as T,ji as r,ok as S,sj as h,vi as o,zk as Gz}from"./chunk-sjr6mvgm.js";import{em as Rz}from"./chunk-2em77vjv.js";var _=Rz(Bz(),1);function uz({projectId:O,contextAssetId:R}){let{isHistoryMode:W,setIsHistoryMode:I,currentSessionId:Vz,chatAssets:u,removeAsset:Wz,messages:E,historySessions:g,isStreaming:D,fetchHistorySessions:m,loadSession:Lz,deleteSession:Nz,startNewSession:Qz,sendMessage:Pz,abortActiveSession:Oz,selectedAgentId:H,setSelectedAgentId:w,inputText:C,setInputText:l}=v(),{teamId:Z,ensureTeamIdForProject:j}=Xz();_.useEffect(()=>{if(O)j(O)},[O,j]);let{data:Dz=[]}=n({queryKey:["agents",Z],queryFn:async()=>{if(!Z)return[];let G=await r.api.teams[":teamId"].agents.$get({param:{teamId:Z}});if(!G.ok)throw Error("failed to fetch agents");return G.json()},enabled:!!Z}),F=Dz.filter((G)=>G.type==="chat"&&G.enabled);_.useEffect(()=>{if(F.length>0){if(!F.some((X)=>X.id===H))w(F[0].id)}},[F,H,w]);let d=_.useRef(null),y=_.useRef(null),k=_.useRef(!0),f=_.useRef(!0);_.useEffect(()=>{f.current=!0,k.current=!0},[O,R,W]),_.useEffect(()=>{let G=y.current?.querySelector('[data-slot="scroll-area-viewport"]');if(!G)return;let{scrollTop:X,isAtBottom:$}=v.getState(),V=setTimeout(()=>{if($)G.scrollTop=G.scrollHeight;else G.scrollTop=X;let Q=setTimeout(()=>{f.current=!1},50);return()=>clearTimeout(Q)},0);return()=>clearTimeout(V)},[O,R,W]),_.useEffect(()=>{let G=y.current?.querySelector('[data-slot="scroll-area-viewport"]');if(!G)return;let X=()=>{if(f.current)return;let $=G.scrollTop,V=G.scrollHeight-$-G.clientHeight<10;v.getState().setScrollState($,V)};return G.addEventListener("scroll",X),()=>{G.removeEventListener("scroll",X)}},[O,R,W]);let{ref:qz,isDropTarget:Ez}=Yz({id:"chatbot-sidebar",data:{type:"chatbot-sidebar"}});_.useEffect(()=>{if(!W){let{isAtBottom:G}=v.getState();if(G||D){let X=k.current?"auto":"smooth";d.current?.scrollIntoView({behavior:X})}k.current=!1}},[E,D,W]),_.useEffect(()=>{if(W&&Z)m(Z)},[W,m,Z]);let q=a(),Fz=_.useCallback(()=>{q.invalidateQueries({queryKey:["search"]}),q.invalidateQueries({queryKey:["folders"]}),q.invalidateQueries({queryKey:["files"]}),q.invalidateQueries({queryKey:["file"]}),q.invalidateQueries({queryKey:["version_stacks"]}),q.invalidateQueries({queryKey:["projects"]})},[q]),x=()=>{if(!C.trim()||D||!Z)return;Pz(Z,C,O,R,Fz),l("")},Hz=(G)=>{if(G.nativeEvent.isComposing)return;if(G.key==="Enter"&&!G.shiftKey)G.preventDefault(),x()},c=(G)=>{if(typeof G==="string")return G;if(Array.isArray(G))return G.map((X)=>{if(typeof X==="string")return X;if(X&&typeof X==="object"&&"type"in X&&X.type==="text"&&"text"in X)return String(X.text);return""}).join("");return""},i=(G)=>{return G.replace(/<@([a-zA-Z0-9_-]+)>/g,"@$1").replace(/^\[([^\]]+)\]:/gm,"\\[$1\\]:")},Cz=(G)=>{switch(G.role){case"user":return z("div",{className:"flex justify-end w-full",children:z("div",{className:"bg-primary text-primary-foreground rounded-lg px-3 py-2 max-w-[85%] text-sm whitespace-pre-wrap shadow-xs break-words",children:c(G.content)})},G.id);case"assistant":{let $=G.content;if(!$)return null;let V=[];if($.forEach((K,L)=>{if(!K||typeof K!=="object")return;let N=K;switch(N.type){case"text":{let U=N.text;if(typeof U!=="string"||!U.trim())return;V.push(z("div",{className:"text-sm leading-[1.8] prose prose-sm dark:prose-invert max-w-none break-words",children:z(p,{components:{pre:({node:P,...vz})=>z("pre",{className:"whitespace-pre-wrap break-all break-words bg-muted text-foreground p-4 rounded-md border border-border/50 font-mono text-sm",...vz})},children:i(U)})},`txt-${L}`));break}case"thinking":{let U=N.thinking;if(typeof U!=="string"||!U.trim())return;V.push(J("details",{className:"group border border-border/50 rounded-lg bg-muted/20 my-2 overflow-hidden",children:[J("summary",{className:"flex items-center gap-2 p-2.5 text-xs font-medium text-muted-foreground select-none cursor-pointer hover:bg-muted/40 transition-colors list-none [&::-webkit-details-marker]:hidden",children:[z(s,{className:"h-3.5 w-3.5 text-primary/70 animate-pulse"}),z("span",{children:Y.role_thinking()||"Thinking"}),z(b,{className:"h-3 w-3 ml-auto transition-transform group-open:rotate-180"})]}),z("div",{className:"p-3 pt-0 text-xs text-muted-foreground/90 border-t border-border/40 bg-muted/10 leading-relaxed prose prose-sm dark:prose-invert max-w-none whitespace-pre-wrap font-sans",children:z(p,{children:i(U)})})]},`think-${L}`));break}case"toolCall":{let U=String(N.name||N.toolName||Y.unknown()),P=N.arguments||N.args;V.push(J("details",{className:"group border border-border/50 rounded-lg bg-violet-500/5 my-2 overflow-hidden",children:[J("summary",{className:"flex items-center gap-2 p-2.5 text-xs font-semibold text-violet-600 dark:text-violet-400 select-none cursor-pointer hover:bg-violet-500/10 transition-colors list-none [&::-webkit-details-marker]:hidden",children:[z(Gz,{className:"h-3.5 w-3.5"}),z("span",{children:Y.calling_tool()}),z("span",{className:"font-mono bg-violet-500/10 px-1.5 py-0.5 rounded text-[11px] text-violet-700 dark:text-violet-300",children:U}),z(b,{className:"h-3 w-3 ml-auto transition-transform group-open:rotate-180"})]}),!!P&&J("div",{className:"p-3 pt-0 text-[10px] text-muted-foreground/90 border-t border-border/40 bg-violet-500/5 font-sans",children:[z("div",{className:"text-[9px] text-muted-foreground/60 uppercase font-bold tracking-wider mb-1.5",children:Y.tool_arguments()||"Arguments"}),z("pre",{className:"font-mono bg-muted/30 p-2 rounded border border-border/30 overflow-x-auto max-h-32",children:JSON.stringify(P,null,2)})]})]},`tool-${L}`));break}case"image":{let U=String(N.mimeType||"image/png"),P=String(N.data||"");V.push(z("div",{className:"my-2 max-w-full",children:P?z("img",{src:P.startsWith("data:")?P:`data:${U};base64,${P}`,alt:"Attached asset",className:"max-h-60 rounded border border-border/50 object-contain shadow-xs"}):z("div",{className:"text-xs text-muted-foreground italic flex items-center gap-1.5 py-1",children:Y.image_object()})},`img-${L}`));break}default:{let U=JSON.stringify(K,null,2);if(U==="{}")return;V.push(z("pre",{className:"text-xs text-foreground/80 font-mono whitespace-pre-wrap break-words bg-muted/20 p-2 rounded",children:U},`other-${L}`))}}}),V.length===0)return null;let Q=!1;if($.length>0){let K=$[$.length-1];if(typeof K==="string"&&K.trim().length>0)Q=!0;else if(K&&typeof K==="object"){let L=K;if(L.type==="text"&&typeof L.text==="string"&&L.text.trim().length>0)Q=!0}}return J("div",{className:"flex flex-col w-full space-y-1",children:[z("div",{className:"space-y-2 w-full",children:V}),Q&&z("div",{className:"text-[10px] text-muted-foreground self-start italic pt-1",children:Y.created_by_agent()})]},G.id)}case"toolResult":return z("div",{className:"flex items-center gap-2 text-xs text-muted-foreground bg-muted/40 p-2 rounded-md border border-border/50",children:z("span",{className:"font-semibold",children:Y.tool_result_with_name({name:G.toolName||"tool"})})},G.id);case"thinking_level_change":case"custom":{let X=G;if(X.customType==="context_display_info"){let Q=X.details?.assets||[];if(Q.length===0)return null;return J("div",{className:"text-xs text-muted-foreground bg-muted/40 p-2.5 rounded-lg border border-border/50 space-y-1 my-1",children:[z("div",{className:"font-semibold",children:Y.assets_added_to_context()}),z("ul",{className:"list-disc list-inside space-y-0.5",children:Q.map((K)=>J("li",{className:"truncate",children:[K.name," ",J("span",{className:"text-muted-foreground/70",children:["(",K.type,")"]})]},K.id))})]},G.id)}let $=X.content||"";return z("div",{className:"text-center text-xs text-muted-foreground italic bg-muted/20 py-1.5 rounded",children:c($)},G.id)}default:return null}};return J("div",{ref:qz,className:T("relative flex flex-col h-full bg-background transition-colors duration-200 min-h-0"),children:[Ez&&z("div",{className:"absolute inset-0 bg-accent/30 border-2 border-primary z-50 pointer-events-none flex items-center justify-center p-6 text-center animate-in fade-in duration-150",children:J("div",{className:"bg-background/95 text-foreground px-4 py-3 rounded-xl border border-border/80 flex flex-col items-center gap-2 shadow-lg max-w-[80%] animate-in zoom-in-95 duration-150",children:[z(M,{className:"h-6 w-6 text-primary animate-bounce"}),z("span",{className:"text-sm font-semibold text-foreground",children:Y.chatbot_drag_drop_hint()||"Drop assets here"})]})}),z("div",{className:"flex items-center justify-between p-4 pt-[0.7rem] flex-shrink-0",children:W?J(B,{children:[z("div",{className:"flex items-center gap-2 font-semibold",children:z("span",{children:Y.history()})}),z("button",{onClick:()=>I(!1),className:"p-1.5 hover:bg-accent rounded-md text-muted-foreground hover:text-foreground transition-colors",title:"Close History",children:z(t,{className:"h-4 w-4"})})]}):J(B,{children:[z("div",{className:"flex items-center gap-2 font-semibold",children:z("span",{children:Y.shumai_agent()})}),J("div",{className:"flex items-center gap-1",children:[z("button",{onClick:Qz,className:"p-1.5 hover:bg-accent rounded-md text-muted-foreground hover:text-foreground transition-colors",title:Y.new_chat(),children:z(zz,{className:"h-4 w-4"})}),z("button",{onClick:()=>I(!0),className:"p-1.5 hover:bg-accent rounded-md text-muted-foreground hover:text-foreground transition-colors",title:Y.history(),children:z(h,{className:"h-4 w-4"})})]})]})}),W?z(A,{className:"flex-1 p-4 min-h-0",children:g.length===0?J("div",{className:"flex flex-col items-center justify-center h-48 text-muted-foreground p-4 text-center",children:[z(h,{className:"h-8 w-8 mb-2 opacity-50 text-muted-foreground"}),z("p",{className:"text-sm",children:Y.no_history_sessions()})]}):z("div",{className:"space-y-2 pb-4",children:g.map((G)=>{let X=G.id===Vz;return J("div",{className:T("group relative flex items-center justify-between p-3 border rounded-lg transition-all cursor-pointer bg-card",X?"border-primary":"border-border hover:bg-accent/30"),children:[J("div",{onClick:()=>Z&&Lz(Z,G.id),className:"flex-1 min-w-0 pr-6",children:[z("div",{className:"text-sm font-semibold text-foreground truncate",children:G.name||Y.new_chat()}),z("div",{className:"text-xs text-muted-foreground mt-0.5",children:Jz(G.createdAt)})]}),z("button",{onClick:($)=>{if($.stopPropagation(),Z&&confirm(Y.delete_session_confirm()))Nz(Z,G.id)},className:"absolute right-3 opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity text-muted-foreground hover:text-destructive p-1 rounded hover:bg-muted",title:"Delete Session",children:z(S,{className:"h-4 w-4"})})]},G.id)})})}):J(B,{children:[z(A,{ref:y,className:"flex-1 p-4 min-h-0 [&>div>div]:!block",children:E.length===0?J("div",{className:"flex flex-col items-center justify-center h-48 border-2 border-dashed border-border rounded-lg text-muted-foreground p-4 text-center",children:[z(M,{className:"h-8 w-8 mb-2 opacity-50 text-muted-foreground"}),z("p",{className:"text-sm",children:Y.chatbot_drag_drop_hint()})]}):J("div",{className:"space-y-4 pb-4",children:[E.map(Cz),D&&E.length>0&&E[E.length-1].role==="user"&&J("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground italic",children:[z(o,{className:"h-3 w-3 animate-spin text-primary"}),z("span",{children:"Thinking..."})]}),z("div",{ref:d})]})}),z("div",{className:"p-2 flex-shrink-0 bg-background",children:J("div",{className:"relative flex flex-col w-full border border-foreground/20 rounded-2xl shadow-xs transition-all duration-200 focus-within:ring-2 focus-within:ring-primary focus-within:border-transparent bg-background overflow-hidden",children:[u.length>0&&z("div",{className:"flex flex-col gap-1.5 min-h-0 max-h-[160px] overflow-y-auto border-b border-border bg-muted/5 p-3 divide-y divide-border/50",children:u.map((G)=>J("div",{className:"flex items-center justify-between py-1.5 text-xs group",children:[J("div",{className:"flex items-baseline gap-1.5 min-w-0 pr-2",children:[z("span",{className:"truncate font-medium text-foreground",children:G.name}),z("span",{className:"text-[9px] text-muted-foreground uppercase flex-shrink-0",children:G.type})]}),z("button",{onClick:()=>Wz(G.id),className:"text-muted-foreground hover:text-destructive transition-colors p-0.5",title:Y.remove_from_context(),children:z(S,{className:"h-3.5 w-3.5"})})]},G.id))}),z("textarea",{value:C,onChange:(G)=>l(G.target.value),onKeyDown:Hz,placeholder:"Type a message...",rows:2,className:"w-full bg-transparent border-none focus:ring-0 focus:outline-hidden resize-none min-h-[44px] max-h-[120px] px-3 py-2 text-sm focus-visible:outline-hidden focus:ring-transparent focus:border-transparent focus-visible:ring-0",disabled:D}),J("div",{className:"flex justify-between items-center px-3 pb-2 pt-1",children:[z("div",{className:"flex items-center gap-1.5 min-w-0 max-w-[70%]",children:F.length>0?J(Zz,{value:H||"",onValueChange:(G)=>w(G),disabled:D,children:[z($z,{className:"h-8 border-none bg-transparent hover:bg-muted text-muted-foreground hover:text-foreground focus:ring-0 focus:ring-offset-0 px-2 py-0 gap-1.5 text-xs shrink-0 select-none shadow-none max-w-full",children:z(_z,{placeholder:Y.select_agent()})}),z(Kz,{children:F.map((G)=>z(Uz,{value:G.id,children:J("div",{className:"flex items-center gap-2",children:[G.avatar?z("img",{src:G.avatar,alt:G.name,className:"w-4 h-4 rounded-full object-cover"}):z(M,{className:"w-4 h-4 text-muted-foreground"}),z("span",{className:"text-xs",children:G.name})]})},G.id))})]}):z("div",{className:"flex items-center gap-1.5 px-2 py-1 text-[11px] text-muted-foreground/60 italic select-none",children:z("span",{children:Y.no_chat_agents_warning()})})}),D?z("button",{onClick:()=>{if(Z)Oz(Z)},className:"p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 shadow-sm bg-destructive text-destructive-foreground hover:bg-destructive/90 transform hover:-translate-y-0.5",title:"Stop generation",children:z("div",{className:"h-4 w-4 flex items-center justify-center",children:z("div",{className:"h-3 w-3 bg-current rounded-[2px] bg-white"})})}):z("button",{onClick:x,disabled:!C.trim()||!H,className:T("p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 shadow-sm",C.trim()&&H?"bg-primary text-primary-foreground hover:bg-primary/95 transform hover:-translate-y-0.5":"bg-muted text-muted-foreground cursor-not-allowed opacity-50"),children:z(e,{className:"h-4 w-4"})})]})]})})]})]})}
2
+ export{uz as n};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{dd as P,ed as J}from"./chunk-bancgvrc.js";import{Td as V,Ud as W,Vd as X}from"./chunk-4bn9eb9h.js";import"./chunk-dej1gq35.js";var Y=class{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}get supportsOutput(){return!0}},Z=class{#h;#j=new k;#z;#H;constructor(h){this.#h={...h}}async init(){if(this.#z=this.#h.database,this.#H=new $(this.#z),this.#h.onCreateConnection)await this.#h.onCreateConnection(this.#H)}async acquireConnection(){return await this.#j.lock(),this.#H}async beginTransaction(h){await h.executeQuery(J.raw("begin"))}async commitTransaction(h){await h.executeQuery(J.raw("commit"))}async rollbackTransaction(h){await h.executeQuery(J.raw("rollback"))}async releaseConnection(){this.#j.unlock()}async destroy(){this.#z?.close()}},$=class{#h;constructor(h){this.#h=h}executeQuery(h){let{sql:z,parameters:H}=h,j=this.#h.prepare(z).all(...H);return Promise.resolve({rows:j})}async*streamQuery(){throw Error("Streaming query is not supported by SQLite driver.")}},k=class{#h;#j;async lock(){while(this.#h!==void 0)await this.#h;this.#h=new Promise((h)=>{this.#j=h})}unlock(){let h=this.#j;this.#h=void 0,this.#j=void 0,h?.()}},w=class{#h;constructor(h){this.#h=h}async getSchemas(){return[]}async getTables(h={withInternalKyselyTables:!1}){let z=this.#h.selectFrom("sqlite_schema").where("type","=","table").where("name","not like","sqlite_%").select("name").$castTo();if(!h.withInternalKyselyTables)z=z.where("name","!=",W).where("name","!=",X);let H=await z.execute();return Promise.all(H.map(({name:j})=>this.#j(j)))}async getMetadata(h){return{tables:await this.getTables(h)}}async#j(h){let z=this.#h,H=(await z.selectFrom("sqlite_master").where("name","=",h).select("sql").$castTo().execute())[0]?.sql?.split(/[\(\),]/)?.find((j)=>j.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.[0]?.replace(/["`]/g,"");return{name:h,columns:(await z.selectFrom(P`pragma_table_info(${h})`.as("table_info")).select(["name","type","notnull","dflt_value"]).execute()).map((j)=>({name:j.name,dataType:j.type,isNullable:!j.notnull,isAutoIncrementing:j.name===H,hasDefaultValue:j.dflt_value!=null})),isView:!0}}},K=class extends V{getCurrentParameterPlaceholder(){return"?"}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}},F=class{#h;constructor(h){this.#h={...h}}createDriver(){return new Z(this.#h)}createQueryCompiler(){return new K}createAdapter(){return new Y}createIntrospector(h){return new w(h)}};export{F as NodeSqliteDialect};
2
+ import{nc as P,oc as J}from"./chunk-yr8a8nzv.js";import{bd as V,cd as W,dd as X}from"./chunk-jqzvazsf.js";import"./chunk-2em77vjv.js";var Y=class{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}get supportsOutput(){return!0}},Z=class{#h;#j=new k;#z;#H;constructor(h){this.#h={...h}}async init(){if(this.#z=this.#h.database,this.#H=new $(this.#z),this.#h.onCreateConnection)await this.#h.onCreateConnection(this.#H)}async acquireConnection(){return await this.#j.lock(),this.#H}async beginTransaction(h){await h.executeQuery(J.raw("begin"))}async commitTransaction(h){await h.executeQuery(J.raw("commit"))}async rollbackTransaction(h){await h.executeQuery(J.raw("rollback"))}async releaseConnection(){this.#j.unlock()}async destroy(){this.#z?.close()}},$=class{#h;constructor(h){this.#h=h}executeQuery(h){let{sql:z,parameters:H}=h,j=this.#h.prepare(z).all(...H);return Promise.resolve({rows:j})}async*streamQuery(){throw Error("Streaming query is not supported by SQLite driver.")}},k=class{#h;#j;async lock(){while(this.#h!==void 0)await this.#h;this.#h=new Promise((h)=>{this.#j=h})}unlock(){let h=this.#j;this.#h=void 0,this.#j=void 0,h?.()}},w=class{#h;constructor(h){this.#h=h}async getSchemas(){return[]}async getTables(h={withInternalKyselyTables:!1}){let z=this.#h.selectFrom("sqlite_schema").where("type","=","table").where("name","not like","sqlite_%").select("name").$castTo();if(!h.withInternalKyselyTables)z=z.where("name","!=",W).where("name","!=",X);let H=await z.execute();return Promise.all(H.map(({name:j})=>this.#j(j)))}async getMetadata(h){return{tables:await this.getTables(h)}}async#j(h){let z=this.#h,H=(await z.selectFrom("sqlite_master").where("name","=",h).select("sql").$castTo().execute())[0]?.sql?.split(/[\(\),]/)?.find((j)=>j.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.[0]?.replace(/["`]/g,"");return{name:h,columns:(await z.selectFrom(P`pragma_table_info(${h})`.as("table_info")).select(["name","type","notnull","dflt_value"]).execute()).map((j)=>({name:j.name,dataType:j.type,isNullable:!j.notnull,isAutoIncrementing:j.name===H,hasDefaultValue:j.dflt_value!=null})),isView:!0}}},K=class extends V{getCurrentParameterPlaceholder(){return"?"}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}},F=class{#h;constructor(h){this.#h={...h}}createDriver(){return new Z(this.#h)}createQueryCompiler(){return new K}createAdapter(){return new Y}createIntrospector(h){return new w(h)}};export{F as NodeSqliteDialect};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  function x(f){let b={};for(let[w,q]of f.entries())b[w]=q;return b}function z(f){if(!f)return;let b={};for(let[w,q]of Object.entries(f))if(q!==null)b[w]=q;return Object.keys(b).length>0?b:void 0}
3
- export{x as Bl,z as Cl};
3
+ export{x as Ul,z as Vl};
@@ -1,2 +1,2 @@
1
- import{Ah as r,Ak as a,zh as i,zk as o}from"./chunk-m6a4rzdt.js";function m({delayDuration:t=0,...e}){return i(o.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function f({...t}){return i(o.Root,{"data-slot":"tooltip",...t})}function s({...t}){return i(o.Trigger,{"data-slot":"tooltip-trigger",...t})}function c({className:t,sideOffset:e=0,children:n,...d}){return i(o.Portal,{children:r(o.Content,{"data-slot":"tooltip-content",sideOffset:e,className:a("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",t),...d,children:[n,i(o.Arrow,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}
2
- export{m as Hg,f as Ig,s as Jg,c as Kg};
1
+ import{Hh as i,Ih as r,Vk as o,Wk as a}from"./chunk-sjr6mvgm.js";function m({delayDuration:t=0,...e}){return i(o.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function f({...t}){return i(o.Root,{"data-slot":"tooltip",...t})}function s({...t}){return i(o.Trigger,{"data-slot":"tooltip-trigger",...t})}function c({className:t,sideOffset:e=0,children:n,...d}){return i(o.Portal,{children:r(o.Content,{"data-slot":"tooltip-content",sideOffset:e,className:a("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",t),...d,children:[n,i(o.Arrow,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}
2
+ export{m as Mg,f as Ng,s as Og,c as Pg};
@@ -0,0 +1,3 @@
1
+ import{ci as w,hi as $,ji as F}from"./chunk-sjr6mvgm.js";var z=null,c=w((J)=>({projectState:null,setProjectState:(D)=>{if(z)clearTimeout(z),z=null;J({projectState:D})},clearProjectState:()=>{if(z)clearTimeout(z);z=setTimeout(()=>{J({projectState:null}),z=null},10)}}));var T="shumai_selected_agent_id",M=()=>{if(typeof window<"u"&&window.localStorage)return localStorage.getItem(T);return null},K=w((J)=>({isChatbotOpen:!1,setIsChatbotOpen:(D)=>J({isChatbotOpen:D}),isHistoryMode:!1,setIsHistoryMode:(D)=>J({isHistoryMode:D}),currentSessionId:null,setCurrentSessionId:(D)=>J({currentSessionId:D}),chatAssets:[],addAssets:(D)=>J((H)=>{let L=new Set(H.chatAssets.map((V)=>V.id)),Q=D.filter((V)=>!L.has(V.id));return{chatAssets:[...H.chatAssets,...Q]}}),removeAsset:(D)=>J((H)=>({chatAssets:H.chatAssets.filter((L)=>L.id!==D)})),clearAssets:()=>J({chatAssets:[]}),messages:[],setMessages:(D)=>J({messages:D}),historySessions:[],setHistorySessions:(D)=>J({historySessions:D}),isStreaming:!1,setIsStreaming:(D)=>J({isStreaming:D}),selectedAgentId:M(),setSelectedAgentId:(D)=>{if(typeof window<"u"&&window.localStorage)if(D)localStorage.setItem(T,D);else localStorage.removeItem(T);J({selectedAgentId:D})},inputText:"",setInputText:(D)=>J({inputText:D}),scrollTop:0,isAtBottom:!0,setScrollState:(D,H)=>J({scrollTop:D,isAtBottom:H}),fetchHistorySessions:async(D)=>{try{let H=await F.api.teams[":teamId"].chat.sessions.$get({param:{teamId:D},query:{first:"50"}});if(H.ok){let L=await H.json();J({historySessions:L.data||[]})}}catch(H){console.error("Failed to fetch history sessions:",H)}},loadSession:async(D,H)=>{try{let L=await F.api.teams[":teamId"].chat.sessions[":sessionId"].messages.$get({param:{teamId:D,sessionId:H}});if(L.ok){let Q=await L.json(),U=K.getState().historySessions.find((P)=>P.id===H)?.agentId||null;J({currentSessionId:H,messages:Q,isHistoryMode:!1,scrollTop:0,isAtBottom:!0,...U?{selectedAgentId:U}:{}})}else throw Error("Failed to load session messages")}catch(L){let Q=L instanceof Error?L.message:"Failed to load session";$.error(Q)}},deleteSession:async(D,H)=>{try{if((await F.api.teams[":teamId"].chat.sessions[":sessionId"].$delete({param:{teamId:D,sessionId:H}})).ok)$.success("Session deleted successfully"),J((Q)=>({historySessions:Q.historySessions.filter((V)=>V.id!==H),currentSessionId:Q.currentSessionId===H?null:Q.currentSessionId,messages:Q.currentSessionId===H?[]:Q.messages}));else throw Error("Failed to delete session")}catch(L){let Q=L instanceof Error?L.message:"Failed to delete session";$.error(Q)}},startNewSession:()=>{let D=M();J({currentSessionId:null,messages:[],chatAssets:[],inputText:"",scrollTop:0,isAtBottom:!0,...D?{selectedAgentId:D}:{}})},sendMessage:async(D,H,L,Q,V)=>{let U=K.getState();if(U.isStreaming)return;let P=`temp-${Date.now()}`,b={id:P,role:"user",content:[{type:"text",text:H}],timestamp:Date.now()},v=[...U.messages];if(U.chatAssets.length>0){let B={id:`temp-context-${Date.now()}`,role:"custom",customType:"context_display_info",details:{assets:U.chatAssets.map((k)=>({id:k.id,name:k.name,type:k.type}))},timestamp:Date.now()-1};v.push(B)}v.push(b),J({messages:v,isStreaming:!0,chatAssets:[],isAtBottom:!0});let p=U.chatAssets.map((X)=>X.id),h=U.selectedAgentId;if(!h){$.error("No agent selected");return}try{let X=await F.api.teams[":teamId"].chat.$post({param:{teamId:D},json:{agentId:h,textPrompt:H,assetIds:p,sessionId:U.currentSessionId||void 0,contextAssetId:Q,projectId:L}});if(!X.ok)throw Error("Failed to start chat");let B=X.headers.get("x-session-id");if(B&&!U.currentSessionId)J({currentSessionId:B});let k=X.body?.getReader();if(!k)throw Error("No stream body");let j=new TextDecoder,G="";while(!0){let{done:S,value:x}=await k.read();if(S)break;G+=j.decode(x,{stream:!0});let C=G.split(`
2
+ `);G=C.pop()||"";for(let y of C){let N=y.trim();if(!N)continue;if(N.startsWith("data: ")){let A=N.slice(6);try{let Z=JSON.parse(A);if(Z.type==="session"){if(!K.getState().currentSessionId)J({currentSessionId:Z.sessionId})}else if(Z.type==="entry"){let q=Z.entry,Y=q;if(Y.role==="toolResult"&&typeof Y.toolName==="string"&&["create_file","create_folder","create_version"].includes(Y.toolName)&&!Y.isError)V?.();J((_)=>{let R=_.messages.some((W)=>W.id===q.id),O=_.messages.filter((W)=>{if(q.role==="user"&&!R)return!(W.id.startsWith("temp-")&&!W.id.startsWith("temp-context-"));if(q.role==="custom"&&q.customType==="context_display_info"&&!R)return!W.id.startsWith("temp-context-");return!0}),f=O.findIndex((W)=>W.id===q.id);if(f!==-1){let W=[...O];return W[f]=q,{messages:W}}else return{messages:[...O,q]}})}else if(Z.type==="done"){if(Z.status==="failed")$.error(Z.error||"Workflow failed")}}catch(Z){console.error("Error parsing SSE line:",Z)}}}}K.getState().fetchHistorySessions(D)}catch(X){let B=X instanceof Error?X.message:"Failed to send message";$.error(B),J((k)=>({messages:k.messages.filter((j)=>j.id!==P)}))}finally{J({isStreaming:!1})}},abortActiveSession:async(D)=>{let{currentSessionId:H,isStreaming:L}=K.getState();if(!H||!L)return;try{if((await F.api.teams[":teamId"].chat.sessions[":sessionId"].abort.$post({param:{teamId:D,sessionId:H}})).ok)$.success("Agent execution stopped");else throw Error("Failed to abort agent execution")}catch(Q){let V=Q instanceof Error?Q.message:"Failed to abort execution";$.error(V)}}}));
3
+ export{c as Sf,K as Tf};
@@ -1,2 +1,2 @@
1
- import{Ak as t,pk as o,zh as e}from"./chunk-m6a4rzdt.js";function n({className:a,...r}){return e(o.Root,{"data-slot":"label",className:t("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",a),...r})}
2
- export{n as Lg};
1
+ import{Hh as e,Lk as o,Wk as t}from"./chunk-sjr6mvgm.js";function n({className:a,...r}){return e(o.Root,{"data-slot":"label",className:t("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",a),...r})}
2
+ export{n as Qg};
@@ -1,2 +1,2 @@
1
- import{k as U1}from"./chunk-sjjndwt4.js";import{l as v1,m as M1}from"./chunk-qcqw7wnv.js";import{r as Q1}from"./chunk-x3ynjbt5.js";import{u as E1}from"./chunk-mw8f8ngt.js";import{C as k1,Q as q1}from"./chunk-y8aehqr8.js";import{qa as O1}from"./chunk-tpp9qf5m.js";import{$a as y1,Oa as v,Ra as H1,Sa as W1,cb as L1,eb as i}from"./chunk-4rbzswqs.js";import{Uf as $1}from"./chunk-38g3s1f3.js";import{xg as B1,yg as I}from"./chunk-eetrc0j1.js";import{Eg as V1}from"./chunk-69tt1pvr.js";import{uh as K1}from"./chunk-n4gghgrj.js";import{Ah as W,Ak as Z1,Bh as G1,Eh as r,Gh as J1,Hh as a,Ik as _1,Mh as Y1,bi as Y,xh as hx,yh as o,zh as X}from"./chunk-m6a4rzdt.js";import{Nl as zx}from"./chunk-dej1gq35.js";var w=zx(hx(),1);function X1(n,h,y,A,V,Z){let R=n.type==="folder",_=h.type==="folder";if(R!==_)return null;let $=_?A:V,L=$.findIndex((J)=>J.id===y),k=$.findIndex((J)=>J.id===h.id);if(L===-1||k===-1)return null;let g=Math.min(L,k),D=Math.max(L,k),O=$.slice(g,D+1),T=new Set(Z);return O.forEach((J)=>{if(J.id)T.add(J.id)}),T}function wx({teamId:n,projectId:h,projectName:y,assetId:A,rootFolderId:V,collection:Z,onUpdateCollection:R}){let _=Y1(),$=G1(),{canEdit:L}=K1(h),{setFields:k}=k1(),g=Y.api.files[":fileId"].metadata.$patch,{mutate:D}=J1({mutationFn:async(x)=>{if(!(await g(x)).ok)throw Error("Failed to patch metadata");return null}}),{data:O}=r({queryKey:["fields",h],queryFn:async()=>{let x=await Y.api.projects[":projectId"].fields.$get({param:{projectId:h}});if(!x.ok)throw Error("Failed to fetch fields");return await x.json()},enabled:!!h});w.useEffect(()=>{if(O)k(O,h)},[O,h,k]);let T=A==="recently-deleted",[J,P]=w.useState(null),[B,M]=w.useState(new Set),[u,l]=w.useState(null),[N1,b1]=w.useState(240),[f1,R1]=w.useState(360),{isChatbotOpen:C}=I(),{members:g1,fetchMembers:s}=q1(),{metadata:D1,fetchMetadata:d,setMetadata:P1}=$1();w.useEffect(()=>{if(n)s(n),d(n)},[n,s,d]);let p=w.useMemo(()=>{return Z?.filter?.searchFilter?.conditions||[]},[Z]),[q,F]=w.useState(p);w.useEffect(()=>{F(p)},[p]);let t=`project:${h}:sort`,E=D1[t]||{field:"custom",order:"asc"},u1=(x)=>{if(x)P1(n,t,x)},K=!!Z,m=q.length>0||K,{fileListLeftSidebarCollapsed:e,setFileListLeftSidebarCollapsed:C1,fileListRightSidebarCollapsed:x1,setFileListRightSidebarCollapsed:p1,viewModes:F1}=V1(),z1=F1[h]??"card",m1=w.useRef(null),{data:N}=T?{data:void 0}:r({queryKey:["folders",A],queryFn:async()=>{let x=await Y.api.folders[":folderId"].$get({param:{folderId:A}});if(!x.ok)throw Error("failed to fetch folder");return await x.json()}}),{setProjectState:h1,clearProjectState:w1}=B1();w.useEffect(()=>{return h1({teamId:n,projectId:h,projectName:y,ancestorFolders:N?.ancestorFolders??[],currentAsset:T?{name:"Recently Deleted",type:"folder"}:K?{name:Z.name,type:"folder"}:{name:N?.name,type:"folder"},isRootFolder:!T&&!K&&A===V,onFolderClick:(x)=>{_({to:"/projects/$projectId/folders/$folderId",params:{projectId:h,folderId:x}})}}),()=>w1()},[n,h,y,N,T,A,V,h1,w1,_]);let{data:S,fetchNextPage:S1,hasNextPage:j1,isFetchingNextPage:c1}=a({queryKey:T?["projects",h,"recently-deleted","folder"]:["search",n,A,"folder",q,E,K],queryFn:async({pageParam:x})=>{if(T||K){if(T){let G=await Y.api.projects[":projectId"]["recently-deleted"].$get({param:{projectId:h},query:{assetType:"folder",after:x}});if(!G.ok)throw Error("failed to fetch recently deleted folders");return await G.json()}return{data:[],pageInfo:{total:0}}}if(m)return{data:[],pageInfo:{total:0}};let z=await Y.api.folders[":folderId"].search.$post({param:{folderId:A},json:{assetType:"folder",after:x,recursively:!1,sort:E,conditions:[]}});if(!z.ok)throw Error("failed to search folders");return await z.json()},enabled:!m,initialPageParam:"",getNextPageParam:(x)=>{return x.pageInfo?.cursor||void 0}}),{data:j,fetchNextPage:o1,hasNextPage:r1,isFetchingNextPage:a1}=a({queryKey:T?["projects",h,"recently-deleted","file"]:["search",n,A,"file",q,E,K],queryFn:async({pageParam:x})=>{if(T){let G=await Y.api.projects[":projectId"]["recently-deleted"].$get({param:{projectId:h},query:{assetType:"file",after:x}});if(!G.ok)throw Error("failed to fetch recently deleted files");return await G.json()}let z=await Y.api.folders[":folderId"].search.$post({param:{folderId:A},json:{assetType:"file",after:x,recursively:m||K,conditions:q,sort:E}});if(!z.ok)throw Error("failed to search files");return await z.json()},initialPageParam:"",getNextPageParam:(x)=>{return x.pageInfo?.cursor||void 0}}),b=S?.pages.flatMap((x)=>x.data??[])??[],H=j?.pages.flatMap((x)=>x.data??[])??[],I1=S?.pages[0]?.pageInfo?.total,i1=j?.pages[0]?.pageInfo?.total,l1=S?.pages[0]?.pageInfo?.totalSize,s1=j?.pages[0]?.pageInfo?.totalSize,n1=()=>{M(new Set),P(null),l(null)},{dragState:Q,handleDragStart:d1,handleDragEnd:t1}=M1({teamId:n,projectId:h,assetId:A,folders:b,files:H,selectedIds:B,onClearSelection:n1}),c=w.useMemo(()=>{if(B.size!==1)return null;let x=Array.from(B)[0];return H.find((G)=>G.id===x)||null},[B,H]),e1=(x)=>{if(T)return;if(x.type==="folder")F([]),_({to:"/projects/$projectId/folders/$folderId",params:{projectId:h,folderId:x.id}});else _({to:"/projects/$projectId/files/$fileId",params:{projectId:h,fileId:x.versionStack?x.versionStack.id:x.id},search:{version:void 0}})},xx=(x,z)=>{let G=z.metaKey||z.ctrlKey;if(z.shiftKey&&u){let T1=[...b,...H].find((f)=>f.id===u);if(T1){let f=X1(T1,x,u,b,H,B);if(f){M(f),P(x);return}}}if(G){let U=new Set(B);if(U.has(x.id))U.delete(x.id);else U.add(x.id);M(U)}else M(new Set([x.id]));l(x.id),P(x)},A1=(x,z,G)=>{D({param:{fileId:x},json:[{key:z,value:G}]},{onSuccess:()=>{$.invalidateQueries({queryKey:["folders",A,"children",{assetType:"file"}]}),$.invalidateQueries({queryKey:["search",n,A]})}})};return W(y1,{modifiers:[v1.configure({anchor:{x:0,y:0}})],plugins:(x)=>x.map((z)=>{if(z===v)return v.configure({dropAnimation:null});if(typeof z==="object"&&z!==null&&"plugin"in z&&z.plugin===v)return v.configure({dropAnimation:null});return z}),sensors:T||!L?[]:[W1.configure({activationConstraints:[new H1.Distance({value:10})]})],onDragStart:d1,onDragEnd:t1,children:[X("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:W("div",{ref:m1,className:"flex flex-1 overflow-hidden relative",children:[!e&&X("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>C1(!0)}),(!x1||C)&&X("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>{p1(!0),I.getState().setIsChatbotOpen(!1)}}),!e&&W(o,{children:[X("div",{className:"bg-background",style:{width:N1},children:X(O1,{teamId:n,projectId:h,projectName:y,rootFolderId:V,dragState:Q,ancestorFolders:N?.ancestorFolders??[]})}),X(i,{onResize:(x)=>{b1((z)=>Math.max(180,Math.min(400,z+x)))},className:"hidden md:block"})]}),X(E1,{teamId:n,projectId:h,assetId:A,folders:b,files:H,totalFolders:I1,totalFiles:i1,totalFoldersSize:l1,totalFilesSize:s1,selectedItem:J,selectedIds:B,onItemSelect:xx,onItemDoubleClick:e1,onSaveField:A1,displayStyle:z1,onClearSelection:n1,fetchNextFoldersPage:S1,hasNextFoldersPage:j1||!1,isFetchingNextFoldersPage:c1,fetchNextFilesPage:o1,hasNextFilesPage:r1||!1,isFetchingNextFilesPage:a1,isRecentlyDeleted:T,filterConditions:q,onFilterChange:F,sort:E,onSortChange:u1,dragState:Q,collection:Z,onUpdateCollection:R,rootFolderId:V}),(!x1||C)&&W(o,{children:[X(i,{onResize:(x)=>{R1((z)=>Math.max(240,Math.min(600,z-x)))},className:"hidden md:block"}),X("div",{style:{width:f1},className:"bg-background flex flex-col flex-shrink-0",children:C?X(U1,{projectId:h,contextAssetId:A}):c?X(Q1,{teamId:n,projectId:h,file:c,onSaveField:(x,z)=>A1(c.id,x,z),members:g1,hideAnnotationControl:!0}):X("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:_1.select_asset_to_view_details()})})]})]})}),X(L1,{children:Q?.isActive?X("div",{className:Z1("flex items-center gap-2 rounded-md bg-popover px-3 py-2 text-sm font-medium text-popover-foreground shadow-md ring-1 ring-border cursor-grabbing",z1==="list"&&"w-30 h-[40px] px-0 flex-none overflow-hidden justify-center"),style:{transform:"translate(0px, 0px)"},children:W("span",{children:["Moving ",Q.itemCount," item",Q.itemCount!==1?"s":""]})}):null})]})}
2
- export{wx as j};
1
+ import{l as v1,m as M1}from"./chunk-c24an5j3.js";import{n as U1}from"./chunk-qmja7bsr.js";import{o as E1}from"./chunk-wgjghs54.js";import{t as Q1}from"./chunk-6pmsknnk.js";import{B as L1,N as q1}from"./chunk-61bxmjd9.js";import{pa as O1}from"./chunk-5386brz2.js";import{qa as i}from"./chunk-15jsnygy.js";import{gf as y1}from"./chunk-kmt9fj1z.js";import{Sf as B1,Tf as I}from"./chunk-rjr8c8be.js";import{Cg as k1,Fg as H1,Hg as W1,pg as v,sg as V1,tg as $1}from"./chunk-g3p6h6sw.js";import{Ch as K1}from"./chunk-jfjjh86p.js";import{$k as _1,Fh as hx,Gh as o,Hh as X,Ih as W,Jh as G1,Mh as r,Oh as J1,Ph as a,Uh as Y1,Wk as Z1,ji as Y}from"./chunk-sjr6mvgm.js";import{em as zx}from"./chunk-2em77vjv.js";var w=zx(hx(),1);function X1(n,h,y,A,V,Z){let R=n.type==="folder",_=h.type==="folder";if(R!==_)return null;let $=_?A:V,L=$.findIndex((J)=>J.id===y),k=$.findIndex((J)=>J.id===h.id);if(L===-1||k===-1)return null;let g=Math.min(L,k),D=Math.max(L,k),O=$.slice(g,D+1),T=new Set(Z);return O.forEach((J)=>{if(J.id)T.add(J.id)}),T}function wx({teamId:n,projectId:h,projectName:y,assetId:A,rootFolderId:V,collection:Z,onUpdateCollection:R}){let _=Y1(),$=G1(),{canEdit:L}=K1(h),{setFields:k}=L1(),g=Y.api.files[":fileId"].metadata.$patch,{mutate:D}=J1({mutationFn:async(x)=>{if(!(await g(x)).ok)throw Error("Failed to patch metadata");return null}}),{data:O}=r({queryKey:["fields",h],queryFn:async()=>{let x=await Y.api.projects[":projectId"].fields.$get({param:{projectId:h}});if(!x.ok)throw Error("Failed to fetch fields");return await x.json()},enabled:!!h});w.useEffect(()=>{if(O)k(O,h)},[O,h,k]);let T=A==="recently-deleted",[J,P]=w.useState(null),[B,M]=w.useState(new Set),[u,l]=w.useState(null),[N1,b1]=w.useState(240),[f1,R1]=w.useState(360),{isChatbotOpen:C}=I(),{members:g1,fetchMembers:s}=q1(),{metadata:D1,fetchMetadata:d,setMetadata:P1}=y1();w.useEffect(()=>{if(n)s(n),d(n)},[n,s,d]);let p=w.useMemo(()=>{return Z?.filter?.searchFilter?.conditions||[]},[Z]),[q,F]=w.useState(p);w.useEffect(()=>{F(p)},[p]);let t=`project:${h}:sort`,E=D1[t]||{field:"custom",order:"asc"},u1=(x)=>{if(x)P1(n,t,x)},K=!!Z,m=q.length>0||K,{fileListLeftSidebarCollapsed:e,setFileListLeftSidebarCollapsed:C1,fileListRightSidebarCollapsed:x1,setFileListRightSidebarCollapsed:p1,viewModes:F1}=W1(),z1=F1[h]??"card",m1=w.useRef(null),{data:N}=T?{data:void 0}:r({queryKey:["folders",A],queryFn:async()=>{let x=await Y.api.folders[":folderId"].$get({param:{folderId:A}});if(!x.ok)throw Error("failed to fetch folder");return await x.json()}}),{setProjectState:h1,clearProjectState:w1}=B1();w.useEffect(()=>{return h1({teamId:n,projectId:h,projectName:y,ancestorFolders:N?.ancestorFolders??[],currentAsset:T?{name:"Recently Deleted",type:"folder"}:K?{name:Z.name,type:"folder"}:{name:N?.name,type:"folder"},isRootFolder:!T&&!K&&A===V,onFolderClick:(x)=>{_({to:"/projects/$projectId/folders/$folderId",params:{projectId:h,folderId:x}})}}),()=>w1()},[n,h,y,N,T,A,V,h1,w1,_]);let{data:S,fetchNextPage:S1,hasNextPage:j1,isFetchingNextPage:c1}=a({queryKey:T?["projects",h,"recently-deleted","folder"]:["search",n,A,"folder",q,E,K],queryFn:async({pageParam:x})=>{if(T||K){if(T){let G=await Y.api.projects[":projectId"]["recently-deleted"].$get({param:{projectId:h},query:{assetType:"folder",after:x}});if(!G.ok)throw Error("failed to fetch recently deleted folders");return await G.json()}return{data:[],pageInfo:{total:0}}}if(m)return{data:[],pageInfo:{total:0}};let z=await Y.api.folders[":folderId"].search.$post({param:{folderId:A},json:{assetType:"folder",after:x,recursively:!1,sort:E,conditions:[]}});if(!z.ok)throw Error("failed to search folders");return await z.json()},enabled:!m,initialPageParam:"",getNextPageParam:(x)=>{return x.pageInfo?.cursor||void 0}}),{data:j,fetchNextPage:o1,hasNextPage:r1,isFetchingNextPage:a1}=a({queryKey:T?["projects",h,"recently-deleted","file"]:["search",n,A,"file",q,E,K],queryFn:async({pageParam:x})=>{if(T){let G=await Y.api.projects[":projectId"]["recently-deleted"].$get({param:{projectId:h},query:{assetType:"file",after:x}});if(!G.ok)throw Error("failed to fetch recently deleted files");return await G.json()}let z=await Y.api.folders[":folderId"].search.$post({param:{folderId:A},json:{assetType:"file",after:x,recursively:m||K,conditions:q,sort:E}});if(!z.ok)throw Error("failed to search files");return await z.json()},initialPageParam:"",getNextPageParam:(x)=>{return x.pageInfo?.cursor||void 0}}),b=S?.pages.flatMap((x)=>x.data??[])??[],H=j?.pages.flatMap((x)=>x.data??[])??[],I1=S?.pages[0]?.pageInfo?.total,i1=j?.pages[0]?.pageInfo?.total,l1=S?.pages[0]?.pageInfo?.totalSize,s1=j?.pages[0]?.pageInfo?.totalSize,n1=()=>{M(new Set),P(null),l(null)},{dragState:Q,handleDragStart:d1,handleDragEnd:t1}=M1({teamId:n,projectId:h,assetId:A,folders:b,files:H,selectedIds:B,onClearSelection:n1}),c=w.useMemo(()=>{if(B.size!==1)return null;let x=Array.from(B)[0];return H.find((G)=>G.id===x)||null},[B,H]),e1=(x)=>{if(T)return;if(x.type==="folder")F([]),_({to:"/projects/$projectId/folders/$folderId",params:{projectId:h,folderId:x.id}});else _({to:"/projects/$projectId/files/$fileId",params:{projectId:h,fileId:x.versionStack?x.versionStack.id:x.id},search:{version:void 0}})},xx=(x,z)=>{let G=z.metaKey||z.ctrlKey;if(z.shiftKey&&u){let T1=[...b,...H].find((f)=>f.id===u);if(T1){let f=X1(T1,x,u,b,H,B);if(f){M(f),P(x);return}}}if(G){let U=new Set(B);if(U.has(x.id))U.delete(x.id);else U.add(x.id);M(U)}else M(new Set([x.id]));l(x.id),P(x)},A1=(x,z,G)=>{D({param:{fileId:x},json:[{key:z,value:G}]},{onSuccess:()=>{$.invalidateQueries({queryKey:["folders",A,"children",{assetType:"file"}]}),$.invalidateQueries({queryKey:["search",n,A]})}})};return W(k1,{modifiers:[v1.configure({anchor:{x:0,y:0}})],plugins:(x)=>x.map((z)=>{if(z===v)return v.configure({dropAnimation:null});if(typeof z==="object"&&z!==null&&"plugin"in z&&z.plugin===v)return v.configure({dropAnimation:null});return z}),sensors:T||!L?[]:[$1.configure({activationConstraints:[new V1.Distance({value:10})]})],onDragStart:d1,onDragEnd:t1,children:[X("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:W("div",{ref:m1,className:"flex flex-1 overflow-hidden relative",children:[!e&&X("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>C1(!0)}),(!x1||C)&&X("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>{p1(!0),I.getState().setIsChatbotOpen(!1)}}),!e&&W(o,{children:[X("div",{className:"bg-background",style:{width:N1},children:X(O1,{teamId:n,projectId:h,projectName:y,rootFolderId:V,dragState:Q,ancestorFolders:N?.ancestorFolders??[]})}),X(i,{onResize:(x)=>{b1((z)=>Math.max(180,Math.min(400,z+x)))},className:"hidden md:block"})]}),X(E1,{teamId:n,projectId:h,assetId:A,folders:b,files:H,totalFolders:I1,totalFiles:i1,totalFoldersSize:l1,totalFilesSize:s1,selectedItem:J,selectedIds:B,onItemSelect:xx,onItemDoubleClick:e1,onSaveField:A1,displayStyle:z1,onClearSelection:n1,fetchNextFoldersPage:S1,hasNextFoldersPage:j1||!1,isFetchingNextFoldersPage:c1,fetchNextFilesPage:o1,hasNextFilesPage:r1||!1,isFetchingNextFilesPage:a1,isRecentlyDeleted:T,filterConditions:q,onFilterChange:F,sort:E,onSortChange:u1,dragState:Q,collection:Z,onUpdateCollection:R,rootFolderId:V}),(!x1||C)&&W(o,{children:[X(i,{onResize:(x)=>{R1((z)=>Math.max(240,Math.min(600,z-x)))},className:"hidden md:block"}),X("div",{style:{width:f1},className:"bg-background flex flex-col flex-shrink-0",children:C?X(U1,{projectId:h,contextAssetId:A}):c?X(Q1,{teamId:n,projectId:h,file:c,onSaveField:(x,z)=>A1(c.id,x,z),members:g1,hideAnnotationControl:!0}):X("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:_1.select_asset_to_view_details()})})]})]})}),X(H1,{children:Q?.isActive?X("div",{className:Z1("flex items-center gap-2 rounded-md bg-popover px-3 py-2 text-sm font-medium text-popover-foreground shadow-md ring-1 ring-border cursor-grabbing",z1==="list"&&"w-30 h-[40px] px-0 flex-none overflow-hidden justify-center"),style:{transform:"translate(0px, 0px)"},children:W("span",{children:["Moving ",Q.itemCount," item",Q.itemCount!==1?"s":""]})}):null})]})}
2
+ export{wx as k};