gemi 0.105.0 → 0.107.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 (242) hide show
  1. package/dist/ai/Agent.d.ts +88 -10
  2. package/dist/ai/Agent.d.ts.map +1 -1
  3. package/dist/ai/AgentController.d.ts +29 -1
  4. package/dist/ai/AgentController.d.ts.map +1 -1
  5. package/dist/ai/AgentProvider.d.ts +6 -0
  6. package/dist/ai/AgentProvider.d.ts.map +1 -1
  7. package/dist/ai/Schema.d.ts +26 -3
  8. package/dist/ai/Schema.d.ts.map +1 -1
  9. package/dist/ai/client/index.js +86 -25
  10. package/dist/ai/client/index.js.map +1 -1
  11. package/dist/ai/client/reducer.d.ts.map +1 -1
  12. package/dist/ai/contextWindow.d.ts +122 -0
  13. package/dist/ai/contextWindow.d.ts.map +1 -0
  14. package/dist/ai/index.d.ts +4 -2
  15. package/dist/ai/index.d.ts.map +1 -1
  16. package/dist/ai/index.js +14 -14
  17. package/dist/ai/index.js.map +10 -9
  18. package/dist/ai/providers/request.d.ts +1 -1
  19. package/dist/ai/providers/request.d.ts.map +1 -1
  20. package/dist/ai/providers/stream.d.ts.map +1 -1
  21. package/dist/ai/types.d.ts +50 -0
  22. package/dist/ai/types.d.ts.map +1 -1
  23. package/dist/ai/useChat.d.ts +47 -1
  24. package/dist/ai/useChat.d.ts.map +1 -1
  25. package/dist/app/index.js +2 -2
  26. package/dist/app/index.js.map +1 -1
  27. package/dist/bin/gemi.js +2 -2
  28. package/dist/bin/gemi.js.map +4 -4
  29. package/dist/bun/customRequestParser.d.ts +9 -0
  30. package/dist/bun/customRequestParser.d.ts.map +1 -0
  31. package/dist/bun/plugin.js +2 -2
  32. package/dist/bun/plugin.js.map +1 -1
  33. package/dist/bun/preload.js +2 -2
  34. package/dist/bun/preload.js.map +2 -2
  35. package/dist/{chunk-rjcmbwcc.js → chunk-00y49jcf.js} +2 -2
  36. package/dist/{chunk-rjcmbwcc.js.map → chunk-00y49jcf.js.map} +1 -1
  37. package/dist/{chunk-22k4b395.js → chunk-1npdp1w2.js} +2 -2
  38. package/dist/{chunk-22k4b395.js.map → chunk-1npdp1w2.js.map} +1 -1
  39. package/dist/{chunk-j6e99sra.js → chunk-1rs13253.js} +75 -75
  40. package/dist/{chunk-j6e99sra.js.map → chunk-1rs13253.js.map} +4 -5
  41. package/dist/{chunk-0fney17e.js → chunk-2gmgd05c.js} +2 -2
  42. package/dist/{chunk-0fney17e.js.map → chunk-2gmgd05c.js.map} +1 -1
  43. package/dist/{chunk-4f7n1r02.js → chunk-2q7m8a16.js} +2 -2
  44. package/dist/{chunk-4f7n1r02.js.map → chunk-2q7m8a16.js.map} +1 -1
  45. package/dist/{chunk-cbywzv21.js → chunk-2xqrh6d0.js} +1 -1
  46. package/dist/{chunk-gyareq03.js → chunk-331s9wqr.js} +3 -3
  47. package/dist/{chunk-gyareq03.js.map → chunk-331s9wqr.js.map} +1 -1
  48. package/dist/{chunk-1xzdexbq.js → chunk-3s3awh38.js} +2 -2
  49. package/dist/{chunk-1xzdexbq.js.map → chunk-3s3awh38.js.map} +1 -1
  50. package/dist/{chunk-v4exgqbp.js → chunk-47rgq59q.js} +2 -2
  51. package/dist/{chunk-v4exgqbp.js.map → chunk-47rgq59q.js.map} +1 -1
  52. package/dist/{chunk-fcsq613t.js → chunk-4rr9wmh8.js} +2 -2
  53. package/dist/{chunk-fcsq613t.js.map → chunk-4rr9wmh8.js.map} +1 -1
  54. package/dist/{chunk-9a8qz3s7.js → chunk-564zfdd1.js} +2 -2
  55. package/dist/{chunk-9a8qz3s7.js.map → chunk-564zfdd1.js.map} +1 -1
  56. package/dist/chunk-5mj7a141.js +17 -0
  57. package/dist/{chunk-48wh5mbp.js.map → chunk-5mj7a141.js.map} +12 -7
  58. package/dist/{chunk-st0d3ndv.js → chunk-5wt25tyd.js} +2 -2
  59. package/dist/{chunk-st0d3ndv.js.map → chunk-5wt25tyd.js.map} +1 -1
  60. package/dist/{chunk-gy6d6jeg.js → chunk-661wezaf.js} +2 -2
  61. package/dist/{chunk-gy6d6jeg.js.map → chunk-661wezaf.js.map} +1 -1
  62. package/dist/{chunk-yxh4xs3k.js → chunk-6rz8kyqb.js} +2 -2
  63. package/dist/{chunk-yxh4xs3k.js.map → chunk-6rz8kyqb.js.map} +1 -1
  64. package/dist/{chunk-y926fhhz.js → chunk-6tyf0h6k.js} +2 -2
  65. package/dist/{chunk-y926fhhz.js.map → chunk-6tyf0h6k.js.map} +1 -1
  66. package/dist/{chunk-18aqqrev.js → chunk-6wrhc9bq.js} +3 -3
  67. package/dist/{chunk-18aqqrev.js.map → chunk-6wrhc9bq.js.map} +1 -1
  68. package/dist/{chunk-w8mm0z6r.js → chunk-6zqqec7r.js} +2 -2
  69. package/dist/{chunk-w8mm0z6r.js.map → chunk-6zqqec7r.js.map} +1 -1
  70. package/dist/{chunk-3m93v7bt.js → chunk-82hpq0bq.js} +2 -2
  71. package/dist/{chunk-3m93v7bt.js.map → chunk-82hpq0bq.js.map} +1 -1
  72. package/dist/{chunk-ee92kx8s.js → chunk-8pynv9rw.js} +2 -2
  73. package/dist/{chunk-ee92kx8s.js.map → chunk-8pynv9rw.js.map} +1 -1
  74. package/dist/{chunk-7kedxtbp.js → chunk-9hbwvcxn.js} +2 -2
  75. package/dist/{chunk-7kedxtbp.js.map → chunk-9hbwvcxn.js.map} +1 -1
  76. package/dist/{chunk-47dqttnk.js → chunk-9jz4rggd.js} +2 -2
  77. package/dist/{chunk-47dqttnk.js.map → chunk-9jz4rggd.js.map} +1 -1
  78. package/dist/{chunk-xnggfm0s.js → chunk-9mqqr05d.js} +3 -3
  79. package/dist/{chunk-xnggfm0s.js.map → chunk-9mqqr05d.js.map} +1 -1
  80. package/dist/{chunk-gvkydx8r.js → chunk-9r3znmqq.js} +2 -2
  81. package/dist/{chunk-gvkydx8r.js.map → chunk-9r3znmqq.js.map} +1 -1
  82. package/dist/{chunk-zq5m4scz.js → chunk-a1g0bahx.js} +2 -2
  83. package/dist/{chunk-zq5m4scz.js.map → chunk-a1g0bahx.js.map} +1 -1
  84. package/dist/{chunk-5ngv175h.js → chunk-anp4kv3w.js} +1 -1
  85. package/dist/{chunk-214av8am.js → chunk-cfsscms3.js} +4 -4
  86. package/dist/{chunk-214av8am.js.map → chunk-cfsscms3.js.map} +1 -1
  87. package/dist/{chunk-q8r9mvzx.js → chunk-eytdyahy.js} +2 -2
  88. package/dist/{chunk-q8r9mvzx.js.map → chunk-eytdyahy.js.map} +1 -1
  89. package/dist/{chunk-j041a7ej.js → chunk-ffagkj3x.js} +2 -2
  90. package/dist/{chunk-j041a7ej.js.map → chunk-ffagkj3x.js.map} +1 -1
  91. package/dist/{chunk-gvv2trvz.js → chunk-fq3sb3xt.js} +3 -3
  92. package/dist/{chunk-gvv2trvz.js.map → chunk-fq3sb3xt.js.map} +1 -1
  93. package/dist/{chunk-b1dqx3b9.js → chunk-ftgd68se.js} +3 -3
  94. package/dist/{chunk-b1dqx3b9.js.map → chunk-ftgd68se.js.map} +1 -1
  95. package/dist/{chunk-j9deswmn.js → chunk-fwympxqk.js} +2 -2
  96. package/dist/{chunk-j9deswmn.js.map → chunk-fwympxqk.js.map} +1 -1
  97. package/dist/{chunk-5dwtmkk8.js → chunk-gqpge54c.js} +2 -2
  98. package/dist/{chunk-5dwtmkk8.js.map → chunk-gqpge54c.js.map} +1 -1
  99. package/dist/{chunk-r5pnz4nn.js → chunk-h3t4n0bn.js} +2 -2
  100. package/dist/{chunk-r5pnz4nn.js.map → chunk-h3t4n0bn.js.map} +1 -1
  101. package/dist/{chunk-zm00crsx.js → chunk-h4x7cba0.js} +3 -3
  102. package/dist/{chunk-zm00crsx.js.map → chunk-h4x7cba0.js.map} +1 -1
  103. package/dist/{chunk-b0jpvp5t.js → chunk-h7pafjej.js} +3 -3
  104. package/dist/{chunk-b0jpvp5t.js.map → chunk-h7pafjej.js.map} +1 -1
  105. package/dist/{chunk-63hvh35x.js → chunk-hdhahvd4.js} +2 -2
  106. package/dist/{chunk-63hvh35x.js.map → chunk-hdhahvd4.js.map} +1 -1
  107. package/dist/{chunk-zytmxty5.js → chunk-hyfzw1fk.js} +2 -2
  108. package/dist/{chunk-zytmxty5.js.map → chunk-hyfzw1fk.js.map} +1 -1
  109. package/dist/{chunk-zmag8k0z.js → chunk-jnw73s8c.js} +2 -2
  110. package/dist/{chunk-zmag8k0z.js.map → chunk-jnw73s8c.js.map} +1 -1
  111. package/dist/{chunk-bsq80942.js → chunk-k17prwhx.js} +3 -3
  112. package/dist/{chunk-bsq80942.js.map → chunk-k17prwhx.js.map} +1 -1
  113. package/dist/{chunk-xxkk60aw.js → chunk-k9qmr2wa.js} +3 -3
  114. package/dist/{chunk-xxkk60aw.js.map → chunk-k9qmr2wa.js.map} +1 -1
  115. package/dist/chunk-kda25fn4.js +5 -0
  116. package/dist/chunk-kda25fn4.js.map +10 -0
  117. package/dist/{chunk-cw7qfcvt.js → chunk-kh273hj0.js} +2 -2
  118. package/dist/{chunk-cw7qfcvt.js.map → chunk-kh273hj0.js.map} +1 -1
  119. package/dist/{chunk-kwkbzswm.js → chunk-kqff894s.js} +2 -2
  120. package/dist/{chunk-kwkbzswm.js.map → chunk-kqff894s.js.map} +1 -1
  121. package/dist/{chunk-ma5rmcbe.js → chunk-kqz8jp6v.js} +2 -2
  122. package/dist/{chunk-ma5rmcbe.js.map → chunk-kqz8jp6v.js.map} +1 -1
  123. package/dist/{chunk-dtybftkq.js → chunk-kstvyvr0.js} +2 -2
  124. package/dist/{chunk-dtybftkq.js.map → chunk-kstvyvr0.js.map} +1 -1
  125. package/dist/{chunk-h945tg0r.js → chunk-m31pfz1s.js} +2 -2
  126. package/dist/{chunk-h945tg0r.js.map → chunk-m31pfz1s.js.map} +1 -1
  127. package/dist/{chunk-4p752vk2.js → chunk-mhq2bd9c.js} +3 -3
  128. package/dist/{chunk-4p752vk2.js.map → chunk-mhq2bd9c.js.map} +1 -1
  129. package/dist/chunk-mrvcaakf.js +5 -0
  130. package/dist/{chunk-f2n21fef.js.map → chunk-mrvcaakf.js.map} +1 -1
  131. package/dist/{chunk-ayss2f8c.js → chunk-njkk498k.js} +2 -2
  132. package/dist/{chunk-ayss2f8c.js.map → chunk-njkk498k.js.map} +1 -1
  133. package/dist/{chunk-hwc8gt4n.js → chunk-pj2e1p07.js} +2 -2
  134. package/dist/{chunk-hwc8gt4n.js.map → chunk-pj2e1p07.js.map} +1 -1
  135. package/dist/{chunk-5k3rm4b6.js → chunk-q2fyp44f.js} +2 -2
  136. package/dist/{chunk-5k3rm4b6.js.map → chunk-q2fyp44f.js.map} +1 -1
  137. package/dist/{chunk-53we503k.js → chunk-q7y9v2v5.js} +3 -3
  138. package/dist/{chunk-53we503k.js.map → chunk-q7y9v2v5.js.map} +1 -1
  139. package/dist/chunk-rh9j8cwv.js +9 -0
  140. package/dist/chunk-rh9j8cwv.js.map +31 -0
  141. package/dist/{chunk-sedwjgvf.js → chunk-rjernda5.js} +2 -2
  142. package/dist/{chunk-sedwjgvf.js.map → chunk-rjernda5.js.map} +1 -1
  143. package/dist/{chunk-2baxmae9.js → chunk-rn2kgbg4.js} +2 -2
  144. package/dist/{chunk-2baxmae9.js.map → chunk-rn2kgbg4.js.map} +1 -1
  145. package/dist/{chunk-8nkdvgd9.js → chunk-sbyqs03h.js} +2 -2
  146. package/dist/{chunk-8nkdvgd9.js.map → chunk-sbyqs03h.js.map} +1 -1
  147. package/dist/{chunk-wc46df4w.js → chunk-t26n9vzw.js} +2 -2
  148. package/dist/{chunk-wc46df4w.js.map → chunk-t26n9vzw.js.map} +1 -1
  149. package/dist/{chunk-8z37k28d.js → chunk-tvy2fqza.js} +2 -2
  150. package/dist/{chunk-8z37k28d.js.map → chunk-tvy2fqza.js.map} +1 -1
  151. package/dist/{chunk-zhk3z9zk.js → chunk-tyhrrnp5.js} +3 -3
  152. package/dist/{chunk-zhk3z9zk.js.map → chunk-tyhrrnp5.js.map} +1 -1
  153. package/dist/{chunk-vh1hxm9y.js → chunk-v52dyw0q.js} +3 -3
  154. package/dist/{chunk-vh1hxm9y.js.map → chunk-v52dyw0q.js.map} +1 -1
  155. package/dist/{chunk-k6rd1nd4.js → chunk-vbm1ng3f.js} +3 -3
  156. package/dist/{chunk-k6rd1nd4.js.map → chunk-vbm1ng3f.js.map} +1 -1
  157. package/dist/{chunk-p2jn4bnx.js → chunk-vj2t77x1.js} +2 -2
  158. package/dist/{chunk-p2jn4bnx.js.map → chunk-vj2t77x1.js.map} +1 -1
  159. package/dist/{chunk-mnctdd8r.js → chunk-we2sj339.js} +2 -2
  160. package/dist/{chunk-mnctdd8r.js.map → chunk-we2sj339.js.map} +1 -1
  161. package/dist/{chunk-szrgwggb.js → chunk-wedwkqe7.js} +3 -3
  162. package/dist/{chunk-szrgwggb.js.map → chunk-wedwkqe7.js.map} +1 -1
  163. package/dist/{chunk-pfjr510h.js → chunk-wsftnxzs.js} +2 -2
  164. package/dist/{chunk-pfjr510h.js.map → chunk-wsftnxzs.js.map} +1 -1
  165. package/dist/{chunk-62cv9vjt.js → chunk-wzqkdmjd.js} +2 -2
  166. package/dist/{chunk-62cv9vjt.js.map → chunk-wzqkdmjd.js.map} +1 -1
  167. package/dist/{chunk-rkre6bqc.js → chunk-xg9vye7c.js} +1 -1
  168. package/dist/{chunk-vqvdptx4.js → chunk-xpyhmg45.js} +2 -2
  169. package/dist/{chunk-vqvdptx4.js.map → chunk-xpyhmg45.js.map} +1 -1
  170. package/dist/{chunk-hzmnqe4x.js → chunk-ydkjf626.js} +2 -2
  171. package/dist/{chunk-hzmnqe4x.js.map → chunk-ydkjf626.js.map} +1 -1
  172. package/dist/{chunk-jfnhzza6.js → chunk-yebaheh7.js} +3 -3
  173. package/dist/{chunk-jfnhzza6.js.map → chunk-yebaheh7.js.map} +1 -1
  174. package/dist/chunk-z38355mx.js +6 -0
  175. package/dist/{chunk-dtcy3110.js.map → chunk-z38355mx.js.map} +2 -2
  176. package/dist/{chunk-dyew1yf7.js → chunk-zrdbytx4.js} +2 -2
  177. package/dist/{chunk-dyew1yf7.js.map → chunk-zrdbytx4.js.map} +1 -1
  178. package/dist/config/index.js +1 -1
  179. package/dist/console/run.js +2 -2
  180. package/dist/console/run.js.map +1 -1
  181. package/dist/container/index.js +2 -2
  182. package/dist/container/index.js.map +1 -1
  183. package/dist/database/index.js +2 -2
  184. package/dist/database/index.js.map +1 -1
  185. package/dist/email/index.js +2 -2
  186. package/dist/email/index.js.map +1 -1
  187. package/dist/facades/index.js +2 -2
  188. package/dist/facades/index.js.map +1 -1
  189. package/dist/foundation/index.js +2 -2
  190. package/dist/foundation/index.js.map +1 -1
  191. package/dist/http/ApiRouter.d.ts.map +1 -1
  192. package/dist/http/BodyLimitMiddleware.d.ts +27 -0
  193. package/dist/http/BodyLimitMiddleware.d.ts.map +1 -0
  194. package/dist/http/HttpRequest.d.ts.map +1 -1
  195. package/dist/http/bodyLimit.d.ts +45 -0
  196. package/dist/http/bodyLimit.d.ts.map +1 -0
  197. package/dist/http/index.d.ts +3 -0
  198. package/dist/http/index.d.ts.map +1 -1
  199. package/dist/http/index.js +2 -2
  200. package/dist/http/index.js.map +1 -1
  201. package/dist/http/middleware-config.d.ts +8 -0
  202. package/dist/http/middleware-config.d.ts.map +1 -1
  203. package/dist/http/safeFetch/addresses.d.ts +60 -0
  204. package/dist/http/safeFetch/addresses.d.ts.map +1 -0
  205. package/dist/http/safeFetch/errors.d.ts +78 -0
  206. package/dist/http/safeFetch/errors.d.ts.map +1 -0
  207. package/dist/http/safeFetch/index.d.ts +4 -0
  208. package/dist/http/safeFetch/index.d.ts.map +1 -0
  209. package/dist/http/safeFetch/safeFetch.d.ts +82 -0
  210. package/dist/http/safeFetch/safeFetch.d.ts.map +1 -0
  211. package/dist/i18n/dictionaryRuntime.js +2 -2
  212. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  213. package/dist/i18n/index.js +2 -2
  214. package/dist/i18n/index.js.map +1 -1
  215. package/dist/kernel/index.js +2 -2
  216. package/dist/kernel/index.js.map +1 -1
  217. package/dist/orm/index.js +2 -2
  218. package/dist/orm/index.js.map +1 -1
  219. package/dist/server/index.js +2 -2
  220. package/dist/server/index.js.map +1 -1
  221. package/dist/services/index.js +2 -2
  222. package/dist/services/index.js.map +1 -1
  223. package/dist/services/middleware/MiddlewareRegistry.d.ts +8 -0
  224. package/dist/services/middleware/MiddlewareRegistry.d.ts.map +1 -1
  225. package/dist/services/queue/work.js +2 -2
  226. package/dist/services/queue/work.js.map +1 -1
  227. package/dist/services/router/ApiRouteDispatcher.d.ts.map +1 -1
  228. package/dist/support/index.js +2 -2
  229. package/dist/support/index.js.map +1 -1
  230. package/dist/vitest/index.d.ts +27 -0
  231. package/dist/vitest/index.d.ts.map +1 -0
  232. package/dist/vitest/index.js +4 -0
  233. package/dist/vitest/index.js.map +10 -0
  234. package/package.json +3 -2
  235. package/dist/chunk-3cxbvrts.js +0 -9
  236. package/dist/chunk-3cxbvrts.js.map +0 -31
  237. package/dist/chunk-48wh5mbp.js +0 -17
  238. package/dist/chunk-dtcy3110.js +0 -6
  239. package/dist/chunk-f2n21fef.js +0 -5
  240. /package/dist/{chunk-cbywzv21.js.map → chunk-2xqrh6d0.js.map} +0 -0
  241. /package/dist/{chunk-5ngv175h.js.map → chunk-anp4kv3w.js.map} +0 -0
  242. /package/dist/{chunk-rkre6bqc.js.map → chunk-xg9vye7c.js.map} +0 -0
@@ -0,0 +1,17 @@
1
+ // @bun
2
+ import{ee as JJ,le as b5}from"./chunk-h7pafjej.js";import{cf as v5,se as MZ,xe as B3}from"./chunk-1npdp1w2.js";import{Af as Sj,Bf as Qj,Df as o1,Ef as V0,Ff as uO,Nf as U9,Of as I$,Pf as _5,df as Lj,hf as T5,if as E4,jf as Kj,kf as Xj,nf as Dj,of as Tj,pf as VZ,qf as Z5,rf as B5,sf as G4,tf as p,yf as A,zf as _j}from"./chunk-rh9j8cwv.js";import{Rf as Q3,Sf as q0,Tf as f1,Uf as R4}from"./chunk-fwympxqk.js";import{Vf as i9,Wf as n2,Xf as H}from"./chunk-njkk498k.js";import{_f as f5}from"./chunk-gqpge54c.js";import{$f as M5}from"./chunk-5wt25tyd.js";import{ag as G5,bg as kZ,cg as qZ,dg as x5,eg as A5,pg as E5}from"./chunk-k9qmr2wa.js";import{Eg as gZ}from"./chunk-4rr9wmh8.js";import{Jg as Y5,Og as z5}from"./chunk-47rgq59q.js";import{Vg as W5,Zg as n}from"./chunk-2q7m8a16.js";import{_g as BZ,bh as N}from"./chunk-9mqqr05d.js";import{ph as F5}from"./chunk-82hpq0bq.js";import{uh as o2}from"./chunk-3s3awh38.js";function L3($){return typeof $==="function"&&$.prototype!==void 0}function D1($){return typeof $==="string"?[$]:$}function _3($,Z){let O=Z?"attachment":"inline",j=$.replace(/["\\]/g,"").replace(/[^\x20-\x7e]/g,"_");return`${O}; filename="${j}"; filename*=UTF-8''${encodeURIComponent($)}`}function l5($){return"total"in $&&"partial"in $&&"body"in $}function J4(){return new Response("Not found",{status:404,headers:{"X-Content-Type-Options":"nosniff"}})}function LZ($){return new Response(null,{status:416,headers:{"Accept-Ranges":"bytes","Content-Range":Tj($),"Content-Length":"0","Cache-Control":"no-store","X-Content-Type-Options":"nosniff"}})}async function d5($){if($ instanceof Blob)return{body:$,start:0,end:$.size-1,total:$.size,partial:!1,type:$.type,name:$.name,download:!1,status:200,extraHeaders:{}};if(l5($))return{body:$.body,start:$.start,end:$.end,total:$.total,partial:$.partial,type:$.type,name:$.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}};let Z=$.file,O=Z instanceof Blob?Z:null,j=$.total??O?.size??-1;return{body:Z,start:$.start??0,end:$.end??j-1,total:j,partial:$.partial??!1,type:$.type??O?.type??"",name:$.name??Z?.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}}}async function Gj($,Z){if($ instanceof Response)return $;if(!$)return J4();let O=await d5($),{body:j,start:J,end:W,total:Y,partial:z}=O;if(j instanceof Blob&&"exists"in j&&typeof j.exists==="function"){if(!await j.exists())return J4()}let{range:X}=Z;if(X){if(Y<=0)return LZ(Math.max(Y,0));if(!z){if(j instanceof Blob){let G=Xj(X,Y);if(!G)return LZ(Y);j=j.slice(G.start,G.end+1),J=G.start,W=G.end,z=!0}}}let D=Boolean(X)&&z,T=D?206:O.status,F=new Headers;if(F.set("Accept-Ranges","bytes"),F.set("Content-Type",O.type||"application/octet-stream"),F.set("X-Content-Type-Options","nosniff"),D)F.set("Content-Range",Dj(J,W,Y)),F.set("Content-Length",String(W-J+1));else if(Y>=0)F.set("Content-Length",String(Y));if(O.name)F.set("Content-Disposition",_3(O.name,O.download));if(O.etag)F.set("ETag",O.etag);if(O.lastModified)F.set("Last-Modified",O.lastModified.toUTCString());for(let[G,U]of Object.entries(O.extraHeaders))F.set(G,U);if((Z.method??"GET").toUpperCase()==="HEAD"){if(j&&"cancel"in j&&typeof j.cancel==="function")await j.cancel();return new Response(null,{status:T,headers:F})}return new Response(j,{status:T,headers:F})}class P$ extends q0{limit;constructor($){super("The request body is too large.",{status:413});this.limit=$}}var W4={b:1,k:1024,kb:1024,m:1048576,mb:1048576,g:1073741824,gb:1073741824};function SZ($){if(typeof $==="number"){if(Number.isFinite($)&&$>=0)return Math.floor($);if($===1/0)return 1/0}else{let Z=$.trim().toLowerCase();if(Z==="none"||Z==="off")return 1/0;let O=/^(\d+(?:\.\d+)?)\s*([a-z]*)$/.exec(Z);if(O&&(O[2]===""||(O[2]in W4)))return Math.floor(Number(O[1])*(W4[O[2]]??1))}throw Error(`Invalid body limit ${JSON.stringify($)}. Use a byte count or a size such as "64kb", "1mb" or "none".`)}var _Z=new WeakMap;function z4($){return _Z.has($)}function X4($){return _Z.get($)?.limit??null}function D4($){let Z=_Z.get($);return Z?Z.read>Z.limit:!1}function i5($){let Z=$.headers.get("Content-Length");if(Z===null||!/^\s*\d+\s*$/.test(Z))return null;return Number(Z)}function Uj($,Z){let O=i5($);if(O!==null&&O>Z)throw new P$(Z)}function S3($,Z,O={}){let j=_Z.get($);if(j)j.limit=Z;else{let J={limit:Z,read:0,stream:void 0,used:!1};_Z.set($,J),s5($,J)}if(O.checkDeclared!==!1)Uj($,Z)}function u5($){return Reflect.get(Object.getPrototypeOf($),"body",$)??null}function Fj($,Z){if(Z.stream!==void 0)return Z.stream;let O=u5($);if(!O)return Z.stream=null;let j;return Z.stream=new ReadableStream({async pull(J){j??=O.getReader();let{done:W,value:Y}=await j.read();if(W){J.close();return}if(Z.read+=Y.byteLength,Z.read>Z.limit){let z=new P$(Z.limit);J.error(z),j.cancel(z).catch(()=>{});return}J.enqueue(Y)},cancel(J){return j?j.cancel(J):O.cancel(J)}},{highWaterMark:0}),Z.stream}async function f$($,Z){if(Uj($,Z.limit),Z.used||Z.stream?.locked)throw TypeError("Body already used");Z.used=!0;let O=Fj($,Z);if(!O)return new Uint8Array(0);let j=O.getReader(),J=[],W=0;for(;;){let{done:X,value:D}=await j.read();if(X)break;J.push(D),W+=D.byteLength}let Y=new Uint8Array(W),z=0;for(let X of J)Y.set(X,z),z+=X.byteLength;return Y}function Y4($){return $.headers.get("Content-Type")??""}function s5($,Z){let O=(j,J)=>Object.defineProperty($,j,{configurable:!0,...J});O("body",{get:()=>Fj($,Z)}),O("bodyUsed",{get:()=>Z.used||Boolean(Z.stream?.locked)||Reflect.get(Object.getPrototypeOf($),"bodyUsed",$)}),O("bytes",{value:()=>f$($,Z)}),O("arrayBuffer",{value:async()=>{let j=await f$($,Z);return j.buffer.slice(j.byteOffset,j.byteOffset+j.byteLength)}}),O("text",{value:async()=>new TextDecoder().decode(await f$($,Z))}),O("json",{value:async()=>JSON.parse(new TextDecoder().decode(await f$($,Z)))}),O("blob",{value:async()=>new Blob([await f$($,Z)],{type:Y4($)})}),O("formData",{value:async()=>new Response(await f$($,Z),{headers:{"Content-Type":Y4($)}}).formData()}),O("clone",{value:()=>{Uj($,Z.limit);let j=Fj($,Z),J=null;if(j){let[W,Y]=j.tee();Z.stream=W,J=Y}return new Request($.url,{method:$.method,headers:$.headers,body:J,signal:$.signal,duplex:"half"})}})}function T4($){return L3($)}class e{method;handler;methodName;__internal_brand="RouteHandler";middlewares=[];constructor($,Z,O){this.method=$;this.handler=Z;this.methodName=O;this.handler=Z,this.methodName=O,this.method=$}get source(){if(!T4(this.handler)||typeof this.methodName!=="string")return;return{controller:this.handler,methodName:this.methodName}}__internal_use(){return{run:this.run.bind(this),middlewares:this.middlewares}}run($){if(T4(this.handler)){let Z=new this.handler;return Z[this.methodName].bind(Z)()}return this.handler()}middleware($){return this.middlewares=D1($),this}}class F4{url;headers;__internal_brand="ProxyHandler";middlewares=[];constructor($,Z){this.url=$;this.headers=Z}middleware($){return this.middlewares=D1($),this}async run(){let $=new A,Z=$.headers.toJSON();for(let O of G4($.rawRequest))delete Z[O];try{return await fetch(this.url,{method:$.rawRequest.method,headers:{...Z,...this.headers},body:$.rawRequest.body})}catch(O){if(D4($.rawRequest))throw new P$(X4($.rawRequest));throw O}}}class U4{constructor(...$){return new e(...$)}}class K4 extends e{__internal_brand="StreamHandler";async run($){let Z=H.getStore(),O=Z?.req?.rawRequest,j=Kj(O?.headers.get("Range"));if(Z)Z.rangeRequest=j;try{let J=await super.run($);return await Gj(J,{range:j,method:O?.method})}catch(J){if(J instanceof Qj)return LZ(J.total);throw J}finally{if(Z)Z.rangeRequest=null}}}class Q4{constructor(...$){return new K4(...$)}}class B4{__internal_brand="ResourceRoutes";first;second;constructor($){this.first={get:new e("GET",$,"list"),post:new e("POST",$,"store")},this.second={get:new e("GET",$,"show"),put:new e("PUT",$,"update"),delete:new e("DELETE",$,"delete")}}middleware($){if($.list)this.first.get.middleware($.list);if($.store)this.first.post.middleware($.store);if($.show)this.second.get.middleware($.show);if($.update)this.second.put.middleware($.update);if($.delete)this.second.delete.middleware($.delete);return this}}class H0{static __brand="ApiRouter";routes={};middlewares=[];middleware($){}get($,Z){return new e("GET",$,Z)}post($,Z){return new e("POST",$,Z)}put($,Z){return new e("PUT",$,Z)}patch($,Z){return new e("PATCH",$,Z)}delete($,Z){return new e("DELETE",$,Z)}resource($){return new B4($)}agent($){if($.kind!=="agent-controller")throw TypeError(`this.agent() takes an AgentController class, and got ${n5($)}.`);return a5($,this)}file($,Z){return new U4("GET",$,Z)}stream($,Z){return new Q4("GET",$,Z)}proxy($,Z={}){return new F4($,Z)}}function n5($){if(typeof $==="function"&&$.name)return $.name;return typeof $}function a5($,Z){let O={stream:new e("POST",$,"stream"),attach:new e("POST",$,"attach"),stop:new e("POST",$,"stop"),upload:new e("POST",$,"upload")};return class extends H0{static __internal_brand="AgentRoute";static controller=$;static handlers=O;constructor(){super();this.middlewares=[...Z?.middlewares??[]]}routes={"/":O.stream,"/attach":O.attach,"/stop":O.stop,"/files":O.upload};static middleware(J){if(J.stream)O.stream.middleware(J.stream);if(J.attach)O.attach.middleware(J.attach);if(J.stop)O.stop.middleware(J.stop);if(J.upload)O.upload.middleware(J.upload);return this}}}class Bj{as;input;bind;__internal_brand="McpModelParam";constructor($,Z,O){this.as=$;this.input=Z;this.bind=O}}class Vj{method;url;meta;__internal_brand="McpRoute";constructor($,Z,O){this.method=$;this.url=Z;this.meta=O}}class V4{static __brand="McpRouter";routes={};param($){return new Bj($.as,$.input,$.bind)}fromApiRoute($,Z,O){return new Vj($,Z,O)}}function Y0($,Z){return $.replace(/:([^/]+[*?]?)/g,(O,j)=>{let J=j.endsWith("?")||j.endsWith("*"),W=J?j.slice(0,-1):j,Y=Z[W];if(Y===void 0){if(J)return"";if(import.meta.env.DEV)throw Error(`Missing parameter: ${W}`);console.error(`Missing parameter: ${W} in URL: ${$}`)}return String(Y)}).replace(/\/\//g,"/").replace(/\/$/,"")}class Cj extends q0{constructor($,Z=307){super("Redirect error");this.name="RedirectError",this.payload={api:{status:200,data:{},directive:{kind:"Redirect",path:$}},view:{status:Z,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:$}}}}}class f3{static to($,...Z){let[O={}]=Z,{search:j={},params:J={},permanent:W,status:Y}={params:{},status:307,permanent:!1,...O},z=new URLSearchParams(j).toString();throw new Cj([Y0($,J)||"/",z.toString()].filter(Boolean).join("?"),Y??(W?301:307))}static external($,Z=307){throw new Cj($,Z)}}var C4=Symbol.for("gemi.HttpResponse");class a1{kind;body;status;headers;[C4]=!0;constructor($,Z,O,j){this.kind=$;this.body=Z;this.status=O;this.headers=j}static json($,Z={}){let O=Z.status??200;return o5(O),new a1("json",$,O,new Headers(Z.headers))}static error($,Z,O={}){if(!Number.isInteger($)||$<400||$>599)throw RangeError(`HttpResponse.error: status must be an integer from 400 to 599, got ${$}.`);return a1.json({error:Z},{...O,status:$})}get ok(){return this.status>=200&&this.status<300}toResponse($,Z){let O=$,j=this.serialize(O);for(let J of Z)O.append("Set-Cookie",J);this.headers.forEach((J,W)=>{if(W.toLowerCase()!=="set-cookie")O.set(W,J)});for(let J of this.headers.getSetCookie())O.append("Set-Cookie",J);if(this.status>=400&&!this.headers.has("Cache-Control"))O.set("Cache-Control","no-store");return new Response(j,{status:this.status,headers:O})}serialize($){switch(this.kind){case"json":return $.set("Content-Type","application/json"),JSON.stringify(this.body)??null}}}function o5($){if(!Number.isInteger($)||$<200||$>599)throw RangeError(`HttpResponse: status must be an integer from 200 to 599, got ${$}.`);if($===204||$===205||$===304)throw RangeError(`HttpResponse.json: a ${$} response has no body.`)}function H$($){return typeof $==="object"&&$!==null&&$[C4]===!0}function r5($,Z,O={}){return a1.error($,Z,O)}class M4{kind="redirect";viewPath="REDIRECT";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>({});else if(typeof $==="function")this.handler=$;else{let[Z,O]=$;this.handler=(j)=>{return new Z()[O](j)}}}async run($,Z){let{destination:O,permanent:j=!1,status:J=307}=await this.handler($);if(!O)throw Error(`Redirect destination is required see ${Z}`);return f3.to(O,{permanent:j,status:J}),{}}middleware($){return this.middlewares=D1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}async function Mj($,Z){if($ instanceof Response)return $;let O=$ instanceof Blob,j=O?$:$.file,J=O?$.name:$.name??$.file?.name,W=(O?$.type:$.type??$.file?.type)||"",Y=O?!1:$.download??!1,z=O?200:$.status??200;if(!O)for(let[X,D]of Object.entries($.headers??{}))Z.set(X,D);if(j instanceof Blob&&"exists"in j&&typeof j.exists==="function"){if(!await j.exists())return new Response("Not found",{status:404})}if(Z.set("Content-Type",W||"application/octet-stream"),j instanceof Blob)Z.set("Content-Length",String(j.size));if(J)Z.set("Content-Disposition",_3(J,Y));return new Response(j instanceof Blob?j.stream():j,{status:z,headers:Z})}class I4{kind="file";viewPath="FILE";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>null;else if(typeof $==="function")this.handler=$;else{let[Z,O]=$;this.handler=(j)=>{return new Z()[O](j)}}}async run($,Z){let O=await this.handler($);if(!O)throw Error(`File route handler must return a file see ${Z}`);return{FILE:O}}middleware($){return this.middlewares=D1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}function N4($,Z){if(H$($))throw Error(`The handler of view "${Z}" returned an HttpResponse. HttpResponse is for api routes; a view handler returns its props.`);return $}class L4{viewPath;middlewares=[];featureGates=[];handler;constructor($,Z){this.viewPath=$;if(!Z)this.handler=()=>({});else if(typeof Z==="function")this.handler=Z;else{let[O,j]=Z;this.handler=(J)=>{return new O()[j](J)}}}async run($,Z){let O=N4(await this.handler($),this.viewPath);return{[this.viewPath]:{...O,breadcrumb:{label:O?.breadcrumb??"",href:Z}}}}middleware($){return this.middlewares=D1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class _4{viewPath;children;middlewares=[];featureGates=[];alwaysRuns=!1;handler=()=>({});constructor($,Z,O){this.viewPath=$;if(typeof Z==="function")this.handler=Z,this.children=class extends _1{routes=O??{}};else if(Array.isArray(Z)){let[j,J]=Z;this.handler=(W)=>{return new j()[J](W)},this.children=class extends _1{routes=O??{}}}else this.children=class extends _1{routes=Z},this.handler=()=>({})}async run($,Z){let O=N4(await this.handler($),this.viewPath);return{[this.viewPath]:{...O,breadcrumb:{label:O?.breadcrumb??"",href:Z}}}}alwaysRun(){return this.alwaysRuns=!0,this}middleware($){return this.middlewares=D1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class _1{middlewares=[];featureGates=[];routes={};view($,Z){return new L4($,Z)}file($){return new I4($)}redirect($){return new M4($)}layout($,Z,O){return new _4($,Z,O)}}class C0{req;config={};constructor($){this.req=$}run(...$){return{}}static configure($){let Z=this;return class extends Z{config=$}}}function t5($){return $}function e5(){return{aliases:{},global:[],bodyLimit:null}}var x$="redirect";function fZ($,Z="/"){if(typeof $!=="string"||!$.startsWith("/"))return Z;if(/[\u0000-\u001f\u007f\\]/.test($)||$.startsWith("//"))return Z;try{let O=new URL($,"http://gemi.invalid");if(O.origin!=="http://gemi.invalid")return Z;let j=`${O.search}${O.hash}`.replaceAll("/","%2F"),J=`${O.pathname}${j}`.replaceAll(":","%3A");return J.startsWith("//")?Z:J}catch{return Z}}function S4($){let Z=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();return Z?Z==="https":new URL($.url).protocol==="https:"}function $7($,Z=!0){let O=new URL($.rawRequest.url),j=O.pathname.replace(/\.(json|og)$/,""),[,J,...W]=j.split("/");if(N(n).supportedLocales.includes(J))j=`/${W.join("/")}`;return Z?`${j}${O.search}`:j}function Z7($,Z){let O=(j)=>j.replace(/\/+$/,"")||"/";return O($)===O(Z)}function P3($,Z){let O=Z||N(E).config.signInPath,j=/^[a-z][a-z\d+.-]*:/i.test(O);if(j?!/^https?:\/\//i.test(O):!O.startsWith("/"))throw Error(`\`auth.signInPath\` must be a path like "/auth/sign-in", or an http(s) URL for sign-in hosted elsewhere. Got "${O}". A route's own \`"auth:<path>"\` cannot carry a URL, because the alias parser splits it on the colon.`);let J=new URL(O,"http://gemi.invalid");if($?.kind==="view"){let W=$7($,!j);if(j||!Z7(new URL(W,J).pathname,J.pathname))J.searchParams.set(x$,W)}return j?J.href:`${J.pathname}${J.search}`}var S1="access_token";function Ij($){return $?.cookies?.get("access_token")||$?.headers?.get("access_token")||null}async function H3($,Z){let O=Ij(Z);if(!O)return null;return(await $.getSession(O,Z.headers.get("User-Agent")))?.user??null}class f4 extends C0{async run($){let Z=H.getStore(),O=Z.req;if(Z.user)return{};let j=await H3(N(E),O);if(!j)throw new o1({redirectTo:P3(O,$)});return Z.setUser(j),{}}}class P4 extends C0{async run(...$){let[Z="public",O="864000",...j]=$,J=`${Z}, max-age=${O}${j.length>0?", ":""}${j.join(", ")}`;if($.length===0)J="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="public")J="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="private")J="private, max-age=0, stale-while-revalidate=300, stale-if-error=600";if(this.req.rawRequest.method==="GET")this.req.ctx().setHeaders("Cache-Control",J);return{}}}var O7={"Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Authorization, X-Requested-With","Access-Control-Allow-Credentials":"true"};class H4 extends C0{config={origins:{"":{"Access-Control-Allow-Methods":"GET, HEAD, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Authorization, X-Requested-With","Access-Control-Allow-Credentials":"true"}}};run(){let $=this.req,Z=$.rawRequest.headers.get("Origin");if(this.config.origins[Z]){$.ctx().setHeaders("Access-Control-Allow-Origin",Z);let O={...O7,...this.config.origins[Z]};for(let[j,J]of Object.entries(O))$.ctx().setHeaders(j,J)}return{}}}class t0{config;static token="ratelimiter";constructor($){this.config=$}get driver(){return this.config.driver}async consume($,Z={}){let O=Z.limit??this.config.limit,j=Z.window??this.config.window,J=Z.cost??1;if(x4("window",j),x4("limit",O),!Number.isFinite(J)||J<0)throw Error(`Rate limiter cost must be zero or greater, got ${J}`);return await this.config.driver.consume({key:$,limit:O,window:j*1000,cost:J})}}function x4($,Z){if(!Number.isFinite(Z)||Z<=0)throw Error(`Rate limiter ${$} must be greater than zero, got ${Z}`)}class PZ extends q0{constructor($){super("Rate limit exceeded");let Z={"Content-Type":"application/json",...$?b4($):{}};this.payload={api:{status:429,data:{error:f1("rate_limit","Rate limit exceeded",429)},headers:Z},view:{error:{message:"Rate limit exceeded"},status:429,headers:Z}}}}class v4 extends C0{async run($,Z){let O=j7();if(!O)return{};let j=await O.consume(this.key(),{limit:A4($)??this.config.limit,window:A4(Z)??this.config.window});if(this.config.headers!==!1){let J=this.req.ctx?.();if(J)for(let[W,Y]of Object.entries(b4(j)))J.setHeaders(W,Y)}if(!j.allowed)throw new PZ(j);return{}}key(){if(this.config.key)return this.config.key(this.req);return`${A$(this.req)}:${this.req.routePath??"*"}`}}function j7(){try{let $=N();return $.bound(t0)?$.make(t0):null}catch{return null}}function A$($){let Z=E4($.rawRequest);if(Z!==void 0)return Z;let O=$.headers.get("x-forwarded-for");if(O){let[j]=O.split(",");if(j?.trim())return j.trim()}return $.headers.get("x-real-ip")?.trim()||"unknown"}function b4($){let Z={"X-RateLimit-Limit":String($.limit),"X-RateLimit-Remaining":String($.remaining),"X-RateLimit-Reset":String(Math.ceil($.resetAt/1000))};if(!$.allowed)Z["Retry-After"]=String(Math.max(1,Math.ceil($.retryAfter/1000)));return Z}function A4($){if($===void 0||$===null||$==="")return;let Z=Number($);if(!Number.isFinite(Z)||Z<=0)return;return Z}class w4 extends C0{async run(){let $=this.req.cookies.get("csrf_token");if(!$)throw new Nj;if(!["POST","PUT","PATCH","DELETE"].includes(this.req.rawRequest.method))return{};if(!Bun.CSRF.verify($,{secret:process.env.SECRET}))throw new Nj;return{}}}class Nj extends q0{constructor(){super("Invalid CSRF token");this.name="InvalidCSRFTokenError"}payload={api:{status:403,data:{error:R4("csrf","Invalid CSRF token",403)}},view:{}}}class x3 extends C0{run($){let Z=$??this.config.limit;if(Z===void 0||Z==="")throw Error('`body-limit` needs a size, as in "body-limit:64kb".');return S3(this.req.rawRequest,SZ(Z)),{}}}class k4{policiesList={};constructor(){let $=this.register();for(let Z of $){let O=new Z;this.policiesList[Z.name]=O}}register(){return[]}}class q4{all($,Z){return!0}}import{lookup as U7}from"dns/promises";import*as K7 from"http";import*as Q7 from"https";import*as q$ from"zlib";function J7($){if($==="")return null;let Z=$.split(".");if(Z.length>1&&Z[Z.length-1]==="")Z.pop();if(Z.length===0||Z.length>4)return null;let O=[];for(let W of Z){let Y=W7(W);if(Y===null)return null;O.push(Y)}let j=O.pop();for(let W of O)if(W>255)return null;if(j>=256**(4-O.length))return null;let J=j;return O.forEach((W,Y)=>{J+=W*256**(3-Y)}),new Uint8Array([Math.floor(J/16777216)&255,Math.floor(J/65536)&255,Math.floor(J/256)&255,J&255])}function W7($){if($==="")return null;let Z=$,O=10;if(/^0x/i.test(Z)){if(Z=Z.slice(2),O=16,Z==="")return 0}else if(Z.length>1&&Z.startsWith("0"))Z=Z.slice(1),O=8;if(!(O===16?/^[0-9a-f]+$/i:O===8?/^[0-7]+$/:/^[0-9]+$/).test(Z))return null;let J=parseInt(Z,O);return Number.isSafeInteger(J)?J:null}function g4($){let Z=$;if(Z.startsWith("[")&&Z.endsWith("]"))Z=Z.slice(1,-1);let O=Z.indexOf("%");if(O!==-1)Z=Z.slice(0,O);if(!Z.includes(":"))return null;let j=Z.split("::");if(j.length>2)return null;let J=(D,T)=>{if(D==="")return[];let F=[],G=D.split(":");for(let U=0;U<G.length;U++){let K=G[U];if(T&&U===G.length-1&&K.includes(".")){if(!/^\d{1,3}(\.\d{1,3}){3}$/.test(K))return null;let Q=K.split(".").map(Number);if(Q.some((B)=>B>255))return null;F.push(Q[0]<<8|Q[1],Q[2]<<8|Q[3]);continue}if(!/^[0-9a-f]{1,4}$/i.test(K))return null;F.push(parseInt(K,16))}return F},W=J(j[0],j.length===1),Y=j.length===2?J(j[1],!0):[];if(!W||!Y)return null;let z;if(j.length===2){let D=8-W.length-Y.length;if(D<1)return null;z=[...W,...Array.from({length:D},()=>0),...Y]}else z=W;if(z.length!==8)return null;let X=new Uint8Array(16);return z.forEach((D,T)=>{X[T*2]=D>>8,X[T*2+1]=D&255}),X}function HZ($){let Z=g4($);if(Z)return{family:6,bytes:Z};let O=J7($);if(O)return{family:4,bytes:O};return null}function r1($){if($.family===6&&Y7($.bytes))return{family:4,bytes:$.bytes.slice(12)};return $}function Y7($){for(let Z=0;Z<10;Z++)if($[Z]!==0)return!1;return $[10]===255&&$[11]===255}function xZ($){if($.family===4)return Array.from($.bytes).join(".");let Z=[];for(let O=0;O<16;O+=2)Z.push(($.bytes[O]<<8|$.bytes[O+1]).toString(16));return Z.join(":")}function v$($){let Z=$.lastIndexOf("/"),O=Z===-1?$:$.slice(0,Z),j=/^[0-9.]+$/.test(O)?z7(O):g4(O);if(!j)return null;let J=r1(j.length===4?{family:4,bytes:j}:{family:6,bytes:j}),W=J.family===4?32:128,Y=W;if(Z!==-1){let z=$.slice(Z+1);if(!/^\d{1,3}$/.test(z))return null;if(Y=Number(z),j.length===16&&J.family===4)Y-=96;if(Y<0||Y>W)return null}return{family:J.family,bytes:J.bytes,prefix:Y}}function z7($){return/^\d{1,3}(\.\d{1,3}){3}$/.test($)&&$.split(".").every((Z)=>Number(Z)<=255)?new Uint8Array($.split(".").map(Number)):null}function T1($,Z){let O=r1($);if(O.family!==Z.family)return!1;let j=Z.prefix;for(let J=0;j>0;J++){let W=Math.min(8,j),Y=255<<8-W&255;if((O.bytes[J]&Y)!==(Z.bytes[J]&Y))return!1;j-=W}return!0}var k=($,Z)=>({cidr:v$($),kind:Z,text:$}),X7=[k("0.0.0.0/8","unspecified"),k("10.0.0.0/8","private"),k("100.64.0.0/10","shared"),k("127.0.0.0/8","loopback"),k("169.254.169.254/32","metadata"),k("169.254.0.0/16","link-local"),k("168.63.129.16/32","metadata"),k("172.16.0.0/12","private"),k("192.0.0.0/24","reserved"),k("192.0.2.0/24","documentation"),k("192.88.99.0/24","reserved"),k("192.168.0.0/16","private"),k("198.18.0.0/15","benchmarking"),k("198.51.100.0/24","documentation"),k("203.0.113.0/24","documentation"),k("224.0.0.0/4","multicast"),k("255.255.255.255/32","broadcast"),k("240.0.0.0/4","reserved")],D7=[k("::/128","unspecified"),k("::1/128","loopback"),k("64:ff9b:1::/48","private"),k("::/8","reserved"),k("100::/64","reserved"),k("2001:db8::/32","documentation"),k("2001::/23","reserved"),k("3fff::/20","documentation"),k("fd00:ec2::254/128","metadata"),k("fc00::/7","unique-local"),k("fe80::/10","link-local"),k("fec0::/10","private"),k("ff00::/8","multicast")],T7=v$("64:ff9b::/96"),G7=v$("2002::/16"),F7=v$("2000::/3");function E$($){let Z=typeof $==="string"?HZ($):$;if(!Z)return{kind:"reserved",range:"not an IP address"};let O=r1(Z);if(O.family===4){let J=X7.find((W)=>T1(O,W.cidr));return J?{kind:J.kind,range:J.text}:null}if(T1(O,T7))return E$({family:4,bytes:O.bytes.slice(12)});if(T1(O,G7))return E$({family:4,bytes:O.bytes.slice(2,6)});let j=D7.find((J)=>T1(O,J.cidr));if(j)return{kind:j.kind,range:j.text};return T1(O,F7)?null:{kind:"reserved",range:"outside 2000::/3"}}function y4($,Z){let O=r1($),j=r1(Z);return O.family===j.family&&O.bytes.every((J,W)=>J===j.bytes[W])}class T0 extends Error{code="safe-fetch";url;constructor($,Z,O){super($,O);this.name=new.target.name,this.url=Z}}class G1 extends T0{reason;code="invalid-url";constructor($,Z,O){super(O,$);this.reason=Z}}class b$ extends T0{host;reason;code="blocked-host";constructor($,Z,O){super(O==="denied"?`Requests to ${Z} are not allowed.`:`${Z} is not on the list of hosts this request may reach.`,$);this.host=Z;this.reason=O}}class P1 extends T0{host;address;range;code="blocked-address";constructor($,Z,O,j){super(Z===O?`${O} is not a public address (${j}).`:`${Z} resolves to ${O}, which is not a public address (${j}).`,$);this.host=Z;this.address=O;this.range=j}}class R$ extends T0{host;code="dns";constructor($,Z,O){super(`Couldn't resolve ${Z}.`,$,{cause:O});this.host=Z}}class w$ extends T0{phase;ms;code="timeout";constructor($,Z,O){super(Z==="connect"?`Couldn't connect within ${O} ms.`:`The request didn't finish within ${O} ms.`,$);this.phase=Z;this.ms=O}}class k$ extends T0{limit;code="too-large";constructor($,Z){super(`The response is larger than ${Z} bytes.`,$);this.limit=Z}}class AZ extends T0{contentType;allowed;code="content-type";constructor($,Z,O){super(`The response is ${Z??"of no content type"}, not ${O.join(" or ")}.`,$);this.contentType=Z;this.allowed=O}}class EZ extends T0{limit;code="too-many-redirects";constructor($,Z){super(`More than ${Z} redirects.`,$);this.limit=Z}}class H1 extends T0{code="network";constructor($,Z){super(`The request failed: ${Z instanceof Error?Z.message:String(Z)}`,$,{cause:Z})}}class bZ extends Response{#J;#Z;address;constructor($,Z,O){super($,Z);this.#J=O.url,this.#Z=O.redirected,this.address=O.address}get url(){return this.#J}get redirected(){return this.#Z}}var vZ={timeout:30000,connectTimeout:1e4,maxSize:10485760,maxRedirects:5,ports:[80,443]},B7=new Set([301,302,303,307,308]),V7=new Set([101,103,204,205,304]),C7=["host","connection","content-length","transfer-encoding","keep-alive","upgrade"],M7=["authorization","cookie","proxy-authorization"];async function h4($,Z={}){let O=I7(Z),j=Z.signal;j?.throwIfAborted();let J=new AbortController,W=J.signal,Y=String($),z=(F)=>{if(!W.aborted)J.abort(F)},X=setTimeout(()=>z(new w$(Y,"total",O.timeout)),O.timeout),D=()=>z(j.reason);j?.addEventListener("abort",D,{once:!0});let T=()=>{clearTimeout(X),j?.removeEventListener("abort",D)};try{let F=p4(Y,O),G=(Z.method??"GET").toUpperCase(),U=new Headers(Z.headers);for(let Q of C7)U.delete(Q);if(!U.has("accept"))U.set("accept","*/*");if(!U.has("user-agent"))U.set("user-agent","gemi");if(!U.has("accept-encoding"))U.set("accept-encoding","gzip, deflate, br");let K=await S7(G,Z.body,U);for(let Q=0;;Q++){Y=F.href;let{request:B,response:M,address:L}=await f7(F,G,U,K,O,W),I=M.statusCode??0,S=M.headers.location;if(B7.has(I)&&S&&Z.redirect!=="manual"){if(B.destroy(),Q>=O.maxRedirects)throw new EZ(F.href,O.maxRedirects);let P;try{P=new URL(S,F)}catch{throw new G1(S,"malformed",`The redirect to "${S}" is not a URL.`)}if(I===303?G!=="HEAD":(I===301||I===302)&&G==="POST"){G="GET",K=null;let V=[];U.forEach((C,_)=>{if(_.startsWith("content-"))V.push(_)});for(let C of V)U.delete(C)}if(P.origin!==F.origin)for(let V of M7)U.delete(V);F=p4(P.href,O);continue}return P7({url:F,hop:Q,method:G,request:B,response:M,address:L,policy:O,signal:W,release:T})}}catch(F){throw T(),W.aborted?W.reason:F}}function I7($){let Z=(j,J)=>{let W={hosts:[],ranges:[]};for(let Y of j){let z=Y.includes("/")||Y.includes(":")||/^[\d.]+$/.test(Y),X=z?v$(Y):null;if(X)W.ranges.push(X);else if(!z&&/^(\*\.)?[a-z0-9-]+(\.[a-z0-9-]+)*\.?$/i.test(Y))W.hosts.push(c4(Y));else throw TypeError(`safeFetch: "${Y}" in ${J} is not a host name or an IP range.`)}return W},O=$.allowPrivate;return{timeout:$.timeout??vZ.timeout,connectTimeout:$.connectTimeout??vZ.connectTimeout,maxSize:$.maxSize??vZ.maxSize,maxRedirects:$.maxRedirects??vZ.maxRedirects,ports:$.ports??vZ.ports,allow:$.allow&&$.allow.length>0?Z($.allow,"allow"):null,deny:Z($.deny??[],"deny"),allowPrivate:O===!0?!0:Z(O||[],"allowPrivate").ranges,contentTypes:$.contentTypes?.length?$.contentTypes:null,resolve:$.resolve??N7}}async function N7($){return(await U7($,{all:!0,verbatim:!0})).map((O)=>O.address)}function c4($){return $.toLowerCase().replace(/\.$/,"")}function m4($,Z){return Z.some((O)=>O.startsWith("*.")?$.endsWith(O.slice(1)):$===O)}function p4($,Z){let O;try{O=new URL($)}catch{throw new G1($,"malformed",`"${$}" is not a URL.`)}if(O.protocol!=="http:"&&O.protocol!=="https:")throw new G1(O.href,"scheme",`Only http and https URLs can be fetched, not ${O.protocol.slice(0,-1)}.`);if(O.username||O.password)throw new G1(O.href,"credentials","The URL has a username or password in it.");let j=l4(O);if(Z.ports!=="any"&&!Z.ports.includes(j))throw new G1(O.href,"port",`Port ${j} is not allowed.`);return O}function l4($){return $.port?Number($.port):$.protocol==="https:"?443:80}async function L7($,Z,O){let j=c4($.hostname.replace(/^\[(.*)\]$/,"$1")),J=HZ(j),W=J!==null&&(j.includes(":")||/^\d+\.\d+\.\d+\.\d+$/.test(j));if(!W&&m4(j,Z.deny.hosts))throw new b$($.href,j,"denied");let Y=!W&&Z.allow!==null&&m4(j,Z.allow.hosts);if(Z.allow&&!Y&&Z.allow.ranges.length===0)throw new b$($.href,j,"not-allowed");let z;if(W)z=[J];else{let X;try{X=await _7(Z.resolve(j),O)}catch(D){if(O.aborted)throw O.reason;throw new R$($.href,j,D)}if(z=X.map((D)=>HZ(D)).filter((D)=>D!==null),z.length===0)throw new R$($.href,j)}for(let X of z){let D=xZ(X);if(Z.deny.ranges.some((F)=>T1(X,F)))throw new P1($.href,j,D,"denied");if(Z.allow&&!Y&&!Z.allow.ranges.some((F)=>T1(X,F)))throw new P1($.href,j,D,"not-allowed");let T=E$(X);if(T&&Z.allowPrivate!==!0&&!Z.allowPrivate.some((F)=>T1(X,F)))throw new P1($.href,j,D,T.kind)}return{host:j,addresses:z,isLiteral:W}}function _7($,Z){if(Z.aborted)return Promise.reject(Z.reason);return new Promise((O,j)=>{let J=()=>j(Z.reason);Z.addEventListener("abort",J,{once:!0}),$.then((W)=>{Z.removeEventListener("abort",J),O(W)},(W)=>{Z.removeEventListener("abort",J),j(W)})})}async function S7($,Z,O){if(Z===void 0||Z===null)return null;if($==="GET"||$==="HEAD")throw TypeError(`safeFetch: a ${$} request can't have a body.`);let j=new Request("http://body.invalid/",{method:"POST",body:Z}),J=j.headers.get("content-type");if(J&&!O.has("content-type"))O.set("content-type",J);return new Uint8Array(await j.arrayBuffer())}async function f7($,Z,O,j,J,W){let Y=new AbortController,z=setTimeout(()=>Y.abort(new w$($.href,"connect",J.connectTimeout)),J.connectTimeout),X=AbortSignal.any([W,Y.signal]);try{let{host:D,addresses:T,isLiteral:F}=await L7($,J,X),G=$.protocol==="https:",U={};if(O.forEach((K,Q)=>{U[Q]=K}),j)U["content-length"]=String(j.byteLength);return await new Promise((K,Q)=>{let B={method:Z,host:D,port:l4($),path:`${$.pathname}${$.search}`,headers:U,agent:!1,lookup:(V,C,_)=>{let x=C?.family,w=T.filter((v)=>!x||v.family===x);if(w.length===0)_(Object.assign(Error(`No IPv${x} address for ${D}`),{code:"ENOTFOUND"}));else if(C?.all)_(null,w.map((v)=>({address:xZ(v),family:v.family})));else _(null,xZ(w[0]),w[0].family)}};if(G&&!F)B.servername=D;let M=(G?Q7:K7).request(B),L=null,I=(V)=>{X.removeEventListener("abort",S),M.destroy(),Q(V)},S=()=>I(X.aborted?X.reason:W.reason);X.addEventListener("abort",S,{once:!0});let P=(V)=>{let C=V?.remoteAddress;if(!C||L!==null)return!0;let _=HZ(C);if(!_||!T.some((x)=>y4(x,_)))return I(new P1($.href,D,C,"not-allowed")),!1;return L=xZ(r1(_)),!0};M.once("socket",(V)=>{let C=()=>{if(P(V)&&!G)clearTimeout(z)};if(V.connecting)V.once("connect",C);else C();if(G)V.once("secureConnect",()=>clearTimeout(z))}),M.once("response",(V)=>{if(clearTimeout(z),V.on("error",()=>{}),!P(V.socket))return;X.removeEventListener("abort",S),K({request:M,response:V,address:L})}),M.on("error",(V)=>{if(X.aborted)return I(X.reason);I(V instanceof T0?V:new H1($.href,V))}),M.end(j??void 0)})}finally{clearTimeout(z)}}function P7({url:$,hop:Z,method:O,request:j,response:J,address:W,policy:Y,signal:z,release:X}){let D=J.statusCode??0;if(D<200||D>599)throw j.destroy(),new H1($.href,Error(`Unexpected status ${D}`));let T=new Headers,F=J.rawHeaders;for(let C=0;C<F.length;C+=2)T.append(F[C],F[C+1]);if(Y.contentTypes){let C=T.get("content-type")?.split(";")[0].trim().toLowerCase()??null;if(!C||!Y.contentTypes.some((_)=>H7(C,_)))throw j.destroy(),new AZ($.href,C,Y.contentTypes)}let G={url:$.href,redirected:Z>0,address:W},U={status:D,statusText:J.statusMessage??"",headers:T};if(O==="HEAD"||V7.has(D))return j.destroy(),X(),new bZ(null,U,G);let K=T.get("content-encoding")?.trim().toLowerCase(),Q=K==="gzip"||K==="x-gzip"?q$.createGunzip():K==="deflate"?q$.createInflate():K==="br"?q$.createBrotliDecompress():null,B=Number(T.get("content-length"));if(!Q&&Number.isFinite(B)&&B>Y.maxSize)throw j.destroy(),new k$($.href,Y.maxSize);if(Q)T.delete("content-encoding"),T.delete("content-length");let M=Q?J.pipe(Q):J,L=0,I=!1,S=()=>{},P=()=>{I=!0,z.removeEventListener("abort",S),X()},V=new ReadableStream({start(C){let _=(w)=>{if(I)return;if(P(),w===void 0)C.close();else j.destroy(),Q?.destroy(),C.error(w)};if(S=()=>_(z.reason),z.addEventListener("abort",S,{once:!0}),z.aborted)return S();M.on("data",(w)=>{if(I)return;if(L+=w.byteLength,L>Y.maxSize)return _(new k$($.href,Y.maxSize));if(C.enqueue(new Uint8Array(w)),(C.desiredSize??1)<=0)M.pause()}),M.once("end",()=>_());let x=(w)=>_(w instanceof T0?w:new H1($.href,w));if(M.on("error",x),Q)J.on("error",x);J.once("aborted",()=>_(new H1($.href,Error("The response was cut off."))))},pull(){M.resume()},cancel(){if(I)return;P(),j.destroy(),Q?.destroy()}});return new bZ(V,U,G)}function H7($,Z){let O=Z.toLowerCase();return O.endsWith("/*")?$.startsWith(O.slice(0,-1)):$===O}import{createHmac as d4,randomBytes as x7}from"crypto";var fj="v2.";function Pj($){return $.startsWith(fj)}function A3(){let $=process.env.SECRET;if(!$)throw Error("Signing in needs a secret to mint session tokens with. Set SECRET in the environment.");return $}function i4($){let Z=x7(16).toString("hex"),O=d4("sha256",A3()).update(`${$}:${Z}`).digest("hex");return`${fj}${O}`}function E3($,Z){let O=d4("sha256",A3()).update(`legacy-session:${Z}:${$}`).digest("hex");return`${fj}${O}`}import{createHash as v7,createHmac as b7,randomInt as R7,timingSafeEqual as n4}from"crypto";function u4($,Z){return Math.floor($/Z)*Z}function A7($,Z){if(Z<=0)return 0;return Math.min(1,Math.max(0,(Z-$)/Z))}function Hj($,Z,O,j){return Z*A7(O,j)+$}function E7($){let{current:Z,previous:O,elapsed:j,window:J,limit:W,cost:Y}=$,z=W-Y;if(z<0)return J;let X=Math.max(0,J-j);if(O>0){let T=J*(1-(z-Z)/O);if(T<=J)return Math.max(0,Math.ceil(T-j))}if(Z<=z)return X;if(Z<=0)return X;let D=J*(1-z/Z);return X+Math.max(0,Math.ceil(D))}function s4($){let{allowed:Z,current:O,previous:j,now:J,elapsed:W,window:Y,limit:z,cost:X}=$;if(Z){let T=Hj(O,j,W,Y);return{allowed:!0,limit:z,remaining:Math.max(0,Math.floor(z-T)),resetAt:J-W+Y,retryAfter:0}}let D=E7({current:O,previous:j,elapsed:W,window:Y,limit:z,cost:X});return{allowed:!1,limit:z,remaining:0,resetAt:J+D,retryAfter:D}}class xj{}class Aj extends xj{buckets=new Map;maxKeys;constructor($={}){super();this.maxKeys=Math.max(1,$.maxKeys??1e5)}consume($){let{key:Z,limit:O,window:j}=$,J=$.cost??1,W=Date.now(),Y=u4(W,j),z=W-Y,X=this.roll(Z,j,Y);X.limit=O;let T=Hj(X.current,X.previous,z,j)+J<=O;if(T)X.current+=J;if(this.buckets.delete(Z),this.buckets.set(Z,X),this.buckets.size>this.maxKeys)this.evict(W);return s4({allowed:T,current:X.current,previous:X.previous,now:W,elapsed:z,window:j,limit:O,cost:J})}clear(){this.buckets.clear()}get size(){return this.buckets.size}roll($,Z,O){let j=this.buckets.get($);if(!j||j.window!==Z)return{window:Z,limit:0,windowStart:O,current:0,previous:0};if(j.windowStart===O)return j;if(j.windowStart+Z===O)return j.previous=j.current,j.current=0,j.windowStart=O,j;return j.previous=0,j.current=0,j.windowStart=O,j}evict($){for(let[j,J]of this.buckets)if($-J.windowStart>=J.window*2)this.buckets.delete(j);let Z=this.maxKeys-Math.floor(this.maxKeys/10);if(this.buckets.size<=Z)return;let O=[...this.buckets].map(([j,J],W)=>({key:j,order:W,spent:J.limit>0?(J.current+J.previous)/J.limit:0}));O.sort((j,J)=>j.spent-J.spent||j.order-J.order);for(let{key:j}of O){if(this.buckets.size<=Z)break;this.buckets.delete(j)}}}var r4="h1.";function v3($,Z,O){let j=b7("sha256",A3()).update(`gemi:one-time:${$}:${Z}:${O}`).digest("hex");return`${r4}${j}`}function RZ($,Z,O,j){let J=typeof j==="string"?j:"",W=typeof O==="string"?O:"",Y=W.startsWith(r4),z=v3($,Z,J),X=Buffer.from(Y?z:J),D=Buffer.from(W);if(X.length!==D.length||J===""||W==="")return n4(X,X),!1;return n4(X,D)}function t4($){let Z="";for(let O=0;O<$;O++)Z+=String(R7(0,10));return Z}var e4=320;function wZ($){if(typeof $!=="string")return null;let Z=$.trim();if(Z===""||Z.length>e4)return null;return Z.toLowerCase()}function Ej($){if(typeof $!=="string")return null;let Z=$.trim();if(Z.length>e4)return null;let O=Z.toLowerCase();if(O.length<3||O.length>254||!/^[^\s@]+@[^\s@]+$/.test(O))return null;return O}var a4=null;function $J(){try{let $=N();if(typeof $?.bound==="function"&&$.bound(t0))return $.make(t0)}catch{}return a4??=new t0({driver:new Aj,limit:1000,window:60}),a4}function o4($){return $.length<=64?$:`sha256:${v7("sha256").update($).digest("hex")}`}async function g$($,Z,O,j){let J=$J(),W=[[`auth:code-${$}:ip:${o4(A$(O))}`,j.perIp]];if(Z!==null)W.push([`auth:code-${$}:email:${o4(Z)}`,j.perEmail]);for(let[Y,z]of W){if(!z)continue;let[X,D]=z,T=await J.consume(Y,{limit:X,window:D});if(!T.allowed)throw new PZ(T)}}async function ZJ($,Z,O,j=10){let J=Math.max(86400,Math.ceil(j*60*(O+1)));return(await $J().consume(`auth:code-attempt:${$}:${Z}`,{limit:O,window:J})).allowed}import{randomBytes as bj}from"crypto";class vj extends A{schema={name:{string:"Invalid name",required:"Name is required","min:2":"Name must be at least 3 characters"},email:{string:"Invalid email",required:"Email is required",email:"Invalid email"},password:{"min:8":"Password must be at least 9 characters"}}}function b3($,Z,O,j=1/0){if(!Number.isInteger(Z)||Z<O||Z>j){let J=j===1/0?`an integer of at least ${O}`:`an integer from ${O} to ${j}`;throw Error(`auth.emailCode.${$} must be ${J}, got ${Z}`)}}function Rj($={}){let Z=$.length??6,O=$.expiresInMinutes??10,j=$.linkExpiresInMinutes??10080,J=$.maxAttempts??5;return b3("length",Z,4,12),b3("expiresInMinutes",O,1),b3("linkExpiresInMinutes",j,1),b3("maxAttempts",J,1),{enabled:$.enabled??!1,createUser:$.createUser??!1,length:Z,expiresInMinutes:O,linkExpiresInMinutes:j,maxAttempts:J,requestLimit:{perEmail:$.requestLimit?.perEmail??[5,900],perIp:$.requestLimit?.perIp??[20,900]},verifyLimit:{perEmail:$.verifyLimit?.perEmail??[10,900],perIp:$.verifyLimit?.perIp??[50,900]},uniformMagicLinkResponse:$.uniformMagicLinkResponse??!1,send:$.send??(({email:W,code:Y})=>{if(Bun.env.NODE_ENV!=="production")console.info(`[gemi] email code for ${W}: ${Y} (set auth.emailCode.send to deliver it)`)})}}async function w7($,Z){if(typeof Z!=="string"||Z==="")return!1;try{return await Bun.password.verify($,Z)}catch{return!1}}function rU($){return $}function OJ($={}){return{basePath:"/auth",verifyEmail:!0,redirectPath:"/dashboard",signInPath:"/auth/sign-in",sessionExpiresInHours:24,sessionAbsoluteExpiresInHours:672,cookieDomain:null,migrateLegacySession:null,signUpRequest:vj,oauthProviders:{},verifyPassword:w7,hashPassword:async(Z)=>await Bun.password.hash(Z),generateForgotPasswordToken:async()=>bj(32).toString("hex"),generateEmailVerificationToken:()=>{if(!($.verifyEmail??!0))return"";return bj(32).toString("hex")},generateMagicLinkToken:()=>bj(32).toString("hex"),extendSession:()=>({}),onUserCreated:async()=>{},onSignUp:()=>{},onSignIn:()=>{},onSignOut:()=>{},onForgotPassword:()=>{},onResetPassword:()=>{},onMagicLinkCreated:()=>{},emailCode:Rj($.emailCode),generateCode:()=>{return},onAuthenticated:()=>{}}}function wj($){if($&&typeof $==="object")delete $.password;return $}function k7(){return new Proxy({},{get:($,Z)=>JJ(Z)})}var jJ=new WeakMap;function WJ($){if($&&typeof $==="object"){for(let Z of Object.values($))WJ(Z);Object.freeze($)}return $}var q7={select:{id:!0,publicId:!0,email:!0,name:!0,locale:!0,globalRole:!0,accounts:{select:{id:!0,publicId:!0,organizationRole:!0,organization:!0}}}},g7=WJ({token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:q7});class kj{models;constructor($=k7()){this.models=$}run($){return this.models.User.asSystem($)}sessionSelect(){return g7}transaction($){return this.models.User.transaction($)}withLegacySessionLock($,Z){let O=this.models.User.$connection??qZ(),j=N(gZ).connection(O),J=()=>this.transaction(async()=>{if(j.dialect==="postgres"){let z=`gemi:legacy-session:${$}`;await kZ()`SELECT pg_advisory_xact_lock(hashtextextended(${z}, 0))`}return Z()});if(j.dialect!=="sqlite"||kZ())return J();let Y=(jJ.get(j)??Promise.resolve()).then(J,J);return jJ.set(j,Y.catch(()=>{})),Y}async createUser($){let Z=await this.run(()=>this.models.User.create({data:$}));return wj(Z)}async updateUserPassword($){let Z=await this.run(()=>this.models.User.update({where:{id:$.id},data:{password:$.password}}));return wj(Z)}async findUserByEmailAddress($,Z){return await this.run(()=>this.models.User.findUnique({where:Z?{email:$,emailVerifiedAt:{not:null}}:{email:$}}))}async findUserByVerificationToken($){if(typeof $!=="string"||$==="")return null;return await this.run(()=>this.models.User.findFirst({where:{verificationToken:$}}))}async verifyUser($){return await this.run(()=>this.models.User.update({where:{email:$},data:{emailVerifiedAt:new Date}}))}async createSession($){return await this.run(()=>this.models.Session.create({data:$,include:{user:!0}}))}async createSessionV2($){return await this.run(()=>this.models.Session.create({data:$,select:this.sessionSelect()}))}async findSession($){if(!$.token)return null;try{return await this.run(()=>this.models.Session.findUnique({where:{token:$.token},select:this.sessionSelect()}))}catch(Z){return console.error("findSession failed:",Z),null}}async updateSession($){return await this.run(()=>this.models.Session.update({where:{token:$.token},data:{expiresAt:$.expiresAt},select:this.sessionSelect()}))}async deleteSession($){if(!$.token)return;await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}))}async claimLegacySession($){if(!$.token)return!1;let{count:Z}=await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}));return Z>0}async deleteAllUserSessions($){await this.run(()=>this.models.Session.deleteMany({where:{userId:$}}))}async createPasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.create({data:{token:$.token,user:{connect:{id:$.user.id}}}}))}async findPasswordResetToken($){if(typeof $.token!=="string"||$.token==="")return null;return await this.run(()=>this.models.PasswordResetToken.findUnique({where:{token:$.token},include:{user:!0}}))}async deletePasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.delete({where:{token:$.token}}))}async findInvitation($,Z){if(typeof $!=="string"||typeof Z!=="string")return null;return await this.run(()=>this.models.OrganizationInvitation.findFirst({where:{publicId:$,email:Z}}))}async deleteInvitationById($){await this.run(()=>this.models.OrganizationInvitation.delete({where:{publicId:$}}))}async createAccount($){return await this.run(()=>this.models.Account.create({data:{userId:$.userId,organizationId:$.organizationId,organizationRole:$.organizationRole}}))}async createMagicLinkToken($){return await this.run(()=>this.models.MagicLinkToken.create({data:{email:$.email,token:$.token,pin:$.pin}}))}async findUserMagicLinkToken($){let Z=(O)=>typeof O==="string"&&O!=="";if(!Z($.email))return null;if($.token!==void 0&&!Z($.token))return null;if($.token===void 0&&!Z($.pin))return null;return await this.run(()=>$.token?this.models.MagicLinkToken.findUnique({where:{token_email:{token:$.token,email:$.email}}}):this.models.MagicLinkToken.findUnique({where:{pin_email:{pin:$.pin,email:$.email}}}))}async findMagicLinkTokenByEmail($){return await this.run(()=>this.models.MagicLinkToken.findFirst({where:{email:$},orderBy:{id:"desc"}}))}async claimMagicLinkToken($){let{count:Z}=await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{id:$}}));return Z===1}async deleteMagicLinkToken($){await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{email:$}}))}async createSocialAccount($){return await this.run(()=>this.models.SocialAccount.create({data:$}))}async findUserBySocialAccount($,Z){if(!Z)return null;let O=await this.run(()=>this.models.SocialAccount.findFirst({where:{provider:$,providerId:Z},include:{user:!0}}));return O?wj(O.user):null}async findSocialAccounts($,Z){return await this.run(()=>this.models.SocialAccount.findMany({where:{userId:$,provider:Z},orderBy:{id:"asc"}}))}async claimSocialAccount($,Z){let{count:O}=await this.run(()=>this.models.SocialAccount.updateMany({where:{id:$.id,providerId:$.providerId},data:{providerId:Z}}));return O===1}}import{randomBytes as IT}from"crypto";function x0($,Z,O,j,J){return p0(Z,NJ($,Z),O,j,J)}function p0($,Z,O,j,J,W){let Y=pj(Z,O,j);if(J&&Z!==Y)throw RangeError(Jz($,Z,O,j,W));return Y}function NJ($,Z){let O=$[Z];if(O===void 0)throw TypeError(Q8(Z));return O}function X0($){return $!==null&&/object|function/.test(typeof $)}function v0($,Z=Map){let O=new Z;return(j,...J)=>{if(O.has(j))return O.get(j);let W=$(j,...J);return O.set(j,W),W}}function nj($){return Z$({name:$},1)}function Z$($,Z){return d0((O)=>({value:O,configurable:1,writable:!Z}),$)}function LJ($){return d0((Z)=>({get:Z,configurable:1}),$)}function n3($){return{[Symbol.toStringTag]:{value:$,configurable:1}}}function d$($,Z){let O={},j=$.length;for(let J of Z)O[$[--j]]=J;return O}function d0($,Z,O){let j={};for(let J in Z)j[J]=$(Z[J],J,O);return j}function uZ($,Z,O){let j={};for(let J=0;J<Z.length;J++){let W=Z[J];j[W]=$(W,J,O)}return j}function y7($,Z,O){let j={};for(let J=0;J<$.length;J++)j[Z[J]]=O[$[J]];return j}function R0($,Z){let O={};for(let j of $)O[j]=Z[j];return O}function aj($,Z){let O={};for(let j in Z)$.has(j)||(O[j]=Z[j]);return O}function oj($){$={...$};let Z=Object.keys($);for(let O of Z)$[O]===void 0&&delete $[O];return $}function _J($,Z){for(let O of Z)if(!(O in $))return 0;return 1}function SJ($,Z,O){for(let j of $)if(Z[j]!==O[j])return 0;return 1}function fJ($,Z,O){let j={...O};for(let J=0;J<Z;J++)j[$[J]]=0;return j}function R($,...Z){return(...O)=>$(...Z,...O)}function YJ($){return $[0].toUpperCase()+$.substring(1)}function sZ($){return $.slice().sort()}function m3($,Z){return String(Z).padStart($,"0")}function x1($,Z){return Math.sign($-Z)}function pj($,Z,O){return Math.min(Math.max($,Z),O)}function U1($,Z){return[Math.floor($/Z),mZ($,Z)]}function mZ($,Z){return($%Z+Z)%Z}function v1($,Z){return[a3($,Z),rj($,Z)]}function a3($,Z){return Math.trunc($/Z)||0}function rj($,Z){return $%Z||0}function R3($){return Math.abs($%1)===0.5}function PJ($,Z,O){let j=0,J=0;for(let z=0;z<=Z;z++){let X=$[O[z]],D=$1[z],T=h/D,[F,G]=v1(X,T);j+=G*D,J+=F}let[W,Y]=v1(j,h);return[J+W,Y]}function o3($,Z,O){let j={};for(let J=Z;J>=0;J--){let W=$1[J];j[O[J]]=a3($,W),$=rj($,W)}return j}function HJ($){return $===q?EO:[]}function xJ($){return $===q?j3:[]}function AJ($){return $===q?["year","day"]:[]}function EJ($){if($!==void 0)return a($)}function vJ($){if($!==void 0)return i0($)}function tj($){if($!==void 0)return nZ($)}function i0($){return wJ(nZ($))}function nZ($){return RJ(AX($))}function ej($){if($==null)throw TypeError("Cannot be null or undefined");return $}function bJ($,Z){if(Z==null)throw RangeError(Q8($));return Z}function Q1($){if(!X0($))throw TypeError(jz);return $}function r3($,Z,O=$){if(typeof Z!==$)throw TypeError($3(O,Z));return Z}function RJ($,Z="number"){if(!Number.isInteger($))throw RangeError($X(Z,$));return $||0}function wJ($,Z="number"){if($<=0)throw RangeError(ZX(Z,$));return $}function $6($){if(typeof $=="symbol")throw TypeError(WX);return String($)}function p3($,Z){return X0($)?String($):a($,Z)}function t3($){if(typeof $=="string")return BigInt($);if(typeof $!="bigint")throw TypeError(JX($));return $}function kJ($,Z="number"){if(typeof $=="bigint")throw TypeError(jX(Z));if($=Number($),!Number.isFinite($))throw RangeError(OX(Z,$));return $}function M0($,Z){return Math.trunc(kJ($,Z))||0}function qJ($,Z){return RJ(kJ($,Z),Z)}function zJ($,Z){return wJ(M0($,Z),Z)}function Z6($,Z){let[O,j]=v1(Z,h),J=$+O,W=Math.sign(J);return W&&W===-Math.sign(j)&&(J-=W,j+=W*h),[J,j]}function m$($,Z,O=1){return Z6($[0]+Z[0]*O,$[1]+Z[1]*O)}function p$($,Z){return Z6($[0],$[1]+Z)}function g0($,Z){return m$(Z,$,-1)}function N0($,Z){return x1($[0],Z[0])||x1($[1],Z[1])}function gJ($,Z,O){return N0($,Z)===-1||N0($,O)===1}function e3($,Z=1){let O=BigInt(h/Z);return[Number($/O),Number($%O)*Z]}function h$($,Z=1){let O=h/Z,[j,J]=v1($,O);return[j,J*Z]}function yJ($,Z=1){let[O,j]=$,J=Math.floor(j/Z),W=h/Z;return BigInt(O)*BigInt(W)+BigInt(J)}function y0($,Z=1,O){let[j,J]=$,[W,Y]=v1(J,Z);return j*(h/Z)+(W+(O?Y/Z:0))}function O6($,Z,O=U1){let[j,J]=$,[W,Y]=O(J,Z);return[j*(h/Z)+W,Y]}function j6($,Z){let O=$.formatToParts(Z),j={};for(let J of O)j[J.type]=J.value;return j}function J6($){return x0($,"isoYear",iZ,dZ,1),$.isoYear===iZ?x0($,"isoMonth",4,12,1):$.isoYear===dZ&&x0($,"isoMonth",1,9,1),$}function A1($){return B1({...$,...l0,isoHour:12}),$}function B1($){let Z=x0($,"isoYear",iZ,dZ,1),O=Z===iZ?1:Z===dZ?-1:0;return O&&m0(I0({...$,isoDay:$.isoDay+O,isoNanosecond:$.isoNanosecond-O})),$}function m0($){if(!$||gJ($,qX,kX))throw RangeError(PO);return $}function b1($){return PJ($,5,a0)[1]}function $O($){let[Z,O]=U1($,h);return[o3(O,5,a0),Z]}function mJ($){return pJ($)[0]}function pJ($){return O6($,c0)}function L0($){return i$($.isoYear,$.isoMonth,$.isoDay,$.isoHour,$.isoMinute,$.isoSecond,$.isoMillisecond)}function I0($){let Z=L0($);if(Z!==void 0){let[O,j]=v1(Z,E0);return[O,j*Z1+($.isoMicrosecond||0)*T$+($.isoNanosecond||0)]}}function W6($,Z){let[O,j]=$O(b1($)-Z);return m0(I0({...$,isoDay:$.isoDay+j,...O}))}function h3(...$){return i$(...$)/Qz}function i$(...$){let[Z,O]=hJ(...$),j=Z.valueOf();if(!isNaN(j))return j-O*E0}function hJ($,Z=1,O=1,j=0,J=0,W=0,Y=0){let z=$===iZ?1:$===dZ?-1:0,X=new Date;return X.setUTCHours(j,J,W,Y),X.setUTCFullYear($,Z-1,O+z),[X,z]}function w1($,Z){let[O,j]=p$($,Z);j<0&&(j+=h,O-=1);let[J,W]=U1(j,Z1),[Y,z]=U1(W,T$);return ZO(O*E0+J,Y,z)}function ZO($,Z=0,O=0){let j=Math.ceil(Math.max(0,Math.abs($)-wX)/E0)*Math.sign($),J=new Date($-j*E0);return d$(bO,[J.getUTCFullYear(),J.getUTCMonth()+1,J.getUTCDate()+j,J.getUTCHours(),J.getUTCMinutes(),J.getUTCSeconds(),J.getUTCMilliseconds(),Z,O])}function cJ($){return[$.isoYear,$.isoMonth,$.isoDay]}function lJ(){return F1}function Y6($,Z){switch(Z){case 2:return z6($)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function dJ($){return z6($)?366:365}function z6($){return $%4==0&&($%100!=0||$%400==0)}function iJ($){let[Z,O]=hJ($.isoYear,$.isoMonth,$.isoDay);return mZ(Z.getUTCDay()-O,7)||7}function uJ({isoYear:$}){return $<1?["bce",1-$]:["ce",$]}function m7($){let Z=L0($);if(Z<yX)return uJ($);let O=j6(R8(c$),Z),{era:j,eraYear:J}=jY(O,c$);return[j,J]}function OO($){return O$($),jO($,1),$}function O$($){return sJ($,1),$}function XJ($){return SJ(f8,$,sJ($))}function sJ($,Z){let{isoYear:O}=$,j=x0($,"isoMonth",1,lJ(),Z);return{isoYear:O,isoMonth:j,isoDay:x0($,"isoDay",1,Y6(O,j),Z)}}function jO($,Z){return d$(a0,[x0($,"isoHour",0,23,Z),x0($,"isoMinute",0,59,Z),x0($,"isoSecond",0,59,Z),x0($,"isoMillisecond",0,999,Z),x0($,"isoMicrosecond",0,999,Z),x0($,"isoNanosecond",0,999,Z)])}function g($){return $===void 0?0:bz(Q1($))}function aZ($,Z=0){$=u0($);let O=Rz($),j=nX($,Z);return[bz($),j,O]}function X6($){return Rz(u0($))}function nJ($){return $=u0($),x8($,9,6,1)}function u$($,Z,O,j=9,J=0,W=4){Z=u0(Z);let Y=x8(Z,j,J),z=G6(Z),X=W3(Z,W),D=J3(Z,j,J,1);return Y==null?Y=Math.max(O,D):tJ(Y,D),z=F6(z,D,1),$&&(X=((T)=>T<4?(T+2)%4:T)(X)),[Y,D,z,X]}function JO($,Z=6,O){let j=G6($=U6($,s3)),J=W3($,7),W=J3($,Z);return W=bJ(s3,W),j=F6(j,W,void 0,O),[W,j,J]}function D6($){return A8(u0($))}function aJ($,Z){return T6(u0($),Z)}function T6($,Z=4){let O=rJ($);return[W3($,4),...oJ(J3($,Z),O)]}function oJ($,Z){return $!=null?[$1[$],$<4?9-3*$:-1]:[Z===void 0?1:10**(9-Z),Z]}function G6($){let Z=$[pZ];return Z===void 0?1:M0(Z,pZ)}function F6($,Z,O,j){let J=j?h:$1[Z+1];if(J){let W=$1[Z];if(J%(($=p0(pZ,$,1,J/W-(j?0:1),1))*W))throw RangeError($3(pZ,$))}else $=p0(pZ,$,1,O?1e9:1,1);return $}function rJ($){let Z=$[mj];if(Z!==void 0){if(typeof Z!="number"){if($6(Z)==="auto")return;throw RangeError($3(mj,Z))}Z=p0(mj,Math.floor(Z),0,9,1)}return Z}function u0($){return $===void 0?{}:Q1($)}function U6($,Z){return typeof $=="string"?{[Z]:$}:Q1($)}function $0($){if($!==void 0){if(X0($))return Object.assign(Object.create(null),$);throw TypeError(jz)}}function WO($,Z){return $&&Object.assign(Object.create(null),$,{overflow:pX[Z]})}function K6($,Z,O=9,j=0,J){let W=Z[$];if(W===void 0)return J?j:void 0;if(W=$6(W),W==="auto")return J?j:null;let Y=dj[W];if(Y===void 0&&(Y=bX[W]),Y===void 0)throw RangeError(zz($,W,dj));return p0($,Y,j,O,1,O3),Y}function j$($,Z,O,j=0){let J=O[$];if(J===void 0)return j;let W=$6(J),Y=Z[W];if(Y===void 0)throw RangeError(zz($,W,Z));return Y}function tJ($,Z){if(Z>$)throw RangeError(SX)}function D0($){return{branding:wO,epochNanoseconds:$}}function U0($,Z,O){return{branding:I1,calendar:O,timeZone:Z,epochNanoseconds:$}}function Z0($,Z=$.calendar){return{branding:F$,calendar:Z,...R0(xz,$)}}function O0($,Z=$.calendar){return{branding:G$,calendar:Z,...R0(P8,$)}}function e1($,Z=$.calendar){return{branding:$Z,calendar:Z,...R0(P8,$)}}function c3($,Z=$.calendar){return{branding:ZZ,calendar:Z,...R0(P8,$)}}function s0($){return{branding:RO,...R0(Hz,$)}}function i($){return{branding:kO,sign:k1($),...R0(L8,$)}}function eJ($){return mJ($.epochNanoseconds)}function YO($){return O6($.epochNanoseconds,Z1)[0]}function $W($){return yJ($.epochNanoseconds,T$)}function ZW($){return yJ($.epochNanoseconds)}function OW($){return $.epochNanoseconds}function G0($){return typeof $=="string"?$:a($.id)}function s$($,Z){return $===Z||G0($)===G0(Z)}function jW($,Z,O,j,J){let W=$$(j),[Y,z]=((B,M)=>{let L=M((B=U6(B,sj))[Ez]),I=sX(B);return I=bJ(sj,I),[I,L]})(J,$);if(cZ(Math.max(Y,W),z))return DJ(j,Y);if(!z)throw RangeError(HO);let[X,D,T]=FO(Z,O,z),F=y6(T),G=UO(T),U=m6(T),K=G(D,X,j),Q=U(D,X,K,Y);return cZ(Y,z)?DJ(Q,Y):((B,M,L,I,S,P,V)=>{let C=k1(B),[_,x]=Q6(I,S8(L,B),L,C,S,P,V),w=B6(M,_,x);return B[y[L]]+w*C})(Q,F(K),Y,D,X,F,G)}function DJ($,Z){return y0(z0($),$1[Z],1)}function Q6($,Z,O,j,J,W,Y){let z=y[O],X={...Z,[z]:Z[z]+j},D=Y($,J,Z),T=Y($,J,X);return[W(D),W(T)]}function B6($,Z,O){let j=y0(g0(Z,O));if(!j)throw RangeError(Z3);return y0(g0(Z,$))/j}function JW($,Z){let[O,j,J]=JO(Z,5,1);return D0(XO($.epochNanoseconds,O,j,J,1))}function WW($,Z,O){let{epochNanoseconds:j,timeZone:J,calendar:W}=Z,[Y,z,X]=JO(O);if(Y===0&&z===1)return Z;let D=$(J);if(Y===6)j=((T,F,G,U)=>{let K=_0(G,F),[Q,B]=T(K),M=G.epochNanoseconds,L=b0(F,Q),I=b0(F,B);if(gJ(M,L,I))throw RangeError(Z3);return KW(B6(M,L,I),U)?I:L})(FW,D,Z,X);else{let T=D.getOffsetNanosecondsFor(j);j=W$(D,TW(w1(j,T),Y,z,X),T,2,0,1)}return U0(j,J,W)}function YW($,Z){return Z0(TW($,...JO(Z)),$.calendar)}function zW($,Z){let[O,j,J]=JO(Z,5);var W;return s0((W=J,V6($,oZ(O,j),W)[0]))}function XW($,Z){let O=$(Z.timeZone),j=_0(Z,O),[J,W]=FW(j),Y=y0(g0(b0(O,J),b0(O,W)),AO,1);if(Y<=0)throw RangeError(Z3);return Y}function DW($,Z){let{timeZone:O,calendar:j}=Z,J=((W,Y,z)=>b0(Y,W(_0(z,Y))))(UW,$(O),Z);return U0(J,O,j)}function TW($,Z,O,j){return GW($,oZ(Z,O),j)}function GW($,Z,O){let[j,J]=V6($,Z,O);return B1({...Y$($,J),...j})}function V6($,Z,O){return $O(R1(b1($),Z,O))}function l3($){return R1($,xO,7)}function oZ($,Z){return $1[$]*Z}function FW($){let Z=UW($);return[Z,Y$(Z,1)]}function UW($){return RX(6,$)}function p7($,Z,O){let j=Math.min($$($),6);return a$(DO(z0($,j),Z,O),j)}function zO($,Z,O,j,J,W,Y,z,X,D){if(j===0&&J===1)return $;let T=cZ(j,z)?KO(z)&&j<6&&O>=6?c7:h7:l7,[F,G,U]=T($,Z,O,j,J,W,Y,z,X,D);return U&&j!==7&&(F=((K,Q,B,M,L,I,S,P)=>{let V=k1(K);for(let C=M+1;C<=B;C++){if(C===7&&B!==7)continue;let _=S8(C,K);_[y[C]]+=V;let x=y0(g0(S(P(L,I,_)),Q));if(x&&Math.sign(x)!==V)break;K=_}return K})(F,G,O,Math.max(6,j),Y,z,X,D)),F}function XO($,Z,O,j,J){if(Z===6){let W=((Y)=>Y[0]+Y[1]/h)($);return[R1(W,O,j),0]}return DO($,oZ(Z,O),j,J)}function DO($,Z,O,j){let[J,W]=$;j&&W<0&&(W+=h,J-=1);let[Y,z]=U1(R1(W,Z,O),h);return Z6(J+Y,z)}function R1($,Z,O){return KW($/Z,O)*Z}function KW($,Z){return rX[Z]($)}function h7($,Z,O,j,J,W){let Y=k1($),z=z0($),X=XO(z,j,J,W),D=g0(z,X),T=Math.sign(X[0]-z[0])===Y,F=a$(X,Math.min(O,6));return[{...$,...F},m$(Z,D),T]}function c7($,Z,O,j,J,W,Y,z,X,D){let T=k1($),F=y0(z0($,5)),G=oZ(j,J),U=R1(F,G,W),[K,Q]=Q6(Y,{...$,..._8},6,T,z,X,D),B=U-y0(g0(K,Q)),M=0;B&&Math.sign(B)!==T?Z=p$(K,U):(M+=T,U=R1(B,G,W),Z=p$(Q,U));let L=BO(U);return[{...$,...L,days:$.days+M},Z,Boolean(M)]}function l7($,Z,O,j,J,W,Y,z,X,D){let T=k1($),F=y[j],G=S8(j,$);j===7&&($={...$,weeks:$.weeks+Math.trunc($.days/7)});let U=a3($[F],J)*J;G[F]=U;let[K,Q]=Q6(Y,G,j,J*T,z,X,D),B=U+B6(Z,K,Q)*T*J,M=R1(B,J,W),L=Math.sign(M-B)===T;return G[F]=M,[G,L?Q:K,L]}function C6($,Z,O,j){let[J,W,Y,z]=((D)=>{let T=T6(D=u0(D));return[D.timeZone,...T]})(j),X=J!==void 0;return((D,T,F,G,U,K)=>{F=DO(F,U,G,1);let Q=T.getOffsetNanosecondsFor(F);return f6(w1(F,Q),K)+(D?J$(l3(Q)):"Z")})(X,Z(X?$(J):U$),O.epochNanoseconds,W,Y,z)}function M6($,Z,O){let[j,J,W,Y,z,X]=((D)=>{D=u0(D);let T=A8(D),F=rJ(D),G=oX(D),U=W3(D,4),K=J3(D,4);return[T,aX(D),G,U,...oJ(K,F)]})(O);return((D,T,F,G,U,K,Q,B,M,L)=>{G=DO(G,M,B,1);let I=D(F).getOffsetNanosecondsFor(G);return f6(w1(G,I),L)+J$(l3(I),Q)+((S,P)=>P!==1?"["+(P===2?"!":"")+G0(S)+"]":"")(F,K)+P6(T,U)})($,Z.calendar,Z.timeZone,Z.epochNanoseconds,j,J,W,Y,z,X)}function I6($,Z){let[O,j,J,W]=((D)=>(D=u0(D),[A8(D),...T6(D)]))(Z);return Y=$.calendar,z=O,X=W,f6(GW($,J,j),X)+P6(Y,z);var Y,z,X}function N6($,Z){return O=$.calendar,j=$,J=D6(Z),d3(j)+P6(O,J);var O,j,J}function L6($,Z){return QW($.calendar,BW,$,D6(Z))}function _6($,Z){return QW($.calendar,d7,$,D6(Z))}function S6($,Z){let[O,j,J]=aJ(Z);return W=J,VW(V6($,j,O)[0],W);var W}function TO($,Z){let[O,j,J]=aJ(Z,3);return j>1&&($={...$,...p7($,j,O)}),((W,Y)=>{let{sign:z}=W,X=z===-1?S0(W):W,{hours:D,minutes:T}=X,[F,G]=O6(z0(X,3),c0,v1);fW(F);let U=H6(G,Y),K=Y>=0||!z||U;return(z<0?"-":"")+"P"+TJ({Y:t1(X.years),M:t1(X.months),W:t1(X.weeks),D:t1(X.days)})+(D||T||F||K?"T"+TJ({H:t1(D),M:t1(T),S:t1(F,K)+U}):"")})($,J)}function QW($,Z,O,j){let J=G0($),W=j>1||j===0&&J!==q;return j===1?J===q?Z(O):d3(O):W?d3(O)+CW(J,j===2):Z(O)}function TJ($){let Z=[];for(let O in $){let j=$[O];j&&Z.push(j,O)}return Z.join("")}function f6($,Z){return d3($)+"T"+VW($,Z)}function d3($){return BW($)+"-"+h0($.isoDay)}function BW($){let{isoYear:Z}=$;return(Z<0||Z>9999?MW(Z)+m3(6,Math.abs(Z)):m3(4,Z))+"-"+h0($.isoMonth)}function d7($){return h0($.isoMonth)+"-"+h0($.isoDay)}function VW($,Z){let O=[h0($.isoHour),h0($.isoMinute)];return Z!==-1&&O.push(h0($.isoSecond)+((j,J,W,Y)=>H6(j*Z1+J*T$+W,Y))($.isoMillisecond,$.isoMicrosecond,$.isoNanosecond,Z)),O.join(":")}function J$($,Z=0){if(Z===1)return"";let[O,j]=U1(Math.abs($),AO),[J,W]=U1(j,xO),[Y,z]=U1(W,c0);return MW($)+h0(O)+":"+h0(J)+(Y||z?":"+h0(Y)+H6(z):"")}function P6($,Z){if(Z!==1){let O=G0($);if(Z>1||Z===0&&O!==q)return CW(O,Z===2)}return""}function CW($,Z){return"["+(Z?"!":"")+"u-ca="+$+"]"}function H6($,Z){let O=m3(9,$);return O=Z===void 0?O.replace($D,""):O.slice(0,Z),O?"."+O:""}function MW($){return $<0?"-":"+"}function t1($,Z){return $||Z?$.toLocaleString("fullwide",{useGrouping:0}):""}function i7($,Z){let{epochNanoseconds:O}=$,j=(Z.getOffsetNanosecondsFor?Z:Z($.timeZone)).getOffsetNanosecondsFor(O),J=w1(O,j);return{calendar:$.calendar,...J,offsetNanoseconds:j}}function IW($,Z){let O=_0(Z,$);return{calendar:Z.calendar,...R0(xz,O),offset:J$(O.offsetNanoseconds),timeZone:Z.timeZone}}function W$($,Z,O,j=0,J=0,W,Y){if(O!==void 0&&j===1&&(j===1||Y))return W6(Z,O);let z=$.getPossibleInstantsFor(Z);if(O!==void 0&&j!==3){let X=((D,T,F,G)=>{let U=I0(T);G&&(F=l3(F));for(let K of D){let Q=y0(g0(K,U));if(G&&(Q=l3(Q)),Q===F)return K}})(z,Z,O,W);if(X!==void 0)return X;if(j===0)throw RangeError(CX)}return Y?I0(Z):b0($,Z,J,z)}function b0($,Z,O=0,j=$.getPossibleInstantsFor(Z)){if(j.length===1)return j[0];if(O===1)throw RangeError(MX);if(j.length)return j[O===3?1:0];let J=I0(Z),W=((z,X)=>{let D=z.getOffsetNanosecondsFor(p$(X,-h));return A6(z.getOffsetNanosecondsFor(p$(X,h))-D)})($,J),Y=W*(O===2?-1:1);return(j=$.getPossibleInstantsFor(w1(J,Y)))[O===2?0:j.length-1]}function x6($){if(Math.abs($)>=h)throw RangeError(BX);return $}function A6($){if($>h)throw RangeError(VX);return $}function E6($,Z,O){return D0(m0(m$(Z.epochNanoseconds,((j)=>{if(PW(j))throw RangeError(LX);return z0(j,5)})($?S0(O):O))))}function v6($,Z,O,j,J,W=Object.create(null)){let Y=Z(j.timeZone),z=$(j.calendar);return{...j,...q6(Y,z,j,O?S0(J):J,W)}}function b6($,Z,O,j,J=Object.create(null)){let{calendar:W}=O;return Z0(g6($(W),O,Z?S0(j):j,J),W)}function R6($,Z,O,j,J){let{calendar:W}=O;return O0(GO($(W),O,Z?S0(j):j,J),W)}function w6($,Z,O,j,J=Object.create(null)){let W=O.calendar,Y=$(W),z=hZ(Y,O);Z&&(j=QO(j)),j.sign<0&&(z=Y.dateAdd(z,{...F0,months:1}),z=Y$(z,-1));let X=Y.dateAdd(z,j,J);return e1(hZ(Y,X),W)}function k6($,Z,O){return s0(NW(Z,$?S0(O):O)[0])}function q6($,Z,O,j,J){let W=z0(j,5),Y=O.epochNanoseconds;if(PW(j)){let z=_0(O,$);Y=m$(b0($,{...GO(Z,z,{...j,..._8},J),...R0(a0,z)}),W)}else Y=m$(Y,W),g(J);return{epochNanoseconds:m0(Y)}}function g6($,Z,O,j){let[J,W]=NW(Z,O);return B1({...GO($,Z,{...O,..._8,days:O.days+W},j),...J})}function GO($,Z,O,j){if(O.years||O.months||O.weeks)return $.dateAdd(Z,O,j);g(j);let J=O.days+z0(O,5)[0];return J?A1(Y$(Z,J)):Z}function hZ($,Z,O=1){return Y$(Z,O-$.day(Z))}function NW($,Z){let[O,j]=z0(Z,5),[J,W]=$O(b1($)+j);return[J,O+W]}function Y$($,Z){return Z?{...$,...ZO(L0($)+Z*E0)}:$}function FO($,Z,O){let j=$(O.calendar);return KO(O)?[O,j,Z(O.timeZone)]:[{...O,...l0},j]}function y6($){return $?OW:I0}function UO($){return $?R(q6,$):g6}function m6($){return $?R(s7,$):n7}function KO($){return $&&$.epochNanoseconds}function cZ($,Z){return $<=6-(KO(Z)?1:0)}function p6($,Z,O,j,J,W,Y){let z=$(u0(Y).relativeTo),X=Math.max($$(J),$$(W));if(cZ(X,z))return i(n$(((Q,B,M,L)=>{let I=m$(z0(Q),z0(B),L?-1:1);if(!Number.isFinite(I[0]))throw RangeError(PO);return{...F0,...a$(I,M)}})(J,W,X,j)));if(!z)throw RangeError(HO);j&&(W=S0(W));let[D,T,F]=FO(Z,O,z),G=UO(F),U=m6(F),K=G(T,D,J);return i(U(T,D,G(T,K,W),X))}function LW($,Z,O,j,J){let W=$$(j),[Y,z,X,D,T]=((V,C,_)=>{V=U6(V,s3);let x=x8(V),w=_(V[Ez]),v=G6(V),m=W3(V,7),s=J3(V);if(x===void 0&&s===void 0)throw RangeError(_X);return s==null&&(s=0),x==null&&(x=Math.max(s,C)),tJ(x,s),v=F6(v,s,1),[x,s,v,m,w]})(J,W,$),F=Math.max(W,Y);if(!KO(T)&&F<=6)return i(n$(((V,C,_,x,w)=>{let v=XO(z0(V),_,x,w);return{...F0,...a$(v,C)}})(j,Y,z,X,D)));if(!T)throw RangeError(HO);let[G,U,K]=FO(Z,O,T),Q=y6(K),B=UO(K),M=m6(K),L=B(U,G,j),I=M(U,G,L,Y),S=j.sign,P=k1(I);if(S&&P&&S!==P)throw RangeError(Z3);return P&&(I=zO(I,Q(L),Y,z,X,D,U,G,Q,B)),i(I)}function _W($){return $.sign===-1?QO($):$}function QO($){return i(S0($))}function S0($){let Z={};for(let O of y)Z[O]=-1*$[O]||0;return Z}function SW($){return!$.sign}function k1($,Z=y){let O=0;for(let j of Z){let J=Math.sign($[j]);if(J){if(O&&O!==J)throw RangeError(NX);O=J}}return O}function n$($){for(let Z of vX)p0(Z,$[Z],-VJ,VJ,1);return fW(y0(z0($),c0)),$}function fW($){if(!Number.isSafeInteger($))throw RangeError(IX)}function z0($,Z=6){return PJ($,Z,y)}function a$($,Z=6){let[O,j]=$,J=o3(j,Z,y);if(J[y[Z]]+=O*(h/$1[Z]),!Number.isFinite(J[y[Z]]))throw RangeError(PO);return J}function BO($,Z=5){return o3($,Z,y)}function PW($){return Boolean(k1($,Pz))}function $$($){let Z=9;for(;Z>0&&!$[y[Z]];Z--);return Z}function u7($,Z){return[$,Z]}function GJ($){let Z=Math.floor($/g3)*g3;return[Z,Z+g3]}function HW($){let Z=q1($=p3($));if(!Z)throw RangeError(A0($));let O;if(Z.m)O=0;else{if(!Z.offset)throw RangeError(A0($));O=o$(Z.offset)}return Z.timeZone&&d6(Z.timeZone,1),D0(W6(OO(Z),O))}function xW($){let Z=q1(a($));if(!Z)throw RangeError(A0($));if(Z.timeZone)return gW(Z,Z.offset?o$(Z.offset):void 0);if(Z.m)throw RangeError(A0($));return mW(Z)}function AW($,Z){let O=q1(a($));if(!O||!O.timeZone)throw RangeError(A0($));let{offset:j}=O,J=j?o$(j):void 0,[,W,Y]=aZ(Z);return gW(O,J,W,Y)}function o$($){let Z=d6($);if(Z===void 0)throw RangeError(A0($));return Z}function EW($){let Z=q1(a($));if(!Z||Z.m)throw RangeError(A0($));return Z0(yW(Z))}function VO($){let Z=q1(a($));if(!Z||Z.m)throw RangeError(A0($));return O0(Z.p?yW(Z):mW(Z))}function vW($,Z){let O=c6(a(Z));if(O)return h6(O),e1(J6(O$(O)));let j=VO(Z);return e1(hZ($(j.calendar),j))}function h6($){if($.calendar!==q)throw RangeError(K1($.calendar))}function bW($,Z){let O=l6(a(Z));if(O)return h6(O),c3(O$(O));let j=VO(Z),{calendar:J}=j,W=$(J),[Y,z,X]=W.h(j),[D,T]=W.I(Y,z),[F,G]=W.N(D,T,X);return c3(A1(W.P(F,G,X)),J)}function RW($){let Z,O=((j)=>{let J=WD.exec(j);return J?(CO(J[10]),cW(J)):void 0})(a($));if(!O){if(O=q1($),!O)throw RangeError(A0($));if(!O.p)throw RangeError(A0($));if(O.m)throw RangeError(K1("Z"));h6(O)}if((Z=c6($))&&XJ(Z))throw RangeError(A0($));if((Z=l6($))&&XJ(Z))throw RangeError(A0($));return s0(jO(O,1))}function wW($){let Z=((O)=>{let j=XD.exec(O);return j?((J)=>{function W(T,F,G){let U=0,K=0;if(G&&([U,X]=U1(X,$1[G])),T!==void 0){if(z)throw RangeError(K1(T));K=((Q)=>{let B=parseInt(Q);if(!Number.isFinite(B))throw RangeError(K1(Q));return B})(T),Y=1,F&&(X=i6(F)*($1[G]/c0),z=1)}return U+K}let Y=0,z=0,X=0,D={...d$(y,[W(J[2]),W(J[3]),W(J[4]),W(J[5]),W(J[6],J[7],5),W(J[8],J[9],4),W(J[10],J[11],3)]),...o3(X,2,y)};if(!Y)throw RangeError(Wz(y));return u6(J[1])<0&&(D=S0(D)),D})(j):void 0})(a($));if(!Z)throw RangeError(A0($));return i(n$(Z))}function kW($){let Z=q1($)||c6($)||l6($);return Z?Z.calendar:$}function qW($){let Z=q1($);return Z&&(Z.timeZone||Z.m&&U$||Z.offset)||$}function gW($,Z,O=0,j=0){let J=MO($.timeZone),W=qO(J);return U0(W$(W,OO($),Z,O,j,!W.v,$.m),J,rZ($.calendar))}function yW($){return pW(B1(OO($)))}function mW($){return pW(A1(O$($)))}function pW($){return{...$,calendar:rZ($.calendar)}}function q1($){let Z=JD.exec($);return Z?((O)=>{let j=O[10],J=(j||"").toUpperCase()==="Z";return{isoYear:hW(O),isoMonth:parseInt(O[4]),isoDay:parseInt(O[5]),...cW(O.slice(5)),...CO(O[16]),p:Boolean(O[6]),m:J,offset:J?void 0:j}})(Z):void 0}function c6($){let Z=OD.exec($);return Z?((O)=>({isoYear:hW(O),isoMonth:parseInt(O[4]),isoDay:1,...CO(O[5])}))(Z):void 0}function l6($){let Z=jD.exec($);return Z?((O)=>({isoYear:l$,isoMonth:parseInt(O[1]),isoDay:parseInt(O[2]),...CO(O[3])}))(Z):void 0}function d6($,Z){let O=YD.exec($);return O?((j,J)=>{let W=j[4]||j[5];if(J&&W)throw RangeError(K1(W));return x6((y$(j[2])*AO+y$(j[3])*xO+y$(j[4])*c0+i6(j[5]||""))*u6(j[1]))})(O,Z):void 0}function hW($){let Z=u6($[1]),O=parseInt($[2]||$[3]);if(Z<0&&!O)throw RangeError(K1(-0));return Z*O}function cW($){let Z=y$($[3]);return{...$O(i6($[4]||""))[0],isoHour:y$($[1]),isoMinute:y$($[2]),isoSecond:Z===60?59:Z}}function CO($){let Z,O,j=[];if($.replace(zD,(J,W,Y)=>{let z=Boolean(W),[X,D]=Y.split("=").reverse();if(D){if(D==="u-ca")j.push(X),Z||(Z=z);else if(z||/[A-Z]/.test(D))throw RangeError(K1(J))}else{if(O)throw RangeError(K1(J));O=X}return""}),j.length>1&&Z)throw RangeError(K1($));return{timeZone:O,calendar:j[0]||q}}function i6($){return parseInt($.padEnd(9,"0"))}function r$($){return new RegExp(`^${$}$`,"i")}function u6($){return $&&$!=="+"?-1:1}function y$($){return $===void 0?0:parseInt($)}function lW($){return MO(a($))}function MO($){let Z=s6($);return typeof Z=="number"?J$(Z):Z?((O)=>{if(TD.test(O))throw RangeError(QX);return O.toLowerCase().split("/").map((j,J)=>(j.length<=3||/\d/.test(j))&&!/etc|yap/.test(j)?j.toUpperCase():j.replace(/baja|dumont|[a-z]+/g,(W,Y)=>W.length<=2&&!J||W==="in"||W==="chat"?W.toUpperCase():W.length>2||!Y?YJ(W).replace(/island|noronha|murdo|rivadavia|urville/,YJ):W)).join("/")})($):U$}function FJ($){let Z=s6($);return typeof Z=="number"?Z:Z?Z.resolvedOptions().timeZone:U$}function s6($){let Z=d6($=$.toUpperCase(),1);return Z!==void 0?Z:$!==U$?DD($):void 0}function n6($,Z){return N0($.epochNanoseconds,Z.epochNanoseconds)}function a6($,Z){return N0($.epochNanoseconds,Z.epochNanoseconds)}function dW($,Z,O,j,J,W){let Y=$(u0(W).relativeTo),z=Math.max($$(j),$$(J));if(SJ(y,j,J))return 0;if(cZ(z,Y))return N0(z0(j),z0(J));if(!Y)throw RangeError(HO);let[X,D,T]=FO(Z,O,Y),F=y6(T),G=UO(T);return N0(F(G(D,X,j)),F(G(D,X,J)))}function o6($,Z){return z$($,Z)||IO($,Z)}function z$($,Z){return x1(L0($),L0(Z))}function IO($,Z){return x1(b1($),b1(Z))}function iW($,Z){return!n6($,Z)}function uW($,Z){return!a6($,Z)&&!!NO($.timeZone,Z.timeZone)&&s$($.calendar,Z.calendar)}function sW($,Z){return!o6($,Z)&&s$($.calendar,Z.calendar)}function nW($,Z){return!z$($,Z)&&s$($.calendar,Z.calendar)}function aW($,Z){return!z$($,Z)&&s$($.calendar,Z.calendar)}function oW($,Z){return!z$($,Z)&&s$($.calendar,Z.calendar)}function rW($,Z){return!IO($,Z)}function NO($,Z){if($===Z)return 1;let O=G0($),j=G0(Z);if(O===j)return 1;try{return FJ(O)===FJ(j)}catch(J){}}function r6($,Z,O,j){let J=u$($,$0(j),3,5),W=LO(Z.epochNanoseconds,O.epochNanoseconds,...J);return i($?S0(W):W)}function t6($,Z,O,j,J,W){let Y=SO(j.calendar,J.calendar),z=$0(W),[X,D,T,F]=u$(O,z,5),G=j.epochNanoseconds,U=J.epochNanoseconds,K=N0(U,G),Q;if(K)if(X<6)Q=LO(G,U,X,D,T,F);else{let B=Z(((L,I)=>{if(!NO(L,I))throw RangeError(Gz);return L})(j.timeZone,J.timeZone)),M=$(Y);Q=eW(M,B,j,J,K,X,z),Q=zO(Q,U,X,D,T,F,M,j,OW,R(q6,B))}else Q=F0;return i(O?S0(Q):Q)}function e6($,Z,O,j,J){let W=SO(O.calendar,j.calendar),Y=$0(J),[z,X,D,T]=u$(Z,Y,6),F=I0(O),G=I0(j),U=N0(G,F),K;if(U)if(z<=6)K=LO(F,G,z,X,D,T);else{let Q=$(W);K=$Y(Q,O,j,U,z,Y),K=zO(K,G,z,X,D,T,Q,O,I0,g6)}else K=F0;return i(Z?S0(K):K)}function $8($,Z,O,j,J){let W=SO(O.calendar,j.calendar),Y=$0(J);return tW(Z,()=>$(W),O,j,...u$(Z,Y,6,9,6),Y)}function Z8($,Z,O,j,J){let W=SO(O.calendar,j.calendar),Y=$0(J),z=u$(Z,Y,9,9,8),X=$(W);return tW(Z,()=>X,hZ(X,O),hZ(X,j),...z,Y)}function tW($,Z,O,j,J,W,Y,z,X){let D=I0(O),T=I0(j),F;if(N0(T,D))if(J===6)F=LO(D,T,J,W,Y,z);else{let G=Z();F=G.dateUntil(O,j,J,X),W===6&&Y===1||(F=zO(F,T,J,W,Y,z,G,O,I0,GO))}else F=F0;return i($?S0(F):F)}function O8($,Z,O,j){let J=$0(j),[W,Y,z,X]=u$($,J,5,5),D=R1(j8(Z,O),oZ(Y,z),X),T={...F0,...BO(D,W)};return i($?S0(T):T)}function s7($,Z,O,j,J,W){let Y=N0(j.epochNanoseconds,O.epochNanoseconds);return Y?J<6?ZY(O.epochNanoseconds,j.epochNanoseconds,J):eW(Z,$,O,j,Y,J,W):F0}function n7($,Z,O,j,J){let W=I0(Z),Y=I0(O),z=N0(Y,W);return z?j<=6?ZY(W,Y,j):$Y($,Z,O,z,j,J):F0}function eW($,Z,O,j,J,W,Y){let[z,X,D]=((G,U,K,Q)=>{function B(){return C={...Y$(I,P++*-Q),...L},_=b0(G,C),N0(S,_)===-Q}let M=_0(U,G),L=R0(a0,M),I=_0(K,G),S=K.epochNanoseconds,P=0,V=j8(M,I),C,_;if(Math.sign(V)===-Q&&P++,B()&&(Q===-1||B()))throw RangeError(Z3);let x=y0(g0(_,S));return[M,C,x]})(Z,O,j,J);var T,F;return{...W===6?(T=z,F=X,{...F0,days:OY(T,F)}):$.dateUntil(z,X,W,Y),...BO(D)}}function $Y($,Z,O,j,J,W){let[Y,z,X]=((D,T,F)=>{let G=T,U=j8(D,T);return Math.sign(U)===-F&&(G=Y$(T,-F),U+=h*F),[D,G,U]})(Z,O,j);return{...$.dateUntil(Y,z,J,W),...BO(X)}}function LO($,Z,O,j,J,W){return{...F0,...a$(XO(g0($,Z),j,J,W),O)}}function ZY($,Z,O){return{...F0,...a$(g0($,Z),O)}}function OY($,Z){return _O(L0($),L0(Z))}function _O($,Z){return Math.trunc((Z-$)/E0)}function j8($,Z){return b1(Z)-b1($)}function SO($,Z){if(!s$($,Z))throw RangeError(C8);return $}function a7($){function Z(J){return((W,Y)=>({...jY(W,Y),F:W.month,day:parseInt(W.day)}))(j6(O,J),j)}let O=R8($),j=i3($);return{id:$,O:o7(Z),B:r7(Z)}}function o7($){return v0((Z)=>{let O=L0(Z);return $(O)},WeakMap)}function r7($){let Z=$(0).year-gX;return v0((O)=>{let j,J=i$(O-Z),W=[],Y=[];do J+=400*E0;while((j=$(J)).year<=O);do J+=(1-j.day)*E0,j.year===O&&(W.push(J),Y.push(j.F)),J-=E0;while((j=$(J)).year>=O);return{k:W.reverse(),C:Kz(Y.reverse())}})}function jY($,Z){let O,j,J=JY($);if($.era){let W=_z[Z];W!==void 0&&(O=Z==="islamic"?"ah":$.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),O==="bc"||O==="b"?O="bce":O!=="ad"&&O!=="a"||(O="ce"),j=J,J=DY(j,W[O]||0))}return{era:O,eraYear:j,year:J}}function JY($){return parseInt($.relatedYear||$.year)}function hj($){let{year:Z,F:O,day:j}=this.O($),{C:J}=this.B(Z);return[Z,J[O]+1,j]}function lZ($,Z=1,O=1){return this.B($).k[Z-1]+(O-1)*E0}function w3($){let Z=KJ(this,$),O=KJ(this,$-1),j=Z.length;if(j>O.length){let J=TY(this);if(J<0)return-J;for(let W=0;W<j;W++)if(Z[W]!==O[W])return W+1}}function k3($){return _O(lZ.call(this,$),lZ.call(this,$+1))}function UJ($,Z){let{k:O}=this.B($),j=Z+1,J=O;return j>O.length&&(j=1,J=this.B($+1).k),_O(O[Z-1],J[j-1])}function q3($){return this.B($).k.length}function KJ($,Z){return Object.keys($.B(Z).C)}function WY($){return rZ(a($))}function rZ($){if(($=$.toLowerCase())!==q&&$!==vO&&i3($)!==i3(R8($).resolvedOptions().calendar))throw RangeError(KX($));return $}function i3($){return $==="islamicc"&&($="islamic"),$.split("-")[0]}function YY($){return this.R($)[0]}function zY($){return this.R($)[1]}function J8($){let[Z]=this.h($);return _O(this.q(Z),L0($))+1}function XY($){let Z=FD.exec($);if(!Z)throw RangeError(FX($));return[parseInt(Z[1]),Boolean(Z[2])]}function u3($,Z,O){return $+(Z||O&&$>=O?1:0)}function cj($,Z){return $-(Z&&$>=Z?1:0)}function DY($,Z){return(Z+$)*(Math.sign(Z)||1)||0}function lj($){return _z[GY($)]}function TY($){return xX[GY($)]}function GY($){return i3($.id||q)}function FY($,Z,O,j){let J=g1(O,j,n0,[],Mz);if(J.timeZone!==void 0){let W=O.dateFromFields(J),Y=X$(J),z=$(J.timeZone);return{epochNanoseconds:W$(Z(z),{...W,...Y},J.offset!==void 0?o$(J.offset):void 0),timeZone:z}}return{...O.dateFromFields(J),...l0}}function UY($,Z,O,j,J,W){let Y=g1(O,J,n0,Vz,Mz),z=$(Y.timeZone),[X,D,T]=aZ(W),F=O.dateFromFields(Y,WO(W,X)),G=X$(Y,X);return U0(W$(Z(z),{...F,...G},Y.offset!==void 0?o$(Y.offset):void 0,D,T),z,j)}function KY($,Z,O){let j=g1($,Z,n0,[],M1),J=g(O);return Z0(B1({...$.dateFromFields(j,WO(O,J)),...X$(j,J)}))}function W8($,Z,O,j=[]){let J=g1($,Z,n0,j);return $.dateFromFields(J,O)}function Y8($,Z,O,j){let J=g1($,Z,N8,j);return $.yearMonthFromFields(J,O)}function z8($,Z,O,j,J=[]){let W=g1($,O,n0,J);return Z&&W.month!==void 0&&W.monthCode===void 0&&W.year===void 0&&(W.year=l$),$.monthDayFromFields(W,j)}function QY($,Z){let O=g(Z);return s0(X$(e0($,ij,[],1),O))}function BY($){let Z=e0($,L8);return i(n$({...F0,...Z}))}function g1($,Z,O,j=[],J=[]){return e0(Z,[...$.fields(O),...J].sort(),j)}function e0($,Z,O,j=!O){let J={},W,Y=0;for(let z of Z){if(z===W)throw RangeError(YX(z));if(z==="constructor"||z==="__proto__")throw RangeError(B8(z));let X=$[z];if(X!==void 0)Y=1,CJ[z]&&(X=CJ[z](X,z)),J[z]=X;else if(O){if(O.includes(z))throw TypeError(Q8(z));J[z]=Lz[z]}W=z}if(j&&!Y)throw TypeError(Wz(Z));return J}function X$($,Z){return jO(BD({...Lz,...$}),Z)}function VY($,Z,O,j,J,W){let Y=$0(W),{calendar:z,timeZone:X}=O;return U0(((D,T,F,G,U)=>{let K=tZ(D,F,G,n0,Cz,Bz),[Q,B,M]=aZ(U,2);return W$(T,{...D.dateFromFields(K,WO(U,Q)),...X$(K,Q)},o$(K.offset),B,M)})($(z),Z(X),j,J,Y),X,z)}function CY($,Z,O,j,J){let W=$0(J);return Z0(((Y,z,X,D)=>{let T=tZ(Y,z,X,n0,M1),F=g(D);return B1({...Y.dateFromFields(T,WO(D,F)),...X$(T,F)})})($(Z.calendar),O,j,W))}function MY($,Z,O,j,J){let W=$0(J);return((Y,z,X,D)=>{let T=tZ(Y,z,X,n0);return Y.dateFromFields(T,D)})($(Z.calendar),O,j,W)}function IY($,Z,O,j,J){let W=$0(J);return e1(((Y,z,X,D)=>{let T=tZ(Y,z,X,N8);return Y.yearMonthFromFields(T,D)})($(Z.calendar),O,j,W))}function NY($,Z,O,j,J){let W=$0(J);return((Y,z,X,D)=>{let T=tZ(Y,z,X,n0);return Y.monthDayFromFields(T,D)})($(Z.calendar),O,j,W)}function LY($,Z,O){return s0(((j,J,W)=>{let Y=g(W);return X$({...R0(ij,j),...e0(J,ij)},Y)})($,Z,O))}function _Y($,Z){return i((O=$,j=Z,n$({...O,...e0(j,L8)})));var O,j}function tZ($,Z,O,j,J=[],W=[]){let Y=[...$.fields(j),...J].sort(),z=e0(Z,Y,W),X=e0(O,Y);return z=$.mergeFields(z,X),e0(z,Y,[])}function X8($,Z){let O=g1($,Z,Nz);return $.monthDayFromFields(O)}function D8($,Z,O){let j=g1($,Z,Iz);return $.yearMonthFromFields(j,O)}function SY($,Z,O,j,J){Z=R0(O=$.fields(O),Z),j=e0(j,J=$.fields(J),[]);let W=$.mergeFields(Z,j);return W=e0(W,[...O,...J].sort(),[]),$.dateFromFields(W)}function qj($,Z){let{era:O,eraYear:j,year:J}=Z,W=lj($);if(O!==void 0||j!==void 0){if(O===void 0||j===void 0)throw TypeError(XX);if(!W)throw RangeError(zX);let Y=W[O];if(Y===void 0)throw RangeError(TX(O));let z=DY(j,Y);if(J!==void 0&&J!==z)throw RangeError(DX);J=z}else if(J===void 0)throw TypeError(GX(W));return J}function gj($,Z,O,j){let{month:J,monthCode:W}=Z;if(W!==void 0){let Y=((z,X,D,T)=>{let F=z.U(D),[G,U]=XY(X),K=u3(G,U,F);if(U){let Q=TY(z);if(Q===void 0)throw RangeError(yZ);if(Q>0){if(K>Q)throw RangeError(yZ);if(F===void 0){if(T===1)throw RangeError(yZ);K--}}else{if(K!==-Q)throw RangeError(yZ);if(F===void 0&&T===1)throw RangeError(yZ)}}return K})($,W,O,j);if(J!==void 0&&J!==Y)throw RangeError(Dz);J=Y,j=1}else if(J===void 0)throw TypeError(UX);return p0("month",J,1,$.L(O),j)}function QJ($,Z,O,j,J){return x0(Z,"day",1,$.j(j,O),J)}function yj($,Z,O,j){let J=0,W=[];for(let Y of O)Z[Y]!==void 0?J=1:W.push(Y);if(Object.assign($,Z),J)for(let Y of j||W)delete $[Y]}function fY($){return D0(m0(e3(t3($))))}function PY($,Z,O,j,J=q){return U0(m0(e3(t3(O))),Z(j),$(J))}function HY($,Z,O,j,J=0,W=0,Y=0,z=0,X=0,D=0,T=q){return Z0(B1(OO(d0(M0,d$(bO,[Z,O,j,J,W,Y,z,X,D])))),$(T))}function xY($,Z,O,j,J=q){return O0(A1(O$(d0(M0,{isoYear:Z,isoMonth:O,isoDay:j}))),$(J))}function AY($,Z,O,j=q,J=1){let W=M0(Z),Y=M0(O),z=$(j);return e1(J6(O$({isoYear:W,isoMonth:Y,isoDay:M0(J)})),z)}function EY($,Z,O,j=q,J=l$){let W=M0(Z),Y=M0(O),z=$(j);return c3(A1(O$({isoYear:M0(J),isoMonth:W,isoDay:Y})),z)}function vY($=0,Z=0,O=0,j=0,J=0,W=0){return s0(jO(d0(M0,d$(a0,[$,Z,O,j,J,W])),1))}function bY($=0,Z=0,O=0,j=0,J=0,W=0,Y=0,z=0,X=0,D=0){return i(n$(d0(qJ,d$(y,[$,Z,O,j,J,W,Y,z,X,D]))))}function T8($,Z,O=q){return U0($.epochNanoseconds,Z,O)}function RY($){return D0($.epochNanoseconds)}function G8($,Z){return Z0(_0(Z,$))}function F8($,Z){return O0(_0(Z,$))}function wY($,Z,O){return D8($(Z.calendar),O)}function kY($,Z,O){return X8($(Z.calendar),O)}function U8($,Z){return s0(_0(Z,$))}function qY($,Z,O,j){let J=((W,Y,z,X)=>{let D=X6(X);return b0(W(Y),z,D)})($,O,Z,j);return U0(m0(J),O,Z.calendar)}function gY($,Z,O){let j=$(Z.calendar);return e1({...Z,...D8(j,O)})}function yY($,Z,O){return X8($(Z.calendar),O)}function mY($,Z,O,j,J){let W=$(J.timeZone),Y=J.plainTime,z=Y!==void 0?Z(Y):l0;return U0(b0(O(W),{...j,...z}),W,j.calendar)}function pY($,Z=l0){return Z0(B1({...$,...Z}))}function hY($,Z,O){return D8($(Z.calendar),O)}function cY($,Z,O){return X8($(Z.calendar),O)}function lY($,Z,O,j){return((J,W,Y)=>SY(J,W,Iz,Q1(Y),j3))($(Z.calendar),O,j)}function dY($,Z,O,j){return((J,W,Y)=>SY(J,W,Nz,Q1(Y),EO))($(Z.calendar),O,j)}function iY($,Z,O,j,J){let W=Q1(J),Y=Z(W.plainDate),z=$(W.timeZone);return U0(b0(O(z),{...Y,...j}),z,Y.calendar)}function uY($,Z){return Z0(B1({...$,...Z}))}function sY($){return D0(m0(h$($,c0)))}function nY($){return D0(m0(h$($,Z1)))}function aY($){return D0(m0(e3(t3($),T$)))}function oY($){return D0(m0(e3(t3($))))}function rY($,Z,O=l0){let j=Z.timeZone,J=$(j),W={..._0(Z,J),...O};return U0(W$(J,W,W.offsetNanoseconds,2),j,Z.calendar)}function tY($,Z,O){let j=Z.timeZone,J=$(j),W={..._0(Z,J),...O},Y=Oz(Z.calendar,O.calendar);return U0(W$(J,W,W.offsetNanoseconds,2),j,Y)}function eY($,Z=l0){return Z0({...$,...Z})}function $z($,Z){return Z0({...$,...Z},Oz($.calendar,Z.calendar))}function fO($,Z){return{...$,calendar:Z}}function Zz($,Z){return{...$,timeZone:Z}}function Oz($,Z){if($===Z)return $;let O=G0($),j=G0(Z);if(O===j||O===q)return Z;if(j===q)return $;throw RangeError(C8)}function t7($,Z){return(O)=>O===q?$:O===vO||O===c$?Object.assign(Object.create($),{id:O}):Object.assign(Object.create(Z),GD(O))}function D$($,Z,O){let j=new Set(O);return(J)=>(((W,Y)=>{for(let z of Y)if(z in W)return 1;return 0})(J=aj(j,J),$)||Object.assign(J,Z),O&&(J.timeZone=U$,["full","long"].includes(J.timeStyle)&&(J.timeStyle="medium")),J)}function V1($,Z=K8){let[O,,,j]=$;return(J,W=bD,...Y)=>{let z=Z(j&&j(...Y),J,W,O),X=z.resolvedOptions();return[z,...e7($,X,Y)]}}function K8($,Z,O,j){if(O=j(O),$){if(O.timeZone!==void 0)throw TypeError(fX);O.timeZone=$}return new y1(Z,O)}function e7($,Z,O){let[,j,J]=$;return O.map((W)=>(W.calendar&&((Y,z,X)=>{if((X||Y!==q)&&Y!==z)throw RangeError(C8)})(G0(W.calendar),Z.calendar,J),j(W,Z)))}function t$($){let Z=eZ();return w1(Z,$.getOffsetNanosecondsFor(Z))}function eZ(){return h$(Date.now(),Z1)}function C1(){return IJ||(IJ=new y1().resolvedOptions().timeZone)}var $X=($,Z)=>`Non-integer ${$}: ${Z}`,ZX=($,Z)=>`Non-positive ${$}: ${Z}`,OX=($,Z)=>`Non-finite ${$}: ${Z}`,jX=($)=>`Cannot convert bigint to ${$}`,JX=($)=>`Invalid bigint: ${$}`,WX="Cannot convert Symbol to string",jz="Invalid object",Jz=($,Z,O,j,J)=>J?Jz($,J[Z],J[O],J[j]):$3($,Z)+`; must be between ${O}-${j}`,$3=($,Z)=>`Invalid ${$}: ${Z}`,Q8=($)=>`Missing ${$}`,B8=($)=>`Invalid field ${$}`,YX=($)=>`Duplicate field ${$}`,Wz=($)=>"No valid fields: "+$.join(),Yz="Invalid bag",zz=($,Z,O)=>$3($,Z)+"; must be "+Object.keys(O).join(),Xz="Cannot use valueOf",V8="Invalid calling context",zX="Forbidden era/eraYear",XX="Mismatching era/eraYear",DX="Mismatching year/eraYear",TX=($)=>`Invalid era: ${$}`,GX=($)=>"Missing year"+($?"/era/eraYear":""),FX=($)=>`Invalid monthCode: ${$}`,Dz="Mismatching month/monthCode",UX="Missing month/monthCode",BJ="Cannot guess year",yZ="Invalid leap month",Tz="Invalid protocol",Z3="Invalid protocol results",C8="Mismatching Calendars",KX=($)=>`Invalid Calendar: ${$}`,Gz="Mismatching TimeZones",QX="Forbidden ICU TimeZone",BX="Out-of-bounds offset",VX="Out-of-bounds TimeZone gap",CX="Invalid TimeZone offset",MX="Ambiguous offset",PO="Out-of-bounds date",IX="Out-of-bounds duration",NX="Cannot mix duration signs",HO="Missing relativeTo",LX="Cannot use large units",_X="Required smallestUnit or largestUnit",SX="smallestUnit > largestUnit",A0=($)=>`Cannot parse: ${$}`,K1=($)=>`Invalid substring: ${$}`,Fz=($)=>`Cannot format ${$}`,Uz="Mismatching types for formatting",fX="Cannot specify TimeZone",Kz=R(uZ,($,Z)=>Z),e$=R(uZ,($,Z,O)=>O),h0=R(m3,2),dj={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},O3=Object.keys(dj),E0=86400000,Qz=1000,T$=1000,Z1=1e6,c0=1e9,xO=60000000000,AO=3600000000000,h=86400000000000,$1=[1,T$,Z1,c0,xO,AO,h],M1=O3.slice(0,6),ij=sZ(M1),Bz=["offset"],Vz=["timeZone"],Cz=M1.concat(Bz),Mz=Cz.concat(Vz),uj=["era","eraYear"],PX=uj.concat(["year"]),EO=["year"],M8=["monthCode"],I8=["month"].concat(M8),j3=["day"],N8=I8.concat(EO),Iz=M8.concat(EO),n0=j3.concat(N8),HX=j3.concat(I8),Nz=j3.concat(M8),Lz=e$(M1,0),q="iso8601",vO="gregory",c$="japanese",_z={[vO]:{bce:-1,ce:0},[c$]:{bce:-1,ce:0,meiji:1867,taisho:1911,showa:1925,heisei:1988,reiwa:2018},ethioaa:{era0:0},ethiopic:{era0:0,era1:5500},coptic:{era0:-1,era1:0},roc:{beforeroc:-1,minguo:0},buddhist:{be:0},islamic:{ah:0},indian:{saka:0},persian:{ap:0}},xX={chinese:13,dangi:13,hebrew:-6},a=R(r3,"string"),Sz=R(r3,"boolean"),AX=R(r3,"number"),fz=R(r3,"function"),y=O3.map(($)=>$+"s"),L8=sZ(y),EX=y.slice(0,6),Pz=y.slice(6),vX=Pz.slice(1),bX=Kz(y),F0=e$(y,0),_8=e$(EX,0),S8=R(fJ,y),a0=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],f8=["isoDay","isoMonth","isoYear"],bO=a0.concat(f8),P8=sZ(f8),Hz=sZ(a0),xz=sZ(bO),l0=e$(Hz,0),RX=R(fJ,bO),y1=Intl.DateTimeFormat,Az="en-GB",H8=1e8,wX=H8*E0,kX=[H8,0],qX=[-H8,0],dZ=275760,iZ=-271821,gX=1970,l$=1972,F1=12,yX=i$(1868,9,8),mX=v0(m7,WeakMap),s3="smallestUnit",sj="unit",pZ="roundingIncrement",mj="fractionalSecondDigits",Ez="relativeTo",vz={constrain:0,reject:1},pX=Object.keys(vz),hX={compatible:0,reject:1,earlier:2,later:3},cX={reject:0,use:1,prefer:2,ignore:3},lX={auto:0,never:1,critical:2,always:3},dX={auto:0,never:1,critical:2},iX={auto:0,never:1},uX={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},J3=R(K6,s3),x8=R(K6,"largestUnit"),sX=R(K6,sj),bz=R(j$,"overflow",vz),Rz=R(j$,"disambiguation",hX),nX=R(j$,"offset",cX),A8=R(j$,"calendarName",lX),aX=R(j$,"timeZoneName",dX),oX=R(j$,"offset",iX),W3=R(j$,"roundingMode",uX),$Z="PlainYearMonth",ZZ="PlainMonthDay",G$="PlainDate",F$="PlainDateTime",RO="PlainTime",I1="ZonedDateTime",wO="Instant",kO="Duration",rX=[Math.floor,($)=>R3($)?Math.floor($):Math.round($),Math.ceil,($)=>R3($)?Math.ceil($):Math.round($),Math.trunc,($)=>R3($)?Math.trunc($)||0:Math.round($),($)=>$<0?Math.floor($):Math.ceil($),($)=>Math.sign($)*Math.round(Math.abs($))||0,($)=>R3($)?($=Math.trunc($)||0)+$%2:Math.round($)],U$="UTC",g3=5184000,tX=h3(1847),eX=h3(new Date().getUTCFullYear()+10),$D=/0+$/,_0=v0(i7,WeakMap),VJ=4294967295,qO=v0(($)=>{let Z=s6($);return typeof Z=="object"?new kz(Z):new wz(Z||0)});class wz{constructor($){this.v=$}getOffsetNanosecondsFor(){return this.v}getPossibleInstantsFor($){return[W6($,this.v)]}l(){}}class kz{constructor($){this.$=((Z)=>{function O(X){let D=pj(X,Y,z),[T,F]=GJ(D),G=J(T),U=J(F);return G===U?G:j(W(T,F),G,U,X)}function j(X,D,T,F){let G,U;for(;(F===void 0||(G=F<X[0]?D:F>=X[1]?T:void 0)===void 0)&&(U=X[1]-X[0]);){let K=X[0]+Math.floor(U/2);Z(K)===T?X[1]=K:X[0]=K+1}return G}let J=v0(Z),W=v0(u7),Y=tX,z=eX;return{G(X){let D=O(X-86400),T=O(X+86400),F=X-D,G=X-T;if(D===T)return[F];let U=O(F);return U===O(G)?[X-U]:D>T?[F,G]:[]},V:O,l(X,D){let T=pj(X,Y,z),[F,G]=GJ(T),U=g3*D,K=D<0?()=>G>Y||(Y=T,0):()=>F<z||(z=T,0);for(;K();){let Q=J(F),B=J(G);if(Q!==B){let M=W(F,G);j(M,Q,B);let L=M[0];if((x1(L,X)||1)===D)return L}F+=U,G+=U}}}})(((Z)=>(O)=>{let j=j6(Z,O*Qz);return h3(JY(j),parseInt(j.month),parseInt(j.day),parseInt(j.hour),parseInt(j.minute),parseInt(j.second))-O})($))}getOffsetNanosecondsFor($){return this.$.V(mJ($))*c0}getPossibleInstantsFor($){let[Z,O]=[h3((j=$).isoYear,j.isoMonth,j.isoDay,j.isoHour,j.isoMinute,j.isoSecond),j.isoMillisecond*Z1+j.isoMicrosecond*T$+j.isoNanosecond];var j;return this.$.G(Z).map((J)=>m0(p$(h$(J,c0),O)))}l($,Z){let[O,j]=pJ($),J=this.$.l(O+(Z>0||j?1:0),Z);if(J!==void 0)return h$(J,c0)}}var E8="([+\u2212-])",y3="(?:[.,](\\d{1,9}))?",qz=`(?:(?:${E8}(\\d{6}))|(\\d{4}))-?(\\d{2})`,v8="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+y3+")?)?",b8=E8+v8,ZD=qz+"-?(\\d{2})(?:[T ]"+v8+"(Z|"+b8+")?)?",gz="\\[(!?)([^\\]]*)\\]",gO=`((?:${gz}){0,9})`,OD=r$(qz+gO),jD=r$("(?:--)?(\\d{2})-?(\\d{2})"+gO),JD=r$(ZD+gO),WD=r$("T?"+v8+"(?:"+b8+")?"+gO),YD=r$(b8),zD=new RegExp(gz,"g"),XD=r$(`${E8}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${y3}H)?(?:(\\d+)${y3}M)?(?:(\\d+)${y3}S)?)?`),DD=v0(($)=>new y1(Az,{timeZone:$,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),TD=/^(AC|AE|AG|AR|AS|BE|BS|CA|CN|CS|CT|EA|EC|IE|IS|JS|MI|NE|NS|PL|PN|PR|PS|SS|VS)T$/,GD=v0(a7),R8=v0(($)=>new y1(Az,{calendar:$,timeZone:U$,era:"short",year:"numeric",month:"short",day:"numeric"})),FD=/^M(\d{2})(L?)$/,UD={era:p3,eraYear:M0,year:M0,month:zJ,monthCode:p3,day:zJ},KD=e$(M1,M0),QD=e$(y,qJ),CJ=Object.assign({},UD,KD,QD,{offset:p3}),BD=R(y7,M1,a0),MJ={dateAdd($,Z,O){let j=g(O),J,{years:W,months:Y,weeks:z,days:X}=Z;if(X+=z0(Z,5)[0],W||Y)J=((D,T,F,G,U)=>{let[K,Q,B]=D.h(T);if(F){let[M,L]=D.I(K,Q);K+=F,Q=u3(M,L,D.U(K)),Q=p0("month",Q,1,D.L(K),U)}return G&&([K,Q]=D._(K,Q,G)),B=p0("day",B,1,D.j(K,Q),U),D.q(K,Q,B)})(this,$,W,Y,j);else{if(!z&&!X)return $;J=L0($)}return J+=(7*z+X)*E0,A1(ZO(J))},dateUntil($,Z,O){if(O<=7){let X=0,D=OY({...$,...l0},{...Z,...l0});return O===7&&([X,D]=v1(D,7)),{...F0,weeks:X,days:D}}let j=this.h($),J=this.h(Z),[W,Y,z]=((X,D,T,F,G,U,K)=>{let Q=G-D,B=U-T,M=K-F;if(Q||B){let L=Math.sign(Q||B),I=X.j(G,U),S=0;if(Math.sign(M)===-L){let P=I;[G,U]=X._(G,U,-L),Q=G-D,B=U-T,I=X.j(G,U),S=L<0?-P:I}if(M=K-Math.min(F,I)+S,Q){let[P,V]=X.I(D,T),[C,_]=X.I(G,U);if(B=C-P||Number(_)-Number(V),Math.sign(B)===-L){let x=L<0&&-X.L(G);Q=(G-=L)-D,B=U-u3(P,V,X.U(G))+(x||X.L(G))}}}return[Q,B,M]})(this,...j,...J);return O===8&&(Y+=this.J(W,j[0]),W=0),{...F0,years:W,months:Y,days:z}},dateFromFields($,Z){let O=g(Z),j=qj(this,$),J=gj(this,$,j,O),W=QJ(this,$,J,j,O);return O0(A1(this.P(j,J,W)),this.id||q)},yearMonthFromFields($,Z){let O=g(Z),j=qj(this,$),J=gj(this,$,j,O);return e1(J6(this.P(j,J,1)),this.id||q)},monthDayFromFields($,Z){let O=g(Z),j=!this.id,{monthCode:J,year:W,month:Y}=$,z,X,D,T,F;if(J!==void 0){[z,X]=XY(J),F=NJ($,"day");let G=this.N(z,X,F);if(!G)throw RangeError(BJ);if([D,T]=G,Y!==void 0&&Y!==T)throw RangeError(Dz);j&&(T=p0("month",T,1,F1,1),F=p0("day",F,1,Y6(W!==void 0?W:D,T),O))}else{D=W===void 0&&j?l$:qj(this,$),T=gj(this,$,D,O),F=QJ(this,$,T,D,O);let G=this.U(D);X=T===G,z=cj(T,G);let U=this.N(z,X,F);if(!U)throw RangeError(BJ);[D,T]=U}return c3(A1(this.P(D,T,F)),this.id||q)},fields($){return lj(this)&&$.includes("year")?[...$,...uj]:$},mergeFields($,Z){let O=Object.assign(Object.create(null),$);return yj(O,Z,I8),lj(this)&&(yj(O,Z,PX),this.id===c$&&yj(O,Z,HX,uj)),O},inLeapYear($){let[Z]=this.h($);return this.K(Z)},monthsInYear($){let[Z]=this.h($);return this.L(Z)},daysInMonth($){let[Z,O]=this.h($);return this.j(Z,O)},daysInYear($){let[Z]=this.h($);return this.X(Z)},dayOfYear:J8,era($){return this.ee($)[0]},eraYear($){return this.ee($)[1]},monthCode($){let[Z,O]=this.h($),[j,J]=this.I(Z,O);return((W,Y)=>"M"+h0(W)+(Y?"L":""))(j,J)},dayOfWeek:iJ,daysInWeek(){return 7}},VD={dayOfYear:J8,h:cJ,q:i$},CD=Object.assign({},VD,{weekOfYear:YY,yearOfWeek:zY,R($){function Z(U){return(7-U<j?7:0)-U}function O(U){let K=dJ(G+U),Q=U||1,B=Z(mZ(X+K*Q,7));return T=(K+(B-D)*Q)/7}let j=this.id?1:4,J=iJ($),W=this.dayOfYear($),Y=mZ(J-1,7),z=W-1,X=mZ(Y-z,7),D=Z(X),T,F=Math.floor((z-D)/7)+1,G=$.isoYear;return F?F>O(0)&&(F=1,G++):(F=O(-1),G--),[F,G,T]}}),MD={dayOfYear:J8,h:hj,q:lZ,weekOfYear:YY,yearOfWeek:zY,R(){return[]}},OZ=t7(Object.assign({},MJ,CD,{h:cJ,ee($){return this.id===vO?uJ($):this.id===c$?mX($):[]},I:($,Z)=>[Z,0],N($,Z){if(!Z)return[l$,$]},K:z6,U(){},L:lJ,J:($)=>$*F1,j:Y6,X:dJ,P:($,Z,O)=>({isoYear:$,isoMonth:Z,isoDay:O}),q:i$,_:($,Z,O)=>($+=a3(O,F1),(Z+=rj(O,F1))<1?($--,Z+=F1):Z>F1&&($++,Z-=F1),[$,Z]),year($){return $.isoYear},month($){return $.isoMonth},day:($)=>$.isoDay}),Object.assign({},MJ,MD,{h:hj,ee($){let Z=this.O($);return[Z.era,Z.eraYear]},I($,Z){let O=w3.call(this,$);return[cj(Z,O),O===Z]},N($,Z,O){let[j,J,W]=hj.call(this,{isoYear:l$,isoMonth:F1,isoDay:31}),Y=w3.call(this,j),z=J===Y;(x1($,cj(J,Y))||x1(Number(Z),Number(z))||x1(O,W))===1&&j--;for(let X=0;X<100;X++){let D=j-X,T=w3.call(this,D),F=u3($,Z,T);if(Z===(F===T)&&O<=UJ.call(this,D,F))return[D,F]}},K($){let Z=k3.call(this,$);return Z>k3.call(this,$-1)&&Z>k3.call(this,$+1)},U:w3,L:q3,J($,Z){let O=Z+$,j=Math.sign($),J=j<0?-1:0,W=0;for(let Y=Z;Y!==O;Y+=j)W+=q3.call(this,Y+J);return W},j:UJ,X:k3,P($,Z,O){return ZO(lZ.call(this,$,Z,O))},q:lZ,_($,Z,O){if(O){if(Z+=O,!Number.isSafeInteger(Z))throw RangeError(PO);if(O<0)for(;Z<1;)Z+=q3.call(this,--$);else{let j;for(;Z>(j=q3.call(this,$));)Z-=j,$++}}return[$,Z]},year($){return this.O($).year},month($){let{year:Z,F:O}=this.O($),{C:j}=this.B(Z);return j[O]+1},day($){return this.O($).day}})),E1="numeric",jZ=["timeZoneName"],yz={month:E1,day:E1},w8={year:E1,month:E1},k8=Object.assign({},w8,{day:E1}),q8={hour:E1,minute:E1,second:E1},g8=Object.assign({},k8,q8),ID=Object.assign({},g8,{timeZoneName:"short"}),ND=Object.keys(w8),LD=Object.keys(yz),_D=Object.keys(k8),SD=Object.keys(q8),y8=["dateStyle"],fD=ND.concat(y8),PD=LD.concat(y8),m8=_D.concat(y8,["weekday"]),Y3=SD.concat(["dayPeriod","timeStyle"]),p8=m8.concat(Y3),HD=p8.concat(jZ),xD=jZ.concat(Y3),AD=jZ.concat(m8),ED=jZ.concat(["day","weekday"],Y3),vD=jZ.concat(["year","weekday"],Y3),bD={},h8=[D$(p8,g8),YO],mz=[D$(HD,ID),YO,0,($,Z)=>{let O=G0($.timeZone);if(Z&&G0(Z.timeZone)!==O)throw RangeError(Gz);return O}],c8=[D$(p8,g8,jZ),L0],l8=[D$(m8,k8,xD),L0],d8=[D$(Y3,q8,AD),($)=>b1($)/Z1],i8=[D$(fD,w8,ED),L0,1],u8=[D$(PD,yz,vD),L0,1],IJ;function J1($,Z,O,j,J){function W(...X){if(!(this instanceof W))throw TypeError(V8);lz(this,Z(...X))}function Y(X,D){return Object.defineProperties(function(...T){return X.call(this,z(this),...T)},nj(D))}function z(X){let D=B0(X);if(!D||D.branding!==$)throw TypeError(V8);return D}return Object.defineProperties(W.prototype,{...LJ(d0(Y,O)),...Z$(d0(Y,j)),...n3("Temporal."+$)}),Object.defineProperties(W,{...Z$(J),...nj($)}),[W,(X)=>{let D=Object.create(W.prototype);return lz(D,X),D},z]}function uz($){return $=$.concat("id").sort(),(Z)=>{if(!_J(Z,$))throw TypeError(Tz);return Z}}function zZ($){if(B0($)||$.calendar!==void 0||$.timeZone!==void 0)throw TypeError(Yz);return $}function yO($,Z){let O={};for(let j in $)O[j]=({o:J},W)=>{let Y=B0(W)||{},{branding:z}=Y,X=z===G$||Z.includes(z)?Y:P0(W);return J[j](X)};return O}function a8($){let Z={};for(let O in $)Z[O]=(j)=>{let{calendar:J}=j;return(W=J,typeof W=="string"?OZ(W):(Y=W,Object.assign(Object.create(nD),{i:Y})))[O](j);var W,Y};return Z}function l1(){throw TypeError(Xz)}function X3({calendar:$}){return typeof $=="string"?new J2($):$}function pz($,Z){if(Z=$0(Z),X0($)){let j=B0($);if(j&&j.branding===ZZ)return g(Z),j;let J=az($);return z8(iO(J||q),!J,$,Z)}let O=bW(OZ,$);return g(Z),O}function sz($,Z,O){return j=Z.call($,f0(D0(O))),x6(nZ(j));var j}function mO($,Z=ez){let O=Object.keys(Z).sort(),j={};for(let J of O)j[J]=R(Z[J],$,fz($[J]));return j}function c($,Z){return typeof $=="string"?qO($):mO($,Z)}function J0($){return c($,n8)}function O1($){if(X0($)){let Z=B0($);if(Z)switch(Z.branding){case wO:return Z;case I1:return D0(Z.epochNanoseconds)}}return HW($)}function hz($,Z,O){let j=Z.l(O1(O).epochNanoseconds,$);return j?f0(D0(j)):null}function d($){return X0($)?(B0($)||{}).timeZone||$T($):((Z)=>MO(qW(a(Z))))($)}function m1($,Z){if(X0($)){let O=B0($)||{};switch(O.branding){case RO:return g(Z),O;case F$:return g(Z),s0(O);case I1:return g(Z),U8(J0,O)}return QY($,Z)}return g(Z),RW($)}function o8($){return $===void 0?void 0:m1($)}function JZ($,Z){if(Z=$0(Z),X0($)){let j=B0($);return j&&j.branding===$Z?(g(Z),j):Y8(lO(D3($)),$,Z)}let O=vW(OZ,$);return g(Z),O}function p1($,Z){if(Z=$0(Z),X0($)){let j=B0($)||{};switch(j.branding){case F$:return g(Z),j;case G$:return g(Z),Z0({...j,...l0});case I1:return g(Z),G8(J0,j)}return KY(dO(D3($)),$,Z)}let O=EW($);return g(Z),O}function P0($,Z){if(Z=$0(Z),X0($)){let j=B0($)||{};switch(j.branding){case G$:return g(Z),j;case F$:return g(Z),O0(j);case I1:return g(Z),F8(J0,j)}return W8(dO(D3($)),$,Z)}let O=VO($);return g(Z),O}function nz($,Z,O){return i0(Z.call($,r(O0(O,$))))}function W1($){return(Z)=>typeof Z=="string"?OZ(Z):((O,j)=>{let J=Object.keys(j).sort(),W={};for(let Y of J)W[Y]=R(j[Y],O,O[Y]);return W})(Z,$)}function o($){if(X0($)){let Z=B0($);return Z&&Z.branding===kO?Z:BY($)}return wW($)}function z3($){if($!==void 0){if(X0($)){let Z=B0($)||{};switch(Z.branding){case I1:case G$:return Z;case F$:return O0(Z)}let O=D3($);return{...FY(d,c,dO(O),$),calendar:O}}return xW($)}}function D3($){return az($)||q}function az($){let{calendar:Z}=$;if(Z!==void 0)return Q0(Z)}function Q0($){return X0($)?(B0($)||{}).calendar||QT($):((Z)=>rZ(kW(a(Z))))($)}function WZ($,Z){if(Z=$0(Z),X0($)){let O=B0($);if(O&&O.branding===I1)return aZ(Z),O;let j=D3($);return UY(d,c,dO(j),j,$,Z)}return AW($,Z)}function cz($){return d0((Z)=>(O)=>Z(s8(O)),$)}function s8($){return _0($,J0)}function RD(){let $=y1.prototype,Z=Object.getOwnPropertyDescriptors($),O=Object.getOwnPropertyDescriptors(y1),j=function(J,W={}){if(!(this instanceof j))return new j(J,W);W2.set(this,((Y,z={})=>{let X=new y1(Y,z),D=X.resolvedOptions(),T=D.locale,F=R0(Object.keys(z),D),G=v0(qD),U=(...K)=>{let Q,B=K.map((M,L)=>{let I=B0(M),S=(I||{}).branding;if(L&&Q&&Q!==S)throw TypeError(Uz);return Q=S,I});return Q?G(Q)(T,F,...B):[X,...K]};return U.u=X,U})(J,W))};for(let J in Z){let W=Z[J],Y=J.startsWith("format")&&wD(J);typeof W.value=="function"?W.value=J==="constructor"?j:Y||kD(J):Y&&(W.get=function(){return Y.bind(this)})}return O.prototype.value=Object.create($,Z),Object.defineProperties(j,O),j}function wD($){return function(...Z){let O=W2.get(this),[j,...J]=O(...Z);return j[$](...J)}}function kD($){return function(...Z){return W2.get(this).u[$](...Z)}}function qD($){let Z=gD[$];if(!Z)throw TypeError(Fz($));return V1(Z,v0(K8))}var gD={Instant:h8,PlainDateTime:c8,PlainDate:l8,PlainTime:d8,PlainYearMonth:i8,PlainMonthDay:u8},yD=V1(h8),mD=V1(mz),pD=V1(c8),hD=V1(l8),cD=V1(d8),lD=V1(i8),dD=V1(u8),r8={era:EJ,eraYear:tj,year:nZ,month:i0,daysInMonth:i0,daysInYear:i0,inLeapYear:Sz,monthsInYear:i0},hO={monthCode:a},t8={day:i0},oz={dayOfWeek:i0,dayOfYear:i0,weekOfYear:vJ,yearOfWeek:tj,daysInWeek:i0},rz=Object.assign({},r8,hO,t8,oz),pO=new WeakMap,B0=pO.get.bind(pO),lz=pO.set.bind(pO),iD={...yO(r8,[$Z]),...yO(oz,[]),...yO(hO,[$Z,ZZ]),...yO(t8,[ZZ])},e8=a8(rz),uD=a8({...r8,...hO}),sD=a8({...hO,...t8}),T3={calendarId:($)=>G0($.calendar)},nD=d0(($,Z)=>function(O){let{i:j}=this;return $(j[Z](r(O0(O,j))))},rz),aD=uZ(($)=>(Z)=>Z[$],y.concat("sign")),$2=uZ(($,Z)=>(O)=>O[a0[Z]],M1),tz={epochSeconds:eJ,epochMilliseconds:YO,epochMicroseconds:$W,epochNanoseconds:ZW},G3=R(aj,new Set(["branding"])),[oD,YZ,rD]=J1(ZZ,R(EY,Q0),{...T3,...sD},{getISOFields:G3,getCalendar:X3,with($,Z,O){return YZ(NY(FT,$,this,zZ(Z),O))},equals:($,Z)=>oW($,pz(Z)),toPlainDate($,Z){return r(dY(F3,$,this,Z))},toLocaleString($,Z,O){let[j,J]=dD(Z,O,$);return j.format(J)},toString:_6,toJSON:($)=>_6($),valueOf:l1},{from:($,Z)=>YZ(pz($,Z))}),ez={getOffsetNanosecondsFor:sz,getPossibleInstantsFor($,Z,O){let j=[...Z.call($,K0(Z0(O,q)))].map((W)=>eD(W).epochNanoseconds),J=j.length;return J>1&&(j.sort(N0),A6(y0(g0(j[0],j[J-1])))),j}},n8={getOffsetNanosecondsFor:sz},[tD,f0,eD]=J1(wO,fY,tz,{add:($,Z)=>f0(E6(0,$,o(Z))),subtract:($,Z)=>f0(E6(1,$,o(Z))),until:($,Z,O)=>l(r6(0,$,O1(Z),O)),since:($,Z,O)=>l(r6(1,$,O1(Z),O)),round:($,Z)=>f0(JW($,Z)),equals:($,Z)=>iW($,O1(Z)),toZonedDateTime($,Z){let O=Q1(Z);return j0(T8($,d(O.timeZone),Q0(O.calendar)))},toZonedDateTimeISO:($,Z)=>j0(T8($,d(Z))),toLocaleString($,Z,O){let[j,J]=yD(Z,O,$);return j.format(J)},toString:($,Z)=>C6(d,J0,$,Z),toJSON:($)=>C6(d,J0,$),valueOf:l1},{from:($)=>f0(O1($)),fromEpochSeconds:($)=>f0(sY($)),fromEpochMilliseconds:($)=>f0(nY($)),fromEpochMicroseconds:($)=>f0(aY($)),fromEpochNanoseconds:($)=>f0(oY($)),compare:($,Z)=>n6(O1($),O1(Z))}),[cO,YK]=J1("TimeZone",($)=>{let Z=lW($);return{branding:"TimeZone",id:Z,o:qO(Z)}},{id:($)=>$.id},{getPossibleInstantsFor:({o:$},Z)=>$.getPossibleInstantsFor(p1(Z)).map((O)=>f0(D0(O))),getOffsetNanosecondsFor:({o:$},Z)=>$.getOffsetNanosecondsFor(O1(Z).epochNanoseconds),getOffsetStringFor($,Z){let O=O1(Z).epochNanoseconds,j=mO(this,n8).getOffsetNanosecondsFor(O);return J$(j)},getPlainDateTimeFor($,Z,O=q){let j=O1(Z).epochNanoseconds,J=mO(this,n8).getOffsetNanosecondsFor(j);return K0(Z0(w1(j,J),Q0(O)))},getInstantFor($,Z,O){let j=p1(Z),J=X6(O),W=mO(this);return f0(D0(b0(W,j,J)))},getNextTransition:({o:$},Z)=>hz(1,$,Z),getPreviousTransition:({o:$},Z)=>hz(-1,$,Z),equals($,Z){return!!NO(this,d(Z))},toString:($)=>$.id,toJSON:($)=>$.id},{from($){let Z=d($);return typeof Z=="string"?new cO(Z):Z}}),$T=uz(Object.keys(ez)),[ZT,h1]=J1(RO,vY,$2,{getISOFields:G3,with($,Z,O){return h1(LY(this,zZ(Z),O))},add:($,Z)=>h1(k6(0,$,o(Z))),subtract:($,Z)=>h1(k6(1,$,o(Z))),until:($,Z,O)=>l(O8(0,$,m1(Z),O)),since:($,Z,O)=>l(O8(1,$,m1(Z),O)),round:($,Z)=>h1(zW($,Z)),equals:($,Z)=>rW($,m1(Z)),toZonedDateTime:($,Z)=>j0(iY(d,P0,c,$,Z)),toPlainDateTime:($,Z)=>K0(uY($,P0(Z))),toLocaleString($,Z,O){let[j,J]=cD(Z,O,$);return j.format(J)},toString:S6,toJSON:($)=>S6($),valueOf:l1},{from:($,Z)=>h1(m1($,Z)),compare:($,Z)=>IO(m1($),m1(Z))}),[OT,c1,jT]=J1($Z,R(AY,Q0),{...T3,...uD},{getISOFields:G3,getCalendar:X3,with($,Z,O){return c1(IY(GT,$,this,zZ(Z),O))},add:($,Z,O)=>c1(w6(dz,0,$,o(Z),O)),subtract:($,Z,O)=>c1(w6(dz,1,$,o(Z),O)),until:($,Z,O)=>l(Z8(iz,0,$,JZ(Z),O)),since:($,Z,O)=>l(Z8(iz,1,$,JZ(Z),O)),equals:($,Z)=>aW($,JZ(Z)),toPlainDate($,Z){return r(lY(F3,$,this,Z))},toLocaleString($,Z,O){let[j,J]=lD(Z,O,$);return j.format(J)},toString:L6,toJSON:($)=>L6($),valueOf:l1},{from:($,Z)=>c1(JZ($,Z)),compare:($,Z)=>z$(JZ($),JZ(Z))}),[JT,K0]=J1(F$,R(HY,Q0),{...T3,...e8,...$2},{getISOFields:G3,getCalendar:X3,with($,Z,O){return K0(CY(F3,$,this,zZ(Z),O))},withCalendar:($,Z)=>K0(fO($,Q0(Z))),withPlainDate:($,Z)=>K0($z($,P0(Z))),withPlainTime:($,Z)=>K0(eY($,o8(Z))),add:($,Z,O)=>K0(b6(K$,0,$,o(Z),O)),subtract:($,Z,O)=>K0(b6(K$,1,$,o(Z),O)),until:($,Z,O)=>l(e6(j1,0,$,p1(Z),O)),since:($,Z,O)=>l(e6(j1,1,$,p1(Z),O)),round:($,Z)=>K0(YW($,Z)),equals:($,Z)=>sW($,p1(Z)),toZonedDateTime:($,Z,O)=>j0(qY(c,$,d(Z),O)),toPlainDate:($)=>r(O0($)),toPlainTime:($)=>h1(s0($)),toPlainYearMonth($){return c1(gY(lO,$,this))},toPlainMonthDay($){return YZ(yY(iO,$,this))},toLocaleString($,Z,O){let[j,J]=pD(Z,O,$);return j.format(J)},toString:I6,toJSON:($)=>I6($),valueOf:l1},{from:($,Z)=>K0(p1($,Z)),compare:($,Z)=>o6(p1($),p1(Z))}),[WT,r,$9]=J1(G$,R(xY,Q0),{...T3,...e8},{getISOFields:G3,getCalendar:X3,with($,Z,O){return r(MY(F3,$,this,zZ(Z),O))},withCalendar:($,Z)=>r(fO($,Q0(Z))),add:($,Z,O)=>r(R6(K$,0,$,o(Z),O)),subtract:($,Z,O)=>r(R6(K$,1,$,o(Z),O)),until:($,Z,O)=>l($8(j1,0,$,P0(Z),O)),since:($,Z,O)=>l($8(j1,1,$,P0(Z),O)),equals:($,Z)=>nW($,P0(Z)),toZonedDateTime($,Z){let O=!X0(Z)||Z instanceof cO?{timeZone:Z}:Z;return j0(mY(d,m1,c,$,O))},toPlainDateTime:($,Z)=>K0(pY($,o8(Z))),toPlainYearMonth($){return c1(hY(lO,$,this))},toPlainMonthDay($){return YZ(cY(iO,$,this))},toLocaleString($,Z,O){let[j,J]=hD(Z,O,$);return j.format(J)},toString:N6,toJSON:($)=>N6($),valueOf:l1},{from:($,Z)=>r(P0($,Z)),compare:($,Z)=>z$(P0($),P0(Z))}),Z2={fields($,Z,O){return[...Z.call($,O)]}},Z9=Object.assign({dateFromFields($,Z,O,j){return $9(Z.call($,Object.assign(Object.create(null),O),j))}},Z2),O9=Object.assign({yearMonthFromFields($,Z,O,j){return jT(Z.call($,Object.assign(Object.create(null),O),j))}},Z2),j9=Object.assign({monthDayFromFields($,Z,O,j){return rD(Z.call($,Object.assign(Object.create(null),O),j))}},Z2),O2={mergeFields($,Z,O,j){return Q1(Z.call($,Object.assign(Object.create(null),O),Object.assign(Object.create(null),j)))}},YT=Object.assign({},Z9,O2),zT=Object.assign({},O9,O2),XT=Object.assign({},j9,O2),j2={dateAdd($,Z,O,j,J){return $9(Z.call($,r(O0(O,$)),l(i(j)),J))}},J9=Object.assign({},j2,{dateUntil($,Z,O,j,J,W){return KT(Z.call($,r(O0(O,$)),r(O0(j,$)),Object.assign(Object.create(null),W,{largestUnit:O3[J]})))}}),DT=Object.assign({},j2,{day:nz}),TT=Object.assign({},J9,{day:nz}),lO=W1(O9),dO=W1(Z9),iO=W1(j9),GT=W1(zT),F3=W1(YT),FT=W1(XT),K$=W1(j2),j1=W1(J9),dz=W1(DT),iz=W1(TT),[UT,l,KT]=J1(kO,bY,{...aD,blank:SW},{with:($,Z)=>l(_Y($,Z)),negated:($)=>l(QO($)),abs:($)=>l(_W($)),add:($,Z,O)=>l(p6(z3,j1,c,0,$,o(Z),O)),subtract:($,Z,O)=>l(p6(z3,j1,c,1,$,o(Z),O)),round:($,Z)=>l(LW(z3,j1,c,$,Z)),total:($,Z)=>jW(z3,j1,c,$,Z),toLocaleString($,Z,O){return Intl.DurationFormat?new Intl.DurationFormat(Z,O).format(this):TO($)},toString:TO,toJSON:($)=>TO($),valueOf:l1},{from:($)=>l(o($)),compare:($,Z,O)=>dW(z3,K$,c,o($),o(Z),O)}),W9={toString:($)=>$.id,toJSON:($)=>$.id,...iD,dateAdd:({id:$,o:Z},O,j,J)=>r(O0(Z.dateAdd(P0(O),o(j),J),$)),dateUntil:({o:$},Z,O,j)=>l(i($.dateUntil(P0(Z),P0(O),nJ(j)))),dateFromFields:({id:$,o:Z},O,j)=>r(W8(Z,O,j,AJ($))),yearMonthFromFields:({id:$,o:Z},O,j)=>c1(Y8(Z,O,j,HJ($))),monthDayFromFields:({id:$,o:Z},O,j)=>YZ(z8(Z,0,O,j,xJ($))),fields({o:$},Z){let O=new Set(n0),j=[];for(let J of Z){if(a(J),!O.has(J))throw RangeError(B8(J));O.delete(J),j.push(J)}return $.fields(j)},mergeFields:({o:$},Z,O)=>$.mergeFields(oj(ej(Z)),oj(ej(O)))},[J2]=J1("Calendar",($)=>{let Z=WY($);return{branding:"Calendar",id:Z,o:OZ(Z)}},{id:($)=>$.id},W9,{from($){let Z=Q0($);return typeof Z=="string"?new J2(Z):Z}}),QT=uz(Object.keys(W9).slice(4)),[BT,j0]=J1(I1,R(PY,Q0,d),{...tz,...T3,...cz(e8),...cz($2),offset:($)=>J$(s8($).offsetNanoseconds),offsetNanoseconds:($)=>s8($).offsetNanoseconds,timeZoneId:($)=>G0($.timeZone),hoursInDay:($)=>XW(c,$)},{getISOFields:($)=>IW(J0,$),getCalendar:X3,getTimeZone:({timeZone:$})=>typeof $=="string"?new cO($):$,with($,Z,O){return j0(VY(F3,c,$,this,zZ(Z),O))},withCalendar:($,Z)=>j0(fO($,Q0(Z))),withTimeZone:($,Z)=>j0(Zz($,d(Z))),withPlainDate:($,Z)=>j0(tY(c,$,P0(Z))),withPlainTime:($,Z)=>j0(rY(c,$,o8(Z))),add:($,Z,O)=>j0(v6(K$,c,0,$,o(Z),O)),subtract:($,Z,O)=>j0(v6(K$,c,1,$,o(Z),O)),until:($,Z,O)=>l(i(t6(j1,c,0,$,WZ(Z),O))),since:($,Z,O)=>l(i(t6(j1,c,1,$,WZ(Z),O))),round:($,Z)=>j0(WW(c,$,Z)),startOfDay:($)=>j0(DW(c,$)),equals:($,Z)=>uW($,WZ(Z)),toInstant:($)=>f0(RY($)),toPlainDateTime:($)=>K0(G8(J0,$)),toPlainDate:($)=>r(F8(J0,$)),toPlainTime:($)=>h1(U8(J0,$)),toPlainYearMonth($){return c1(wY(lO,$,this))},toPlainMonthDay($){return YZ(kY(iO,$,this))},toLocaleString($,Z,O={}){let[j,J]=mD(Z,O,$);return j.format(J)},toString:($,Z)=>M6(J0,$,Z),toJSON:($)=>M6(J0,$),valueOf:l1},{from:($,Z)=>j0(WZ($,Z)),compare:($,Z)=>a6(WZ($),WZ(Z))}),VT=Object.defineProperties({},{...n3("Temporal.Now"),...Z$({timeZoneId:()=>C1(),instant:()=>f0(D0(eZ())),zonedDateTime:($,Z=C1())=>j0(U0(eZ(),d(Z),Q0($))),zonedDateTimeISO:($=C1())=>j0(U0(eZ(),d($),q)),plainDateTime:($,Z=C1())=>K0(Z0(t$(J0(d(Z))),Q0($))),plainDateTimeISO:($=C1())=>K0(Z0(t$(J0(d($))),q)),plainDate:($,Z=C1())=>r(O0(t$(J0(d(Z))),Q0($))),plainDateISO:($=C1())=>r(O0(t$(J0(d($))),q)),plainTimeISO:($=C1())=>h1(s0(t$(J0(d($)))))})}),XZ=Object.defineProperties({},{...n3("Temporal"),...Z$({PlainYearMonth:OT,PlainMonthDay:oD,PlainDate:WT,PlainTime:ZT,PlainDateTime:JT,ZonedDateTime:BT,Instant:tD,Calendar:J2,TimeZone:cO,Duration:UT,Now:VT})}),CT=RD(),W2=new WeakMap,MT=Object.defineProperties(Object.create(Intl),Z$({DateTimeFormat:CT}));var Y2=new WeakMap;function NT($){let Z=Y2.get($);if(!Z)Z=$(IT(32).toString("hex")),Y2.set($,Z),Z.catch(()=>Y2.delete($));return Z}async function z2($,Z,O){if(typeof O==="string"&&O!=="")return await $.verifyPassword(Z,O);try{await $.verifyPassword(Z,await NT($.hashPassword))}catch{}return!1}async function Q$($,Z){let O=Z.user??Z.session?.user;if(!O||!$.onAuthenticated)return;let{password:j,...J}=O;await $.onAuthenticated({...Z,user:J})}class T2 extends Error{}function X2($){return typeof $==="string"&&$!==""?$:null}function Y9($){return wZ($)}var LT=256;function z9($){return typeof $==="string"&&$!==""&&$.length<=LT?$:null}var D2="intended_url";class G2 extends A{schema={email:{required:"Email is required",string:"Invalid email",email:"Invalid email"},password:{required:"Password is required"}}}class X9 extends A{schema={email:{required:"Email is required",email:"Invalid email"}}}class D9 extends A{schema={password:{required:"Password is required",password:"Invalid password"}}}class u extends Lj{async me(){let $=await B$.user();if(!$)throw new _j;return $}async verifyEmail($=new A){let Z=await $.input(),{userProvider:O}=N(E),j=X2(Z.get("token"));if(!j)return{email:null};let J=await O.findUserByVerificationToken(j);if(!J)return{email:null};return await O.verifyUser(J.email),{email:J.email}}async signInWithMagicLink($=new A){let Z=N(E),{userProvider:O}=Z,j=X2($.search.get("token")),J=null;try{J=wZ(decodeURIComponent($.search.get("email")??""))}catch{}if(await g$("link",null,$,{perIp:Z.config.emailCode.verifyLimit.perIp}),!J||!j||!await Z.verifyMagicLinkToken(J,j))return{error:"Invalid token"};await O.verifyUser(J);let W=await Z.createOrUpdateSession({email:J});return $.ctx().setCookie("access_token",W.token,N(E).accessTokenCookieOptions($,W.expiresAt)),await Z.config.onSignIn(W,$.search.toJSON()),await Q$(Z.config,{session:W,isNewUser:!1,method:"magic-link",req:$}),{session:W}}async verifyPinRequest($){let Z=N(E),O=await $.input(),{email:j,pin:J}=O.toJSON(),W=wZ(j),Y=z9(J);if(await g$("verify",W,$,Z.config.emailCode.verifyLimit),!W||!Y)throw new p({pin:["Invalid pin"]});let z=await Z.verifyOneTimeCode(W,Y);if(z.status==="too_many_attempts")throw new p({pin:["Too many attempts"]});if(z.status!=="ok")throw new p({pin:["Invalid pin"]});return await Z.userProvider.verifyUser(W),W}async signInWithPinV2($=new A){let Z=N(E),O=await this.verifyPinRequest($),j=await Z.createOrUpdateSessionV2({email:O});return $.ctx().setCookie("access_token",j.token,N(E).accessTokenCookieOptions($,j.expiresAt)),await Z.config.onSignIn(j,$.search.toJSON()),await Q$(Z.config,{session:j,isNewUser:!1,method:"magic-link",req:$}),j}async signInWithPin($=new A){let Z=N(E),O=await this.verifyPinRequest($),j=await Z.createOrUpdateSession({email:O});return $.ctx().setCookie("access_token",j.token,N(E).accessTokenCookieOptions($,j.expiresAt)),await Z.config.onSignIn(j,$.search.toJSON()),await Q$(Z.config,{session:j,isNewUser:!1,method:"magic-link",req:$}),{session:j}}async signInV2($=new G2){let Z=await $.input(),{email:O,password:j}=Z.toJSON(),J=O.toLowerCase().trim(),W=N(E),Y=await W.userProvider.findUserByEmailAddress(J,W.config.verifyEmail),z=typeof j==="string"&&await z2(W.config,j,Y?.password);if(!Y||!z)throw new p({invalid_credentials:["Invalid credentials"]});let X=await W.createOrUpdateSessionV2({email:Y.email,id:Y.id});$.ctx().setCookie("access_token",X.token,N(E).accessTokenCookieOptions($,X.expiresAt)),await W.config.onSignIn(Y,$.search.toJSON()),await Q$(W.config,{session:X,user:Y,isNewUser:!1,method:"password",req:$});let{password:D,...T}=Y;return T}async signIn($=new G2){let Z=await $.input(),{email:O,password:j}=Z.toJSON(),J=O.toLowerCase().trim(),W=N(E),Y=await W.userProvider.findUserByEmailAddress(J,W.config.verifyEmail),z=typeof j==="string"&&await z2(W.config,j,Y?.password);if(!Y||!z)throw new p({invalid_credentials:["Invalid credentials"]});let X=await W.createOrUpdateSession({email:Y.email,id:Y.id});$.ctx().setCookie("access_token",X.token,N(E).accessTokenCookieOptions($,X.expiresAt)),await W.config.onSignIn(Y,$.search.toJSON()),await Q$(W.config,{session:X,user:Y,isNewUser:!1,method:"password",req:$});let{password:D,...T}=Y;return T}async signUp(){let $=N(E),{userProvider:Z,config:O}=$,j=new O.signUpRequest,J=await j.input(),{email:W,password:Y,name:z,invitationId:X}=J.toJSON(),D=Y9(W);if(!D)throw new p({email:["Invalid email"]});if(Y!=null&&typeof Y!=="string")throw new p({password:["Invalid password"]});if(X!=null&&typeof X!=="string")throw new p({invitationId:["Invalid invitation"]});if(await Z.findUserByEmailAddress(D,!1))throw new p({email:["Email address already exists"]});let F=await O.hashPassword(Y),G=N(n).detectLocale(j),U;if(X)U=await Z.findInvitation(X,D);let K,Q="";if(U)K=await Z.transaction(async()=>{await Z.deleteInvitationById(X);let B=await Z.createUser({email:D,name:z,password:F,emailVerifiedAt:new Date,locale:G});return await Z.createAccount({organizationId:U.organizationId,userId:B.id,organizationRole:U.role}),await O.onUserCreated(B),B});else Q=await O.generateEmailVerificationToken(D),K=await Z.transaction(async()=>{let B=await Z.createUser({email:D,name:z,password:F,verificationToken:Q,locale:G});return await O.onUserCreated(B),B});return await O.onSignUp(K,Q,j.search.toJSON()),K}async signOut($=new A){let Z=Ij($),O=N(E),{config:j}=O,J=await O.revokeSession(Z,$.headers.get("User-Agent"));if($.ctx().setCookie("access_token","",N(E).accessTokenCookieOptions($,new Date(0))),N(E).cookieDomain($))$.ctx().setCookie("access_token","",{...N(E).accessTokenCookieOptions($,new Date(0)),domain:void 0});if(J?.user)J.user.extension=await j.extendSession(J.user),await j.onSignOut(J.user);return{}}async forgotPassword($=new X9){let Z=await $.input(),O=Y9(Z.get("email"));if(!O)return{};let{userProvider:j,config:J}=N(E),W=await j.findUserByEmailAddress(O,J.verifyEmail);if(!W)return{};let Y=await J.generateForgotPasswordToken(W);return await j.createPasswordResetToken({user:W,token:Y}),await J.onForgotPassword(W,Y),{}}async resetPassword($=new D9){let{userProvider:Z,config:O}=N(E),j=await $.input(),{password:J,token:W}=j.toJSON(),Y=X2(W),z=Y?await Z.findPasswordResetToken({token:Y}):null;if(!z)throw new p({token:["Invalid token"]});if(XZ.Instant.from(z.createdAt.toISOString()).add({hours:24}).until(XZ.Now.instant()).sign>=0)throw new p({token:["Token expired"]});await Z.deletePasswordResetToken({token:Y});let D=await Z.findUserByEmailAddress(z.user.email,O.verifyEmail);if(!D)throw new p({email:["User not found"]});let T=await O.hashPassword(J);return await Z.updateUserPassword({id:D.id,password:T}),await Z.deleteAllUserSessions(D.id),await O.onResetPassword(D),{}}async changePassword($=new A){let{userProvider:Z,config:O}=N(E),j=await B$.user(),J=await $.input(),{oldPassword:W,newPassword:Y}=J.toJSON();if(typeof Y!=="string")throw new p({newPassword:["Invalid password"]});let z=await Z.findUserByEmailAddress(j.email,O.verifyEmail);if(!(typeof W==="string"&&await z2(O,W,z?.password)))throw new p({oldPassword:["Incorrect password"]});let D=await O.hashPassword(Y);return await Z.updateUserPassword({id:j.id,password:D}),await Z.deleteAllUserSessions(j.id),{}}async oauthRedirect($=new A){let{provider:Z}=$.params,O=N(E).config.oauthProviders[Z];if(!O)throw Error(`Invalid provider: ${Z}`);let j=fZ($.search.get(x$),"");if(j)$.ctx().setCookie(D2,encodeURIComponent(j),{httpOnly:!0,sameSite:"Lax",secure:S4($.rawRequest),maxAge:600});return{destination:await O.getRedirectUrl($)}}async oauthCallback($=new A){let{provider:Z}=$.params,O=N(E),{userProvider:j,config:J}=O,W=J.oauthProviders[Z],{email:Y,name:z,username:X,providerId:D}=await W.onCallback($),T=D?await j.findUserBySocialAccount(Z,D):null,F="signin";if(!T){if(!Y)return console.error("Authentication error: No email returned from OAuth provider callback"),{session:null};let Q=N(n).detectLocale($);try{let B=await this.linkOAuthAccount({provider:Z,providerId:D,email:Y,name:z,username:X,locale:Q});if(B)T=B.user,F=B.action}catch(B){let M=D?await j.findUserBySocialAccount(Z,D):null;if(!M)throw B;T=M}if(!T)return{session:null}}let G=await O.createOrUpdateSessionV2({email:T.email,id:T.id});if($.ctx().setCookie("access_token",G.token,N(E).accessTokenCookieOptions($,G.expiresAt)),F==="signup")await J.onSignUp(T,"",$.search.toJSON());else await J.onSignIn(T,$.search.toJSON());await Q$(O.config,{session:G,user:T,isNewUser:F==="signup",method:"oauth",req:$});let U=$.cookies.get(D2),K=J.redirectPath;if(U){try{K=fZ(decodeURIComponent(U),K)}catch{}$.ctx().setCookie(D2,"",{maxAge:-1})}return{session:G,redirectTo:K}}async linkOAuthAccount($){let{provider:Z,providerId:O,email:j,name:J,username:W,locale:Y}=$,{userProvider:z,config:X}=N(E),D=(G)=>({provider:Z,userId:G,email:j,username:W,providerId:O,expiresAt:new Date,accessToken:"",refreshToken:""}),T=await z.findUserByEmailAddress(j,!1);if(T){if(!O)return{user:T,action:"signin"};let G=await z.findSocialAccounts(T.id,Z);if(G.some((K)=>K.providerId===O))return{user:T,action:"signin"};if(G.some((K)=>K.providerId))return console.error(`Authentication error: user ${T.id} is already linked to a different ${Z} account`),null;let U=G[0];if(U){if(!await z.claimSocialAccount(U,O))throw Error(`${Z} account link changed concurrently`)}else await z.createSocialAccount(D(T.id));return{user:T,action:"signin"}}return{user:await z.transaction(async()=>{let G=await z.createUser({email:j,name:J,locale:Y,emailVerifiedAt:new Date});if(O)await z.createSocialAccount(D(G.id));return await X.onUserCreated(G),G}),action:"signup"}}async createMagicLinkToken($=new A){let Z=await $.input(),O=wZ(Z.get("email")),j=N(E),{uniformMagicLinkResponse:J,requestLimit:W}=j.config.emailCode;if(await g$("request",O,$,W),!O)return{email:null};let{user:Y,pin:z,token:X}=await j.createMagicLinkToken(O);if(Y)return await j.config.onMagicLinkCreated(Y,{email:O,pin:z,token:X}),{email:O};return{email:J?O:null}}async requestEmailCode($=new A){let Z=N(E),O=Z.config.emailCode;if(!O.enabled)throw new q0("Not found",{status:404});let j=await $.input(),J=Ej(j.get("email"));if(await g$("request",J,$,O.requestLimit),!J)throw new p({email:["Invalid email"]});let W=await Z.userProvider.findUserByEmailAddress(J,!1);if(W||O.createUser){let{pin:Y,token:z}=await Z.issueOneTimeCode(J,O.length);await O.send({email:J,code:Y,token:z,isNewUser:!W,req:$})}return{ok:!0}}async verifyEmailCode($=new A){let Z=N(E),{userProvider:O,config:j}=Z;if(!j.emailCode.enabled)throw new q0("Not found",{status:404});let J=await $.input(),{email:W,code:Y,name:z}=J.toJSON(),X=Ej(W),D=z9(Y);if(await g$("verify",X,$,j.emailCode.verifyLimit),!X||!D)throw new p({code:["invalid_code"]});let T=await Z.verifyOneTimeCode(X,D,{claim:!1});if(T.status==="too_many_attempts")throw new p({code:["too_many_attempts"]});if(T.status!=="ok")throw new p({code:["invalid_code"]});let F=T.row,G=await O.findUserByEmailAddress(X,!1),U=!1;if(G){if(!await O.claimMagicLinkToken(F.id))throw new p({code:["invalid_code"]});await O.verifyUser(X)}else if(j.emailCode.createUser){let Q=N(n).detectLocale($);try{G=await O.transaction(async()=>{if(!await O.claimMagicLinkToken(F.id))throw new T2;let B=await O.createUser({email:X,name:typeof z==="string"?z.trim():"",emailVerifiedAt:new Date,locale:Q});return await j.onUserCreated(B),B}),U=!0}catch(B){if(B instanceof T2)throw new p({code:["invalid_code"]});throw B}}else throw await O.claimMagicLinkToken(F.id),new p({code:["invalid_code"]});let K=await Z.createOrUpdateSessionV2({email:X,id:G.id});return $.ctx().setCookie("access_token",K.token,N(E).accessTokenCookieOptions($,K.expiresAt)),await j.onSignIn(K,$.search.toJSON()),await Q$(Z.config,{session:K,isNewUser:U,method:"email-code",req:$}),{session:K,isNewUser:U}}}class T9 extends _1{middlewares=["cache:private"];routes={"/:provider":this.view("_Redirect",[u,"oauthRedirect"]),"/:provider/callback":this.view("auth/OauthCallback",[u,"oauthCallback"])}}class F2 extends _1{middlewares=["cache:private"];routes={"/sign-in/magic-link":this.view("auth/MagicLinkSignIn",[u,"signInWithMagicLink"]),"/oauth":T9}}class U2 extends H0{middlewares=["cache:private"];routes={"/sign-in":this.post(u,"signIn"),"/sign-in-v2":this.post(u,"signInV2"),"/sign-up":this.post(u,"signUp"),"/sign-out":this.post(u,"signOut"),"/forgot-password":this.post(u,"forgotPassword"),"/reset-password":this.post(u,"resetPassword"),"/change-password":this.post(u,"changePassword"),"/verify-email":this.post(u,"verifyEmail"),"/me":this.get(u,"me").middleware(["auth"]),"/magic-link":this.post(u,"createMagicLinkToken"),"/sign-in-with-pin":this.post(u,"signInWithPin"),"/sign-in-with-pin-v2":this.post(u,"signInWithPinV2"),"/email-code":this.post(u,"requestEmailCode"),"/email-code/verify":this.post(u,"verifyEmailCode")}}class K2 extends H0{middlewares=["cache:private,0,no-store"];routes={"/set-locale/:locale":this.get(async()=>{let Z=new A().params.locale;return await N(n).onLocaleChange(Z),{locale:Z}}),"/translations/:locale/:scope*":this.get(async()=>{let $=new A,Z=`/${$.params.scope??""}`,O=$.params.locale,j=N(n),J=O??j.detectLocale($),W=j.getPageTranslations(J,Z);return $.ctx().setCookie("i18n-locale",J,{expires:new Date(Date.now()+31536000000)}),{[J]:W}})}}class Q2{}class B2 extends Q2{async resize($,Z){let{height:O,width:j,quality:J,fit:W}=Z;return await(await uO("The Sharp image optimization driver"))($).resize(j>0?j:void 0,O>0?O:void 0,{fit:W}).webp({quality:J>0?J:80,force:!0}).toBuffer()}}function mK($){return $}function G9(){return{driver:new B2}}class V2 extends H0{routes={"/resize":this.file(async()=>{let $=new A,Z=new URL($.rawRequest.url),O=Z.searchParams.get("url"),j=Number(Z.searchParams.get("w")),J=Number(Z.searchParams.get("h")),W=Z.searchParams.get("fit")??"cover",Y=Number(Z.searchParams.get("q"));if(!O)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});let X=`${O.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${O}`,D=await fetch(X);if(!D.ok)return new Response(JSON.stringify({error:"Image not found",info:X}),{headers:{"Content-Type":"application/json"},status:404});let T=Buffer.from(await D.arrayBuffer()),F=await N(F9).resize(T,{height:J,width:j,fit:W,quality:Y});D.headers.delete("Content-Type"),D.headers.delete("Content-Length");let G=new Headers(D.headers);return G.set("Content-Type","image/webp"),G.set("Content-Length",`${F.byteLength}`),new Response(new Uint8Array(F),{headers:G})})}}class F9{static token="image";driver;constructor($={}){this.driver=$.driver??G9().driver}resize($,Z){return this.driver.resize($,Z)}}class C2 extends H0{middlewares=["cache:private,0"];routes={"/live":this.get(async()=>{let $=Bun.file(N(U9).currentLogFilePath);return new Response(await $.text(),{headers:{"Content-Type":"text/plain"}})})}}function _T($){let Z=new Map;for(let O of $)if(typeof O==="string"){let[j,J=""]=O.split(":");if(j.startsWith("-")){if(Z.has(j.replace("-","")))Z.delete(j.replace("-",""))}else Z.set(j,J.split(",").filter(Boolean))}else Z.set(O,[]);return Z}var ST={"body-limit":x3};class DZ{config;static token="middleware";defaultBodyLimit;constructor($){this.config=$;this.defaultBodyLimit=$.bodyLimit===null||$.bodyLimit===void 0?null:SZ($.bodyLimit)}get aliases(){return{...ST,...this.config.aliases}}applyDefaultBodyLimit($){if(this.defaultBodyLimit!==null&&!z4($))S3($,this.defaultBodyLimit,{checkDeclared:!1})}assertGlobalMiddleware(){for(let $ of this.config.global){if(typeof $!=="string")continue;let[Z]=$.split(":");if(Z.startsWith("-"))throw Error(`Global middleware "${$}" cancels an alias, but nothing is inherited into the global list. Remove it.`);if(!this.aliases[Z])throw Error(`Global middleware "${Z}" is not a registered alias. Add it to \`aliases\` in the middleware config, or list the class itself.`)}}runGlobalMiddleware(){return this.runMiddleware(this.config.global)}runMiddleware($){let Z=new A,O=this.aliases;return Array.from(_T($).entries()).map(([j,J])=>{if(typeof j==="string"){let W=O[j];if(W){let Y=new W(Z);return()=>Y.run.call(Y,...J)}}else{if(L3(j)){let W=new j(Z);return W.run.bind(W)}return j}}).filter(Boolean).reduce((j,J)=>{return async()=>{return{...await j(),...await J()}}},()=>Promise.resolve({}))()}}function ZQ($){return $}function K9(){return{onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{}}}function Q9(){return{partialRendering:!0,onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{},onStreamComplete:()=>{}}}function fT($){return"run"in $}function PT($){return Object.hasOwn($,"get")||Object.hasOwn($,"post")||Object.hasOwn($,"put")||Object.hasOwn($,"patch")||Object.hasOwn($,"delete")}function HT($){return Object.hasOwn($,"first")&&Object.hasOwn($,"second")}function xT($){if("__brand"in $)return $.__brand==="ApiRouter";return!1}function AT($){if("__internal_brand"in $)return $.__internal_brand==="ProxyHandler";return!1}function B9($){if("__internal_brand"in $)return $.__internal_brand==="StreamHandler";return!1}function M2($,Z="",O=[]){let j={};function J(W,Y,z,X,D){let T=W==="/"?"":W,F=Z==="/"?"":Z,G=(`${F}${T}`===""?"/":`${F}${T}`).replaceAll("//","/");if(!j[G])j[G]={};j[G][Y.toUpperCase()]={exec:z,middleware:[...O,...X],...D?{source:D}:{}},j[G].OPTIONS={exec:()=>{let K=new A().ctx().headers;return new Response(null,{headers:K,status:204})},middleware:[]}}for(let[W,Y]of Object.entries($)){if(AT(Y)){let z=Y;for(let X of["GET","POST","PUT","DELETE"])J(W,X,z.run.bind(z),z.middlewares);continue}if(fT(Y)){let z=Y,X=z.method,D=z.middlewares,T=z.run.bind(z);if(J(W,X,T,D,z.source),B9(Y))J(W,"HEAD",T,D,z.source)}if(PT(Y))for(let[z,X]of Object.entries(Y)){let D=X,T=D.middlewares,F=D.run.bind(D);if(J(W,z,F,T,D.source),z==="get"&&B9(D))J(W,"HEAD",F,T,D.source)}if(xT(Y)){let z=new Y,X=M2(z.routes,`${Z}${W}`,z.middlewares);for(let[D,T]of Object.entries(X))j[D.replaceAll("//","/")]=T}if(HT(Y)){let{first:z,second:X}=Y;for(let[D,T]of Object.entries(z)){let F=T.middlewares,G=T.run.bind(T),[U,...K]=W.split("/").reverse();if(!U.startsWith(":"))throw Error("Resource route must end with a dynamic segment");J(K.reverse().join("/"),D,G,F,T.source)}for(let[D,T]of Object.entries(X)){let F=T.middlewares,G=T.run.bind(T);J(W,D,G,F,T.source)}}}return Object.fromEntries(Object.entries(j).sort(([W],[Y])=>{let z=W.split("/").length+W.split(":").length,X=Y.split("/").length+Y.split(":").length;return z-X}))}function sO($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function I2($,Z){if($==="/")return Z;if(Z==="/")return $;return`${$}${Z}`}function N2($){let Z=sO($);return Z.length>1?Z.replace(/\/$/,""):Z}function V9($,Z){return Z.map((O)=>({...O,path:N2(I2($,O.path))}))}function nO($){let Z={};for(let[O,j]of Object.entries($))if("run"in j){let J=j;if("children"in J){let W=new J.children,Y=nO(W.routes);for(let[z,{exec:X,middleware:D,segments:T,features:F}]of Object.entries(Y)){let G=I2(O,z),U=(K)=>J.run.call(J,K,O);Z[sO(G)]={exec:[U,...X],middleware:[...J.middlewares,...D],features:[...J.featureGates,...F],viewPath:J.viewPath,segments:[{path:N2(O),viewPath:J.viewPath,...J.alwaysRuns?{alwaysRun:!0}:{}},...V9(O,T)]}}}else{let W=(Y)=>J.run.call(J,Y,O);Z[sO(O)]={exec:[W],middleware:J.middlewares,features:J.featureGates,viewPath:J.viewPath,segments:[{path:N2(O),viewPath:J.viewPath}]}}}else{let J=new j,W=nO(J.routes);for(let[Y,{exec:z,middleware:X,viewPath:D,segments:T,features:F}]of Object.entries(W)){let G=I2(O,Y);Z[sO(G)]={exec:z,middleware:[...J.middlewares,...X],features:[...J.featureGates,...F],viewPath:D,segments:V9(O,T)}}}return Object.fromEntries(Object.entries(Z).sort(([O],[j])=>{let J=O.split("/").length+O.split(":").length,W=j.split("/").length+j.split(":").length;return J-W}))}var ET=Object.defineProperty,f=($,Z)=>ET($,"name",{value:Z,configurable:!0}),FZ=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor($,Z,O,j,J,W){this.type=$,this.name=Z,this.prefix=O,this.value=j,this.suffix=J,this.modifier=W}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};f(FZ,"Part");var vT=/[$_\p{ID_Start}]/u,bT=/[$_\u200C\u200D\p{ID_Continue}]/u,_2=".*";function C9($,Z){return(Z?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test($)}f(C9,"isASCII");function P2($,Z=!1){let O=[],j=0;for(;j<$.length;){let J=$[j],W=f(function(Y){if(!Z)throw TypeError(Y);O.push({type:"INVALID_CHAR",index:j,value:$[j++]})},"ErrorOrInvalid");if(J==="*"){O.push({type:"ASTERISK",index:j,value:$[j++]});continue}if(J==="+"||J==="?"){O.push({type:"OTHER_MODIFIER",index:j,value:$[j++]});continue}if(J==="\\"){O.push({type:"ESCAPED_CHAR",index:j++,value:$[j++]});continue}if(J==="{"){O.push({type:"OPEN",index:j,value:$[j++]});continue}if(J==="}"){O.push({type:"CLOSE",index:j,value:$[j++]});continue}if(J===":"){let Y="",z=j+1;for(;z<$.length;){let X=$.substr(z,1);if(z===j+1&&vT.test(X)||z!==j+1&&bT.test(X)){Y+=$[z++];continue}break}if(!Y){W(`Missing parameter name at ${j}`);continue}O.push({type:"NAME",index:j,value:Y}),j=z;continue}if(J==="("){let Y=1,z="",X=j+1,D=!1;if($[X]==="?"){W(`Pattern cannot start with "?" at ${X}`);continue}for(;X<$.length;){if(!C9($[X],!1)){W(`Invalid character '${$[X]}' at ${X}.`),D=!0;break}if($[X]==="\\"){z+=$[X++]+$[X++];continue}if($[X]===")"){if(Y--,Y===0){X++;break}}else if($[X]==="("&&(Y++,$[X+1]!=="?")){W(`Capturing groups are not allowed at ${X}`),D=!0;break}z+=$[X++]}if(D)continue;if(Y){W(`Unbalanced pattern at ${j}`);continue}if(!z){W(`Missing pattern at ${j}`);continue}O.push({type:"REGEX",index:j,value:z}),j=X;continue}O.push({type:"CHAR",index:j,value:$[j++]})}return O.push({type:"END",index:j,value:""}),O}f(P2,"lexer");function H2($,Z={}){let O=P2($);Z.delimiter??="/#?",Z.prefixes??="./";let j=`[^${w0(Z.delimiter)}]+?`,J=[],W=0,Y=0,z="",X=new Set,D=f((I)=>{if(Y<O.length&&O[Y].type===I)return O[Y++].value},"tryConsume"),T=f(()=>D("OTHER_MODIFIER")??D("ASTERISK"),"tryConsumeModifier"),F=f((I)=>{let S=D(I);if(S!==void 0)return S;let{type:P,index:V}=O[Y];throw TypeError(`Unexpected ${P} at ${V}, expected ${I}`)},"mustConsume"),G=f(()=>{let I="",S;for(;S=D("CHAR")??D("ESCAPED_CHAR");)I+=S;return I},"consumeText"),U=f((I)=>I,"DefaultEncodePart"),K=Z.encodePart||U,Q="",B=f((I)=>{Q+=I},"appendToPendingFixedValue"),M=f(()=>{Q.length&&(J.push(new FZ(3,"","",K(Q),"",3)),Q="")},"maybeAddPartFromPendingFixedValue"),L=f((I,S,P,V,C)=>{let _=3;switch(C){case"?":_=1;break;case"*":_=0;break;case"+":_=2;break}if(!S&&!P&&_===3){B(I);return}if(M(),!S&&!P){if(!I)return;J.push(new FZ(3,"","",K(I),"",_));return}let x;P?P==="*"?x=_2:x=P:x=j;let w=2;x===j?(w=1,x=""):x===_2&&(w=0,x="");let v;if(S?v=S:P&&(v=W++),X.has(v))throw TypeError(`Duplicate name '${v}'.`);X.add(v),J.push(new FZ(w,v,K(I),x,K(V),_))},"addPart");for(;Y<O.length;){let I=D("CHAR"),S=D("NAME"),P=D("REGEX");if(!S&&!P&&(P=D("ASTERISK")),S||P){let C=I??"";Z.prefixes.indexOf(C)===-1&&(B(C),C=""),M();let _=T();L(C,S,P,"",_);continue}let V=I??D("ESCAPED_CHAR");if(V){B(V);continue}if(D("OPEN")){let C=G(),_=D("NAME"),x=D("REGEX");!_&&!x&&(x=D("ASTERISK"));let w=G();F("CLOSE");let v=T();L(C,_,x,w,v);continue}M(),F("END")}return J}f(H2,"parse");function w0($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}f(w0,"escapeString");function S2($){return $&&$.ignoreCase?"ui":"u"}f(S2,"flags");function M9($,Z,O){return x2(H2($,O),Z,O)}f(M9,"stringToRegexp");function V$($){switch($){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}f(V$,"modifierToString");function x2($,Z,O={}){O.delimiter??="/#?",O.prefixes??="./",O.sensitive??=!1,O.strict??=!1,O.end??=!0,O.start??=!0,O.endsWith="";let j=O.start?"^":"";for(let z of $){if(z.type===3){z.modifier===3?j+=w0(z.value):j+=`(?:${w0(z.value)})${V$(z.modifier)}`;continue}Z&&Z.push(z.name);let X=`[^${w0(O.delimiter)}]+?`,D=z.value;if(z.type===1?D=X:z.type===0&&(D=_2),!z.prefix.length&&!z.suffix.length){z.modifier===3||z.modifier===1?j+=`(${D})${V$(z.modifier)}`:j+=`((?:${D})${V$(z.modifier)})`;continue}if(z.modifier===3||z.modifier===1){j+=`(?:${w0(z.prefix)}(${D})${w0(z.suffix)})`,j+=V$(z.modifier);continue}j+=`(?:${w0(z.prefix)}`,j+=`((?:${D})(?:`,j+=w0(z.suffix),j+=w0(z.prefix),j+=`(?:${D}))*)${w0(z.suffix)})`,z.modifier===0&&(j+="?")}let J=`[${w0(O.endsWith)}]|$`,W=`[${w0(O.delimiter)}]`;if(O.end)return O.strict||(j+=`${W}?`),O.endsWith.length?j+=`(?=${J})`:j+="$",new RegExp(j,S2(O));O.strict||(j+=`(?:${W}(?=${J}))?`);let Y=!1;if($.length){let z=$[$.length-1];z.type===3&&z.modifier===3&&(Y=O.delimiter.indexOf(z)>-1)}return Y||(j+=`(?=${W}|${J})`),new RegExp(j,S2(O))}f(x2,"partsToRegexp");var i1={delimiter:"",prefixes:"",sensitive:!0,strict:!0},RT={delimiter:".",prefixes:"",sensitive:!0,strict:!0},wT={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function I9($,Z){return $.length?$[0]==="/"?!0:!Z||$.length<2?!1:($[0]=="\\"||$[0]=="{")&&$[1]=="/":!1}f(I9,"isAbsolutePathname");function A2($,Z){return $.startsWith(Z)?$.substring(Z.length,$.length):$}f(A2,"maybeStripPrefix");function N9($,Z){return $.endsWith(Z)?$.substr(0,$.length-Z.length):$}f(N9,"maybeStripSuffix");function E2($){return!$||$.length<2?!1:$[0]==="["||($[0]==="\\"||$[0]==="{")&&$[1]==="["}f(E2,"treatAsIPv6Hostname");var L9=["ftp","file","http","https","ws","wss"];function v2($){if(!$)return!0;for(let Z of L9)if($.test(Z))return!0;return!1}f(v2,"isSpecialScheme");function _9($,Z){if($=A2($,"#"),Z||$==="")return $;let O=new URL("https://example.com");return O.hash=$,O.hash?O.hash.substring(1,O.hash.length):""}f(_9,"canonicalizeHash");function S9($,Z){if($=A2($,"?"),Z||$==="")return $;let O=new URL("https://example.com");return O.search=$,O.search?O.search.substring(1,O.search.length):""}f(S9,"canonicalizeSearch");function f9($,Z){return Z||$===""?$:E2($)?w2($):R2($)}f(f9,"canonicalizeHostname");function P9($,Z){if(Z||$==="")return $;let O=new URL("https://example.com");return O.password=$,O.password}f(P9,"canonicalizePassword");function H9($,Z){if(Z||$==="")return $;let O=new URL("https://example.com");return O.username=$,O.username}f(H9,"canonicalizeUsername");function x9($,Z,O){if(O||$==="")return $;if(Z&&!L9.includes(Z))return new URL(`${Z}:${$}`).pathname;let j=$[0]=="/";return $=new URL(j?$:"/-"+$,"https://example.com").pathname,j||($=$.substring(2,$.length)),$}f(x9,"canonicalizePathname");function A9($,Z,O){return b2(Z)===$&&($=""),O||$===""?$:k2($)}f(A9,"canonicalizePort");function E9($,Z){return $=N9($,":"),Z||$===""?$:aO($)}f(E9,"canonicalizeProtocol");function b2($){switch($){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}f(b2,"defaultPortForProtocol");function aO($){if($==="")return $;if(/^[-+.A-Za-z0-9]*$/.test($))return $.toLowerCase();throw TypeError(`Invalid protocol '${$}'.`)}f(aO,"protocolEncodeCallback");function v9($){if($==="")return $;let Z=new URL("https://example.com");return Z.username=$,Z.username}f(v9,"usernameEncodeCallback");function b9($){if($==="")return $;let Z=new URL("https://example.com");return Z.password=$,Z.password}f(b9,"passwordEncodeCallback");function R2($){if($==="")return $;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test($))throw TypeError(`Invalid hostname '${$}'`);let Z=new URL("https://example.com");return Z.hostname=$,Z.hostname}f(R2,"hostnameEncodeCallback");function w2($){if($==="")return $;if(/[^0-9a-fA-F[\]:]/g.test($))throw TypeError(`Invalid IPv6 hostname '${$}'`);return $.toLowerCase()}f(w2,"ipv6HostnameEncodeCallback");function k2($){if($===""||/^[0-9]*$/.test($)&&parseInt($)<=65535)return $;throw TypeError(`Invalid port '${$}'.`)}f(k2,"portEncodeCallback");function R9($){if($==="")return $;let Z=new URL("https://example.com");return Z.pathname=$[0]!=="/"?"/-"+$:$,$[0]!=="/"?Z.pathname.substring(2,Z.pathname.length):Z.pathname}f(R9,"standardURLPathnameEncodeCallback");function w9($){return $===""?$:new URL(`data:${$}`).pathname}f(w9,"pathURLPathnameEncodeCallback");function k9($){if($==="")return $;let Z=new URL("https://example.com");return Z.search=$,Z.search.substring(1,Z.search.length)}f(k9,"searchEncodeCallback");function q9($){if($==="")return $;let Z=new URL("https://example.com");return Z.hash=$,Z.hash.substring(1,Z.hash.length)}f(q9,"hashEncodeCallback");var g9=class{#J;#Z=[];#O={};#$=0;#W=1;#D=0;#z=0;#U=0;#K=0;#Q=!1;constructor($){this.#J=$}get result(){return this.#O}parse(){for(this.#Z=P2(this.#J,!0);this.#$<this.#Z.length;this.#$+=this.#W){if(this.#W=1,this.#Z[this.#$].type==="END"){if(this.#z===0){this.#M(),this.#T()?this.#j(9,1):this.#G()?this.#j(8,1):this.#j(7,0);continue}else if(this.#z===2){this.#F(5);continue}this.#j(10,0);break}if(this.#U>0)if(this.#P())this.#U-=1;else continue;if(this.#f()){this.#U+=1;continue}switch(this.#z){case 0:this.#I()&&this.#F(1);break;case 1:if(this.#I()){this.#A();let $=7,Z=1;this.#L()?($=2,Z=3):this.#Q&&($=2),this.#j($,Z)}break;case 2:this.#V()?this.#F(3):(this.#C()||this.#G()||this.#T())&&this.#F(5);break;case 3:this.#_()?this.#j(4,1):this.#V()&&this.#j(5,1);break;case 4:this.#V()&&this.#j(5,1);break;case 5:this.#H()?this.#K+=1:this.#x()&&(this.#K-=1),this.#S()&&!this.#K?this.#j(6,1):this.#C()?this.#j(7,0):this.#G()?this.#j(8,1):this.#T()&&this.#j(9,1);break;case 6:this.#C()?this.#j(7,0):this.#G()?this.#j(8,1):this.#T()&&this.#j(9,1);break;case 7:this.#G()?this.#j(8,1):this.#T()&&this.#j(9,1);break;case 8:this.#T()&&this.#j(9,1);break;case 9:break;case 10:break}}this.#O.hostname!==void 0&&this.#O.port===void 0&&(this.#O.port="")}#j($,Z){switch(this.#z){case 0:break;case 1:this.#O.protocol=this.#X();break;case 2:break;case 3:this.#O.username=this.#X();break;case 4:this.#O.password=this.#X();break;case 5:this.#O.hostname=this.#X();break;case 6:this.#O.port=this.#X();break;case 7:this.#O.pathname=this.#X();break;case 8:this.#O.search=this.#X();break;case 9:this.#O.hash=this.#X();break;case 10:break}this.#z!==0&&$!==10&&([1,2,3,4].includes(this.#z)&&[6,7,8,9].includes($)&&(this.#O.hostname??=""),[1,2,3,4,5,6].includes(this.#z)&&[8,9].includes($)&&(this.#O.pathname??=this.#Q?"/":""),[1,2,3,4,5,6,7].includes(this.#z)&&$===9&&(this.#O.search??="")),this.#N($,Z)}#N($,Z){this.#z=$,this.#D=this.#$+Z,this.#$+=Z,this.#W=0}#M(){this.#$=this.#D,this.#W=0}#F($){this.#M(),this.#z=$}#B($){return $<0&&($=this.#Z.length-$),$<this.#Z.length?this.#Z[$]:this.#Z[this.#Z.length-1]}#Y($,Z){let O=this.#B($);return O.value===Z&&(O.type==="CHAR"||O.type==="ESCAPED_CHAR"||O.type==="INVALID_CHAR")}#I(){return this.#Y(this.#$,":")}#L(){return this.#Y(this.#$+1,"/")&&this.#Y(this.#$+2,"/")}#V(){return this.#Y(this.#$,"@")}#_(){return this.#Y(this.#$,":")}#S(){return this.#Y(this.#$,":")}#C(){return this.#Y(this.#$,"/")}#G(){if(this.#Y(this.#$,"?"))return!0;if(this.#Z[this.#$].value!=="?")return!1;let $=this.#B(this.#$-1);return $.type!=="NAME"&&$.type!=="REGEX"&&$.type!=="CLOSE"&&$.type!=="ASTERISK"}#T(){return this.#Y(this.#$,"#")}#f(){return this.#Z[this.#$].type=="OPEN"}#P(){return this.#Z[this.#$].type=="CLOSE"}#H(){return this.#Y(this.#$,"[")}#x(){return this.#Y(this.#$,"]")}#X(){let $=this.#Z[this.#$],Z=this.#B(this.#D).index;return this.#J.substring(Z,$.index)}#A(){let $={};Object.assign($,i1),$.encodePart=aO;let Z=M9(this.#X(),void 0,$);this.#Q=v2(Z)}};f(g9,"Parser");var L2=["protocol","username","password","hostname","port","pathname","search","hash"],d1="*";function f2($,Z){if(typeof $!="string")throw TypeError("parameter 1 is not of type 'string'.");let O=new URL($,Z);return{protocol:O.protocol.substring(0,O.protocol.length-1),username:O.username,password:O.password,hostname:O.hostname,port:O.port,pathname:O.pathname,search:O.search!==""?O.search.substring(1,O.search.length):void 0,hash:O.hash!==""?O.hash.substring(1,O.hash.length):void 0}}f(f2,"extractValues");function Y1($,Z){return Z?GZ($):$}f(Y1,"processBaseURLString");function TZ($,Z,O){let j;if(typeof Z.baseURL=="string")try{j=new URL(Z.baseURL),Z.protocol===void 0&&($.protocol=Y1(j.protocol.substring(0,j.protocol.length-1),O)),!O&&Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.username===void 0&&($.username=Y1(j.username,O)),!O&&Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.username===void 0&&Z.password===void 0&&($.password=Y1(j.password,O)),Z.protocol===void 0&&Z.hostname===void 0&&($.hostname=Y1(j.hostname,O)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&($.port=Y1(j.port,O)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&($.pathname=Y1(j.pathname,O)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&Z.search===void 0&&($.search=Y1(j.search.substring(1,j.search.length),O)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&Z.search===void 0&&Z.hash===void 0&&($.hash=Y1(j.hash.substring(1,j.hash.length),O))}catch{throw TypeError(`invalid baseURL '${Z.baseURL}'.`)}if(typeof Z.protocol=="string"&&($.protocol=E9(Z.protocol,O)),typeof Z.username=="string"&&($.username=H9(Z.username,O)),typeof Z.password=="string"&&($.password=P9(Z.password,O)),typeof Z.hostname=="string"&&($.hostname=f9(Z.hostname,O)),typeof Z.port=="string"&&($.port=A9(Z.port,$.protocol,O)),typeof Z.pathname=="string"){if($.pathname=Z.pathname,j&&!I9($.pathname,O)){let J=j.pathname.lastIndexOf("/");J>=0&&($.pathname=Y1(j.pathname.substring(0,J+1),O)+$.pathname)}$.pathname=x9($.pathname,$.protocol,O)}return typeof Z.search=="string"&&($.search=S9(Z.search,O)),typeof Z.hash=="string"&&($.hash=_9(Z.hash,O)),$}f(TZ,"applyInit");function GZ($){return $.replace(/([+*?:{}()\\])/g,"\\$1")}f(GZ,"escapePatternString");function y9($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}f(y9,"escapeRegexpString");function m9($,Z){Z.delimiter??="/#?",Z.prefixes??="./",Z.sensitive??=!1,Z.strict??=!1,Z.end??=!0,Z.start??=!0,Z.endsWith="";let O=".*",j=`[^${y9(Z.delimiter)}]+?`,J=/[$_\u200C\u200D\p{ID_Continue}]/u,W="";for(let Y=0;Y<$.length;++Y){let z=$[Y];if(z.type===3){if(z.modifier===3){W+=GZ(z.value);continue}W+=`{${GZ(z.value)}}${V$(z.modifier)}`;continue}let X=z.hasCustomName(),D=!!z.suffix.length||!!z.prefix.length&&(z.prefix.length!==1||!Z.prefixes.includes(z.prefix)),T=Y>0?$[Y-1]:null,F=Y<$.length-1?$[Y+1]:null;if(!D&&X&&z.type===1&&z.modifier===3&&F&&!F.prefix.length&&!F.suffix.length)if(F.type===3){let G=F.value.length>0?F.value[0]:"";D=J.test(G)}else D=!F.hasCustomName();if(!D&&!z.prefix.length&&T&&T.type===3){let G=T.value[T.value.length-1];D=Z.prefixes.includes(G)}D&&(W+="{"),W+=GZ(z.prefix),X&&(W+=`:${z.name}`),z.type===2?W+=`(${z.value})`:z.type===1?X||(W+=`(${j})`):z.type===0&&(!X&&(!T||T.type===3||T.modifier!==3||D||z.prefix!=="")?W+="*":W+=`(${O})`),z.type===1&&X&&z.suffix.length&&J.test(z.suffix[0])&&(W+="\\"),W+=GZ(z.suffix),D&&(W+="}"),z.modifier!==3&&(W+=V$(z.modifier))}return W}f(m9,"partsToPattern");var q2=class{#J;#Z={};#O={};#$={};#W={};#D=!1;constructor($={},Z,O){try{let j;if(typeof Z=="string"?j=Z:O=Z,typeof $=="string"){let z=new g9($);if(z.parse(),$=z.result,j===void 0&&typeof $.protocol!="string")throw TypeError("A base URL must be provided for a relative constructor string.");$.baseURL=j}else{if(!$||typeof $!="object")throw TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(j)throw TypeError("parameter 1 is not of type 'string'.")}typeof O>"u"&&(O={ignoreCase:!1});let J={ignoreCase:O.ignoreCase===!0},W={pathname:d1,protocol:d1,username:d1,password:d1,hostname:d1,port:d1,search:d1,hash:d1};this.#J=TZ(W,$,!0),b2(this.#J.protocol)===this.#J.port&&(this.#J.port="");let Y;for(Y of L2){if(!(Y in this.#J))continue;let z={},X=this.#J[Y];switch(this.#O[Y]=[],Y){case"protocol":Object.assign(z,i1),z.encodePart=aO;break;case"username":Object.assign(z,i1),z.encodePart=v9;break;case"password":Object.assign(z,i1),z.encodePart=b9;break;case"hostname":Object.assign(z,RT),E2(X)?z.encodePart=w2:z.encodePart=R2;break;case"port":Object.assign(z,i1),z.encodePart=k2;break;case"pathname":v2(this.#Z.protocol)?(Object.assign(z,wT,J),z.encodePart=R9):(Object.assign(z,i1,J),z.encodePart=w9);break;case"search":Object.assign(z,i1,J),z.encodePart=k9;break;case"hash":Object.assign(z,i1,J),z.encodePart=q9;break}try{this.#W[Y]=H2(X,z),this.#Z[Y]=x2(this.#W[Y],this.#O[Y],z),this.#$[Y]=m9(this.#W[Y],z),this.#D=this.#D||this.#W[Y].some((D)=>D.type===2)}catch{throw TypeError(`invalid ${Y} pattern '${this.#J[Y]}'.`)}}}catch(j){throw TypeError(`Failed to construct 'URLPattern': ${j.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test($={},Z){let O={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&Z)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return!1;try{typeof $=="object"?O=TZ(O,$,!1):O=TZ(O,f2($,Z),!1)}catch{return!1}let j;for(j of L2)if(!this.#Z[j].exec(O[j]))return!1;return!0}exec($={},Z){let O={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&Z)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return;try{typeof $=="object"?O=TZ(O,$,!1):O=TZ(O,f2($,Z),!1)}catch{return null}let j={};Z?j.inputs=[$,Z]:j.inputs=[$];let J;for(J of L2){let W=this.#Z[J].exec(O[J]);if(!W)return null;let Y={};for(let[z,X]of this.#O[J].entries())if(typeof X=="string"||typeof X=="number"){let D=W[z+1];Y[X]=D}j[J]={input:O[J]??"",groups:Y}}return j}static compareComponent($,Z,O){let j=f((z,X)=>{for(let D of["type","modifier","prefix","value","suffix"]){if(z[D]<X[D])return-1;if(z[D]===X[D])continue;return 1}return 0},"comparePart"),J=new FZ(3,"","","","",3),W=new FZ(0,"","","","",3),Y=f((z,X)=>{let D=0;for(;D<Math.min(z.length,X.length);++D){let T=j(z[D],X[D]);if(T)return T}return z.length===X.length?0:j(z[D]??J,X[D]??J)},"comparePartList");return!Z.#$[$]&&!O.#$[$]?0:Z.#$[$]&&!O.#$[$]?Y(Z.#W[$],[W]):!Z.#$[$]&&O.#$[$]?Y([W],O.#W[$]):Y(Z.#W[$],O.#W[$])}get protocol(){return this.#$.protocol}get username(){return this.#$.username}get password(){return this.#$.password}get hostname(){return this.#$.hostname}get port(){return this.#$.port}get pathname(){return this.#$.pathname}get search(){return this.#$.search}get hash(){return this.#$.hash}get hasRegExpGroups(){return this.#D}};f(q2,"URLPattern");function U3($,Z){for(let[O,j]of Object.entries($)){let J=new q2({pathname:O});if(J.test({pathname:Z}))return{routePath:O,params:J.exec({pathname:Z})?.pathname.groups??{},route:j}}return null}var C$={startIndex:0,carriedViews:[]};function p9($,Z){let O=Y0($.path,Z);return O.includes("*")?null:O}function kT($,Z){if(!$)return C$;if($.search!==Z.search)return C$;let O=Math.min($.segments.length,Z.segments.length-1),j=0;while(j<O){let J=$.segments[j],W=Z.segments[j];if(W.alwaysRun)break;if(J.viewPath!==W.viewPath)break;let Y=p9(J,$.params),z=p9(W,Z.params);if(Y===null||z===null||Y!==z)break;j++}if(j===0)return C$;return{startIndex:j,carriedViews:Z.segments.slice(0,j).map(({viewPath:J})=>J)}}function qT($,Z){let[,O,...j]=$.split("/");if(!Z.includes(O))return $;let J=`/${j.join("/")}`;return J==="/"?"/":J.replace(/\/$/,"")}function h9($){let{flatViewRoutes:Z,supportedLocales:O,from:j,origin:J,to:W}=$;if(!j)return C$;let Y;try{Y=new URL(j,J)}catch{return C$}if(Y.origin!==J)return C$;let z=U3(Z,qT(Y.pathname,O));if(!z)return C$;return kT({segments:z.route.segments,params:z.params,search:Y.search},W)}var g2="x-gemi-from";import{createElement as CZ,Fragment as WG}from"react";function gT($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function oO($){let Z={};for(let[O,j]of Object.entries($))if("run"in j){let J=j.viewPath;if("children"in j){Z[O]=[J];let W=new j.children,Y=oO(W.routes);for(let[z,X]of Object.entries(Y)){let D=O==="/"?z:`${O}${z}`,T=z==="/"&&O!=="/"?O:D;Z[T]=[J,...X]}if(Z[O].length===1)delete Z[O]}else Z[O]=[J]}else{let J=new j,W=oO(J.routes);for(let[Y,z]of Object.entries(W)){let X=O==="/"?Y:`${O}${Y}`,D=Y==="/"&&O!=="/"?O:X;Z[D]=z}}return Object.fromEntries(Object.entries(Z).map(([O,j])=>[gT(O),j]))}function rO($){let Z=[];for(let[O,j]of Object.entries($))if("run"in j){let J=j.viewPath;if(J==="__")continue;if(J==="REDIRECT")continue;if(J==="FILE")continue;if("children"in j){let W=new j.children,Y=rO(W.routes);Z.push([J,Y])}else Z.push([J,[]])}else{let J=new j,W=rO(J.routes);Z.push(...W)}return Z}function y2($){let Z=[];for(let[O,j]of $)Z.push(O,...y2(j).flat());return Array.from(new Set(Z))}class u1 extends V0{static getFacadeAccessor(){return n}static getSupportedLocales(){return this.getFacadeRoot().supportedLocales}static getDefaultLocale(){return this.getFacadeRoot().defaultLocale}static locale(){let $=this.getFacadeRoot(),Z=H.getStore();if(Z)return Z.locale??$.detectLocale(Z.req);return $.defaultLocale}static timeZone(){return this.getFacadeRoot().detectTimeZone(H.getStore()?.req)}static formatter($={}){return this.getFacadeRoot().formatter($.locale??u1.locale(),$.timeZone??u1.timeZone())}static setLocale($=u1.locale()){let Z=this.getFacadeRoot(),O=$;if(!Z.supportedLocales.includes($))O=Z.defaultLocale;let j=H.getStore();return j.setCookie("i18n-locale",O,{expires:new Date(Date.now()+31536000000),secure:!1,httpOnly:!1}),j.setLocale(O),O}}class m2{id;static token="kernel.id";constructor($=crypto.randomUUID()){this.id=$}}var yT=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),mT=new Set(["svg","math"]);function c9($){return $===32||$===9||$===10||$===12||$===13}function l9($){return $>=65&&$<=90||$>=97&&$<=122}function tO($){return $>=65&&$<=90?$+32:$}function d9(){let $="data",Z="",O=!1,j="",J=0,W=0,Y=!1,z=0,X=0,D=()=>$==="data"&&z===0&&X===0,T=()=>{if(!O&&yT.has(Z)){$="rawText",j=`</${Z}`,J=0,Z="";return}if($="data",Z==="template")if(O)z=Math.max(0,z-1);else z+=1;else if(mT.has(Z)){if(O)X=Math.max(0,X-1);else if(!Y)X+=1}Z=""},F=(G)=>{switch($){case"data":if(G===60)$="tagOpen";return;case"tagOpen":if(G===33)$="bang",W=0;else if(G===47)$="endTagOpen";else if(l9(G))$="tagName",O=!1,Y=!1,Z=String.fromCharCode(tO(G));else if(G===63)$="bogus";else if(G===60)$="tagOpen";else $="data";return;case"endTagOpen":if(l9(G))$="tagName",O=!0,Y=!1,Z=String.fromCharCode(tO(G));else if(G===62)$="data";else $="bogus";return;case"tagName":if(c9(G)||G===47)$="inTag",Y=G===47;else if(G===62)T();else Z+=String.fromCharCode(tO(G));return;case"inTag":if(G===62){T();return}if(Y=G===47,G===34)$="attrDouble";else if(G===39)$="attrSingle";return;case"attrDouble":if(G===34)$="inTag";Y=!1;return;case"attrSingle":if(G===39)$="inTag";Y=!1;return;case"bang":if(G===45){if(W+=1,W===2)$="comment",W=0}else if(G===62)$="data";else $="bogus";return;case"bogus":if(G===62)$="data";return;case"comment":if(G===45)W=W<2?W+1:2;else if(G===62&&W>=2)$="data",W=0;else W=0;return;case"rawText":{if(J<j.length){if(tO(G)===j.charCodeAt(J))J+=1;else J=G===60?1:0;return}if(G===62)$="data",Z="";else if(c9(G)||G===47)$="inTag",Z="";else J=G===60?1:0;return}}};return{scanToInsertionPoint(G){for(let U=0;U<G.length;U++){if(D())return U;F(G[U])}return G.length},write(G){for(let U=0;U<G.length;U++)F(G[U])},isSafe:D}}function M$($){let Z=JSON.stringify($);if(Z===void 0)return"undefined";return Z.replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function pT($){return`<script>(self.__GEMI_STREAM__=self.__GEMI_STREAM__||[]).push(${M$([$.path,$.variantKey,$.data])})</script>`}function hT($){return`<script>(self.__GEMI_DICT__=self.__GEMI_DICT__||[]).push(${M$([$.id,$.locale,$.strings])})</script>`}function p2($,Z,O={},j){let J=new TextEncoder,W=[],Y=!1,z=!1,X=()=>{if(z)return;z=!0,O.onClose?.()};Z.onSettle((K)=>{if(K.status!=="resolved")return;W.push(pT(K))}),j?.onUse((K)=>{W.push(hT(K))});let D=$.getReader(),T=d9(),F=(K,Q)=>{K.enqueue(Q),O.onChunk?.(Q)},G=(K)=>{while(W.length>0){let Q=J.encode(W.shift());T.write(Q),F(K,Q)}},U=(K,Q)=>{if(W.length===0){T.write(Q),F(K,Q);return}let B=T.scanToInsertionPoint(Q);if(B>0)F(K,Q.subarray(0,B));if(T.isSafe())G(K);let M=Q.subarray(B);if(M.length>0)T.write(M),F(K,M)};return new ReadableStream({async pull(K){let Q;try{Q=await D.read()}catch(L){throw X(),L}let{done:B,value:M}=Q;if(B){G(K),K.close(),X();return}if(!Y){if(Y=!0,T.write(M),F(K,M),O.onShell?.(),T.isSafe())G(K);return}U(K,M)},cancel(K){return X(),D.cancel(K)}})}var cT=/bot|crawler|spider|crawling|slurp|bingpreview|mediapartners|headless|lighthouse|prerender|facebookexternalhit|whatsapp|telegram|discord|twitterbot|linkedinbot/i;function eO($){if(!$)return!1;return cT.test($)}async function u9($,Z=()=>{}){let O=H.getStore(),j=O?.req??null,J=null;if(j?.rawRequest?.url)try{J=new URL(j.rawRequest.url).pathname}catch{J=null}return{user:O?.user??null,attributes:await lT($,Z),request:{path:J,routePath:j?.routePath??null,locale:O?.locale??null},anonymousId:i9(),isBot:eO(j?.rawRequest?.headers?.get("user-agent")??null),now:new Date}}function s9($){return{user:$.user??null,attributes:$.attributes??{},request:{path:null,routePath:null,locale:null},anonymousId:$.subjectId??null,isBot:!1,now:new Date}}async function lT($,Z){if(!$.context)return{};try{let O=H.getStore();return await $.context(O?.req??null)??{}}catch(O){return Z(`The \`context\` hook in app/config/features.ts threw; evaluating with no attributes. ${O instanceof Error?O.message:String(O)}`),{}}}function n9($,Z){return`${$}:${Z}`}function h2($){let Z=new Bun.CryptoHasher("sha1").update($).digest("hex"),O=Number.parseInt(Z.slice(0,8),16);return Math.floor(O/4294967296*1e4)}function a9($,Z){if(Z>=100)return!0;if(Z<=0)return!1;return $<Math.round(Z*100)}function o9($,Z,O,j){if(j.unavailable)return{value:!1,reason:"unavailable"};if(j.active!==!0)return{value:!1,reason:"inactive"};if(Z.when){let W;try{W=Z.when(O)}catch(Y){return j.warn?.(`The \`when\` for feature "${$}" threw; treating it as off. ${Y instanceof Error?Y.message:String(Y)}`),{value:!1,reason:"error"}}if(typeof W==="boolean")return{value:W,reason:"attributed"}}if(Z.rollout===void 0)return{value:!0,reason:"on"};if(O.isBot)return{value:!1,reason:"bot"};let J=iT($,Z,O,j.buckets);return a9(J,Z.rollout)?{value:!0,reason:"rollout"}:{value:!1,reason:"excluded"}}function dT($){let Z=$.user?.publicId??$.user?.id;if(Z!==void 0&&Z!==null)return String(Z);return $.anonymousId??""}function iT($,Z,O,j){let J=n9(Z.salt??$,dT(O));if(!j)return h2(J);let W=j.get(J);if(W!==void 0)return W;let Y=h2(J);return j.set(J,Y),Y}class r9 extends Error{cause;kind="FeatureReloadFailed";constructor($){super(`Could not reload feature switches after a write, so the cached switches may still predate it: ${$ instanceof Error?$.message:String($)}`);this.cause=$}}class c2{source;declared;ttlMs;warn;snapshot=null;inflight=null;lastFailureLoggedAt=0;generation=0;lastError=null;retryAfter=0;constructor($,Z,O,j=()=>{}){this.source=$;this.declared=Z;this.ttlMs=O;this.warn=j}async get(){let $=this.snapshot;if($&&Date.now()-$.loadedAt<this.ttlMs)return $;if($){if(Date.now()>=this.retryAfter)this.refresh().catch(()=>{});return $}return await this.refresh()}refresh(){return this.inflight??=this.load().finally(()=>{this.inflight=null}),this.inflight}async invalidate(){await this.inflight?.catch(()=>{});let $=this.generation,Z=await this.refresh();if(this.generation===$)throw new r9(this.lastError);return Z}peek(){return this.snapshot}async load(){try{let $=await this.source.load(),{active:Z,audit:O}=this.readRows($);return this.snapshot={active:Z,audit:O,loadedAt:Date.now(),unavailable:!1},this.generation++,this.lastError=null,this.retryAfter=0,this.snapshot}catch($){return this.handleFailure($)}}readRows($){let Z=new Map,O=new Map;for(let j of $??[]){let J=typeof j?.key==="string"?j.key:null;if(!J){this.warn("Ignoring a feature row with no `key`.");continue}if(!(J in this.declared)){this.warn(`Feature row "${J}" is not declared in app/features, so it is ignored. Delete the row, or declare the feature.`);continue}Z.set(J,j.active===!0);let W=uT(j);if(W)O.set(J,W)}return{active:Z,audit:O}}handleFailure($){let Z=$ instanceof Error?$.message:String($),O=Date.now();if(this.lastError=$,this.retryAfter=O+this.ttlMs,O-this.lastFailureLoggedAt>=this.ttlMs)this.lastFailureLoggedAt=O,this.warn(`Could not load feature switches: ${Z}`);if(this.snapshot)return this.snapshot;return this.snapshot={active:new Map,audit:new Map,loadedAt:O,unavailable:!0},this.snapshot}}function uT($){let Z={},O=$.updatedBy;if(typeof O==="string")Z.updatedBy=O;else if(O===null)Z.updatedBy=null;let j=$.updatedAt;if(j instanceof Date||typeof j==="string"||typeof j==="number"){let J=j instanceof Date?j:new Date(j);if(!Number.isNaN(J.getTime()))Z.updatedAt=J}return"updatedBy"in Z||"updatedAt"in Z?Z:null}class sT{}class nT extends Error{modelName;kind="FeatureModelMissing";constructor($){super(`No "${$}" model is registered, so every feature stays off. Add the model to prisma/schema.prisma and export it from app/models \u2014 see docs/feature-flags.md.`);this.modelName=$}}class l2 extends Error{sourceName;kind="FeatureSourceReadOnly";constructor($){super(`The feature source (${$}) is read-only, so Features.set() cannot write to it. Change the switch where that source reads from, or give the source a write() method.`);this.sourceName=$}}class t9 extends Error{key;kind="UndeclaredFeature";constructor($){super(`"${$}" is not declared in app/features, so it cannot be switched. A row for it would be ignored \u2014 declare the feature first.`);this.key=$}}class e9{manager;ctx;constructor($,Z){this.manager=$;this.ctx=Z}async enabled($){return(await this.explain($)).value}async explain($){return await this.manager.evaluateIn($,this.ctx,new Map)}async all(){return await this.manager.evaluateAllIn(this.ctx,new Map,{clientOnly:!1})}}class UZ{config;log;static token="features";store;declared;warnedAboutSize=!1;warnedAboutActor=!1;constructor($,Z=()=>{}){this.config=$;this.log=Z;this.declared=$.features??{},this.store=new c2($.source,this.declared,Math.max(0,$.ttl)*1000,this.log)}declarations(){return this.declared}async list(){let{active:$,audit:Z,unavailable:O}=await this.switches();return{unavailable:O,features:Object.entries(this.declared).map(([j,J])=>({key:j,describe:J.describe,rollout:J.rollout,targeted:J.when!==void 0,serverOnly:J.serverOnly,salt:J.salt,active:$.get(j),...Z.get(j)}))}}async refresh(){if(!this.config.enabled)return;if(Object.keys(this.declared).length===0)return;await this.store.refresh()}async invalidate(){try{if(this.config.enabled&&Object.keys(this.declared).length>0)await this.store.invalidate()}finally{H.getStore()?.featureEvaluations?.clear()}}async set($,Z,O={}){if(typeof $!=="string"||!Object.hasOwn(this.declared,$))throw new t9(String($));if(typeof Z!=="boolean")throw TypeError(`Features.set("${$}", \u2026) takes a boolean, not ${Z===null?"null":typeof Z}.`);let j=aT(O.actor),J=this.config.source;if(typeof J.write!=="function")throw new l2(J.constructor?.name||"an anonymous source");let{actorRecorded:W}=await J.write($,Z,{actor:j});if(j!==null&&!W&&!this.warnedAboutActor)this.warnedAboutActor=!0,this.log('Features.set() was given an actor, but the feature source has nowhere to record it. For the database source, add a nullable `updatedBy String?` column to the feature flag model to keep "last changed by".');await this.invalidate()}async enabled($){return(await this.explain($)).value}async explain($){let Z=await this.requestContext();return await this.evaluateIn($,Z,this.requestBuckets())}async all(){let $=await this.requestContext();return await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!1})}async forClient(){if(!this.config.enabled)return{};let $=await this.requestContext(),Z=await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!0});return this.warnIfOversized(Object.keys(Z).length),Z}for($){return new e9(this,s9($))}async evaluateIn($,Z,O){let j=this.memoFor(Z),J=j?.get($);if(J)return J;let W=this.declared[$];if(!W)return{value:!1,reason:"undeclared"};let{active:Y,unavailable:z}=await this.switchFor($),X=o9($,W,Z,{active:Y,unavailable:z,buckets:O,warn:this.log});return j?.set($,X),this.notify($,X,Z),X}async evaluateAllIn($,Z,O){let j={};for(let[J,W]of Object.entries(this.declared)){if(O.clientOnly&&W.serverOnly)continue;j[J]=(await this.evaluateIn(J,$,Z)).value}return j}async switches(){if(!this.config.enabled||Object.keys(this.declared).length===0)return{active:new Map,audit:new Map,unavailable:!1};let $=await this.store.get();return{active:$.active,audit:$.audit,unavailable:$.unavailable}}async switchFor($){if(!this.config.enabled)return{active:!1,unavailable:!1};let Z=await this.store.get();return{active:Z.active.get($),unavailable:Z.unavailable}}async requestContext(){let $=H.getStore();if($?.featureContext)return $.featureContext;let Z=await u9(this.config,this.log);if($)$.featureContext=Z;return Z}memoFor($){let Z=H.getStore();if(!Z||Z.featureContext!==$)return null;return Z.featureEvaluations??=new Map,Z.featureEvaluations}requestBuckets(){let $=H.getStore();if(!$)return new Map;return $.featureBuckets??=new Map,$.featureBuckets}notify($,Z,O){if(!this.config.onEvaluate)return;try{this.config.onEvaluate($,Z,O)}catch(j){this.log(`The \`onEvaluate\` hook in app/config/features.ts threw for "${$}". ${j instanceof Error?j.message:String(j)}`)}}warnIfOversized($){if(this.warnedAboutSize||$<=this.config.maxClientFlags)return;this.warnedAboutSize=!0,this.log(`${$} client-visible features are embedded in every document. Mark the ones only the server reads with \`serverOnly: true\` to keep them out of the payload.`)}}function aT($){if($===void 0||$===null)return null;if(typeof $==="string"){if($.length>0)return $}else if(typeof $==="object"){let{publicId:Z,id:O}=$;if(typeof Z==="string"&&Z.length>0)return Z;if(typeof O==="string"&&O.length>0||typeof O==="number")return String(O)}throw TypeError("Features.set() was given an `actor` that identifies nobody. Pass a string, or a user with a `publicId` or an `id`.")}function $5($){return Object.fromEntries(Object.entries($).filter(([,Z])=>{return Z!==null&&Z!==void 0}))}var oT=50;class KZ{fetcher;entries=new Map;settleListener=null;failListener=null;shellAt=null;settledBacklog=[];shipped=new Set;requestStartedAt=performance.now();renderStartedAt=null;discoveryHintsMuted=!1;constructor($){this.fetcher=$}elapsed(){return Math.round(performance.now()-this.requestStartedAt)}keyFor($,Z){return[$,Z].filter((O)=>O.length>0).join("?")}markRenderStart(){if(this.renderStartedAt===null)this.renderStartedAt=performance.now()}markShell(){if(this.shellAt===null)this.shellAt=this.elapsed()}summarize($){let Z=this.elapsed();return{shellAt:this.shellAt??Z,settledAt:Z,aborted:$,queries:Array.from(this.entries.values(),(O)=>({path:O.path,variantKey:O.variantKey,startedAt:O.startedAt,settledAt:O.settledAt,status:O.status,source:O.source}))}}onQueryFail($){this.failListener=$}muteDiscoveryHints(){this.discoveryHintsMuted=!0}maybeLogLateDiscovery($){if(!$.lateBy||this.discoveryHintsMuted)return;if($.status!=="resolved")return;if(Bun.env.NODE_ENV==="production")return;let Z="";try{let J=JSON.stringify($.data)?.length??0;Z=J>=1024?`${(J/1024).toFixed(1)} kB`:`${J} B`}catch{Z="an unserializable payload"}let O=($.settledAt??0)-$.startedAt,j=$.variantKey?`, { search: ${JSON.stringify(Object.fromEntries(new URLSearchParams($.variantKey)))} }`:"";console.warn(`[gemi] useQuery("${$.patternPath}") was discovered ${$.lateBy}ms into the `+`server render \u2014 under a suspended segment, so its fetch (${O}ms, resolved ${Z}) could not overlap the others. It still streamed. If the query belongs on this route, \`Query.prefetch("${$.patternPath}"${j})\` in the view `+"handler starts it at request time \u2014 but note prefetched data is also re-fetched and "+`streamed into every client-side navigation payload for the route, even when the client already holds it, so weigh that bandwidth against the ${Z}. If the data is only needed conditionally (a closed popover, a hidden tab), \`{ lazy: true }\` + \`trigger()\` avoids running it here at all. \`Query.noPrefetch()\` in the handler marks the omission intentional and silences this hint for the route.`)}read($,Z){return this.entries.get(this.keyFor($,Z))}ensure($,Z={},O="render"){let j=Z.params??{},J=new URLSearchParams($5(Z.search??{}));J.delete("json"),J.sort();let W=Y0($,j),Y=J.toString(),z=this.keyFor(W,Y),X=this.entries.get(z);if(X)return X;let D;if(O==="render"&&this.renderStartedAt!==null){let U=Math.round(performance.now()-this.renderStartedAt);if(U>oT)D=U}let T,F=new Promise((U)=>{T=U}),G={path:W,patternPath:$,variantKey:Y,lateBy:D,status:"pending",promise:F,source:O,startedAt:this.elapsed()};return this.entries.set(z,G),this.fetcher($,j,J).then((U)=>{G.status="resolved",G.data=U},(U)=>{G.status="rejected",G.error=U}).then(()=>{if(G.settledAt=this.elapsed(),this.maybeLogLateDiscovery(G),G.status==="rejected"&&this.failListener)this.failListener(G);if(this.settleListener)this.settleListener(G);else this.settledBacklog.push(G);T()}),G}async allSettled(){let $=0;while($!==this.entries.size)$=this.entries.size,await Promise.all(Array.from(this.entries.values(),(Z)=>Z.promise))}snapshotResolved(){let $={};for(let[Z,O]of this.entries){if(O.status!=="resolved")continue;this.shipped.add(Z),$[O.path]??={},$[O.path][O.variantKey]=O.data}return $}onSettle($){this.settleListener=(O)=>{if(this.shipped.has(this.keyFor(O.path,O.variantKey)))return;$(O)};let Z=this.settledBacklog;this.settledBacklog=[];for(let O of Z)this.settleListener(O)}}class s1 extends Error{path;variantKey;status;body;retryAfter;constructor($,Z,O,j,J){super(typeof j?.message==="string"?j.message:`Request to /api${$} failed with status ${O}`);this.path=$;this.variantKey=Z;this.status=O;this.body=j;this.retryAfter=J;this.name="QueryError"}}function QZ(){let $=JSON.stringify({error:f1("permission","Forbidden",403)});return new Response($,{status:403,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}function d2(){return{status:403,error:{message:"Forbidden"}}}function K3($){let Z=BZ.getStore();return(O,j,J)=>{let W=new URL($.url).origin,Y=[Y0(O,j),J.toString()].filter((T)=>T.length>0).join("?"),z=new Request(`${W}/${Y}`,{headers:$.headers,signal:$.signal}),X=Z5($);if(X)VZ(z,X);let D=new A(z,j);return BZ.run(Z,()=>H.run(D,async()=>{try{let T=await N(o0).dispatchers(X).api.getRouteData(O);if(H$(T)){if(!T.ok)throw new s1(Y0(O,j),J.toString(),T.status,T.body);return T.body}if(T instanceof Response){let F=await T.json().catch(()=>null);if(!T.ok)throw new s1(Y0(O,j),J.toString(),T.status,F);return F}return T}catch(T){if(T instanceof s1)throw T;let F=new s1(Y0(O,j),J.toString(),500,{message:T instanceof Error?T.message:String(T)});throw F.cause=T,F}}))}}var rT=new Set(["script","style","template","title"]),tT=/\shidden([\s=/]|$)/i,eT=/"[^"]*"|'[^']*'/g;function $G($){let Z=0,O=0,j=0,J=0;while(J<$.length){let W=$.indexOf("<",J),Y=W===-1?$.length:W;if(Y>J){let F=$.slice(J,Y).replace(/\s+/g,"").length;if(j>0)O+=F;else Z+=F}if(W===-1)break;if($.startsWith("<!--",W)){let F=$.indexOf("-->",W+4);J=F===-1?$.length:F+3;continue}let z=$.indexOf(">",W);if(z===-1)break;let X=$.slice(W+1,z);J=z+1;let D=/^\/?([a-zA-Z][a-zA-Z0-9-]*)/.exec(X)?.[1]?.toLowerCase();if(!D)continue;let T=X.startsWith("/");if(!T&&rT.has(D)&&!X.endsWith("/")){let F=$.indexOf(`</${D}`,J);J=F===-1?$.length:F;continue}if(D!=="div")continue;if(T){if(j>0)j-=1}else if(j>0)j+=1;else if(tT.test(X.replace(eT,'""')))j=1}return{shellChars:Z,deferredChars:O}}var ZG=1000,OG=64;function jG($){return $>=1000?`${($/1000).toFixed(1)} kB`:`${$} chars`}function JG($,Z){if(Z.deferredChars<ZG)return null;if(Z.shellChars>=OG)return null;return`[gemi] GET ${$} streams ${jG(Z.deferredChars)} of its `+`content behind reveal scripts \u2014 a no-JS visitor sees ~${Z.shellChars} chars. If this is a public/content route, add "no-stream" to its middleware.`}function O5($=console.warn){let Z=new Set;return{shouldObserve(O){return!Z.has(O)},report(O,j){if(Z.has(O))return;let J=JG(O,j);if(!J)return;Z.add(O),$(J)}}}function j5(){let $=new TextDecoder,Z="";return{onChunk(O){Z+=$.decode(O,{stream:!0})},measure(){return Z+=$.decode(),$G(Z)}}}function J5($,Z,O=1e4,j){let J=new TextEncoder,W=()=>{};return new ReadableStream({start(Y){let z=!1,X=(T)=>{if(z)return;z=!0,clearTimeout(D);try{Y.close()}catch{}j?.({aborted:T})};W=X,Y.enqueue(J.encode(`${JSON.stringify($)}
3
+ `)),Z.onSettle((T)=>{if(z||T.status!=="resolved")return;Y.enqueue(J.encode(`${JSON.stringify([T.path,T.variantKey,T.data])}
4
+ `))});let D=setTimeout(()=>X(!0),O);Z.allSettled().then(()=>X(!1),()=>X(!1))},cancel(){W(!1)}})}var YG=async()=>(await import("./chunk-wedwkqe7.js")).default,i2,u2=async(...$)=>{return i2??=import("react-dom/server.browser").catch((Z)=>{throw i2=void 0,Z}),(await i2).renderToReadableStream(...$)},zG=1e4,XG=`
5
+ !function(){try{var d=document.documentElement,c=d.classList;
6
+ c.remove('light','dark');
7
+ var e=localStorage.getItem('theme');
8
+ if('system'===e||(!e&&'system'===defaultTheme)){
9
+ var t='(prefers-color-scheme: dark)',m=window.matchMedia(t);
10
+ if(m.media!==t||m.matches){d.style.colorScheme='dark';c.add('dark')}
11
+ else{d.style.colorScheme='light';c.add('light')}
12
+ }else if(e){
13
+ c.add(e||'')
14
+ }}catch(e){}}()
15
+ `;async function DG($,Z,O){let j=`${O==="italic"?"italic,":""}wght@${O==="italic"?"1,":""}${Z}`,Y=(await(await fetch(`https://fonts.googleapis.com/css2?family=${$}:${j}&display=swap`,{headers:{"User-Agent":"Mozilla/5.0 Firefox/1.0"}})).text()).match(/url\(([^)]+)\)/)?.[1];return await fetch(Y).then((z)=>z.arrayBuffer())}var a2="/assets";function TG($){return $===a2||$.startsWith(`${a2}/`)}function GG($){let Z=$.filter(TG);if(Z.length>0){let O=Z.length>1;throw Error(`View route path${O?"s":""} ${Z.map((j)=>`"${j}"`).join(", ")} use${O?"":"s"} the reserved "${a2}" prefix. The client build output is served from there before the router runs, so the route would never match. Mount it somewhere else.`)}}function FG($){let Z=N(o0).resolver;return{...$.domain,root:Z.root,origin:Z.publicOrigin($.rawRequest)}}function s2($){let{status:Z=400,error:O}=$;return new Response(O?.message,{...$,status:Z})}function UG($){let{status:Z=400,data:O,directive:j,headers:J}=$;return new Response(JSON.stringify({data:O,directive:j}),{headers:J,status:Z})}class V3{static token="router.view";flatViewRoutes={};routeManifest={};clientRouteManifest={};componentTree=[];flatComponentTree=[];root=null;shellReporter=O5();preloadCache=new WeakMap;hooks;partialRendering;constructor($){let Z=Q9();this.partialRendering=$.partialRendering??Z.partialRendering,this.hooks={onRequestStart:$.onRequestStart??Z.onRequestStart,onRequestEnd:$.onRequestEnd??Z.onRequestEnd,onRequestFail:$.onRequestFail??Z.onRequestFail,onStreamComplete:$.onStreamComplete??Z.onStreamComplete};let O={"/":$.rootRouter,"/auth":F2};this.flatViewRoutes=nO(O),GG(Object.keys(this.flatViewRoutes)),this.routeManifest=oO(O),this.clientRouteManifest=Object.fromEntries(Object.entries(this.routeManifest).filter(([,j])=>j.at(-1)!=="FILE")),this.componentTree=rO(O),this.flatComponentTree=y2(this.componentTree),this.root=$.root}async passesFeatureGates($){let Z=N(UZ);for(let O of $)if(!await Z.enabled(O))return!1;return!0}async onRequestEnd($){return n2(),await this.hooks.onRequestEnd($)}completeStream($,Z){let O=(j)=>{I$.error(j?.message??'Error in "onStreamComplete" event handler',{err:JSON.stringify(j)})};try{Promise.resolve(this.hooks.onStreamComplete($,Z)).catch(O)}catch(j){O(j)}}modulePreloadLinks($){let{clientEntry:Z,modulePreloadManifest:O,views:j,routeKey:J}=$,W=()=>{let X=new Set(Z?.preload??[]);for(let D of j)for(let T of O?.[D]??[])X.add(T);return[...X].map((D)=>CZ("link",{key:`modulepreload:${D}`,rel:"modulepreload",href:D}))};if(!O)return W();let Y=this.preloadCache.get(O);if(!Y||Y.clientEntry!==Z)Y={clientEntry:Z,byRoute:new Map},this.preloadCache.set(O,Y);let z=Y.byRoute.get(J);if(!z)z=W(),Y.byRoute.set(J,z);return z}async render($){let{req:Z,runInRequestScope:O,csrfTokenHMAC:j,currentPathName:J,headers:W,i18n:Y,params:z,pathname:X,serverQueries:D,userAgent:T,noStream:F,url:G,user:U,viewData:K,breadcrumbs:Q,urlLocaleSegment:B,meta:M,isOgRequest:L,appId:I,features:S}=$,P=X.replace(`/${B}`,""),V={kind:"view",data:{meta:M,pageData:{[P]:K},__csrf:j.toString("base64"),prefetchedData:{},i18n:Y,auth:{user:U},routeManifest:this.clientRouteManifest,breadcrumbs:Q,router:{urlLocaleSegment:B,pathname:J,params:z,currentPath:X,searchParams:G.search,is404:!J?!0:!1,domain:Z.domain?FG(Z):null},appId:I,features:S,componentTree:[["404",[]],...this.componentTree]},head:{}},C=this.root,_=this.routeManifest[J];return async(x)=>{let{bootstrapModules:w=[],loaders:v,getStyles:m,viewImportMap:s,cssManifest:Yj,ogMap:C3,viewModules:M3,clientEntry:r0,modulePreloadManifest:n1,assetBase:L1}=x,W0=r0?[]:w,I3=(t)=>[t,`window.loaders=${v}`,...r0?[`import(${JSON.stringify(r0.module)}).catch(function(e){setTimeout(function(){throw e})})`]:[]].join(";");if(L){let t=null,_$=null;for(let S$ of _??[])if(typeof C3[S$]==="function")_$=S$,t=C3[S$];if(!t)return new Response("Not found",{status:404});let w5=Object.values(V.data.pageData)[0];try{await u2(CZ(t,w5[_$]),{onError:()=>{}})}catch(S$){let{fonts:k5,...q5}=S$.satoriOptions,g5=await Promise.all(k5.map((N3)=>{return DG(N3.name,N3.weight,N3.style).then((c5)=>({...N3,data:c5}))})),j4=new Headers(W);j4.set("Content-Type","image/png");let[y5,m5]=await Promise.all([YG(),uO("Rendering an OG image")]),p5=await y5(S$.jsx,{...q5,fonts:g5}),h5=await m5(Buffer.from(p5)).png({compressionLevel:0,effort:10}).toBuffer();return new Response(new Uint8Array(h5),{headers:j4})}return new Response("data")}if(V.data.cssManifest=Yj,V.data.modulePreloadManifest=n1??{},L1&&L1!=="/")V.data.assetBase=L1;let zj=this.modulePreloadLinks({clientEntry:r0,modulePreloadManifest:n1,views:_??["404"],routeKey:J??"404"}),N$=await m(_);V.data.prefetchedData=D.snapshotResolved(),D.markRenderStart();let X1=new AbortController,NZ=setTimeout(()=>X1.abort(),zG),L$=eO(T)||F,b=Bun.env.NODE_ENV!=="production"&&!L$&&J&&this.shellReporter.shouldObserve(J)?j5():null,k0=z5();try{let t=await u2(CZ(WG,{children:[...zj,...N$,CZ("script",{key:"theme-script",dangerouslySetInnerHTML:{__html:XG}}),CZ(C,{data:V.data,viewImportMap:s,viewModules:M3,serverQueries:D,dictionarySink:k0,key:"root"})]}),{bootstrapScriptContent:I3(`window.__GEMI_DATA__ = ${M$(V.data)}`),bootstrapModules:W0,signal:X1.signal,...L$?{progressiveChunkSize:Number.MAX_SAFE_INTEGER}:{},onError(_$){if(Bun.env.NODE_ENV!=="production")console.error(_$)}});if(t.allReady.catch(()=>{}).finally(()=>clearTimeout(NZ)),L$)await t.allReady.catch(()=>{});return new Response(p2(t,D,{onShell:L$?void 0:()=>D.markShell(),onChunk:b?.onChunk,onClose:()=>O(()=>{if(this.completeStream(Z,D.summarize(X1.signal.aborted)),b)this.shellReporter.report(J,b.measure())})},k0),{status:!J?404:200,headers:W})}catch(t){if(clearTimeout(NZ),Bun.env.NODE_ENV==="production")throw O(()=>this.completeStream(Z,D.summarize(X1.signal.aborted))),t;let _$=await u2(CZ("div"),{bootstrapScriptContent:I3(`window.error= ${M$(t.message)}; window.stack_trace=${M$(t.stack)};window.__GEMI_DATA__ = ${M$(V.data)}`),bootstrapModules:Bun.env.NODE_ENV==="development"?["/render-error.js",...W0]:W0});return new Response(p2(_$,D,{onClose:()=>O(()=>this.completeStream(Z,D.summarize(X1.signal.aborted)))}),{status:!J?404:200,headers:W})}}}async handleViewRequest($,Z){let O=new URL($.url),j=O.pathname.endsWith(".json"),J=O.pathname.endsWith(".og"),W=O.pathname.replace(".json","").replace(".og",""),[,Y,...z]=W.split("/"),X=`/${z.join("/")}`,D=null,T=null,F=N(n);if(!F.supportedLocales.includes(Y))X=W;else D=Y,T=Y;let U=T===null&&U3(this.flatViewRoutes,X)!==null;if(F.isLocaleAware&&!J&&T===null&&!U){let V=W5(Y,F.supportedLocales,F.defaultLocale);if(V){let C=z.length?`/${z.join("/")}`:"";return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${V}${C}${j?".json":""}${O.search}`}})}}if(F.isLocaleAware&&!J){let V=N(n).detectLocale(new A($,{},"view",X));if(T===null&&V!==F.defaultLocale){let C=O.pathname==="/"?"":O.pathname;return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${V}${C}${O.search}`}})}}X=X.replace("//","/");let K=[],Q=[],B=null,M={},L=null,I=!1,S=[];try{let V=U3(this.flatViewRoutes,X);if(V){if(B=V.routePath,M=V.params,K=V.route.exec,Q=V.route.middleware,S=V.route.features,I=Q.includes("no-stream"),j&&this.partialRendering){let C=$.headers.get(g2),_=h9({flatViewRoutes:this.flatViewRoutes,supportedLocales:N(n).supportedLocales,from:C,origin:O.origin,to:{segments:V.route.segments,params:M,search:O.search}});if(_.startIndex>0)K=K.slice(_.startIndex),L={from:C,carriedViews:_.carriedViews}}}}catch(V){throw V}let P=new A($,M,"view",B);return this.hooks.onRequestStart(P),await H.run(P,async()=>{let V=null,C=H.getStore(),_=BZ.getStore(),x=(m)=>BZ.run(_,()=>H.runWith(C,m));C.serverQueries=new KZ(K3($));let w=new Set;if(C.serverQueries.onQueryFail((m)=>{w.add(m.error);try{x(()=>Promise.resolve(this.hooks.onRequestFail(v,m.error)).catch(()=>{}))}catch{}}),T){let m=T.replaceAll("/","");u1.setLocale(m)}else u1.setLocale();let v=C.req;n2();try{let m=!1;try{await N(DZ).runMiddleware(Q)}catch(b){if(!MZ(b))throw b;m=!0}if(m||S.length>0&&!await this.passesFeatureGates(S))B=null,K=[],v.routePath="";let s=N(n),Yj=s.isEnabled,C3=s.isLocaleAware,M3=new A($,v.params),r0={defaultLocale:s.defaultLocale,timeZone:s.detectTimeZone(M3)};if(C3){let b=null;if(T)b=T.replaceAll("/",""),C.setLocale(b);else b=s.detectLocale(M3),C.setLocale(b);let k0=Yj?s.getPageTranslations(b,v.routePath):{};r0={...r0,supportedLocales:s.supportedLocales,currentLocale:b,dictionary:{[b]:k0},defaultLocale:s.defaultLocale}}await Y5(r0.currentLocale??"");let n1;try{n1=await Promise.all(K.map((b)=>b(v)))}catch(b){if(!MZ(b))throw b;B=null,K=[],v.routePath="",n1=[]}let{cookies:L1,headers:W0}=C;V={data:n1,cookies:L1,headers:W0,user:C.user,prefetchedData:C.serverQueries.snapshotResolved(),currentPathName:B,params:v.params,urlLocaleSegment:D,meta:C.renderMeta(),appId:N(m2).id,features:await N(UZ).forClient()};let{params:I3,user:zj}=V,N$={},X1={};for(let b of n1??[]){let[k0,t]=Object.entries(b)?.[0]??[];if(!k0||!t)continue;X1[`${k0}:${B}`]=t.breadcrumb,N$[k0]=t}let NZ=N$.FILE;if(NZ){for(let b of L1)W0.append("Set-Cookie",b.toString());try{await this.onRequestEnd(v)}catch(b){I$.error(b?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(b)})}return await Mj(NZ,W0)}if(j){W0.set("Content-Type","application/x-ndjson; charset=utf-8"),W0.append("Vary",g2),L1.forEach((k0)=>W0.append("Set-Cookie",k0.toString())),await this.hooks.onRequestEnd(v);let b={meta:L&&!C.metadata.touched?null:V.meta,data:{[X]:N$},breadcrumbs:X1,prefetchedData:C.serverQueries.snapshotResolved(),i18n:r0,features:V.features,is404:!B,appId:V.appId,partial:L};return new Response(J5(b,C.serverQueries,void 0,({aborted:k0})=>x(()=>this.completeStream(v,C.serverQueries.summarize(k0)))),{headers:W0})}if(W0.set("Content-Type","text/html; charset=utf-8"),!I)W0.append("Vary","User-Agent");for(let b of L1)W0.append("Set-Cookie",b.toString());let L$=Bun.CSRF.generate(process.env.SECRET);W0.append("Set-Cookie",`csrf_token=${L$}; HttpOnly; Secure; SameSite=Strict; Expires=${new Date(Date.now()+86400000).toUTCString()}`);try{await this.onRequestEnd(v)}catch(b){I$.error(b?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(b)})}return await this.render({req:v,runInRequestScope:x,csrfTokenHMAC:Buffer.from(""),currentPathName:B,headers:W0,i18n:r0,params:I3,pathname:O.pathname,serverQueries:C.serverQueries,userAgent:$.headers.get("user-agent"),noStream:I,url:O,user:zj,viewData:N$,breadcrumbs:X1,urlLocaleSegment:D,meta:V.meta,appId:V.appId,features:V.features,isOgRequest:J})}catch(m){if(m.kind===Q3)if(j)return UG(m.payload.viewData??m.payload.api);else return s2(m.payload.view);if(!w.has(m))this.hooks.onRequestFail(v,m);if(B3(m))return console.error(m),j?QZ():s2(d2());if(m instanceof s1&&m.status===403)return j?QZ():s2(d2());throw m}},Z)}}function r2(){let $=JSON.stringify({error:f1("not_found","Not found",404)});return new Response($,{status:404,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}class U5 extends H0{routes={"/api-routes":this.get(()=>{let $=N($j).flatRoutes,Z=[];for(let[O,j]of Object.entries($))for(let[J,W]of Object.entries(j)){let{exec:Y,middleware:z}=W;Z.push({path:O,method:J,middleware:z})}return Z}),"/view-routes":this.get(()=>{let $=N(V3).flatViewRoutes,Z=[];for(let[O,{middleware:j,viewPath:J}]of Object.entries($))Z.push({path:O,method:"GET",viewPath:J,middleware:j});return Z})}}var KG=new Set([S1,"cookie","content-type","content-length","transfer-encoding","connection","host","user-agent","forwarded"]),QG=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,BG=/^[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]*$/;function VG($,Z,O){for(let[j,J]of Object.entries(O.headers??{})){if(J===void 0||J===null)continue;let W=j.toLowerCase();if(KG.has(W)||W.startsWith("x-forwarded-"))throw Error(`dispatchAs: credentials may not set the "${j}" header. The access token stays the initiator's, and the request's framing is dispatchAs's own.`);$.set(j,J)}for(let[j,J]of Object.entries(O.cookies??{})){if(J===void 0||J===null)continue;if(j===S1)throw Error(`dispatchAs: credentials may not set the "${S1}" cookie. The access token stays the initiator's.`);if(!QG.test(j)||!BG.test(J))throw Error(`dispatchAs: "${j}" is not a cookie a Cookie header can carry.`);Z.push(`${j}=${J}`)}}function CG($,Z){let O=$.body.getReader(),j=!1,J=()=>{if(j)return;j=!0;try{Z()}catch(Y){console.error(Y)}},W=new ReadableStream({async pull(Y){let z;try{z=await O.read()}catch(X){J(),Y.error(X);return}if(z.done){J();try{Y.close()}catch{}return}try{Y.enqueue(z.value)}catch{}},async cancel(Y){try{await O.cancel(Y)}finally{J()}}},{highWaterMark:0});return new Response(W,{status:$.status,statusText:$.statusText,headers:$.headers})}function X5($){let{status:Z=400,data:O,headers:j}=$,J=new Headers({"Content-Type":"application/json",...j});if(!J.has("Cache-Control"))J.set("Cache-Control","no-store");return new Response(JSON.stringify(O),{status:Z,headers:J})}function D5($,Z,O){let j=[];Z?.forEach((Y,z)=>j.push([z,Y]));let J=[...typeof Z?.getSetCookie==="function"?Z.getSetCookie():[],...Array.from(O??[])];if(j.length===0&&J.length===0)return $;let W=(Y)=>{for(let[z,X]of j){if(z.toLowerCase()==="set-cookie")continue;if(!Y.has(z))Y.set(z,X)}for(let z of J)Y.append("Set-Cookie",z)};try{return W($.headers),$}catch{let Y=new Headers($.headers);return W(Y),new Response($.body,{status:$.status,statusText:$.statusText,headers:Y})}}class $j{static token="router.api";flatRoutes={};onRequestStart;onRequestEnd;onRequestFail;constructor($){let Z=K9();this.onRequestStart=$.onRequestStart??Z.onRequestStart,this.onRequestEnd=$.onRequestEnd??Z.onRequestEnd,this.onRequestFail=$.onRequestFail??Z.onRequestFail,this.flatRoutes=M2({"/":$.rootRouter,"/auth":U2,"/__gemi__/services/i18n":K2,"/__gemi__/services/logs":C2,"/__gemi__/services/image":V2,"/__gemi__/debug":U5})}getRouteHandlerAndParams($){let Z=new URL($.url),O=F5(Z.pathname),j={},J;for(let[W]of Object.entries(this.flatRoutes))try{let Y=new URLPattern({pathname:W});if(Y.test({pathname:O})){J=W,j=Y.exec({pathname:O})?.pathname.groups;break}}catch(Y){console.error(Y)}return{params:j,path:J}}async runRouteMiddleware($,Z){let j=this.flatRoutes[$][Z.rawRequest.method].middleware;try{await N(DZ).runMiddleware(j)}catch(J){if(J.kind===Q3)return X5(J.payload.api);else{if(MZ(J))return r2();if(this.onRequestFail(Z,J),console.error(J),B3(J))return QZ();throw J}}}async getRouteData($){let Z=this.flatRoutes[$],O=H.getStore(),j=Z[O.req.rawRequest.method].exec??(()=>Promise.resolve({})),J={};try{J=await j()}catch(W){if(W.kind===Q3)return X5(W.payload.api);if(MZ(W))return r2();if(this.onRequestFail(O.req,W),console.error(W),B3(W))return QZ();throw W}return J}isFrameworkRoute($){return $.startsWith("/__gemi__")}async endRequest($,Z,O){let j=async()=>{try{if(!this.isFrameworkRoute(O))await this.onRequestEnd(Z)}catch(J){I$.error(J?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(J)})}finally{$.destroy()}};if(!$.hasPendingWork()){await j();return}$.whenIdle().then(j).catch((J)=>{console.error(J)})}isOpenEndedBody($,Z){return $.method!=="HEAD"&&!Z.headers.has("Content-Length")&&Z.body!==null}async handleApiRequest($,Z){let{params:O,path:j}=this.getRouteHandlerAndParams($),J=this.flatRoutes[j];if(!J||!J[$.method])return new Response(JSON.stringify({error:f1("not_found","Not found",404)}),{status:404});let W=new A($,O,"api",j);if(!this.isFrameworkRoute(j))this.onRequestStart(W);return await H.run(W,async()=>{let Y=H.getStore(),z=!1,X=async()=>{z=!0,await this.endRequest(Y,W,j)};try{let D=N(n);if(D.isEnabled){let Q=D.detectLocale(W);Y.setLocale(Q)}Y.setRequest(W),N(DZ).applyDefaultBodyLimit($);let T=await this.runRouteMiddleware(j,W);if(T instanceof Response){let Q=D5(T,Y.headers,Y.cookies);return await X(),Q}let F=await this.getRouteData(j),G=Y.headers,U=Y.cookies;if(F instanceof Response){let Q=D5(F,G,U);if(this.isOpenEndedBody($,Q)){let B=CG(Q,()=>this.endRequest(Y,W,j));return z=!0,B}return await X(),Q}let K=(H$(F)?F:a1.json(F)).toResponse(G,U);return await X(),K}catch(D){if(!z)try{await X()}catch(T){console.error(T)}throw D}},Z)}async dispatchAs($,Z,O,j,J){let W=new URL($.rawRequest.url).origin,Y=new URL(`${W}/api${O}`),z=`/api${O.split(/[?#]/)[0]}`;if(!O.startsWith("/")||Y.origin!==W||Y.pathname!==z||Y.hash!==""||Y.pathname.startsWith("/api/__gemi__")||Y.pathname==="/api/auth"||Y.pathname.startsWith("/api/auth/"))throw Error(`dispatchAs: "${O}" is not an app api path. Pass the route's own path, without "/api", with every param encoded.`);let X=new Headers,D=[],T=$.cookies.get(S1);if(T)D.push(`${S1}=${T}`);if(J?.credentials)VG(X,D,J.credentials);if(D.length>0)X.set("Cookie",D.join("; "));let F=$.headers.get(S1);if(F)X.set(S1,F);let G=$.headers.get("User-Agent");if(G)X.set("User-Agent",G);let U;if(j instanceof FormData)U=j;else if(j!==void 0)X.set("Content-Type","application/json"),U=JSON.stringify(j);let K=new Request(Y,{method:Z,headers:X,body:U});if(T5(K,A$($)),$.domain)VZ(K,$.domain);return H.exit(()=>G5.exit(()=>this.handleApiRequest(K)))}}import{timingSafeEqual as MG}from"crypto";var Oj="",$4="*",IG=60000,NG=1e4,t2=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,Zj=16,K5=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,e2="x-forwarded-host";function Q5($){return $.startsWith(":")}function Z4($,Z){if($===null)return!1;let O=Buffer.from($,"utf8"),j=Buffer.from(Z,"utf8");return O.length===j.length&&MG(O,j)}function LG($){if(!$)return null;if($===!0)return{header:e2,secret:null};return{header:($.hostHeader??e2).toLowerCase(),secret:$.secret?{header:$.secret.header.toLowerCase(),value:$.secret.value}:null}}function _G($){if(!$||$===!0)return;let{hostHeader:Z,secret:O}=$;if(Z!==void 0&&(typeof Z!=="string"||!K5.test(Z)))throw Error(`\`route.domains.trustProxy.hostHeader\` must be a single header name, e.g. "x-forwarded-host". Got ${JSON.stringify(Z)}.`);if(!O)return;if(typeof O.header!=="string"||!K5.test(O.header))throw Error(`\`route.domains.trustProxy.secret.header\` must be a header name. Got "${O.header}".`);if(O.header.toLowerCase()===(Z??e2).toLowerCase())throw Error("`route.domains.trustProxy.secret.header` names the same header as `hostHeader`; the secret needs a header of its own.");if(typeof O.value!=="string"||O.value.length<Zj)throw Error(`\`route.domains.trustProxy.secret.value\` must be at least ${Zj} characters. A guessable one lets any client name its own host.`)}function z1($){if(!$)return null;try{return new URL(`http://${$.trim()}`).hostname.toLowerCase().replace(/\.$/,"")||null}catch{return null}}function SG($){try{let Z=new URL(`http://${$.trim()}`),O=Z.hostname.toLowerCase().replace(/\.$/,"");return O?Z.port?`${O}:${Z.port}`:O:null}catch{return null}}function fG($){let Z=z1($.root),O=$.root?.trim().toLowerCase().replace(/\.$/,"");if(!Z||Z!==O||!Z.split(".").every((W)=>t2.test(W)))throw Error(`\`route.domains.root\` must be a bare hostname, e.g. "example.com" \u2014 no scheme, port or path. Got "${$.root}".`);if($.custom&&($.custom.cacheTtlMs??0)<0)throw Error(`\`route.domains.custom.cacheTtlMs\` is ${$.custom.cacheTtlMs}; it cannot be negative. Use 0 to disable the cache.`);if($.ask&&$.ask.secret.length<Zj)throw Error(`\`route.domains.ask.secret\` must be at least ${Zj} characters. A guessable one is worse than leaving \`ask\` out.`);_G($.trustProxy);let j=new Set,J=null;for(let W of $.groups??[]){let{subdomain:Y}=W;if(j.has(Y))throw Error(`\`route.domains\` declares the subdomain "${Y}" twice.`);if(j.add(Y),Q5(Y)){if(!/^:[A-Za-z_][A-Za-z0-9_]*$/.test(Y))throw Error(`"${Y}" is not a valid param subdomain. It must be a single \`:name\` label.`);if(J)throw Error(`\`route.domains\` declares two param subdomains, "${J.subdomain}" and "${Y}"; a host could match either.`);J=W;continue}if(W.exists)throw Error(`The subdomain "${Y}" is fixed, so \`exists\` has no param to check. It only applies to a \`:param\` subdomain.`);if(!Y.split(".").every((z)=>t2.test(z)))throw Error(`"${Y}" is not a valid subdomain.`)}if($.custom&&!j.has($.custom.group))throw Error(`\`route.domains.custom.group\` is "${$.custom.group}", but no group declares that subdomain.`);if($.ask&&J&&!J.exists)throw Error(`\`route.domains.ask\` is set, so "${J.subdomain}" needs an \`exists\` to say which tenants are real. Without one every host under the root would be approved for a certificate.`)}class O4{root;hostTrust;fixed=new Map;param=null;custom;cacheTtlMs;cache=new Map;inFlight=new Map;askSecret;proxySecretHeader;constructor($){fG($),this.root=z1($.root),this.hostTrust=LG($.trustProxy);for(let Z of $.groups??[])if(Q5(Z.subdomain))this.param={...Z,name:Z.subdomain.slice(1)};else this.fixed.set(Z.subdomain.toLowerCase(),Z);this.custom=$.custom??null,this.cacheTtlMs=this.custom?.cacheTtlMs??IG,this.askSecret=$.ask?.secret??null,this.proxySecretHeader=this.hostTrust?.secret?.header??null}forwardedHost($){let Z=this.hostTrust;if(!Z)return null;if(Z.secret&&!Z4($.headers.get(Z.secret.header),Z.secret.value))return null;return $.headers.get(Z.header)?.split(",")[0]?.trim()||null}hostOf($){return z1(this.forwardedHost($))??z1(new URL($.url).host)}publicOrigin($){let Z=new URL($.url),O=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),j=O==="http"||O==="https"?O:Z.protocol.replace(/:$/,""),J=this.forwardedHost($),W=J&&z1(J)?SG(J):null;return`${j}://${W??Z.host}`}async resolve($){let Z=this.hostOf($);if(!Z)return null;let O=await this.match(Z,$);if(O)return O;if(this.custom?.fallback&&!this.isUnderRoot(Z))return{host:Z,group:$4,params:{},custom:!0};return null}async allows($,Z){let O=z1($);return O?await this.match(O,Z)!==null:!1}isUnderRoot($){return $===this.root||$.endsWith(`.${this.root}`)}async match($,Z){if($===this.root)return{host:$,group:Oj,params:{},custom:!1};if($.endsWith(`.${this.root}`)){let j=$.slice(0,-(this.root.length+1)),J=this.fixed.get(j);if(J)return{host:$,group:J.subdomain,params:{},custom:!1};if(this.param&&t2.test(j)){let W={[this.param.name]:j};if(this.param.exists&&!await this.param.exists(W,Z))return null;return{host:$,group:this.param.subdomain,params:W,custom:!1}}return null}if(!this.custom)return null;let O=await this.resolveCustom($);return O?{host:$,group:this.custom.group,params:O,custom:!0}:null}async resolveCustom($){let Z=Date.now(),O=this.cache.get($);if(O&&O.expiresAt>Z)return this.cache.delete($),this.cache.set($,O),O.value;let j=this.inFlight.get($);if(j)return j;let J=(async()=>await this.custom.resolve($)??null)();this.inFlight.set($,J);let W;try{W=await J}finally{this.inFlight.delete($)}if(this.cacheTtlMs>0){if(this.cache.size>=NG)this.cache.delete(this.cache.keys().next().value);this.cache.delete($),this.cache.set($,{value:W,expiresAt:Date.now()+this.cacheTtlMs})}return W}forget($){if($===void 0)this.cache.clear();else{let Z=z1($);if(Z)this.cache.delete(Z)}}}var PG="/__gemi__/domains/ask";class o0{static token="router.domains";resolver;acceptsCustomDomains;groups=new Map;constructor($,Z){this.groups.set(Oj,$);let{domains:O}=Z;if(this.acceptsCustomDomains=Boolean(O?.custom),!O){this.resolver=null;return}this.resolver=new O4(O);let j=(J)=>({api:J.api?new $j({...Z.api,...J.api}):$.api,view:J.view?new V3({...Z.view,...J.view}):$.view});for(let J of O.groups??[])this.groups.set(J.subdomain,j(J));if(O.custom?.fallback)this.groups.set($4,j(O.custom.fallback))}async route($){if(!this.resolver)return this.dispatchers(null);if(this.resolver.proxySecretHeader)B5($,this.resolver.proxySecretHeader);let Z=await this.resolver.resolve($);if(!Z)return null;return VZ($,Z),this.dispatchers(Z)}async ask($){if(!this.resolver?.askSecret||$.method!=="GET")return null;let Z=new URL($.url);if(Z.pathname!==PG)return null;if(!Z4(Z.searchParams.get("secret"),this.resolver.askSecret))return null;let O=Z.searchParams.get("domain"),j=O?await this.resolver.allows(O,$):!1;return new Response(null,{status:j?200:404})}dispatchers($){return this.groups.get($?.group??Oj)}viewDispatchers(){return Array.from(new Set(Array.from(this.groups.values(),($)=>$.view)))}}function jj($){let Z=new Date($??0).getTime();return Number.isFinite(Z)?Z:0}var V5=600000;function C5($,Z){return[E3($,Z),E3($,Z-1)]}class E{static token="auth";config;provider;constructor($={},Z=new kj){this.config={...M5(OJ($),$),emailCode:Rj($.emailCode)},this.provider=Z}get userProvider(){return this.provider}accessTokenCookieOptions($,Z){return{expires:Z,secure:this.publicOrigin($).startsWith("https://"),httpOnly:!0,domain:this.cookieDomain($)}}publicOrigin($){let Z=N().bound(o0)?N(o0).resolver:null;return Z?Z.publicOrigin($.rawRequest):new URL($.rawRequest.url).origin}cookieDomain($){let Z=this.config.cookieDomain;if(!Z)return;let O=Z==="root"?N(o0).resolver?.root:z1(Z);if(!O)throw Error('`auth.cookieDomain` is "root", but `route.domains` is not configured.');let j=$.domain?.host??z1(new URL($.rawRequest.url).host);return j===O||j?.endsWith(`.${O}`)?O:void 0}async getSession($,Z){if(!$)return null;if(!Pj($))return this.config.migrateLegacySession?this.convertLegacySession($,Z,this.config.migrateLegacySession):null;let O=await this.userProvider.findSession({token:$,userAgent:Z});if(!O?.user)return null;let j=Date.now(),J=jj(O.expiresAt),W=jj(O.absoluteExpiresAt);if(J<=j||W<=j)return await this.userProvider.deleteSession({token:$}),null;let z=await this.slideSession(O,j);return z.user.extension=await this.config.extendSession(z.user),z}async convertLegacySession($,Z,O){let j=H.getStore()?.req;if(!j)return null;let J=Date.now(),W=Math.floor(J/V5),Y=null,z=await this.userProvider.findSession({token:$,userAgent:Z});if(z?.user){if(!await O(z,{token:$,req:j,userAgent:Z}))return null;let D=E3($,W),T=z.user.id;if(await this.userProvider.withLegacySessionLock($,async()=>{if(!await this.userProvider.claimLegacySession({token:$}))return!1;return await this.userProvider.createSessionV2({token:D,userId:T,userAgent:Z,...this.freshLifetime(J)}),!0}))Y=D}if(!Y){for(let D of C5($,W))if((await this.userProvider.findSession({token:D,userAgent:Z}))?.user){Y=D;break}}if(!Y)return null;let X=await this.getSession(Y,Z);if(X)j.ctx().setCookie("access_token",Y,this.accessTokenCookieOptions(j,new Date(X.expiresAt)));return X}async revokeSession($,Z){if(!$)return await this.userProvider.deleteSession({token:$}),null;if(Pj($)||!this.config.migrateLegacySession){let J=await this.userProvider.findSession({token:$,userAgent:Z});return await this.userProvider.deleteSession({token:$}),J}let O=Math.floor(Date.now()/V5),j=C5($,O);return this.userProvider.withLegacySessionLock($,async()=>{let J=await this.userProvider.findSession({token:$,userAgent:Z});for(let W of j){if(J?.user)break;J=await this.userProvider.findSession({token:W,userAgent:Z})}await this.userProvider.deleteSession({token:$});for(let W of j)await this.userProvider.deleteSession({token:W});return J})}requestCarryingCookie($){let Z=H.getStore()?.req;return Z?.cookies.get("access_token")===$?Z:null}async slideSession($,Z){let O=this.config.sessionExpiresInHours*3600000;if(new Date($.expiresAt).getTime()-Z>=O/2)return $;let j=new Date(Math.min(Z+O,new Date($.absoluteExpiresAt).getTime())),J=await this.userProvider.updateSession({token:$.token,expiresAt:j}),W=this.requestCarryingCookie($.token);if(W)W.ctx().setCookie("access_token",$.token,this.accessTokenCookieOptions(W,j));if(!J)return $;return{...$,expiresAt:J.expiresAt??j}}freshLifetime($){return{expiresAt:new Date($+this.config.sessionExpiresInHours*3600000),absoluteExpiresAt:new Date($+this.config.sessionAbsoluteExpiresInHours*3600000)}}async generateMagicLink($){}async upsertSession($){await this.userProvider.findSession({token:"",userAgent:""})}async authenticate($){try{let Z=await this.userProvider.findUserByEmailAddress($,!1);if(!Z)throw Error(`User not found with email: ${$}`);let O=await this.createOrUpdateSession({email:$,id:Z.id}),j=new A;if(j.ctx().setCookie("access_token",O.token,this.accessTokenCookieOptions(j,O.expiresAt)),O?.user)O.user.extension=await this.config.extendSession(O.user);return O}catch(Z){console.log(Z)}}async createOrUpdateSessionV2($){let Z=await this.createOrUpdateSession($),O=null;if(Z?.user)O=await this.config.extendSession(Z.user),Z.user.extension=O;return Z}async createOrUpdateSession($){let Z=new A,O=$.id??(await this.userProvider.findUserByEmailAddress($.email,!1))?.id;if(!O)throw new o1;let j=Bun.env.NODE_ENV==="development"?"local":Z.headers.get("User-Agent"),J=i4(O),W=await this.userProvider.createSessionV2({token:J,userId:O,userAgent:j,...this.freshLifetime(Date.now())}),Y=await this.userProvider.findSession({token:J,userAgent:j??""});return Y?.user?Y:W}async createMagicLinkToken($){let Z=await this.userProvider.findUserByEmailAddress($,!1);if(Z){let{pin:O,token:j}=await this.issueOneTimeCode($,6);return{user:Z,email:$,pin:O,token:j}}return{}}async issueOneTimeCode($,Z){await this.userProvider.deleteMagicLinkToken($);let O=await this.config.generateMagicLinkToken($),j=await this.config.generateCode($),J=typeof j==="string"&&j!==""?j:t4(Z);return await this.userProvider.createMagicLinkToken({email:$,token:v3("link",$,O),pin:v3("pin",$,J)}),{email:$,pin:J,token:O}}async verifyOneTimeCode($,Z,O={}){let{expiresInMinutes:j,maxAttempts:J}=this.config.emailCode,W=await this.userProvider.findMagicLinkTokenByEmail($);if(!W)return RZ("pin",$,null,Z),{status:"invalid"};let Y=jj(W.createdAt);if(Y+j*60000<=Date.now())return RZ("pin",$,null,Z),{status:"expired"};if(!await ZJ(W.id,Y,J,j))return await this.userProvider.claimMagicLinkToken(W.id),{status:"too_many_attempts"};if(!RZ("pin",$,W.pin,Z))return{status:"invalid"};if(O.claim!==!1&&!await this.userProvider.claimMagicLinkToken(W.id))return{status:"invalid"};return{status:"ok",row:W}}async verifyMagicLinkToken($,Z){let O=await this.userProvider.findMagicLinkTokenByEmail($),j=RZ("link",$,O?.token,Z);if(!O||!j)return!1;if(jj(O.createdAt)+this.config.emailCode.linkExpiresInMinutes*60000<=Date.now())return!1;return await this.userProvider.claimMagicLinkToken(O.id)}}class B$ extends V0{static getFacadeAccessor(){return E}static async user(){let $=H.getStore(),Z=$?.user;if(!Z){if(Z=await H3(this.getFacadeRoot(),$?.req),Z)$?.setUser(Z)}if(Z)return Z;throw new o1({redirectTo:P3($?.req,this.getFacadeRoot().config.signInPath)})}static intendedUrl($){let Z=H.getStore()?.req;return fZ(Z?.search.get(x$),$??this.getFacadeRoot().config.redirectPath)}static async guard($){let Z=await B$.user();if(!await $(Z))throw new Sj}static async guardSafe($){let Z=await B$.user();try{return await $(Z)}catch(O){return!1}}static async authenticate($){return await this.getFacadeRoot().authenticate($)}static async createMagicLink($){return await this.getFacadeRoot().createMagicLinkToken($)}}class Jj{static ensure($,Z={}){let O=H.getStore();if(O.req.kind==="api")throw Error("Query.prefetch() cannot be called from an API request");return O.serverQueries??=new KZ(K3(O.req.rawRequest)),O.serverQueries.ensure($,Z,"prefetch")}static async instant($,...Z){let O=Jj.ensure($,Z[0]);if(await O.promise,O.status==="rejected")throw O.error;return O.data}static prefetch($,...Z){Jj.ensure($,Z[0])}static noPrefetch(){let $=H.getStore();if($.req.kind==="api")throw Error("Query.noPrefetch() cannot be called from an API request");$.serverQueries??=new KZ(K3($.req.rawRequest)),$.serverQueries.muteDiscoveryHints()}}function I5($,Z,O="/"){let j=new URL($.origin),J=Z.host?Z.host:Z.subdomain?`${Z.subdomain}.${$.root}`:$.root,W=new URL(O.startsWith("/")?O:`/${O}`,j),Y=HG(J);if(!Y)throw Error(`"${J}" is not a hostname, so there is no URL for it. Give a bare host, optionally with a port \u2014 no scheme, path or credentials.`);if(W.hostname=Y.hostname,Y.port)W.port=Y.port;return W.toString()}function HG($){try{let Z=new URL(`http://${$.trim()}`);return Z.host===$.trim().toLowerCase()&&Z.pathname==="/"?{hostname:Z.hostname,port:Z.port}:null}catch{return null}}class N5{static absolute($,...Z){return`${process.env.HOST_NAME}${Y0(String($),Z[0]??{})}`}static relative($,...Z){return Y0(String($),Z[0]??{})}static forDomain($,Z,...O){let j=N(o0).resolver;if(!j)throw Error("`Url.forDomain` needs `route.domains` to be configured.");let J=H.getStore()?.req?.rawRequest,W=J?j.publicOrigin(J):process.env.HOST_NAME;if(!W)throw Error("`Url.forDomain` outside a request needs `HOST_NAME` for the protocol.");return I5({root:j.root,origin:W},$,Y0(String(Z),O[0]??{}))}}class L5{name="Meta";static description($){H.getStore().metadata.description($)}static title($){H.getStore().metadata.title($)}static openGraph($){H.getStore().metadata.openGraph($)}}var xG={set($,Z,O){H.getStore().setCookie($,Z,O)},setIfAbsent($,Z,O){if(H.getStore().req.cookies.has($))return!1;return H.getStore().setCookie($,Z,O),!0},delete($,Z){H.getStore().deleteCookie($,Z)}};class N1 extends V0{static getFacadeAccessor(){return _5}static get client(){return this.getFacadeRoot().client}static get($){return N1.client.get($)}static set($,Z){return N1.client.set($,Z)}static del(...$){return N1.client.del(...$)}static exists($){return N1.client.exists($)}static incr($){return N1.client.incr($)}static expire($,Z){return N1.client.expire($,Z)}static ttl($){return N1.client.ttl($)}}class S5 extends V0{static getFacadeAccessor(){return t0}static consume($,Z={}){return this.getFacadeRoot().consume($,Z)}}class P5 extends V0{static getFacadeAccessor(){return f5}static run($,Z,O){return this.getFacadeRoot().run($,Z,O)}static acquire($,Z={}){return this.getFacadeRoot().acquire($,Z)}}class H5 extends V0{static getFacadeAccessor(){return UZ}static enabled($){return this.getFacadeRoot().enabled($)}static all(){return this.getFacadeRoot().forClient()}static explain($){return this.getFacadeRoot().explain($)}static for($){return this.getFacadeRoot().for($)}static list(){return this.getFacadeRoot().list()}static set($,Z,O){return this.getFacadeRoot().set($,Z,O)}static refresh(){return this.getFacadeRoot().refresh()}static invalidate(){return this.getFacadeRoot().invalidate()}}class Wj{bound;constructor($){this.bound=$}get name(){return this.bound??qZ()}get sql(){return this.connection().sql}get dialect(){return this.connection().dialect}async query($){return await this.run($,"query")}async execute($){let Z=await this.run($,"execute");return Number(Z?.count??0)}async transaction($){let Z=this.name,O=this.connection(Z);return E5(O.sql,(j)=>x5(Z,()=>$(j)),{slowTransactionThreshold:O.config.slowTransactionThreshold,connection:Z})}async schema(){let $=this.connection(),{introspect:Z}=await import("./chunk-2xqrh6d0.js");return Z(this.handle()??$.sql,$.dialect)}run($,Z){let O=this.connection(),{text:j,values:J}=b5($,v5(O.dialect),Z);return(this.handle()??O.sql).unsafe(j,J)}handle(){let $=kZ();if($===void 0)return;return qZ()===this.name?$:void 0}connection($=this.name){return A5($),N(gZ).connection($)}}var IZ=new Wj;class R5 extends V0{static getFacadeAccessor(){return gZ}static connection($){return new Wj($)}static get sql(){return IZ.sql}static get dialect(){return IZ.dialect}static query($){return IZ.query($)}static execute($){return IZ.execute($)}static transaction($){return IZ.transaction($)}static schema(){return IZ.schema()}static close(){return this.getFacadeRoot().close()}}export{D1 as ic,LZ as jc,Gj as kc,P$ as lc,SZ as mc,H0 as nc,Bj as oc,Vj as pc,V4 as qc,f3 as rc,a1 as sc,r5 as tc,Mj as uc,_1 as vc,C0 as wc,t5 as xc,e5 as yc,fj as zc,Pj as Ac,i4 as Bc,t0 as Cc,PZ as Dc,v4 as Ec,A$ as Fc,u4 as Gc,s4 as Hc,xj as Ic,Aj as Jc,v3 as Kc,RZ as Lc,rU as Mc,OJ as Nc,g7 as Oc,kj as Pc,B$ as Qc,u1 as Rc,Jj as Sc,N5 as Tc,L5 as Uc,xG as Vc,N1 as Wc,S5 as Xc,P5 as Yc,n9 as Zc,h2 as _c,a9 as $c,o9 as ad,dT as bd,r9 as cd,c2 as dd,sT as ed,nT as fd,l2 as gd,t9 as hd,e9 as id,UZ as jd,H5 as kd,Wj as ld,R5 as md,Q2 as nd,B2 as od,mK as pd,G9 as qd,F9 as rd,x3 as sd,DZ as td,ZQ as ud,K9 as vd,Q9 as wd,m2 as xd,QZ as yd,d2 as zd,a2 as Ad,TG as Bd,s2 as Cd,UG as Dd,V3 as Ed,r2 as Fd,X5 as Gd,D5 as Hd,$j as Id,o0 as Jd,E as Kd,f4 as Ld,P4 as Md,H4 as Nd,w4 as Od,k4 as Pd,q4 as Qd,E$ as Rd,T0 as Sd,G1 as Td,b$ as Ud,P1 as Vd,R$ as Wd,w$ as Xd,k$ as Yd,AZ as Zd,EZ as _d,H1 as $d,bZ as ae,h4 as be};
16
+
17
+ //# debugId=BBBF96F0FE98119F64756E2164756E21