@shumai-one/shumai 0.4.1 → 0.4.2

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 (173) hide show
  1. package/bin/{chunk-rfsbzd39.js → chunk-07h4b77v.js} +2 -2
  2. package/bin/{chunk-j9q9rjvd.js → chunk-0t4n4d5w.js} +2 -2
  3. package/bin/{chunk-be9a7kc6.js → chunk-1611z9jg.js} +2 -2
  4. package/bin/{chunk-q46rc697.js → chunk-1phqxp6z.js} +1 -1
  5. package/bin/{chunk-xxtcmzcv.js → chunk-23hckrrz.js} +2 -2
  6. package/bin/{chunk-j10gz94w.js → chunk-30z44j1g.js} +2 -2
  7. package/bin/{chunk-thd9zasr.js → chunk-3j463k1g.js} +1 -1
  8. package/bin/{chunk-d6d1j7qq.js → chunk-4181tdds.js} +2 -2
  9. package/bin/{chunk-44370df5.js → chunk-480jtqng.js} +2 -2
  10. package/bin/{chunk-pcxjm1re.js → chunk-4c3g146q.js} +2 -2
  11. package/bin/chunk-4ca0zt5e.js +1 -0
  12. package/bin/chunk-4d9bgmf2.js +2 -0
  13. package/bin/{chunk-b0cqsrse.js → chunk-4ev56fss.js} +5 -5
  14. package/bin/{chunk-tcqw0q8x.js → chunk-4gk52tjq.js} +1 -1
  15. package/bin/chunk-4mdqkj4d.js +1 -0
  16. package/bin/{chunk-f4d3v0nc.js → chunk-4r91fggc.js} +2 -2
  17. package/bin/chunk-50fb1x3w.js +1 -0
  18. package/bin/chunk-59gj1njz.js +1 -0
  19. package/bin/{chunk-4ee336e3.js → chunk-5pr0t7fb.js} +1 -1
  20. package/bin/chunk-5vewxmz7.js +3 -0
  21. package/bin/chunk-62zx96pe.js +2 -0
  22. package/bin/{chunk-7xcyn1ba.js → chunk-63y0eb07.js} +2 -2
  23. package/bin/chunk-6d5xrgfx.js +2 -0
  24. package/bin/{chunk-jw00fmkp.js → chunk-6gbtz5bf.js} +2 -2
  25. package/bin/{chunk-r6g1srb3.js → chunk-6gjg5egq.js} +1 -1
  26. package/bin/{chunk-c97vh5wb.js → chunk-6m4jz9s1.js} +3 -3
  27. package/bin/{chunk-7zgvmn5q.js → chunk-6s4x525w.js} +1 -1
  28. package/bin/{chunk-7qzt5nhz.js → chunk-6w2wmvqs.js} +1 -1
  29. package/bin/{chunk-kejt7kcr.js → chunk-77d23vcn.js} +2 -2
  30. package/bin/{chunk-1vs91e4q.js → chunk-77m5p188.js} +2 -2
  31. package/bin/chunk-7bvx087f.js +1 -0
  32. package/bin/chunk-7pfjfrjg.js +5 -0
  33. package/bin/{chunk-78cxvbjd.js → chunk-7q10s127.js} +1 -1
  34. package/bin/{chunk-za7ga4bf.js → chunk-7thx8ctx.js} +2 -2
  35. package/bin/{chunk-s9sgkkjp.js → chunk-8t4s91gh.js} +1 -1
  36. package/bin/{chunk-bbar8rsh.js → chunk-98ey5p2e.js} +1 -1
  37. package/bin/{chunk-gfdfkqrc.js → chunk-9amndcyh.js} +3 -3
  38. package/bin/chunk-9bk23g9x.js +1 -0
  39. package/bin/chunk-9mkcfy43.js +1 -0
  40. package/bin/{chunk-8yt4m2pb.js → chunk-9t3nsq5n.js} +2 -2
  41. package/bin/{chunk-zqvavykq.js → chunk-9tjq99ds.js} +2 -2
  42. package/bin/chunk-9wm9rwh1.js +2 -0
  43. package/bin/{chunk-8pfgh13x.js → chunk-ab16fyg4.js} +2 -2
  44. package/bin/chunk-arv0g2av.js +1 -0
  45. package/bin/{chunk-hx2mvd20.js → chunk-aytj4zxg.js} +2 -2
  46. package/bin/{chunk-4k2d8w9w.js → chunk-b1ypjqgp.js} +2 -2
  47. package/bin/{chunk-pt51m9h1.js → chunk-bdjv0ykq.js} +2 -2
  48. package/bin/chunk-c1k86mfa.js +10 -0
  49. package/bin/{chunk-me3xj7na.js → chunk-caa96dgd.js} +1 -1
  50. package/bin/chunk-ce4v2yjy.js +1 -0
  51. package/bin/{chunk-pg00gkr4.js → chunk-cqh60y54.js} +2 -2
  52. package/bin/chunk-cvq7zgw7.js +1 -0
  53. package/bin/{chunk-16txy3r1.js → chunk-d9mjbtp2.js} +2 -2
  54. package/bin/{chunk-116p639c.js → chunk-dn7sbjws.js} +2 -2
  55. package/bin/{chunk-txkmks1h.js → chunk-dxyq9h8n.js} +1 -1
  56. package/bin/{chunk-mgytr7nc.js → chunk-e3cabksx.js} +1 -1
  57. package/bin/{chunk-f8ysqfyv.js → chunk-egcrbj94.js} +2 -2
  58. package/bin/chunk-ev17v1mv.js +2 -0
  59. package/bin/{chunk-a5b3aevg.js → chunk-evtpwg71.js} +1 -1
  60. package/bin/{chunk-zt15ht52.js → chunk-f3e0nsv2.js} +1 -1
  61. package/bin/{chunk-r9pzpqst.js → chunk-f40gjqpq.js} +1 -1
  62. package/bin/chunk-fe7822ak.js +299 -0
  63. package/bin/{chunk-srs9jq8f.js → chunk-g8tkhw9j.js} +2 -2
  64. package/bin/{chunk-mgnxa0vy.js → chunk-g9r0p4t8.js} +1 -1
  65. package/bin/chunk-gbjyh9ms.js +1 -0
  66. package/bin/{chunk-pn94h6x7.js → chunk-gtbsb39v.js} +1 -1
  67. package/bin/{chunk-d9sh922y.js → chunk-gytz1q13.js} +1 -1
  68. package/bin/chunk-h0fxysxs.js +7 -0
  69. package/bin/{chunk-9f83pnfc.js → chunk-h8bdvsqt.js} +2 -2
  70. package/bin/{chunk-ts10cfmc.js → chunk-hag024w8.js} +2 -2
  71. package/bin/{chunk-09pe07g6.js → chunk-hc6w5nw4.js} +1 -1
  72. package/bin/chunk-j69dqc48.js +2 -0
  73. package/bin/{chunk-13ypr8v0.js → chunk-jbtw1zym.js} +1 -1
  74. package/bin/{chunk-7wvw67f3.js → chunk-jc1vb7rj.js} +2 -2
  75. package/bin/{chunk-92yvt66q.js → chunk-jdv78w9r.js} +1 -1
  76. package/bin/{chunk-gyaem1t4.js → chunk-jjs70y9v.js} +1 -1
  77. package/bin/{chunk-6tv7rm3x.js → chunk-jmdar2gz.js} +2 -2
  78. package/bin/{chunk-cyvx7gcx.js → chunk-jvwz10n4.js} +1 -1
  79. package/bin/{chunk-ygsbmfcy.js → chunk-k47md1g4.js} +2 -2
  80. package/bin/{chunk-hmmzbyy1.js → chunk-k4v0brcb.js} +2 -2
  81. package/bin/chunk-k6n7c07e.js +1 -0
  82. package/bin/{chunk-af6m9p1d.js → chunk-kk2cstsg.js} +1 -1
  83. package/bin/{chunk-wfee9d83.js → chunk-knz4h56q.js} +3 -3
  84. package/bin/{chunk-j5rx3x1q.js → chunk-kqqtt6bd.js} +1 -1
  85. package/bin/{chunk-ym9xavj0.js → chunk-kvyp1t4j.js} +1 -1
  86. package/bin/{chunk-4yhd7bmp.js → chunk-kxskpgsq.js} +2 -2
  87. package/bin/{chunk-q059y3wx.js → chunk-m6srbjcs.js} +2 -2
  88. package/bin/{chunk-3gqdepkd.js → chunk-mcc1scxs.js} +2 -2
  89. package/bin/{chunk-90tbc5f4.js → chunk-mq83a0kk.js} +2 -2
  90. package/bin/chunk-mxm8g4q0.js +1 -0
  91. package/bin/{chunk-f32kxe6c.js → chunk-nhpgdqq5.js} +2 -2
  92. package/bin/{chunk-2jsjrqw4.js → chunk-nne496aa.js} +2 -2
  93. package/bin/{chunk-cerjktz2.js → chunk-nqpb0r9h.js} +1 -1
  94. package/bin/chunk-ns0zww9g.js +2 -0
  95. package/bin/{chunk-2sc2jxd3.js → chunk-ps4xfp23.js} +1 -1
  96. package/bin/chunk-pz2ec6xt.js +2 -0
  97. package/bin/{chunk-px2cvc1n.js → chunk-q163k309.js} +2 -2
  98. package/bin/chunk-q1da61ps.js +1 -0
  99. package/bin/{chunk-785kxysj.js → chunk-qrf0ady6.js} +2 -2
  100. package/bin/{chunk-kkveddbn.js → chunk-qy28f25e.js} +1 -1
  101. package/bin/{chunk-fcsar7p0.js → chunk-r7s4ypw1.js} +1 -1
  102. package/bin/chunk-ran23vm9.js +1 -0
  103. package/bin/chunk-rfvdc4n0.js +2 -0
  104. package/bin/{chunk-8rcfhfq5.js → chunk-rgthkvgx.js} +1 -1
  105. package/bin/chunk-s39n3yw3.js +2 -0
  106. package/bin/{chunk-z340qkez.js → chunk-s7wdd0g7.js} +1 -1
  107. package/bin/{chunk-n8gsjwht.js → chunk-s88ha5kx.js} +2 -2
  108. package/bin/chunk-sf91bt9m.js +2 -0
  109. package/bin/{chunk-c43nmcfq.js → chunk-sjwbjf9j.js} +1 -1
  110. package/bin/chunk-t62076pv.js +1 -0
  111. package/bin/{chunk-k20w9eaz.js → chunk-tbbwss3v.js} +1 -1
  112. package/bin/{chunk-djkajvn7.js → chunk-tjcc7a6y.js} +1 -1
  113. package/bin/{chunk-nndzhn3n.js → chunk-tp6ab26e.js} +1 -1
  114. package/bin/{chunk-5395g4kq.js → chunk-v2wxk9p5.js} +2 -2
  115. package/bin/{chunk-wzdnsgwq.js → chunk-vbk6y4hk.js} +2 -2
  116. package/bin/{chunk-dyvmwafa.js → chunk-vfgfg5fk.js} +2 -2
  117. package/bin/{chunk-5c4h0t33.js → chunk-vm6c3xx9.js} +2 -2
  118. package/bin/{chunk-wxsq9zmf.js → chunk-vsx96mt6.js} +1 -1
  119. package/bin/{chunk-vh7eb7tp.js → chunk-wbyw1shz.js} +2 -2
  120. package/bin/chunk-whh2vh50.css +1 -0
  121. package/bin/{chunk-m49g5tf4.js → chunk-wjkcq65s.js} +2 -2
  122. package/bin/{chunk-47r5b77s.js → chunk-wkefwkfp.js} +1 -1
  123. package/bin/{chunk-7sf0gbbm.js → chunk-x7bsnk1e.js} +2 -2
  124. package/bin/{chunk-rar0gk7s.js → chunk-xbhw6bpz.js} +2 -2
  125. package/bin/{chunk-5bkj2n94.js → chunk-xg5yrcj5.js} +2 -2
  126. package/bin/{chunk-ewge52nq.js → chunk-xw2gpcsh.js} +1 -1
  127. package/bin/{chunk-xyzmew7g.js → chunk-ycq8ank7.js} +1 -1
  128. package/bin/{chunk-w9p59ahz.js → chunk-yp9hvkc5.js} +9 -9
  129. package/bin/{chunk-bkbqvxfv.js → chunk-ytypyfkc.js} +2 -2
  130. package/bin/{chunk-axb1f1ae.js → chunk-z1kjmf60.js} +2 -2
  131. package/bin/chunk-z36bx86r.js +2 -0
  132. package/bin/chunk-z7hdnecp.js +3 -0
  133. package/bin/{chunk-2vc6pw8q.js → chunk-zeby1cq7.js} +1 -1
  134. package/bin/chunk-zs5e8z1w.js +1 -0
  135. package/bin/chunk-zxnyefg5.js +2 -0
  136. package/bin/shumai-app.html +1 -1
  137. package/bin/shumai-app.js +297 -285
  138. package/package.json +7 -7
  139. package/bin/chunk-082zg4nr.js +0 -307
  140. package/bin/chunk-0qdzjcny.js +0 -2
  141. package/bin/chunk-0z1p2pvf.js +0 -1
  142. package/bin/chunk-29e0mb43.js +0 -1
  143. package/bin/chunk-2a0egvsg.js +0 -1
  144. package/bin/chunk-2f35h4fn.js +0 -2
  145. package/bin/chunk-2q7ew7yz.js +0 -2
  146. package/bin/chunk-44xtwvd7.js +0 -2
  147. package/bin/chunk-4azttb3w.js +0 -1
  148. package/bin/chunk-4yybby29.js +0 -2
  149. package/bin/chunk-6nrynqdw.js +0 -2
  150. package/bin/chunk-7g2k89gq.js +0 -2
  151. package/bin/chunk-7psq38hv.js +0 -1
  152. package/bin/chunk-93v3tm93.js +0 -1
  153. package/bin/chunk-ajryg2e2.js +0 -1
  154. package/bin/chunk-b27jgdsf.css +0 -1
  155. package/bin/chunk-bwyph9a0.js +0 -1
  156. package/bin/chunk-dbjc1vxt.js +0 -1
  157. package/bin/chunk-gr30nssh.js +0 -1
  158. package/bin/chunk-gtwhwdbs.js +0 -1
  159. package/bin/chunk-hk6tvf7b.js +0 -1
  160. package/bin/chunk-hzz4hsss.js +0 -1
  161. package/bin/chunk-k1f3gj25.js +0 -3
  162. package/bin/chunk-ktvmxqfg.js +0 -5
  163. package/bin/chunk-mkb4dycy.js +0 -2
  164. package/bin/chunk-n21a21vx.js +0 -2
  165. package/bin/chunk-r88vwaxc.js +0 -1
  166. package/bin/chunk-rfrpb986.js +0 -1
  167. package/bin/chunk-s503pcvb.js +0 -7
  168. package/bin/chunk-t77dwtcc.js +0 -2
  169. package/bin/chunk-tkgpc6c9.js +0 -2
  170. package/bin/chunk-v9hbssqd.js +0 -3
  171. package/bin/chunk-v9zc56qr.js +0 -1
  172. package/bin/chunk-x2nnv4j8.js +0 -1
  173. /package/bin/{chunk-kryt6pg3.js → chunk-xg9xscqz.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{vd as GJ,wd as zJ}from"./chunk-j5rx3x1q.js";import{vm as OJ}from"./chunk-r6g1srb3.js";import{Am as r,ym as n,zm as WJ}from"./chunk-3gqdepkd.js";import{Bm as jJ}from"./chunk-bbar8rsh.js";import"./chunk-ewge52nq.js";import{Gm as p}from"./chunk-rar0gk7s.js";import"./chunk-7wvw67f3.js";import{Vm as KJ,Wm as _J}from"./chunk-pn94h6x7.js";import{$m as a,bn as LJ}from"./chunk-wxsq9zmf.js";import"./chunk-k20w9eaz.js";import{fn as i}from"./chunk-7qzt5nhz.js";import{mn as DJ}from"./chunk-116p639c.js";import{nn as YJ,on as y,pn as NJ,qn as VJ}from"./chunk-q46rc697.js";import"./chunk-txkmks1h.js";function o(J){let Q=J.filter((F)=>F!==void 0);if(Q.length===0)return{cleanup:()=>{}};if(Q.length===1)return{signal:Q[0],cleanup:()=>{}};let Z=new AbortController,$=[],X=(F)=>{if(!Z.signal.aborted)Z.abort(F.reason)};for(let F of Q){if(F.aborted){X(F);break}let Y=()=>X(F);F.addEventListener("abort",Y,{once:!0}),$.push({signal:F,listener:Y})}return{signal:Z.signal,cleanup:()=>{for(let{signal:F,listener:Y}of $)F.removeEventListener("abort",Y)}}}var fJ={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443};function c(J,Q){let Z=J.toLowerCase(),$=J.toUpperCase();return Q?.[Z]||Q?.[$]||p(Z)||p($)||""}function SJ(J){if(J instanceof URL)return J;try{return new URL(J)}catch{return}}function TJ(J,Q,Z){let $=c("no_proxy",Z).toLowerCase();if(!$)return!0;if($==="*")return!1;return $.split(/[,\s]/).every((X)=>{if(!X)return!0;let F=X.match(/^(.+):(\d+)$/),Y=F?F[1]:X,G=F?Number.parseInt(F[2],10):0;if(G&&G!==Q)return!0;if(!/^[.*]/.test(Y))return J!==Y;if(Y.startsWith("*"))Y=Y.slice(1);return!J.endsWith(Y)})}function hJ(J,Q){let Z=SJ(J);if(!Z?.protocol||!Z.host)return"";let $=Z.protocol.split(":",1)[0],X=Z.host.replace(/:\d*$/,""),F=Number.parseInt(Z.port,10)||fJ[$]||0;if(!TJ(X,F,Q))return"";let Y=c(`${$}_proxy`,Q)||c("all_proxy",Q);if(Y&&!Y.includes("://"))Y=`${$}://${Y}`;return Y}var xJ="Unsupported proxy protocol. SOCKS and PAC proxy URLs are not supported; use an HTTP or HTTPS proxy URL.";function e(J,Q){let Z=hJ(J,Q);if(!Z)return;let $;try{$=new URL(Z)}catch(X){throw Error(`Invalid proxy URL ${JSON.stringify(Z)}: ${X instanceof Error?X.message:String(X)}`)}if($.protocol!=="http:"&&$.protocol!=="https:")throw Error(`${xJ} Got ${$.protocol}`);return $}function bJ(){if(typeof process>"u"||!(process.versions?.node||process.versions?.bun))return null;return process.getBuiltinModule?.("node:os")??null}var I=bJ(),kJ="https://chatgpt.com/backend-api",IJ="https://api.openai.com/auth",gJ=0,JJ=1000,vJ=60000,yJ=15000,mJ=3,BJ=new Set(["openai","openai-codex","opencode"]),uJ=1009,pJ="websocket_connection_limit_reached",cJ="previous_response_not_found",lJ=new Set(["completed","incomplete","failed","cancelled","queued","in_progress"]);function dJ(J){return/GoUsageLimitError|FreeUsageLimitError|Monthly usage limit reached|available balance|insufficient_quota|out of budget|quota exceeded|billing/i.test(J)}function iJ(J,Q){if(J===429&&dJ(Q))return!1;if(J===429||J===500||J===502||J===503||J===504)return!0;return/rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(Q)}function aJ(J){let Q=J.get("retry-after-ms");if(Q!==null){let F=Number(Q);if(Number.isFinite(F))return Math.max(0,F)}let Z=J.get("retry-after");if(!Z)return;let $=Number(Z);if(Number.isFinite($))return Math.max(0,$*1000);let X=Date.parse(Z);if(!Number.isNaN(X))return Math.max(0,X-Date.now());return}class t extends Error{}function nJ(J,Q){let Z=Q?.maxRetryDelayMs??vJ;if(Z>0&&J>Z)throw new t(`Server requested ${Math.ceil(J/1000)}s retry delay (max: ${Math.ceil(Z/1000)}s)`);return J}function QJ(J,Q){return new Promise((Z,$)=>{if(Q?.aborted){$(Error("Request was aborted"));return}let X=setTimeout(Z,J);Q?.addEventListener("abort",()=>{clearTimeout(X),$(Error("Request was aborted"))})})}function ZJ(J){if(J===void 0)return;if(!Number.isFinite(J)||J<0)throw Error(`Invalid timeoutMs: ${String(J)}`);return Math.floor(J)}function rJ(){if(typeof process>"u"||!(process.versions?.node||process.versions?.bun))return null;return process.getBuiltinModule?.("node:zlib")??null}function tJ(J){let Q=rJ();if(!Q||typeof Q.zstdCompressSync!=="function")return null;try{let Z=Q.zstdCompressSync(J,{params:{[Q.constants.ZSTD_c_compressionLevel]:mJ}});return new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength)}catch{return null}}var sJ=(J,Q,Z)=>{let $=new YJ;return(async()=>{let X={role:"assistant",content:[],api:"openai-codex-responses",provider:J.provider,model:J.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let F=Z?.apiKey;if(!F)throw Error(`No API key for provider: ${J.provider}`);let Y=UQ(F),G=a(Q.tools,J.compat?.supportsOpenAIGrammarTools??!1),N=Z?.cacheRetention==="none"?void 0:Z?.sessionId,V=jJ(N),K=oJ(J,Q,Z,V,G),D=await Z?.onPayload?.(K,J);if(D!==void 0)K=D;let R=V||zJ(),z=CQ(J.headers,Z?.headers,Y,F,V),A=MQ(J.headers,Z?.headers,Y,F,R),j=JSON.stringify(K),_=ZJ(Z?.timeoutMs),U=ZJ(Z?.websocketConnectTimeoutMs),L=Z?.transport||"auto",W=!1,O=L!=="sse"&&EJ(N);if(O)$J(N);if(L!=="sse"&&!O){let B=!1,H=!1,M=!1;while(!0){B=!1;try{if(await wQ(JQ(J.baseUrl),K,A,X,$,J,()=>{if(B=!0,!W)W=!0,$.push({type:"start",partial:X})},_,U,N,G,Z),Z?.signal?.aborted)throw Error("Request was aborted");$.push({type:"done",reason:X.stopReason,message:X}),$.end();return}catch(w){let x=Z?.signal?.aborted,b=!B&&$Q(w),S=FQ(w);if(!x&&S&&!M){M=!0;continue}if(!x&&b&&!H){H=!0;continue}if(x||ZQ(w)&&!b)throw w;if(VJ(X,NJ("provider_transport_failure",w,{configuredTransport:L,fallbackTransport:B?void 0:"sse",eventsEmitted:B,phase:B?"after_message_stream_start":"before_message_stream_start",requestBytes:new TextEncoder().encode(j).byteLength})),KQ(N,w),B)throw w;$J(N);break}}}let C=tJ(j);if(C)z.set("content-encoding","zstd");let f=C??j,q,h,u=Z?.maxRetries??gJ;for(let B=0;B<=u;B++){if(Z?.signal?.aborted)throw Error("Request was aborted");try{let H=_!==void 0&&_>0?AbortSignal.timeout(_):void 0,M=o([Z?.signal,H]);try{q=await fetch(qJ(J.baseUrl),{method:"POST",headers:z,body:f,signal:M.signal})}catch(S){if(H?.aborted&&!Z?.signal?.aborted)throw Error(`Codex SSE response headers timed out after ${_}ms`);throw S}finally{M.cleanup()}if(await Z?.onResponse?.({status:q.status,headers:i(q.headers)},J),q.ok)break;let w=await q.text();if(B<u&&iJ(q.status,w)){let S=aJ(q.headers),MJ=S===void 0?JJ*2**B:nJ(S,Z);await QJ(MJ,Z?.signal);continue}let x=new Response(w,{status:q.status,statusText:q.statusText}),b=await PQ(x);throw Error(b.friendlyMessage||b.message)}catch(H){if(H instanceof Error){if(H.name==="AbortError"||H.message==="Request was aborted")throw Error("Request was aborted")}if(h=H instanceof Error?H:Error(String(H)),B<u&&!(h instanceof t)&&!h.message.includes("usage limit")){let M=JJ*2**B;await QJ(M,Z?.signal);continue}throw h}}if(!q?.ok)throw h??Error("Failed after retries");if(!q.body)throw Error("No response body");if(!W)W=!0,$.push({type:"start",partial:X});if(await QQ(q,X,$,J,G,Z),Z?.signal?.aborted)throw Error("Request was aborted");$.push({type:"done",reason:X.stopReason,message:X}),$.end()}catch(F){for(let Y of X.content)delete Y.partialJson,delete Y.customInput;X.stopReason=Z?.signal?.aborted?"aborted":"error",X.errorMessage=_J(KJ(F)),$.push({type:"error",reason:X.stopReason,error:X}),$.end()}})(),$},iQ=(J,Q,Z)=>{let $=Z?.apiKey;if(!$)throw Error(`No API key for provider: ${J.provider}`);let X=LJ(J,Q,Z,$),F=Z?.reasoning?DJ(J,Z.reasoning):void 0;return sJ(J,Q,{...X,reasoningEffort:F==="off"?void 0:F})};function oJ(J,Q,Z,$,X=a(Q.tools,J.compat?.supportsOpenAIGrammarTools??!1)){let F=J.compat?.supportsStrictMode??!0,Y=J.compat?.supportsOpenAIGrammarTools??!1,G=OJ(Q,J.compat?.supportsToolSearch??!1),N=n(J,Q,BJ,{includeSystemPrompt:!1,grammarToolInputProperties:X,deferredTools:G.deferred,toolOptions:{strict:null,supportsStrictMode:F,supportsOpenAIGrammarTools:Y}}),V={model:J.id,store:!1,stream:!0,instructions:Q.systemPrompt||"You are a helpful assistant.",input:N,text:{verbosity:Z?.textVerbosity||"low"},include:["reasoning.encrypted_content"],prompt_cache_key:$,tool_choice:Z?.toolChoice??"auto",parallel_tool_calls:!0};if(Z?.temperature!==void 0)V.temperature=Z.temperature;if(Z?.serviceTier!==void 0)V.service_tier=Z.serviceTier;if(G.immediate.length>0)V.tools=WJ(G.immediate,{strict:null,supportsStrictMode:F,supportsOpenAIGrammarTools:Y});if(Z?.reasoningEffort!==void 0){let K=Z.reasoningEffort==="none"?J.thinkingLevelMap?.off??"none":J.thinkingLevelMap?.[Z.reasoningEffort]??Z.reasoningEffort;if(K!==null)V.reasoning={effort:K,summary:Z.reasoningSummary??"auto"}}return V}function eJ(J,Q){switch(Q){case"flex":return 0.5;case"priority":return J.id==="gpt-5.5"?2.5:2;default:return 1}}function RJ(J,Q,Z){let $=eJ(Z,Q);if($===1)return;J.cost.input*=$,J.cost.output*=$,J.cost.cacheRead*=$,J.cost.cacheWrite*=$,J.cost.total=J.cost.input+J.cost.output+J.cost.cacheRead+J.cost.cacheWrite}function AJ(J,Q){if(J==="default"&&(Q==="flex"||Q==="priority"))return Q;return J??Q}function qJ(J){let Z=(J&&J.trim().length>0?J:kJ).replace(/\/+$/,"");if(Z.endsWith("/codex/responses"))return Z;if(Z.endsWith("/codex"))return`${Z}/responses`;return`${Z}/codex/responses`}function JQ(J){let Q=new URL(qJ(J));if(Q.protocol==="https:")Q.protocol="wss:";if(Q.protocol==="http:")Q.protocol="ws:";return Q.toString()}async function QQ(J,Q,Z,$,X,F){await r(HJ(NQ(J,F?.signal)),Q,Z,$,{serviceTier:F?.serviceTier,grammarToolInputProperties:X,resolveServiceTier:AJ,applyServiceTierPricing:(Y,G)=>RJ(Y,G,$)})}class T extends Error{code;payload;constructor(J,Q){super(J);this.name="CodexApiError",this.code=Q?.code,this.payload=Q?.payload,this.cause=Q?.cause}}class m extends Error{payload;constructor(J,Q){super(J);this.name="CodexProtocolError",this.payload=Q?.payload,this.cause=Q?.cause}}function ZQ(J){return J instanceof T||J instanceof m}function $Q(J){return J instanceof T&&J.code===pJ}function FQ(J){return J instanceof T&&J.code===cJ}function XQ(J){let Q=J.error&&typeof J.error==="object"?J.error:void 0;return{code:typeof J.code==="string"?J.code:typeof Q?.code==="string"?Q.code:void 0,message:typeof J.message==="string"?J.message:typeof Q?.message==="string"?Q.message:void 0}}async function*HJ(J){for await(let Q of J){let Z=typeof Q.type==="string"?Q.type:void 0;if(!Z)continue;if(Z==="error"){let{code:$,message:X}=XQ(Q);throw new T(`Codex error: ${X||$||JSON.stringify(Q)}`,{code:$,payload:Q})}if(Z==="response.failed"){let $=Q.response,X=$?.error?.code,F=$?.error?.message;throw new T(F||"Codex response failed",{code:X,payload:Q})}if(Z==="response.done"||Z==="response.completed"||Z==="response.incomplete"){let $=Q.response,X=$?{...$,status:YQ($.status)}:$;yield{...Q,type:"response.completed",response:X};return}yield Q}}function YQ(J){if(typeof J!=="string")return;return lJ.has(J)?J:void 0}async function*NQ(J,Q){if(!J.body)return;let Z=J.body.getReader(),$=new TextDecoder,X="",F=()=>{Z.cancel().catch(()=>{})};Q?.addEventListener("abort",F,{once:!0});try{while(!0){if(Q?.aborted)throw Error("Request was aborted");let{done:Y,value:G}=await Z.read();if(Q?.aborted)throw Error("Request was aborted");if(Y)break;X+=$.decode(G,{stream:!0});let N=X.indexOf(`
2
+ import{wd as GJ,xd as zJ}from"./chunk-kqqtt6bd.js";import{wm as OJ}from"./chunk-6gjg5egq.js";import{Am as WJ,Bm as r,zm as n}from"./chunk-mcc1scxs.js";import{Cm as jJ}from"./chunk-98ey5p2e.js";import"./chunk-xw2gpcsh.js";import{Hm as p}from"./chunk-xbhw6bpz.js";import"./chunk-jc1vb7rj.js";import{Wm as KJ,Xm as _J}from"./chunk-gtbsb39v.js";import{an as a,cn as LJ}from"./chunk-vsx96mt6.js";import"./chunk-tbbwss3v.js";import{gn as i}from"./chunk-6w2wmvqs.js";import{nn as DJ}from"./chunk-dn7sbjws.js";import{on as YJ,pn as y,qn as NJ,rn as VJ}from"./chunk-1phqxp6z.js";import"./chunk-dxyq9h8n.js";function o(J){let Q=J.filter((F)=>F!==void 0);if(Q.length===0)return{cleanup:()=>{}};if(Q.length===1)return{signal:Q[0],cleanup:()=>{}};let Z=new AbortController,$=[],X=(F)=>{if(!Z.signal.aborted)Z.abort(F.reason)};for(let F of Q){if(F.aborted){X(F);break}let Y=()=>X(F);F.addEventListener("abort",Y,{once:!0}),$.push({signal:F,listener:Y})}return{signal:Z.signal,cleanup:()=>{for(let{signal:F,listener:Y}of $)F.removeEventListener("abort",Y)}}}var fJ={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443};function c(J,Q){let Z=J.toLowerCase(),$=J.toUpperCase();return Q?.[Z]||Q?.[$]||p(Z)||p($)||""}function SJ(J){if(J instanceof URL)return J;try{return new URL(J)}catch{return}}function TJ(J,Q,Z){let $=c("no_proxy",Z).toLowerCase();if(!$)return!0;if($==="*")return!1;return $.split(/[,\s]/).every((X)=>{if(!X)return!0;let F=X.match(/^(.+):(\d+)$/),Y=F?F[1]:X,G=F?Number.parseInt(F[2],10):0;if(G&&G!==Q)return!0;if(!/^[.*]/.test(Y))return J!==Y;if(Y.startsWith("*"))Y=Y.slice(1);return!J.endsWith(Y)})}function hJ(J,Q){let Z=SJ(J);if(!Z?.protocol||!Z.host)return"";let $=Z.protocol.split(":",1)[0],X=Z.host.replace(/:\d*$/,""),F=Number.parseInt(Z.port,10)||fJ[$]||0;if(!TJ(X,F,Q))return"";let Y=c(`${$}_proxy`,Q)||c("all_proxy",Q);if(Y&&!Y.includes("://"))Y=`${$}://${Y}`;return Y}var xJ="Unsupported proxy protocol. SOCKS and PAC proxy URLs are not supported; use an HTTP or HTTPS proxy URL.";function e(J,Q){let Z=hJ(J,Q);if(!Z)return;let $;try{$=new URL(Z)}catch(X){throw Error(`Invalid proxy URL ${JSON.stringify(Z)}: ${X instanceof Error?X.message:String(X)}`)}if($.protocol!=="http:"&&$.protocol!=="https:")throw Error(`${xJ} Got ${$.protocol}`);return $}function bJ(){if(typeof process>"u"||!(process.versions?.node||process.versions?.bun))return null;return process.getBuiltinModule?.("node:os")??null}var I=bJ(),kJ="https://chatgpt.com/backend-api",IJ="https://api.openai.com/auth",gJ=0,JJ=1000,vJ=60000,yJ=15000,mJ=3,BJ=new Set(["openai","openai-codex","opencode"]),uJ=1009,pJ="websocket_connection_limit_reached",cJ="previous_response_not_found",lJ=new Set(["completed","incomplete","failed","cancelled","queued","in_progress"]);function dJ(J){return/GoUsageLimitError|FreeUsageLimitError|Monthly usage limit reached|available balance|insufficient_quota|out of budget|quota exceeded|billing/i.test(J)}function iJ(J,Q){if(J===429&&dJ(Q))return!1;if(J===429||J===500||J===502||J===503||J===504)return!0;return/rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(Q)}function aJ(J){let Q=J.get("retry-after-ms");if(Q!==null){let F=Number(Q);if(Number.isFinite(F))return Math.max(0,F)}let Z=J.get("retry-after");if(!Z)return;let $=Number(Z);if(Number.isFinite($))return Math.max(0,$*1000);let X=Date.parse(Z);if(!Number.isNaN(X))return Math.max(0,X-Date.now());return}class t extends Error{}function nJ(J,Q){let Z=Q?.maxRetryDelayMs??vJ;if(Z>0&&J>Z)throw new t(`Server requested ${Math.ceil(J/1000)}s retry delay (max: ${Math.ceil(Z/1000)}s)`);return J}function QJ(J,Q){return new Promise((Z,$)=>{if(Q?.aborted){$(Error("Request was aborted"));return}let X=setTimeout(Z,J);Q?.addEventListener("abort",()=>{clearTimeout(X),$(Error("Request was aborted"))})})}function ZJ(J){if(J===void 0)return;if(!Number.isFinite(J)||J<0)throw Error(`Invalid timeoutMs: ${String(J)}`);return Math.floor(J)}function rJ(){if(typeof process>"u"||!(process.versions?.node||process.versions?.bun))return null;return process.getBuiltinModule?.("node:zlib")??null}function tJ(J){let Q=rJ();if(!Q||typeof Q.zstdCompressSync!=="function")return null;try{let Z=Q.zstdCompressSync(J,{params:{[Q.constants.ZSTD_c_compressionLevel]:mJ}});return new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength)}catch{return null}}var sJ=(J,Q,Z)=>{let $=new YJ;return(async()=>{let X={role:"assistant",content:[],api:"openai-codex-responses",provider:J.provider,model:J.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let F=Z?.apiKey;if(!F)throw Error(`No API key for provider: ${J.provider}`);let Y=UQ(F),G=a(Q.tools,J.compat?.supportsOpenAIGrammarTools??!1),N=Z?.cacheRetention==="none"?void 0:Z?.sessionId,V=jJ(N),K=oJ(J,Q,Z,V,G),D=await Z?.onPayload?.(K,J);if(D!==void 0)K=D;let R=V||zJ(),z=CQ(J.headers,Z?.headers,Y,F,V),A=MQ(J.headers,Z?.headers,Y,F,R),j=JSON.stringify(K),_=ZJ(Z?.timeoutMs),U=ZJ(Z?.websocketConnectTimeoutMs),L=Z?.transport||"auto",W=!1,O=L!=="sse"&&EJ(N);if(O)$J(N);if(L!=="sse"&&!O){let B=!1,H=!1,M=!1;while(!0){B=!1;try{if(await wQ(JQ(J.baseUrl),K,A,X,$,J,()=>{if(B=!0,!W)W=!0,$.push({type:"start",partial:X})},_,U,N,G,Z),Z?.signal?.aborted)throw Error("Request was aborted");$.push({type:"done",reason:X.stopReason,message:X}),$.end();return}catch(w){let x=Z?.signal?.aborted,b=!B&&$Q(w),S=FQ(w);if(!x&&S&&!M){M=!0;continue}if(!x&&b&&!H){H=!0;continue}if(x||ZQ(w)&&!b)throw w;if(VJ(X,NJ("provider_transport_failure",w,{configuredTransport:L,fallbackTransport:B?void 0:"sse",eventsEmitted:B,phase:B?"after_message_stream_start":"before_message_stream_start",requestBytes:new TextEncoder().encode(j).byteLength})),KQ(N,w),B)throw w;$J(N);break}}}let C=tJ(j);if(C)z.set("content-encoding","zstd");let f=C??j,q,h,u=Z?.maxRetries??gJ;for(let B=0;B<=u;B++){if(Z?.signal?.aborted)throw Error("Request was aborted");try{let H=_!==void 0&&_>0?AbortSignal.timeout(_):void 0,M=o([Z?.signal,H]);try{q=await fetch(qJ(J.baseUrl),{method:"POST",headers:z,body:f,signal:M.signal})}catch(S){if(H?.aborted&&!Z?.signal?.aborted)throw Error(`Codex SSE response headers timed out after ${_}ms`);throw S}finally{M.cleanup()}if(await Z?.onResponse?.({status:q.status,headers:i(q.headers)},J),q.ok)break;let w=await q.text();if(B<u&&iJ(q.status,w)){let S=aJ(q.headers),MJ=S===void 0?JJ*2**B:nJ(S,Z);await QJ(MJ,Z?.signal);continue}let x=new Response(w,{status:q.status,statusText:q.statusText}),b=await PQ(x);throw Error(b.friendlyMessage||b.message)}catch(H){if(H instanceof Error){if(H.name==="AbortError"||H.message==="Request was aborted")throw Error("Request was aborted")}if(h=H instanceof Error?H:Error(String(H)),B<u&&!(h instanceof t)&&!h.message.includes("usage limit")){let M=JJ*2**B;await QJ(M,Z?.signal);continue}throw h}}if(!q?.ok)throw h??Error("Failed after retries");if(!q.body)throw Error("No response body");if(!W)W=!0,$.push({type:"start",partial:X});if(await QQ(q,X,$,J,G,Z),Z?.signal?.aborted)throw Error("Request was aborted");$.push({type:"done",reason:X.stopReason,message:X}),$.end()}catch(F){for(let Y of X.content)delete Y.partialJson,delete Y.customInput;X.stopReason=Z?.signal?.aborted?"aborted":"error",X.errorMessage=_J(KJ(F)),$.push({type:"error",reason:X.stopReason,error:X}),$.end()}})(),$},iQ=(J,Q,Z)=>{let $=Z?.apiKey;if(!$)throw Error(`No API key for provider: ${J.provider}`);let X=LJ(J,Q,Z,$),F=Z?.reasoning?DJ(J,Z.reasoning):void 0;return sJ(J,Q,{...X,reasoningEffort:F==="off"?void 0:F})};function oJ(J,Q,Z,$,X=a(Q.tools,J.compat?.supportsOpenAIGrammarTools??!1)){let F=J.compat?.supportsStrictMode??!0,Y=J.compat?.supportsOpenAIGrammarTools??!1,G=OJ(Q,J.compat?.supportsToolSearch??!1),N=n(J,Q,BJ,{includeSystemPrompt:!1,grammarToolInputProperties:X,deferredTools:G.deferred,toolOptions:{strict:null,supportsStrictMode:F,supportsOpenAIGrammarTools:Y}}),V={model:J.id,store:!1,stream:!0,instructions:Q.systemPrompt||"You are a helpful assistant.",input:N,text:{verbosity:Z?.textVerbosity||"low"},include:["reasoning.encrypted_content"],prompt_cache_key:$,tool_choice:Z?.toolChoice??"auto",parallel_tool_calls:!0};if(Z?.temperature!==void 0)V.temperature=Z.temperature;if(Z?.serviceTier!==void 0)V.service_tier=Z.serviceTier;if(G.immediate.length>0)V.tools=WJ(G.immediate,{strict:null,supportsStrictMode:F,supportsOpenAIGrammarTools:Y});if(Z?.reasoningEffort!==void 0){let K=Z.reasoningEffort==="none"?J.thinkingLevelMap?.off??"none":J.thinkingLevelMap?.[Z.reasoningEffort]??Z.reasoningEffort;if(K!==null)V.reasoning={effort:K,summary:Z.reasoningSummary??"auto"}}return V}function eJ(J,Q){switch(Q){case"flex":return 0.5;case"priority":return J.id==="gpt-5.5"?2.5:2;default:return 1}}function RJ(J,Q,Z){let $=eJ(Z,Q);if($===1)return;J.cost.input*=$,J.cost.output*=$,J.cost.cacheRead*=$,J.cost.cacheWrite*=$,J.cost.total=J.cost.input+J.cost.output+J.cost.cacheRead+J.cost.cacheWrite}function AJ(J,Q){if(J==="default"&&(Q==="flex"||Q==="priority"))return Q;return J??Q}function qJ(J){let Z=(J&&J.trim().length>0?J:kJ).replace(/\/+$/,"");if(Z.endsWith("/codex/responses"))return Z;if(Z.endsWith("/codex"))return`${Z}/responses`;return`${Z}/codex/responses`}function JQ(J){let Q=new URL(qJ(J));if(Q.protocol==="https:")Q.protocol="wss:";if(Q.protocol==="http:")Q.protocol="ws:";return Q.toString()}async function QQ(J,Q,Z,$,X,F){await r(HJ(NQ(J,F?.signal)),Q,Z,$,{serviceTier:F?.serviceTier,grammarToolInputProperties:X,resolveServiceTier:AJ,applyServiceTierPricing:(Y,G)=>RJ(Y,G,$)})}class T extends Error{code;payload;constructor(J,Q){super(J);this.name="CodexApiError",this.code=Q?.code,this.payload=Q?.payload,this.cause=Q?.cause}}class m extends Error{payload;constructor(J,Q){super(J);this.name="CodexProtocolError",this.payload=Q?.payload,this.cause=Q?.cause}}function ZQ(J){return J instanceof T||J instanceof m}function $Q(J){return J instanceof T&&J.code===pJ}function FQ(J){return J instanceof T&&J.code===cJ}function XQ(J){let Q=J.error&&typeof J.error==="object"?J.error:void 0;return{code:typeof J.code==="string"?J.code:typeof Q?.code==="string"?Q.code:void 0,message:typeof J.message==="string"?J.message:typeof Q?.message==="string"?Q.message:void 0}}async function*HJ(J){for await(let Q of J){let Z=typeof Q.type==="string"?Q.type:void 0;if(!Z)continue;if(Z==="error"){let{code:$,message:X}=XQ(Q);throw new T(`Codex error: ${X||$||JSON.stringify(Q)}`,{code:$,payload:Q})}if(Z==="response.failed"){let $=Q.response,X=$?.error?.code,F=$?.error?.message;throw new T(F||"Codex response failed",{code:X,payload:Q})}if(Z==="response.done"||Z==="response.completed"||Z==="response.incomplete"){let $=Q.response,X=$?{...$,status:YQ($.status)}:$;yield{...Q,type:"response.completed",response:X};return}yield Q}}function YQ(J){if(typeof J!=="string")return;return lJ.has(J)?J:void 0}async function*NQ(J,Q){if(!J.body)return;let Z=J.body.getReader(),$=new TextDecoder,X="",F=()=>{Z.cancel().catch(()=>{})};Q?.addEventListener("abort",F,{once:!0});try{while(!0){if(Q?.aborted)throw Error("Request was aborted");let{done:Y,value:G}=await Z.read();if(Q?.aborted)throw Error("Request was aborted");if(Y)break;X+=$.decode(G,{stream:!0});let N=X.indexOf(`
3
3
 
4
4
  `);while(N!==-1){let V=X.slice(0,N);X=X.slice(N+2);let K=V.split(`
5
5
  `).filter((D)=>D.startsWith("data:")).map((D)=>D.slice(5).trim());if(K.length>0){let D=K.join(`
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{rn as a,sn as _}from"./chunk-txkmks1h.js";var f=_((J)=>{Object.defineProperty(J,"__esModule",{value:!0});J.Allow=J.ALL=J.COLLECTION=J.ATOM=J.SPECIAL=J.INF=J._INFINITY=J.INFINITY=J.NAN=J.BOOL=J.NULL=J.OBJ=J.ARR=J.NUM=J.STR=void 0;J.STR=1;J.NUM=2;J.ARR=4;J.OBJ=8;J.NULL=16;J.BOOL=32;J.NAN=64;J.INFINITY=128;J._INFINITY=256;J.INF=J.INFINITY|J._INFINITY;J.SPECIAL=J.NULL|J.BOOL|J.INF|J.NAN;J.ATOM=J.STR|J.NUM|J.SPECIAL;J.COLLECTION=J.ARR|J.OBJ;J.ALL=J.ATOM|J.COLLECTION;J.Allow={STR:J.STR,NUM:J.NUM,ARR:J.ARR,OBJ:J.OBJ,NULL:J.NULL,BOOL:J.BOOL,NAN:J.NAN,INFINITY:J.INFINITY,_INFINITY:J._INFINITY,INF:J.INF,SPECIAL:J.SPECIAL,ATOM:J.ATOM,COLLECTION:J.COLLECTION,ALL:J.ALL};J.default=J.Allow});var w=_((X)=>{var d=X&&X.__createBinding||(Object.create?function(F,G,H,z){if(z===void 0)z=H;var K=Object.getOwnPropertyDescriptor(G,H);if(!K||("get"in K?!G.__esModule:K.writable||K.configurable))K={enumerable:!0,get:function(){return G[H]}};Object.defineProperty(F,z,K)}:function(F,G,H,z){if(z===void 0)z=H;F[z]=G[H]}),x=X&&X.__exportStar||function(F,G){for(var H in F)if(H!=="default"&&!Object.prototype.hasOwnProperty.call(G,H))d(G,F,H)};Object.defineProperty(X,"__esModule",{value:!0});X.Allow=X.MalformedJSON=X.PartialJSON=X.parseJSON=X.parse=void 0;var Y=f();Object.defineProperty(X,"Allow",{enumerable:!0,get:function(){return Y.Allow}});x(f(),X);class b extends Error{}X.PartialJSON=b;class P extends Error{}X.MalformedJSON=P;function m(F,G=Y.Allow.ALL){if(typeof F!=="string")throw TypeError(`expecting str, got ${typeof F}`);if(!F.trim())throw Error(`${F} is empty`);return p(F.trim(),G)}X.parseJSON=m;var p=(F,G)=>{let H=F.length,z=0,K=(Q)=>{throw new b(`${Q} at position ${z}`)},$=(Q)=>{throw new P(`${Q} at position ${z}`)},U=()=>{if(V(),z>=H)K("Unexpected end of input");if(F[z]==='"')return O();if(F[z]==="{")return c();if(F[z]==="[")return j();if(F.substring(z,z+4)==="null"||Y.Allow.NULL&G&&H-z<4&&"null".startsWith(F.substring(z)))return z+=4,null;if(F.substring(z,z+4)==="true"||Y.Allow.BOOL&G&&H-z<4&&"true".startsWith(F.substring(z)))return z+=4,!0;if(F.substring(z,z+5)==="false"||Y.Allow.BOOL&G&&H-z<5&&"false".startsWith(F.substring(z)))return z+=5,!1;if(F.substring(z,z+8)==="Infinity"||Y.Allow.INFINITY&G&&H-z<8&&"Infinity".startsWith(F.substring(z)))return z+=8,1/0;if(F.substring(z,z+9)==="-Infinity"||Y.Allow._INFINITY&G&&1<H-z&&H-z<9&&"-Infinity".startsWith(F.substring(z)))return z+=9,-1/0;if(F.substring(z,z+3)==="NaN"||Y.Allow.NAN&G&&H-z<3&&"NaN".startsWith(F.substring(z)))return z+=3,NaN;return g()},O=()=>{let Q=z,Z=!1;z++;while(z<H&&(F[z]!=='"'||Z&&F[z-1]==="\\"))Z=F[z]==="\\"?!Z:!1,z++;if(F.charAt(z)=='"')try{return JSON.parse(F.substring(Q,++z-Number(Z)))}catch(q){$(String(q))}else if(Y.Allow.STR&G)try{return JSON.parse(F.substring(Q,z-Number(Z))+'"')}catch(q){return JSON.parse(F.substring(Q,F.lastIndexOf("\\"))+'"')}K("Unterminated string literal")},c=()=>{z++,V();let Q={};try{while(F[z]!=="}"){if(V(),z>=H&&Y.Allow.OBJ&G)return Q;let Z=O();V(),z++;try{let q=U();Q[Z]=q}catch(q){if(Y.Allow.OBJ&G)return Q;else throw q}if(V(),F[z]===",")z++}}catch(Z){if(Y.Allow.OBJ&G)return Q;else K("Expected '}' at end of object")}return z++,Q},j=()=>{z++;let Q=[];try{while(F[z]!=="]")if(Q.push(U()),V(),F[z]===",")z++}catch(Z){if(Y.Allow.ARR&G)return Q;K("Expected ']' at end of array")}return z++,Q},g=()=>{if(z===0){if(F==="-")$("Not sure what '-' is");try{return JSON.parse(F)}catch(Z){if(Y.Allow.NUM&G)try{return JSON.parse(F.substring(0,F.lastIndexOf("e")))}catch(q){}$(String(Z))}}let Q=z;if(F[z]==="-")z++;while(F[z]&&",]}".indexOf(F[z])===-1)z++;if(z==H&&!(Y.Allow.NUM&G))K("Unterminated number literal");try{return JSON.parse(F.substring(Q,z))}catch(Z){if(F.substring(Q,z)==="-")K("Not sure what '-' is");try{return JSON.parse(F.substring(Q,F.lastIndexOf("e")))}catch(q){$(String(q))}}},V=()=>{while(z<H&&`
2
+ import{sn as a,tn as _}from"./chunk-dxyq9h8n.js";var f=_((J)=>{Object.defineProperty(J,"__esModule",{value:!0});J.Allow=J.ALL=J.COLLECTION=J.ATOM=J.SPECIAL=J.INF=J._INFINITY=J.INFINITY=J.NAN=J.BOOL=J.NULL=J.OBJ=J.ARR=J.NUM=J.STR=void 0;J.STR=1;J.NUM=2;J.ARR=4;J.OBJ=8;J.NULL=16;J.BOOL=32;J.NAN=64;J.INFINITY=128;J._INFINITY=256;J.INF=J.INFINITY|J._INFINITY;J.SPECIAL=J.NULL|J.BOOL|J.INF|J.NAN;J.ATOM=J.STR|J.NUM|J.SPECIAL;J.COLLECTION=J.ARR|J.OBJ;J.ALL=J.ATOM|J.COLLECTION;J.Allow={STR:J.STR,NUM:J.NUM,ARR:J.ARR,OBJ:J.OBJ,NULL:J.NULL,BOOL:J.BOOL,NAN:J.NAN,INFINITY:J.INFINITY,_INFINITY:J._INFINITY,INF:J.INF,SPECIAL:J.SPECIAL,ATOM:J.ATOM,COLLECTION:J.COLLECTION,ALL:J.ALL};J.default=J.Allow});var w=_((X)=>{var d=X&&X.__createBinding||(Object.create?function(F,G,H,z){if(z===void 0)z=H;var K=Object.getOwnPropertyDescriptor(G,H);if(!K||("get"in K?!G.__esModule:K.writable||K.configurable))K={enumerable:!0,get:function(){return G[H]}};Object.defineProperty(F,z,K)}:function(F,G,H,z){if(z===void 0)z=H;F[z]=G[H]}),x=X&&X.__exportStar||function(F,G){for(var H in F)if(H!=="default"&&!Object.prototype.hasOwnProperty.call(G,H))d(G,F,H)};Object.defineProperty(X,"__esModule",{value:!0});X.Allow=X.MalformedJSON=X.PartialJSON=X.parseJSON=X.parse=void 0;var Y=f();Object.defineProperty(X,"Allow",{enumerable:!0,get:function(){return Y.Allow}});x(f(),X);class b extends Error{}X.PartialJSON=b;class P extends Error{}X.MalformedJSON=P;function m(F,G=Y.Allow.ALL){if(typeof F!=="string")throw TypeError(`expecting str, got ${typeof F}`);if(!F.trim())throw Error(`${F} is empty`);return p(F.trim(),G)}X.parseJSON=m;var p=(F,G)=>{let H=F.length,z=0,K=(Q)=>{throw new b(`${Q} at position ${z}`)},$=(Q)=>{throw new P(`${Q} at position ${z}`)},U=()=>{if(V(),z>=H)K("Unexpected end of input");if(F[z]==='"')return O();if(F[z]==="{")return c();if(F[z]==="[")return j();if(F.substring(z,z+4)==="null"||Y.Allow.NULL&G&&H-z<4&&"null".startsWith(F.substring(z)))return z+=4,null;if(F.substring(z,z+4)==="true"||Y.Allow.BOOL&G&&H-z<4&&"true".startsWith(F.substring(z)))return z+=4,!0;if(F.substring(z,z+5)==="false"||Y.Allow.BOOL&G&&H-z<5&&"false".startsWith(F.substring(z)))return z+=5,!1;if(F.substring(z,z+8)==="Infinity"||Y.Allow.INFINITY&G&&H-z<8&&"Infinity".startsWith(F.substring(z)))return z+=8,1/0;if(F.substring(z,z+9)==="-Infinity"||Y.Allow._INFINITY&G&&1<H-z&&H-z<9&&"-Infinity".startsWith(F.substring(z)))return z+=9,-1/0;if(F.substring(z,z+3)==="NaN"||Y.Allow.NAN&G&&H-z<3&&"NaN".startsWith(F.substring(z)))return z+=3,NaN;return g()},O=()=>{let Q=z,Z=!1;z++;while(z<H&&(F[z]!=='"'||Z&&F[z-1]==="\\"))Z=F[z]==="\\"?!Z:!1,z++;if(F.charAt(z)=='"')try{return JSON.parse(F.substring(Q,++z-Number(Z)))}catch(q){$(String(q))}else if(Y.Allow.STR&G)try{return JSON.parse(F.substring(Q,z-Number(Z))+'"')}catch(q){return JSON.parse(F.substring(Q,F.lastIndexOf("\\"))+'"')}K("Unterminated string literal")},c=()=>{z++,V();let Q={};try{while(F[z]!=="}"){if(V(),z>=H&&Y.Allow.OBJ&G)return Q;let Z=O();V(),z++;try{let q=U();Q[Z]=q}catch(q){if(Y.Allow.OBJ&G)return Q;else throw q}if(V(),F[z]===",")z++}}catch(Z){if(Y.Allow.OBJ&G)return Q;else K("Expected '}' at end of object")}return z++,Q},j=()=>{z++;let Q=[];try{while(F[z]!=="]")if(Q.push(U()),V(),F[z]===",")z++}catch(Z){if(Y.Allow.ARR&G)return Q;K("Expected ']' at end of array")}return z++,Q},g=()=>{if(z===0){if(F==="-")$("Not sure what '-' is");try{return JSON.parse(F)}catch(Z){if(Y.Allow.NUM&G)try{return JSON.parse(F.substring(0,F.lastIndexOf("e")))}catch(q){}$(String(Z))}}let Q=z;if(F[z]==="-")z++;while(F[z]&&",]}".indexOf(F[z])===-1)z++;if(z==H&&!(Y.Allow.NUM&G))K("Unterminated number literal");try{return JSON.parse(F.substring(Q,z))}catch(Z){if(F.substring(Q,z)==="-")K("Not sure what '-' is");try{return JSON.parse(F.substring(Q,F.lastIndexOf("e")))}catch(q){$(String(q))}}},V=()=>{while(z<H&&`
3
3
  \r `.includes(F[z]))z++};return U()},l=m;X.parse=l});var N=a(w(),1),e=new Set(['"',"\\","/","b","f","n","r","t","u"]);function s(F){let G=F.codePointAt(0);return G!==void 0&&G>=0&&G<=31}function t(F){switch(F){case"\b":return"\\b";case"\f":return"\\f";case`
4
4
  `:return"\\n";case"\r":return"\\r";case"\t":return"\\t";default:return`\\u${F.codePointAt(0)?.toString(16).padStart(4,"0")??"0000"}`}}function k(F){let G="",H=!1;for(let z=0;z<F.length;z++){let K=F[z];if(!H){if(G+=K,K==='"')H=!0;continue}if(K==='"'){G+=K,H=!1;continue}if(K==="\\"){let $=F[z+1];if($===void 0){G+="\\\\";continue}if($==="u"){let U=F.slice(z+2,z+6);if(/^[0-9a-fA-F]{4}$/.test(U)){G+=`\\u${U}`,z+=5;continue}}if(e.has($)){G+=`\\${$}`,z+=1;continue}G+="\\\\";continue}G+=s(K)?t(K):K}return G}function i(F){try{return JSON.parse(F)}catch(G){let H=k(F);if(H!==F)return JSON.parse(H);throw G}}function n(F){if(!F||F.trim()==="")return{};try{return i(F)}catch{try{return N.parse(F)??{}}catch{try{return N.parse(k(F))??{}}catch{return{}}}}}
5
- export{i as Hm,n as Im};
5
+ export{i as Im,n as Jm};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import"./chunk-kryt6pg3.js";import{$a as I,rb as w}from"./chunk-wfee9d83.js";import"./chunk-za7ga4bf.js";import"./chunk-txkmks1h.js";function R(q,$){if(typeof q==="string"&&typeof $==="string")return q.toLowerCase()===$.toLowerCase();return q===$}function y(q,$){if(typeof q!=="string")return $.includes(q);return $.some((E)=>typeof E==="string"&&q.toLowerCase()===E.toLowerCase())}function j(q,$){return!y(q,$)}function g(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().includes($.toLowerCase())}function f(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().startsWith($.toLowerCase())}function V(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().endsWith($.toLowerCase())}var v=(q,$)=>{let E=null,M=w({config:{adapterId:"memory",adapterName:"Memory Adapter",usePlural:!1,debugLogs:$?.debugLogs||!1,supportsArrays:!0,customTransformInput(P){if(P.options.advanced?.database?.generateId==="serial"&&P.field==="id"&&P.action==="create")return q[P.model].length+1;return P.data},transaction:async(P)=>{let A=structuredClone(q);try{return await P(M(E))}catch(_){throw Object.keys(q).forEach((S)=>{q[S]=A[S]}),_}}},adapter:({getFieldName:P,getDefaultFieldName:A,options:_,getModelName:S})=>{let N=(x,K,Y)=>{if(!K)return x;return x.sort((L,Z)=>{let z=P({model:Y,field:K.field}),D=L[z],X=Z[z],Q=0;if(D==null&&X==null)Q=0;else if(D==null)Q=-1;else if(X==null)Q=1;else if(typeof D==="string"&&typeof X==="string")Q=D.localeCompare(X);else if(D instanceof Date&&X instanceof Date)Q=D.getTime()-X.getTime();else if(typeof D==="number"&&typeof X==="number")Q=D-X;else if(typeof D==="boolean"&&typeof X==="boolean")Q=D===X?0:D?1:-1;else Q=String(D).localeCompare(String(X));return K.direction==="asc"?Q:-Q})};function F(x,K,Y,L){let Z=(()=>{let X=q[K];if(!X)throw I.error(`[MemoryAdapter] Model ${K} not found in the DB`,Object.keys(q)),Error(`Model ${K} not found`);let Q=(G,O)=>{let{field:J,value:H,operator:B,mode:k="sensitive"}=O,U=k==="insensitive"&&(typeof H==="string"||Array.isArray(H)&&H.every((W)=>typeof W==="string"));switch(B){case"in":if(!Array.isArray(H))throw Error("Value must be an array");if(U)return y(G[J],H);return H.includes(G[J]);case"not_in":if(!Array.isArray(H))throw Error("Value must be an array");if(U)return j(G[J],H);return!H.includes(G[J]);case"contains":if(U)return g(G[J],H);return G[J]?.includes(H);case"starts_with":if(U)return f(G[J],H);return G[J].startsWith(H);case"ends_with":if(U)return V(G[J],H);return G[J].endsWith(H);case"ne":return U?!R(G[J],H):G[J]!==H;case"gt":return H!=null&&Boolean(G[J]>H);case"gte":return H!=null&&Boolean(G[J]>=H);case"lt":return H!=null&&Boolean(G[J]<H);case"lte":return H!=null&&Boolean(G[J]<=H);default:if(U)return R(G[J],H);if(H===null)return G[J]==null;return G[J]===H}},T=X.filter((G)=>{if(!x.length||x.length===0)return!0;let O=Q(G,x[0]);for(let J of x){let H=Q(G,J);if(J.connector==="OR")O=O||H;else O=O&&H}return O});if(L?.length&&L.length>0)T=T.map((G)=>Object.fromEntries(Object.entries(G).filter(([O])=>L.includes(A({model:K,field:O})))));return T})();if(!Y)return Z;let z=new Map,D=new Map;for(let X of Z){let Q=String(X.id);if(!z.has(Q)){let G={...X};for(let[O,J]of Object.entries(Y)){let H=S(O);if(J.relation==="one-to-one")G[H]=null;else G[H]=[],D.set(`${Q}-${O}`,new Set)}z.set(Q,G)}let T=z.get(Q);for(let[G,O]of Object.entries(Y)){let J=S(G),H=q[J];if(!H)throw I.error(`[MemoryAdapter] JoinOption model ${J} not found in the DB`,Object.keys(q)),Error(`JoinOption model ${J} not found`);let B=H.filter((k)=>k[O.on.to]===X[O.on.from]);if(O.relation==="one-to-one")T[J]=B[0]||null;else{let k=D.get(`${Q}-${G}`),U=O.limit??100,W=0;for(let C of B){if(W>=U)break;if(!k.has(C.id))T[J].push(C),k.add(C.id),W++}}}}return Array.from(z.values())}return{create:async({model:x,data:K})=>{if(_.advanced?.database?.generateId==="serial")K.id=q[S(x)].length+1;if(!q[x])q[x]=[];return q[x].push(K),K},findOne:async({model:x,where:K,select:Y,join:L})=>{let Z=F(K,x,L,Y);if(L){let z=Z;if(!z.length)return null;return z[0]}return Z[0]||null},findMany:async({model:x,where:K,sortBy:Y,limit:L,select:Z,offset:z,join:D})=>{let X=F(K||[],x,D,Z);if(D){let T=X;if(!T.length)return[];N(T,Y,x);let G=T;if(z!==void 0)G=G.slice(z);if(L!==void 0)G=G.slice(0,L);return G}let Q=N(X,Y,x);if(z!==void 0)Q=Q.slice(z);if(L!==void 0)Q=Q.slice(0,L);return Q||[]},count:async({model:x,where:K})=>{if(K)return F(K,x).length;return q[x].length},update:async({model:x,where:K,update:Y})=>{let L=F(K,x);return L.forEach((Z)=>{Object.assign(Z,Y)}),L[0]||null},delete:async({model:x,where:K})=>{let Y=q[x],L=F(K,x);q[x]=Y.filter((Z)=>!L.includes(Z))},deleteMany:async({model:x,where:K})=>{let Y=q[x],L=F(K,x),Z=0;return q[x]=Y.filter((z)=>{if(L.includes(z))return Z++,!1;return!L.includes(z)}),Z},consumeOne:async({model:x,where:K})=>{let Y=q[x],L=F(K,x)[0];if(!L)return null;return q[x]=Y.filter((Z)=>Z!==L),L},updateMany({model:x,where:K,update:Y}){let L=F(K,x);return L.forEach((Z)=>{Object.assign(Z,Y)}),L[0]||null}}}});return(P)=>{return E=P,M(P)}};export{v as memoryAdapter};
2
+ import"./chunk-xg9xscqz.js";import{ab as I,sb as w}from"./chunk-knz4h56q.js";import"./chunk-7thx8ctx.js";import"./chunk-dxyq9h8n.js";function R(q,$){if(typeof q==="string"&&typeof $==="string")return q.toLowerCase()===$.toLowerCase();return q===$}function y(q,$){if(typeof q!=="string")return $.includes(q);return $.some((E)=>typeof E==="string"&&q.toLowerCase()===E.toLowerCase())}function j(q,$){return!y(q,$)}function g(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().includes($.toLowerCase())}function f(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().startsWith($.toLowerCase())}function V(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().endsWith($.toLowerCase())}var v=(q,$)=>{let E=null,M=w({config:{adapterId:"memory",adapterName:"Memory Adapter",usePlural:!1,debugLogs:$?.debugLogs||!1,supportsArrays:!0,customTransformInput(P){if(P.options.advanced?.database?.generateId==="serial"&&P.field==="id"&&P.action==="create")return q[P.model].length+1;return P.data},transaction:async(P)=>{let A=structuredClone(q);try{return await P(M(E))}catch(_){throw Object.keys(q).forEach((S)=>{q[S]=A[S]}),_}}},adapter:({getFieldName:P,getDefaultFieldName:A,options:_,getModelName:S})=>{let N=(x,K,Y)=>{if(!K)return x;return x.sort((L,Z)=>{let z=P({model:Y,field:K.field}),D=L[z],X=Z[z],Q=0;if(D==null&&X==null)Q=0;else if(D==null)Q=-1;else if(X==null)Q=1;else if(typeof D==="string"&&typeof X==="string")Q=D.localeCompare(X);else if(D instanceof Date&&X instanceof Date)Q=D.getTime()-X.getTime();else if(typeof D==="number"&&typeof X==="number")Q=D-X;else if(typeof D==="boolean"&&typeof X==="boolean")Q=D===X?0:D?1:-1;else Q=String(D).localeCompare(String(X));return K.direction==="asc"?Q:-Q})};function F(x,K,Y,L){let Z=(()=>{let X=q[K];if(!X)throw I.error(`[MemoryAdapter] Model ${K} not found in the DB`,Object.keys(q)),Error(`Model ${K} not found`);let Q=(G,O)=>{let{field:J,value:H,operator:B,mode:k="sensitive"}=O,U=k==="insensitive"&&(typeof H==="string"||Array.isArray(H)&&H.every((W)=>typeof W==="string"));switch(B){case"in":if(!Array.isArray(H))throw Error("Value must be an array");if(U)return y(G[J],H);return H.includes(G[J]);case"not_in":if(!Array.isArray(H))throw Error("Value must be an array");if(U)return j(G[J],H);return!H.includes(G[J]);case"contains":if(U)return g(G[J],H);return G[J]?.includes(H);case"starts_with":if(U)return f(G[J],H);return G[J].startsWith(H);case"ends_with":if(U)return V(G[J],H);return G[J].endsWith(H);case"ne":return U?!R(G[J],H):G[J]!==H;case"gt":return H!=null&&Boolean(G[J]>H);case"gte":return H!=null&&Boolean(G[J]>=H);case"lt":return H!=null&&Boolean(G[J]<H);case"lte":return H!=null&&Boolean(G[J]<=H);default:if(U)return R(G[J],H);if(H===null)return G[J]==null;return G[J]===H}},T=X.filter((G)=>{if(!x.length||x.length===0)return!0;let O=Q(G,x[0]);for(let J of x){let H=Q(G,J);if(J.connector==="OR")O=O||H;else O=O&&H}return O});if(L?.length&&L.length>0)T=T.map((G)=>Object.fromEntries(Object.entries(G).filter(([O])=>L.includes(A({model:K,field:O})))));return T})();if(!Y)return Z;let z=new Map,D=new Map;for(let X of Z){let Q=String(X.id);if(!z.has(Q)){let G={...X};for(let[O,J]of Object.entries(Y)){let H=S(O);if(J.relation==="one-to-one")G[H]=null;else G[H]=[],D.set(`${Q}-${O}`,new Set)}z.set(Q,G)}let T=z.get(Q);for(let[G,O]of Object.entries(Y)){let J=S(G),H=q[J];if(!H)throw I.error(`[MemoryAdapter] JoinOption model ${J} not found in the DB`,Object.keys(q)),Error(`JoinOption model ${J} not found`);let B=H.filter((k)=>k[O.on.to]===X[O.on.from]);if(O.relation==="one-to-one")T[J]=B[0]||null;else{let k=D.get(`${Q}-${G}`),U=O.limit??100,W=0;for(let C of B){if(W>=U)break;if(!k.has(C.id))T[J].push(C),k.add(C.id),W++}}}}return Array.from(z.values())}return{create:async({model:x,data:K})=>{if(_.advanced?.database?.generateId==="serial")K.id=q[S(x)].length+1;if(!q[x])q[x]=[];return q[x].push(K),K},findOne:async({model:x,where:K,select:Y,join:L})=>{let Z=F(K,x,L,Y);if(L){let z=Z;if(!z.length)return null;return z[0]}return Z[0]||null},findMany:async({model:x,where:K,sortBy:Y,limit:L,select:Z,offset:z,join:D})=>{let X=F(K||[],x,D,Z);if(D){let T=X;if(!T.length)return[];N(T,Y,x);let G=T;if(z!==void 0)G=G.slice(z);if(L!==void 0)G=G.slice(0,L);return G}let Q=N(X,Y,x);if(z!==void 0)Q=Q.slice(z);if(L!==void 0)Q=Q.slice(0,L);return Q||[]},count:async({model:x,where:K})=>{if(K)return F(K,x).length;return q[x].length},update:async({model:x,where:K,update:Y})=>{let L=F(K,x);return L.forEach((Z)=>{Object.assign(Z,Y)}),L[0]||null},delete:async({model:x,where:K})=>{let Y=q[x],L=F(K,x);q[x]=Y.filter((Z)=>!L.includes(Z))},deleteMany:async({model:x,where:K})=>{let Y=q[x],L=F(K,x),Z=0;return q[x]=Y.filter((z)=>{if(L.includes(z))return Z++,!1;return!L.includes(z)}),Z},consumeOne:async({model:x,where:K})=>{let Y=q[x],L=F(K,x)[0];if(!L)return null;return q[x]=Y.filter((Z)=>Z!==L),L},updateMany({model:x,where:K,update:Y}){let L=F(K,x);return L.forEach((Z)=>{Object.assign(Z,Y)}),L[0]||null}}}});return(P)=>{return E=P,M(P)}};export{v as memoryAdapter};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  function w(q){let k=q[q.length-1];return k&&k.role!=="user"?"agent":"user"}function x(q){return q.some((k)=>{if(k.role==="user"&&Array.isArray(k.content))return k.content.some((v)=>v.type==="image");if(k.role==="toolResult"&&Array.isArray(k.content))return k.content.some((v)=>v.type==="image");return!1})}function y(q){let k={"X-Initiator":w(q.messages),"Openai-Intent":"conversation-edits"};if(q.hasImages)k["Copilot-Vision-Request"]="true";return k}
3
- export{x as wm,y as xm};
3
+ export{x as xm,y as ym};
@@ -1,2 +1,2 @@
1
- import{Qe as f,Se as B,Te as a,Ue as t,Ye as s}from"./chunk-t77dwtcc.js";import{Nf as d,Of as n,Pf as e,Qf as W}from"./chunk-ktvmxqfg.js";import{hh as Q}from"./chunk-ygsbmfcy.js";import{di as o,ei as j,fi as x}from"./chunk-2f35h4fn.js";import{Bi as P,Ii as $,Ri as r,Ti as l,Ui as u,Wi as i,Yi as q,wi as g,zi as M}from"./chunk-s503pcvb.js";import{$i as $w,Dj as D,Ij as E,Sl as I,Wl as H,Xj as T,aj as c,bj as z,cj as G,il as S,qm as _,rl as m,tm as R,um as k}from"./chunk-w9p59ahz.js";import{rn as Zw}from"./chunk-txkmks1h.js";var Y=Zw($w(),1);var Hw=[W.TODO,W.READY,W.IN_PROGRESS,W.IN_REVIEW,W.DONE,W.BLOCKED];function Kw({teamId:J,assetId:Z,assetName:A,isOpen:F,onClose:K}){let U=g(),[v,O]=Y.useState(null),[y,C]=Y.useState(!1),[N,ww]=Y.useState(W.TODO),[h,zw]=Y.useState(""),{data:Gw,isLoading:Jw}=M({queryKey:["teams",J,"kanban","assets",Z,"tasks"],queryFn:async()=>{let w=await $.api.teams[":teamId"].kanban.assets[":assetId"].tasks.$get({param:{teamId:J,assetId:Z}});if(!w.ok)throw Error("Failed to fetch linked tasks");return await w.json()},enabled:!!J&&!!Z&&F}),X=Gw?.data||[],L=Y.useMemo(()=>new Set(X.map((w)=>w.id)),[X]),{data:Rw,isLoading:Vw}=M({queryKey:["teams",J,"kanban","tasks","status",N],queryFn:async()=>{let w=await $.api.teams[":teamId"].kanban.tasks.$get({param:{teamId:J},query:{status:N,first:"100"}});if(!w.ok)return{data:[]};return await w.json()},enabled:!!J&&y&&F}),p=Rw?.data||[],b=Y.useMemo(()=>{let w=h.trim().toLowerCase();return p.filter((V)=>{if(L.has(V.id))return!1;if(!w)return!0;return V.title.toLowerCase().includes(w)})},[p,L,h]),Ww=P({mutationFn:async(w)=>{let V=await $.api.teams[":teamId"].kanban.assets[":assetId"].tasks.$post({param:{teamId:J,assetId:Z},json:{taskId:w}});if(!V.ok)throw Error("Failed to link task");return await V.json()},onSuccess:()=>{U.invalidateQueries({queryKey:["teams",J,"kanban","assets",Z,"tasks"]}),U.invalidateQueries({queryKey:["teams",J,"kanban"]}),q.success(R.asset_linked())}}),Yw=P({mutationFn:async(w)=>{let V=await $.api.teams[":teamId"].kanban.assets[":assetId"].tasks[":taskId"].$delete({param:{teamId:J,assetId:Z,taskId:w}});if(!V.ok)throw Error("Failed to unlink task");return await V.json()},onSuccess:()=>{U.invalidateQueries({queryKey:["teams",J,"kanban","assets",Z,"tasks"]}),U.invalidateQueries({queryKey:["teams",J,"kanban"]}),q.success(R.asset_unlinked())}});return G(c,{children:[z(r,{open:F,onOpenChange:(w)=>!w&&K(),children:G(l,{className:"sm:max-w-2xl flex flex-col h-[520px] p-0 overflow-hidden",children:[z(u,{className:"p-4 border-b flex flex-row items-center justify-between space-y-0 shrink-0",children:G("div",{className:"flex items-center gap-2 min-w-0 pr-4",children:[z(E,{className:"w-5 h-5 text-primary shrink-0"}),G("div",{className:"min-w-0",children:[z(i,{className:"text-sm font-semibold truncate",children:R.linked_tasks()}),A&&z("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:A})]})]})}),z("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden bg-background",children:z(Q,{className:"flex-1 min-h-0 p-4 [&>div>div]:block!",children:Jw?z("div",{className:"flex items-center justify-center p-12",children:z(D,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):X.length===0?G("div",{className:"flex flex-col items-center justify-center p-12 text-center text-xs text-muted-foreground gap-2",children:[z(E,{className:"w-8 h-8 opacity-30"}),z("p",{children:R.no_linked_tasks()})]}):z("div",{className:"space-y-2",children:X.map((w)=>G("div",{onClick:()=>O(w.id),className:"flex items-center justify-between gap-3 p-2.5 rounded-lg border border-border/60 bg-muted/20 hover:bg-muted/50 cursor-pointer transition-all hover:border-border",children:[G("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[w.isAgentTask&&z("span",{className:"p-1 rounded bg-orange-500/15 text-orange-600 dark:text-orange-400 shrink-0",children:z(T,{className:"w-3.5 h-3.5"})}),z("span",{className:H("text-[10px] px-1.5 py-0.5 rounded border uppercase font-medium shrink-0",B(w.status)),children:f(w.status)}),z("span",{className:H("text-[10px] px-1.5 py-0.5 rounded border uppercase font-medium shrink-0",t(w.priority)),children:a(w.priority)}),z("span",{className:"text-xs font-medium text-foreground truncate flex-1",children:w.title})]}),G("div",{className:"flex items-center gap-2 shrink-0",children:[w.assignee&&G("div",{className:"flex items-center gap-1 text-[11px] text-muted-foreground",title:w.assignee.name,children:[G(o,{className:"w-4 h-4 text-[9px]",children:[z(j,{src:w.assignee.image||void 0}),z(x,{children:w.assignee.name.slice(0,1).toUpperCase()})]}),z("span",{className:"hidden sm:inline text-[11px] max-w-[70px] truncate",children:w.assignee.name})]}),z(_,{type:"button",variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive hover:bg-destructive/10",onClick:(V)=>{V.stopPropagation(),Yw.mutate(w.id)},title:R.unlink_task(),children:z(I,{className:"w-3.5 h-3.5"})})]})]},w.id))})})}),G("div",{className:"p-3 px-4 border-t bg-muted/10 flex items-center justify-between shrink-0",children:[G(d,{open:y,onOpenChange:C,children:[z(n,{asChild:!0,children:G(_,{variant:"outline",size:"sm",className:"gap-1.5 text-xs h-8",children:[z(S,{className:"w-3.5 h-3.5"}),z("span",{children:R.link_to_task()})]})}),G(e,{className:"w-80 sm:w-96 p-0",align:"start",children:[z("div",{className:"p-2 border-b",children:G("div",{className:"relative",children:[z(m,{className:"w-3.5 h-3.5 absolute left-2.5 top-2.5 text-muted-foreground"}),z(k,{placeholder:R.search_tasks(),value:h,onChange:(w)=>zw(w.target.value),className:"pl-8 h-8 text-xs bg-muted/30",autoFocus:!0})]})}),z("div",{className:"flex border-b overflow-x-auto p-1 gap-1 bg-muted/20",children:Hw.map((w)=>z("button",{type:"button",onClick:()=>ww(w),className:H("px-2 py-1 text-[11px] font-medium rounded transition-colors whitespace-nowrap",N===w?"bg-background shadow-xs text-foreground font-semibold":"text-muted-foreground hover:text-foreground hover:bg-muted/50"),children:f(w)},w))}),z(Q,{className:"h-56",children:Vw?G("div",{className:"flex items-center justify-center p-6 text-xs text-muted-foreground",children:[z(D,{className:"w-4 h-4 animate-spin mr-1.5"}),z("span",{children:R.loading()})]}):b.length===0?z("div",{className:"p-6 text-center text-xs text-muted-foreground",children:R.no_matching_tasks()}):z("div",{className:"p-1 space-y-0.5",children:b.map((w)=>G("button",{type:"button",onClick:()=>{Ww.mutate(w.id),C(!1)},className:"w-full text-left p-2 rounded hover:bg-muted/60 transition-colors flex items-center justify-between gap-2 text-xs group",children:[z("span",{className:"truncate flex-1 font-medium text-foreground",children:w.title}),z("span",{className:H("text-[10px] px-1.5 py-0.5 rounded border uppercase shrink-0",B(w.status)),children:f(w.status)})]},w.id))})})]})]}),z(_,{variant:"ghost",size:"sm",onClick:K,className:"text-xs h-8",children:R.close()})]})]})}),v&&z(s,{teamId:J,taskId:v,isOpen:!0,onClose:()=>O(null)})]})}
2
- export{Kw as Oe};
1
+ import{Re as f,Te as B,Ue as a,Ve as t,Ze as s}from"./chunk-ns0zww9g.js";import{Lf as W}from"./chunk-7pfjfrjg.js";import{kg as d,lg as n,mg as e}from"./chunk-62zx96pe.js";import{ih as Q}from"./chunk-k47md1g4.js";import{Gi as $,Hi as o,Ii as j,Ji as x,Si as r,Ui as l,Vi as u,Xi as i,Zi as q,ui as g,xi as M,zi as P}from"./chunk-h0fxysxs.js";import{Ej as D,Jj as E,Tl as I,Xl as H,Yj as T,aj as $w,bj as c,cj as z,dj as G,jl as S,rm as _,sl as m,um as R,vm as k}from"./chunk-yp9hvkc5.js";import{sn as Zw}from"./chunk-dxyq9h8n.js";var Y=Zw($w(),1);var Hw=[W.TODO,W.READY,W.IN_PROGRESS,W.IN_REVIEW,W.DONE,W.BLOCKED];function Kw({teamId:J,assetId:Z,assetName:A,isOpen:F,onClose:K}){let U=g(),[v,O]=Y.useState(null),[y,C]=Y.useState(!1),[N,ww]=Y.useState(W.TODO),[h,zw]=Y.useState(""),{data:Gw,isLoading:Jw}=M({queryKey:["teams",J,"kanban","assets",Z,"tasks"],queryFn:async()=>{let w=await $.api.teams[":teamId"].kanban.assets[":assetId"].tasks.$get({param:{teamId:J,assetId:Z}});if(!w.ok)throw Error("Failed to fetch linked tasks");return await w.json()},enabled:!!J&&!!Z&&F}),X=Gw?.data||[],L=Y.useMemo(()=>new Set(X.map((w)=>w.id)),[X]),{data:Rw,isLoading:Vw}=M({queryKey:["teams",J,"kanban","tasks","status",N],queryFn:async()=>{let w=await $.api.teams[":teamId"].kanban.tasks.$get({param:{teamId:J},query:{status:N,first:"100"}});if(!w.ok)return{data:[]};return await w.json()},enabled:!!J&&y&&F}),p=Rw?.data||[],b=Y.useMemo(()=>{let w=h.trim().toLowerCase();return p.filter((V)=>{if(L.has(V.id))return!1;if(!w)return!0;return V.title.toLowerCase().includes(w)})},[p,L,h]),Ww=P({mutationFn:async(w)=>{let V=await $.api.teams[":teamId"].kanban.assets[":assetId"].tasks.$post({param:{teamId:J,assetId:Z},json:{taskId:w}});if(!V.ok)throw Error("Failed to link task");return await V.json()},onSuccess:()=>{U.invalidateQueries({queryKey:["teams",J,"kanban","assets",Z,"tasks"]}),U.invalidateQueries({queryKey:["teams",J,"kanban"]}),q.success(R.asset_linked())}}),Yw=P({mutationFn:async(w)=>{let V=await $.api.teams[":teamId"].kanban.assets[":assetId"].tasks[":taskId"].$delete({param:{teamId:J,assetId:Z,taskId:w}});if(!V.ok)throw Error("Failed to unlink task");return await V.json()},onSuccess:()=>{U.invalidateQueries({queryKey:["teams",J,"kanban","assets",Z,"tasks"]}),U.invalidateQueries({queryKey:["teams",J,"kanban"]}),q.success(R.asset_unlinked())}});return G(c,{children:[z(r,{open:F,onOpenChange:(w)=>!w&&K(),children:G(l,{className:"sm:max-w-2xl flex flex-col h-[520px] p-0 overflow-hidden",children:[z(u,{className:"p-4 border-b flex flex-row items-center justify-between space-y-0 shrink-0",children:G("div",{className:"flex items-center gap-2 min-w-0 pr-4",children:[z(E,{className:"w-5 h-5 text-primary shrink-0"}),G("div",{className:"min-w-0",children:[z(i,{className:"text-sm font-semibold truncate",children:R.linked_tasks()}),A&&z("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:A})]})]})}),z("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden bg-background",children:z(Q,{className:"flex-1 min-h-0 p-4 [&>div>div]:block!",children:Jw?z("div",{className:"flex items-center justify-center p-12",children:z(D,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):X.length===0?G("div",{className:"flex flex-col items-center justify-center p-12 text-center text-xs text-muted-foreground gap-2",children:[z(E,{className:"w-8 h-8 opacity-30"}),z("p",{children:R.no_linked_tasks()})]}):z("div",{className:"space-y-2",children:X.map((w)=>G("div",{onClick:()=>O(w.id),className:"flex items-center justify-between gap-3 p-2.5 rounded-lg border border-border/60 bg-muted/20 hover:bg-muted/50 cursor-pointer transition-all hover:border-border",children:[G("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[w.isAgentTask&&z("span",{className:"p-1 rounded bg-orange-500/15 text-orange-600 dark:text-orange-400 shrink-0",children:z(T,{className:"w-3.5 h-3.5"})}),z("span",{className:H("text-[10px] px-1.5 py-0.5 rounded border uppercase font-medium shrink-0",B(w.status)),children:f(w.status)}),z("span",{className:H("text-[10px] px-1.5 py-0.5 rounded border uppercase font-medium shrink-0",t(w.priority)),children:a(w.priority)}),z("span",{className:"text-xs font-medium text-foreground truncate flex-1",children:w.title})]}),G("div",{className:"flex items-center gap-2 shrink-0",children:[w.assignee&&G("div",{className:"flex items-center gap-1 text-[11px] text-muted-foreground",title:w.assignee.name,children:[G(o,{className:"w-4 h-4 text-[9px]",children:[z(j,{src:w.assignee.image||void 0}),z(x,{children:w.assignee.name.slice(0,1).toUpperCase()})]}),z("span",{className:"hidden sm:inline text-[11px] max-w-[70px] truncate",children:w.assignee.name})]}),z(_,{type:"button",variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive hover:bg-destructive/10",onClick:(V)=>{V.stopPropagation(),Yw.mutate(w.id)},title:R.unlink_task(),children:z(I,{className:"w-3.5 h-3.5"})})]})]},w.id))})})}),G("div",{className:"p-3 px-4 border-t bg-muted/10 flex items-center justify-between shrink-0",children:[G(d,{open:y,onOpenChange:C,children:[z(n,{asChild:!0,children:G(_,{variant:"outline",size:"sm",className:"gap-1.5 text-xs h-8",children:[z(S,{className:"w-3.5 h-3.5"}),z("span",{children:R.link_to_task()})]})}),G(e,{className:"w-80 sm:w-96 p-0",align:"start",children:[z("div",{className:"p-2 border-b",children:G("div",{className:"relative",children:[z(m,{className:"w-3.5 h-3.5 absolute left-2.5 top-2.5 text-muted-foreground"}),z(k,{placeholder:R.search_tasks(),value:h,onChange:(w)=>zw(w.target.value),className:"pl-8 h-8 text-xs bg-muted/30",autoFocus:!0})]})}),z("div",{className:"flex border-b overflow-x-auto p-1 gap-1 bg-muted/20",children:Hw.map((w)=>z("button",{type:"button",onClick:()=>ww(w),className:H("px-2 py-1 text-[11px] font-medium rounded transition-colors whitespace-nowrap",N===w?"bg-background shadow-xs text-foreground font-semibold":"text-muted-foreground hover:text-foreground hover:bg-muted/50"),children:f(w)},w))}),z(Q,{className:"h-56",children:Vw?G("div",{className:"flex items-center justify-center p-6 text-xs text-muted-foreground",children:[z(D,{className:"w-4 h-4 animate-spin mr-1.5"}),z("span",{children:R.loading()})]}):b.length===0?z("div",{className:"p-6 text-center text-xs text-muted-foreground",children:R.no_matching_tasks()}):z("div",{className:"p-1 space-y-0.5",children:b.map((w)=>G("button",{type:"button",onClick:()=>{Ww.mutate(w.id),C(!1)},className:"w-full text-left p-2 rounded hover:bg-muted/60 transition-colors flex items-center justify-between gap-2 text-xs group",children:[z("span",{className:"truncate flex-1 font-medium text-foreground",children:w.title}),z("span",{className:H("text-[10px] px-1.5 py-0.5 rounded border uppercase shrink-0",B(w.status)),children:f(w.status)})]},w.id))})})]})]}),z(_,{variant:"ghost",size:"sm",onClick:K,className:"text-xs h-8",children:R.close()})]})]})}),v&&z(s,{teamId:J,taskId:v,isOpen:!0,onClose:()=>O(null)})]})}
2
+ export{Kw as Pe};
@@ -1,2 +1,2 @@
1
- import{e as c1,f as r1}from"./chunk-a5b3aevg.js";import{h as j1}from"./chunk-0qdzjcny.js";import{s as m1}from"./chunk-2vc6pw8q.js";import{w as F1}from"./chunk-09pe07g6.js";import{E as S1}from"./chunk-082zg4nr.js";import{H as p1}from"./chunk-44xtwvd7.js";import{ba as d}from"./chunk-4yhd7bmp.js";import{Le as g1}from"./chunk-zqvavykq.js";import{vf as R1}from"./chunk-pt51m9h1.js";import{Lf as C1}from"./chunk-2q7ew7yz.js";import{eg as D1,fg as s}from"./chunk-k1f3gj25.js";import{ng as P1}from"./chunk-7xcyn1ba.js";import{Pg as M,Sg as b1,Tg as M1,ah as u1,dh as N1,gh as f1}from"./chunk-785kxysj.js";import{ti as n1}from"./chunk-4k2d8w9w.js";import{Bi as U1,Ci as l,Ii as Y,wi as Q1,zi as i}from"./chunk-s503pcvb.js";import{$i as G0,Wl as L1,aj as I,bj as G,cj as W,hj as v1,tm as D}from"./chunk-w9p59ahz.js";import{rn as X0}from"./chunk-txkmks1h.js";var T=X0(G0(),1);function E1(h,w,q,k,Z,_){let C=h.type==="folder",V=w.type==="folder";if(C!==V)return null;let B=V?k:Z,O=B.findIndex((A)=>A.id===q),H=B.findIndex((A)=>A.id===w.id);if(O===-1||H===-1)return null;let P=Math.min(O,H),R=Math.max(O,H),E=B.slice(P,R+1),X=new Set(_);return E.forEach((A)=>{if(A.id)X.add(A.id)}),X}function J0({teamId:h,projectId:w,projectName:q,assetId:k,rootFolderId:Z,collection:_,onUpdateCollection:C}){let V=v1(),B=Q1(),{canEdit:O}=n1(w),{setFields:H}=p1(),P=Y.api.files[":fileId"].metadata.$patch,{mutate:R}=U1({mutationFn:async(z)=>{if(!(await P(z)).ok)throw Error("Failed to patch metadata");return null}}),{data:E}=i({queryKey:["fields",w],queryFn:async()=>{let z=await Y.api.projects[":projectId"].fields.$get({param:{projectId:w}});if(!z.ok)throw Error("Failed to fetch fields");return await z.json()},enabled:!!w});T.useEffect(()=>{if(E)H(E,w)},[E,w,H]);let X=k==="recently-deleted",A=k==="recents",[t,g]=T.useState(null),[K,u]=T.useState(new Set),[p,e]=T.useState(null),[o1,a1]=T.useState(240),[I1,i1]=T.useState(360),{isChatbotOpen:F}=s(),{members:l1,fetchMembers:z1}=C1(),{metadata:s1,fetchMetadata:w1,setMetadata:d1}=g1();T.useEffect(()=>{if(h)z1(h),w1(h)},[h,z1,w1]);let m=T.useMemo(()=>{return _?.filter?.searchFilter?.conditions||[]},[_]),[Q,S]=T.useState(m);T.useEffect(()=>{S(m)},[m]);let x1=`project:${w}:sort`,U=s1[x1]||{field:"custom",order:"asc"},t1=(z)=>{if(z)d1(h,x1,z)},$=!!_,N=Q.length>0||$,{fileListLeftSidebarCollapsed:A1,setFileListLeftSidebarCollapsed:e1,fileListRightSidebarCollapsed:k1,setFileListRightSidebarCollapsed:z0,viewModes:w0}=P1(),h1=w0[w]??"card",x0=T.useRef(null),{data:v}=X||A?{data:void 0}:i({queryKey:["folders",k],queryFn:async()=>{let z=await Y.api.folders[":folderId"].$get({param:{folderId:k}});if(!z.ok)throw Error("failed to fetch folder");return await z.json()}}),{setProjectState:T1,clearProjectState:X1}=D1();T.useEffect(()=>{return T1({teamId:h,projectId:w,projectName:q,rootFolderId:Z,ancestorFolders:v?.ancestorFolders??[],currentAsset:X?{name:D.recently_deleted(),type:"folder"}:A?{name:D.recents(),type:"folder"}:$?{id:_.id,name:_.name,type:"folder"}:{id:v?.id||k,name:v?.name,type:"folder"},isRootFolder:!X&&!A&&!$&&k===Z,onFolderClick:(z)=>{V({to:"/projects/$projectId/folders/$folderId",params:{projectId:w,folderId:z}})}}),()=>X1()},[h,w,q,v,X,A,k,Z,T1,X1,V]);let{data:j,fetchNextPage:G1,hasNextPage:J1,isFetchingNextPage:Y1,isLoading:A0}=l({queryKey:X?["projects",w,"recently-deleted","folder"]:A?["projects",w,"recents","folder"]:["search",h,k,"folder",Q,U,$],queryFn:async({pageParam:z})=>{if(X||$||A){if(X){let J=await Y.api.projects[":projectId"]["recently-deleted"].$get({param:{projectId:w},query:{assetType:"folder",after:z}});if(!J.ok)throw Error("failed to fetch recently deleted folders");return await J.json()}return{data:[],pageInfo:{total:0}}}if(N)return{data:[],pageInfo:{total:0}};let x=await Y.api.folders[":folderId"].search.$post({param:{folderId:k},json:{assetType:"folder",after:z,recursively:!1,sort:U,conditions:[]}});if(!x.ok)throw Error("failed to search folders");return await x.json()},enabled:!N&&!A,initialPageParam:"",getNextPageParam:(z)=>{return z.pageInfo?.cursor||void 0}}),{data:c,fetchNextPage:Z1,hasNextPage:_1,isFetchingNextPage:K1,isLoading:k0}=l({queryKey:X?["projects",w,"recently-deleted","file"]:A?["projects",w,"recents","file"]:["search",h,k,"file",Q,U,$],queryFn:async({pageParam:z})=>{if(X){let J=await Y.api.projects[":projectId"]["recently-deleted"].$get({param:{projectId:w},query:{assetType:"file",after:z}});if(!J.ok)throw Error("failed to fetch recently deleted files");return await J.json()}if(A){let J=await Y.api.projects[":projectId"].recents.$get({param:{projectId:w},query:{after:z,first:"20"}});if(!J.ok)throw Error("failed to fetch recent files");return await J.json()}let x=await Y.api.folders[":folderId"].search.$post({param:{folderId:k},json:{assetType:"file",after:z,recursively:N||$,conditions:Q,sort:U}});if(!x.ok)throw Error("failed to search files");return await x.json()},initialPageParam:"",getNextPageParam:(z)=>{return z.pageInfo?.cursor||void 0}}),L=j?.pages.flatMap((z)=>z.data??[])??[],y=c?.pages.flatMap((z)=>z.data??[])??[],V1=(!N&&!A?A0:!1)||k0,$1=j?.pages[0]?.pageInfo?.total,y1=c?.pages[0]?.pageInfo?.total,B1=j?.pages[0]?.pageInfo?.totalSize,H1=c?.pages[0]?.pageInfo?.totalSize,r=()=>{u(new Set),g(null),e(null)},{dragState:n,handleDragStart:h0,handleDragEnd:T0}=r1({teamId:h,projectId:w,assetId:k,folders:L,files:y,selectedIds:K,onClearSelection:r}),o=T.useMemo(()=>{if(K.size!==1)return null;let z=Array.from(K)[0];return y.find((J)=>J.id===z)||null},[K,y]),W1=(z)=>{if(X)return;if(z.type==="folder")S([]),V({to:"/projects/$projectId/folders/$folderId",params:{projectId:w,folderId:z.id}});else V({to:"/projects/$projectId/files/$fileId",params:{projectId:w,fileId:z.versionStack?z.versionStack.id:z.id},search:{version:void 0}})},q1=(z,x)=>{let J=x.metaKey||x.ctrlKey;if(x.shiftKey&&p){let O1=[...L,...y].find((f)=>f.id===p);if(O1){let f=E1(O1,z,p,L,y,K);if(f){u(f),g(z);return}}}if(J){let b=new Set(K);if(b.has(z.id))b.delete(z.id);else b.add(z.id);u(b)}else u(new Set([z.id]));e(z.id),g(z)},a=(z,x,J)=>{R({param:{fileId:z},json:[{key:x,value:J}]},{onSuccess:()=>{B.invalidateQueries({queryKey:["folders",k,"children",{assetType:"file"}]}),B.invalidateQueries({queryKey:["search",h,k]})}})};if(R1())return G(m1,{teamId:h,projectId:w,assetId:k,folders:L,files:y,totalFolders:$1,totalFiles:y1,totalFoldersSize:B1,totalFilesSize:H1,selectedItem:t,selectedIds:K,onItemSelect:q1,onItemDoubleClick:W1,onSaveField:a,onClearSelection:r,fetchNextFoldersPage:G1,hasNextFoldersPage:J1||!1,isFetchingNextFoldersPage:Y1,fetchNextFilesPage:Z1,hasNextFilesPage:_1||!1,isFetchingNextFilesPage:K1,isRecentlyDeleted:X,isRecents:A,isLoading:V1,rootFolderId:Z});return W(u1,{modifiers:[c1.configure({anchor:{x:0,y:0}})],plugins:(z)=>z.map((x)=>{if(x===M)return M.configure({dropAnimation:null});if(typeof x==="object"&&x!==null&&"plugin"in x&&x.plugin===M)return M.configure({dropAnimation:null});return x}),sensors:X||A||!O?[]:[M1.configure({activationConstraints:[new b1.Distance({value:10})]})],onDragStart:h0,onDragEnd:T0,children:[G("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:W("div",{ref:x0,className:"flex flex-1 overflow-hidden relative",children:[!A1&&G("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>e1(!0)}),(!k1||F)&&G("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>{z0(!0),s.getState().setIsChatbotOpen(!1)}}),!A1&&W(I,{children:[G("div",{className:"bg-background",style:{width:o1},children:G(f1,{teamId:h,projectId:w,projectName:q,rootFolderId:Z,dragState:n,ancestorFolders:v?.ancestorFolders??[]})}),G(d,{onResize:(z)=>{a1((x)=>Math.max(180,Math.min(400,x+z)))},className:"hidden md:block"})]}),G(F1,{teamId:h,projectId:w,assetId:k,folders:L,files:y,totalFolders:$1,totalFiles:y1,totalFoldersSize:B1,totalFilesSize:H1,selectedItem:t,selectedIds:K,onItemSelect:q1,onItemDoubleClick:W1,onSaveField:a,displayStyle:h1,onClearSelection:r,fetchNextFoldersPage:G1,hasNextFoldersPage:J1||!1,isFetchingNextFoldersPage:Y1,fetchNextFilesPage:Z1,hasNextFilesPage:_1||!1,isFetchingNextFilesPage:K1,isRecentlyDeleted:X,isRecents:A,isLoading:V1,filterConditions:Q,onFilterChange:S,sort:U,onSortChange:t1,dragState:n,collection:_,onUpdateCollection:C,rootFolderId:Z}),(!k1||F)&&W(I,{children:[G(d,{onResize:(z)=>{i1((x)=>Math.max(240,Math.min(600,x-z)))},className:"hidden md:block"}),G("div",{style:{width:I1},className:"bg-background flex flex-col flex-shrink-0",children:F?G(j1,{projectId:w,contextAssetId:k}):o?G(S1,{teamId:h,projectId:w,file:o,onSaveField:(z,x)=>a(o.id,z,x),members:l1,hideAnnotationControl:!0}):G("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:D.select_asset_to_view_details()})})]})]})}),G(N1,{children:n?.isActive?G("div",{className:L1("flex items-center gap-2 rounded-md bg-popover px-3 py-2 text-sm font-medium text-popover-foreground shadow-md ring-1 ring-border cursor-grabbing",h1==="list"&&"w-30 h-[40px] px-0 flex-none overflow-hidden justify-center"),style:{transform:"translate(0px, 0px)"},children:W("span",{children:["Moving ",n.itemCount," item",n.itemCount!==1?"s":""]})}):null})]})}
1
+ import{e as c1,f as r1}from"./chunk-evtpwg71.js";import{h as j1}from"./chunk-s39n3yw3.js";import{s as m1}from"./chunk-zeby1cq7.js";import{w as F1}from"./chunk-hc6w5nw4.js";import{D as S1}from"./chunk-fe7822ak.js";import{G as p1}from"./chunk-z36bx86r.js";import{ca as d}from"./chunk-kxskpgsq.js";import{Me as g1}from"./chunk-9tjq99ds.js";import{wf as R1}from"./chunk-bdjv0ykq.js";import{$f as D1,ag as s}from"./chunk-5vewxmz7.js";import{dg as C1}from"./chunk-pz2ec6xt.js";import{og as P1}from"./chunk-63y0eb07.js";import{Qg as M,Tg as b1,Ug as M1,bh as u1,eh as N1,hh as f1}from"./chunk-qrf0ady6.js";import{ri as n1}from"./chunk-b1ypjqgp.js";import{Ai as l,Gi as Y,ui as Q1,xi as i,zi as U1}from"./chunk-h0fxysxs.js";import{Xl as L1,aj as G0,bj as I,cj as G,dj as W,ij as v1,um as D}from"./chunk-yp9hvkc5.js";import{sn as X0}from"./chunk-dxyq9h8n.js";var T=X0(G0(),1);function E1(h,w,q,k,Z,_){let C=h.type==="folder",V=w.type==="folder";if(C!==V)return null;let B=V?k:Z,O=B.findIndex((A)=>A.id===q),H=B.findIndex((A)=>A.id===w.id);if(O===-1||H===-1)return null;let P=Math.min(O,H),R=Math.max(O,H),E=B.slice(P,R+1),X=new Set(_);return E.forEach((A)=>{if(A.id)X.add(A.id)}),X}function J0({teamId:h,projectId:w,projectName:q,assetId:k,rootFolderId:Z,collection:_,onUpdateCollection:C}){let V=v1(),B=Q1(),{canEdit:O}=n1(w),{setFields:H}=p1(),P=Y.api.files[":fileId"].metadata.$patch,{mutate:R}=U1({mutationFn:async(z)=>{if(!(await P(z)).ok)throw Error("Failed to patch metadata");return null}}),{data:E}=i({queryKey:["fields",w],queryFn:async()=>{let z=await Y.api.projects[":projectId"].fields.$get({param:{projectId:w}});if(!z.ok)throw Error("Failed to fetch fields");return await z.json()},enabled:!!w});T.useEffect(()=>{if(E)H(E,w)},[E,w,H]);let X=k==="recently-deleted",A=k==="recents",[t,g]=T.useState(null),[K,u]=T.useState(new Set),[p,e]=T.useState(null),[o1,a1]=T.useState(240),[I1,i1]=T.useState(360),{isChatbotOpen:F}=s(),{members:l1,fetchMembers:z1}=C1(),{metadata:s1,fetchMetadata:w1,setMetadata:d1}=g1();T.useEffect(()=>{if(h)z1(h),w1(h)},[h,z1,w1]);let m=T.useMemo(()=>{return _?.filter?.searchFilter?.conditions||[]},[_]),[Q,S]=T.useState(m);T.useEffect(()=>{S(m)},[m]);let x1=`project:${w}:sort`,U=s1[x1]||{field:"custom",order:"asc"},t1=(z)=>{if(z)d1(h,x1,z)},$=!!_,N=Q.length>0||$,{fileListLeftSidebarCollapsed:A1,setFileListLeftSidebarCollapsed:e1,fileListRightSidebarCollapsed:k1,setFileListRightSidebarCollapsed:z0,viewModes:w0}=P1(),h1=w0[w]??"card",x0=T.useRef(null),{data:v}=X||A?{data:void 0}:i({queryKey:["folders",k],queryFn:async()=>{let z=await Y.api.folders[":folderId"].$get({param:{folderId:k}});if(!z.ok)throw Error("failed to fetch folder");return await z.json()}}),{setProjectState:T1,clearProjectState:X1}=D1();T.useEffect(()=>{return T1({teamId:h,projectId:w,projectName:q,rootFolderId:Z,ancestorFolders:v?.ancestorFolders??[],currentAsset:X?{name:D.recently_deleted(),type:"folder"}:A?{name:D.recents(),type:"folder"}:$?{id:_.id,name:_.name,type:"folder"}:{id:v?.id||k,name:v?.name,type:"folder"},isRootFolder:!X&&!A&&!$&&k===Z,onFolderClick:(z)=>{V({to:"/projects/$projectId/folders/$folderId",params:{projectId:w,folderId:z}})}}),()=>X1()},[h,w,q,v,X,A,k,Z,T1,X1,V]);let{data:j,fetchNextPage:G1,hasNextPage:J1,isFetchingNextPage:Y1,isLoading:A0}=l({queryKey:X?["projects",w,"recently-deleted","folder"]:A?["projects",w,"recents","folder"]:["search",h,k,"folder",Q,U,$],queryFn:async({pageParam:z})=>{if(X||$||A){if(X){let J=await Y.api.projects[":projectId"]["recently-deleted"].$get({param:{projectId:w},query:{assetType:"folder",after:z}});if(!J.ok)throw Error("failed to fetch recently deleted folders");return await J.json()}return{data:[],pageInfo:{total:0}}}if(N)return{data:[],pageInfo:{total:0}};let x=await Y.api.folders[":folderId"].search.$post({param:{folderId:k},json:{assetType:"folder",after:z,recursively:!1,sort:U,conditions:[]}});if(!x.ok)throw Error("failed to search folders");return await x.json()},enabled:!N&&!A,initialPageParam:"",getNextPageParam:(z)=>{return z.pageInfo?.cursor||void 0}}),{data:c,fetchNextPage:Z1,hasNextPage:_1,isFetchingNextPage:K1,isLoading:k0}=l({queryKey:X?["projects",w,"recently-deleted","file"]:A?["projects",w,"recents","file"]:["search",h,k,"file",Q,U,$],queryFn:async({pageParam:z})=>{if(X){let J=await Y.api.projects[":projectId"]["recently-deleted"].$get({param:{projectId:w},query:{assetType:"file",after:z}});if(!J.ok)throw Error("failed to fetch recently deleted files");return await J.json()}if(A){let J=await Y.api.projects[":projectId"].recents.$get({param:{projectId:w},query:{after:z,first:"20"}});if(!J.ok)throw Error("failed to fetch recent files");return await J.json()}let x=await Y.api.folders[":folderId"].search.$post({param:{folderId:k},json:{assetType:"file",after:z,recursively:N||$,conditions:Q,sort:U}});if(!x.ok)throw Error("failed to search files");return await x.json()},initialPageParam:"",getNextPageParam:(z)=>{return z.pageInfo?.cursor||void 0}}),L=j?.pages.flatMap((z)=>z.data??[])??[],y=c?.pages.flatMap((z)=>z.data??[])??[],V1=(!N&&!A?A0:!1)||k0,$1=j?.pages[0]?.pageInfo?.total,y1=c?.pages[0]?.pageInfo?.total,B1=j?.pages[0]?.pageInfo?.totalSize,H1=c?.pages[0]?.pageInfo?.totalSize,r=()=>{u(new Set),g(null),e(null)},{dragState:n,handleDragStart:h0,handleDragEnd:T0}=r1({teamId:h,projectId:w,assetId:k,folders:L,files:y,selectedIds:K,onClearSelection:r}),o=T.useMemo(()=>{if(K.size!==1)return null;let z=Array.from(K)[0];return y.find((J)=>J.id===z)||null},[K,y]),W1=(z)=>{if(X)return;if(z.type==="folder")S([]),V({to:"/projects/$projectId/folders/$folderId",params:{projectId:w,folderId:z.id}});else V({to:"/projects/$projectId/files/$fileId",params:{projectId:w,fileId:z.versionStack?z.versionStack.id:z.id},search:{version:void 0}})},q1=(z,x)=>{let J=x.metaKey||x.ctrlKey;if(x.shiftKey&&p){let O1=[...L,...y].find((f)=>f.id===p);if(O1){let f=E1(O1,z,p,L,y,K);if(f){u(f),g(z);return}}}if(J){let b=new Set(K);if(b.has(z.id))b.delete(z.id);else b.add(z.id);u(b)}else u(new Set([z.id]));e(z.id),g(z)},a=(z,x,J)=>{R({param:{fileId:z},json:[{key:x,value:J}]},{onSuccess:()=>{B.invalidateQueries({queryKey:["folders",k,"children",{assetType:"file"}]}),B.invalidateQueries({queryKey:["search",h,k]})}})};if(R1())return G(m1,{teamId:h,projectId:w,assetId:k,folders:L,files:y,totalFolders:$1,totalFiles:y1,totalFoldersSize:B1,totalFilesSize:H1,selectedItem:t,selectedIds:K,onItemSelect:q1,onItemDoubleClick:W1,onSaveField:a,onClearSelection:r,fetchNextFoldersPage:G1,hasNextFoldersPage:J1||!1,isFetchingNextFoldersPage:Y1,fetchNextFilesPage:Z1,hasNextFilesPage:_1||!1,isFetchingNextFilesPage:K1,isRecentlyDeleted:X,isRecents:A,isLoading:V1,rootFolderId:Z});return W(u1,{modifiers:[c1.configure({anchor:{x:0,y:0}})],plugins:(z)=>z.map((x)=>{if(x===M)return M.configure({dropAnimation:null});if(typeof x==="object"&&x!==null&&"plugin"in x&&x.plugin===M)return M.configure({dropAnimation:null});return x}),sensors:X||A||!O?[]:[M1.configure({activationConstraints:[new b1.Distance({value:10})]})],onDragStart:h0,onDragEnd:T0,children:[G("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:W("div",{ref:x0,className:"flex flex-1 overflow-hidden relative",children:[!A1&&G("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>e1(!0)}),(!k1||F)&&G("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>{z0(!0),s.getState().setIsChatbotOpen(!1)}}),!A1&&W(I,{children:[G("div",{className:"bg-background",style:{width:o1},children:G(f1,{teamId:h,projectId:w,projectName:q,rootFolderId:Z,dragState:n,ancestorFolders:v?.ancestorFolders??[]})}),G(d,{onResize:(z)=>{a1((x)=>Math.max(180,Math.min(400,x+z)))},className:"hidden md:block"})]}),G(F1,{teamId:h,projectId:w,assetId:k,folders:L,files:y,totalFolders:$1,totalFiles:y1,totalFoldersSize:B1,totalFilesSize:H1,selectedItem:t,selectedIds:K,onItemSelect:q1,onItemDoubleClick:W1,onSaveField:a,displayStyle:h1,onClearSelection:r,fetchNextFoldersPage:G1,hasNextFoldersPage:J1||!1,isFetchingNextFoldersPage:Y1,fetchNextFilesPage:Z1,hasNextFilesPage:_1||!1,isFetchingNextFilesPage:K1,isRecentlyDeleted:X,isRecents:A,isLoading:V1,filterConditions:Q,onFilterChange:S,sort:U,onSortChange:t1,dragState:n,collection:_,onUpdateCollection:C,rootFolderId:Z}),(!k1||F)&&W(I,{children:[G(d,{onResize:(z)=>{i1((x)=>Math.max(240,Math.min(600,x-z)))},className:"hidden md:block"}),G("div",{style:{width:I1},className:"bg-background flex flex-col flex-shrink-0",children:F?G(j1,{projectId:w,contextAssetId:k}):o?G(S1,{teamId:h,projectId:w,file:o,onSaveField:(z,x)=>a(o.id,z,x),members:l1,hideAnnotationControl:!0}):G("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:D.select_asset_to_view_details()})})]})]})}),G(N1,{children:n?.isActive?G("div",{className:L1("flex items-center gap-2 rounded-md bg-popover px-3 py-2 text-sm font-medium text-popover-foreground shadow-md ring-1 ring-border cursor-grabbing",h1==="list"&&"w-30 h-[40px] px-0 flex-none overflow-hidden justify-center"),style:{transform:"translate(0px, 0px)"},children:W("span",{children:["Moving ",n.itemCount," item",n.itemCount!==1?"s":""]})}):null})]})}
2
2
  export{J0 as d};
@@ -1,2 +1,2 @@
1
- import{Wl as t,bj as r,cj as i,hm as o}from"./chunk-w9p59ahz.js";function m({className:e,children:l,...a}){return i(o.Root,{"data-slot":"scroll-area",className:t("relative",e),...a,children:[r(o.Viewport,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:l}),r(c,{}),r(o.Corner,{})]})}function c({className:e,orientation:l="vertical",...a}){return r(o.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar",orientation:l,className:t("flex touch-none p-px transition-colors select-none",l==="vertical"&&"h-full w-2.5 border-l border-l-transparent",l==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...a,children:r(o.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}
2
- export{m as hh,c as ih};
1
+ import{Xl as t,cj as r,dj as i,im as o}from"./chunk-yp9hvkc5.js";function m({className:e,children:l,...a}){return i(o.Root,{"data-slot":"scroll-area",className:t("relative",e),...a,children:[r(o.Viewport,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:l}),r(c,{}),r(o.Corner,{})]})}function c({className:e,orientation:l="vertical",...a}){return r(o.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar",orientation:l,className:t("flex touch-none p-px transition-colors select-none",l==="vertical"&&"h-full w-2.5 border-l border-l-transparent",l==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...a,children:r(o.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}
2
+ export{m as ih,c as jh};
@@ -1,2 +1,2 @@
1
- import{Wl as i,ak as c,bj as e,bk as s,cj as n,ek as d,im as o}from"./chunk-w9p59ahz.js";function S({...t}){return e(o.Root,{"data-slot":"select",...t})}function P({...t}){return e(o.Value,{"data-slot":"select-value",...t})}function b({className:t,size:a="default",children:r,...l}){return n(o.Trigger,{"data-slot":"select-trigger","data-size":a,className:i("flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",t),...l,children:[r,e(o.Icon,{asChild:!0,children:e(s,{className:"size-4 opacity-50"})})]})}function h({className:t,children:a,position:r="item-aligned",align:l="center",...p}){return e(o.Portal,{children:n(o.Content,{"data-slot":"select-content",className:i("relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,align:l,...p,children:[e(m,{}),e(o.Viewport,{className:i("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:a}),e(u,{})]})})}function y({className:t,children:a,...r}){return n(o.Item,{"data-slot":"select-item",className:i("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...r,children:[e("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:e(o.ItemIndicator,{children:e(c,{className:"size-4"})})}),e(o.ItemText,{children:a})]})}function m({className:t,...a}){return e(o.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:i("flex cursor-default items-center justify-center py-1",t),...a,children:e(d,{className:"size-4"})})}function u({className:t,...a}){return e(o.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:i("flex cursor-default items-center justify-center py-1",t),...a,children:e(s,{className:"size-4"})})}
2
- export{S as gg,P as hg,b as ig,h as jg,y as kg};
1
+ import{Xl as i,bk as c,cj as e,ck as s,dj as n,fk as d,jm as o}from"./chunk-yp9hvkc5.js";function S({...t}){return e(o.Root,{"data-slot":"select",...t})}function P({...t}){return e(o.Value,{"data-slot":"select-value",...t})}function b({className:t,size:a="default",children:r,...l}){return n(o.Trigger,{"data-slot":"select-trigger","data-size":a,className:i("flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",t),...l,children:[r,e(o.Icon,{asChild:!0,children:e(s,{className:"size-4 opacity-50"})})]})}function h({className:t,children:a,position:r="item-aligned",align:l="center",...p}){return e(o.Portal,{children:n(o.Content,{"data-slot":"select-content",className:i("relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,align:l,...p,children:[e(m,{}),e(o.Viewport,{className:i("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:a}),e(u,{})]})})}function y({className:t,children:a,...r}){return n(o.Item,{"data-slot":"select-item",className:i("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...r,children:[e("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:e(o.ItemIndicator,{children:e(c,{className:"size-4"})})}),e(o.ItemText,{children:a})]})}function m({className:t,...a}){return e(o.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:i("flex cursor-default items-center justify-center py-1",t),...a,children:e(d,{className:"size-4"})})}function u({className:t,...a}){return e(o.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:i("flex cursor-default items-center justify-center py-1",t),...a,children:e(s,{className:"size-4"})})}
2
+ export{S as eg,P as fg,b as gg,h as hg,y as ig};
@@ -0,0 +1 @@
1
+ import{d as y}from"./chunk-jvwz10n4.js";import"./chunk-evtpwg71.js";import"./chunk-s39n3yw3.js";import"./chunk-zeby1cq7.js";import"./chunk-hc6w5nw4.js";import"./chunk-fe7822ak.js";import"./chunk-z36bx86r.js";import"./chunk-480jtqng.js";import"./chunk-g8tkhw9j.js";import"./chunk-c1k86mfa.js";import"./chunk-6d5xrgfx.js";import"./chunk-kxskpgsq.js";import"./chunk-rfvdc4n0.js";import"./chunk-g9r0p4t8.js";import{pe as v,qe as m}from"./chunk-egcrbj94.js";import"./chunk-9tjq99ds.js";import"./chunk-23hckrrz.js";import"./chunk-bdjv0ykq.js";import"./chunk-4r91fggc.js";import"./chunk-sf91bt9m.js";import"./chunk-77d23vcn.js";import"./chunk-30z44j1g.js";import"./chunk-7pfjfrjg.js";import"./chunk-5vewxmz7.js";import"./chunk-ev17v1mv.js";import"./chunk-pz2ec6xt.js";import"./chunk-k4v0brcb.js";import"./chunk-4181tdds.js";import"./chunk-62zx96pe.js";import"./chunk-63y0eb07.js";import"./chunk-qrf0ady6.js";import"./chunk-k47md1g4.js";import"./chunk-77m5p188.js";import"./chunk-d9mjbtp2.js";import"./chunk-ytypyfkc.js";import"./chunk-mq83a0kk.js";import"./chunk-hag024w8.js";import"./chunk-07h4b77v.js";import"./chunk-ps4xfp23.js";import"./chunk-nhpgdqq5.js";import{qi as w}from"./chunk-b1ypjqgp.js";import{Gi as r,xi as i,yi as f,zi as x}from"./chunk-h0fxysxs.js";import"./chunk-z1kjmf60.js";import{aj as q,cj as n,nj as b,um as g}from"./chunk-yp9hvkc5.js";import{sn as W}from"./chunk-dxyq9h8n.js";var d=W(q(),1);function A(){let{projectId:e,collectionId:l}=K.useParams(),{teamId:o,ensureTeamIdForProject:h}=w();d.useEffect(()=>{h(e)},[e,h]);let{data:p}=f(v(e)),{data:s,refetch:z}=i({...m(l)}),{mutate:k}=x({mutationFn:async(a)=>{let c=await r.api.collections[":collectionId"].$patch({param:{collectionId:l},json:a});if(!c.ok)throw Error("Failed to update collection");return await c.json()},onSuccess:()=>{z()}}),t=p?.rootFolder,{data:u}=i({queryKey:["folders",t],queryFn:async()=>{let a=await r.api.folders[":folderId"].$get({param:{folderId:t}});if(!a.ok)throw Error("Failed to fetch folder");return await a.json()},enabled:!!t});if(!o||!t||!u||!s)return n("div",{children:g.loading_collection()});let C=s.filter.sourceFolderId||t;return n(y,{teamId:o,projectId:e,projectName:p.name??"",assetId:C,rootFolderId:t,collection:s,onUpdateCollection:k})}var K=b("/projects/$projectId/collections/$collectionId")({component:A});export{K as Route};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Jm as C,Km as E,Lm as I,Mm as b,Nm as h,Om as B,Pm as x}from"./chunk-8pfgh13x.js";import{Um as M}from"./chunk-c97vh5wb.js";import{Vm as G,Wm as K}from"./chunk-pn94h6x7.js";import{bn as T}from"./chunk-wxsq9zmf.js";import{en as S}from"./chunk-k20w9eaz.js";import{gn as O}from"./chunk-7qzt5nhz.js";import{ln as v,mn as y}from"./chunk-116p639c.js";import{nn as P}from"./chunk-q46rc697.js";import"./chunk-txkmks1h.js";var k=0,D=(q,N,w)=>{let J=new P;return(async()=>{let j={role:"assistant",content:[],api:"google-generative-ai",provider:q.provider,model:q.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let X=w?.apiKey;if(!X)throw Error(`No API key for provider: ${q.provider}`);let V=a(q,X,w?.headers),Y=m(q,N,w),$=await w?.onPayload?.(Y,q);if($!==void 0)Y=$;let g=await V.models.generateContentStream(Y);J.push({type:"start",partial:j});let Q=null,H=j.content,W=()=>H.length-1;for await(let Z of g){j.responseId||=Z.responseId;let z=Z.candidates?.[0];if(z?.content?.parts)for(let U of z.content.parts){if(U.text!==void 0){let _=C(U);if(!Q||_&&Q.type!=="thinking"||!_&&Q.type!=="text"){if(Q)if(Q.type==="text")J.push({type:"text_end",contentIndex:H.length-1,content:Q.text,partial:j});else J.push({type:"thinking_end",contentIndex:W(),content:Q.thinking,partial:j});if(_)Q={type:"thinking",thinking:"",thinkingSignature:void 0},j.content.push(Q),J.push({type:"thinking_start",contentIndex:W(),partial:j});else Q={type:"text",text:""},j.content.push(Q),J.push({type:"text_start",contentIndex:W(),partial:j})}if(Q.type==="thinking")Q.thinking+=U.text,Q.thinkingSignature=E(Q.thinkingSignature,U.thoughtSignature),J.push({type:"thinking_delta",contentIndex:W(),delta:U.text,partial:j});else Q.text+=U.text,Q.textSignature=E(Q.textSignature,U.thoughtSignature),J.push({type:"text_delta",contentIndex:W(),delta:U.text,partial:j})}if(U.functionCall){if(Q){if(Q.type==="text")J.push({type:"text_end",contentIndex:W(),content:Q.text,partial:j});else J.push({type:"thinking_end",contentIndex:W(),content:Q.thinking,partial:j});Q=null}let _=U.functionCall.id,A={type:"toolCall",id:!_||j.content.some((R)=>R.type==="toolCall"&&R.id===_)?`${U.functionCall.name}_${Date.now()}_${++k}`:_,name:U.functionCall.name||"",arguments:U.functionCall.args??{},...U.thoughtSignature&&{thoughtSignature:U.thoughtSignature}};j.content.push(A),J.push({type:"toolcall_start",contentIndex:W(),partial:j}),J.push({type:"toolcall_delta",contentIndex:W(),delta:JSON.stringify(A.arguments),partial:j}),J.push({type:"toolcall_end",contentIndex:W(),toolCall:A,partial:j})}}if(z?.finishReason){if(j.stopReason=x(z.finishReason),j.content.some((U)=>U.type==="toolCall"))j.stopReason="toolUse"}if(Z.usageMetadata)j.usage={input:(Z.usageMetadata.promptTokenCount||0)-(Z.usageMetadata.cachedContentTokenCount||0),output:(Z.usageMetadata.candidatesTokenCount||0)+(Z.usageMetadata.thoughtsTokenCount||0),cacheRead:Z.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:Z.usageMetadata.thoughtsTokenCount||0,totalTokens:Z.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},v(q,j.usage)}if(Q)if(Q.type==="text")J.push({type:"text_end",contentIndex:W(),content:Q.text,partial:j});else J.push({type:"thinking_end",contentIndex:W(),content:Q.thinking,partial:j});if(w?.signal?.aborted)throw Error("Request was aborted");if(j.stopReason==="aborted"||j.stopReason==="error")throw Error("An unknown error occurred");J.push({type:"done",reason:j.stopReason,message:j}),J.end()}catch(X){for(let V of j.content)if("index"in V)delete V.index;j.stopReason=w?.signal?.aborted?"aborted":"error",j.errorMessage=K(G(X)),J.push({type:"error",reason:j.stopReason,error:j}),J.end()}})(),J},qj=(q,N,w)=>{let J=w?.apiKey;if(!J)throw Error(`No API key for provider: ${q.provider}`);let j=T(q,N,w,J);if(!w?.reasoning)return D(q,N,{...j,thinking:{enabled:!1}});let X=y(q,w.reasoning),V=X==="off"?"high":X,Y=q;if(F(Y)||f(Y)||L(Y))return D(q,N,{...j,thinking:{enabled:!0,level:d(V,Y)}});return D(q,N,{...j,thinking:{enabled:!0,budgetTokens:c(Y,V,w.thinkingBudgets)}})};function a(q,N,w){let J={};if(q.baseUrl)J.baseUrl=q.baseUrl,J.apiVersion="";let j=O({...q.headers,...w});if(j)J.headers=j;return new M({apiKey:N,httpOptions:Object.keys(J).length>0?J:void 0})}function m(q,N,w={}){let J=I(q,N),j={};if(w.temperature!==void 0)j.temperature=w.temperature;if(w.maxTokens!==void 0)j.maxOutputTokens=w.maxTokens;let X=N.tools?.length?B(N.tools,w.toolChoice,h(q.id)):void 0,V={...Object.keys(j).length>0&&j,...N.systemPrompt&&{systemInstruction:S(N.systemPrompt)},...N.tools&&N.tools.length>0&&{tools:b(N.tools)},...X!==void 0&&{toolConfig:{functionCallingConfig:{mode:X}}}};if(w.thinking?.enabled&&q.reasoning){let $={includeThoughts:!0};if(w.thinking.level!==void 0)$.thinkingLevel=w.thinking.level;else if(w.thinking.budgetTokens!==void 0)$.thinkingBudget=w.thinking.budgetTokens;V.thinkingConfig=$}else if(q.reasoning&&w.thinking&&!w.thinking.enabled)V.thinkingConfig=u(q);if(w.signal){if(w.signal.aborted)throw Error("Request aborted");V.abortSignal=w.signal}return{model:q.id,contents:J,config:V}}function L(q){return/gemma-?4/.test(q.id.toLowerCase())}function F(q){return/gemini-3(?:\.\d+)?-pro/.test(q.id.toLowerCase())}function f(q){let N=q.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(N)||N==="gemini-flash-latest"||N==="gemini-flash-lite-latest"}function u(q){if(F(q))return{thinkingLevel:"LOW"};if(f(q))return{thinkingLevel:"MINIMAL"};if(L(q))return{thinkingLevel:"MINIMAL"};return{thinkingBudget:0}}function d(q,N){if(F(N))switch(q){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}if(L(N))switch(q){case"minimal":case"low":return"MINIMAL";case"medium":case"high":return"HIGH"}switch(q){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}function c(q,N,w){if(w?.[N]!==void 0)return w[N];if(q.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[N];if(q.id.includes("2.5-flash-lite"))return{minimal:512,low:2048,medium:8192,high:24576}[N];if(q.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[N];return-1}export{qj as streamSimple,D as stream};
2
+ import{Km as C,Lm as E,Mm as I,Nm as b,Om as h,Pm as B,Qm as x}from"./chunk-ab16fyg4.js";import{Vm as M}from"./chunk-6m4jz9s1.js";import{Wm as G,Xm as K}from"./chunk-gtbsb39v.js";import{cn as T}from"./chunk-vsx96mt6.js";import{fn as S}from"./chunk-tbbwss3v.js";import{hn as O}from"./chunk-6w2wmvqs.js";import{mn as v,nn as y}from"./chunk-dn7sbjws.js";import{on as P}from"./chunk-1phqxp6z.js";import"./chunk-dxyq9h8n.js";var k=0,D=(q,N,w)=>{let J=new P;return(async()=>{let j={role:"assistant",content:[],api:"google-generative-ai",provider:q.provider,model:q.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let X=w?.apiKey;if(!X)throw Error(`No API key for provider: ${q.provider}`);let V=a(q,X,w?.headers),Y=m(q,N,w),$=await w?.onPayload?.(Y,q);if($!==void 0)Y=$;let g=await V.models.generateContentStream(Y);J.push({type:"start",partial:j});let Q=null,H=j.content,W=()=>H.length-1;for await(let Z of g){j.responseId||=Z.responseId;let z=Z.candidates?.[0];if(z?.content?.parts)for(let U of z.content.parts){if(U.text!==void 0){let _=C(U);if(!Q||_&&Q.type!=="thinking"||!_&&Q.type!=="text"){if(Q)if(Q.type==="text")J.push({type:"text_end",contentIndex:H.length-1,content:Q.text,partial:j});else J.push({type:"thinking_end",contentIndex:W(),content:Q.thinking,partial:j});if(_)Q={type:"thinking",thinking:"",thinkingSignature:void 0},j.content.push(Q),J.push({type:"thinking_start",contentIndex:W(),partial:j});else Q={type:"text",text:""},j.content.push(Q),J.push({type:"text_start",contentIndex:W(),partial:j})}if(Q.type==="thinking")Q.thinking+=U.text,Q.thinkingSignature=E(Q.thinkingSignature,U.thoughtSignature),J.push({type:"thinking_delta",contentIndex:W(),delta:U.text,partial:j});else Q.text+=U.text,Q.textSignature=E(Q.textSignature,U.thoughtSignature),J.push({type:"text_delta",contentIndex:W(),delta:U.text,partial:j})}if(U.functionCall){if(Q){if(Q.type==="text")J.push({type:"text_end",contentIndex:W(),content:Q.text,partial:j});else J.push({type:"thinking_end",contentIndex:W(),content:Q.thinking,partial:j});Q=null}let _=U.functionCall.id,A={type:"toolCall",id:!_||j.content.some((R)=>R.type==="toolCall"&&R.id===_)?`${U.functionCall.name}_${Date.now()}_${++k}`:_,name:U.functionCall.name||"",arguments:U.functionCall.args??{},...U.thoughtSignature&&{thoughtSignature:U.thoughtSignature}};j.content.push(A),J.push({type:"toolcall_start",contentIndex:W(),partial:j}),J.push({type:"toolcall_delta",contentIndex:W(),delta:JSON.stringify(A.arguments),partial:j}),J.push({type:"toolcall_end",contentIndex:W(),toolCall:A,partial:j})}}if(z?.finishReason){if(j.stopReason=x(z.finishReason),j.content.some((U)=>U.type==="toolCall"))j.stopReason="toolUse"}if(Z.usageMetadata)j.usage={input:(Z.usageMetadata.promptTokenCount||0)-(Z.usageMetadata.cachedContentTokenCount||0),output:(Z.usageMetadata.candidatesTokenCount||0)+(Z.usageMetadata.thoughtsTokenCount||0),cacheRead:Z.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:Z.usageMetadata.thoughtsTokenCount||0,totalTokens:Z.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},v(q,j.usage)}if(Q)if(Q.type==="text")J.push({type:"text_end",contentIndex:W(),content:Q.text,partial:j});else J.push({type:"thinking_end",contentIndex:W(),content:Q.thinking,partial:j});if(w?.signal?.aborted)throw Error("Request was aborted");if(j.stopReason==="aborted"||j.stopReason==="error")throw Error("An unknown error occurred");J.push({type:"done",reason:j.stopReason,message:j}),J.end()}catch(X){for(let V of j.content)if("index"in V)delete V.index;j.stopReason=w?.signal?.aborted?"aborted":"error",j.errorMessage=K(G(X)),J.push({type:"error",reason:j.stopReason,error:j}),J.end()}})(),J},qj=(q,N,w)=>{let J=w?.apiKey;if(!J)throw Error(`No API key for provider: ${q.provider}`);let j=T(q,N,w,J);if(!w?.reasoning)return D(q,N,{...j,thinking:{enabled:!1}});let X=y(q,w.reasoning),V=X==="off"?"high":X,Y=q;if(F(Y)||f(Y)||L(Y))return D(q,N,{...j,thinking:{enabled:!0,level:d(V,Y)}});return D(q,N,{...j,thinking:{enabled:!0,budgetTokens:c(Y,V,w.thinkingBudgets)}})};function a(q,N,w){let J={};if(q.baseUrl)J.baseUrl=q.baseUrl,J.apiVersion="";let j=O({...q.headers,...w});if(j)J.headers=j;return new M({apiKey:N,httpOptions:Object.keys(J).length>0?J:void 0})}function m(q,N,w={}){let J=I(q,N),j={};if(w.temperature!==void 0)j.temperature=w.temperature;if(w.maxTokens!==void 0)j.maxOutputTokens=w.maxTokens;let X=N.tools?.length?B(N.tools,w.toolChoice,h(q.id)):void 0,V={...Object.keys(j).length>0&&j,...N.systemPrompt&&{systemInstruction:S(N.systemPrompt)},...N.tools&&N.tools.length>0&&{tools:b(N.tools)},...X!==void 0&&{toolConfig:{functionCallingConfig:{mode:X}}}};if(w.thinking?.enabled&&q.reasoning){let $={includeThoughts:!0};if(w.thinking.level!==void 0)$.thinkingLevel=w.thinking.level;else if(w.thinking.budgetTokens!==void 0)$.thinkingBudget=w.thinking.budgetTokens;V.thinkingConfig=$}else if(q.reasoning&&w.thinking&&!w.thinking.enabled)V.thinkingConfig=u(q);if(w.signal){if(w.signal.aborted)throw Error("Request aborted");V.abortSignal=w.signal}return{model:q.id,contents:J,config:V}}function L(q){return/gemma-?4/.test(q.id.toLowerCase())}function F(q){return/gemini-3(?:\.\d+)?-pro/.test(q.id.toLowerCase())}function f(q){let N=q.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(N)||N==="gemini-flash-latest"||N==="gemini-flash-lite-latest"}function u(q){if(F(q))return{thinkingLevel:"LOW"};if(f(q))return{thinkingLevel:"MINIMAL"};if(L(q))return{thinkingLevel:"MINIMAL"};return{thinkingBudget:0}}function d(q,N){if(F(N))switch(q){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}if(L(N))switch(q){case"minimal":case"low":return"MINIMAL";case"medium":case"high":return"HIGH"}switch(q){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}function c(q,N,w){if(w?.[N]!==void 0)return w[N];if(q.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[N];if(q.id.includes("2.5-flash-lite"))return{minimal:512,low:2048,medium:8192,high:24576}[N];if(q.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[N];return-1}export{qj as streamSimple,D as stream};