@shumai-one/shumai 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/bin/{chunk-qxscgcn9.js → chunk-01ym2agz.js} +1 -1
  2. package/bin/{chunk-ae6zgjhd.js → chunk-047n9gfs.js} +2 -2
  3. package/bin/chunk-0a4ahz7r.js +2 -0
  4. package/bin/{chunk-v5hz09a1.js → chunk-0awcpx0a.js} +2 -2
  5. package/bin/{chunk-19q13a80.js → chunk-0fbgfgxv.js} +5 -5
  6. package/bin/{chunk-jt6v15wx.js → chunk-0nnqha4f.js} +1 -1
  7. package/bin/chunk-0tvggyy4.js +1 -0
  8. package/bin/{chunk-zckxc8m6.js → chunk-113baw0m.js} +2 -2
  9. package/bin/{chunk-mneeg71d.js → chunk-1dbjyarc.js} +2 -2
  10. package/bin/{chunk-951r2rx1.js → chunk-1qre79kf.js} +1 -1
  11. package/bin/chunk-27v3yepb.js +1 -0
  12. package/bin/{chunk-5vqbzsjv.js → chunk-2rq3w8sg.js} +1 -1
  13. package/bin/{chunk-v034sfw8.js → chunk-3020am4q.js} +2 -2
  14. package/bin/{chunk-zdzkjp4q.js → chunk-3fjgf7eb.js} +2 -2
  15. package/bin/chunk-3pwwg1xm.js +1 -0
  16. package/bin/{chunk-19jpn3r6.js → chunk-3sfb63fp.js} +1 -1
  17. package/bin/{chunk-wwkhskce.js → chunk-3tg10kwz.js} +2 -2
  18. package/bin/{chunk-0y4zq3y4.js → chunk-4g4pxmef.js} +1 -1
  19. package/bin/{chunk-2pw7xcrn.js → chunk-4jj92zwa.js} +1 -1
  20. package/bin/{chunk-bpxw19ez.js → chunk-4yhvexzk.js} +1 -1
  21. package/bin/chunk-58cbk6e8.js +1 -0
  22. package/bin/{chunk-eqr0znmc.js → chunk-59t9s2jh.js} +1 -1
  23. package/bin/{chunk-n76w2wcr.js → chunk-5e7r7a9d.js} +1 -1
  24. package/bin/{chunk-8tzfcqtb.js → chunk-5m51b7af.js} +1 -1
  25. package/bin/{chunk-m6v8vt2b.js → chunk-65t6rm5d.js} +2 -2
  26. package/bin/chunk-6bed0rz4.js +1 -0
  27. package/bin/{chunk-1nvj833s.js → chunk-6smn0q1n.js} +5 -5
  28. package/bin/{chunk-r249n1xe.js → chunk-6zerk0em.js} +2 -2
  29. package/bin/{chunk-gvas3xkp.js → chunk-7bbsv8g0.js} +1 -1
  30. package/bin/chunk-83bdgs2c.js +1 -0
  31. package/bin/{chunk-93p27bbm.js → chunk-86qtjd30.js} +5 -5
  32. package/bin/{chunk-b5r0be06.js → chunk-8rekh4h9.js} +1 -1
  33. package/bin/{chunk-d2dgazjj.js → chunk-8s9fehda.js} +1 -1
  34. package/bin/{chunk-r776bhsg.js → chunk-8sf2hf31.js} +1 -1
  35. package/bin/{chunk-mn108p93.js → chunk-9d3w678j.js} +1 -1
  36. package/bin/{chunk-xr2v0d6y.js → chunk-9gftd4f7.js} +4 -4
  37. package/bin/{chunk-n9vp9nbg.js → chunk-9rcg8zgs.js} +32 -32
  38. package/bin/{chunk-6jkjx0n2.js → chunk-a23q1kc4.js} +3 -3
  39. package/bin/{chunk-81dawvn4.js → chunk-a6cdt85k.js} +2 -2
  40. package/bin/chunk-a76h3ehe.js +1 -0
  41. package/bin/{chunk-rmvhyqyb.js → chunk-b1bkd2p4.js} +8 -8
  42. package/bin/{chunk-wnqxyqrg.js → chunk-bf5m8f6t.js} +2 -2
  43. package/bin/chunk-cf57fk11.js +2 -0
  44. package/bin/{chunk-0v9srsdz.js → chunk-cv5xx81e.js} +1 -1
  45. package/bin/{chunk-3q5qkfkc.js → chunk-czybv3vy.js} +1 -1
  46. package/bin/{chunk-ggfx2b0f.js → chunk-d4sbcvpa.js} +1 -1
  47. package/bin/{chunk-9ggwc289.js → chunk-d6xezgrg.js} +1 -1
  48. package/bin/{chunk-bbcmhcvc.js → chunk-da86fpjt.js} +2 -2
  49. package/bin/chunk-dzjmwat0.js +14 -0
  50. package/bin/{chunk-rza95y4z.js → chunk-eex8sjfs.js} +2 -2
  51. package/bin/{chunk-9zgqjdx1.js → chunk-emgyjhmx.js} +2 -2
  52. package/bin/{chunk-k3prp6c6.js → chunk-exmwerag.js} +5 -5
  53. package/bin/{chunk-kzr6ecke.js → chunk-f38xyahm.js} +1 -1
  54. package/bin/{chunk-ffj9cq9y.js → chunk-fb1bes2h.js} +1 -1
  55. package/bin/chunk-fbvak7q2.js +1 -0
  56. package/bin/{chunk-15w79661.js → chunk-fg9sr6r9.js} +1 -1
  57. package/bin/{chunk-dppfek34.js → chunk-fyb6t7ct.js} +2 -2
  58. package/bin/chunk-g2ptqqm3.js +3 -0
  59. package/bin/{chunk-t1yamxgk.js → chunk-ggwqxn95.js} +1 -1
  60. package/bin/chunk-ghk54h71.js +13 -0
  61. package/bin/{chunk-kvwec0p3.js → chunk-h1fbev9c.js} +2 -2
  62. package/bin/{chunk-f5z3096k.js → chunk-h9akn41s.js} +2 -2
  63. package/bin/{chunk-asy868kq.js → chunk-hdansxny.js} +1 -1
  64. package/bin/{chunk-grjek810.js → chunk-hjwpd09v.js} +2 -2
  65. package/bin/{chunk-zf5cyxnt.js → chunk-hjzbw975.js} +1 -1
  66. package/bin/{chunk-jgfye6nf.js → chunk-j4p3eqtd.js} +1 -1
  67. package/bin/chunk-jtkxeat4.js +2 -0
  68. package/bin/{chunk-8zgq5sav.js → chunk-jw4g9628.js} +3 -3
  69. package/bin/{chunk-0ge2mm8j.js → chunk-jxebakyq.js} +1 -1
  70. package/bin/{chunk-0asthrjf.js → chunk-kfewyax2.js} +2 -2
  71. package/bin/chunk-kk3m4za5.js +1 -0
  72. package/bin/{chunk-vzdgsfkf.js → chunk-m7tnj47b.js} +1 -1
  73. package/bin/{chunk-w73v578p.js → chunk-maw5ah8t.js} +2 -2
  74. package/bin/{chunk-8ny7wvzb.js → chunk-n0wwtjwv.js} +1 -1
  75. package/bin/{chunk-e439kt05.js → chunk-nahdd2t9.js} +1 -1
  76. package/bin/{chunk-04avc4fn.js → chunk-nv7tztvh.js} +32 -32
  77. package/bin/{chunk-mn208vrv.js → chunk-nyjwdxyj.js} +2 -2
  78. package/bin/{chunk-qmrg2jhs.js → chunk-p0yfxt5e.js} +5 -5
  79. package/bin/{chunk-p0j4wpa5.js → chunk-q27qn367.js} +2 -2
  80. package/bin/{chunk-j53sjkxt.js → chunk-q36sdt2w.js} +1 -1
  81. package/bin/{chunk-vm2pz2hm.js → chunk-q7t5zs7n.js} +2 -2
  82. package/bin/{chunk-cpj562n6.js → chunk-qbj5pe8t.js} +1 -1
  83. package/bin/chunk-qj0bxb1m.js +2 -0
  84. package/bin/{chunk-9bakwac0.js → chunk-qk5hsn6e.js} +4 -4
  85. package/bin/{chunk-6rn094yj.js → chunk-qnyqtaf0.js} +1 -1
  86. package/bin/{chunk-ypkkfwfb.js → chunk-qqkr6h07.js} +2 -2
  87. package/bin/chunk-qyqc5j3a.css +1 -0
  88. package/bin/chunk-qzaf6bre.js +2 -0
  89. package/bin/{chunk-cx32wsa1.js → chunk-r1e59gf0.js} +1 -1
  90. package/bin/chunk-ra5csbkr.js +2 -0
  91. package/bin/{chunk-rtaya5wc.js → chunk-rh8dy99a.js} +2 -2
  92. package/bin/{chunk-ryepy5er.js → chunk-rx9g95wk.js} +4 -4
  93. package/bin/{chunk-2w6gve12.js → chunk-rxyy37wa.js} +3 -3
  94. package/bin/{chunk-7qvvf0yd.js → chunk-scez7ppq.js} +2 -2
  95. package/bin/{chunk-twpc640e.js → chunk-t2a1vq34.js} +1 -1
  96. package/bin/chunk-t879v3b7.js +1 -0
  97. package/bin/{chunk-a8bymrv1.js → chunk-tjavzarz.js} +2 -2
  98. package/bin/{chunk-ce0bhc72.js → chunk-treyx8em.js} +1 -1
  99. package/bin/{chunk-dche0gy0.js → chunk-v3z4z04s.js} +1 -1
  100. package/bin/{chunk-5bk16qdp.js → chunk-v3z63tpw.js} +2 -2
  101. package/bin/{chunk-5rzxekn4.js → chunk-v9bes1fv.js} +1 -1
  102. package/bin/{chunk-d5hbzp7t.js → chunk-vjyget8s.js} +1 -1
  103. package/bin/{chunk-4zksqvwj.js → chunk-vmm9m3nv.js} +2 -2
  104. package/bin/chunk-vvr8tnse.js +211 -0
  105. package/bin/{chunk-tvkekn4z.js → chunk-w3stry4v.js} +1 -1
  106. package/bin/{chunk-3pm6q6kg.js → chunk-w89czwjj.js} +1 -1
  107. package/bin/{chunk-rw5h0n0s.js → chunk-wk0hk00z.js} +1 -1
  108. package/bin/{chunk-15vsw36h.js → chunk-ww9qq8yq.js} +5 -5
  109. package/bin/chunk-x4q082e6.js +2 -0
  110. package/bin/{chunk-98mg3dpd.js → chunk-x6rf77jm.js} +4 -4
  111. package/bin/chunk-x7dyj53k.js +2 -0
  112. package/bin/{chunk-y2dhf3p0.js → chunk-xbw7ffrz.js} +2 -2
  113. package/bin/{chunk-5nqvqvqp.js → chunk-xcrd0y8v.js} +3 -3
  114. package/bin/{chunk-0j22699g.js → chunk-z0z0jn5h.js} +2 -2
  115. package/bin/{chunk-w9z27p0m.js → chunk-zasjhrwc.js} +1 -1
  116. package/bin/chunk-zefds5gg.js +1 -0
  117. package/bin/{chunk-8ayz61rc.js → chunk-zzzgk1d5.js} +3 -3
  118. package/bin/shumai-app.html +1 -1
  119. package/bin/shumai-app.js +390 -373
  120. package/package.json +8 -11
  121. package/prisma/migrations/20261014054332_add_embedding_768/migration.sql +8 -0
  122. package/prisma/schema.prisma +10 -8
  123. package/bin/chunk-2gf95tj0.js +0 -1
  124. package/bin/chunk-2tk5w3jc.js +0 -1
  125. package/bin/chunk-301e7g3z.js +0 -2
  126. package/bin/chunk-3kmjbc3m.js +0 -2
  127. package/bin/chunk-3td60k1m.js +0 -2
  128. package/bin/chunk-42hrvk6k.js +0 -211
  129. package/bin/chunk-8abhmarc.js +0 -2
  130. package/bin/chunk-965102pf.js +0 -3
  131. package/bin/chunk-acn3r2m2.js +0 -1
  132. package/bin/chunk-ce75dw3k.css +0 -1
  133. package/bin/chunk-d9qpgkek.js +0 -2
  134. package/bin/chunk-dv6p6n5e.js +0 -1
  135. package/bin/chunk-gnt9gewm.js +0 -2
  136. package/bin/chunk-k97axrc4.js +0 -13
  137. package/bin/chunk-qb178ntp.js +0 -2
  138. package/bin/chunk-s4r6e6ms.js +0 -1
  139. package/bin/chunk-syjjke3f.js +0 -1
  140. package/bin/chunk-tgfxe0sb.js +0 -1
  141. package/bin/chunk-tjretpx8.js +0 -1
  142. package/bin/chunk-w4yjgez6.js +0 -14
  143. package/bin/chunk-wjcebkpb.js +0 -1
  144. package/bin/chunk-ws71fg50.js +0 -2
  145. package/bin/chunk-yfp3q4da.js +0 -1
  146. package/bin/chunk-z8e4wc59.js +0 -1
@@ -1 +1 @@
1
- import{P,m,D,_,u,S,L,t,o,V,Z,B,mt,ze,A,I,O,Pe,on,Et,ro,no,Lo,de,we,Ne,C,ge,Ae,_e,K,Wr,Vt,Ef,km,If,e_,t_,Mf,kf,De,W_,na,fy,hy,fh,ct,Bf,bb,Ob,Ch,jb,Gb,Vb,Qb,Kb,Wb,Da,vi,Hc,Gf,Oa,Cv,Dv,lw,ww,Sw,Uw,jw,qw,Ed,$x,PS,DS,zS,qS,gp,xg,Ap,xE,SE,Rl,OC,$C,Gn,WC,iI,cI,aA,Ua,Qc,Pl,Zp,Bp,Up,Nl,Kc,Wc,zp,jp,Yc,jT,qT,HT,$T,VT,_n,Yp,D1,O1,Jc,MA,H1,$1,G1,V1,Q1,ue,ae,pe,qe,le,z,ce,ut,Dr,yn,Vn,eu,M,vr,dn,W,Me,Le,Ze,Be,Ue,ne,Ei,$t,_r,Ct,lm}from"./chunk-42hrvk6k.js";import{Va}from"./chunk-04avc4fn.js";import{au,Ti}from"./chunk-w4yjgez6.js";import{jo}from"./chunk-w9z27p0m.js";import"./chunk-ffj9cq9y.js";import"./chunk-wnqxyqrg.js";import"./chunk-5bk16qdp.js";import{Ir}from"./chunk-bpxw19ez.js";import{da,Hl}from"./chunk-rza95y4z.js";import{ua}from"./chunk-jgfye6nf.js";import{Ul}from"./chunk-v034sfw8.js";import{zl}from"./chunk-8abhmarc.js";import{nr}from"./chunk-qb178ntp.js";import"./chunk-wwkhskce.js";import{Wl,Yl}from"./chunk-bbcmhcvc.js";import"./chunk-8tzfcqtb.js";import"./chunk-9zgqjdx1.js";import{uo}from"./chunk-qxscgcn9.js";import"./chunk-grjek810.js";import{fo}from"./chunk-fxg81vtx.js";import{Nr}from"./chunk-d2dgazjj.js";S();var kt=[["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=I("folder-open",kt);var St=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],lt=I("list-filter",St);S();function _t({ratio:a}){switch(a){case"16:9":return t("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"});case"9:16":return t("span",{className:"inline-block w-2.5 h-4 border border-current rounded-[1px] shrink-0"});case"4:3":return t("span",{className:"inline-block w-3.5 h-2.5 border border-current rounded-[1px] shrink-0"});case"3:4":return t("span",{className:"inline-block w-2.5 h-3.5 border border-current rounded-[1px] shrink-0"});case"1:1":return t("span",{className:"inline-block w-3 h-3 border border-current rounded-[1px] shrink-0"});default:return t("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"})}}function st(){return Math.random().toString(36).substring(2,9)}function dt(){return{id:st(),type:"text",text:"CONFIDENTIAL",x:0.5,y:0.5,size:0.05,color:"#999999",opacity:0.5,rotation:-30}}function It(){return{id:st(),type:"image",imageAssetKey:"",x:0.5,y:0.5,size:0.15,opacity:0.5,rotation:0}}var rt=[{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"}],Ft={"16:9":1.7777777777777777,"9:16":0.5625,"4:3":1.3333333333333333,"3:4":0.75,"1:1":1};function ft({open:a,onOpenChange:y,initialConfig:h,shareId:f,teamId:N,onSaveSuccess:v}){let q=V(),[d,w]=u([]),[c,x]=u(null),[R,H]=u(null),[k,xe]=u("16:9"),[ve,be]=u("grid"),[Ce,J]=u(!1),[he,ie]=u("new"),[fe,ee]=u(""),[te,re]=u(null),F=_(null),se=_(null),[oe,Ie]=u({w:0,h:0}),[T,G]=u(!1),s=P((e)=>{if(se.current=e,!e)return;let l=()=>{let{clientWidth:E,clientHeight:b}=e;if(E<=0||b<=0)return;let Q=Ft[k],at=E,Re=at/Q;if(Re>b)Re=b,at=Re*Q;Ie({w:Math.round(at),h:Math.round(Re)})};l();let n=new ResizeObserver(l);return n.observe(e),()=>{n.disconnect(),se.current=null}},[k]),X=ut((e)=>e.teamId),ye=N||X,[Qe,je]=u(!1),[Y,Fe]=u({}),me=_(null),ke=A.api.teams[":teamId"].files.$post,Te=async(e,l)=>{let n=e.target.files?.[0];if(!n)return;if(n.size>1048576){if(M.error(Cv()),me.current)me.current.value="";return}if(!ye){M.error(Hc());return}je(!0);let E=URL.createObjectURL(n);Fe((b)=>({...b,[l]:E}));try{let b=await ke({param:{teamId:ye},form:{file:n}});if(!b.ok)throw Error(Hc());let Q=await b.json();j(l,{imageAssetKey:Q.key,imageAssetUrl:Q.url})}catch(b){let Q=b instanceof Error?b.message:Hc();M.error(Q)}finally{if(je(!1),me.current)me.current.value=""}};m(()=>{if(a){if(h?.blocks&&h.blocks.length>0)w(h.blocks),x(h.blocks[0].id);else{let e=dt();w([e]),x(e.id)}H(null)}},[a,h]);let{data:U=[]}=Z({queryKey:["watermark-templates",N],queryFn:async()=>{let e=await A.api["watermark-templates"].$get({query:N?{teamId:N}:{}});if(!e.ok)return[];return await e.json()},enabled:a}),Ee=A.api.shares[":shareId"].watermark.$put,{mutate:Se,isPending:Ve}=B({mutationFn:async(e)=>{let l=await Ee({param:{shareId:f},json:{enabled:!0,config:e}});if(!l.ok){let n=await l.json().catch(()=>null);throw Error(n?.error||vi())}return await l.json()},onSuccess:()=>{q.invalidateQueries({queryKey:["share",f]}),q.invalidateQueries({queryKey:["shares"]}),M.success(Q1()),y(!1),v?.()},onError:(e)=>{M.error(e.message||vi())}}),He=A.api["watermark-templates"].$post,{mutate:Ge,isPending:Xe}=B({mutationFn:async({name:e,config:l})=>{let n=await He({json:{name:e,teamId:N||void 0,config:l}});if(!n.ok)throw Error(vi());return await n.json()},onSuccess:(e)=>{q.invalidateQueries({queryKey:["watermark-templates"]}),H(e.id),J(!1),M.success(HT())},onError:()=>{M.error(vi())}}),Ye=A.api["watermark-templates"][":templateId"].$put,{mutate:We,isPending:Je}=B({mutationFn:async({templateId:e,config:l})=>{let n=await Ye({param:{templateId:e},json:{config:l}});if(!n.ok)throw Error(vi());return await n.json()},onSuccess:()=>{q.invalidateQueries({queryKey:["watermark-templates"]}),J(!1),M.success($T())},onError:()=>{M.error(vi())}}),r=A.api["watermark-templates"][":templateId"].$delete,{mutate:p}=B({mutationFn:async(e)=>{if(!(await r({param:{templateId:e}})).ok)throw Error(Da())},onSuccess:(e,l)=>{if(q.invalidateQueries({queryKey:["watermark-templates"]}),R===l)H(null);M.success(jT())},onError:()=>{M.error(Da())}}),g=d.findIndex((e)=>e.id===c),i=g>=0?d[g]:null,$e=()=>{let e=dt();w((l)=>[...l,e]),x(e.id)},xt=()=>{let e=It();w((l)=>[...l,e]),x(e.id)},nt=(e)=>{if(!e)return;w((l)=>{let n=l.filter((E)=>E.id!==e);if(c===e)x(n.length>0?n[Math.max(0,g-1)].id:null);return n})},j=(e,l)=>{w((n)=>n.map((E)=>E.id===e?{...E,...l}:E))},ht=()=>{if(d.length===0)return;let e=(g-1+d.length)%d.length;x(d[e].id)},vt=()=>{if(d.length===0)return;let e=(g+1)%d.length;x(d[e].id)},wt=(e,l)=>{e.stopPropagation(),x(l),G(!0)},et=P((e)=>{if(!T||!c||!F.current)return;let l=F.current.getBoundingClientRect(),n=(e.clientX-l.left)/l.width,E=(e.clientY-l.top)/l.height,b=Math.max(0,Math.min(1,Math.round(n*100)/100)),Q=Math.max(0,Math.min(1,Math.round(E*100)/100));j(c,{x:b,y:Q})},[T,c]),tt=P(()=>{G(!1)},[]);m(()=>{if(T)window.addEventListener("mousemove",et),window.addEventListener("mouseup",tt);return()=>{window.removeEventListener("mousemove",et),window.removeEventListener("mouseup",tt)}},[T,et,tt]),m(()=>{let e=(l)=>{if(!a||!c)return;let n=l.target?.tagName?.toLowerCase();if(n==="input"||n==="textarea"||n==="select")return;if(l.key==="Delete"||l.key==="Backspace")l.preventDefault(),nt(c)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,c,g]);let bt=(e)=>{if(e.config?.blocks&&e.config.blocks.length>0){let l=e.config.blocks.map((n)=>({...n,id:st()}));w(l),x(l[0].id),H(e.id)}},yt=()=>{if(d.length===0){M.error(DS());return}Se({blocks:d})},Nt=()=>{if(he==="new"){if(!fe.trim()){M.error(Ch());return}Ge({name:fe.trim(),config:{blocks:d}})}else{let e=te||R;if(!e){M.error(aA());return}We({templateId:e,config:{blocks:d}})}};return o(L,{children:[t(ue,{open:a,onOpenChange:y,children:o(ae,{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:[o("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border bg-card",children:[t("div",{className:"flex items-center gap-3",children:t(le,{className:"text-base font-semibold",children:$1()})}),o("div",{className:"flex items-center gap-2",children:[o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:o(C,{variant:"outline",size:"sm",className:"gap-2 text-xs",children:[t(it,{className:"h-4 w-4 text-muted-foreground"}),G1()]})}),o(_e,{align:"end",className:"w-56",children:[t(Wr,{className:"text-xs font-semibold text-muted-foreground",children:qw()}),U.length===0?t("div",{className:"px-2 py-1.5 text-xs text-muted-foreground italic",children:PS()}):U.map((e)=>o(K,{onClick:()=>bt(e),className:"flex items-center justify-between text-xs cursor-pointer",children:[t("span",{className:"truncate flex-1",children:e.name}),R===e.id&&t(Pe,{className:"h-3.5 w-3.5 text-primary ml-2 flex-shrink-0"}),t(C,{variant:"ghost",size:"icon",className:"h-5 w-5 hover:bg-destructive/10 hover:text-destructive ml-1",onClick:(l)=>{l.stopPropagation(),p(e.id)},children:t(we,{className:"h-3 w-3"})})]},e.id)),t(Vt,{}),o(K,{onClick:()=>{ie("new"),ee(""),J(!0)},className:"text-xs gap-2 cursor-pointer",children:[t(de,{className:"h-3.5 w-3.5 text-primary"}),fh()]}),U.length>0&&o(K,{onClick:()=>{ie("overwrite"),re(R||U[0].id),J(!0)},className:"text-xs gap-2 cursor-pointer",children:[t(ua,{className:"h-3.5 w-3.5 text-muted-foreground"}),xg()]})]})]}),t(C,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>y(!1),children:De()}),o(C,{size:"sm",className:"text-xs bg-primary hover:bg-primary/90 text-primary-foreground gap-1.5",disabled:Ve,onClick:yt,children:[t(ua,{className:"h-3.5 w-3.5"}),WC()]})]})]}),o("div",{className:"flex-1 flex overflow-hidden",children:[o("div",{className:"w-[65%] flex flex-col p-4 bg-muted/20 border-r border-border overflow-hidden select-none",children:[o("div",{className:"flex items-center justify-between mb-3",children:[t("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)=>o(C,{variant:k===e?"secondary":"ghost",size:"sm",className:Oe("h-7 px-2.5 text-xs gap-1.5 font-mono transition-all",k===e?"bg-background shadow-xs font-semibold text-foreground border border-border/50":"text-muted-foreground hover:text-foreground"),onClick:()=>xe(e),children:[t(_t,{ratio:e}),t("span",{children:e})]},e))}),t("div",{className:"flex items-center gap-1.5 bg-background border border-border/60 rounded-md p-1",children:rt.map((e)=>t("button",{type:"button",onClick:()=>be(e.id),style:{backgroundColor:e.bg},className:Oe("w-5 h-5 rounded-full border border-border/80 transition-all cursor-pointer relative",ve===e.id?"ring-2 ring-primary ring-offset-1 scale-110":"hover:scale-105 opacity-80 hover:opacity-100"),title:e.label},e.id))})]}),t("div",{ref:s,className:"flex-1 flex items-center justify-center overflow-hidden",children:(()=>{let e=rt.find((n)=>n.id===ve)||rt[0],l=oe.w>0&&oe.h>0;return t("div",{ref:F,onClick:()=>x(null),style:{backgroundColor:e.bg,backgroundImage:`radial-gradient(${e.dot} 1px, transparent 1px)`,backgroundSize:"16px 16px",...l?{width:oe.w,height:oe.h}:{}},className:Oe("relative rounded-lg border border-border overflow-hidden shadow-inner transition-all",k==="16:9"&&"aspect-[16/9] w-full max-h-full",k==="9:16"&&"aspect-[9/16] h-full max-w-full",k==="4:3"&&"aspect-[4/3] w-full max-h-full",k==="3:4"&&"aspect-[3/4] h-full max-w-full",k==="1:1"&&"aspect-square h-full max-w-full"),children:d.map((n)=>{let E=n.id===c,b=n.size*(oe.w||640);return t("div",{onMouseDown:(Q)=>wt(Q,n.id),onClick:(Q)=>{Q.stopPropagation(),x(n.id)},style:{left:`${n.x*100}%`,top:`${n.y*100}%`,transform:`translate(-50%, -50%) rotate(${n.rotation}deg)`,opacity:n.opacity},className:Oe("absolute cursor-move select-none transition-shadow rounded p-1.5 flex items-center justify-center",E?"ring-2 ring-primary ring-offset-2 ring-offset-background/80 bg-primary/10":"hover:ring-1 hover:ring-muted-foreground/50"),children:n.type==="text"?t("span",{style:{fontSize:`${b}px`,color:n.color,lineHeight:1,whiteSpace:"nowrap",fontWeight:700,textShadow:"0 1px 3px rgba(0,0,0,0.5)"},children:n.text||"Text"}):t("div",{style:{width:`${b}px`,height:`${b}px`},className:"bg-primary/20 border border-primary/40 rounded flex items-center justify-center p-1 overflow-hidden",children:Y[n.id]||n.imageAssetUrl?t("img",{src:Y[n.id]||n.imageAssetUrl,alt:"Watermark logo",className:"w-full h-full object-contain pointer-events-none"}):t(ro,{className:"h-1/2 w-1/2 opacity-70 text-primary"})})},n.id)})})})()})]}),o("div",{className:"w-[35%] flex flex-col bg-card overflow-hidden border-l border-border",children:[t("div",{className:"p-4 border-b border-border bg-muted/10 flex items-center justify-between",children:o("div",{className:"flex items-center gap-2",children:[t(no,{className:"h-4 w-4 text-muted-foreground"}),t("span",{className:"text-xs font-semibold",children:MA()})]})}),o("div",{className:"p-3 border-b border-border bg-background flex items-center justify-between gap-2",children:[o("div",{className:"flex items-center gap-1",children:[t(C,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:d.length<=1,onClick:ht,children:t(on,{className:"h-4 w-4"})}),o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:t(C,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs font-mono",children:d.length===0?"0 / 0":`${g+1} / ${d.length}`})}),t(_e,{align:"start",className:"w-48",children:d.map((e,l)=>o(K,{onClick:()=>x(e.id),className:"text-xs flex items-center justify-between cursor-pointer",children:[o("span",{className:"flex items-center gap-2 truncate",children:[e.type==="text"?t(Va,{className:"h-3.5 w-3.5 text-muted-foreground"}):t(ro,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.type==="text"?e.text||"Text":e.imageAssetKey||"Image"]}),o("span",{className:"text-[10px] font-mono text-muted-foreground ml-2",children:["#",l+1]})]},e.id))})]}),t(C,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:d.length<=1,onClick:vt,children:t(Et,{className:"h-4 w-4"})})]}),o("div",{className:"flex items-center gap-1",children:[i&&t(C,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10",title:ct(),onClick:()=>nt(i.id),children:t(we,{className:"h-4 w-4"})}),o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:o(C,{size:"sm",className:"h-7 text-xs gap-1",children:[t(de,{className:"h-3.5 w-3.5"}),Ef()]})}),o(_e,{align:"end",children:[o(K,{onClick:$e,className:"text-xs gap-2 cursor-pointer",children:[t(Va,{className:"h-3.5 w-3.5"}),If()]}),o(K,{onClick:xt,className:"text-xs gap-2 cursor-pointer",children:[t(ro,{className:"h-3.5 w-3.5"}),km()]})]})]})]})]}),t(ce,{className:"flex-1 min-h-0 p-4",children:i?o("div",{className:"space-y-5 text-xs",children:[o("div",{className:"flex items-center justify-between pb-2 border-b border-border",children:[o("span",{className:"font-semibold text-muted-foreground flex items-center gap-1.5",children:[i.type==="text"?t(Va,{className:"h-4 w-4 text-primary"}):t(ro,{className:"h-4 w-4 text-primary"}),i.type==="text"?If():km()]}),o("span",{className:"text-[10px] font-mono text-muted-foreground",children:["ID: ",i.id.slice(0,6)]})]}),i.type==="text"&&o("div",{className:"space-y-2",children:[t(W,{className:"text-xs",children:VT()}),t(z,{type:"text",value:i.text,onChange:(e)=>j(i.id,{text:e.target.value}),className:"text-xs h-8"})]}),i.type==="image"&&o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:ww()}),i.imageAssetKey&&o("button",{type:"button",onClick:()=>j(i.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:[t(Ne,{className:"w-3.5 h-3.5"}),Rl?Rl():"Remove"]})]}),t("input",{type:"file",ref:me,className:"hidden",accept:"image/*",onChange:(e)=>Te(e,i.id)}),o("div",{onClick:()=>me.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:[Qe&&t("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-xs flex flex-col items-center justify-center gap-2 z-20",children:o("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-background border rounded-full shadow-lg",children:[t(O,{className:"w-4 h-4 animate-spin text-primary"}),t("span",{className:"text-xs font-semibold",children:Jc()})]})}),Y[i.id]||i.imageAssetUrl?o(L,{children:[t("img",{src:Y[i.id]||i.imageAssetUrl,alt:"Uploaded logo preview",className:"max-w-full max-h-full object-contain transition-transform duration-300 group-hover:scale-105"}),o("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:[t(uo,{className:"w-5 h-5 transform translate-y-1 group-hover:translate-y-0 transition-transform duration-300"}),t("span",{className:"text-xs font-semibold",children:Yp()})]})]}):o("div",{className:"flex flex-col items-center gap-1.5 text-center p-3",children:[t("div",{className:"p-2 rounded-full bg-background border shadow-xs group-hover:scale-110 transition-transform duration-300",children:t(uo,{className:"w-4 h-4 text-muted-foreground"})}),o("div",{children:[t("p",{className:"text-xs font-medium text-foreground",children:D1()}),t("p",{className:"text-[10px] text-muted-foreground mt-0.5 max-w-[150px] mx-auto leading-normal",children:O1()})]})]})]})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:i.type==="text"?Dv():Sw()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.size*100),"%"]})]}),o("div",{className:"flex items-center gap-3",children:[t(jo,{min:i.type==="text"?0.01:0.02,max:i.type==="text"?0.12:0.5,step:0.005,value:[i.size],onValueChange:([e])=>j(i.id,{size:e}),className:"flex-1"}),t(z,{type:"number",min:1,max:100,value:Math.round(i.size*100),onChange:(e)=>j(i.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"})]})]}),i.type==="text"&&o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:W_()}),t("span",{className:"font-mono text-[11px] text-muted-foreground uppercase",children:i.color})]}),o("div",{className:"flex items-center gap-2",children:[t("input",{type:"color",value:i.color,onChange:(e)=>j(i.id,{color:e.target.value}),className:"w-8 h-8 rounded border border-border cursor-pointer bg-transparent p-0"}),t(z,{type:"text",value:i.color,onChange:(e)=>j(i.id,{color:e.target.value}),className:"flex-1 h-8 text-xs font-mono"})]}),t("div",{className:"flex items-center gap-1.5 pt-1",children:["#FFFFFF","#000000","#999999","#EF4444","#3B82F6","#10B981","#F59E0B"].map((e)=>t("button",{type:"button",onClick:()=>j(i.id,{color:e}),style:{backgroundColor:e},className:"w-5 h-5 rounded-full border border-border hover:scale-110 transition-transform"},e))})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:zS()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.opacity*100),"%"]})]}),t(jo,{min:0,max:1,step:0.01,value:[i.opacity],onValueChange:([e])=>j(i.id,{opacity:e})})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:$C()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[i.rotation,"°"]})]}),t(jo,{min:-180,max:180,step:1,value:[i.rotation],onValueChange:([e])=>j(i.id,{rotation:e})}),t("div",{className:"flex items-center gap-1.5 pt-1",children:[-45,-30,0,30,45].map((e)=>o(C,{variant:"outline",size:"sm",className:"h-6 text-[10px] flex-1 px-1 font-mono",onClick:()=>j(i.id,{rotation:e}),children:[e,"°"]},e))})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:xE()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.x*100),"%"]})]}),t(jo,{min:0,max:1,step:0.01,value:[i.x],onValueChange:([e])=>j(i.id,{x:e})})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:SE()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.y*100),"%"]})]}),t(jo,{min:0,max:1,step:0.01,value:[i.y],onValueChange:([e])=>j(i.id,{y:e})})]})]}):o("div",{className:"py-12 text-center text-xs text-muted-foreground space-y-3",children:[t("p",{children:cI()}),o(C,{size:"sm",variant:"outline",onClick:$e,children:[t(de,{className:"h-3.5 w-3.5 mr-1"}),If()]})]})})]})]})]})}),t(ue,{open:Ce,onOpenChange:J,children:o(ae,{className:"max-w-md",children:[t(pe,{children:t(le,{className:"text-sm font-semibold",children:he==="new"?fh():xg()})}),t("div",{className:"py-3 space-y-4 text-xs",children:he==="new"?o("div",{className:"space-y-2",children:[t(W,{children:qT()}),t(z,{type:"text",value:fe,onChange:(e)=>ee(e.target.value),placeholder:Ch(),className:"text-xs"})]}):o("div",{className:"space-y-2",children:[t(W,{children:aA()}),t("select",{value:te||"",onChange:(e)=>re(e.target.value),className:"w-full h-9 rounded-md border border-input bg-background px-3 text-xs",children:U.map((e)=>t("option",{value:e.id,children:e.name},e.id))})]})}),o(qe,{children:[t(C,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>J(!1),children:De()}),t(C,{size:"sm",className:"text-xs",disabled:Xe||Je,onClick:Nt,children:na()})]})]})})]})}function Oe(...a){return a.filter(Boolean).join(" ")}S();function gt({shareLink:a,viewMode:y,onViewModeChange:h,defaultSortOrder:f,onSortOrderChange:N}){let v=V(),[q,d]=u(a.password||""),[w,c]=u(a.expireAt?new Date(a.expireAt):void 0),[x,R]=u(!1);m(()=>{d(a.password||"")},[a.password]);let[H,k]=u(a.hasPassword),[xe,ve]=u(!!a.expireAt),{data:be,refetch:Ce}=Z({queryKey:["share-watermark",a.id],queryFn:async()=>{let s=await A.api.shares[":shareId"].watermark.$get({param:{shareId:a.id}});if(!s.ok)return null;return await s.json()},refetchInterval:(s)=>(s.state.data?.watermarkStatus||a.watermarkStatus)==="processing"?3000:!1}),J=A.api.shares[":shareId"].watermark.$put,{mutate:he}=B({mutationFn:async()=>{let s=await J({param:{shareId:a.id},json:{enabled:!1}});if(!s.ok)throw Error(vi());return await s.json()},onSuccess:()=>{v.invalidateQueries({queryKey:["shares",a.projectId]}),v.invalidateQueries({queryKey:["share",a.id]}),v.invalidateQueries({queryKey:["share-watermark",a.id]}),M.success(H1())}}),ie=be?.watermarkStatus??a.watermarkStatus??(a.watermarkConfigId?"ready":"disabled"),fe=be?.watermarkConfig?.config??a.watermarkConfig?.config??null,ee=fe!==null&&ie!=="disabled",{data:te}=Z({queryKey:["fields",a.projectId],queryFn:async()=>{let s=await A.api.projects[":projectId"].fields.$get({param:{projectId:a.projectId}});if(!s.ok)throw Error(Gb());return await s.json()},enabled:!!a.projectId}),re=A.api.shares[":shareId"].$put,{mutate:F}=B({mutationFn:async(s)=>{let X=await re({param:{shareId:a.id},json:s});if(!X.ok)throw Error(vi());return await X.json()},onSuccess:()=>{v.invalidateQueries({queryKey:["shares",a.projectId]}),v.invalidateQueries({queryKey:["share",a.id]}),M.success(Ua())}}),se=`${window.location.origin}/share/${a.id}`,oe=async(s)=>{if(await fo(s))M.success(fy())},Ie=(s)=>{let X=a.fieldVisibility||{},ye={...X,[s]:!X[s]};F({fieldVisibility:ye})},T="index",G="asc";if(f){let s=f.split(":");T=s[0],G=s[1]||"asc"}return o("div",{className:"flex flex-col h-full bg-background border-l border-border",children:[t("div",{className:"flex-1 overflow-y-auto",children:o("div",{className:"p-4 space-y-6",children:[o("div",{className:"space-y-4",children:[o("div",{className:"flex items-center justify-between",children:[t("h3",{className:"text-sm font-medium",children:Uw()}),t(Me,{checked:!a.isDisabled,onCheckedChange:(s)=>F({isDisabled:!s})})]}),o("div",{className:"relative w-full",children:[t(z,{value:se,readOnly:!0,className:"pr-10 bg-muted/50 text-xs"}),t(C,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full",onClick:()=>oe(se),children:t(Nr,{className:"h-4 w-4"})})]})]}),o("div",{className:"space-y-1",children:[t(Ke,{title:iI(),icon:t(Yl,{className:"h-4 w-4"}),children:o("div",{className:"p-3 space-y-4 pt-2",children:[o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:Ap()}),t(Me,{checked:H,onCheckedChange:(s)=>{if(k(s),!s)F({password:null})}})]}),H&&o("div",{className:"flex gap-2 animate-in fade-in slide-in-from-top-1 duration-200",children:[t(z,{type:"text",value:q,onChange:(s)=>d(s.target.value),placeholder:Ob(),className:"text-xs"}),t(C,{size:"sm",onClick:()=>F({password:q}),children:Gn()})]})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:jb()}),t(Me,{checked:xe,onCheckedChange:(s)=>{if(ve(s),!s)c(void 0),F({expireAt:null})}})]}),xe&&t("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:t(Ei,{value:w,onChange:(s)=>{c(s),F({expireAt:s?s.toISOString():null})},className:"text-xs"})})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:e_()}),t(Me,{checked:a.allowDownload,onCheckedChange:(s)=>F({allowDownload:s})})]}),t("p",{className:"text-xs text-muted-foreground",children:t_()})]}),o("div",{className:"space-y-2 pt-2 border-t border-border/50",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:MA()}),t(Me,{checked:ee,disabled:ie==="processing",onCheckedChange:(s)=>{if(!s)he();else R(!0)}})]}),ee&&ie==="processing"&&o("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 font-medium py-1 animate-pulse",children:[t(O,{className:"h-3.5 w-3.5 animate-spin"}),t("span",{children:V1()})]}),ee&&ie!=="processing"&&t(C,{variant:"outline",size:"sm",className:"w-full text-xs gap-1.5 mt-1",onClick:()=>R(!0),children:bb()})]})]})}),t(Ke,{title:Mf(),icon:t(Wl,{className:"h-4 w-4"}),children:o("div",{className:"p-3 space-y-3 pt-2 flex gap-2",children:[o(C,{variant:y==="card"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>h("card"),children:[t(no,{className:"h-4 w-4"}),lw()]}),o(C,{variant:y==="list"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>h("list"),children:[t(Lo,{className:"h-4 w-4"}),jw()]})]})}),t(Ke,{title:Oa(),icon:t(lt,{className:"h-4 w-4"}),children:t("div",{className:"p-3 space-y-3 pt-2",children:te?.map((s)=>o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:s.config?.name}),t(Me,{checked:a.fieldVisibility?.[s.id]??!1,onCheckedChange:()=>Ie(s.id)})]},s.id))})}),t(Ke,{title:Pl(),icon:t(zl,{className:"h-4 w-4"}),children:o("div",{className:"p-3 space-y-4 pt-2",children:[o("div",{className:"space-y-2",children:[t(W,{className:"text-xs text-muted-foreground",children:Gf()}),o(Le,{value:T,onValueChange:(s)=>{if(s==="index")N(null);else N(`${s}:${G}`)},children:[t(Be,{className:"w-full text-xs h-9",children:t(Ze,{})}),o(Ue,{children:[t(ne,{value:"index",children:Zp()}),t(ne,{value:"name",children:Nl()}),t(ne,{value:"createdAt",children:Bp()}),t(ne,{value:"size",children:zp()})]})]})]}),o("div",{className:"space-y-2",children:[t(W,{className:"text-xs text-muted-foreground",children:gp()}),o(C,{variant:"outline",className:"w-full justify-between font-normal text-xs h-9",disabled:T==="index",onClick:()=>{N(`${T}:${G==="asc"?"desc":"asc"}`)},children:[t("span",{children:T==="name"?G==="asc"?Qc():Yc():T==="createdAt"?G==="asc"?Wc():Kc():T==="size"?G==="asc"?jp():Up():G==="asc"?kf():Bf()}),t(au,{className:"h-4 w-4 opacity-50"})]})]})]})})]})]})}),o("div",{className:"p-4 border-t border-border space-y-2",children:[o(C,{variant:"outline",className:"w-full justify-center",onClick:()=>window.open(se,"_blank"),children:[t(Ul,{className:"h-4 w-4 mr-2"}),qS()]}),o(C,{className:"w-full justify-center bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>oe(se),children:[t(Nr,{className:"h-4 w-4 mr-2"}),hy()]})]}),t(ft,{open:x,onOpenChange:R,initialConfig:fe,shareId:a.id,onSaveSuccess:()=>{Ce(),v.invalidateQueries({queryKey:["share",a.id]}),v.invalidateQueries({queryKey:["shares",a.projectId]})}})]})}function Ke({title:a,icon:y,children:h}){let[f,N]=u(!1);return o("div",{className:"border-b border-border last:border-0",children:[o("button",{onClick:()=>N(!f),className:"w-full flex items-center justify-between py-3 px-2 hover:bg-muted/50 transition-colors",children:[o("div",{className:"flex items-center gap-3",children:[y,t("span",{className:"text-sm font-medium",children:a})]}),t(Et,{className:Dt("h-4 w-4 transition-transform",f&&"rotate-90")})]}),f&&h&&t("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:h})]})}function Dt(...a){return a.filter(Boolean).join(" ")}function ot({teamId:a,projectId:y,projectName:h,shareId:f,rootFolderId:N}){let v=V(),{fetchMetadata:q}=_r();m(()=>{if(a)q(a)},[a,q]);let{data:d}=Z({queryKey:["share",f],queryFn:async()=>{let r=await A.api.shares[":shareId"].$get({param:{shareId:f}});if(!r.ok)throw Error(Kb());return await r.json()}}),w=d?.rootFolderId,[c,x]=u(null),[R,H]=u([]);m(()=>{if(w)x(w),H([]),U(new Set)},[w,f]);let k=dn((r)=>r.setProjectState),xe=dn((r)=>r.clearProjectState),ve=(r)=>{if(r===c)return;if(r===w)x(w),H([]);else{let p=R.findIndex((g)=>g.id===r);if(p!==-1)x(r),H(R.slice(p+1))}U(new Set)},[be,Ce]=u(240),[J,he]=u(360),{shareConfigLeftSidebarCollapsed:ie,shareConfigRightSidebarCollapsed:fe}=$t(),ee=d?.defaultSortOrder||null,te,re;if(ee){let r=ee.split(":");te=r[0],re=r[1]}let F=d?.viewMode??"card",{data:se,fetchNextPage:oe,hasNextPage:Ie,isFetchingNextPage:T,isLoading:G}=mt({queryKey:["folder-children",a,c,"folder",te,re],queryFn:async({pageParam:r})=>{let p=await A.api.folders[":folderId"].children.$get({param:{folderId:c},query:{assetType:"folder",after:r,sort:te,order:re}});if(!p.ok)throw Error(Qb());return await p.json()},enabled:!!c,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),{data:s,fetchNextPage:X,hasNextPage:ye,isFetchingNextPage:Qe,isLoading:je}=mt({queryKey:["folder-children",a,c,"file",te,re],queryFn:async({pageParam:r})=>{let p=await A.api.folders[":folderId"].children.$get({param:{folderId:c},query:{assetType:"file",after:r,sort:te,order:re}});if(!p.ok)throw Error(Vb());return await p.json()},enabled:!!c,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),Y=D(()=>se?.pages.flatMap((r)=>r.data??[])??[],[se]),Fe=D(()=>s?.pages.flatMap((r)=>r.data??[])??[],[s]);m(()=>{if(d)k({teamId:a,projectId:y,projectName:h,ancestorFolders:R,currentAsset:{name:c===w?d.name:Y.find((r)=>r.id===c)?.name||d.name,type:"folder"},isRootFolder:!1,shareId:f,onFolderClick:ve});return()=>xe()},[a,y,h,R,c,w,d,f,Y,k,xe]);let[me,ke]=u(null),[Te,U]=u(new Set),Ee=()=>{U(new Set),ke(null)},{dragState:Se,handleDragStart:Ve,handleDragEnd:He}=Hl({teamId:a,projectId:y,assetId:c||"",folders:Y,files:Fe,selectedIds:Te,onClearSelection:Ee}),Ge=A.api.shares[":shareId"].assets[":assetId"].$delete,{mutate:Xe}=B({mutationFn:async(r)=>{if(!(await Ge({param:{shareId:f,assetId:r}})).ok)throw Error(Wb())},onSuccess:()=>{v.invalidateQueries({queryKey:["folder-children",a,c]}),M.success(OC())}}),Ye=A.api.shares[":shareId"].$put,{mutate:We}=B({mutationFn:async(r)=>{let p=await Ye({param:{shareId:f},json:r});if(!p.ok)throw Error(vi());return await p.json()},onSuccess:()=>{v.invalidateQueries({queryKey:["share",f]}),M.success(Ua())}}),Je=(r)=>{if(r.type==="folder"||r.targetType==="folder"){let p=c===w?d?.name||"":Y.find((g)=>g.id===c)?.name||_n();H((g)=>[{id:c,name:p},...g]),x(r.id),U(new Set)}};if(!d)return t("div",{children:Ed()});return o(Vn,{modifiers:[da.configure({anchor:{x:0,y:0}})],sensors:[yn.configure({activationConstraints:[new Dr.Distance({value:10})]})],onDragStart:Ve,onDragEnd:He,children:[t("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:o("div",{className:"flex flex-1 overflow-hidden relative",children:[!ie&&o(L,{children:[t("div",{className:"bg-background",style:{width:be},children:t(vr,{teamId:a,projectId:y,projectName:h,rootFolderId:N,dragState:Se})}),t(Ir,{onResize:(r)=>Ce((p)=>Math.max(180,Math.min(400,p+r)))})]}),t(Ti,{teamId:a,projectId:y,assetId:c||"",folders:Y,files:Fe,selectedItem:me,selectedIds:Te,onItemSelect:(r,p)=>{if(p.metaKey||p.ctrlKey){let g=new Set(Te);if(g.has(r.id)){if(g.delete(r.id),U(g),me?.id===r.id){let i=[...Y,...Fe].find(($e)=>g.has($e.id));ke(i||null)}}else g.add(r.id),U(g),ke(r)}else U(new Set([r.id])),ke(r)},onItemDoubleClick:Je,onSaveField:()=>{},displayStyle:F,onClearSelection:Ee,fetchNextFoldersPage:oe,hasNextFoldersPage:Ie,isFetchingNextFoldersPage:T,fetchNextFilesPage:X,hasNextFilesPage:ye,isFetchingNextFilesPage:Qe,isLoading:G||je,filterConditions:[],onFilterChange:()=>{},dragState:Se,isShareView:!0,onRemoveFromShare:(r)=>{r.forEach((p)=>Xe(p.id))},fieldVisibility:d.fieldVisibility}),!fe&&o(L,{children:[t(Ir,{onResize:(r)=>he((p)=>Math.max(240,Math.min(600,p-r)))}),t("div",{style:{width:J},className:"flex-shrink-0 h-full",children:t(gt,{shareLink:d,viewMode:F,onViewModeChange:(r)=>We({viewMode:r}),defaultSortOrder:ee,onSortOrderChange:(r)=>We({defaultSortOrder:r})})})]})]})}),t(eu,{children:Se?.isActive?t("div",{className:"flex items-center gap-2 rounded-md bg-popover px-3 py-2 text-sm font-medium shadow-md",children:$x({count:Se.itemCount})}):null})]})}S();function Mt(){let{projectId:a,shareId:y}=Tt.useParams(),{teamId:h,ensureTeamIdForProject:f}=ut();m(()=>{f(a)},[a,f]);let{data:N}=nr(lm(a)),v=N?.rootFolder,{data:q}=Z({queryKey:["folders",v],queryFn:async()=>{let d=await A.api.folders[":folderId"].$get({param:{folderId:v}});if(!d.ok)throw Error("Failed to fetch folder");return await d.json()},enabled:!!v});if(!h||!v||!q)return t(Ct,{});return t(ot,{teamId:h,projectId:a,projectName:N.name??"",shareId:y,rootFolderId:v})}var Tt=ze("/projects/$projectId/shares/$shareId")({component:Mt});export{Tt as Route};
1
+ import{P,m,D,_,u,S,L,t,o,G,Z,B,mt,Ue,A,I,O,Re,nn,Et,ro,no,Lo,fe,we,Pe,C,ge,Ae,_e,K,Wr,Vt,Cf,Nm,Tf,t_,r_,kf,Rf,Ne,Y_,na,py,gy,hh,ct,Uf,vb,Fb,Mh,qb,Vb,Qb,Kb,Wb,Yb,Oa,wi,Gc,Vf,Fa,Iv,Ov,cw,xw,Ew,zw,qw,Hw,Ed,$x,PS,DS,zS,qS,Ap,Eg,_p,xE,SE,Dl,OC,$C,Gn,WC,iI,cI,cA,za,Wc,Ol,Bp,Up,zp,Fl,Yc,Jc,jp,qp,Xc,zT,jT,qT,HT,GT,An,Jp,N1,D1,eu,RA,q1,H1,$1,G1,V1,de,le,me,qe,ce,z,ue,ut,Dr,_n,Vn,ru,M,vr,un,W,Me,Fe,Le,Ze,Be,ne,Ci,$t,_r,Ct,dm}from"./chunk-vvr8tnse.js";import{Wa}from"./chunk-nv7tztvh.js";import{cu,Mi}from"./chunk-dzjmwat0.js";import{jo}from"./chunk-zasjhrwc.js";import"./chunk-fb1bes2h.js";import"./chunk-bf5m8f6t.js";import"./chunk-v3z63tpw.js";import{Ir}from"./chunk-4yhvexzk.js";import{da,Vl}from"./chunk-eex8sjfs.js";import{ua}from"./chunk-j4p3eqtd.js";import{ql}from"./chunk-3020am4q.js";import{Hl}from"./chunk-cf57fk11.js";import{tr}from"./chunk-ra5csbkr.js";import"./chunk-3tg10kwz.js";import{Xl,ec}from"./chunk-da86fpjt.js";import"./chunk-5m51b7af.js";import"./chunk-emgyjhmx.js";import{uo}from"./chunk-01ym2agz.js";import"./chunk-hjwpd09v.js";import{fo}from"./chunk-fxg81vtx.js";import{Nr}from"./chunk-8s9fehda.js";S();var kt=[["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=I("folder-open",kt);var St=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],lt=I("list-filter",St);S();function _t({ratio:a}){switch(a){case"16:9":return t("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"});case"9:16":return t("span",{className:"inline-block w-2.5 h-4 border border-current rounded-[1px] shrink-0"});case"4:3":return t("span",{className:"inline-block w-3.5 h-2.5 border border-current rounded-[1px] shrink-0"});case"3:4":return t("span",{className:"inline-block w-2.5 h-3.5 border border-current rounded-[1px] shrink-0"});case"1:1":return t("span",{className:"inline-block w-3 h-3 border border-current rounded-[1px] shrink-0"});default:return t("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"})}}function st(){return Math.random().toString(36).substring(2,9)}function dt(){return{id:st(),type:"text",text:"CONFIDENTIAL",x:0.5,y:0.5,size:0.05,color:"#999999",opacity:0.5,rotation:-30}}function It(){return{id:st(),type:"image",imageAssetKey:"",x:0.5,y:0.5,size:0.15,opacity:0.5,rotation:0}}var rt=[{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"}],Ft={"16:9":1.7777777777777777,"9:16":0.5625,"4:3":1.3333333333333333,"3:4":0.75,"1:1":1};function ft({open:a,onOpenChange:y,initialConfig:h,shareId:f,teamId:N,onSaveSuccess:v}){let q=G(),[d,w]=u([]),[c,x]=u(null),[R,V]=u(null),[k,xe]=u("16:9"),[ve,be]=u("grid"),[Ce,J]=u(!1),[he,oe]=u("new"),[pe,ee]=u(""),[te,ae]=u(null),F=_(null),re=_(null),[se,Ie]=u({w:0,h:0}),[T,H]=u(!1),s=P((e)=>{if(re.current=e,!e)return;let l=()=>{let{clientWidth:E,clientHeight:b}=e;if(E<=0||b<=0)return;let Q=Ft[k],at=E,$e=at/Q;if($e>b)$e=b,at=$e*Q;Ie({w:Math.round(at),h:Math.round($e)})};l();let n=new ResizeObserver(l);return n.observe(e),()=>{n.disconnect(),re.current=null}},[k]),X=ut((e)=>e.teamId),ye=N||X,[Qe,je]=u(!1),[Y,De]=u({}),ie=_(null),ke=A.api.teams[":teamId"].files.$post,Te=async(e,l)=>{let n=e.target.files?.[0];if(!n)return;if(n.size>1048576){if(M.error(Iv()),ie.current)ie.current.value="";return}if(!ye){M.error(Gc());return}je(!0);let E=URL.createObjectURL(n);De((b)=>({...b,[l]:E}));try{let b=await ke({param:{teamId:ye},form:{file:n}});if(!b.ok)throw Error(Gc());let Q=await b.json();j(l,{imageAssetKey:Q.key,imageAssetUrl:Q.url})}catch(b){let Q=b instanceof Error?b.message:Gc();M.error(Q)}finally{if(je(!1),ie.current)ie.current.value=""}};m(()=>{if(a){if(h?.blocks&&h.blocks.length>0)w(h.blocks),x(h.blocks[0].id);else{let e=dt();w([e]),x(e.id)}V(null)}},[a,h]);let{data:U=[]}=Z({queryKey:["watermark-templates",N],queryFn:async()=>{let e=await A.api["watermark-templates"].$get({query:N?{teamId:N}:{}});if(!e.ok)return[];return await e.json()},enabled:a}),Ee=A.api.shares[":shareId"].watermark.$put,{mutate:Se,isPending:Ve}=B({mutationFn:async(e)=>{let l=await Ee({param:{shareId:f},json:{enabled:!0,config:e}});if(!l.ok){let n=await l.json().catch(()=>null);throw Error(n?.error||wi())}return await l.json()},onSuccess:()=>{q.invalidateQueries({queryKey:["share",f]}),q.invalidateQueries({queryKey:["shares"]}),M.success(V1()),y(!1),v?.()},onError:(e)=>{M.error(e.message||wi())}}),He=A.api["watermark-templates"].$post,{mutate:Ge,isPending:Xe}=B({mutationFn:async({name:e,config:l})=>{let n=await He({json:{name:e,teamId:N||void 0,config:l}});if(!n.ok)throw Error(wi());return await n.json()},onSuccess:(e)=>{q.invalidateQueries({queryKey:["watermark-templates"]}),V(e.id),J(!1),M.success(qT())},onError:()=>{M.error(wi())}}),Ye=A.api["watermark-templates"][":templateId"].$put,{mutate:ze,isPending:Je}=B({mutationFn:async({templateId:e,config:l})=>{let n=await Ye({param:{templateId:e},json:{config:l}});if(!n.ok)throw Error(wi());return await n.json()},onSuccess:()=>{q.invalidateQueries({queryKey:["watermark-templates"]}),J(!1),M.success(HT())},onError:()=>{M.error(wi())}}),r=A.api["watermark-templates"][":templateId"].$delete,{mutate:p}=B({mutationFn:async(e)=>{if(!(await r({param:{templateId:e}})).ok)throw Error(Oa())},onSuccess:(e,l)=>{if(q.invalidateQueries({queryKey:["watermark-templates"]}),R===l)V(null);M.success(zT())},onError:()=>{M.error(Oa())}}),g=d.findIndex((e)=>e.id===c),i=g>=0?d[g]:null,We=()=>{let e=dt();w((l)=>[...l,e]),x(e.id)},xt=()=>{let e=It();w((l)=>[...l,e]),x(e.id)},nt=(e)=>{if(!e)return;w((l)=>{let n=l.filter((E)=>E.id!==e);if(c===e)x(n.length>0?n[Math.max(0,g-1)].id:null);return n})},j=(e,l)=>{w((n)=>n.map((E)=>E.id===e?{...E,...l}:E))},ht=()=>{if(d.length===0)return;let e=(g-1+d.length)%d.length;x(d[e].id)},vt=()=>{if(d.length===0)return;let e=(g+1)%d.length;x(d[e].id)},wt=(e,l)=>{e.stopPropagation(),x(l),H(!0)},et=P((e)=>{if(!T||!c||!F.current)return;let l=F.current.getBoundingClientRect(),n=(e.clientX-l.left)/l.width,E=(e.clientY-l.top)/l.height,b=Math.max(0,Math.min(1,Math.round(n*100)/100)),Q=Math.max(0,Math.min(1,Math.round(E*100)/100));j(c,{x:b,y:Q})},[T,c]),tt=P(()=>{H(!1)},[]);m(()=>{if(T)window.addEventListener("mousemove",et),window.addEventListener("mouseup",tt);return()=>{window.removeEventListener("mousemove",et),window.removeEventListener("mouseup",tt)}},[T,et,tt]),m(()=>{let e=(l)=>{if(!a||!c)return;let n=l.target?.tagName?.toLowerCase();if(n==="input"||n==="textarea"||n==="select")return;if(l.key==="Delete"||l.key==="Backspace")l.preventDefault(),nt(c)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,c,g]);let bt=(e)=>{if(e.config?.blocks&&e.config.blocks.length>0){let l=e.config.blocks.map((n)=>({...n,id:st()}));w(l),x(l[0].id),V(e.id)}},yt=()=>{if(d.length===0){M.error(DS());return}Se({blocks:d})},Nt=()=>{if(he==="new"){if(!pe.trim()){M.error(Mh());return}Ge({name:pe.trim(),config:{blocks:d}})}else{let e=te||R;if(!e){M.error(cA());return}ze({templateId:e,config:{blocks:d}})}};return o(L,{children:[t(de,{open:a,onOpenChange:y,children:o(le,{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:[o("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border bg-card",children:[t("div",{className:"flex items-center gap-3",children:t(ce,{className:"text-base font-semibold",children:H1()})}),o("div",{className:"flex items-center gap-2",children:[o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:o(C,{variant:"outline",size:"sm",className:"gap-2 text-xs",children:[t(it,{className:"h-4 w-4 text-muted-foreground"}),$1()]})}),o(_e,{align:"end",className:"w-56",children:[t(Wr,{className:"text-xs font-semibold text-muted-foreground",children:Hw()}),U.length===0?t("div",{className:"px-2 py-1.5 text-xs text-muted-foreground italic",children:PS()}):U.map((e)=>o(K,{onClick:()=>bt(e),className:"flex items-center justify-between text-xs cursor-pointer",children:[t("span",{className:"truncate flex-1",children:e.name}),R===e.id&&t(Re,{className:"h-3.5 w-3.5 text-primary ml-2 flex-shrink-0"}),t(C,{variant:"ghost",size:"icon",className:"h-5 w-5 hover:bg-destructive/10 hover:text-destructive ml-1",onClick:(l)=>{l.stopPropagation(),p(e.id)},children:t(we,{className:"h-3 w-3"})})]},e.id)),t(Vt,{}),o(K,{onClick:()=>{oe("new"),ee(""),J(!0)},className:"text-xs gap-2 cursor-pointer",children:[t(fe,{className:"h-3.5 w-3.5 text-primary"}),hh()]}),U.length>0&&o(K,{onClick:()=>{oe("overwrite"),ae(R||U[0].id),J(!0)},className:"text-xs gap-2 cursor-pointer",children:[t(ua,{className:"h-3.5 w-3.5 text-muted-foreground"}),Eg()]})]})]}),t(C,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>y(!1),children:Ne()}),o(C,{size:"sm",className:"text-xs bg-primary hover:bg-primary/90 text-primary-foreground gap-1.5",disabled:Ve,onClick:yt,children:[t(ua,{className:"h-3.5 w-3.5"}),WC()]})]})]}),o("div",{className:"flex-1 flex overflow-hidden",children:[o("div",{className:"w-[65%] flex flex-col p-4 bg-muted/20 border-r border-border overflow-hidden select-none",children:[o("div",{className:"flex items-center justify-between mb-3",children:[t("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)=>o(C,{variant:k===e?"secondary":"ghost",size:"sm",className:Oe("h-7 px-2.5 text-xs gap-1.5 font-mono transition-all",k===e?"bg-background shadow-xs font-semibold text-foreground border border-border/50":"text-muted-foreground hover:text-foreground"),onClick:()=>xe(e),children:[t(_t,{ratio:e}),t("span",{children:e})]},e))}),t("div",{className:"flex items-center gap-1.5 bg-background border border-border/60 rounded-md p-1",children:rt.map((e)=>t("button",{type:"button",onClick:()=>be(e.id),style:{backgroundColor:e.bg},className:Oe("w-5 h-5 rounded-full border border-border/80 transition-all cursor-pointer relative",ve===e.id?"ring-2 ring-primary ring-offset-1 scale-110":"hover:scale-105 opacity-80 hover:opacity-100"),title:e.label},e.id))})]}),t("div",{ref:s,className:"flex-1 flex items-center justify-center overflow-hidden",children:(()=>{let e=rt.find((n)=>n.id===ve)||rt[0],l=se.w>0&&se.h>0;return t("div",{ref:F,onClick:()=>x(null),style:{backgroundColor:e.bg,backgroundImage:`radial-gradient(${e.dot} 1px, transparent 1px)`,backgroundSize:"16px 16px",...l?{width:se.w,height:se.h}:{}},className:Oe("relative rounded-lg border border-border overflow-hidden shadow-inner transition-all",k==="16:9"&&"aspect-[16/9] w-full max-h-full",k==="9:16"&&"aspect-[9/16] h-full max-w-full",k==="4:3"&&"aspect-[4/3] w-full max-h-full",k==="3:4"&&"aspect-[3/4] h-full max-w-full",k==="1:1"&&"aspect-square h-full max-w-full"),children:d.map((n)=>{let E=n.id===c,b=n.size*(se.w||640);return t("div",{onMouseDown:(Q)=>wt(Q,n.id),onClick:(Q)=>{Q.stopPropagation(),x(n.id)},style:{left:`${n.x*100}%`,top:`${n.y*100}%`,transform:`translate(-50%, -50%) rotate(${n.rotation}deg)`,opacity:n.opacity},className:Oe("absolute cursor-move select-none transition-shadow rounded p-1.5 flex items-center justify-center",E?"ring-2 ring-primary ring-offset-2 ring-offset-background/80 bg-primary/10":"hover:ring-1 hover:ring-muted-foreground/50"),children:n.type==="text"?t("span",{style:{fontSize:`${b}px`,color:n.color,lineHeight:1,whiteSpace:"nowrap",fontWeight:700,textShadow:"0 1px 3px rgba(0,0,0,0.5)"},children:n.text||"Text"}):t("div",{style:{width:`${b}px`,height:`${b}px`},className:"bg-primary/20 border border-primary/40 rounded flex items-center justify-center p-1 overflow-hidden",children:Y[n.id]||n.imageAssetUrl?t("img",{src:Y[n.id]||n.imageAssetUrl,alt:"Watermark logo",className:"w-full h-full object-contain pointer-events-none"}):t(ro,{className:"h-1/2 w-1/2 opacity-70 text-primary"})})},n.id)})})})()})]}),o("div",{className:"w-[35%] flex flex-col bg-card overflow-hidden border-l border-border",children:[t("div",{className:"p-4 border-b border-border bg-muted/10 flex items-center justify-between",children:o("div",{className:"flex items-center gap-2",children:[t(no,{className:"h-4 w-4 text-muted-foreground"}),t("span",{className:"text-xs font-semibold",children:RA()})]})}),o("div",{className:"p-3 border-b border-border bg-background flex items-center justify-between gap-2",children:[o("div",{className:"flex items-center gap-1",children:[t(C,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:d.length<=1,onClick:ht,children:t(nn,{className:"h-4 w-4"})}),o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:t(C,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs font-mono",children:d.length===0?"0 / 0":`${g+1} / ${d.length}`})}),t(_e,{align:"start",className:"w-48",children:d.map((e,l)=>o(K,{onClick:()=>x(e.id),className:"text-xs flex items-center justify-between cursor-pointer",children:[o("span",{className:"flex items-center gap-2 truncate",children:[e.type==="text"?t(Wa,{className:"h-3.5 w-3.5 text-muted-foreground"}):t(ro,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.type==="text"?e.text||"Text":e.imageAssetKey||"Image"]}),o("span",{className:"text-[10px] font-mono text-muted-foreground ml-2",children:["#",l+1]})]},e.id))})]}),t(C,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:d.length<=1,onClick:vt,children:t(Et,{className:"h-4 w-4"})})]}),o("div",{className:"flex items-center gap-1",children:[i&&t(C,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10",title:ct(),onClick:()=>nt(i.id),children:t(we,{className:"h-4 w-4"})}),o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:o(C,{size:"sm",className:"h-7 text-xs gap-1",children:[t(fe,{className:"h-3.5 w-3.5"}),Cf()]})}),o(_e,{align:"end",children:[o(K,{onClick:We,className:"text-xs gap-2 cursor-pointer",children:[t(Wa,{className:"h-3.5 w-3.5"}),Tf()]}),o(K,{onClick:xt,className:"text-xs gap-2 cursor-pointer",children:[t(ro,{className:"h-3.5 w-3.5"}),Nm()]})]})]})]})]}),t(ue,{className:"flex-1 min-h-0 p-4",children:i?o("div",{className:"space-y-5 text-xs",children:[o("div",{className:"flex items-center justify-between pb-2 border-b border-border",children:[o("span",{className:"font-semibold text-muted-foreground flex items-center gap-1.5",children:[i.type==="text"?t(Wa,{className:"h-4 w-4 text-primary"}):t(ro,{className:"h-4 w-4 text-primary"}),i.type==="text"?Tf():Nm()]}),o("span",{className:"text-[10px] font-mono text-muted-foreground",children:["ID: ",i.id.slice(0,6)]})]}),i.type==="text"&&o("div",{className:"space-y-2",children:[t(W,{className:"text-xs",children:GT()}),t(z,{type:"text",value:i.text,onChange:(e)=>j(i.id,{text:e.target.value}),className:"text-xs h-8"})]}),i.type==="image"&&o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:xw()}),i.imageAssetKey&&o("button",{type:"button",onClick:()=>j(i.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:[t(Pe,{className:"w-3.5 h-3.5"}),Dl?Dl():"Remove"]})]}),t("input",{type:"file",ref:ie,className:"hidden",accept:"image/*",onChange:(e)=>Te(e,i.id)}),o("div",{onClick:()=>ie.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:[Qe&&t("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-xs flex flex-col items-center justify-center gap-2 z-20",children:o("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-background border rounded-full shadow-lg",children:[t(O,{className:"w-4 h-4 animate-spin text-primary"}),t("span",{className:"text-xs font-semibold",children:eu()})]})}),Y[i.id]||i.imageAssetUrl?o(L,{children:[t("img",{src:Y[i.id]||i.imageAssetUrl,alt:"Uploaded logo preview",className:"max-w-full max-h-full object-contain transition-transform duration-300 group-hover:scale-105"}),o("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:[t(uo,{className:"w-5 h-5 transform translate-y-1 group-hover:translate-y-0 transition-transform duration-300"}),t("span",{className:"text-xs font-semibold",children:Jp()})]})]}):o("div",{className:"flex flex-col items-center gap-1.5 text-center p-3",children:[t("div",{className:"p-2 rounded-full bg-background border shadow-xs group-hover:scale-110 transition-transform duration-300",children:t(uo,{className:"w-4 h-4 text-muted-foreground"})}),o("div",{children:[t("p",{className:"text-xs font-medium text-foreground",children:N1()}),t("p",{className:"text-[10px] text-muted-foreground mt-0.5 max-w-[150px] mx-auto leading-normal",children:D1()})]})]})]})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:i.type==="text"?Ov():Ew()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.size*100),"%"]})]}),o("div",{className:"flex items-center gap-3",children:[t(jo,{min:i.type==="text"?0.01:0.02,max:i.type==="text"?0.12:0.5,step:0.005,value:[i.size],onValueChange:([e])=>j(i.id,{size:e}),className:"flex-1"}),t(z,{type:"number",min:1,max:100,value:Math.round(i.size*100),onChange:(e)=>j(i.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"})]})]}),i.type==="text"&&o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:Y_()}),t("span",{className:"font-mono text-[11px] text-muted-foreground uppercase",children:i.color})]}),o("div",{className:"flex items-center gap-2",children:[t("input",{type:"color",value:i.color,onChange:(e)=>j(i.id,{color:e.target.value}),className:"w-8 h-8 rounded border border-border cursor-pointer bg-transparent p-0"}),t(z,{type:"text",value:i.color,onChange:(e)=>j(i.id,{color:e.target.value}),className:"flex-1 h-8 text-xs font-mono"})]}),t("div",{className:"flex items-center gap-1.5 pt-1",children:["#FFFFFF","#000000","#999999","#EF4444","#3B82F6","#10B981","#F59E0B"].map((e)=>t("button",{type:"button",onClick:()=>j(i.id,{color:e}),style:{backgroundColor:e},className:"w-5 h-5 rounded-full border border-border hover:scale-110 transition-transform"},e))})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:zS()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.opacity*100),"%"]})]}),t(jo,{min:0,max:1,step:0.01,value:[i.opacity],onValueChange:([e])=>j(i.id,{opacity:e})})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:$C()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[i.rotation,"°"]})]}),t(jo,{min:-180,max:180,step:1,value:[i.rotation],onValueChange:([e])=>j(i.id,{rotation:e})}),t("div",{className:"flex items-center gap-1.5 pt-1",children:[-45,-30,0,30,45].map((e)=>o(C,{variant:"outline",size:"sm",className:"h-6 text-[10px] flex-1 px-1 font-mono",onClick:()=>j(i.id,{rotation:e}),children:[e,"°"]},e))})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:xE()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.x*100),"%"]})]}),t(jo,{min:0,max:1,step:0.01,value:[i.x],onValueChange:([e])=>j(i.id,{x:e})})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:SE()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.y*100),"%"]})]}),t(jo,{min:0,max:1,step:0.01,value:[i.y],onValueChange:([e])=>j(i.id,{y:e})})]})]}):o("div",{className:"py-12 text-center text-xs text-muted-foreground space-y-3",children:[t("p",{children:cI()}),o(C,{size:"sm",variant:"outline",onClick:We,children:[t(fe,{className:"h-3.5 w-3.5 mr-1"}),Tf()]})]})})]})]})]})}),t(de,{open:Ce,onOpenChange:J,children:o(le,{className:"max-w-md",children:[t(me,{children:t(ce,{className:"text-sm font-semibold",children:he==="new"?hh():Eg()})}),t("div",{className:"py-3 space-y-4 text-xs",children:he==="new"?o("div",{className:"space-y-2",children:[t(W,{children:jT()}),t(z,{type:"text",value:pe,onChange:(e)=>ee(e.target.value),placeholder:Mh(),className:"text-xs"})]}):o("div",{className:"space-y-2",children:[t(W,{children:cA()}),t("select",{value:te||"",onChange:(e)=>ae(e.target.value),className:"w-full h-9 rounded-md border border-input bg-background px-3 text-xs",children:U.map((e)=>t("option",{value:e.id,children:e.name},e.id))})]})}),o(qe,{children:[t(C,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>J(!1),children:Ne()}),t(C,{size:"sm",className:"text-xs",disabled:Xe||Je,onClick:Nt,children:na()})]})]})})]})}function Oe(...a){return a.filter(Boolean).join(" ")}S();function gt({shareLink:a,viewMode:y,onViewModeChange:h,defaultSortOrder:f,onSortOrderChange:N}){let v=G(),[q,d]=u(a.password||""),[w,c]=u(a.expireAt?new Date(a.expireAt):void 0),[x,R]=u(!1);m(()=>{d(a.password||"")},[a.password]);let[V,k]=u(a.hasPassword),[xe,ve]=u(!!a.expireAt),{data:be,refetch:Ce}=Z({queryKey:["share-watermark",a.id],queryFn:async()=>{let s=await A.api.shares[":shareId"].watermark.$get({param:{shareId:a.id}});if(!s.ok)return null;return await s.json()},refetchInterval:(s)=>(s.state.data?.watermarkStatus||a.watermarkStatus)==="processing"?3000:!1}),J=A.api.shares[":shareId"].watermark.$put,{mutate:he}=B({mutationFn:async()=>{let s=await J({param:{shareId:a.id},json:{enabled:!1}});if(!s.ok)throw Error(wi());return await s.json()},onSuccess:()=>{v.invalidateQueries({queryKey:["shares",a.projectId]}),v.invalidateQueries({queryKey:["share",a.id]}),v.invalidateQueries({queryKey:["share-watermark",a.id]}),M.success(q1())}}),oe=be?.watermarkStatus??a.watermarkStatus??(a.watermarkConfigId?"ready":"disabled"),pe=be?.watermarkConfig?.config??a.watermarkConfig?.config??null,ee=pe!==null&&oe!=="disabled",{data:te}=Z({queryKey:["fields",a.projectId],queryFn:async()=>{let s=await A.api.projects[":projectId"].fields.$get({param:{projectId:a.projectId}});if(!s.ok)throw Error(Vb());return await s.json()},enabled:!!a.projectId}),ae=A.api.shares[":shareId"].$put,{mutate:F}=B({mutationFn:async(s)=>{let X=await ae({param:{shareId:a.id},json:s});if(!X.ok)throw Error(wi());return await X.json()},onSuccess:()=>{v.invalidateQueries({queryKey:["shares",a.projectId]}),v.invalidateQueries({queryKey:["share",a.id]}),M.success(za())}}),re=`${window.location.origin}/share/${a.id}`,se=async(s)=>{if(await fo(s))M.success(py())},Ie=(s)=>{let X=a.fieldVisibility||{},ye={...X,[s]:!X[s]};F({fieldVisibility:ye})},T="index",H="asc";if(f){let s=f.split(":");T=s[0],H=s[1]||"asc"}return o("div",{className:"flex flex-col h-full bg-background border-l border-border",children:[t("div",{className:"flex-1 overflow-y-auto",children:o("div",{className:"p-4 space-y-6",children:[o("div",{className:"space-y-4",children:[o("div",{className:"flex items-center justify-between",children:[t("h3",{className:"text-sm font-medium",children:zw()}),t(Me,{checked:!a.isDisabled,onCheckedChange:(s)=>F({isDisabled:!s})})]}),o("div",{className:"relative w-full",children:[t(z,{value:re,readOnly:!0,className:"pr-10 bg-muted/50 text-xs"}),t(C,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full",onClick:()=>se(re),children:t(Nr,{className:"h-4 w-4"})})]})]}),o("div",{className:"space-y-1",children:[t(Ke,{title:iI(),icon:t(ec,{className:"h-4 w-4"}),children:o("div",{className:"p-3 space-y-4 pt-2",children:[o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:_p()}),t(Me,{checked:V,onCheckedChange:(s)=>{if(k(s),!s)F({password:null})}})]}),V&&o("div",{className:"flex gap-2 animate-in fade-in slide-in-from-top-1 duration-200",children:[t(z,{type:"text",value:q,onChange:(s)=>d(s.target.value),placeholder:Fb(),className:"text-xs"}),t(C,{size:"sm",onClick:()=>F({password:q}),children:Gn()})]})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:qb()}),t(Me,{checked:xe,onCheckedChange:(s)=>{if(ve(s),!s)c(void 0),F({expireAt:null})}})]}),xe&&t("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:t(Ci,{value:w,onChange:(s)=>{c(s),F({expireAt:s?s.toISOString():null})},className:"text-xs"})})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:t_()}),t(Me,{checked:a.allowDownload,onCheckedChange:(s)=>F({allowDownload:s})})]}),t("p",{className:"text-xs text-muted-foreground",children:r_()})]}),o("div",{className:"space-y-2 pt-2 border-t border-border/50",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:RA()}),t(Me,{checked:ee,disabled:oe==="processing",onCheckedChange:(s)=>{if(!s)he();else R(!0)}})]}),ee&&oe==="processing"&&o("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 font-medium py-1 animate-pulse",children:[t(O,{className:"h-3.5 w-3.5 animate-spin"}),t("span",{children:G1()})]}),ee&&oe!=="processing"&&t(C,{variant:"outline",size:"sm",className:"w-full text-xs gap-1.5 mt-1",onClick:()=>R(!0),children:vb()})]})]})}),t(Ke,{title:kf(),icon:t(Xl,{className:"h-4 w-4"}),children:o("div",{className:"p-3 space-y-3 pt-2 flex gap-2",children:[o(C,{variant:y==="card"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>h("card"),children:[t(no,{className:"h-4 w-4"}),cw()]}),o(C,{variant:y==="list"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>h("list"),children:[t(Lo,{className:"h-4 w-4"}),qw()]})]})}),t(Ke,{title:Fa(),icon:t(lt,{className:"h-4 w-4"}),children:t("div",{className:"p-3 space-y-3 pt-2",children:te?.map((s)=>o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:s.config?.name}),t(Me,{checked:a.fieldVisibility?.[s.id]??!1,onCheckedChange:()=>Ie(s.id)})]},s.id))})}),t(Ke,{title:Ol(),icon:t(Hl,{className:"h-4 w-4"}),children:o("div",{className:"p-3 space-y-4 pt-2",children:[o("div",{className:"space-y-2",children:[t(W,{className:"text-xs text-muted-foreground",children:Vf()}),o(Fe,{value:T,onValueChange:(s)=>{if(s==="index")N(null);else N(`${s}:${H}`)},children:[t(Ze,{className:"w-full text-xs h-9",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"index",children:Bp()}),t(ne,{value:"name",children:Fl()}),t(ne,{value:"createdAt",children:Up()}),t(ne,{value:"size",children:jp()})]})]})]}),o("div",{className:"space-y-2",children:[t(W,{className:"text-xs text-muted-foreground",children:Ap()}),o(C,{variant:"outline",className:"w-full justify-between font-normal text-xs h-9",disabled:T==="index",onClick:()=>{N(`${T}:${H==="asc"?"desc":"asc"}`)},children:[t("span",{children:T==="name"?H==="asc"?Wc():Xc():T==="createdAt"?H==="asc"?Jc():Yc():T==="size"?H==="asc"?qp():zp():H==="asc"?Rf():Uf()}),t(cu,{className:"h-4 w-4 opacity-50"})]})]})]})})]})]})}),o("div",{className:"p-4 border-t border-border space-y-2",children:[o(C,{variant:"outline",className:"w-full justify-center",onClick:()=>window.open(re,"_blank"),children:[t(ql,{className:"h-4 w-4 mr-2"}),qS()]}),o(C,{className:"w-full justify-center bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>se(re),children:[t(Nr,{className:"h-4 w-4 mr-2"}),gy()]})]}),t(ft,{open:x,onOpenChange:R,initialConfig:pe,shareId:a.id,onSaveSuccess:()=>{Ce(),v.invalidateQueries({queryKey:["share",a.id]}),v.invalidateQueries({queryKey:["shares",a.projectId]})}})]})}function Ke({title:a,icon:y,children:h}){let[f,N]=u(!1);return o("div",{className:"border-b border-border last:border-0",children:[o("button",{onClick:()=>N(!f),className:"w-full flex items-center justify-between py-3 px-2 hover:bg-muted/50 transition-colors",children:[o("div",{className:"flex items-center gap-3",children:[y,t("span",{className:"text-sm font-medium",children:a})]}),t(Et,{className:Dt("h-4 w-4 transition-transform",f&&"rotate-90")})]}),f&&h&&t("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:h})]})}function Dt(...a){return a.filter(Boolean).join(" ")}function ot({teamId:a,projectId:y,projectName:h,shareId:f,rootFolderId:N}){let v=G(),{fetchMetadata:q}=_r();m(()=>{if(a)q(a)},[a,q]);let{data:d}=Z({queryKey:["share",f],queryFn:async()=>{let r=await A.api.shares[":shareId"].$get({param:{shareId:f}});if(!r.ok)throw Error(Wb());return await r.json()}}),w=d?.rootFolderId,[c,x]=u(null),[R,V]=u([]);m(()=>{if(w)x(w),V([]),U(new Set)},[w,f]);let k=un((r)=>r.setProjectState),xe=un((r)=>r.clearProjectState),ve=(r)=>{if(r===c)return;if(r===w)x(w),V([]);else{let p=R.findIndex((g)=>g.id===r);if(p!==-1)x(r),V(R.slice(p+1))}U(new Set)},[be,Ce]=u(240),[J,he]=u(360),{shareConfigLeftSidebarCollapsed:oe,shareConfigRightSidebarCollapsed:pe}=$t(),ee=d?.defaultSortOrder||null,te,ae;if(ee){let r=ee.split(":");te=r[0],ae=r[1]}let F=d?.viewMode??"card",{data:re,fetchNextPage:se,hasNextPage:Ie,isFetchingNextPage:T,isLoading:H}=mt({queryKey:["folder-children",a,c,"folder",te,ae],queryFn:async({pageParam:r})=>{let p=await A.api.folders[":folderId"].children.$get({param:{folderId:c},query:{assetType:"folder",after:r,sort:te,order:ae}});if(!p.ok)throw Error(Kb());return await p.json()},enabled:!!c,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),{data:s,fetchNextPage:X,hasNextPage:ye,isFetchingNextPage:Qe,isLoading:je}=mt({queryKey:["folder-children",a,c,"file",te,ae],queryFn:async({pageParam:r})=>{let p=await A.api.folders[":folderId"].children.$get({param:{folderId:c},query:{assetType:"file",after:r,sort:te,order:ae}});if(!p.ok)throw Error(Qb());return await p.json()},enabled:!!c,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),Y=D(()=>re?.pages.flatMap((r)=>r.data??[])??[],[re]),De=D(()=>s?.pages.flatMap((r)=>r.data??[])??[],[s]);m(()=>{if(d)k({teamId:a,projectId:y,projectName:h,ancestorFolders:R,currentAsset:{name:c===w?d.name:Y.find((r)=>r.id===c)?.name||d.name,type:"folder"},isRootFolder:!1,shareId:f,onFolderClick:ve});return()=>xe()},[a,y,h,R,c,w,d,f,Y,k,xe]);let[ie,ke]=u(null),[Te,U]=u(new Set),Ee=()=>{U(new Set),ke(null)},{dragState:Se,handleDragStart:Ve,handleDragEnd:He}=Vl({teamId:a,projectId:y,assetId:c||"",folders:Y,files:De,selectedIds:Te,onClearSelection:Ee}),Ge=A.api.shares[":shareId"].assets[":assetId"].$delete,{mutate:Xe}=B({mutationFn:async(r)=>{if(!(await Ge({param:{shareId:f,assetId:r}})).ok)throw Error(Yb())},onSuccess:()=>{v.invalidateQueries({queryKey:["folder-children",a,c]}),M.success(OC())}}),Ye=A.api.shares[":shareId"].$put,{mutate:ze}=B({mutationFn:async(r)=>{let p=await Ye({param:{shareId:f},json:r});if(!p.ok)throw Error(wi());return await p.json()},onSuccess:()=>{v.invalidateQueries({queryKey:["share",f]}),M.success(za())}}),Je=(r)=>{if(r.type==="folder"||r.targetType==="folder"){let p=c===w?d?.name||"":Y.find((g)=>g.id===c)?.name||An();V((g)=>[{id:c,name:p},...g]),x(r.id),U(new Set)}};if(!d)return t("div",{children:Ed()});return o(Vn,{modifiers:[da.configure({anchor:{x:0,y:0}})],sensors:[_n.configure({activationConstraints:[new Dr.Distance({value:10})]})],onDragStart:Ve,onDragEnd:He,children:[t("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:o("div",{className:"flex flex-1 overflow-hidden relative",children:[!oe&&o(L,{children:[t("div",{className:"bg-background",style:{width:be},children:t(vr,{teamId:a,projectId:y,projectName:h,rootFolderId:N,dragState:Se})}),t(Ir,{onResize:(r)=>Ce((p)=>Math.max(180,Math.min(400,p+r)))})]}),t(Mi,{teamId:a,projectId:y,assetId:c||"",folders:Y,files:De,selectedItem:ie,selectedIds:Te,onItemSelect:(r,p)=>{if(p.metaKey||p.ctrlKey){let g=new Set(Te);if(g.has(r.id)){if(g.delete(r.id),U(g),ie?.id===r.id){let i=[...Y,...De].find((We)=>g.has(We.id));ke(i||null)}}else g.add(r.id),U(g),ke(r)}else U(new Set([r.id])),ke(r)},onItemDoubleClick:Je,onSaveField:()=>{},displayStyle:F,onClearSelection:Ee,fetchNextFoldersPage:se,hasNextFoldersPage:Ie,isFetchingNextFoldersPage:T,fetchNextFilesPage:X,hasNextFilesPage:ye,isFetchingNextFilesPage:Qe,isLoading:H||je,filterConditions:[],onFilterChange:()=>{},dragState:Se,isShareView:!0,onRemoveFromShare:(r)=>{r.forEach((p)=>Xe(p.id))},fieldVisibility:d.fieldVisibility}),!pe&&o(L,{children:[t(Ir,{onResize:(r)=>he((p)=>Math.max(240,Math.min(600,p-r)))}),t("div",{style:{width:J},className:"flex-shrink-0 h-full",children:t(gt,{shareLink:d,viewMode:F,onViewModeChange:(r)=>ze({viewMode:r}),defaultSortOrder:ee,onSortOrderChange:(r)=>ze({defaultSortOrder:r})})})]})]})}),t(ru,{children:Se?.isActive?t("div",{className:"flex items-center gap-2 rounded-md bg-popover px-3 py-2 text-sm font-medium shadow-md",children:$x({count:Se.itemCount})}):null})]})}S();function Mt(){let{projectId:a,shareId:y}=Tt.useParams(),{teamId:h,ensureTeamIdForProject:f}=ut();m(()=>{f(a)},[a,f]);let{data:N}=tr(dm(a)),v=N?.rootFolder,{data:q}=Z({queryKey:["folders",v],queryFn:async()=>{let d=await A.api.folders[":folderId"].$get({param:{folderId:v}});if(!d.ok)throw Error("Failed to fetch folder");return await d.json()},enabled:!!v});if(!h||!v||!q)return t(Ct,{});return t(ot,{teamId:h,projectId:a,projectName:N.name??"",shareId:y,rootFolderId:v})}var Tt=Ue("/projects/$projectId/shares/$shareId")({component:Mt});export{Tt as Route};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{tl,rl}from"./chunk-7qvvf0yd.js";import{w}from"./chunk-a8bymrv1.js";var j=w(function(v,f){var{defineProperty:i,getOwnPropertyDescriptor:s,getOwnPropertyNames:_}=Object,k=Object.prototype.hasOwnProperty,l=(t,e)=>{for(var o in e)i(t,o,{get:e[o],enumerable:!0})},u=(t,e,o,n)=>{if(e&&typeof e==="object"||typeof e==="function"){for(let r of _(e))if(!k.call(t,r)&&r!==o)i(t,r,{get:()=>e[r],enumerable:!(n=s(e,r))||n.enumerable})}return t},d=(t)=>u(i({},"__esModule",{value:!0}),t),p={};l(p,{refreshToken:()=>O});f.exports=d(p);var c=tl(),a=rl();async function O(t){let e=t?.project,o=t?.team;if(!e&&!o){let r=(0,a.findProjectInfo)();e=r.projectId,o=r.teamId}else if(!e||!o){let r=(0,a.findProjectInfo)();e=e??r.projectId,o=o??r.teamId}if(!e)throw new c.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let n=(0,a.loadToken)(e);if(!n||(0,a.isExpired)((0,a.getTokenPayload)(n.token),t?.expirationBufferMs)){let r=await(0,a.getVercelToken)({expirationBufferMs:t?.expirationBufferMs});if(n=await(0,a.getVercelOidcToken)(r,e,o),!n)throw new c.VercelOidcTokenError("Failed to refresh OIDC token");(0,a.saveToken)(n,e)}process.env.VERCEL_OIDC_TOKEN=n.token;return}});export default j();
2
+ import{ol,sl}from"./chunk-scez7ppq.js";import{w}from"./chunk-tjavzarz.js";var j=w(function(v,f){var{defineProperty:i,getOwnPropertyDescriptor:s,getOwnPropertyNames:_}=Object,k=Object.prototype.hasOwnProperty,l=(t,e)=>{for(var o in e)i(t,o,{get:e[o],enumerable:!0})},u=(t,e,o,n)=>{if(e&&typeof e==="object"||typeof e==="function"){for(let r of _(e))if(!k.call(t,r)&&r!==o)i(t,r,{get:()=>e[r],enumerable:!(n=s(e,r))||n.enumerable})}return t},d=(t)=>u(i({},"__esModule",{value:!0}),t),p={};l(p,{refreshToken:()=>O});f.exports=d(p);var c=ol(),a=sl();async function O(t){let e=t?.project,o=t?.team;if(!e&&!o){let r=(0,a.findProjectInfo)();e=r.projectId,o=r.teamId}else if(!e||!o){let r=(0,a.findProjectInfo)();e=e??r.projectId,o=o??r.teamId}if(!e)throw new c.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let n=(0,a.loadToken)(e);if(!n||(0,a.isExpired)((0,a.getTokenPayload)(n.token),t?.expirationBufferMs)){let r=await(0,a.getVercelToken)({expirationBufferMs:t?.expirationBufferMs});if(n=await(0,a.getVercelOidcToken)(r,e,o),!n)throw new c.VercelOidcTokenError("Failed to refresh OIDC token");(0,a.saveToken)(n,e)}process.env.VERCEL_OIDC_TOKEN=n.token;return}});export default j();
@@ -1 +1 @@
1
- import{m,D,u,S,L,t,o,mt,Re,ze,A,O,ta,jn,no,Ce,Ie,Te,Y0,Q_,Lf,zc,hS,_n,ut,Nt,vr,$t,Ct,am}from"./chunk-42hrvk6k.js";import{Ir}from"./chunk-bpxw19ez.js";import{nr}from"./chunk-qb178ntp.js";import{Pn,Nn,Dn,xr,It,xt}from"./chunk-t1yamxgk.js";S();var k=(a)=>{if(!a)return"??";return a.split(" ").map((r)=>r[0]).slice(0,2).join("").toUpperCase()};function T(){let{projectId:a}=j.useParams(),{teamId:r,ensureTeamIdForProject:n}=ut(),v=Re();m(()=>{n(a)},[a,n]);let{data:i}=nr(am(a)),d=i?.rootFolder,[N,h]=u(240),{fileListLeftSidebarCollapsed:c,setFileListLeftSidebarCollapsed:y}=$t(),{data:f,isLoading:w,fetchNextPage:p,hasNextPage:b,isFetchingNextPage:l}=mt({queryKey:["collections",a],queryFn:async({pageParam:e})=>{let s=await A.api.projects[":projectId"].collections.$get({param:{projectId:a},query:{first:"20",after:e}});if(!s.ok)throw Error("Failed to fetch collections");return await s.json()},initialPageParam:"",getNextPageParam:(e)=>e.pageInfo?.cursor||void 0,enabled:!!a}),{ref:I,inView:x}=Nt();m(()=>{if(x&&b&&!l)p()},[x,b,l,p]);let g=D(()=>f?.pages.flatMap((e)=>e.data)||[],[f]);if(!r||!d||!i)return t(Ct,{});return t("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:o("div",{className:"flex flex-1 overflow-hidden relative",children:[!c&&t("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>y(!0)}),!c&&o(L,{children:[t("div",{className:"bg-background",style:{width:N},children:t(vr,{teamId:r,projectId:a,projectName:i.name??"",rootFolderId:d})}),t(Ir,{onResize:(e)=>{h((s)=>Math.max(180,Math.min(400,s+e)))},className:"hidden md:block"})]}),o("div",{className:"flex-1 flex flex-col min-h-0 bg-card overflow-hidden",children:[t("header",{className:"h-14 border-b flex items-center justify-between px-6 shrink-0 bg-background/50 backdrop-blur-sm sticky top-0 z-10",children:o("div",{className:"flex items-center gap-2",children:[t(ta,{className:"h-5 w-5 text-primary"}),t("h1",{className:"font-bold text-lg text-foreground",children:Y0()})]})}),t("div",{className:"flex-1 overflow-y-auto p-6",children:w?t("div",{className:"flex justify-center items-center h-64",children:t("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):g.length===0?o("div",{className:"flex flex-col items-center justify-center h-64 text-muted-foreground gap-3",children:[t(no,{className:"h-10 w-10 text-muted-foreground/50"}),t("p",{children:hS()})]}):o("div",{className:"border border-border rounded-xl bg-background overflow-hidden shadow-xs",children:[o(Pn,{children:[t(Nn,{children:o(xr,{className:"hover:bg-transparent bg-muted/20",children:[t(It,{className:"font-semibold px-4 py-3",children:Q_()}),t(It,{className:"font-semibold px-4 py-3",children:zc()}),t(It,{className:"font-semibold px-4 py-3 w-[200px]",children:Lf()})]})}),t(Dn,{children:g.map((e)=>o(xr,{className:"hover:bg-muted/10 transition-colors cursor-pointer",onClick:()=>v({to:"/projects/$projectId/collections/$collectionId",params:{projectId:a,collectionId:e.id}}),children:[t(xt,{className:"font-medium px-4 py-3.5",children:o("div",{className:"flex items-center gap-2",children:[t(ta,{className:"h-4 w-4 text-primary shrink-0"}),t("span",{className:"text-foreground font-semibold hover:underline",children:e.name})]})}),t(xt,{className:"px-4 py-3.5",children:o("div",{className:"flex items-center gap-2",children:[o(Ce,{className:"h-6 w-6",children:[e.creator?.image&&t(Ie,{src:e.creator.image,alt:e.creator.name,className:"object-cover"}),t(Te,{className:"text-[10px]",children:k(e.creator?.name)})]}),t("span",{className:"text-sm font-medium text-foreground truncate max-w-[200px]",children:e.creator?.name||_n()})]})}),t(xt,{className:"px-4 py-3.5 text-muted-foreground text-sm",children:o("div",{className:"flex items-center gap-2",children:[t(jn,{className:"h-3.5 w-3.5 text-muted-foreground/70"}),t("span",{children:new Date(e.createdAt).toLocaleDateString()})]})})]},e.id))})]}),t("div",{ref:I,className:"h-10 w-full flex items-center justify-center",children:l&&t(O,{className:"h-6 w-6 animate-spin text-primary"})})]})})]})]})})}var j=ze("/projects/$projectId/collections/")({component:T});export{j as Route};
1
+ import{m,D,u,S,L,t,o,mt,ke,Ue,A,O,ta,jn,no,Ce,Ie,Te,J0,K_,Zf,qc,hS,An,ut,Nt,vr,$t,Ct,um}from"./chunk-vvr8tnse.js";import{Ir}from"./chunk-4yhvexzk.js";import{tr}from"./chunk-ra5csbkr.js";import{Pn,Nn,Dn,xr,It,xt}from"./chunk-ggwqxn95.js";S();var k=(a)=>{if(!a)return"??";return a.split(" ").map((r)=>r[0]).slice(0,2).join("").toUpperCase()};function T(){let{projectId:a}=j.useParams(),{teamId:r,ensureTeamIdForProject:n}=ut(),v=ke();m(()=>{n(a)},[a,n]);let{data:i}=tr(um(a)),d=i?.rootFolder,[N,h]=u(240),{fileListLeftSidebarCollapsed:c,setFileListLeftSidebarCollapsed:y}=$t(),{data:f,isLoading:w,fetchNextPage:p,hasNextPage:b,isFetchingNextPage:l}=mt({queryKey:["collections",a],queryFn:async({pageParam:e})=>{let s=await A.api.projects[":projectId"].collections.$get({param:{projectId:a},query:{first:"20",after:e}});if(!s.ok)throw Error("Failed to fetch collections");return await s.json()},initialPageParam:"",getNextPageParam:(e)=>e.pageInfo?.cursor||void 0,enabled:!!a}),{ref:I,inView:x}=Nt();m(()=>{if(x&&b&&!l)p()},[x,b,l,p]);let g=D(()=>f?.pages.flatMap((e)=>e.data)||[],[f]);if(!r||!d||!i)return t(Ct,{});return t("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:o("div",{className:"flex flex-1 overflow-hidden relative",children:[!c&&t("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>y(!0)}),!c&&o(L,{children:[t("div",{className:"bg-background",style:{width:N},children:t(vr,{teamId:r,projectId:a,projectName:i.name??"",rootFolderId:d})}),t(Ir,{onResize:(e)=>{h((s)=>Math.max(180,Math.min(400,s+e)))},className:"hidden md:block"})]}),o("div",{className:"flex-1 flex flex-col min-h-0 bg-card overflow-hidden",children:[t("header",{className:"h-14 border-b flex items-center justify-between px-6 shrink-0 bg-background/50 backdrop-blur-sm sticky top-0 z-10",children:o("div",{className:"flex items-center gap-2",children:[t(ta,{className:"h-5 w-5 text-primary"}),t("h1",{className:"font-bold text-lg text-foreground",children:J0()})]})}),t("div",{className:"flex-1 overflow-y-auto p-6",children:w?t("div",{className:"flex justify-center items-center h-64",children:t("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):g.length===0?o("div",{className:"flex flex-col items-center justify-center h-64 text-muted-foreground gap-3",children:[t(no,{className:"h-10 w-10 text-muted-foreground/50"}),t("p",{children:hS()})]}):o("div",{className:"border border-border rounded-xl bg-background overflow-hidden shadow-xs",children:[o(Pn,{children:[t(Nn,{children:o(xr,{className:"hover:bg-transparent bg-muted/20",children:[t(It,{className:"font-semibold px-4 py-3",children:K_()}),t(It,{className:"font-semibold px-4 py-3",children:qc()}),t(It,{className:"font-semibold px-4 py-3 w-[200px]",children:Zf()})]})}),t(Dn,{children:g.map((e)=>o(xr,{className:"hover:bg-muted/10 transition-colors cursor-pointer",onClick:()=>v({to:"/projects/$projectId/collections/$collectionId",params:{projectId:a,collectionId:e.id}}),children:[t(xt,{className:"font-medium px-4 py-3.5",children:o("div",{className:"flex items-center gap-2",children:[t(ta,{className:"h-4 w-4 text-primary shrink-0"}),t("span",{className:"text-foreground font-semibold hover:underline",children:e.name})]})}),t(xt,{className:"px-4 py-3.5",children:o("div",{className:"flex items-center gap-2",children:[o(Ce,{className:"h-6 w-6",children:[e.creator?.image&&t(Ie,{src:e.creator.image,alt:e.creator.name,className:"object-cover"}),t(Te,{className:"text-[10px]",children:k(e.creator?.name)})]}),t("span",{className:"text-sm font-medium text-foreground truncate max-w-[200px]",children:e.creator?.name||An()})]})}),t(xt,{className:"px-4 py-3.5 text-muted-foreground text-sm",children:o("div",{className:"flex items-center gap-2",children:[t(jn,{className:"h-3.5 w-3.5 text-muted-foreground/70"}),t("span",{children:new Date(e.createdAt).toLocaleDateString()})]})})]},e.id))})]}),t("div",{ref:I,className:"h-10 w-full flex items-center justify-center",children:l&&t(O,{className:"h-6 w-6 animate-spin text-primary"})})]})})]})]})})}var j=Ue("/projects/$projectId/collections/")({component:T});export{j as Route};
@@ -1,12 +1,12 @@
1
1
  // @bun
2
- import{Xr}from"./chunk-8zgq5sav.js";import{Ts}from"./chunk-y2dhf3p0.js";import{He,dc,fc,po,Xa,mo}from"./chunk-dppfek34.js";import{hn}from"./chunk-ae6zgjhd.js";function v(i,o){let a={v:1,id:i};if(o)a.phase=o;return JSON.stringify(a)}function C(i){if(!i)return;if(i.startsWith("{"))try{let o=JSON.parse(i);if(o.v===1&&typeof o.id==="string"){if(o.phase==="commentary"||o.phase==="final_answer")return{id:o.id,phase:o.phase};return{id:o.id}}}catch{}return{id:i}}function J(i,o){let a=o.filter((l)=>l.type==="text").map((l)=>l.text).join(`
3
- `),u=o.filter((l)=>l.type==="image"),p=a.length>0;if(u.length===0||!i.input.includes("image"))return He(p?a:u.length>0?"(see attached image)":"(no tool output)");let f=[];if(p)f.push({type:"input_text",text:He(a)});for(let l of u)f.push({type:"input_image",detail:"auto",image_url:`data:${l.mimeType};base64,${l.data}`});return f}function ti(i,o,a,u){let p=[],f=new Set,l=(r)=>{let c=r.replace(/[^a-zA-Z0-9_-]/g,"_");return(c.length>64?c.slice(0,64):c).replace(/_+$/,"")},y=(r)=>{let c=`fc_${Ts(r)}`;return c.length>64?c.slice(0,64):c},m=(r,c,t)=>{if(!a.has(i.provider))return l(r);if(!r.includes("|"))return l(r);let[e,n]=r.split("|"),s=l(e),g=t.provider!==i.provider||t.api!==i.api?y(n):l(n);if(!g.startsWith("fc_"))g=l(`fc_${g}`);return`${s}|${g}`},h=mo(o.messages,i,m);if((u?.includeSystemPrompt??!0)&&o.systemPrompt){let r=i.compat,c=i.reasoning&&r?.supportsDeveloperRole!==!1?"developer":"system";p.push({role:c,content:He(o.systemPrompt)})}let x=0;for(let r of h){if(r.role==="user")if(typeof r.content==="string")p.push({role:"user",content:[{type:"input_text",text:He(r.content)}]});else{let c=r.content.map((t)=>{if(t.type==="text")return{type:"input_text",text:He(t.text)};return{type:"input_image",detail:"auto",image_url:`data:${t.mimeType};base64,${t.data}`}});if(c.length===0)continue;p.push({role:"user",content:c})}else if(r.role==="assistant"){let c=[],t=r,e=t.model!==i.id&&t.provider===i.provider&&t.api===i.api,n=0;for(let s of r.content)if(s.type==="thinking"){if(s.thinkingSignature){let d=JSON.parse(s.thinkingSignature);c.push(d)}}else if(s.type==="text"){let d=s,g=C(d.textSignature),b=n===0?`msg_pi_${x}`:`msg_pi_${x}_${n}`;n++;let _=g?.id;if(!_)_=b;else if(_.length>64)_=`msg_${Ts(_)}`;c.push({type:"message",role:"assistant",content:[{type:"output_text",text:He(d.text),annotations:[]}],status:"completed",id:_,phase:g?.phase})}else if(s.type==="toolCall"){let d=s,[g,b]=d.id.split("|"),_=u?.grammarToolInputProperties?.get(d.name),k=b;if(e&&k?.startsWith("fc_")||_===void 0&&!k?.startsWith("fc_"))k=void 0;if(_!==void 0)c.push({type:"custom_tool_call",id:k,call_id:g,name:d.name,input:He(dc(d.name,d.arguments,_))});else c.push({type:"function_call",id:k,call_id:g,name:d.name,arguments:JSON.stringify(d.arguments)})}if(c.length===0)continue;p.push(...c)}else if(r.role==="toolResult"){let[c]=r.toolCallId.split("|"),t=J(i,r.content);if(u?.grammarToolInputProperties?.has(r.toolName))p.push({type:"custom_tool_call_output",call_id:c,output:t});else p.push({type:"function_call_output",call_id:c,output:t});let e=[];for(let n of r.addedToolNames??[]){let s=u?.deferredTools?.get(n);if(!s||f.has(n))continue;f.add(n),e.push(s)}if(e.length>0){let n=e.map((d)=>d.name),s=`pi_tool_load_${Ts(`${r.toolCallId}:${n.join(",")}`)}`;p.push({type:"tool_search_call",call_id:s,execution:"client",status:"completed",arguments:{query:n.join(" "),limit:n.length}}),p.push({type:"tool_search_output",call_id:s,execution:"client",status:"completed",tools:ri(e,{...u?.toolOptions,deferLoading:!0})})}}x++}return p}function ri(i,o){let a=o?.strict===void 0?!1:o.strict,u=o?.supportsStrictMode??!0,p=o?.supportsOpenAIGrammarTools??!1;return i.map((f)=>{let l=Xa(f,p);if(l)return{type:"custom",name:f.name,description:f.description,format:{type:"grammar",syntax:l.format,definition:l.definition},...o?.deferLoading?{defer_loading:!0}:{}};let y=po(f,u),m={type:"function",name:f.name,description:f.description,parameters:f.parameters,...o?.deferLoading?{defer_loading:!0}:{}};if(u)m.strict=y??a;return m})}function T(i){let o=i.customInput?.property;if(o===void 0)return"";let a=i.arguments[o];return typeof a==="string"?a:""}function S(i,o,a){let u=i.customInput;if(!u)return;let p=fc(u.jsonBuffer,u.property,o,a);return i.arguments={[u.property]:o},p}async function ni(i,o,a,u,p){let f=!1,l=new Map,y=new Map,m=(t,e)=>{let n=l.get(t);return n?.type===e?n:void 0},h=(t,e)=>{if(e===void 0)return;a.push({type:"toolcall_delta",contentIndex:t.contentIndex,delta:e,partial:o})},I=(t,e)=>{if(e.type==="reasoning"){let n={type:"thinking",thinking:""};o.content.push(n);let s={type:"thinking",block:n,contentIndex:o.content.length-1};return l.set(t,s),a.push({type:"thinking_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="message"){let n={type:"text",text:""};o.content.push(n);let s={type:"text",block:n,contentIndex:o.content.length-1};return l.set(t,s),a.push({type:"text_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="function_call"){let n={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{},partialJson:e.arguments||""};o.content.push(n);let s={type:"toolCall",block:n,contentIndex:o.content.length-1};return l.set(t,s),a.push({type:"toolcall_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="custom_tool_call"){let n=p?.grammarToolInputProperties?.get(e.name)??"input",s=e.input||"",d={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{[n]:s},customInput:{property:n,jsonBuffer:{input:"",started:!1,closed:!1}}};o.content.push(d);let g={type:"toolCall",block:d,contentIndex:o.content.length-1};return l.set(t,g),a.push({type:"toolcall_start",contentIndex:g.contentIndex,partial:o}),g}return},x=(t,e)=>l.get(t)??I(t,e),r=(t)=>{for(let e of t){if(e.type!=="reasoning"||!e.encrypted_content)continue;let n=y.get(e.id);if(!n?.thinkingSignature)continue;let s=JSON.parse(n.thinkingSignature);if(s.encrypted_content)continue;n.thinkingSignature=JSON.stringify({...s,encrypted_content:e.encrypted_content})}},c=(t)=>{if(f=!0,r(t.output??[]),t?.id)o.responseId=t.id;if(t?.usage){let e=t.usage.input_tokens_details,n=e?.cached_tokens||0,s=e?.cache_write_tokens||0;o.usage={input:Math.max(0,(t.usage.input_tokens||0)-n-s),output:t.usage.output_tokens||0,cacheRead:n,cacheWrite:s,reasoning:t.usage.output_tokens_details?.reasoning_tokens||0,totalTokens:t.usage.total_tokens||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}if(hn(u,o.usage),p?.applyServiceTierPricing){let e=p.resolveServiceTier?p.resolveServiceTier(t?.service_tier,p.serviceTier):t?.service_tier??p.serviceTier;p.applyServiceTierPricing(o.usage,e)}if(o.stopReason=w(t?.status),o.content.some((e)=>e.type==="toolCall")&&o.stopReason==="stop")o.stopReason="toolUse"};for await(let t of i)if(t.type==="response.created")o.responseId=t.response.id;else if(t.type==="response.output_item.added")I(t.output_index,t.item);else if(t.type==="response.reasoning_summary_text.delta"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=t.delta,a.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.reasoning_summary_part.done"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=`
2
+ import{Jr}from"./chunk-jw4g9628.js";import{Ms}from"./chunk-xbw7ffrz.js";import{He,mc,hc,po,rl,mo}from"./chunk-fyb6t7ct.js";import{mn}from"./chunk-047n9gfs.js";function v(i,o){let a={v:1,id:i};if(o)a.phase=o;return JSON.stringify(a)}function C(i){if(!i)return;if(i.startsWith("{"))try{let o=JSON.parse(i);if(o.v===1&&typeof o.id==="string"){if(o.phase==="commentary"||o.phase==="final_answer")return{id:o.id,phase:o.phase};return{id:o.id}}}catch{}return{id:i}}function J(i,o){let a=o.filter((l)=>l.type==="text").map((l)=>l.text).join(`
3
+ `),u=o.filter((l)=>l.type==="image"),p=a.length>0;if(u.length===0||!i.input.includes("image"))return He(p?a:u.length>0?"(see attached image)":"(no tool output)");let f=[];if(p)f.push({type:"input_text",text:He(a)});for(let l of u)f.push({type:"input_image",detail:"auto",image_url:`data:${l.mimeType};base64,${l.data}`});return f}function ri(i,o,a,u){let p=[],f=new Set,l=(r)=>{let c=r.replace(/[^a-zA-Z0-9_-]/g,"_");return(c.length>64?c.slice(0,64):c).replace(/_+$/,"")},y=(r)=>{let c=`fc_${Ms(r)}`;return c.length>64?c.slice(0,64):c},m=(r,c,t)=>{if(!a.has(i.provider))return l(r);if(!r.includes("|"))return l(r);let[e,n]=r.split("|"),s=l(e),g=t.provider!==i.provider||t.api!==i.api?y(n):l(n);if(!g.startsWith("fc_"))g=l(`fc_${g}`);return`${s}|${g}`},h=mo(o.messages,i,m);if((u?.includeSystemPrompt??!0)&&o.systemPrompt){let r=i.compat,c=i.reasoning&&r?.supportsDeveloperRole!==!1?"developer":"system";p.push({role:c,content:He(o.systemPrompt)})}let x=0;for(let r of h){if(r.role==="user")if(typeof r.content==="string")p.push({role:"user",content:[{type:"input_text",text:He(r.content)}]});else{let c=r.content.map((t)=>{if(t.type==="text")return{type:"input_text",text:He(t.text)};return{type:"input_image",detail:"auto",image_url:`data:${t.mimeType};base64,${t.data}`}});if(c.length===0)continue;p.push({role:"user",content:c})}else if(r.role==="assistant"){let c=[],t=r,e=t.model!==i.id&&t.provider===i.provider&&t.api===i.api,n=0;for(let s of r.content)if(s.type==="thinking"){if(s.thinkingSignature){let d=JSON.parse(s.thinkingSignature);c.push(d)}}else if(s.type==="text"){let d=s,g=C(d.textSignature),b=n===0?`msg_pi_${x}`:`msg_pi_${x}_${n}`;n++;let _=g?.id;if(!_)_=b;else if(_.length>64)_=`msg_${Ms(_)}`;c.push({type:"message",role:"assistant",content:[{type:"output_text",text:He(d.text),annotations:[]}],status:"completed",id:_,phase:g?.phase})}else if(s.type==="toolCall"){let d=s,[g,b]=d.id.split("|"),_=u?.grammarToolInputProperties?.get(d.name),k=b;if(e&&k?.startsWith("fc_")||_===void 0&&!k?.startsWith("fc_"))k=void 0;if(_!==void 0)c.push({type:"custom_tool_call",id:k,call_id:g,name:d.name,input:He(mc(d.name,d.arguments,_))});else c.push({type:"function_call",id:k,call_id:g,name:d.name,arguments:JSON.stringify(d.arguments)})}if(c.length===0)continue;p.push(...c)}else if(r.role==="toolResult"){let[c]=r.toolCallId.split("|"),t=J(i,r.content);if(u?.grammarToolInputProperties?.has(r.toolName))p.push({type:"custom_tool_call_output",call_id:c,output:t});else p.push({type:"function_call_output",call_id:c,output:t});let e=[];for(let n of r.addedToolNames??[]){let s=u?.deferredTools?.get(n);if(!s||f.has(n))continue;f.add(n),e.push(s)}if(e.length>0){let n=e.map((d)=>d.name),s=`pi_tool_load_${Ms(`${r.toolCallId}:${n.join(",")}`)}`;p.push({type:"tool_search_call",call_id:s,execution:"client",status:"completed",arguments:{query:n.join(" "),limit:n.length}}),p.push({type:"tool_search_output",call_id:s,execution:"client",status:"completed",tools:ni(e,{...u?.toolOptions,deferLoading:!0})})}}x++}return p}function ni(i,o){let a=o?.strict===void 0?!1:o.strict,u=o?.supportsStrictMode??!0,p=o?.supportsOpenAIGrammarTools??!1;return i.map((f)=>{let l=rl(f,p);if(l)return{type:"custom",name:f.name,description:f.description,format:{type:"grammar",syntax:l.format,definition:l.definition},...o?.deferLoading?{defer_loading:!0}:{}};let y=po(f,u),m={type:"function",name:f.name,description:f.description,parameters:f.parameters,...o?.deferLoading?{defer_loading:!0}:{}};if(u)m.strict=y??a;return m})}function T(i){let o=i.customInput?.property;if(o===void 0)return"";let a=i.arguments[o];return typeof a==="string"?a:""}function S(i,o,a){let u=i.customInput;if(!u)return;let p=hc(u.jsonBuffer,u.property,o,a);return i.arguments={[u.property]:o},p}async function oi(i,o,a,u,p){let f=!1,l=new Map,y=new Map,m=(t,e)=>{let n=l.get(t);return n?.type===e?n:void 0},h=(t,e)=>{if(e===void 0)return;a.push({type:"toolcall_delta",contentIndex:t.contentIndex,delta:e,partial:o})},I=(t,e)=>{if(e.type==="reasoning"){let n={type:"thinking",thinking:""};o.content.push(n);let s={type:"thinking",block:n,contentIndex:o.content.length-1};return l.set(t,s),a.push({type:"thinking_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="message"){let n={type:"text",text:""};o.content.push(n);let s={type:"text",block:n,contentIndex:o.content.length-1};return l.set(t,s),a.push({type:"text_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="function_call"){let n={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{},partialJson:e.arguments||""};o.content.push(n);let s={type:"toolCall",block:n,contentIndex:o.content.length-1};return l.set(t,s),a.push({type:"toolcall_start",contentIndex:s.contentIndex,partial:o}),s}if(e.type==="custom_tool_call"){let n=p?.grammarToolInputProperties?.get(e.name)??"input",s=e.input||"",d={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{[n]:s},customInput:{property:n,jsonBuffer:{input:"",started:!1,closed:!1}}};o.content.push(d);let g={type:"toolCall",block:d,contentIndex:o.content.length-1};return l.set(t,g),a.push({type:"toolcall_start",contentIndex:g.contentIndex,partial:o}),g}return},x=(t,e)=>l.get(t)??I(t,e),r=(t)=>{for(let e of t){if(e.type!=="reasoning"||!e.encrypted_content)continue;let n=y.get(e.id);if(!n?.thinkingSignature)continue;let s=JSON.parse(n.thinkingSignature);if(s.encrypted_content)continue;n.thinkingSignature=JSON.stringify({...s,encrypted_content:e.encrypted_content})}},c=(t)=>{if(f=!0,r(t.output??[]),t?.id)o.responseId=t.id;if(t?.usage){let e=t.usage.input_tokens_details,n=e?.cached_tokens||0,s=e?.cache_write_tokens||0;o.usage={input:Math.max(0,(t.usage.input_tokens||0)-n-s),output:t.usage.output_tokens||0,cacheRead:n,cacheWrite:s,reasoning:t.usage.output_tokens_details?.reasoning_tokens||0,totalTokens:t.usage.total_tokens||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}if(mn(u,o.usage),p?.applyServiceTierPricing){let e=p.resolveServiceTier?p.resolveServiceTier(t?.service_tier,p.serviceTier):t?.service_tier??p.serviceTier;p.applyServiceTierPricing(o.usage,e)}if(o.stopReason=w(t?.status),o.content.some((e)=>e.type==="toolCall")&&o.stopReason==="stop")o.stopReason="toolUse"};for await(let t of i)if(t.type==="response.created")o.responseId=t.response.id;else if(t.type==="response.output_item.added")I(t.output_index,t.item);else if(t.type==="response.reasoning_summary_text.delta"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=t.delta,a.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.reasoning_summary_part.done"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=`
4
4
 
5
5
  `,a.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:`
6
6
 
7
- `,partial:o})}else if(t.type==="response.reasoning_text.delta"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=t.delta,a.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.output_text.delta"){let e=m(t.output_index,"text");if(!e)continue;e.block.text+=t.delta,a.push({type:"text_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.refusal.delta"){let e=m(t.output_index,"text");if(!e)continue;e.block.text+=t.delta,a.push({type:"text_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.function_call_arguments.delta"){let e=m(t.output_index,"toolCall");if(!e||e.block.partialJson===void 0)continue;e.block.partialJson+=t.delta,e.block.arguments=Xr(e.block.partialJson),h(e,t.delta)}else if(t.type==="response.function_call_arguments.done"){let e=m(t.output_index,"toolCall");if(!e||e.block.partialJson===void 0)continue;let n=e.block.partialJson;if(e.block.partialJson=t.arguments,e.block.arguments=Xr(e.block.partialJson),t.arguments.startsWith(n)){let s=t.arguments.slice(n.length);if(s.length>0)h(e,s)}}else if(t.type==="response.custom_tool_call_input.delta"){let e=m(t.output_index,"toolCall");if(!e||!e.block.customInput)continue;h(e,S(e.block,T(e.block)+t.delta,!1))}else if(t.type==="response.custom_tool_call_input.done"){let e=m(t.output_index,"toolCall");if(!e||!e.block.customInput)continue;h(e,S(e.block,t.input,!0))}else if(t.type==="response.output_item.done"){let e=t.item,n=x(t.output_index,e);if(e.type==="reasoning"&&n?.type==="thinking"){let s=e.summary?.map((g)=>g.text).join(`
7
+ `,partial:o})}else if(t.type==="response.reasoning_text.delta"){let e=m(t.output_index,"thinking");if(!e)continue;e.block.thinking+=t.delta,a.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.output_text.delta"){let e=m(t.output_index,"text");if(!e)continue;e.block.text+=t.delta,a.push({type:"text_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.refusal.delta"){let e=m(t.output_index,"text");if(!e)continue;e.block.text+=t.delta,a.push({type:"text_delta",contentIndex:e.contentIndex,delta:t.delta,partial:o})}else if(t.type==="response.function_call_arguments.delta"){let e=m(t.output_index,"toolCall");if(!e||e.block.partialJson===void 0)continue;e.block.partialJson+=t.delta,e.block.arguments=Jr(e.block.partialJson),h(e,t.delta)}else if(t.type==="response.function_call_arguments.done"){let e=m(t.output_index,"toolCall");if(!e||e.block.partialJson===void 0)continue;let n=e.block.partialJson;if(e.block.partialJson=t.arguments,e.block.arguments=Jr(e.block.partialJson),t.arguments.startsWith(n)){let s=t.arguments.slice(n.length);if(s.length>0)h(e,s)}}else if(t.type==="response.custom_tool_call_input.delta"){let e=m(t.output_index,"toolCall");if(!e||!e.block.customInput)continue;h(e,S(e.block,T(e.block)+t.delta,!1))}else if(t.type==="response.custom_tool_call_input.done"){let e=m(t.output_index,"toolCall");if(!e||!e.block.customInput)continue;h(e,S(e.block,t.input,!0))}else if(t.type==="response.output_item.done"){let e=t.item,n=x(t.output_index,e);if(e.type==="reasoning"&&n?.type==="thinking"){let s=e.summary?.map((g)=>g.text).join(`
8
8
 
9
9
  `)||"",d=e.content?.map((g)=>g.text).join(`
10
10
 
11
- `)||"";n.block.thinking=s||d||n.block.thinking,n.block.thinkingSignature=JSON.stringify(e),y.set(e.id,n.block),a.push({type:"thinking_end",contentIndex:n.contentIndex,content:n.block.thinking,partial:o}),l.delete(t.output_index)}else if(e.type==="message"&&n?.type==="text")n.block.text=e.content?.map((s)=>s.type==="output_text"?s.text:s.refusal).join("")||"",n.block.textSignature=v(e.id,e.phase??void 0),a.push({type:"text_end",contentIndex:n.contentIndex,content:n.block.text,partial:o}),l.delete(t.output_index);else if(e.type==="function_call"&&n?.type==="toolCall"&&n.block.partialJson!==void 0)n.block.arguments=Xr(e.arguments||n.block.partialJson||"{}"),delete n.block.partialJson,a.push({type:"toolcall_end",contentIndex:n.contentIndex,toolCall:n.block,partial:o}),l.delete(t.output_index);else if(e.type==="custom_tool_call"&&n?.type==="toolCall"&&n.block.customInput)h(n,S(n.block,e.input??T(n.block),!0)),delete n.block.customInput,a.push({type:"toolcall_end",contentIndex:n.contentIndex,toolCall:n.block,partial:o}),l.delete(t.output_index)}else if(t.type==="response.completed"||t.type==="response.incomplete")c(t.response);else if(t.type==="error")throw Error(`Error Code ${t.code}: ${t.message}`||"Unknown error");else if(t.type==="response.failed"){f=!0;let e=t.response?.error,n=t.response?.incomplete_details,s=e?`${e.code||"unknown"}: ${e.message||"no message"}`:n?.reason?`incomplete: ${n.reason}`:"Unknown error (no error details in response)";throw Error(s)}if(!f)throw Error("OpenAI Responses stream ended before a terminal response event")}function w(i){if(!i)return"stop";switch(i){case"completed":return"stop";case"incomplete":return"length";case"failed":case"cancelled":return"error";case"in_progress":case"queued":return"stop";default:throw Error(`Unhandled stop reason: ${i}`)}}
12
- export{ti,ri,ni};
11
+ `)||"";n.block.thinking=s||d||n.block.thinking,n.block.thinkingSignature=JSON.stringify(e),y.set(e.id,n.block),a.push({type:"thinking_end",contentIndex:n.contentIndex,content:n.block.thinking,partial:o}),l.delete(t.output_index)}else if(e.type==="message"&&n?.type==="text")n.block.text=e.content?.map((s)=>s.type==="output_text"?s.text:s.refusal).join("")||"",n.block.textSignature=v(e.id,e.phase??void 0),a.push({type:"text_end",contentIndex:n.contentIndex,content:n.block.text,partial:o}),l.delete(t.output_index);else if(e.type==="function_call"&&n?.type==="toolCall"&&n.block.partialJson!==void 0)n.block.arguments=Jr(e.arguments||n.block.partialJson||"{}"),delete n.block.partialJson,a.push({type:"toolcall_end",contentIndex:n.contentIndex,toolCall:n.block,partial:o}),l.delete(t.output_index);else if(e.type==="custom_tool_call"&&n?.type==="toolCall"&&n.block.customInput)h(n,S(n.block,e.input??T(n.block),!0)),delete n.block.customInput,a.push({type:"toolcall_end",contentIndex:n.contentIndex,toolCall:n.block,partial:o}),l.delete(t.output_index)}else if(t.type==="response.completed"||t.type==="response.incomplete")c(t.response);else if(t.type==="error")throw Error(`Error Code ${t.code}: ${t.message}`||"Unknown error");else if(t.type==="response.failed"){f=!0;let e=t.response?.error,n=t.response?.incomplete_details,s=e?`${e.code||"unknown"}: ${e.message||"no message"}`:n?.reason?`incomplete: ${n.reason}`:"Unknown error (no error details in response)";throw Error(s)}if(!f)throw Error("OpenAI Responses stream ended before a terminal response event")}function w(i){if(!i)return"stop";switch(i){case"completed":return"stop";case"incomplete":return"length";case"failed":case"cancelled":return"error";case"in_progress":case"queued":return"stop";default:throw Error(`Unhandled stop reason: ${i}`)}}
12
+ export{ri,ni,oi};
@@ -0,0 +1,2 @@
1
+ import{I}from"./chunk-vvr8tnse.js";var e=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],nc=I("code",e);
2
+ export{nc};