gemi 0.86.1 → 0.88.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/dist/ai/Agent.d.ts +44 -2
  2. package/dist/ai/Agent.d.ts.map +1 -1
  3. package/dist/ai/AgentController.d.ts +5 -0
  4. package/dist/ai/AgentController.d.ts.map +1 -1
  5. package/dist/ai/Schema.d.ts +102 -0
  6. package/dist/ai/Schema.d.ts.map +1 -1
  7. package/dist/ai/index.d.ts +3 -3
  8. package/dist/ai/index.d.ts.map +1 -1
  9. package/dist/ai/index.js +12 -12
  10. package/dist/ai/index.js.map +5 -5
  11. package/dist/ai/signing.d.ts +34 -1
  12. package/dist/ai/signing.d.ts.map +1 -1
  13. package/dist/app/index.js +1 -1
  14. package/dist/auth/AuthController.d.ts +45 -3
  15. package/dist/auth/AuthController.d.ts.map +1 -1
  16. package/dist/auth/AuthManager.d.ts +42 -1
  17. package/dist/auth/AuthManager.d.ts.map +1 -1
  18. package/dist/auth/UserProvider.d.ts +18 -1
  19. package/dist/auth/UserProvider.d.ts.map +1 -1
  20. package/dist/auth/config.d.ts +109 -0
  21. package/dist/auth/config.d.ts.map +1 -1
  22. package/dist/auth/oneTimeCode.d.ts +99 -0
  23. package/dist/auth/oneTimeCode.d.ts.map +1 -0
  24. package/dist/auth/routes.d.ts +13 -0
  25. package/dist/auth/routes.d.ts.map +1 -1
  26. package/dist/auth/types.d.ts +8 -0
  27. package/dist/auth/types.d.ts.map +1 -1
  28. package/dist/bin/gemi.js +198 -39
  29. package/dist/bin/gemi.js.map +5 -4
  30. package/dist/bun/plugin.js +1 -1
  31. package/dist/bun/preload.js +1 -1
  32. package/dist/{chunk-swhyp0yw.js → chunk-0808z3mq.js} +2 -2
  33. package/dist/{chunk-swhyp0yw.js.map → chunk-0808z3mq.js.map} +1 -1
  34. package/dist/{chunk-d3jkypc7.js → chunk-0efykzjy.js} +3 -3
  35. package/dist/{chunk-d3jkypc7.js.map → chunk-0efykzjy.js.map} +1 -1
  36. package/dist/{chunk-zs90w6ke.js → chunk-16mnpn6c.js} +2 -2
  37. package/dist/{chunk-zs90w6ke.js.map → chunk-16mnpn6c.js.map} +1 -1
  38. package/dist/{chunk-1jcp8m8h.js → chunk-17nh5gfm.js} +2 -2
  39. package/dist/{chunk-1jcp8m8h.js.map → chunk-17nh5gfm.js.map} +1 -1
  40. package/dist/{chunk-mszy6cfw.js → chunk-3ph0aj0x.js} +2 -2
  41. package/dist/{chunk-mszy6cfw.js.map → chunk-3ph0aj0x.js.map} +1 -1
  42. package/dist/{chunk-qje4kdff.js → chunk-3rb5ht8v.js} +3 -3
  43. package/dist/{chunk-qje4kdff.js.map → chunk-3rb5ht8v.js.map} +1 -1
  44. package/dist/chunk-3w65ra1s.js +5 -0
  45. package/dist/{chunk-1yzdxv2a.js.map → chunk-3w65ra1s.js.map} +1 -1
  46. package/dist/{chunk-v8nf45gt.js → chunk-443dm19c.js} +2 -2
  47. package/dist/{chunk-v8nf45gt.js.map → chunk-443dm19c.js.map} +1 -1
  48. package/dist/{chunk-4ysar3ev.js → chunk-49v5xq8q.js} +2 -2
  49. package/dist/{chunk-4ysar3ev.js.map → chunk-49v5xq8q.js.map} +1 -1
  50. package/dist/chunk-4v4v5wkh.js +7 -0
  51. package/dist/chunk-4v4v5wkh.js.map +11 -0
  52. package/dist/{chunk-2yw23zhn.js → chunk-523t3bcz.js} +4 -4
  53. package/dist/{chunk-2yw23zhn.js.map → chunk-523t3bcz.js.map} +1 -1
  54. package/dist/{chunk-1yq1e6sb.js → chunk-56p9a7nx.js} +3 -3
  55. package/dist/{chunk-1yq1e6sb.js.map → chunk-56p9a7nx.js.map} +1 -1
  56. package/dist/{chunk-fbwe0agk.js → chunk-61rs7kxf.js} +2 -2
  57. package/dist/{chunk-fbwe0agk.js.map → chunk-61rs7kxf.js.map} +1 -1
  58. package/dist/{chunk-cbycz5z3.js → chunk-64z2zt41.js} +2 -2
  59. package/dist/{chunk-cbycz5z3.js.map → chunk-64z2zt41.js.map} +1 -1
  60. package/dist/{chunk-saqfc6vp.js → chunk-6dyt8w27.js} +4 -4
  61. package/dist/{chunk-saqfc6vp.js.map → chunk-6dyt8w27.js.map} +1 -1
  62. package/dist/{chunk-ha705bcz.js → chunk-6rc6yec4.js} +3 -3
  63. package/dist/{chunk-ha705bcz.js.map → chunk-6rc6yec4.js.map} +1 -1
  64. package/dist/{chunk-09sr33ff.js → chunk-6s6fj97j.js} +2 -2
  65. package/dist/{chunk-09sr33ff.js.map → chunk-6s6fj97j.js.map} +1 -1
  66. package/dist/{chunk-7nj2t2gm.js → chunk-6tt3ynm7.js} +2 -2
  67. package/dist/{chunk-7nj2t2gm.js.map → chunk-6tt3ynm7.js.map} +1 -1
  68. package/dist/{chunk-trdwxm5x.js → chunk-6y62ccam.js} +3 -3
  69. package/dist/{chunk-trdwxm5x.js.map → chunk-6y62ccam.js.map} +1 -1
  70. package/dist/{chunk-81v4c4b1.js → chunk-713fezaz.js} +2 -2
  71. package/dist/{chunk-81v4c4b1.js.map → chunk-713fezaz.js.map} +1 -1
  72. package/dist/{chunk-xckeyg3v.js → chunk-78gs7xvn.js} +2 -2
  73. package/dist/{chunk-xckeyg3v.js.map → chunk-78gs7xvn.js.map} +1 -1
  74. package/dist/{chunk-ndat0nf0.js → chunk-7r78cdyd.js} +2 -2
  75. package/dist/{chunk-ndat0nf0.js.map → chunk-7r78cdyd.js.map} +1 -1
  76. package/dist/chunk-86p57tjw.js +5 -0
  77. package/dist/{chunk-hmh79ezn.js.map → chunk-86p57tjw.js.map} +3 -6
  78. package/dist/{chunk-ct7wxm98.js → chunk-8dpnghvk.js} +2 -2
  79. package/dist/{chunk-ct7wxm98.js.map → chunk-8dpnghvk.js.map} +1 -1
  80. package/dist/{chunk-zf4r4kat.js → chunk-8pesk2wm.js} +2 -2
  81. package/dist/{chunk-zf4r4kat.js.map → chunk-8pesk2wm.js.map} +1 -1
  82. package/dist/{chunk-8gexb1gt.js → chunk-8r7xhy1g.js} +2 -2
  83. package/dist/{chunk-8gexb1gt.js.map → chunk-8r7xhy1g.js.map} +1 -1
  84. package/dist/{chunk-gx0x772p.js → chunk-8y08amzz.js} +2 -2
  85. package/dist/{chunk-gx0x772p.js.map → chunk-8y08amzz.js.map} +1 -1
  86. package/dist/{chunk-y7qnx8vm.js → chunk-9c1zx81w.js} +2 -2
  87. package/dist/{chunk-y7qnx8vm.js.map → chunk-9c1zx81w.js.map} +1 -1
  88. package/dist/{chunk-7c33ngqs.js → chunk-ak3yy4za.js} +2 -2
  89. package/dist/{chunk-7c33ngqs.js.map → chunk-ak3yy4za.js.map} +1 -1
  90. package/dist/{chunk-z6cgama8.js → chunk-aqtf14yz.js} +2 -2
  91. package/dist/{chunk-z6cgama8.js.map → chunk-aqtf14yz.js.map} +1 -1
  92. package/dist/{chunk-z4k18gnp.js → chunk-bsbn7qtd.js} +2 -2
  93. package/dist/{chunk-z4k18gnp.js.map → chunk-bsbn7qtd.js.map} +1 -1
  94. package/dist/{chunk-2gdhcswa.js → chunk-d1r618e8.js} +1 -1
  95. package/dist/{chunk-v4ngf77f.js → chunk-d5h5v4rj.js} +2 -2
  96. package/dist/{chunk-v4ngf77f.js.map → chunk-d5h5v4rj.js.map} +1 -1
  97. package/dist/{chunk-7n5775qx.js → chunk-e3fnjj0h.js} +2 -2
  98. package/dist/{chunk-7n5775qx.js.map → chunk-e3fnjj0h.js.map} +1 -1
  99. package/dist/chunk-efzvxta5.js +24 -0
  100. package/dist/{chunk-gs8x0k68.js.map → chunk-efzvxta5.js.map} +6 -5
  101. package/dist/{chunk-sjckrbr2.js → chunk-fkt43zw1.js} +2 -2
  102. package/dist/{chunk-sjckrbr2.js.map → chunk-fkt43zw1.js.map} +1 -1
  103. package/dist/{chunk-p7r3ecpk.js → chunk-g2bsmw1m.js} +2 -2
  104. package/dist/{chunk-9tsw1bmt.js.map → chunk-g2bsmw1m.js.map} +1 -1
  105. package/dist/{chunk-1w5a11cd.js → chunk-gzfat1x1.js} +2 -2
  106. package/dist/{chunk-1w5a11cd.js.map → chunk-gzfat1x1.js.map} +1 -1
  107. package/dist/{chunk-wwzg4dmy.js → chunk-hnbj9jx2.js} +3 -3
  108. package/dist/{chunk-wwzg4dmy.js.map → chunk-hnbj9jx2.js.map} +1 -1
  109. package/dist/{chunk-dadygfkf.js → chunk-j0fgc58k.js} +2 -2
  110. package/dist/{chunk-dadygfkf.js.map → chunk-j0fgc58k.js.map} +1 -1
  111. package/dist/{chunk-6nnq3rjj.js → chunk-j3y6pdqp.js} +2 -2
  112. package/dist/{chunk-6nnq3rjj.js.map → chunk-j3y6pdqp.js.map} +1 -1
  113. package/dist/{chunk-v2hvnxsf.js → chunk-jfgjscq6.js} +2 -2
  114. package/dist/{chunk-v2hvnxsf.js.map → chunk-jfgjscq6.js.map} +1 -1
  115. package/dist/{chunk-k5j65f2c.js → chunk-ngq4n2b3.js} +2 -2
  116. package/dist/{chunk-k5j65f2c.js.map → chunk-ngq4n2b3.js.map} +1 -1
  117. package/dist/{chunk-kmsrzbx1.js → chunk-pqydkns8.js} +2 -2
  118. package/dist/{chunk-kmsrzbx1.js.map → chunk-pqydkns8.js.map} +1 -1
  119. package/dist/{chunk-pzwyg474.js → chunk-pw95y0fx.js} +2 -2
  120. package/dist/{chunk-pzwyg474.js.map → chunk-pw95y0fx.js.map} +1 -1
  121. package/dist/{chunk-9tv5j3b2.js → chunk-pwaftx6n.js} +3 -3
  122. package/dist/{chunk-9tv5j3b2.js.map → chunk-pwaftx6n.js.map} +1 -1
  123. package/dist/{chunk-p0m3qgs5.js → chunk-q6ydpt33.js} +2 -2
  124. package/dist/{chunk-p0m3qgs5.js.map → chunk-q6ydpt33.js.map} +1 -1
  125. package/dist/{chunk-81k26w39.js → chunk-r1sj312m.js} +2 -2
  126. package/dist/{chunk-81k26w39.js.map → chunk-r1sj312m.js.map} +1 -1
  127. package/dist/{chunk-55x9kkdt.js → chunk-r78aqvne.js} +2 -2
  128. package/dist/{chunk-55x9kkdt.js.map → chunk-r78aqvne.js.map} +1 -1
  129. package/dist/{chunk-1b5s4w5f.js → chunk-r9qzgvpx.js} +2 -2
  130. package/dist/{chunk-1b5s4w5f.js.map → chunk-r9qzgvpx.js.map} +1 -1
  131. package/dist/{chunk-174jkg6d.js → chunk-rhe7s1fm.js} +3 -3
  132. package/dist/{chunk-174jkg6d.js.map → chunk-rhe7s1fm.js.map} +1 -1
  133. package/dist/{chunk-vwp1g8wh.js → chunk-rp0reqjn.js} +2 -2
  134. package/dist/{chunk-vwp1g8wh.js.map → chunk-rp0reqjn.js.map} +1 -1
  135. package/dist/{chunk-cfykfnqx.js → chunk-rw0t90pf.js} +2 -2
  136. package/dist/{chunk-cfykfnqx.js.map → chunk-rw0t90pf.js.map} +1 -1
  137. package/dist/{chunk-mk8m3ffx.js → chunk-s72y1w84.js} +2 -2
  138. package/dist/{chunk-mk8m3ffx.js.map → chunk-s72y1w84.js.map} +1 -1
  139. package/dist/{chunk-9tsw1bmt.js → chunk-t93t317r.js} +2 -2
  140. package/dist/{chunk-p7r3ecpk.js.map → chunk-t93t317r.js.map} +1 -1
  141. package/dist/{chunk-dwqh79e5.js → chunk-ttckhvew.js} +2 -2
  142. package/dist/{chunk-dwqh79e5.js.map → chunk-ttckhvew.js.map} +1 -1
  143. package/dist/{chunk-rdnm6rem.js → chunk-whjhrz97.js} +2 -2
  144. package/dist/{chunk-rdnm6rem.js.map → chunk-whjhrz97.js.map} +1 -1
  145. package/dist/{chunk-sejnmn1q.js → chunk-x85x83pa.js} +1 -1
  146. package/dist/{chunk-s046a984.js → chunk-xc90ycw2.js} +2 -2
  147. package/dist/{chunk-s046a984.js.map → chunk-xc90ycw2.js.map} +1 -1
  148. package/dist/{chunk-jhe0t7yj.js → chunk-xqyx8kzr.js} +2 -2
  149. package/dist/{chunk-jhe0t7yj.js.map → chunk-xqyx8kzr.js.map} +2 -2
  150. package/dist/{chunk-c3gzpjba.js → chunk-yafxbmy3.js} +1 -1
  151. package/dist/{chunk-pmmrhak1.js → chunk-yc3n6zhr.js} +3 -3
  152. package/dist/{chunk-pmmrhak1.js.map → chunk-yc3n6zhr.js.map} +1 -1
  153. package/dist/chunk-ymgehegb.js +17 -0
  154. package/dist/{chunk-tag4fdmj.js.map → chunk-ymgehegb.js.map} +12 -8
  155. package/dist/{chunk-m7y8d3k7.js → chunk-zf8bgrnj.js} +2 -2
  156. package/dist/{chunk-m7y8d3k7.js.map → chunk-zf8bgrnj.js.map} +1 -1
  157. package/dist/{chunk-fc2je244.js → chunk-zn5bqe6m.js} +3 -3
  158. package/dist/{chunk-fc2je244.js.map → chunk-zn5bqe6m.js.map} +1 -1
  159. package/dist/{chunk-4zj05vry.js → chunk-ztzd90gp.js} +2 -2
  160. package/dist/{chunk-4zj05vry.js.map → chunk-ztzd90gp.js.map} +1 -1
  161. package/dist/chunks/{ThemeProvider-D1kDfCwY.js → ThemeProvider-z_MW40tl.js} +126 -6
  162. package/dist/chunks/ThemeProvider-z_MW40tl.js.map +1 -0
  163. package/dist/client/ClientRouter.d.ts.map +1 -1
  164. package/dist/client/ClientRouterContext.d.ts.map +1 -1
  165. package/dist/client/ComponentContext.d.ts +8 -1
  166. package/dist/client/ComponentContext.d.ts.map +1 -1
  167. package/dist/client/MutationError.d.ts +4 -4
  168. package/dist/client/auth/useEmailCode.d.ts +36 -0
  169. package/dist/client/auth/useEmailCode.d.ts.map +1 -0
  170. package/dist/client/chunkLoadRecovery.d.ts +96 -0
  171. package/dist/client/chunkLoadRecovery.d.ts.map +1 -0
  172. package/dist/client/index.d.ts +4 -0
  173. package/dist/client/index.d.ts.map +1 -1
  174. package/dist/client/index.js +53 -4
  175. package/dist/client/index.js.map +1 -1
  176. package/dist/client/init.d.ts +9 -0
  177. package/dist/client/init.d.ts.map +1 -1
  178. package/dist/config/index.d.ts +12 -0
  179. package/dist/config/index.d.ts.map +1 -1
  180. package/dist/config/index.js +1 -1
  181. package/dist/config/index.js.map +2 -2
  182. package/dist/console/run.js +2 -2
  183. package/dist/console/run.js.map +1 -1
  184. package/dist/container/index.js +2 -2
  185. package/dist/container/index.js.map +1 -1
  186. package/dist/database/index.js +2 -2
  187. package/dist/database/index.js.map +1 -1
  188. package/dist/email/index.js +2 -2
  189. package/dist/email/index.js.map +1 -1
  190. package/dist/facades/index.js +2 -2
  191. package/dist/facades/index.js.map +1 -1
  192. package/dist/foundation/index.js +2 -2
  193. package/dist/foundation/index.js.map +1 -1
  194. package/dist/http/Error.d.ts +2 -2
  195. package/dist/http/index.js +2 -2
  196. package/dist/http/index.js.map +1 -1
  197. package/dist/i18n/dictionaryRuntime.js +2 -2
  198. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  199. package/dist/i18n/index.js +2 -2
  200. package/dist/i18n/index.js.map +1 -1
  201. package/dist/kernel/index.d.ts +2 -0
  202. package/dist/kernel/index.d.ts.map +1 -1
  203. package/dist/kernel/index.js +3 -3
  204. package/dist/kernel/index.js.map +2 -2
  205. package/dist/orm/index.js +3 -3
  206. package/dist/orm/index.js.map +1 -1
  207. package/dist/server/forwardedFor.d.ts +1 -1
  208. package/dist/server/index.js +2 -2
  209. package/dist/server/index.js.map +1 -1
  210. package/dist/server/staticAssetMiss.d.ts +7 -0
  211. package/dist/server/staticAssetMiss.d.ts.map +1 -1
  212. package/dist/services/index.d.ts +1 -1
  213. package/dist/services/index.d.ts.map +1 -1
  214. package/dist/services/index.js +3 -3
  215. package/dist/services/index.js.map +1 -1
  216. package/dist/services/queue/work.js +2 -2
  217. package/dist/services/queue/work.js.map +1 -1
  218. package/dist/services/rate-limiter/drivers/InMemoryRateLimiterDriver.d.ts +10 -1
  219. package/dist/services/rate-limiter/drivers/InMemoryRateLimiterDriver.d.ts.map +1 -1
  220. package/dist/support/index.js +2 -2
  221. package/dist/support/index.js.map +1 -1
  222. package/dist/testing/index.js +1 -1
  223. package/package.json +1 -1
  224. package/dist/chunk-1yzdxv2a.js +0 -5
  225. package/dist/chunk-gs8x0k68.js +0 -24
  226. package/dist/chunk-hmh79ezn.js +0 -5
  227. package/dist/chunk-tag4fdmj.js +0 -17
  228. package/dist/chunk-w312e9nx.js +0 -5
  229. package/dist/chunk-w312e9nx.js.map +0 -11
  230. package/dist/chunks/ThemeProvider-D1kDfCwY.js.map +0 -1
  231. /package/dist/{chunk-2gdhcswa.js.map → chunk-d1r618e8.js.map} +0 -0
  232. /package/dist/{chunk-sejnmn1q.js.map → chunk-x85x83pa.js.map} +0 -0
  233. /package/dist/{chunk-c3gzpjba.js.map → chunk-yafxbmy3.js.map} +0 -0
package/dist/orm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Aa as u4,Ba as s,Ca as M5,Da as L3,Ea as R7,Fa as I7,Ga as S0,Ha as x4,Ia as C3,Ja as N7,Ka as o0,La as U0,Ma as D9,Na as B9,Oa as P9,Pa as j9,Qa as _9,Ra as K9,Sa as Q9,Ta as U7,Ua as O7,Va as S7,za as h4}from"../chunk-7c33ngqs.js";import{Hd as Z7,Id as L0,Jd as D0,Kd as e4,Ld as f3,Md as K7,Nd as Q7,Od as T7,Pd as L7,Qd as C7}from"../chunk-ha705bcz.js";import{$d as t6,Ae as D7,Be as E3,Ce as f,De as B7,Ee as P7,Fe as j7,Ge as _7,He as w4,Rd as _,Sd as I,Td as q0,Ud as v,Vd as l6,Wd as Z0,Xd as n6,Yd as U4,Zd as o6,_d as H4,be as r6,ce as O4,de as a6,ee as e6,fe as S4,ge as P3,he as w0,ie as x3,je as v3,ke as p,le as $7,me as x0,ne as F4,oe as C0,pe as i,qe as j,re as c,ue as R,ve as q,we as m,xe as G7,ye as W7,ze as M7}from"../chunk-k5j65f2c.js";import"../chunk-1jcp8m8h.js";import{Af as P0,Bf as T3,Ff as Y7,Gf as V7,Hf as A4,If as b4,Jf as H7,Kf as E4,Lf as q4,yf as z7,zf as n0}from"../chunk-trdwxm5x.js";import{Wf as X7,Yf as J7,_f as I4}from"../chunk-1w5a11cd.js";import{tg as N4}from"../chunk-d3jkypc7.js";import"../chunk-8gexb1gt.js";import"../chunk-swhyp0yw.js";import"../chunk-9tsw1bmt.js";function K0($,Z,X,J,z,V){let Y=r($,Z),G=V0($,Y,Z,V),H=X.quoteIdent(J),W=`${H}.`,M=G.parentFields.map((C,L)=>{let N=`${W}${X.quoteIdent(r0(Y,Z,G.childFields[L]))}`,U=`${z}${X.quoteIdent(r0($,Z,C))}`;return`${N} = ${U}`}).join(" and ");if(!G.join)return{child:Y,source:`${X.quoteIdent(Y.table)} as ${H}`,correlation:M,qualifier:W};let D=`${W}${X.quoteIdent(r0(Y,Z,G.childFields[0]))}`,B=`${z}${X.quoteIdent(r0($,Z,G.parentFields[0]))}`,P=X.quoteIdent(`${J}j`);return{child:Y,source:`${X.quoteIdent(Y.table)} as ${H} join ${X.quoteIdent(G.join.table)} as ${P} on ${P}.${X.quoteIdent(G.join.childColumn)} = ${D}`,correlation:`${P}.${X.quoteIdent(G.join.parentColumn)} = ${B}`,qualifier:W}}function r0($,Z,X){let J=$.fields[X];if(!J)throw new p($.name,Z.name,`it joins on '${X}', which is not a field on ${$.name}.`);return J.column}function y($,Z,X){let J=a0($);if(typeof Z!=="object"||Z===null||Array.isArray(Z))throw g4($,X,J);let z=Object.keys(Z).filter((Y)=>Z[Y]!==void 0),V=Z;for(let Y of J){if(Y.length===1&&z.includes(Y[0]))return k4($,X,Y[0],V[Y[0]]),Y;let G=Y.join("_");if(Y.length>1&&z.includes(G)){let H=V[G];if(H&&typeof H==="object"&&!Array.isArray(H))for(let W of Y)k4($,X,`${G}.${W}`,H[W]);return Y}}throw g4($,X,J)}function U3($){if($===null||$===void 0)return!1;let Z=typeof $;if(Z!=="object")return Z!=="function"&&Z!=="symbol";if(Array.isArray($))return!1;if($ instanceof Date||ArrayBuffer.isView($))return!0;let X=Object.getPrototypeOf($);return X!==Object.prototype&&X!==null}function k4($,Z,X,J){if(J===void 0||U3(J))return;throw new I(`${Z.argument}.${X}`,Z.model,Z.operation,`A unique key takes a plain value to match, not ${J===null?"null":Array.isArray(J)?"an array":"a filter object"}. Use findFirst/findMany (or updateMany/deleteMany) to filter on ${$.name}.${X.split(".").pop()}.`)}function O3($,Z,X){y($,Z,{model:$.name,operation:X,argument:"where"})}function a0($){let Z=[];if($.primaryKey.length>0)Z.push($.primaryKey);for(let X of $.uniques)Z.push(X);return Z}function g4($,Z,X){let J=X.map((Y)=>Y.length===1?Y[0]:Y.join("_")).join(", "),V=Z.argument.startsWith("data.")?`Name it by one of those, or reach it through the ${$.name} model directly.`:`Use ${Z.operation==="delete"||Z.operation==="update"?`${Z.operation}Many`:"findFirst"} to query on anything else.`;return new _(Z.argument,Z.model,Z.operation,`${$.name} needs a unique field here. It declares: ${J}. ${V}`)}function g($,Z,X){let J=Z.castParameter($);if(!J)return c(X);return c((z,V)=>{let Y=X(z,V);if(Y===null||Y===void 0)return null;let G=f(Y);if(G==="db")return null;if(G==="json")return"null";if(G==="any")throw Error("gemi ORM bug: Prisma.AnyNull reached the parameter binder. It is a filter operand only, and both the filter and write paths are supposed to have handled it before this point.");return JSON.stringify(Y)},J)}function x($,Z,X,J){if(Z===void 0||Z===null)return null;if(typeof Z!=="object"||Array.isArray(Z))throw new I("where",$.name,X.operation,"Expected an object.");let z=[];for(let V of Object.keys(Z).sort()){let Y=Z[V];if(Y===void 0)continue;let G=(W)=>J(W)?.[V];if(V==="AND"||V==="OR"){let W=y4($,Y,X,G,V);if(W)z.push(W);continue}if(V===a){z.push(F9($,Y,X,G));continue}if(V==="NOT"){let W=y4($,Y,X,G,"AND");if(W)z.push(R(j("not "),A0(W)));continue}if(V in $.relations){let W=U9($,$.relations[V],Y,X,G);if(W)z.push(W);continue}let H=$.fields[V];if(!H){let W=S9($,V,Y,X,G);if(W){z.push(W);continue}throw new v(V,$.name,Object.keys($.fields))}z.push(q3($,H,Y,X,G))}if(z.length===0)return null;if(z.length===1)return z[0];return l(z," and ")}function U9($,Z,X,J,z){let V=h4(Z.kind),Y=O9($,Z,X,V,J),G=J.relationDepth??0,H=J.dialect,W=J.qualifier??`${H.quoteIdent($.table)}.`,M=K0($,Z,H,`_r${G}`,W,J.operation),D=M.child,B=j(M.correlation),P={...J,qualifier:M.qualifier,relationDepth:G+1},C=[];for(let L of V){if(!(L in Y))continue;let N=Y[L],U=(T)=>Y.direct?z(T):z(T)?.[L];if(N===null){C.push(S3(M,B,null,L==="is"));continue}let K=x(D,N,P,U);if(L==="every"){if(!K)continue;C.push(S3(M,B,R(j("not "),A0(K)),!0));continue}let Q=L==="none"||L==="isNot";C.push(S3(M,B,K,Q))}if(C.length===0)return null;if(C.length===1)return C[0];return l(C," and ")}function S3($,Z,X,J){let z=[j(`${J?"not ":""}exists (select 1 from ${$.source} where `),Z];if(X)z.push(j(" and "),X);return z.push(j(")")),R(...z)}function O9($,Z,X,J,z){let V=`where.${Z.name}`,Y=Z.kind==="many";if(X===null){if(Y)throw new _(V,$.name,z.operation,`${Z.name} is a to-many relation, so null is not a filter for it. Use { none: {} } for "has no related rows".`);return{is:null,direct:!0}}if(typeof X!=="object"||Array.isArray(X))throw new I(V,$.name,z.operation,Y?`Expected an object holding ${J.join(", ")}.`:"Expected an object, or null.");if(u4(X,J))return X;if(Y)throw new _(V,$.name,z.operation,`Expected one of ${J.join(", ")}. A to-many relation has no `+"single reading of a bare filter \u2014 { some: \u2026 } and { every: \u2026 } mean "+"different things.");return{is:X,direct:!0}}function S9($,Z,X,J,z){let V=a0($).find((H)=>H.length>1&&H.join("_")===Z);if(!V)return null;if(typeof X!=="object"||X===null||Array.isArray(X))throw new I(`where.${Z}`,$.name,J.operation,`Expected an object holding ${V.join(" and ")}.`);let Y=X,G=[];for(let H of V){if(Y[H]===void 0)throw new _(`where.${Z}`,$.name,J.operation,`Missing '${H}'. A composite key needs all of ${V.join(", ")}.`);if(!U3(Y[H]))throw new I(`where.${Z}.${H}`,$.name,J.operation,`A composite key takes a plain value for each of ${V.join(", ")}, not a filter, an array or null.`);G.push(q3($,$.fields[H],Y[H],J,(W)=>z(W)?.[H]))}return G.length===1?G[0]:l(G," and ")}function y4($,Z,X,J,z){let V=[];if(Array.isArray(Z))for(let Y=0;Y<Z.length;Y++){let G=x($,Z[Y],X,(H)=>J(H)?.[Y]);if(G)V.push(G)}else{let Y=x($,Z,X,J);if(Y)V.push(Y)}if(V.length===0)return z==="AND"?null:m4;if(V.length===1)return V[0];return l(V,z==="AND"?" and ":" or ")}var m4=j("false");function l($,Z){return R(j("("),q($,Z),j(")"))}function A0($){return $.text.startsWith("(")?$:l([$],"")}var b3=new Set(["equals","not","in","notIn","lt","lte","gt","gte","contains","startsWith","endsWith","mode"]),p4={lt:"<",lte:"<=",gt:">",gte:">="},a="$compositeIn",d4=Symbol("gemi.orm.compositeInFromPlanner");function c4($,Z){return{[d4]:!0,fields:$,values:Z}}function F9($,Z,X,J){let{dialect:z}=X,Y=A9($,Z,X).map((H)=>{let W=$.fields[H];if(!W)throw new v(H,$.name,Object.keys($.fields));return W}),G=Y.map((H)=>`${X.qualifier??""}${z.quoteIdent(H.column)}`);return z.compositeIn(G,Y.map((H)=>H.type),(H)=>J(H).values)}function A9($,Z,X){let J=()=>{throw new v(a,$.name,Object.keys($.fields))};if(typeof Z!=="object"||Z===null||Array.isArray(Z))return J();if(Z[d4]!==!0)return J();let z=(G)=>{throw new _(a,$.name,X.operation,G)},{fields:V,values:Y}=Z;if(!Array.isArray(V)||V.length===0)return z(`the planner built a '${a}' with no fields.`);if(!V.every((G)=>typeof G==="string"))return z(`the planner built a '${a}' with a non-string field.`);if(!Array.isArray(Y))return z(`the planner built a '${a}' with no values.`);if(!Y.every((G)=>Array.isArray(G)&&G.length===V.length))return z(`the planner built a '${a}' whose tuples do not all have ${V.length} value(s).`);return V}var b9=["equals","has","hasEvery","hasSome","isEmpty"],F3=new Set(b9);function E9($,Z,X,J,z,V){let{dialect:Y}=z;if(T0($,Z,`where.${Z.name}`,z.operation,Y),Array.isArray(J))throw new I(`where.${Z.name}`,$.name,z.operation,`'${Z.name}' is a scalar list, and a bare array is not a filter on `+"one \u2014 Prisma rejects it here too. Say which comparison you mean: "+`{ ${Z.name}: { equals: [...] } } for the whole list, or { ${Z.name}: { hasEvery: [...] } } for "contains all of these". A bare array *is* accepted as a value in \`data\`.`);if(!w3(J))throw new I(`where.${Z.name}`,$.name,z.operation,`'${Z.name}' is a scalar list. Expected an object holding ${[...F3].sort().join(", ")}; received ${J===null?"null":typeof J}.`);let G=J,H=[];for(let W of Object.keys(G).sort()){let M=G[W];if(M===void 0)continue;if(!F3.has(W))throw new I(`where.${Z.name}.${W}`,$.name,z.operation,`'${Z.name}' is a scalar list, and a list filter takes ${[...F3].sort().join(", ")}. The scalar operators \u2014 `+`${[...b3].sort().join(", ")} \u2014 apply to a single value and `+"Prisma does not offer them here.");let D=(B)=>V(B)?.[W];H.push(q9($,Z,X,W,M,z,D))}if(H.length===0)return j("true");if(H.length===1)return H[0];return l(H," and ")}function q9($,Z,X,J,z,V,Y){let{dialect:G}=V;if(J==="equals")return w9($,Z,X,z,V,Y);if(J==="isEmpty"){if(typeof z!=="boolean")throw new I(`where.${Z.name}.isEmpty`,$.name,V.operation,`Expected true or false, received ${z===null?"null":typeof z}.`);return G.listIsEmpty(X,z)}if(J==="has"){let W=x9(Z);return G.listHas(X,g(W,G,Q0(W,G,Y)))}if(!Array.isArray(z))throw new I(`where.${Z.name}.${J}`,$.name,V.operation,`Expected an array, received ${z===null?"null":typeof z}.`);let H=g(Z,G,Q0(Z,G,Y));return J==="hasEvery"?G.listHasEvery(X,H):G.listHasSome(X,H)}function w9($,Z,X,J,z,V){let{dialect:Y}=z;if(J===null)return j(`${X} is null`);if(!Array.isArray(J))throw new I(`where.${Z.name}.equals`,$.name,z.operation,`'${Z.name}' is a scalar list, so it compares against an array. Received ${typeof J}. For "is this element present", use { ${Z.name}: { has: \u2026 } }.`);return R(j(`${X} = `),g(Z,Y,Q0(Z,Y,V)))}function x9($){return{...$,isList:!1}}function T0($,Z,X,J,z){if(z.listFilters.size>0)return;throw new _(X,$.name,J,`'${Z.name}' is a scalar list, and ${z.name} has no array type to hold one. Prisma refuses the column itself on ${z.name} \u2014 `+'"the current connector does not support lists of primitive types" \u2014 so '+`this is a difference between the databases rather than a gap in the ORM. The generated artifact is dialect-agnostic, which is why this surfaces here rather than at \`prisma generate\`: the schema was generated against Postgres and DATABASE_URL names a ${z.name} database, which has no '${Z.column}' column either. It works on postgres.`)}var v9=["equals","not","string_contains","string_starts_with","string_ends_with","array_contains","lt","lte","gt","gte"],A3=new Set(v9);function f9($,Z,X,J,z,V){let{dialect:Y}=z;if(Z.type!=="Json")throw new _(`${Z.name}.path`,$.name,z.operation,`A 'path' filter reads inside a JSON document, and '${Z.name}' is a ${Z.type} column.`);h9($,Z,J.path,z);let G=(M)=>V(M)?.path,H=Object.keys(J).filter((M)=>M!=="path"&&J[M]!==void 0).sort();if(H.length===0)throw new _(`${Z.name}.path`,$.name,z.operation,`A 'path' needs a filter beside it \u2014 ${[...A3].sort().join(", ")}. Prisma refuses a bare path too.`);let W=[];for(let M of H){if(!A3.has(M))throw new _(`${Z.name}.${M}`,$.name,z.operation,`A JSON path filter takes ${[...A3].sort().join(", ")}.`);if(!Y.jsonFilters.has(M))throw new _(`${Z.name}.${M}`,$.name,z.operation,`'${M}' on a JSON path is not available on ${Y.name}. Prisma refuses it here too, so this is a difference between the databases rather than a gap in the ORM. It works on postgres.`);let D=J[M],B=D===null?"json":f(D);if(B&&(M==="equals"||M==="not")){W.push(k9(B,X,G,Z,Y,M==="not"));continue}if(B&&D!==null){let P=M==="array_contains"?"'array_contains' tests containment against a document, and a sentinel is not one":`'${M}' compares an extracted value against a scalar, and a sentinel is not one`;throw new I(`where.${Z.name}.${M}`,$.name,z.operation,`${b0(B)} asks which kind of null a value is, which `+`only 'equals' and 'not' can express \u2014 ${P}. Prisma refuses it under this operator too. Write { ${Z.name}: { path: [\u2026], equals: ${b0(B)} } }, `+"or filter the column itself \u2014 "+`{ ${Z.name}: { equals: ${b0(B)} } }.`)}if(s4(D))throw new I(`where.${Z.name}.${M}`,$.name,z.operation,"Prisma.AnyNull is a question rather than a value \u2014 'either kind of "+"null' \u2014 so it cannot appear inside a document. Ask it directly: "+`{ ${Z.name}: { path: [\u2026], equals: Prisma.AnyNull } }.`);g9(M,D,$,Z,z),W.push(y9(M,X,G,Z,Y,(P)=>V(P)?.[M]))}return W.length===1?W[0]:l(W," and ")}function k9($,Z,X,J,z,V){let Y=()=>R(z.jsonValueAt(Z,X),j(V?" is not null":" is null")),G=()=>R(z.jsonValueAt(Z,X),j(V?" <> ":" = "),g(J,z,()=>z.encode(E3,J)));if($==="db")return Y();if($==="json")return G();return l([G(),Y()],V?" and ":" or ")}function g9($,Z,X,J,z){let V=$==="string_contains"||$==="string_starts_with"||$==="string_ends_with";if(V&&typeof Z!=="string")throw new I(`where.${J.name}.${$}`,X.name,z.operation,`Expected a string, received ${Z===null?"null":typeof Z}. Prisma raises here too \u2014 without this the pattern becomes `+`'%${String(Z)}%', which runs and returns the wrong rows.`);if(Z===null)throw new I(`where.${J.name}.${$}`,X.name,z.operation,$==="array_contains"?"null cannot be tested for containment through a JSON path: the operand binds as SQL NULL rather than as the JSON value, and "+"'x @> NULL' is NULL rather than true \u2014 the query would run and "+`match nothing. A null *inside* the document is an ordinary value and still compiles: { ${J.name}: { path: [\u2026], array_contains: [null] } }.`:`null cannot be compared through a JSON path with '${$}', which `+"compares the extracted value as a number \u2014 the comparison against "+`NULL is NULL rather than true, so the query would run and match nothing. Prisma refuses it here too. For "the value at this path is a JSON null", use equals or not: { ${J.name}: { path: [\u2026], equals: null } }.`);if($==="array_contains"||V)return;if(typeof Z==="object")throw new _(`where.${J.name}.${$}`,X.name,z.operation,`'${$}' on a JSON path compares the extracted value as a scalar, so `+"an object or array operand cannot be expressed \u2014 it would bind as "+`'${String(Z)}' and match nothing. Prisma accepts one here; gemi does not yet. Use array_contains for containment, or narrow the path until it names a scalar.`)}function y9($,Z,X,J,z,V){if($==="array_contains")return z.jsonArrayContains(Z,X,V);let Y=$==="string_contains"||$==="string_starts_with"||$==="string_ends_with",G=z.jsonExtract(Z,X,!0);if(Y){let D=$==="string_contains"?(B)=>`%${B}%`:$==="string_starts_with"?(B)=>`${B}%`:(B)=>`%${B}`;return R(j("("),G,j(") like "),c((B,P)=>{let C=V(B,P);return C===null||C===void 0?null:D(String(C))}))}let H=$==="equals"?"=":$==="not"?"<>":p4[$],W=$!=="equals"&&$!=="not",M=W?R(j("cast(("),G,j(") as real)")):R(j("("),G,j(")"));return R(M,j(` ${H} `),c((D,B)=>{let P=V(D,B);if(P===null||P===void 0)return null;if(W)return Number(P);return z.jsonComparesAsText?String(P):P}))}function h9($,Z,X,J){let{dialect:z}=J,V=z.jsonPathSyntax==="array"?"array":"jsonpath",Y=Array.isArray(X)?"array":typeof X==="string"?"jsonpath":"other";if(Array.isArray(X)&&X.length===0||X==="")throw new _(`${Z.name}.path`,$.name,J.operation,`A JSON path cannot be empty. ${z.jsonPathSyntax==="array"?`On ${z.name} an empty array selects the whole document, `+"which is a filter on the column rather than on a path \u2014 write "+`{ ${Z.name}: { equals: \u2026 } } if that is what you meant.`:`On ${z.name} an empty string raises inside json_extract.`}`);if(Y===V){if(V!=="array")return;let H=X.findIndex((D)=>typeof D!=="string");if(H===-1)return;let W=X[H],M=W===null?"null":W===void 0?"undefined":Array.isArray(W)?"an array":typeof W==="object"?"an object":`a ${typeof W}`;throw new _(`${Z.name}.path`,$.name,J.operation,`A JSON path is an array of strings, and path[${H}] is ${M}. `+(typeof W==="number"?'An array index is a key too \u2014 write ["items", "0"] rather than '+`["items", 0]; it reaches the same element, because ${z.name} takes the path as text. Prisma's path is string[] and its client refuses a number here too.`:"Prisma's path is string[] too."))}throw new _(`${Z.name}.path`,$.name,J.operation,z.jsonPathSyntax==="array"?`On ${z.name} a JSON path is an array of keys \u2014 ["a", "b"] \u2014 `+"not a JSONPath string. Prisma splits them the same way, and refuses the other form on each database.":`On ${z.name} a JSON path is a JSONPath string \u2014 "$.a.b" \u2014 not `+"an array of keys. Prisma splits them the same way, and refuses the other form on each database.")}function q3($,Z,X,J,z){let{dialect:V}=J,Y=`${J.qualifier??""}${V.quoteIdent(Z.column)}`,G=f(X);if(G)throw new I(`where.${Z.name}`,$.name,J.operation,`${b0(G)} is not a filter on `+"its own \u2014 Prisma rejects it here too. Write it as an explicit "+`comparison: { ${Z.name}: { equals: ${b0(G)} } }.`);if(Z.isList)return E9($,Z,Y,X,J,z);if(!w3(X))return e0(Y,Z,X,V,z);let H=X,W=Object.keys(H).sort();if(H.path!==void 0)return f9($,Z,Y,H,J,z);let M=H.mode==="insensitive";if(H.mode!==void 0&&H.mode!=="default"){if(!M)throw new I(`mode: ${JSON.stringify(H.mode)}`,$.name,J.operation,"Prisma takes 'default' or 'insensitive'.");if(!V.supportsInsensitiveMode)throw new _('mode: "insensitive"',$.name,J.operation,`The ${V.name} dialect cannot express it \u2014 Prisma rejects it `+"here too. Note SQLite's LIKE is already case-insensitive for ASCII.")}let D=[];for(let B of W){let P=H[B];if(P===void 0||B==="mode")continue;if(!b3.has(B))throw new I(`where.${Z.name}.${B}`,$.name,J.operation,`A scalar filter takes ${[...b3].sort().join(", ")}.`);if(B!=="equals"&&B!=="not"&&s4(P))throw new I(`where.${Z.name}.${B}`,$.name,J.operation,`Prisma.AnyNull means 'either kind of null', which only 'equals' and 'not' can express. Write { ${Z.name}: { equals: Prisma.AnyNull } }, or name the one you mean with Prisma.DbNull or Prisma.JsonNull.`);let C=(L)=>z(L)?.[B];switch(B){case"equals":D.push(e0(Y,Z,P,V,C));break;case"not":D.push(u9($,Z,P,J,C,Y));break;case"in":case"notIn":D.push(p9($,Y,Z,P,J,C,B==="notIn"));break;case"lt":case"lte":case"gt":case"gte":D.push(R(j(`${Y} ${p4[B]} `),g(Z,V,Q0(Z,V,C))));break;case"contains":case"startsWith":case"endsWith":if(typeof P!=="string")throw new I(`where.${Z.name}.${B}`,$.name,J.operation,`Expected a string, received ${P===null?"null":typeof P}.`);if(Z.type!=="String")throw new _(`where.${Z.name}.${B}`,$.name,J.operation,`'${Z.name}' is a ${Z.type}, and ${B} only applies to strings.`);D.push(V.like(Y,M,d9(B,C)));break}}if(D.length===0)return j("true");if(D.length===1)return D[0];return l(D," and ")}function b0($){return`Prisma.${$==="db"?"DbNull":$==="json"?"JsonNull":"AnyNull"}`}function s4($){if(f($)==="any")return!0;return Array.isArray($)&&$.some((Z)=>f(Z)==="any")}function u9($,Z,X,J,z,V){if(X===null||f(X)==="db")return j(`${V} is not null`);if(f(X)==="json")return R(j("not "),A0(e0(V,Z,X,J.dialect,z)));if(f(X)==="any")return R(j("not "),A0(e0(V,Z,X,J.dialect,z)));if(!w3(X))return R(j(`${V} <> `),g(Z,J.dialect,Q0(Z,J.dialect,z)));let Y=q3($,Z,X,J,z);return R(j("not "),A0(Y))}function e0($,Z,X,J,z){if(X===null||f(X)==="db")return j(`${$} is null`);if(f(X)==="any")return l([j(`${$} is null`),m9($,Z,J)]," or ");return R(j(`${$} = `),g(Z,J,Q0(Z,J,z)))}function m9($,Z,X){return R(j(`${$} = `),g(Z,X,()=>X.encode(E3,Z)))}function p9($,Z,X,J,z,V,Y){let{dialect:G}=z;if(!Array.isArray(J))throw new I(`where.${X.name}.${Y?"notIn":"in"}`,$.name,z.operation,"Expected an array.");if(J.length===0)return Y?j("true"):m4;return G.inList(Z,Y,J.length,(H)=>{return V(H).map((M)=>G.encode(M,X))})}function d9($,Z){return(X)=>{let J=String(Z(X));if($==="contains")return`%${J}%`;if($==="startsWith")return`${J}%`;return`%${J}`}}function Q0($,Z,X){return(J)=>Z.encode(X(J),$)}function w3($){return typeof $==="object"&&$!==null&&!Array.isArray($)&&!($ instanceof Date)&&!ArrayBuffer.isView($)}function i4($,Z,X,J,z,V,Y){let G=`orderBy.${Z.name}`;if(typeof X!=="object"||X===null||Array.isArray(X))throw new I(G,$.name,J,Z.kind==="many"?'Expected { _count: "asc" | "desc" }.':`Expected an object naming one field of ${Z.model}.`);let H=X,W=Object.keys(H).filter((L)=>L!=="where");if(W.length!==1)throw new _(G,$.name,J,W.length===0?"Name the field to order by.":`Name exactly one field to order by; got ${W.join(", ")}. `+"Order by several with an array: [{ a: \u2026 }, { b: \u2026 }].");let[M]=W,D=K0($,Z,z,`_o${Y}`,`${z.quoteIdent($.table)}.`,J),B=c9($,Z,D.child,M,H[M],J,D.qualifier,z),P=x(D.child,H.where,{dialect:z,operation:J,qualifier:D.qualifier},(L)=>V(L)?.where),C=[j(`(select ${B.expression} from ${D.source} where ${D.correlation}`)];if(P)C.push(j(" and "),P);return C.push(j(")")),{expression:R(...C),direction:B.direction,nulls:B.nulls}}function c9($,Z,X,J,z,V,Y,G){let H=`orderBy.${Z.name}.${J}`,{direction:W,nulls:M}=s9($,H,z,V);if(J===s){if(Z.kind!=="many")throw new _(H,$.name,V,`${Z.name} is a to-one relation, so its count is 0 or 1. Order by one of ${X.name}'s fields instead.`);return{expression:"count(*)",direction:W,nulls:M}}if(Z.kind==="many")throw new _(H,$.name,V,`${Z.name} is a to-many relation, so ordering by '${J}' has no single answer for a parent with several children. Only `+"{ _count: \u2026 } is supported.");let D=X.fields[J];if(!D)throw new _(H,$.name,V,`'${J}' is not a field on ${X.name}. Known fields: ${Object.keys(X.fields).join(", ")}.`);return{expression:`${Y}${G.quoteIdent(D.column)}`,direction:W,nulls:M}}function s9($,Z,X,J){if(X==="asc"||X==="desc")return{direction:X};if(typeof X==="object"&&X!==null){let{sort:z,nulls:V}=X;if(z!=="asc"&&z!=="desc")throw new I(Z,$.name,J,'Expected "asc" or "desc".');if(V===void 0)return{direction:z};if(V!=="first"&&V!=="last")throw new _(`${Z}.nulls`,$.name,J,'Expected "first" or "last".');return{direction:z,nulls:V}}throw new _(Z,$.name,J,'Expected "asc", "desc", or { sort, nulls }.')}var i9=new Set(["asc","desc"]),l9=new Set(["first","last"]);function H0($,Z,X,J){if(Z===void 0||Z===null)return[];let z=Array.isArray(Z),V=z?Z:[Z],Y=[];for(let G=0;G<V.length;G++){let H=V[G],W=(M)=>{let D=J?.locate(M);return z?D?.[G]:D};if(typeof H!=="object"||H===null)throw new I("orderBy",$.name,X,"Expected an object or an array of objects.");for(let[M,D]of Object.entries(H)){if(D===void 0)continue;if(M in $.relations){if(!J)throw new _(`orderBy.${M}`,$.name,X,"Ordering by a relation is not implemented here.");let P=i4($,$.relations[M],D,X,J.dialect,(C)=>W(C)?.[M],Y.length);Y.push({column:M,direction:P.direction,...P.nulls?{nulls:P.nulls}:{},expression:P.expression});continue}let B=$.fields[M];if(!B)throw new v(M,$.name,Object.keys($.fields));Y.push({column:B.column,...l4($,M,D,X)})}}return Y}function l4($,Z,X,J){if(typeof X==="string"){if(!i9.has(X))throw new I(`orderBy.${Z}: ${JSON.stringify(X)}`,$.name,J,'Expected "asc" or "desc".');return{direction:X}}if(typeof X==="object"&&X!==null){let{sort:z,nulls:V}=X,Y=l4($,Z,z,J).direction;if(V===void 0)return{direction:Y};if(typeof V!=="string"||!l9.has(V))throw new _(`orderBy.${Z}.nulls: ${JSON.stringify(V)}`,$.name,J,'Expected "first" or "last".');return{direction:Y,nulls:V}}throw new _(`orderBy.${Z}`,$.name,J,'Expected "asc", "desc", or { sort, nulls }.')}function $3($){return $.map((Z)=>({...Z,direction:Z.direction==="asc"?"desc":"asc",...Z.nulls?{nulls:Z.nulls==="first"?"last":"first"}:{}}))}function n($,Z,X){if($.length===0)return null;return q($.map((J)=>{let z=` ${J.direction}`+(J.nulls?` nulls ${J.nulls}`:"");if(J.expression)return q([J.expression,j(z)],"");return j(`${X??""}${Z.quoteIdent(J.column)}${z}`)}),", ")}function Z3($,Z,X,J,z){if(typeof z!=="number"||!Number.isInteger(z))throw new I(X,$,Z,`Expected an integer, got ${JSON.stringify(z)}.`);if(J==="skip"&&z<0)throw new I(X,$,Z,"A 'skip' counts rows to pass over, so it cannot be negative. Prisma rejects one too.")}function M0($,Z,X,J,z,V=!1){if(X?.take!==void 0)Z3($.name,Z,"take","take",X.take);if(X?.skip!==void 0)Z3($.name,Z,"skip","skip",X.skip);let Y=V?1:X?.take,G=X?.skip,H=z;if((Y!==void 0||G!==void 0)&&H.length===0&&!V)H=$.primaryKey.map((P)=>({column:$.fields[P]?.column??P,direction:"asc"}));let M=typeof Y==="number"&&Y<0;if(M)H=$3(H);let D=Y===void 0?null:V?()=>1:(P)=>Math.abs(Number(P?.take)),B=G===void 0?null:(P)=>Number(P?.skip);return{clause:J.paginate(D,B),terms:H,reversed:M}}function e($,Z,X){let J=Z?.select,z=Z?.omit;if(J!==void 0&&Z?.include!==void 0)throw new _("select + include",$.name,X,"Prisma allows only one of them on the same query.");if(J!==void 0&&z!==void 0)throw new _("select + omit",$.name,X,"'select' names what to keep and 'omit' what to drop, so the two describe different column lists. Prisma allows only one of them on "+"the same query. Drop the 'omit' \u2014 a 'select' already excludes "+"everything it does not name.");if(J===void 0||J===null)return n9($,z,X);if(typeof J!=="object"||Array.isArray(J))throw new I("select",$.name,X,"Expected an object.");let V=[];for(let[G,H]of Object.entries($.fields))if(J[G]===!0)V.push(H);let Y=0;for(let G of Object.keys(J)){let H=J[G];if(H===void 0)continue;if(G in $.relations){if(H!==!1)Y++;continue}if(G===s){if(H!==!1)Y++;continue}if(!(G in $.fields))throw new v(G,$.name,Object.keys($.fields));if(typeof H!=="boolean")throw new I(`select.${G}`,$.name,X,"Expected true or false.")}if(V.length===0&&Y===0)throw new _("select",$.name,X,"At least one field must be selected.");return V}function n9($,Z,X){if(Z===void 0||Z===null)return Object.values($.fields);if(typeof Z!=="object"||Array.isArray(Z))throw new I("omit",$.name,X,"Expected an object of fields.");let J=new Set;for(let V of Object.keys(Z)){let Y=Z[V];if(Y===void 0)continue;if(V in $.relations)throw new _(`omit.${V}`,$.name,X,`'${V}' is a relation, not a column. A relation is already absent unless an 'include' asks for it.`);if(!(V in $.fields))throw new v(V,$.name,Object.keys($.fields));if(typeof Y!=="boolean")throw new I(`omit.${V}`,$.name,X,"Expected true or false.");if(Y)J.add(V)}let z=Object.values($.fields).filter((V)=>!J.has(V.name));if(z.length===0)throw new _("omit",$.name,X,`It omits every field on ${$.name}, which leaves no column to select. Prisma rejects that too.`);return z}function X3($,Z,X){if(X.length===0)return{fields:Z};let J=new Set(Z.map((Y)=>Y.name)),z=X.filter((Y)=>!J.has(Y));if(z.length===0)return{fields:Z};let V=new Set([...J,...z]);return{fields:Object.values($.fields).filter((Y)=>V.has(Y.name)),hidden:z}}var n4=new Set(["where","orderBy","select","omit","include","take","skip"]),o4=new Set(["where","select","omit","include"]),Y3=10;function v0($){return[...new Set($.map((Z)=>Z.strategy))].sort()}function R0($,Z,X,J,z=G0){let V=f0($,Z,J);if(V.length===0)return{plans:[],keyFields:[]};let Y=[],G=new Set;for(let H of V){Z5($,H,J);let W=z5($,H);X5(W,H.node,J,2);let M=z.plan({parent:$,child:W,relation:H.relation,as:H.as,node:H.node,locate:H.locate,dialect:X,operation:J});Y.push(M);for(let D of M.parentFields)G.add(D)}return{plans:Y,keyFields:[...G]}}async function V3($,Z,X,J,z){let V=Array.isArray(X)?X:X===null||X===void 0?[]:[X];if(V.length===0)return;for(let Y of $){if(Y.root)continue;await Y.load(V,J,z)}if(Z&&Z.length>0)for(let Y of V)for(let G of Z)delete Y[G]}function f0($,Z,X){if(Z===void 0||Z===null)return[];let{include:J,select:z}=Z;$5($,J,z,X);let V=[];if(J!==void 0&&J!==null){if(typeof J!=="object"||Array.isArray(J))throw new I("include",$.name,X,"Expected an object.");for(let Y of Object.keys(J).sort()){let G=J[Y];if(G===void 0||G===!1)continue;if(Y===s)continue;let H=$.relations[Y];if(!H)throw new w0(Y,$.name,Object.keys($.relations));V.push({as:Y,relation:H,node:G,locate:(W)=>W?.include?.[Y]})}return V}if(z!==void 0&&z!==null&&typeof z==="object")for(let Y of Object.keys(z).sort()){let G=z[Y];if(G===void 0||G===!1)continue;let H=$.relations[Y];if(!H)continue;V.push({as:Y,relation:H,node:G,locate:(W)=>W?.select?.[Y]})}return V}function $5($,Z,X,J,z){if(Z===void 0||X===void 0)return;throw new _(z?`${z}: select + include`:"select + include",$.name,J,"Prisma allows only one of them on the same query, at any level.")}function Z5($,Z,X){let J=Z.node;if(J===!0)return;if(typeof J!=="object"||J===null||Array.isArray(J))throw new I(Z.as,$.name,X,"Expected true or an object of relation arguments.");let z=J;$5($,z.include,z.select,X,Z.as);let V=Z.relation.kind==="many";for(let Y of Object.keys(z).sort()){if(z[Y]===void 0)continue;if(V&&(Y==="take"||Y==="skip")){o9($,Z,X,Y,z[Y]);continue}if(V?n4.has(Y):o4.has(Y))continue;if(Y==="lock")throw new q0(`${Z.as}.lock`,$.name,X,"'lock' locks the rows of the model being queried, not an included relation's. Lock the related rows with their own locking read in the same transaction.");if(Y==="orderBy"&&!V)throw new _(`${Z.as}.orderBy`,$.name,X,"Prisma does not accept 'orderBy' on a to-one relation \u2014 there is at "+"most one row to order.");if(Y==="take"||Y==="skip")throw new _(`${Z.as}.${Y}`,$.name,X,`Prisma does not accept '${Y}' on a to-one relation.`);throw new _(`${Z.as}.${Y}`,$.name,X,`A relation node takes ${[...V?n4:o4].sort().join(", ")}.`)}}function o9($,Z,X,J,z){Z3($.name,X,`${Z.as}.${J}`,J,z)}function k3($,Z){let X=$.node;if(typeof X!=="object"||X===null||Array.isArray(X))return;for(let J of["take","skip"]){if(X[J]===void 0)continue;throw new _(`${$.as}.${J}`,$.parent.name,$.operation,`A '${J}' inside a to-many relation is per parent, and the batched `+"relation planner serves every parent from one query \u2014 so the only "+`limit it could emit would page every parent's children as one set. Only the lateral join strategy can express it, by paginating inside a subquery that already runs once per parent row, and it needs Postgres: ${Z}. Load '${$.as}' as its own query, or narrow it with 'where'.`)}}function X5($,Z,X,J){if(typeof Z!=="object"||Z===null||Array.isArray(Z))return;if(Z.select!==void 0)e($,Z,X);let z=f0($,Z,X);if(z.length===0)return;if(J>Y3)throw new x3($.name,Y3);for(let V of z)Z5($,V,X),X5(z5($,V),V.node,X,J+1)}function J5($,Z,X,J){if($.parentFields.length!==1)throw new _(X.name,Z.name,J,`${X.name} joins on ${$.parentFields.length} fields (${$.parentFields.join(", ")}), and it is planned through a join table, which links two models by a single primary key each side. Prisma does not build an implicit many-to-many over a composite key.`);return{parentField:$.parentFields[0],childField:$.childFields[0],join:$.join}}function V0($,Z,X,J){if(X.joinTable)return r9($,Z,X);if(X.from.length>0)return t4($,X,X.from,X.to,J);let z=t9($,Z,X);if(z.from.length===0)throw new p($.name,X.name,`neither ${$.name}.${X.name} nor ${Z.name}.${z.name} holds the foreign key.`);return t4($,X,z.to,z.from,J)}function t4($,Z,X,J,z){if(X.length===0)throw new _(Z.name,$.name,z,`${Z.name} names no join fields.`);if(X.length!==J.length)throw new p($.name,Z.name,`it joins ${X.length} field(s) to ${J.length}: ${X.join(", ")} against ${J.join(", ")}.`);return{parentFields:X,childFields:J}}function t9($,Z,X){let J=Object.values(Z.relations).filter((z)=>z.relationName===X.relationName&&!(Z.name===$.name&&z.name===X.name));if(J.length!==1)throw new p($.name,X.name,J.length===0?`${Z.name} declares no relation named '${X.relationName}'.`:`${Z.name} declares ${J.length} relations named '${X.relationName}'.`);return J[0]}function r9($,Z,X){let{table:J,a:z,b:V}=X.joinTable;if(z===V){let G=X.joinTable.ownerColumn;if(!G)throw new _(X.name,$.name,"include",`${X.name} is a self-referential implicit many-to-many, and the generated artifact predates support for one. Re-run \`prisma generate\`.`);return{parentFields:[J3($,X)],childFields:[J3(Z,X)],join:{table:J,parentColumn:G,childColumn:G==="A"?"B":"A"}}}if($.name!==z&&$.name!==V)throw new p($.name,X.name,`the join table '${J}' connects ${z} and ${V}, neither of which is ${$.name}.`);let Y=$.name===z?"A":"B";return{parentFields:[J3($,X)],childFields:[J3(Z,X)],join:{table:J,parentColumn:Y,childColumn:Y==="A"?"B":"A"}}}function J3($,Z){if($.primaryKey.length!==1)throw new p($.name,Z.name,`an implicit many-to-many joins on ${$.name}'s primary key, which has ${$.primaryKey.length} fields.`);return $.primaryKey[0]}function z3($,Z,X){let J=$.fields[X];if(!J)throw new p($.name,Z.name,`it joins on '${X}', which is not a field on ${$.name}.`);return J}function z5($,Z){return r($,Z.relation,Z.as)}function r($,Z,X=Z.name){let J=Z.model;if(!L0(J))throw new v3($.name,X,J,e4());let z=D0(J)?.$schema;if(!z)throw new x0(J);return z}var r4="batched",G0={name:r4,plan($){k3($,"this query planned with the batched strategy");let Z=V0($.parent,$.child,$.relation,$.operation);for(let V of Z.parentFields)a4($.parent,$.relation,z3($.parent,$.relation,V));for(let V of Z.childFields)a4($.child,$.relation,z3($.child,$.relation,V));let X=z3($.parent,$.relation,Z.parentFields[0]),J=z3($.child,$.relation,Z.childFields[0]),z=$.relation.kind==="many";return{as:$.as,model:$.relation.model,kind:$.relation.kind,parentFields:Z.parentFields,strategy:r4,load(V,Y,G){let H={parentKeyField:X,childKeyField:J,many:z,parents:V,args:Y,executor:G};return Z.join?e9($,Z,H):a9($,Z,H)}}}};async function a9($,Z,X){let{keys:J,byKey:z}=H5(X.parents,Z.parentFields);if(J.length===0)return;let V=$.locate(X.args),Y=Y5(V,Z.childFields,J,$.child,$.dialect),G=await X.executor.exec($.relation.model,"findMany",Y.args,!0);for(let H of G){let W=z.get(E0(Z.childFields.map((M)=>H[M])));if(!W)continue;for(let M of W)V5(M,$.as,H,X.many)}if(Y.hidden)for(let H of G)for(let W of Z.childFields)delete H[W]}async function e9($,Z,X){let{keys:J,byKey:z}=H5(X.parents,Z.parentFields);if(J.length===0)return;let{dialect:V}=$,Y=Z.join,G=await $$(V,Y,J.map((P)=>V.encode(P[0],X.parentKeyField)),X.executor),H=new Map,W=[];for(let P of G){let C=E0([V.decode(P[Y.parentColumn],X.parentKeyField)]),L=z.get(C);if(!L)continue;let N=V.decode(P[Y.childColumn],X.childKeyField),U=E0([N]),K=H.get(U);if(K===void 0)K=[],H.set(U,K),W.push([N]);for(let Q of L)K.push(Q)}if(W.length===0)return;let M=$.locate(X.args),D=Y5(M,Z.childFields,W,$.child,$.dialect),B=await X.executor.exec($.relation.model,"findMany",D.args,!0);for(let P of B){let C=H.get(E0([P[Z.childFields[0]]]));if(!C)continue;for(let L of C)V5(L,$.as,P,X.many)}if(D.hidden)for(let P of B)delete P[Z.childFields[0]]}async function $$($,Z,X,J){let z=R(j(`select ${$.quoteIdent(Z.parentColumn)}, ${$.quoteIdent(Z.childColumn)} from ${$.quoteIdent(Z.table)} where `),$.inList($.quoteIdent(Z.parentColumn),!1,X.length,()=>X)),{text:V,binders:Y}=m(z,$,{model:Z.table,operation:"include"}),G=C0();return J.query(V,Y.map((H)=>H(void 0,G)))}function Y5($,Z,X,J,z){let V=$===!0||$===null||typeof $!=="object"?{}:$,Y=Z.length===1?{[Z[0]]:{in:X.map((D)=>D[0])}}:Z$(J,Z,X,z),G={where:V.where===void 0?Y:{AND:[V.where,Y]}};if(V.orderBy!==void 0)G.orderBy=V.orderBy;if(V.include!==void 0)G.include=V.include;let H=V.omit;if(H!==void 0){let D=Z.filter((B)=>H[B]===!0);if(D.length===0)G.omit=H;else{let B={...H};for(let P of D)delete B[P];return G.omit=B,{args:G,hidden:!0}}}let W=V.select;if(W===void 0)return{args:G,hidden:!1};let M=Z.filter((D)=>W[D]!==!0);if(M.length===0)return G.select=W,{args:G,hidden:!1};G.select={...W};for(let D of M)G.select[D]=!0;return{args:G,hidden:!0}}function Z$($,Z,X,J){let z=Z.map((V)=>$.fields[V]?.type);if(z.every((V)=>V!==void 0)&&J.canBindCompositeIn(z))return{[a]:c4(Z,X)};return{OR:X.map((V)=>Object.fromEntries(Z.map((Y,G)=>[Y,V[G]])))}}function E0($){return JSON.stringify($.map(X$))}function V5($,Z,X,J){if(J){$[Z].push(X);return}if($[Z]===null)$[Z]=X}function H5($,Z){let X=new Map,J=[];for(let z of $){let V=Z.map((H)=>z[H]);if(V.some((H)=>H===null||H===void 0))continue;let Y=E0(V),G=X.get(Y);if(G===void 0)G=[],X.set(Y,G),J.push(V);G.push(z)}return{keys:J,byKey:X}}function X$($){if(typeof $!=="object"||$===null)return $;if($ instanceof Date)return $.getTime();if(ArrayBuffer.isView($)){let Z=new Uint8Array($.buffer,$.byteOffset,$.byteLength),X="";for(let J of Z)X+=J.toString(16).padStart(2,"0");return`bytes:${X}`}throw Error(`Cannot key a relation stitch on ${Object.prototype.toString.call($)}.`)}function a4($,Z,X){if(X.isList)throw new p($.name,Z.name,`it joins on '${X.name}', a ${X.type} list \u2014 which decodes to a new `+"array per row and so cannot be compared between the two sides.");if(X.type!=="Json")return;throw new p($.name,Z.name,`it joins on '${X.name}', a ${X.type} \u2014 which decodes to a new object `+"per row and so cannot be compared between the two sides.")}var G5=(()=>{try{return Function("return 1")()===1}catch{return!1}})(),W5=!0;function J$($){W5=$}function z$(){return G5}function k0($,Z,X=[]){if(G5&&W5)return Y$($,Z,X);return g3($,Z,X)}function g3($,Z,X=[]){let J=$.map((G)=>({key:G.name,column:G.column,field:G,decode:Z.needsDecode(G)})),z=J.length,V=X.map((G)=>({key:G.key,many:G.kind==="many"})),Y=V.length;return(G)=>{let H=[];for(let W=0;W<G.length;W++){let M=G[W],D={};for(let B=0;B<z;B++){let P=J[B],C=M[P.column];D[P.key]=P.decode?Z.decode(C,P.field):C??null}for(let B=0;B<Y;B++)D[V[B].key]=V[B].many?[]:null;H.push(D)}return H}}function Y$($,Z,X){let J=[];for(let V=0;V<$.length;V++){let Y=$[V],G=JSON.stringify(Y.name),H=JSON.stringify(Y.column);J.push(Z.needsDecode(Y)?`${G}: d.decode(row[${H}], f[${V}])`:`${G}: row[${H}] ?? null`)}for(let V of X)J.push(`${JSON.stringify(V.key)}: ${V.kind==="many"?"[]":"null"}`);let z=`
2
+ import{Aa as u4,Ba as s,Ca as M5,Da as L3,Ea as R7,Fa as I7,Ga as S0,Ha as x4,Ia as C3,Ja as N7,Ka as o0,La as U0,Ma as D9,Na as B9,Oa as P9,Pa as j9,Qa as _9,Ra as K9,Sa as Q9,Ta as U7,Ua as O7,Va as S7,za as h4}from"../chunk-ak3yy4za.js";import{Kd as Z7,Ld as L0,Md as D0,Nd as e4,Od as f3,Pd as K7,Qd as Q7,Rd as T7,Sd as L7,Td as C7}from"../chunk-6rc6yec4.js";import{$d as U4,Ae as G7,Be as W7,Ce as M7,De as D7,Ee as E3,Fe as f,Ge as B7,He as P7,Ie as j7,Je as _7,Ke as w4,Ud as _,Vd as I,Wd as q0,Xd as v,Yd as l6,Zd as Z0,_d as n6,ae as o6,be as H4,ce as t6,ee as r6,fe as O4,ge as a6,he as e6,ie as S4,je as P3,ke as w0,le as x3,me as v3,ne as p,oe as $7,pe as x0,qe as F4,re as C0,se as i,te as j,ue as c,xe as R,ye as q,ze as m}from"../chunk-ngq4n2b3.js";import"../chunk-17nh5gfm.js";import{Bf as z7,Cf as n0,Df as P0,Ef as T3,If as Y7,Jf as V7,Kf as A4,Lf as b4,Mf as H7,Nf as E4,Of as q4}from"../chunk-6y62ccam.js";import{$f as J7,Zf as X7,bg as N4}from"../chunk-gzfat1x1.js";import{wg as I4}from"../chunk-0efykzjy.js";import"../chunk-8r7xhy1g.js";import"../chunk-0808z3mq.js";import"../chunk-t93t317r.js";function K0($,Z,X,J,z,V){let Y=r($,Z),G=V0($,Y,Z,V),H=X.quoteIdent(J),W=`${H}.`,M=G.parentFields.map((C,L)=>{let N=`${W}${X.quoteIdent(r0(Y,Z,G.childFields[L]))}`,U=`${z}${X.quoteIdent(r0($,Z,C))}`;return`${N} = ${U}`}).join(" and ");if(!G.join)return{child:Y,source:`${X.quoteIdent(Y.table)} as ${H}`,correlation:M,qualifier:W};let D=`${W}${X.quoteIdent(r0(Y,Z,G.childFields[0]))}`,B=`${z}${X.quoteIdent(r0($,Z,G.parentFields[0]))}`,P=X.quoteIdent(`${J}j`);return{child:Y,source:`${X.quoteIdent(Y.table)} as ${H} join ${X.quoteIdent(G.join.table)} as ${P} on ${P}.${X.quoteIdent(G.join.childColumn)} = ${D}`,correlation:`${P}.${X.quoteIdent(G.join.parentColumn)} = ${B}`,qualifier:W}}function r0($,Z,X){let J=$.fields[X];if(!J)throw new p($.name,Z.name,`it joins on '${X}', which is not a field on ${$.name}.`);return J.column}function y($,Z,X){let J=a0($);if(typeof Z!=="object"||Z===null||Array.isArray(Z))throw g4($,X,J);let z=Object.keys(Z).filter((Y)=>Z[Y]!==void 0),V=Z;for(let Y of J){if(Y.length===1&&z.includes(Y[0]))return k4($,X,Y[0],V[Y[0]]),Y;let G=Y.join("_");if(Y.length>1&&z.includes(G)){let H=V[G];if(H&&typeof H==="object"&&!Array.isArray(H))for(let W of Y)k4($,X,`${G}.${W}`,H[W]);return Y}}throw g4($,X,J)}function U3($){if($===null||$===void 0)return!1;let Z=typeof $;if(Z!=="object")return Z!=="function"&&Z!=="symbol";if(Array.isArray($))return!1;if($ instanceof Date||ArrayBuffer.isView($))return!0;let X=Object.getPrototypeOf($);return X!==Object.prototype&&X!==null}function k4($,Z,X,J){if(J===void 0||U3(J))return;throw new I(`${Z.argument}.${X}`,Z.model,Z.operation,`A unique key takes a plain value to match, not ${J===null?"null":Array.isArray(J)?"an array":"a filter object"}. Use findFirst/findMany (or updateMany/deleteMany) to filter on ${$.name}.${X.split(".").pop()}.`)}function O3($,Z,X){y($,Z,{model:$.name,operation:X,argument:"where"})}function a0($){let Z=[];if($.primaryKey.length>0)Z.push($.primaryKey);for(let X of $.uniques)Z.push(X);return Z}function g4($,Z,X){let J=X.map((Y)=>Y.length===1?Y[0]:Y.join("_")).join(", "),V=Z.argument.startsWith("data.")?`Name it by one of those, or reach it through the ${$.name} model directly.`:`Use ${Z.operation==="delete"||Z.operation==="update"?`${Z.operation}Many`:"findFirst"} to query on anything else.`;return new _(Z.argument,Z.model,Z.operation,`${$.name} needs a unique field here. It declares: ${J}. ${V}`)}function g($,Z,X){let J=Z.castParameter($);if(!J)return c(X);return c((z,V)=>{let Y=X(z,V);if(Y===null||Y===void 0)return null;let G=f(Y);if(G==="db")return null;if(G==="json")return"null";if(G==="any")throw Error("gemi ORM bug: Prisma.AnyNull reached the parameter binder. It is a filter operand only, and both the filter and write paths are supposed to have handled it before this point.");return JSON.stringify(Y)},J)}function x($,Z,X,J){if(Z===void 0||Z===null)return null;if(typeof Z!=="object"||Array.isArray(Z))throw new I("where",$.name,X.operation,"Expected an object.");let z=[];for(let V of Object.keys(Z).sort()){let Y=Z[V];if(Y===void 0)continue;let G=(W)=>J(W)?.[V];if(V==="AND"||V==="OR"){let W=y4($,Y,X,G,V);if(W)z.push(W);continue}if(V===a){z.push(F9($,Y,X,G));continue}if(V==="NOT"){let W=y4($,Y,X,G,"AND");if(W)z.push(R(j("not "),A0(W)));continue}if(V in $.relations){let W=U9($,$.relations[V],Y,X,G);if(W)z.push(W);continue}let H=$.fields[V];if(!H){let W=S9($,V,Y,X,G);if(W){z.push(W);continue}throw new v(V,$.name,Object.keys($.fields))}z.push(q3($,H,Y,X,G))}if(z.length===0)return null;if(z.length===1)return z[0];return l(z," and ")}function U9($,Z,X,J,z){let V=h4(Z.kind),Y=O9($,Z,X,V,J),G=J.relationDepth??0,H=J.dialect,W=J.qualifier??`${H.quoteIdent($.table)}.`,M=K0($,Z,H,`_r${G}`,W,J.operation),D=M.child,B=j(M.correlation),P={...J,qualifier:M.qualifier,relationDepth:G+1},C=[];for(let L of V){if(!(L in Y))continue;let N=Y[L],U=(T)=>Y.direct?z(T):z(T)?.[L];if(N===null){C.push(S3(M,B,null,L==="is"));continue}let K=x(D,N,P,U);if(L==="every"){if(!K)continue;C.push(S3(M,B,R(j("not "),A0(K)),!0));continue}let Q=L==="none"||L==="isNot";C.push(S3(M,B,K,Q))}if(C.length===0)return null;if(C.length===1)return C[0];return l(C," and ")}function S3($,Z,X,J){let z=[j(`${J?"not ":""}exists (select 1 from ${$.source} where `),Z];if(X)z.push(j(" and "),X);return z.push(j(")")),R(...z)}function O9($,Z,X,J,z){let V=`where.${Z.name}`,Y=Z.kind==="many";if(X===null){if(Y)throw new _(V,$.name,z.operation,`${Z.name} is a to-many relation, so null is not a filter for it. Use { none: {} } for "has no related rows".`);return{is:null,direct:!0}}if(typeof X!=="object"||Array.isArray(X))throw new I(V,$.name,z.operation,Y?`Expected an object holding ${J.join(", ")}.`:"Expected an object, or null.");if(u4(X,J))return X;if(Y)throw new _(V,$.name,z.operation,`Expected one of ${J.join(", ")}. A to-many relation has no `+"single reading of a bare filter \u2014 { some: \u2026 } and { every: \u2026 } mean "+"different things.");return{is:X,direct:!0}}function S9($,Z,X,J,z){let V=a0($).find((H)=>H.length>1&&H.join("_")===Z);if(!V)return null;if(typeof X!=="object"||X===null||Array.isArray(X))throw new I(`where.${Z}`,$.name,J.operation,`Expected an object holding ${V.join(" and ")}.`);let Y=X,G=[];for(let H of V){if(Y[H]===void 0)throw new _(`where.${Z}`,$.name,J.operation,`Missing '${H}'. A composite key needs all of ${V.join(", ")}.`);if(!U3(Y[H]))throw new I(`where.${Z}.${H}`,$.name,J.operation,`A composite key takes a plain value for each of ${V.join(", ")}, not a filter, an array or null.`);G.push(q3($,$.fields[H],Y[H],J,(W)=>z(W)?.[H]))}return G.length===1?G[0]:l(G," and ")}function y4($,Z,X,J,z){let V=[];if(Array.isArray(Z))for(let Y=0;Y<Z.length;Y++){let G=x($,Z[Y],X,(H)=>J(H)?.[Y]);if(G)V.push(G)}else{let Y=x($,Z,X,J);if(Y)V.push(Y)}if(V.length===0)return z==="AND"?null:m4;if(V.length===1)return V[0];return l(V,z==="AND"?" and ":" or ")}var m4=j("false");function l($,Z){return R(j("("),q($,Z),j(")"))}function A0($){return $.text.startsWith("(")?$:l([$],"")}var b3=new Set(["equals","not","in","notIn","lt","lte","gt","gte","contains","startsWith","endsWith","mode"]),p4={lt:"<",lte:"<=",gt:">",gte:">="},a="$compositeIn",d4=Symbol("gemi.orm.compositeInFromPlanner");function c4($,Z){return{[d4]:!0,fields:$,values:Z}}function F9($,Z,X,J){let{dialect:z}=X,Y=A9($,Z,X).map((H)=>{let W=$.fields[H];if(!W)throw new v(H,$.name,Object.keys($.fields));return W}),G=Y.map((H)=>`${X.qualifier??""}${z.quoteIdent(H.column)}`);return z.compositeIn(G,Y.map((H)=>H.type),(H)=>J(H).values)}function A9($,Z,X){let J=()=>{throw new v(a,$.name,Object.keys($.fields))};if(typeof Z!=="object"||Z===null||Array.isArray(Z))return J();if(Z[d4]!==!0)return J();let z=(G)=>{throw new _(a,$.name,X.operation,G)},{fields:V,values:Y}=Z;if(!Array.isArray(V)||V.length===0)return z(`the planner built a '${a}' with no fields.`);if(!V.every((G)=>typeof G==="string"))return z(`the planner built a '${a}' with a non-string field.`);if(!Array.isArray(Y))return z(`the planner built a '${a}' with no values.`);if(!Y.every((G)=>Array.isArray(G)&&G.length===V.length))return z(`the planner built a '${a}' whose tuples do not all have ${V.length} value(s).`);return V}var b9=["equals","has","hasEvery","hasSome","isEmpty"],F3=new Set(b9);function E9($,Z,X,J,z,V){let{dialect:Y}=z;if(T0($,Z,`where.${Z.name}`,z.operation,Y),Array.isArray(J))throw new I(`where.${Z.name}`,$.name,z.operation,`'${Z.name}' is a scalar list, and a bare array is not a filter on `+"one \u2014 Prisma rejects it here too. Say which comparison you mean: "+`{ ${Z.name}: { equals: [...] } } for the whole list, or { ${Z.name}: { hasEvery: [...] } } for "contains all of these". A bare array *is* accepted as a value in \`data\`.`);if(!w3(J))throw new I(`where.${Z.name}`,$.name,z.operation,`'${Z.name}' is a scalar list. Expected an object holding ${[...F3].sort().join(", ")}; received ${J===null?"null":typeof J}.`);let G=J,H=[];for(let W of Object.keys(G).sort()){let M=G[W];if(M===void 0)continue;if(!F3.has(W))throw new I(`where.${Z.name}.${W}`,$.name,z.operation,`'${Z.name}' is a scalar list, and a list filter takes ${[...F3].sort().join(", ")}. The scalar operators \u2014 `+`${[...b3].sort().join(", ")} \u2014 apply to a single value and `+"Prisma does not offer them here.");let D=(B)=>V(B)?.[W];H.push(q9($,Z,X,W,M,z,D))}if(H.length===0)return j("true");if(H.length===1)return H[0];return l(H," and ")}function q9($,Z,X,J,z,V,Y){let{dialect:G}=V;if(J==="equals")return w9($,Z,X,z,V,Y);if(J==="isEmpty"){if(typeof z!=="boolean")throw new I(`where.${Z.name}.isEmpty`,$.name,V.operation,`Expected true or false, received ${z===null?"null":typeof z}.`);return G.listIsEmpty(X,z)}if(J==="has"){let W=x9(Z);return G.listHas(X,g(W,G,Q0(W,G,Y)))}if(!Array.isArray(z))throw new I(`where.${Z.name}.${J}`,$.name,V.operation,`Expected an array, received ${z===null?"null":typeof z}.`);let H=g(Z,G,Q0(Z,G,Y));return J==="hasEvery"?G.listHasEvery(X,H):G.listHasSome(X,H)}function w9($,Z,X,J,z,V){let{dialect:Y}=z;if(J===null)return j(`${X} is null`);if(!Array.isArray(J))throw new I(`where.${Z.name}.equals`,$.name,z.operation,`'${Z.name}' is a scalar list, so it compares against an array. Received ${typeof J}. For "is this element present", use { ${Z.name}: { has: \u2026 } }.`);return R(j(`${X} = `),g(Z,Y,Q0(Z,Y,V)))}function x9($){return{...$,isList:!1}}function T0($,Z,X,J,z){if(z.listFilters.size>0)return;throw new _(X,$.name,J,`'${Z.name}' is a scalar list, and ${z.name} has no array type to hold one. Prisma refuses the column itself on ${z.name} \u2014 `+'"the current connector does not support lists of primitive types" \u2014 so '+`this is a difference between the databases rather than a gap in the ORM. The generated artifact is dialect-agnostic, which is why this surfaces here rather than at \`prisma generate\`: the schema was generated against Postgres and DATABASE_URL names a ${z.name} database, which has no '${Z.column}' column either. It works on postgres.`)}var v9=["equals","not","string_contains","string_starts_with","string_ends_with","array_contains","lt","lte","gt","gte"],A3=new Set(v9);function f9($,Z,X,J,z,V){let{dialect:Y}=z;if(Z.type!=="Json")throw new _(`${Z.name}.path`,$.name,z.operation,`A 'path' filter reads inside a JSON document, and '${Z.name}' is a ${Z.type} column.`);h9($,Z,J.path,z);let G=(M)=>V(M)?.path,H=Object.keys(J).filter((M)=>M!=="path"&&J[M]!==void 0).sort();if(H.length===0)throw new _(`${Z.name}.path`,$.name,z.operation,`A 'path' needs a filter beside it \u2014 ${[...A3].sort().join(", ")}. Prisma refuses a bare path too.`);let W=[];for(let M of H){if(!A3.has(M))throw new _(`${Z.name}.${M}`,$.name,z.operation,`A JSON path filter takes ${[...A3].sort().join(", ")}.`);if(!Y.jsonFilters.has(M))throw new _(`${Z.name}.${M}`,$.name,z.operation,`'${M}' on a JSON path is not available on ${Y.name}. Prisma refuses it here too, so this is a difference between the databases rather than a gap in the ORM. It works on postgres.`);let D=J[M],B=D===null?"json":f(D);if(B&&(M==="equals"||M==="not")){W.push(k9(B,X,G,Z,Y,M==="not"));continue}if(B&&D!==null){let P=M==="array_contains"?"'array_contains' tests containment against a document, and a sentinel is not one":`'${M}' compares an extracted value against a scalar, and a sentinel is not one`;throw new I(`where.${Z.name}.${M}`,$.name,z.operation,`${b0(B)} asks which kind of null a value is, which `+`only 'equals' and 'not' can express \u2014 ${P}. Prisma refuses it under this operator too. Write { ${Z.name}: { path: [\u2026], equals: ${b0(B)} } }, `+"or filter the column itself \u2014 "+`{ ${Z.name}: { equals: ${b0(B)} } }.`)}if(s4(D))throw new I(`where.${Z.name}.${M}`,$.name,z.operation,"Prisma.AnyNull is a question rather than a value \u2014 'either kind of "+"null' \u2014 so it cannot appear inside a document. Ask it directly: "+`{ ${Z.name}: { path: [\u2026], equals: Prisma.AnyNull } }.`);g9(M,D,$,Z,z),W.push(y9(M,X,G,Z,Y,(P)=>V(P)?.[M]))}return W.length===1?W[0]:l(W," and ")}function k9($,Z,X,J,z,V){let Y=()=>R(z.jsonValueAt(Z,X),j(V?" is not null":" is null")),G=()=>R(z.jsonValueAt(Z,X),j(V?" <> ":" = "),g(J,z,()=>z.encode(E3,J)));if($==="db")return Y();if($==="json")return G();return l([G(),Y()],V?" and ":" or ")}function g9($,Z,X,J,z){let V=$==="string_contains"||$==="string_starts_with"||$==="string_ends_with";if(V&&typeof Z!=="string")throw new I(`where.${J.name}.${$}`,X.name,z.operation,`Expected a string, received ${Z===null?"null":typeof Z}. Prisma raises here too \u2014 without this the pattern becomes `+`'%${String(Z)}%', which runs and returns the wrong rows.`);if(Z===null)throw new I(`where.${J.name}.${$}`,X.name,z.operation,$==="array_contains"?"null cannot be tested for containment through a JSON path: the operand binds as SQL NULL rather than as the JSON value, and "+"'x @> NULL' is NULL rather than true \u2014 the query would run and "+`match nothing. A null *inside* the document is an ordinary value and still compiles: { ${J.name}: { path: [\u2026], array_contains: [null] } }.`:`null cannot be compared through a JSON path with '${$}', which `+"compares the extracted value as a number \u2014 the comparison against "+`NULL is NULL rather than true, so the query would run and match nothing. Prisma refuses it here too. For "the value at this path is a JSON null", use equals or not: { ${J.name}: { path: [\u2026], equals: null } }.`);if($==="array_contains"||V)return;if(typeof Z==="object")throw new _(`where.${J.name}.${$}`,X.name,z.operation,`'${$}' on a JSON path compares the extracted value as a scalar, so `+"an object or array operand cannot be expressed \u2014 it would bind as "+`'${String(Z)}' and match nothing. Prisma accepts one here; gemi does not yet. Use array_contains for containment, or narrow the path until it names a scalar.`)}function y9($,Z,X,J,z,V){if($==="array_contains")return z.jsonArrayContains(Z,X,V);let Y=$==="string_contains"||$==="string_starts_with"||$==="string_ends_with",G=z.jsonExtract(Z,X,!0);if(Y){let D=$==="string_contains"?(B)=>`%${B}%`:$==="string_starts_with"?(B)=>`${B}%`:(B)=>`%${B}`;return R(j("("),G,j(") like "),c((B,P)=>{let C=V(B,P);return C===null||C===void 0?null:D(String(C))}))}let H=$==="equals"?"=":$==="not"?"<>":p4[$],W=$!=="equals"&&$!=="not",M=W?R(j("cast(("),G,j(") as real)")):R(j("("),G,j(")"));return R(M,j(` ${H} `),c((D,B)=>{let P=V(D,B);if(P===null||P===void 0)return null;if(W)return Number(P);return z.jsonComparesAsText?String(P):P}))}function h9($,Z,X,J){let{dialect:z}=J,V=z.jsonPathSyntax==="array"?"array":"jsonpath",Y=Array.isArray(X)?"array":typeof X==="string"?"jsonpath":"other";if(Array.isArray(X)&&X.length===0||X==="")throw new _(`${Z.name}.path`,$.name,J.operation,`A JSON path cannot be empty. ${z.jsonPathSyntax==="array"?`On ${z.name} an empty array selects the whole document, `+"which is a filter on the column rather than on a path \u2014 write "+`{ ${Z.name}: { equals: \u2026 } } if that is what you meant.`:`On ${z.name} an empty string raises inside json_extract.`}`);if(Y===V){if(V!=="array")return;let H=X.findIndex((D)=>typeof D!=="string");if(H===-1)return;let W=X[H],M=W===null?"null":W===void 0?"undefined":Array.isArray(W)?"an array":typeof W==="object"?"an object":`a ${typeof W}`;throw new _(`${Z.name}.path`,$.name,J.operation,`A JSON path is an array of strings, and path[${H}] is ${M}. `+(typeof W==="number"?'An array index is a key too \u2014 write ["items", "0"] rather than '+`["items", 0]; it reaches the same element, because ${z.name} takes the path as text. Prisma's path is string[] and its client refuses a number here too.`:"Prisma's path is string[] too."))}throw new _(`${Z.name}.path`,$.name,J.operation,z.jsonPathSyntax==="array"?`On ${z.name} a JSON path is an array of keys \u2014 ["a", "b"] \u2014 `+"not a JSONPath string. Prisma splits them the same way, and refuses the other form on each database.":`On ${z.name} a JSON path is a JSONPath string \u2014 "$.a.b" \u2014 not `+"an array of keys. Prisma splits them the same way, and refuses the other form on each database.")}function q3($,Z,X,J,z){let{dialect:V}=J,Y=`${J.qualifier??""}${V.quoteIdent(Z.column)}`,G=f(X);if(G)throw new I(`where.${Z.name}`,$.name,J.operation,`${b0(G)} is not a filter on `+"its own \u2014 Prisma rejects it here too. Write it as an explicit "+`comparison: { ${Z.name}: { equals: ${b0(G)} } }.`);if(Z.isList)return E9($,Z,Y,X,J,z);if(!w3(X))return e0(Y,Z,X,V,z);let H=X,W=Object.keys(H).sort();if(H.path!==void 0)return f9($,Z,Y,H,J,z);let M=H.mode==="insensitive";if(H.mode!==void 0&&H.mode!=="default"){if(!M)throw new I(`mode: ${JSON.stringify(H.mode)}`,$.name,J.operation,"Prisma takes 'default' or 'insensitive'.");if(!V.supportsInsensitiveMode)throw new _('mode: "insensitive"',$.name,J.operation,`The ${V.name} dialect cannot express it \u2014 Prisma rejects it `+"here too. Note SQLite's LIKE is already case-insensitive for ASCII.")}let D=[];for(let B of W){let P=H[B];if(P===void 0||B==="mode")continue;if(!b3.has(B))throw new I(`where.${Z.name}.${B}`,$.name,J.operation,`A scalar filter takes ${[...b3].sort().join(", ")}.`);if(B!=="equals"&&B!=="not"&&s4(P))throw new I(`where.${Z.name}.${B}`,$.name,J.operation,`Prisma.AnyNull means 'either kind of null', which only 'equals' and 'not' can express. Write { ${Z.name}: { equals: Prisma.AnyNull } }, or name the one you mean with Prisma.DbNull or Prisma.JsonNull.`);let C=(L)=>z(L)?.[B];switch(B){case"equals":D.push(e0(Y,Z,P,V,C));break;case"not":D.push(u9($,Z,P,J,C,Y));break;case"in":case"notIn":D.push(p9($,Y,Z,P,J,C,B==="notIn"));break;case"lt":case"lte":case"gt":case"gte":D.push(R(j(`${Y} ${p4[B]} `),g(Z,V,Q0(Z,V,C))));break;case"contains":case"startsWith":case"endsWith":if(typeof P!=="string")throw new I(`where.${Z.name}.${B}`,$.name,J.operation,`Expected a string, received ${P===null?"null":typeof P}.`);if(Z.type!=="String")throw new _(`where.${Z.name}.${B}`,$.name,J.operation,`'${Z.name}' is a ${Z.type}, and ${B} only applies to strings.`);D.push(V.like(Y,M,d9(B,C)));break}}if(D.length===0)return j("true");if(D.length===1)return D[0];return l(D," and ")}function b0($){return`Prisma.${$==="db"?"DbNull":$==="json"?"JsonNull":"AnyNull"}`}function s4($){if(f($)==="any")return!0;return Array.isArray($)&&$.some((Z)=>f(Z)==="any")}function u9($,Z,X,J,z,V){if(X===null||f(X)==="db")return j(`${V} is not null`);if(f(X)==="json")return R(j("not "),A0(e0(V,Z,X,J.dialect,z)));if(f(X)==="any")return R(j("not "),A0(e0(V,Z,X,J.dialect,z)));if(!w3(X))return R(j(`${V} <> `),g(Z,J.dialect,Q0(Z,J.dialect,z)));let Y=q3($,Z,X,J,z);return R(j("not "),A0(Y))}function e0($,Z,X,J,z){if(X===null||f(X)==="db")return j(`${$} is null`);if(f(X)==="any")return l([j(`${$} is null`),m9($,Z,J)]," or ");return R(j(`${$} = `),g(Z,J,Q0(Z,J,z)))}function m9($,Z,X){return R(j(`${$} = `),g(Z,X,()=>X.encode(E3,Z)))}function p9($,Z,X,J,z,V,Y){let{dialect:G}=z;if(!Array.isArray(J))throw new I(`where.${X.name}.${Y?"notIn":"in"}`,$.name,z.operation,"Expected an array.");if(J.length===0)return Y?j("true"):m4;return G.inList(Z,Y,J.length,(H)=>{return V(H).map((M)=>G.encode(M,X))})}function d9($,Z){return(X)=>{let J=String(Z(X));if($==="contains")return`%${J}%`;if($==="startsWith")return`${J}%`;return`%${J}`}}function Q0($,Z,X){return(J)=>Z.encode(X(J),$)}function w3($){return typeof $==="object"&&$!==null&&!Array.isArray($)&&!($ instanceof Date)&&!ArrayBuffer.isView($)}function i4($,Z,X,J,z,V,Y){let G=`orderBy.${Z.name}`;if(typeof X!=="object"||X===null||Array.isArray(X))throw new I(G,$.name,J,Z.kind==="many"?'Expected { _count: "asc" | "desc" }.':`Expected an object naming one field of ${Z.model}.`);let H=X,W=Object.keys(H).filter((L)=>L!=="where");if(W.length!==1)throw new _(G,$.name,J,W.length===0?"Name the field to order by.":`Name exactly one field to order by; got ${W.join(", ")}. `+"Order by several with an array: [{ a: \u2026 }, { b: \u2026 }].");let[M]=W,D=K0($,Z,z,`_o${Y}`,`${z.quoteIdent($.table)}.`,J),B=c9($,Z,D.child,M,H[M],J,D.qualifier,z),P=x(D.child,H.where,{dialect:z,operation:J,qualifier:D.qualifier},(L)=>V(L)?.where),C=[j(`(select ${B.expression} from ${D.source} where ${D.correlation}`)];if(P)C.push(j(" and "),P);return C.push(j(")")),{expression:R(...C),direction:B.direction,nulls:B.nulls}}function c9($,Z,X,J,z,V,Y,G){let H=`orderBy.${Z.name}.${J}`,{direction:W,nulls:M}=s9($,H,z,V);if(J===s){if(Z.kind!=="many")throw new _(H,$.name,V,`${Z.name} is a to-one relation, so its count is 0 or 1. Order by one of ${X.name}'s fields instead.`);return{expression:"count(*)",direction:W,nulls:M}}if(Z.kind==="many")throw new _(H,$.name,V,`${Z.name} is a to-many relation, so ordering by '${J}' has no single answer for a parent with several children. Only `+"{ _count: \u2026 } is supported.");let D=X.fields[J];if(!D)throw new _(H,$.name,V,`'${J}' is not a field on ${X.name}. Known fields: ${Object.keys(X.fields).join(", ")}.`);return{expression:`${Y}${G.quoteIdent(D.column)}`,direction:W,nulls:M}}function s9($,Z,X,J){if(X==="asc"||X==="desc")return{direction:X};if(typeof X==="object"&&X!==null){let{sort:z,nulls:V}=X;if(z!=="asc"&&z!=="desc")throw new I(Z,$.name,J,'Expected "asc" or "desc".');if(V===void 0)return{direction:z};if(V!=="first"&&V!=="last")throw new _(`${Z}.nulls`,$.name,J,'Expected "first" or "last".');return{direction:z,nulls:V}}throw new _(Z,$.name,J,'Expected "asc", "desc", or { sort, nulls }.')}var i9=new Set(["asc","desc"]),l9=new Set(["first","last"]);function H0($,Z,X,J){if(Z===void 0||Z===null)return[];let z=Array.isArray(Z),V=z?Z:[Z],Y=[];for(let G=0;G<V.length;G++){let H=V[G],W=(M)=>{let D=J?.locate(M);return z?D?.[G]:D};if(typeof H!=="object"||H===null)throw new I("orderBy",$.name,X,"Expected an object or an array of objects.");for(let[M,D]of Object.entries(H)){if(D===void 0)continue;if(M in $.relations){if(!J)throw new _(`orderBy.${M}`,$.name,X,"Ordering by a relation is not implemented here.");let P=i4($,$.relations[M],D,X,J.dialect,(C)=>W(C)?.[M],Y.length);Y.push({column:M,direction:P.direction,...P.nulls?{nulls:P.nulls}:{},expression:P.expression});continue}let B=$.fields[M];if(!B)throw new v(M,$.name,Object.keys($.fields));Y.push({column:B.column,...l4($,M,D,X)})}}return Y}function l4($,Z,X,J){if(typeof X==="string"){if(!i9.has(X))throw new I(`orderBy.${Z}: ${JSON.stringify(X)}`,$.name,J,'Expected "asc" or "desc".');return{direction:X}}if(typeof X==="object"&&X!==null){let{sort:z,nulls:V}=X,Y=l4($,Z,z,J).direction;if(V===void 0)return{direction:Y};if(typeof V!=="string"||!l9.has(V))throw new _(`orderBy.${Z}.nulls: ${JSON.stringify(V)}`,$.name,J,'Expected "first" or "last".');return{direction:Y,nulls:V}}throw new _(`orderBy.${Z}`,$.name,J,'Expected "asc", "desc", or { sort, nulls }.')}function $3($){return $.map((Z)=>({...Z,direction:Z.direction==="asc"?"desc":"asc",...Z.nulls?{nulls:Z.nulls==="first"?"last":"first"}:{}}))}function n($,Z,X){if($.length===0)return null;return q($.map((J)=>{let z=` ${J.direction}`+(J.nulls?` nulls ${J.nulls}`:"");if(J.expression)return q([J.expression,j(z)],"");return j(`${X??""}${Z.quoteIdent(J.column)}${z}`)}),", ")}function Z3($,Z,X,J,z){if(typeof z!=="number"||!Number.isInteger(z))throw new I(X,$,Z,`Expected an integer, got ${JSON.stringify(z)}.`);if(J==="skip"&&z<0)throw new I(X,$,Z,"A 'skip' counts rows to pass over, so it cannot be negative. Prisma rejects one too.")}function M0($,Z,X,J,z,V=!1){if(X?.take!==void 0)Z3($.name,Z,"take","take",X.take);if(X?.skip!==void 0)Z3($.name,Z,"skip","skip",X.skip);let Y=V?1:X?.take,G=X?.skip,H=z;if((Y!==void 0||G!==void 0)&&H.length===0&&!V)H=$.primaryKey.map((P)=>({column:$.fields[P]?.column??P,direction:"asc"}));let M=typeof Y==="number"&&Y<0;if(M)H=$3(H);let D=Y===void 0?null:V?()=>1:(P)=>Math.abs(Number(P?.take)),B=G===void 0?null:(P)=>Number(P?.skip);return{clause:J.paginate(D,B),terms:H,reversed:M}}function e($,Z,X){let J=Z?.select,z=Z?.omit;if(J!==void 0&&Z?.include!==void 0)throw new _("select + include",$.name,X,"Prisma allows only one of them on the same query.");if(J!==void 0&&z!==void 0)throw new _("select + omit",$.name,X,"'select' names what to keep and 'omit' what to drop, so the two describe different column lists. Prisma allows only one of them on "+"the same query. Drop the 'omit' \u2014 a 'select' already excludes "+"everything it does not name.");if(J===void 0||J===null)return n9($,z,X);if(typeof J!=="object"||Array.isArray(J))throw new I("select",$.name,X,"Expected an object.");let V=[];for(let[G,H]of Object.entries($.fields))if(J[G]===!0)V.push(H);let Y=0;for(let G of Object.keys(J)){let H=J[G];if(H===void 0)continue;if(G in $.relations){if(H!==!1)Y++;continue}if(G===s){if(H!==!1)Y++;continue}if(!(G in $.fields))throw new v(G,$.name,Object.keys($.fields));if(typeof H!=="boolean")throw new I(`select.${G}`,$.name,X,"Expected true or false.")}if(V.length===0&&Y===0)throw new _("select",$.name,X,"At least one field must be selected.");return V}function n9($,Z,X){if(Z===void 0||Z===null)return Object.values($.fields);if(typeof Z!=="object"||Array.isArray(Z))throw new I("omit",$.name,X,"Expected an object of fields.");let J=new Set;for(let V of Object.keys(Z)){let Y=Z[V];if(Y===void 0)continue;if(V in $.relations)throw new _(`omit.${V}`,$.name,X,`'${V}' is a relation, not a column. A relation is already absent unless an 'include' asks for it.`);if(!(V in $.fields))throw new v(V,$.name,Object.keys($.fields));if(typeof Y!=="boolean")throw new I(`omit.${V}`,$.name,X,"Expected true or false.");if(Y)J.add(V)}let z=Object.values($.fields).filter((V)=>!J.has(V.name));if(z.length===0)throw new _("omit",$.name,X,`It omits every field on ${$.name}, which leaves no column to select. Prisma rejects that too.`);return z}function X3($,Z,X){if(X.length===0)return{fields:Z};let J=new Set(Z.map((Y)=>Y.name)),z=X.filter((Y)=>!J.has(Y));if(z.length===0)return{fields:Z};let V=new Set([...J,...z]);return{fields:Object.values($.fields).filter((Y)=>V.has(Y.name)),hidden:z}}var n4=new Set(["where","orderBy","select","omit","include","take","skip"]),o4=new Set(["where","select","omit","include"]),Y3=10;function v0($){return[...new Set($.map((Z)=>Z.strategy))].sort()}function R0($,Z,X,J,z=G0){let V=f0($,Z,J);if(V.length===0)return{plans:[],keyFields:[]};let Y=[],G=new Set;for(let H of V){Z5($,H,J);let W=z5($,H);X5(W,H.node,J,2);let M=z.plan({parent:$,child:W,relation:H.relation,as:H.as,node:H.node,locate:H.locate,dialect:X,operation:J});Y.push(M);for(let D of M.parentFields)G.add(D)}return{plans:Y,keyFields:[...G]}}async function V3($,Z,X,J,z){let V=Array.isArray(X)?X:X===null||X===void 0?[]:[X];if(V.length===0)return;for(let Y of $){if(Y.root)continue;await Y.load(V,J,z)}if(Z&&Z.length>0)for(let Y of V)for(let G of Z)delete Y[G]}function f0($,Z,X){if(Z===void 0||Z===null)return[];let{include:J,select:z}=Z;$5($,J,z,X);let V=[];if(J!==void 0&&J!==null){if(typeof J!=="object"||Array.isArray(J))throw new I("include",$.name,X,"Expected an object.");for(let Y of Object.keys(J).sort()){let G=J[Y];if(G===void 0||G===!1)continue;if(Y===s)continue;let H=$.relations[Y];if(!H)throw new w0(Y,$.name,Object.keys($.relations));V.push({as:Y,relation:H,node:G,locate:(W)=>W?.include?.[Y]})}return V}if(z!==void 0&&z!==null&&typeof z==="object")for(let Y of Object.keys(z).sort()){let G=z[Y];if(G===void 0||G===!1)continue;let H=$.relations[Y];if(!H)continue;V.push({as:Y,relation:H,node:G,locate:(W)=>W?.select?.[Y]})}return V}function $5($,Z,X,J,z){if(Z===void 0||X===void 0)return;throw new _(z?`${z}: select + include`:"select + include",$.name,J,"Prisma allows only one of them on the same query, at any level.")}function Z5($,Z,X){let J=Z.node;if(J===!0)return;if(typeof J!=="object"||J===null||Array.isArray(J))throw new I(Z.as,$.name,X,"Expected true or an object of relation arguments.");let z=J;$5($,z.include,z.select,X,Z.as);let V=Z.relation.kind==="many";for(let Y of Object.keys(z).sort()){if(z[Y]===void 0)continue;if(V&&(Y==="take"||Y==="skip")){o9($,Z,X,Y,z[Y]);continue}if(V?n4.has(Y):o4.has(Y))continue;if(Y==="lock")throw new q0(`${Z.as}.lock`,$.name,X,"'lock' locks the rows of the model being queried, not an included relation's. Lock the related rows with their own locking read in the same transaction.");if(Y==="orderBy"&&!V)throw new _(`${Z.as}.orderBy`,$.name,X,"Prisma does not accept 'orderBy' on a to-one relation \u2014 there is at "+"most one row to order.");if(Y==="take"||Y==="skip")throw new _(`${Z.as}.${Y}`,$.name,X,`Prisma does not accept '${Y}' on a to-one relation.`);throw new _(`${Z.as}.${Y}`,$.name,X,`A relation node takes ${[...V?n4:o4].sort().join(", ")}.`)}}function o9($,Z,X,J,z){Z3($.name,X,`${Z.as}.${J}`,J,z)}function k3($,Z){let X=$.node;if(typeof X!=="object"||X===null||Array.isArray(X))return;for(let J of["take","skip"]){if(X[J]===void 0)continue;throw new _(`${$.as}.${J}`,$.parent.name,$.operation,`A '${J}' inside a to-many relation is per parent, and the batched `+"relation planner serves every parent from one query \u2014 so the only "+`limit it could emit would page every parent's children as one set. Only the lateral join strategy can express it, by paginating inside a subquery that already runs once per parent row, and it needs Postgres: ${Z}. Load '${$.as}' as its own query, or narrow it with 'where'.`)}}function X5($,Z,X,J){if(typeof Z!=="object"||Z===null||Array.isArray(Z))return;if(Z.select!==void 0)e($,Z,X);let z=f0($,Z,X);if(z.length===0)return;if(J>Y3)throw new x3($.name,Y3);for(let V of z)Z5($,V,X),X5(z5($,V),V.node,X,J+1)}function J5($,Z,X,J){if($.parentFields.length!==1)throw new _(X.name,Z.name,J,`${X.name} joins on ${$.parentFields.length} fields (${$.parentFields.join(", ")}), and it is planned through a join table, which links two models by a single primary key each side. Prisma does not build an implicit many-to-many over a composite key.`);return{parentField:$.parentFields[0],childField:$.childFields[0],join:$.join}}function V0($,Z,X,J){if(X.joinTable)return r9($,Z,X);if(X.from.length>0)return t4($,X,X.from,X.to,J);let z=t9($,Z,X);if(z.from.length===0)throw new p($.name,X.name,`neither ${$.name}.${X.name} nor ${Z.name}.${z.name} holds the foreign key.`);return t4($,X,z.to,z.from,J)}function t4($,Z,X,J,z){if(X.length===0)throw new _(Z.name,$.name,z,`${Z.name} names no join fields.`);if(X.length!==J.length)throw new p($.name,Z.name,`it joins ${X.length} field(s) to ${J.length}: ${X.join(", ")} against ${J.join(", ")}.`);return{parentFields:X,childFields:J}}function t9($,Z,X){let J=Object.values(Z.relations).filter((z)=>z.relationName===X.relationName&&!(Z.name===$.name&&z.name===X.name));if(J.length!==1)throw new p($.name,X.name,J.length===0?`${Z.name} declares no relation named '${X.relationName}'.`:`${Z.name} declares ${J.length} relations named '${X.relationName}'.`);return J[0]}function r9($,Z,X){let{table:J,a:z,b:V}=X.joinTable;if(z===V){let G=X.joinTable.ownerColumn;if(!G)throw new _(X.name,$.name,"include",`${X.name} is a self-referential implicit many-to-many, and the generated artifact predates support for one. Re-run \`prisma generate\`.`);return{parentFields:[J3($,X)],childFields:[J3(Z,X)],join:{table:J,parentColumn:G,childColumn:G==="A"?"B":"A"}}}if($.name!==z&&$.name!==V)throw new p($.name,X.name,`the join table '${J}' connects ${z} and ${V}, neither of which is ${$.name}.`);let Y=$.name===z?"A":"B";return{parentFields:[J3($,X)],childFields:[J3(Z,X)],join:{table:J,parentColumn:Y,childColumn:Y==="A"?"B":"A"}}}function J3($,Z){if($.primaryKey.length!==1)throw new p($.name,Z.name,`an implicit many-to-many joins on ${$.name}'s primary key, which has ${$.primaryKey.length} fields.`);return $.primaryKey[0]}function z3($,Z,X){let J=$.fields[X];if(!J)throw new p($.name,Z.name,`it joins on '${X}', which is not a field on ${$.name}.`);return J}function z5($,Z){return r($,Z.relation,Z.as)}function r($,Z,X=Z.name){let J=Z.model;if(!L0(J))throw new v3($.name,X,J,e4());let z=D0(J)?.$schema;if(!z)throw new x0(J);return z}var r4="batched",G0={name:r4,plan($){k3($,"this query planned with the batched strategy");let Z=V0($.parent,$.child,$.relation,$.operation);for(let V of Z.parentFields)a4($.parent,$.relation,z3($.parent,$.relation,V));for(let V of Z.childFields)a4($.child,$.relation,z3($.child,$.relation,V));let X=z3($.parent,$.relation,Z.parentFields[0]),J=z3($.child,$.relation,Z.childFields[0]),z=$.relation.kind==="many";return{as:$.as,model:$.relation.model,kind:$.relation.kind,parentFields:Z.parentFields,strategy:r4,load(V,Y,G){let H={parentKeyField:X,childKeyField:J,many:z,parents:V,args:Y,executor:G};return Z.join?e9($,Z,H):a9($,Z,H)}}}};async function a9($,Z,X){let{keys:J,byKey:z}=H5(X.parents,Z.parentFields);if(J.length===0)return;let V=$.locate(X.args),Y=Y5(V,Z.childFields,J,$.child,$.dialect),G=await X.executor.exec($.relation.model,"findMany",Y.args,!0);for(let H of G){let W=z.get(E0(Z.childFields.map((M)=>H[M])));if(!W)continue;for(let M of W)V5(M,$.as,H,X.many)}if(Y.hidden)for(let H of G)for(let W of Z.childFields)delete H[W]}async function e9($,Z,X){let{keys:J,byKey:z}=H5(X.parents,Z.parentFields);if(J.length===0)return;let{dialect:V}=$,Y=Z.join,G=await $$(V,Y,J.map((P)=>V.encode(P[0],X.parentKeyField)),X.executor),H=new Map,W=[];for(let P of G){let C=E0([V.decode(P[Y.parentColumn],X.parentKeyField)]),L=z.get(C);if(!L)continue;let N=V.decode(P[Y.childColumn],X.childKeyField),U=E0([N]),K=H.get(U);if(K===void 0)K=[],H.set(U,K),W.push([N]);for(let Q of L)K.push(Q)}if(W.length===0)return;let M=$.locate(X.args),D=Y5(M,Z.childFields,W,$.child,$.dialect),B=await X.executor.exec($.relation.model,"findMany",D.args,!0);for(let P of B){let C=H.get(E0([P[Z.childFields[0]]]));if(!C)continue;for(let L of C)V5(L,$.as,P,X.many)}if(D.hidden)for(let P of B)delete P[Z.childFields[0]]}async function $$($,Z,X,J){let z=R(j(`select ${$.quoteIdent(Z.parentColumn)}, ${$.quoteIdent(Z.childColumn)} from ${$.quoteIdent(Z.table)} where `),$.inList($.quoteIdent(Z.parentColumn),!1,X.length,()=>X)),{text:V,binders:Y}=m(z,$,{model:Z.table,operation:"include"}),G=C0();return J.query(V,Y.map((H)=>H(void 0,G)))}function Y5($,Z,X,J,z){let V=$===!0||$===null||typeof $!=="object"?{}:$,Y=Z.length===1?{[Z[0]]:{in:X.map((D)=>D[0])}}:Z$(J,Z,X,z),G={where:V.where===void 0?Y:{AND:[V.where,Y]}};if(V.orderBy!==void 0)G.orderBy=V.orderBy;if(V.include!==void 0)G.include=V.include;let H=V.omit;if(H!==void 0){let D=Z.filter((B)=>H[B]===!0);if(D.length===0)G.omit=H;else{let B={...H};for(let P of D)delete B[P];return G.omit=B,{args:G,hidden:!0}}}let W=V.select;if(W===void 0)return{args:G,hidden:!1};let M=Z.filter((D)=>W[D]!==!0);if(M.length===0)return G.select=W,{args:G,hidden:!1};G.select={...W};for(let D of M)G.select[D]=!0;return{args:G,hidden:!0}}function Z$($,Z,X,J){let z=Z.map((V)=>$.fields[V]?.type);if(z.every((V)=>V!==void 0)&&J.canBindCompositeIn(z))return{[a]:c4(Z,X)};return{OR:X.map((V)=>Object.fromEntries(Z.map((Y,G)=>[Y,V[G]])))}}function E0($){return JSON.stringify($.map(X$))}function V5($,Z,X,J){if(J){$[Z].push(X);return}if($[Z]===null)$[Z]=X}function H5($,Z){let X=new Map,J=[];for(let z of $){let V=Z.map((H)=>z[H]);if(V.some((H)=>H===null||H===void 0))continue;let Y=E0(V),G=X.get(Y);if(G===void 0)G=[],X.set(Y,G),J.push(V);G.push(z)}return{keys:J,byKey:X}}function X$($){if(typeof $!=="object"||$===null)return $;if($ instanceof Date)return $.getTime();if(ArrayBuffer.isView($)){let Z=new Uint8Array($.buffer,$.byteOffset,$.byteLength),X="";for(let J of Z)X+=J.toString(16).padStart(2,"0");return`bytes:${X}`}throw Error(`Cannot key a relation stitch on ${Object.prototype.toString.call($)}.`)}function a4($,Z,X){if(X.isList)throw new p($.name,Z.name,`it joins on '${X.name}', a ${X.type} list \u2014 which decodes to a new `+"array per row and so cannot be compared between the two sides.");if(X.type!=="Json")return;throw new p($.name,Z.name,`it joins on '${X.name}', a ${X.type} \u2014 which decodes to a new object `+"per row and so cannot be compared between the two sides.")}var G5=(()=>{try{return Function("return 1")()===1}catch{return!1}})(),W5=!0;function J$($){W5=$}function z$(){return G5}function k0($,Z,X=[]){if(G5&&W5)return Y$($,Z,X);return g3($,Z,X)}function g3($,Z,X=[]){let J=$.map((G)=>({key:G.name,column:G.column,field:G,decode:Z.needsDecode(G)})),z=J.length,V=X.map((G)=>({key:G.key,many:G.kind==="many"})),Y=V.length;return(G)=>{let H=[];for(let W=0;W<G.length;W++){let M=G[W],D={};for(let B=0;B<z;B++){let P=J[B],C=M[P.column];D[P.key]=P.decode?Z.decode(C,P.field):C??null}for(let B=0;B<Y;B++)D[V[B].key]=V[B].many?[]:null;H.push(D)}return H}}function Y$($,Z,X){let J=[];for(let V=0;V<$.length;V++){let Y=$[V],G=JSON.stringify(Y.name),H=JSON.stringify(Y.column);J.push(Z.needsDecode(Y)?`${G}: d.decode(row[${H}], f[${V}])`:`${G}: row[${H}] ?? null`)}for(let V of X)J.push(`${JSON.stringify(V.key)}: ${V.kind==="many"?"[]":"null"}`);let z=`
3
3
  return function shape(rows) {
4
4
  const out = [];
5
5
  for (let i = 0; i < rows.length; i++) {
@@ -8,6 +8,6 @@ import{Aa as u4,Ba as s,Ca as M5,Da as L3,Ea as R7,Fa as I7,Ga as S0,Ha as x4,Ia
8
8
  }
9
9
  return out;
10
10
  };
11
- `;try{return Function("d","f",z)(Z,$)}catch{return g3($,Z,X)}}function H3($,Z,X,J){let z=Z?.include??Z?.select;if(typeof z!=="object"||z===null)return[];let V=z[s];if(V===void 0||V===!1)return[];let Y=H$($,V,J),G=[];for(let H of Object.keys(Y).sort()){let W=Y[H];if(W===void 0||W===!1)continue;let M=$.relations[H];if(!M)throw new w0(H,$.name,Object.keys($.relations));if(W!==!0&&(typeof W!=="object"||Array.isArray(W)))throw new I(`_count.select.${H}`,$.name,J,"Expected true or an object holding 'where'.");G.push(V$($,M,W,X,J,G.length,Z))}if(G.length===0&&Z?.select)throw new I("_count.select",$.name,J,"No relations to count, and '_count' is the only thing selected. Name at least one relation, or select a column beside it.");return G}function V$($,Z,X,J,z,V,Y){let G=`_count.select.${Z.name}`;if(Z.kind!=="many")throw new _(G,$.name,z,`${Z.name} is a to-one relation. Counting it can only ever return 0 or 1, which is what its nullability already tells you.`);let H=K0($,Z,J,`_c${V}`,`${J.quoteIdent($.table)}.`,z),W=X===!0?void 0:X?.where,M=Y?.include!==void 0?"include":"select",D=(C)=>C?.[M]?.[s]?.select?.[Z.name]?.where,B=x(H.child,W,{dialect:J,operation:z,qualifier:H.qualifier},D),P=[j(`(select count(*) from ${H.source} where ${H.correlation}`)];if(B)P.push(j(" and "),B);return P.push(j(`) as ${J.quoteIdent(`_count.${Z.name}`)}`)),{as:Z.name,alias:`_count.${Z.name}`,column:R(...P)}}function H$($,Z,X){if(Z===!0){let z=M5($);if(z.length===0)throw new _("_count",$.name,X,`${$.name} has no to-many relations, so there is nothing for '_count: true' to count.`);return Object.fromEntries(z.map((V)=>[V,!0]))}if(typeof Z!=="object"||Z===null||Array.isArray(Z))throw new I("_count",$.name,X,"Expected an object holding 'select'.");let J=Z.select;if(typeof J!=="object"||J===null||Array.isArray(J))throw new I("_count.select",$.name,X,"Expected an object naming the relations to count.");return J}var o=["_count","_avg","_sum","_min","_max"],D5=new Set(["where","orderBy","take","skip",...o]),G$=new Set(["Int","Float","BigInt","Decimal"]),W$=new Set(["Json","Bytes"]),y0={_count:"count",_avg:"avg",_sum:"sum",_min:"min",_max:"max"};function y3($){return $==="aggregate"}function h0($,Z,X,J){let z=Z==="count";D$($,Z,X,z);let V=z?M$($,Z,X?.select):h3($,Z,X);if(V.length===0)throw new _(Z,$.name,Z,z?"A 'select' on a count must name at least one field, or '_all'.":`An aggregate needs at least one of ${o.join(", ")}. Prisma rejects an empty one too.`);let Y=x($,X?.where,{dialect:J,operation:Z},(L)=>L?.where),G=Y?R(j(" where "),Y):j(""),H=j(` from ${J.quoteIdent($.table)}`),W=q(V.map((L)=>j(`${y0[L.kind]}(${L.field?J.quoteIdent(L.field.column):"*"}) as ${J.quoteIdent(L.alias)}`)),", "),M=H0($,X?.orderBy,Z,{dialect:J,locate:(L)=>L?.orderBy}),D=X?.take!==void 0||X?.skip!==void 0,B;if(!D)B=R(j("select "),W,H,G);else{let{clause:L,terms:N}=M0($,Z,X,J,M),U=n(N,J),K=new Map;for(let Q of V)if(Q.field)K.set(Q.field.column,Q.field.column);if(K.size===0){let Q=$.primaryKey[0]??Object.keys($.fields)[0],T=$.fields[Q]?.column??Q;K.set(T,T)}B=R(j("select "),W,j(` from (select ${[...K.values()].map((Q)=>J.quoteIdent(Q)).join(", ")}`),H,G,U?R(j(" order by "),U):j(""),L,j(`) as ${J.quoteIdent("sub")}`))}let{text:P,binders:C}=m(B,J,{model:$.name,operation:Z});return{text:P,bind:i(C),shape(L){let N=L[0]??{};if(z){let K={};for(let Q of V)K[Q.as]=I0(Q,N[Q.alias],J);return K}let U={};for(let K of V){if(K.kind==="_count"&&K.as===G3){U._count=I0(K,N[K.alias],J);continue}let Q=U[K.kind]??={};Q[K.as]=I0(K,N[K.alias],J)}return U}}}var G3="";function h3($,Z,X){let J=[];for(let z of o){let V=X?.[z];if(V===void 0||V===!1)continue;if(z==="_count"&&V===!0){J.push({kind:z,as:G3,alias:g0(z,J.length)});continue}if(typeof V!=="object"||V===null||Array.isArray(V))throw new I(z,$.name,Z,z==="_count"?"Expected true or an object of fields.":"Expected an object of fields.");for(let Y of Object.keys(V).sort()){let G=V[Y];if(G===void 0||G===!1)continue;if(z==="_count"&&Y==="_all"){J.push({kind:z,as:"_all",alias:g0(z,J.length)});continue}let H=u0($,Z,z,Y);W3($,Z,z,H),J.push({kind:z,field:H,as:Y,alias:g0(z,J.length)})}}return J}function M$($,Z,X){if(typeof X!=="object"||X===null||Array.isArray(X))throw new I("select",$.name,Z,"Expected an object of fields.");let J=[];for(let z of Object.keys(X).sort()){let V=X[z];if(V===void 0||V===!1)continue;if(z==="_all"){J.push({kind:"_count",as:"_all",alias:g0("_count",J.length)});continue}let Y=u0($,Z,"_count",z);J.push({kind:"_count",field:Y,as:z,alias:g0("_count",J.length)})}return J}var g0=($,Z)=>`${$}_${Z}`;function u0($,Z,X,J){let z=$.fields[J];if(!z){if(J in $.relations)throw new _(`${X}.${J}`,$.name,Z,`'${J}' is a relation. Aggregate its own model instead, or use '_count' inside an 'include' to count it per row.`);throw new v(J,$.name,Object.keys($.fields))}return z}function W3($,Z,X,J){if((X==="_sum"||X==="_avg")&&!G$.has(J.type))throw new _(`${X}.${J.name}`,$.name,Z,`'${J.name}' is a ${J.type}, and ${X} needs a number. Prisma does not offer it on this field either.`);if((X==="_min"||X==="_max")&&W$.has(J.type))throw new _(`${X}.${J.name}`,$.name,Z,`'${J.name}' is a ${J.type}, which has no ordering the two dialects agree on.`)}function I0($,Z,X){if($.kind==="_count")return Number(Z??0);if(Z===null||Z===void 0)return null;if($.kind==="_avg")return Number(Z);if($.kind==="_sum"){let J=$.field?.type;if(J==="BigInt")return BigInt(String(Z));if(J==="Decimal")return Z;return Number(Z)}return $.field?X.decode(Z,$.field):Z}function D$($,Z,X,J){if(X===void 0||X===null){if(J)return;throw new _(Z,$.name,Z,`An aggregate needs at least one of ${o.join(", ")}.`)}if(typeof X!=="object"||Array.isArray(X))throw new I(String(X),$.name,Z,"Expected an object.");if(J)return;for(let z of Object.keys(X).sort()){if(X[z]===void 0)continue;if(D5.has(z))continue;if(z==="select"||z==="include")throw new _(z,$.name,Z,`An aggregate returns the functions it was given, so there is nothing to ${z==="select"?"select":"include"}. Prisma does not accept it either.`);throw new _(z,$.name,Z,`${Z} takes ${[...D5].sort().join(", ")}.`)}}var B5=new Set(["update","share"]),B$=new Set(["mode","skipLocked","noWait"]),u3='Expected "update", "share", or { mode: "update" | "share", skipLocked?: boolean, noWait?: boolean }.';function P5($,Z,X){if($===void 0)return;if(typeof $==="string"){if(B5.has($))return{mode:$,onLocked:"wait"};throw new I("lock",Z,X,u3)}if($===null||typeof $!=="object"||Array.isArray($))throw new I("lock",Z,X,u3);let J=$;for(let z of Object.keys(J))if(!B$.has(z))throw new I(`lock.${z}`,Z,X,"A lock takes mode, skipLocked and noWait.");if(typeof J.mode!=="string"||!B5.has(J.mode))throw new I("lock.mode",Z,X,u3);for(let z of["skipLocked","noWait"])if(J[z]!==void 0&&typeof J[z]!=="boolean")throw new I(`lock.${z}`,Z,X,"Expected a boolean.");if(J.skipLocked===!0&&J.noWait===!0)throw new I("lock",Z,X,"'skipLocked' and 'noWait' cannot both be set: a row another transaction holds is either left out of the result or fails the statement, not both.");return{mode:J.mode,onLocked:J.skipLocked===!0?"skipLocked":J.noWait===!0?"noWait":"wait"}}var M3={findMany:new Set(["where","orderBy","skip","take","select","include","omit","lock"]),findFirst:new Set(["where","orderBy","skip","take","select","include","omit","lock"]),findFirstOrThrow:new Set(["where","orderBy","skip","take","select","include","omit","lock"]),findUnique:new Set(["where","select","include","omit","lock"]),findUniqueOrThrow:new Set(["where","select","include","omit","lock"]),count:new Set(["where","orderBy","skip","take","select"])},P$={distinct:"Prisma's 'distinct' is applied **in memory**, not in SQL \u2014 its query log "+"shows no DISTINCT at all, and 'take' therefore does not reduce the rows pulled or paginate by group. Reproducing that faithfully would mean reading the whole result set and deduplicating in JavaScript behind an argument that reads like a database operation. Implementing it as a real 'DISTINCT ON' instead would be a silent divergence from Prisma. Write it "+"as SQL instead, with 'sql' and 'DB.query' \u2014 where what runs is what you "+"wrote, and 'distinct on' means what the database means by it.",cursor:"'cursor' is only correct under a *total* ordering, which Prisma does not "+"enforce \u2014 under a non-unique 'orderBy' it silently skips or repeats rows "+"at the page boundary. For a stable page use 'take' with a 'where' on the last row's sort key, or compose the keyset comparison with 'sql' and 'DB.query'."};function j5($){return $ in M3}var m3=new Set(["findFirst","findFirstOrThrow","findUnique","findUniqueOrThrow"]);function p3($,Z,X,J,z){if(j$($,Z,X),Z==="count"&&X?.select!==void 0&&X.select!==null)return h0($,Z,X,J);let V=Z==="count"?{plans:[],keyFields:[]}:R0($,X,J,Z,z),G=V.plans.some((E)=>E.root!==void 0)?`${J.quoteIdent($.table)}.`:void 0,H={dialect:J,operation:Z,qualifier:G},W=x($,X?.where,H,(E)=>E?.where);if(Z==="findUnique"||Z==="findUniqueOrThrow")O3($,X?.where,Z);let M=j(` from ${J.quoteIdent($.table)}`),D=W?R(j(" where "),W):j("");if(Z==="count"){let E=j(`select count(*) as ${J.quoteIdent("_count")}`),t=X?.take!==void 0||X?.skip!==void 0,d=H0($,X?.orderBy,Z,{dialect:J,locate:(F0)=>F0?.orderBy}),W0;if(!t)W0=R(E,M,D);else{let{clause:F0,terms:N3}=M0($,Z,X,J,d,m3.has(Z)),f4=n(N3,J),N9=$.primaryKey[0]??Object.keys($.fields)[0];W0=R(E,j(` from (select ${J.quoteIdent($.fields[N9].column)}`),M,D,f4?R(j(" order by "),f4):j(""),F0,j(`) as ${J.quoteIdent("sub")}`))}let{text:_0,binders:Y0}=m(W0,J,{model:$.name,operation:Z});return{text:_0,bind:i(Y0),shape(F0){let N3=F0[0];return Number(N3?._count??0)}}}let B=e($,X,Z),{plans:P,keyFields:C}=V,{fields:L,hidden:N}=X3($,B,C),U=P.filter((E)=>E.root!==void 0),K=H3($,X,J,Z),Q=q([...L.map((E)=>j(`${G??""}${J.quoteIdent(E.column)}`)),...U.map((E)=>E.root.column),...K.map((E)=>E.column)],", "),T=R(...U.map((E)=>E.root.join)),{clause:O,terms:F,reversed:A}=M0($,Z,X,J,H0($,X?.orderBy,Z,{dialect:J,locate:(E)=>E?.orderBy}),m3.has(Z)),b=n(F,J,G),S=P5(X?.lock,$.name,Z),k=R(j("select "),Q,M,T,D,b?R(j(" order by "),b):j(""),O,S?J.rowLock(S,$.table):j("")),{text:z0,binders:t0}=m(k,J,{model:$.name,operation:Z}),v4=k0(L,J,P.map((E)=>({key:E.as,kind:E.kind}))),I9=m3.has(Z);return{text:z0,bind:i(t0),relations:P.length>0?P:void 0,strategies:P.length>0?v0(P):void 0,hidden:N,shape(E){let t=v4(E);if(K.length>0)for(let d=0;d<t.length;d++){let W0=E[d]??{},_0={};for(let Y0 of K)_0[Y0.as]=Number(W0[Y0.alias]??0);t[d]._count=_0}if(U.length>0)for(let d=0;d<t.length;d++){let W0=t[d],_0=E[d]??{};for(let Y0 of U)W0[Y0.as]=Y0.root.decode(_0[Y0.as])}if(A)t.reverse();return I9?t[0]??null:t}}}function j$($,Z,X){if(X===void 0||X===null)return;if(typeof X!=="object"||Array.isArray(X))throw new I(String(X),$.name,Z,"Expected an object.");if(X.select!==void 0&&X.include!==void 0)throw new _("select + include",$.name,Z,"Prisma allows only one of them on the same query.");let J=M3[Z];for(let z of Object.keys(X).sort()){if(X[z]===void 0)continue;if(J.has(z))continue;let V=P$[z];if(V)throw new q0(z,$.name,Z,V);throw new _(z,$.name,Z,`${Z} takes ${[...J].sort().join(", ")}.`)}}var m0={name:"lateral",plan($){let Z=L5($.parent,$.relation,$.as,$.node,$.dialect,$.operation);if(Z)return k3($,`this node declined to fold (${Z})`),G0.plan($);let{dialect:X}=$,J=r($.parent,$.relation,$.as),z=V0($.parent,J,$.relation,$.operation),V=C5({parent:$.parent,child:J,relation:$.relation,as:$.as,node:$.node,locate:$.locate,link:z,dialect:X,operation:$.operation,depth:1,counter:{next:0}});return{as:$.as,model:$.relation.model,kind:$.relation.kind,parentFields:z.parentFields,strategy:"lateral",root:{column:R(j(`${V.alias}.${X.quoteIdent("data")} as `),j(X.quoteIdent($.as))),join:R(j(" left join lateral ("),V.subquery,j(`) as ${V.alias} on true`)),decode:V.decode,folded:V.folded},load:async()=>{throw Error(`${$.parent.name}.${$.as} was folded into the root statement, so it must not also be loaded. This means attachRelations stopped honouring RelationPlan.root.`)}}}};function L5($,Z,X,J,z,V){if(z.name!=="postgres")return"not postgres";if(Z.joinTable)return"implicit many-to-many";let Y=r($,Z,X);if(Y.table===$.table)return"self-relation";let G=I5(J);if(G===void 0)return;if(K$(G))return"_count on a folded node";if(_$(Y,G.orderBy))return"relation ordering on a folded node";for(let H of f0(Y,G,V)){let W=L5(Y,H.relation,H.as,H.node,z,V);if(W)return`${H.as}: ${W}`}return}function _$($,Z){if(Z===void 0||Z===null)return!1;for(let X of Array.isArray(Z)?Z:[Z]){if(typeof X!=="object"||X===null)continue;for(let[J,z]of Object.entries(X)){if(z===void 0)continue;if(J in $.relations)return!0}}return!1}function K$($){for(let Z of["include","select"]){let X=$[Z];if(typeof X!=="object"||X===null||Array.isArray(X))continue;let J=X[s];if(J!==void 0&&J!==!1)return!0}return!1}function C5($){let{dialect:Z,child:X,operation:J}=$,z=I5($.node),V=$.relation.kind==="many",Y=$.counter.next++,G=Z.quoteIdent(K5("__lat_",$.as,$.depth,Y)),H=Z.quoteIdent(X.table),W=`${H}.`,M=e(X,z,J),D=f0(X,z,J).map((S)=>{let k=r(X,S.relation,S.as);return{as:S.as,relation:S.relation,fold:C5({parent:X,child:k,relation:S.relation,as:S.as,node:S.node,locate:(z0)=>S.locate($.locate(z0)),link:V0(X,k,S.relation,J),dialect:Z,operation:J,depth:$.depth+1,counter:$.counter})}}),B=T$(M,W,Z,D.map((S)=>({key:S.as,alias:S.fold.alias}))),P=R(...D.map((S)=>R(j(" left join lateral ("),S.fold.subquery,j(`) as ${S.fold.alias} on true`)))),C=j($.link.parentFields.map((S,k)=>`${W}${Z.quoteIdent(T5(X,$.link.childFields[k]).column)} = ${Z.quoteIdent($.parent.table)}.${Z.quoteIdent(T5($.parent,S).column)}`).join(" and ")),L=x(X,z?.where,{dialect:Z,operation:J,qualifier:W},(S)=>$.locate(S)?.where),N=R(j(` from ${H}`),P,j(" where "),C,L?R(j(" and "),L):j("")),U=L$(M,Z,V,D.map((S)=>({key:S.as,decode:S.fold.decode}))),K=D.map((S)=>({as:S.as,model:S.relation.model,kind:S.relation.kind,folded:S.fold.folded})),Q=H0(X,z?.orderBy,J);if(!V)return{alias:G,folded:K,decode:U,subquery:R(j("select "),B,j(` as ${Z.quoteIdent("data")}`),N,j(" limit 1"))};let T=Q$($,z,Q,X);if(!T){let S=n(Q,Z,W);return{alias:G,folded:K,decode:U,subquery:R(j("select coalesce(json_agg("),B,S?R(j(" order by "),S):j(""),j(`), '[]'::json) as ${Z.quoteIdent("data")}`),N)}}let O=Z.quoteIdent(K5("__page_",$.as,$.depth,Y)),F=T.terms.map((S,k)=>j(`, ${W}${Z.quoteIdent(S.column)} as ${Z.quoteIdent(R5(k))}`)),A=n(_5(T.inner),Z),b=n(_5(T.terms),Z,`${O}.`);return{alias:G,folded:K,decode:U,subquery:R(j(`select coalesce(json_agg(${O}.${Z.quoteIdent("data")}`),b?R(j(" order by "),b):j(""),j(`), '[]'::json) as ${Z.quoteIdent("data")} from (select `),B,j(` as ${Z.quoteIdent("data")}`),...F,N,A?R(j(" order by "),A):j(""),T.clause,j(`) as ${O}`))}}function Q$($,Z,X,J){let z=Z?.take,V=Z?.skip;if(z===void 0&&V===void 0)return;let Y=X.length>0?X:J.primaryKey.map((W)=>({column:J.fields[W]?.column??W,direction:"asc"})),G=z===void 0?null:(W)=>Math.abs(Number($.locate(W)?.take)),H=V===void 0?null:(W)=>Number($.locate(W)?.skip);return{clause:$.dialect.paginate(G,H),terms:Y,inner:typeof z==="number"&&z<0?$3(Y):Y}}var R5=($)=>`__ord_${$}`;function _5($){return $.map((Z,X)=>({...Z,column:R5(X),expression:void 0}))}function K5($,Z,X,J){return X===1?`${$}${Z}`:`${$}${Z}_${J}`}function I5($){if($===!0||$===void 0||$===null)return;if(typeof $!=="object"||Array.isArray($))return;return $}function T$($,Z,X,J){let z=$.map((V)=>{let Y=`${Z}${X.quoteIdent(V.column)}`,G=V.type==="BigInt"?`${Y}::text${V.isList?"[]":""}`:Y;return`'${V.name}', ${G}`});for(let V of J)z.push(`'${V.key}', ${V.alias}.${X.quoteIdent("data")}`);return j(`json_build_object(${z.join(", ")})`)}function L$($,Z,X,J){let z=$.map((Y)=>({field:Y,convert:C$(Y)})).filter((Y)=>Y.convert!==void 0),V=(Y)=>{if(Y===null||Y===void 0||typeof Y!=="object")return null;let G=Y;for(let{field:H,convert:W}of z)G[H.name]=W(G[H.name]);for(let H of J)G[H.key]=H.decode(G[H.key]);return G};return(Y)=>{let G=typeof Y==="string"?R$(Y):Y??null;if(X){if(!Array.isArray(G))return[];return G.map(V).filter((H)=>H!==null)}return V(G)}}function C$($){if($.isList){let Z=Q5($);if(!Z)return;return(X)=>{if(X===null||X===void 0)return null;if(!Array.isArray(X))return X;return X.map((J)=>J===null||J===void 0?null:Z(J))}}return Q5($)}function Q5($){switch($.type){case"DateTime":return(Z)=>Z===null||Z===void 0?null:Z instanceof Date?Z:new Date(String(Z));case"BigInt":return(Z)=>Z===null||Z===void 0?null:BigInt(String(Z));case"Json":return;case"Bytes":return(Z)=>{if(Z===null||Z===void 0)return null;if(ArrayBuffer.isView(Z))return Buffer.isBuffer(Z)?new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength):Z;let X=Buffer.from(String(Z).replace(/^\\?x/,""),"hex");return new Uint8Array(X.buffer,X.byteOffset,X.byteLength)};default:return}}function R$($){try{return JSON.parse($)}catch{return null}}function T5($,Z){let X=$.fields[Z];if(!X)throw Error(`${$.name} has no field '${Z}', which the lateral strategy needs to correlate on. This means the generated artifact is stale.`);return X}function N5($){return $.name==="postgres"?m0:G0}function d3($,Z,X){if($===void 0)return N5(Z);if($==="batched")return G0;if($==="lateral")return m0;throw new _(`strategy: ${JSON.stringify($)}`,X.model,X.operation,'Unknown relation strategy. Expected "batched" or "lateral".')}var I$=2,c3=21;class s3 extends Error{constructor($){super(`The generated model artifact is version ${$}, but this version of gemi reads version 2. Re-run \`prisma generate\` to refresh app/models/generated.`);this.name="StaleSchemaArtifactError"}}function N$($){if($!==2)throw new s3($)}var U$=new Set(["cuid","uuid","nanoid","ulid","now","value"]);function O5($){return U$.has($.kind)}function p0($){if($.isUpdatedAt)return!0;return $.default!==void 0&&O5($.default)}function n3($,Z){if($.isUpdatedAt)return Z;let X=$.default;if(!X)return;switch(X.kind){case"cuid":return S5();case"uuid":return b5(X.version??4);case"nanoid":return F5(X.length??c3);case"ulid":return A5();case"now":return Z;case"value":return X.value;default:return}}function o3($,Z){let X=$.length,J=256-256%X,z=new Uint8Array(Z);crypto.getRandomValues(z);let V="";for(let Y=0;Y<Z;Y++){let G=z[Y];while(G>=J){let H=new Uint8Array(1);crypto.getRandomValues(H),G=H[0]}V+=$[G%X]}return V}var O$="0123456789abcdefghijklmnopqrstuvwxyz",i3=36,t3=4,S$=i3**t3,F$=0;function A$($,Z){return $.length>=Z?$:"0".repeat(Z-$.length)+$}var b$=l3();function l3(){return o3(O$,t3)}function S5(){let $=Date.now().toString(i3),Z=A$((F$++%S$).toString(i3),t3);return`c${$}${Z}${b$}${l3()}${l3()}`}var E$="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function F5($=c3){return o3(E$,$)}var U5="0123456789ABCDEFGHJKMNPQRSTVWXYZ",q$=10,w$=16;function A5($=Date.now()){let Z="",X=$;for(let J=0;J<q$;J++)Z=U5[X%32]+Z,X=Math.floor(X/32);return Z+o3(U5,w$)}function b5($=4){return $===7?v$():crypto.randomUUID()}var x$=Array.from({length:256},($,Z)=>Z.toString(16).padStart(2,"0"));function v$(){let $=new Uint8Array(16);crypto.getRandomValues($);let Z=Date.now();$[0]=Math.floor(Z/1099511627776)&255,$[1]=Math.floor(Z/4294967296)&255,$[2]=Z>>>24&255,$[3]=Z>>>16&255,$[4]=Z>>>8&255,$[5]=Z&255,$[6]=$[6]&15|112,$[8]=$[8]&63|128;let X=x$;return X[$[0]]+X[$[1]]+X[$[2]]+X[$[3]]+"-"+X[$[4]]+X[$[5]]+"-"+X[$[6]]+X[$[7]]+"-"+X[$[8]]+X[$[9]]+"-"+X[$[10]]+X[$[11]]+X[$[12]]+X[$[13]]+X[$[14]]+X[$[15]]}var f$=["connect","connectOrCreate","create","createMany","disconnect","delete","update","set","updateMany","deleteMany","upsert"],E5=new Set(f$),k$=["disconnect","delete","update","set","updateMany","deleteMany","upsert"],g$=new Set(k$),y$=["createMany","set","updateMany","deleteMany"],v5=new Set(y$.filter(($)=>$!=="createMany")),f5=new Set(["create","createMany"]),h$={},q5={contributions:[],before:[],after:[],keyFields:[]};function B3($,Z,X,J,z){if(typeof Z!=="object"||Z===null||Array.isArray(Z))return q5;let V=Object.keys(Z).sort().filter((H)=>(H in $.relations)).filter((H)=>Z[H]!==void 0);if(V.length===0)return q5;let Y={contributions:[],before:[],after:[],keyFields:[]},G=new Map;for(let H of V){let W=$.relations[H],M=Z[H],D=(P)=>J(P)?.[H],B=Y.contributions.length;u$($,W,M,X,D,Y,z);for(let P=B;P<Y.contributions.length;P++){let C=Y.contributions[P].field,L=G.get(C);if(L!==void 0&&L!==H)throw new _(`data.${H}`,$.name,X,`'${C}' is written by both the '${L}' and '${H}' relations, which join on it in common. Prisma lets the last key in 'data' win; gemi plans relations in a fixed order and will not guess which row you meant. Write one of them through the relation and set the other's own columns directly.`);G.set(C,H)}}return Y}function u$($,Z,X,J,z,V,Y){if(typeof X!=="object"||X===null||Array.isArray(X))throw new I(`data.${Z.name}`,$.name,J,"Expected an object holding 'connect' or 'create'.");let G=Object.keys(X).sort().filter((D)=>X[D]!==void 0);if(G.length===0)return;let H=r($,Z),W=V0($,H,Z,J);if(W.join){let D=J5(W,$,Z,J);for(let B of G)c$($,Z,H,D,B,X[B],J,(P)=>z(P)?.[B],V,Y);return}for(let D of G){if(!E5.has(D)){let B=h$[D];throw new _(`data.${Z.name}.${D}`,$.name,J,`Only ${[...E5].sort().join(", ")} are implemented.`+(B?` '${D}' is not: ${B}`:""))}if(g$.has(D)&&f5.has(J))throw new _(`data.${Z.name}.${D}`,$.name,J,`'${D}' acts on rows already linked to this one, and a '${J}' `+"has none yet \u2014 Prisma refuses it here too. Use it on an 'update'.")}let M=Z.from.length>0;for(let D of G){let B=X[D],P=(C)=>z(C)?.[D];if(M)m$($,Z,H,W,D,B,J,P,V);else p$($,Z,H,W,D,B,J,P,V)}}function m$($,Z,X,J,z,V,Y,G,H){let{parentFields:W,childFields:M}=J,D=()=>{for(let K of W)H.contributions.push({field:K,value:(Q,T)=>T.resolved[K]})},B=(K,Q)=>{for(let T=0;T<W.length;T++)K.resolved[W[T]]=Q[T]??null},P=Object.values(X.relations).filter((K)=>K.relationName===Z.relationName&&!(X.name===$.name&&K.name===Z.name)),C=new Set(W),L=W.every((K)=>$.fields[K]?.nullable===!0)&&$.uniques.some((K)=>K.length===C.size&&K.every((Q)=>C.has(Q)))&&P.length===1&&P[0].kind!=="many",N=!f5.has(Y);if(z==="createMany")throw new _(`data.${Z.name}.createMany`,$.name,Y,`'${Z.name}' is a to-one: this row holds the foreign key, so there is one related row at most and nothing to create many of. Prisma does not accept it here either.`);if(z==="create"){H.before.push({relation:Z.name,operation:"create",async run(K,Q,T){let O=await T.exec(Z.model,"create",{data:G(K),select:w(M)},!1);B(Q,u(O,M))}}),D();return}if(z==="disconnect"){$4($,Z,W,{model:$.name,operation:Y,argument:`data.${Z.name}.disconnect`}),y5($,Z,X,V,z,Y);let K=Z4(z,V);if(K===null||K===void 0)return;if(V===!0){for(let Q of W)H.contributions.push({field:Q,value:()=>null});return}H.before.push({relation:Z.name,operation:"disconnect",async run(Q,T,O){B(T,x5(W));let F=await O.exec($.name,"findFirst",{where:Q?.where,select:w(W)},!0),A=u(F,W);if(!c0(A))return;if(B(T,A),await O.exec(Z.model,"findFirst",{where:B0(G(Q),h(J,F)),select:w(M)},!1))B(T,x5(W))}}),D();return}if(z==="delete")throw new _(`data.${Z.name}.delete`,$.name,Y,`'${Z.name}' is a to-one whose foreign key lives on this row, so deleting through it would remove a row this statement is not about. Delete it directly, or 'disconnect' it first.`);if(z==="update"){H.keyFields.push(...W),e3($,Z,X,z,V,Y),H.after.push({relation:Z.name,operation:"update",async run(K,Q,T,O){let F=O[0];if(!F)return;if(!c0(u(F,W)))throw new Z0(Z.model,"update");let A=G(K),b=A!==null&&typeof A==="object"&&A.data!==void 0,S=A,k=b?S.data:A,z0=b?S.where:void 0,t0=B0(z0,h(J,F));if(z0!==void 0){if(!await T.exec(Z.model,"findFirst",{where:t0,select:w(M)},!1))throw new Z0(Z.model,"update")}await T.exec(Z.model,"updateMany",{where:t0,data:k},!1)}});return}if(v5.has(z))throw new _(`data.${Z.name}.${z}`,$.name,Y,`'${Z.name}' is a to-one: this row holds a single foreign key, so there is no set of rows for '${z}' to act on. Prisma does not accept it here either. Use 'connect', 'disconnect' or 'update'.`);if(z==="upsert"){e3($,Z,X,z,V,Y),k5($,Z,X,V,Y,!1),H.before.push({relation:Z.name,operation:"upsert",async run(K,Q,T){let O=G(K),F=await T.exec($.name,"findFirst",{where:K?.where,select:w(W)},!0);if(c0(u(F,W))){let b=B0(O?.where,h(J,F)),S=await T.exec(Z.model,"findFirst",{where:b,select:w(M)},!1);if(S){B(Q,u(S,M)),await T.exec(Z.model,"updateMany",{where:b,data:O?.update},!1);return}}let A=await T.exec(Z.model,"create",{data:O?.create,select:w(M)},!1);B(Q,u(A,M))}}),D();return}if(z==="connectOrCreate"){J4($,Z,X,V,Y,!1),H.before.push({relation:Z.name,operation:"connectOrCreate",async run(K,Q,T){let O=G(K)?.where,F=await T.exec(Z.model,"findUnique",{where:O,select:w(M)},!1);if(F){let b=u(F,M);if(L)await a3($,W,b,K?.where,N,T);B(Q,b);return}let A=await T.exec(Z.model,"create",{data:G(K)?.create,select:w(M)},!1);B(Q,u(A,M))}}),D();return}if(typeof V!=="object"||V===null||Array.isArray(V))throw new I(`data.${Z.name}.connect`,$.name,Y,"Expected an object naming a unique field.");if(M.length===1&&V[M[0]]!==void 0&&Object.keys(V).filter((K)=>V[K]!==void 0).length===1){let K=M[0],Q=W[0];if(L)H.before.push({relation:Z.name,operation:"connect",async run(T,O,F){await a3($,[Q],[G(T)?.[K]],T?.where,N,F)}});H.contributions.push({field:Q,value:(T)=>G(T)?.[K]});return}y(X,V,{model:$.name,operation:Y,argument:`data.${Z.name}.connect`}),H.before.push({relation:Z.name,operation:"connect",async run(K,Q,T){let O=await T.exec(Z.model,"findUniqueOrThrow",{where:G(K),select:w(M)},!1),F=u(O,M);if(L)await a3($,W,F,K?.where,N,T);B(Q,F)}}),D()}function p$($,Z,X,J,z,V,Y,G,H){let{parentFields:W,childFields:M}=J;H.keyFields.push(...W);let D=Z.kind!=="many"&&M.every((P)=>X.fields[P]?.nullable===!0),B=V;if(Z.kind!=="many"){if(v5.has(z))throw new _(`data.${Z.name}.${z}`,$.name,Y,`'${Z.name}' is a to-one: there is a single ${X.name} row, so there is no set of rows for '${z}' to act on. Prisma does not offer it on a to-one either. Use 'connect', 'disconnect' or 'update'.`);if(Array.isArray(V))throw new I(`data.${Z.name}.${z}`,$.name,Y,`'${Z.name}' is a to-one \u2014 ${X.name} holds the foreign key, so there is one row here at most. Expected a single object for '${z}', not an array of them. Prisma refuses the array too.`);e3($,Z,X,z,V,Y);let P=G;G=(C)=>Z4(z,P(C)),V=Z4(z,V)}if(z==="upsert"){k5($,Z,X,V,Y,Z.kind==="many"),H.after.push({relation:Z.name,operation:"upsert",async run(P,C,L,N){let U=N[0];if(!U)return;for(let K of $0(G(P))){let Q=B0(K.where,h(J,U));if(await L.exec(Z.model,"findFirst",{where:Q,select:w(M)},!1)){await L.exec(Z.model,"updateMany",{where:Q,data:K.update},!1);continue}await L.exec(Z.model,"create",{data:{...K.create,...h(J,U)},select:w(M)},!1)}}});return}if(z==="updateMany"||z==="deleteMany"){let P=z==="updateMany";i$($,Z,V,z,Y),H.after.push({relation:Z.name,operation:z,async run(C,L,N,U){let K=U[0];if(!K)return;let Q=G(C),T=P?Q?.where:Q,O=B0(T,h(J,K));await N.exec(Z.model,z,P?{where:O,data:Q?.data}:{where:O},!1)}});return}if(z==="set"){D3($,Z,X,V,"set",Y),$4(X,Z,M,{model:$.name,operation:Y,argument:`data.${Z.name}.set`}),H.after.push({relation:Z.name,operation:"set",async run(P,C,L,N){let U=N[0];if(!U)return;let K=h(J,U);await d0(Z.model,M,u(U,W),L);for(let Q of $0(G(P)))await L.exec(Z.model,"updateMany",{where:Q,data:K},!1)}});return}if(z==="update"){l$($,Z,X,V,Y,Z.kind==="many"),H.after.push({relation:Z.name,operation:"update",async run(P,C,L,N){let U=N[0];if(!U)return;let K=$0(G(P));for(let Q=0;Q<K.length;Q++){let T=K[Q],O=B0(T.where,h(J,U));if(!await L.exec(Z.model,"findFirst",{where:O,select:w(M)},!1))throw new Z0(Z.model,"update");await L.exec(Z.model,"updateMany",{where:O,data:T.data},!1)}}});return}if(z==="disconnect"||z==="delete"){let P=z==="delete";if(!P)$4(X,Z,M,{model:$.name,operation:Y,argument:`data.${Z.name}.disconnect`});if(Z.kind==="many")D3($,Z,X,V,z,Y);else y5($,Z,X,B,z,Y);H.after.push({relation:Z.name,operation:z,async run(C,L,N,U){let K=U[0];if(!K)return;let Q=$0(G(C));for(let T=0;T<Q.length;T++){let O=B0(Q[T],h(J,K));if(!P){await N.exec(Z.model,"updateMany",{where:O,data:g5(M)},!1,M);continue}if(!await N.exec(Z.model,"findFirst",{where:O,select:w(M)},!1)){if(Z.kind!=="many")throw new Z0(Z.model,"delete");throw new _(`data.${Z.name}.delete`,$.name,Y,`the row named by ${JSON.stringify(Q[T])} is not connected to this ${$.name}. Prisma raises here too, rather than deleting a row belonging to somebody else.`)}await N.exec(Z.model,"deleteMany",{where:O},!1)}}});return}if(z==="create"){H.after.push({relation:Z.name,operation:"create",async run(P,C,L,N){let U=N[0];if(!U)return;if(D)await d0(Z.model,M,u(U,W),L);for(let K of $0(G(P)))await L.exec(Z.model,"create",{data:{...K,...h(J,U)},select:w(M)},!1)}});return}if(z==="createMany"){if(Z.kind!=="many")throw new _(`data.${Z.name}.createMany`,$.name,Y,`'${Z.name}' is a to-one, so there is nothing to create many of. Prisma does not accept it here either.`);n$($,Z,V,Y),H.after.push({relation:Z.name,operation:"createMany",async run(P,C,L,N){let U=N[0];if(!U)return;let K=$0(G(P)?.data).map((Q)=>({...Q,...h(J,U)}));await L.exec(Z.model,"createMany",{data:K},!1)}});return}if(z==="connectOrCreate"){J4($,Z,X,V,Y,Z.kind==="many"),H.after.push({relation:Z.name,operation:"connectOrCreate",async run(P,C,L,N){let U=N[0];if(!U)return;let K=$0(G(P));for(let Q=0;Q<K.length;Q++){let T=K[Q],O=await L.exec(Z.model,"findUnique",{where:T.where,select:w(M)},!1);if(O){if(D&&M.every((F,A)=>X4(O[F],U[W[A]])))continue;if(D)await d0(Z.model,M,u(U,W),L);await L.exec(Z.model,"update",{where:T.where,data:h(J,U),select:w(M)},!1,M);continue}await L.exec(Z.model,"create",{data:{...T.create,...h(J,U)},select:w(M)},!1)}}});return}D3($,Z,X,V,z,Y),H.after.push({relation:Z.name,operation:"connect",async run(P,C,L,N){let U=N[0];if(!U)return;let K=[];for(let Q of $0(G(P))){if(D&&await s$(Z.model,M,Q,u(U,W),L))continue;K.push(Q)}if(K.length===0)return;if(D)await d0(Z.model,M,u(U,W),L);for(let Q of K)await L.exec(Z.model,"update",{where:Q,data:h(J,U),select:w(M)},!1,M)}})}var w5=new Set(["connect","connectOrCreate","disconnect","set","create"]),d$={createMany:"Prisma does not offer 'createMany' through an implicit many-to-many "+"either \u2014 it reports it as an unknown argument. Use 'create', which writes "+"the row and its pair.",update:"Reaching the far row means reading the pairs first, which this path does not do yet. Update the related model directly, filtered by its own key.",updateMany:"As 'update': it needs the pairs read before the far rows can be matched.",delete:"It deletes the far row rather than the pair \u2014 Prisma does this through a "+"join table too \u2014 and reaching it means reading the pairs first, which "+"this path does not do yet. Use 'disconnect' to remove the link, or delete the row through its own model.",deleteMany:"As 'delete': the far rows have to be found through the pairs first."};function c$($,Z,X,J,z,V,Y,G,H,W){if(z==="connectOrCreate")J4($,Z,X,V,Y,Z.kind==="many");if(!w5.has(z)){let C=d$[z];if(C)throw new _(`data.${Z.name}.${z}`,$.name,Y,`'${Z.name}' is an implicit many-to-many, and '${z}' means something different through a join table. ${C}`);throw new _(`data.${Z.name}.${z}`,$.name,Y,`'${Z.name}' is an implicit many-to-many. Only ${[...w5].sort().join(", ")} are implemented through its join table.`)}if(z==="connect"||z==="disconnect"||z==="set")D3($,Z,X,V,z,Y);let{join:M,parentField:D,childField:B}=J,P=(C)=>W.quoteIdent(C);H.keyFields.push(D),H.after.push({relation:Z.name,operation:z,async run(C,L,N,U){let K=U[0];if(!K)return;let Q=K[D];if(Q===null||Q===void 0)return;if(z==="set"){let F=await N.query(`select ${P(M.childColumn)} from ${P(M.table)} where ${P(M.parentColumn)} = ${W.placeholder(0)}`,[Q]),A=Array.from(F,(b)=>b[M.childColumn]);if(A.length>0){let b=await N.exec(Z.model,"findMany",{where:{[B]:{in:A}},select:{[B]:!0}},!1),S=Array.from(b,(k)=>k[B]);if(S.length>0)await r3(N,`delete from ${P(M.table)} where ${P(M.parentColumn)} = ${W.placeholder(0)} and ${P(M.childColumn)} in (`+S.map((k,z0)=>W.placeholder(z0+1)).join(", ")+")",[Q,...S])}}let T=$0(G(C));if(T.length===0)return;let O=[];for(let F of T){if(z==="create"){let b=await N.exec(Z.model,"create",{data:F,select:{[B]:!0}},!1);if(b)O.push(b[B]);continue}if(z==="connectOrCreate"){let b=F,S=await N.exec(Z.model,"findUnique",{where:b.where,select:{[B]:!0}},!1);if(S){O.push(S[B]);continue}let k=await N.exec(Z.model,"create",{data:b.create,select:{[B]:!0}},!1);if(k)O.push(k[B]);continue}let A=await N.exec(Z.model,"findUniqueOrThrow",{where:F,select:{[B]:!0}},!1);if(A)O.push(A[B])}for(let F of O){if(z==="disconnect"){await r3(N,`delete from ${P(M.table)} where ${P(M.parentColumn)} = ${W.placeholder(0)} and ${P(M.childColumn)} = ${W.placeholder(1)}`,[Q,F]);continue}await r3(N,`insert into ${P(M.table)} (${P(M.parentColumn)}, ${P(M.childColumn)}) values (${W.placeholder(0)}, ${W.placeholder(1)}) on conflict do nothing`,[Q,F])}}})}async function r3($,Z,X){await $.query(Z,X)}function k5($,Z,X,J,z,V){let Y=`data.${Z.name}.upsert`,G=Array.isArray(J)?J:[J];for(let H of G){if(typeof H!=="object"||H===null||Array.isArray(H))throw new _(Y,$.name,z,V?"Expected an object with 'where', 'create' and 'update'.":"Expected an object with 'create' and 'update' \u2014 on a to-one the "+"'where' is optional, since the parent's key already names the row.");let W=H,M=V?["where","create","update"]:["create","update"];for(let D of M)if(W[D]===void 0)throw new _(Y,$.name,z,`Expected a '${D}' key \u2014 'upsert' names the row to look for, `+"what to write if it is there, and what to write if it is not.");if(!V)continue;y(X,W.where,{model:$.name,operation:z,argument:`data.${Z.name}.upsert.where`})}}function B0($,Z){if($===void 0||$===null||typeof $!=="object"||Array.isArray($)||Object.keys($).length===0)return Z;return{AND:[$,Z]}}function h($,Z){let X={};for(let J=0;J<$.childFields.length;J++)X[$.childFields[J]]=Z[$.parentFields[J]];return X}function w($){let Z={};for(let X of $)Z[X]=!0;return Z}function g5($){let Z={};for(let X of $)Z[X]=null;return Z}function x5($){return $.map(()=>null)}function u($,Z){return Z.map((X)=>$?.[X])}function c0($){return $.every((Z)=>Z!==null&&Z!==void 0)}async function d0($,Z,X,J){if(!c0(X))return;let z={};for(let Y=0;Y<Z.length;Y++)z[Z[Y]]=X[Y];if((await J.exec($,"findMany",{where:z,select:w(Z)},!1)).length===0)return;await J.exec($,"updateMany",{where:z,data:g5(Z)},!1,Z)}async function s$($,Z,X,J,z){let V=await z.exec($,"findUnique",{where:X,select:w(Z)},!1);if(V===null||V===void 0)return!1;return Z.every((Y,G)=>X4(V[Y],J[G]))}async function a3($,Z,X,J,z,V){if(!c0(X))return;if(z){let Y=await V.exec($.name,"findFirst",{where:J,select:w(Z)},!0);if(Y===null||Y===void 0)return;if(Z.every((G,H)=>X4(Y[G],X[H])))return}await d0($.name,Z,X,V)}function X4($,Z){if($===null||$===void 0||Z===null||Z===void 0)return!1;return $===Z||String($)===String(Z)}function i$($,Z,X,J,z){let V=`data.${Z.name}.${J}`;if(typeof X!=="object"||X===null||Array.isArray(X))throw new _(V,$.name,z,J==="updateMany"?"Expected an object with 'where' and 'data'.":"Expected an object of filters \u2014 'deleteMany' takes the filter "+"directly, not wrapped in a 'where'.");if(J!=="updateMany")return;let Y=X;for(let G of["where","data"])if(Y[G]===void 0)throw new _(V,$.name,z,`Expected a '${G}' key \u2014 'updateMany' names which rows to `+"write and what to write to them.")}function l$($,Z,X,J,z,V){let Y=`data.${Z.name}.update`,G=Array.isArray(J)?J:[J],H=[];for(let W of G){if(typeof W!=="object"||W===null||Array.isArray(W))throw new _(Y,$.name,z,"Expected an object with 'where' and 'data'.");let M=W,D=V?["where","data"]:["data"];for(let B of D)if(M[B]===void 0)throw new _(Y,$.name,z,`Expected a '${B}' key \u2014 'update' names the row to write and `+"the columns to write to it.");if(V)y(X,M.where,{model:$.name,operation:z,argument:`data.${Z.name}.update.where`});H.push(M)}return H}function D3($,Z,X,J,z,V){let Y=`data.${Z.name}.${z}`,G=Array.isArray(J)?J:[J],H=[];for(let W of G){if(typeof W!=="object"||W===null||Array.isArray(W))throw new _(Y,$.name,V,"Expected an object naming a unique field, or an array of them.");y(X,W,{model:$.name,operation:V,argument:`data.${Z.name}.${z}`}),H.push(W)}return H}function y5($,Z,X,J,z,V){if(J===void 0)return;if(typeof J==="boolean")return;if(J!==null&&typeof J==="object"&&!Array.isArray(J))return;throw new I(`data.${Z.name}.${z}`,$.name,V,`'${Z.name}' is a to-one, so '${z}' takes either a boolean \u2014 `+`'true' for the connected ${X.name}, 'false' for nothing \u2014 or an `+`object of filters it has to match. Prisma's operand here is '${X.name}WhereInput | boolean'.`+(J===null?" 'null' is not one of them \u2014 write 'false' for the no-op. Prisma "+"answers 'null' with a validation error rather than accepting it.":""))}function e3($,Z,X,J,z,V){if(J!=="update"&&J!=="upsert")return;let Y=`data.${Z.name}.${J}`,G=(D)=>{throw new I(Y,$.name,V,D)};if(z===null||typeof z!=="object"||Array.isArray(z))G(`Expected an object, got ${JSON.stringify(z)??typeof z}. `+(J==="upsert"?"'upsert' on a to-one takes { create, update } \u2014 and an optional "+`'where' the connected ${X.name} has to match.`:`'update' on a to-one takes the ${X.name} columns directly, `+"or { data } \u2014 and an optional 'where' the connected row has to "+"match."));let H=z;if(!(J==="upsert"||H.data!==void 0))return;let M=J==="upsert"?["where","create","update"]:["where","data"];for(let D of Object.keys(H)){if(H[D]===void 0||M.includes(D))continue;G(`Unknown key '${D}'. '${J}' on a to-one takes ${M.map((B)=>`'${B}'`).join(", ")} and nothing else, so '${D}' would be dropped rather than applied \u2014 a misspelled `+"'where' would turn a filtered write into an unconditional one. Prisma refuses the same key by name.")}if(H.where!==void 0&&(H.where===null||typeof H.where!=="object"||Array.isArray(H.where)))G("'where' has to be an object of filters \u2014 Prisma's is a "+`'${X.name}WhereInput', which narrows *which* single row is written rather than choosing among several. Anything else is dropped by the conjunction that keeps this operand on the connected row, so the write would land unfiltered.`)}function $4($,Z,X,J){let z=X.find((V)=>!$.fields[V]?.nullable);if(z===void 0)return;throw new _(J.argument,J.model,J.operation,`'${$.name}.${z}' is required, so there is no value to leave `+"behind \u2014 a disconnected row would have to be deleted or repointed "+"instead. Prisma does not offer 'disconnect' on a required relation either.")}function J4($,Z,X,J,z,V){let Y=`data.${Z.name}.connectOrCreate`;if(Array.isArray(J)&&!V){let W=Z.from.length>0;throw new I(Y,$.name,z,`'${Z.name}' is a to-one: `+(W?"this row holds the foreign key":`${X.name} holds the foreign key`)+", so there is one row to point at and a list has no meaning. Prisma "+"refuses an array here too \u2014 as a validation error on the argument, "+"which is why this is a bad value rather than a gap.")}let G=Array.isArray(J)?J:[J];if(G.length===0)return[];let H=[];for(let W of G){if(typeof W!=="object"||W===null||Array.isArray(W))throw new _(Y,$.name,z,"Expected an object with 'where' and 'create'.");let M=W;for(let B of["where","create"])if(M[B]===void 0)throw new _(Y,$.name,z,`Expected a '${B}' key \u2014 'connectOrCreate' names the row to `+"look for and the row to write if it is not there.");let D=Object.keys(M).filter((B)=>B!=="where"&&B!=="create"&&M[B]!==void 0);if(D.length>0)throw new _(Y,$.name,z,`Unexpected ${D.sort().join(", ")} \u2014 'connectOrCreate' takes `+"'where' and 'create'.");y(X,M.where,{model:$.name,operation:z,argument:`data.${Z.name}.connectOrCreate.where`}),H.push(M)}return H}function n$($,Z,X,J){let z=`data.${Z.name}.createMany`;if(typeof X!=="object"||X===null||Array.isArray(X))throw new I(z,$.name,J,"Expected an object with a 'data' key \u2014 the rows go inside it, not "+"directly under 'createMany'.");let V=Object.keys(X).filter((Y)=>X[Y]!==void 0);if(!V.includes("data"))throw new I(z,$.name,J,"Expected a 'data' key.");for(let Y of V){if(Y==="data")continue;throw new _(`${z}.${Y}`,$.name,J,Y==="skipDuplicates"?`'skipDuplicates' is not implemented on a *nested* 'createMany'. Write the children with their own '${Z.model}.createMany' call, which takes it.`:"Expected only 'data'.")}}function $0($){if($===void 0||$===null)return[];return Array.isArray($)?$:[$]}function Z4($,Z){if($==="update"){if(Z!==null&&typeof Z==="object"&&Z.data!==void 0){let X=Z;return{where:X.where,data:X.data}}return{where:void 0,data:Z}}if($==="delete"||$==="disconnect"){if(Z===!0)return{};if(Z===!1)return null;return Z}return Z}var G4={create:new Set(["data","select","include","omit"]),createMany:new Set(["data","skipDuplicates"]),update:new Set(["data","where","select","include","omit"]),updateMany:new Set(["data","where"]),delete:new Set(["where","select","include","omit"]),deleteMany:new Set(["where"]),upsert:new Set(["where","create","update","select","include","omit"])},o$=new Set(["create","update","delete","upsert"]),u5=new Set(["createMany","updateMany","deleteMany"]);function m5($){return $ in G4}function W4($,Z,X,J){if(G6($,Z,X),!J.supportsReturning)throw new H4($.name,Z,J.name);switch(Z){case"create":return t$($,Z,X,J);case"createMany":return r$($,Z,X,J);case"update":case"updateMany":return $6($,Z,X,J);case"delete":case"deleteMany":return Z6($,Z,X,J);case"upsert":return X6($,Z,X,J);default:throw new _(Z,$.name,Z,`'${Z}' is not a write operation. The writes are ${Object.keys(G4).sort().join(", ")}.`)}}function t$($,Z,X,J){let z=B3($,X?.data,Z,(H)=>H?.data,J),V=p5($,X?.data,z.contributions,Z,J,(H)=>H?.data),Y=s0($,X,J,Z,z),G=R(j(`insert into ${J.quoteIdent($.table)}`),D4([V],J),Y.clause);return j3($,G,J,Z,Y,z)}function r$($,Z,X,J){let z=X?.data===void 0?[]:r5(X.data),V=a$($,Z,X,J);if(z.length===0)return t5($,Z,J);let Y=e$($,z,Z,J);if(Y[0].length===0&&z.length>1)throw new _("data",$.name,Z,`All ${z.length} rows are empty and ${$.name} has no client-side default to fill, so there is no column to insert. A multi-row insert of nothing but database defaults cannot be expressed on both dialects. Call create ${z.length} times, or set at least one field per row.`);let G=s0($,void 0,J,Z,void 0),H=R(j(`insert into ${J.quoteIdent($.table)}`),D4(Y,J),V??j(""),G.clause),{text:W,binders:M}=m(H,J,{model:$.name,operation:Z});return{text:W,bind:i(M),shape:(D)=>({count:D.length})}}function a$($,Z,X,J){let z=X?.skipDuplicates;if(z===void 0)return null;if(typeof z!=="boolean")throw new I("skipDuplicates",$.name,Z,`Expected true or false, got ${JSON.stringify(z)}.`);let V=J.ignoreConflicts();if(V===null)throw new _("skipDuplicates",$.name,Z,`'skipDuplicates' is not available on ${J.name}. Prisma does not `+"offer it there either \u2014 it is a Postgres and MySQL argument. To "+"import a batch that may overlap, write the rows one at a time and catch UniqueConstraintError, or move this model to Postgres.");return z?V:null}function e$($,Z,X,J){let z=Z.map((Y,G)=>{if(typeof Y!=="object"||Y===null||Array.isArray(Y))throw new I(`data[${G}]`,$.name,X,"Expected an object.");let H=new Set;for(let[W,M]of Object.entries(Y)){if(M===void 0)continue;if(W in $.relations)throw new _(`data.${W}`,$.name,X,"createMany cannot contain nested writes. Use create per row.");if(!(W in $.fields))throw new v(W,$.name,Object.keys($.fields));H.add(W)}return H}),V=[];for(let Y of Object.values($.fields))if(z.some((H)=>H.has(Y.name))||p0(Y)||z4(Y))V.push(Y);for(let Y of V){if(!z.some((W)=>!W.has(Y.name)))continue;if(p0(Y))continue;if(Y.nullable)continue;if(z4(Y))continue;if(Y.default)throw new _(`data.${Y.name}`,$.name,X,`Some rows set '${Y.name}' and others leave it to the database default. A single multi-row insert cannot express both. Split the call, or set '${Y.name}' on every row.`);let H=z.findIndex((W)=>!W.has(Y.name));throw new P3($.name,`${X}.data[${H}]`,Y.name)}for(let Y of V)if(Y.isList)T0($,Y,`data.${Y.name}`,X,J);return Z.map((Y,G)=>V.map((H)=>{if(!z[G].has(H.name))return{field:H,value:z4(H)?o5(H,J):j4(H,J)};if(H.isList)B4($,H,Y?.[H.name],X,["set"]);let W=d5(H,Y?.[H.name]);return{field:H,value:N0($,X,H,J,(M)=>{let D=r5(M?.data)[G]?.[H.name];return W?D?.set:D})}}))}function $6($,Z,X,J){let z=Z==="updateMany";if(X?.data===null)throw new I("data",$.name,Z,"Expected an object of the fields to set, like { name: 'new name' }. An empty object is accepted and reads the row back unchanged; null is not.");if(!z)y($,X?.where,{model:$.name,operation:Z,argument:"where"});if(z)c5($,X?.data,Z,"data","updateMany cannot contain nested writes \u2014 it has no single row to "+"attach them to. Use update per row.");let V=z?void 0:B3($,X?.data,Z,(D)=>D?.data,J),Y=s5($,X?.data,V?.contributions??[],Z,J),G=x($,X?.where,{dialect:J,operation:Z},(D)=>D?.where);if(z&&Y.length===0)return t5($,Z,J);let H=Y.length===0,W=s0($,X,J,Z,V),M=H?R(j("select "),W.selected,j(` from ${J.quoteIdent($.table)}`),G?R(j(" where "),G):j("")):R(j(`update ${J.quoteIdent($.table)} set `),q(Y,", "),G?R(j(" where "),G):j(""),W.clause);return j3($,M,J,Z,W,V)}function Z6($,Z,X,J){if(Z==="delete")y($,X?.where,{model:$.name,operation:Z,argument:"where"});let z=x($,X?.where,{dialect:J,operation:Z},(G)=>G?.where),V=s0($,X,J,Z,void 0),Y=R(j(`delete from ${J.quoteIdent($.table)}`),z?R(j(" where "),z):j(""),V.clause);return j3($,Y,J,Z,V,void 0)}function X6($,Z,X,J){let z=y($,X?.where,{model:$.name,operation:Z,argument:"where"}),V=z.length>1?z.join("_"):z[0],Y=Object.keys(X.where).filter((L)=>L!==V&&X.where[L]!==void 0);if(Y.length>0)throw new _("where",$.name,Z,`The where clause carries ${Y.join(", ")} beside the unique key '${V}'. An upsert compiles its where into an 'on conflict' target, which can only be a key, so the extra ${Y.length===1?"filter would be":"filters would be"} silently dropped. Name exactly one unique key here \u2014 or, if you meant `+"to filter further, use findFirst plus update / create.");for(let L of["create","update"])c5($,X?.[L],Z,L,"Nested writes inside an upsert are not implemented: they would have to run before it is known whether the row is being inserted or updated.");let G=M4($,X,z);if(G.length>0)throw new _("upsert",$.name,Z,`The where clause selects on ${z.join(", ")}, but 'create' does not set ${G.join(", ")}, so 'on conflict' cannot express it. Model.upsert runs this as a read and a write inside one transaction instead; reaching this means the statement was compiled directly.`);let H=J6(p5($,X?.create,[],Z,J,(L)=>L?.create),$,z,Z,J),W=`${J.quoteIdent($.table)}.`,M=s5($,X?.update,[],Z,J,(L)=>L?.update,W),D=q(z.map((L)=>j(J.quoteIdent(Y4($,L).column))),", "),B=M.length>0?M:[j(`${J.quoteIdent(Y4($,z[0]).column)} = ${W}${J.quoteIdent(Y4($,z[0]).column)}`)],P=s0($,X,J,Z,void 0),C=R(j(`insert into ${J.quoteIdent($.table)}`),D4([H],J),j(" on conflict ("),D,j(") do update set "),q(B,", "),P.clause);return j3($,C,J,Z,P,void 0)}function M4($,Z,X){let J=P4($,Z?.create);return X.filter((z)=>!J.has(z))}function J6($,Z,X,J,z){let V=new Set(X);return $.map((Y)=>{if(!V.has(Y.field.name))return Y;let G=Y6(X,Y.field.name);return{field:Y.field,value:(H,W)=>{let M=Y.value(H,W),D=z.encode(G(H),Y.field);if(!z6(M,D))throw new _("upsert",Z.name,J,`'${Y.field.name}' is ${h5(D)} in the where clause but ${h5(M)} in 'create'. An upsert looks the row up by the where clause and inserts what 'create' says, so the two must agree on the key.`);return M}}})}function z6($,Z){if($===Z)return!0;if($ instanceof Date&&Z instanceof Date)return $.getTime()===Z.getTime();if(ArrayBuffer.isView($)&&ArrayBuffer.isView(Z)){let X=new Uint8Array($.buffer,$.byteOffset,$.byteLength),J=new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength);if(X.length!==J.length)return!1;for(let z=0;z<X.length;z++)if(X[z]!==J[z])return!1;return!0}return!1}function h5($){if($ instanceof Date)return JSON.stringify($.toISOString());if(ArrayBuffer.isView($)){let Z=new Uint8Array($.buffer,$.byteOffset,$.byteLength),X=Array.from(Z.slice(0,8),(z)=>z.toString(16).padStart(2,"0")).join(""),J=Z.length>8?"\u2026":"";return`${Z.length} bytes (0x${X}${J})`}if(typeof $==="string")return JSON.stringify($);if($===null||$===void 0)return String($);return`${JSON.stringify(String($))} (${typeof $})`}function Y6($,Z){let X=$.length>1?$.join("_"):void 0;return(J)=>{let z=J?.where;if(z===void 0||z===null)return;if(X!==void 0&&z[X]!==void 0)return z[X][Z];return z[Z]}}function D4($,Z){let X=$[0];if(X.length===0)return j(" default values");let J=q(X.map((V)=>j(Z.quoteIdent(V.field.column))),", "),z=$.map((V)=>R(j("("),q(V.map((Y)=>g(Y.field,Z,Y.value)),", "),j(")")));return R(j(" ("),J,j(") values "),q(z,", "))}function p5($,Z,X,J,z,V){if(Z!==void 0&&Z!==null){if(typeof Z!=="object"||Array.isArray(Z))throw new I("data",$.name,J,"Expected an object.")}let Y=P4($,Z),G=new Map(X.map((W)=>[W.field,W]));for(let W of G.keys())if(Y.has(W))throw new _(`data.${W}`,$.name,J,`'${W}' is set both directly and through a nested relation write. Prisma keeps those two forms exclusive; use one of them.`);let H=[];for(let W of Object.values($.fields)){let M=G.get(W.name);if(M){H.push({field:W,value:(D,B)=>z.encode(M.value(D,B),W)});continue}if(Y.has(W.name)){if(W.isList)T0($,W,`data.${W.name}`,J,z),B4($,W,Z?.[W.name],J,["set"]);let D=d5(W,Z?.[W.name]);H.push({field:W,value:N0($,J,W,z,(B)=>{let P=V(B)?.[W.name];return D?P?.set:P})});continue}if(p0(W)){H.push({field:W,value:j4(W,z)});continue}if(W.default||W.nullable)continue;if(W.isList){T0($,W,`data.${W.name}`,J,z),H.push({field:W,value:o5(W,z)});continue}throw new P3($.name,J,W.name)}return H}function B4($,Z,X,J,z){if(!Z.isList)return;if(typeof X!=="object"||X===null||Array.isArray(X)||X instanceof Date||ArrayBuffer.isView(X))return;let V=Object.keys(X).filter((Y)=>X[Y]!==void 0);if(V.length===1&&z.includes(V[0]))return;throw new _(`data.${Z.name}`,$.name,J,`'${Z.name}' is a scalar list, so it takes ${z.join(" or ")} \u2014 `+`or a bare array. Received ${V.length===0?"an empty object":`{ ${V.join(", ")} }`}. The arithmetic operators apply to a number, not to a list of them.`)}function d5($,Z){return $.isList===!0&&typeof Z==="object"&&Z!==null&&!Array.isArray(Z)&&!(Z instanceof Date)&&!ArrayBuffer.isView(Z)&&Object.keys(Z).length===1&&"set"in Z}function P4($,Z){let X=new Set;if(typeof Z!=="object"||Z===null)return X;for(let[J,z]of Object.entries(Z)){if(z===void 0)continue;if(J in $.relations)continue;if(!(J in $.fields))throw new v(J,$.name,Object.keys($.fields));X.add(J)}return X}function c5($,Z,X,J,z){if(typeof Z!=="object"||Z===null||Array.isArray(Z))return;for(let[V,Y]of Object.entries(Z)){if(Y===void 0)continue;if(V in $.relations)throw new _(`${J}.${V}`,$.name,X,z)}}function s5($,Z,X,J,z,V=(G)=>G?.data,Y=""){if(Z!==void 0&&Z!==null){if(typeof Z!=="object"||Array.isArray(Z))throw new I("data",$.name,J,"Expected an object.")}let G=P4($,Z),H=new Map(X.map((D)=>[D.field,D])),W=H.size>0||G.size>0,M=[];for(let D of Object.values($.fields)){let B=z.quoteIdent(D.column),P=H.get(D.name);if(P){M.push(R(j(`${B} = `),c((C,L)=>z.encode(P.value(C,L),D))));continue}if(G.has(D.name)){M.push(V6($,D,B,`${Y}${B}`,Z,J,z,(C)=>V(C)?.[D.name]));continue}if(D.isUpdatedAt&&W)M.push(R(j(`${B} = `),g(D,z,j4(D,z))))}return M}var i5={increment:"+",decrement:"-",multiply:"*",divide:"/"},l5=["set","push"];function n5($){return $.isList?l5:["set",...Object.keys(i5)]}function V6($,Z,X,J,z,V,Y,G){let H=z[Z.name];if(Z.isList)T0($,Z,`data.${Z.name}`,V,Y),B4($,Z,H,V,l5);if(H6(H,Z)){let W=Object.keys(H).filter((B)=>H[B]!==void 0);if(W.length!==1)throw new _(`data.${Z.name}`,$.name,V,`Expected exactly one of ${n5(Z).join(", ")}.`);let[M]=W,D=(B)=>G(B)?.[M];if(M==="set")return R(j(`${X} = `),g(Z,Y,N0($,V,Z,Y,D)));if(M==="push")return R(j(`${X} = `),Y.listPush(J,g(Z,Y,N0($,V,Z,Y,(B)=>{let P=D(B);return Array.isArray(P)?P:[P]}))));return R(j(`${X} = ${J} ${i5[M]} `),g(Z,Y,N0($,V,Z,Y,D)))}return R(j(`${X} = `),g(Z,Y,N0($,V,Z,Y,G)))}function H6($,Z){if(typeof $!=="object"||$===null||Array.isArray($)||$ instanceof Date||ArrayBuffer.isView($)||Z.type==="Json"&&!Z.isList)return!1;let X=n5(Z),J=Object.keys($);if(J.length===0)return!1;return J.every((z)=>X.includes(z))}function N0($,Z,X,J,z){return(V)=>{let Y=z(V);if(f(Y)==="any")throw new I(`data.${X.name}`,$.name,Z,"Prisma.AnyNull is a filter operand, not a value \u2014 Prisma rejects it "+"in a write here too. Write Prisma.DbNull for a SQL NULL column, or Prisma.JsonNull for the JSON value null.");if(X.isList&&Y!==null&&Y!==void 0){if(!Array.isArray(Y))throw new I(`data.${X.name}`,$.name,Z,`'${X.name}' is a scalar list, so it takes an array \u2014 or `+`{ set: [...] } / { push: \u2026 }. Received ${typeof Y}.`);if(Y.some((G)=>f(G)==="any"))throw new I(`data.${X.name}`,$.name,Z,"Prisma.AnyNull is a filter operand, not a value, and that does not change for being inside a list.")}return J.encode(Y,X)}}function o5($,Z){return()=>Z.encode([],$)}function z4($){return $.isList===!0&&!$.default&&!$.nullable}function j4($,Z){return(X,J)=>Z.encode(n3($,J.now),$)}function s0($,Z,X,J,z){if(u5.has(J))return{clause:j(` returning ${V4($,X)}`),selected:j(V4($,X)),fields:[],relations:[],counts:[]};let V=e($,Z,J),{plans:Y,keyFields:G}=R0($,Z,X,J),{fields:H,hidden:W}=X3($,V,[...G,...z?.keyFields??[]]),M=H3($,Z,X,J),D=q([...H.map((B)=>j(X.quoteIdent(B.column))),...M.map((B)=>B.column)],", ");return{clause:R(j(" returning "),D),selected:D,fields:H,hidden:W,relations:Y,counts:M}}function t5($,Z,X){let J=V4($,X),{text:z,binders:V}=m(j(`select ${J} from ${X.quoteIdent($.table)} where false`),X,{model:$.name,operation:Z});return{text:z,bind:i(V),shape:(Y)=>({count:Y.length})}}function V4($,Z){let X=$.primaryKey[0]??Object.keys($.fields)[0];return Z.quoteIdent($.fields[X].column)}function Y4($,Z){let X=$.fields[Z];if(!X)throw new v(Z,$.name,Object.keys($.fields));return X}function j3($,Z,X,J,z,V){let{text:Y,binders:G}=m(Z,X,{model:$.name,operation:J}),H=k0(z.fields,X,z.relations.map((D)=>({key:D.as,kind:D.kind}))),W=o$.has(J),M=u5.has(J);return{text:Y,bind:i(G),relations:z.relations.length>0?z.relations:void 0,strategies:z.relations.length>0?v0(z.relations):void 0,hidden:z.hidden,before:V&&V.before.length>0?V.before:void 0,after:V&&V.after.length>0?V.after:void 0,counts:z.counts.length>0?!0:void 0,shape(D){if(M)return{count:D.length};let B=H(D);if(z.counts.length>0)for(let P=0;P<B.length;P++){let C=D[P]??{},L={};for(let N of z.counts)L[N.as]=Number(C[N.alias]??0);B[P]._count=L}return W?B[0]??null:B}}}function r5($){if($===void 0||$===null)return[];return Array.isArray($)?$:[$]}function G6($,Z,X){if(X===void 0||X===null)throw new _("args",$.name,Z,`${Z} requires arguments.`);if(typeof X!=="object"||Array.isArray(X))throw new I(String(X),$.name,Z,"Expected an object.");if(X.select!==void 0&&X.include!==void 0)throw new _("select + include",$.name,Z,"Prisma allows only one of them on the same query.");let J=G4[Z];for(let z of Object.keys(X).sort()){if(X[z]===void 0)continue;if(!J.has(z))throw new _(z,$.name,Z,`${Z} takes ${[...J].sort().join(", ")}.`)}for(let z of W6(Z))if(X[z]===void 0)throw new _(z,$.name,Z,`${Z} requires '${z}'.`)}function W6($){switch($){case"create":case"createMany":return["data"];case"update":return["data","where"];case"updateMany":return["data"];case"delete":return["where"];case"upsert":return["where","create","update"];default:return[]}}function M6($,Z,X,J,z){if($!=="postgres")return null;if(J.length>0)return null;if(z===0)return null;if(!/^\s*select/i.test(X))return null;let V=Object.values(Z.fields).filter((Y)=>Y.type==="DateTime").map((Y)=>Y.name);if(V.length===0)return null;return`[gemi] ${Z.name} was read with a query that binds no parameters, on Postgres, in a process whose clock is not UTC. Bun decodes timestamp(3) over the simple query protocol as local time, so ${V.length===1?"the column":"columns"} ${V.join(", ")} will be off by this machine's UTC offset \u2014 the same `+'row read through a query that binds a parameter returns a different instant. Set TZ=UTC on this process. See "Run Postgres deployments with TZ=UTC" in docs/orm.md. (Warned once.)'}function D6($,Z){if(Z===void 0)return new Date($).getTimezoneOffset();let X=new Intl.DateTimeFormat("en-US",{timeZone:Z,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date($)),J=(V)=>Number(X.find((Y)=>Y.type===V)?.value),z=Date.UTC(J("year"),J("month")-1,J("day"),J("hour"),J("minute"),J("second"));return($-z)/60000}function a5($){let Z=new Date().getUTCFullYear();for(let X=0;X<12;X++)if(D6(Date.UTC(Z,X,1),$)!==0)return!0;return!1}function e5($,Z){let X=!1;return(J,z,V,Y)=>{if(!$||X)return null;let G=M6(J,z,V,Y,Z());if(G!==null)X=!0;return G}}var $9=new Set(["by","where","orderBy","having","take","skip",...o]);function _4($){return $==="groupBy"}function K4($,Z,X,J){R6($,Z,X);let z=P6($,Z,X?.by),V=h3($,Z,X),Y=j(` from ${J.quoteIdent($.table)}`),G=x($,X?.where,{dialect:J,operation:Z},(T)=>T?.where),H=G?R(j(" where "),G):j(""),W=q([...z.map((T)=>j(`${J.quoteIdent(T.field.column)} as ${J.quoteIdent(T.alias)}`)),...V.map((T)=>j(B6(T,J)))],", "),M=R(j(" group by "),q(z.map((T)=>j(J.quoteIdent(T.field.column))),", ")),D=X9($,Z,X?.having,z,J),B=D?R(j(" having "),D):j(""),P=L6($,Z,X?.orderBy,z,J),C=P?R(j(" order by "),P):j(""),N=X?.take!==void 0||X?.skip!==void 0?M0($,Z,X,J,[]).clause:j(""),U=R(j("select "),W,Y,H,M,B,C,N),{text:K,binders:Q}=m(U,J,{model:$.name,operation:Z});return{text:K,bind:i(Q),shape(T){return T.map((O)=>{let F={};for(let A of V){if(A.kind==="_count"&&A.as===G3){F._count=I0(A,O[A.alias],J);continue}let b=F[A.kind]??={};b[A.as]=I0(A,O[A.alias],J)}for(let A of z)F[A.field.name]=J.needsDecode(A.field)?J.decode(O[A.alias],A.field):O[A.alias];return F})}}}function B6($,Z){let X=$.field?Z.quoteIdent($.field.column):"*";return`${y0[$.kind]}(${X}) as ${Z.quoteIdent($.alias)}`}function P6($,Z,X){let J=typeof X==="string"?[X]:X;if(!Array.isArray(J))throw new _("by",$.name,Z,`Expected a field name or an array of them, got ${JSON.stringify(X)}.`);if(J.length===0)throw new _("by",$.name,Z,"At least one field is required to group by. Prisma rejects an empty "+"'by' too \u2014 without one there is nothing to group, and the answer "+"would be 'aggregate'.");let z=[],V=new Set;for(let Y of J){if(typeof Y!=="string")throw new _("by",$.name,Z,`Expected field names, got ${JSON.stringify(Y)}.`);if(V.has(Y))continue;if(V.add(Y),Y in $.relations)throw new _(`by.${Y}`,$.name,Z,`'${Y}' is a relation. A group is a set of rows of this model, so only its own columns can name one.`);let G=$.fields[Y];if(!G)throw new v(Y,$.name,Object.keys($.fields));z.push({field:G,alias:`_by_${z.length}`})}return z}function X9($,Z,X,J,z,V=(Y)=>Y?.having){if(X===void 0||X===null)return null;if(typeof X!=="object"||Array.isArray(X))throw new _("having",$.name,Z,"Expected an object of field filters.");let Y=X,G=[];for(let H of Object.keys(Y).sort()){let W=Y[H];if(W===void 0)continue;if(H==="AND"||H==="OR"||H==="NOT"){let B=j6($,Z,H,W,J,z,V);if(B)G.push(B);continue}let M=_6(W),D=K6($,Z,H,J,M);if(M){Q6($,Z,H,W);for(let B of o){let P=W[B];if(P===void 0)continue;W3($,Z,B,D),G.push(Z9(`${y0[B]}(${z.quoteIdent(D.column)})`,P,$,Z,`having.${H}.${B}`,(C)=>V(C)?.[H]?.[B],z))}continue}G.push(Z9(z.quoteIdent(D.column),W,$,Z,`having.${H}`,(B)=>V(B)?.[H],z))}if(G.length===0)return null;return G.length===1?G[0]:R(j("("),q(G," and "),j(")"))}function j6($,Z,X,J,z,V,Y){let G=Array.isArray(J)?J:[J],H=[];for(let M=0;M<G.length;M++){let D=Array.isArray(J)?(P)=>Y(P)?.[X]?.[M]:(P)=>Y(P)?.[X],B=X9($,Z,G[M],z,V,D);if(B)H.push(B)}if(H.length===0)return X==="OR"?j("false"):null;let W=H.length===1?H[0]:R(j("("),q(H,X==="OR"?" or ":" and "),j(")"));return X==="NOT"?R(j("not ("),W,j(")")):W}function _6($){if(typeof $!=="object"||$===null||Array.isArray($))return!1;return o.some((Z)=>(Z in $))}function K6($,Z,X,J,z){let V=u0($,Z,"_count",X);if(z)return V;if(J.some((Y)=>Y.field.name===V.name))return V;throw new _(`having.${X}`,$.name,Z,`'${X}' is not in 'by'. A 'having' filter on a plain column needs the `+"column to be grouped \u2014 a group has one value for those and many for "+`everything else. Prisma refuses this too. Add '${X}' to 'by', aggregate it instead ('having: { ${X}: { _count: { \u2026 } } }'), or `+"filter the rows with 'where' rather than the groups with 'having'.")}function Q6($,Z,X,J){let z=Object.keys(J).filter((V)=>!o.includes(V));if(z.length===0)return;throw new _(`having.${X}`,$.name,Z,"A 'having' filter is either a comparison on a grouped column or a filter "+"on an aggregate of it, not both \u2014 this one mixes "+`${z.sort().join(", ")} with an aggregate. Prisma's query engine panics on this shape rather than answering it, so there is no behaviour to match. Use an 'AND' of the two filters instead.`)}var J9={equals:"=",not:"<>",lt:"<",lte:"<=",gt:">",gte:">="},T6=J9;function Z9($,Z,X,J,z,V,Y){if(typeof Z!=="object"||Z===null||Z instanceof Date)return R(j(`${$} = `),c((W)=>Y.encodeUntyped(V(W))));let G=Z,H=[];for(let W of Object.keys(G).sort()){let M=G[W];if(M===void 0)continue;let D=T6[W];if(!D)throw new _(`${z}.${W}`,X.name,J,`A 'having' filter takes ${Object.keys(J9).sort().join(", ")}.`);if(M===null){H.push(j(`${$} is ${W==="not"?"not ":""}null`));continue}H.push(R(j(`${$} ${D} `),c((B)=>Y.encodeUntyped(V(B)?.[W]))))}if(H.length===0)return j("true");return H.length===1?H[0]:R(j("("),q(H," and "),j(")"))}function L6($,Z,X,J,z){if(X===void 0||X===null)return null;let V=Array.isArray(X)?X:[X],Y=[];for(let G of V){if(typeof G!=="object"||G===null)throw new _("orderBy",$.name,Z,"Expected an object of fields, or an array of them.");for(let H of Object.keys(G)){let W=G[H];if(W===void 0)continue;if(o.includes(H)){Y.push(...C6($,Z,H,W,z));continue}let M=$.fields[H];if(!M)throw new v(H,$.name,Object.keys($.fields));if(!J.some((D)=>D.field.name===M.name))throw new _(`orderBy.${H}`,$.name,Z,`'${H}' is not in 'by'. Every field an 'orderBy' names has to be one of the grouped columns, because a group has one value for those and many for everything else. Prisma refuses this too.`);Y.push(`${z.quoteIdent(M.column)} ${_3($,Z,H,W)}`)}}if(Y.length===0)return null;return j(Y.join(", "))}function C6($,Z,X,J,z){if(typeof J!=="object"||J===null||Array.isArray(J))throw new _(`orderBy.${X}`,$.name,Z,"Expected an object of fields.");let V=[],Y=J;for(let G of Object.keys(Y)){let H=Y[G];if(H===void 0)continue;if(X==="_count"&&G==="_all"){V.push(`count(*) ${_3($,Z,`${X}._all`,H)}`);continue}let W=u0($,Z,X,G);W3($,Z,X,W),V.push(`${y0[X]}(${z.quoteIdent(W.column)}) ${_3($,Z,`${X}.${G}`,H)}`)}return V}function _3($,Z,X,J){if(J==="asc"||J==="desc")return J;if(typeof J==="object"&&J!==null&&!Array.isArray(J)){let{sort:z,nulls:V}=J,Y=_3($,Z,X,z);if(V===void 0)return Y;if(V!=="first"&&V!=="last")throw new _(`orderBy.${X}.nulls`,$.name,Z,`Expected 'first' or 'last', got ${JSON.stringify(V)}.`);return`${Y} nulls ${V}`}throw new _(`orderBy.${X}`,$.name,Z,`Expected 'asc', 'desc', or { sort, nulls }, got ${JSON.stringify(J)}.`)}function R6($,Z,X){if(X===void 0||X===null||typeof X!=="object")throw new _("by",$.name,Z,"groupBy requires 'by'.");for(let J of Object.keys(X).sort()){if(X[J]===void 0)continue;if($9.has(J))continue;throw new _(J,$.name,Z,`${Z} takes ${[...$9].sort().join(", ")}.`)}if(X.by===void 0)throw new _("by",$.name,Z,"groupBy requires 'by'.")}function Q4($,Z,X,J,z){if(y3(Z))return h0($,Z,X,J);if(_4(Z))return K4($,Z,X,J);if(j5(Z))return p3($,Z,X,J,z);if(m5(Z))return W4($,Z,X,J);throw new _(Z,$.name,Z,`'${Z}' is not an operation this ORM compiles \u2014 the reads, the writes, `+"'aggregate' and 'groupBy' are, and a raw statement goes through 'DB.query' or 'DB.execute'.")}var Y9=1000,X0=new Map,T4=0,L4=0,C4=0,I6=new Set(["orderBy","select","omit","include","distinct","mode","_count","_avg","_sum","_min","_max","skipDuplicates","by"]),N6=new Set(["_count","_avg","_sum","_min","_max"]);function J0($,Z=!1,X=!1,J=!1){if($===null)return"null";if($===void 0)return"undefined";let z=typeof $;if(z!=="object")return Z?JSON.stringify($):z;if($ instanceof Date)return"date";let V=f($);if(V)return`jsonNull:${V}`;if(Array.isArray($))return`[${$.map((G)=>J0(G,Z,X,J)).join(",")}]`;return`{${Object.entries($).filter(([,G])=>G!==void 0).sort(([G],[H])=>G<H?-1:G>H?1:0).map(([G,H])=>`${G}:${F6(G,H,Z,X,J)}`).join(",")}}`}var U6=new Set(["in","notIn","hasEvery","hasSome","push","path"]),O6="$compositeIn";function z9($){return $.length===0?"[]":"[*]"}var S6=new Set(["where","cursor","data"]);function F6($,Z,X,J,z){if($==="take"&&typeof Z==="number")return`number:${Math.sign(Z)}`;if($==="skip"&&typeof Z==="number")return"number";if(J&&U6.has($)&&Array.isArray(Z)){if($!=="path"||Z.every((V)=>typeof V==="string"))return z9(Z)}if($===O6){let V=Z;return J0(J?{fields:V.fields,values:z9(V.values)}:Z,!0,J)}if(($==="disconnect"||$==="delete")&&typeof Z==="boolean")return JSON.stringify(Z);if(S6.has($))return J0(Z,!1,J,z);if($==="having")return J0(Z,!1,J,!0);if(z&&N6.has($))return J0(Z,!1,J,!0);return J0(Z,X||I6.has($),J,z)}function V9($,Z,X,J,z="batched"){return`${$.name}:${z}:${Z}:${X}:${J0(J,!1,$.bindsListAsOneParameter)}${A6(J)}`}function A6($){if($===null||typeof $!=="object")return"";let Z=$.lock;return Z===void 0?"":`:lock=${J0(Z,!0)}`}function i0($,Z,X,J,z){let V=V9(J,$.name,Z,X,z?.name),Y=X0.get(V);if(Y)return L4++,X0.delete(V),X0.set(V,Y),Y;let G=Q4($,Z,X,J,z);if(T4++,X0.size>=Y9){let H=X0.keys().next();if(!H.done)X0.delete(H.value),C4++}return X0.set(V,G),G}function b6(){return{size:X0.size,compiles:T4,hits:L4,evictions:C4,capacity:Y9}}function E6(){X0.clear(),T4=0,L4=0,C4=0}var H9=new WeakMap;function K3($,Z,X=P0()){let J={},z={},V=$;for(let Y of Object.keys(V)){if(!(Y in Z.fields))continue;J[Y]=V[Y]}for(let Y of Z.primaryKey)z[Y]=V[Y];H9.set($,{model:Z.name,connection:X,key:z,snapshot:J})}function j0($){if($===null||typeof $!=="object")return;return H9.get($)}function R4($,Z){let X=j0($);if(!X)return{};let J=$,z={};for(let V of Object.keys(X.snapshot))if(!x6(J[V],X.snapshot[V]))z[V]=J[V];return q6($,X,Z),z}function q6($,Z,X){for(let J of Object.keys($)){if(J in Z.snapshot)continue;if(!(J in X.fields))continue;if(J in X.relations)continue;throw new _(`save.${J}`,X.name,"save",`'${J}' was not fetched by the query this row came from, so save `+"cannot write it \u2014 the diff has nothing to compare it against, and "+`writing it blind would overwrite whatever the column actually holds. Select '${J}' in the query, or update it explicitly with ${X.name}.update({ where, data: { ${J} } }).`)}}function Q3($,Z){let X=j0($);if(!X)return;for(let J of Object.keys(Z))X.snapshot[J]=Z[J]}function G9($,Z){let X=$===null||$===void 0?String($):Array.isArray($)?"an array":typeof $;return new _("save",Z,"save","This object carries no provenance, so there is no row to update. Either "+"the query did not ask for it \u2014 pass { track: true } as the second "+`argument, e.g. ${Z}.findUnique({ where }, { track: true }) \u2014 or this `+`is a copy of a row that did. Provenance is keyed on object identity, so spreading, cloning or JSON round-tripping a row loses it. (Received ${X}.)`)}function w6($){return j0($)!==void 0}function x6($,Z){if($===Z)return!0;if($ instanceof Date&&Z instanceof Date)return $.getTime()===Z.getTime();if(ArrayBuffer.isView($)&&ArrayBuffer.isView(Z)){let X=new Uint8Array($.buffer,$.byteOffset,$.byteLength),J=new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength);if(X.length!==J.length)return!1;for(let z=0;z<X.length;z++)if(X[z]!==J[z])return!1;return!0}return!1}var v6=new Set(["findFirstOrThrow","findUniqueOrThrow","update","delete"]);function l0($,Z){return q4($.sql,Z,{slowTransactionThreshold:$.config.slowTransactionThreshold,connection:$.name})}var W9=new WeakMap;class R3{constructor(){}static $schema;static $policies;static $connection;static on($){let Z=W9.get(this);if(Z===void 0)W9.set(this,Z=new Map);let X=Z.get($);if(X!==void 0)return X;let J=class extends this{static $connection=$};return Object.defineProperty(J,"name",{value:this.name,configurable:!0}),Z.set($,J),J}static asSystem($){return b4($)}static asUser($,Z){return E4($,Z)}static async save($){let Z=this.$modelSchema(),X=j0($);if(!X)throw G9($,Z.name);if(X.model!==Z.name)throw new _("save",Z.name,"save",`This row came from ${X.model}, not ${Z.name}. Save it through the model it was read from.`);if(this.$connection!==void 0&&this.$connection!==X.connection)throw new _("save",Z.name,"save",`This row was read on the "${X.connection}" connection and this save names "${this.$connection}". A save writes the row back where it came from, so the two cannot both be honoured. Drop the \`on("${this.$connection}")\`, or write it as an explicit ${Z.name}.on("${this.$connection}").update({ where, data }) if copying it across connections is what you meant.`);let J=Z.primaryKey.filter((Y)=>X.key[Y]===void 0);if(J.length>0)throw new _("save",Z.name,"save",`This row was fetched without ${J.join(", ")}, so there is no way to identify which row to update. A tracked row needs its primary key: add ${J.map((Y)=>`${Y}: true`).join(", ")} to the select, or drop the select to fetch every column.`);let z=R4($,Z);if(Object.keys(z).length===0)return null;let V=await T3(X.connection,()=>this.$exec("update",{where:X.key,data:z}));if(V&&typeof V==="object"&&!Array.isArray(V)){let Y=V,G=$,H={};for(let W of Object.keys(Y)){if(!(W in Z.fields))continue;G[W]=Y[W],H[W]=Y[W]}Q3($,H)}else Q3($,z);return V}static wrap($){let Z=this.$modelSchema(),X=new this;return Object.assign(X,$),K3(X,Z,this.$connection??j0($)?.connection??P0()),X}save(){return this.constructor.save(this)}static $modelSchema(){let $=this.$schema;if(!$)throw new x0(this.name);return $}static async transaction($){let Z=this.$connection??P0();return l0(N4(I4).connection(Z),()=>T3(Z,()=>$()))}static async $exec($,Z={},X){return T3(this.$connection??P0(),()=>this.$execute($,Z,X))}static async $execute($,Z={},X){let J=this.$modelSchema(),z=N4(I4).connection(P0()),V=w4(z.dialect),Y=n0()??z.sql;if(Z?.lock!==void 0&&M3[$]?.has("lock")&&n0()===void 0)throw new F4(J.name,$);let G=A4(),H=G?[]:S0(this),W,M=Z;if(!G){let K=L0(J.name)?D0(J.name):void 0;if(K!==void 0&&K!==this&&!f6(this,K)){let Q=S0(K);if(H.length!==Q.length||H.some((O,F)=>O!==Q[F]))throw new O4(J.name,K.name??String(K),this.name,H.length>0?"queried":"registered")}}let D=D9(X);if(!G&&!D)M=Q9(J,M,o0(),G,(K)=>{if(!L0(K))return;let Q=D0(K),T=Q.$schema;if(!T)return;return{policies:S0(Q),schema:T}});if($==="upsert"&&!D&&m6(J,Z,$)){let{where:K,create:Q,update:T,...O}=Z;return l0(z,async()=>{return await this.$exec("findFirst",{where:K},X)===null?await this.$exec("create",{data:Q,...O},X):await this.$exec("update",{where:K,data:T,...O},X)})}if(H.length>0){if(W=L3(J.name,(D?_9(X):void 0)??$,o0(),G),!D)M=x4(H,W,M,P9(X))}let B=d3(X?.strategy,V,{model:J.name,operation:$});if($==="createMany"&&Array.isArray(M?.data)){let K=u6(J,M,V,B,$);if(K!==null)return l0(z,async()=>{let Q=0;for(let T of K){let O=await this.$exec("createMany",{...M,data:T},U0({strategy:X?.strategy}));Q+=O.count}return{count:Q}})}let P=i0(J,$,M,V,B),C={exec:(K,Q,T,O,F)=>{let A=O?U0({strategy:X?.strategy}):{strategy:X?.strategy};return D0(K).$exec(Q,T,F&&F.length>0?B9(A,F):A)},query:(K,Q)=>Y.unsafe(K,Q)},L=C0();if($==="delete"&&(P.relations!==void 0||P.counts)){let{where:K,...Q}=M;return l0(z,async()=>{let T=await this.$exec("findFirst",{where:K,...Q},j9(U0({strategy:X?.strategy}),$));if(T===null)throw new Z0(J.name,$);return await this.$exec("delete",{where:K},U0({strategy:X?.strategy})),T})}let N=async()=>{Y=n0()??Y,await M9(P.before,M,L,C,[]);let K=await g6(Y,V,J,$,P.text,P.bind(M,L)),Q=this.$shape(P,K);if(Q===null&&v6.has($))throw new Z0(J.name,$);if(await M9(P.after,M,L,C,O0(Q)),P.counts&&P.after!==void 0)await h6(J,this,M,O0(Q),X);if(P.relations!==void 0)await V3(P.relations,P.hidden,Q,M,C);else if(P.hidden!==void 0&&P.hidden.length>0)for(let T of O0(Q))for(let O of P.hidden)delete T[O];if(P.relations!==void 0&&!G)for(let T of P.relations){if(T.root===void 0)continue;T9({as:T.as,model:T.model,folded:T.root.folded},Q,K9,G)}if(W)C3(H,W,Q);if(X?.track===!0)for(let T of O0(Q))K3(T,J);return Q};return P.before!==void 0&&P.before.length>0||P.after!==void 0&&P.after.length>0?l0(z,N):N()}static $shape($,Z){return $.shape(Z)}}function f6($,Z){return Object.getPrototypeOf($)===Z&&!Object.hasOwn($,"$policies")}async function M9($,Z,X,J,z){if($===void 0)return;for(let V of $)await V.run(Z,X,J,z)}var k6=e5(a5(),()=>new Date().getTimezoneOffset());async function g6($,Z,X,J,z,V){let Y=k6(Z.name,X,z,V);if(Y)console.warn(Y);try{return await $.unsafe(z,V)}catch(G){let H=Z.constraintViolation(G);if(!H)throw G;throw new U4(X.name,J,y6(X,H.columns),H.constraint,{cause:G})}}function y6($,Z){return Z.map((X)=>{for(let J of Object.values($.fields))if(J.column===X)return J.name;return X})}async function h6($,Z,X,J,z){let V=X?.include?._count??X?.select?._count;if(V===void 0||J.length===0)return;for(let Y of J){let G={},H=$.primaryKey.length>0;for(let M of $.primaryKey){let D=Y[M];if(D===void 0){H=!1;break}G[M]=D}if(!H)continue;let W=await Z.$exec("findFirst",{where:G,select:{_count:V}},U0({strategy:z?.strategy}));if(W&&W._count!==void 0)Y._count=W._count}}function O0($){if(Array.isArray($))return $;if($===null||$===void 0)return[];if(typeof $!=="object")return[];return[$]}function u6($,Z,X,J,z){let V=Z.data;if(V.length<2)return null;try{return i0($,z,Z,X,J),null}catch(Y){if(!(Y instanceof S4))throw Y;let G={...Z,data:[V[0]]},H=i0($,z,G,X,J).bind(G,C0()).length;if(H===0||H>Y.limit)throw Y;let W=Math.floor(Y.limit/H),M=[];for(let D=0;D<V.length;D+=W)M.push(V.slice(D,D+W));return M}}function m6($,Z,X){try{let J=y($,Z?.where,{model:$.name,operation:X,argument:"where"});return M4($,Z,J).length>0}catch{return!1}}function T9($,Z,X,J){let z=L0($.model)?D0($.model):void 0,V=z?S0(z):[],Y=$.folded??[];if(V.length===0&&Y.length===0)return;let G=V.length>0?L3(z.$schema?.name??$.model,X,o0(),J):void 0,H=[];for(let W of O0(Z)){let M=W?.[$.as];if(M===void 0||M===null)continue;if(G)C3(V,G,M);if(Y.length>0)H.push(...O0(M))}for(let W of Y)T9(W,H,X,J)}class L9 extends R3{static $shape($,Z){let X=$.shape(Z);if(Array.isArray(X))return X.map((J)=>this.hydrate(J));if(X===null||typeof X!=="object")return X;if("count"in X)return X;return this.hydrate(X)}static hydrate($){if($===null||typeof $!=="object")return $;return this.wrap($)}}function p6($={}){let Z=$.field??"deletedAt";return{scope:()=>({[Z]:null}),onCreate:(X,J)=>J,onUpdate:(X,J)=>J}}function d6($,Z={}){let X=Z.field??"deletedAt";return(J)=>{return C9($,J,"delete"),$.update({...J,data:{[X]:new Date}})}}function c6($,Z={}){let X=Z.field??"deletedAt";return(J={})=>{return C9($,J,"deleteMany"),$.updateMany({...J,data:{[X]:new Date}})}}function C9($,Z,X){if(Z?.data===void 0)return;throw new _("data",$.$schema?.name??"unknown",X,`${X} takes no 'data' \u2014 the soft-delete rewrite supplies it. `+"Call update directly if you meant to change other fields at the same time.")}var s6=Number.MAX_SAFE_INTEGER;function I3($){if(typeof $==="string"){if($.trim()==="")return null}else if(typeof $!=="number")return null;let Z=Number($);if(!Number.isFinite(Z))return null;return Math.trunc(Z)}var R9=($,Z,X)=>Math.min(Math.max($,Z),X);function i6($,Z={}){let X=Z.maxPerPage===1/0?1/0:Math.max(1,I3(Z.maxPerPage)??100),J=R9(I3(Z.perPage)??25,1,X),z=R9(I3($?.perPage)??J,1,X),V=Math.max(I3($?.page)??1,1),Y=Math.min((V-1)*z,s6);return{take:z,skip:Y}}export{q4 as withTransaction,L7 as unsafeSql,V7 as transactionDepth,K3 as track,v0 as strategiesOf,K7 as sql,p6 as softDeletes,c6 as softDeleteMany,d6 as softDelete,z$ as shaperCompilationAvailable,J$ as setShaperCompilation,E4 as runAsUser,b4 as runAsSystem,d3 as resolveStrategy,Q3 as resnapshot,C7 as renderFragment,f3 as registry,S7 as registerModels,Z7 as register,N7 as redactNullable,j0 as provenanceOf,L3 as policyContext,S0 as policiesFor,R0 as planRelations,V9 as planKey,b6 as planCacheStats,i6 as paginate,j7 as ormSupports,z7 as ormContext,m0 as lateralStrategy,f as jsonNullKind,Q7 as join,o6 as isUniqueConstraintError,w6 as isTracked,A4 as isSystemScope,n6 as isRecordNotFoundError,O5 as isClientSideDefault,p0 as hasClientSideValue,i0 as getOrCompile,_7 as everyDialect,T7 as empty,w4 as dialectFor,N5 as defaultStrategy,o0 as currentUser,n0 as currentTransaction,H7 as currentActor,b5 as createUuid,A5 as createUlid,F5 as createNanoid,S5 as createCuid,C0 as createBindContext,W4 as compileWrite,p3 as compileRead,Q4 as compile,n3 as clientSideValue,E6 as clearPlanCache,R4 as changedFields,J0 as canonicalShape,k0 as buildRowShaper,g3 as buildInterpretedShaper,G0 as batchedStrategy,O7 as auditModelRegistrations,V3 as attachRelations,N$ as assertSchemaArtifactVersion,U7 as assertPoliciesRegistered,C3 as applyRedaction,x4 as applyPolicies,_ as UnsupportedQueryError,P7 as UnsupportedDialectError,q0 as UnsupportedByDesignError,v3 as UnregisteredRelationTargetError,O4 as UnregisteredPolicyClassError,w0 as UnknownRelationError,v as UnknownFieldError,X7 as UnknownConnectionError,U4 as UniqueConstraintError,Y7 as TransactionDependencyError,s3 as StaleSchemaArtifactError,B7 as SqliteDialect,I7 as ScopedPolicy,r6 as ScopeEscapeError,I$ as SCHEMA_ARTIFACT_VERSION,H4 as ReturningUnsupportedError,x3 as RelationDepthExceededError,Z0 as RecordNotFoundError,G7 as PostgresDialect,t6 as PolicyDeniedError,R7 as Policy,S4 as ParameterLimitError,$7 as ModelNotRegisteredError,R3 as Model,P3 as MissingRequiredValueError,x0 as MissingModelSchemaError,p as MalformedRelationError,Y3 as MAX_RELATION_DEPTH,F4 as LockOutsideTransactionError,M7 as JsonNull,a6 as InvalidPolicyEntryError,I as InvalidArgumentError,l6 as DecodeError,W7 as DbNull,J7 as CrossConnectionTransactionError,D7 as AnyNull,e6 as AmbiguousModelRegistrationError,L9 as ActiveRecordModel};
11
+ `;try{return Function("d","f",z)(Z,$)}catch{return g3($,Z,X)}}function H3($,Z,X,J){let z=Z?.include??Z?.select;if(typeof z!=="object"||z===null)return[];let V=z[s];if(V===void 0||V===!1)return[];let Y=H$($,V,J),G=[];for(let H of Object.keys(Y).sort()){let W=Y[H];if(W===void 0||W===!1)continue;let M=$.relations[H];if(!M)throw new w0(H,$.name,Object.keys($.relations));if(W!==!0&&(typeof W!=="object"||Array.isArray(W)))throw new I(`_count.select.${H}`,$.name,J,"Expected true or an object holding 'where'.");G.push(V$($,M,W,X,J,G.length,Z))}if(G.length===0&&Z?.select)throw new I("_count.select",$.name,J,"No relations to count, and '_count' is the only thing selected. Name at least one relation, or select a column beside it.");return G}function V$($,Z,X,J,z,V,Y){let G=`_count.select.${Z.name}`;if(Z.kind!=="many")throw new _(G,$.name,z,`${Z.name} is a to-one relation. Counting it can only ever return 0 or 1, which is what its nullability already tells you.`);let H=K0($,Z,J,`_c${V}`,`${J.quoteIdent($.table)}.`,z),W=X===!0?void 0:X?.where,M=Y?.include!==void 0?"include":"select",D=(C)=>C?.[M]?.[s]?.select?.[Z.name]?.where,B=x(H.child,W,{dialect:J,operation:z,qualifier:H.qualifier},D),P=[j(`(select count(*) from ${H.source} where ${H.correlation}`)];if(B)P.push(j(" and "),B);return P.push(j(`) as ${J.quoteIdent(`_count.${Z.name}`)}`)),{as:Z.name,alias:`_count.${Z.name}`,column:R(...P)}}function H$($,Z,X){if(Z===!0){let z=M5($);if(z.length===0)throw new _("_count",$.name,X,`${$.name} has no to-many relations, so there is nothing for '_count: true' to count.`);return Object.fromEntries(z.map((V)=>[V,!0]))}if(typeof Z!=="object"||Z===null||Array.isArray(Z))throw new I("_count",$.name,X,"Expected an object holding 'select'.");let J=Z.select;if(typeof J!=="object"||J===null||Array.isArray(J))throw new I("_count.select",$.name,X,"Expected an object naming the relations to count.");return J}var o=["_count","_avg","_sum","_min","_max"],D5=new Set(["where","orderBy","take","skip",...o]),G$=new Set(["Int","Float","BigInt","Decimal"]),W$=new Set(["Json","Bytes"]),y0={_count:"count",_avg:"avg",_sum:"sum",_min:"min",_max:"max"};function y3($){return $==="aggregate"}function h0($,Z,X,J){let z=Z==="count";D$($,Z,X,z);let V=z?M$($,Z,X?.select):h3($,Z,X);if(V.length===0)throw new _(Z,$.name,Z,z?"A 'select' on a count must name at least one field, or '_all'.":`An aggregate needs at least one of ${o.join(", ")}. Prisma rejects an empty one too.`);let Y=x($,X?.where,{dialect:J,operation:Z},(L)=>L?.where),G=Y?R(j(" where "),Y):j(""),H=j(` from ${J.quoteIdent($.table)}`),W=q(V.map((L)=>j(`${y0[L.kind]}(${L.field?J.quoteIdent(L.field.column):"*"}) as ${J.quoteIdent(L.alias)}`)),", "),M=H0($,X?.orderBy,Z,{dialect:J,locate:(L)=>L?.orderBy}),D=X?.take!==void 0||X?.skip!==void 0,B;if(!D)B=R(j("select "),W,H,G);else{let{clause:L,terms:N}=M0($,Z,X,J,M),U=n(N,J),K=new Map;for(let Q of V)if(Q.field)K.set(Q.field.column,Q.field.column);if(K.size===0){let Q=$.primaryKey[0]??Object.keys($.fields)[0],T=$.fields[Q]?.column??Q;K.set(T,T)}B=R(j("select "),W,j(` from (select ${[...K.values()].map((Q)=>J.quoteIdent(Q)).join(", ")}`),H,G,U?R(j(" order by "),U):j(""),L,j(`) as ${J.quoteIdent("sub")}`))}let{text:P,binders:C}=m(B,J,{model:$.name,operation:Z});return{text:P,bind:i(C),shape(L){let N=L[0]??{};if(z){let K={};for(let Q of V)K[Q.as]=I0(Q,N[Q.alias],J);return K}let U={};for(let K of V){if(K.kind==="_count"&&K.as===G3){U._count=I0(K,N[K.alias],J);continue}let Q=U[K.kind]??={};Q[K.as]=I0(K,N[K.alias],J)}return U}}}var G3="";function h3($,Z,X){let J=[];for(let z of o){let V=X?.[z];if(V===void 0||V===!1)continue;if(z==="_count"&&V===!0){J.push({kind:z,as:G3,alias:g0(z,J.length)});continue}if(typeof V!=="object"||V===null||Array.isArray(V))throw new I(z,$.name,Z,z==="_count"?"Expected true or an object of fields.":"Expected an object of fields.");for(let Y of Object.keys(V).sort()){let G=V[Y];if(G===void 0||G===!1)continue;if(z==="_count"&&Y==="_all"){J.push({kind:z,as:"_all",alias:g0(z,J.length)});continue}let H=u0($,Z,z,Y);W3($,Z,z,H),J.push({kind:z,field:H,as:Y,alias:g0(z,J.length)})}}return J}function M$($,Z,X){if(typeof X!=="object"||X===null||Array.isArray(X))throw new I("select",$.name,Z,"Expected an object of fields.");let J=[];for(let z of Object.keys(X).sort()){let V=X[z];if(V===void 0||V===!1)continue;if(z==="_all"){J.push({kind:"_count",as:"_all",alias:g0("_count",J.length)});continue}let Y=u0($,Z,"_count",z);J.push({kind:"_count",field:Y,as:z,alias:g0("_count",J.length)})}return J}var g0=($,Z)=>`${$}_${Z}`;function u0($,Z,X,J){let z=$.fields[J];if(!z){if(J in $.relations)throw new _(`${X}.${J}`,$.name,Z,`'${J}' is a relation. Aggregate its own model instead, or use '_count' inside an 'include' to count it per row.`);throw new v(J,$.name,Object.keys($.fields))}return z}function W3($,Z,X,J){if((X==="_sum"||X==="_avg")&&!G$.has(J.type))throw new _(`${X}.${J.name}`,$.name,Z,`'${J.name}' is a ${J.type}, and ${X} needs a number. Prisma does not offer it on this field either.`);if((X==="_min"||X==="_max")&&W$.has(J.type))throw new _(`${X}.${J.name}`,$.name,Z,`'${J.name}' is a ${J.type}, which has no ordering the two dialects agree on.`)}function I0($,Z,X){if($.kind==="_count")return Number(Z??0);if(Z===null||Z===void 0)return null;if($.kind==="_avg")return Number(Z);if($.kind==="_sum"){let J=$.field?.type;if(J==="BigInt")return BigInt(String(Z));if(J==="Decimal")return Z;return Number(Z)}return $.field?X.decode(Z,$.field):Z}function D$($,Z,X,J){if(X===void 0||X===null){if(J)return;throw new _(Z,$.name,Z,`An aggregate needs at least one of ${o.join(", ")}.`)}if(typeof X!=="object"||Array.isArray(X))throw new I(String(X),$.name,Z,"Expected an object.");if(J)return;for(let z of Object.keys(X).sort()){if(X[z]===void 0)continue;if(D5.has(z))continue;if(z==="select"||z==="include")throw new _(z,$.name,Z,`An aggregate returns the functions it was given, so there is nothing to ${z==="select"?"select":"include"}. Prisma does not accept it either.`);throw new _(z,$.name,Z,`${Z} takes ${[...D5].sort().join(", ")}.`)}}var B5=new Set(["update","share"]),B$=new Set(["mode","skipLocked","noWait"]),u3='Expected "update", "share", or { mode: "update" | "share", skipLocked?: boolean, noWait?: boolean }.';function P5($,Z,X){if($===void 0)return;if(typeof $==="string"){if(B5.has($))return{mode:$,onLocked:"wait"};throw new I("lock",Z,X,u3)}if($===null||typeof $!=="object"||Array.isArray($))throw new I("lock",Z,X,u3);let J=$;for(let z of Object.keys(J))if(!B$.has(z))throw new I(`lock.${z}`,Z,X,"A lock takes mode, skipLocked and noWait.");if(typeof J.mode!=="string"||!B5.has(J.mode))throw new I("lock.mode",Z,X,u3);for(let z of["skipLocked","noWait"])if(J[z]!==void 0&&typeof J[z]!=="boolean")throw new I(`lock.${z}`,Z,X,"Expected a boolean.");if(J.skipLocked===!0&&J.noWait===!0)throw new I("lock",Z,X,"'skipLocked' and 'noWait' cannot both be set: a row another transaction holds is either left out of the result or fails the statement, not both.");return{mode:J.mode,onLocked:J.skipLocked===!0?"skipLocked":J.noWait===!0?"noWait":"wait"}}var M3={findMany:new Set(["where","orderBy","skip","take","select","include","omit","lock"]),findFirst:new Set(["where","orderBy","skip","take","select","include","omit","lock"]),findFirstOrThrow:new Set(["where","orderBy","skip","take","select","include","omit","lock"]),findUnique:new Set(["where","select","include","omit","lock"]),findUniqueOrThrow:new Set(["where","select","include","omit","lock"]),count:new Set(["where","orderBy","skip","take","select"])},P$={distinct:"Prisma's 'distinct' is applied **in memory**, not in SQL \u2014 its query log "+"shows no DISTINCT at all, and 'take' therefore does not reduce the rows pulled or paginate by group. Reproducing that faithfully would mean reading the whole result set and deduplicating in JavaScript behind an argument that reads like a database operation. Implementing it as a real 'DISTINCT ON' instead would be a silent divergence from Prisma. Write it "+"as SQL instead, with 'sql' and 'DB.query' \u2014 where what runs is what you "+"wrote, and 'distinct on' means what the database means by it.",cursor:"'cursor' is only correct under a *total* ordering, which Prisma does not "+"enforce \u2014 under a non-unique 'orderBy' it silently skips or repeats rows "+"at the page boundary. For a stable page use 'take' with a 'where' on the last row's sort key, or compose the keyset comparison with 'sql' and 'DB.query'."};function j5($){return $ in M3}var m3=new Set(["findFirst","findFirstOrThrow","findUnique","findUniqueOrThrow"]);function p3($,Z,X,J,z){if(j$($,Z,X),Z==="count"&&X?.select!==void 0&&X.select!==null)return h0($,Z,X,J);let V=Z==="count"?{plans:[],keyFields:[]}:R0($,X,J,Z,z),G=V.plans.some((E)=>E.root!==void 0)?`${J.quoteIdent($.table)}.`:void 0,H={dialect:J,operation:Z,qualifier:G},W=x($,X?.where,H,(E)=>E?.where);if(Z==="findUnique"||Z==="findUniqueOrThrow")O3($,X?.where,Z);let M=j(` from ${J.quoteIdent($.table)}`),D=W?R(j(" where "),W):j("");if(Z==="count"){let E=j(`select count(*) as ${J.quoteIdent("_count")}`),t=X?.take!==void 0||X?.skip!==void 0,d=H0($,X?.orderBy,Z,{dialect:J,locate:(F0)=>F0?.orderBy}),W0;if(!t)W0=R(E,M,D);else{let{clause:F0,terms:N3}=M0($,Z,X,J,d,m3.has(Z)),f4=n(N3,J),N9=$.primaryKey[0]??Object.keys($.fields)[0];W0=R(E,j(` from (select ${J.quoteIdent($.fields[N9].column)}`),M,D,f4?R(j(" order by "),f4):j(""),F0,j(`) as ${J.quoteIdent("sub")}`))}let{text:_0,binders:Y0}=m(W0,J,{model:$.name,operation:Z});return{text:_0,bind:i(Y0),shape(F0){let N3=F0[0];return Number(N3?._count??0)}}}let B=e($,X,Z),{plans:P,keyFields:C}=V,{fields:L,hidden:N}=X3($,B,C),U=P.filter((E)=>E.root!==void 0),K=H3($,X,J,Z),Q=q([...L.map((E)=>j(`${G??""}${J.quoteIdent(E.column)}`)),...U.map((E)=>E.root.column),...K.map((E)=>E.column)],", "),T=R(...U.map((E)=>E.root.join)),{clause:O,terms:F,reversed:A}=M0($,Z,X,J,H0($,X?.orderBy,Z,{dialect:J,locate:(E)=>E?.orderBy}),m3.has(Z)),b=n(F,J,G),S=P5(X?.lock,$.name,Z),k=R(j("select "),Q,M,T,D,b?R(j(" order by "),b):j(""),O,S?J.rowLock(S,$.table):j("")),{text:z0,binders:t0}=m(k,J,{model:$.name,operation:Z}),v4=k0(L,J,P.map((E)=>({key:E.as,kind:E.kind}))),I9=m3.has(Z);return{text:z0,bind:i(t0),relations:P.length>0?P:void 0,strategies:P.length>0?v0(P):void 0,hidden:N,shape(E){let t=v4(E);if(K.length>0)for(let d=0;d<t.length;d++){let W0=E[d]??{},_0={};for(let Y0 of K)_0[Y0.as]=Number(W0[Y0.alias]??0);t[d]._count=_0}if(U.length>0)for(let d=0;d<t.length;d++){let W0=t[d],_0=E[d]??{};for(let Y0 of U)W0[Y0.as]=Y0.root.decode(_0[Y0.as])}if(A)t.reverse();return I9?t[0]??null:t}}}function j$($,Z,X){if(X===void 0||X===null)return;if(typeof X!=="object"||Array.isArray(X))throw new I(String(X),$.name,Z,"Expected an object.");if(X.select!==void 0&&X.include!==void 0)throw new _("select + include",$.name,Z,"Prisma allows only one of them on the same query.");let J=M3[Z];for(let z of Object.keys(X).sort()){if(X[z]===void 0)continue;if(J.has(z))continue;let V=P$[z];if(V)throw new q0(z,$.name,Z,V);throw new _(z,$.name,Z,`${Z} takes ${[...J].sort().join(", ")}.`)}}var m0={name:"lateral",plan($){let Z=L5($.parent,$.relation,$.as,$.node,$.dialect,$.operation);if(Z)return k3($,`this node declined to fold (${Z})`),G0.plan($);let{dialect:X}=$,J=r($.parent,$.relation,$.as),z=V0($.parent,J,$.relation,$.operation),V=C5({parent:$.parent,child:J,relation:$.relation,as:$.as,node:$.node,locate:$.locate,link:z,dialect:X,operation:$.operation,depth:1,counter:{next:0}});return{as:$.as,model:$.relation.model,kind:$.relation.kind,parentFields:z.parentFields,strategy:"lateral",root:{column:R(j(`${V.alias}.${X.quoteIdent("data")} as `),j(X.quoteIdent($.as))),join:R(j(" left join lateral ("),V.subquery,j(`) as ${V.alias} on true`)),decode:V.decode,folded:V.folded},load:async()=>{throw Error(`${$.parent.name}.${$.as} was folded into the root statement, so it must not also be loaded. This means attachRelations stopped honouring RelationPlan.root.`)}}}};function L5($,Z,X,J,z,V){if(z.name!=="postgres")return"not postgres";if(Z.joinTable)return"implicit many-to-many";let Y=r($,Z,X);if(Y.table===$.table)return"self-relation";let G=I5(J);if(G===void 0)return;if(K$(G))return"_count on a folded node";if(_$(Y,G.orderBy))return"relation ordering on a folded node";for(let H of f0(Y,G,V)){let W=L5(Y,H.relation,H.as,H.node,z,V);if(W)return`${H.as}: ${W}`}return}function _$($,Z){if(Z===void 0||Z===null)return!1;for(let X of Array.isArray(Z)?Z:[Z]){if(typeof X!=="object"||X===null)continue;for(let[J,z]of Object.entries(X)){if(z===void 0)continue;if(J in $.relations)return!0}}return!1}function K$($){for(let Z of["include","select"]){let X=$[Z];if(typeof X!=="object"||X===null||Array.isArray(X))continue;let J=X[s];if(J!==void 0&&J!==!1)return!0}return!1}function C5($){let{dialect:Z,child:X,operation:J}=$,z=I5($.node),V=$.relation.kind==="many",Y=$.counter.next++,G=Z.quoteIdent(K5("__lat_",$.as,$.depth,Y)),H=Z.quoteIdent(X.table),W=`${H}.`,M=e(X,z,J),D=f0(X,z,J).map((S)=>{let k=r(X,S.relation,S.as);return{as:S.as,relation:S.relation,fold:C5({parent:X,child:k,relation:S.relation,as:S.as,node:S.node,locate:(z0)=>S.locate($.locate(z0)),link:V0(X,k,S.relation,J),dialect:Z,operation:J,depth:$.depth+1,counter:$.counter})}}),B=T$(M,W,Z,D.map((S)=>({key:S.as,alias:S.fold.alias}))),P=R(...D.map((S)=>R(j(" left join lateral ("),S.fold.subquery,j(`) as ${S.fold.alias} on true`)))),C=j($.link.parentFields.map((S,k)=>`${W}${Z.quoteIdent(T5(X,$.link.childFields[k]).column)} = ${Z.quoteIdent($.parent.table)}.${Z.quoteIdent(T5($.parent,S).column)}`).join(" and ")),L=x(X,z?.where,{dialect:Z,operation:J,qualifier:W},(S)=>$.locate(S)?.where),N=R(j(` from ${H}`),P,j(" where "),C,L?R(j(" and "),L):j("")),U=L$(M,Z,V,D.map((S)=>({key:S.as,decode:S.fold.decode}))),K=D.map((S)=>({as:S.as,model:S.relation.model,kind:S.relation.kind,folded:S.fold.folded})),Q=H0(X,z?.orderBy,J);if(!V)return{alias:G,folded:K,decode:U,subquery:R(j("select "),B,j(` as ${Z.quoteIdent("data")}`),N,j(" limit 1"))};let T=Q$($,z,Q,X);if(!T){let S=n(Q,Z,W);return{alias:G,folded:K,decode:U,subquery:R(j("select coalesce(json_agg("),B,S?R(j(" order by "),S):j(""),j(`), '[]'::json) as ${Z.quoteIdent("data")}`),N)}}let O=Z.quoteIdent(K5("__page_",$.as,$.depth,Y)),F=T.terms.map((S,k)=>j(`, ${W}${Z.quoteIdent(S.column)} as ${Z.quoteIdent(R5(k))}`)),A=n(_5(T.inner),Z),b=n(_5(T.terms),Z,`${O}.`);return{alias:G,folded:K,decode:U,subquery:R(j(`select coalesce(json_agg(${O}.${Z.quoteIdent("data")}`),b?R(j(" order by "),b):j(""),j(`), '[]'::json) as ${Z.quoteIdent("data")} from (select `),B,j(` as ${Z.quoteIdent("data")}`),...F,N,A?R(j(" order by "),A):j(""),T.clause,j(`) as ${O}`))}}function Q$($,Z,X,J){let z=Z?.take,V=Z?.skip;if(z===void 0&&V===void 0)return;let Y=X.length>0?X:J.primaryKey.map((W)=>({column:J.fields[W]?.column??W,direction:"asc"})),G=z===void 0?null:(W)=>Math.abs(Number($.locate(W)?.take)),H=V===void 0?null:(W)=>Number($.locate(W)?.skip);return{clause:$.dialect.paginate(G,H),terms:Y,inner:typeof z==="number"&&z<0?$3(Y):Y}}var R5=($)=>`__ord_${$}`;function _5($){return $.map((Z,X)=>({...Z,column:R5(X),expression:void 0}))}function K5($,Z,X,J){return X===1?`${$}${Z}`:`${$}${Z}_${J}`}function I5($){if($===!0||$===void 0||$===null)return;if(typeof $!=="object"||Array.isArray($))return;return $}function T$($,Z,X,J){let z=$.map((V)=>{let Y=`${Z}${X.quoteIdent(V.column)}`,G=V.type==="BigInt"?`${Y}::text${V.isList?"[]":""}`:Y;return`'${V.name}', ${G}`});for(let V of J)z.push(`'${V.key}', ${V.alias}.${X.quoteIdent("data")}`);return j(`json_build_object(${z.join(", ")})`)}function L$($,Z,X,J){let z=$.map((Y)=>({field:Y,convert:C$(Y)})).filter((Y)=>Y.convert!==void 0),V=(Y)=>{if(Y===null||Y===void 0||typeof Y!=="object")return null;let G=Y;for(let{field:H,convert:W}of z)G[H.name]=W(G[H.name]);for(let H of J)G[H.key]=H.decode(G[H.key]);return G};return(Y)=>{let G=typeof Y==="string"?R$(Y):Y??null;if(X){if(!Array.isArray(G))return[];return G.map(V).filter((H)=>H!==null)}return V(G)}}function C$($){if($.isList){let Z=Q5($);if(!Z)return;return(X)=>{if(X===null||X===void 0)return null;if(!Array.isArray(X))return X;return X.map((J)=>J===null||J===void 0?null:Z(J))}}return Q5($)}function Q5($){switch($.type){case"DateTime":return(Z)=>Z===null||Z===void 0?null:Z instanceof Date?Z:new Date(String(Z));case"BigInt":return(Z)=>Z===null||Z===void 0?null:BigInt(String(Z));case"Json":return;case"Bytes":return(Z)=>{if(Z===null||Z===void 0)return null;if(ArrayBuffer.isView(Z))return Buffer.isBuffer(Z)?new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength):Z;let X=Buffer.from(String(Z).replace(/^\\?x/,""),"hex");return new Uint8Array(X.buffer,X.byteOffset,X.byteLength)};default:return}}function R$($){try{return JSON.parse($)}catch{return null}}function T5($,Z){let X=$.fields[Z];if(!X)throw Error(`${$.name} has no field '${Z}', which the lateral strategy needs to correlate on. This means the generated artifact is stale.`);return X}function N5($){return $.name==="postgres"?m0:G0}function d3($,Z,X){if($===void 0)return N5(Z);if($==="batched")return G0;if($==="lateral")return m0;throw new _(`strategy: ${JSON.stringify($)}`,X.model,X.operation,'Unknown relation strategy. Expected "batched" or "lateral".')}var I$=2,c3=21;class s3 extends Error{constructor($){super(`The generated model artifact is version ${$}, but this version of gemi reads version 2. Re-run \`prisma generate\` to refresh app/models/generated.`);this.name="StaleSchemaArtifactError"}}function N$($){if($!==2)throw new s3($)}var U$=new Set(["cuid","uuid","nanoid","ulid","now","value"]);function O5($){return U$.has($.kind)}function p0($){if($.isUpdatedAt)return!0;return $.default!==void 0&&O5($.default)}function n3($,Z){if($.isUpdatedAt)return Z;let X=$.default;if(!X)return;switch(X.kind){case"cuid":return S5();case"uuid":return b5(X.version??4);case"nanoid":return F5(X.length??c3);case"ulid":return A5();case"now":return Z;case"value":return X.value;default:return}}function o3($,Z){let X=$.length,J=256-256%X,z=new Uint8Array(Z);crypto.getRandomValues(z);let V="";for(let Y=0;Y<Z;Y++){let G=z[Y];while(G>=J){let H=new Uint8Array(1);crypto.getRandomValues(H),G=H[0]}V+=$[G%X]}return V}var O$="0123456789abcdefghijklmnopqrstuvwxyz",i3=36,t3=4,S$=i3**t3,F$=0;function A$($,Z){return $.length>=Z?$:"0".repeat(Z-$.length)+$}var b$=l3();function l3(){return o3(O$,t3)}function S5(){let $=Date.now().toString(i3),Z=A$((F$++%S$).toString(i3),t3);return`c${$}${Z}${b$}${l3()}${l3()}`}var E$="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function F5($=c3){return o3(E$,$)}var U5="0123456789ABCDEFGHJKMNPQRSTVWXYZ",q$=10,w$=16;function A5($=Date.now()){let Z="",X=$;for(let J=0;J<q$;J++)Z=U5[X%32]+Z,X=Math.floor(X/32);return Z+o3(U5,w$)}function b5($=4){return $===7?v$():crypto.randomUUID()}var x$=Array.from({length:256},($,Z)=>Z.toString(16).padStart(2,"0"));function v$(){let $=new Uint8Array(16);crypto.getRandomValues($);let Z=Date.now();$[0]=Math.floor(Z/1099511627776)&255,$[1]=Math.floor(Z/4294967296)&255,$[2]=Z>>>24&255,$[3]=Z>>>16&255,$[4]=Z>>>8&255,$[5]=Z&255,$[6]=$[6]&15|112,$[8]=$[8]&63|128;let X=x$;return X[$[0]]+X[$[1]]+X[$[2]]+X[$[3]]+"-"+X[$[4]]+X[$[5]]+"-"+X[$[6]]+X[$[7]]+"-"+X[$[8]]+X[$[9]]+"-"+X[$[10]]+X[$[11]]+X[$[12]]+X[$[13]]+X[$[14]]+X[$[15]]}var f$=["connect","connectOrCreate","create","createMany","disconnect","delete","update","set","updateMany","deleteMany","upsert"],E5=new Set(f$),k$=["disconnect","delete","update","set","updateMany","deleteMany","upsert"],g$=new Set(k$),y$=["createMany","set","updateMany","deleteMany"],v5=new Set(y$.filter(($)=>$!=="createMany")),f5=new Set(["create","createMany"]),h$={},q5={contributions:[],before:[],after:[],keyFields:[]};function B3($,Z,X,J,z){if(typeof Z!=="object"||Z===null||Array.isArray(Z))return q5;let V=Object.keys(Z).sort().filter((H)=>(H in $.relations)).filter((H)=>Z[H]!==void 0);if(V.length===0)return q5;let Y={contributions:[],before:[],after:[],keyFields:[]},G=new Map;for(let H of V){let W=$.relations[H],M=Z[H],D=(P)=>J(P)?.[H],B=Y.contributions.length;u$($,W,M,X,D,Y,z);for(let P=B;P<Y.contributions.length;P++){let C=Y.contributions[P].field,L=G.get(C);if(L!==void 0&&L!==H)throw new _(`data.${H}`,$.name,X,`'${C}' is written by both the '${L}' and '${H}' relations, which join on it in common. Prisma lets the last key in 'data' win; gemi plans relations in a fixed order and will not guess which row you meant. Write one of them through the relation and set the other's own columns directly.`);G.set(C,H)}}return Y}function u$($,Z,X,J,z,V,Y){if(typeof X!=="object"||X===null||Array.isArray(X))throw new I(`data.${Z.name}`,$.name,J,"Expected an object holding 'connect' or 'create'.");let G=Object.keys(X).sort().filter((D)=>X[D]!==void 0);if(G.length===0)return;let H=r($,Z),W=V0($,H,Z,J);if(W.join){let D=J5(W,$,Z,J);for(let B of G)c$($,Z,H,D,B,X[B],J,(P)=>z(P)?.[B],V,Y);return}for(let D of G){if(!E5.has(D)){let B=h$[D];throw new _(`data.${Z.name}.${D}`,$.name,J,`Only ${[...E5].sort().join(", ")} are implemented.`+(B?` '${D}' is not: ${B}`:""))}if(g$.has(D)&&f5.has(J))throw new _(`data.${Z.name}.${D}`,$.name,J,`'${D}' acts on rows already linked to this one, and a '${J}' `+"has none yet \u2014 Prisma refuses it here too. Use it on an 'update'.")}let M=Z.from.length>0;for(let D of G){let B=X[D],P=(C)=>z(C)?.[D];if(M)m$($,Z,H,W,D,B,J,P,V);else p$($,Z,H,W,D,B,J,P,V)}}function m$($,Z,X,J,z,V,Y,G,H){let{parentFields:W,childFields:M}=J,D=()=>{for(let K of W)H.contributions.push({field:K,value:(Q,T)=>T.resolved[K]})},B=(K,Q)=>{for(let T=0;T<W.length;T++)K.resolved[W[T]]=Q[T]??null},P=Object.values(X.relations).filter((K)=>K.relationName===Z.relationName&&!(X.name===$.name&&K.name===Z.name)),C=new Set(W),L=W.every((K)=>$.fields[K]?.nullable===!0)&&$.uniques.some((K)=>K.length===C.size&&K.every((Q)=>C.has(Q)))&&P.length===1&&P[0].kind!=="many",N=!f5.has(Y);if(z==="createMany")throw new _(`data.${Z.name}.createMany`,$.name,Y,`'${Z.name}' is a to-one: this row holds the foreign key, so there is one related row at most and nothing to create many of. Prisma does not accept it here either.`);if(z==="create"){H.before.push({relation:Z.name,operation:"create",async run(K,Q,T){let O=await T.exec(Z.model,"create",{data:G(K),select:w(M)},!1);B(Q,u(O,M))}}),D();return}if(z==="disconnect"){$4($,Z,W,{model:$.name,operation:Y,argument:`data.${Z.name}.disconnect`}),y5($,Z,X,V,z,Y);let K=Z4(z,V);if(K===null||K===void 0)return;if(V===!0){for(let Q of W)H.contributions.push({field:Q,value:()=>null});return}H.before.push({relation:Z.name,operation:"disconnect",async run(Q,T,O){B(T,x5(W));let F=await O.exec($.name,"findFirst",{where:Q?.where,select:w(W)},!0),A=u(F,W);if(!c0(A))return;if(B(T,A),await O.exec(Z.model,"findFirst",{where:B0(G(Q),h(J,F)),select:w(M)},!1))B(T,x5(W))}}),D();return}if(z==="delete")throw new _(`data.${Z.name}.delete`,$.name,Y,`'${Z.name}' is a to-one whose foreign key lives on this row, so deleting through it would remove a row this statement is not about. Delete it directly, or 'disconnect' it first.`);if(z==="update"){H.keyFields.push(...W),e3($,Z,X,z,V,Y),H.after.push({relation:Z.name,operation:"update",async run(K,Q,T,O){let F=O[0];if(!F)return;if(!c0(u(F,W)))throw new Z0(Z.model,"update");let A=G(K),b=A!==null&&typeof A==="object"&&A.data!==void 0,S=A,k=b?S.data:A,z0=b?S.where:void 0,t0=B0(z0,h(J,F));if(z0!==void 0){if(!await T.exec(Z.model,"findFirst",{where:t0,select:w(M)},!1))throw new Z0(Z.model,"update")}await T.exec(Z.model,"updateMany",{where:t0,data:k},!1)}});return}if(v5.has(z))throw new _(`data.${Z.name}.${z}`,$.name,Y,`'${Z.name}' is a to-one: this row holds a single foreign key, so there is no set of rows for '${z}' to act on. Prisma does not accept it here either. Use 'connect', 'disconnect' or 'update'.`);if(z==="upsert"){e3($,Z,X,z,V,Y),k5($,Z,X,V,Y,!1),H.before.push({relation:Z.name,operation:"upsert",async run(K,Q,T){let O=G(K),F=await T.exec($.name,"findFirst",{where:K?.where,select:w(W)},!0);if(c0(u(F,W))){let b=B0(O?.where,h(J,F)),S=await T.exec(Z.model,"findFirst",{where:b,select:w(M)},!1);if(S){B(Q,u(S,M)),await T.exec(Z.model,"updateMany",{where:b,data:O?.update},!1);return}}let A=await T.exec(Z.model,"create",{data:O?.create,select:w(M)},!1);B(Q,u(A,M))}}),D();return}if(z==="connectOrCreate"){J4($,Z,X,V,Y,!1),H.before.push({relation:Z.name,operation:"connectOrCreate",async run(K,Q,T){let O=G(K)?.where,F=await T.exec(Z.model,"findUnique",{where:O,select:w(M)},!1);if(F){let b=u(F,M);if(L)await a3($,W,b,K?.where,N,T);B(Q,b);return}let A=await T.exec(Z.model,"create",{data:G(K)?.create,select:w(M)},!1);B(Q,u(A,M))}}),D();return}if(typeof V!=="object"||V===null||Array.isArray(V))throw new I(`data.${Z.name}.connect`,$.name,Y,"Expected an object naming a unique field.");if(M.length===1&&V[M[0]]!==void 0&&Object.keys(V).filter((K)=>V[K]!==void 0).length===1){let K=M[0],Q=W[0];if(L)H.before.push({relation:Z.name,operation:"connect",async run(T,O,F){await a3($,[Q],[G(T)?.[K]],T?.where,N,F)}});H.contributions.push({field:Q,value:(T)=>G(T)?.[K]});return}y(X,V,{model:$.name,operation:Y,argument:`data.${Z.name}.connect`}),H.before.push({relation:Z.name,operation:"connect",async run(K,Q,T){let O=await T.exec(Z.model,"findUniqueOrThrow",{where:G(K),select:w(M)},!1),F=u(O,M);if(L)await a3($,W,F,K?.where,N,T);B(Q,F)}}),D()}function p$($,Z,X,J,z,V,Y,G,H){let{parentFields:W,childFields:M}=J;H.keyFields.push(...W);let D=Z.kind!=="many"&&M.every((P)=>X.fields[P]?.nullable===!0),B=V;if(Z.kind!=="many"){if(v5.has(z))throw new _(`data.${Z.name}.${z}`,$.name,Y,`'${Z.name}' is a to-one: there is a single ${X.name} row, so there is no set of rows for '${z}' to act on. Prisma does not offer it on a to-one either. Use 'connect', 'disconnect' or 'update'.`);if(Array.isArray(V))throw new I(`data.${Z.name}.${z}`,$.name,Y,`'${Z.name}' is a to-one \u2014 ${X.name} holds the foreign key, so there is one row here at most. Expected a single object for '${z}', not an array of them. Prisma refuses the array too.`);e3($,Z,X,z,V,Y);let P=G;G=(C)=>Z4(z,P(C)),V=Z4(z,V)}if(z==="upsert"){k5($,Z,X,V,Y,Z.kind==="many"),H.after.push({relation:Z.name,operation:"upsert",async run(P,C,L,N){let U=N[0];if(!U)return;for(let K of $0(G(P))){let Q=B0(K.where,h(J,U));if(await L.exec(Z.model,"findFirst",{where:Q,select:w(M)},!1)){await L.exec(Z.model,"updateMany",{where:Q,data:K.update},!1);continue}await L.exec(Z.model,"create",{data:{...K.create,...h(J,U)},select:w(M)},!1)}}});return}if(z==="updateMany"||z==="deleteMany"){let P=z==="updateMany";i$($,Z,V,z,Y),H.after.push({relation:Z.name,operation:z,async run(C,L,N,U){let K=U[0];if(!K)return;let Q=G(C),T=P?Q?.where:Q,O=B0(T,h(J,K));await N.exec(Z.model,z,P?{where:O,data:Q?.data}:{where:O},!1)}});return}if(z==="set"){D3($,Z,X,V,"set",Y),$4(X,Z,M,{model:$.name,operation:Y,argument:`data.${Z.name}.set`}),H.after.push({relation:Z.name,operation:"set",async run(P,C,L,N){let U=N[0];if(!U)return;let K=h(J,U);await d0(Z.model,M,u(U,W),L);for(let Q of $0(G(P)))await L.exec(Z.model,"updateMany",{where:Q,data:K},!1)}});return}if(z==="update"){l$($,Z,X,V,Y,Z.kind==="many"),H.after.push({relation:Z.name,operation:"update",async run(P,C,L,N){let U=N[0];if(!U)return;let K=$0(G(P));for(let Q=0;Q<K.length;Q++){let T=K[Q],O=B0(T.where,h(J,U));if(!await L.exec(Z.model,"findFirst",{where:O,select:w(M)},!1))throw new Z0(Z.model,"update");await L.exec(Z.model,"updateMany",{where:O,data:T.data},!1)}}});return}if(z==="disconnect"||z==="delete"){let P=z==="delete";if(!P)$4(X,Z,M,{model:$.name,operation:Y,argument:`data.${Z.name}.disconnect`});if(Z.kind==="many")D3($,Z,X,V,z,Y);else y5($,Z,X,B,z,Y);H.after.push({relation:Z.name,operation:z,async run(C,L,N,U){let K=U[0];if(!K)return;let Q=$0(G(C));for(let T=0;T<Q.length;T++){let O=B0(Q[T],h(J,K));if(!P){await N.exec(Z.model,"updateMany",{where:O,data:g5(M)},!1,M);continue}if(!await N.exec(Z.model,"findFirst",{where:O,select:w(M)},!1)){if(Z.kind!=="many")throw new Z0(Z.model,"delete");throw new _(`data.${Z.name}.delete`,$.name,Y,`the row named by ${JSON.stringify(Q[T])} is not connected to this ${$.name}. Prisma raises here too, rather than deleting a row belonging to somebody else.`)}await N.exec(Z.model,"deleteMany",{where:O},!1)}}});return}if(z==="create"){H.after.push({relation:Z.name,operation:"create",async run(P,C,L,N){let U=N[0];if(!U)return;if(D)await d0(Z.model,M,u(U,W),L);for(let K of $0(G(P)))await L.exec(Z.model,"create",{data:{...K,...h(J,U)},select:w(M)},!1)}});return}if(z==="createMany"){if(Z.kind!=="many")throw new _(`data.${Z.name}.createMany`,$.name,Y,`'${Z.name}' is a to-one, so there is nothing to create many of. Prisma does not accept it here either.`);n$($,Z,V,Y),H.after.push({relation:Z.name,operation:"createMany",async run(P,C,L,N){let U=N[0];if(!U)return;let K=$0(G(P)?.data).map((Q)=>({...Q,...h(J,U)}));await L.exec(Z.model,"createMany",{data:K},!1)}});return}if(z==="connectOrCreate"){J4($,Z,X,V,Y,Z.kind==="many"),H.after.push({relation:Z.name,operation:"connectOrCreate",async run(P,C,L,N){let U=N[0];if(!U)return;let K=$0(G(P));for(let Q=0;Q<K.length;Q++){let T=K[Q],O=await L.exec(Z.model,"findUnique",{where:T.where,select:w(M)},!1);if(O){if(D&&M.every((F,A)=>X4(O[F],U[W[A]])))continue;if(D)await d0(Z.model,M,u(U,W),L);await L.exec(Z.model,"update",{where:T.where,data:h(J,U),select:w(M)},!1,M);continue}await L.exec(Z.model,"create",{data:{...T.create,...h(J,U)},select:w(M)},!1)}}});return}D3($,Z,X,V,z,Y),H.after.push({relation:Z.name,operation:"connect",async run(P,C,L,N){let U=N[0];if(!U)return;let K=[];for(let Q of $0(G(P))){if(D&&await s$(Z.model,M,Q,u(U,W),L))continue;K.push(Q)}if(K.length===0)return;if(D)await d0(Z.model,M,u(U,W),L);for(let Q of K)await L.exec(Z.model,"update",{where:Q,data:h(J,U),select:w(M)},!1,M)}})}var w5=new Set(["connect","connectOrCreate","disconnect","set","create"]),d$={createMany:"Prisma does not offer 'createMany' through an implicit many-to-many "+"either \u2014 it reports it as an unknown argument. Use 'create', which writes "+"the row and its pair.",update:"Reaching the far row means reading the pairs first, which this path does not do yet. Update the related model directly, filtered by its own key.",updateMany:"As 'update': it needs the pairs read before the far rows can be matched.",delete:"It deletes the far row rather than the pair \u2014 Prisma does this through a "+"join table too \u2014 and reaching it means reading the pairs first, which "+"this path does not do yet. Use 'disconnect' to remove the link, or delete the row through its own model.",deleteMany:"As 'delete': the far rows have to be found through the pairs first."};function c$($,Z,X,J,z,V,Y,G,H,W){if(z==="connectOrCreate")J4($,Z,X,V,Y,Z.kind==="many");if(!w5.has(z)){let C=d$[z];if(C)throw new _(`data.${Z.name}.${z}`,$.name,Y,`'${Z.name}' is an implicit many-to-many, and '${z}' means something different through a join table. ${C}`);throw new _(`data.${Z.name}.${z}`,$.name,Y,`'${Z.name}' is an implicit many-to-many. Only ${[...w5].sort().join(", ")} are implemented through its join table.`)}if(z==="connect"||z==="disconnect"||z==="set")D3($,Z,X,V,z,Y);let{join:M,parentField:D,childField:B}=J,P=(C)=>W.quoteIdent(C);H.keyFields.push(D),H.after.push({relation:Z.name,operation:z,async run(C,L,N,U){let K=U[0];if(!K)return;let Q=K[D];if(Q===null||Q===void 0)return;if(z==="set"){let F=await N.query(`select ${P(M.childColumn)} from ${P(M.table)} where ${P(M.parentColumn)} = ${W.placeholder(0)}`,[Q]),A=Array.from(F,(b)=>b[M.childColumn]);if(A.length>0){let b=await N.exec(Z.model,"findMany",{where:{[B]:{in:A}},select:{[B]:!0}},!1),S=Array.from(b,(k)=>k[B]);if(S.length>0)await r3(N,`delete from ${P(M.table)} where ${P(M.parentColumn)} = ${W.placeholder(0)} and ${P(M.childColumn)} in (`+S.map((k,z0)=>W.placeholder(z0+1)).join(", ")+")",[Q,...S])}}let T=$0(G(C));if(T.length===0)return;let O=[];for(let F of T){if(z==="create"){let b=await N.exec(Z.model,"create",{data:F,select:{[B]:!0}},!1);if(b)O.push(b[B]);continue}if(z==="connectOrCreate"){let b=F,S=await N.exec(Z.model,"findUnique",{where:b.where,select:{[B]:!0}},!1);if(S){O.push(S[B]);continue}let k=await N.exec(Z.model,"create",{data:b.create,select:{[B]:!0}},!1);if(k)O.push(k[B]);continue}let A=await N.exec(Z.model,"findUniqueOrThrow",{where:F,select:{[B]:!0}},!1);if(A)O.push(A[B])}for(let F of O){if(z==="disconnect"){await r3(N,`delete from ${P(M.table)} where ${P(M.parentColumn)} = ${W.placeholder(0)} and ${P(M.childColumn)} = ${W.placeholder(1)}`,[Q,F]);continue}await r3(N,`insert into ${P(M.table)} (${P(M.parentColumn)}, ${P(M.childColumn)}) values (${W.placeholder(0)}, ${W.placeholder(1)}) on conflict do nothing`,[Q,F])}}})}async function r3($,Z,X){await $.query(Z,X)}function k5($,Z,X,J,z,V){let Y=`data.${Z.name}.upsert`,G=Array.isArray(J)?J:[J];for(let H of G){if(typeof H!=="object"||H===null||Array.isArray(H))throw new _(Y,$.name,z,V?"Expected an object with 'where', 'create' and 'update'.":"Expected an object with 'create' and 'update' \u2014 on a to-one the "+"'where' is optional, since the parent's key already names the row.");let W=H,M=V?["where","create","update"]:["create","update"];for(let D of M)if(W[D]===void 0)throw new _(Y,$.name,z,`Expected a '${D}' key \u2014 'upsert' names the row to look for, `+"what to write if it is there, and what to write if it is not.");if(!V)continue;y(X,W.where,{model:$.name,operation:z,argument:`data.${Z.name}.upsert.where`})}}function B0($,Z){if($===void 0||$===null||typeof $!=="object"||Array.isArray($)||Object.keys($).length===0)return Z;return{AND:[$,Z]}}function h($,Z){let X={};for(let J=0;J<$.childFields.length;J++)X[$.childFields[J]]=Z[$.parentFields[J]];return X}function w($){let Z={};for(let X of $)Z[X]=!0;return Z}function g5($){let Z={};for(let X of $)Z[X]=null;return Z}function x5($){return $.map(()=>null)}function u($,Z){return Z.map((X)=>$?.[X])}function c0($){return $.every((Z)=>Z!==null&&Z!==void 0)}async function d0($,Z,X,J){if(!c0(X))return;let z={};for(let Y=0;Y<Z.length;Y++)z[Z[Y]]=X[Y];if((await J.exec($,"findMany",{where:z,select:w(Z)},!1)).length===0)return;await J.exec($,"updateMany",{where:z,data:g5(Z)},!1,Z)}async function s$($,Z,X,J,z){let V=await z.exec($,"findUnique",{where:X,select:w(Z)},!1);if(V===null||V===void 0)return!1;return Z.every((Y,G)=>X4(V[Y],J[G]))}async function a3($,Z,X,J,z,V){if(!c0(X))return;if(z){let Y=await V.exec($.name,"findFirst",{where:J,select:w(Z)},!0);if(Y===null||Y===void 0)return;if(Z.every((G,H)=>X4(Y[G],X[H])))return}await d0($.name,Z,X,V)}function X4($,Z){if($===null||$===void 0||Z===null||Z===void 0)return!1;return $===Z||String($)===String(Z)}function i$($,Z,X,J,z){let V=`data.${Z.name}.${J}`;if(typeof X!=="object"||X===null||Array.isArray(X))throw new _(V,$.name,z,J==="updateMany"?"Expected an object with 'where' and 'data'.":"Expected an object of filters \u2014 'deleteMany' takes the filter "+"directly, not wrapped in a 'where'.");if(J!=="updateMany")return;let Y=X;for(let G of["where","data"])if(Y[G]===void 0)throw new _(V,$.name,z,`Expected a '${G}' key \u2014 'updateMany' names which rows to `+"write and what to write to them.")}function l$($,Z,X,J,z,V){let Y=`data.${Z.name}.update`,G=Array.isArray(J)?J:[J],H=[];for(let W of G){if(typeof W!=="object"||W===null||Array.isArray(W))throw new _(Y,$.name,z,"Expected an object with 'where' and 'data'.");let M=W,D=V?["where","data"]:["data"];for(let B of D)if(M[B]===void 0)throw new _(Y,$.name,z,`Expected a '${B}' key \u2014 'update' names the row to write and `+"the columns to write to it.");if(V)y(X,M.where,{model:$.name,operation:z,argument:`data.${Z.name}.update.where`});H.push(M)}return H}function D3($,Z,X,J,z,V){let Y=`data.${Z.name}.${z}`,G=Array.isArray(J)?J:[J],H=[];for(let W of G){if(typeof W!=="object"||W===null||Array.isArray(W))throw new _(Y,$.name,V,"Expected an object naming a unique field, or an array of them.");y(X,W,{model:$.name,operation:V,argument:`data.${Z.name}.${z}`}),H.push(W)}return H}function y5($,Z,X,J,z,V){if(J===void 0)return;if(typeof J==="boolean")return;if(J!==null&&typeof J==="object"&&!Array.isArray(J))return;throw new I(`data.${Z.name}.${z}`,$.name,V,`'${Z.name}' is a to-one, so '${z}' takes either a boolean \u2014 `+`'true' for the connected ${X.name}, 'false' for nothing \u2014 or an `+`object of filters it has to match. Prisma's operand here is '${X.name}WhereInput | boolean'.`+(J===null?" 'null' is not one of them \u2014 write 'false' for the no-op. Prisma "+"answers 'null' with a validation error rather than accepting it.":""))}function e3($,Z,X,J,z,V){if(J!=="update"&&J!=="upsert")return;let Y=`data.${Z.name}.${J}`,G=(D)=>{throw new I(Y,$.name,V,D)};if(z===null||typeof z!=="object"||Array.isArray(z))G(`Expected an object, got ${JSON.stringify(z)??typeof z}. `+(J==="upsert"?"'upsert' on a to-one takes { create, update } \u2014 and an optional "+`'where' the connected ${X.name} has to match.`:`'update' on a to-one takes the ${X.name} columns directly, `+"or { data } \u2014 and an optional 'where' the connected row has to "+"match."));let H=z;if(!(J==="upsert"||H.data!==void 0))return;let M=J==="upsert"?["where","create","update"]:["where","data"];for(let D of Object.keys(H)){if(H[D]===void 0||M.includes(D))continue;G(`Unknown key '${D}'. '${J}' on a to-one takes ${M.map((B)=>`'${B}'`).join(", ")} and nothing else, so '${D}' would be dropped rather than applied \u2014 a misspelled `+"'where' would turn a filtered write into an unconditional one. Prisma refuses the same key by name.")}if(H.where!==void 0&&(H.where===null||typeof H.where!=="object"||Array.isArray(H.where)))G("'where' has to be an object of filters \u2014 Prisma's is a "+`'${X.name}WhereInput', which narrows *which* single row is written rather than choosing among several. Anything else is dropped by the conjunction that keeps this operand on the connected row, so the write would land unfiltered.`)}function $4($,Z,X,J){let z=X.find((V)=>!$.fields[V]?.nullable);if(z===void 0)return;throw new _(J.argument,J.model,J.operation,`'${$.name}.${z}' is required, so there is no value to leave `+"behind \u2014 a disconnected row would have to be deleted or repointed "+"instead. Prisma does not offer 'disconnect' on a required relation either.")}function J4($,Z,X,J,z,V){let Y=`data.${Z.name}.connectOrCreate`;if(Array.isArray(J)&&!V){let W=Z.from.length>0;throw new I(Y,$.name,z,`'${Z.name}' is a to-one: `+(W?"this row holds the foreign key":`${X.name} holds the foreign key`)+", so there is one row to point at and a list has no meaning. Prisma "+"refuses an array here too \u2014 as a validation error on the argument, "+"which is why this is a bad value rather than a gap.")}let G=Array.isArray(J)?J:[J];if(G.length===0)return[];let H=[];for(let W of G){if(typeof W!=="object"||W===null||Array.isArray(W))throw new _(Y,$.name,z,"Expected an object with 'where' and 'create'.");let M=W;for(let B of["where","create"])if(M[B]===void 0)throw new _(Y,$.name,z,`Expected a '${B}' key \u2014 'connectOrCreate' names the row to `+"look for and the row to write if it is not there.");let D=Object.keys(M).filter((B)=>B!=="where"&&B!=="create"&&M[B]!==void 0);if(D.length>0)throw new _(Y,$.name,z,`Unexpected ${D.sort().join(", ")} \u2014 'connectOrCreate' takes `+"'where' and 'create'.");y(X,M.where,{model:$.name,operation:z,argument:`data.${Z.name}.connectOrCreate.where`}),H.push(M)}return H}function n$($,Z,X,J){let z=`data.${Z.name}.createMany`;if(typeof X!=="object"||X===null||Array.isArray(X))throw new I(z,$.name,J,"Expected an object with a 'data' key \u2014 the rows go inside it, not "+"directly under 'createMany'.");let V=Object.keys(X).filter((Y)=>X[Y]!==void 0);if(!V.includes("data"))throw new I(z,$.name,J,"Expected a 'data' key.");for(let Y of V){if(Y==="data")continue;throw new _(`${z}.${Y}`,$.name,J,Y==="skipDuplicates"?`'skipDuplicates' is not implemented on a *nested* 'createMany'. Write the children with their own '${Z.model}.createMany' call, which takes it.`:"Expected only 'data'.")}}function $0($){if($===void 0||$===null)return[];return Array.isArray($)?$:[$]}function Z4($,Z){if($==="update"){if(Z!==null&&typeof Z==="object"&&Z.data!==void 0){let X=Z;return{where:X.where,data:X.data}}return{where:void 0,data:Z}}if($==="delete"||$==="disconnect"){if(Z===!0)return{};if(Z===!1)return null;return Z}return Z}var G4={create:new Set(["data","select","include","omit"]),createMany:new Set(["data","skipDuplicates"]),update:new Set(["data","where","select","include","omit"]),updateMany:new Set(["data","where"]),delete:new Set(["where","select","include","omit"]),deleteMany:new Set(["where"]),upsert:new Set(["where","create","update","select","include","omit"])},o$=new Set(["create","update","delete","upsert"]),u5=new Set(["createMany","updateMany","deleteMany"]);function m5($){return $ in G4}function W4($,Z,X,J){if(G6($,Z,X),!J.supportsReturning)throw new H4($.name,Z,J.name);switch(Z){case"create":return t$($,Z,X,J);case"createMany":return r$($,Z,X,J);case"update":case"updateMany":return $6($,Z,X,J);case"delete":case"deleteMany":return Z6($,Z,X,J);case"upsert":return X6($,Z,X,J);default:throw new _(Z,$.name,Z,`'${Z}' is not a write operation. The writes are ${Object.keys(G4).sort().join(", ")}.`)}}function t$($,Z,X,J){let z=B3($,X?.data,Z,(H)=>H?.data,J),V=p5($,X?.data,z.contributions,Z,J,(H)=>H?.data),Y=s0($,X,J,Z,z),G=R(j(`insert into ${J.quoteIdent($.table)}`),D4([V],J),Y.clause);return j3($,G,J,Z,Y,z)}function r$($,Z,X,J){let z=X?.data===void 0?[]:r5(X.data),V=a$($,Z,X,J);if(z.length===0)return t5($,Z,J);let Y=e$($,z,Z,J);if(Y[0].length===0&&z.length>1)throw new _("data",$.name,Z,`All ${z.length} rows are empty and ${$.name} has no client-side default to fill, so there is no column to insert. A multi-row insert of nothing but database defaults cannot be expressed on both dialects. Call create ${z.length} times, or set at least one field per row.`);let G=s0($,void 0,J,Z,void 0),H=R(j(`insert into ${J.quoteIdent($.table)}`),D4(Y,J),V??j(""),G.clause),{text:W,binders:M}=m(H,J,{model:$.name,operation:Z});return{text:W,bind:i(M),shape:(D)=>({count:D.length})}}function a$($,Z,X,J){let z=X?.skipDuplicates;if(z===void 0)return null;if(typeof z!=="boolean")throw new I("skipDuplicates",$.name,Z,`Expected true or false, got ${JSON.stringify(z)}.`);let V=J.ignoreConflicts();if(V===null)throw new _("skipDuplicates",$.name,Z,`'skipDuplicates' is not available on ${J.name}. Prisma does not `+"offer it there either \u2014 it is a Postgres and MySQL argument. To "+"import a batch that may overlap, write the rows one at a time and catch UniqueConstraintError, or move this model to Postgres.");return z?V:null}function e$($,Z,X,J){let z=Z.map((Y,G)=>{if(typeof Y!=="object"||Y===null||Array.isArray(Y))throw new I(`data[${G}]`,$.name,X,"Expected an object.");let H=new Set;for(let[W,M]of Object.entries(Y)){if(M===void 0)continue;if(W in $.relations)throw new _(`data.${W}`,$.name,X,"createMany cannot contain nested writes. Use create per row.");if(!(W in $.fields))throw new v(W,$.name,Object.keys($.fields));H.add(W)}return H}),V=[];for(let Y of Object.values($.fields))if(z.some((H)=>H.has(Y.name))||p0(Y)||z4(Y))V.push(Y);for(let Y of V){if(!z.some((W)=>!W.has(Y.name)))continue;if(p0(Y))continue;if(Y.nullable)continue;if(z4(Y))continue;if(Y.default)throw new _(`data.${Y.name}`,$.name,X,`Some rows set '${Y.name}' and others leave it to the database default. A single multi-row insert cannot express both. Split the call, or set '${Y.name}' on every row.`);let H=z.findIndex((W)=>!W.has(Y.name));throw new P3($.name,`${X}.data[${H}]`,Y.name)}for(let Y of V)if(Y.isList)T0($,Y,`data.${Y.name}`,X,J);return Z.map((Y,G)=>V.map((H)=>{if(!z[G].has(H.name))return{field:H,value:z4(H)?o5(H,J):j4(H,J)};if(H.isList)B4($,H,Y?.[H.name],X,["set"]);let W=d5(H,Y?.[H.name]);return{field:H,value:N0($,X,H,J,(M)=>{let D=r5(M?.data)[G]?.[H.name];return W?D?.set:D})}}))}function $6($,Z,X,J){let z=Z==="updateMany";if(X?.data===null)throw new I("data",$.name,Z,"Expected an object of the fields to set, like { name: 'new name' }. An empty object is accepted and reads the row back unchanged; null is not.");if(!z)y($,X?.where,{model:$.name,operation:Z,argument:"where"});if(z)c5($,X?.data,Z,"data","updateMany cannot contain nested writes \u2014 it has no single row to "+"attach them to. Use update per row.");let V=z?void 0:B3($,X?.data,Z,(D)=>D?.data,J),Y=s5($,X?.data,V?.contributions??[],Z,J),G=x($,X?.where,{dialect:J,operation:Z},(D)=>D?.where);if(z&&Y.length===0)return t5($,Z,J);let H=Y.length===0,W=s0($,X,J,Z,V),M=H?R(j("select "),W.selected,j(` from ${J.quoteIdent($.table)}`),G?R(j(" where "),G):j("")):R(j(`update ${J.quoteIdent($.table)} set `),q(Y,", "),G?R(j(" where "),G):j(""),W.clause);return j3($,M,J,Z,W,V)}function Z6($,Z,X,J){if(Z==="delete")y($,X?.where,{model:$.name,operation:Z,argument:"where"});let z=x($,X?.where,{dialect:J,operation:Z},(G)=>G?.where),V=s0($,X,J,Z,void 0),Y=R(j(`delete from ${J.quoteIdent($.table)}`),z?R(j(" where "),z):j(""),V.clause);return j3($,Y,J,Z,V,void 0)}function X6($,Z,X,J){let z=y($,X?.where,{model:$.name,operation:Z,argument:"where"}),V=z.length>1?z.join("_"):z[0],Y=Object.keys(X.where).filter((L)=>L!==V&&X.where[L]!==void 0);if(Y.length>0)throw new _("where",$.name,Z,`The where clause carries ${Y.join(", ")} beside the unique key '${V}'. An upsert compiles its where into an 'on conflict' target, which can only be a key, so the extra ${Y.length===1?"filter would be":"filters would be"} silently dropped. Name exactly one unique key here \u2014 or, if you meant `+"to filter further, use findFirst plus update / create.");for(let L of["create","update"])c5($,X?.[L],Z,L,"Nested writes inside an upsert are not implemented: they would have to run before it is known whether the row is being inserted or updated.");let G=M4($,X,z);if(G.length>0)throw new _("upsert",$.name,Z,`The where clause selects on ${z.join(", ")}, but 'create' does not set ${G.join(", ")}, so 'on conflict' cannot express it. Model.upsert runs this as a read and a write inside one transaction instead; reaching this means the statement was compiled directly.`);let H=J6(p5($,X?.create,[],Z,J,(L)=>L?.create),$,z,Z,J),W=`${J.quoteIdent($.table)}.`,M=s5($,X?.update,[],Z,J,(L)=>L?.update,W),D=q(z.map((L)=>j(J.quoteIdent(Y4($,L).column))),", "),B=M.length>0?M:[j(`${J.quoteIdent(Y4($,z[0]).column)} = ${W}${J.quoteIdent(Y4($,z[0]).column)}`)],P=s0($,X,J,Z,void 0),C=R(j(`insert into ${J.quoteIdent($.table)}`),D4([H],J),j(" on conflict ("),D,j(") do update set "),q(B,", "),P.clause);return j3($,C,J,Z,P,void 0)}function M4($,Z,X){let J=P4($,Z?.create);return X.filter((z)=>!J.has(z))}function J6($,Z,X,J,z){let V=new Set(X);return $.map((Y)=>{if(!V.has(Y.field.name))return Y;let G=Y6(X,Y.field.name);return{field:Y.field,value:(H,W)=>{let M=Y.value(H,W),D=z.encode(G(H),Y.field);if(!z6(M,D))throw new _("upsert",Z.name,J,`'${Y.field.name}' is ${h5(D)} in the where clause but ${h5(M)} in 'create'. An upsert looks the row up by the where clause and inserts what 'create' says, so the two must agree on the key.`);return M}}})}function z6($,Z){if($===Z)return!0;if($ instanceof Date&&Z instanceof Date)return $.getTime()===Z.getTime();if(ArrayBuffer.isView($)&&ArrayBuffer.isView(Z)){let X=new Uint8Array($.buffer,$.byteOffset,$.byteLength),J=new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength);if(X.length!==J.length)return!1;for(let z=0;z<X.length;z++)if(X[z]!==J[z])return!1;return!0}return!1}function h5($){if($ instanceof Date)return JSON.stringify($.toISOString());if(ArrayBuffer.isView($)){let Z=new Uint8Array($.buffer,$.byteOffset,$.byteLength),X=Array.from(Z.slice(0,8),(z)=>z.toString(16).padStart(2,"0")).join(""),J=Z.length>8?"\u2026":"";return`${Z.length} bytes (0x${X}${J})`}if(typeof $==="string")return JSON.stringify($);if($===null||$===void 0)return String($);return`${JSON.stringify(String($))} (${typeof $})`}function Y6($,Z){let X=$.length>1?$.join("_"):void 0;return(J)=>{let z=J?.where;if(z===void 0||z===null)return;if(X!==void 0&&z[X]!==void 0)return z[X][Z];return z[Z]}}function D4($,Z){let X=$[0];if(X.length===0)return j(" default values");let J=q(X.map((V)=>j(Z.quoteIdent(V.field.column))),", "),z=$.map((V)=>R(j("("),q(V.map((Y)=>g(Y.field,Z,Y.value)),", "),j(")")));return R(j(" ("),J,j(") values "),q(z,", "))}function p5($,Z,X,J,z,V){if(Z!==void 0&&Z!==null){if(typeof Z!=="object"||Array.isArray(Z))throw new I("data",$.name,J,"Expected an object.")}let Y=P4($,Z),G=new Map(X.map((W)=>[W.field,W]));for(let W of G.keys())if(Y.has(W))throw new _(`data.${W}`,$.name,J,`'${W}' is set both directly and through a nested relation write. Prisma keeps those two forms exclusive; use one of them.`);let H=[];for(let W of Object.values($.fields)){let M=G.get(W.name);if(M){H.push({field:W,value:(D,B)=>z.encode(M.value(D,B),W)});continue}if(Y.has(W.name)){if(W.isList)T0($,W,`data.${W.name}`,J,z),B4($,W,Z?.[W.name],J,["set"]);let D=d5(W,Z?.[W.name]);H.push({field:W,value:N0($,J,W,z,(B)=>{let P=V(B)?.[W.name];return D?P?.set:P})});continue}if(p0(W)){H.push({field:W,value:j4(W,z)});continue}if(W.default||W.nullable)continue;if(W.isList){T0($,W,`data.${W.name}`,J,z),H.push({field:W,value:o5(W,z)});continue}throw new P3($.name,J,W.name)}return H}function B4($,Z,X,J,z){if(!Z.isList)return;if(typeof X!=="object"||X===null||Array.isArray(X)||X instanceof Date||ArrayBuffer.isView(X))return;let V=Object.keys(X).filter((Y)=>X[Y]!==void 0);if(V.length===1&&z.includes(V[0]))return;throw new _(`data.${Z.name}`,$.name,J,`'${Z.name}' is a scalar list, so it takes ${z.join(" or ")} \u2014 `+`or a bare array. Received ${V.length===0?"an empty object":`{ ${V.join(", ")} }`}. The arithmetic operators apply to a number, not to a list of them.`)}function d5($,Z){return $.isList===!0&&typeof Z==="object"&&Z!==null&&!Array.isArray(Z)&&!(Z instanceof Date)&&!ArrayBuffer.isView(Z)&&Object.keys(Z).length===1&&"set"in Z}function P4($,Z){let X=new Set;if(typeof Z!=="object"||Z===null)return X;for(let[J,z]of Object.entries(Z)){if(z===void 0)continue;if(J in $.relations)continue;if(!(J in $.fields))throw new v(J,$.name,Object.keys($.fields));X.add(J)}return X}function c5($,Z,X,J,z){if(typeof Z!=="object"||Z===null||Array.isArray(Z))return;for(let[V,Y]of Object.entries(Z)){if(Y===void 0)continue;if(V in $.relations)throw new _(`${J}.${V}`,$.name,X,z)}}function s5($,Z,X,J,z,V=(G)=>G?.data,Y=""){if(Z!==void 0&&Z!==null){if(typeof Z!=="object"||Array.isArray(Z))throw new I("data",$.name,J,"Expected an object.")}let G=P4($,Z),H=new Map(X.map((D)=>[D.field,D])),W=H.size>0||G.size>0,M=[];for(let D of Object.values($.fields)){let B=z.quoteIdent(D.column),P=H.get(D.name);if(P){M.push(R(j(`${B} = `),c((C,L)=>z.encode(P.value(C,L),D))));continue}if(G.has(D.name)){M.push(V6($,D,B,`${Y}${B}`,Z,J,z,(C)=>V(C)?.[D.name]));continue}if(D.isUpdatedAt&&W)M.push(R(j(`${B} = `),g(D,z,j4(D,z))))}return M}var i5={increment:"+",decrement:"-",multiply:"*",divide:"/"},l5=["set","push"];function n5($){return $.isList?l5:["set",...Object.keys(i5)]}function V6($,Z,X,J,z,V,Y,G){let H=z[Z.name];if(Z.isList)T0($,Z,`data.${Z.name}`,V,Y),B4($,Z,H,V,l5);if(H6(H,Z)){let W=Object.keys(H).filter((B)=>H[B]!==void 0);if(W.length!==1)throw new _(`data.${Z.name}`,$.name,V,`Expected exactly one of ${n5(Z).join(", ")}.`);let[M]=W,D=(B)=>G(B)?.[M];if(M==="set")return R(j(`${X} = `),g(Z,Y,N0($,V,Z,Y,D)));if(M==="push")return R(j(`${X} = `),Y.listPush(J,g(Z,Y,N0($,V,Z,Y,(B)=>{let P=D(B);return Array.isArray(P)?P:[P]}))));return R(j(`${X} = ${J} ${i5[M]} `),g(Z,Y,N0($,V,Z,Y,D)))}return R(j(`${X} = `),g(Z,Y,N0($,V,Z,Y,G)))}function H6($,Z){if(typeof $!=="object"||$===null||Array.isArray($)||$ instanceof Date||ArrayBuffer.isView($)||Z.type==="Json"&&!Z.isList)return!1;let X=n5(Z),J=Object.keys($);if(J.length===0)return!1;return J.every((z)=>X.includes(z))}function N0($,Z,X,J,z){return(V)=>{let Y=z(V);if(f(Y)==="any")throw new I(`data.${X.name}`,$.name,Z,"Prisma.AnyNull is a filter operand, not a value \u2014 Prisma rejects it "+"in a write here too. Write Prisma.DbNull for a SQL NULL column, or Prisma.JsonNull for the JSON value null.");if(X.isList&&Y!==null&&Y!==void 0){if(!Array.isArray(Y))throw new I(`data.${X.name}`,$.name,Z,`'${X.name}' is a scalar list, so it takes an array \u2014 or `+`{ set: [...] } / { push: \u2026 }. Received ${typeof Y}.`);if(Y.some((G)=>f(G)==="any"))throw new I(`data.${X.name}`,$.name,Z,"Prisma.AnyNull is a filter operand, not a value, and that does not change for being inside a list.")}return J.encode(Y,X)}}function o5($,Z){return()=>Z.encode([],$)}function z4($){return $.isList===!0&&!$.default&&!$.nullable}function j4($,Z){return(X,J)=>Z.encode(n3($,J.now),$)}function s0($,Z,X,J,z){if(u5.has(J))return{clause:j(` returning ${V4($,X)}`),selected:j(V4($,X)),fields:[],relations:[],counts:[]};let V=e($,Z,J),{plans:Y,keyFields:G}=R0($,Z,X,J),{fields:H,hidden:W}=X3($,V,[...G,...z?.keyFields??[]]),M=H3($,Z,X,J),D=q([...H.map((B)=>j(X.quoteIdent(B.column))),...M.map((B)=>B.column)],", ");return{clause:R(j(" returning "),D),selected:D,fields:H,hidden:W,relations:Y,counts:M}}function t5($,Z,X){let J=V4($,X),{text:z,binders:V}=m(j(`select ${J} from ${X.quoteIdent($.table)} where false`),X,{model:$.name,operation:Z});return{text:z,bind:i(V),shape:(Y)=>({count:Y.length})}}function V4($,Z){let X=$.primaryKey[0]??Object.keys($.fields)[0];return Z.quoteIdent($.fields[X].column)}function Y4($,Z){let X=$.fields[Z];if(!X)throw new v(Z,$.name,Object.keys($.fields));return X}function j3($,Z,X,J,z,V){let{text:Y,binders:G}=m(Z,X,{model:$.name,operation:J}),H=k0(z.fields,X,z.relations.map((D)=>({key:D.as,kind:D.kind}))),W=o$.has(J),M=u5.has(J);return{text:Y,bind:i(G),relations:z.relations.length>0?z.relations:void 0,strategies:z.relations.length>0?v0(z.relations):void 0,hidden:z.hidden,before:V&&V.before.length>0?V.before:void 0,after:V&&V.after.length>0?V.after:void 0,counts:z.counts.length>0?!0:void 0,shape(D){if(M)return{count:D.length};let B=H(D);if(z.counts.length>0)for(let P=0;P<B.length;P++){let C=D[P]??{},L={};for(let N of z.counts)L[N.as]=Number(C[N.alias]??0);B[P]._count=L}return W?B[0]??null:B}}}function r5($){if($===void 0||$===null)return[];return Array.isArray($)?$:[$]}function G6($,Z,X){if(X===void 0||X===null)throw new _("args",$.name,Z,`${Z} requires arguments.`);if(typeof X!=="object"||Array.isArray(X))throw new I(String(X),$.name,Z,"Expected an object.");if(X.select!==void 0&&X.include!==void 0)throw new _("select + include",$.name,Z,"Prisma allows only one of them on the same query.");let J=G4[Z];for(let z of Object.keys(X).sort()){if(X[z]===void 0)continue;if(!J.has(z))throw new _(z,$.name,Z,`${Z} takes ${[...J].sort().join(", ")}.`)}for(let z of W6(Z))if(X[z]===void 0)throw new _(z,$.name,Z,`${Z} requires '${z}'.`)}function W6($){switch($){case"create":case"createMany":return["data"];case"update":return["data","where"];case"updateMany":return["data"];case"delete":return["where"];case"upsert":return["where","create","update"];default:return[]}}function M6($,Z,X,J,z){if($!=="postgres")return null;if(J.length>0)return null;if(z===0)return null;if(!/^\s*select/i.test(X))return null;let V=Object.values(Z.fields).filter((Y)=>Y.type==="DateTime").map((Y)=>Y.name);if(V.length===0)return null;return`[gemi] ${Z.name} was read with a query that binds no parameters, on Postgres, in a process whose clock is not UTC. Bun decodes timestamp(3) over the simple query protocol as local time, so ${V.length===1?"the column":"columns"} ${V.join(", ")} will be off by this machine's UTC offset \u2014 the same `+'row read through a query that binds a parameter returns a different instant. Set TZ=UTC on this process. See "Run Postgres deployments with TZ=UTC" in docs/orm.md. (Warned once.)'}function D6($,Z){if(Z===void 0)return new Date($).getTimezoneOffset();let X=new Intl.DateTimeFormat("en-US",{timeZone:Z,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date($)),J=(V)=>Number(X.find((Y)=>Y.type===V)?.value),z=Date.UTC(J("year"),J("month")-1,J("day"),J("hour"),J("minute"),J("second"));return($-z)/60000}function a5($){let Z=new Date().getUTCFullYear();for(let X=0;X<12;X++)if(D6(Date.UTC(Z,X,1),$)!==0)return!0;return!1}function e5($,Z){let X=!1;return(J,z,V,Y)=>{if(!$||X)return null;let G=M6(J,z,V,Y,Z());if(G!==null)X=!0;return G}}var $9=new Set(["by","where","orderBy","having","take","skip",...o]);function _4($){return $==="groupBy"}function K4($,Z,X,J){R6($,Z,X);let z=P6($,Z,X?.by),V=h3($,Z,X),Y=j(` from ${J.quoteIdent($.table)}`),G=x($,X?.where,{dialect:J,operation:Z},(T)=>T?.where),H=G?R(j(" where "),G):j(""),W=q([...z.map((T)=>j(`${J.quoteIdent(T.field.column)} as ${J.quoteIdent(T.alias)}`)),...V.map((T)=>j(B6(T,J)))],", "),M=R(j(" group by "),q(z.map((T)=>j(J.quoteIdent(T.field.column))),", ")),D=X9($,Z,X?.having,z,J),B=D?R(j(" having "),D):j(""),P=L6($,Z,X?.orderBy,z,J),C=P?R(j(" order by "),P):j(""),N=X?.take!==void 0||X?.skip!==void 0?M0($,Z,X,J,[]).clause:j(""),U=R(j("select "),W,Y,H,M,B,C,N),{text:K,binders:Q}=m(U,J,{model:$.name,operation:Z});return{text:K,bind:i(Q),shape(T){return T.map((O)=>{let F={};for(let A of V){if(A.kind==="_count"&&A.as===G3){F._count=I0(A,O[A.alias],J);continue}let b=F[A.kind]??={};b[A.as]=I0(A,O[A.alias],J)}for(let A of z)F[A.field.name]=J.needsDecode(A.field)?J.decode(O[A.alias],A.field):O[A.alias];return F})}}}function B6($,Z){let X=$.field?Z.quoteIdent($.field.column):"*";return`${y0[$.kind]}(${X}) as ${Z.quoteIdent($.alias)}`}function P6($,Z,X){let J=typeof X==="string"?[X]:X;if(!Array.isArray(J))throw new _("by",$.name,Z,`Expected a field name or an array of them, got ${JSON.stringify(X)}.`);if(J.length===0)throw new _("by",$.name,Z,"At least one field is required to group by. Prisma rejects an empty "+"'by' too \u2014 without one there is nothing to group, and the answer "+"would be 'aggregate'.");let z=[],V=new Set;for(let Y of J){if(typeof Y!=="string")throw new _("by",$.name,Z,`Expected field names, got ${JSON.stringify(Y)}.`);if(V.has(Y))continue;if(V.add(Y),Y in $.relations)throw new _(`by.${Y}`,$.name,Z,`'${Y}' is a relation. A group is a set of rows of this model, so only its own columns can name one.`);let G=$.fields[Y];if(!G)throw new v(Y,$.name,Object.keys($.fields));z.push({field:G,alias:`_by_${z.length}`})}return z}function X9($,Z,X,J,z,V=(Y)=>Y?.having){if(X===void 0||X===null)return null;if(typeof X!=="object"||Array.isArray(X))throw new _("having",$.name,Z,"Expected an object of field filters.");let Y=X,G=[];for(let H of Object.keys(Y).sort()){let W=Y[H];if(W===void 0)continue;if(H==="AND"||H==="OR"||H==="NOT"){let B=j6($,Z,H,W,J,z,V);if(B)G.push(B);continue}let M=_6(W),D=K6($,Z,H,J,M);if(M){Q6($,Z,H,W);for(let B of o){let P=W[B];if(P===void 0)continue;W3($,Z,B,D),G.push(Z9(`${y0[B]}(${z.quoteIdent(D.column)})`,P,$,Z,`having.${H}.${B}`,(C)=>V(C)?.[H]?.[B],z))}continue}G.push(Z9(z.quoteIdent(D.column),W,$,Z,`having.${H}`,(B)=>V(B)?.[H],z))}if(G.length===0)return null;return G.length===1?G[0]:R(j("("),q(G," and "),j(")"))}function j6($,Z,X,J,z,V,Y){let G=Array.isArray(J)?J:[J],H=[];for(let M=0;M<G.length;M++){let D=Array.isArray(J)?(P)=>Y(P)?.[X]?.[M]:(P)=>Y(P)?.[X],B=X9($,Z,G[M],z,V,D);if(B)H.push(B)}if(H.length===0)return X==="OR"?j("false"):null;let W=H.length===1?H[0]:R(j("("),q(H,X==="OR"?" or ":" and "),j(")"));return X==="NOT"?R(j("not ("),W,j(")")):W}function _6($){if(typeof $!=="object"||$===null||Array.isArray($))return!1;return o.some((Z)=>(Z in $))}function K6($,Z,X,J,z){let V=u0($,Z,"_count",X);if(z)return V;if(J.some((Y)=>Y.field.name===V.name))return V;throw new _(`having.${X}`,$.name,Z,`'${X}' is not in 'by'. A 'having' filter on a plain column needs the `+"column to be grouped \u2014 a group has one value for those and many for "+`everything else. Prisma refuses this too. Add '${X}' to 'by', aggregate it instead ('having: { ${X}: { _count: { \u2026 } } }'), or `+"filter the rows with 'where' rather than the groups with 'having'.")}function Q6($,Z,X,J){let z=Object.keys(J).filter((V)=>!o.includes(V));if(z.length===0)return;throw new _(`having.${X}`,$.name,Z,"A 'having' filter is either a comparison on a grouped column or a filter "+"on an aggregate of it, not both \u2014 this one mixes "+`${z.sort().join(", ")} with an aggregate. Prisma's query engine panics on this shape rather than answering it, so there is no behaviour to match. Use an 'AND' of the two filters instead.`)}var J9={equals:"=",not:"<>",lt:"<",lte:"<=",gt:">",gte:">="},T6=J9;function Z9($,Z,X,J,z,V,Y){if(typeof Z!=="object"||Z===null||Z instanceof Date)return R(j(`${$} = `),c((W)=>Y.encodeUntyped(V(W))));let G=Z,H=[];for(let W of Object.keys(G).sort()){let M=G[W];if(M===void 0)continue;let D=T6[W];if(!D)throw new _(`${z}.${W}`,X.name,J,`A 'having' filter takes ${Object.keys(J9).sort().join(", ")}.`);if(M===null){H.push(j(`${$} is ${W==="not"?"not ":""}null`));continue}H.push(R(j(`${$} ${D} `),c((B)=>Y.encodeUntyped(V(B)?.[W]))))}if(H.length===0)return j("true");return H.length===1?H[0]:R(j("("),q(H," and "),j(")"))}function L6($,Z,X,J,z){if(X===void 0||X===null)return null;let V=Array.isArray(X)?X:[X],Y=[];for(let G of V){if(typeof G!=="object"||G===null)throw new _("orderBy",$.name,Z,"Expected an object of fields, or an array of them.");for(let H of Object.keys(G)){let W=G[H];if(W===void 0)continue;if(o.includes(H)){Y.push(...C6($,Z,H,W,z));continue}let M=$.fields[H];if(!M)throw new v(H,$.name,Object.keys($.fields));if(!J.some((D)=>D.field.name===M.name))throw new _(`orderBy.${H}`,$.name,Z,`'${H}' is not in 'by'. Every field an 'orderBy' names has to be one of the grouped columns, because a group has one value for those and many for everything else. Prisma refuses this too.`);Y.push(`${z.quoteIdent(M.column)} ${_3($,Z,H,W)}`)}}if(Y.length===0)return null;return j(Y.join(", "))}function C6($,Z,X,J,z){if(typeof J!=="object"||J===null||Array.isArray(J))throw new _(`orderBy.${X}`,$.name,Z,"Expected an object of fields.");let V=[],Y=J;for(let G of Object.keys(Y)){let H=Y[G];if(H===void 0)continue;if(X==="_count"&&G==="_all"){V.push(`count(*) ${_3($,Z,`${X}._all`,H)}`);continue}let W=u0($,Z,X,G);W3($,Z,X,W),V.push(`${y0[X]}(${z.quoteIdent(W.column)}) ${_3($,Z,`${X}.${G}`,H)}`)}return V}function _3($,Z,X,J){if(J==="asc"||J==="desc")return J;if(typeof J==="object"&&J!==null&&!Array.isArray(J)){let{sort:z,nulls:V}=J,Y=_3($,Z,X,z);if(V===void 0)return Y;if(V!=="first"&&V!=="last")throw new _(`orderBy.${X}.nulls`,$.name,Z,`Expected 'first' or 'last', got ${JSON.stringify(V)}.`);return`${Y} nulls ${V}`}throw new _(`orderBy.${X}`,$.name,Z,`Expected 'asc', 'desc', or { sort, nulls }, got ${JSON.stringify(J)}.`)}function R6($,Z,X){if(X===void 0||X===null||typeof X!=="object")throw new _("by",$.name,Z,"groupBy requires 'by'.");for(let J of Object.keys(X).sort()){if(X[J]===void 0)continue;if($9.has(J))continue;throw new _(J,$.name,Z,`${Z} takes ${[...$9].sort().join(", ")}.`)}if(X.by===void 0)throw new _("by",$.name,Z,"groupBy requires 'by'.")}function Q4($,Z,X,J,z){if(y3(Z))return h0($,Z,X,J);if(_4(Z))return K4($,Z,X,J);if(j5(Z))return p3($,Z,X,J,z);if(m5(Z))return W4($,Z,X,J);throw new _(Z,$.name,Z,`'${Z}' is not an operation this ORM compiles \u2014 the reads, the writes, `+"'aggregate' and 'groupBy' are, and a raw statement goes through 'DB.query' or 'DB.execute'.")}var Y9=1000,X0=new Map,T4=0,L4=0,C4=0,I6=new Set(["orderBy","select","omit","include","distinct","mode","_count","_avg","_sum","_min","_max","skipDuplicates","by"]),N6=new Set(["_count","_avg","_sum","_min","_max"]);function J0($,Z=!1,X=!1,J=!1){if($===null)return"null";if($===void 0)return"undefined";let z=typeof $;if(z!=="object")return Z?JSON.stringify($):z;if($ instanceof Date)return"date";let V=f($);if(V)return`jsonNull:${V}`;if(Array.isArray($))return`[${$.map((G)=>J0(G,Z,X,J)).join(",")}]`;return`{${Object.entries($).filter(([,G])=>G!==void 0).sort(([G],[H])=>G<H?-1:G>H?1:0).map(([G,H])=>`${G}:${F6(G,H,Z,X,J)}`).join(",")}}`}var U6=new Set(["in","notIn","hasEvery","hasSome","push","path"]),O6="$compositeIn";function z9($){return $.length===0?"[]":"[*]"}var S6=new Set(["where","cursor","data"]);function F6($,Z,X,J,z){if($==="take"&&typeof Z==="number")return`number:${Math.sign(Z)}`;if($==="skip"&&typeof Z==="number")return"number";if(J&&U6.has($)&&Array.isArray(Z)){if($!=="path"||Z.every((V)=>typeof V==="string"))return z9(Z)}if($===O6){let V=Z;return J0(J?{fields:V.fields,values:z9(V.values)}:Z,!0,J)}if(($==="disconnect"||$==="delete")&&typeof Z==="boolean")return JSON.stringify(Z);if(S6.has($))return J0(Z,!1,J,z);if($==="having")return J0(Z,!1,J,!0);if(z&&N6.has($))return J0(Z,!1,J,!0);return J0(Z,X||I6.has($),J,z)}function V9($,Z,X,J,z="batched"){return`${$.name}:${z}:${Z}:${X}:${J0(J,!1,$.bindsListAsOneParameter)}${A6(J)}`}function A6($){if($===null||typeof $!=="object")return"";let Z=$.lock;return Z===void 0?"":`:lock=${J0(Z,!0)}`}function i0($,Z,X,J,z){let V=V9(J,$.name,Z,X,z?.name),Y=X0.get(V);if(Y)return L4++,X0.delete(V),X0.set(V,Y),Y;let G=Q4($,Z,X,J,z);if(T4++,X0.size>=Y9){let H=X0.keys().next();if(!H.done)X0.delete(H.value),C4++}return X0.set(V,G),G}function b6(){return{size:X0.size,compiles:T4,hits:L4,evictions:C4,capacity:Y9}}function E6(){X0.clear(),T4=0,L4=0,C4=0}var H9=new WeakMap;function K3($,Z,X=P0()){let J={},z={},V=$;for(let Y of Object.keys(V)){if(!(Y in Z.fields))continue;J[Y]=V[Y]}for(let Y of Z.primaryKey)z[Y]=V[Y];H9.set($,{model:Z.name,connection:X,key:z,snapshot:J})}function j0($){if($===null||typeof $!=="object")return;return H9.get($)}function R4($,Z){let X=j0($);if(!X)return{};let J=$,z={};for(let V of Object.keys(X.snapshot))if(!x6(J[V],X.snapshot[V]))z[V]=J[V];return q6($,X,Z),z}function q6($,Z,X){for(let J of Object.keys($)){if(J in Z.snapshot)continue;if(!(J in X.fields))continue;if(J in X.relations)continue;throw new _(`save.${J}`,X.name,"save",`'${J}' was not fetched by the query this row came from, so save `+"cannot write it \u2014 the diff has nothing to compare it against, and "+`writing it blind would overwrite whatever the column actually holds. Select '${J}' in the query, or update it explicitly with ${X.name}.update({ where, data: { ${J} } }).`)}}function Q3($,Z){let X=j0($);if(!X)return;for(let J of Object.keys(Z))X.snapshot[J]=Z[J]}function G9($,Z){let X=$===null||$===void 0?String($):Array.isArray($)?"an array":typeof $;return new _("save",Z,"save","This object carries no provenance, so there is no row to update. Either "+"the query did not ask for it \u2014 pass { track: true } as the second "+`argument, e.g. ${Z}.findUnique({ where }, { track: true }) \u2014 or this `+`is a copy of a row that did. Provenance is keyed on object identity, so spreading, cloning or JSON round-tripping a row loses it. (Received ${X}.)`)}function w6($){return j0($)!==void 0}function x6($,Z){if($===Z)return!0;if($ instanceof Date&&Z instanceof Date)return $.getTime()===Z.getTime();if(ArrayBuffer.isView($)&&ArrayBuffer.isView(Z)){let X=new Uint8Array($.buffer,$.byteOffset,$.byteLength),J=new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength);if(X.length!==J.length)return!1;for(let z=0;z<X.length;z++)if(X[z]!==J[z])return!1;return!0}return!1}var v6=new Set(["findFirstOrThrow","findUniqueOrThrow","update","delete"]);function l0($,Z){return q4($.sql,Z,{slowTransactionThreshold:$.config.slowTransactionThreshold,connection:$.name})}var W9=new WeakMap;class R3{constructor(){}static $schema;static $policies;static $connection;static on($){let Z=W9.get(this);if(Z===void 0)W9.set(this,Z=new Map);let X=Z.get($);if(X!==void 0)return X;let J=class extends this{static $connection=$};return Object.defineProperty(J,"name",{value:this.name,configurable:!0}),Z.set($,J),J}static asSystem($){return b4($)}static asUser($,Z){return E4($,Z)}static async save($){let Z=this.$modelSchema(),X=j0($);if(!X)throw G9($,Z.name);if(X.model!==Z.name)throw new _("save",Z.name,"save",`This row came from ${X.model}, not ${Z.name}. Save it through the model it was read from.`);if(this.$connection!==void 0&&this.$connection!==X.connection)throw new _("save",Z.name,"save",`This row was read on the "${X.connection}" connection and this save names "${this.$connection}". A save writes the row back where it came from, so the two cannot both be honoured. Drop the \`on("${this.$connection}")\`, or write it as an explicit ${Z.name}.on("${this.$connection}").update({ where, data }) if copying it across connections is what you meant.`);let J=Z.primaryKey.filter((Y)=>X.key[Y]===void 0);if(J.length>0)throw new _("save",Z.name,"save",`This row was fetched without ${J.join(", ")}, so there is no way to identify which row to update. A tracked row needs its primary key: add ${J.map((Y)=>`${Y}: true`).join(", ")} to the select, or drop the select to fetch every column.`);let z=R4($,Z);if(Object.keys(z).length===0)return null;let V=await T3(X.connection,()=>this.$exec("update",{where:X.key,data:z}));if(V&&typeof V==="object"&&!Array.isArray(V)){let Y=V,G=$,H={};for(let W of Object.keys(Y)){if(!(W in Z.fields))continue;G[W]=Y[W],H[W]=Y[W]}Q3($,H)}else Q3($,z);return V}static wrap($){let Z=this.$modelSchema(),X=new this;return Object.assign(X,$),K3(X,Z,this.$connection??j0($)?.connection??P0()),X}save(){return this.constructor.save(this)}static $modelSchema(){let $=this.$schema;if(!$)throw new x0(this.name);return $}static async transaction($){let Z=this.$connection??P0();return l0(I4(N4).connection(Z),()=>T3(Z,()=>$()))}static async $exec($,Z={},X){return T3(this.$connection??P0(),()=>this.$execute($,Z,X))}static async $execute($,Z={},X){let J=this.$modelSchema(),z=I4(N4).connection(P0()),V=w4(z.dialect),Y=n0()??z.sql;if(Z?.lock!==void 0&&M3[$]?.has("lock")&&n0()===void 0)throw new F4(J.name,$);let G=A4(),H=G?[]:S0(this),W,M=Z;if(!G){let K=L0(J.name)?D0(J.name):void 0;if(K!==void 0&&K!==this&&!f6(this,K)){let Q=S0(K);if(H.length!==Q.length||H.some((O,F)=>O!==Q[F]))throw new O4(J.name,K.name??String(K),this.name,H.length>0?"queried":"registered")}}let D=D9(X);if(!G&&!D)M=Q9(J,M,o0(),G,(K)=>{if(!L0(K))return;let Q=D0(K),T=Q.$schema;if(!T)return;return{policies:S0(Q),schema:T}});if($==="upsert"&&!D&&m6(J,Z,$)){let{where:K,create:Q,update:T,...O}=Z;return l0(z,async()=>{return await this.$exec("findFirst",{where:K},X)===null?await this.$exec("create",{data:Q,...O},X):await this.$exec("update",{where:K,data:T,...O},X)})}if(H.length>0){if(W=L3(J.name,(D?_9(X):void 0)??$,o0(),G),!D)M=x4(H,W,M,P9(X))}let B=d3(X?.strategy,V,{model:J.name,operation:$});if($==="createMany"&&Array.isArray(M?.data)){let K=u6(J,M,V,B,$);if(K!==null)return l0(z,async()=>{let Q=0;for(let T of K){let O=await this.$exec("createMany",{...M,data:T},U0({strategy:X?.strategy}));Q+=O.count}return{count:Q}})}let P=i0(J,$,M,V,B),C={exec:(K,Q,T,O,F)=>{let A=O?U0({strategy:X?.strategy}):{strategy:X?.strategy};return D0(K).$exec(Q,T,F&&F.length>0?B9(A,F):A)},query:(K,Q)=>Y.unsafe(K,Q)},L=C0();if($==="delete"&&(P.relations!==void 0||P.counts)){let{where:K,...Q}=M;return l0(z,async()=>{let T=await this.$exec("findFirst",{where:K,...Q},j9(U0({strategy:X?.strategy}),$));if(T===null)throw new Z0(J.name,$);return await this.$exec("delete",{where:K},U0({strategy:X?.strategy})),T})}let N=async()=>{Y=n0()??Y,await M9(P.before,M,L,C,[]);let K=await g6(Y,V,J,$,P.text,P.bind(M,L)),Q=this.$shape(P,K);if(Q===null&&v6.has($))throw new Z0(J.name,$);if(await M9(P.after,M,L,C,O0(Q)),P.counts&&P.after!==void 0)await h6(J,this,M,O0(Q),X);if(P.relations!==void 0)await V3(P.relations,P.hidden,Q,M,C);else if(P.hidden!==void 0&&P.hidden.length>0)for(let T of O0(Q))for(let O of P.hidden)delete T[O];if(P.relations!==void 0&&!G)for(let T of P.relations){if(T.root===void 0)continue;T9({as:T.as,model:T.model,folded:T.root.folded},Q,K9,G)}if(W)C3(H,W,Q);if(X?.track===!0)for(let T of O0(Q))K3(T,J);return Q};return P.before!==void 0&&P.before.length>0||P.after!==void 0&&P.after.length>0?l0(z,N):N()}static $shape($,Z){return $.shape(Z)}}function f6($,Z){return Object.getPrototypeOf($)===Z&&!Object.hasOwn($,"$policies")}async function M9($,Z,X,J,z){if($===void 0)return;for(let V of $)await V.run(Z,X,J,z)}var k6=e5(a5(),()=>new Date().getTimezoneOffset());async function g6($,Z,X,J,z,V){let Y=k6(Z.name,X,z,V);if(Y)console.warn(Y);try{return await $.unsafe(z,V)}catch(G){let H=Z.constraintViolation(G);if(!H)throw G;throw new U4(X.name,J,y6(X,H.columns),H.constraint,{cause:G})}}function y6($,Z){return Z.map((X)=>{for(let J of Object.values($.fields))if(J.column===X)return J.name;return X})}async function h6($,Z,X,J,z){let V=X?.include?._count??X?.select?._count;if(V===void 0||J.length===0)return;for(let Y of J){let G={},H=$.primaryKey.length>0;for(let M of $.primaryKey){let D=Y[M];if(D===void 0){H=!1;break}G[M]=D}if(!H)continue;let W=await Z.$exec("findFirst",{where:G,select:{_count:V}},U0({strategy:z?.strategy}));if(W&&W._count!==void 0)Y._count=W._count}}function O0($){if(Array.isArray($))return $;if($===null||$===void 0)return[];if(typeof $!=="object")return[];return[$]}function u6($,Z,X,J,z){let V=Z.data;if(V.length<2)return null;try{return i0($,z,Z,X,J),null}catch(Y){if(!(Y instanceof S4))throw Y;let G={...Z,data:[V[0]]},H=i0($,z,G,X,J).bind(G,C0()).length;if(H===0||H>Y.limit)throw Y;let W=Math.floor(Y.limit/H),M=[];for(let D=0;D<V.length;D+=W)M.push(V.slice(D,D+W));return M}}function m6($,Z,X){try{let J=y($,Z?.where,{model:$.name,operation:X,argument:"where"});return M4($,Z,J).length>0}catch{return!1}}function T9($,Z,X,J){let z=L0($.model)?D0($.model):void 0,V=z?S0(z):[],Y=$.folded??[];if(V.length===0&&Y.length===0)return;let G=V.length>0?L3(z.$schema?.name??$.model,X,o0(),J):void 0,H=[];for(let W of O0(Z)){let M=W?.[$.as];if(M===void 0||M===null)continue;if(G)C3(V,G,M);if(Y.length>0)H.push(...O0(M))}for(let W of Y)T9(W,H,X,J)}class L9 extends R3{static $shape($,Z){let X=$.shape(Z);if(Array.isArray(X))return X.map((J)=>this.hydrate(J));if(X===null||typeof X!=="object")return X;if("count"in X)return X;return this.hydrate(X)}static hydrate($){if($===null||typeof $!=="object")return $;return this.wrap($)}}function p6($={}){let Z=$.field??"deletedAt";return{scope:()=>({[Z]:null}),onCreate:(X,J)=>J,onUpdate:(X,J)=>J}}function d6($,Z={}){let X=Z.field??"deletedAt";return(J)=>{return C9($,J,"delete"),$.update({...J,data:{[X]:new Date}})}}function c6($,Z={}){let X=Z.field??"deletedAt";return(J={})=>{return C9($,J,"deleteMany"),$.updateMany({...J,data:{[X]:new Date}})}}function C9($,Z,X){if(Z?.data===void 0)return;throw new _("data",$.$schema?.name??"unknown",X,`${X} takes no 'data' \u2014 the soft-delete rewrite supplies it. `+"Call update directly if you meant to change other fields at the same time.")}var s6=Number.MAX_SAFE_INTEGER;function I3($){if(typeof $==="string"){if($.trim()==="")return null}else if(typeof $!=="number")return null;let Z=Number($);if(!Number.isFinite(Z))return null;return Math.trunc(Z)}var R9=($,Z,X)=>Math.min(Math.max($,Z),X);function i6($,Z={}){let X=Z.maxPerPage===1/0?1/0:Math.max(1,I3(Z.maxPerPage)??100),J=R9(I3(Z.perPage)??25,1,X),z=R9(I3($?.perPage)??J,1,X),V=Math.max(I3($?.page)??1,1),Y=Math.min((V-1)*z,s6);return{take:z,skip:Y}}export{q4 as withTransaction,L7 as unsafeSql,V7 as transactionDepth,K3 as track,v0 as strategiesOf,K7 as sql,p6 as softDeletes,c6 as softDeleteMany,d6 as softDelete,z$ as shaperCompilationAvailable,J$ as setShaperCompilation,E4 as runAsUser,b4 as runAsSystem,d3 as resolveStrategy,Q3 as resnapshot,C7 as renderFragment,f3 as registry,S7 as registerModels,Z7 as register,N7 as redactNullable,j0 as provenanceOf,L3 as policyContext,S0 as policiesFor,R0 as planRelations,V9 as planKey,b6 as planCacheStats,i6 as paginate,j7 as ormSupports,z7 as ormContext,m0 as lateralStrategy,f as jsonNullKind,Q7 as join,o6 as isUniqueConstraintError,w6 as isTracked,A4 as isSystemScope,n6 as isRecordNotFoundError,O5 as isClientSideDefault,p0 as hasClientSideValue,i0 as getOrCompile,_7 as everyDialect,T7 as empty,w4 as dialectFor,N5 as defaultStrategy,o0 as currentUser,n0 as currentTransaction,H7 as currentActor,b5 as createUuid,A5 as createUlid,F5 as createNanoid,S5 as createCuid,C0 as createBindContext,W4 as compileWrite,p3 as compileRead,Q4 as compile,n3 as clientSideValue,E6 as clearPlanCache,R4 as changedFields,J0 as canonicalShape,k0 as buildRowShaper,g3 as buildInterpretedShaper,G0 as batchedStrategy,O7 as auditModelRegistrations,V3 as attachRelations,N$ as assertSchemaArtifactVersion,U7 as assertPoliciesRegistered,C3 as applyRedaction,x4 as applyPolicies,_ as UnsupportedQueryError,P7 as UnsupportedDialectError,q0 as UnsupportedByDesignError,v3 as UnregisteredRelationTargetError,O4 as UnregisteredPolicyClassError,w0 as UnknownRelationError,v as UnknownFieldError,X7 as UnknownConnectionError,U4 as UniqueConstraintError,Y7 as TransactionDependencyError,s3 as StaleSchemaArtifactError,B7 as SqliteDialect,I7 as ScopedPolicy,r6 as ScopeEscapeError,I$ as SCHEMA_ARTIFACT_VERSION,H4 as ReturningUnsupportedError,x3 as RelationDepthExceededError,Z0 as RecordNotFoundError,G7 as PostgresDialect,t6 as PolicyDeniedError,R7 as Policy,S4 as ParameterLimitError,$7 as ModelNotRegisteredError,R3 as Model,P3 as MissingRequiredValueError,x0 as MissingModelSchemaError,p as MalformedRelationError,Y3 as MAX_RELATION_DEPTH,F4 as LockOutsideTransactionError,M7 as JsonNull,a6 as InvalidPolicyEntryError,I as InvalidArgumentError,l6 as DecodeError,W7 as DbNull,J7 as CrossConnectionTransactionError,D7 as AnyNull,e6 as AmbiguousModelRegistrationError,L9 as ActiveRecordModel};
12
12
 
13
- //# debugId=588F5405E59A6F1564756E2164756E21
13
+ //# debugId=747B5C01BD7679F764756E2164756E21