@shumai-one/shumai 0.6.2 → 0.6.4

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 (192) hide show
  1. package/bin/{chunk-mcj1xpcc.js → chunk-01vx2chc.js} +2 -2
  2. package/bin/chunk-0epkrexd.js +2 -0
  3. package/bin/chunk-0h5239kt.js +2 -0
  4. package/bin/{chunk-jt0ykktx.js → chunk-0jnstdgf.js} +1 -1
  5. package/bin/{chunk-x03jwaga.js → chunk-0njsjy6x.js} +4 -4
  6. package/bin/{chunk-7naa7tpn.js → chunk-13rq2gtr.js} +2 -2
  7. package/bin/chunk-1aqs9sdh.js +3 -0
  8. package/bin/{chunk-m0q2cgfg.js → chunk-22jbsrka.js} +1 -1
  9. package/bin/chunk-2qknebmd.js +1 -0
  10. package/bin/{chunk-a411xhmm.js → chunk-2qzmh3ae.js} +4 -4
  11. package/bin/{chunk-2nhgdqdg.js → chunk-2tt0b8ym.js} +2 -2
  12. package/bin/{chunk-p3f5aevs.js → chunk-2zm7czk6.js} +1 -1
  13. package/bin/{chunk-p4s95471.js → chunk-396tfwdx.js} +1 -1
  14. package/bin/chunk-3mx4trvh.js +10 -0
  15. package/bin/{chunk-b5rhvzv9.js → chunk-45pb3kzz.js} +2 -2
  16. package/bin/{chunk-q83h0hkx.js → chunk-47fmhzwv.js} +2 -2
  17. package/bin/chunk-4awk4xhq.js +2 -0
  18. package/bin/{chunk-2cdxm1cp.js → chunk-4b2x2qba.js} +23 -23
  19. package/bin/{chunk-knj2s8mg.js → chunk-4rjy7ybr.js} +8 -8
  20. package/bin/{chunk-q8w4mbw4.js → chunk-598x693h.js} +2 -2
  21. package/bin/chunk-5c7ztqs7.js +1 -0
  22. package/bin/{chunk-2jj4j8cn.js → chunk-65dh7x4c.js} +2 -2
  23. package/bin/{chunk-hnkcgvcj.js → chunk-66e2vrky.js} +1 -1
  24. package/bin/{chunk-g22wmpk1.js → chunk-6j3beg6n.js} +2 -2
  25. package/bin/{chunk-cgmebxx6.js → chunk-6ke13k69.js} +1 -1
  26. package/bin/{chunk-7sgrtxbt.js → chunk-6rqakmg0.js} +2 -2
  27. package/bin/{chunk-4mws03es.js → chunk-6ty4tfmf.js} +3 -3
  28. package/bin/chunk-7e9ws6dh.js +129 -0
  29. package/bin/chunk-7mdddkfc.js +1 -0
  30. package/bin/{chunk-q2bew2vc.js → chunk-7q4mgd5x.js} +2 -2
  31. package/bin/chunk-7yv7shad.js +1 -0
  32. package/bin/{chunk-qwpkcp8d.js → chunk-81b8rfv7.js} +2 -2
  33. package/bin/{chunk-atfz7g7e.js → chunk-8a7ymmd4.js} +2 -2
  34. package/bin/chunk-8ac9at5y.js +2 -0
  35. package/bin/{chunk-gxepkvt2.js → chunk-8zcfgz9c.js} +1 -1
  36. package/bin/{chunk-mcw198kg.js → chunk-955kf5kc.js} +8 -8
  37. package/bin/{chunk-jzgbxqdg.js → chunk-978rm9a9.js} +2 -2
  38. package/bin/{chunk-jt02kpfc.js → chunk-9qzbrp4d.js} +2 -2
  39. package/bin/{chunk-tekwpkjf.js → chunk-a283dh05.js} +2 -2
  40. package/bin/chunk-aa2a06cc.js +1 -0
  41. package/bin/{chunk-8cjet7pp.js → chunk-ajr1w3vq.js} +6 -6
  42. package/bin/chunk-akafypge.js +218 -0
  43. package/bin/chunk-amk373q2.js +2 -0
  44. package/bin/chunk-apq2gvvp.js +4 -0
  45. package/bin/chunk-av2w1sez.js +2 -0
  46. package/bin/{chunk-5wapd171.js → chunk-b6kmj34z.js} +12 -12
  47. package/bin/chunk-bkzaw9p8.js +1 -0
  48. package/bin/{chunk-zezje74z.js → chunk-bssb9tar.js} +3 -3
  49. package/bin/chunk-bwvj1aqc.js +1 -0
  50. package/bin/chunk-by9esjn7.js +3 -0
  51. package/bin/chunk-bywk8mbc.js +2 -0
  52. package/bin/{chunk-9xhjy897.js → chunk-c61g9hfa.js} +4 -4
  53. package/bin/{chunk-zrszykjf.js → chunk-cdcgjh8k.js} +1 -1
  54. package/bin/{chunk-yk12hydf.js → chunk-d277evce.js} +4 -4
  55. package/bin/{chunk-55h9ze53.js → chunk-d3brvxh7.js} +2 -2
  56. package/bin/{chunk-9t3p4xp6.js → chunk-dcb1nzf1.js} +1 -1
  57. package/bin/{chunk-mzsw9var.js → chunk-dfbzatq9.js} +2 -2
  58. package/bin/chunk-e0bckx12.js +2 -0
  59. package/bin/{chunk-3ckkwdjx.js → chunk-e2p4s2pj.js} +3 -3
  60. package/bin/chunk-e8zzg57c.js +2 -0
  61. package/bin/{chunk-vp3czaeh.js → chunk-edfaqwaq.js} +2 -2
  62. package/bin/chunk-ehgrp0f9.js +1 -0
  63. package/bin/chunk-evs2aaav.js +12 -0
  64. package/bin/{chunk-s9ksftq2.js → chunk-f5bhcjhw.js} +1 -1
  65. package/bin/{chunk-ns33grgx.js → chunk-fb9dedm2.js} +2 -2
  66. package/bin/{chunk-srxp5jav.js → chunk-ff0mh9p3.js} +32 -32
  67. package/bin/chunk-fpfby5tz.js +1 -0
  68. package/bin/{chunk-eyjfhdp9.js → chunk-gd3b5akr.js} +2 -2
  69. package/bin/{chunk-1wfg56z3.js → chunk-gm1fy3hm.js} +5 -5
  70. package/bin/{chunk-9n1w5dw1.js → chunk-gqkjx7rz.js} +3 -3
  71. package/bin/{chunk-1nvd90g2.js → chunk-h7f5370s.js} +1 -1
  72. package/bin/chunk-hcyhsn8e.js +2 -0
  73. package/bin/{chunk-vcrmjtcz.js → chunk-jxm0gzmf.js} +2 -2
  74. package/bin/{chunk-b7bnp021.js → chunk-k3ggy3xk.js} +2 -2
  75. package/bin/{chunk-257dcd2f.js → chunk-k9vjs21p.js} +2 -2
  76. package/bin/chunk-ka40gv72.js +1 -0
  77. package/bin/chunk-km70p970.js +2 -0
  78. package/bin/{chunk-e4yscwen.js → chunk-m6v8rb39.js} +8 -8
  79. package/bin/chunk-m8spagwp.js +4 -0
  80. package/bin/{chunk-y241cxff.js → chunk-mfh7mg5b.js} +1 -1
  81. package/bin/chunk-n0cn0218.js +2 -0
  82. package/bin/chunk-n54ftsdx.js +2 -0
  83. package/bin/{chunk-02fvcrej.js → chunk-n7cvj15k.js} +7 -7
  84. package/bin/chunk-na5fh7er.js +2 -0
  85. package/bin/chunk-neazdbxy.js +1 -0
  86. package/bin/chunk-nk24qw3m.js +1 -0
  87. package/bin/{chunk-73yncv54.js → chunk-nsbbseff.js} +2 -2
  88. package/bin/chunk-nseef85h.js +1 -0
  89. package/bin/chunk-p35ztj2z.js +3 -0
  90. package/bin/chunk-pcjc9ygv.js +2 -0
  91. package/bin/{chunk-167z646e.js → chunk-pemmtd8q.js} +1 -1
  92. package/bin/{chunk-82tps5n1.js → chunk-pzrqnnpg.js} +1 -1
  93. package/bin/{chunk-a74g6h8a.js → chunk-q43m934j.js} +2 -2
  94. package/bin/{chunk-r1xer8gn.js → chunk-q57m34h0.js} +3 -3
  95. package/bin/chunk-q5k72jz9.js +3 -0
  96. package/bin/chunk-q9fsxakd.js +2 -0
  97. package/bin/chunk-qadpe0ct.js +2 -0
  98. package/bin/chunk-qeypjv4f.css +1 -0
  99. package/bin/chunk-qw92z3wf.js +2 -0
  100. package/bin/chunk-r0byfq1t.js +1 -0
  101. package/bin/chunk-r0q88qw3.js +2 -0
  102. package/bin/chunk-rjhczkh3.js +2 -0
  103. package/bin/{chunk-mwktrwtx.js → chunk-s0wxbybf.js} +1 -1
  104. package/bin/{chunk-q5vkxee3.js → chunk-s4hkcw24.js} +2 -2
  105. package/bin/chunk-szta50g1.js +1 -0
  106. package/bin/chunk-t6cb99gp.js +2 -0
  107. package/bin/chunk-tcr080b9.js +1 -0
  108. package/bin/{chunk-yq32evnn.js → chunk-v4nqx084.js} +5 -5
  109. package/bin/{chunk-ympbfzz4.js → chunk-v7jzc3ye.js} +1 -1
  110. package/bin/{chunk-9zsv6d2f.js → chunk-vbe8wred.js} +1 -1
  111. package/bin/{chunk-hpbn0k9n.js → chunk-vf9s8b5t.js} +2 -2
  112. package/bin/{chunk-m9adtgzk.js → chunk-vk3eqr65.js} +1 -1
  113. package/bin/{chunk-hpwv4am3.js → chunk-vm9bbk97.js} +4 -4
  114. package/bin/{chunk-v05rrxp5.js → chunk-w4gqg27w.js} +2 -2
  115. package/bin/{chunk-x8mjh387.js → chunk-w6ym7tsd.js} +4 -4
  116. package/bin/{chunk-hzkjgcre.js → chunk-ways29d1.js} +1 -1
  117. package/bin/chunk-wesg7tg9.js +1 -0
  118. package/bin/chunk-wmrrapwv.js +2 -0
  119. package/bin/chunk-wnwsjgj8.js +2 -0
  120. package/bin/{chunk-hw6czrya.js → chunk-wrb4xq9v.js} +1 -1
  121. package/bin/{chunk-v5cn90cf.js → chunk-wzrzc07t.js} +2 -2
  122. package/bin/chunk-xd1axsdv.js +2 -0
  123. package/bin/{chunk-cwat1jwx.js → chunk-xk0jmx4s.js} +2 -2
  124. package/bin/{chunk-g6sdezec.js → chunk-y545vfn0.js} +1 -1
  125. package/bin/{chunk-fatmqnp1.js → chunk-y6h885fs.js} +1 -1
  126. package/bin/{chunk-cz13a82m.js → chunk-yncmfr39.js} +2 -2
  127. package/bin/{chunk-01052ssf.js → chunk-yxnz4ypt.js} +11 -11
  128. package/bin/chunk-zc1asygg.js +2 -0
  129. package/bin/{chunk-m82tkhaa.js → chunk-zc7wzcvh.js} +7 -7
  130. package/bin/chunk-zdvhh8mk.js +2 -0
  131. package/bin/{chunk-kvhf12b4.js → chunk-zg0b902x.js} +2 -2
  132. package/bin/{chunk-7v7mypc6.js → chunk-zhq7a7hs.js} +2 -2
  133. package/bin/{chunk-f25fe9th.js → chunk-zmnvskn7.js} +11 -11
  134. package/bin/shumai-app.html +1 -1
  135. package/bin/shumai-app.js +470 -389
  136. package/package.json +7 -7
  137. package/prisma/migrations/20261102032402_add_archive_storage/migration.sql +25 -0
  138. package/prisma/schema.prisma +12 -6
  139. package/bin/chunk-0bj887zm.js +0 -2
  140. package/bin/chunk-1ktk6764.js +0 -10
  141. package/bin/chunk-26qn7fek.js +0 -2
  142. package/bin/chunk-2ne2b54t.js +0 -2
  143. package/bin/chunk-2vbeqczj.js +0 -1
  144. package/bin/chunk-37p6bcx2.js +0 -1
  145. package/bin/chunk-3knfx6dm.js +0 -1
  146. package/bin/chunk-3z85zxkn.js +0 -1
  147. package/bin/chunk-54tbfvya.js +0 -2
  148. package/bin/chunk-56kh5fxc.js +0 -1
  149. package/bin/chunk-576nj64j.js +0 -2
  150. package/bin/chunk-6cnqjngz.js +0 -1
  151. package/bin/chunk-7g46e1wy.js +0 -3
  152. package/bin/chunk-84x8p7v5.js +0 -1
  153. package/bin/chunk-88jg9dq5.js +0 -2
  154. package/bin/chunk-8fyg9dy4.js +0 -2
  155. package/bin/chunk-8gtfgkrn.js +0 -2
  156. package/bin/chunk-8mqbztj8.js +0 -2
  157. package/bin/chunk-8qdtvfx3.css +0 -1
  158. package/bin/chunk-8xb6yz11.js +0 -2
  159. package/bin/chunk-8yjsmr7g.js +0 -2
  160. package/bin/chunk-91rb0jpb.js +0 -2
  161. package/bin/chunk-96qpjght.js +0 -2
  162. package/bin/chunk-9f1xk1nt.js +0 -1
  163. package/bin/chunk-9mk9cvbk.js +0 -1
  164. package/bin/chunk-9nw5w8vh.js +0 -1
  165. package/bin/chunk-ah8fjb6f.js +0 -2
  166. package/bin/chunk-cf5axr8c.js +0 -1
  167. package/bin/chunk-dk42gf7v.js +0 -2
  168. package/bin/chunk-e4f56spj.js +0 -4
  169. package/bin/chunk-eb7mzbfm.js +0 -1
  170. package/bin/chunk-er14d498.js +0 -3
  171. package/bin/chunk-f6avg5qe.js +0 -129
  172. package/bin/chunk-fvx9k1dc.js +0 -2
  173. package/bin/chunk-gtf19jc1.js +0 -2
  174. package/bin/chunk-h1n7jqnw.js +0 -1
  175. package/bin/chunk-hfm82066.js +0 -2
  176. package/bin/chunk-j2s311yc.js +0 -3
  177. package/bin/chunk-kj6h5j5a.js +0 -4
  178. package/bin/chunk-km4gn6b6.js +0 -1
  179. package/bin/chunk-ny1kbmxt.js +0 -2
  180. package/bin/chunk-p3j6ydk1.js +0 -1
  181. package/bin/chunk-pk406dgy.js +0 -2
  182. package/bin/chunk-s1e4qy3q.js +0 -14
  183. package/bin/chunk-swtwaaqe.js +0 -1
  184. package/bin/chunk-tagdrg7p.js +0 -1
  185. package/bin/chunk-twtxnzbv.js +0 -2
  186. package/bin/chunk-v5mcjwxy.js +0 -2
  187. package/bin/chunk-vkzasgxw.js +0 -2
  188. package/bin/chunk-x342vzdx.js +0 -2
  189. package/bin/chunk-xc54vhfz.js +0 -2
  190. package/bin/chunk-xvkwbczx.js +0 -3
  191. package/bin/chunk-z1p13dnc.js +0 -2
  192. package/bin/chunk-zarz3sqn.js +0 -211
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shumai-one/shumai",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "A fullstack AI-powered media workspace and workflow engine",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,12 +25,12 @@
25
25
  "exiftool-vendored": "38.1.0"
26
26
  },
27
27
  "optionalDependencies": {
28
- "@shumai-one/shumai-darwin-arm64": "0.6.2",
29
- "@shumai-one/shumai-darwin-x64": "0.6.2",
30
- "@shumai-one/shumai-linux-arm64": "0.6.2",
31
- "@shumai-one/shumai-linux-x64": "0.6.2",
32
- "@shumai-one/shumai-win32-arm64": "0.6.2",
33
- "@shumai-one/shumai-win32-x64": "0.6.2"
28
+ "@shumai-one/shumai-darwin-arm64": "0.6.4",
29
+ "@shumai-one/shumai-darwin-x64": "0.6.4",
30
+ "@shumai-one/shumai-linux-arm64": "0.6.4",
31
+ "@shumai-one/shumai-linux-x64": "0.6.4",
32
+ "@shumai-one/shumai-win32-arm64": "0.6.4",
33
+ "@shumai-one/shumai-win32-x64": "0.6.4"
34
34
  },
35
35
  "repository": {
36
36
  "type": "git",
@@ -0,0 +1,25 @@
1
+ -- AlterEnum
2
+ -- This migration adds more than one value to an enum.
3
+ -- With PostgreSQL versions 11 and earlier, this is not possible
4
+ -- in a single migration. This can be worked around by creating
5
+ -- multiple migrations, each migration adding only one value to
6
+ -- the enum.
7
+
8
+
9
+ ALTER TYPE "AssetStatus" ADD VALUE 'archiving';
10
+ ALTER TYPE "AssetStatus" ADD VALUE 'archived';
11
+ ALTER TYPE "AssetStatus" ADD VALUE 'restoring';
12
+
13
+ -- AlterEnum
14
+ -- This migration adds more than one value to an enum.
15
+ -- With PostgreSQL versions 11 and earlier, this is not possible
16
+ -- in a single migration. This can be worked around by creating
17
+ -- multiple migrations, each migration adding only one value to
18
+ -- the enum.
19
+
20
+
21
+ ALTER TYPE "WorkflowTaskType" ADD VALUE 'archive_asset';
22
+ ALTER TYPE "WorkflowTaskType" ADD VALUE 'restore_asset';
23
+
24
+ -- AlterTable
25
+ ALTER TABLE "storage_keys" ADD COLUMN "is_archived" BOOLEAN NOT NULL DEFAULT false;
@@ -40,6 +40,9 @@ enum AssetStatus {
40
40
  uploaded
41
41
  processing
42
42
  processed
43
+ archiving
44
+ archived
45
+ restoring
43
46
  failed
44
47
  trashed
45
48
  pending_purge
@@ -128,6 +131,8 @@ enum WorkflowTaskType {
128
131
  query_embedding_for_search
129
132
  agent_tool_call // @deprecated: Agent tools now execute directly in-process via Core services
130
133
  kanban_agent_run
134
+ archive_asset
135
+ restore_asset
131
136
  }
132
137
 
133
138
  enum WorkflowTaskStatus {
@@ -606,12 +611,13 @@ model Asset {
606
611
  }
607
612
 
608
613
  model StorageKey {
609
- id String @id @default(ulid())
610
- key String @unique
611
- status StorageKeyStatus @default(active)
612
- createdAt DateTime @default(now()) @map("created_at")
613
- updatedAt DateTime @updatedAt @map("updated_at")
614
- assets Asset[]
614
+ id String @id @default(ulid())
615
+ key String @unique
616
+ status StorageKeyStatus @default(active)
617
+ isArchived Boolean @default(false) @map("is_archived")
618
+ createdAt DateTime @default(now()) @map("created_at")
619
+ updatedAt DateTime @updatedAt @map("updated_at")
620
+ assets Asset[]
615
621
 
616
622
  @@map("storage_keys")
617
623
  }
@@ -1,2 +0,0 @@
1
- import{S,G,M,w,Z,Y,a,g,X,Tt,We,R,K,Pn,F,t1,re,Zn,hs,tm,lt,Nt,Ft,St}from"./chunk-zarz3sqn.js";import{wa}from"./chunk-s1e4qy3q.js";import{gu,Ns}from"./chunk-f6avg5qe.js";import{hu}from"./chunk-gtf19jc1.js";import{Ea}from"./chunk-r1xer8gn.js";import{pu,mu}from"./chunk-z1p13dnc.js";import{Jr}from"./chunk-q5vkxee3.js";import{_r}from"./chunk-ny1kbmxt.js";Z();function ba({shareId:r,initialFolderId:ve,initialFileId:W,startTime:O,versionId:x,compare:ye,compareLeftId:C,compareRightId:k,compareActiveSide:Q="left"}){let c=We(),A=hs(),p=!!ye&&!!C&&!!k,[d,J]=w(()=>localStorage.getItem(`share_pwd_${r}`)||""),[q,xe]=w(""),{data:s,error:b,isLoading:Se}=X({queryKey:["share-info",r,d],queryFn:async()=>{let e=await R.api.shares[":shareId"].info.$get({param:{shareId:r}},{headers:{"x-share-password":d}});if(e.status===401)throw Error("Unauthorized");if(e.status===403){let t=await e.json();throw Error(t.error||"Forbidden")}if(!e.ok)throw Error("Failed to fetch share info");return await e.json()},retry:!1}),o=ve||s?.rootFolderId,l=W||null,z=x||l,[V,ee]=w([]),{data:j}=X({queryKey:["public-share-folder",r,o,d],queryFn:async()=>{let e=await R.api.shares[":shareId"].files[":fileId"].$get({param:{shareId:r,fileId:o}},{headers:{"x-share-password":d}});if(e.status===401)throw Error("Unauthorized");return await e.json()},enabled:!!s&&!!o});S(()=>{if(j?.ancestorFolders&&s){let e=j.ancestorFolders.findIndex((t)=>t.id===s.rootFolderId);if(e!==-1)ee(j.ancestorFolders.slice(0,e));else if(o===s.rootFolderId)ee([])}},[j,s,o]);let[D,u]=w(null),[I,f]=w(new Set),[be,Pe]=w(360),[U,Ne]=w(()=>!W),P=M(null),[te,E]=w([]),[Ce,se]=w(0),[ke,_]=w(null),[oe,Ae]=w(null),[je,De]=w(void 0),{data:T,fetchNextPage:ae,hasNextPage:ne,isFetchingNextPage:ie,isLoading:le,error:de}=Tt({queryKey:["public-share-children",r,o,"folder",d],queryFn:async({pageParam:e})=>{let t=await R.api.shares[":shareId"].folders[":folderId"].children.$get({param:{shareId:r,folderId:o},query:{assetType:"folder",after:e}},{headers:{"x-share-password":d}});if(t.status===401)throw Error("Unauthorized");if(t.status===403)throw Error("Expired");return await t.json()},enabled:!!s&&!!o,initialPageParam:"",getNextPageParam:(e)=>e.pageInfo?.cursor||void 0,retry:!1}),{data:L,fetchNextPage:ce,hasNextPage:fe,isFetchingNextPage:ue,isLoading:me}=Tt({queryKey:["public-share-children",r,o,"file",d],queryFn:async({pageParam:e})=>{let t=await R.api.shares[":shareId"].folders[":folderId"].children.$get({param:{shareId:r,folderId:o},query:{assetType:"file",after:e}},{headers:{"x-share-password":d}});if(t.status===401)throw Error("Unauthorized");if(t.status===403)throw Error("Expired");return await t.json()},enabled:!!s&&!!o,initialPageParam:"",getNextPageParam:(e)=>e.pageInfo?.cursor||void 0,retry:!1}),{data:pe}=X({queryKey:["public-share-fields",r,d],queryFn:async()=>{let e=await R.api.shares[":shareId"].fields.$get({param:{shareId:r}},{headers:{"x-share-password":d}});if(e.status===401)throw Error("Unauthorized");return await e.json()},enabled:!!s}),{data:m,isLoading:$e}=X({queryKey:["public-share-file",r,l,d],queryFn:async()=>{let e=await R.api.shares[":shareId"].files[":fileId"].$get({param:{shareId:r,fileId:l}},{headers:{"x-share-password":d}});if(e.status===401)throw Error("Unauthorized");return await e.json()},enabled:!!l&&!!s}),{data:Ee,isLoading:Te}=X({queryKey:["public-share-file",r,x,d],queryFn:async()=>{let e=await R.api.shares[":shareId"].files[":fileId"].$get({param:{shareId:r,fileId:x}},{headers:{"x-share-password":d}});if(e.status===401)throw Error("Unauthorized");return await e.json()},enabled:!!x&&!!s}),n=x?Ee:m,Le=$e||!!x&&Te;S(()=>{if(de?.message==="Unauthorized")J(""),localStorage.removeItem(`share_pwd_${r}`)},[de,r]);let h=G(()=>T?.pages.flatMap((e)=>e.data??[])??[],[T]),v=G(()=>L?.pages.flatMap((e)=>e.data??[])??[],[L]),Re=T?.pages[0]?.pageInfo?.total,qe=L?.pages[0]?.pageInfo?.total,ze=T?.pages[0]?.pageInfo?.totalSize,Me=L?.pages[0]?.pageInfo?.totalSize,ge=G(()=>{if(n)return n;if(I.size!==1)return null;let e=Array.from(I)[0];return[...h,...v].find((t)=>t.id===e)||null},[I,h,v,n]),Ke=(e)=>{e.preventDefault(),J(q),localStorage.setItem(`share_pwd_${r}`,q)},he=(e)=>{if(e.type==="folder"||e.targetType==="folder")c({to:"/share/$shareId/folders/$folderId",params:{shareId:r,folderId:e.id}});else c({to:"/share/$shareId/files/$fileId",params:{shareId:r,fileId:e.versionStack?e.versionStack.id:e.id}});f(new Set)},Ve=(e)=>{if(!s)return;let t=e==="root"?s.rootFolderId:e;if(t===s.rootFolderId)c({to:"/share/$shareId",params:{shareId:r}});else c({to:"/share/$shareId/folders/$folderId",params:{shareId:r,folderId:t}});f(new Set),u(null)},Ue=(e)=>{_(e.id||null);let t=e.annotations;if(t&&t.length>0)E(t);else E([]);if(p){if(e.second!==null&&e.second!==void 0)De({second:e.second,nonce:Date.now()});return}if(e.second!==null&&e.second!==void 0)P.current?.seekTo(e.second),P.current?.pause();else if(t&&t.length>0)P.current?.pause()},we=()=>{E([]),_(null)},_e=()=>{E([]),_(null)},B=(e)=>{if(!l)return;c({to:"/share/$shareId/files/$fileId",params:{shareId:r,fileId:l},search:(t)=>({...t,...e})})},Be=()=>{B({compare:void 0,cmpLeft:void 0,cmpRight:void 0,cmpActive:void 0,version:Q==="left"?C:k})},{setProjectState:Ie,clearProjectState:Fe}=Zn();S(()=>{if(s&&o){let e=o===s.rootFolderId?s.name:h.find((t)=>t.id===o)?.name||s.name;Ie({teamId:"",projectId:s.projectId,projectName:s.name,ancestorFolders:V,currentAsset:{name:n?.name||e,type:l?"file":"folder",version:m?.versionStack?m.versionStack.versions.find((t)=>t.id===z)?.version??m.versionStack.versions.length:void 0,proxyType:n?.proxyType||null},isRootFolder:o===s.rootFolderId&&!l,isPublic:!0,shareId:r,fileId:l||void 0,allowDownload:s.allowDownload,downloadInfo:n?{originalKey:n.media?.original?.key,videoTranscodes:n.media?.videoTranscodes?.map((t)=>({key:t.key,width:t.width,height:t.height,resolution:t.resolution,hdr:t.hdr}))}:void 0,onFolderClick:Ve,isRightSidebarCollapsed:U,onRightSidebarToggle:()=>Ne((t)=>!t),versions:m?.versionStack?.versions,compareMode:p,canCompareVersions:(m?.versionStack?.versions?.length??0)>=2,onCompareVersions:()=>{let t=gu(m?.versionStack?.versions);if(!t||!l)return;c({to:"/share/$shareId/files/$fileId",params:{shareId:r,fileId:l},search:(i)=>({...i,compare:!0,cmpLeft:t.left.id,cmpRight:t.right.id,cmpActive:"left"})})}})}return()=>Fe()},[s,o,h,n,m,z,l,V,Ie,Fe,U,p,c,r]);let y;if(Se&&!b)y=a("div",{className:"flex flex-1 items-center justify-center bg-background",children:a(K,{className:"h-8 w-8 animate-spin text-foreground"})});else if(b)if(b.message==="Unauthorized"){let e=d!=="";y=a("div",{className:"flex flex-1 items-center justify-center p-4",children:g(lt,{className:"w-full max-w-md",children:[g(Nt,{className:"text-center",children:[a("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:a(Pn,{className:"h-6 w-6 text-primary"})}),a(Ft,{children:t1()})]}),a(St,{children:g("form",{onSubmit:Ke,className:"space-y-4",children:[g("div",{className:"space-y-2",children:[a(re,{type:"password",placeholder:"Enter password",value:q,onChange:(t)=>xe(t.target.value),autoFocus:!0}),e&&a("p",{className:"text-sm font-medium text-destructive",children:"Incorrect password. Please try again."})]}),a(F,{type:"submit",className:"w-full",children:"Access Share"})]})})]})})}else{let e=b.message.includes("expired"),t=b.message.includes("disabled");y=a("div",{className:"flex flex-1 items-center justify-center p-4",children:g(lt,{className:"w-full max-w-md",children:[g(Nt,{className:"text-center",children:[a("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-destructive/10",children:a(_r,{className:"h-6 w-6 text-destructive"})}),a(Ft,{children:e?"Share Expired":t?"Share Disabled":"Error"})]}),a(St,{className:"text-center text-muted-foreground",children:b.message})]})})}else if(!s)y=a("div",{className:"flex flex-1 items-center justify-center bg-background",children:a(K,{className:"h-8 w-8 animate-spin text-foreground"})});else if(A&&l&&!p&&n){let e=n?.ancestorFolders?.[0]?.id||(o!==s.rootFolderId?o:void 0),t=n?.ancestorFolders&&n.ancestorFolders.length>0?n.ancestorFolders:V;y=a(pu,{projectId:s.projectId,fileId:l,file:n,projectInfo:{name:s.name,rootFolder:s.rootFolderId},ancestorFolders:t,versions:m?.versionStack?.versions??n?.versionStack?.versions,activeFileId:z||l,startTime:O,isPublic:!0,shareId:r,allowDownload:s.allowDownload,publicFields:pe,siblingFiles:v,onNavigateToFile:(i)=>{c({to:"/share/$shareId/files/$fileId",params:{shareId:r,fileId:i}})},onNavigateBack:()=>{if(e&&e!==s.rootFolderId)c({to:"/share/$shareId/folders/$folderId",params:{shareId:r,folderId:e}});else c({to:"/share/$shareId",params:{shareId:r}})},onSelectVersion:(i)=>{c({to:"/share/$shareId/files/$fileId",params:{shareId:r,fileId:l},search:(N)=>({...N,version:i})})},onSaveField:()=>{}})}else y=g("div",{className:"flex flex-1 overflow-hidden relative",children:[l?g("div",{className:"flex-1 relative bg-muted/30",children:[Le&&!p&&a("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/50",children:a(K,{className:"h-8 w-8 animate-spin text-foreground"})}),p&&C&&k?a(mu,{isPublic:!0,shareId:r,versions:n?.versionStack?.versions??[],leftId:C,rightId:k,activeSide:Q,annotations:te,seekRequest:je,allowDownload:s.allowDownload,onActiveSideChange:(e)=>B({cmpActive:e}),onSwitchVersion:(e,t)=>B(e==="left"?{cmpLeft:t}:{cmpRight:t}),onExit:Be,onActiveAssetChange:Ae,onPlay:we,onTimeUpdate:se}):n&&a(Ns,{file:n,mediaControllerRef:P,onPlay:we,onTimeUpdate:se,onSeek:_e,annotations:te,startTime:O,shareId:r,allowDownload:s.allowDownload})]}):o&&(A?a(hu,{teamId:"",projectId:s.projectId,assetId:o,folders:h,files:v,totalFolders:Re,totalFiles:qe,totalFoldersSize:ze,totalFilesSize:Me,selectedItem:D,selectedIds:I,onItemSelect:(e,t)=>{if(t.metaKey||t.ctrlKey){let i=new Set(I);if(i.has(e.id)){if(i.delete(e.id),f(i),D?.id===e.id){let N=[...h,...v].find((H)=>i.has(H.id));u(N||null)}}else i.add(e.id),f(i),u(e)}else f(new Set([e.id])),u(e)},onItemDoubleClick:he,onClearSelection:()=>{f(new Set),u(null)},fetchNextFoldersPage:ae,hasNextFoldersPage:ne,isFetchingNextFoldersPage:ie,fetchNextFilesPage:ce,hasNextFilesPage:fe,isFetchingNextFilesPage:ue,isLoading:le||me,isShareView:!0,isPublic:!0,shareId:r,allowDownload:s.allowDownload}):a(wa,{teamId:"",projectId:s.projectId,assetId:o,folders:h,files:v,selectedItem:D,selectedIds:I,onItemSelect:(e,t)=>{if(t.metaKey||t.ctrlKey){let i=new Set(I);if(i.has(e.id)){if(i.delete(e.id),f(i),D?.id===e.id){let N=[...h,...v].find((H)=>i.has(H.id));u(N||null)}}else i.add(e.id),f(i),u(e)}else f(new Set([e.id])),u(e)},onItemDoubleClick:he,onSaveField:()=>{},displayStyle:s.viewMode??"card",onClearSelection:()=>{f(new Set),u(null)},fetchNextFoldersPage:ae,hasNextFoldersPage:ne,isFetchingNextFoldersPage:ie,fetchNextFilesPage:ce,hasNextFilesPage:fe,isFetchingNextFilesPage:ue,isLoading:le||me,isShareView:!0,isPublic:!0,shareId:r,sharePassword:d,allowDownload:s.allowDownload})),!U&&!A&&g(Y,{children:[a(Jr,{onResize:(e)=>Pe((t)=>Math.max(240,Math.min(600,t-e)))}),a("div",{style:{width:be},className:"flex-shrink-0 border-l",children:a(Ea,{teamId:"",projectId:s.projectId,file:p?oe:ge,onSaveField:()=>{},members:[],readOnly:!0,publicFields:pe,onCommentSelect:Ue,isPublic:!0,shareId:r,currentTime:Ce,onTyping:()=>{P.current?.pause()},selectedCommentId:ke,hideAnnotationControl:(p?oe:ge)?.proxyType==="audio"})})]})]});return g("div",{className:"flex h-[100dvh] flex-col bg-background",children:[(!A||!l)&&a(tm,{}),y]})}
2
- export{ba};
@@ -1,10 +0,0 @@
1
- import{J,Q,S,G,M,w,Z,Y,a,g,ee,R,z,Ka,Be,cr,Er,Ol,Ue,Ge,F,Dn,Nn,Fn,Ln,$e,He,Qe,Gb,VE,mx,yh,EI,bk,Ik,Tk,YM,Pt,ha,pt,mt,ht,Fi,An,ar,Te}from"./chunk-zarz3sqn.js";import{ss,ro,un,dl}from"./chunk-55h9ze53.js";import{yu}from"./chunk-91rb0jpb.js";var Mt=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Gd=z("arrow-left",Mt);var At=[["path",{d:"m11 10 3 3",key:"fzmg1i"}],["path",{d:"M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z",key:"p4q2r7"}],["path",{d:"M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031",key:"wy6l02"}]],Le=z("brush",At);var Et=[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]],Se=z("redo",Et);var It=[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]],Pe=z("undo",It);Z();var Rt=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#a855f7","#ec4899","#000000","#ffffff"],Bi=J(({projectId:h,onSendMessage:Fe,replyingTo:c,onCancelReply:ne,placeholder:_e,initialText:B="",value:A,onChangeText:E,disabled:pe=!1,allowMentions:ze,disableMentions:je=!1,allowAttachments:Oe=!0,workspaceAssets:x,onRemoveWorkspaceAsset:fe,allowMarkup:qe,hideAnnotationControl:We=!1,canMarkup:Ke=!0,markupDisabledTooltip:Ve,allowTimestamp:Xe=!0,currentTime:u,frameRate:m,startTimecode:ge,formatTimestamp:v,bottomLeftExtra:Je,isStreaming:oe=!1,onAbort:Ye,onTyping:I},Ze)=>{let[p,D]=w([]),[re,H]=w(null),[f,et]=w(!0),L=ze??!je,tt=qe??!We,T=Xe,{videoTimeDisplayMode:O}=ar(),nt=G(()=>{if(u===void 0)return"";if(v)return v(u);if(!m)return"";let e=Math.round(u*m);return ro(e,m,O,ge)},[u,m,O,ge,v]),{teamId:q,ensureTeamIdForProject:be}=Pt(),{members:he,loading:xe,fetchMembers:ot,fetchProjectMembers:rt}=An();S(()=>{if(h&&!q)be(h)},[h,q,be]);let{isDrawing:at,setIsDrawing:P,currentTool:W,setTool:K,currentColor:ve,setColor:st,undo:lt,redo:it,history:ct,historyIndex:ye,annotations:ae,reset:we}=un(),[se,y]=w(!1),[le,dt]=w(""),[U,_]=w(0),[b,Ne]=w({bots:!1,users:!1}),[ie,N]=w(!1),ut=G(()=>{if(!f||!T||u===void 0||!v&&!m||ie)return"";if(O==="timecode")return"pl-[120px]";return"pl-[85px]"},[f,T,u,m,ie,O,v]),r=M(null),V=M(null),k=M(null),ke=M(null),C=M(!1),{mutateAsync:Ce}=ee({mutationFn:async({projectId:e,data:t})=>{let n=await R.api.projects[":projectId"].attachments.$post({param:{projectId:e},json:t});if(!n.ok)throw Error("Failed to create attachment");return await n.json()}});S(()=>{if(A!==void 0&&r.current){if(C.current){C.current=!1;return}if(r.current.innerText!==A)r.current.innerText=A,N(!!A.trim())}else if(B&&r.current){r.current.innerText=B,N(!!B.trim()),r.current.focus();let e=document.createRange(),t=window.getSelection();e.selectNodeContents(r.current),e.collapse(!1),t?.removeAllRanges(),t?.addRange(e)}},[A,B]);let ce=M(null),Me=Q((e)=>{if(!r.current)return;let t=document.createElement("span");t.contentEditable="false",t.dataset.type="mention",t.dataset.id=e.id,t.className="inline-block bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300 px-1.5 py-0.5 rounded-md text-sm font-medium align-middle select-none mx-0.5",t.innerText=`@${e.name}`;let n=document.createTextNode(" ");r.current.appendChild(t),r.current.appendChild(n);let s=document.createRange(),l=window.getSelection();s.setStartAfter(n),s.collapse(!0),l?.removeAllRanges(),l?.addRange(s),N(!0);let o=r.current.innerText||"";C.current=!0,E?.(o),I?.(),r.current.focus()},[E,I]);S(()=>{if(c&&r.current){if(c.id!==ce.current){if(ce.current=c.id,L&&c.creator?.id&&c.creator?.name){let n=r.current.querySelectorAll('span[data-type="mention"]');if(!Array.from(n).some((l)=>l.dataset.id===c.creator.id)){Me({id:c.creator.id,name:c.creator.name});return}}}r.current.focus();let e=document.createRange(),t=window.getSelection();e.selectNodeContents(r.current),e.collapse(!1),t?.removeAllRanges(),t?.addRange(e)}else if(!c)ce.current=null},[c,L,Me]),S(()=>()=>{P(!1)},[P]);let j=he.filter((e)=>e.type==="agent"&&e.name?.toLowerCase().startsWith(le.toLowerCase())).map((e)=>({type:"user",data:e})),X=he.filter((e)=>e.type!=="agent"&&e.name?.toLowerCase().startsWith(le.toLowerCase())).map((e)=>({type:"user",data:e})),te=[...b.bots?[]:j,...b.users?[]:X];S(()=>{_(0)},[le,se,b]),S(()=>{ke.current?.querySelector(`[data-index="${U}"]`)?.scrollIntoView({block:"nearest"})},[U]);let Ae=(e)=>e.split(" ").map((t)=>t[0]).slice(0,2).join("").toUpperCase(),Ee=()=>{if(!r.current)return;let e=r.current.innerText||"";if(N(!!e.trim()),C.current=!0,E?.(e),I?.(),!L){y(!1),k.current=null;return}let t=window.getSelection();if(!t||t.rangeCount===0)return;let n=t.getRangeAt(0),{startContainer:s,startOffset:l}=n;if(s.nodeType===Node.TEXT_NODE){let i=(s.textContent||"").slice(0,l),d=i.lastIndexOf("@");if(d!==-1){let kt=d===0,Ct=i[d-1];if(kt||/\s/.test(Ct)){let De=i.slice(d+1);if(!/\s/.test(De)){if(dt(De),y(!0),h)rt(h,!0,!0);else if(q)ot(q,!0,!0);let me=document.createRange();me.setStart(s,d),me.setEnd(s,l),k.current=me;return}}}}y(!1),k.current=null},de=(e)=>{if(!k.current||!r.current)return;let t=k.current;t.deleteContents();let n=document.createElement("span");n.contentEditable="false",n.dataset.type="mention",n.dataset.id=e.data.id,n.className="inline-block bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300 px-1.5 py-0.5 rounded-md text-sm font-medium align-middle select-none mx-0.5",n.innerText=`@${e.data.name}`,t.insertNode(n);let s=document.createTextNode(" ");n.after(s);let l=document.createRange(),o=window.getSelection();l.setStartAfter(s),l.collapse(!0),o?.removeAllRanges(),o?.addRange(l),y(!1),k.current=null,N(!0);let i=r.current.innerText||"";C.current=!0,E?.(i),I?.(),r.current.focus()},ft=(e)=>{e.preventDefault();let t=e.clipboardData.getData("text/plain");if(!t)return;let n=window.getSelection();if(!n||n.rangeCount===0||!r.current?.contains(n.anchorNode)){if(r.current){r.current.focus();let l=document.createRange();l.selectNodeContents(r.current),l.collapse(!1),n=window.getSelection(),n?.removeAllRanges(),n?.addRange(l)}}if(!(typeof document.execCommand==="function"&&document.queryCommandSupported?.("insertText")&&document.execCommand("insertText",!1,t))){let l=window.getSelection();if(l&&l.rangeCount>0){let o=l.getRangeAt(0);o.deleteContents();let i=document.createTextNode(t);o.insertNode(i),o.setStartAfter(i),o.collapse(!0),l.removeAllRanges(),l.addRange(o)}else if(r.current)r.current.innerText+=t}Ee()},gt=(e)=>{if(e.nativeEvent.isComposing)return;if(se&&L&&te.length>0){if(e.key==="ArrowUp"){e.preventDefault(),_((t)=>t>0?t-1:te.length-1);return}if(e.key==="ArrowDown"){e.preventDefault(),_((t)=>t<te.length-1?t+1:0);return}if(e.key==="Enter"||e.key==="Tab"){e.preventDefault(),de(te[U]);return}if(e.key==="Escape"){e.preventDefault(),y(!1);return}}if(e.key==="Enter"&&!e.shiftKey)e.preventDefault(),Ie()},bt=Q(async(e)=>{if(!e.target.files)return;let t=Array.from(e.target.files);for(let n of t){let s=`${Date.now()}-${n.name}`,l={id:s,file:n,progress:0};D((o)=>[...o,l]);try{let o=await Ce({projectId:h,data:{fileName:n.name,contentType:n.type,size:n.size}});if(o.uploadUrl&&o.id)await fetch(o.uploadUrl,{method:"PUT",body:n,headers:{"Content-Type":n.type}}),D((i)=>i.map((d)=>d.id===s?{...d,progress:100,attachmentId:o.id}:d))}catch(o){D((i)=>i.map((d)=>d.id===s?{...d,error:o instanceof Error?o.message:"Upload failed"}:d))}}if(V.current)V.current.value=""},[h,Ce]),xt=(e)=>{D((t)=>t.filter((n)=>n.id!==e))},Ie=()=>{if(!r.current)return;if(p.some((o)=>!o.attachmentId&&!o.error))return;let t=p.map((o)=>o.attachmentId).filter((o)=>!!o),n=p.filter((o)=>!o.error&&!!o.attachmentId).map((o)=>({id:o.attachmentId,name:o.file.name,type:o.file.type,url:o.file.type.startsWith("image/")||Fi(o.file.name)?URL.createObjectURL(o.file):void 0})),s="";r.current.childNodes.forEach((o)=>{if(o.nodeType===Node.TEXT_NODE)s+=o.textContent;else if(o.nodeType===Node.ELEMENT_NODE){let i=o;if(i.dataset.type==="mention")s+=`<@${i.dataset.id}>`;else if(i.tagName==="BR")s+=`
2
- `;else if(i.tagName==="DIV"||i.tagName==="P")s+=`
3
- `+i.innerText;else s+=i.innerText}}),s=s.trim();let l=(x?.length??0)>0;if(!s&&t.length===0&&ae.length===0&&!l)return;if(Fe(s,t,ae,c?.id,T&&f?u:void 0,n),r.current.innerHTML="",N(!1),C.current=!0,E?.(""),D([]),H(null),P(!1),we(),y(!1),ne)ne()},ue=p.some((e)=>!e.attachmentId&&!e.error),vt=p.some((e)=>!!e.attachmentId),yt=(x?.length??0)>0,wt=pe||oe,Re=(ie||vt||ae.length>0||yt)&&!wt,Nt=x&&x.length>0||p.length>0||!!c;return g("div",{ref:Ze,className:"relative flex flex-col w-full border border-foreground/35 rounded-3xl shadow-sm transition-all duration-200 bg-background",children:[a("style",{children:`
4
- [contenteditable]:empty:before {
5
- content: attr(data-placeholder);
6
- color: #9ca3af;
7
- cursor: text;
8
- }
9
- `}),se&&L&&(xe||j.length>0||X.length>0)&&a("div",{onMouseDown:(e)=>e.preventDefault(),className:"absolute bottom-full left-4 mb-2 w-64 rounded-xl shadow-lg border border-border overflow-hidden z-20 bg-popover text-popover-foreground animate-in fade-in slide-in-from-bottom-2 duration-200",children:a("div",{ref:ke,className:"h-64 overflow-y-auto",children:xe?g("div",{className:"p-2 space-y-4 animate-pulse",children:[g("div",{className:"space-y-2",children:[a("div",{className:"px-3 py-1.5 bg-muted/50 border-b border-border",children:a(Te,{className:"h-3 w-16"})}),g("div",{className:"flex items-center gap-2 px-3 py-2",children:[a(Te,{className:"w-6 h-6 rounded-full"}),a(Te,{className:"h-4 w-28"})]}),g("div",{className:"flex items-center gap-2 px-3 py-2",children:[a(Te,{className:"w-6 h-6 rounded-full"}),a(Te,{className:"h-4 w-20"})]})]}),g("div",{className:"space-y-2",children:[a("div",{className:"px-3 py-1.5 bg-muted/50 border-b border-border",children:a(Te,{className:"h-3 w-16"})}),g("div",{className:"flex items-center gap-2 px-3 py-2",children:[a(Te,{className:"w-6 h-6 rounded-full"}),a(Te,{className:"h-4 w-32"})]}),g("div",{className:"flex items-center gap-2 px-3 py-2",children:[a(Te,{className:"w-6 h-6 rounded-full"}),a(Te,{className:"h-4 w-24"})]})]})]}):g(Y,{children:[j.length>0&&g(Y,{children:[g("button",{type:"button",onMouseDown:(e)=>e.preventDefault(),onClick:(e)=>{e.preventDefault(),e.stopPropagation(),Ne((t)=>({...t,bots:!t.bots})),r.current?.focus()},className:"w-full text-xs font-semibold text-muted-foreground px-3 py-2 bg-muted/50 border-b border-border flex items-center justify-between hover:bg-muted transition-colors cursor-pointer select-none",children:[a("span",{children:"Agents"}),a(Be,{className:`w-3 h-3 transition-transform ${b.bots?"-rotate-90":""}`})]}),!b.bots&&j.map((e,t)=>{let n=t;return g("button",{type:"button","data-index":n,onMouseDown:(s)=>s.preventDefault(),onClick:()=>de(e),onMouseEnter:()=>_(n),className:`w-full flex items-center gap-2 px-3 py-2 transition-colors text-left cursor-pointer ${n===U?"bg-accent text-accent-foreground":"hover:bg-accent/50"}`,children:[g($e,{className:"w-6 h-6",children:[e.type==="user"&&e.data.image&&a(He,{src:e.data.image,alt:e.data.name,className:"object-cover"}),a(Qe,{className:"text-[10px] bg-purple-400 text-black font-semibold",children:Ae(e.data.name)})]}),a("span",{className:"text-sm",children:e.data.name})]},e.data.id)})]}),X.length>0&&g(Y,{children:[g("button",{type:"button",onMouseDown:(e)=>e.preventDefault(),onClick:(e)=>{e.preventDefault(),e.stopPropagation(),Ne((t)=>({...t,users:!t.users})),r.current?.focus()},className:"w-full text-xs font-semibold text-muted-foreground px-3 py-2 bg-muted/50 border-b border-border flex items-center justify-between hover:bg-muted transition-colors cursor-pointer select-none",children:[a("span",{children:"Members"}),a(Be,{className:`w-3 h-3 transition-transform ${b.users?"-rotate-90":""}`})]}),!b.users&&X.map((e,t)=>{let n=b.bots?0:j.length,s=t+n;return g("button",{type:"button","data-index":s,onMouseDown:(l)=>l.preventDefault(),onClick:()=>de(e),onMouseEnter:()=>_(s),className:`w-full flex items-center gap-2 px-3 py-2 transition-colors text-left cursor-pointer ${s===U?"bg-accent text-accent-foreground":"hover:bg-accent/50"}`,children:[g($e,{className:"w-6 h-6",children:[e.type==="user"&&e.data.image&&a(He,{src:e.data.image,alt:e.data.name,className:"object-cover"}),a(Qe,{className:"text-[10px] bg-purple-400 text-black font-semibold",children:Ae(e.data.name)})]}),a("span",{className:"text-sm",children:e.data.name})]},e.data.id)})]})]})})}),Nt&&g("div",{className:"flex flex-col gap-2 p-3 pb-0 animate-in fade-in slide-in-from-bottom-2 duration-200",children:[x&&x.length>0&&a("div",{className:"flex flex-col gap-1.5 min-h-0 max-h-[160px] overflow-y-auto border border-border/60 rounded-lg bg-muted/20 p-2.5 divide-y divide-border/50",children:x.map((e)=>g("div",{className:"flex items-center justify-between py-1 text-xs group",children:[g("div",{className:"flex items-baseline gap-1.5 min-w-0 pr-2",children:[a("span",{className:"truncate font-medium text-foreground",children:e.name}),a("span",{className:"text-[9px] text-muted-foreground uppercase flex-shrink-0",children:e.type})]}),fe&&a("button",{onClick:()=>fe(e.id),className:"text-muted-foreground hover:text-destructive transition-colors p-0.5 cursor-pointer",title:bk?.()||"Remove from context",children:a(Ue,{className:"h-3.5 w-3.5"})})]},e.id))}),c&&g("div",{className:"flex items-center justify-between bg-muted p-2 px-3 rounded-lg border border-border",children:[a("div",{className:"text-xs text-muted-foreground truncate mr-2",children:Tk({message:c.message||""})}),a("button",{onClick:ne,className:"text-muted-foreground hover:text-foreground p-1 rounded-full hover:bg-muted-foreground/10 shrink-0",children:a(Ge,{className:"w-3.5 h-3.5"})})]}),p.length>0&&a("div",{className:"flex gap-3 overflow-x-auto py-2 px-1 scrollbar-hide",children:p.map((e)=>g("div",{className:"relative group flex-shrink-0",children:[g("div",{className:"w-16 h-16 rounded-lg border border-gray-200 overflow-hidden bg-gray-50 flex items-center justify-center",children:[e.file.type.startsWith("image/")?a("img",{src:URL.createObjectURL(e.file),alt:"preview",onClick:()=>H(e.file),className:`w-full h-full object-cover ${!e.attachmentId?"opacity-50":""}`}):a(Er,{className:"w-8 h-8 text-gray-400"}),ue&&!e.attachmentId&&!e.error&&a("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:a(dl,{progress:e.progress,className:"w-10 h-10"})})]}),a("button",{onClick:()=>xt(e.id),className:"absolute -top-1.5 -right-1.5 bg-gray-500 text-white rounded-full p-0.5 shadow-md opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500 z-10 cursor-pointer",children:a(Ge,{className:"w-3 h-3"})}),a("span",{className:"text-[10px] text-gray-500 mt-1 block max-w-[4rem] truncate text-center",children:e.file.name})]},e.id))})]}),g("div",{onClick:()=>r.current?.focus(),className:"w-full px-4 pt-1 pb-1 cursor-text flow-root max-h-60 overflow-y-auto",children:[T&&f&&u!==void 0&&(m!==void 0||v!==void 0)&&a("div",{onClick:(e)=>{e.stopPropagation(),r.current?.focus()},className:"float-left select-none bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-300 px-2.5 py-0.5 mt-3 mr-2 rounded-sm text-xs font-mono font-bold flex items-center gap-1 cursor-text",children:nt}),a("div",{ref:r,contentEditable:!pe&&!oe,suppressContentEditableWarning:!0,onInput:Ee,onKeyDown:gt,onPaste:ft,"data-placeholder":_e||(c?Ik():EI()),className:`bg-transparent border-none focus:ring-0 resize-none min-h-[40px] leading-relaxed py-2 focus:outline-none block whitespace-pre-wrap break-words ${ut}`})]}),g("div",{className:"flex justify-between items-center px-2 pb-2",children:[at?g("div",{className:"flex items-center gap-2 overflow-x-auto scrollbar-hide w-full mr-2",children:[a(F,{onClick:()=>{P(!1),we()},variant:"ghost",size:"icon",className:"p-2 rounded-full cursor-pointer text-gray-500 hover:text-gray-700 hover:bg-gray-100 mr-2",title:"Back",children:a(Gd,{className:"w-4 h-4"})}),a("div",{className:"h-4 w-px bg-gray-300 mx-1"}),a("button",{onClick:()=>K("arrow"),className:`p-1.5 rounded hover:bg-gray-100 ${W==="arrow"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Arrow",children:a(Ka,{size:16,className:"rotate-45"})}),a("button",{onClick:()=>K("line"),className:`p-1.5 rounded hover:bg-gray-100 ${W==="line"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Line",children:a(ss,{size:16,className:"-rotate-45"})}),a("button",{onClick:()=>K("box"),className:`p-1.5 rounded hover:bg-gray-100 ${W==="box"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Box",children:a(yu,{size:16})}),a("button",{onClick:()=>K("freehand"),className:`p-1.5 rounded hover:bg-gray-100 ${W==="freehand"?"text-blue-500 bg-blue-50":"text-gray-500"}`,title:"Freehand",children:a(Le,{size:16})}),a("div",{className:"h-4 w-px bg-gray-300 mx-1"}),g(pt,{children:[a(mt,{asChild:!0,children:g("button",{className:"flex items-center gap-1 p-1 rounded hover:bg-gray-100",children:[a("div",{className:"w-4 h-4 rounded-full border border-gray-200",style:{backgroundColor:ve}}),a(Be,{size:12,className:"text-gray-500"})]})}),a(ht,{className:"w-auto p-2",align:"center",side:"top",children:a("div",{className:"flex items-center gap-1",children:Rt.map((e)=>a("button",{onClick:()=>st(e),className:`w-6 h-6 rounded-full border border-gray-200 transition-transform hover:scale-110 ${ve===e?"ring-2 ring-blue-500 ring-offset-1":""}`,style:{backgroundColor:e}},e))})})]}),a("div",{className:"h-4 w-px bg-gray-300 mx-1"}),a("button",{onClick:lt,disabled:ye<=0,className:"p-1.5 rounded hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-500",children:a(Pe,{size:16})}),a("button",{onClick:it,disabled:ye>=ct.length-1,className:"p-1.5 rounded hover:bg-gray-100 disabled:opacity-30 disabled:cursor-not-allowed text-gray-500",children:a(Se,{size:16})})]}):g("div",{className:"flex items-center gap-1.5 min-w-0 max-w-[80%]",children:[Je,Oe&&g(Y,{children:[a("input",{type:"file",ref:V,className:"hidden",multiple:!0,onChange:bt}),a(F,{onClick:()=>V.current?.click(),className:"p-2 rounded-full cursor-pointer shrink-0",variant:"ghost",size:"icon",title:Gb(),children:a(Ol,{className:"w-4 h-4"})})]}),T&&u!==void 0&&(m!==void 0||v!==void 0)&&a(F,{onClick:()=>et(!f),variant:f?"secondary":"ghost",size:"icon",className:`p-2 rounded-full cursor-pointer shrink-0 ${f?"text-blue-600 bg-blue-50 dark:bg-blue-900/20":""}`,title:f?VE():mx(),children:a(cr,{className:"w-4 h-4"})}),tt&&(Ke?a(F,{onClick:()=>{I?.(),P(!0)},variant:"ghost",size:"icon",className:"p-2 rounded-full cursor-pointer shrink-0",title:YM(),children:a(ha,{className:"w-4 h-4"})}):a(Dn,{children:g(Nn,{children:[a(Fn,{asChild:!0,children:a("span",{className:"inline-block cursor-not-allowed shrink-0",children:a(F,{disabled:!0,variant:"ghost",size:"icon",className:"p-2 rounded-full opacity-40 cursor-not-allowed pointer-events-none",children:a(ha,{className:"w-4 h-4"})})})}),a(Ln,{side:"top",children:a("p",{className:"text-xs",children:Ve||yh()})})]})}))]}),oe?a("button",{onClick:Ye,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 cursor-pointer",title:"Stop generation",children:a("div",{className:"h-4 w-4 flex items-center justify-center",children:a("div",{className:"h-3 w-3 rounded-[2px] bg-white"})})}):a("button",{onClick:Ie,disabled:!Re||ue,className:`p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 ${Re&&!ue?"bg-blue-600 text-white shadow-md hover:bg-blue-700 hover:shadow-lg transform hover:-translate-y-0.5 cursor-pointer":"bg-gray-400 cursor-not-allowed opacity-50"}`,children:a(Ka,{className:"w-4 h-4"})})]}),re&&g("div",{className:"fixed inset-0 z-[100] bg-black/95 flex flex-col items-center justify-center p-4 animate-in fade-in duration-200",onClick:()=>H(null),children:[a("button",{className:"absolute top-4 right-4 text-white/70 hover:text-white hover:bg-white/20 rounded-full p-2 transition-colors z-50",children:a(Ge,{className:"w-8 h-8"})}),a("div",{className:"w-full h-full flex items-center justify-center p-2",children:a("img",{src:URL.createObjectURL(re),alt:"Enlarged view",className:"max-w-full max-h-[85vh] object-contain rounded shadow-2xl cursor-zoom-out",onClick:(e)=>{e.stopPropagation(),H(null)}})}),a("div",{className:"absolute bottom-6 text-white text-sm font-medium bg-black/50 px-4 py-2 rounded-full backdrop-blur-sm",children:re.name})]})]})});Bi.displayName="ChatInput";
10
- export{Gd,Bi};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Yt}from"./chunk-9xhjy897.js";import{at}from"./chunk-e4yscwen.js";import{se}from"./chunk-2jj4j8cn.js";var _=se(Yt()),N=se(at()),id="AWS_ACCESS_KEY_ID",ad="AWS_SECRET_ACCESS_KEY",S="AWS_SESSION_TOKEN",C="AWS_CREDENTIAL_EXPIRATION",A="AWS_CREDENTIAL_SCOPE",p="AWS_ACCOUNT_ID",Nf=(e)=>async()=>{e?.logger?.debug("@aws-sdk/credential-provider-env - fromEnv");let o=process.env[id],E=process.env[ad],r=process.env[S],n=process.env[C],s=process.env[A],t=process.env[p];if(o&&E){let c={accessKeyId:o,secretAccessKey:E,...r&&{sessionToken:r},...n&&{expiration:new Date(n)},...s&&{credentialScope:s},...t&&{accountId:t}};return _.setCredentialFeature(c,"CREDENTIALS_ENV_VARS","g"),c}throw new N.CredentialsProviderError("Unable to find environment variable credentials.",{logger:e?.logger})};export{id,ad,Nf};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{id,ad,Nf}from"./chunk-26qn7fek.js";export{id as ENV_KEY,ad as ENV_SECRET,Nf as fromEnv};
@@ -1 +0,0 @@
1
- import{S,Z,a,X,Je,R,Pt,qt,Mg}from"./chunk-zarz3sqn.js";import"./chunk-f6avg5qe.js";import"./chunk-s1e4qy3q.js";import"./chunk-ns33grgx.js";import"./chunk-q2bew2vc.js";import"./chunk-55h9ze53.js";import"./chunk-1ktk6764.js";import"./chunk-ah8fjb6f.js";import"./chunk-96qpjght.js";import"./chunk-8mqbztj8.js";import"./chunk-gtf19jc1.js";import"./chunk-zezje74z.js";import"./chunk-r1xer8gn.js";import"./chunk-q5vkxee3.js";import{xo}from"./chunk-xc54vhfz.js";import"./chunk-hpbn0k9n.js";import{gr}from"./chunk-pk406dgy.js";import"./chunk-8yjsmr7g.js";import"./chunk-atfz7g7e.js";import"./chunk-257dcd2f.js";import"./chunk-91rb0jpb.js";import"./chunk-ny1kbmxt.js";import"./chunk-fvx9k1dc.js";import"./chunk-kvhf12b4.js";import"./chunk-qwpkcp8d.js";import"./chunk-v5cn90cf.js";Z();function m(){let{projectId:o,folderId:n}=c.useParams(),{teamId:r,ensureTeamIdForProject:t}=Pt();S(()=>{t(o)},[o,t]);let{data:d}=gr(Mg(o)),e=d?.rootFolder,{data:s}=X({queryKey:["folders",e],queryFn:()=>(async()=>await(await R.api.folders[":folderId"].$get({param:{folderId:e}})).json())(),enabled:!!e});if(!r||!e||!s)return a(qt,{});return a(xo,{teamId:r,projectId:o,projectName:d.name??"",assetId:n,rootFolderId:e})}var c=Je("/projects/$projectId/folders/$folderId")({component:m});export{c as Route};
@@ -1 +0,0 @@
1
- import{S,Z,a,X,Je,R,Pt,qt,Sg}from"./chunk-zarz3sqn.js";import"./chunk-f6avg5qe.js";import"./chunk-s1e4qy3q.js";import"./chunk-ns33grgx.js";import"./chunk-q2bew2vc.js";import"./chunk-55h9ze53.js";import"./chunk-1ktk6764.js";import"./chunk-ah8fjb6f.js";import"./chunk-96qpjght.js";import"./chunk-8mqbztj8.js";import"./chunk-gtf19jc1.js";import"./chunk-zezje74z.js";import"./chunk-r1xer8gn.js";import"./chunk-q5vkxee3.js";import{xo}from"./chunk-xc54vhfz.js";import"./chunk-hpbn0k9n.js";import{gr}from"./chunk-pk406dgy.js";import"./chunk-8yjsmr7g.js";import"./chunk-atfz7g7e.js";import"./chunk-257dcd2f.js";import"./chunk-91rb0jpb.js";import"./chunk-ny1kbmxt.js";import"./chunk-fvx9k1dc.js";import"./chunk-kvhf12b4.js";import"./chunk-qwpkcp8d.js";import"./chunk-v5cn90cf.js";Z();function s(){let{projectId:o}=m.useParams(),{teamId:r,ensureTeamIdForProject:t}=Pt();S(()=>{t(o)},[o,t]);let{data:n}=gr(Sg(o)),e=n?.rootFolder,{data:d}=X({queryKey:["folders",e],queryFn:()=>(async()=>await(await R.api.folders[":folderId"].$get({param:{folderId:e}})).json())(),enabled:!!e});if(!r||!e||!d)return a(qt,{});return a(xo,{teamId:r,projectId:o,projectName:n.name??"",assetId:"recently-deleted",rootFolderId:e})}var m=Je("/projects/$projectId/recently-deleted")({component:s});export{m as Route};
@@ -1 +0,0 @@
1
- import{Q,S,G,M,w,Z,Y,a,g,ie,X,ee,Tt,Je,R,z,K,qe,Mn,jt,Do,No,ps,Re,Ue,Ge,F,De,Ne,Fe,de,En,ur,Um,vA,jm,Cb,Sb,$m,Hm,Ke,Pw,Ya,Kw,Jw,a_,Mt,th,nx,_x,w_,Cx,kx,Rx,Mx,Ox,Px,Fl,pa,bd,lh,Ll,uC,vC,VC,cS,dS,IS,kS,RS,vp,OI,yT,bT,kT,MT,Dh,_0,Nh,p1,m1,Wc,xk,Nk,wo,Uk,Wk,Xk,ny,jl,Cd,Jc,ng,og,sg,Yc,Sd,Id,ig,ag,Td,LM,ZM,BM,UM,jM,Jn,gg,RO,MO,kd,My,zO,jO,qO,$O,HO,Se,xe,ke,ot,Ce,re,Ie,Pt,an,Yn,Eo,Md,j,qr,Zn,fe,Ve,Xe,et,tt,rt,be,Aa,ar,Fr,qt,Rg}from"./chunk-zarz3sqn.js";import{ec}from"./chunk-f6avg5qe.js";import{Zd,wa}from"./chunk-s1e4qy3q.js";import{_s}from"./chunk-ns33grgx.js";import"./chunk-q2bew2vc.js";import"./chunk-55h9ze53.js";import"./chunk-8mqbztj8.js";import{Jr}from"./chunk-q5vkxee3.js";import{il,lu}from"./chunk-96qpjght.js";import{ou,su}from"./chunk-tekwpkjf.js";import{al}from"./chunk-b5rhvzv9.js";import{uu}from"./chunk-7naa7tpn.js";import{gr}from"./chunk-pk406dgy.js";import{fu}from"./chunk-8fyg9dy4.js";import"./chunk-atfz7g7e.js";import"./chunk-257dcd2f.js";import"./chunk-ny1kbmxt.js";import"./chunk-fvx9k1dc.js";import{zo}from"./chunk-kvhf12b4.js";import"./chunk-qwpkcp8d.js";import{jo}from"./chunk-88jg9dq5.js";import{Zr}from"./chunk-v5cn90cf.js";Z();var bt=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],it=z("folder-open",bt);var yt=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],lt=z("list-filter",yt);Z();function Nt({ratio:t}){switch(t){case"16:9":return a("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"});case"9:16":return a("span",{className:"inline-block w-2.5 h-4 border border-current rounded-[1px] shrink-0"});case"4:3":return a("span",{className:"inline-block w-3.5 h-2.5 border border-current rounded-[1px] shrink-0"});case"3:4":return a("span",{className:"inline-block w-2.5 h-3.5 border border-current rounded-[1px] shrink-0"});case"1:1":return a("span",{className:"inline-block w-3 h-3 border border-current rounded-[1px] shrink-0"});default:return a("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"})}}function at(){return Math.random().toString(36).substring(2,9)}function dt(){return{id:at(),type:"text",text:"CONFIDENTIAL",x:0.5,y:0.5,size:0.05,color:"#999999",opacity:0.5,rotation:-30}}function kt(){return{id:at(),type:"image",imageAssetKey:"",x:0.5,y:0.5,size:0.15,opacity:0.5,rotation:0}}var Ze=[{id:"dark",label:"Dark Slate",bg:"#1e293b",dot:"#475569"},{id:"black",label:"Black",bg:"#000000",dot:"#404040"},{id:"gray",label:"Slate Gray",bg:"#64748b",dot:"#cbd5e1"},{id:"white",label:"White",bg:"#ffffff",dot:"#94a3b8"},{id:"green",label:"Chroma Green",bg:"#059669",dot:"#047857"}],St={"16:9":1.7777777777777777,"9:16":0.5625,"4:3":1.3333333333333333,"3:4":0.75,"1:1":1};function mt({open:t,onOpenChange:b,initialConfig:f,shareId:m,teamId:y,onSaveSuccess:x}){let D=ie(),[l,v]=w([]),[d,p]=w(null),[B,E]=w(null),[N,oe]=w("16:9"),[le,ce]=w("grid"),[ge,q]=w(!1),[ne,te]=w("new"),[se,O]=w(""),[U,V]=w(null),k=M(null),H=M(null),[J,ve]=w({w:0,h:0}),[_,A]=w(!1),s=Q((e)=>{if(H.current=e,!e)return;let i=()=>{let{clientWidth:C,clientHeight:h}=e;if(C<=0||h<=0)return;let P=St[N],Ye=C,Te=Ye/P;if(Te>h)Te=h,Ye=Te*P;ve({w:Math.round(Ye),h:Math.round(Te)})};i();let o=new ResizeObserver(i);return o.observe(e),()=>{o.disconnect(),H.current=null}},[N]),W=Pt((e)=>e.teamId),me=y||W,[Ee,ye]=w(!1),[L,he]=w({}),ae=M(null),ue=R.api.teams[":teamId"].files.$post,we=async(e,i)=>{let o=e.target.files?.[0];if(!o)return;if(o.size>1048576){if(j.error(uC()),ae.current)ae.current.value="";return}if(!me){j.error(bd());return}ye(!0);let C=URL.createObjectURL(o);he((h)=>({...h,[i]:C}));try{let h=await ue({param:{teamId:me},form:{file:o}});if(!h.ok)throw Error(bd());let P=await h.json();I(i,{imageAssetKey:P.key,imageAssetUrl:P.url})}catch(h){let P=h instanceof Error?h.message:bd();j.error(P)}finally{if(ye(!1),ae.current)ae.current.value=""}};S(()=>{if(t){if(f?.blocks&&f.blocks.length>0)v(f.blocks),p(f.blocks[0].id);else{let e=dt();v([e]),p(e.id)}E(null)}},[t,f]);let{data:T=[]}=X({queryKey:["watermark-templates",y],queryFn:async()=>{let e=await R.api["watermark-templates"].$get({query:y?{teamId:y}:{}});if(!e.ok)return[];return await e.json()},enabled:t}),_e=R.api.shares[":shareId"].watermark.$put,{mutate:pe,isPending:Ae}=ee({mutationFn:async(e)=>{let i=await _e({param:{shareId:m},json:{enabled:!0,config:e}});if(!i.ok){let o=await i.json().catch(()=>null);throw Error(o?.error||pa())}return await i.json()},onSuccess:()=>{D.invalidateQueries({queryKey:["share",m]}),D.invalidateQueries({queryKey:["shares"]}),j.success(HO()),b(!1),x?.()},onError:(e)=>{j.error(e.message||pa())}}),We=R.api["watermark-templates"].$post,{mutate:ze,isPending:Le}=ee({mutationFn:async({name:e,config:i})=>{let o=await We({json:{name:e,teamId:y||void 0,config:i}});if(!o.ok)throw Error(pa());return await o.json()},onSuccess:(e)=>{D.invalidateQueries({queryKey:["watermark-templates"]}),E(e.id),q(!1),j.success(BM())},onError:()=>{j.error(pa())}}),$e=R.api["watermark-templates"][":templateId"].$put,{mutate:Me,isPending:Oe}=ee({mutationFn:async({templateId:e,config:i})=>{let o=await $e({param:{templateId:e},json:{config:i}});if(!o.ok)throw Error(pa());return await o.json()},onSuccess:()=>{D.invalidateQueries({queryKey:["watermark-templates"]}),q(!1),j.success(UM())},onError:()=>{j.error(pa())}}),r=R.api["watermark-templates"][":templateId"].$delete,{mutate:c}=ee({mutationFn:async(e)=>{if(!(await r({param:{templateId:e}})).ok)throw Error(Fl())},onSuccess:(e,i)=>{if(D.invalidateQueries({queryKey:["watermark-templates"]}),B===i)E(null);j.success(LM())},onError:()=>{j.error(Fl())}}),u=l.findIndex((e)=>e.id===d),n=u>=0?l[u]:null,Be=()=>{let e=dt();v((i)=>[...i,e]),p(e.id)},pt=()=>{let e=kt();v((i)=>[...i,e]),p(e.id)},nt=(e)=>{if(!e)return;v((i)=>{let o=i.filter((C)=>C.id!==e);if(d===e)p(o.length>0?o[Math.max(0,u-1)].id:null);return o})},I=(e,i)=>{v((o)=>o.map((C)=>C.id===e?{...C,...i}:C))},ft=()=>{if(l.length===0)return;let e=(u-1+l.length)%l.length;p(l[e].id)},gt=()=>{if(l.length===0)return;let e=(u+1)%l.length;p(l[e].id)},xt=(e,i)=>{e.stopPropagation(),p(i),A(!0)},Qe=Q((e)=>{if(!_||!d||!k.current)return;let i=k.current.getBoundingClientRect(),o=(e.clientX-i.left)/i.width,C=(e.clientY-i.top)/i.height,h=Math.max(0,Math.min(1,Math.round(o*100)/100)),P=Math.max(0,Math.min(1,Math.round(C*100)/100));I(d,{x:h,y:P})},[_,d]),He=Q(()=>{A(!1)},[]);S(()=>{if(_)window.addEventListener("mousemove",Qe),window.addEventListener("mouseup",He);return()=>{window.removeEventListener("mousemove",Qe),window.removeEventListener("mouseup",He)}},[_,Qe,He]),S(()=>{let e=(i)=>{if(!t||!d)return;let o=i.target?.tagName?.toLowerCase();if(o==="input"||o==="textarea"||o==="select")return;if(i.key==="Delete"||i.key==="Backspace")i.preventDefault(),nt(d)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,d,u]);let vt=(e)=>{if(e.config?.blocks&&e.config.blocks.length>0){let i=e.config.blocks.map((o)=>({...o,id:at()}));v(i),p(i[0].id),E(e.id)}},ht=()=>{if(l.length===0){j.error(bT());return}pe({blocks:l})},wt=()=>{if(ne==="new"){if(!se.trim()){j.error(w_());return}ze({name:se.trim(),config:{blocks:l}})}else{let e=U||B;if(!e){j.error(ny());return}Me({templateId:e,config:{blocks:l}})}};return g(Y,{children:[a(Se,{open:t,onOpenChange:b,children:g(xe,{showCloseButton:!1,className:"sm:max-w-[1400px] max-w-[95vw] w-[95vw] h-[88vh] flex flex-col p-0 gap-0 overflow-hidden",onPointerDownOutside:(e)=>e.preventDefault(),children:[g("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border bg-card",children:[a("div",{className:"flex items-center gap-3",children:a(Ce,{className:"text-base font-semibold",children:jO()})}),g("div",{className:"flex items-center gap-2",children:[g(De,{modal:!1,children:[a(Ne,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"gap-2 text-xs",children:[a(it,{className:"h-4 w-4 text-muted-foreground"}),qO()]})}),g(Fe,{align:"end",className:"w-56",children:[a(En,{className:"text-xs font-semibold text-muted-foreground",children:RS()}),T.length===0?a("div",{className:"px-2 py-1.5 text-xs text-muted-foreground italic",children:yT()}):T.map((e)=>g(de,{onClick:()=>vt(e),className:"flex items-center justify-between text-xs cursor-pointer",children:[a("span",{className:"truncate flex-1",children:e.name}),B===e.id&&a(qe,{className:"h-3.5 w-3.5 text-primary ml-2 flex-shrink-0"}),a(F,{variant:"ghost",size:"icon",className:"h-5 w-5 hover:bg-destructive/10 hover:text-destructive ml-1",onClick:(i)=>{i.stopPropagation(),c(e.id)},children:a(Ue,{className:"h-3 w-3"})})]},e.id)),a(ur,{}),g(de,{onClick:()=>{te("new"),O(""),q(!0)},className:"text-xs gap-2 cursor-pointer",children:[a(Re,{className:"h-3.5 w-3.5 text-primary"}),a_()]}),T.length>0&&g(de,{onClick:()=>{te("overwrite"),V(B||T[0].id),q(!0)},className:"text-xs gap-2 cursor-pointer",children:[a(al,{className:"h-3.5 w-3.5 text-muted-foreground"}),_0()]})]})]}),a(F,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>b(!1),children:Ke()}),g(F,{size:"sm",className:"text-xs bg-primary hover:bg-primary/90 text-primary-foreground gap-1.5",disabled:Ae,onClick:ht,children:[a(al,{className:"h-3.5 w-3.5"}),Uk()]})]})]}),g("div",{className:"flex-1 flex overflow-hidden",children:[g("div",{className:"w-[65%] flex flex-col p-4 bg-muted/20 border-r border-border overflow-hidden select-none",children:[g("div",{className:"flex items-center justify-between mb-3",children:[a("div",{className:"flex items-center gap-1 bg-muted/60 p-1 rounded-md border border-border/60",children:["16:9","9:16","4:3","3:4","1:1"].map((e)=>g(F,{variant:N===e?"secondary":"ghost",size:"sm",className:Pe("h-7 px-2.5 text-xs gap-1.5 font-mono transition-all",N===e?"bg-background shadow-xs font-semibold text-foreground border border-border/50":"text-muted-foreground hover:text-foreground"),onClick:()=>oe(e),children:[a(Nt,{ratio:e}),a("span",{children:e})]},e))}),a("div",{className:"flex items-center gap-1.5 bg-background border border-border/60 rounded-md p-1",children:Ze.map((e)=>a("button",{type:"button",onClick:()=>ce(e.id),style:{backgroundColor:e.bg},className:Pe("w-5 h-5 rounded-full border border-border/80 transition-all cursor-pointer relative",le===e.id?"ring-2 ring-primary ring-offset-1 scale-110":"hover:scale-105 opacity-80 hover:opacity-100"),title:e.label},e.id))})]}),a("div",{ref:s,className:"flex-1 flex items-center justify-center overflow-hidden",children:(()=>{let e=Ze.find((o)=>o.id===le)||Ze[0],i=J.w>0&&J.h>0;return a("div",{ref:k,onClick:()=>p(null),style:{backgroundColor:e.bg,backgroundImage:`radial-gradient(${e.dot} 1px, transparent 1px)`,backgroundSize:"16px 16px",...i?{width:J.w,height:J.h}:{}},className:Pe("relative rounded-lg border border-border overflow-hidden shadow-inner transition-all",N==="16:9"&&"aspect-[16/9] w-full max-h-full",N==="9:16"&&"aspect-[9/16] h-full max-w-full",N==="4:3"&&"aspect-[4/3] w-full max-h-full",N==="3:4"&&"aspect-[3/4] h-full max-w-full",N==="1:1"&&"aspect-square h-full max-w-full"),children:l.map((o)=>{let C=o.id===d,h=o.size*(J.w||640);return a("div",{onMouseDown:(P)=>xt(P,o.id),onClick:(P)=>{P.stopPropagation(),p(o.id)},style:{left:`${o.x*100}%`,top:`${o.y*100}%`,transform:`translate(-50%, -50%) rotate(${o.rotation}deg)`,opacity:o.opacity},className:Pe("absolute cursor-move select-none transition-shadow rounded p-1.5 flex items-center justify-center",C?"ring-2 ring-primary ring-offset-2 ring-offset-background/80 bg-primary/10":"hover:ring-1 hover:ring-muted-foreground/50"),children:o.type==="text"?a("span",{style:{fontSize:`${h}px`,color:o.color,lineHeight:1,whiteSpace:"nowrap",fontWeight:700,textShadow:"0 1px 3px rgba(0,0,0,0.5)"},children:o.text||"Text"}):a("div",{style:{width:`${h}px`,height:`${h}px`},className:"bg-primary/20 border border-primary/40 rounded flex items-center justify-center p-1 overflow-hidden",children:L[o.id]||o.imageAssetUrl?a("img",{src:L[o.id]||o.imageAssetUrl,alt:"Watermark logo",className:"w-full h-full object-contain pointer-events-none"}):a(Do,{className:"h-1/2 w-1/2 opacity-70 text-primary"})})},o.id)})})})()})]}),g("div",{className:"w-[35%] flex flex-col bg-card overflow-hidden border-l border-border",children:[a("div",{className:"p-4 border-b border-border bg-muted/10 flex items-center justify-between",children:g("div",{className:"flex items-center gap-2",children:[a(No,{className:"h-4 w-4 text-muted-foreground"}),a("span",{className:"text-xs font-semibold",children:My()})]})}),g("div",{className:"p-3 border-b border-border bg-background flex items-center justify-between gap-2",children:[g("div",{className:"flex items-center gap-1",children:[a(F,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:l.length<=1,onClick:ft,children:a(Mn,{className:"h-4 w-4"})}),g(De,{modal:!1,children:[a(Ne,{asChild:!0,children:a(F,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs font-mono",children:l.length===0?"0 / 0":`${u+1} / ${l.length}`})}),a(Fe,{align:"start",className:"w-48",children:l.map((e,i)=>g(de,{onClick:()=>p(e.id),className:"text-xs flex items-center justify-between cursor-pointer",children:[g("span",{className:"flex items-center gap-2 truncate",children:[e.type==="text"?a(ec,{className:"h-3.5 w-3.5 text-muted-foreground"}):a(Do,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.type==="text"?e.text||"Text":e.imageAssetKey||"Image"]}),g("span",{className:"text-[10px] font-mono text-muted-foreground ml-2",children:["#",i+1]})]},e.id))})]}),a(F,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:l.length<=1,onClick:gt,children:a(jt,{className:"h-4 w-4"})})]}),g("div",{className:"flex items-center gap-1",children:[n&&a(F,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10",title:Mt(),onClick:()=>nt(n.id),children:a(Ue,{className:"h-4 w-4"})}),g(De,{modal:!1,children:[a(Ne,{asChild:!0,children:g(F,{size:"sm",className:"h-7 text-xs gap-1",children:[a(Re,{className:"h-3.5 w-3.5"}),Um()]})}),g(Fe,{align:"end",children:[g(de,{onClick:Be,className:"text-xs gap-2 cursor-pointer",children:[a(ec,{className:"h-3.5 w-3.5"}),jm()]}),g(de,{onClick:pt,className:"text-xs gap-2 cursor-pointer",children:[a(Do,{className:"h-3.5 w-3.5"}),vA()]})]})]})]})]}),a(Ie,{className:"flex-1 min-h-0 p-4",children:n?g("div",{className:"space-y-5 text-xs",children:[g("div",{className:"flex items-center justify-between pb-2 border-b border-border",children:[g("span",{className:"font-semibold text-muted-foreground flex items-center gap-1.5",children:[n.type==="text"?a(ec,{className:"h-4 w-4 text-primary"}):a(Do,{className:"h-4 w-4 text-primary"}),n.type==="text"?jm():vA()]}),g("span",{className:"text-[10px] font-mono text-muted-foreground",children:["ID: ",n.id.slice(0,6)]})]}),n.type==="text"&&g("div",{className:"space-y-2",children:[a(fe,{className:"text-xs",children:jM()}),a(re,{type:"text",value:n.text,onChange:(e)=>I(n.id,{text:e.target.value}),className:"text-xs h-8"})]}),n.type==="image"&&g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:cS()}),n.imageAssetKey&&g("button",{type:"button",onClick:()=>I(n.id,{imageAssetKey:"",imageAssetUrl:void 0}),className:"text-xs text-muted-foreground hover:text-destructive flex items-center gap-1 font-medium transition-colors cursor-pointer",children:[a(Ge,{className:"w-3.5 h-3.5"}),Wc?Wc():"Remove"]})]}),a("input",{type:"file",ref:ae,className:"hidden",accept:"image/*",onChange:(e)=>we(e,n.id)}),g("div",{onClick:()=>ae.current?.click(),className:"relative aspect-square w-full rounded-xl border border-dashed border-border flex items-center justify-center cursor-pointer overflow-hidden group shadow-inner bg-muted/20 hover:border-primary/50 hover:bg-muted/40 transition-all p-2",children:[Ee&&a("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-xs flex flex-col items-center justify-center gap-2 z-20",children:g("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-background border rounded-full shadow-lg",children:[a(K,{className:"w-4 h-4 animate-spin text-primary"}),a("span",{className:"text-xs font-semibold",children:kd()})]})}),L[n.id]||n.imageAssetUrl?g(Y,{children:[a("img",{src:L[n.id]||n.imageAssetUrl,alt:"Uploaded logo preview",className:"max-w-full max-h-full object-contain transition-transform duration-300 group-hover:scale-105"}),g("div",{className:"absolute inset-0 bg-black/45 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col items-center justify-center gap-1 text-white z-10",children:[a(zo,{className:"w-5 h-5 transform translate-y-1 group-hover:translate-y-0 transition-transform duration-300"}),a("span",{className:"text-xs font-semibold",children:gg()})]})]}):g("div",{className:"flex flex-col items-center gap-1.5 text-center p-3",children:[a("div",{className:"p-2 rounded-full bg-background border shadow-xs group-hover:scale-110 transition-transform duration-300",children:a(zo,{className:"w-4 h-4 text-muted-foreground"})}),g("div",{children:[a("p",{className:"text-xs font-medium text-foreground",children:RO()}),a("p",{className:"text-[10px] text-muted-foreground mt-0.5 max-w-[150px] mx-auto leading-normal",children:MO()})]})]})]})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:n.type==="text"?vC():dS()}),g("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(n.size*100),"%"]})]}),g("div",{className:"flex items-center gap-3",children:[a(_s,{min:n.type==="text"?0.01:0.02,max:n.type==="text"?0.12:0.5,step:0.005,value:[n.size],onValueChange:([e])=>I(n.id,{size:e}),className:"flex-1"}),a(re,{type:"number",min:1,max:100,value:Math.round(n.size*100),onChange:(e)=>I(n.id,{size:Math.min(1,Math.max(0.001,Number(e.target.value)/100))}),className:"w-16 h-7 text-xs font-mono text-right"})]})]}),n.type==="text"&&g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Pw()}),a("span",{className:"font-mono text-[11px] text-muted-foreground uppercase",children:n.color})]}),g("div",{className:"flex items-center gap-2",children:[a("input",{type:"color",value:n.color,onChange:(e)=>I(n.id,{color:e.target.value}),className:"w-8 h-8 rounded border border-border cursor-pointer bg-transparent p-0"}),a(re,{type:"text",value:n.color,onChange:(e)=>I(n.id,{color:e.target.value}),className:"flex-1 h-8 text-xs font-mono"})]}),a("div",{className:"flex items-center gap-1.5 pt-1",children:["#FFFFFF","#000000","#999999","#EF4444","#3B82F6","#10B981","#F59E0B"].map((e)=>a("button",{type:"button",onClick:()=>I(n.id,{color:e}),style:{backgroundColor:e},className:"w-5 h-5 rounded-full border border-border hover:scale-110 transition-transform"},e))})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:kT()}),g("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(n.opacity*100),"%"]})]}),a(_s,{min:0,max:1,step:0.01,value:[n.opacity],onValueChange:([e])=>I(n.id,{opacity:e})})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Nk()}),g("span",{className:"font-mono text-[11px] text-muted-foreground",children:[n.rotation,"°"]})]}),a(_s,{min:-180,max:180,step:1,value:[n.rotation],onValueChange:([e])=>I(n.id,{rotation:e})}),a("div",{className:"flex items-center gap-1.5 pt-1",children:[-45,-30,0,30,45].map((e)=>g(F,{variant:"outline",size:"sm",className:"h-6 text-[10px] flex-1 px-1 font-mono",onClick:()=>I(n.id,{rotation:e}),children:[e,"°"]},e))})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:p1()}),g("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(n.x*100),"%"]})]}),a(_s,{min:0,max:1,step:0.01,value:[n.x],onValueChange:([e])=>I(n.id,{x:e})})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:m1()}),g("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(n.y*100),"%"]})]}),a(_s,{min:0,max:1,step:0.01,value:[n.y],onValueChange:([e])=>I(n.id,{y:e})})]})]}):g("div",{className:"py-12 text-center text-xs text-muted-foreground space-y-3",children:[a("p",{children:Xk()}),g(F,{size:"sm",variant:"outline",onClick:Be,children:[a(Re,{className:"h-3.5 w-3.5 mr-1"}),jm()]})]})})]})]})]})}),a(Se,{open:ge,onOpenChange:q,children:g(xe,{className:"max-w-md",children:[a(ke,{children:a(Ce,{className:"text-sm font-semibold",children:ne==="new"?a_():_0()})}),a("div",{className:"py-3 space-y-4 text-xs",children:ne==="new"?g("div",{className:"space-y-2",children:[a(fe,{children:ZM()}),a(re,{type:"text",value:se,onChange:(e)=>O(e.target.value),placeholder:w_(),className:"text-xs"})]}):g("div",{className:"space-y-2",children:[a(fe,{children:ny()}),a("select",{value:U||"",onChange:(e)=>V(e.target.value),className:"w-full h-9 rounded-md border border-input bg-background px-3 text-xs",children:T.map((e)=>a("option",{value:e.id,children:e.name},e.id))})]})}),g(ot,{children:[a(F,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>q(!1),children:Ke()}),a(F,{size:"sm",className:"text-xs",disabled:Le||Oe,onClick:wt,children:Ya()})]})]})})]})}function Pe(...t){return t.filter(Boolean).join(" ")}Z();function ut({shareLink:t,viewMode:b,onViewModeChange:f,defaultSortOrder:m,onSortOrderChange:y}){let x=ie(),[D,l]=w(t.password||""),[v,d]=w(t.expireAt?new Date(t.expireAt):void 0),[p,B]=w(!1);S(()=>{l(t.password||"")},[t.password]);let[E,N]=w(t.hasPassword),[oe,le]=w(!!t.expireAt),{data:ce,refetch:ge}=X({queryKey:["share-watermark",t.id],queryFn:async()=>{let s=await R.api.shares[":shareId"].watermark.$get({param:{shareId:t.id}});if(!s.ok)return null;return await s.json()},refetchInterval:(s)=>(s.state.data?.watermarkStatus||t.watermarkStatus)==="processing"?3000:!1}),q=R.api.shares[":shareId"].watermark.$put,{mutate:ne}=ee({mutationFn:async()=>{let s=await q({param:{shareId:t.id},json:{enabled:!1}});if(!s.ok)throw Error(pa());return await s.json()},onSuccess:()=>{x.invalidateQueries({queryKey:["shares",t.projectId]}),x.invalidateQueries({queryKey:["share",t.id]}),x.invalidateQueries({queryKey:["share-watermark",t.id]}),j.success(zO())}}),te=ce?.watermarkStatus??t.watermarkStatus??(t.watermarkConfigId?"ready":"disabled"),se=ce?.watermarkConfig?.config??t.watermarkConfig?.config??null,O=se!==null&&te!=="disabled",{data:U}=X({queryKey:["fields",t.projectId],queryFn:async()=>{let s=await R.api.projects[":projectId"].fields.$get({param:{projectId:t.projectId}});if(!s.ok)throw Error(kx());return await s.json()},enabled:!!t.projectId}),V=R.api.shares[":shareId"].$put,{mutate:k}=ee({mutationFn:async(s)=>{let W=await V({param:{shareId:t.id},json:s});if(!W.ok)throw Error(pa());return await W.json()},onSuccess:()=>{x.invalidateQueries({queryKey:["shares",t.projectId]}),x.invalidateQueries({queryKey:["share",t.id]}),j.success(jl())}}),H=`${window.location.origin}/share/${t.id}`,J=async(s)=>{if(await jo(s))j.success(Kw())},ve=(s)=>{let W=t.fieldVisibility||{},me={...W,[s]:!W[s]};k({fieldVisibility:me})},_="index",A="asc";if(m){let s=m.split(":");_=s[0],A=s[1]||"asc"}return g("div",{className:"flex flex-col h-full bg-background border-l border-border",children:[a("div",{className:"flex-1 overflow-y-auto",children:g("div",{className:"p-4 space-y-6",children:[g("div",{className:"space-y-4",children:[g("div",{className:"flex items-center justify-between",children:[a("h3",{className:"text-sm font-medium",children:IS()}),a(Ve,{checked:!t.isDisabled,onCheckedChange:(s)=>k({isDisabled:!s})})]}),g("div",{className:"relative w-full",children:[a(re,{value:H,readOnly:!0,className:"pr-10 bg-muted/50 text-xs"}),a(F,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full",onClick:()=>J(H),children:a(Zr,{className:"h-4 w-4"})})]})]}),g("div",{className:"space-y-1",children:[a(je,{title:Wk(),icon:a(su,{className:"h-4 w-4"}),children:g("div",{className:"p-3 space-y-4 pt-2",children:[g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Nh()}),a(Ve,{checked:E,onCheckedChange:(s)=>{if(N(s),!s)k({password:null})}})]}),E&&g("div",{className:"flex gap-2 animate-in fade-in slide-in-from-top-1 duration-200",children:[a(re,{type:"text",value:D,onChange:(s)=>l(s.target.value),placeholder:_x(),className:"text-xs"}),a(F,{size:"sm",onClick:()=>k({password:D}),children:wo()})]})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Cx()}),a(Ve,{checked:oe,onCheckedChange:(s)=>{if(le(s),!s)d(void 0),k({expireAt:null})}})]}),oe&&a("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:a(Aa,{value:v,onChange:(s)=>{d(s),k({expireAt:s?s.toISOString():null})},className:"text-xs"})})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Cb()}),a(Ve,{checked:t.allowDownload,onCheckedChange:(s)=>k({allowDownload:s})})]}),a("p",{className:"text-xs text-muted-foreground",children:Sb()})]}),g("div",{className:"space-y-2 pt-2 border-t border-border/50",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:My()}),a(Ve,{checked:O,disabled:te==="processing",onCheckedChange:(s)=>{if(!s)ne();else B(!0)}})]}),O&&te==="processing"&&g("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 font-medium py-1 animate-pulse",children:[a(K,{className:"h-3.5 w-3.5 animate-spin"}),a("span",{children:$O()})]}),O&&te!=="processing"&&a(F,{variant:"outline",size:"sm",className:"w-full text-xs gap-1.5 mt-1",onClick:()=>B(!0),children:nx()})]})]})}),a(je,{title:$m(),icon:a(ou,{className:"h-4 w-4"}),children:g("div",{className:"p-3 space-y-3 pt-2 flex gap-2",children:[g(F,{variant:b==="card"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>f("card"),children:[a(No,{className:"h-4 w-4"}),VC()]}),g(F,{variant:b==="list"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>f("list"),children:[a(ps,{className:"h-4 w-4"}),kS()]})]})}),a(je,{title:Ll(),icon:a(lt,{className:"h-4 w-4"}),children:a("div",{className:"p-3 space-y-3 pt-2",children:U?.map((s)=>g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:s.config?.name}),a(Ve,{checked:t.fieldVisibility?.[s.id]??!1,onCheckedChange:()=>ve(s.id)})]},s.id))})}),a(je,{title:Jc(),icon:a(fu,{className:"h-4 w-4"}),children:g("div",{className:"p-3 space-y-4 pt-2",children:[g("div",{className:"space-y-2",children:[a(fe,{className:"text-xs text-muted-foreground",children:lh()}),g(Xe,{value:_,onValueChange:(s)=>{if(s==="index")y(null);else y(`${s}:${A}`)},children:[a(tt,{className:"w-full text-xs h-9",children:a(et,{})}),g(rt,{children:[a(be,{value:"index",children:ng()}),a(be,{value:"name",children:Yc()}),a(be,{value:"createdAt",children:og()}),a(be,{value:"size",children:ig()})]})]})]}),g("div",{className:"space-y-2",children:[a(fe,{className:"text-xs text-muted-foreground",children:Dh()}),g(F,{variant:"outline",className:"w-full justify-between font-normal text-xs h-9",disabled:_==="index",onClick:()=>{y(`${_}:${A==="asc"?"desc":"asc"}`)},children:[a("span",{children:_==="name"?A==="asc"?Cd():Td():_==="createdAt"?A==="asc"?Id():Sd():_==="size"?A==="asc"?ag():sg():A==="asc"?Hm():th()}),a(Zd,{className:"h-4 w-4 opacity-50"})]})]})]})})]})]})}),g("div",{className:"p-4 border-t border-border space-y-2",children:[g(F,{variant:"outline",className:"w-full justify-center",onClick:()=>window.open(H,"_blank"),children:[a(uu,{className:"h-4 w-4 mr-2"}),MT()]}),g(F,{className:"w-full justify-center bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>J(H),children:[a(Zr,{className:"h-4 w-4 mr-2"}),Jw()]})]}),a(mt,{open:p,onOpenChange:B,initialConfig:se,shareId:t.id,onSaveSuccess:()=>{ge(),x.invalidateQueries({queryKey:["share",t.id]}),x.invalidateQueries({queryKey:["shares",t.projectId]})}})]})}function je({title:t,icon:b,children:f}){let[m,y]=w(!1);return g("div",{className:"border-b border-border last:border-0",children:[g("button",{onClick:()=>y(!m),className:"w-full flex items-center justify-between py-3 px-2 hover:bg-muted/50 transition-colors",children:[g("div",{className:"flex items-center gap-3",children:[b,a("span",{className:"text-sm font-medium",children:t})]}),a(jt,{className:_t("h-4 w-4 transition-transform",m&&"rotate-90")})]}),m&&f&&a("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:f})]})}function _t(...t){return t.filter(Boolean).join(" ")}function st({teamId:t,projectId:b,projectName:f,shareId:m,rootFolderId:y}){let x=ie(),{fetchMetadata:D}=Fr();S(()=>{if(t)D(t)},[t,D]);let{data:l}=X({queryKey:["share",m],queryFn:async()=>{let r=await R.api.shares[":shareId"].$get({param:{shareId:m}});if(!r.ok)throw Error(Ox());return await r.json()}}),v=l?.rootFolderId,[d,p]=w(null),[B,E]=w([]);S(()=>{if(v)p(v),E([]),T(new Set)},[v,m]);let N=Zn((r)=>r.setProjectState),oe=Zn((r)=>r.clearProjectState),le=(r)=>{if(r===d)return;if(r===v)p(v),E([]);else{let c=B.findIndex((u)=>u.id===r);if(c!==-1)p(r),E(B.slice(c+1))}T(new Set)},[ce,ge]=w(240),[q,ne]=w(360),{shareConfigLeftSidebarCollapsed:te,shareConfigRightSidebarCollapsed:se}=ar(),O=l?.defaultSortOrder||null,U,V;if(O){let r=O.split(":");U=r[0],V=r[1]}let k=l?.viewMode??"card",{data:H,fetchNextPage:J,hasNextPage:ve,isFetchingNextPage:_,isLoading:A}=Tt({queryKey:["folder-children",t,d,"folder",U,V],queryFn:async({pageParam:r})=>{let c=await R.api.folders[":folderId"].children.$get({param:{folderId:d},query:{assetType:"folder",after:r,sort:U,order:V}});if(!c.ok)throw Error(Mx());return await c.json()},enabled:!!d,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),{data:s,fetchNextPage:W,hasNextPage:me,isFetchingNextPage:Ee,isLoading:ye}=Tt({queryKey:["folder-children",t,d,"file",U,V],queryFn:async({pageParam:r})=>{let c=await R.api.folders[":folderId"].children.$get({param:{folderId:d},query:{assetType:"file",after:r,sort:U,order:V}});if(!c.ok)throw Error(Rx());return await c.json()},enabled:!!d,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),L=G(()=>H?.pages.flatMap((r)=>r.data??[])??[],[H]),he=G(()=>s?.pages.flatMap((r)=>r.data??[])??[],[s]);S(()=>{if(l)N({teamId:t,projectId:b,projectName:f,ancestorFolders:B,currentAsset:{name:d===v?l.name:L.find((r)=>r.id===d)?.name||l.name,type:"folder"},isRootFolder:!1,shareId:m,onFolderClick:le});return()=>oe()},[t,b,f,B,d,v,l,m,L,N,oe]);let[ae,ue]=w(null),[we,T]=w(new Set),_e=()=>{T(new Set),ue(null)},{dragState:pe,handleDragStart:Ae,handleDragEnd:We}=lu({teamId:t,projectId:b,assetId:d||"",folders:L,files:he,selectedIds:we,onClearSelection:_e}),ze=R.api.shares[":shareId"].assets[":assetId"].$delete,{mutate:Le}=ee({mutationFn:async(r)=>{if(!(await ze({param:{shareId:m,assetId:r}})).ok)throw Error(Px())},onSuccess:()=>{x.invalidateQueries({queryKey:["folder-children",t,d]}),j.success(xk())}}),$e=R.api.shares[":shareId"].$put,{mutate:Me}=ee({mutationFn:async(r)=>{let c=await $e({param:{shareId:m},json:r});if(!c.ok)throw Error(pa());return await c.json()},onSuccess:()=>{x.invalidateQueries({queryKey:["share",m]}),j.success(jl())}}),Oe=(r)=>{if(r.type==="folder"||r.targetType==="folder"){let c=d===v?l?.name||"":L.find((u)=>u.id===d)?.name||Jn();E((u)=>[{id:d,name:c},...u]),p(r.id),T(new Set)}};if(!l)return a("div",{children:vp()});return g(Eo,{modifiers:[il.configure({anchor:{x:0,y:0}})],sensors:[Yn.configure({activationConstraints:[new an.Distance({value:10})]})],onDragStart:Ae,onDragEnd:We,children:[a("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:g("div",{className:"flex flex-1 overflow-hidden relative",children:[!te&&g(Y,{children:[a("div",{className:"bg-background",style:{width:ce},children:a(qr,{teamId:t,projectId:b,projectName:f,rootFolderId:y,dragState:pe})}),a(Jr,{onResize:(r)=>ge((c)=>Math.max(180,Math.min(400,c+r)))})]}),a(wa,{teamId:t,projectId:b,assetId:d||"",folders:L,files:he,selectedItem:ae,selectedIds:we,onItemSelect:(r,c)=>{if(c.metaKey||c.ctrlKey){let u=new Set(we);if(u.has(r.id)){if(u.delete(r.id),T(u),ae?.id===r.id){let n=[...L,...he].find((Be)=>u.has(Be.id));ue(n||null)}}else u.add(r.id),T(u),ue(r)}else T(new Set([r.id])),ue(r)},onItemDoubleClick:Oe,onSaveField:()=>{},displayStyle:k,onClearSelection:_e,fetchNextFoldersPage:J,hasNextFoldersPage:ve,isFetchingNextFoldersPage:_,fetchNextFilesPage:W,hasNextFilesPage:me,isFetchingNextFilesPage:Ee,isLoading:A||ye,filterConditions:[],onFilterChange:()=>{},dragState:pe,isShareView:!0,onRemoveFromShare:(r)=>{r.forEach((c)=>Le(c.id))},fieldVisibility:l.fieldVisibility}),!se&&g(Y,{children:[a(Jr,{onResize:(r)=>ne((c)=>Math.max(240,Math.min(600,c-r)))}),a("div",{style:{width:q},className:"flex-shrink-0 h-full",children:a(ut,{shareLink:l,viewMode:k,onViewModeChange:(r)=>Me({viewMode:r}),defaultSortOrder:O,onSortOrderChange:(r)=>Me({defaultSortOrder:r})})})]})]})}),a(Md,{children:pe?.isActive?a("div",{className:"flex items-center gap-2 rounded-md bg-popover px-3 py-2 text-sm font-medium shadow-md",children:OI({count:pe.itemCount})}):null})]})}Z();function It(){let{projectId:t,shareId:b}=Ct.useParams(),{teamId:f,ensureTeamIdForProject:m}=Pt();S(()=>{m(t)},[t,m]);let{data:y}=gr(Rg(t)),x=y?.rootFolder,{data:D}=X({queryKey:["folders",x],queryFn:async()=>{let l=await R.api.folders[":folderId"].$get({param:{folderId:x}});if(!l.ok)throw Error("Failed to fetch folder");return await l.json()},enabled:!!x});if(!f||!x||!D)return a(qt,{});return a(st,{teamId:f,projectId:t,projectName:y.name??"",shareId:b,rootFolderId:x})}var Ct=Je("/projects/$projectId/shares/$shareId")({component:It});export{Ct as Route};
@@ -1 +0,0 @@
1
- import{J,Q,S,G,M,w,Mo,Z,Y,a,g,ie,Lf,Zf,jr,cd,Ga,Yo,ir,ks,Bf,Uf,zf,jf,ud,qf,X,ee,Tt,Je,R,z,wr,K,tn,$t,qe,Be,cr,On,rr,Rs,Ge,B,Ut,Le,pe,Gt,Vr,er,we,Cr,F,$e,He,Qe,$y,Hy,Bm,Ab,vb,bb,zb,Qm,Kb,XA,Ke,xw,Tw,kw,Ya,s_,cE,cp,_d,c_,Mi,Ms,S_,zx,I_,dh,mC,hC,gC,AC,rS,z_,yS,bI,wI,Eh,eT,kh,Rh,mT,wT,IT,VT,g0,xd,s1,S0,Ip,L0,z1,q1,Bh,H1,V1,B0,W1,J1,U0,Y1,ek,Pp,Dp,Np,Kc,Hh,lk,ck,uk,dk,Fp,yk,Pi,Pk,Vk,Jk,uR,eg,fR,ER,xR,SR,IR,TR,kR,ay,RR,ly,py,oM,sM,iM,TM,gy,_y,kM,by,zp,OM,FM,JM,nO,Sy,Jn,pg,SO,OO,PO,Rd,BO,Ag,eP,_t,yt,vt,bt,wt,Et,xt,Ct,Se,xe,ke,Ce,Ot,re,Ie,Vt,j,$l,Hl,tu,nn,vg,co,uo,Wr,gn,ve,pt,mt,ht,Sr,on,rm,lt,Nt,Ft,Ht,St}from"./chunk-zarz3sqn.js";import{os,Lr}from"./chunk-q2bew2vc.js";import{_u}from"./chunk-zezje74z.js";import{Li,eo,gs,iu,Vl,ya,au}from"./chunk-q8w4mbw4.js";import"./chunk-hpbn0k9n.js";import{Bn,Un,zn,Tr,ft,ct}from"./chunk-576nj64j.js";import"./chunk-8yjsmr7g.js";import{Uo}from"./chunk-atfz7g7e.js";import{yu}from"./chunk-91rb0jpb.js";import{jn}from"./chunk-fvx9k1dc.js";import{Zr}from"./chunk-v5cn90cf.js";Z();function de(e,t){let s=new Set(t);return e.filter((i)=>!s.has(i))}var me=class extends Yo{#r;#e;#o;#a;#t;#s;#i;#n;#l;#d=[];constructor(e,t,s){super();this.#r=e,this.#a=s,this.#o=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){if(this.listeners.size===1)this.#t.forEach((e)=>{e.subscribe((t)=>{this.#p(e,t)})})}onUnsubscribe(){if(!this.listeners.size)this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach((e)=>{e.destroy()})}setQueries(e,t){this.#o=e,this.#a=t,ir.batch(()=>{let s=this.#t,i=this.#u(this.#o);i.forEach((p)=>p.observer.setOptions(p.defaultedQueryOptions));let n=i.map((p)=>p.observer),r=n.map((p)=>p.getCurrentResult()),c=s.length!==n.length,u=n.some((p,b)=>p!==s[b]),f=c||u,v=f?!0:r.some((p,b)=>{let h=this.#e[b];return!h||!Ga(p,h)});if(!f&&!v)return;if(f)this.#d=i,this.#t=n;if(this.#e=r,!this.hasListeners())return;if(f)de(s,n).forEach((p)=>{p.destroy()}),de(n,s).forEach((p)=>{p.subscribe((b)=>{this.#p(p,b)})});this.#f()})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map((e)=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){let s=this.#u(e),i=s.map((r)=>r.observer.getOptimisticResult(r.defaultedQueryOptions)),n=s.map((r)=>r.defaultedQueryOptions.queryHash);return[i,(r)=>this.#c(r??i,t,n),()=>this.#m(i,s)]}#m(e,t){let s=new Set;return t.map((i,n)=>{let r=e[n];return!i.defaultedQueryOptions.notifyOnChangeProps?i.observer.trackResult(r,(c)=>{if(!s.has(c))s.add(c),t.forEach((u)=>{u.observer.trackProp(c)})}):r})}#c(e,t,s){if(t){let i=this.#l,n=s!==void 0&&i!==void 0&&(i.length!==s.length||s.some((r,c)=>r!==i[c]));if(this.#e!==this.#n||n||t!==this.#i){if(this.#i=t,this.#n=this.#e,s!==void 0)this.#l=s;this.#s=cd(this.#s,t(e))}return this.#s}return e}#g(){return!this.#a?.combine||this.#t.some((e,t)=>e.options.suspense&&this.#e[t]?.data===void 0)}#u(e){let t=new Map;this.#t.forEach((i)=>{let n=i.options.queryHash;if(!n)return;let r=t.get(n);if(r)r.push(i);else t.set(n,[i])});let s=[];return e.forEach((i)=>{let n=this.#r.defaultQueryOptions(i),r=t.get(n.queryHash)?.shift()??new ks(this.#r,n);s.push({defaultedQueryOptions:n,observer:r})}),s}#p(e,t){let s=this.#t.indexOf(e);if(s!==-1)this.#e=this.#e.slice(),this.#e[s]=t,this.#f()}#f(){if(this.hasListeners()){let e=this.#g(),t=this.#s,s=e?t:this.#c(this.#m(this.#e,this.#d),this.#a?.combine);if(e||t!==s)ir.batch(()=>{this.listeners.forEach((i)=>{i(this.#e)})})}}};Z();function ce({queries:e,...t},s){let i=ie(s),n=Lf(),r=Zf(),c=t.subscribed!==!1,u=G(()=>e.map((m)=>{let x=i.defaultQueryOptions(m);return x._optimisticResults=n?"isRestoring":c?"optimistic":void 0,x}),[e,i,n,c]);u.forEach((m)=>{jf(m);let x=i.getQueryCache().get(m.queryHash);Bf(m,r,x)}),Uf(r);let[f]=w(()=>new me(i,u,t)),[v,p,b]=f.getOptimisticResult(u,t.combine),h=!n&&c;Mo(Q((m)=>h?f.subscribe(ir.batchCalls(m)):jr,[f,h]),()=>f.getCurrentResult(),()=>f.getCurrentResult()),S(()=>{f.setQueries(u,t)},[u,t,f]);let l=v.some((m,x)=>ud(u[x],m))?v.flatMap((m,x)=>{let T=u[x];if(T&&ud(T,m)){let k=new ks(i,T);return qf(T,k,r)}return[]}):[];if(l.length>0)throw Promise.all(l);let C=v.find((m,x)=>{let T=u[x];return T&&zf({result:m,errorResetBoundary:r,throwOnError:T.throwOnError,query:i.getQueryCache().get(T.queryHash),suspense:T.suspense})});if(C)throw C.error;return p(b())}Z();Z();var je=Object.defineProperty,O=(e,t)=>je(e,"name",{value:t,configurable:!0}),se="Collapsible",[Fe,da]=Ut(se),[We,oe]=Fe(se),ze=J(O(function(t,s){let{__scopeCollapsible:i,open:n,defaultOpen:r,disabled:c,onOpenChange:u,...f}=t,[v,p]=er({prop:n,defaultProp:r??!1,onChange:u,caller:se});return a(We,{scope:i,disabled:c,contentId:Vr(),open:v,onOpenToggle:Q(()=>p((b)=>!b),[p]),children:a(we.div,{"data-state":te(v),"data-disabled":c?"":void 0,...f,ref:s})})},"Collapsible")),Ue="CollapsibleTrigger",Ve=J(O(function(t,s){let{__scopeCollapsible:i,...n}=t,r=oe(Ue,i);return a(we.button,{type:"button","aria-controls":r.open?r.contentId:void 0,"aria-expanded":r.open||!1,"data-state":te(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...n,ref:s,onClick:pe(t.onClick,r.onOpenToggle)})},"CollapsibleTrigger")),ue="CollapsibleContent",Xe=J(O(function(t,s){let{forceMount:i,...n}=t,r=oe(ue,t.__scopeCollapsible);return a(Cr,{present:i||r.open,children:({present:c})=>a(Ye,{...n,ref:s,present:c})})},"CollapsibleContent")),Ye=J(O(function(t,s){let{__scopeCollapsible:i,present:n,children:r,...c}=t,u=oe(ue,i),[f,v]=w(n),p=M(null),b=Le(s,p),h=M(0),l=h.current,C=M(0),m=C.current,x=u.open||f,T=M(x),k=M(void 0);return S(()=>{let _=requestAnimationFrame(()=>T.current=!1);return()=>cancelAnimationFrame(_)},[]),Gt(()=>{let _=p.current;if(_){k.current=k.current||{transitionDuration:_.style.transitionDuration,animationName:_.style.animationName},_.style.transitionDuration="0s",_.style.animationName="none";let q=_.getBoundingClientRect();if(h.current=q.height,C.current=q.width,!T.current)_.style.transitionDuration=k.current.transitionDuration,_.style.animationName=k.current.animationName;v(n)}},[u.open,n]),a(we.div,{"data-state":te(u.open),"data-disabled":u.disabled?"":void 0,id:u.contentId,hidden:!x,...c,ref:b,style:{["--radix-collapsible-content-height"]:l?`${l}px`:void 0,["--radix-collapsible-content-width"]:m?`${m}px`:void 0,...t.style},children:x&&r})},"CollapsibleContentImpl"));function te(e){return e?"open":"closed"}O(te,"getState");var Ze=ze;var tt=[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V3",key:"1lcnhd"}],["path",{d:"M19 21V9",key:"unv183"}]],fe=z("chart-no-axes-column",tt);var at=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],P=z("funnel",at);var st=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],ge=z("eye",st);var rt=[["path",{d:"M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z",key:"1n2ejm"}],["path",{d:"M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1",key:"1qfcsi"}]],W=z("messages-square",rt);var ot=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],be=z("rotate-cw",ot);var it=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],ae=z("workflow",it);function he({teamId:e}){let[t,s]=w("team"),[i,n]=w("1h"),{data:r,isLoading:c}=X({queryKey:["teams",e,"ai-usage",i,"team"],queryFn:async()=>{let m=await R.api.teams[":teamId"]["ai-usage"].$get({param:{teamId:e},query:{timeframe:i}});if(!m.ok)throw Error("Failed to fetch team AI usage");return await m.json()},enabled:!!e&&t==="team"}),{data:u,isLoading:f}=X({queryKey:["teams",e,"members"],queryFn:async()=>{let m=await R.api.teams[":teamId"].members.$get({param:{teamId:e},query:{}});if(!m.ok)throw Error("Failed to fetch team members");return await m.json()},enabled:!!e&&t==="members"}),v=ce({queries:(u||[]).map((m)=>({queryKey:["teams",e,"ai-usage",i,m.id],queryFn:async()=>{let x=await R.api.teams[":teamId"]["ai-usage"].$get({param:{teamId:e},query:{timeframe:i,userId:m.id}});if(!x.ok)throw Error(`Failed to fetch AI usage for member ${m.id}`);return await x.json()},enabled:!!e&&t==="members"}))}),p=f||v.some((m)=>m.isLoading),b=(m)=>{if(!m)return"U";let x=m.split(" ");if(x.length>1)return`${x[0][0]}${x[x.length-1][0]}`.toUpperCase();return m.substring(0,2).toUpperCase()},h=(m)=>{if(!m)return"";switch(m.toLowerCase()){case"owner":return xd();case"editor":return Mi();case"reviewer":return Pi();default:return m}},l=(m)=>(m??0).toLocaleString(),C=(m)=>`$${(m??0).toFixed(6)}`;return g(lt,{className:"border-border/60 shadow-sm",children:[g(Nt,{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between pb-6",children:[g("div",{children:[a(Ft,{className:"text-xl font-semibold tracking-tight",children:vb()}),a(Ht,{className:"text-sm text-muted-foreground mt-1",children:bb()})]}),g("div",{className:"flex flex-wrap items-center gap-3",children:[g(os,{type:"single",value:t,onValueChange:(m)=>{if(m)s(m)},className:"border rounded-lg p-1 bg-muted/30",children:[a(Lr,{value:"team",className:"px-3 py-1.5 text-xs font-medium",children:FM()}),a(Lr,{value:"members",className:"px-3 py-1.5 text-xs font-medium",children:wI()})]}),g(os,{type:"single",value:i,onValueChange:(m)=>{if(m)n(m)},className:"border rounded-lg p-1 bg-muted/30",children:[a(Lr,{value:"1h",className:"px-2.5 py-1.5 text-xs font-medium",children:"1h"}),a(Lr,{value:"24h",className:"px-2.5 py-1.5 text-xs font-medium",children:"24h"}),a(Lr,{value:"7d",className:"px-2.5 py-1.5 text-xs font-medium",children:"7d"}),a(Lr,{value:"30d",className:"px-2.5 py-1.5 text-xs font-medium",children:"30d"})]})]})]}),a(St,{children:t==="team"?c?a("div",{className:"flex h-48 items-center justify-center",children:a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):a("div",{className:"rounded-md border",children:g(Bn,{children:[a(Un,{children:g(Tr,{children:[a(ft,{children:zp()}),a(ft,{className:"text-right",children:z_()}),a(ft,{className:"text-right",children:g0()}),a(ft,{className:"text-right",children:XA()}),a(ft,{className:"text-right",children:Sy()}),a(ft,{className:"text-right",children:s_()})]})}),a(zn,{children:g(Tr,{children:[a(ct,{className:"font-medium",children:zp()}),a(ct,{className:"text-right",children:l(r?.team?.inputTokens)}),a(ct,{className:"text-right",children:l(r?.team?.outputTokens)}),a(ct,{className:"text-right",children:l(r?.team?.cacheReadTokens)}),a(ct,{className:"text-right font-medium",children:l(r?.team?.totalTokens)}),a(ct,{className:"text-right font-medium",children:C(r?.team?.cost)})]})})]})}):p?a("div",{className:"flex h-48 items-center justify-center",children:a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):a("div",{className:"rounded-md border",children:g(Bn,{children:[a(Un,{children:g(Tr,{children:[a(ft,{children:bI()}),a(ft,{children:Pk()}),a(ft,{className:"text-right",children:z_()}),a(ft,{className:"text-right",children:g0()}),a(ft,{className:"text-right",children:XA()}),a(ft,{className:"text-right",children:Sy()}),a(ft,{className:"text-right",children:s_()})]})}),a(zn,{children:(u||[]).map((m,x)=>{let T=v[x]?.data?.member;return g(Tr,{children:[a(ct,{children:g("div",{className:"flex items-center gap-3",children:[g($e,{className:"h-8 w-8 rounded-full",children:[m.image&&a(He,{src:m.image,alt:m.name,className:"object-cover"}),a(Qe,{className:"bg-primary/20 text-xs",children:b(m.name)})]}),g("div",{className:"flex flex-col",children:[a("span",{className:"text-sm font-medium leading-none",children:m.name}),a("span",{className:"text-xs text-muted-foreground mt-0.5",children:m.email})]})]})}),a(ct,{className:"text-xs text-muted-foreground",children:h(m.role)}),a(ct,{className:"text-right",children:l(T?.inputTokens)}),a(ct,{className:"text-right",children:l(T?.outputTokens)}),a(ct,{className:"text-right",children:l(T?.cacheReadTokens)}),a(ct,{className:"text-right font-medium",children:l(T?.totalTokens)}),a(ct,{className:"text-right font-medium",children:C(T?.cost)})]},m.id)})})]})})})]})}Z();function Ne({teamId:e}){let[t,s]=w(null),{ref:i,inView:n}=Vt(),{data:r,isLoading:c,isError:u,fetchNextPage:f,hasNextPage:v,isFetchingNextPage:p}=Tt({queryKey:["teams",e,"agent-sessions"],queryFn:async({pageParam:l})=>{let C=await R.api.teams[":teamId"]["agent-sessions"].$get({param:{teamId:e},query:{first:"20",after:l?String(l):void 0}});if(!C.ok)throw Error("Failed to fetch agent sessions");return await C.json()},initialPageParam:"",getNextPageParam:(l)=>l.pageInfo.cursor||void 0,enabled:!!e});S(()=>{if(n&&v&&!p)f()},[n,v,p,f]);let b=r?.pages.flatMap((l)=>l.data).filter((l)=>l.id!=="pending")||[],h=(l)=>{switch(l){case"comment":return a(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20",children:TR()});case"chat":return a(ve,{variant:"outline",className:"bg-violet-500/10 text-violet-600 dark:text-violet-400 border-violet-500/20",children:IR()});case"naming":return a(ve,{variant:"outline",className:"bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20",children:kR()});default:return a(ve,{variant:"outline",className:"bg-muted text-muted-foreground border-border",children:l})}};return g("div",{className:"space-y-6",children:[g(lt,{className:"border border-border/50 shadow-xs",children:[a(Nt,{className:"pb-4",children:a("div",{className:"flex items-center justify-between",children:g("div",{children:[g(Ft,{className:"text-xl font-bold flex items-center gap-2",children:[a(W,{className:"w-5 h-5 text-violet-500"}),ay()]}),a(Ht,{className:"mt-1 text-sm text-muted-foreground",children:RR()})]})})}),a(St,{children:c?a("div",{className:"flex h-64 items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):u?a("div",{className:"flex h-64 items-center justify-center text-destructive",children:"Failed to load agent sessions."}):b.length===0?g("div",{className:"flex flex-col items-center justify-center py-12 text-center text-muted-foreground",children:[a(W,{className:"w-10 h-10 text-muted-foreground/40 mb-3"}),a("p",{className:"text-base font-medium",children:mT()})]}):g("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[g(Bn,{children:[a(Un,{className:"bg-muted/40",children:g(Tr,{children:[a(ft,{children:xR()}),a(ft,{children:_d()}),a(ft,{children:SR()}),a(ft,{className:"text-right",children:cE()})]})}),a(zn,{children:b.map((l)=>g(Tr,{onClick:()=>s(l.id),className:"cursor-pointer hover:bg-muted/50 transition-colors",children:[a(ct,{className:"font-medium",children:g("div",{className:"flex flex-col",children:[a("span",{className:"text-sm font-semibold text-foreground",children:l.name||pg()}),a("span",{className:"text-xs font-mono text-muted-foreground/70",children:l.id})]})}),a(ct,{children:g("div",{className:"flex items-center gap-2",children:[g($e,{className:"h-6 w-6",children:[a(He,{src:l.creator?.image||void 0}),a(Qe,{className:"text-[10px]",children:l.creator?.name?.[0]?.toUpperCase()||"?"})]}),a("span",{className:"text-sm text-foreground/90",children:l.creator?.name||"System / Agent"})]})}),a(ct,{children:h(l.type)}),a(ct,{className:"text-right text-xs text-muted-foreground",children:nn(l.createdAt)})]},l.id))})]}),a("div",{ref:i,className:"py-4 flex justify-center",children:p&&a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})})]}),a(_u,{sessionId:t,open:!!t,onOpenChange:(l)=>{if(!l)s(null)}})]})}Z();function ye({...e}){return a(Ze,{"data-slot":"collapsible",...e})}function Te({...e}){return a(Ve,{"data-slot":"collapsible-trigger",...e})}function _e({...e}){return a(Xe,{"data-slot":"collapsible-content",...e})}function ne(e){switch(e.toLowerCase()){case"owner":return xd();case"editor":return Mi();case"reviewer":return Pi();default:return e}}function nt(e,t){if(typeof e==="object"&&e!==null&&"message"in e){let s=e.message;if(typeof s==="string")return s}return t}function dt({rule:e}){let t=e.resourceData??{};if(e.resource==="agent_mcp_call_count")return a("span",{children:ck({value:String(t.id??"")})});if(e.resource==="agent_bash_call_count")return a("span",{children:lk({value:String(t.match??"*")})});if(e.resource==="agent_tool_call_count")return a("span",{children:uk({value:String(t.name??t.toolName??"*")})});return null}function ut({rule:e}){if(e.scopeMode==="all_members")return g(ve,{variant:"secondary",className:"gap-1 text-xs",children:[a(Uo,{className:"h-3 w-3"}),g("span",{children:[Pp(),e.role?` (${ne(e.role)})`:` (${Kc()})`]})]});if(e.scopeMode==="each_member")return g(ve,{variant:"secondary",className:"gap-1 text-xs",children:[a(jn,{className:"h-3 w-3"}),g("span",{children:[Dp(),e.role?` (${ne(e.role)})`:` (${Kc()})`]})]});return g(ve,{variant:"secondary",className:"gap-1 text-xs",children:[a(Rs,{className:"h-3 w-3"}),g("span",{children:[Np()," (",e.userIds?.length||0,")"]})]})}function gt({teamId:e,rule:t,record:s}){let i=ie(),[n,r]=w(!1),[c,u]=w(()=>new Date),f=Vl[t.resource],v=t.scopeMode==="all_members",p=s.percent>=100,b=v?t.role?`${ek()}: ${ne(t.role)}`:dk():s.user?.name||s.userId||Jn();S(()=>{if(!s.isWindowActive||!s.periodEnd)return;let l=window.setInterval(()=>u(new Date),60000);return()=>window.clearInterval(l)},[s.isWindowActive,s.periodEnd]);let h=ee({mutationFn:async()=>{let l=await R.api.teams[":teamId"].quotas[":id"].records.reset.$post({param:{teamId:e,id:t.id},json:{userId:s.userId??null}});if(!l.ok){let C=await l.json().catch(()=>null);throw Error(nt(C,I_()))}return await l.json()},onSuccess:()=>{i.invalidateQueries({queryKey:["teams",e,"quotas",t.id,"records"]}),i.invalidateQueries({queryKey:["teams",e,"quotas"]}),r(!1),j.success(J1())},onError:(l)=>{let C=l instanceof Error?l.message:I_();r(!1),j.error(C)}});return g(Y,{children:[g("div",{className:"space-y-3 rounded-xl border border-border/70 bg-card p-4 text-card-foreground shadow-2xs",children:[g("div",{className:"flex items-center justify-between gap-3",children:[g("div",{className:"flex min-w-0 items-center gap-3",children:[v?a("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:a(Uo,{className:"h-5 w-5"})}):g($e,{className:"h-9 w-9 shrink-0 border border-border/50",children:[a(He,{src:s.user?.image||void 0}),a(Qe,{className:"text-xs font-semibold",children:s.user?.name?.[0]?.toUpperCase()||"U"})]}),g("div",{className:"min-w-0",children:[a("div",{className:"truncate text-sm font-semibold text-foreground",children:b}),!v&&s.user?.email&&a("div",{className:"truncate text-xs text-muted-foreground",children:s.user.email})]})]}),g("div",{className:"flex shrink-0 items-center gap-2",children:[s.isWindowActive&&s.periodEnd?g(ve,{variant:"outline",className:"hidden gap-1 border-primary/30 bg-primary/5 text-xs text-primary sm:flex",children:[a(cr,{className:"h-3 w-3"}),a("span",{children:B0({time:vg(s.periodEnd,c)})})]}):g(ve,{variant:"secondary",className:"hidden gap-1 text-xs text-muted-foreground sm:flex",children:[a(wr,{className:"h-3 w-3 text-primary"}),a("span",{children:L0()})]}),g(F,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>r(!0),disabled:h.isPending,children:[h.isPending?a(K,{className:"h-3.5 w-3.5 animate-spin"}):a(Li,{className:"h-3.5 w-3.5"}),U0()]})]})]}),g("div",{className:"space-y-1.5 pt-1",children:[a(rm,{value:Math.min(100,Math.max(0,s.percent)),className:"h-2"}),g("div",{className:"flex items-center justify-between gap-2 text-xs font-medium",children:[g("span",{className:p?"font-bold text-destructive":"text-foreground",children:[ya(t.resource,s.consumed)," /"," ",ya(t.resource,t.limit)," ",f?.unit]}),g("span",{className:p?"font-bold text-destructive":"text-muted-foreground",children:[s.percent,"%"]})]})]}),g("div",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground sm:hidden",children:[s.isWindowActive&&s.periodEnd?g("span",{className:"flex items-center gap-1 text-primary",children:[a(cr,{className:"h-3 w-3"}),B0({time:vg(s.periodEnd,c)})]}):g("span",{className:"flex items-center gap-1",children:[a(wr,{className:"h-3 w-3 text-primary"}),L0()]}),g("span",{children:[W1(),": ",ya(t.resource,s.remaining)," ",f?.unit]})]})]}),a(_t,{open:n,onOpenChange:r,children:g(yt,{children:[g(vt,{children:[a(wt,{children:U0()}),a(Et,{children:Y1({target:b})})]}),g(bt,{children:[a(Ct,{disabled:h.isPending,children:Ke()}),g(xt,{onClick:(l)=>{l.preventDefault(),h.mutate()},disabled:h.isPending,children:[h.isPending&&a(K,{className:"mr-2 h-4 w-4 animate-spin"}),Ya()]})]})]})})]})}function kt({teamId:e,rule:t}){let[s,i]=w(!1),[n,r]=w(""),c=Vl[t.resource],u=c?.icon||gs,{data:f,isLoading:v,isError:p}=X({queryKey:["teams",e,"quotas",t.id,"records"],queryFn:async()=>{let l=await R.api.teams[":teamId"].quotas[":id"].records.$get({param:{teamId:e,id:t.id}});if(!l.ok)throw Error(S_());return await l.json()},enabled:s,refetchInterval:s?1e4:!1}),b=f?.records??[],h=b.filter((l)=>{if(!n.trim())return!0;let C=n.toLowerCase();return l.user?.name.toLowerCase().includes(C)||l.user?.email.toLowerCase().includes(C)});return g(ye,{open:s,onOpenChange:i,className:"rounded-xl border border-border/70",children:[a(Te,{asChild:!0,children:g("button",{type:"button","aria-label":s?z1():H1(),className:"flex w-full items-center justify-between gap-4 p-4 text-left transition-colors hover:bg-muted/40",children:[g("div",{className:"flex min-w-0 items-start gap-3",children:[a("div",{className:"mt-0.5 rounded-lg bg-primary/10 p-2 text-primary",children:a(u,{className:"h-5 w-5"})}),g("div",{className:"min-w-0",children:[g("div",{className:"flex flex-wrap items-center gap-2",children:[a("span",{className:"font-semibold text-foreground",children:c?.label()||t.resource}),!t.enabled&&a(ve,{variant:"secondary",children:Bh()})]}),g("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[a(ut,{rule:t}),g(ve,{variant:"outline",className:"gap-1 text-xs",children:[a(cr,{className:"h-3 w-3"}),ya(t.resource,t.limit)," ",c?.unit," /"," ",au(t.period)]}),a(dt,{rule:t})]})]})]}),a(Be,{className:`h-5 w-5 shrink-0 text-muted-foreground transition-transform ${s?"rotate-180":""}`})]})}),a(_e,{children:g("div",{className:"space-y-3 border-t border-border/60 bg-muted/10 p-4",children:[t.scopeMode!=="all_members"&&b.length>3&&g("div",{className:"relative",children:[a(rr,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),a(re,{value:n,onChange:(l)=>r(l.target.value),placeholder:Hh(),className:"h-9 pl-9 text-sm"})]}),v?a("div",{className:"flex justify-center py-10",children:a(K,{className:"h-7 w-7 animate-spin text-primary"})}):p?a("div",{className:"py-8 text-center text-sm text-destructive",children:S_()}):h.length===0?a("div",{className:"py-8 text-center text-sm text-muted-foreground",children:V1()}):h.map((l,C)=>a(gt,{teamId:e,rule:t,record:l},l.id||l.userId||`record-${C}`))]})})]})}function Ae({teamId:e}){let{data:t,isLoading:s,isError:i}=X({queryKey:["teams",e,"quotas"],queryFn:async()=>{let r=await R.api.teams[":teamId"].quotas.$get({param:{teamId:e}});if(!r.ok)throw Error(Ms());return await r.json()},enabled:!!e}),n=t?.rules??[];return g(lt,{className:"border-border/60 shadow-sm",children:[g(Nt,{children:[g(Ft,{className:"flex items-center gap-2 text-xl font-semibold tracking-tight",children:[a(gs,{className:"h-5 w-5 text-primary"}),Fp()]}),a(Ht,{children:q1()})]}),a(St,{children:s?a("div",{className:"flex h-48 items-center justify-center",children:a(K,{className:"h-7 w-7 animate-spin text-muted-foreground"})}):i?a("div",{className:"py-10 text-center text-sm text-destructive",children:Ms()}):n.length===0?g("div",{className:"flex flex-col items-center justify-center rounded-xl border-2 border-dashed border-border py-12 text-center",children:[a(gs,{className:"mb-3 h-10 w-10 text-muted-foreground/50"}),a("p",{className:"text-base font-medium text-foreground",children:Rh()}),a("p",{className:"mt-1 max-w-md text-sm text-muted-foreground",children:kh()})]}):a("div",{className:"space-y-3",children:n.map((r)=>a(kt,{teamId:e,rule:r},r.id))})})]})}Z();var At=Object.values(tu);function Re({teamId:e}){let[t,s]=w([]),[i,n]=w([]),[r,c]=w(""),{ref:u,inView:f}=Vt(),{data:v}=X({queryKey:["teams",e,"members"],queryFn:async()=>{let d=await R.api.teams[":teamId"].members.$get({param:{teamId:e},query:{}});if(!d.ok)return[];return await d.json()},enabled:!!e}),p=v||[],{data:b,isLoading:h,isError:l,fetchNextPage:C,hasNextPage:m,isFetchingNextPage:x}=Tt({queryKey:["teams",e,"audit-logs",t,i,r],queryFn:async({pageParam:d})=>{let N=await R.api.teams[":teamId"]["audit-logs"].$get({param:{teamId:e},query:{first:"20",after:d?String(d):void 0,actions:t.length>0?t:void 0,userIds:i.length>0?i:void 0,itemId:r.trim()||void 0}});if(!N.ok)throw Error("Failed to fetch audit logs");return await N.json()},initialPageParam:"",getNextPageParam:(d)=>d.pageInfo.endCursor||void 0,enabled:!!e});S(()=>{if(f&&m&&!x)C()},[f,m,x,C]);let T=b?.pages.flatMap((d)=>d.nodes)||[],k=b?.pages[0]?.total??0,_=(d)=>{s((N)=>N.includes(d)?N.filter((D)=>D!==d):[...N,d])},q=(d)=>{n((N)=>N.includes(d)?N.filter((D)=>D!==d):[...N,d])},I=(d)=>{if(d.includes("delete")||d.includes("remove")||d.includes("revoke"))return a(ve,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 font-mono text-xs",children:d});if(d.includes("create")||d.includes("add"))return a(ve,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 font-mono text-xs",children:d});if(d.includes("update")||d.includes("reparent")||d.includes("copy"))return a(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 font-mono text-xs",children:d});return a(ve,{variant:"outline",className:"bg-muted text-muted-foreground border-border font-mono text-xs",children:d})},U=new Map(p.map((d)=>[d.userId||d.id,d]));return a("div",{className:"space-y-6",children:g(lt,{className:"border border-border/50 shadow-xs",children:[g(Nt,{className:"pb-4",children:[g("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[g("div",{children:[g(Ft,{className:"text-xl font-bold flex items-center gap-2",children:[a(Li,{className:"h-5 w-5 text-primary"}),Qm()]}),a(Ht,{className:"mt-1",children:Kb()})]}),k>0&&g(ve,{variant:"secondary",className:"w-fit text-xs font-normal",children:[k," ",Qm()]})]}),g("div",{className:"mt-4 flex flex-wrap items-center gap-3 pt-4 border-t border-border/40",children:[g(pt,{children:[a(mt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),mC(),t.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:t.length})]})}),g(ht,{className:"w-64 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:Jk()}),a("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:At.map((d)=>g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:t.includes(d),onCheckedChange:()=>_(d)}),a("span",{className:"font-mono",children:d})]},d))}),t.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>s([]),children:"Clear Actions"})]})]}),g(pt,{children:[a(mt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),AC(),i.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:i.length})]})}),g(ht,{className:"w-64 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:fR()}),a("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:p.map((d)=>{let N=d.userId||d.user?.id||d.id,D=d.user?.name||d.name||N,E=d.user?.image||d.image;return g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:i.includes(N),onCheckedChange:()=>q(N)}),g($e,{className:"h-5 w-5",children:[a(He,{src:E||void 0}),a(Qe,{className:"text-[10px]",children:D.slice(0,2).toUpperCase()})]}),a("span",{className:"truncate",children:D})]},N)})}),i.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>n([]),children:"Clear Users"})]})]}),g("div",{className:"relative flex-1 min-w-[200px] max-w-xs",children:[a(rr,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),a(re,{type:"text",placeholder:Vk(),value:r,onChange:(d)=>c(d.target.value),className:"pl-8 pr-8 h-9 text-xs"}),r&&a("button",{onClick:()=>c(""),className:"absolute right-2.5 top-2.5 text-muted-foreground hover:text-foreground",children:a(Ge,{className:"h-4 w-4"})})]}),(t.length>0||i.length>0||r)&&a(F,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{s([]),n([]),c("")},children:"Clear all"})]})]}),g(St,{className:"p-0",children:[h?a("div",{className:"flex h-64 items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):l?a("div",{className:"p-8 text-center text-sm text-destructive",children:"Failed to load audit logs."}):T.length===0?a("div",{className:"p-12 text-center text-sm text-muted-foreground",children:eT()}):g(Bn,{children:[a(Un,{children:g(Tr,{className:"hover:bg-transparent border-b border-border/50",children:[a(ft,{className:"w-[180px] pl-6 text-xs font-semibold",children:Hy()}),a(ft,{className:"w-[200px] px-4 text-xs font-semibold",children:PO()}),a(ft,{className:"px-4 text-xs font-semibold",children:yS()}),a(ft,{className:"px-4 text-xs font-semibold",children:S0()}),a(ft,{className:"w-[160px] pr-6 text-right text-xs font-semibold",children:JM()})]})}),a(zn,{children:T.map((d)=>{let N=d.userId?U.get(d.userId):null,D=N?.user?.name||N?.name||d.userId||"System",E=N?.user?.image||N?.image;return g(Tr,{className:"hover:bg-muted/40 transition-colors",children:[a(ct,{className:"py-3 pl-6 font-medium",children:I(d.action)}),a(ct,{className:"py-3 px-4",children:g("div",{className:"flex items-center gap-2",children:[g($e,{className:"h-6 w-6",children:[a(He,{src:E||void 0}),a(Qe,{className:"text-[10px]",children:D.slice(0,2).toUpperCase()})]}),a("span",{className:"text-xs font-medium text-foreground truncate max-w-[160px]",children:d.agent?Rd({user:D,agent:d.agent.name}):D}),d.agent&&a($t,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]})}),a(ct,{className:"py-3 px-4 text-xs font-mono text-muted-foreground",children:d.itemId||"-"}),a(ct,{className:"py-3 px-4 text-xs font-mono text-muted-foreground",children:d.projectId||"-"}),a(ct,{className:"py-3 pr-6 text-right text-xs text-muted-foreground",children:nn(d.createdAt)})]},d.id)})})]}),a("div",{ref:u,className:"py-4 flex justify-center",children:x&&a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]})})}Z();Z();function De({task:e,open:t,onOpenChange:s}){let[i,n]=w(null);if(!e)return null;let r=(u,f)=>{navigator.clipboard.writeText(u),n(f),setTimeout(()=>{n(null)},2000)},c=(u)=>{switch(u){case"completed":return a(ve,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 text-xs font-mono",children:"completed"});case"processing":return a(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 text-xs font-mono",children:"processing"});case"pending":return a(ve,{variant:"outline",className:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 border-yellow-500/20 text-xs font-mono",children:"pending"});case"failed":return a(ve,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 text-xs font-mono",children:"failed"});default:return a(ve,{variant:"outline",className:"text-xs font-mono",children:u||"unknown"})}};return a(Se,{open:t,onOpenChange:s,children:g(xe,{className:"max-w-2xl max-h-[90vh] flex flex-col p-6",children:[g(ke,{className:"pb-2 border-b border-border/50",children:[g("div",{className:"flex items-center justify-between gap-2 pr-6",children:[g("div",{className:"flex items-center gap-2",children:[a(On,{className:"h-5 w-5 text-primary"}),a(Ce,{className:"text-lg font-bold",children:TM()})]}),g("div",{className:"flex items-center gap-2",children:[c(e.status),e.type&&a(ve,{variant:"secondary",className:"font-mono text-xs",children:e.type})]})]}),g(Ot,{className:"text-xs text-muted-foreground mt-1 flex items-center gap-2",children:[g("span",{children:[gy(),": ",a("span",{className:"font-mono text-foreground",children:e.id})]}),a(F,{variant:"ghost",size:"icon",className:"h-5 w-5 text-muted-foreground hover:text-foreground",onClick:()=>r(e.id,"task_id"),children:i==="task_id"?a(qe,{className:"h-3 w-3 text-emerald-500"}):a(Zr,{className:"h-3 w-3"})})]})]}),g("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 py-3 text-xs border-b border-border/40",children:[g("div",{children:[a("div",{className:"text-muted-foreground",children:dh()}),a("div",{className:"truncate font-medium text-foreground mt-0.5",title:e.fileName||"-",children:e.fileName||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:ly()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.fileSize!==null&&e.fileSize!==void 0?on(e.fileSize):"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:Ip()}),a("div",{className:"truncate font-medium text-foreground mt-0.5",title:e.projectName||"-",children:e.projectName||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:zb()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.assetId||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:S0()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.projectId||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:cp()}),g("div",{className:"font-medium text-foreground mt-0.5 flex items-center gap-1",children:[a(cr,{className:"h-3 w-3 text-muted-foreground"}),nn(e.createdAt)]})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:SO()}),a("div",{className:"font-medium text-foreground mt-0.5",children:nn(e.updatedAt)})]}),e.heartbeat&&g("div",{children:[a("div",{className:"text-muted-foreground",children:rS()}),a("div",{className:"font-medium text-foreground mt-0.5",children:nn(e.heartbeat)})]}),e.model&&g("div",{children:[a("div",{className:"text-muted-foreground",children:Eh()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.model})]}),(e.inputTokens>0||e.outputTokens>0)&&g("div",{children:[g("div",{className:"text-muted-foreground flex items-center gap-1",children:[a(eo,{className:"h-3 w-3"})," ",nO()]}),g("div",{className:"font-medium text-foreground mt-0.5 font-mono",children:[e.inputTokens.toLocaleString()," in / ",e.outputTokens.toLocaleString()," out"]})]}),e.sessionId&&g("div",{className:"col-span-2",children:[a("div",{className:"text-muted-foreground",children:ER()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.sessionId})]})]}),a("div",{className:"flex-1 min-h-0 pt-3",children:g(co,{defaultValue:"payload",className:"w-full h-full flex flex-col",children:[g(uo,{className:"grid w-full grid-cols-2",children:[a(Wr,{value:"payload",children:s1()}),a(Wr,{value:"output",children:VT()})]}),a(gn,{value:"payload",className:"flex-1 mt-2 min-h-0",children:a(Ie,{className:"h-64 w-full rounded-md border border-border/50 bg-muted/30 p-3 font-mono text-xs",children:a("pre",{className:"whitespace-pre-wrap break-all text-foreground/90",children:e.payload?JSON.stringify(e.payload,null,2):"null"})})}),a(gn,{value:"output",className:"flex-1 mt-2 min-h-0",children:a(Ie,{className:"h-64 w-full rounded-md border border-border/50 bg-muted/30 p-3 font-mono text-xs",children:a("pre",{className:"whitespace-pre-wrap break-all text-foreground/90",children:e.output?JSON.stringify(e.output,null,2):"null"})})})]})})]})})}var Rt=Object.values($l),Dt=Object.values(Hl);function Pe({teamId:e}){let t=ie(),[s,i]=w([]),[n,r]=w([]),[c,u]=w(null),[f,v]=w(null),{ref:p,inView:b}=Vt(),h=G(()=>["teams",e,"workflow-tasks",s,n],[e,s,n]),{data:l,isLoading:C,isError:m,fetchNextPage:x,hasNextPage:T,isFetchingNextPage:k,refetch:_,isRefetching:q}=Tt({queryKey:h,queryFn:async({pageParam:o})=>{let y=await R.api.teams[":teamId"]["workflow-tasks"].$get({param:{teamId:e},query:{first:"20",after:o?String(o):void 0,status:s.length>0?s:void 0,types:n.length>0?n:void 0}});if(!y.ok)throw Error("Failed to fetch workflow tasks");return await y.json()},initialPageParam:"",getNextPageParam:(o)=>o.pageInfo.endCursor||void 0,enabled:!!e});S(()=>{if(b&&T&&!k)x()},[b,T,k,x]);let I=G(()=>l?.pages.flatMap((o)=>o.nodes)||[],[l]),U=l?.pages[0]?.total??0,d=G(()=>I.filter((o)=>o.status==="pending"||o.status==="processing").map((o)=>o.id),[I]);X({queryKey:["teams",e,"workflow-tasks","batch-status",d],queryFn:async()=>{if(d.length===0)return null;let o=await R.api.teams[":teamId"]["workflow-tasks"]["batch-status"].$post({param:{teamId:e},json:{taskIds:d}});if(!o.ok)return null;let y=await o.json();if(y.tasks&&y.tasks.length>0)t.setQueryData(h,(A)=>{if(!A)return A;let V=new Map(y.tasks.map((L)=>[L.id,L]));return{...A,pages:A.pages.map((L)=>({...L,nodes:L.nodes.map((le)=>V.get(le.id)||le)}))}});return y},enabled:d.length>0,refetchInterval:6000});let N=ee({mutationFn:async(o)=>{let y=await R.api.teams[":teamId"]["workflow-tasks"][":taskId"].stop.$post({param:{teamId:e,taskId:o}});if(!y.ok){let A=await y.json().catch(()=>({message:"Failed to stop task"}));throw Error(A.message||"Failed to stop task")}return await y.json()},onSuccess:(o)=>{j.success(kM()),t.setQueryData(h,(y)=>{if(!y)return y;return{...y,pages:y.pages.map((A)=>({...A,nodes:A.nodes.map((V)=>V.id===o.task.id?o.task:V)}))}}),u(null)},onError:(o)=>{j.error(o.message||"Failed to stop task")}}),D=(o)=>{i((y)=>y.includes(o)?y.filter((A)=>A!==o):[...y,o])},E=(o)=>{r((y)=>y.includes(o)?y.filter((A)=>A!==o):[...y,o])},Ee=(o)=>{switch(o){case"completed":return a(ve,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 font-mono text-xs",children:"completed"});case"processing":return g(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 font-mono text-xs gap-1.5",children:[a(K,{className:"h-3 w-3 animate-spin"}),"processing"]});case"pending":return a(ve,{variant:"outline",className:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 border-yellow-500/20 font-mono text-xs",children:"pending"});case"failed":return a(ve,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 font-mono text-xs",children:"failed"});default:return a(ve,{variant:"outline",className:"font-mono text-xs",children:o||"-"})}},Oe=(o)=>{if(!o)return a(ve,{variant:"outline",children:"-"});if(o.startsWith("transcode"))return a(ve,{variant:"outline",className:"bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20 font-mono text-xs",children:o});if(o.startsWith("ai_")||o==="chat")return a(ve,{variant:"outline",className:"bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 border-indigo-500/20 font-mono text-xs",children:o});return a(ve,{variant:"secondary",className:"font-mono text-xs",children:o})};return g("div",{className:"space-y-6",children:[g(lt,{className:"border border-border/50 shadow-xs",children:[g(Nt,{className:"pb-4",children:[g("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[g("div",{children:[g(Ft,{className:"text-xl font-bold flex items-center gap-2",children:[a(ae,{className:"h-5 w-5 text-primary"}),Ag()]}),a(Ht,{className:"mt-1",children:eP()})]}),g("div",{className:"flex items-center gap-3",children:[U>0&&g(ve,{variant:"secondary",className:"w-fit text-xs font-normal",children:[U," ",Ag()]}),g(F,{variant:"outline",size:"sm",className:"h-9 gap-1.5 text-xs",onClick:()=>_(),disabled:q,children:[a(be,{className:`h-3.5 w-3.5 ${q?"animate-spin":""}`}),yk()]})]})]}),g("div",{className:"mt-4 flex flex-wrap items-center gap-3 pt-4 border-t border-border/40",children:[g(pt,{children:[a(mt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),hC(),s.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:s.length})]})}),g(ht,{className:"w-56 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:uR()}),a("div",{className:"space-y-1",children:Dt.map((o)=>g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:s.includes(o),onCheckedChange:()=>D(o)}),a("span",{className:"font-mono",children:o})]},o))}),s.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>i([]),children:Tw()})]})]}),g(pt,{children:[a(mt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),gC(),n.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:n.length})]})}),g(ht,{className:"w-64 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:eg()}),a("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:Rt.map((o)=>g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:n.includes(o),onCheckedChange:()=>E(o)}),a("span",{className:"font-mono truncate",children:o})]},o))}),n.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>r([]),children:kw()})]})]}),(s.length>0||n.length>0)&&a(F,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{i([]),r([])},children:xw()})]})]}),g(St,{className:"p-0",children:[C?a("div",{className:"flex h-64 items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):m?a("div",{className:"p-8 text-center text-sm text-destructive",children:zx()}):I.length===0?a("div",{className:"p-12 text-center text-sm text-muted-foreground",children:wT()}):g(Bn,{children:[a(Un,{children:g(Tr,{className:"hover:bg-transparent border-b border-border/50",children:[a(ft,{className:"w-[170px] pl-6 text-xs font-semibold",children:by()}),a(ft,{className:"w-[130px] px-4 text-xs font-semibold",children:_y()}),a(ft,{className:"min-w-[180px] px-4 text-xs font-semibold",children:dh()}),a(ft,{className:"w-[110px] px-4 text-xs font-semibold",children:ly()}),a(ft,{className:"w-[160px] px-4 text-xs font-semibold",children:Ip()}),a(ft,{className:"w-[130px] px-4 text-right text-xs font-semibold",children:cp()}),a(ft,{className:"w-[120px] pr-6 text-right text-xs font-semibold",children:Bm()})]})}),a(zn,{children:I.map((o)=>{let y=o.status==="pending"||o.status==="processing";return g(Tr,{className:"hover:bg-muted/40 transition-colors",children:[a(ct,{className:"py-3 pl-6 font-medium",children:Oe(o.type)}),a(ct,{className:"py-3 px-4 font-medium",children:Ee(o.status)}),a(ct,{className:"py-3 px-4 text-xs font-medium",children:a("span",{className:"truncate block max-w-[220px]",title:o.fileName||o.assetId||"-",children:o.fileName||o.assetId||"-"})}),a(ct,{className:"py-3 px-4 text-xs font-mono text-muted-foreground",children:o.fileSize!==null&&o.fileSize!==void 0?on(o.fileSize):"-"}),a(ct,{className:"py-3 px-4 text-xs text-muted-foreground",children:a("span",{className:"truncate block max-w-[160px]",title:o.projectName||o.projectId||"-",children:o.projectName||o.projectId||"-"})}),a(ct,{className:"py-3 px-4 text-right text-xs text-muted-foreground whitespace-nowrap",children:nn(o.createdAt)}),a(ct,{className:"py-3 pr-6 text-right",children:g("div",{className:"flex items-center justify-end gap-1",children:[a(F,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",onClick:()=>v(o),title:BO(),children:a(ge,{className:"h-4 w-4"})}),y&&g(F,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs border-destructive/30 text-destructive hover:bg-destructive/10",onClick:()=>u(o),disabled:N.isPending,children:[a(yu,{className:"h-3 w-3 mr-1 fill-current"}),py()]})]})})]},o.id)})})]}),a("div",{ref:p,className:"py-4 flex justify-center",children:k&&a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]}),a(_t,{open:!!c,onOpenChange:(o)=>{if(!o)u(null)},children:g(yt,{children:[g(vt,{children:[g("div",{className:"flex items-center gap-2",children:[a(tn,{className:"h-5 w-5 text-destructive"}),a(wt,{children:sM()})]}),a(Et,{className:"pt-2 text-sm text-muted-foreground",children:oM()}),c&&g("div",{className:"mt-3 p-2.5 rounded-md bg-muted/50 border border-border/40 font-mono text-xs space-y-1",children:[g("div",{children:[gy(),": ",c.id]}),c.fileName&&g("div",{className:"font-sans",children:[dh(),":"," ",a("span",{className:"font-medium text-foreground",children:c.fileName})]}),g("div",{children:[by(),": ",c.type||"unknown"]}),g("div",{children:[_y(),": ",c.status]})]})]}),g(bt,{children:[a(Ct,{disabled:N.isPending,children:Ke()}),a(xt,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",disabled:N.isPending,onClick:()=>{if(c)N.mutate(c.id)},children:N.isPending?g(Y,{children:[a(K,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}),iM()]}):py()})]})]})}),a(De,{task:f,open:!!f,onOpenChange:(o)=>{if(!o)v(null)}})]})}function qt(){let{teamId:e}=It.useParams(),[t,s]=w("audit-logs"),{data:i,isLoading:n}=X({queryKey:["teams",e,"me"],queryFn:async()=>{let r=await R.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!r.ok)throw Error("Failed to fetch me");return await r.json()},enabled:!!e});if(n)return a("div",{className:"flex h-screen items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(i?.role?.toLowerCase()!=="owner")return g("div",{className:"flex h-full flex-col items-center justify-center p-8 text-center",children:[a(iu,{className:"h-12 w-12 text-destructive mb-4"}),a("h2",{className:"text-xl font-bold tracking-tight mb-2",children:$y()}),a("p",{className:"text-sm text-muted-foreground max-w-md",children:IT()})]});return a("div",{className:"h-full bg-background font-sans selection:bg-primary/20 transition-colors duration-300",children:g("div",{className:"flex flex-col md:flex-row h-full",children:[a("div",{className:"w-full h-full md:w-72 bg-sidebar border-b md:border-b-0 md:border-r border-sidebar-border z-10 md:left-16 overflow-y-auto transition-colors duration-300",children:g("nav",{className:"p-4 space-y-1 mt-4",children:[a("div",{className:"mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider",children:c_()}),a("div",{className:"mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:OM()}),g("button",{onClick:()=>s("audit-logs"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="audit-logs"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(Li,{className:"w-5 h-5"}),Qm(),t==="audit-logs"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("workflow-tasks"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="workflow-tasks"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(ae,{className:"w-5 h-5"}),Ag(),t==="workflow-tasks"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("quotas"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="quotas"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(gs,{className:"w-5 h-5"}),Fp(),t==="quotas"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),a("div",{className:"mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:Ab()}),g("button",{onClick:()=>s("ai-usage"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="ai-usage"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(fe,{className:"w-5 h-5"}),OO(),t==="ai-usage"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("ai-sessions"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="ai-sessions"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(W,{className:"w-5 h-5"}),ay(),t==="ai-sessions"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]})}),a("div",{className:"flex-1 overflow-y-auto p-4 md:p-8",children:g("div",{className:"max-w-6xl mx-auto space-y-8",children:[t==="audit-logs"&&a(Re,{teamId:e}),t==="workflow-tasks"&&a(Pe,{teamId:e}),t==="ai-usage"&&a(he,{teamId:e}),t==="ai-sessions"&&a(Ne,{teamId:e}),t==="quotas"&&a(Ae,{teamId:e})]})})]})})}var It=Je("/teams/$teamId/dashboard")({component:qt});export{It as Route};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{zy,Wg,mf,gl,nP,oP,sP,Jg,jy,iP,hf,Qn}from"./chunk-f25fe9th.js";import"./chunk-gxepkvt2.js";import"./chunk-3ckkwdjx.js";import"./chunk-yk12hydf.js";export{gl as d,Wg as f,mf as h,hf as i,oP as m,jy as n,sP as o,nP as p,iP as r,Jg as s,Qn as t,zy as u};
@@ -1 +0,0 @@
1
- import{S,Z,a,X,Je,R,Pt,qt,Ig}from"./chunk-zarz3sqn.js";import"./chunk-55h9ze53.js";import"./chunk-1ktk6764.js";import"./chunk-ah8fjb6f.js";import"./chunk-q5vkxee3.js";import{Kl}from"./chunk-srxp5jav.js";import"./chunk-b5rhvzv9.js";import"./chunk-8xb6yz11.js";import"./chunk-7sgrtxbt.js";import"./chunk-hpbn0k9n.js";import{gr}from"./chunk-pk406dgy.js";import"./chunk-257dcd2f.js";import"./chunk-91rb0jpb.js";import"./chunk-ny1kbmxt.js";Z();function m(){let{projectId:e}=c.useParams(),{teamId:r,ensureTeamIdForProject:t}=Pt();S(()=>{t(e)},[e,t]);let{data:n}=gr(Ig(e)),o=n?.rootFolder,{data:s}=X({queryKey:["folders",o],queryFn:async()=>{let d=await R.api.folders[":folderId"].$get({param:{folderId:o}});if(!d.ok)throw Error("failed to fetch folder");return await d.json()},enabled:!!o});if(!r||!o||!s)return a(qt,{});return a(Kl,{teamId:r,projectId:e,projectName:n.name??"",assetId:o,rootFolderId:o,isRoot:!0})}var c=Je("/projects/$projectId/agentsmd")({component:m});export{c as Route};
@@ -1,2 +0,0 @@
1
- import{a,B}from"./chunk-zarz3sqn.js";function Bn({className:t,...e}){return a("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:a("table",{"data-slot":"table",className:B("w-full caption-bottom text-sm",t),...e})})}function Un({className:t,...e}){return a("thead",{"data-slot":"table-header",className:B("[&_tr]:border-b",t),...e})}function zn({className:t,...e}){return a("tbody",{"data-slot":"table-body",className:B("[&_tr:last-child]:border-0",t),...e})}function Tr({className:t,...e}){return a("tr",{"data-slot":"table-row",className:B("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),...e})}function ft({className:t,...e}){return a("th",{"data-slot":"table-head",className:B("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...e})}function ct({className:t,...e}){return a("td",{"data-slot":"table-cell",className:B("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...e})}
2
- export{Bn,Un,zn,Tr,ft,ct};
@@ -1 +0,0 @@
1
- import{a,Je}from"./chunk-zarz3sqn.js";import"./chunk-s1e4qy3q.js";import"./chunk-ns33grgx.js";import"./chunk-q2bew2vc.js";import"./chunk-f6avg5qe.js";import"./chunk-55h9ze53.js";import"./chunk-8mqbztj8.js";import"./chunk-gtf19jc1.js";import"./chunk-zezje74z.js";import"./chunk-r1xer8gn.js";import"./chunk-1ktk6764.js";import"./chunk-z1p13dnc.js";import"./chunk-q5vkxee3.js";import{ba}from"./chunk-0bj887zm.js";import"./chunk-8yjsmr7g.js";import"./chunk-atfz7g7e.js";import"./chunk-257dcd2f.js";import"./chunk-91rb0jpb.js";import"./chunk-ny1kbmxt.js";import"./chunk-fvx9k1dc.js";import"./chunk-kvhf12b4.js";import"./chunk-qwpkcp8d.js";import"./chunk-v5cn90cf.js";function o(){let{shareId:e,folderId:r}=d.useParams();return a(ba,{shareId:e,initialFolderId:r})}var d=Je("/share/$shareId/folders/$folderId")({component:o});export{d as Route};
@@ -1,3 +0,0 @@
1
- // @bun
2
- function Hn(n){let e={};for(let[t,r]of n.entries())e[t]=r;return e}function Na(n){if(!n)return;let e={};for(let[t,r]of Object.entries(n))if(r!==null)e[t]=r;return Object.keys(e).length>0?e:void 0}
3
- export{Hn,Na};
@@ -1 +0,0 @@
1
- import{S,Z,a,X,ee,Je,R,q_,Pt,Og,Uy}from"./chunk-zarz3sqn.js";import"./chunk-f6avg5qe.js";import"./chunk-s1e4qy3q.js";import"./chunk-ns33grgx.js";import"./chunk-q2bew2vc.js";import"./chunk-55h9ze53.js";import"./chunk-1ktk6764.js";import"./chunk-ah8fjb6f.js";import"./chunk-96qpjght.js";import"./chunk-8mqbztj8.js";import"./chunk-gtf19jc1.js";import"./chunk-zezje74z.js";import"./chunk-r1xer8gn.js";import"./chunk-q5vkxee3.js";import{xo}from"./chunk-xc54vhfz.js";import"./chunk-hpbn0k9n.js";import{gr}from"./chunk-pk406dgy.js";import"./chunk-8yjsmr7g.js";import"./chunk-atfz7g7e.js";import"./chunk-257dcd2f.js";import"./chunk-91rb0jpb.js";import"./chunk-ny1kbmxt.js";import"./chunk-fvx9k1dc.js";import"./chunk-kvhf12b4.js";import"./chunk-qwpkcp8d.js";import"./chunk-v5cn90cf.js";Z();function f(){let{projectId:e,collectionId:n}=I.useParams(),{teamId:c,ensureTeamIdForProject:i}=Pt();S(()=>{i(e)},[e,i]);let{data:l}=gr(Og(e)),{data:r,refetch:d}=X({...Uy(n)}),{mutate:p}=ee({mutationFn:async(t)=>{let s=await R.api.collections[":collectionId"].$patch({param:{collectionId:n},json:t});if(!s.ok)throw Error("Failed to update collection");return await s.json()},onSuccess:()=>{d()}}),o=l?.rootFolder,{data:m}=X({queryKey:["folders",o],queryFn:async()=>{let t=await R.api.folders[":folderId"].$get({param:{folderId:o}});if(!t.ok)throw Error("Failed to fetch folder");return await t.json()},enabled:!!o});if(!c||!o||!m||!r)return a("div",{children:q_()});let u=r.filter.sourceFolderId||o;return a(xo,{teamId:c,projectId:e,projectName:l.name??"",assetId:u,rootFolderId:o,collection:r,onUpdateCollection:p})}var I=Je("/projects/$projectId/collections/$collectionId")({component:f});export{I as Route};
@@ -1,2 +0,0 @@
1
- async function jo(t){if(typeof navigator<"u"&&navigator.clipboard&&typeof navigator.clipboard.writeText==="function")try{return await navigator.clipboard.writeText(t),!0}catch{}try{let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="2em",e.style.height="2em",e.style.padding="0",e.style.border="none",e.style.outline="none",e.style.boxShadow="none",e.style.background="transparent",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select();let o=document.execCommand("copy");return document.body.removeChild(e),o}catch(e){return console.error("Failed to copy text to clipboard:",e),!1}}
2
- export{jo};
@@ -1,2 +0,0 @@
1
- import{z}from"./chunk-zarz3sqn.js";var o=[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]],fu=z("arrow-up-narrow-wide",o);
2
- export{fu};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{iA,aA,lA,cA,uA,Om,Pf,Nm,pA,Fm}from"./chunk-2cdxm1cp.js";import{Ye}from"./chunk-2jj4j8cn.js";var Ji={};Ye(Ji,{bigint:()=>e,boolean:()=>Vu,date:()=>t,number:()=>Xg,string:()=>_f});function _f(r){return iA(Om,r)}function Xg(r){return aA(Pf,r)}function Vu(r){return lA(Nm,r)}function e(r){return cA(pA,r)}function t(r){return uA(Fm,r)}export{_f,Xg,Vu,Ji};
@@ -1,2 +0,0 @@
1
- import{w,Z,Y,a,g,K,Be,Ue,F,Dn,Nn,Fn,Ln,$e,He,Qe,De,Ne,Fe,pd,fa,ev,tv,av,lv,cv,CA,Ke,Mi,E_,Zx,qx,Qx,TC,AS,_S,yI,vI,xd,b1,Zh,E1,Wc,wk,Ek,Pi,MR,zp,cg,_t,yt,vt,bt,wt,Et,xt,Ct,Se,xe,ke,Ce,re,j}from"./chunk-zarz3sqn.js";import{jo}from"./chunk-88jg9dq5.js";import{Zr}from"./chunk-v5cn90cf.js";Z();function vu({open:P,onOpenChange:G,title:V,members:_,isOwner:r,onInvite:u,onUpdateRole:D,onRemoveMember:y,currentUserId:H,availableMembersToAdd:M,onAddMember:d,type:s="team"}){let[v,C]=w("editor"),[c,b]=w(null),[A,T]=w(!1),[x,m]=w(null),[n,f]=w(null),[R,I]=w({}),[i,l]=w(null),p=(e)=>{if(!e)return"";switch(e.toLowerCase()){case"owner":return xd();case"editor":return Mi();case"reviewer":return Pi();default:return e}},k=(e,t)=>{I((o)=>({...o,[e]:t}))},L=async(e,t)=>{if(!D)return;m(e);try{await D(e,t),j.success(vI())}catch(o){console.error(o),j.error(Qx())}finally{m(null)}},U=async()=>{if(!y||!n?.id)return;m(n.id);try{await y(n.id),j.success(yI()),f(null)}catch(e){console.error(e),j.error(qx())}finally{m(null)}},S=async()=>{if(!u)return;T(!0);try{let e=await u(v),t=`${window.location.origin}/signup?inviteCode=${e}`;b(t)}catch(e){console.error(e),j.error(Zx())}finally{T(!1)}},q=async()=>{if(c){if(await jo(c))j.success(AS())}},h=(e)=>{if(!e)return"??";return e.split(" ").map((t)=>t[0]).slice(0,2).join("").toUpperCase()},E=(e)=>{if(!e)b(null),C("editor"),I({}),l(null);G(e)},N=Array.isArray(_)?_:[],J=Array.isArray(M)?M:[],O=s==="project"&&r?N.filter((e)=>e.role==="owner"||e.scope==="project"||e.hasCustomRole):N,z=s==="project"&&r?N.filter((e)=>e.scope==="team"&&e.role!=="owner"&&!e.hasCustomRole):[],B=s==="project"&&r?J.filter((e)=>e.scope==="project"):[];return a(Se,{open:P,onOpenChange:E,children:g(xe,{className:"sm:max-w-xl",onOpenAutoFocus:(e)=>e.preventDefault(),children:[a(ke,{children:a(Ce,{children:V})}),g("div",{className:"space-y-4",children:[a("div",{className:"max-h-[300px] overflow-y-auto space-y-2",children:O.map((e)=>{let t=s==="team"&&e.scope==="project";return g("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50",children:[g("div",{className:"flex items-center gap-3",children:[g($e,{children:[e.image&&a(He,{src:e.image,alt:e.name,className:"object-cover"}),a(Qe,{children:h(e.name)})]}),g("div",{className:"flex flex-col",children:[a("span",{className:"text-sm font-medium",children:e.name}),g("div",{className:"flex items-center gap-2",children:[!t&&a("span",{className:"text-xs text-muted-foreground capitalize",children:p(e.role)}),e.scope&&g(Y,{children:[!t&&a("span",{className:"text-[10px] text-muted-foreground/70",children:"•"}),a("span",{className:"text-xs text-muted-foreground capitalize",children:e.scope==="team"?cg():Zh()})]})]})]})]}),r&&e.role!=="owner"&&e.id!==H&&g("div",{className:"flex items-center gap-2",children:[t?a(Dn,{children:g(Nn,{children:[a(Fn,{asChild:!0,children:a("span",{children:a(F,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26 justify-between",disabled:!0,children:a(Be,{className:"ml-auto h-3 w-3 opacity-50"})})})}),a(Ln,{side:"top",children:a("p",{className:"text-xs",children:E1()})})]})}):g(De,{children:[a(Ne,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26",disabled:x===e.id,children:[p(e.role),a(Be,{className:"ml-1 h-3 w-3 opacity-50"})]})}),a(Fe,{children:g(pd,{value:e.role,onValueChange:(o)=>L(e.id,o),children:[a(fa,{value:"editor",className:"text-xs",children:Mi()}),a(fa,{value:"reviewer",className:"text-xs",children:Pi()})]})})]}),a(F,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>f(e),disabled:x===e.id,children:x===e.id?a(K,{className:"h-3 w-3 animate-spin"}):a(Ue,{className:"h-3 w-3"})})]})]},e.id)})}),a(_t,{open:!!n,onOpenChange:(e)=>!e&&f(null),children:g(yt,{children:[g(vt,{children:[a(wt,{children:wk()}),a(Et,{children:Ek({name:n?.name||"",type:s==="project"?b1():zp()})})]}),g(bt,{children:[a(Ct,{children:Ke()}),a(xt,{onClick:U,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:Wc()})]})]})})," ",r&&d&&z.length>0&&g("div",{className:"border-t pt-4",children:[a("h4",{className:"text-sm font-medium mb-1",children:av()}),a("p",{className:"text-xs text-muted-foreground mb-3 font-normal",children:lv()}),a("div",{className:"max-h-[200px] overflow-y-auto space-y-2 pr-1",children:z.map((e)=>{let t=R[e.id]||"editor";return g("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50",children:[g("div",{className:"flex items-center gap-3",children:[g($e,{children:[e.image&&a(He,{src:e.image,alt:e.name,className:"object-cover"}),a(Qe,{children:h(e.name)})]}),g("div",{className:"flex flex-col",children:[a("span",{className:"text-sm font-medium",children:e.name}),a("span",{className:"text-xs text-muted-foreground capitalize",children:e.scope==="team"?cg():Zh()})]})]}),g("div",{className:"flex items-center gap-2",children:[g(De,{children:[a(Ne,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26",disabled:i===e.id,children:[p(t),a(Be,{className:"ml-1 h-3 w-3 opacity-50"})]})}),a(Fe,{children:g(pd,{value:t,onValueChange:(o)=>k(e.id,o),children:[a(fa,{value:"editor",className:"text-xs",children:Mi()}),a(fa,{value:"reviewer",className:"text-xs",children:Pi()})]})})]}),a(F,{onClick:async()=>{l(e.id);try{await d(e.id,t),j.success(CA({name:e.name||""}))}catch(o){console.error(o),j.error(E_({name:e.name||""}))}finally{l(null)}},disabled:i!==null,size:"sm",className:"h-8 text-xs px-3",children:i===e.id?a(K,{className:"h-3 w-3 animate-spin"}):MR()})]})]},e.id)})})]}),r&&d&&B.length>0&&g("div",{className:"border-t pt-4",children:[a("h4",{className:"text-sm font-medium mb-1",children:ev()}),a("p",{className:"text-xs text-muted-foreground mb-3 font-normal",children:tv()}),a("div",{className:"max-h-[200px] overflow-y-auto space-y-2 pr-1",children:B.map((e)=>{let t=R[e.id]||"editor";return g("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50",children:[g("div",{className:"flex items-center gap-3",children:[g($e,{children:[e.image&&a(He,{src:e.image,alt:e.name,className:"object-cover"}),a(Qe,{children:h(e.name)})]}),g("div",{className:"flex flex-col",children:[a("span",{className:"text-sm font-medium",children:e.name}),a("span",{className:"text-xs text-muted-foreground capitalize",children:e.scope==="team"?cg():Zh()})]})]}),g("div",{className:"flex items-center gap-2",children:[g(De,{children:[a(Ne,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26",disabled:i===e.id,children:[p(t),a(Be,{className:"ml-1 h-3 w-3 opacity-50"})]})}),a(Fe,{children:g(pd,{value:t,onValueChange:(o)=>k(e.id,o),children:[a(fa,{value:"editor",className:"text-xs",children:Mi()}),a(fa,{value:"reviewer",className:"text-xs",children:Pi()})]})})]}),a(F,{onClick:async()=>{l(e.id);try{await d(e.id,t),j.success(CA({name:e.name||""}))}catch(o){console.error(o),j.error(E_({name:e.name||""}))}finally{l(null)}},disabled:i!==null,size:"sm",className:"h-8 text-xs px-3",children:i===e.id?a(K,{className:"h-3 w-3 animate-spin"}):cv()})]})]},e.id)})})]}),r&&u&&g("div",{className:"border-t pt-4",children:[a("h4",{className:"text-sm font-medium mb-3",children:_S()}),g("div",{className:"space-y-3",children:[g("div",{className:"flex gap-2",children:[g(De,{children:[a(Ne,{asChild:!0,children:g(F,{variant:"outline",className:"w-[120px] justify-between",children:[v==="editor"?Mi():Pi(),a(Be,{className:"h-4 w-4 opacity-50"})]})}),a(Fe,{children:g(pd,{value:v,onValueChange:(e)=>C(e),children:[a(fa,{value:"editor",children:Mi()}),a(fa,{value:"reviewer",children:Pi()})]})})]}),g(F,{onClick:S,disabled:A,className:"flex-1",children:[A&&a(K,{className:"mr-2 h-4 w-4 animate-spin"}),TC()]})]}),c&&g("div",{className:"flex gap-2",children:[a(re,{value:c,readOnly:!0}),a(F,{variant:"outline",size:"icon",onClick:q,children:a(Zr,{className:"h-4 w-4"})})]})]})]})]})]})})}
2
- export{vu};