@shumai-one/shumai 0.3.11 → 0.4.1

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 (186) hide show
  1. package/bin/chunk-082zg4nr.js +307 -0
  2. package/bin/chunk-09pe07g6.js +7 -0
  3. package/bin/chunk-0qdzjcny.js +2 -0
  4. package/bin/chunk-0z1p2pvf.js +1 -0
  5. package/bin/{chunk-cmd0feyq.js → chunk-116p639c.js} +2 -2
  6. package/bin/{chunk-cyjh5qsk.js → chunk-13ypr8v0.js} +1 -1
  7. package/bin/{chunk-sepsqqdf.js → chunk-16txy3r1.js} +2 -2
  8. package/bin/{chunk-dyen2t1p.js → chunk-1vs91e4q.js} +2 -2
  9. package/bin/chunk-29e0mb43.js +1 -0
  10. package/bin/chunk-2a0egvsg.js +1 -0
  11. package/bin/chunk-2f35h4fn.js +2 -0
  12. package/bin/{chunk-tdp1jjv1.js → chunk-2jsjrqw4.js} +2 -2
  13. package/bin/chunk-2q7ew7yz.js +2 -0
  14. package/bin/{chunk-ps2hw0ps.js → chunk-2sc2jxd3.js} +1 -1
  15. package/bin/chunk-2vc6pw8q.js +2 -0
  16. package/bin/{chunk-f9ydhm8q.js → chunk-3gqdepkd.js} +2 -2
  17. package/bin/chunk-44370df5.js +4 -0
  18. package/bin/chunk-44xtwvd7.js +2 -0
  19. package/bin/{chunk-7t31qfw5.js → chunk-47r5b77s.js} +2 -2
  20. package/bin/chunk-4azttb3w.js +1 -0
  21. package/bin/{chunk-whm06pnc.js → chunk-4ee336e3.js} +1 -1
  22. package/bin/{chunk-qrhf20g2.js → chunk-4k2d8w9w.js} +2 -2
  23. package/bin/{chunk-kcg7d7pk.js → chunk-4yhd7bmp.js} +2 -2
  24. package/bin/chunk-4yybby29.js +2 -0
  25. package/bin/{chunk-0g0gt4bj.js → chunk-5395g4kq.js} +2 -2
  26. package/bin/{chunk-gx410cm2.js → chunk-5bkj2n94.js} +2 -2
  27. package/bin/{chunk-aq7q5e36.js → chunk-5c4h0t33.js} +2 -2
  28. package/bin/{chunk-byjze6hm.js → chunk-6nrynqdw.js} +2 -2
  29. package/bin/chunk-6tv7rm3x.js +2 -0
  30. package/bin/chunk-785kxysj.js +68 -0
  31. package/bin/{chunk-c16vvzdj.js → chunk-78cxvbjd.js} +1 -1
  32. package/bin/chunk-7g2k89gq.js +2 -0
  33. package/bin/chunk-7psq38hv.js +1 -0
  34. package/bin/{chunk-xsqk7ek2.js → chunk-7qzt5nhz.js} +1 -1
  35. package/bin/{chunk-b78s1cxz.js → chunk-7sf0gbbm.js} +2 -2
  36. package/bin/{chunk-9qytehed.js → chunk-7wvw67f3.js} +2 -2
  37. package/bin/chunk-7xcyn1ba.js +2 -0
  38. package/bin/{chunk-vvx62hp4.js → chunk-7zgvmn5q.js} +1 -1
  39. package/bin/{chunk-12r8a5ev.js → chunk-8pfgh13x.js} +2 -2
  40. package/bin/{chunk-xext4yvc.js → chunk-8rcfhfq5.js} +1 -1
  41. package/bin/{chunk-8qg6jjz4.js → chunk-8yt4m2pb.js} +2 -2
  42. package/bin/{chunk-y0k1f3gk.js → chunk-90tbc5f4.js} +2 -2
  43. package/bin/{chunk-mvkqjrcd.js → chunk-92yvt66q.js} +1 -1
  44. package/bin/chunk-93v3tm93.js +1 -0
  45. package/bin/{chunk-s04f76tb.js → chunk-9f83pnfc.js} +2 -2
  46. package/bin/chunk-a5b3aevg.js +2 -0
  47. package/bin/{chunk-0vqefpcw.js → chunk-af6m9p1d.js} +1 -1
  48. package/bin/chunk-ajryg2e2.js +1 -0
  49. package/bin/chunk-axb1f1ae.js +2 -0
  50. package/bin/chunk-b0cqsrse.js +9 -0
  51. package/bin/chunk-b27jgdsf.css +1 -0
  52. package/bin/{chunk-qz3kfrpr.js → chunk-bbar8rsh.js} +1 -1
  53. package/bin/{chunk-8bv8qsb8.js → chunk-be9a7kc6.js} +2 -2
  54. package/bin/{chunk-dwkv3bx5.js → chunk-bkbqvxfv.js} +2 -2
  55. package/bin/chunk-bwyph9a0.js +1 -0
  56. package/bin/{chunk-0xqf53hc.js → chunk-c43nmcfq.js} +1 -1
  57. package/bin/{chunk-4yke5y3z.js → chunk-c97vh5wb.js} +3 -3
  58. package/bin/{chunk-1dzby9bb.js → chunk-cerjktz2.js} +1 -1
  59. package/bin/chunk-cyvx7gcx.js +2 -0
  60. package/bin/{chunk-esa954t1.js → chunk-d6d1j7qq.js} +2 -2
  61. package/bin/{chunk-6edh2e59.js → chunk-d9sh922y.js} +1 -1
  62. package/bin/chunk-dbjc1vxt.js +1 -0
  63. package/bin/{chunk-pz7ms4n2.js → chunk-djkajvn7.js} +1 -1
  64. package/bin/{chunk-s0jy7grq.js → chunk-dyvmwafa.js} +2 -2
  65. package/bin/{chunk-zvjx64p5.js → chunk-ewge52nq.js} +1 -1
  66. package/bin/{chunk-qrnw89xg.js → chunk-f32kxe6c.js} +2 -2
  67. package/bin/{chunk-7anqxpyv.js → chunk-f4d3v0nc.js} +2 -2
  68. package/bin/{chunk-xfzk0mrt.js → chunk-f8ysqfyv.js} +2 -2
  69. package/bin/{chunk-dhhfwbns.js → chunk-fcsar7p0.js} +1 -1
  70. package/bin/{chunk-kbw63gr4.js → chunk-gfdfkqrc.js} +3 -3
  71. package/bin/chunk-gr30nssh.js +1 -0
  72. package/bin/chunk-gtwhwdbs.js +1 -0
  73. package/bin/{chunk-xsgxk1fj.js → chunk-gyaem1t4.js} +1 -1
  74. package/bin/chunk-hk6tvf7b.js +1 -0
  75. package/bin/{chunk-ntqn09r0.js → chunk-hmmzbyy1.js} +2 -2
  76. package/bin/{chunk-s9yzt7s3.js → chunk-hx2mvd20.js} +2 -2
  77. package/bin/chunk-hzz4hsss.js +1 -0
  78. package/bin/{chunk-5nk7y4ec.js → chunk-j10gz94w.js} +2 -2
  79. package/bin/{chunk-p9w4ar11.js → chunk-j5rx3x1q.js} +1 -1
  80. package/bin/{chunk-knh1stxe.js → chunk-j9q9rjvd.js} +2 -2
  81. package/bin/{chunk-ty32j999.js → chunk-jw00fmkp.js} +2 -2
  82. package/bin/chunk-k1f3gj25.js +3 -0
  83. package/bin/{chunk-393g7z2g.js → chunk-k20w9eaz.js} +1 -1
  84. package/bin/{chunk-31f07jzm.js → chunk-kejt7kcr.js} +2 -2
  85. package/bin/{chunk-k1jcdr0n.js → chunk-kkveddbn.js} +1 -1
  86. package/bin/chunk-ktvmxqfg.js +5 -0
  87. package/bin/{chunk-szf2q87p.js → chunk-m49g5tf4.js} +2 -2
  88. package/bin/{chunk-77c2xm0z.js → chunk-me3xj7na.js} +1 -1
  89. package/bin/{chunk-nw03w9pa.js → chunk-mgnxa0vy.js} +1 -1
  90. package/bin/{chunk-fv14er33.js → chunk-mgytr7nc.js} +1 -1
  91. package/bin/chunk-mkb4dycy.js +2 -0
  92. package/bin/chunk-n21a21vx.js +2 -0
  93. package/bin/{chunk-8r2agmv2.js → chunk-n8gsjwht.js} +2 -2
  94. package/bin/{chunk-t2z4qys8.js → chunk-nndzhn3n.js} +1 -1
  95. package/bin/{chunk-ghw914d2.js → chunk-pcxjm1re.js} +2 -2
  96. package/bin/{chunk-3qva5sqr.js → chunk-pg00gkr4.js} +2 -2
  97. package/bin/{chunk-wdgwymdp.js → chunk-pn94h6x7.js} +1 -1
  98. package/bin/chunk-pt51m9h1.js +2 -0
  99. package/bin/{chunk-hpm4razn.js → chunk-px2cvc1n.js} +2 -2
  100. package/bin/{chunk-rr12edz4.js → chunk-q059y3wx.js} +2 -2
  101. package/bin/{chunk-a5ja6d97.js → chunk-q46rc697.js} +1 -1
  102. package/bin/{chunk-sdjss6ja.js → chunk-r6g1srb3.js} +1 -1
  103. package/bin/chunk-r88vwaxc.js +1 -0
  104. package/bin/chunk-r9pzpqst.js +2 -0
  105. package/bin/{chunk-fsj3kxya.js → chunk-rar0gk7s.js} +2 -2
  106. package/bin/chunk-rfrpb986.js +1 -0
  107. package/bin/{chunk-4pj17byj.js → chunk-rfsbzd39.js} +2 -2
  108. package/bin/{chunk-jsqsrcse.js → chunk-s503pcvb.js} +3 -3
  109. package/bin/{chunk-50vzkdc8.js → chunk-s9sgkkjp.js} +1 -1
  110. package/bin/{chunk-12ps84z8.js → chunk-srs9jq8f.js} +2 -2
  111. package/bin/chunk-t77dwtcc.js +2 -0
  112. package/bin/{chunk-res6r4tm.js → chunk-tcqw0q8x.js} +1 -1
  113. package/bin/{chunk-sqy50q9g.js → chunk-thd9zasr.js} +1 -1
  114. package/bin/chunk-tkgpc6c9.js +2 -0
  115. package/bin/{chunk-qh3w5w8e.js → chunk-ts10cfmc.js} +2 -2
  116. package/bin/{chunk-69at8jm8.js → chunk-txkmks1h.js} +1 -1
  117. package/bin/chunk-v9hbssqd.js +3 -0
  118. package/bin/chunk-v9zc56qr.js +1 -0
  119. package/bin/{chunk-v073nwjn.js → chunk-vh7eb7tp.js} +2 -2
  120. package/bin/chunk-w9p59ahz.js +73 -0
  121. package/bin/{chunk-7888x3vz.js → chunk-wfee9d83.js} +3 -3
  122. package/bin/{chunk-r18tcdds.js → chunk-wxsq9zmf.js} +1 -1
  123. package/bin/chunk-wzdnsgwq.js +2 -0
  124. package/bin/chunk-x2nnv4j8.js +1 -0
  125. package/bin/chunk-xxtcmzcv.js +2 -0
  126. package/bin/{chunk-axnvvkdf.js → chunk-xyzmew7g.js} +1 -1
  127. package/bin/{chunk-2s97ngr8.js → chunk-ygsbmfcy.js} +2 -2
  128. package/bin/{chunk-z8crenxd.js → chunk-ym9xavj0.js} +1 -1
  129. package/bin/{chunk-3j47y8ah.js → chunk-z340qkez.js} +1 -1
  130. package/bin/{chunk-6qzcnkgx.js → chunk-za7ga4bf.js} +2 -2
  131. package/bin/{chunk-nzrrvn6c.js → chunk-zqvavykq.js} +2 -2
  132. package/bin/{chunk-f5c9g4y9.js → chunk-zt15ht52.js} +1 -1
  133. package/bin/shumai-app.html +1 -1
  134. package/bin/shumai-app.js +283 -315
  135. package/package.json +7 -7
  136. package/prisma/schema.prisma +1 -1
  137. package/bin/chunk-02b97gsf.js +0 -2
  138. package/bin/chunk-0ash207y.js +0 -2
  139. package/bin/chunk-0j3yb84c.js +0 -1
  140. package/bin/chunk-0wgqr4jg.js +0 -2
  141. package/bin/chunk-1tby7q3f.js +0 -1
  142. package/bin/chunk-3ztat2q9.js +0 -68
  143. package/bin/chunk-48yphy68.js +0 -73
  144. package/bin/chunk-4t2qcxp5.js +0 -1
  145. package/bin/chunk-5dfy6173.js +0 -2
  146. package/bin/chunk-68bfd8x7.js +0 -3
  147. package/bin/chunk-6ts5az6h.js +0 -2
  148. package/bin/chunk-72nj00dp.js +0 -1
  149. package/bin/chunk-8b11b9cj.js +0 -2
  150. package/bin/chunk-8ekjxb5q.js +0 -2
  151. package/bin/chunk-8zar6cc4.js +0 -2
  152. package/bin/chunk-9m9bn55a.js +0 -1
  153. package/bin/chunk-ayr3tsz3.js +0 -2
  154. package/bin/chunk-bthrbggg.js +0 -2
  155. package/bin/chunk-csh1ggtt.js +0 -1
  156. package/bin/chunk-ctx1ms5t.js +0 -2
  157. package/bin/chunk-day0vn14.js +0 -2
  158. package/bin/chunk-e5r6rnt9.js +0 -2
  159. package/bin/chunk-gwzk0fvn.js +0 -2
  160. package/bin/chunk-gx8sz5bw.js +0 -2
  161. package/bin/chunk-gydktfnx.js +0 -2
  162. package/bin/chunk-h5j1dqc0.js +0 -1
  163. package/bin/chunk-h7kyj2g2.js +0 -2
  164. package/bin/chunk-har4xctf.js +0 -2
  165. package/bin/chunk-hks5k0tm.js +0 -7
  166. package/bin/chunk-hv4t9h3e.js +0 -9
  167. package/bin/chunk-kchbbtdm.js +0 -2
  168. package/bin/chunk-mkwrrdme.js +0 -2
  169. package/bin/chunk-mm995mvc.js +0 -2
  170. package/bin/chunk-mz9pthjh.js +0 -2
  171. package/bin/chunk-n2ae527q.js +0 -307
  172. package/bin/chunk-n3xn2ve1.js +0 -1
  173. package/bin/chunk-q3fdffq5.js +0 -1
  174. package/bin/chunk-rd2n0rs6.js +0 -1
  175. package/bin/chunk-sttc4axf.js +0 -1
  176. package/bin/chunk-t6pmgmg2.js +0 -1
  177. package/bin/chunk-txpqhfqw.js +0 -1
  178. package/bin/chunk-vrdbqapq.js +0 -2
  179. package/bin/chunk-vwa17b2r.js +0 -1
  180. package/bin/chunk-wch8ygpt.js +0 -3
  181. package/bin/chunk-wqwvxskj.js +0 -1
  182. package/bin/chunk-wr3q8a9n.js +0 -1
  183. package/bin/chunk-wt01m93x.js +0 -1
  184. package/bin/chunk-xr1wr22v.css +0 -1
  185. package/bin/chunk-y1pnq12c.js +0 -2
  186. /package/bin/{chunk-xg9xscqz.js → chunk-kryt6pg3.js} +0 -0
@@ -0,0 +1,3 @@
1
+ import{Di as w,Ii as F,Yi as q}from"./chunk-s503pcvb.js";var z=null,u=w((J)=>({projectState:null,setProjectState:(D)=>{if(z)clearTimeout(z),z=null;J({projectState:D})},clearProjectState:()=>{if(z)clearTimeout(z);z=setTimeout(()=>{J({projectState:null}),z=null},10)}}));var T="shumai_selected_agent_id",M=()=>{if(typeof window<"u"&&window.localStorage)return localStorage.getItem(T);return null},K=w((J)=>({isChatbotOpen:!1,setIsChatbotOpen:(D)=>J({isChatbotOpen:D}),isHistoryMode:!1,setIsHistoryMode:(D)=>J({isHistoryMode:D}),currentSessionId:null,setCurrentSessionId:(D)=>J({currentSessionId:D}),chatAssets:[],addAssets:(D)=>J((H)=>{let L=new Set(H.chatAssets.map((W)=>W.id)),Q=D.filter((W)=>!L.has(W.id));return{chatAssets:[...H.chatAssets,...Q]}}),removeAsset:(D)=>J((H)=>({chatAssets:H.chatAssets.filter((L)=>L.id!==D)})),clearAssets:()=>J({chatAssets:[]}),messages:[],setMessages:(D)=>J({messages:D}),historySessions:[],setHistorySessions:(D)=>J({historySessions:D}),isStreaming:!1,setIsStreaming:(D)=>J({isStreaming:D}),selectedAgentId:M(),setSelectedAgentId:(D)=>{if(typeof window<"u"&&window.localStorage)if(D)localStorage.setItem(T,D);else localStorage.removeItem(T);J({selectedAgentId:D})},inputText:"",setInputText:(D)=>J({inputText:D}),scrollTop:0,isAtBottom:!0,setScrollState:(D,H)=>J({scrollTop:D,isAtBottom:H}),fetchHistorySessions:async(D)=>{try{let H=await F.api.teams[":teamId"].chat.sessions.$get({param:{teamId:D},query:{first:"50"}});if(H.ok){let L=await H.json();J({historySessions:L.data||[]})}}catch(H){console.error("Failed to fetch history sessions:",H)}},loadSession:async(D,H)=>{try{let L=await F.api.teams[":teamId"].chat.sessions[":sessionId"].messages.$get({param:{teamId:D,sessionId:H}});if(L.ok){let Q=await L.json(),V=K.getState().historySessions.find((P)=>P.id===H)?.agentId||null;J({currentSessionId:H,messages:Q,isHistoryMode:!1,scrollTop:0,isAtBottom:!0,...V?{selectedAgentId:V}:{}})}else throw Error("Failed to load session messages")}catch(L){let Q=L instanceof Error?L.message:"Failed to load session";q.error(Q)}},deleteSession:async(D,H)=>{try{if((await F.api.teams[":teamId"].chat.sessions[":sessionId"].$delete({param:{teamId:D,sessionId:H}})).ok)q.success("Session deleted successfully"),J((Q)=>({historySessions:Q.historySessions.filter((W)=>W.id!==H),currentSessionId:Q.currentSessionId===H?null:Q.currentSessionId,messages:Q.currentSessionId===H?[]:Q.messages}));else throw Error("Failed to delete session")}catch(L){let Q=L instanceof Error?L.message:"Failed to delete session";q.error(Q)}},startNewSession:()=>{let D=M();J({currentSessionId:null,messages:[],chatAssets:[],inputText:"",scrollTop:0,isAtBottom:!0,...D?{selectedAgentId:D}:{}})},sendMessage:async(D,H,L,Q,W)=>{let V=K.getState();if(V.isStreaming)return;let P=`temp-${Date.now()}`,b={id:P,role:"user",content:[{type:"text",text:H}],timestamp:Date.now()},v=[...V.messages];if(V.chatAssets.length>0){let B={id:`temp-context-${Date.now()}`,role:"custom",customType:"context_display_info",details:{assets:V.chatAssets.map((U)=>({id:U.id,name:U.name,type:U.type}))},timestamp:Date.now()-1};v.push(B)}v.push(b),J({messages:v,isStreaming:!0,chatAssets:[],isAtBottom:!0});let p=V.chatAssets.map((Z)=>Z.id),h=V.selectedAgentId;if(!h){q.error("No agent selected");return}try{let Z=await F.api.teams[":teamId"].chat.$post({param:{teamId:D},json:{agentId:h,textPrompt:H,assetIds:p,sessionId:V.currentSessionId||void 0,contextAssetId:Q,projectId:L}});if(!Z.ok)throw Error("Failed to start chat");let B=Z.headers.get("x-session-id");if(B&&!V.currentSessionId)J({currentSessionId:B});let U=Z.body?.getReader();if(!U)throw Error("No stream body");let j=new TextDecoder,G="";while(!0){let{done:S,value:x}=await U.read();if(S)break;G+=j.decode(x,{stream:!0});let C=G.split(`
2
+ `);G=C.pop()||"";for(let A of C){let N=A.trim();if(!N)continue;if(N.startsWith("data: ")){let y=N.slice(6);try{let $=JSON.parse(y);if($.type==="session"){if(!K.getState().currentSessionId)J({currentSessionId:$.sessionId})}else if($.type==="entry"){let X=$.entry,Y=X;if(Y.role==="toolResult"&&typeof Y.toolName==="string"&&["create_file","create_folder","create_version"].includes(Y.toolName)&&!Y.isError)W?.();J((_)=>{let R=_.messages.some((k)=>k.id===X.id),l=(X.role==="user"||X.role==="custom"&&X.customType==="shumai_message")&&!R,O=_.messages.filter((k)=>{if(l)return!k.id.startsWith("temp-");if(X.role==="custom"&&X.customType==="context_display_info"&&!R)return!k.id.startsWith("temp-context-");return!0}),f=O.findIndex((k)=>k.id===X.id);if(f!==-1){let k=[...O];return k[f]=X,{messages:k}}else return{messages:[...O,X]}})}else if($.type==="done"){if($.status==="failed")q.error($.error||"Workflow failed")}}catch($){console.error("Error parsing SSE line:",$)}}}}K.getState().fetchHistorySessions(D)}catch(Z){let B=Z instanceof Error?Z.message:"Failed to send message";q.error(B),J((U)=>({messages:U.messages.filter((j)=>j.id!==P)}))}finally{J({isStreaming:!1})}},abortActiveSession:async(D)=>{let{currentSessionId:H,isStreaming:L}=K.getState();if(!H||!L)return;try{if((await F.api.teams[":teamId"].chat.sessions[":sessionId"].abort.$post({param:{teamId:D,sessionId:H}})).ok)q.success("Agent execution stopped");else throw Error("Failed to abort agent execution")}catch(Q){let W=Q instanceof Error?Q.message:"Failed to abort execution";q.error(W)}}}));
3
+ export{u as eg,K as fg};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  function f(b){return b.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"")}
3
- export{f as Mm};
3
+ export{f as en};
@@ -1,2 +1,2 @@
1
- import{Cl as n,Li as e,Tl as r,Wl as i}from"./chunk-48yphy68.js";function u({className:a,orientation:t="horizontal",...o}){return e(r.Root,{"data-slot":"tabs","data-orientation":t,orientation:t,className:i("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",a),...o})}var s=n("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function b({className:a,variant:t="default",...o}){return e(r.List,{"data-slot":"tabs-list","data-variant":t,className:i(s({variant:t}),a),...o})}function g({className:a,...t}){return e(r.Trigger,{"data-slot":"tabs-trigger",className:i("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",a),...t})}function f({className:a,...t}){return e(r.Content,{"data-slot":"tabs-content",className:i("flex-1 outline-none",a),...t})}
2
- export{u as qf,b as rf,g as sf,f as tf};
1
+ import{Wl as i,Xl as u,bj as o,mm as n}from"./chunk-w9p59ahz.js";function m({className:t,orientation:a="horizontal",...r}){return o(n.Root,{"data-slot":"tabs","data-orientation":a,orientation:a,className:i("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",t),...r})}var g=u("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function x({className:t,variant:a="default",...r}){return o(n.List,{"data-slot":"tabs-list","data-variant":a,className:i(g({variant:a}),t),...r})}function y({className:t,...a}){return o(n.Trigger,{"data-slot":"tabs-trigger",className:i("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",t),...a})}function h({className:t,...a}){return o(n.Content,{"data-slot":"tabs-content",className:i("flex-1 outline-none",t),...a})}var b=/\.(png|jpe?g|webp|gif|svg|avif|bmp|ico)$/i;function k(t){if(!t)return!1;return b.test(t)}function z(t,a){if(!t||t.length===0)return null;let r=[...t].sort((e,d)=>{let p=e.width??0;return(d.width??0)-p}),s=r.filter((e)=>(e.width??0)>=a);if(s.length>0)return s.sort((e,d)=>{let p=e.width??0,l=d.width??0;return p-l}),s[0];return r[0]}
2
+ export{m as zf,x as Af,y as Bf,h as Cf,k as Df,z as Ef};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$d as L,Ad as k,Bd as l,Cd as m,Dd as n,Ed as o,Fd as p,Gd as q,Hd as r,Id as s,Jd as t,Kd as u,Ld as v,Md as w,Nd as x,Od as y,Pd as z,Qd as A,Rd as B,Sd as C,Td as D,Ud as E,Vd as F,Wd as G,Xd as H,Yd as I,Zd as J,_d as K,pd as a,rd as b,sd as c,td as d,ud as e,vd as f,wd as g,xd as h,yd as i,zd as j}from"./chunk-v073nwjn.js";import"./chunk-69at8jm8.js";export{r as jwtVerify,s as jwtDecrypt,E as jwksCache,d as importX509,c as importSPKI,e as importPKCS8,f as importJWK,K as generateSecret,J as generateKeyPair,q as generalVerify,l as generalDecrypt,o as flattenedVerify,j as flattenedDecrypt,g as exportSPKI,h as exportPKCS8,i as exportJWK,b as errors,H as decodeProtectedHeader,I as decodeJwt,D as customFetch,L as cryptoRuntime,F as createRemoteJWKSet,C as createLocalJWKSet,p as compactVerify,k as compactDecrypt,A as calculateJwkThumbprintUri,z as calculateJwkThumbprint,a as base64url,G as UnsecuredJWT,x as SignJWT,w as GeneralSign,n as GeneralEncrypt,u as FlattenedSign,m as FlattenedEncrypt,y as EncryptJWT,B as EmbeddedJWK,v as CompactSign,t as CompactEncrypt};
2
+ import{$d as D,Ad as c,Bd as d,Cd as e,Dd as f,Ed as g,Fd as h,Gd as i,Hd as j,Id as k,Jd as l,Kd as m,Ld as n,Md as o,Nd as p,Od as q,Pd as r,Qd as s,Rd as t,Sd as u,Td as v,Ud as w,Vd as x,Wd as y,Xd as z,Yd as A,Zd as B,_d as C,ae as E,be as F,ce as G,de as H,ee as I,fe as J,ge as K,he as L,xd as a,zd as b}from"./chunk-vh7eb7tp.js";import"./chunk-txkmks1h.js";export{r as jwtVerify,s as jwtDecrypt,E as jwksCache,d as importX509,c as importSPKI,e as importPKCS8,f as importJWK,K as generateSecret,J as generateKeyPair,q as generalVerify,l as generalDecrypt,o as flattenedVerify,j as flattenedDecrypt,g as exportSPKI,h as exportPKCS8,i as exportJWK,b as errors,H as decodeProtectedHeader,I as decodeJwt,D as customFetch,L as cryptoRuntime,F as createRemoteJWKSet,C as createLocalJWKSet,p as compactVerify,k as compactDecrypt,A as calculateJwkThumbprintUri,z as calculateJwkThumbprint,a as base64url,G as UnsecuredJWT,x as SignJWT,w as GeneralSign,n as GeneralEncrypt,u as FlattenedSign,m as FlattenedEncrypt,y as EncryptJWT,B as EmbeddedJWK,v as CompactSign,t as CompactEncrypt};
@@ -0,0 +1,5 @@
1
+ import{Ah as e}from"./chunk-bkbqvxfv.js";import{Wl as _,ak as pe,am as F,bj as m,fm as f}from"./chunk-w9p59ahz.js";var g={human:"human",agent:"agent"};var k={editor:"editor",reviewer:"reviewer"};var G={team:"team",project:"project"};var V={all_members:"all_members",each_member:"each_member",selected_members:"selected_members"};var W={agent_total_tokens:"agent_total_tokens",agent_cost:"agent_cost",agent_mcp_call_count:"agent_mcp_call_count",agent_bash_call_count:"agent_bash_call_count",agent_tool_call_count:"agent_tool_call_count"},c={TODO:"TODO",READY:"READY",IN_PROGRESS:"IN_PROGRESS",BLOCKED:"BLOCKED",IN_REVIEW:"IN_REVIEW",DONE:"DONE"},d={LOW:"LOW",MEDIUM:"MEDIUM",HIGH:"HIGH",URGENT:"URGENT"},y={CREATED:"CREATED",STATUS_CHANGED:"STATUS_CHANGED",ASSIGNED:"ASSIGNED",UNASSIGNED:"UNASSIGNED",COMMENTED:"COMMENTED",CHANGES_REQUESTED:"CHANGES_REQUESTED",BLOCKED:"BLOCKED",UNBLOCKED:"UNBLOCKED",PRIORITY_CHANGED:"PRIORITY_CHANGED",GOAL_CHANGED:"GOAL_CHANGED",DEPENDENCY_ADDED:"DEPENDENCY_ADDED",DEPENDENCY_REMOVED:"DEPENDENCY_REMOVED"},B={chat:"chat",autofill:"autofill",embedding:"embedding"};var u=e.object({cursor:e.string().optional(),total:e.number().optional(),totalSize:e.number().optional()}),p=e.object({first:e.coerce.number().optional(),after:e.string().optional()});var ct=e.object({name:e.string()}),ce=e.object({id:e.string(),name:e.string(),rootFolder:e.string().optional(),updatedAt:e.union([e.string(),e.date()])});var lt=e.object({data:e.array(ce),pageInfo:u}),mt=e.object({teamId:e.string(),userId:e.string()}),ut=e.object({id:e.string(),name:e.string(),email:e.string().optional(),role:e.enum(["owner","editor","reviewer","bot","unknown"]),image:e.string().optional(),unreadNotificationCount:e.number().optional()}),dt=e.object({name:e.string().optional(),imageKey:e.string().nullable().optional()}),ft=e.object({id:e.string(),name:e.string(),role:e.enum(["owner","editor","reviewer","bot","unknown"]),email:e.string().optional(),type:e.nativeEnum(g).optional(),image:e.string().optional(),scope:e.nativeEnum(G).optional()}),gt=e.object({includeAgents:e.string().optional().transform((t)=>t==="true")}),le={best_match:"best_match",all:"all"},me={off:"off",auto:"auto"},yt=e.union([e.object({key:e.literal("transcode.videoStrategy"),value:e.nativeEnum(le)}),e.object({key:e.literal("transcode.hardwareAcceleration"),value:e.nativeEnum(me)})]),bt=e.object({networkSandboxEnabled:e.boolean(),allowedDomains:e.array(e.string()),pendingDomains:e.array(e.string()).default([])}),ht=e.object({networkSandboxEnabled:e.boolean().optional(),allowedDomains:e.array(e.string()).optional(),pendingDomains:e.array(e.string()).optional()}),St=e.object({role:e.enum(["editor","reviewer"])});var H=e.nativeEnum(B),Z=e.enum(["off","minimal","low","medium","high","xhigh"]),R=e.enum(["owner","editor","reviewer"]),ue=e.object({id:e.string().optional(),skillId:e.string(),skill:e.object({id:e.string(),name:e.string()}).optional()}),Rt=e.object({id:e.string(),name:e.string(),type:H,enabled:e.boolean(),permission:R.optional().default("reviewer"),avatar:e.string().optional(),providerId:e.string().optional(),modelId:e.string().optional(),thinkingLevel:Z.optional().default("off"),systemPrompt:e.string().optional(),soul:e.string().optional(),skills:e.array(ue).optional(),mcpServerIds:e.array(e.string()).optional(),deniedTools:e.array(e.string()).optional()}),Y=e.object({name:e.string().min(1),type:H,enabled:e.boolean().optional().default(!0),permission:R.optional(),avatar:e.string().optional(),providerId:e.string().optional(),modelId:e.string().optional(),thinkingLevel:Z.optional().default("off"),systemPrompt:e.string().optional(),soul:e.string().optional(),skills:e.array(e.string()).optional(),mcpServerIds:e.array(e.string()).optional(),deniedTools:e.array(e.string()).optional()}),It=Y.superRefine((t,a)=>{if(t.type==="chat"||t.type==="autofill"){if(!t.providerId)a.addIssue({code:e.ZodIssueCode.custom,message:"providerId is required for chat/autofill agents",path:["providerId"]});if(!t.modelId)a.addIssue({code:e.ZodIssueCode.custom,message:"modelId is required for chat/autofill agents",path:["modelId"]})}}),Tt=Y.superRefine((t,a)=>{if(t.type==="chat"||t.type==="autofill"){if(!t.providerId)a.addIssue({code:e.ZodIssueCode.custom,message:"providerId is required for chat/autofill agents",path:["providerId"]});if(!t.modelId)a.addIssue({code:e.ZodIssueCode.custom,message:"modelId is required for chat/autofill agents",path:["modelId"]})}}),vt=e.object({permission:R}),jt=e.object({id:e.string(),sessionId:e.string(),entry:e.unknown()}),qt=e.object({id:e.string(),name:e.string().nullable().optional(),type:e.string(),createdAt:e.string(),creator:e.object({id:e.string(),name:e.string().nullable().optional(),email:e.string().nullable().optional(),image:e.string().nullable().optional()}).nullable().optional(),agentId:e.string().optional()});var Ct=e.object({apiKey:e.string().optional(),baseUrl:e.string().optional(),chatModels:e.array(e.string()).optional()}),de=e.enum(["1h","24h","7d","30d"]),Mt=e.object({timeframe:de.default("30d"),userId:e.string().optional()});var Kt=e.object({data:e.array(e.lazy(()=>he)),pageInfo:u}),J=e.object({proxyType:e.enum(["image","video","audio","pdf"]).nullable().optional(),thumbnailUrl:e.string().optional(),originalHeight:e.number().optional(),originalWidth:e.number().optional(),spriteUrl:e.string().optional(),duration:e.number().optional(),pageCount:e.number().optional()}),fe=e.object({type:e.string().nullable(),preview:J.nullable()}),b=e.object({id:e.string(),name:e.string(),image:e.string().optional()}),ge=e.object({fieldId:e.string(),value:e.any()}),ye=e.object({id:e.string(),name:e.string()}),be=e.object({duration:e.number().optional(),originalWidth:e.number().optional(),originalHeight:e.number().optional(),frameRate:e.number().optional(),totalFrames:e.number().optional(),startTimecode:e.string().optional()}),he=e.object({id:e.string(),name:e.string(),sizeByte:e.number(),fileCount:e.number(),type:e.string(),targetType:e.string().optional().nullable(),status:e.string(),proxyType:e.enum(["image","video","audio","pdf"]).nullable().optional(),latestChildren:e.array(fe).optional(),preview:J.nullable().optional(),createdAt:e.string(),updatedAt:e.string(),deletedAt:e.string().nullable().optional(),projectId:e.string().optional().nullable(),creator:b.nullable().optional(),fieldValues:e.array(ge).optional(),sortIndex:e.string().optional().nullable(),startTime:e.number().optional().nullable(),endTime:e.number().optional().nullable(),hasAgentsMd:e.boolean().optional(),media:e.object({original:e.object({key:e.string().optional()}).optional(),videoTranscodes:e.array(e.object({id:e.string(),url:e.string(),key:e.string(),width:e.number(),height:e.number(),size:e.number()})).optional(),imageTranscodes:e.array(e.object({id:e.string(),url:e.string(),key:e.string(),width:e.number(),height:e.number(),size:e.number()})).optional(),videoPreview:e.object({url:e.string(),key:e.string().optional()}).optional(),pdfTranscode:e.object({url:e.string(),key:e.string().optional()}).optional(),proxyType:e.enum(["image","video","audio","pdf"]).nullable().optional(),metadata:be.optional()}).optional(),ancestorFolders:e.array(ye).optional(),versionStack:e.object({id:e.string(),versions:e.array(e.object({version:e.number(),current:e.boolean(),id:e.string(),name:e.string().optional().nullable(),previewUrl:e.string().optional().nullable(),createdAt:e.string().optional().nullable(),creator:e.object({id:e.string(),name:e.string().nullable(),image:e.string().optional().nullable()}).nullable().optional()}))}).optional().nullable()}),wt=e.object({name:e.string(),type:e.string(),projectId:e.string().optional(),parentId:e.string().optional(),key:e.string().optional(),sizeByte:e.number().optional(),contentType:e.string().optional(),creatorId:e.string().optional()}),Qt=e.object({assetId:e.string()}),Lt=e.object({id:e.string(),name:e.string()}),I=e.enum(["file","folder","all"]),Ot=e.object({assetId:e.string().optional(),assetType:I.optional().default("all"),projectId:e.string().optional(),showDeleted:e.boolean().optional(),prefix:e.string().optional(),sort:e.string().optional(),order:e.string().optional(),...p.shape}),Ft=e.object({assetId:e.string(),userId:e.string(),replyToId:e.string().optional(),message:e.string(),annotations:e.any().optional(),second:e.number().optional(),attachmentIds:e.array(e.string())}),Se=e.object({id:e.string(),assetId:e.string(),url:e.string(),proxyType:e.enum(["image","video","audio","pdf"]).nullable().optional()}),_e=e.object({id:e.string(),assetId:e.string(),message:e.string().nullable(),annotations:e.any(),second:e.number().nullable(),creator:b,replies:e.array(e.lazy(()=>_e)),attachments:e.array(Se),mentions:e.array(b),createdAt:e.string(),updatedAt:e.string(),sessionId:e.string().nullable(),isCompleted:e.boolean(),completionLastChangedBy:b.nullable()}),Gt=e.object({isCompleted:e.boolean()}),Vt=e.object({newParentId:e.string(),assetIds:e.array(e.string()),creatorId:e.string().optional()}),Wt=e.object({newParentId:e.string(),assetIds:e.array(e.string()),withComments:e.boolean().default(!1),creatorId:e.string().optional()}),Bt=e.object({name:e.string()}),Ht=e.object({beforeIndex:e.string().optional(),afterIndex:e.string().optional()}),Zt=e.object({ids:e.array(e.string())}),Yt=e.object({ids:e.array(e.string())}),Jt=e.object({file:e.instanceof(File)}),$t=e.object({key:e.string()}),Xt=e.object({fileName:e.string(),contentType:e.string(),size:e.number()}),At=e.object({id:e.string(),uploadUrl:e.string()}),zt=e.object({ids:e.array(e.string())}),xe=e.object({id:e.string(),name:e.string(),url:e.string()}),eo=e.object({files:e.array(xe)});var ro=e.object({userCount:e.number()}),ao=e.object({name:e.string().min(1,"Name is required").max(100,"Name is too long")}),no=e.object({id:e.string(),token:e.string(),name:e.string(),createdAt:e.string()});var ke=e.enum(["is","eq","neq","gt","gte","lt","lte","contains","notContains","isEmpty","isNotEmpty","in","notIn","hasAny","hasAll","hasNone","isWithin"]),Re=e.object({field:e.string(),operator:ke,value:e.any()}),Ie=e.enum(["asc","desc"]),Te=e.object({field:e.string(),order:Ie}),ve=e.enum(["AND","OR"]),je=e.enum(["file","folder"]),T=e.object({operator:ve.optional().default("AND"),conditions:e.array(Re).optional().default([]),sort:Te.optional(),assetType:je.optional(),showSymlink:e.boolean().optional(),recursively:e.boolean().optional().default(!0),query:e.string().optional(),isSemantic:e.boolean().optional().default(!1)}),co=T.extend(p.shape);var v=e.object({sourceFolderId:e.string(),searchFilter:T}),qe=e.object({id:e.string(),name:e.string(),filter:v,projectId:e.string(),createdAt:e.string(),updatedAt:e.string(),creator:e.object({id:e.string(),name:e.string(),image:e.string().optional().nullable()}).optional().nullable()}),go=e.object({name:e.string(),filter:v}),yo=e.object({name:e.string().optional(),filter:v.optional()});var bo=e.object({data:e.array(qe),pageInfo:e.object({cursor:e.string().optional(),total:e.number().optional()})});var _o=e.object({name:e.string(),parentId:e.string()}),xo=e.object({name:e.string()}),ko=e.object({ids:e.array(e.string())}),Ro=e.object({ids:e.array(e.string())}),Io=e.object({content:e.string().max(1e5)});var qo=e.object({code:e.string(),role:e.string(),teamId:e.string(),teamName:e.string(),projectId:e.string().optional(),projectName:e.string().optional(),inviterName:e.string(),isUsed:e.boolean()}),Po=e.object({role:e.nativeEnum(k)}),Eo=e.object({role:e.nativeEnum(k)}),Co=e.object({code:e.string()});var Ko={text:"text",longText:"longText",select:"select",selectMulti:"selectMulti",rating:"rating",number:"number",toggle:"toggle",date:"date",user:"user",userMulti:"userMulti"},Pe={NONE:"NONE",CONTENT:"CONTENT",CREATION_CONTEXT:"CREATION_CONTEXT"},wo=e.object({id:e.string(),displayName:e.string(),color:e.string().optional()}),j=e.object({name:e.string(),type:e.enum(["text","longText","select","selectMulti","rating","number","toggle","date","user","userMulti"]),autofillSource:e.nativeEnum(Pe).optional(),text:e.any().optional(),longText:e.any().optional(),select:e.any().optional(),selectMulti:e.any().optional(),rating:e.any().optional(),number:e.any().optional(),toggle:e.any().optional(),date:e.any().optional(),user:e.any().optional(),userMulti:e.any().optional()}),Qo=e.object({key:e.string().optional(),label:e.string().optional(),scope:e.string().optional(),config:j,description:e.string().default("")}),Lo=e.object({label:e.string().optional(),config:j,description:e.string().optional()}),Ee=e.object({fieldId:e.string(),visible:e.boolean()}),Oo=e.array(Ee),Ce=e.object({key:e.string(),value:e.any()}),Fo=e.array(Ce),Go=e.object({id:e.string(),config:j,scope:e.string(),readOnly:e.boolean(),visible:e.boolean(),description:e.string()});var $=e.enum(["auto","none","bearer","oauth"]),q=e.enum(["streamable_http","sse"]),h=e.enum(["owner","editor","reviewer"]),Me=e.object({grantType:e.enum(["authorization_code","client_credentials"]).optional(),clientId:e.string().optional(),clientSecret:e.string().optional(),scope:e.string().optional(),authorizationParams:e.record(e.string(),e.string()).optional(),redirectUri:e.string().optional(),clientName:e.string().optional(),clientUri:e.string().optional(),skipIssuerMetadataValidation:e.boolean().optional()}),X=e.object({type:$.optional(),bearerToken:e.string().optional(),headers:e.record(e.string(),e.string()).optional(),oauth:Me.optional()}),P=e.object({excludeTools:e.array(e.string()).optional(),requestTimeoutMs:e.number().int().positive().optional(),idleTimeoutMs:e.number().int().positive().optional(),keepAlive:e.boolean().optional(),protocolVersion:e.enum(["legacy","auto","2026-07-28"]).optional(),directTools:e.array(e.string()).optional()}),De=e.object({name:e.string(),title:e.string().optional(),description:e.string().optional(),inputSchema:e.unknown().optional()}),Bo=e.object({url:e.string().url(),transport:q.optional(),authConfig:X.optional(),config:P.optional(),permission:h.optional()}),Ho=e.object({transport:q.optional(),authConfig:X.optional(),config:P.optional(),permission:h.optional()}),Zo=e.object({permission:h}),Ue=e.object({id:e.string(),name:e.string(),description:e.string().optional(),instructions:e.string().optional(),url:e.string(),transport:q,authType:$,config:P.optional(),permission:h,status:e.string(),lastError:e.string().nullable().optional(),toolCount:e.number(),hasCredential:e.boolean(),createdAt:e.string(),updatedAt:e.string()}),Yo=e.object({servers:e.array(Ue)}),Jo=e.object({}),$o=e.object({tools:e.array(De)}),A=e.enum(["authenticated","expired","not_authenticated","in_progress"]),Xo=e.object({status:A}),Ao=e.object({authorizationUrl:e.string().optional(),status:A}),zo=e.object({code:e.string(),iss:e.string().optional()}),er=e.object({ok:e.boolean(),toolCount:e.number(),message:e.string().optional()});var z=e.object({id:e.string().optional(),name:e.string().optional(),role:e.string().optional()}),ee=e.object({id:e.string().optional(),name:e.string().optional()}),Ne=e.object({id:e.string().optional(),proxyType:e.enum(["image","video","audio","pdf"]).nullable().optional(),name:e.string().optional(),preview:e.string().optional(),thumbnailUrl:e.string().optional(),originalWidth:e.number().optional(),originalHeight:e.number().optional()}),Ke=e.object({id:e.string().optional(),title:e.string().optional(),status:e.string().optional()}),rr=e.object({id:e.string().optional(),creator:z.optional(),type:e.string().optional(),team:ee.optional(),project:ee.optional(),asset:Ne.optional(),kanbanTask:Ke.optional(),user:z.optional(),createdAt:e.string().optional(),isRead:e.boolean().optional()}),ar=e.object({unreadOnly:e.union([e.boolean(),e.string()]).transform((t)=>t===!0||t==="true").optional(),after:e.string().optional(),pageSize:e.coerce.number().optional()}),nr=e.object({notificationId:e.string().min(1)}),sr=e.object({comments:e.boolean().default(!0),replies:e.boolean().default(!0),mentions:e.boolean().default(!0),yourUploads:e.boolean().default(!1),otherUploads:e.boolean().default(!0),statusUpdates:e.boolean().default(!0),kanbanTasks:e.boolean().default(!0),kanbanComments:e.boolean().default(!0)});var ur=e.object({name:e.string(),coverImageKey:e.string().optional(),enableNotification:e.boolean().default(!0)}),dr=e.object({name:e.string().optional(),coverImageKey:e.string().optional(),enableNotification:e.boolean().optional()}),we=e.object({id:e.string(),name:e.string(),teamId:e.string(),rootFolder:e.string().optional(),coverImage:e.string().optional(),coverImageKey:e.string().optional(),enableNotification:e.boolean(),updatedAt:e.union([e.string(),e.date()])}),fr=e.object({sortBy:e.string().optional(),sortDirection:e.enum(["asc","desc"]).optional()}).merge(p),gr=e.object({data:e.array(we),pageInfo:u}),yr=e.object({teamId:e.string()}),br=e.object({id:e.string(),name:e.string(),role:e.enum(["owner","editor","reviewer","bot","unknown"]),type:e.nativeEnum(g).optional(),image:e.string().optional(),scope:e.enum(["team","project"]).optional(),hasCustomRole:e.boolean().optional()}),hr=e.object({assetType:I.optional().default("all"),sort:e.enum(["createdAt","name","size"]).optional(),order:e.enum(["asc","desc"]).optional()}).merge(p),Sr=e.object({role:e.enum(["editor","reviewer"])}),_r=e.object({userId:e.string(),role:e.enum(["owner","editor","reviewer"])}),xr=e.object({id:e.string(),name:e.string(),role:e.enum(["owner","editor","reviewer","bot","unknown"]),image:e.string().optional()});var te=["openai-completions","mistral-conversations","openai-responses","azure-openai-responses","openai-codex-responses","anthropic-messages","bedrock-converse-stream","google-generative-ai","google-vertex"],Qe=e.object({api:e.enum(te).optional(),reasoning:e.boolean().default(!1),input:e.array(e.enum(["text","image"])).default(["text"]),contextWindow:e.number().int().positive().default(128000),maxTokens:e.number().int().positive().default(4096),cost:e.object({input:e.number().nonnegative().default(0),output:e.number().nonnegative().default(0),cacheRead:e.number().nonnegative().default(0),cacheWrite:e.number().nonnegative().default(0)})}),E=e.object({id:e.string().optional(),modelId:e.string().min(1,"Model ID is required"),name:e.string().min(0).default(""),config:Qe}),C=e.object({baseUrl:e.string().url("Must be a valid URL").optional().or(e.literal("")),apiKey:e.string().optional().or(e.literal("")),api:e.enum(te),headers:e.record(e.string(),e.string()).optional(),authHeader:e.boolean().optional()}),Ir=e.object({name:e.string().min(1,"Provider name is required"),config:C,models:e.array(E).min(1,"At least one model is required")}),Tr=e.object({config:C,models:e.array(E).min(1,"At least one model is required")}),vr=e.object({id:e.string(),name:e.string(),isBuiltin:e.boolean(),config:C,models:e.array(E).optional(),modelsCount:e.number().optional(),createdAt:e.date(),updatedAt:e.date()});var Er=e.object({name:e.string().min(1),expireAt:e.string().datetime().optional(),password:e.string().optional(),isDisabled:e.boolean().optional(),allowDownload:e.boolean().optional(),defaultSortOrder:e.string().optional(),viewMode:e.string().optional()}),Cr=e.object({name:e.string().min(1).optional(),expireAt:e.string().datetime().optional().nullable(),password:e.string().optional().nullable(),isDisabled:e.boolean().optional(),allowDownload:e.boolean().optional(),defaultSortOrder:e.string().optional().nullable(),viewMode:e.string().optional().nullable(),fieldVisibility:e.record(e.string(),e.boolean()).optional().nullable()}),Mr=p.extend({projectId:e.string().optional()}),Dr=e.object({assetIds:e.array(e.string().min(1)).min(1)});var Kr=e.object({assetId:e.string().optional(),githubUrl:e.string().optional(),override:e.boolean().optional()}),wr=e.object({config:e.object({environmentVariables:e.array(e.object({name:e.string(),default:e.string().optional()}))})}),Qr=e.object({permission:e.enum(["owner","editor","reviewer"])});var oe=e.lazy(()=>e.object({name:e.string(),id:e.string(),size:e.number(),children:e.array(oe),type:e.string(),mediaType:e.string().optional()})),Fr=e.object({parentId:e.string(),files:e.array(oe)}),Le=e.object({id:e.string(),fileId:e.string(),url:e.string()}),Gr=e.object({taskId:e.string(),presignedUrls:e.array(Le),createdAssets:e.array(e.object({tempId:e.string(),assetId:e.string()})).optional()}),Vr=e.object({fileId:e.string(),errorMessage:e.string().optional()}),Wr=e.object({id:e.string(),name:e.string(),total:e.number(),uploaded:e.number(),createdAt:e.string()}),Br=e.object({bucket:e.string(),key:e.string(),Signature:e.string()}),Hr=e.object({file:e.instanceof(File)});var Oe=e.object({key:e.string(),value:e.unknown()}),Jr=e.object({value:e.unknown()}),$r=e.array(Oe);var zr=e.object({fileIds:e.array(e.string())}),ea=e.object({fileId:e.string(),beforeId:e.string()}),ta=e.object({id:e.string(),version:e.number(),name:e.string().optional().nullable(),previewUrl:e.string().optional().nullable(),createdAt:e.string().optional().nullable(),creator:e.object({id:e.string(),name:e.string().nullable(),image:e.string().optional().nullable()}).nullable().optional()});var aa=e.object({agentId:e.string(),textPrompt:e.string().optional(),attachedFiles:e.array(e.string()).optional(),assetIds:e.array(e.string()).optional(),sessionId:e.string().optional(),contextAssetId:e.string().optional(),projectId:e.string().optional()}).superRefine((t,a)=>{let n=t.textPrompt&&t.textPrompt.trim().length>0,r=t.attachedFiles&&t.attachedFiles.length>0,s=t.assetIds&&t.assetIds.length>0;if(!n&&!r&&!s)a.addIssue({code:e.ZodIssueCode.custom,message:"At least one of textPrompt, attachedFiles, or assetIds must be provided.",path:["textPrompt"]})}),na=e.object({id:e.string(),agentId:e.string(),userId:e.string().nullable(),assetId:e.string().nullable(),userCommentId:e.string().nullable(),name:e.string().nullable().optional(),createdAt:e.string(),updatedAt:e.string()}),Fe=e.object({id:e.string(),name:e.string(),type:e.string(),mediaType:e.enum(["image","video","pdf","audio","other"]).optional(),mimeType:e.string().optional(),parentId:e.string().optional(),path:e.string().optional(),durationSeconds:e.number().optional(),totalFrames:e.number().optional(),totalPages:e.number().optional(),navigated:e.boolean().optional(),ancestors:e.array(e.object({id:e.string(),name:e.string()})).optional()}),re=e.object({id:e.string(),name:e.string(),type:e.string(),mediaType:e.enum(["image","video","pdf","audio","other"]).optional(),mimeType:e.string().optional(),path:e.string().optional()}),Ge=e.discriminatedUnion("type",[e.object({type:e.literal("time"),seconds:e.number()}),e.object({type:e.literal("page"),page:e.number()})]),sa=e.object({user:e.object({id:e.string(),name:e.string(),role:e.string()}).optional(),currentAsset:Fe.optional(),position:Ge.optional(),annotation:e.boolean().optional(),attachedFiles:e.array(re).optional(),referencedAssets:e.array(re).optional()}),ia=e.intersection(e.object({id:e.string()}),e.unknown());var S;((o)=>{o.team_create="team_create";o.team_update="team_update";o.team_delete="team_delete";o.team_member_add="team_member_add";o.team_member_update="team_member_update";o.team_member_remove="team_member_remove";o.project_create="project_create";o.project_update="project_update";o.project_delete="project_delete";o.project_empty_trash="project_empty_trash";o.project_member_add="project_member_add";o.project_member_update="project_member_update";o.project_member_remove="project_member_remove";o.file_create="file_create";o.file_update="file_update";o.file_delete="file_delete";o.folder_create="folder_create";o.folder_update="folder_update";o.folder_delete="folder_delete";o.asset_reparent="asset_reparent";o.asset_copy="asset_copy";o.share_create="share_create";o.share_update="share_update";o.share_delete="share_delete";o.agent_create="agent_create";o.agent_update="agent_update";o.agent_delete="agent_delete";o.skill_create="skill_create";o.skill_update="skill_update";o.skill_delete="skill_delete";o.mcp_server_create="mcp_server_create";o.mcp_server_update="mcp_server_update";o.mcp_server_delete="mcp_server_delete";o.provider_create="provider_create";o.provider_update="provider_update";o.provider_delete="provider_delete";o.invite_create="invite_create";o.invite_revoke="invite_revoke";o.metadata_field_create="metadata_field_create";o.metadata_field_update="metadata_field_update";o.metadata_field_delete="metadata_field_delete";o.comment_create="comment_create";o.comment_update="comment_update";o.comment_delete="comment_delete";o.comment_complete="comment_complete";o.quota_rule_create="quota_rule_create";o.quota_rule_update="quota_rule_update";o.quota_rule_delete="quota_rule_delete";o.quota_record_reset="quota_record_reset";o.quota_policy_create="quota_policy_create";o.quota_policy_update="quota_policy_update";o.quota_policy_delete="quota_policy_delete";o.kanban_goal_create="kanban_goal_create";o.kanban_goal_update="kanban_goal_update";o.kanban_goal_delete="kanban_goal_delete";o.kanban_task_create="kanban_task_create";o.kanban_task_update="kanban_task_update";o.kanban_task_delete="kanban_task_delete";o.kanban_comment_create="kanban_comment_create";o.kanban_comment_delete="kanban_comment_delete";o.kanban_dependency_add="kanban_dependency_add";o.kanban_dependency_remove="kanban_dependency_remove"})(S||={});var Ve=e.object({id:e.string(),action:e.nativeEnum(S),teamId:e.string(),userId:e.string().nullable().optional(),projectId:e.string().nullable().optional(),itemId:e.string().nullable().optional(),createdAt:e.string()}),la=e.object({first:e.coerce.number().optional(),after:e.string().optional(),actions:e.union([e.nativeEnum(S),e.array(e.nativeEnum(S))]).transform((t)=>Array.isArray(t)?t:[t]).optional(),userIds:e.union([e.string(),e.array(e.string())]).transform((t)=>Array.isArray(t)?t:[t]).optional(),itemId:e.string().optional()}),ma=e.object({nodes:e.array(Ve),pageInfo:e.object({hasNextPage:e.boolean(),endCursor:e.string().nullable()}),total:e.number()});var We=e.object({id:e.string(),type:e.literal("text"),x:e.number().min(0).max(1),y:e.number().min(0).max(1),opacity:e.number().min(0).max(1),rotation:e.number().min(-180).max(180),text:e.string(),size:e.number().positive().max(1),color:e.string()}),Be=e.object({id:e.string(),type:e.literal("image"),x:e.number().min(0).max(1),y:e.number().min(0).max(1),opacity:e.number().min(0).max(1),rotation:e.number().min(-180).max(180),imageAssetKey:e.string().min(1),imageAssetUrl:e.string().optional(),size:e.number().positive().max(1)}),He=e.discriminatedUnion("type",[We,Be]),M=e.object({blocks:e.array(He)}),fa=e.object({name:e.string().min(1),teamId:e.string().optional(),config:M}),ga=e.object({name:e.string().min(1).optional(),config:M.optional()}),ya=e.object({enabled:e.boolean(),config:M.optional()}).superRefine((t,a)=>{if(t.enabled&&(!t.config||t.config.blocks.length===0))a.addIssue({code:"custom",path:["config"],message:"Watermark configuration is required when enabling watermark"})});var D=e.nativeEnum(V),U=e.enum(["1hour","5hour","1day","7day","one_hour","five_hours","one_day","seven_days"]);function xa(t){switch(t){case"one_hour":case"1hour":return"1hour";case"five_hours":case"5hour":return"5hour";case"one_day":case"1day":return"1day";case"seven_days":case"7day":return"7day";default:return t}}var N=e.nativeEnum(W),K=e.enum(["owner","editor","reviewer"]),ae=e.object({id:e.string().min(1,"MCP server ID is required")}),ne=e.object({match:e.string().min(1,"Bash match wildcard is required")}),se=e.object({name:e.string().min(1,"Tool name is required")}),w=e.record(e.string(),e.unknown()),Ze=e.object({id:e.string().nullable(),ruleId:e.string(),teamId:e.string(),userId:e.string().nullable().optional(),user:e.object({id:e.string(),name:e.string(),email:e.string(),image:e.string().nullable().optional()}).nullable().optional(),periodStart:e.string().nullable().optional(),periodEnd:e.string().nullable().optional(),consumed:e.number(),remaining:e.number(),percent:e.number(),isWindowActive:e.boolean()}),ka=e.object({records:e.array(Ze),total:e.number()}),Ye=e.object({id:e.string(),teamId:e.string(),scopeMode:D,role:K.nullable().optional(),userIds:e.array(e.string()).nullable().optional(),resource:N,resourceData:w.nullable().optional(),limit:e.number(),period:U,enabled:e.boolean(),recordsCount:e.number().optional(),createdAt:e.string(),updatedAt:e.string()}),Ra=e.object({rules:e.array(Ye),total:e.number()}),Ia=e.object({scopeMode:D,role:K.optional().nullable(),userIds:e.array(e.string()).optional().nullable(),resource:N,resourceData:w.optional().nullable(),limit:e.number().positive("Limit must be greater than 0"),period:U,enabled:e.boolean().optional().default(!0)}).superRefine((t,a)=>{if(t.scopeMode==="selected_members"){if(!t.userIds||t.userIds.length===0)a.addIssue({code:e.ZodIssueCode.custom,message:'userIds must contain at least one user when scopeMode is "selected_members"',path:["userIds"]})}if(t.resource==="agent_mcp_call_count"){if(!ae.safeParse(t.resourceData).success)a.addIssue({code:e.ZodIssueCode.custom,message:"resourceData.id is required for agent_mcp_call_count",path:["resourceData","id"]})}else if(t.resource==="agent_bash_call_count"){if(!ne.safeParse(t.resourceData).success)a.addIssue({code:e.ZodIssueCode.custom,message:"resourceData.match is required for agent_bash_call_count",path:["resourceData","match"]})}else if(t.resource==="agent_tool_call_count"){if(!se.safeParse(t.resourceData).success)a.addIssue({code:e.ZodIssueCode.custom,message:"resourceData.name is required for agent_tool_call_count",path:["resourceData","name"]})}}),Ta=e.object({userId:e.string().nullable()}),va=e.object({scopeMode:D.optional(),role:K.optional().nullable(),userIds:e.array(e.string()).optional().nullable(),resource:N.optional(),resourceData:w.optional().nullable(),limit:e.number().positive("Limit must be greater than 0").optional(),period:U.optional(),enabled:e.boolean().optional()}).superRefine((t,a)=>{if(t.scopeMode==="selected_members"&&t.userIds!==void 0){if(!t.userIds||t.userIds.length===0)a.addIssue({code:e.ZodIssueCode.custom,message:'userIds must contain at least one user when scopeMode is "selected_members"',path:["userIds"]})}if(t.resource==="agent_mcp_call_count"&&t.resourceData!==void 0){if(!ae.safeParse(t.resourceData).success)a.addIssue({code:e.ZodIssueCode.custom,message:"resourceData.id is required for agent_mcp_call_count",path:["resourceData","id"]})}else if(t.resource==="agent_bash_call_count"&&t.resourceData!==void 0){if(!ne.safeParse(t.resourceData).success)a.addIssue({code:e.ZodIssueCode.custom,message:"resourceData.match is required for agent_bash_call_count",path:["resourceData","match"]})}else if(t.resource==="agent_tool_call_count"&&t.resourceData!==void 0){if(!se.safeParse(t.resourceData).success)a.addIssue({code:e.ZodIssueCode.custom,message:"resourceData.name is required for agent_tool_call_count",path:["resourceData","name"]})}});var Pa="unassigned",Ea=e.object({title:e.string().min(1),description:e.string().optional()}),Ca=e.object({title:e.string().min(1).optional(),description:e.string().nullable().optional()}),Je=e.object({id:e.string(),title:e.string(),description:e.string().nullable().optional(),teamId:e.string(),creatorId:e.string().nullable().optional(),taskCount:e.number().optional(),createdAt:e.union([e.string(),e.date()]),updatedAt:e.union([e.string(),e.date()])}),Ma=e.object({}),Da=e.object({data:e.array(Je)});var l=e.object({id:e.string(),name:e.string(),image:e.string().optional()}),$e=e.object({summary:e.string().optional(),blockReason:e.string().optional(),blockKind:e.string().optional(),reason:e.string().optional(),assets:e.array(e.object({id:e.string(),type:e.string().optional(),name:e.string().optional(),description:e.string().optional()})).optional()}).passthrough(),Q=e.object({id:e.string(),taskId:e.string(),actor:l.nullable().optional(),type:e.nativeEnum(y),fromStatus:e.nativeEnum(c).nullable().optional(),toStatus:e.nativeEnum(c).nullable().optional(),data:$e.nullable().optional(),createdAt:e.union([e.string(),e.date()])}),wa=e.object({data:e.array(Q)});var Xe=e.object({id:e.string(),name:e.string(),key:e.string(),sizeByte:e.number(),contentType:e.string().nullable().optional(),proxyType:e.enum(["image","video","audio","pdf"]).nullable().optional()}),Ae=e.object({id:e.string(),name:e.string(),sizeByte:e.number(),contentType:e.string().nullable().optional(),url:e.string(),proxyType:e.enum(["image","video","audio","pdf"]).nullable().optional()}),Fa=e.object({id:e.string(),name:e.string(),key:e.string(),sizeByte:e.number(),contentType:e.string().nullable().optional(),uploadUrl:e.string(),proxyType:e.enum(["image","video","audio","pdf"]).nullable().optional()}),Ga=e.object({body:e.string().default(""),attachments:e.array(Xe).optional()}).refine((t)=>t.body.trim().length>0||t.attachments&&t.attachments.length>0,{message:"Comment body or attachments required"}),L=e.object({id:e.string(),taskId:e.string(),author:l,body:e.string(),attachments:e.array(Ae).default([]),createdAt:e.union([e.string(),e.date()]),updatedAt:e.union([e.string(),e.date()])}),Va=e.object({data:e.array(L)});var $a=e.object({title:e.string().min(1),description:e.string().optional(),isAgentTask:e.boolean().optional(),priority:e.nativeEnum(d).optional(),startDate:e.union([e.string(),e.date()]).optional(),dueDate:e.union([e.string(),e.date()]).optional(),goalId:e.string().optional(),projectId:e.string().optional(),reporterId:e.string().optional(),assigneeId:e.string().optional(),targetFolderId:e.string().optional(),parentIds:e.array(e.string()).optional(),assetIds:e.array(e.string()).optional()}),Xa=e.object({fromStatus:e.nativeEnum(c).optional(),title:e.string().min(1).optional(),description:e.string().nullable().optional(),status:e.nativeEnum(c).optional(),reason:e.string().optional(),priority:e.nativeEnum(d).optional(),startDate:e.union([e.string(),e.date()]).nullable().optional(),dueDate:e.union([e.string(),e.date()]).nullable().optional(),goalId:e.string().nullable().optional(),projectId:e.string().nullable().optional(),reporterId:e.string().nullable().optional(),assigneeId:e.string().nullable().optional(),targetFolderId:e.string().nullable().optional(),beforeIndex:e.string().optional(),afterIndex:e.string().optional(),parentIds:e.array(e.string()).optional(),assetIds:e.array(e.string()).optional()}),Aa=e.object({status:e.nativeEnum(c).optional(),isAgentTask:e.union([e.boolean(),e.string()]).transform((t)=>t===!0||t==="true").optional(),goalId:e.string().optional(),projectId:e.string().optional(),priority:e.nativeEnum(d).optional(),assigneeId:e.string().optional(),reporterId:e.string().optional()}).merge(p),ze=e.object({id:e.string(),type:e.nativeEnum(y),actor:l.nullable().optional(),summary:e.string().optional(),blockReason:e.string().optional(),blockKind:e.string().optional(),reason:e.string().optional(),createdAt:e.union([e.string(),e.date()])}),et=e.object({id:e.string(),title:e.string()}),ie=e.object({id:e.string(),title:e.string(),isAgentTask:e.boolean(),status:e.nativeEnum(c),priority:e.nativeEnum(d),sortIndex:e.string().nullable().optional()}),tt=e.object({id:e.string(),name:e.string(),type:e.string(),proxyType:e.enum(["image","video","audio","pdf"]).nullable().optional(),thumbnailUrl:e.string().nullable().optional(),path:e.string(),creator:l.nullable().optional(),sizeByte:e.number().optional(),fileCount:e.number().optional(),projectId:e.string().nullable().optional(),createdAt:e.union([e.string(),e.date()])}),O=e.object({id:e.string(),title:e.string(),description:e.string().nullable().optional(),isAgentTask:e.boolean(),status:e.nativeEnum(c),priority:e.nativeEnum(d),startDate:e.union([e.string(),e.date()]).nullable().optional(),dueDate:e.union([e.string(),e.date()]).nullable().optional(),startedAt:e.union([e.string(),e.date()]).nullable().optional(),completedAt:e.union([e.string(),e.date()]).nullable().optional(),teamId:e.string(),projectId:e.string().nullable().optional(),sortIndex:e.string().nullable().optional(),creator:l,reporter:l.nullable().optional(),assignee:l.nullable().optional(),goal:et.nullable().optional(),targetFolderId:e.string().nullable().optional(),latestStatusEvent:ze.nullable().optional(),commentCount:e.number().default(0),dependencyCount:e.number().default(0),dependentCount:e.number().default(0),assetCount:e.number().default(0),createdAt:e.union([e.string(),e.date()]),updatedAt:e.union([e.string(),e.date()])}),za=O.extend({dependencies:e.array(ie),dependents:e.array(ie),assets:e.array(tt),comments:e.array(L),events:e.array(Q)}),en=e.object({data:e.array(O),pageInfo:u}),tn=e.object({taskId:e.string()}),on=e.object({assetIds:e.array(e.string())}),rn=e.object({data:e.array(O),total:e.number()});var dn=e.object({assetId:e.string()});function ot(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function i(t,a){if(a===void 0||a===null)return"";return` ${t}="${ot(a)}"`}function gn(t){if(!t)return"";let a=[];if(t.user){let n="";if(t.user.id!==void 0)n+=i("id",t.user.id);if(t.user.name!==void 0)n+=i("name",t.user.name);if(t.user.role!==void 0)n+=i("role",t.user.role);if(n)a.push(` <user${n} />`)}if(t.currentAsset){let n=t.currentAsset,r="";if(n.id!==void 0)r+=i("id",n.id);if(n.name!==void 0)r+=i("name",n.name);if(n.type!==void 0)r+=i("type",n.type);if(n.mediaType!==void 0)r+=i("media_type",n.mediaType);if(n.mimeType!==void 0)r+=i("mime_type",n.mimeType);if(n.parentId!==void 0)r+=i("parent_id",n.parentId);if(n.path!==void 0)r+=i("path",n.path);if(n.durationSeconds!==void 0)r+=` duration_seconds="${n.durationSeconds.toFixed(2)}"`;if(n.totalFrames!==void 0)r+=` total_frames="${Math.round(n.totalFrames)}"`;if(n.totalPages!==void 0)r+=` total_pages="${Math.round(n.totalPages)}"`;if(n.navigated!==void 0)r+=` navigated="${String(n.navigated)}"`;if(n.ancestors&&n.ancestors.length>0){a.push(` <current_asset${r}>`),a.push(" <ancestors>");for(let s of n.ancestors){let x="";if(s.id!==void 0)x+=i("id",s.id);if(s.name!==void 0)x+=i("name",s.name);a.push(` <folder${x} />`)}a.push(" </ancestors>"),a.push(" </current_asset>")}else a.push(` <current_asset${r} />`)}if(t.position){if(t.position.type==="time")a.push(` <position type="time" seconds="${t.position.seconds.toFixed(2)}" />`);else if(t.position.type==="page")a.push(` <position type="page" page="${Math.round(t.position.page)}" />`)}if(t.annotation)a.push(" <annotation />");if(t.attachedFiles&&t.attachedFiles.length>0){let n=[...t.attachedFiles].sort((r,s)=>r.id.localeCompare(s.id));a.push(" <attached_files>");for(let r of n){let s="";if(r.id!==void 0)s+=i("id",r.id);if(r.name!==void 0)s+=i("name",r.name);if(r.type!==void 0)s+=i("type",r.type);if(r.mediaType!==void 0)s+=i("media_type",r.mediaType);if(r.mimeType!==void 0)s+=i("mime_type",r.mimeType);if(r.path!==void 0)s+=i("path",r.path);a.push(` <file${s} />`)}a.push(" </attached_files>")}if(t.referencedAssets&&t.referencedAssets.length>0){let n=[...t.referencedAssets].sort((r,s)=>r.id.localeCompare(s.id));a.push(" <referenced_assets>");for(let r of n)if(r.type==="folder"){let s="";if(r.id!==void 0)s+=i("id",r.id);if(r.name!==void 0)s+=i("name",r.name);if(r.path!==void 0)s+=i("path",r.path);a.push(` <folder${s} />`)}else{let s="";if(r.id!==void 0)s+=i("id",r.id);if(r.name!==void 0)s+=i("name",r.name);if(r.type!==void 0)s+=i("type",r.type);if(r.mediaType!==void 0)s+=i("media_type",r.mediaType);if(r.mimeType!==void 0)s+=i("mime_type",r.mimeType);if(r.path!==void 0)s+=i("path",r.path);a.push(` <asset${s} />`)}a.push(" </referenced_assets>")}if(a.length===0)return"";return`<context>
2
+ ${a.join(`
3
+ `)}
4
+ </context>`}function Yn({...t}){return m(f.Root,{"data-slot":"popover",...t})}function Jn({...t}){return m(f.Trigger,{"data-slot":"popover-trigger",...t})}function $n({className:t,align:a="center",sideOffset:n=4,...r}){return m(f.Portal,{children:m(f.Content,{"data-slot":"popover-content",align:a,sideOffset:n,className:_("z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden 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",t),...r})})}function os({className:t,...a}){return m(F.Root,{"data-slot":"checkbox",className:_("peer size-4 shrink-0 rounded-[4px] border border-input shadow-xs transition-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-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:data-[state=checked]:bg-primary",t),...a,children:m(F.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:m(pe,{className:"size-3.5"})})})}
5
+ export{Yn as Nf,Jn as Of,$n as Pf,c as Qf,d as Rf,y as Sf,Z as Tf,Ko as Uf,Pe as Vf,te as Wf,E as Xf,C as Yf,le as Zf,me as _f,S as $f,xa as ag,Pa as bg,gn as cg,os as dg};
@@ -1,2 +1,2 @@
1
- import{we as A}from"./chunk-gwzk0fvn.js";import{qi as z}from"./chunk-jsqsrcse.js";import{Li as v,Vi as w}from"./chunk-48yphy68.js";var B=(b)=>({queryKey:["projects",b],queryFn:async()=>{let h=await z.api.projects[":projectId"].$get({param:{projectId:b}});if(!h.ok)throw Error("Failed to fetch project");return await h.json()}}),H=w("/projects/$projectId/folders/$folderId_/agentsmd")({loader:({context:{queryClient:b},params:{projectId:h}})=>b.ensureQueryData(B(h)),pendingComponent:()=>v(A,{})});
2
- export{B as je,H as ke};
1
+ import{og as A}from"./chunk-7xcyn1ba.js";import{Ii as z}from"./chunk-s503pcvb.js";import{bj as v,lj as w}from"./chunk-w9p59ahz.js";var B=(b)=>({queryKey:["projects",b],queryFn:async()=>{let h=await z.api.projects[":projectId"].$get({param:{projectId:b}});if(!h.ok)throw Error("Failed to fetch project");return await h.json()}}),H=w("/projects/$projectId/folders/$folderId_/agentsmd")({loader:({context:{queryClient:b},params:{projectId:h}})=>b.ensureQueryData(B(h)),pendingComponent:()=>v(A,{})});
2
+ export{B as re,H as se};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{mm as F}from"./chunk-fsj3kxya.js";import{pm as B,qm as A,rm as b,sm as h,tm as x,um as f,vm as g}from"./chunk-12r8a5ev.js";import{Am as H,xm as N,zm as v}from"./chunk-4yke5y3z.js";import{Bm as K,Cm as y}from"./chunk-wdgwymdp.js";import{Jm as I}from"./chunk-r18tcdds.js";import{Mm as C}from"./chunk-393g7z2g.js";import{Om as T}from"./chunk-xsqk7ek2.js";import{Tm as L,Um as P}from"./chunk-cmd0feyq.js";import{Vm as U}from"./chunk-a5ja6d97.js";import"./chunk-69at8jm8.js";var k="v1",u="gcp-vertex-credentials",c={THINKING_LEVEL_UNSPECIFIED:N.THINKING_LEVEL_UNSPECIFIED,MINIMAL:N.MINIMAL,LOW:N.LOW,MEDIUM:N.MEDIUM,HIGH:N.HIGH},s=0,V=(q,w,J)=>{let X=new U;return(async()=>{let Q={role:"assistant",content:[],api:"google-vertex",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 z=e(J),$=z?l(q,z,J?.headers):p(q,o(J),qq(J),J?.headers,J?.env),R=wq(q,w,J),_=await J?.onPayload?.(R,q);if(_!==void 0)R=_;let d=await $.models.generateContentStream(R);X.push({type:"start",partial:Q});let Y=null,M=Q.content,D=()=>M.length-1;for await(let W of d){Q.responseId||=W.responseId;let G=W.candidates?.[0];if(G?.content?.parts)for(let Z of G.content.parts){if(Z.text!==void 0){let S=B(Z);if(!Y||S&&Y.type!=="thinking"||!S&&Y.type!=="text"){if(Y)if(Y.type==="text")X.push({type:"text_end",contentIndex:M.length-1,content:Y.text,partial:Q});else X.push({type:"thinking_end",contentIndex:D(),content:Y.thinking,partial:Q});if(S)Y={type:"thinking",thinking:"",thinkingSignature:void 0},Q.content.push(Y),X.push({type:"thinking_start",contentIndex:D(),partial:Q});else Y={type:"text",text:""},Q.content.push(Y),X.push({type:"text_start",contentIndex:D(),partial:Q})}if(Y.type==="thinking")Y.thinking+=Z.text,Y.thinkingSignature=A(Y.thinkingSignature,Z.thoughtSignature),X.push({type:"thinking_delta",contentIndex:D(),delta:Z.text,partial:Q});else Y.text+=Z.text,Y.textSignature=A(Y.textSignature,Z.thoughtSignature),X.push({type:"text_delta",contentIndex:D(),delta:Z.text,partial:Q})}if(Z.functionCall){if(Y){if(Y.type==="text")X.push({type:"text_end",contentIndex:D(),content:Y.text,partial:Q});else X.push({type:"thinking_end",contentIndex:D(),content:Y.thinking,partial:Q});Y=null}let S=Z.functionCall.id,j={type:"toolCall",id:!S||Q.content.some((O)=>O.type==="toolCall"&&O.id===S)?`${Z.functionCall.name}_${Date.now()}_${++s}`:S,name:Z.functionCall.name||"",arguments:Z.functionCall.args??{},...Z.thoughtSignature&&{thoughtSignature:Z.thoughtSignature}};Q.content.push(j),X.push({type:"toolcall_start",contentIndex:D(),partial:Q}),X.push({type:"toolcall_delta",contentIndex:D(),delta:JSON.stringify(j.arguments),partial:Q}),X.push({type:"toolcall_end",contentIndex:D(),toolCall:j,partial:Q})}}if(G?.finishReason){if(Q.stopReason=g(G.finishReason),Q.content.some((Z)=>Z.type==="toolCall"))Q.stopReason="toolUse"}if(W.usageMetadata)Q.usage={input:(W.usageMetadata.promptTokenCount||0)-(W.usageMetadata.cachedContentTokenCount||0),output:(W.usageMetadata.candidatesTokenCount||0)+(W.usageMetadata.thoughtsTokenCount||0),cacheRead:W.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:W.usageMetadata.thoughtsTokenCount||0,totalTokens:W.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},L(q,Q.usage)}if(Y)if(Y.type==="text")X.push({type:"text_end",contentIndex:D(),content:Y.text,partial:Q});else X.push({type:"thinking_end",contentIndex:D(),content:Y.thinking,partial:Q});if(J?.signal?.aborted)throw Error("Request was aborted");if(Q.stopReason==="aborted"||Q.stopReason==="error")throw Error("An unknown error occurred");X.push({type:"done",reason:Q.stopReason,message:Q}),X.end()}catch(z){for(let $ of Q.content)if("index"in $)delete $.index;Q.stopReason=J?.signal?.aborted?"aborted":"error",Q.errorMessage=y(K(z)),X.push({type:"error",reason:Q.stopReason,error:Q}),X.end()}})(),X},Gq=(q,w,J)=>{let X=I(q,w,J,void 0);if(!J?.reasoning)return V(q,w,{...X,thinking:{enabled:!1}});let Q=P(q,J.reasoning),z=Q==="off"?"high":Q,$=q;if(E($)||a($))return V(q,w,{...X,thinking:{enabled:!0,level:Qq(z,$)}});return V(q,w,{...X,thinking:{enabled:!0,budgetTokens:Xq($,z,J.thinkingBudgets)}})};function p(q,w,J,X,Q){let z=n(Q);return new H({vertexai:!0,project:w,location:J,apiVersion:k,...z?{googleAuthOptions:z}:{},httpOptions:m(q,X)})}function l(q,w,J){return new H({vertexai:!0,apiKey:w,apiVersion:k,httpOptions:m(q,J)})}function m(q,w){let J={},X=r(q.baseUrl);if(X){if(J.baseUrl=X,J.baseUrlResourceScope=v.COLLECTION,i(X))J.apiVersion=""}let Q=T({...q.headers,...w});if(Q)J.headers=Q;return Object.keys(J).length>0?J:void 0}function r(q){let w=q.trim();if(!w||w.includes("{location}"))return;return w}function i(q){try{return new URL(q).pathname.split("/").some((J)=>/^v\d+(?:beta\d*)?$/.test(J))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(q)}}function n(q){let w=F("GOOGLE_APPLICATION_CREDENTIALS",q);return w?{keyFilename:w}:void 0}function e(q){let w=q?.apiKey?.trim();if(!w||w===u||t(w))return;return w}function t(q){return/^<[^>]+>$/.test(q)}function o(q){let w=q?.project||F("GOOGLE_CLOUD_PROJECT",q?.env)||F("GCLOUD_PROJECT",q?.env);if(!w)throw Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");return w}function qq(q){let w=q?.location||F("GOOGLE_CLOUD_LOCATION",q?.env);if(!w)throw Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");return w}function wq(q,w,J={}){let X=b(q,w),Q={};if(J.temperature!==void 0)Q.temperature=J.temperature;if(J.maxTokens!==void 0)Q.maxOutputTokens=J.maxTokens;let z=w.tools?.length?f(w.tools,J.toolChoice,x(q.id)):void 0,$={...Object.keys(Q).length>0&&Q,...w.systemPrompt&&{systemInstruction:C(w.systemPrompt)},...w.tools&&w.tools.length>0&&{tools:h(w.tools)},...z!==void 0&&{toolConfig:{functionCallingConfig:{mode:z}}}};if(J.thinking?.enabled&&q.reasoning){let _={includeThoughts:!0};if(J.thinking.level!==void 0)_.thinkingLevel=c[J.thinking.level];else if(J.thinking.budgetTokens!==void 0)_.thinkingBudget=J.thinking.budgetTokens;$.thinkingConfig=_}else if(q.reasoning&&J.thinking&&!J.thinking.enabled)$.thinkingConfig=Jq(q);if(J.signal){if(J.signal.aborted)throw Error("Request aborted");$.abortSignal=J.signal}return{model:q.id,contents:X,config:$}}function E(q){return/gemini-3(?:\.\d+)?-pro/.test(q.id.toLowerCase())}function a(q){let w=q.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(w)||w==="gemini-flash-latest"||w==="gemini-flash-lite-latest"}function Jq(q){let w=q;if(E(w))return{thinkingLevel:N.LOW};if(a(w))return{thinkingLevel:N.MINIMAL};return{thinkingBudget:0}}function Qq(q,w){if(E(w))switch(q){case"minimal":case"low":return"LOW";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 Xq(q,w,J){if(J?.[w]!==void 0)return J[w];if(q.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[w];if(q.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[w];return-1}export{Gq as streamSimple,V as stream};
2
+ import{Gm as F}from"./chunk-rar0gk7s.js";import{Jm as B,Km as A,Lm as b,Mm as h,Nm as x,Om as f,Pm as g}from"./chunk-8pfgh13x.js";import{Rm as N,Tm as v,Um as H}from"./chunk-c97vh5wb.js";import{Vm as K,Wm as y}from"./chunk-pn94h6x7.js";import{bn as I}from"./chunk-wxsq9zmf.js";import{en as C}from"./chunk-k20w9eaz.js";import{gn as T}from"./chunk-7qzt5nhz.js";import{ln as L,mn as P}from"./chunk-116p639c.js";import{nn as U}from"./chunk-q46rc697.js";import"./chunk-txkmks1h.js";var k="v1",u="gcp-vertex-credentials",c={THINKING_LEVEL_UNSPECIFIED:N.THINKING_LEVEL_UNSPECIFIED,MINIMAL:N.MINIMAL,LOW:N.LOW,MEDIUM:N.MEDIUM,HIGH:N.HIGH},s=0,V=(q,w,J)=>{let X=new U;return(async()=>{let Q={role:"assistant",content:[],api:"google-vertex",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 z=e(J),$=z?l(q,z,J?.headers):p(q,o(J),qq(J),J?.headers,J?.env),R=wq(q,w,J),_=await J?.onPayload?.(R,q);if(_!==void 0)R=_;let d=await $.models.generateContentStream(R);X.push({type:"start",partial:Q});let Y=null,M=Q.content,D=()=>M.length-1;for await(let W of d){Q.responseId||=W.responseId;let G=W.candidates?.[0];if(G?.content?.parts)for(let Z of G.content.parts){if(Z.text!==void 0){let S=B(Z);if(!Y||S&&Y.type!=="thinking"||!S&&Y.type!=="text"){if(Y)if(Y.type==="text")X.push({type:"text_end",contentIndex:M.length-1,content:Y.text,partial:Q});else X.push({type:"thinking_end",contentIndex:D(),content:Y.thinking,partial:Q});if(S)Y={type:"thinking",thinking:"",thinkingSignature:void 0},Q.content.push(Y),X.push({type:"thinking_start",contentIndex:D(),partial:Q});else Y={type:"text",text:""},Q.content.push(Y),X.push({type:"text_start",contentIndex:D(),partial:Q})}if(Y.type==="thinking")Y.thinking+=Z.text,Y.thinkingSignature=A(Y.thinkingSignature,Z.thoughtSignature),X.push({type:"thinking_delta",contentIndex:D(),delta:Z.text,partial:Q});else Y.text+=Z.text,Y.textSignature=A(Y.textSignature,Z.thoughtSignature),X.push({type:"text_delta",contentIndex:D(),delta:Z.text,partial:Q})}if(Z.functionCall){if(Y){if(Y.type==="text")X.push({type:"text_end",contentIndex:D(),content:Y.text,partial:Q});else X.push({type:"thinking_end",contentIndex:D(),content:Y.thinking,partial:Q});Y=null}let S=Z.functionCall.id,j={type:"toolCall",id:!S||Q.content.some((O)=>O.type==="toolCall"&&O.id===S)?`${Z.functionCall.name}_${Date.now()}_${++s}`:S,name:Z.functionCall.name||"",arguments:Z.functionCall.args??{},...Z.thoughtSignature&&{thoughtSignature:Z.thoughtSignature}};Q.content.push(j),X.push({type:"toolcall_start",contentIndex:D(),partial:Q}),X.push({type:"toolcall_delta",contentIndex:D(),delta:JSON.stringify(j.arguments),partial:Q}),X.push({type:"toolcall_end",contentIndex:D(),toolCall:j,partial:Q})}}if(G?.finishReason){if(Q.stopReason=g(G.finishReason),Q.content.some((Z)=>Z.type==="toolCall"))Q.stopReason="toolUse"}if(W.usageMetadata)Q.usage={input:(W.usageMetadata.promptTokenCount||0)-(W.usageMetadata.cachedContentTokenCount||0),output:(W.usageMetadata.candidatesTokenCount||0)+(W.usageMetadata.thoughtsTokenCount||0),cacheRead:W.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:W.usageMetadata.thoughtsTokenCount||0,totalTokens:W.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},L(q,Q.usage)}if(Y)if(Y.type==="text")X.push({type:"text_end",contentIndex:D(),content:Y.text,partial:Q});else X.push({type:"thinking_end",contentIndex:D(),content:Y.thinking,partial:Q});if(J?.signal?.aborted)throw Error("Request was aborted");if(Q.stopReason==="aborted"||Q.stopReason==="error")throw Error("An unknown error occurred");X.push({type:"done",reason:Q.stopReason,message:Q}),X.end()}catch(z){for(let $ of Q.content)if("index"in $)delete $.index;Q.stopReason=J?.signal?.aborted?"aborted":"error",Q.errorMessage=y(K(z)),X.push({type:"error",reason:Q.stopReason,error:Q}),X.end()}})(),X},Gq=(q,w,J)=>{let X=I(q,w,J,void 0);if(!J?.reasoning)return V(q,w,{...X,thinking:{enabled:!1}});let Q=P(q,J.reasoning),z=Q==="off"?"high":Q,$=q;if(E($)||a($))return V(q,w,{...X,thinking:{enabled:!0,level:Qq(z,$)}});return V(q,w,{...X,thinking:{enabled:!0,budgetTokens:Xq($,z,J.thinkingBudgets)}})};function p(q,w,J,X,Q){let z=n(Q);return new H({vertexai:!0,project:w,location:J,apiVersion:k,...z?{googleAuthOptions:z}:{},httpOptions:m(q,X)})}function l(q,w,J){return new H({vertexai:!0,apiKey:w,apiVersion:k,httpOptions:m(q,J)})}function m(q,w){let J={},X=r(q.baseUrl);if(X){if(J.baseUrl=X,J.baseUrlResourceScope=v.COLLECTION,i(X))J.apiVersion=""}let Q=T({...q.headers,...w});if(Q)J.headers=Q;return Object.keys(J).length>0?J:void 0}function r(q){let w=q.trim();if(!w||w.includes("{location}"))return;return w}function i(q){try{return new URL(q).pathname.split("/").some((J)=>/^v\d+(?:beta\d*)?$/.test(J))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(q)}}function n(q){let w=F("GOOGLE_APPLICATION_CREDENTIALS",q);return w?{keyFilename:w}:void 0}function e(q){let w=q?.apiKey?.trim();if(!w||w===u||t(w))return;return w}function t(q){return/^<[^>]+>$/.test(q)}function o(q){let w=q?.project||F("GOOGLE_CLOUD_PROJECT",q?.env)||F("GCLOUD_PROJECT",q?.env);if(!w)throw Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");return w}function qq(q){let w=q?.location||F("GOOGLE_CLOUD_LOCATION",q?.env);if(!w)throw Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");return w}function wq(q,w,J={}){let X=b(q,w),Q={};if(J.temperature!==void 0)Q.temperature=J.temperature;if(J.maxTokens!==void 0)Q.maxOutputTokens=J.maxTokens;let z=w.tools?.length?f(w.tools,J.toolChoice,x(q.id)):void 0,$={...Object.keys(Q).length>0&&Q,...w.systemPrompt&&{systemInstruction:C(w.systemPrompt)},...w.tools&&w.tools.length>0&&{tools:h(w.tools)},...z!==void 0&&{toolConfig:{functionCallingConfig:{mode:z}}}};if(J.thinking?.enabled&&q.reasoning){let _={includeThoughts:!0};if(J.thinking.level!==void 0)_.thinkingLevel=c[J.thinking.level];else if(J.thinking.budgetTokens!==void 0)_.thinkingBudget=J.thinking.budgetTokens;$.thinkingConfig=_}else if(q.reasoning&&J.thinking&&!J.thinking.enabled)$.thinkingConfig=Jq(q);if(J.signal){if(J.signal.aborted)throw Error("Request aborted");$.abortSignal=J.signal}return{model:q.id,contents:X,config:$}}function E(q){return/gemini-3(?:\.\d+)?-pro/.test(q.id.toLowerCase())}function a(q){let w=q.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(w)||w==="gemini-flash-latest"||w==="gemini-flash-lite-latest"}function Jq(q){let w=q;if(E(w))return{thinkingLevel:N.LOW};if(a(w))return{thinkingLevel:N.MINIMAL};return{thinkingBudget:0}}function Qq(q,w){if(E(w))switch(q){case"minimal":case"low":return"LOW";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 Xq(q,w,J){if(J?.[w]!==void 0)return J[w];if(q.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[w];if(q.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[w];return-1}export{Gq as streamSimple,V as stream};
@@ -1,2 +1,2 @@
1
1
  async function q(j){if(typeof navigator<"u"&&navigator.clipboard&&typeof navigator.clipboard.writeText==="function")try{return await navigator.clipboard.writeText(j),!0}catch{}try{let h=document.createElement("textarea");h.value=j,h.style.position="fixed",h.style.top="0",h.style.left="0",h.style.width="2em",h.style.height="2em",h.style.padding="0",h.style.border="none",h.style.outline="none",h.style.boxShadow="none",h.style.background="transparent",h.style.opacity="0",document.body.appendChild(h),h.focus(),h.select();let p=document.execCommand("copy");return document.body.removeChild(h),p}catch(h){return console.error("Failed to copy text to clipboard:",h),!1}}
2
- export{q as X};
2
+ export{q as da};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  function N(k){if(!(k instanceof Error)||!("status"in k)||!("headers"in k))return!1;return(k.status===void 0||typeof k.status==="number")&&(k.headers===void 0||k.headers instanceof Headers)}function O(k){let w=k.headers?.get("x-should-retry");if(w==="true")return!0;if(w==="false")return!1;if(k.status===void 0)return!0;return k.status===408||k.status===409||k.status===429||typeof k.status==="number"&&k.status>=500}function J(k,w,C){let z=w??60000;if(z>0&&k>z)throw Error(`Server requested ${Math.ceil(k/1000)}s retry delay (max: ${Math.ceil(z/1000)}s). ${C}`);return k}function Q(k,w,C){let z=k.headers?.get("retry-after-ms");if(z){let F=Number.parseFloat(z);if(!Number.isNaN(F))return J(F,C,k.message)}let B=k.headers?.get("retry-after");if(B){let F=Number.parseFloat(B),K=Number.isNaN(F)?Date.parse(B)-Date.now():F*1000;return J(K,C,k.message)}return Math.min(0.5*2**w,8)*1000*(1-Math.random()*0.25)}function H(){let k=Error("Request aborted");return k.name="AbortError",k}function T(k,w){return new Promise((C,z)=>{if(w?.aborted){z(H());return}let B=()=>{clearTimeout(G),z(H())},G=setTimeout(()=>{w?.removeEventListener("abort",B),C()},Math.max(0,k));w?.addEventListener("abort",B,{once:!0})})}async function V(k,w={}){let C=w.maxRetries??0,z=C;for(;;)try{return await k()}catch(B){if(w.signal?.aborted)throw H();if(z<=0||!N(B)||!O(B))throw B;let G=C-z;z--,await T(Q(B,G,w.maxRetryDelayMs),w.signal)}}
3
- export{V as lm};
3
+ export{V as Fm};
@@ -0,0 +1,2 @@
1
+ import{da as Vq}from"./chunk-mgnxa0vy.js";import{Bh as o,Ch as r,Dh as m,Eh as e}from"./chunk-ts10cfmc.js";import{di as h,ei as C,fi as O}from"./chunk-2f35h4fn.js";import{gi as P,ii as k,ji as G,li as B,mi as Y}from"./chunk-4k2d8w9w.js";import{Ji as qq,Ki as Eq,Li as Jq,Mi as Kq,Ni as Nq,Oi as Qq,Pi as Wq,Qi as Xq,Ri as Yq,Ti as Zq,Ui as _q,Wi as $q,Yi as X}from"./chunk-s503pcvb.js";import{$i as Cq,Dj as z,Fl as s,aj as t,bj as E,bk as H,cj as K,lk as n,qm as W,tm as J,um as Hq}from"./chunk-w9p59ahz.js";import{rn as hq}from"./chunk-txkmks1h.js";var Z=hq(Cq(),1);function uq({open:fq,onOpenChange:Fq,title:zq,members:g,isOwner:_,onInvite:c,onUpdateRole:I,onRemoveMember:v,currentUserId:Pq,availableMembersToAdd:M,onAddMember:L,type:V="team"}){let[T,u]=Z.useState("editor"),[S,p]=Z.useState(null),[l,x]=Z.useState(!1),[D,U]=Z.useState(null),[f,A]=Z.useState(null),[j,i]=Z.useState({}),[$,F]=Z.useState(null),y=(q)=>{if(!q)return"";switch(q.toLowerCase()){case"owner":return J.owner();case"editor":return J.editor();case"reviewer":return J.reviewer();default:return q}},a=(q,N)=>{i((Q)=>({...Q,[q]:N}))},kq=async(q,N)=>{if(!I)return;U(q);try{await I(q,N),X.success(J.member_role_updated())}catch(Q){console.error(Q),X.error(J.failed_to_update_member_role())}finally{U(null)}},Gq=async()=>{if(!v||!f?.id)return;U(f.id);try{await v(f.id),X.success(J.member_removed()),A(null)}catch(q){console.error(q),X.error(J.failed_to_remove_member())}finally{U(null)}},Bq=async()=>{if(!c)return;x(!0);try{let q=await c(T),N=`${window.location.origin}/signup?inviteCode=${q}`;p(N)}catch(q){console.error(q),X.error(J.failed_to_generate_invite_link())}finally{x(!1)}},Lq=async()=>{if(S){if(await Vq(S))X.success(J.invite_link_copied())}},R=(q)=>{if(!q)return"??";return q.split(" ").map((N)=>N[0]).slice(0,2).join("").toUpperCase()},Sq=(q)=>{if(!q)p(null),u("editor"),i({}),F(null);Fq(q)},w=Array.isArray(g)?g:[],Uq=Array.isArray(M)?M:[],yq=V==="project"&&_?w.filter((q)=>q.role==="owner"||q.scope==="project"||q.hasCustomRole):w,d=V==="project"&&_?w.filter((q)=>q.scope==="team"&&q.role!=="owner"&&!q.hasCustomRole):[],b=V==="project"&&_?Uq.filter((q)=>q.scope==="project"):[];return E(Yq,{open:fq,onOpenChange:Sq,children:K(Zq,{className:"sm:max-w-xl",onOpenAutoFocus:(q)=>q.preventDefault(),children:[E(_q,{children:E($q,{children:zq})}),K("div",{className:"space-y-4",children:[E("div",{className:"max-h-[300px] overflow-y-auto space-y-2",children:yq.map((q)=>{let N=V==="team"&&q.scope==="project";return K("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50",children:[K("div",{className:"flex items-center gap-3",children:[K(h,{children:[q.image&&E(C,{src:q.image,alt:q.name,className:"object-cover"}),E(O,{children:R(q.name)})]}),K("div",{className:"flex flex-col",children:[E("span",{className:"text-sm font-medium",children:q.name}),K("div",{className:"flex items-center gap-2",children:[!N&&E("span",{className:"text-xs text-muted-foreground capitalize",children:y(q.role)}),q.scope&&K(t,{children:[!N&&E("span",{className:"text-[10px] text-muted-foreground/70",children:"•"}),E("span",{className:"text-xs text-muted-foreground capitalize",children:q.scope==="team"?J.team_member():J.project_member()})]})]})]})]}),_&&q.role!=="owner"&&q.id!==Pq&&K("div",{className:"flex items-center gap-2",children:[N?E(o,{children:K(r,{children:[E(m,{asChild:!0,children:E("span",{children:E(W,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26 justify-between",disabled:!0,children:E(H,{className:"ml-auto h-3 w-3 opacity-50"})})})}),E(e,{side:"top",children:E("p",{className:"text-xs",children:J.project_member_role_tooltip()})})]})}):K(P,{children:[E(k,{asChild:!0,children:K(W,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26",disabled:D===q.id,children:[y(q.role),E(H,{className:"ml-1 h-3 w-3 opacity-50"})]})}),E(G,{children:K(B,{value:q.role,onValueChange:(Q)=>kq(q.id,Q),children:[E(Y,{value:"editor",className:"text-xs",children:J.editor()}),E(Y,{value:"reviewer",className:"text-xs",children:J.reviewer()})]})})]}),E(W,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>A(q),disabled:D===q.id,children:D===q.id?E(z,{className:"h-3 w-3 animate-spin"}):E(s,{className:"h-3 w-3"})})]})]},q.id)})}),E(qq,{open:!!f,onOpenChange:(q)=>!q&&A(null),children:K(Eq,{children:[K(Jq,{children:[E(Nq,{children:J.remove_member()}),E(Qq,{children:J.remove_member_confirmation({name:f?.name||"",type:V==="project"?J.project():J.team()})})]}),K(Kq,{children:[E(Xq,{children:J.cancel()}),E(Wq,{onClick:Gq,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:J.remove()})]})]})})," ",_&&L&&d.length>0&&K("div",{className:"border-t pt-4",children:[E("h4",{className:"text-sm font-medium mb-1",children:J.add_team_member_to_project()}),E("p",{className:"text-xs text-muted-foreground mb-3 font-normal",children:J.add_team_member_to_project_hint()}),E("div",{className:"max-h-[200px] overflow-y-auto space-y-2 pr-1",children:d.map((q)=>{let N=j[q.id]||"editor";return K("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50",children:[K("div",{className:"flex items-center gap-3",children:[K(h,{children:[q.image&&E(C,{src:q.image,alt:q.name,className:"object-cover"}),E(O,{children:R(q.name)})]}),K("div",{className:"flex flex-col",children:[E("span",{className:"text-sm font-medium",children:q.name}),E("span",{className:"text-xs text-muted-foreground capitalize",children:q.scope==="team"?J.team_member():J.project_member()})]})]}),K("div",{className:"flex items-center gap-2",children:[K(P,{children:[E(k,{asChild:!0,children:K(W,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26",disabled:$===q.id,children:[y(N),E(H,{className:"ml-1 h-3 w-3 opacity-50"})]})}),E(G,{children:K(B,{value:N,onValueChange:(Q)=>a(q.id,Q),children:[E(Y,{value:"editor",className:"text-xs",children:J.editor()}),E(Y,{value:"reviewer",className:"text-xs",children:J.reviewer()})]})})]}),E(W,{onClick:async()=>{F(q.id);try{await L(q.id,N),X.success(J.added_member_successfully({name:q.name||""}))}catch(Q){console.error(Q),X.error(J.failed_to_add_member({name:q.name||""}))}finally{F(null)}},disabled:$!==null,size:"sm",className:"h-8 text-xs px-3",children:$===q.id?E(z,{className:"h-3 w-3 animate-spin"}):J.set_role()})]})]},q.id)})})]}),_&&L&&b.length>0&&K("div",{className:"border-t pt-4",children:[E("h4",{className:"text-sm font-medium mb-1",children:J.add_members_from_other_projects()}),E("p",{className:"text-xs text-muted-foreground mb-3 font-normal",children:J.add_members_from_other_projects_hint()}),E("div",{className:"max-h-[200px] overflow-y-auto space-y-2 pr-1",children:b.map((q)=>{let N=j[q.id]||"editor";return K("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50",children:[K("div",{className:"flex items-center gap-3",children:[K(h,{children:[q.image&&E(C,{src:q.image,alt:q.name,className:"object-cover"}),E(O,{children:R(q.name)})]}),K("div",{className:"flex flex-col",children:[E("span",{className:"text-sm font-medium",children:q.name}),E("span",{className:"text-xs text-muted-foreground capitalize",children:q.scope==="team"?J.team_member():J.project_member()})]})]}),K("div",{className:"flex items-center gap-2",children:[K(P,{children:[E(k,{asChild:!0,children:K(W,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26",disabled:$===q.id,children:[y(N),E(H,{className:"ml-1 h-3 w-3 opacity-50"})]})}),E(G,{children:K(B,{value:N,onValueChange:(Q)=>a(q.id,Q),children:[E(Y,{value:"editor",className:"text-xs",children:J.editor()}),E(Y,{value:"reviewer",className:"text-xs",children:J.reviewer()})]})})]}),E(W,{onClick:async()=>{F(q.id);try{await L(q.id,N),X.success(J.added_member_successfully({name:q.name||""}))}catch(Q){console.error(Q),X.error(J.failed_to_add_member({name:q.name||""}))}finally{F(null)}},disabled:$!==null,size:"sm",className:"h-8 text-xs px-3",children:$===q.id?E(z,{className:"h-3 w-3 animate-spin"}):J.add_to_project()})]})]},q.id)})})]}),_&&c&&K("div",{className:"border-t pt-4",children:[E("h4",{className:"text-sm font-medium mb-3",children:J.invite_new_member()}),K("div",{className:"space-y-3",children:[K("div",{className:"flex gap-2",children:[K(P,{children:[E(k,{asChild:!0,children:K(W,{variant:"outline",className:"w-[120px] justify-between",children:[T==="editor"?J.editor():J.reviewer(),E(H,{className:"h-4 w-4 opacity-50"})]})}),E(G,{children:K(B,{value:T,onValueChange:(q)=>u(q),children:[E(Y,{value:"editor",children:J.editor()}),E(Y,{value:"reviewer",children:J.reviewer()})]})})]}),K(W,{onClick:Bq,disabled:l,className:"flex-1",children:[l&&E(z,{className:"mr-2 h-4 w-4 animate-spin"}),J.generate_link()]})]}),S&&K("div",{className:"flex gap-2",children:[E(Hq,{value:S,readOnly:!0}),E(W,{variant:"outline",size:"icon",onClick:Lq,children:E(n,{className:"h-4 w-4"})})]})]})]})]})]})})}
2
+ export{uq as ca};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Oa as e,Pa as p,Qa as t}from"./chunk-gfdfkqrc.js";import"./chunk-wfee9d83.js";import"./chunk-n8gsjwht.js";import"./chunk-hx2mvd20.js";import"./chunk-8rcfhfq5.js";import"./chunk-za7ga4bf.js";import"./chunk-txkmks1h.js";export{t as kyselyAdapter,e as getKyselyDatabaseType,p as createKyselyAdapter};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Ob as c,Pb as V,Qb as _k,Rb as ek,Sb as kW,Ub as GW,Wb as _,Xb as kk,Yb as h,Zb as dk,_b as j,ac as J,ec as I,fc as zk,gc as x,hc as hk,ic as Kk,jc as pW,kc as y,lc as dW,mc as v,nc as fk,oc as Xk,pc as w,qc as sW,rc as TW,sc as Mk,uc as YW,vc as Ch}from"./chunk-xext4yvc.js";function z(k){return kk(k)&&_(k.toOperationNode)}var Q=h({is(k){return k.kind==="ValueNode"},create(k){return h({kind:"ValueNode",value:k})},createImmediate(k){return h({kind:"ValueNode",value:k,immediate:!0})}});var S=h({is(k){return k.kind==="ColumnNode"},create(k){return h({kind:"ColumnNode",column:J.create(k)})}});var pk=h({is(k){return k.kind==="SelectAllNode"},create(){return h({kind:"SelectAllNode"})}});var Ak=h({is(k){return k.kind==="ReferenceNode"},create(k,W){return h({kind:"ReferenceNode",table:W,column:k})},createSelectAll(k){return h({kind:"ReferenceNode",table:k,column:pk.create()})}});function ok(k){return kk(k)&&"expressionType"in k&&z(k)}function iW(k){return kk(k)&&"expression"in k&&V(k.alias)&&z(k)}var a=h({is(k){return k.kind==="SelectModifierNode"},create(k,W){return h({kind:"SelectModifierNode",modifier:k,of:W})},createWithExpression(k){return h({kind:"SelectModifierNode",rawModifier:k})}});var Yk=h({is(k){return k.kind==="BinaryOperationNode"},create(k,W,$){return h({kind:"BinaryOperationNode",leftOperand:k,operator:W,rightOperand:$})}});var sk=h({is(k){return k.kind==="PrimitiveValueListNode"},create(k){return h({kind:"PrimitiveValueListNode",values:h([...k])})}});var rk=h({is(k){return k.kind==="ValueListNode"},create(k){return h({kind:"ValueListNode",values:h(k)})}});function lW(k){if(j(k))return ih(k);return X(k)}function X(k){if(Wk(k))return p(k);return Q.create(k)}function WW(k){return _k(k)||ek(k)||kW(k)}function Bk(k){if(!WW(k))throw Error(`unsafe immediate value ${JSON.stringify(k)}`);return Q.createImmediate(k)}function ih(k){if(k.some(Wk))return rk.create(k.map((W)=>X(W)));return sk.create(k)}function L(k){if(k.length===3)return hW(k[0],k[1],k[2]);else if(k.length===1)return X(k[0]);throw Error(`invalid arguments: ${JSON.stringify(k)}`)}function hW(k,W,$){if(lh(W)&&oW($))return Yk.create(f(k),PW(W),Q.createImmediate($));return Yk.create(f(k),PW(W),lW($))}function m(k,W,$){return Yk.create(f(k),PW(W),f($))}function UW(k,W){return mk(Object.entries(k).filter(([,$])=>!c($)).map(([$,M])=>hW($,oW(M)?"is":"=",M)),W)}function mk(k,W,$=!0){let M=W==="and"?x.create:hk.create;if(k.length===0)return Yk.create(Q.createImmediate(1),y.create("="),Q.createImmediate(W==="and"?1:0));let G=aW(k[0]);for(let q=1;q<k.length;++q)G=M(G,aW(k[q]));if(k.length>1&&$)return Xk.create(G);return G}function lh(k){return k==="is"||k==="is not"}function oW(k){return kW(k)||ek(k)}function PW(k){if(V(k)&&pW.includes(k))return y.create(k);if(z(k))return k.toOperationNode();throw Error(`invalid operator ${JSON.stringify(k)}`)}function aW(k){return z(k)?k.toOperationNode():k}var $k=h({is(k){return k.kind==="OrderByNode"},create(k){return h({kind:"OrderByNode",items:h([...k])})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var VW=h({is(k){return k.kind==="PartitionByNode"},create(k){return h({kind:"PartitionByNode",items:h(k)})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var xk=h({is(k){return k.kind==="OverNode"},create(){return h({kind:"OverNode"})},cloneWithOrderByItems(k,W){return h({...k,orderBy:k.orderBy?$k.cloneWithItems(k.orderBy,W):$k.create(W)})},cloneWithPartitionByItems(k,W){return h({...k,partitionBy:k.partitionBy?VW.cloneWithItems(k.partitionBy,W):VW.create(W)})}});var Vk=h({is(k){return k.kind==="FromNode"},create(k){return h({kind:"FromNode",froms:h(k)})},cloneWithFroms(k,W){return h({...k,froms:h([...k.froms,...W])})}});var wW=h({is(k){return k.kind==="GroupByNode"},create(k){return h({kind:"GroupByNode",items:h(k)})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var FW=h({is(k){return k.kind==="HavingNode"},create(k){return h({kind:"HavingNode",having:k})},cloneWithOperation(k,W,$){return h({...k,having:W==="And"?x.create(k.having,$):hk.create(k.having,$)})}});var o=h({is(k){return k.kind==="UpdateQueryNode"},create(k,W){return h({kind:"UpdateQueryNode",table:k.length===1?k[0]:sW.create(k),...W&&{with:W}})},createWithoutTable(){return h({kind:"UpdateQueryNode"})},cloneWithFromItems(k,W){return h({...k,from:k.from?Vk.cloneWithFroms(k.from,W):Vk.create(W)})},cloneWithUpdates(k,W){return h({...k,updates:k.updates?h([...k.updates,...W]):W})},cloneWithLimit(k,W){return h({...k,limit:W})}});var Dk=h({is(k){return k.kind==="DeleteQueryNode"},create(k,W){return h({kind:"DeleteQueryNode",from:Vk.create(k),...W&&{with:W}})},cloneWithOrderByItems:(k,W)=>K.cloneWithOrderByItems(k,W),cloneWithoutOrderBy:(k)=>K.cloneWithoutOrderBy(k),cloneWithLimit(k,W){return h({...k,limit:W})},cloneWithoutLimit(k){return h({...k,limit:void 0})},cloneWithUsing(k,W){return h({...k,using:k.using!==void 0?TW.cloneWithTables(k.using,W):TW.create(W)})}});var C=h({is(k){return k.kind==="WhereNode"},create(k){return h({kind:"WhereNode",where:k})},cloneWithOperation(k,W,$){return h({...k,where:W==="And"?x.create(k.where,$):hk.create(k.where,$)})}});var vW=h({is(k){return k.kind==="ReturningNode"},create(k){return h({kind:"ReturningNode",selections:h(k)})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})}});var rW=h({is(k){return k.kind==="ExplainNode"},create(k,W){return h({kind:"ExplainNode",format:k,options:W})}});var N=h({is(k){return k.kind==="MergeQueryNode"},create(k,W){return h({kind:"MergeQueryNode",into:k,...W&&{with:W}})},cloneWithUsing(k,W){return h({...k,using:W})},cloneWithWhen(k,W){return h({...k,whens:k.whens?h([...k.whens,W]):h([W])})},cloneWithThen(k,W){return h({...k,whens:k.whens?h([...k.whens.slice(0,-1),Mk.cloneWithResult(k.whens[k.whens.length-1],W)]):void 0})}});var AW=h({is(k){return k.kind==="OutputNode"},create(k){return h({kind:"OutputNode",selections:h(k)})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})}});var K=h({is(k){return Y.is(k)||w.is(k)||o.is(k)||Dk.is(k)||N.is(k)},cloneWithEndModifier(k,W){return h({...k,endModifiers:k.endModifiers?h([...k.endModifiers,W]):h([W])})},cloneWithWhere(k,W){return h({...k,where:k.where?C.cloneWithOperation(k.where,"And",W):C.create(W)})},cloneWithJoin(k,W){return h({...k,joins:k.joins?h([...k.joins,W]):h([W])})},cloneWithReturning(k,W){return h({...k,returning:k.returning?vW.cloneWithSelections(k.returning,W):vW.create(W)})},cloneWithoutReturning(k){return h({...k,returning:void 0})},cloneWithoutWhere(k){return h({...k,where:void 0})},cloneWithExplain(k,W,$){return h({...k,explain:rW.create(W,$?.toOperationNode())})},cloneWithTop(k,W){return h({...k,top:W})},cloneWithOutput(k,W){return h({...k,output:k.output?AW.cloneWithSelections(k.output,W):AW.create(W)})},cloneWithOrderByItems(k,W){return h({...k,orderBy:k.orderBy?$k.cloneWithItems(k.orderBy,W):$k.create(W)})},cloneWithoutOrderBy(k){return h({...k,orderBy:void 0})}});var Y=h({is(k){return k.kind==="SelectQueryNode"},create(k){return h({kind:"SelectQueryNode",...k&&{with:k}})},createFrom(k,W){return h({kind:"SelectQueryNode",from:Vk.create(k),...W&&{with:W}})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})},cloneWithDistinctOn(k,W){return h({...k,distinctOn:k.distinctOn?h([...k.distinctOn,...W]):h(W)})},cloneWithFrontModifier(k,W){return h({...k,frontModifiers:k.frontModifiers?h([...k.frontModifiers,W]):h([W])})},cloneWithOrderByItems:(k,W)=>K.cloneWithOrderByItems(k,W),cloneWithGroupByItems(k,W){return h({...k,groupBy:k.groupBy?wW.cloneWithItems(k.groupBy,W):wW.create(W)})},cloneWithLimit(k,W){return h({...k,limit:W})},cloneWithOffset(k,W){return h({...k,offset:W})},cloneWithFetch(k,W){return h({...k,fetch:W})},cloneWithHaving(k,W){return h({...k,having:k.having?FW.cloneWithOperation(k.having,"And",W):FW.create(W)})},cloneWithSetOperations(k,W){return h({...k,setOperations:k.setOperations?h([...k.setOperations,...W]):h([...W])})},cloneWithoutSelections(k){return h({...k,selections:[]})},cloneWithoutLimit(k){return h({...k,limit:void 0})},cloneWithoutOffset(k){return h({...k,offset:void 0})},cloneWithoutOrderBy:(k)=>K.cloneWithoutOrderBy(k),cloneWithoutGroupBy(k){return h({...k,groupBy:void 0})}});class Rk{#k;constructor(k){this.#k=h(k)}on(...k){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,L(k))})}onRef(k,W,$){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,m(k,W,$))})}onTrue(){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,v.createWithSql("true"))})}$call(k){return k(this)}toOperationNode(){return this.#k.joinNode}}class ah{#k;get dynamicReference(){return this.#k}get refType(){return}constructor(k){this.#k=k}toOperationNode(){return _W(this.#k)}}function $W(k){return kk(k)&&z(k)&&V(k.dynamicReference)}var g=h({is(k){return k.kind==="OrderByItemNode"},create(k,W){return h({kind:"OrderByItemNode",orderBy:k,direction:W})},cloneWith(k,W){return h({...k,...W})}});var eW=h({is(k){return k.kind==="CollateNode"},create(k){return h({kind:"CollateNode",collation:J.create(k)})}});class Lk{#k;constructor(k){this.#k=h(k)}desc(){return new Lk({node:g.cloneWith(this.#k.node,{direction:v.createWithSql("desc")})})}asc(){return new Lk({node:g.cloneWith(this.#k.node,{direction:v.createWithSql("asc")})})}nullsLast(){return new Lk({node:g.cloneWith(this.#k.node,{nulls:"last"})})}nullsFirst(){return new Lk({node:g.cloneWith(this.#k.node,{nulls:"first"})})}collate(k){return new Lk({node:g.cloneWith(this.#k.node,{collation:eW.create(k)})})}toOperationNode(){return this.#k.node}}function RW(k){return k==="asc"||k==="desc"}function B(k){if(k.length===2)return[mW(k[0],k[1])];if(k.length===1){let[W]=k;if(Array.isArray(W))return fk("orderBy(array) is deprecated, use multiple orderBy calls instead."),W.map(($)=>mW($));return[mW(W)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${k.length}`)}function mW(k,W){let $=ph(k);if(g.is($)){if(W)throw Error("Cannot specify direction twice!");return $}return kh($,W)}function ph(k){if(Wk(k))return p(k);if($W(k))return k.toOperationNode();let[W,$]=k.split(" ");if($)return fk("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),kh(t(W),$);return t(k)}function kh(k,W){if(typeof W==="string"){if(!RW(W))throw Error(`Invalid order by direction: ${W}`);return g.create(k,v.createWithSql(W))}if(ok(W))return fk("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),g.create(k,W.toOperationNode());let $=g.create(k);if(!W)return $;return W(new Lk({node:$})).toOperationNode()}var Wh=h({is(k){return k.kind==="PartitionByItemNode"},create(k){return h({kind:"PartitionByItemNode",partitionBy:k})}});function hh(k){return Gk(k).map(Wh.create)}class Ck{#k;constructor(k){this.#k=h(k)}orderBy(...k){return new Ck({overNode:xk.cloneWithOrderByItems(this.#k.overNode,B(k))})}clearOrderBy(){return new Ck({overNode:K.cloneWithoutOrderBy(this.#k.overNode)})}partitionBy(k){return new Ck({overNode:xk.cloneWithPartitionByItems(this.#k.overNode,hh(k))})}$call(k){return k(this)}toOperationNode(){return this.#k.overNode}}var Sk=h({is(k){return k.kind==="SelectionNode"},create(k){return h({kind:"SelectionNode",selection:k})},createSelectAll(){return h({kind:"SelectionNode",selection:pk.create()})},createSelectAllFromTable(k){return h({kind:"SelectionNode",selection:Ak.createSelectAll(k)})}});class oh{#k;get table(){return this.#k}constructor(k){this.#k=k}as(k){return new $h(this.#k,k)}}class $h{#k;#W;get table(){return this.#k}get alias(){return this.#W}constructor(k,W){this.#k=k,this.#W=W}toOperationNode(){return I.create(F(this.#k),J.create(this.#W))}}function Mh(k){return kk(k)&&z(k)&&V(k.table)&&V(k.alias)}function n(k){if(j(k))return k.map((W)=>wk(W));else return[wk(k)]}function wk(k){if(V(k))return fW(k);else if(Mh(k))return k.toOperationNode();else return MW(k)}function fW(k){if(k.includes(" as ")){let[$,M]=k.split(" as ").map(Kh);return I.create(F($),J.create(M))}else return F(k)}function F(k){if(k.includes(".")){let[$,M]=k.split(".").map(Kh);return zk.createWithSchema($,M)}else return zk.create(k)}function Kh(k){return k.trim()}function A(k){if(_(k))return A(k(d()));else if(j(k))return k.map((W)=>Gh(W));else return[Gh(k)]}function Gh(k){if(V(k))return Sk.create(Zh(k));else if($W(k))return Sk.create(k.toOperationNode());else return Sk.create(MW(k))}function R(k){if(!k)return[Sk.createSelectAll()];else if(Array.isArray(k))return k.map(Hh);else return[Hh(k)]}function Hh(k){if(V(k))return Sk.createSelectAllFromTable(F(k));throw Error(`invalid value selectAll expression: ${JSON.stringify(k)}`)}var Yh=h({is(k){return k.kind==="ValuesNode"},create(k){return h({kind:"ValuesNode",values:h(k)})}});var Xh=h({is(k){return k.kind==="DefaultInsertValueNode"},create(){return h({kind:"DefaultInsertValueNode"})}});function KW(k){let W=_(k)?k(d()):k,$=j(W)?W:h([W]);return sh($)}function sh(k){let W=rh(k);return[h([...W.keys()].map(S.create)),Yh.create(k.map(($)=>eh($,W)))]}function rh(k){let W=new Map;for(let $ of k){let M=Object.keys($);for(let G of M)if(!W.has(G)&&$[G]!==void 0)W.set(G,W.size)}return W}function eh(k,W){let $=Object.keys(k),M=Array.from({length:W.size}),G=!1,q=$.length;for(let ak of $){let Nk=W.get(ak);if(c(Nk)){q--;continue}let qW=k[ak];if(c(qW)||Wk(qW))G=!0;M[Nk]=qW}if(q<W.size||G){let ak=Xh.create();return rk.create(M.map((Nk)=>c(Nk)?ak:X(Nk)))}return sk.create(M)}var CW=h({is(k){return k.kind==="ColumnUpdateNode"},create(k,W){return h({kind:"ColumnUpdateNode",column:k,value:W})}});function Dh(...k){if(k.length===2)return[CW.create(f(k[0]),X(k[1]))];return ck(k[0])}function ck(k){let W=_(k)?k(d()):k;return Object.entries(W).filter(([$,M])=>M!==void 0).map(([$,M])=>{return CW.create(S.create($),X(M))})}var Lh=h({is(k){return k.kind==="OnDuplicateKeyNode"},create(k){return h({kind:"OnDuplicateKeyNode",updates:k})}});class SW{insertId;numInsertedOrUpdatedRows;constructor(k,W){this.insertId=k,this.numInsertedOrUpdatedRows=W}}class u extends Error{node;constructor(k){super("no result");this.node=k}}function s(k){return Object.prototype.hasOwnProperty.call(k,"prototype")}var E=h({is(k){return k.kind==="OnConflictNode"},create(){return h({kind:"OnConflictNode"})},cloneWith(k,W){return h({...k,...W})},cloneWithIndexWhere(k,W){return h({...k,indexWhere:k.indexWhere?C.cloneWithOperation(k.indexWhere,"And",W):C.create(W)})},cloneWithIndexOrWhere(k,W){return h({...k,indexWhere:k.indexWhere?C.cloneWithOperation(k.indexWhere,"Or",W):C.create(W)})},cloneWithUpdateWhere(k,W){return h({...k,updateWhere:k.updateWhere?C.cloneWithOperation(k.updateWhere,"And",W):C.create(W)})},cloneWithUpdateOrWhere(k,W){return h({...k,updateWhere:k.updateWhere?C.cloneWithOperation(k.updateWhere,"Or",W):C.create(W)})},cloneWithoutIndexWhere(k){return h({...k,indexWhere:void 0})},cloneWithoutUpdateWhere(k){return h({...k,updateWhere:void 0})}});class r{#k;constructor(k){this.#k=h(k)}column(k){let W=S.create(k);return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{columns:this.#k.onConflictNode.columns?h([...this.#k.onConflictNode.columns,W]):h([W])})})}columns(k){let W=k.map(S.create);return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{columns:this.#k.onConflictNode.columns?h([...this.#k.onConflictNode.columns,...W]):h(W)})})}constraint(k){return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{constraint:J.create(k)})})}expression(k){return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{indexExpression:k.toOperationNode()})})}where(...k){return new r({...this.#k,onConflictNode:E.cloneWithIndexWhere(this.#k.onConflictNode,L(k))})}whereRef(k,W,$){return new r({...this.#k,onConflictNode:E.cloneWithIndexWhere(this.#k.onConflictNode,m(k,W,$))})}clearWhere(){return new r({...this.#k,onConflictNode:E.cloneWithoutIndexWhere(this.#k.onConflictNode)})}doNothing(){return new zh({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{doNothing:!0})})}doUpdateSet(k){return new yk({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{updates:ck(k)})})}$call(k){return k(this)}}class zh{#k;constructor(k){this.#k=h(k)}toOperationNode(){return this.#k.onConflictNode}}class yk{#k;constructor(k){this.#k=h(k)}where(...k){return new yk({...this.#k,onConflictNode:E.cloneWithUpdateWhere(this.#k.onConflictNode,L(k))})}whereRef(k,W,$){return new yk({...this.#k,onConflictNode:E.cloneWithUpdateWhere(this.#k.onConflictNode,m(k,W,$))})}clearWhere(){return new yk({...this.#k,onConflictNode:E.cloneWithoutUpdateWhere(this.#k.onConflictNode)})}$call(k){return k(this)}toOperationNode(){return this.#k.onConflictNode}}var Jh=h({is(k){return k.kind==="TopNode"},create(k,W){return h({kind:"TopNode",expression:k,modifiers:W})}});function i(k,W){if(!_k(k)&&!GW(k))throw Error(`Invalid top expression: ${k}`);if(!c(W)&&!k$(W))throw Error(`Invalid top modifiers: ${W}`);return Jh.create(k,W)}function k$(k){return k==="percent"||k==="with ties"||k==="percent with ties"}var Fk=h({is(k){return k.kind==="OrActionNode"},create(k){return h({kind:"OrActionNode",action:k})}});class D{#k;constructor(k){this.#k=h(k)}values(k){let[W,$]=KW(k);return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{columns:W,values:$})})}columns(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{columns:h(k.map(S.create))})})}expression(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{values:p(k)})})}defaultValues(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{defaultValues:!0})})}modifyEnd(k){return new D({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}ignore(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("ignore")})})}orIgnore(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("ignore")})})}orAbort(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("abort")})})}orFail(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("fail")})})}orReplace(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("replace")})})}orRollback(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("rollback")})})}top(k,W){return new D({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}onConflict(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{onConflict:k(new r({onConflictNode:E.create()})).toOperationNode()})})}onDuplicateKeyUpdate(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{onDuplicateKey:Lh.create(ck(k))})})}returning(k){return new D({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(){return new D({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R())})}output(k){return new D({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new D({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}clearReturning(){return new D({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new D({...this.#k})}$castTo(){return new D(this.#k)}$narrowType(){return new D(this.#k)}$assertType(){return new D(this.#k)}withPlugin(k){return new D({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new SW(W.insertId,W.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new D({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}class IW{numDeletedRows;constructor(k){this.numDeletedRows=k}}var Ik=h({is(k){return k.kind==="LimitNode"},create(k){return h({kind:"LimitNode",limit:k})}});var P;class HW{#k;constructor(k){this.#k=h(k)}where(...k){return new P({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new P({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}clearWhere(){return new P({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}top(k,W){return new P({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}using(k){return new P({...this.#k,queryNode:Dk.cloneWithUsing(this.#k.queryNode,n(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}#W(k,W){return new P({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}returning(k){return new P({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new P({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new P({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new P({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}clearReturning(){return new P({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}clearLimit(){return new P({...this.#k,queryNode:Dk.cloneWithoutLimit(this.#k.queryNode)})}orderBy(...k){return new P({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}clearOrderBy(){return new P({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}limit(k){return new P({...this.#k,queryNode:Dk.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}modifyEnd(k){return new P({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new P({...this.#k})}$castTo(){return new P(this.#k)}$narrowType(){return new P(this.#k)}$assertType(){return new P(this.#k)}withPlugin(k){return new P({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new IW(W.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new P({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}P=HW;class jW{numUpdatedRows;numChangedRows;constructor(k,W){this.numUpdatedRows=k,this.numChangedRows=W}}var U;class jk{#k;constructor(k){this.#k=h(k)}where(...k){return new U({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new U({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}clearWhere(){return new U({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}top(k,W){return new U({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}from(k){return new U({...this.#k,queryNode:o.cloneWithFromItems(this.#k.queryNode,n(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}#W(k,W){return new U({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}orderBy(...k){return new U({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}clearOrderBy(){return new U({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}limit(k){return new U({...this.#k,queryNode:o.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}set(...k){return new U({...this.#k,queryNode:o.cloneWithUpdates(this.#k.queryNode,Dh(...k))})}returning(k){return new U({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new U({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new U({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new U({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}modifyEnd(k){return new U({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}clearReturning(){return new U({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new U({...this.#k})}$castTo(){return new U(this.#k)}$narrowType(){return new U(this.#k)}$assertType(){return new U(this.#k)}withPlugin(k){return new U({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new jW(W.numAffectedRows??BigInt(0),W.numChangedRows)]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new U({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}U=jk;var EW=h({is(k){return k.kind==="CommonTableExpressionNameNode"},create(k,W){return h({kind:"CommonTableExpressionNameNode",table:zk.create(k),columns:W?h(W.map(S.create)):void 0})}});var Ek=h({is(k){return k.kind==="CommonTableExpressionNode"},create(k,W){return h({kind:"CommonTableExpressionNode",name:k,expression:W})},cloneWith(k,W){return h({...k,...W})}});class gk{#k;constructor(k){this.#k=h(k)}materialized(){return new gk({...this.#k,node:Ek.cloneWith(this.#k.node,{materialized:!0})})}notMaterialized(){return new gk({...this.#k,node:Ek.cloneWith(this.#k.node,{materialized:!1})})}toOperationNode(){return this.#k.node}}function OW(k,W){let $=W(Ph()).toOperationNode();if(_(k))return k(W$($)).toOperationNode();return Ek.create(qh(k),$)}function W$(k){return(W)=>{return new gk({node:Ek.create(qh(W),k)})}}function qh(k){if(k.includes("(")){let W=k.split(/[\(\)]/),$=W[0],M=W[1].split(",").map((G)=>G.trim());return EW.create($,M)}else return EW.create(k)}var tk=h({is(k){return k.kind==="WithNode"},create(k,W){return h({kind:"WithNode",expressions:h([k]),...W})},cloneWithExpression(k,W){return h({...k,expressions:h([...k.expressions,W])})}});var Uh=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function Vh(k){let W="";for(let $=0;$<k;++$)W+=h$();return W}function h$(){return Uh[~~(Math.random()*Uh.length)]}function T(){return new wh}class wh{#k;get queryId(){if(this.#k===void 0)this.#k=Vh(8);return this.#k}}var Fh=h({is(k){return k.kind==="MatchedNode"},create(k,W=!1){return h({kind:"MatchedNode",not:k,bySource:W})}});function bW(k,W,$){return Mk.create(mk([Fh.create(!k.isMatched,k.bySource),...W&&W.length>0?[W.length===3&&$?m(W[0],W[1],W[2]):L(W)]:[]],"and",!1))}function Ok(k){if(V(k))return v.create([k],[]);if(z(k))return k.toOperationNode();return k}class ZW{#k;#W;#h;constructor(){this.#k=new Promise((k,W)=>{this.#h=W,this.#W=k})}get promise(){return this.#k}resolve=(k)=>{if(this.#W)this.#W(k)};reject=(k)=>{if(this.#h)this.#h(k)}}async function Th(k){let W=new ZW,$=new ZW;return k.provideConnection(async(M)=>{return W.resolve(M),await $.promise}).catch((M)=>W.reject(M)),h({connection:await W.promise,release:$.resolve})}var $$=h([]);class QW{#k;constructor(k=$$){this.#k=k}get plugins(){return this.#k}transformQuery(k,W){for(let $ of this.#k){let M=$.transformQuery({node:k,queryId:W});if(M.kind===k.kind)k=M;else throw Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${k.kind}`,`but it returned a ${M.kind}`].join(" "))}return k}async executeQuery(k){return await this.provideConnection(async(W)=>{let $=await W.executeQuery(k);if("numUpdatedOrDeletedRows"in $)fk("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`.");return await this.#W($,k.queryId)})}async*stream(k,W){let{connection:$,release:M}=await Th(this);try{for await(let G of $.streamQuery(k,W))yield await this.#W(G,k.queryId)}finally{M()}}async#W(k,W){for(let $ of this.#k)k=await $.transformResult({result:k,queryId:W});return k}}class bk extends QW{get adapter(){throw Error("this query cannot be compiled to SQL")}compileQuery(){throw Error("this query cannot be compiled to SQL")}provideConnection(){throw Error("this query cannot be executed")}withConnectionProvider(){throw Error("this query cannot have a connection provider")}withPlugin(k){return new bk([...this.plugins,k])}withPlugins(k){return new bk([...this.plugins,...k])}withPluginAtFront(k){return new bk([k,...this.plugins])}withoutPlugins(){return new bk([])}}var qk=new bk;class NW{numChangedRows;constructor(k){this.numChangedRows=k}}class Hk{#k;constructor(k){this.#k=h(k)}modifyEnd(k){return new Hk({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}top(k,W){return new Hk({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}using(...k){return new O({...this.#k,queryNode:N.cloneWithUsing(this.#k.queryNode,Jk("Using",k))})}returning(k){return new Hk({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new Hk({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new Hk({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new Hk({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}}class O{#k;constructor(k){this.#k=h(k)}modifyEnd(k){return new O({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}top(k,W){return new O({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}whenMatched(){return this.#W([])}whenMatchedAnd(...k){return this.#W(k)}whenMatchedAndRef(k,W,$){return this.#W([k,W,$],!0)}#W(k,W){return new BW({...this.#k,queryNode:N.cloneWithWhen(this.#k.queryNode,bW({isMatched:!0},k,W))})}whenNotMatched(){return this.#h([])}whenNotMatchedAnd(...k){return this.#h(k)}whenNotMatchedAndRef(k,W,$){return this.#h([k,W,$],!0)}whenNotMatchedBySource(){return this.#h([],!1,!0)}whenNotMatchedBySourceAnd(...k){return this.#h(k,!1,!0)}whenNotMatchedBySourceAndRef(k,W,$){return this.#h([k,W,$],!0,!0)}returning(k){return new O({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new O({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new O({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new O({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}#h(k,W=!1,$=!1){let M={...this.#k,queryNode:N.cloneWithWhen(this.#k.queryNode,bW({isMatched:!1,bySource:$},k,W))};return new($?BW:vh)(M)}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new O({...this.#k})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new NW(W.numAffectedRows)]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}}class BW{#k;constructor(k){this.#k=h(k)}thenDelete(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("delete"))})}thenDoNothing(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("do nothing"))})}thenUpdate(k){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok(k(new jk({queryId:this.#k.queryId,executor:qk,queryNode:o.createWithoutTable()}))))})}thenUpdateSet(...k){return this.thenUpdate((W)=>W.set(...k))}}class vh{#k;constructor(k){this.#k=h(k)}thenDoNothing(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("do nothing"))})}thenInsertValues(k){let[W,$]=KW(k);return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok(w.cloneWith(w.createWithoutInto(),{columns:W,values:$})))})}}class Pk{#k;constructor(k){this.#k=h(k)}selectFrom(k){return nk({queryId:T(),executor:this.#k.executor,queryNode:Y.createFrom(n(k),this.#k.withNode)})}selectNoFrom(k){return nk({queryId:T(),executor:this.#k.executor,queryNode:Y.cloneWithSelections(Y.create(this.#k.withNode),A(k))})}insertInto(k){return new D({queryId:T(),executor:this.#k.executor,queryNode:w.create(F(k),this.#k.withNode)})}replaceInto(k){return new D({queryId:T(),executor:this.#k.executor,queryNode:w.create(F(k),this.#k.withNode,!0)})}deleteFrom(k){return new HW({queryId:T(),executor:this.#k.executor,queryNode:Dk.create(n(k),this.#k.withNode)})}updateTable(k){return new jk({queryId:T(),executor:this.#k.executor,queryNode:o.create(n(k),this.#k.withNode)})}mergeInto(k){return new Hk({queryId:T(),executor:this.#k.executor,queryNode:N.create(fW(k),this.#k.withNode)})}with(k,W){let $=OW(k,W);return new Pk({...this.#k,withNode:this.#k.withNode?tk.cloneWithExpression(this.#k.withNode,$):tk.create($)})}withRecursive(k,W){let $=OW(k,W);return new Pk({...this.#k,withNode:this.#k.withNode?tk.cloneWithExpression(this.#k.withNode,$):tk.create($,{recursive:!0})})}withPlugin(k){return new Pk({...this.#k,executor:this.#k.executor.withPlugin(k)})}withoutPlugins(){return new Pk({...this.#k,executor:this.#k.executor.withoutPlugins()})}withSchema(k){return new Pk({...this.#k,executor:this.#k.executor.withPluginAtFront(new YW(k))})}}function Ph(){return new Pk({executor:qk})}function Ah(k,W){return new Rk({joinNode:Kk.create(k,wk(W))})}function _h(){return new Ck({overNode:xk.create()})}function Jk(k,W){if(W.length===3)return K$(k,W[0],W[1],W[2]);else if(W.length===2)return M$(k,W[0],W[1]);else if(W.length===1)return G$(k,W[0]);else throw Error("not implemented")}function M$(k,W,$){return $(Ah(k,W)).toOperationNode()}function K$(k,W,$,M){return Kk.createWithOn(k,wk(W),m($,"=",M))}function G$(k,W){return Kk.create(k,wk(W))}var mh=h({is(k){return k.kind==="OffsetNode"},create(k){return h({kind:"OffsetNode",offset:k})}});var Rh=h({is(k){return k.kind==="GroupByItemNode"},create(k){return h({kind:"GroupByItemNode",groupBy:k})}});function fh(k){return k=_(k)?k(d()):k,Gk(k).map(Rh.create)}function Tk(k,W,$){if(_(W))W=W(XW());if(!j(W))W=[W];return W.map((M)=>Ch.create(k,p(M),$))}class Z{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}or(...k){return new DW(hk.create(this.#k,L(k)))}and(...k){return new LW(x.create(this.#k,L(k)))}$castTo(){return new Z(this.#k)}$notNull(){return new Z(this.#k)}toOperationNode(){return this.#k}}class zW{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}class DW{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}or(...k){return new DW(hk.create(this.#k,L(k)))}$castTo(){return new DW(this.#k)}toOperationNode(){return Xk.create(this.#k)}}class LW{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}and(...k){return new LW(x.create(this.#k,L(k)))}$castTo(){return new LW(this.#k)}toOperationNode(){return Xk.create(this.#k)}}var Sh=h({is(k){return k.kind==="FetchNode"},create(k,W){return{kind:"FetchNode",rowCount:Q.create(k),modifier:W}}});function Ih(k,W){if(!_k(k)&&!GW(k))throw Error(`Invalid fetch row count: ${k}`);if(!H$(W))throw Error(`Invalid fetch modifier: ${W}`);return Sh.create(k,W)}function H$(k){return k==="only"||k==="with ties"}var H;class xW{#k;constructor(k){this.#k=h(k)}get expressionType(){return}get isSelectQueryBuilder(){return!0}where(...k){return new H({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new H({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}having(...k){return new H({...this.#k,queryNode:Y.cloneWithHaving(this.#k.queryNode,L(k))})}havingRef(k,W,$){return new H({...this.#k,queryNode:Y.cloneWithHaving(this.#k.queryNode,m(k,W,$))})}select(k){return new H({...this.#k,queryNode:Y.cloneWithSelections(this.#k.queryNode,A(k))})}distinctOn(k){return new H({...this.#k,queryNode:Y.cloneWithDistinctOn(this.#k.queryNode,Gk(k))})}modifyFront(k){return new H({...this.#k,queryNode:Y.cloneWithFrontModifier(this.#k.queryNode,a.createWithExpression(k.toOperationNode()))})}modifyEnd(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.createWithExpression(k.toOperationNode()))})}distinct(){return new H({...this.#k,queryNode:Y.cloneWithFrontModifier(this.#k.queryNode,a.create("Distinct"))})}forUpdate(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForUpdate",k?dk(k).map(F):void 0))})}forShare(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForShare",k?dk(k).map(F):void 0))})}forKeyShare(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForKeyShare",k?dk(k).map(F):void 0))})}forNoKeyUpdate(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForNoKeyUpdate",k?dk(k).map(F):void 0))})}skipLocked(){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("SkipLocked"))})}noWait(){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("NoWait"))})}selectAll(k){return new H({...this.#k,queryNode:Y.cloneWithSelections(this.#k.queryNode,R(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}crossJoin(...k){return this.#W("CrossJoin",k)}innerJoinLateral(...k){return this.#W("LateralInnerJoin",k)}leftJoinLateral(...k){return this.#W("LateralLeftJoin",k)}crossJoinLateral(...k){return this.#W("LateralCrossJoin",k)}crossApply(...k){return this.#W("CrossApply",k)}outerApply(...k){return this.#W("OuterApply",k)}#W(k,W){return new H({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}orderBy(...k){return new H({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}groupBy(k){return new H({...this.#k,queryNode:Y.cloneWithGroupByItems(this.#k.queryNode,fh(k))})}limit(k){return new H({...this.#k,queryNode:Y.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}offset(k){return new H({...this.#k,queryNode:Y.cloneWithOffset(this.#k.queryNode,mh.create(X(k)))})}fetch(k,W="only"){return new H({...this.#k,queryNode:Y.cloneWithFetch(this.#k.queryNode,Ih(k,W))})}top(k,W){return new H({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}union(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("union",k,!1))})}unionAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("union",k,!0))})}intersect(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("intersect",k,!1))})}intersectAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("intersect",k,!0))})}except(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("except",k,!1))})}exceptAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("except",k,!0))})}as(k){return new jh(this,k)}clearSelect(){return new H({...this.#k,queryNode:Y.cloneWithoutSelections(this.#k.queryNode)})}clearWhere(){return new H({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}clearLimit(){return new H({...this.#k,queryNode:Y.cloneWithoutLimit(this.#k.queryNode)})}clearOffset(){return new H({...this.#k,queryNode:Y.cloneWithoutOffset(this.#k.queryNode)})}clearOrderBy(){return new H({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}clearGroupBy(){return new H({...this.#k,queryNode:Y.cloneWithoutGroupBy(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new H({...this.#k})}$castTo(){return new H(this.#k)}$narrowType(){return new H(this.#k)}$assertType(){return new H(this.#k)}$asTuple(){return new Z(this.toOperationNode())}$asScalar(){return new Z(this.toOperationNode())}withPlugin(k){return new H({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile();return(await this.#k.executor.executeQuery(k)).rows}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new H({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}H=xW;function nk(k){return new xW(k)}class jh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return I.create(this.#k.toOperationNode(),J.create(this.#W))}}var e=h({is(k){return k.kind==="AggregateFunctionNode"},create(k,W=[]){return h({kind:"AggregateFunctionNode",func:k,aggregated:W})},cloneWithDistinct(k){return h({...k,distinct:!0})},cloneWithOrderBy(k,W,$=!1){let M=$?"withinGroup":"orderBy";return h({...k,[M]:k[M]?$k.cloneWithItems(k[M],W):$k.create(W)})},cloneWithFilter(k,W){return h({...k,filter:k.filter?C.cloneWithOperation(k.filter,"And",W):C.create(W)})},cloneWithOrFilter(k,W){return h({...k,filter:k.filter?C.cloneWithOperation(k.filter,"Or",W):C.create(W)})},cloneWithOver(k,W){return h({...k,over:W})}});var cW=h({is(k){return k.kind==="FunctionNode"},create(k,W){return h({kind:"FunctionNode",func:k,arguments:W})}});class b{#k;constructor(k){this.#k=h(k)}get expressionType(){return}as(k){return new Eh(this,k)}distinct(){return new b({...this.#k,aggregateFunctionNode:e.cloneWithDistinct(this.#k.aggregateFunctionNode)})}orderBy(...k){return new b({...this.#k,aggregateFunctionNode:K.cloneWithOrderByItems(this.#k.aggregateFunctionNode,B(k))})}clearOrderBy(){return new b({...this.#k,aggregateFunctionNode:K.cloneWithoutOrderBy(this.#k.aggregateFunctionNode)})}withinGroupOrderBy(...k){return new b({...this.#k,aggregateFunctionNode:e.cloneWithOrderBy(this.#k.aggregateFunctionNode,B(k),!0)})}filterWhere(...k){return new b({...this.#k,aggregateFunctionNode:e.cloneWithFilter(this.#k.aggregateFunctionNode,L(k))})}filterWhereRef(k,W,$){return new b({...this.#k,aggregateFunctionNode:e.cloneWithFilter(this.#k.aggregateFunctionNode,m(k,W,$))})}over(k){let W=_h();return new b({...this.#k,aggregateFunctionNode:e.cloneWithOver(this.#k.aggregateFunctionNode,(k?k(W):W).toOperationNode())})}$call(k){return k(this)}$castTo(){return new b(this.#k)}$notNull(){return new b(this.#k)}toOperationNode(){return this.#k.aggregateFunctionNode}}class Eh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),J.create(this.#W))}}function Oh(){let k=($,M)=>{return new Z(cW.create($,Gk(M??[])))},W=($,M)=>{return new b({aggregateFunctionNode:e.create($,M?Gk(M):void 0)})};return Object.assign(k,{agg:W,avg($){return W("avg",[$])},coalesce(...$){return k("coalesce",$)},count($){return W("count",[$])},countAll($){return new b({aggregateFunctionNode:e.create("count",R($))})},max($){return W("max",[$])},min($){return W("min",[$])},sum($){return W("sum",[$])},any($){return k("any",[$])},jsonAgg($){return new b({aggregateFunctionNode:e.create("json_agg",[V($)?F($):$.toOperationNode()])})},toJson($){return new Z(cW.create("to_json",[V($)?F($):$.toOperationNode()]))}})}var bh=h({is(k){return k.kind==="UnaryOperationNode"},create(k,W){return h({kind:"UnaryOperationNode",operator:k,operand:W})}});function Qh(k,W){return bh.create(y.create(k),f(W))}var l=h({is(k){return k.kind==="CaseNode"},create(k){return h({kind:"CaseNode",value:k})},cloneWithWhen(k,W){return h({...k,when:h(k.when?[...k.when,W]:[W])})},cloneWithThen(k,W){return h({...k,when:k.when?h([...k.when.slice(0,-1),Mk.cloneWithResult(k.when[k.when.length-1],W)]):void 0})},cloneWith(k,W){return h({...k,...W})}});class yW{#k;constructor(k){this.#k=h(k)}when(...k){return new gW({...this.#k,node:l.cloneWithWhen(this.#k.node,Mk.create(L(k)))})}}class gW{#k;constructor(k){this.#k=h(k)}then(k){return new Nh({...this.#k,node:l.cloneWithThen(this.#k.node,WW(k)?Bk(k):X(k))})}}class Nh{#k;constructor(k){this.#k=h(k)}when(...k){return new gW({...this.#k,node:l.cloneWithWhen(this.#k.node,Mk.create(L(k)))})}else(k){return new Bh({...this.#k,node:l.cloneWith(this.#k.node,{else:WW(k)?Bk(k):X(k)})})}end(){return new Z(l.cloneWith(this.#k.node,{isStatement:!1}))}endCase(){return new Z(l.cloneWith(this.#k.node,{isStatement:!0}))}}class Bh{#k;constructor(k){this.#k=h(k)}end(){return new Z(l.cloneWith(this.#k.node,{isStatement:!1}))}endCase(){return new Z(l.cloneWith(this.#k.node,{isStatement:!0}))}}var JW=h({is(k){return k.kind==="JSONOperatorChainNode"},create(k){return h({kind:"JSONOperatorChainNode",operator:k,values:h([])})},cloneWithValue(k,W){return h({...k,values:h([...k.values,W])})}});var tW=h({is(k){return k.kind==="JSONPathLegNode"},create(k,W){return h({kind:"JSONPathLegNode",type:k,value:W})}});var Uk=h({is(k){return k.kind==="JSONPathNode"},create(k){return h({kind:"JSONPathNode",inOperator:k,pathLegs:h([])})},cloneWithLeg(k,W){return h({...k,pathLegs:h([...k.pathLegs,W])})}});var Qk=h({is(k){return k.kind==="JSONReferenceNode"},create(k,W){return h({kind:"JSONReferenceNode",reference:k,traversal:W})},cloneWithTraversal(k,W){return h({...k,traversal:W})}});var Z$=/^#-\d+$/;class ik{#k;constructor(k){this.#k=k}at(k){if(typeof k!=="number"&&typeof k!=="string"||typeof k==="number"&&!Number.isInteger(k)||typeof k==="string"&&k!=="last"&&!Z$.test(k))throw Error(`Unexpected index value in .at(...): ${k}`);return this.#W("ArrayLocation",k)}key(k){return this.#W("Member",k)}#W(k,W){if(Qk.is(this.#k))return new uk(Qk.cloneWithTraversal(this.#k,Uk.is(this.#k.traversal)?Uk.cloneWithLeg(this.#k.traversal,tW.create(k,W)):JW.cloneWithValue(this.#k.traversal,Q.createImmediate(W))));return new uk(Uk.cloneWithLeg(this.#k,tW.create(k,W)))}}class uk extends ik{#k;constructor(k){super(k);this.#k=k}get expressionType(){return}as(k){return new xh(this,k)}$castTo(){return new uk(this.#k)}$notNull(){return new uk(this.#k)}toOperationNode(){return this.#k}}class xh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}var nW=h({is(k){return k.kind==="TupleNode"},create(k){return h({kind:"TupleNode",values:h(k)})}});var Y$=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],X$=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],ch=h({is(k){return k.kind==="DataTypeNode"},create(k){return h({kind:"DataTypeNode",dataType:k})}});function yh(k){if(Y$.includes(k))return!0;if(X$.some((W)=>W.test(k)))return!0;return!1}function gh(k){if(z(k))return k.toOperationNode();if(yh(k))return ch.create(k);throw Error(`invalid column data type ${JSON.stringify(k)}`)}var th=h({is(k){return k.kind==="CastNode"},create(k,W){return h({kind:"CastNode",expression:k,dataType:W})}});function XW(k=qk){function W(G,q,vk){return new Z(hW(G,q,vk))}function $(G,q){return new Z(Qh(G,q))}let M=Object.assign(W,{fn:void 0,eb:void 0,selectFrom(G){return nk({queryId:T(),executor:k,queryNode:Y.createFrom(n(G))})},case(G){return new yW({node:l.create(c(G)?void 0:f(G))})},ref(G,q){if(c(q))return new Z(t(G));return new ik(nh(G,q))},jsonPath(){return new ik(Uk.create())},table(G){return new Z(F(G))},val(G){return new Z(X(G))},refTuple(...G){return new Z(nW.create(G.map(f)))},tuple(...G){return new Z(nW.create(G.map(X)))},lit(G){return new Z(Bk(G))},unary:$,not(G){return $("not",G)},exists(G){return $("exists",G)},neg(G){return $("-",G)},between(G,q,vk){return new Z(Yk.create(f(G),y.create("between"),x.create(X(q),X(vk))))},betweenSymmetric(G,q,vk){return new Z(Yk.create(f(G),y.create("between symmetric"),x.create(X(q),X(vk))))},and(G){if(j(G))return new Z(mk(G,"and"));return new Z(UW(G,"and"))},or(G){if(j(G))return new Z(mk(G,"or"));return new Z(UW(G,"or"))},parens(...G){let q=L(G);if(Xk.is(q))return new Z(q);else return new Z(Xk.create(q))},cast(G,q){return new Z(th.create(f(G),gh(q)))},withSchema(G){return XW(k.withPluginAtFront(new YW(G)))}});return M.fn=Oh(),M.eb=M,M}function d(k){return XW()}function p(k){if(z(k))return k.toOperationNode();else if(_(k))return k(d()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(k)}`)}function MW(k){if(z(k))return k.toOperationNode();else if(_(k))return k(d()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(k)}`)}function Wk(k){return ok(k)||iW(k)||_(k)}function _W(k){if(V(k))return t(k);return k.toOperationNode()}function Gk(k){if(j(k))return k.map((W)=>f(W));else return[f(k)]}function f(k){if(Wk(k))return p(k);return _W(k)}function nh(k,W){let $=t(k);if(dW(W))return Qk.create($,JW.create(y.create(W)));let M=W.slice(0,-1);if(dW(M))return Qk.create($,Uk.create(y.create(M)));throw Error(`Invalid JSON operator: ${W}`)}function t(k){if(!k.includes("."))return Ak.create(S.create(k));let $=k.split(".").map(uW);if($.length===3)return L$($);if($.length===2)return z$($);throw Error(`invalid column reference ${k}`)}function Zh(k){if(k.includes(" as ")){let[$,M]=k.split(" as ").map(uW);return I.create(t($),J.create(M))}else return t(k)}function D$(k){return S.create(k)}function R3(k){if(k.includes(" ")){let[$,M]=k.split(" ").map(uW);if(!RW(M))throw Error(`invalid order direction "${M}" next to "${$}"`);return B([$,M])[0]}else return D$(k)}function L$(k){let[W,$,M]=k;return Ak.create(S.create(M),zk.createWithSchema(W,$))}function z$(k){let[W,$]=k;return Ak.create(S.create($),zk.create(W))}function uW(k){return k.trim()}class lk{#k;constructor(k){this.#k=h(k)}get expressionType(){return}get isRawBuilder(){return!0}as(k){return new dh(this,k)}$castTo(){return new lk({...this.#k})}$notNull(){return new lk(this.#k)}withPlugin(k){return new lk({...this.#k,plugins:this.#k.plugins!==void 0?h([...this.#k.plugins,k]):h([k])})}toOperationNode(){return this.#h(this.#W())}compile(k){return this.#$(this.#W(k))}async execute(k){let W=this.#W(k);return W.executeQuery(this.#$(W))}#W(k){let W=k!==void 0?k.getExecutor():qk;return this.#k.plugins!==void 0?W.withPlugins(this.#k.plugins):W}#h(k){return k.transformQuery(this.#k.rawNode,this.#k.queryId)}#$(k){return k.compileQuery(this.#h(k),this.#k.queryId)}}function Zk(k){return new lk(k)}class dh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}get rawBuilder(){return this.#k}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}var J$=Object.assign((k,...W)=>{return Zk({queryId:T(),rawNode:v.create(k,W?.map(uh)??[])})},{ref(k){return Zk({queryId:T(),rawNode:v.createWithChild(t(k))})},val(k){return Zk({queryId:T(),rawNode:v.createWithChild(X(k))})},value(k){return this.val(k)},table(k){return Zk({queryId:T(),rawNode:v.createWithChild(F(k))})},id(...k){let W=Array(k.length+1).fill(".");return W[0]="",W[W.length-1]="",Zk({queryId:T(),rawNode:v.create(W,k.map(J.create))})},lit(k){return Zk({queryId:T(),rawNode:v.createWithChild(Q.createImmediate(k))})},literal(k){return this.lit(k)},raw(k){return Zk({queryId:T(),rawNode:v.createWithSql(k)})},join(k,W=J$`, `){let $=Array(Math.max(2*k.length-1,0)),M=W.toOperationNode();for(let G=0;G<k.length;++G)if($[2*G]=uh(k[G]),G!==k.length-1)$[2*G+1]=M;return Zk({queryId:T(),rawNode:v.createWithChildren($)})}});function uh(k){if(z(k))return k.toOperationNode();return X(k)}var l3=h({raw(k,W=[]){return h({sql:k,query:v.createWithSql(k),parameters:h(W),queryId:T()})}});
3
- export{z as kb,S as lb,pk as mb,ah as nb,t as ob,D$ as pb,R3 as qb,rk as rb,Q as sb,L as tb,K as ub,Y as vb,Vh as wb,T as xb,ZW as yb,Th as zb,QW as Ab,Pk as Bb,Oh as Cb,l as Db,yW as Eb,gh as Fb,p as Gb,oh as Hb,F as Ib,J$ as Jb,l3 as Kb};
2
+ import{Ac as Mk,Cc as YW,Dc as Ch,Wb as c,Xb as V,Yb as _k,Zb as ek,_b as kW,ac as GW,cc as _,dc as kk,ec as h,fc as dk,gc as j,ic as J,mc as I,nc as zk,oc as x,pc as hk,qc as Kk,rc as pW,sc as y,tc as dW,uc as v,vc as fk,wc as Xk,xc as w,yc as sW,zc as TW}from"./chunk-8rcfhfq5.js";function z(k){return kk(k)&&_(k.toOperationNode)}var Q=h({is(k){return k.kind==="ValueNode"},create(k){return h({kind:"ValueNode",value:k})},createImmediate(k){return h({kind:"ValueNode",value:k,immediate:!0})}});var S=h({is(k){return k.kind==="ColumnNode"},create(k){return h({kind:"ColumnNode",column:J.create(k)})}});var pk=h({is(k){return k.kind==="SelectAllNode"},create(){return h({kind:"SelectAllNode"})}});var Ak=h({is(k){return k.kind==="ReferenceNode"},create(k,W){return h({kind:"ReferenceNode",table:W,column:k})},createSelectAll(k){return h({kind:"ReferenceNode",table:k,column:pk.create()})}});function ok(k){return kk(k)&&"expressionType"in k&&z(k)}function iW(k){return kk(k)&&"expression"in k&&V(k.alias)&&z(k)}var a=h({is(k){return k.kind==="SelectModifierNode"},create(k,W){return h({kind:"SelectModifierNode",modifier:k,of:W})},createWithExpression(k){return h({kind:"SelectModifierNode",rawModifier:k})}});var Yk=h({is(k){return k.kind==="BinaryOperationNode"},create(k,W,$){return h({kind:"BinaryOperationNode",leftOperand:k,operator:W,rightOperand:$})}});var sk=h({is(k){return k.kind==="PrimitiveValueListNode"},create(k){return h({kind:"PrimitiveValueListNode",values:h([...k])})}});var rk=h({is(k){return k.kind==="ValueListNode"},create(k){return h({kind:"ValueListNode",values:h(k)})}});function lW(k){if(j(k))return ih(k);return X(k)}function X(k){if(Wk(k))return p(k);return Q.create(k)}function WW(k){return _k(k)||ek(k)||kW(k)}function Bk(k){if(!WW(k))throw Error(`unsafe immediate value ${JSON.stringify(k)}`);return Q.createImmediate(k)}function ih(k){if(k.some(Wk))return rk.create(k.map((W)=>X(W)));return sk.create(k)}function L(k){if(k.length===3)return hW(k[0],k[1],k[2]);else if(k.length===1)return X(k[0]);throw Error(`invalid arguments: ${JSON.stringify(k)}`)}function hW(k,W,$){if(lh(W)&&oW($))return Yk.create(f(k),PW(W),Q.createImmediate($));return Yk.create(f(k),PW(W),lW($))}function m(k,W,$){return Yk.create(f(k),PW(W),f($))}function UW(k,W){return mk(Object.entries(k).filter(([,$])=>!c($)).map(([$,M])=>hW($,oW(M)?"is":"=",M)),W)}function mk(k,W,$=!0){let M=W==="and"?x.create:hk.create;if(k.length===0)return Yk.create(Q.createImmediate(1),y.create("="),Q.createImmediate(W==="and"?1:0));let G=aW(k[0]);for(let q=1;q<k.length;++q)G=M(G,aW(k[q]));if(k.length>1&&$)return Xk.create(G);return G}function lh(k){return k==="is"||k==="is not"}function oW(k){return kW(k)||ek(k)}function PW(k){if(V(k)&&pW.includes(k))return y.create(k);if(z(k))return k.toOperationNode();throw Error(`invalid operator ${JSON.stringify(k)}`)}function aW(k){return z(k)?k.toOperationNode():k}var $k=h({is(k){return k.kind==="OrderByNode"},create(k){return h({kind:"OrderByNode",items:h([...k])})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var VW=h({is(k){return k.kind==="PartitionByNode"},create(k){return h({kind:"PartitionByNode",items:h(k)})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var xk=h({is(k){return k.kind==="OverNode"},create(){return h({kind:"OverNode"})},cloneWithOrderByItems(k,W){return h({...k,orderBy:k.orderBy?$k.cloneWithItems(k.orderBy,W):$k.create(W)})},cloneWithPartitionByItems(k,W){return h({...k,partitionBy:k.partitionBy?VW.cloneWithItems(k.partitionBy,W):VW.create(W)})}});var Vk=h({is(k){return k.kind==="FromNode"},create(k){return h({kind:"FromNode",froms:h(k)})},cloneWithFroms(k,W){return h({...k,froms:h([...k.froms,...W])})}});var wW=h({is(k){return k.kind==="GroupByNode"},create(k){return h({kind:"GroupByNode",items:h(k)})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var FW=h({is(k){return k.kind==="HavingNode"},create(k){return h({kind:"HavingNode",having:k})},cloneWithOperation(k,W,$){return h({...k,having:W==="And"?x.create(k.having,$):hk.create(k.having,$)})}});var o=h({is(k){return k.kind==="UpdateQueryNode"},create(k,W){return h({kind:"UpdateQueryNode",table:k.length===1?k[0]:sW.create(k),...W&&{with:W}})},createWithoutTable(){return h({kind:"UpdateQueryNode"})},cloneWithFromItems(k,W){return h({...k,from:k.from?Vk.cloneWithFroms(k.from,W):Vk.create(W)})},cloneWithUpdates(k,W){return h({...k,updates:k.updates?h([...k.updates,...W]):W})},cloneWithLimit(k,W){return h({...k,limit:W})}});var Dk=h({is(k){return k.kind==="DeleteQueryNode"},create(k,W){return h({kind:"DeleteQueryNode",from:Vk.create(k),...W&&{with:W}})},cloneWithOrderByItems:(k,W)=>K.cloneWithOrderByItems(k,W),cloneWithoutOrderBy:(k)=>K.cloneWithoutOrderBy(k),cloneWithLimit(k,W){return h({...k,limit:W})},cloneWithoutLimit(k){return h({...k,limit:void 0})},cloneWithUsing(k,W){return h({...k,using:k.using!==void 0?TW.cloneWithTables(k.using,W):TW.create(W)})}});var C=h({is(k){return k.kind==="WhereNode"},create(k){return h({kind:"WhereNode",where:k})},cloneWithOperation(k,W,$){return h({...k,where:W==="And"?x.create(k.where,$):hk.create(k.where,$)})}});var vW=h({is(k){return k.kind==="ReturningNode"},create(k){return h({kind:"ReturningNode",selections:h(k)})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})}});var rW=h({is(k){return k.kind==="ExplainNode"},create(k,W){return h({kind:"ExplainNode",format:k,options:W})}});var N=h({is(k){return k.kind==="MergeQueryNode"},create(k,W){return h({kind:"MergeQueryNode",into:k,...W&&{with:W}})},cloneWithUsing(k,W){return h({...k,using:W})},cloneWithWhen(k,W){return h({...k,whens:k.whens?h([...k.whens,W]):h([W])})},cloneWithThen(k,W){return h({...k,whens:k.whens?h([...k.whens.slice(0,-1),Mk.cloneWithResult(k.whens[k.whens.length-1],W)]):void 0})}});var AW=h({is(k){return k.kind==="OutputNode"},create(k){return h({kind:"OutputNode",selections:h(k)})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})}});var K=h({is(k){return Y.is(k)||w.is(k)||o.is(k)||Dk.is(k)||N.is(k)},cloneWithEndModifier(k,W){return h({...k,endModifiers:k.endModifiers?h([...k.endModifiers,W]):h([W])})},cloneWithWhere(k,W){return h({...k,where:k.where?C.cloneWithOperation(k.where,"And",W):C.create(W)})},cloneWithJoin(k,W){return h({...k,joins:k.joins?h([...k.joins,W]):h([W])})},cloneWithReturning(k,W){return h({...k,returning:k.returning?vW.cloneWithSelections(k.returning,W):vW.create(W)})},cloneWithoutReturning(k){return h({...k,returning:void 0})},cloneWithoutWhere(k){return h({...k,where:void 0})},cloneWithExplain(k,W,$){return h({...k,explain:rW.create(W,$?.toOperationNode())})},cloneWithTop(k,W){return h({...k,top:W})},cloneWithOutput(k,W){return h({...k,output:k.output?AW.cloneWithSelections(k.output,W):AW.create(W)})},cloneWithOrderByItems(k,W){return h({...k,orderBy:k.orderBy?$k.cloneWithItems(k.orderBy,W):$k.create(W)})},cloneWithoutOrderBy(k){return h({...k,orderBy:void 0})}});var Y=h({is(k){return k.kind==="SelectQueryNode"},create(k){return h({kind:"SelectQueryNode",...k&&{with:k}})},createFrom(k,W){return h({kind:"SelectQueryNode",from:Vk.create(k),...W&&{with:W}})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})},cloneWithDistinctOn(k,W){return h({...k,distinctOn:k.distinctOn?h([...k.distinctOn,...W]):h(W)})},cloneWithFrontModifier(k,W){return h({...k,frontModifiers:k.frontModifiers?h([...k.frontModifiers,W]):h([W])})},cloneWithOrderByItems:(k,W)=>K.cloneWithOrderByItems(k,W),cloneWithGroupByItems(k,W){return h({...k,groupBy:k.groupBy?wW.cloneWithItems(k.groupBy,W):wW.create(W)})},cloneWithLimit(k,W){return h({...k,limit:W})},cloneWithOffset(k,W){return h({...k,offset:W})},cloneWithFetch(k,W){return h({...k,fetch:W})},cloneWithHaving(k,W){return h({...k,having:k.having?FW.cloneWithOperation(k.having,"And",W):FW.create(W)})},cloneWithSetOperations(k,W){return h({...k,setOperations:k.setOperations?h([...k.setOperations,...W]):h([...W])})},cloneWithoutSelections(k){return h({...k,selections:[]})},cloneWithoutLimit(k){return h({...k,limit:void 0})},cloneWithoutOffset(k){return h({...k,offset:void 0})},cloneWithoutOrderBy:(k)=>K.cloneWithoutOrderBy(k),cloneWithoutGroupBy(k){return h({...k,groupBy:void 0})}});class Rk{#k;constructor(k){this.#k=h(k)}on(...k){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,L(k))})}onRef(k,W,$){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,m(k,W,$))})}onTrue(){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,v.createWithSql("true"))})}$call(k){return k(this)}toOperationNode(){return this.#k.joinNode}}class ah{#k;get dynamicReference(){return this.#k}get refType(){return}constructor(k){this.#k=k}toOperationNode(){return _W(this.#k)}}function $W(k){return kk(k)&&z(k)&&V(k.dynamicReference)}var g=h({is(k){return k.kind==="OrderByItemNode"},create(k,W){return h({kind:"OrderByItemNode",orderBy:k,direction:W})},cloneWith(k,W){return h({...k,...W})}});var eW=h({is(k){return k.kind==="CollateNode"},create(k){return h({kind:"CollateNode",collation:J.create(k)})}});class Lk{#k;constructor(k){this.#k=h(k)}desc(){return new Lk({node:g.cloneWith(this.#k.node,{direction:v.createWithSql("desc")})})}asc(){return new Lk({node:g.cloneWith(this.#k.node,{direction:v.createWithSql("asc")})})}nullsLast(){return new Lk({node:g.cloneWith(this.#k.node,{nulls:"last"})})}nullsFirst(){return new Lk({node:g.cloneWith(this.#k.node,{nulls:"first"})})}collate(k){return new Lk({node:g.cloneWith(this.#k.node,{collation:eW.create(k)})})}toOperationNode(){return this.#k.node}}function RW(k){return k==="asc"||k==="desc"}function B(k){if(k.length===2)return[mW(k[0],k[1])];if(k.length===1){let[W]=k;if(Array.isArray(W))return fk("orderBy(array) is deprecated, use multiple orderBy calls instead."),W.map(($)=>mW($));return[mW(W)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${k.length}`)}function mW(k,W){let $=ph(k);if(g.is($)){if(W)throw Error("Cannot specify direction twice!");return $}return kh($,W)}function ph(k){if(Wk(k))return p(k);if($W(k))return k.toOperationNode();let[W,$]=k.split(" ");if($)return fk("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),kh(t(W),$);return t(k)}function kh(k,W){if(typeof W==="string"){if(!RW(W))throw Error(`Invalid order by direction: ${W}`);return g.create(k,v.createWithSql(W))}if(ok(W))return fk("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),g.create(k,W.toOperationNode());let $=g.create(k);if(!W)return $;return W(new Lk({node:$})).toOperationNode()}var Wh=h({is(k){return k.kind==="PartitionByItemNode"},create(k){return h({kind:"PartitionByItemNode",partitionBy:k})}});function hh(k){return Gk(k).map(Wh.create)}class Ck{#k;constructor(k){this.#k=h(k)}orderBy(...k){return new Ck({overNode:xk.cloneWithOrderByItems(this.#k.overNode,B(k))})}clearOrderBy(){return new Ck({overNode:K.cloneWithoutOrderBy(this.#k.overNode)})}partitionBy(k){return new Ck({overNode:xk.cloneWithPartitionByItems(this.#k.overNode,hh(k))})}$call(k){return k(this)}toOperationNode(){return this.#k.overNode}}var Sk=h({is(k){return k.kind==="SelectionNode"},create(k){return h({kind:"SelectionNode",selection:k})},createSelectAll(){return h({kind:"SelectionNode",selection:pk.create()})},createSelectAllFromTable(k){return h({kind:"SelectionNode",selection:Ak.createSelectAll(k)})}});class oh{#k;get table(){return this.#k}constructor(k){this.#k=k}as(k){return new $h(this.#k,k)}}class $h{#k;#W;get table(){return this.#k}get alias(){return this.#W}constructor(k,W){this.#k=k,this.#W=W}toOperationNode(){return I.create(F(this.#k),J.create(this.#W))}}function Mh(k){return kk(k)&&z(k)&&V(k.table)&&V(k.alias)}function n(k){if(j(k))return k.map((W)=>wk(W));else return[wk(k)]}function wk(k){if(V(k))return fW(k);else if(Mh(k))return k.toOperationNode();else return MW(k)}function fW(k){if(k.includes(" as ")){let[$,M]=k.split(" as ").map(Kh);return I.create(F($),J.create(M))}else return F(k)}function F(k){if(k.includes(".")){let[$,M]=k.split(".").map(Kh);return zk.createWithSchema($,M)}else return zk.create(k)}function Kh(k){return k.trim()}function A(k){if(_(k))return A(k(d()));else if(j(k))return k.map((W)=>Gh(W));else return[Gh(k)]}function Gh(k){if(V(k))return Sk.create(Zh(k));else if($W(k))return Sk.create(k.toOperationNode());else return Sk.create(MW(k))}function R(k){if(!k)return[Sk.createSelectAll()];else if(Array.isArray(k))return k.map(Hh);else return[Hh(k)]}function Hh(k){if(V(k))return Sk.createSelectAllFromTable(F(k));throw Error(`invalid value selectAll expression: ${JSON.stringify(k)}`)}var Yh=h({is(k){return k.kind==="ValuesNode"},create(k){return h({kind:"ValuesNode",values:h(k)})}});var Xh=h({is(k){return k.kind==="DefaultInsertValueNode"},create(){return h({kind:"DefaultInsertValueNode"})}});function KW(k){let W=_(k)?k(d()):k,$=j(W)?W:h([W]);return sh($)}function sh(k){let W=rh(k);return[h([...W.keys()].map(S.create)),Yh.create(k.map(($)=>eh($,W)))]}function rh(k){let W=new Map;for(let $ of k){let M=Object.keys($);for(let G of M)if(!W.has(G)&&$[G]!==void 0)W.set(G,W.size)}return W}function eh(k,W){let $=Object.keys(k),M=Array.from({length:W.size}),G=!1,q=$.length;for(let ak of $){let Nk=W.get(ak);if(c(Nk)){q--;continue}let qW=k[ak];if(c(qW)||Wk(qW))G=!0;M[Nk]=qW}if(q<W.size||G){let ak=Xh.create();return rk.create(M.map((Nk)=>c(Nk)?ak:X(Nk)))}return sk.create(M)}var CW=h({is(k){return k.kind==="ColumnUpdateNode"},create(k,W){return h({kind:"ColumnUpdateNode",column:k,value:W})}});function Dh(...k){if(k.length===2)return[CW.create(f(k[0]),X(k[1]))];return ck(k[0])}function ck(k){let W=_(k)?k(d()):k;return Object.entries(W).filter(([$,M])=>M!==void 0).map(([$,M])=>{return CW.create(S.create($),X(M))})}var Lh=h({is(k){return k.kind==="OnDuplicateKeyNode"},create(k){return h({kind:"OnDuplicateKeyNode",updates:k})}});class SW{insertId;numInsertedOrUpdatedRows;constructor(k,W){this.insertId=k,this.numInsertedOrUpdatedRows=W}}class u extends Error{node;constructor(k){super("no result");this.node=k}}function s(k){return Object.prototype.hasOwnProperty.call(k,"prototype")}var E=h({is(k){return k.kind==="OnConflictNode"},create(){return h({kind:"OnConflictNode"})},cloneWith(k,W){return h({...k,...W})},cloneWithIndexWhere(k,W){return h({...k,indexWhere:k.indexWhere?C.cloneWithOperation(k.indexWhere,"And",W):C.create(W)})},cloneWithIndexOrWhere(k,W){return h({...k,indexWhere:k.indexWhere?C.cloneWithOperation(k.indexWhere,"Or",W):C.create(W)})},cloneWithUpdateWhere(k,W){return h({...k,updateWhere:k.updateWhere?C.cloneWithOperation(k.updateWhere,"And",W):C.create(W)})},cloneWithUpdateOrWhere(k,W){return h({...k,updateWhere:k.updateWhere?C.cloneWithOperation(k.updateWhere,"Or",W):C.create(W)})},cloneWithoutIndexWhere(k){return h({...k,indexWhere:void 0})},cloneWithoutUpdateWhere(k){return h({...k,updateWhere:void 0})}});class r{#k;constructor(k){this.#k=h(k)}column(k){let W=S.create(k);return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{columns:this.#k.onConflictNode.columns?h([...this.#k.onConflictNode.columns,W]):h([W])})})}columns(k){let W=k.map(S.create);return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{columns:this.#k.onConflictNode.columns?h([...this.#k.onConflictNode.columns,...W]):h(W)})})}constraint(k){return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{constraint:J.create(k)})})}expression(k){return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{indexExpression:k.toOperationNode()})})}where(...k){return new r({...this.#k,onConflictNode:E.cloneWithIndexWhere(this.#k.onConflictNode,L(k))})}whereRef(k,W,$){return new r({...this.#k,onConflictNode:E.cloneWithIndexWhere(this.#k.onConflictNode,m(k,W,$))})}clearWhere(){return new r({...this.#k,onConflictNode:E.cloneWithoutIndexWhere(this.#k.onConflictNode)})}doNothing(){return new zh({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{doNothing:!0})})}doUpdateSet(k){return new yk({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{updates:ck(k)})})}$call(k){return k(this)}}class zh{#k;constructor(k){this.#k=h(k)}toOperationNode(){return this.#k.onConflictNode}}class yk{#k;constructor(k){this.#k=h(k)}where(...k){return new yk({...this.#k,onConflictNode:E.cloneWithUpdateWhere(this.#k.onConflictNode,L(k))})}whereRef(k,W,$){return new yk({...this.#k,onConflictNode:E.cloneWithUpdateWhere(this.#k.onConflictNode,m(k,W,$))})}clearWhere(){return new yk({...this.#k,onConflictNode:E.cloneWithoutUpdateWhere(this.#k.onConflictNode)})}$call(k){return k(this)}toOperationNode(){return this.#k.onConflictNode}}var Jh=h({is(k){return k.kind==="TopNode"},create(k,W){return h({kind:"TopNode",expression:k,modifiers:W})}});function i(k,W){if(!_k(k)&&!GW(k))throw Error(`Invalid top expression: ${k}`);if(!c(W)&&!k$(W))throw Error(`Invalid top modifiers: ${W}`);return Jh.create(k,W)}function k$(k){return k==="percent"||k==="with ties"||k==="percent with ties"}var Fk=h({is(k){return k.kind==="OrActionNode"},create(k){return h({kind:"OrActionNode",action:k})}});class D{#k;constructor(k){this.#k=h(k)}values(k){let[W,$]=KW(k);return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{columns:W,values:$})})}columns(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{columns:h(k.map(S.create))})})}expression(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{values:p(k)})})}defaultValues(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{defaultValues:!0})})}modifyEnd(k){return new D({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}ignore(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("ignore")})})}orIgnore(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("ignore")})})}orAbort(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("abort")})})}orFail(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("fail")})})}orReplace(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("replace")})})}orRollback(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("rollback")})})}top(k,W){return new D({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}onConflict(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{onConflict:k(new r({onConflictNode:E.create()})).toOperationNode()})})}onDuplicateKeyUpdate(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{onDuplicateKey:Lh.create(ck(k))})})}returning(k){return new D({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(){return new D({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R())})}output(k){return new D({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new D({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}clearReturning(){return new D({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new D({...this.#k})}$castTo(){return new D(this.#k)}$narrowType(){return new D(this.#k)}$assertType(){return new D(this.#k)}withPlugin(k){return new D({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new SW(W.insertId,W.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new D({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}class IW{numDeletedRows;constructor(k){this.numDeletedRows=k}}var Ik=h({is(k){return k.kind==="LimitNode"},create(k){return h({kind:"LimitNode",limit:k})}});var P;class HW{#k;constructor(k){this.#k=h(k)}where(...k){return new P({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new P({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}clearWhere(){return new P({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}top(k,W){return new P({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}using(k){return new P({...this.#k,queryNode:Dk.cloneWithUsing(this.#k.queryNode,n(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}#W(k,W){return new P({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}returning(k){return new P({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new P({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new P({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new P({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}clearReturning(){return new P({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}clearLimit(){return new P({...this.#k,queryNode:Dk.cloneWithoutLimit(this.#k.queryNode)})}orderBy(...k){return new P({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}clearOrderBy(){return new P({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}limit(k){return new P({...this.#k,queryNode:Dk.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}modifyEnd(k){return new P({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new P({...this.#k})}$castTo(){return new P(this.#k)}$narrowType(){return new P(this.#k)}$assertType(){return new P(this.#k)}withPlugin(k){return new P({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new IW(W.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new P({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}P=HW;class jW{numUpdatedRows;numChangedRows;constructor(k,W){this.numUpdatedRows=k,this.numChangedRows=W}}var U;class jk{#k;constructor(k){this.#k=h(k)}where(...k){return new U({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new U({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}clearWhere(){return new U({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}top(k,W){return new U({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}from(k){return new U({...this.#k,queryNode:o.cloneWithFromItems(this.#k.queryNode,n(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}#W(k,W){return new U({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}orderBy(...k){return new U({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}clearOrderBy(){return new U({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}limit(k){return new U({...this.#k,queryNode:o.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}set(...k){return new U({...this.#k,queryNode:o.cloneWithUpdates(this.#k.queryNode,Dh(...k))})}returning(k){return new U({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new U({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new U({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new U({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}modifyEnd(k){return new U({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}clearReturning(){return new U({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new U({...this.#k})}$castTo(){return new U(this.#k)}$narrowType(){return new U(this.#k)}$assertType(){return new U(this.#k)}withPlugin(k){return new U({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new jW(W.numAffectedRows??BigInt(0),W.numChangedRows)]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new U({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}U=jk;var EW=h({is(k){return k.kind==="CommonTableExpressionNameNode"},create(k,W){return h({kind:"CommonTableExpressionNameNode",table:zk.create(k),columns:W?h(W.map(S.create)):void 0})}});var Ek=h({is(k){return k.kind==="CommonTableExpressionNode"},create(k,W){return h({kind:"CommonTableExpressionNode",name:k,expression:W})},cloneWith(k,W){return h({...k,...W})}});class gk{#k;constructor(k){this.#k=h(k)}materialized(){return new gk({...this.#k,node:Ek.cloneWith(this.#k.node,{materialized:!0})})}notMaterialized(){return new gk({...this.#k,node:Ek.cloneWith(this.#k.node,{materialized:!1})})}toOperationNode(){return this.#k.node}}function OW(k,W){let $=W(Ph()).toOperationNode();if(_(k))return k(W$($)).toOperationNode();return Ek.create(qh(k),$)}function W$(k){return(W)=>{return new gk({node:Ek.create(qh(W),k)})}}function qh(k){if(k.includes("(")){let W=k.split(/[\(\)]/),$=W[0],M=W[1].split(",").map((G)=>G.trim());return EW.create($,M)}else return EW.create(k)}var tk=h({is(k){return k.kind==="WithNode"},create(k,W){return h({kind:"WithNode",expressions:h([k]),...W})},cloneWithExpression(k,W){return h({...k,expressions:h([...k.expressions,W])})}});var Uh=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function Vh(k){let W="";for(let $=0;$<k;++$)W+=h$();return W}function h$(){return Uh[~~(Math.random()*Uh.length)]}function T(){return new wh}class wh{#k;get queryId(){if(this.#k===void 0)this.#k=Vh(8);return this.#k}}var Fh=h({is(k){return k.kind==="MatchedNode"},create(k,W=!1){return h({kind:"MatchedNode",not:k,bySource:W})}});function bW(k,W,$){return Mk.create(mk([Fh.create(!k.isMatched,k.bySource),...W&&W.length>0?[W.length===3&&$?m(W[0],W[1],W[2]):L(W)]:[]],"and",!1))}function Ok(k){if(V(k))return v.create([k],[]);if(z(k))return k.toOperationNode();return k}class ZW{#k;#W;#h;constructor(){this.#k=new Promise((k,W)=>{this.#h=W,this.#W=k})}get promise(){return this.#k}resolve=(k)=>{if(this.#W)this.#W(k)};reject=(k)=>{if(this.#h)this.#h(k)}}async function Th(k){let W=new ZW,$=new ZW;return k.provideConnection(async(M)=>{return W.resolve(M),await $.promise}).catch((M)=>W.reject(M)),h({connection:await W.promise,release:$.resolve})}var $$=h([]);class QW{#k;constructor(k=$$){this.#k=k}get plugins(){return this.#k}transformQuery(k,W){for(let $ of this.#k){let M=$.transformQuery({node:k,queryId:W});if(M.kind===k.kind)k=M;else throw Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${k.kind}`,`but it returned a ${M.kind}`].join(" "))}return k}async executeQuery(k){return await this.provideConnection(async(W)=>{let $=await W.executeQuery(k);if("numUpdatedOrDeletedRows"in $)fk("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`.");return await this.#W($,k.queryId)})}async*stream(k,W){let{connection:$,release:M}=await Th(this);try{for await(let G of $.streamQuery(k,W))yield await this.#W(G,k.queryId)}finally{M()}}async#W(k,W){for(let $ of this.#k)k=await $.transformResult({result:k,queryId:W});return k}}class bk extends QW{get adapter(){throw Error("this query cannot be compiled to SQL")}compileQuery(){throw Error("this query cannot be compiled to SQL")}provideConnection(){throw Error("this query cannot be executed")}withConnectionProvider(){throw Error("this query cannot have a connection provider")}withPlugin(k){return new bk([...this.plugins,k])}withPlugins(k){return new bk([...this.plugins,...k])}withPluginAtFront(k){return new bk([k,...this.plugins])}withoutPlugins(){return new bk([])}}var qk=new bk;class NW{numChangedRows;constructor(k){this.numChangedRows=k}}class Hk{#k;constructor(k){this.#k=h(k)}modifyEnd(k){return new Hk({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}top(k,W){return new Hk({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}using(...k){return new O({...this.#k,queryNode:N.cloneWithUsing(this.#k.queryNode,Jk("Using",k))})}returning(k){return new Hk({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new Hk({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new Hk({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new Hk({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}}class O{#k;constructor(k){this.#k=h(k)}modifyEnd(k){return new O({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}top(k,W){return new O({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}whenMatched(){return this.#W([])}whenMatchedAnd(...k){return this.#W(k)}whenMatchedAndRef(k,W,$){return this.#W([k,W,$],!0)}#W(k,W){return new BW({...this.#k,queryNode:N.cloneWithWhen(this.#k.queryNode,bW({isMatched:!0},k,W))})}whenNotMatched(){return this.#h([])}whenNotMatchedAnd(...k){return this.#h(k)}whenNotMatchedAndRef(k,W,$){return this.#h([k,W,$],!0)}whenNotMatchedBySource(){return this.#h([],!1,!0)}whenNotMatchedBySourceAnd(...k){return this.#h(k,!1,!0)}whenNotMatchedBySourceAndRef(k,W,$){return this.#h([k,W,$],!0,!0)}returning(k){return new O({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new O({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new O({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new O({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}#h(k,W=!1,$=!1){let M={...this.#k,queryNode:N.cloneWithWhen(this.#k.queryNode,bW({isMatched:!1,bySource:$},k,W))};return new($?BW:vh)(M)}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new O({...this.#k})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new NW(W.numAffectedRows)]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}}class BW{#k;constructor(k){this.#k=h(k)}thenDelete(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("delete"))})}thenDoNothing(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("do nothing"))})}thenUpdate(k){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok(k(new jk({queryId:this.#k.queryId,executor:qk,queryNode:o.createWithoutTable()}))))})}thenUpdateSet(...k){return this.thenUpdate((W)=>W.set(...k))}}class vh{#k;constructor(k){this.#k=h(k)}thenDoNothing(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("do nothing"))})}thenInsertValues(k){let[W,$]=KW(k);return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok(w.cloneWith(w.createWithoutInto(),{columns:W,values:$})))})}}class Pk{#k;constructor(k){this.#k=h(k)}selectFrom(k){return nk({queryId:T(),executor:this.#k.executor,queryNode:Y.createFrom(n(k),this.#k.withNode)})}selectNoFrom(k){return nk({queryId:T(),executor:this.#k.executor,queryNode:Y.cloneWithSelections(Y.create(this.#k.withNode),A(k))})}insertInto(k){return new D({queryId:T(),executor:this.#k.executor,queryNode:w.create(F(k),this.#k.withNode)})}replaceInto(k){return new D({queryId:T(),executor:this.#k.executor,queryNode:w.create(F(k),this.#k.withNode,!0)})}deleteFrom(k){return new HW({queryId:T(),executor:this.#k.executor,queryNode:Dk.create(n(k),this.#k.withNode)})}updateTable(k){return new jk({queryId:T(),executor:this.#k.executor,queryNode:o.create(n(k),this.#k.withNode)})}mergeInto(k){return new Hk({queryId:T(),executor:this.#k.executor,queryNode:N.create(fW(k),this.#k.withNode)})}with(k,W){let $=OW(k,W);return new Pk({...this.#k,withNode:this.#k.withNode?tk.cloneWithExpression(this.#k.withNode,$):tk.create($)})}withRecursive(k,W){let $=OW(k,W);return new Pk({...this.#k,withNode:this.#k.withNode?tk.cloneWithExpression(this.#k.withNode,$):tk.create($,{recursive:!0})})}withPlugin(k){return new Pk({...this.#k,executor:this.#k.executor.withPlugin(k)})}withoutPlugins(){return new Pk({...this.#k,executor:this.#k.executor.withoutPlugins()})}withSchema(k){return new Pk({...this.#k,executor:this.#k.executor.withPluginAtFront(new YW(k))})}}function Ph(){return new Pk({executor:qk})}function Ah(k,W){return new Rk({joinNode:Kk.create(k,wk(W))})}function _h(){return new Ck({overNode:xk.create()})}function Jk(k,W){if(W.length===3)return K$(k,W[0],W[1],W[2]);else if(W.length===2)return M$(k,W[0],W[1]);else if(W.length===1)return G$(k,W[0]);else throw Error("not implemented")}function M$(k,W,$){return $(Ah(k,W)).toOperationNode()}function K$(k,W,$,M){return Kk.createWithOn(k,wk(W),m($,"=",M))}function G$(k,W){return Kk.create(k,wk(W))}var mh=h({is(k){return k.kind==="OffsetNode"},create(k){return h({kind:"OffsetNode",offset:k})}});var Rh=h({is(k){return k.kind==="GroupByItemNode"},create(k){return h({kind:"GroupByItemNode",groupBy:k})}});function fh(k){return k=_(k)?k(d()):k,Gk(k).map(Rh.create)}function Tk(k,W,$){if(_(W))W=W(XW());if(!j(W))W=[W];return W.map((M)=>Ch.create(k,p(M),$))}class Z{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}or(...k){return new DW(hk.create(this.#k,L(k)))}and(...k){return new LW(x.create(this.#k,L(k)))}$castTo(){return new Z(this.#k)}$notNull(){return new Z(this.#k)}toOperationNode(){return this.#k}}class zW{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}class DW{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}or(...k){return new DW(hk.create(this.#k,L(k)))}$castTo(){return new DW(this.#k)}toOperationNode(){return Xk.create(this.#k)}}class LW{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}and(...k){return new LW(x.create(this.#k,L(k)))}$castTo(){return new LW(this.#k)}toOperationNode(){return Xk.create(this.#k)}}var Sh=h({is(k){return k.kind==="FetchNode"},create(k,W){return{kind:"FetchNode",rowCount:Q.create(k),modifier:W}}});function Ih(k,W){if(!_k(k)&&!GW(k))throw Error(`Invalid fetch row count: ${k}`);if(!H$(W))throw Error(`Invalid fetch modifier: ${W}`);return Sh.create(k,W)}function H$(k){return k==="only"||k==="with ties"}var H;class xW{#k;constructor(k){this.#k=h(k)}get expressionType(){return}get isSelectQueryBuilder(){return!0}where(...k){return new H({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new H({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}having(...k){return new H({...this.#k,queryNode:Y.cloneWithHaving(this.#k.queryNode,L(k))})}havingRef(k,W,$){return new H({...this.#k,queryNode:Y.cloneWithHaving(this.#k.queryNode,m(k,W,$))})}select(k){return new H({...this.#k,queryNode:Y.cloneWithSelections(this.#k.queryNode,A(k))})}distinctOn(k){return new H({...this.#k,queryNode:Y.cloneWithDistinctOn(this.#k.queryNode,Gk(k))})}modifyFront(k){return new H({...this.#k,queryNode:Y.cloneWithFrontModifier(this.#k.queryNode,a.createWithExpression(k.toOperationNode()))})}modifyEnd(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.createWithExpression(k.toOperationNode()))})}distinct(){return new H({...this.#k,queryNode:Y.cloneWithFrontModifier(this.#k.queryNode,a.create("Distinct"))})}forUpdate(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForUpdate",k?dk(k).map(F):void 0))})}forShare(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForShare",k?dk(k).map(F):void 0))})}forKeyShare(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForKeyShare",k?dk(k).map(F):void 0))})}forNoKeyUpdate(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForNoKeyUpdate",k?dk(k).map(F):void 0))})}skipLocked(){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("SkipLocked"))})}noWait(){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("NoWait"))})}selectAll(k){return new H({...this.#k,queryNode:Y.cloneWithSelections(this.#k.queryNode,R(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}crossJoin(...k){return this.#W("CrossJoin",k)}innerJoinLateral(...k){return this.#W("LateralInnerJoin",k)}leftJoinLateral(...k){return this.#W("LateralLeftJoin",k)}crossJoinLateral(...k){return this.#W("LateralCrossJoin",k)}crossApply(...k){return this.#W("CrossApply",k)}outerApply(...k){return this.#W("OuterApply",k)}#W(k,W){return new H({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}orderBy(...k){return new H({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}groupBy(k){return new H({...this.#k,queryNode:Y.cloneWithGroupByItems(this.#k.queryNode,fh(k))})}limit(k){return new H({...this.#k,queryNode:Y.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}offset(k){return new H({...this.#k,queryNode:Y.cloneWithOffset(this.#k.queryNode,mh.create(X(k)))})}fetch(k,W="only"){return new H({...this.#k,queryNode:Y.cloneWithFetch(this.#k.queryNode,Ih(k,W))})}top(k,W){return new H({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}union(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("union",k,!1))})}unionAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("union",k,!0))})}intersect(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("intersect",k,!1))})}intersectAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("intersect",k,!0))})}except(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("except",k,!1))})}exceptAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("except",k,!0))})}as(k){return new jh(this,k)}clearSelect(){return new H({...this.#k,queryNode:Y.cloneWithoutSelections(this.#k.queryNode)})}clearWhere(){return new H({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}clearLimit(){return new H({...this.#k,queryNode:Y.cloneWithoutLimit(this.#k.queryNode)})}clearOffset(){return new H({...this.#k,queryNode:Y.cloneWithoutOffset(this.#k.queryNode)})}clearOrderBy(){return new H({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}clearGroupBy(){return new H({...this.#k,queryNode:Y.cloneWithoutGroupBy(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new H({...this.#k})}$castTo(){return new H(this.#k)}$narrowType(){return new H(this.#k)}$assertType(){return new H(this.#k)}$asTuple(){return new Z(this.toOperationNode())}$asScalar(){return new Z(this.toOperationNode())}withPlugin(k){return new H({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile();return(await this.#k.executor.executeQuery(k)).rows}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new H({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}H=xW;function nk(k){return new xW(k)}class jh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return I.create(this.#k.toOperationNode(),J.create(this.#W))}}var e=h({is(k){return k.kind==="AggregateFunctionNode"},create(k,W=[]){return h({kind:"AggregateFunctionNode",func:k,aggregated:W})},cloneWithDistinct(k){return h({...k,distinct:!0})},cloneWithOrderBy(k,W,$=!1){let M=$?"withinGroup":"orderBy";return h({...k,[M]:k[M]?$k.cloneWithItems(k[M],W):$k.create(W)})},cloneWithFilter(k,W){return h({...k,filter:k.filter?C.cloneWithOperation(k.filter,"And",W):C.create(W)})},cloneWithOrFilter(k,W){return h({...k,filter:k.filter?C.cloneWithOperation(k.filter,"Or",W):C.create(W)})},cloneWithOver(k,W){return h({...k,over:W})}});var cW=h({is(k){return k.kind==="FunctionNode"},create(k,W){return h({kind:"FunctionNode",func:k,arguments:W})}});class b{#k;constructor(k){this.#k=h(k)}get expressionType(){return}as(k){return new Eh(this,k)}distinct(){return new b({...this.#k,aggregateFunctionNode:e.cloneWithDistinct(this.#k.aggregateFunctionNode)})}orderBy(...k){return new b({...this.#k,aggregateFunctionNode:K.cloneWithOrderByItems(this.#k.aggregateFunctionNode,B(k))})}clearOrderBy(){return new b({...this.#k,aggregateFunctionNode:K.cloneWithoutOrderBy(this.#k.aggregateFunctionNode)})}withinGroupOrderBy(...k){return new b({...this.#k,aggregateFunctionNode:e.cloneWithOrderBy(this.#k.aggregateFunctionNode,B(k),!0)})}filterWhere(...k){return new b({...this.#k,aggregateFunctionNode:e.cloneWithFilter(this.#k.aggregateFunctionNode,L(k))})}filterWhereRef(k,W,$){return new b({...this.#k,aggregateFunctionNode:e.cloneWithFilter(this.#k.aggregateFunctionNode,m(k,W,$))})}over(k){let W=_h();return new b({...this.#k,aggregateFunctionNode:e.cloneWithOver(this.#k.aggregateFunctionNode,(k?k(W):W).toOperationNode())})}$call(k){return k(this)}$castTo(){return new b(this.#k)}$notNull(){return new b(this.#k)}toOperationNode(){return this.#k.aggregateFunctionNode}}class Eh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),J.create(this.#W))}}function Oh(){let k=($,M)=>{return new Z(cW.create($,Gk(M??[])))},W=($,M)=>{return new b({aggregateFunctionNode:e.create($,M?Gk(M):void 0)})};return Object.assign(k,{agg:W,avg($){return W("avg",[$])},coalesce(...$){return k("coalesce",$)},count($){return W("count",[$])},countAll($){return new b({aggregateFunctionNode:e.create("count",R($))})},max($){return W("max",[$])},min($){return W("min",[$])},sum($){return W("sum",[$])},any($){return k("any",[$])},jsonAgg($){return new b({aggregateFunctionNode:e.create("json_agg",[V($)?F($):$.toOperationNode()])})},toJson($){return new Z(cW.create("to_json",[V($)?F($):$.toOperationNode()]))}})}var bh=h({is(k){return k.kind==="UnaryOperationNode"},create(k,W){return h({kind:"UnaryOperationNode",operator:k,operand:W})}});function Qh(k,W){return bh.create(y.create(k),f(W))}var l=h({is(k){return k.kind==="CaseNode"},create(k){return h({kind:"CaseNode",value:k})},cloneWithWhen(k,W){return h({...k,when:h(k.when?[...k.when,W]:[W])})},cloneWithThen(k,W){return h({...k,when:k.when?h([...k.when.slice(0,-1),Mk.cloneWithResult(k.when[k.when.length-1],W)]):void 0})},cloneWith(k,W){return h({...k,...W})}});class yW{#k;constructor(k){this.#k=h(k)}when(...k){return new gW({...this.#k,node:l.cloneWithWhen(this.#k.node,Mk.create(L(k)))})}}class gW{#k;constructor(k){this.#k=h(k)}then(k){return new Nh({...this.#k,node:l.cloneWithThen(this.#k.node,WW(k)?Bk(k):X(k))})}}class Nh{#k;constructor(k){this.#k=h(k)}when(...k){return new gW({...this.#k,node:l.cloneWithWhen(this.#k.node,Mk.create(L(k)))})}else(k){return new Bh({...this.#k,node:l.cloneWith(this.#k.node,{else:WW(k)?Bk(k):X(k)})})}end(){return new Z(l.cloneWith(this.#k.node,{isStatement:!1}))}endCase(){return new Z(l.cloneWith(this.#k.node,{isStatement:!0}))}}class Bh{#k;constructor(k){this.#k=h(k)}end(){return new Z(l.cloneWith(this.#k.node,{isStatement:!1}))}endCase(){return new Z(l.cloneWith(this.#k.node,{isStatement:!0}))}}var JW=h({is(k){return k.kind==="JSONOperatorChainNode"},create(k){return h({kind:"JSONOperatorChainNode",operator:k,values:h([])})},cloneWithValue(k,W){return h({...k,values:h([...k.values,W])})}});var tW=h({is(k){return k.kind==="JSONPathLegNode"},create(k,W){return h({kind:"JSONPathLegNode",type:k,value:W})}});var Uk=h({is(k){return k.kind==="JSONPathNode"},create(k){return h({kind:"JSONPathNode",inOperator:k,pathLegs:h([])})},cloneWithLeg(k,W){return h({...k,pathLegs:h([...k.pathLegs,W])})}});var Qk=h({is(k){return k.kind==="JSONReferenceNode"},create(k,W){return h({kind:"JSONReferenceNode",reference:k,traversal:W})},cloneWithTraversal(k,W){return h({...k,traversal:W})}});var Z$=/^#-\d+$/;class ik{#k;constructor(k){this.#k=k}at(k){if(typeof k!=="number"&&typeof k!=="string"||typeof k==="number"&&!Number.isInteger(k)||typeof k==="string"&&k!=="last"&&!Z$.test(k))throw Error(`Unexpected index value in .at(...): ${k}`);return this.#W("ArrayLocation",k)}key(k){return this.#W("Member",k)}#W(k,W){if(Qk.is(this.#k))return new uk(Qk.cloneWithTraversal(this.#k,Uk.is(this.#k.traversal)?Uk.cloneWithLeg(this.#k.traversal,tW.create(k,W)):JW.cloneWithValue(this.#k.traversal,Q.createImmediate(W))));return new uk(Uk.cloneWithLeg(this.#k,tW.create(k,W)))}}class uk extends ik{#k;constructor(k){super(k);this.#k=k}get expressionType(){return}as(k){return new xh(this,k)}$castTo(){return new uk(this.#k)}$notNull(){return new uk(this.#k)}toOperationNode(){return this.#k}}class xh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}var nW=h({is(k){return k.kind==="TupleNode"},create(k){return h({kind:"TupleNode",values:h(k)})}});var Y$=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],X$=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],ch=h({is(k){return k.kind==="DataTypeNode"},create(k){return h({kind:"DataTypeNode",dataType:k})}});function yh(k){if(Y$.includes(k))return!0;if(X$.some((W)=>W.test(k)))return!0;return!1}function gh(k){if(z(k))return k.toOperationNode();if(yh(k))return ch.create(k);throw Error(`invalid column data type ${JSON.stringify(k)}`)}var th=h({is(k){return k.kind==="CastNode"},create(k,W){return h({kind:"CastNode",expression:k,dataType:W})}});function XW(k=qk){function W(G,q,vk){return new Z(hW(G,q,vk))}function $(G,q){return new Z(Qh(G,q))}let M=Object.assign(W,{fn:void 0,eb:void 0,selectFrom(G){return nk({queryId:T(),executor:k,queryNode:Y.createFrom(n(G))})},case(G){return new yW({node:l.create(c(G)?void 0:f(G))})},ref(G,q){if(c(q))return new Z(t(G));return new ik(nh(G,q))},jsonPath(){return new ik(Uk.create())},table(G){return new Z(F(G))},val(G){return new Z(X(G))},refTuple(...G){return new Z(nW.create(G.map(f)))},tuple(...G){return new Z(nW.create(G.map(X)))},lit(G){return new Z(Bk(G))},unary:$,not(G){return $("not",G)},exists(G){return $("exists",G)},neg(G){return $("-",G)},between(G,q,vk){return new Z(Yk.create(f(G),y.create("between"),x.create(X(q),X(vk))))},betweenSymmetric(G,q,vk){return new Z(Yk.create(f(G),y.create("between symmetric"),x.create(X(q),X(vk))))},and(G){if(j(G))return new Z(mk(G,"and"));return new Z(UW(G,"and"))},or(G){if(j(G))return new Z(mk(G,"or"));return new Z(UW(G,"or"))},parens(...G){let q=L(G);if(Xk.is(q))return new Z(q);else return new Z(Xk.create(q))},cast(G,q){return new Z(th.create(f(G),gh(q)))},withSchema(G){return XW(k.withPluginAtFront(new YW(G)))}});return M.fn=Oh(),M.eb=M,M}function d(k){return XW()}function p(k){if(z(k))return k.toOperationNode();else if(_(k))return k(d()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(k)}`)}function MW(k){if(z(k))return k.toOperationNode();else if(_(k))return k(d()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(k)}`)}function Wk(k){return ok(k)||iW(k)||_(k)}function _W(k){if(V(k))return t(k);return k.toOperationNode()}function Gk(k){if(j(k))return k.map((W)=>f(W));else return[f(k)]}function f(k){if(Wk(k))return p(k);return _W(k)}function nh(k,W){let $=t(k);if(dW(W))return Qk.create($,JW.create(y.create(W)));let M=W.slice(0,-1);if(dW(M))return Qk.create($,Uk.create(y.create(M)));throw Error(`Invalid JSON operator: ${W}`)}function t(k){if(!k.includes("."))return Ak.create(S.create(k));let $=k.split(".").map(uW);if($.length===3)return L$($);if($.length===2)return z$($);throw Error(`invalid column reference ${k}`)}function Zh(k){if(k.includes(" as ")){let[$,M]=k.split(" as ").map(uW);return I.create(t($),J.create(M))}else return t(k)}function D$(k){return S.create(k)}function R3(k){if(k.includes(" ")){let[$,M]=k.split(" ").map(uW);if(!RW(M))throw Error(`invalid order direction "${M}" next to "${$}"`);return B([$,M])[0]}else return D$(k)}function L$(k){let[W,$,M]=k;return Ak.create(S.create(M),zk.createWithSchema(W,$))}function z$(k){let[W,$]=k;return Ak.create(S.create($),zk.create(W))}function uW(k){return k.trim()}class lk{#k;constructor(k){this.#k=h(k)}get expressionType(){return}get isRawBuilder(){return!0}as(k){return new dh(this,k)}$castTo(){return new lk({...this.#k})}$notNull(){return new lk(this.#k)}withPlugin(k){return new lk({...this.#k,plugins:this.#k.plugins!==void 0?h([...this.#k.plugins,k]):h([k])})}toOperationNode(){return this.#h(this.#W())}compile(k){return this.#$(this.#W(k))}async execute(k){let W=this.#W(k);return W.executeQuery(this.#$(W))}#W(k){let W=k!==void 0?k.getExecutor():qk;return this.#k.plugins!==void 0?W.withPlugins(this.#k.plugins):W}#h(k){return k.transformQuery(this.#k.rawNode,this.#k.queryId)}#$(k){return k.compileQuery(this.#h(k),this.#k.queryId)}}function Zk(k){return new lk(k)}class dh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}get rawBuilder(){return this.#k}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}var J$=Object.assign((k,...W)=>{return Zk({queryId:T(),rawNode:v.create(k,W?.map(uh)??[])})},{ref(k){return Zk({queryId:T(),rawNode:v.createWithChild(t(k))})},val(k){return Zk({queryId:T(),rawNode:v.createWithChild(X(k))})},value(k){return this.val(k)},table(k){return Zk({queryId:T(),rawNode:v.createWithChild(F(k))})},id(...k){let W=Array(k.length+1).fill(".");return W[0]="",W[W.length-1]="",Zk({queryId:T(),rawNode:v.create(W,k.map(J.create))})},lit(k){return Zk({queryId:T(),rawNode:v.createWithChild(Q.createImmediate(k))})},literal(k){return this.lit(k)},raw(k){return Zk({queryId:T(),rawNode:v.createWithSql(k)})},join(k,W=J$`, `){let $=Array(Math.max(2*k.length-1,0)),M=W.toOperationNode();for(let G=0;G<k.length;++G)if($[2*G]=uh(k[G]),G!==k.length-1)$[2*G+1]=M;return Zk({queryId:T(),rawNode:v.createWithChildren($)})}});function uh(k){if(z(k))return k.toOperationNode();return X(k)}var l3=h({raw(k,W=[]){return h({sql:k,query:v.createWithSql(k),parameters:h(W),queryId:T()})}});
3
+ export{z as sb,S as tb,pk as ub,ah as vb,t as wb,D$ as xb,R3 as yb,rk as zb,Q as Ab,L as Bb,K as Cb,Y as Db,Vh as Eb,T as Fb,ZW as Gb,Th as Hb,QW as Ib,Pk as Jb,Oh as Kb,l as Lb,yW as Mb,gh as Nb,p as Ob,oh as Pb,F as Qb,J$ as Rb,l3 as Sb};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Jb as P,Kb as J}from"./chunk-8r2agmv2.js";import{xc as V,yc as W,zc as X}from"./chunk-xext4yvc.js";import"./chunk-69at8jm8.js";var Y=class{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}get supportsOutput(){return!0}},Z=class{#h;#j=new k;#z;#H;constructor(h){this.#h={...h}}async init(){if(this.#z=this.#h.database,this.#H=new $(this.#z),this.#h.onCreateConnection)await this.#h.onCreateConnection(this.#H)}async acquireConnection(){return await this.#j.lock(),this.#H}async beginTransaction(h){await h.executeQuery(J.raw("begin"))}async commitTransaction(h){await h.executeQuery(J.raw("commit"))}async rollbackTransaction(h){await h.executeQuery(J.raw("rollback"))}async releaseConnection(){this.#j.unlock()}async destroy(){this.#z?.close()}},$=class{#h;constructor(h){this.#h=h}executeQuery(h){let{sql:z,parameters:H}=h,j=this.#h.prepare(z).all(...H);return Promise.resolve({rows:j})}async*streamQuery(){throw Error("Streaming query is not supported by SQLite driver.")}},k=class{#h;#j;async lock(){while(this.#h!==void 0)await this.#h;this.#h=new Promise((h)=>{this.#j=h})}unlock(){let h=this.#j;this.#h=void 0,this.#j=void 0,h?.()}},w=class{#h;constructor(h){this.#h=h}async getSchemas(){return[]}async getTables(h={withInternalKyselyTables:!1}){let z=this.#h.selectFrom("sqlite_schema").where("type","=","table").where("name","not like","sqlite_%").select("name").$castTo();if(!h.withInternalKyselyTables)z=z.where("name","!=",W).where("name","!=",X);let H=await z.execute();return Promise.all(H.map(({name:j})=>this.#j(j)))}async getMetadata(h){return{tables:await this.getTables(h)}}async#j(h){let z=this.#h,H=(await z.selectFrom("sqlite_master").where("name","=",h).select("sql").$castTo().execute())[0]?.sql?.split(/[\(\),]/)?.find((j)=>j.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.[0]?.replace(/["`]/g,"");return{name:h,columns:(await z.selectFrom(P`pragma_table_info(${h})`.as("table_info")).select(["name","type","notnull","dflt_value"]).execute()).map((j)=>({name:j.name,dataType:j.type,isNullable:!j.notnull,isAutoIncrementing:j.name===H,hasDefaultValue:j.dflt_value!=null})),isView:!0}}},K=class extends V{getCurrentParameterPlaceholder(){return"?"}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}},F=class{#h;constructor(h){this.#h={...h}}createDriver(){return new Z(this.#h)}createQueryCompiler(){return new K}createAdapter(){return new Y}createIntrospector(h){return new w(h)}};export{F as NodeSqliteDialect};
2
+ import{Rb as P,Sb as J}from"./chunk-n8gsjwht.js";import{Fc as V,Gc as W,Hc as X}from"./chunk-8rcfhfq5.js";import"./chunk-txkmks1h.js";var Y=class{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}get supportsOutput(){return!0}},Z=class{#h;#j=new k;#z;#H;constructor(h){this.#h={...h}}async init(){if(this.#z=this.#h.database,this.#H=new $(this.#z),this.#h.onCreateConnection)await this.#h.onCreateConnection(this.#H)}async acquireConnection(){return await this.#j.lock(),this.#H}async beginTransaction(h){await h.executeQuery(J.raw("begin"))}async commitTransaction(h){await h.executeQuery(J.raw("commit"))}async rollbackTransaction(h){await h.executeQuery(J.raw("rollback"))}async releaseConnection(){this.#j.unlock()}async destroy(){this.#z?.close()}},$=class{#h;constructor(h){this.#h=h}executeQuery(h){let{sql:z,parameters:H}=h,j=this.#h.prepare(z).all(...H);return Promise.resolve({rows:j})}async*streamQuery(){throw Error("Streaming query is not supported by SQLite driver.")}},k=class{#h;#j;async lock(){while(this.#h!==void 0)await this.#h;this.#h=new Promise((h)=>{this.#j=h})}unlock(){let h=this.#j;this.#h=void 0,this.#j=void 0,h?.()}},w=class{#h;constructor(h){this.#h=h}async getSchemas(){return[]}async getTables(h={withInternalKyselyTables:!1}){let z=this.#h.selectFrom("sqlite_schema").where("type","=","table").where("name","not like","sqlite_%").select("name").$castTo();if(!h.withInternalKyselyTables)z=z.where("name","!=",W).where("name","!=",X);let H=await z.execute();return Promise.all(H.map(({name:j})=>this.#j(j)))}async getMetadata(h){return{tables:await this.getTables(h)}}async#j(h){let z=this.#h,H=(await z.selectFrom("sqlite_master").where("name","=",h).select("sql").$castTo().execute())[0]?.sql?.split(/[\(\),]/)?.find((j)=>j.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.[0]?.replace(/["`]/g,"");return{name:h,columns:(await z.selectFrom(P`pragma_table_info(${h})`.as("table_info")).select(["name","type","notnull","dflt_value"]).execute()).map((j)=>({name:j.name,dataType:j.type,isNullable:!j.notnull,isAutoIncrementing:j.name===H,hasDefaultValue:j.dflt_value!=null})),isView:!0}}},K=class extends V{getCurrentParameterPlaceholder(){return"?"}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}},F=class{#h;constructor(h){this.#h={...h}}createDriver(){return new Z(this.#h)}createQueryCompiler(){return new K}createAdapter(){return new Y}createIntrospector(h){return new w(h)}};export{F as NodeSqliteDialect};
@@ -1,2 +1,2 @@
1
- import{we as A}from"./chunk-gwzk0fvn.js";import{qi as z}from"./chunk-jsqsrcse.js";import{Li as v,Vi as w}from"./chunk-48yphy68.js";var B=(b)=>({queryKey:["projects",b],queryFn:async()=>{let h=await z.api.projects[":projectId"].$get({param:{projectId:b}});if(!h.ok)throw Error("Failed to fetch project");return await h.json()}}),H=w("/projects/$projectId/folders/$folderId")({loader:({context:{queryClient:b},params:{projectId:h}})=>b.ensureQueryData(B(h)),pendingComponent:()=>v(A,{})});
2
- export{B as ee,H as fe};
1
+ import{og as A}from"./chunk-7xcyn1ba.js";import{Ii as z}from"./chunk-s503pcvb.js";import{bj as v,lj as w}from"./chunk-w9p59ahz.js";var B=(b)=>({queryKey:["projects",b],queryFn:async()=>{let h=await z.api.projects[":projectId"].$get({param:{projectId:b}});if(!h.ok)throw Error("Failed to fetch project");return await h.json()}}),H=w("/projects/$projectId/folders/$folderId")({loader:({context:{queryClient:b},params:{projectId:h}})=>b.ensureQueryData(B(h)),pendingComponent:()=>v(A,{})});
2
+ export{B as me,H as ne};