gemi 0.70.1 → 0.71.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 (213) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/ai/index.js.map +1 -1
  3. package/dist/app/index.js +1 -1
  4. package/dist/auth/AuthManager.d.ts +1 -1
  5. package/dist/auth/AuthManager.d.ts.map +1 -1
  6. package/dist/auth/UserProvider.d.ts +93 -9
  7. package/dist/auth/UserProvider.d.ts.map +1 -1
  8. package/dist/broadcasting/index.js +1 -1
  9. package/dist/bun/plugin.js +1 -1
  10. package/dist/bun/preload.js +1 -1
  11. package/dist/{chunk-p0m3qgs5.js → chunk-0kpvbnz0.js} +2 -2
  12. package/dist/{chunk-p0m3qgs5.js.map → chunk-0kpvbnz0.js.map} +1 -1
  13. package/dist/chunk-0x9a9yha.js +19 -0
  14. package/dist/{chunk-4t9zv1rk.js.map → chunk-0x9a9yha.js.map} +9 -8
  15. package/dist/{chunk-63n765wn.js → chunk-25a65e4r.js} +2 -2
  16. package/dist/{chunk-63n765wn.js.map → chunk-25a65e4r.js.map} +1 -1
  17. package/dist/{chunk-dmxr0bt8.js → chunk-26n9365a.js} +3 -3
  18. package/dist/{chunk-dmxr0bt8.js.map → chunk-26n9365a.js.map} +1 -1
  19. package/dist/{chunk-7tmqw6a5.js → chunk-2a2qd22n.js} +2 -2
  20. package/dist/{chunk-7tmqw6a5.js.map → chunk-2a2qd22n.js.map} +1 -1
  21. package/dist/{chunk-k4vj2b98.js → chunk-385exk8p.js} +2 -2
  22. package/dist/{chunk-k4vj2b98.js.map → chunk-385exk8p.js.map} +1 -1
  23. package/dist/{chunk-mpk36kdy.js → chunk-3g94pe6x.js} +2 -2
  24. package/dist/{chunk-mpk36kdy.js.map → chunk-3g94pe6x.js.map} +1 -1
  25. package/dist/{chunk-8nzcqw9n.js → chunk-3w80kmxr.js} +2 -2
  26. package/dist/{chunk-8nzcqw9n.js.map → chunk-3w80kmxr.js.map} +1 -1
  27. package/dist/{chunk-c776vm8q.js → chunk-3zraw16t.js} +3 -3
  28. package/dist/{chunk-c776vm8q.js.map → chunk-3zraw16t.js.map} +1 -1
  29. package/dist/{chunk-tkrj74c1.js → chunk-3zv572s2.js} +2 -2
  30. package/dist/{chunk-tkrj74c1.js.map → chunk-3zv572s2.js.map} +1 -1
  31. package/dist/{chunk-zpjx407m.js → chunk-44j2dckn.js} +3 -3
  32. package/dist/{chunk-zpjx407m.js.map → chunk-44j2dckn.js.map} +1 -1
  33. package/dist/{chunk-rm5qa99y.js → chunk-47589yz8.js} +3 -3
  34. package/dist/{chunk-rm5qa99y.js.map → chunk-47589yz8.js.map} +1 -1
  35. package/dist/{chunk-th8drc6f.js → chunk-4yj86ds2.js} +2 -2
  36. package/dist/{chunk-th8drc6f.js.map → chunk-4yj86ds2.js.map} +1 -1
  37. package/dist/{chunk-xmjzrg41.js → chunk-544va0er.js} +3 -3
  38. package/dist/{chunk-xmjzrg41.js.map → chunk-544va0er.js.map} +1 -1
  39. package/dist/{chunk-vpvde0nb.js → chunk-5fxqzs72.js} +2 -2
  40. package/dist/{chunk-vpvde0nb.js.map → chunk-5fxqzs72.js.map} +1 -1
  41. package/dist/{chunk-5p4ywbsz.js → chunk-88qvsv9w.js} +2 -2
  42. package/dist/{chunk-5p4ywbsz.js.map → chunk-88qvsv9w.js.map} +1 -1
  43. package/dist/{chunk-vxr752md.js → chunk-8dvntsme.js} +2 -2
  44. package/dist/{chunk-vxr752md.js.map → chunk-8dvntsme.js.map} +1 -1
  45. package/dist/{chunk-z4k18gnp.js → chunk-9hbwvcxn.js} +2 -2
  46. package/dist/{chunk-z4k18gnp.js.map → chunk-9hbwvcxn.js.map} +1 -1
  47. package/dist/{chunk-wqamwrrn.js → chunk-ak7jma5c.js} +2 -2
  48. package/dist/{chunk-wqamwrrn.js.map → chunk-ak7jma5c.js.map} +1 -1
  49. package/dist/{chunk-5qnk24jy.js → chunk-awjqnh2x.js} +2 -2
  50. package/dist/{chunk-5qnk24jy.js.map → chunk-awjqnh2x.js.map} +1 -1
  51. package/dist/{chunk-5fxz3knw.js → chunk-b2bpwb1d.js} +2 -2
  52. package/dist/{chunk-5fxz3knw.js.map → chunk-b2bpwb1d.js.map} +1 -1
  53. package/dist/{chunk-4j6vrkmj.js → chunk-b53j44zv.js} +2 -2
  54. package/dist/{chunk-4j6vrkmj.js.map → chunk-b53j44zv.js.map} +1 -1
  55. package/dist/{chunk-4azcbkxm.js → chunk-bjr740m4.js} +1 -1
  56. package/dist/{chunk-qxfby5zf.js → chunk-bt9rjc80.js} +3 -3
  57. package/dist/{chunk-qxfby5zf.js.map → chunk-bt9rjc80.js.map} +1 -1
  58. package/dist/{chunk-f8wyyky5.js → chunk-c6z9f6cp.js} +2 -2
  59. package/dist/{chunk-f8wyyky5.js.map → chunk-c6z9f6cp.js.map} +1 -1
  60. package/dist/chunk-cvm5sm4m.js +5 -0
  61. package/dist/{chunk-ds8d17k6.js.map → chunk-cvm5sm4m.js.map} +1 -1
  62. package/dist/{chunk-f65v7rqq.js → chunk-drrxkg9v.js} +3 -3
  63. package/dist/{chunk-f65v7rqq.js.map → chunk-drrxkg9v.js.map} +1 -1
  64. package/dist/{chunk-p9rg95p6.js → chunk-ejspccjb.js} +1 -1
  65. package/dist/{chunk-q2qnet5h.js → chunk-ep1jte2d.js} +2 -2
  66. package/dist/{chunk-q2qnet5h.js.map → chunk-ep1jte2d.js.map} +1 -1
  67. package/dist/{chunk-44jp4cb2.js → chunk-ev1pe2ry.js} +2 -2
  68. package/dist/{chunk-44jp4cb2.js.map → chunk-ev1pe2ry.js.map} +1 -1
  69. package/dist/{chunk-2yrgzmpk.js → chunk-gf3y4k0r.js} +2 -2
  70. package/dist/{chunk-2yrgzmpk.js.map → chunk-gf3y4k0r.js.map} +1 -1
  71. package/dist/{chunk-wc4jpf86.js → chunk-gjanfny1.js} +3 -3
  72. package/dist/{chunk-wc4jpf86.js.map → chunk-gjanfny1.js.map} +1 -1
  73. package/dist/{chunk-qtwmbqzr.js → chunk-gkedmh5f.js} +2 -2
  74. package/dist/{chunk-qtwmbqzr.js.map → chunk-gkedmh5f.js.map} +1 -1
  75. package/dist/{chunk-vbrbsk9b.js → chunk-gn0vhf9n.js} +3 -3
  76. package/dist/{chunk-vbrbsk9b.js.map → chunk-gn0vhf9n.js.map} +1 -1
  77. package/dist/{chunk-fxdc34cj.js → chunk-jgn1jyys.js} +2 -2
  78. package/dist/{chunk-fxdc34cj.js.map → chunk-jgn1jyys.js.map} +1 -1
  79. package/dist/{chunk-7srjk8t7.js → chunk-ksxes55e.js} +2 -2
  80. package/dist/{chunk-7srjk8t7.js.map → chunk-ksxes55e.js.map} +1 -1
  81. package/dist/{chunk-dacq5bw8.js → chunk-mt1776nd.js} +2 -2
  82. package/dist/{chunk-dacq5bw8.js.map → chunk-mt1776nd.js.map} +1 -1
  83. package/dist/{chunk-y73tppyk.js → chunk-n74re6da.js} +2 -2
  84. package/dist/{chunk-y73tppyk.js.map → chunk-n74re6da.js.map} +1 -1
  85. package/dist/chunk-ngq4n2b3.js +54 -0
  86. package/dist/chunk-ngq4n2b3.js.map +15 -0
  87. package/dist/{chunk-k7hm7f3t.js → chunk-p7tbab19.js} +3 -3
  88. package/dist/{chunk-k7hm7f3t.js.map → chunk-p7tbab19.js.map} +1 -1
  89. package/dist/{chunk-ah13y0hy.js → chunk-ps59yj5b.js} +2 -2
  90. package/dist/{chunk-ah13y0hy.js.map → chunk-ps59yj5b.js.map} +1 -1
  91. package/dist/chunk-qb1x1r58.js +5 -0
  92. package/dist/{chunk-x2tqctjm.js.map → chunk-qb1x1r58.js.map} +4 -5
  93. package/dist/{chunk-nkfj4qq5.js → chunk-qcpar2xh.js} +2 -2
  94. package/dist/{chunk-nkfj4qq5.js.map → chunk-qcpar2xh.js.map} +1 -1
  95. package/dist/{chunk-pmze0zcr.js → chunk-qm16ep90.js} +2 -2
  96. package/dist/{chunk-pmze0zcr.js.map → chunk-qm16ep90.js.map} +1 -1
  97. package/dist/{chunk-ezd59jpg.js → chunk-r4t5a213.js} +1 -1
  98. package/dist/{chunk-bq3sc20y.js → chunk-rnbgw55r.js} +2 -2
  99. package/dist/{chunk-bq3sc20y.js.map → chunk-rnbgw55r.js.map} +1 -1
  100. package/dist/{chunk-p48th4ps.js → chunk-ryynt7wx.js} +2 -2
  101. package/dist/{chunk-p48th4ps.js.map → chunk-ryynt7wx.js.map} +1 -1
  102. package/dist/{chunk-cw2wjrya.js → chunk-sbeszmmp.js} +3 -3
  103. package/dist/{chunk-cw2wjrya.js.map → chunk-sbeszmmp.js.map} +1 -1
  104. package/dist/{chunk-q8630z08.js → chunk-sm8h95v3.js} +2 -2
  105. package/dist/{chunk-q8630z08.js.map → chunk-sm8h95v3.js.map} +1 -1
  106. package/dist/{chunk-ceemr927.js → chunk-tfsbtz0j.js} +2 -2
  107. package/dist/{chunk-ceemr927.js.map → chunk-tfsbtz0j.js.map} +1 -1
  108. package/dist/{chunk-gj5jjmf8.js → chunk-vt9tm0xx.js} +2 -2
  109. package/dist/{chunk-gj5jjmf8.js.map → chunk-vt9tm0xx.js.map} +1 -1
  110. package/dist/{chunk-paqjyvjm.js → chunk-w316w188.js} +2 -2
  111. package/dist/{chunk-paqjyvjm.js.map → chunk-w316w188.js.map} +1 -1
  112. package/dist/{chunk-snheb16b.js → chunk-wa5emk60.js} +2 -2
  113. package/dist/{chunk-snheb16b.js.map → chunk-wa5emk60.js.map} +1 -1
  114. package/dist/{chunk-yffy1k69.js → chunk-wtyn66c0.js} +2 -2
  115. package/dist/{chunk-yffy1k69.js.map → chunk-wtyn66c0.js.map} +1 -1
  116. package/dist/{chunk-wbv5kyhe.js → chunk-wxahf19j.js} +4 -4
  117. package/dist/{chunk-wbv5kyhe.js.map → chunk-wxahf19j.js.map} +1 -1
  118. package/dist/{chunk-wx3rx7vp.js → chunk-x3jwa5mx.js} +2 -2
  119. package/dist/{chunk-wx3rx7vp.js.map → chunk-x3jwa5mx.js.map} +1 -1
  120. package/dist/{chunk-3296fwss.js → chunk-xh65fgg1.js} +2 -2
  121. package/dist/{chunk-3296fwss.js.map → chunk-xh65fgg1.js.map} +1 -1
  122. package/dist/{chunk-083j4ktb.js → chunk-xkt6pnv3.js} +2 -2
  123. package/dist/{chunk-083j4ktb.js.map → chunk-xkt6pnv3.js.map} +1 -1
  124. package/dist/{chunk-v6v1b4jp.js → chunk-ybtwp81a.js} +2 -2
  125. package/dist/{chunk-v6v1b4jp.js.map → chunk-ybtwp81a.js.map} +1 -1
  126. package/dist/{chunk-em9kwz08.js → chunk-yt96ny9v.js} +2 -2
  127. package/dist/{chunk-em9kwz08.js.map → chunk-yt96ny9v.js.map} +1 -1
  128. package/dist/{chunk-s7v66c70.js → chunk-yvkm7qya.js} +2 -2
  129. package/dist/{chunk-s7v66c70.js.map → chunk-yvkm7qya.js.map} +1 -1
  130. package/dist/{chunk-kh64a9rh.js → chunk-z99bj1mv.js} +2 -2
  131. package/dist/{chunk-kh64a9rh.js.map → chunk-z99bj1mv.js.map} +1 -1
  132. package/dist/{chunk-hq496pa4.js → chunk-zbhqa2z7.js} +2 -2
  133. package/dist/{chunk-hq496pa4.js.map → chunk-zbhqa2z7.js.map} +1 -1
  134. package/dist/{chunk-b004v4jt.js → chunk-zkpwb3fp.js} +2 -2
  135. package/dist/{chunk-b004v4jt.js.map → chunk-zkpwb3fp.js.map} +1 -1
  136. package/dist/{chunk-2qyghpe0.js → chunk-zz0t0pwk.js} +2 -2
  137. package/dist/{chunk-2qyghpe0.js.map → chunk-zz0t0pwk.js.map} +1 -1
  138. package/dist/config/index.js +1 -1
  139. package/dist/console/run.js +2 -2
  140. package/dist/console/run.js.map +1 -1
  141. package/dist/container/index.js +2 -2
  142. package/dist/container/index.js.map +1 -1
  143. package/dist/database/index.js +2 -2
  144. package/dist/database/index.js.map +1 -1
  145. package/dist/email/index.js +2 -2
  146. package/dist/email/index.js.map +1 -1
  147. package/dist/facades/Features.d.ts +45 -2
  148. package/dist/facades/Features.d.ts.map +1 -1
  149. package/dist/facades/index.js +2 -2
  150. package/dist/facades/index.js.map +1 -1
  151. package/dist/foundation/index.js +2 -2
  152. package/dist/foundation/index.js.map +1 -1
  153. package/dist/http/index.js +2 -2
  154. package/dist/http/index.js.map +1 -1
  155. package/dist/i18n/dictionaryRuntime.js +2 -2
  156. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  157. package/dist/i18n/index.js +2 -2
  158. package/dist/i18n/index.js.map +1 -1
  159. package/dist/kernel/index.d.ts +3 -2
  160. package/dist/kernel/index.d.ts.map +1 -1
  161. package/dist/kernel/index.js +3 -3
  162. package/dist/kernel/index.js.map +2 -2
  163. package/dist/orm/Model.d.ts.map +1 -1
  164. package/dist/orm/compile/lock.d.ts +23 -0
  165. package/dist/orm/compile/lock.d.ts.map +1 -0
  166. package/dist/orm/compile/plan-relations.d.ts.map +1 -1
  167. package/dist/orm/compile/read.d.ts.map +1 -1
  168. package/dist/orm/dialect/index.d.ts +23 -0
  169. package/dist/orm/dialect/index.d.ts.map +1 -1
  170. package/dist/orm/dialect/postgres.d.ts +2 -0
  171. package/dist/orm/dialect/postgres.d.ts.map +1 -1
  172. package/dist/orm/dialect/sqlite.d.ts +2 -0
  173. package/dist/orm/dialect/sqlite.d.ts.map +1 -1
  174. package/dist/orm/errors.d.ts +17 -0
  175. package/dist/orm/errors.d.ts.map +1 -1
  176. package/dist/orm/index.d.ts +2 -2
  177. package/dist/orm/index.d.ts.map +1 -1
  178. package/dist/orm/index.js +3 -3
  179. package/dist/orm/index.js.map +11 -10
  180. package/dist/orm/plan.d.ts.map +1 -1
  181. package/dist/orm/types.d.ts +32 -0
  182. package/dist/orm/types.d.ts.map +1 -1
  183. package/dist/server/index.js +2 -2
  184. package/dist/server/index.js.map +1 -1
  185. package/dist/services/features/FeatureFlagStore.d.ts +14 -1
  186. package/dist/services/features/FeatureFlagStore.d.ts.map +1 -1
  187. package/dist/services/features/FeatureManager.d.ts +43 -0
  188. package/dist/services/features/FeatureManager.d.ts.map +1 -1
  189. package/dist/services/features/sources/DatabaseFeatureFlagSource.d.ts +17 -1
  190. package/dist/services/features/sources/DatabaseFeatureFlagSource.d.ts.map +1 -1
  191. package/dist/services/features/sources/FeatureFlagSource.d.ts +28 -0
  192. package/dist/services/features/sources/FeatureFlagSource.d.ts.map +1 -1
  193. package/dist/services/features/sources/StaticFeatureFlagSource.d.ts +7 -2
  194. package/dist/services/features/sources/StaticFeatureFlagSource.d.ts.map +1 -1
  195. package/dist/services/features/types.d.ts +11 -0
  196. package/dist/services/features/types.d.ts.map +1 -1
  197. package/dist/services/index.d.ts +3 -3
  198. package/dist/services/index.d.ts.map +1 -1
  199. package/dist/services/index.js +7 -7
  200. package/dist/services/index.js.map +3 -3
  201. package/dist/services/queue/work.js +2 -2
  202. package/dist/services/queue/work.js.map +1 -1
  203. package/dist/support/index.js +2 -2
  204. package/dist/support/index.js.map +1 -1
  205. package/package.json +1 -1
  206. package/dist/chunk-4t9zv1rk.js +0 -19
  207. package/dist/chunk-ayja3wqv.js +0 -54
  208. package/dist/chunk-ayja3wqv.js.map +0 -15
  209. package/dist/chunk-ds8d17k6.js +0 -5
  210. package/dist/chunk-x2tqctjm.js +0 -5
  211. /package/dist/{chunk-4azcbkxm.js.map → chunk-bjr740m4.js.map} +0 -0
  212. /package/dist/{chunk-p9rg95p6.js.map → chunk-ejspccjb.js.map} +0 -0
  213. /package/dist/{chunk-ezd59jpg.js.map → chunk-r4t5a213.js.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemi",
3
- "version": "0.70.1",
3
+ "version": "0.71.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "Enes Tufekci <enes@gemijs.dev>",
@@ -1,19 +0,0 @@
1
- // @bun
2
- import{Jd as yz,Qd as T2}from"./chunk-vbrbsk9b.js";import{Ge as O2,Xd as n$,ae as kO}from"./chunk-ayja3wqv.js";import{$e as NZ,He as HZ,Je as d8,Le as y8,Me as xz,Ne as VZ,Oe as QZ,Re as SZ,Se as MZ,Te as u$,Ue as P8,Ve as gO,We as y1,Xe as E0,Ye as x,Ze as wZ,_e as bZ,bf as m1,cf as O0,df as jZ}from"./chunk-c776vm8q.js";import{kf as Q8,lf as rj,mf as N}from"./chunk-kh64a9rh.js";import{nf as l8}from"./chunk-3296fwss.js";import{Bf as $2,of as m8,pf as r8,qf as zz,rf as t8,sf as e8}from"./chunk-cw2wjrya.js";import{Nf as Fz}from"./chunk-083j4ktb.js";import{Vf as v8,_f as g8}from"./chunk-fxdc34cj.js";import{eg as b8,fg as a}from"./chunk-ceemr927.js";import{ig as K}from"./chunk-dmxr0bt8.js";import{jg as s$}from"./chunk-dacq5bw8.js";import{vg as Mj}from"./chunk-63n765wn.js";import{xg as q8}from"./chunk-p48th4ps.js";import{Cg as ej}from"./chunk-vpvde0nb.js";import{randomBytes as OJ}from"crypto";function pO($){return typeof $==="function"&&$.prototype!==void 0}function G1($){return typeof $==="string"?[$]:$}function iO($,O){let T=O?"attachment":"inline",Z=$.replace(/["\\]/g,"").replace(/[^\x20-\x7e]/g,"_");return`${T}; filename="${Z}"; filename*=UTF-8''${encodeURIComponent($)}`}function X2($){return"total"in $&&"partial"in $&&"body"in $}function e$($){return new Response(null,{status:416,headers:{"Accept-Ranges":"bytes","Content-Range":MZ($),"Content-Length":"0","Cache-Control":"no-store"}})}async function U2($){if($ instanceof Blob)return{body:$,start:0,end:$.size-1,total:$.size,partial:!1,type:$.type,name:$.name,download:!1,status:200,extraHeaders:{}};if(X2($))return{body:$.body,start:$.start,end:$.end,total:$.total,partial:$.partial,type:$.type,name:$.name,download:!1,etag:$.etag,lastModified:$.lastModified,status:200,extraHeaders:{}};let O=$.file,T=O instanceof Blob?O:null,Z=$.total??T?.size??-1;return{body:O,start:$.start??0,end:$.end??Z-1,total:Z,partial:$.partial??!1,type:$.type??T?.type??"",name:$.name??O?.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}}}async function IZ($,O){if($ instanceof Response)return $;if(!$)return new Response("Not found",{status:404});let T=await U2($),{body:Z,start:f,end:j,total:z,partial:F}=T;if(Z instanceof Blob&&"exists"in Z&&typeof Z.exists==="function"){if(!await Z.exists())return new Response("Not found",{status:404})}let{range:W}=O;if(W){if(z<=0)return e$(Math.max(z,0));if(!F){if(Z instanceof Blob){let D=QZ(W,z);if(!D)return e$(z);Z=Z.slice(D.start,D.end+1),f=D.start,j=D.end,F=!0}}}let C=Boolean(W)&&F,J=C?206:T.status,Y=new Headers;if(Y.set("Accept-Ranges","bytes"),Y.set("Content-Type",T.type||"application/octet-stream"),C)Y.set("Content-Range",SZ(f,j,z)),Y.set("Content-Length",String(j-f+1));else if(z>=0)Y.set("Content-Length",String(z));if(T.name)Y.set("Content-Disposition",iO(T.name,T.download));if(T.etag)Y.set("ETag",T.etag);if(T.lastModified)Y.set("Last-Modified",T.lastModified.toUTCString());for(let[D,U]of Object.entries(T.extraHeaders))Y.set(D,U);if((O.method??"GET").toUpperCase()==="HEAD"){if(Z&&"cancel"in Z&&typeof Z.cancel==="function")await Z.cancel();return new Response(null,{status:J,headers:Y})}return new Response(Z,{status:J,headers:Y})}function Cz($){return pO($)}class s{method;handler;methodName;__internal_brand="RouteHandler";middlewares=[];constructor($,O,T){this.method=$;this.handler=O;this.methodName=T;this.handler=O,this.methodName=T,this.method=$}get source(){if(!Cz(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(Cz(this.handler)){let O=new this.handler;return O[this.methodName].bind(O)()}return this.handler()}middleware($){return this.middlewares=G1($),this}}class Jz{url;headers;__internal_brand="ProxyHandler";constructor($,O){this.url=$;this.headers=O}run(){let $=new x;return fetch(this.url,{method:$.rawRequest.method,headers:{...$.headers.toJSON(),...this.headers},body:$.rawRequest.body})}}class Dz{constructor(...$){return new s(...$)}}class Yz extends s{__internal_brand="StreamHandler";async run($){let O=N.getStore(),T=O?.req?.rawRequest,Z=VZ(T?.headers.get("Range"));if(O)O.rangeRequest=Z;try{let f=await super.run($);return await IZ(f,{range:Z,method:T?.method})}catch(f){if(f instanceof NZ)return e$(f.total);throw f}finally{if(O)O.rangeRequest=null}}}class Xz{constructor(...$){return new Yz(...$)}}class Uz{__internal_brand="ResourceRoutes";first;second;constructor($){this.first={get:new s("GET",$,"list"),post:new s("POST",$,"store")},this.second={get:new s("GET",$,"show"),put:new s("PUT",$,"update"),delete:new s("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 N0{static __brand="ApiRouter";routes={};middlewares=[];middleware($){}get($,O){return new s("GET",$,O)}post($,O){return new s("POST",$,O)}put($,O){return new s("PUT",$,O)}patch($,O){return new s("PATCH",$,O)}delete($,O){return new s("DELETE",$,O)}resource($){return new Uz($)}agent($){return G2($,this)}file($,O){return new Dz("GET",$,O)}stream($,O){return new Xz("GET",$,O)}proxy($,O={}){return new Jz($,O)}}function G2($,O){let T={stream:new s("POST",$,"stream"),attach:new s("POST",$,"attach"),stop:new s("POST",$,"stop"),upload:new s("POST",$,"upload")};return class extends N0{static __internal_brand="AgentRoute";static controller=$;static handlers=T;constructor(){super();this.middlewares=[...O?.middlewares??[]]}routes={"/":T.stream,"/attach":T.attach,"/stop":T.stop,"/files":T.upload};static middleware(f){if(f.stream)T.stream.middleware(f.stream);if(f.attach)T.attach.middleware(f.attach);if(f.stop)T.stop.middleware(f.stop);if(f.upload)T.upload.middleware(f.upload);return this}}}class EZ{method;url;meta;__internal_brand="McpRoute";constructor($,O,T){this.method=$;this.url=O;this.meta=T}}class Gz{static __brand="McpRouter";routes={};fromApiRoute($,O,T){return new EZ($,O,T)}}function u($,O){return $.replace(/:([^/]+[*?]?)/g,(T,Z)=>{let f=Z.endsWith("?")||Z.endsWith("*"),j=f?Z.slice(0,-1):Z,z=O[j];if(z===void 0){if(f)return"";if(import.meta.env.DEV)throw Error(`Missing parameter: ${j}`);console.error(`Missing parameter: ${j} in URL: ${$}`)}return String(z)}).replace(/\/\//g,"/").replace(/\/$/,"")}class xZ extends y1{constructor($,O=307){super("Redirect error");this.name="RedirectError",this.payload={api:{status:200,data:{},directive:{kind:"Redirect",path:$}},view:{status:O,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:$}}}}}class hO{static to($,...O){let[T={}]=O,{search:Z={},params:f={},permanent:j,status:z}={params:{},status:307,permanent:!1,...T},F=new URLSearchParams(Z).toString();throw new xZ([u($,f)||"/",F.toString()].filter(Boolean).join("?"),z??(j?301:307))}static external($,O=307){throw new xZ($,O)}}class Bz{kind="redirect";viewPath="REDIRECT";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>({});else if(typeof $==="function")this.handler=$;else{let[O,T]=$;this.handler=(Z)=>{return new O()[T](Z)}}}async run($,O){let{destination:T,permanent:Z=!1,status:f=307}=await this.handler($);if(!T)throw Error(`Redirect destination is required see ${O}`);return hO.to(T,{permanent:Z,status:f}),{}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}async function _Z($,O){if($ instanceof Response)return $;let T=$ instanceof Blob,Z=T?$:$.file,f=T?$.name:$.name??$.file?.name,j=(T?$.type:$.type??$.file?.type)||"",z=T?!1:$.download??!1,F=T?200:$.status??200;if(!T)for(let[W,C]of Object.entries($.headers??{}))O.set(W,C);if(Z instanceof Blob&&"exists"in Z&&typeof Z.exists==="function"){if(!await Z.exists())return new Response("Not found",{status:404})}if(O.set("Content-Type",j||"application/octet-stream"),Z instanceof Blob)O.set("Content-Length",String(Z.size));if(f)O.set("Content-Disposition",iO(f,z));return new Response(Z instanceof Blob?Z.stream():Z,{status:F,headers:O})}class Kz{kind="file";viewPath="FILE";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>null;else if(typeof $==="function")this.handler=$;else{let[O,T]=$;this.handler=(Z)=>{return new O()[T](Z)}}}async run($,O){let T=await this.handler($);if(!T)throw Error(`File route handler must return a file see ${O}`);return{FILE:T}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class Lz{viewPath;middlewares=[];featureGates=[];handler;constructor($,O){this.viewPath=$;if(!O)this.handler=()=>({});else if(typeof O==="function")this.handler=O;else{let[T,Z]=O;this.handler=(f)=>{return new T()[Z](f)}}}async run($,O){let T=await this.handler($);return{[this.viewPath]:{...T,breadcrumb:{label:T?.breadcrumb??"",href:O}}}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class Qz{viewPath;children;middlewares=[];featureGates=[];alwaysRuns=!1;handler=()=>({});constructor($,O,T){this.viewPath=$;if(typeof O==="function")this.handler=O,this.children=class extends B1{routes=T??{}};else if(Array.isArray(O)){let[Z,f]=O;this.handler=(j)=>{return new Z()[f](j)},this.children=class extends B1{routes=T??{}}}else this.children=class extends B1{routes=O},this.handler=()=>({})}async run($,O){let T=await this.handler($);return{[this.viewPath]:{...T,breadcrumb:{label:T?.breadcrumb??"",href:O}}}}alwaysRun(){return this.alwaysRuns=!0,this}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class B1{middlewares=[];featureGates=[];routes={};view($,O){return new Lz($,O)}file($){return new Kz($)}redirect($){return new Bz($)}layout($,O,T){return new Qz($,O,T)}}class v0{req;config={};constructor($){this.req=$}run(...$){return{}}static configure($){let O=this;return class extends O{config=$}}}function B2($){return $}function K2(){return{aliases:{},global:[]}}var Y$="redirect";function $O($,O="/"){if(typeof $!=="string"||!$.startsWith("/"))return O;if(/[\u0000-\u001f\u007f\\]/.test($)||$.startsWith("//"))return O;try{let T=new URL($,"http://gemi.invalid");if(T.origin!=="http://gemi.invalid")return O;let Z=`${T.search}${T.hash}`.replaceAll("/","%2F"),f=`${T.pathname}${Z}`.replaceAll(":","%3A");return f.startsWith("//")?O:f}catch{return O}}function Sz($){let O=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();return O?O==="https":new URL($.url).protocol==="https:"}function L2($,O=!0){let T=new URL($.rawRequest.url),Z=T.pathname.replace(/\.(json|og)$/,""),[,f,...j]=Z.split("/");if(K(a).supportedLocales.includes(f))Z=`/${j.join("/")}`;return O?`${Z}${T.search}`:Z}function Q2($,O){let T=(Z)=>Z.replace(/\/+$/,"")||"/";return T($)===T(O)}function lO($,O){let T=O||K(w).config.signInPath,Z=/^[a-z][a-z\d+.-]*:/i.test(T);if(Z?!/^https?:\/\//i.test(T):!T.startsWith("/"))throw Error(`\`auth.signInPath\` must be a path like "/auth/sign-in", or an http(s) URL for sign-in hosted elsewhere. Got "${T}". A route's own \`"auth:<path>"\` cannot carry a URL, because the alias parser splits it on the colon.`);let f=new URL(T,"http://gemi.invalid");if($?.kind==="view"){let j=L2($,!Z);if(Z||!Q2(new URL(j,f).pathname,f.pathname))f.searchParams.set(Y$,j)}return Z?f.href:`${f.pathname}${f.search}`}class Mz extends v0{async run($){let O=N.getStore(),T=O.req,Z=()=>new m1({redirectTo:lO(T,$)}),f=T.cookies.get("access_token"),j=T.headers.get("access_token"),z=f||j;if(!z)throw Z();let F=O.user;if(!F){let W=await K(w).getSession(z,T.headers.get("User-Agent"));if(!W)throw Z();F=W?.user,O.setUser(F)}return{}}}class Iz extends v0{async run(...$){let[O="public",T="864000",...Z]=$,f=`${O}, max-age=${T}${Z.length>0?", ":""}${Z.join(", ")}`;if($.length===0)f="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="public")f="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="private")f="private, max-age=0, stale-while-revalidate=300, stale-if-error=600";if(this.req.rawRequest.method==="GET")this.req.ctx().setHeaders("Cache-Control",f);return{}}}var S2={"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 Vz extends v0{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,O=$.rawRequest.headers.get("Origin");if(this.config.origins[O]){$.ctx().setHeaders("Access-Control-Allow-Origin",O);let T={...S2,...this.config.origins[O]};for(let[Z,f]of Object.entries(T))$.ctx().setHeaders(Z,f)}return{}}}class X${config;static token="ratelimiter";constructor($){this.config=$}get driver(){return this.config.driver}async consume($,O={}){let T=O.limit??this.config.limit,Z=O.window??this.config.window,f=O.cost??1;if(Nz("window",Z),Nz("limit",T),!Number.isFinite(f)||f<0)throw Error(`Rate limiter cost must be zero or greater, got ${f}`);return await this.config.driver.consume({key:$,limit:T,window:Z*1000,cost:f})}}function Nz($,O){if(!Number.isFinite(O)||O<=0)throw Error(`Rate limiter ${$} must be greater than zero, got ${O}`)}class PZ extends y1{constructor($){super("Rate limit exceeded");let O={"Content-Type":"application/json",...$?Pz($):{}};this.payload={api:{status:429,data:{error:{message:"Rate limit exceeded"}},headers:O},view:{error:{message:"Rate limit exceeded"},status:429,headers:O}}}}class _z extends v0{async run($,O){let T=M2();if(!T)return{};let Z=await T.consume(this.key(),{limit:Ez($)??this.config.limit,window:Ez(O)??this.config.window});if(this.config.headers!==!1){let f=this.req.ctx?.();if(f)for(let[j,z]of Object.entries(Pz(Z)))f.setHeaders(j,z)}if(!Z.allowed)throw new PZ(Z);return{}}key(){if(this.config.key)return this.config.key(this.req);return`${dO(this.req)}:${this.req.routePath??"*"}`}}function M2(){try{let $=K();return $.bound(X$)?$.make(X$):null}catch{return null}}function dO($){let O=xz($.rawRequest);if(O!==void 0)return O;let T=$.headers.get("x-forwarded-for");if(T){let[Z]=T.split(",");if(Z?.trim())return Z.trim()}return $.headers.get("x-real-ip")?.trim()||"unknown"}function Pz($){let O={"X-RateLimit-Limit":String($.limit),"X-RateLimit-Remaining":String($.remaining),"X-RateLimit-Reset":String(Math.ceil($.resetAt/1000))};if(!$.allowed)O["Retry-After"]=String(Math.max(1,Math.ceil($.retryAfter/1000)));return O}function Ez($){if($===void 0||$===null||$==="")return;let O=Number($);if(!Number.isFinite(O)||O<=0)return;return O}class Az extends v0{async run(){let $=this.req.cookies.get("csrf_token");if(!$)throw new AZ;if(!["POST","PUT","PATCH","DELETE"].includes(this.req.rawRequest.method))return{};if(!Bun.CSRF.verify($,{secret:process.env.SECRET}))throw new AZ;return{}}}class AZ extends y1{constructor(){super("Invalid CSRF token");this.name="InvalidCSRFTokenError"}payload={api:{status:403,data:{error:"Invalid CSRF token"}},view:{}}}class Hz{policiesList={};constructor(){let $=this.register();for(let O of $){let T=new O;this.policiesList[O.name]=T}}register(){return[]}}class wz{all($,O){return!0}}import{createHmac as bz,randomBytes as I2}from"crypto";var vZ="v2.";function vz($){return $.startsWith(vZ)}function gz(){let $=process.env.SECRET;if(!$)throw Error("Signing in needs a secret to mint session tokens with. Set SECRET in the environment.");return $}function kz($){let O=I2(16).toString("hex"),T=bz("sha256",gz()).update(`${$}:${O}`).digest("hex");return`${vZ}${T}`}function gZ($,O){let T=bz("sha256",gz()).update(`legacy-session:${O}:${$}`).digest("hex");return`${vZ}${T}`}import{randomBytes as RZ}from"crypto";class kZ extends x{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 lD($){return $}function Rz($={}){return{basePath:"/auth",verifyEmail:!0,redirectPath:"/dashboard",signInPath:"/auth/sign-in",sessionExpiresInHours:24,sessionAbsoluteExpiresInHours:672,cookieDomain:null,migrateLegacySession:null,signUpRequest:kZ,oauthProviders:{},verifyPassword:async(O,T)=>await Bun.password.verify(O,T),hashPassword:async(O)=>await Bun.password.hash(O),generateForgotPasswordToken:async()=>RZ(32).toString("hex"),generateEmailVerificationToken:()=>{if(!($.verifyEmail??!0))return"";return RZ(32).toString("hex")},generateMagicLinkToken:()=>RZ(32).toString("hex"),extendSession:()=>({}),onUserCreated:async()=>{},onSignUp:()=>{},onSignIn:()=>{},onSignOut:()=>{},onForgotPassword:()=>{},onResetPassword:()=>{},onMagicLinkCreated:()=>{}}}function yZ($){if($&&typeof $==="object")delete $.password;return $}function V2(){return new Proxy({},{get:($,O)=>yz(O)})}var mZ={select:{id:!0,publicId:!0,email:!0,name:!0,locale:!0,globalRole:!0,accounts:{select:{id:!0,publicId:!0,organizationRole:!0,organization:!0}}}};class qZ{models;constructor($=V2()){this.models=$}run($){return this.models.User.asSystem($)}transaction($){return this.models.User.transaction($)}async createUser($){let O=await this.run(()=>this.models.User.create({data:$}));return yZ(O)}async updateUserPassword($){let O=await this.run(()=>this.models.User.update({where:{id:$.id},data:{password:$.password}}));return yZ(O)}async findUserByEmailAddress($,O){return await this.run(()=>this.models.User.findUnique({where:O?{email:$,emailVerifiedAt:{not:null}}:{email:$}}))}async findUserByVerificationToken($){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:{token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:mZ}}))}async findSession($){if(!$.token)return null;try{return await this.run(()=>this.models.Session.findUnique({where:{token:$.token},select:{token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:mZ}}))}catch(O){return console.error("findSession failed:",O),null}}async updateSession($){return await this.run(()=>this.models.Session.update({where:{token:$.token},data:{expiresAt:$.expiresAt},select:{token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:mZ}}))}async deleteSession($){if(!$.token)return;await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}))}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($){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($,O){return await this.run(()=>this.models.OrganizationInvitation.findFirst({where:{publicId:$,email:O}}))}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($){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 deleteMagicLinkToken($){await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{email:$}}))}async createSocialAccount($){return await this.run(()=>this.models.SocialAccount.create({data:$}))}async findUserBySocialAccount($,O){if(!O)return null;let T=await this.run(()=>this.models.SocialAccount.findFirst({where:{provider:$,providerId:O},include:{user:!0}}));return T?yZ(T.user):null}async findSocialAccounts($,O){return await this.run(()=>this.models.SocialAccount.findMany({where:{userId:$,provider:O},orderBy:{id:"asc"}}))}async claimSocialAccount($,O){let{count:T}=await this.run(()=>this.models.SocialAccount.updateMany({where:{id:$.id,providerId:$.providerId},data:{providerId:O}}));return T===1}}import{timingSafeEqual as t7}from"crypto";function x0($,O,T,Z,f){return y0(O,ez($,O),T,Z,f)}function y0($,O,T,Z,f,j){let z=lZ(O,T,Z);if(f&&O!==z)throw RangeError(R6($,O,T,Z,j));return z}function ez($,O){let T=$[O];if(T===void 0)throw TypeError(S3(O));return T}function z0($){return $!==null&&/object|function/.test(typeof $)}function A0($,O=Map){let T=new O;return(Z,...f)=>{if(T.has(Z))return T.get(Z);let j=$(Z,...f);return T.set(Z,j),j}}function tZ($){return i1({name:$},1)}function i1($,O){return p0((T)=>({value:T,configurable:1,writable:!O}),$)}function $F($){return p0((O)=>({get:O,configurable:1}),$)}function FT($){return{[Symbol.toStringTag]:{value:$,configurable:1}}}function S$($,O){let T={},Z=$.length;for(let f of O)T[$[--Z]]=f;return T}function p0($,O,T){let Z={};for(let f in O)Z[f]=$(O[f],f,T);return Z}function CO($,O,T){let Z={};for(let f=0;f<O.length;f++){let j=O[f];Z[j]=$(j,f,T)}return Z}function N2($,O,T){let Z={};for(let f=0;f<$.length;f++)Z[O[f]]=T[$[f]];return Z}function w0($,O){let T={};for(let Z of $)T[Z]=O[Z];return T}function eZ($,O){let T={};for(let Z in O)$.has(Z)||(T[Z]=O[Z]);return T}function $f($){$={...$};let O=Object.keys($);for(let T of O)$[T]===void 0&&delete $[T];return $}function OF($,O){for(let T of O)if(!(T in $))return 0;return 1}function TF($,O,T){for(let Z of $)if(O[Z]!==T[Z])return 0;return 1}function ZF($,O,T){let Z={...T};for(let f=0;f<O;f++)Z[$[f]]=0;return Z}function b($,...O){return(...T)=>$(...O,...T)}function mz($){return $[0].toUpperCase()+$.substring(1)}function JO($){return $.slice().sort()}function tO($,O){return String(O).padStart($,"0")}function K1($,O){return Math.sign($-O)}function lZ($,O,T){return Math.min(Math.max($,O),T)}function j1($,O){return[Math.floor($/O),TO($,O)]}function TO($,O){return($%O+O)%O}function S1($,O){return[WT($,O),Of($,O)]}function WT($,O){return Math.trunc($/O)||0}function Of($,O){return $%O||0}function sO($){return Math.abs($%1)===0.5}function fF($,O,T){let Z=0,f=0;for(let F=0;F<=O;F++){let W=$[T[F]],C=n0[F],J=m/C,[Y,D]=S1(W,J);Z+=D*C,f+=Y}let[j,z]=S1(Z,m);return[f+j,z]}function CT($,O,T){let Z={};for(let f=O;f>=0;f--){let j=n0[f];Z[T[f]]=WT($,j),$=Of($,j)}return Z}function jF($){return $===v?hT:[]}function zF($){return $===v?SO:[]}function FF($){return $===v?["year","day"]:[]}function WF($){if($!==void 0)return h($)}function CF($){if($!==void 0)return i0($)}function Tf($){if($!==void 0)return DO($)}function i0($){return YF(DO($))}function DO($){return DF(G4($))}function Zf($){if($==null)throw TypeError("Cannot be null or undefined");return $}function JF($,O){if(O==null)throw RangeError(S3($));return O}function F1($){if(!z0($))throw TypeError(k6);return $}function JT($,O,T=$){if(typeof O!==$)throw TypeError(KO(T,O));return O}function DF($,O="number"){if(!Number.isInteger($))throw RangeError(c2(O,$));return $||0}function YF($,O="number"){if($<=0)throw RangeError(p2(O,$));return $}function ff($){if(typeof $=="symbol")throw TypeError(d2);return String($)}function eO($,O){return z0($)?String($):h($,O)}function DT($){if(typeof $=="string")return BigInt($);if(typeof $!="bigint")throw TypeError(l2($));return $}function XF($,O="number"){if(typeof $=="bigint")throw TypeError(h2(O));if($=Number($),!Number.isFinite($))throw RangeError(i2(O,$));return $}function U0($,O){return Math.trunc(XF($,O))||0}function UF($,O){return DF(XF($,O),O)}function qz($,O){return YF(U0($,O),O)}function jf($,O){let[T,Z]=S1(O,m),f=$+T,j=Math.sign(f);return j&&j===-Math.sign(Z)&&(f-=j,Z+=j*m),[f,Z]}function G$($,O,T=1){return jf($[0]+O[0]*T,$[1]+O[1]*T)}function B$($,O){return jf($[0],$[1]+O)}function g0($,O){return G$(O,$,-1)}function B0($,O){return K1($[0],O[0])||K1($[1],O[1])}function GF($,O,T){return B0($,O)===-1||B0($,T)===1}function YT($,O=1){let T=BigInt(m/O);return[Number($/T),Number($%T)*O]}function K$($,O=1){let T=m/O,[Z,f]=S1($,T);return[Z,f*O]}function BF($,O=1){let[T,Z]=$,f=Math.floor(Z/O),j=m/O;return BigInt(T)*BigInt(j)+BigInt(f)}function k0($,O=1,T){let[Z,f]=$,[j,z]=S1(f,O);return Z*(m/O)+(j+(T?z/O:0))}function zf($,O,T=j1){let[Z,f]=$,[j,z]=T(f,O);return[Z*(m/O)+j,z]}function Ff($,O){let T=$.formatToParts(O),Z={};for(let f of T)Z[f.type]=f.value;return Z}function Wf($){return x0($,"isoYear",WO,FO,1),$.isoYear===WO?x0($,"isoMonth",4,12,1):$.isoYear===FO&&x0($,"isoMonth",1,9,1),$}function L1($){return W1({...$,...c0,isoHour:12}),$}function W1($){let O=x0($,"isoYear",WO,FO,1),T=O===WO?1:O===FO?-1:0;return T&&R0(G0({...$,isoDay:$.isoDay+T,isoNanosecond:$.isoNanosecond-T})),$}function R0($){if(!$||GF($,I4,M4))throw RangeError(qT);return $}function M1($){return fF($,5,s0)[1]}function XT($){let[O,T]=j1($,m);return[CT(T,5,s0),O]}function KF($){return LF($)[0]}function LF($){return zf($,q0)}function K0($){return M$($.isoYear,$.isoMonth,$.isoDay,$.isoHour,$.isoMinute,$.isoSecond,$.isoMillisecond)}function G0($){let O=K0($);if(O!==void 0){let[T,Z]=S1(O,P0);return[T,Z*o0+($.isoMicrosecond||0)*r1+($.isoNanosecond||0)]}}function Cf($,O){let[T,Z]=XT(M1($)-O);return R0(G0({...$,isoDay:$.isoDay+Z,...T}))}function $T(...$){return M$(...$)/u6}function M$(...$){let[O,T]=QF(...$),Z=O.valueOf();if(!isNaN(Z))return Z-T*P0}function QF($,O=1,T=1,Z=0,f=0,j=0,z=0){let F=$===WO?1:$===FO?-1:0,W=new Date;return W.setUTCHours(Z,f,j,z),W.setUTCFullYear($,O-1,T+F),[W,F]}function V1($,O){let[T,Z]=B$($,O);Z<0&&(Z+=m,T-=1);let[f,j]=j1(Z,o0),[z,F]=j1(j,r1);return UT(T*P0+f,z,F)}function UT($,O=0,T=0){let Z=Math.ceil(Math.max(0,Math.abs($)-S4)/P0)*Math.sign($),f=new Date($-Z*P0);return S$(dT,[f.getUTCFullYear(),f.getUTCMonth()+1,f.getUTCDate()+Z,f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds(),f.getUTCMilliseconds(),O,T])}function SF($){return[$.isoYear,$.isoMonth,$.isoDay]}function MF(){return f1}function Jf($,O){switch(O){case 2:return Df($)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function IF($){return Df($)?366:365}function Df($){return $%4==0&&($%100!=0||$%400==0)}function VF($){let[O,T]=QF($.isoYear,$.isoMonth,$.isoDay);return TO(O.getUTCDay()-T,7)||7}function NF({isoYear:$}){return $<1?["bce",1-$]:["ce",$]}function E2($){let O=K0($);if(O<N4)return NF($);let T=Ff(m3(L$),O),{era:Z,eraYear:f}=kW(T,L$);return[Z,f]}function GT($){return h1($),BT($,1),$}function h1($){return EF($,1),$}function cz($){return TF(H3,$,EF($))}function EF($,O){let{isoYear:T}=$,Z=x0($,"isoMonth",1,MF(),O);return{isoYear:T,isoMonth:Z,isoDay:x0($,"isoDay",1,Jf(T,Z),O)}}function BT($,O){return S$(s0,[x0($,"isoHour",0,23,O),x0($,"isoMinute",0,59,O),x0($,"isoSecond",0,59,O),x0($,"isoMillisecond",0,999,O),x0($,"isoMicrosecond",0,999,O),x0($,"isoNanosecond",0,999,O)])}function k($){return $===void 0?0:JC(F1($))}function YO($,O=0){$=h0($);let T=DC($),Z=g4($,O);return[JC($),Z,T]}function Yf($){return DC(h0($))}function xF($){return $=h0($),v3($,9,6,1)}function I$($,O,T,Z=9,f=0,j=4){O=h0(O);let z=v3(O,Z,f),F=Gf(O),W=IO(O,j),C=MO(O,Z,f,1);return z==null?z=Math.max(T,C):HF(z,C),F=Bf(F,C,1),$&&(W=((J)=>J<4?(J+2)%4:J)(W)),[z,C,F,W]}function KT($,O=6,T){let Z=Gf($=Kf($,zT)),f=IO($,7),j=MO($,O);return j=JF(zT,j),Z=Bf(Z,j,void 0,T),[j,Z,f]}function Xf($){return g3(h0($))}function _F($,O){return Uf(h0($),O)}function Uf($,O=4){let T=AF($);return[IO($,4),...PF(MO($,O),T)]}function PF($,O){return $!=null?[n0[$],$<4?9-3*$:-1]:[O===void 0?1:10**(9-O),O]}function Gf($){let O=$[ZO];return O===void 0?1:U0(O,ZO)}function Bf($,O,T,Z){let f=Z?m:n0[O+1];if(f){let j=n0[O];if(f%(($=y0(ZO,$,1,f/j-(Z?0:1),1))*j))throw RangeError(KO(ZO,$))}else $=y0(ZO,$,1,T?1e9:1,1);return $}function AF($){let O=$[hZ];if(O!==void 0){if(typeof O!="number"){if(ff(O)==="auto")return;throw RangeError(KO(hZ,O))}O=y0(hZ,Math.floor(O),0,9,1)}return O}function h0($){return $===void 0?{}:F1($)}function Kf($,O){return typeof $=="string"?{[O]:$}:F1($)}function n($){if($!==void 0){if(z0($))return Object.assign(Object.create(null),$);throw TypeError(k6)}}function LT($,O){return $&&Object.assign(Object.create(null),$,{overflow:x4[O]})}function Lf($,O,T=9,Z=0,f){let j=O[$];if(j===void 0)return f?Z:void 0;if(j=ff(j),j==="auto")return f?Z:null;let z=aZ[j];if(z===void 0&&(z=L4[j]),z===void 0)throw RangeError(q6($,j,aZ));return y0($,z,Z,T,1,QO),z}function l1($,O,T,Z=0){let f=T[$];if(f===void 0)return Z;let j=ff(f),z=O[j];if(z===void 0)throw RangeError(q6($,j,O));return z}function HF($,O){if(O>$)throw RangeError(J4)}function F0($){return{branding:uT,epochNanoseconds:$}}function J0($,O,T){return{branding:Y1,calendar:T,timeZone:O,epochNanoseconds:$}}function o($,O=$.calendar){return{branding:e1,calendar:O,...w0(zC,$)}}function r($,O=$.calendar){return{branding:t1,calendar:O,...w0(w3,$)}}function c1($,O=$.calendar){return{branding:H$,calendar:O,...w0(w3,$)}}function OT($,O=$.calendar){return{branding:w$,calendar:O,...w0(w3,$)}}function l0($){return{branding:sT,...w0(jC,$)}}function i($){return{branding:aT,sign:N1($),...w0(_3,$)}}function wF($){return KF($.epochNanoseconds)}function QT($){return zf($.epochNanoseconds,o0)[0]}function bF($){return BF($.epochNanoseconds,r1)}function vF($){return BF($.epochNanoseconds)}function gF($){return $.epochNanoseconds}function W0($){return typeof $=="string"?$:h($.id)}function V$($,O){return $===O||W0($)===W0(O)}function kF($,O,T,Z,f){let j=p1(Z),[z,F]=((B,L)=>{let M=L((B=Kf(B,rZ))[WC]),Q=v4(B);return Q=JF(rZ,Q),[Q,M]})(f,$);if(jO(Math.max(z,j),F))return pz(Z,z);if(!F)throw RangeError(cT);let[W,C,J]=ET(O,T,F),Y=hf(J),D=xT(J),U=lf(J),X=D(C,W,Z),G=U(C,W,X,z);return jO(z,F)?pz(G,z):((B,L,M,Q,E,_,S)=>{let I=N1(B),[P,A]=Qf(Q,A3(M,B),M,I,E,_,S),T0=Sf(L,P,A);return B[R[M]]+T0*I})(G,Y(X),z,C,W,Y,D)}function pz($,O){return k0(j0($),n0[O],1)}function Qf($,O,T,Z,f,j,z){let F=R[T],W={...O,[F]:O[F]+Z},C=z($,f,O),J=z($,f,W);return[j(C),j(J)]}function Sf($,O,T){let Z=k0(g0(O,T));if(!Z)throw RangeError(LO);return k0(g0(O,$))/Z}function RF($,O){let[T,Z,f]=KT(O,5,1);return F0(MT($.epochNanoseconds,T,Z,f,1))}function yF($,O,T){let{epochNanoseconds:Z,timeZone:f,calendar:j}=O,[z,F,W]=KT(T);if(z===0&&F===1)return O;let C=$(f);if(z===6)Z=((J,Y,D,U)=>{let X=L0(D,Y),[G,B]=J(X),L=D.epochNanoseconds,M=H0(Y,G),Q=H0(Y,B);if(GF(L,M,Q))throw RangeError(LO);return sF(Sf(L,M,Q),U)?Q:M})(lF,C,O,W);else{let J=C.getOffsetNanosecondsFor(Z);Z=s1(C,iF(V1(Z,J),z,F,W),J,2,0,1)}return J0(Z,f,j)}function mF($,O){return o(iF($,...KT(O)),$.calendar)}function qF($,O){let[T,Z,f]=KT(O,5);var j;return l0((j=f,Mf($,XO(T,Z),j)[0]))}function cF($,O){let T=$(O.timeZone),Z=L0(O,T),[f,j]=lF(Z),z=k0(g0(H0(T,f),H0(T,j)),iT,1);if(z<=0)throw RangeError(LO);return z}function pF($,O){let{timeZone:T,calendar:Z}=O,f=((j,z,F)=>H0(z,j(L0(F,z))))(dF,$(T),O);return J0(f,T,Z)}function iF($,O,T,Z){return hF($,XO(O,T),Z)}function hF($,O,T){let[Z,f]=Mf($,O,T);return W1({...u1($,f),...Z})}function Mf($,O,T){return XT(I1(M1($),O,T))}function TT($){return I1($,pT,7)}function XO($,O){return n0[$]*O}function lF($){let O=dF($);return[O,u1(O,1)]}function dF($){return Q4(6,$)}function x2($,O,T){let Z=Math.min(p1($),6);return E$(IT(j0($,Z),O,T),Z)}function ST($,O,T,Z,f,j,z,F,W,C){if(Z===0&&f===1)return $;let J=jO(Z,F)?_T(F)&&Z<6&&T>=6?P2:_2:A2,[Y,D,U]=J($,O,T,Z,f,j,z,F,W,C);return U&&Z!==7&&(Y=((X,G,B,L,M,Q,E,_)=>{let S=N1(X);for(let I=L+1;I<=B;I++){if(I===7&&B!==7)continue;let P=A3(I,X);P[R[I]]+=S;let A=k0(g0(E(_(M,Q,P)),G));if(A&&Math.sign(A)!==S)break;X=P}return X})(Y,D,T,Math.max(6,Z),z,F,W,C)),Y}function MT($,O,T,Z,f){if(O===6){let j=((z)=>z[0]+z[1]/m)($);return[I1(j,T,Z),0]}return IT($,XO(O,T),Z,f)}function IT($,O,T,Z){let[f,j]=$;Z&&j<0&&(j+=m,f-=1);let[z,F]=j1(I1(j,O,T),m);return jf(f+z,F)}function I1($,O,T){return sF($/O,T)*O}function sF($,O){return y4[O]($)}function _2($,O,T,Z,f,j){let z=N1($),F=j0($),W=MT(F,Z,f,j),C=g0(F,W),J=Math.sign(W[0]-F[0])===z,Y=E$(W,Math.min(T,6));return[{...$,...Y},G$(O,C),J]}function P2($,O,T,Z,f,j,z,F,W,C){let J=N1($),Y=k0(j0($,5)),D=XO(Z,f),U=I1(Y,D,j),[X,G]=Qf(z,{...$,...P3},6,J,F,W,C),B=U-k0(g0(X,G)),L=0;B&&Math.sign(B)!==J?O=B$(X,U):(L+=J,U=I1(B,D,j),O=B$(G,U));let M=AT(U);return[{...$,...M,days:$.days+L},O,Boolean(L)]}function A2($,O,T,Z,f,j,z,F,W,C){let J=N1($),Y=R[Z],D=A3(Z,$);Z===7&&($={...$,weeks:$.weeks+Math.trunc($.days/7)});let U=WT($[Y],f)*f;D[Y]=U;let[X,G]=Qf(z,D,Z,f*J,F,W,C),B=U+Sf(O,X,G)*J*f,L=I1(B,f,j),M=Math.sign(L-B)===J;return D[Y]=L,[D,M?G:X,M]}function If($,O,T,Z){let[f,j,z,F]=((C)=>{let J=Uf(C=h0(C));return[C.timeZone,...J]})(Z),W=f!==void 0;return((C,J,Y,D,U,X)=>{Y=IT(Y,U,D,1);let G=J.getOffsetNanosecondsFor(Y);return Af(V1(Y,G),X)+(C?d1(TT(G)):"Z")})(W,O(W?$(f):$$),T.epochNanoseconds,j,z,F)}function Vf($,O,T){let[Z,f,j,z,F,W]=((C)=>{C=h0(C);let J=g3(C),Y=AF(C),D=R4(C),U=IO(C,4),X=MO(C,4);return[J,k4(C),D,U,...PF(X,Y)]})(T);return((C,J,Y,D,U,X,G,B,L,M)=>{D=IT(D,L,B,1);let Q=C(Y).getOffsetNanosecondsFor(D);return Af(V1(D,Q),M)+d1(TT(Q),G)+((E,_)=>_!==1?"["+(_===2?"!":"")+W0(E)+"]":"")(Y,X)+Hf(J,U)})($,O.calendar,O.timeZone,O.epochNanoseconds,Z,f,j,z,F,W)}function Nf($,O){let[T,Z,f,j]=((C)=>(C=h0(C),[g3(C),...Uf(C)]))(O);return z=$.calendar,F=T,W=j,Af(hF($,f,Z),W)+Hf(z,F);var z,F,W}function Ef($,O){return T=$.calendar,Z=$,f=Xf(O),ZT(Z)+Hf(T,f);var T,Z,f}function xf($,O){return uF($.calendar,aF,$,Xf(O))}function _f($,O){return uF($.calendar,H2,$,Xf(O))}function Pf($,O){let[T,Z,f]=_F(O);return j=f,nF(Mf($,Z,T)[0],j);var j}function VT($,O){let[T,Z,f]=_F(O,3);return Z>1&&($={...$,...x2($,Z,T)}),((j,z)=>{let{sign:F}=j,W=F===-1?Q0(j):j,{hours:C,minutes:J}=W,[Y,D]=zf(j0(W,3),q0,S1);ZW(Y);let U=wf(D,z),X=z>=0||!F||U;return(F<0?"-":"")+"P"+iz({Y:q1(W.years),M:q1(W.months),W:q1(W.weeks),D:q1(W.days)})+(C||J||Y||X?"T"+iz({H:q1(C),M:q1(J),S:q1(Y,X)+U}):"")})($,f)}function uF($,O,T,Z){let f=W0($),j=Z>1||Z===0&&f!==v;return Z===1?f===v?O(T):ZT(T):j?ZT(T)+oF(f,Z===2):O(T)}function iz($){let O=[];for(let T in $){let Z=$[T];Z&&O.push(Z,T)}return O.join("")}function Af($,O){return ZT($)+"T"+nF($,O)}function ZT($){return aF($)+"-"+m0($.isoDay)}function aF($){let{isoYear:O}=$;return(O<0||O>9999?rF(O)+tO(6,Math.abs(O)):tO(4,O))+"-"+m0($.isoMonth)}function H2($){return m0($.isoMonth)+"-"+m0($.isoDay)}function nF($,O){let T=[m0($.isoHour),m0($.isoMinute)];return O!==-1&&T.push(m0($.isoSecond)+((Z,f,j,z)=>wf(Z*o0+f*r1+j,z))($.isoMillisecond,$.isoMicrosecond,$.isoNanosecond,O)),T.join(":")}function d1($,O=0){if(O===1)return"";let[T,Z]=j1(Math.abs($),iT),[f,j]=j1(Z,pT),[z,F]=j1(j,q0);return rF($)+m0(T)+":"+m0(f)+(z||F?":"+m0(z)+wf(F):"")}function Hf($,O){if(O!==1){let T=W0($);if(O>1||O===0&&T!==v)return oF(T,O===2)}return""}function oF($,O){return"["+(O?"!":"")+"u-ca="+$+"]"}function wf($,O){let T=tO(9,$);return T=O===void 0?T.replace(c4,""):T.slice(0,O),T?"."+T:""}function rF($){return $<0?"-":"+"}function q1($,O){return $||O?$.toLocaleString("fullwide",{useGrouping:0}):""}function w2($,O){let{epochNanoseconds:T}=$,Z=(O.getOffsetNanosecondsFor?O:O($.timeZone)).getOffsetNanosecondsFor(T),f=V1(T,Z);return{calendar:$.calendar,...f,offsetNanoseconds:Z}}function tF($,O){let T=L0(O,$);return{calendar:O.calendar,...w0(zC,T),offset:d1(T.offsetNanoseconds),timeZone:O.timeZone}}function s1($,O,T,Z=0,f=0,j,z){if(T!==void 0&&Z===1&&(Z===1||z))return Cf(O,T);let F=$.getPossibleInstantsFor(O);if(T!==void 0&&Z!==3){let W=((C,J,Y,D)=>{let U=G0(J);D&&(Y=TT(Y));for(let X of C){let G=k0(g0(X,U));if(D&&(G=TT(G)),G===Y)return X}})(F,O,T,j);if(W!==void 0)return W;if(Z===0)throw RangeError(f4)}return z?G0(O):H0($,O,f,F)}function H0($,O,T=0,Z=$.getPossibleInstantsFor(O)){if(Z.length===1)return Z[0];if(T===1)throw RangeError(j4);if(Z.length)return Z[T===3?1:0];let f=G0(O),j=((F,W)=>{let C=F.getOffsetNanosecondsFor(B$(W,-m));return vf(F.getOffsetNanosecondsFor(B$(W,m))-C)})($,f),z=j*(T===2?-1:1);return(Z=$.getPossibleInstantsFor(V1(f,z)))[T===2?0:Z.length-1]}function bf($){if(Math.abs($)>=m)throw RangeError(T4);return $}function vf($){if($>m)throw RangeError(Z4);return $}function gf($,O,T){return F0(R0(G$(O.epochNanoseconds,((Z)=>{if(fW(Z))throw RangeError(W4);return j0(Z,5)})($?Q0(T):T))))}function kf($,O,T,Z,f,j=Object.create(null)){let z=O(Z.timeZone),F=$(Z.calendar);return{...Z,...cf(z,F,Z,T?Q0(f):f,j)}}function Rf($,O,T,Z,f=Object.create(null)){let{calendar:j}=T;return o(pf($(j),T,O?Q0(Z):Z,f),j)}function yf($,O,T,Z,f){let{calendar:j}=T;return r(NT($(j),T,O?Q0(Z):Z,f),j)}function mf($,O,T,Z,f=Object.create(null)){let j=T.calendar,z=$(j),F=fO(z,T);O&&(Z=PT(Z)),Z.sign<0&&(F=z.dateAdd(F,{...C0,months:1}),F=u1(F,-1));let W=z.dateAdd(F,Z,f);return c1(fO(z,W),j)}function qf($,O,T){return l0(eF(O,$?Q0(T):T)[0])}function cf($,O,T,Z,f){let j=j0(Z,5),z=T.epochNanoseconds;if(fW(Z)){let F=L0(T,$);z=G$(H0($,{...NT(O,F,{...Z,...P3},f),...w0(s0,F)}),j)}else z=G$(z,j),k(f);return{epochNanoseconds:R0(z)}}function pf($,O,T,Z){let[f,j]=eF(O,T);return W1({...NT($,O,{...T,...P3,days:T.days+j},Z),...f})}function NT($,O,T,Z){if(T.years||T.months||T.weeks)return $.dateAdd(O,T,Z);k(Z);let f=T.days+j0(T,5)[0];return f?L1(u1(O,f)):O}function fO($,O,T=1){return u1(O,T-$.day(O))}function eF($,O){let[T,Z]=j0(O,5),[f,j]=XT(M1($)+Z);return[f,T+j]}function u1($,O){return O?{...$,...UT(K0($)+O*P0)}:$}function ET($,O,T){let Z=$(T.calendar);return _T(T)?[T,Z,O(T.timeZone)]:[{...T,...c0},Z]}function hf($){return $?gF:G0}function xT($){return $?b(cf,$):pf}function lf($){return $?b(v2,$):g2}function _T($){return $&&$.epochNanoseconds}function jO($,O){return $<=6-(_T(O)?1:0)}function df($,O,T,Z,f,j,z){let F=$(h0(z).relativeTo),W=Math.max(p1(f),p1(j));if(jO(W,F))return i(N$(((G,B,L,M)=>{let Q=G$(j0(G),j0(B),M?-1:1);if(!Number.isFinite(Q[0]))throw RangeError(qT);return{...C0,...E$(Q,L)}})(f,j,W,Z)));if(!F)throw RangeError(cT);Z&&(j=Q0(j));let[C,J,Y]=ET(O,T,F),D=xT(Y),U=lf(Y),X=D(J,C,f);return i(U(J,C,D(J,X,j),W))}function $W($,O,T,Z,f){let j=p1(Z),[z,F,W,C,J]=((S,I,P)=>{S=Kf(S,zT);let A=v3(S),T0=P(S[WC]),g=Gf(S),y=IO(S,7),Z0=MO(S);if(A===void 0&&Z0===void 0)throw RangeError(C4);return Z0==null&&(Z0=0),A==null&&(A=Math.max(Z0,I)),HF(A,Z0),g=Bf(g,Z0,1),[A,Z0,g,y,T0]})(f,j,$),Y=Math.max(j,z);if(!_T(J)&&Y<=6)return i(N$(((S,I,P,A,T0)=>{let g=MT(j0(S),P,A,T0);return{...C0,...E$(g,I)}})(Z,z,F,W,C)));if(!J)throw RangeError(cT);let[D,U,X]=ET(O,T,J),G=hf(X),B=xT(X),L=lf(X),M=B(U,D,Z),Q=L(U,D,M,z),E=Z.sign,_=N1(Q);if(E&&_&&E!==_)throw RangeError(LO);return _&&(Q=ST(Q,G(M),z,F,W,C,U,D,G,B)),i(Q)}function OW($){return $.sign===-1?PT($):$}function PT($){return i(Q0($))}function Q0($){let O={};for(let T of R)O[T]=-1*$[T]||0;return O}function TW($){return!$.sign}function N1($,O=R){let T=0;for(let Z of O){let f=Math.sign($[Z]);if(f){if(T&&T!==f)throw RangeError(F4);T=f}}return T}function N$($){for(let O of K4)y0(O,$[O],-nz,nz,1);return ZW(k0(j0($),q0)),$}function ZW($){if(!Number.isSafeInteger($))throw RangeError(z4)}function j0($,O=6){return fF($,O,R)}function E$($,O=6){let[T,Z]=$,f=CT(Z,O,R);if(f[R[O]]+=T*(m/n0[O]),!Number.isFinite(f[R[O]]))throw RangeError(qT);return f}function AT($,O=5){return CT($,O,R)}function fW($){return Boolean(N1($,fC))}function p1($){let O=9;for(;O>0&&!$[R[O]];O--);return O}function b2($,O){return[$,O]}function hz($){let O=Math.floor($/oO)*oO;return[O,O+oO]}function jW($){let O=E1($=eO($));if(!O)throw RangeError(_0($));let T;if(O.m)T=0;else{if(!O.offset)throw RangeError(_0($));T=x$(O.offset)}return O.timeZone&&nf(O.timeZone,1),F0(Cf(GT(O),T))}function zW($){let O=E1(h($));if(!O)throw RangeError(_0($));if(O.timeZone)return GW(O,O.offset?x$(O.offset):void 0);if(O.m)throw RangeError(_0($));return KW(O)}function FW($,O){let T=E1(h($));if(!T||!T.timeZone)throw RangeError(_0($));let{offset:Z}=T,f=Z?x$(Z):void 0,[,j,z]=YO(O);return GW(T,f,j,z)}function x$($){let O=nf($);if(O===void 0)throw RangeError(_0($));return O}function WW($){let O=E1(h($));if(!O||O.m)throw RangeError(_0($));return o(BW(O))}function HT($){let O=E1(h($));if(!O||O.m)throw RangeError(_0($));return r(O.p?BW(O):KW(O))}function CW($,O){let T=uf(h(O));if(T)return sf(T),c1(Wf(h1(T)));let Z=HT(O);return c1(fO($(Z.calendar),Z))}function sf($){if($.calendar!==v)throw RangeError(z1($.calendar))}function JW($,O){let T=af(h(O));if(T)return sf(T),OT(h1(T));let Z=HT(O),{calendar:f}=Z,j=$(f),[z,F,W]=j.h(Z),[C,J]=j.I(z,F),[Y,D]=j.N(C,J,W);return OT(L1(j.P(Y,D,W)),f)}function DW($){let O,T=((Z)=>{let f=d4.exec(Z);return f?(wT(f[10]),SW(f)):void 0})(h($));if(!T){if(T=E1($),!T)throw RangeError(_0($));if(!T.p)throw RangeError(_0($));if(T.m)throw RangeError(z1("Z"));sf(T)}if((O=uf($))&&cz(O))throw RangeError(_0($));if((O=af($))&&cz(O))throw RangeError(_0($));return l0(BT(T,1))}function YW($){let O=((T)=>{let Z=a4.exec(T);return Z?((f)=>{function j(J,Y,D){let U=0,X=0;if(D&&([U,W]=j1(W,n0[D])),J!==void 0){if(F)throw RangeError(z1(J));X=((G)=>{let B=parseInt(G);if(!Number.isFinite(B))throw RangeError(z1(G));return B})(J),z=1,Y&&(W=of(Y)*(n0[D]/q0),F=1)}return U+X}let z=0,F=0,W=0,C={...S$(R,[j(f[2]),j(f[3]),j(f[4]),j(f[5]),j(f[6],f[7],5),j(f[8],f[9],4),j(f[10],f[11],3)]),...CT(W,2,R)};if(!z)throw RangeError(y6(R));return rf(f[1])<0&&(C=Q0(C)),C})(Z):void 0})(h($));if(!O)throw RangeError(_0($));return i(N$(O))}function XW($){let O=E1($)||uf($)||af($);return O?O.calendar:$}function UW($){let O=E1($);return O&&(O.timeZone||O.m&&$$||O.offset)||$}function GW($,O,T=0,Z=0){let f=bT($.timeZone),j=nT(f);return J0(s1(j,GT($),O,T,Z,!j.v,$.m),f,UO($.calendar))}function BW($){return LW(W1(GT($)))}function KW($){return LW(L1(h1($)))}function LW($){return{...$,calendar:UO($.calendar)}}function E1($){let O=l4.exec($);return O?((T)=>{let Z=T[10],f=(Z||"").toUpperCase()==="Z";return{isoYear:QW(T),isoMonth:parseInt(T[4]),isoDay:parseInt(T[5]),...SW(T.slice(5)),...wT(T[16]),p:Boolean(T[6]),m:f,offset:f?void 0:Z}})(O):void 0}function uf($){let O=i4.exec($);return O?((T)=>({isoYear:QW(T),isoMonth:parseInt(T[4]),isoDay:1,...wT(T[5])}))(O):void 0}function af($){let O=h4.exec($);return O?((T)=>({isoYear:Q$,isoMonth:parseInt(T[1]),isoDay:parseInt(T[2]),...wT(T[3])}))(O):void 0}function nf($,O){let T=s4.exec($);return T?((Z,f)=>{let j=Z[4]||Z[5];if(f&&j)throw RangeError(z1(j));return bf((U$(Z[2])*iT+U$(Z[3])*pT+U$(Z[4])*q0+of(Z[5]||""))*rf(Z[1]))})(T,O):void 0}function QW($){let O=rf($[1]),T=parseInt($[2]||$[3]);if(O<0&&!T)throw RangeError(z1(-0));return O*T}function SW($){let O=U$($[3]);return{...XT(of($[4]||""))[0],isoHour:U$($[1]),isoMinute:U$($[2]),isoSecond:O===60?59:O}}function wT($){let O,T,Z=[];if($.replace(u4,(f,j,z)=>{let F=Boolean(j),[W,C]=z.split("=").reverse();if(C){if(C==="u-ca")Z.push(W),O||(O=F);else if(F||/[A-Z]/.test(C))throw RangeError(z1(f))}else{if(T)throw RangeError(z1(f));T=W}return""}),Z.length>1&&O)throw RangeError(z1($));return{timeZone:T,calendar:Z[0]||v}}function of($){return parseInt($.padEnd(9,"0"))}function _$($){return new RegExp(`^${$}$`,"i")}function rf($){return $&&$!=="+"?-1:1}function U$($){return $===void 0?0:parseInt($)}function MW($){return bT(h($))}function bT($){let O=tf($);return typeof O=="number"?d1(O):O?((T)=>{if(o4.test(T))throw RangeError(O4);return T.toLowerCase().split("/").map((Z,f)=>(Z.length<=3||/\d/.test(Z))&&!/etc|yap/.test(Z)?Z.toUpperCase():Z.replace(/baja|dumont|[a-z]+/g,(j,z)=>j.length<=2&&!f||j==="in"||j==="chat"?j.toUpperCase():j.length>2||!z?mz(j).replace(/island|noronha|murdo|rivadavia|urville/,mz):j)).join("/")})($):$$}function lz($){let O=tf($);return typeof O=="number"?O:O?O.resolvedOptions().timeZone:$$}function tf($){let O=nf($=$.toUpperCase(),1);return O!==void 0?O:$!==$$?n4($):void 0}function ef($,O){return B0($.epochNanoseconds,O.epochNanoseconds)}function $3($,O){return B0($.epochNanoseconds,O.epochNanoseconds)}function IW($,O,T,Z,f,j){let z=$(h0(j).relativeTo),F=Math.max(p1(Z),p1(f));if(TF(R,Z,f))return 0;if(jO(F,z))return B0(j0(Z),j0(f));if(!z)throw RangeError(cT);let[W,C,J]=ET(O,T,z),Y=hf(J),D=xT(J);return B0(Y(D(C,W,Z)),Y(D(C,W,f)))}function O3($,O){return a1($,O)||vT($,O)}function a1($,O){return K1(K0($),K0(O))}function vT($,O){return K1(M1($),M1(O))}function VW($,O){return!ef($,O)}function NW($,O){return!$3($,O)&&!!gT($.timeZone,O.timeZone)&&V$($.calendar,O.calendar)}function EW($,O){return!O3($,O)&&V$($.calendar,O.calendar)}function xW($,O){return!a1($,O)&&V$($.calendar,O.calendar)}function _W($,O){return!a1($,O)&&V$($.calendar,O.calendar)}function PW($,O){return!a1($,O)&&V$($.calendar,O.calendar)}function AW($,O){return!vT($,O)}function gT($,O){if($===O)return 1;let T=W0($),Z=W0(O);if(T===Z)return 1;try{return lz(T)===lz(Z)}catch(f){}}function T3($,O,T,Z){let f=I$($,n(Z),3,5),j=kT(O.epochNanoseconds,T.epochNanoseconds,...f);return i($?Q0(j):j)}function Z3($,O,T,Z,f,j){let z=yT(Z.calendar,f.calendar),F=n(j),[W,C,J,Y]=I$(T,F,5),D=Z.epochNanoseconds,U=f.epochNanoseconds,X=B0(U,D),G;if(X)if(W<6)G=kT(D,U,W,C,J,Y);else{let B=O(((M,Q)=>{if(!gT(M,Q))throw RangeError(h6);return M})(Z.timeZone,f.timeZone)),L=$(z);G=wW(L,B,Z,f,X,W,F),G=ST(G,U,W,C,J,Y,L,Z,gF,b(cf,B))}else G=C0;return i(T?Q0(G):G)}function f3($,O,T,Z,f){let j=yT(T.calendar,Z.calendar),z=n(f),[F,W,C,J]=I$(O,z,6),Y=G0(T),D=G0(Z),U=B0(D,Y),X;if(U)if(F<=6)X=kT(Y,D,F,W,C,J);else{let G=$(j);X=bW(G,T,Z,U,F,z),X=ST(X,D,F,W,C,J,G,T,G0,pf)}else X=C0;return i(O?Q0(X):X)}function j3($,O,T,Z,f){let j=yT(T.calendar,Z.calendar),z=n(f);return HW(O,()=>$(j),T,Z,...I$(O,z,6,9,6),z)}function z3($,O,T,Z,f){let j=yT(T.calendar,Z.calendar),z=n(f),F=I$(O,z,9,9,8),W=$(j);return HW(O,()=>W,fO(W,T),fO(W,Z),...F,z)}function HW($,O,T,Z,f,j,z,F,W){let C=G0(T),J=G0(Z),Y;if(B0(J,C))if(f===6)Y=kT(C,J,f,j,z,F);else{let D=O();Y=D.dateUntil(T,Z,f,W),j===6&&z===1||(Y=ST(Y,J,f,j,z,F,D,T,G0,NT))}else Y=C0;return i($?Q0(Y):Y)}function F3($,O,T,Z){let f=n(Z),[j,z,F,W]=I$($,f,5,5),C=I1(W3(O,T),XO(z,F),W),J={...C0,...AT(C,j)};return i($?Q0(J):J)}function v2($,O,T,Z,f,j){let z=B0(Z.epochNanoseconds,T.epochNanoseconds);return z?f<6?vW(T.epochNanoseconds,Z.epochNanoseconds,f):wW(O,$,T,Z,z,f,j):C0}function g2($,O,T,Z,f){let j=G0(O),z=G0(T),F=B0(z,j);return F?Z<=6?vW(j,z,Z):bW($,O,T,F,Z,f):C0}function wW($,O,T,Z,f,j,z){let[F,W,C]=((D,U,X,G)=>{function B(){return I={...u1(Q,_++*-G),...M},P=H0(D,I),B0(E,P)===-G}let L=L0(U,D),M=w0(s0,L),Q=L0(X,D),E=X.epochNanoseconds,_=0,S=W3(L,Q),I,P;if(Math.sign(S)===-G&&_++,B()&&(G===-1||B()))throw RangeError(LO);let A=k0(g0(P,E));return[L,I,A]})(O,T,Z,f);var J,Y;return{...j===6?(J=F,Y=W,{...C0,days:gW(J,Y)}):$.dateUntil(F,W,j,z),...AT(C)}}function bW($,O,T,Z,f,j){let[z,F,W]=((C,J,Y)=>{let D=J,U=W3(C,J);return Math.sign(U)===-Y&&(D=u1(J,-Y),U+=m*Y),[C,D,U]})(O,T,Z);return{...$.dateUntil(z,F,f,j),...AT(W)}}function kT($,O,T,Z,f,j){return{...C0,...E$(MT(g0($,O),Z,f,j),T)}}function vW($,O,T){return{...C0,...E$(g0($,O),T)}}function gW($,O){return RT(K0($),K0(O))}function RT($,O){return Math.trunc((O-$)/P0)}function W3($,O){return M1(O)-M1($)}function yT($,O){if(!V$($,O))throw RangeError(V3);return $}function k2($){function O(f){return((j,z)=>({...kW(j,z),F:j.month,day:parseInt(j.day)}))(Ff(T,f),Z)}let T=m3($),Z=fT($);return{id:$,O:R2(O),B:y2(O)}}function R2($){return A0((O)=>{let T=K0(O);return $(T)},WeakMap)}function y2($){let O=$(0).year-V4;return A0((T)=>{let Z,f=M$(T-O),j=[],z=[];do f+=400*P0;while((Z=$(f)).year<=T);do f+=(1-Z.day)*P0,Z.year===T&&(j.push(f),z.push(Z.F)),f-=P0;while((Z=$(f)).year>=T);return{k:j.reverse(),C:s6(z.reverse())}})}function kW($,O){let T,Z,f=RW($);if($.era){let j=OC[O];j!==void 0&&(T=O==="islamic"?"ah":$.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),T==="bc"||T==="b"?T="bce":T!=="ad"&&T!=="a"||(T="ce"),Z=f,f=pW(Z,j[T]||0))}return{era:T,eraYear:Z,year:f}}function RW($){return parseInt($.relatedYear||$.year)}function dZ($){let{year:O,F:T,day:Z}=this.O($),{C:f}=this.B(O);return[O,f[T]+1,Z]}function zO($,O=1,T=1){return this.B($).k[O-1]+(T-1)*P0}function uO($){let O=sz(this,$),T=sz(this,$-1),Z=O.length;if(Z>T.length){let f=iW(this);if(f<0)return-f;for(let j=0;j<Z;j++)if(O[j]!==T[j])return j+1}}function aO($){return RT(zO.call(this,$),zO.call(this,$+1))}function dz($,O){let{k:T}=this.B($),Z=O+1,f=T;return Z>T.length&&(Z=1,f=this.B($+1).k),RT(T[O-1],f[Z-1])}function nO($){return this.B($).k.length}function sz($,O){return Object.keys($.B(O).C)}function yW($){return UO(h($))}function UO($){if(($=$.toLowerCase())!==v&&$!==lT&&fT($)!==fT(m3($).resolvedOptions().calendar))throw RangeError($4($));return $}function fT($){return $==="islamicc"&&($="islamic"),$.split("-")[0]}function mW($){return this.R($)[0]}function qW($){return this.R($)[1]}function C3($){let[O]=this.h($);return RT(this.q(O),K0($))+1}function cW($){let O=t4.exec($);if(!O)throw RangeError(t2($));return[parseInt(O[1]),Boolean(O[2])]}function jT($,O,T){return $+(O||T&&$>=T?1:0)}function sZ($,O){return $-(O&&$>=O?1:0)}function pW($,O){return(O+$)*(Math.sign(O)||1)||0}function uZ($){return OC[hW($)]}function iW($){return U4[hW($)]}function hW($){return fT($.id||v)}function lW($,O,T,Z){let f=x1(T,Z,d0,[],r6);if(f.timeZone!==void 0){let j=T.dateFromFields(f),z=n1(f),F=$(f.timeZone);return{epochNanoseconds:s1(O(F),{...j,...z},f.offset!==void 0?x$(f.offset):void 0),timeZone:F}}return{...T.dateFromFields(f),...c0}}function dW($,O,T,Z,f,j){let z=x1(T,f,d0,n6,r6),F=$(z.timeZone),[W,C,J]=YO(j),Y=T.dateFromFields(z,LT(j,W)),D=n1(z,W);return J0(s1(O(F),{...Y,...D},z.offset!==void 0?x$(z.offset):void 0,C,J),F,Z)}function sW($,O,T){let Z=x1($,O,d0,[],D1),f=k(T);return o(W1({...$.dateFromFields(Z,LT(T,f)),...n1(Z,f)}))}function J3($,O,T,Z=[]){let f=x1($,O,d0,Z);return $.dateFromFields(f,T)}function D3($,O,T,Z){let f=x1($,O,x3,Z);return $.yearMonthFromFields(f,T)}function Y3($,O,T,Z,f=[]){let j=x1($,T,d0,f);return O&&j.month!==void 0&&j.monthCode===void 0&&j.year===void 0&&(j.year=Q$),$.monthDayFromFields(j,Z)}function uW($,O){let T=k(O);return l0(n1(a0($,nZ,[],1),T))}function aW($){let O=a0($,_3);return i(N$({...C0,...O}))}function x1($,O,T,Z=[],f=[]){return a0(O,[...$.fields(T),...f].sort(),Z)}function a0($,O,T,Z=!T){let f={},j,z=0;for(let F of O){if(F===j)throw RangeError(s2(F));if(F==="constructor"||F==="__proto__")throw RangeError(M3(F));let W=$[F];if(W!==void 0)z=1,oz[F]&&(W=oz[F](W,F)),f[F]=W;else if(T){if(T.includes(F))throw TypeError(S3(F));f[F]=$C[F]}j=F}if(Z&&!z)throw TypeError(y6(O));return f}function n1($,O){return BT(T5({...$C,...$}),O)}function nW($,O,T,Z,f,j){let z=n(j),{calendar:F,timeZone:W}=T;return J0(((C,J,Y,D,U)=>{let X=GO(C,Y,D,d0,o6,a6),[G,B,L]=YO(U,2);return s1(J,{...C.dateFromFields(X,LT(U,G)),...n1(X,G)},x$(X.offset),B,L)})($(F),O(W),Z,f,z),W,F)}function oW($,O,T,Z,f){let j=n(f);return o(((z,F,W,C)=>{let J=GO(z,F,W,d0,D1),Y=k(C);return W1({...z.dateFromFields(J,LT(C,Y)),...n1(J,Y)})})($(O.calendar),T,Z,j))}function rW($,O,T,Z,f){let j=n(f);return((z,F,W,C)=>{let J=GO(z,F,W,d0);return z.dateFromFields(J,C)})($(O.calendar),T,Z,j)}function tW($,O,T,Z,f){let j=n(f);return c1(((z,F,W,C)=>{let J=GO(z,F,W,x3);return z.yearMonthFromFields(J,C)})($(O.calendar),T,Z,j))}function eW($,O,T,Z,f){let j=n(f);return((z,F,W,C)=>{let J=GO(z,F,W,d0);return z.monthDayFromFields(J,C)})($(O.calendar),T,Z,j)}function $6($,O,T){return l0(((Z,f,j)=>{let z=k(j);return n1({...w0(nZ,Z),...a0(f,nZ)},z)})($,O,T))}function O6($,O){return i((T=$,Z=O,N$({...T,...a0(Z,_3)})));var T,Z}function GO($,O,T,Z,f=[],j=[]){let z=[...$.fields(Z),...f].sort(),F=a0(O,z,j),W=a0(T,z);return F=$.mergeFields(F,W),a0(F,z,[])}function X3($,O){let T=x1($,O,e6);return $.monthDayFromFields(T)}function U3($,O,T){let Z=x1($,O,t6);return $.yearMonthFromFields(Z,T)}function T6($,O,T,Z,f){O=w0(T=$.fields(T),O),Z=a0(Z,f=$.fields(f),[]);let j=$.mergeFields(O,Z);return j=a0(j,[...T,...f].sort(),[]),$.dateFromFields(j)}function cZ($,O){let{era:T,eraYear:Z,year:f}=O,j=uZ($);if(T!==void 0||Z!==void 0){if(T===void 0||Z===void 0)throw TypeError(a2);if(!j)throw RangeError(u2);let z=j[T];if(z===void 0)throw RangeError(o2(T));let F=pW(Z,z);if(f!==void 0&&f!==F)throw RangeError(n2);f=F}else if(f===void 0)throw TypeError(r2(j));return f}function pZ($,O,T,Z){let{month:f,monthCode:j}=O;if(j!==void 0){let z=((F,W,C,J)=>{let Y=F.U(C),[D,U]=cW(W),X=jT(D,U,Y);if(U){let G=iW(F);if(G===void 0)throw RangeError(OO);if(G>0){if(X>G)throw RangeError(OO);if(Y===void 0){if(J===1)throw RangeError(OO);X--}}else{if(X!==-G)throw RangeError(OO);if(Y===void 0&&J===1)throw RangeError(OO)}}return X})($,j,T,Z);if(f!==void 0&&f!==z)throw RangeError(p6);f=z,Z=1}else if(f===void 0)throw TypeError(e2);return y0("month",f,1,$.L(T),Z)}function uz($,O,T,Z,f){return x0(O,"day",1,$.j(Z,T),f)}function iZ($,O,T,Z){let f=0,j=[];for(let z of T)O[z]!==void 0?f=1:j.push(z);if(Object.assign($,O),f)for(let z of Z||j)delete $[z]}function Z6($){return F0(R0(YT(DT($))))}function f6($,O,T,Z,f=v){return J0(R0(YT(DT(T))),O(Z),$(f))}function j6($,O,T,Z,f=0,j=0,z=0,F=0,W=0,C=0,J=v){return o(W1(GT(p0(U0,S$(dT,[O,T,Z,f,j,z,F,W,C])))),$(J))}function z6($,O,T,Z,f=v){return r(L1(h1(p0(U0,{isoYear:O,isoMonth:T,isoDay:Z}))),$(f))}function F6($,O,T,Z=v,f=1){let j=U0(O),z=U0(T),F=$(Z);return c1(Wf(h1({isoYear:j,isoMonth:z,isoDay:U0(f)})),F)}function W6($,O,T,Z=v,f=Q$){let j=U0(O),z=U0(T),F=$(Z);return OT(L1(h1({isoYear:U0(f),isoMonth:j,isoDay:z})),F)}function C6($=0,O=0,T=0,Z=0,f=0,j=0){return l0(BT(p0(U0,S$(s0,[$,O,T,Z,f,j])),1))}function J6($=0,O=0,T=0,Z=0,f=0,j=0,z=0,F=0,W=0,C=0){return i(N$(p0(UF,S$(R,[$,O,T,Z,f,j,z,F,W,C]))))}function G3($,O,T=v){return J0($.epochNanoseconds,O,T)}function D6($){return F0($.epochNanoseconds)}function B3($,O){return o(L0(O,$))}function K3($,O){return r(L0(O,$))}function Y6($,O,T){return U3($(O.calendar),T)}function X6($,O,T){return X3($(O.calendar),T)}function L3($,O){return l0(L0(O,$))}function U6($,O,T,Z){let f=((j,z,F,W)=>{let C=Yf(W);return H0(j(z),F,C)})($,T,O,Z);return J0(R0(f),T,O.calendar)}function G6($,O,T){let Z=$(O.calendar);return c1({...O,...U3(Z,T)})}function B6($,O,T){return X3($(O.calendar),T)}function K6($,O,T,Z,f){let j=$(f.timeZone),z=f.plainTime,F=z!==void 0?O(z):c0;return J0(H0(T(j),{...Z,...F}),j,Z.calendar)}function L6($,O=c0){return o(W1({...$,...O}))}function Q6($,O,T){return U3($(O.calendar),T)}function S6($,O,T){return X3($(O.calendar),T)}function M6($,O,T,Z){return((f,j,z)=>T6(f,j,t6,F1(z),SO))($(O.calendar),T,Z)}function I6($,O,T,Z){return((f,j,z)=>T6(f,j,e6,F1(z),hT))($(O.calendar),T,Z)}function V6($,O,T,Z,f){let j=F1(f),z=O(j.plainDate),F=$(j.timeZone);return J0(H0(T(F),{...z,...Z}),F,z.calendar)}function N6($,O){return o(W1({...$,...O}))}function E6($){return F0(R0(K$($,q0)))}function x6($){return F0(R0(K$($,o0)))}function _6($){return F0(R0(YT(DT($),r1)))}function P6($){return F0(R0(YT(DT($))))}function A6($,O,T=c0){let Z=O.timeZone,f=$(Z),j={...L0(O,f),...T};return J0(s1(f,j,j.offsetNanoseconds,2),Z,O.calendar)}function H6($,O,T){let Z=O.timeZone,f=$(Z),j={...L0(O,f),...T},z=g6(O.calendar,T.calendar);return J0(s1(f,j,j.offsetNanoseconds,2),Z,z)}function w6($,O=c0){return o({...$,...O})}function b6($,O){return o({...$,...O},g6($.calendar,O.calendar))}function mT($,O){return{...$,calendar:O}}function v6($,O){return{...$,timeZone:O}}function g6($,O){if($===O)return $;let T=W0($),Z=W0(O);if(T===Z||T===v)return O;if(Z===v)return $;throw RangeError(V3)}function m2($,O){return(T)=>T===v?$:T===lT||T===L$?Object.assign(Object.create($),{id:T}):Object.assign(Object.create(O),r4(T))}function o1($,O,T){let Z=new Set(T);return(f)=>(((j,z)=>{for(let F of z)if(F in j)return 1;return 0})(f=eZ(Z,f),$)||Object.assign(f,O),T&&(f.timeZone=$$,["full","long"].includes(f.timeStyle)&&(f.timeStyle="medium")),f)}function C1($,O=Q3){let[T,,,Z]=$;return(f,j=L5,...z)=>{let F=O(Z&&Z(...z),f,j,T),W=F.resolvedOptions();return[F,...q2($,W,z)]}}function Q3($,O,T,Z){if(T=Z(T),$){if(T.timeZone!==void 0)throw TypeError(D4);T.timeZone=$}return new _1(O,T)}function q2($,O,T){let[,Z,f]=$;return T.map((j)=>(j.calendar&&((z,F,W)=>{if((W||z!==v)&&z!==F)throw RangeError(V3)})(W0(j.calendar),O.calendar,f),Z(j,O)))}function P$($){let O=BO();return V1(O,$.getOffsetNanosecondsFor(O))}function BO(){return K$(Date.now(),o0)}function J1(){return tz||(tz=new _1().resolvedOptions().timeZone)}var c2=($,O)=>`Non-integer ${$}: ${O}`,p2=($,O)=>`Non-positive ${$}: ${O}`,i2=($,O)=>`Non-finite ${$}: ${O}`,h2=($)=>`Cannot convert bigint to ${$}`,l2=($)=>`Invalid bigint: ${$}`,d2="Cannot convert Symbol to string",k6="Invalid object",R6=($,O,T,Z,f)=>f?R6($,f[O],f[T],f[Z]):KO($,O)+`; must be between ${T}-${Z}`,KO=($,O)=>`Invalid ${$}: ${O}`,S3=($)=>`Missing ${$}`,M3=($)=>`Invalid field ${$}`,s2=($)=>`Duplicate field ${$}`,y6=($)=>"No valid fields: "+$.join(),m6="Invalid bag",q6=($,O,T)=>KO($,O)+"; must be "+Object.keys(T).join(),c6="Cannot use valueOf",I3="Invalid calling context",u2="Forbidden era/eraYear",a2="Mismatching era/eraYear",n2="Mismatching year/eraYear",o2=($)=>`Invalid era: ${$}`,r2=($)=>"Missing year"+($?"/era/eraYear":""),t2=($)=>`Invalid monthCode: ${$}`,p6="Mismatching month/monthCode",e2="Missing month/monthCode",az="Cannot guess year",OO="Invalid leap month",i6="Invalid protocol",LO="Invalid protocol results",V3="Mismatching Calendars",$4=($)=>`Invalid Calendar: ${$}`,h6="Mismatching TimeZones",O4="Forbidden ICU TimeZone",T4="Out-of-bounds offset",Z4="Out-of-bounds TimeZone gap",f4="Invalid TimeZone offset",j4="Ambiguous offset",qT="Out-of-bounds date",z4="Out-of-bounds duration",F4="Cannot mix duration signs",cT="Missing relativeTo",W4="Cannot use large units",C4="Required smallestUnit or largestUnit",J4="smallestUnit > largestUnit",_0=($)=>`Cannot parse: ${$}`,z1=($)=>`Invalid substring: ${$}`,l6=($)=>`Cannot format ${$}`,d6="Mismatching types for formatting",D4="Cannot specify TimeZone",s6=b(CO,($,O)=>O),A$=b(CO,($,O,T)=>T),m0=b(tO,2),aZ={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},QO=Object.keys(aZ),P0=86400000,u6=1000,r1=1000,o0=1e6,q0=1e9,pT=60000000000,iT=3600000000000,m=86400000000000,n0=[1,r1,o0,q0,pT,iT,m],D1=QO.slice(0,6),nZ=JO(D1),a6=["offset"],n6=["timeZone"],o6=D1.concat(a6),r6=o6.concat(n6),oZ=["era","eraYear"],Y4=oZ.concat(["year"]),hT=["year"],N3=["monthCode"],E3=["month"].concat(N3),SO=["day"],x3=E3.concat(hT),t6=N3.concat(hT),d0=SO.concat(x3),X4=SO.concat(E3),e6=SO.concat(N3),$C=A$(D1,0),v="iso8601",lT="gregory",L$="japanese",OC={[lT]:{bce:-1,ce:0},[L$]:{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}},U4={chinese:13,dangi:13,hebrew:-6},h=b(JT,"string"),TC=b(JT,"boolean"),G4=b(JT,"number"),ZC=b(JT,"function"),R=QO.map(($)=>$+"s"),_3=JO(R),B4=R.slice(0,6),fC=R.slice(6),K4=fC.slice(1),L4=s6(R),C0=A$(R,0),P3=A$(B4,0),A3=b(ZF,R),s0=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],H3=["isoDay","isoMonth","isoYear"],dT=s0.concat(H3),w3=JO(H3),jC=JO(s0),zC=JO(dT),c0=A$(jC,0),Q4=b(ZF,dT),_1=Intl.DateTimeFormat,FC="en-GB",b3=1e8,S4=b3*P0,M4=[b3,0],I4=[-b3,0],FO=275760,WO=-271821,V4=1970,Q$=1972,f1=12,N4=M$(1868,9,8),E4=A0(E2,WeakMap),zT="smallestUnit",rZ="unit",ZO="roundingIncrement",hZ="fractionalSecondDigits",WC="relativeTo",CC={constrain:0,reject:1},x4=Object.keys(CC),_4={compatible:0,reject:1,earlier:2,later:3},P4={reject:0,use:1,prefer:2,ignore:3},A4={auto:0,never:1,critical:2,always:3},H4={auto:0,never:1,critical:2},w4={auto:0,never:1},b4={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},MO=b(Lf,zT),v3=b(Lf,"largestUnit"),v4=b(Lf,rZ),JC=b(l1,"overflow",CC),DC=b(l1,"disambiguation",_4),g4=b(l1,"offset",P4),g3=b(l1,"calendarName",A4),k4=b(l1,"timeZoneName",H4),R4=b(l1,"offset",w4),IO=b(l1,"roundingMode",b4),H$="PlainYearMonth",w$="PlainMonthDay",t1="PlainDate",e1="PlainDateTime",sT="PlainTime",Y1="ZonedDateTime",uT="Instant",aT="Duration",y4=[Math.floor,($)=>sO($)?Math.floor($):Math.round($),Math.ceil,($)=>sO($)?Math.ceil($):Math.round($),Math.trunc,($)=>sO($)?Math.trunc($)||0:Math.round($),($)=>$<0?Math.floor($):Math.ceil($),($)=>Math.sign($)*Math.round(Math.abs($))||0,($)=>sO($)?($=Math.trunc($)||0)+$%2:Math.round($)],$$="UTC",oO=5184000,m4=$T(1847),q4=$T(new Date().getUTCFullYear()+10),c4=/0+$/,L0=A0(w2,WeakMap),nz=4294967295,nT=A0(($)=>{let O=tf($);return typeof O=="object"?new XC(O):new YC(O||0)});class YC{constructor($){this.v=$}getOffsetNanosecondsFor(){return this.v}getPossibleInstantsFor($){return[Cf($,this.v)]}l(){}}class XC{constructor($){this.$=((O)=>{function T(W){let C=lZ(W,z,F),[J,Y]=hz(C),D=f(J),U=f(Y);return D===U?D:Z(j(J,Y),D,U,W)}function Z(W,C,J,Y){let D,U;for(;(Y===void 0||(D=Y<W[0]?C:Y>=W[1]?J:void 0)===void 0)&&(U=W[1]-W[0]);){let X=W[0]+Math.floor(U/2);O(X)===J?W[1]=X:W[0]=X+1}return D}let f=A0(O),j=A0(b2),z=m4,F=q4;return{G(W){let C=T(W-86400),J=T(W+86400),Y=W-C,D=W-J;if(C===J)return[Y];let U=T(Y);return U===T(D)?[W-U]:C>J?[Y,D]:[]},V:T,l(W,C){let J=lZ(W,z,F),[Y,D]=hz(J),U=oO*C,X=C<0?()=>D>z||(z=J,0):()=>Y<F||(F=J,0);for(;X();){let G=f(Y),B=f(D);if(G!==B){let L=j(Y,D);Z(L,G,B);let M=L[0];if((K1(M,W)||1)===C)return M}Y+=U,D+=U}}}})(((O)=>(T)=>{let Z=Ff(O,T*u6);return $T(RW(Z),parseInt(Z.month),parseInt(Z.day),parseInt(Z.hour),parseInt(Z.minute),parseInt(Z.second))-T})($))}getOffsetNanosecondsFor($){return this.$.V(KF($))*q0}getPossibleInstantsFor($){let[O,T]=[$T((Z=$).isoYear,Z.isoMonth,Z.isoDay,Z.isoHour,Z.isoMinute,Z.isoSecond),Z.isoMillisecond*o0+Z.isoMicrosecond*r1+Z.isoNanosecond];var Z;return this.$.G(O).map((f)=>R0(B$(K$(f,q0),T)))}l($,O){let[T,Z]=LF($),f=this.$.l(T+(O>0||Z?1:0),O);if(f!==void 0)return K$(f,q0)}}var k3="([+\u2212-])",rO="(?:[.,](\\d{1,9}))?",UC=`(?:(?:${k3}(\\d{6}))|(\\d{4}))-?(\\d{2})`,R3="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+rO+")?)?",y3=k3+R3,p4=UC+"-?(\\d{2})(?:[T ]"+R3+"(Z|"+y3+")?)?",GC="\\[(!?)([^\\]]*)\\]",oT=`((?:${GC}){0,9})`,i4=_$(UC+oT),h4=_$("(?:--)?(\\d{2})-?(\\d{2})"+oT),l4=_$(p4+oT),d4=_$("T?"+R3+"(?:"+y3+")?"+oT),s4=_$(y3),u4=new RegExp(GC,"g"),a4=_$(`${k3}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${rO}H)?(?:(\\d+)${rO}M)?(?:(\\d+)${rO}S)?)?`),n4=A0(($)=>new _1(FC,{timeZone:$,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),o4=/^(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$/,r4=A0(k2),m3=A0(($)=>new _1(FC,{calendar:$,timeZone:$$,era:"short",year:"numeric",month:"short",day:"numeric"})),t4=/^M(\d{2})(L?)$/,e4={era:eO,eraYear:U0,year:U0,month:qz,monthCode:eO,day:qz},$5=A$(D1,U0),O5=A$(R,UF),oz=Object.assign({},e4,$5,O5,{offset:eO}),T5=b(N2,D1,s0),rz={dateAdd($,O,T){let Z=k(T),f,{years:j,months:z,weeks:F,days:W}=O;if(W+=j0(O,5)[0],j||z)f=((C,J,Y,D,U)=>{let[X,G,B]=C.h(J);if(Y){let[L,M]=C.I(X,G);X+=Y,G=jT(L,M,C.U(X)),G=y0("month",G,1,C.L(X),U)}return D&&([X,G]=C._(X,G,D)),B=y0("day",B,1,C.j(X,G),U),C.q(X,G,B)})(this,$,j,z,Z);else{if(!F&&!W)return $;f=K0($)}return f+=(7*F+W)*P0,L1(UT(f))},dateUntil($,O,T){if(T<=7){let W=0,C=gW({...$,...c0},{...O,...c0});return T===7&&([W,C]=S1(C,7)),{...C0,weeks:W,days:C}}let Z=this.h($),f=this.h(O),[j,z,F]=((W,C,J,Y,D,U,X)=>{let G=D-C,B=U-J,L=X-Y;if(G||B){let M=Math.sign(G||B),Q=W.j(D,U),E=0;if(Math.sign(L)===-M){let _=Q;[D,U]=W._(D,U,-M),G=D-C,B=U-J,Q=W.j(D,U),E=M<0?-_:Q}if(L=X-Math.min(Y,Q)+E,G){let[_,S]=W.I(C,J),[I,P]=W.I(D,U);if(B=I-_||Number(P)-Number(S),Math.sign(B)===-M){let A=M<0&&-W.L(D);G=(D-=M)-C,B=U-jT(_,S,W.U(D))+(A||W.L(D))}}}return[G,B,L]})(this,...Z,...f);return T===8&&(z+=this.J(j,Z[0]),j=0),{...C0,years:j,months:z,days:F}},dateFromFields($,O){let T=k(O),Z=cZ(this,$),f=pZ(this,$,Z,T),j=uz(this,$,f,Z,T);return r(L1(this.P(Z,f,j)),this.id||v)},yearMonthFromFields($,O){let T=k(O),Z=cZ(this,$),f=pZ(this,$,Z,T);return c1(Wf(this.P(Z,f,1)),this.id||v)},monthDayFromFields($,O){let T=k(O),Z=!this.id,{monthCode:f,year:j,month:z}=$,F,W,C,J,Y;if(f!==void 0){[F,W]=cW(f),Y=ez($,"day");let D=this.N(F,W,Y);if(!D)throw RangeError(az);if([C,J]=D,z!==void 0&&z!==J)throw RangeError(p6);Z&&(J=y0("month",J,1,f1,1),Y=y0("day",Y,1,Jf(j!==void 0?j:C,J),T))}else{C=j===void 0&&Z?Q$:cZ(this,$),J=pZ(this,$,C,T),Y=uz(this,$,J,C,T);let D=this.U(C);W=J===D,F=sZ(J,D);let U=this.N(F,W,Y);if(!U)throw RangeError(az);[C,J]=U}return OT(L1(this.P(C,J,Y)),this.id||v)},fields($){return uZ(this)&&$.includes("year")?[...$,...oZ]:$},mergeFields($,O){let T=Object.assign(Object.create(null),$);return iZ(T,O,E3),uZ(this)&&(iZ(T,O,Y4),this.id===L$&&iZ(T,O,X4,oZ)),T},inLeapYear($){let[O]=this.h($);return this.K(O)},monthsInYear($){let[O]=this.h($);return this.L(O)},daysInMonth($){let[O,T]=this.h($);return this.j(O,T)},daysInYear($){let[O]=this.h($);return this.X(O)},dayOfYear:C3,era($){return this.ee($)[0]},eraYear($){return this.ee($)[1]},monthCode($){let[O,T]=this.h($),[Z,f]=this.I(O,T);return((j,z)=>"M"+m0(j)+(z?"L":""))(Z,f)},dayOfWeek:VF,daysInWeek(){return 7}},Z5={dayOfYear:C3,h:SF,q:M$},f5=Object.assign({},Z5,{weekOfYear:mW,yearOfWeek:qW,R($){function O(U){return(7-U<Z?7:0)-U}function T(U){let X=IF(D+U),G=U||1,B=O(TO(W+X*G,7));return J=(X+(B-C)*G)/7}let Z=this.id?1:4,f=VF($),j=this.dayOfYear($),z=TO(f-1,7),F=j-1,W=TO(z-F,7),C=O(W),J,Y=Math.floor((F-C)/7)+1,D=$.isoYear;return Y?Y>T(0)&&(Y=1,D++):(Y=T(-1),D--),[Y,D,J]}}),j5={dayOfYear:C3,h:dZ,q:zO,weekOfYear:mW,yearOfWeek:qW,R(){return[]}},b$=m2(Object.assign({},rz,f5,{h:SF,ee($){return this.id===lT?NF($):this.id===L$?E4($):[]},I:($,O)=>[O,0],N($,O){if(!O)return[Q$,$]},K:Df,U(){},L:MF,J:($)=>$*f1,j:Jf,X:IF,P:($,O,T)=>({isoYear:$,isoMonth:O,isoDay:T}),q:M$,_:($,O,T)=>($+=WT(T,f1),(O+=Of(T,f1))<1?($--,O+=f1):O>f1&&($++,O-=f1),[$,O]),year($){return $.isoYear},month($){return $.isoMonth},day:($)=>$.isoDay}),Object.assign({},rz,j5,{h:dZ,ee($){let O=this.O($);return[O.era,O.eraYear]},I($,O){let T=uO.call(this,$);return[sZ(O,T),T===O]},N($,O,T){let[Z,f,j]=dZ.call(this,{isoYear:Q$,isoMonth:f1,isoDay:31}),z=uO.call(this,Z),F=f===z;(K1($,sZ(f,z))||K1(Number(O),Number(F))||K1(T,j))===1&&Z--;for(let W=0;W<100;W++){let C=Z-W,J=uO.call(this,C),Y=jT($,O,J);if(O===(Y===J)&&T<=dz.call(this,C,Y))return[C,Y]}},K($){let O=aO.call(this,$);return O>aO.call(this,$-1)&&O>aO.call(this,$+1)},U:uO,L:nO,J($,O){let T=O+$,Z=Math.sign($),f=Z<0?-1:0,j=0;for(let z=O;z!==T;z+=Z)j+=nO.call(this,z+f);return j},j:dz,X:aO,P($,O,T){return UT(zO.call(this,$,O,T))},q:zO,_($,O,T){if(T){if(O+=T,!Number.isSafeInteger(O))throw RangeError(qT);if(T<0)for(;O<1;)O+=nO.call(this,--$);else{let Z;for(;O>(Z=nO.call(this,$));)O-=Z,$++}}return[$,O]},year($){return this.O($).year},month($){let{year:O,F:T}=this.O($),{C:Z}=this.B(O);return Z[T]+1},day($){return this.O($).day}})),Q1="numeric",v$=["timeZoneName"],BC={month:Q1,day:Q1},q3={year:Q1,month:Q1},c3=Object.assign({},q3,{day:Q1}),p3={hour:Q1,minute:Q1,second:Q1},i3=Object.assign({},c3,p3),z5=Object.assign({},i3,{timeZoneName:"short"}),F5=Object.keys(q3),W5=Object.keys(BC),C5=Object.keys(c3),J5=Object.keys(p3),h3=["dateStyle"],D5=F5.concat(h3),Y5=W5.concat(h3),l3=C5.concat(h3,["weekday"]),VO=J5.concat(["dayPeriod","timeStyle"]),d3=l3.concat(VO),X5=d3.concat(v$),U5=v$.concat(VO),G5=v$.concat(l3),B5=v$.concat(["day","weekday"],VO),K5=v$.concat(["year","weekday"],VO),L5={},s3=[o1(d3,i3),QT],KC=[o1(X5,z5),QT,0,($,O)=>{let T=W0($.timeZone);if(O&&W0(O.timeZone)!==T)throw RangeError(h6);return T}],u3=[o1(d3,i3,v$),K0],a3=[o1(l3,c3,U5),K0],n3=[o1(VO,p3,G5),($)=>M1($)/o0],o3=[o1(D5,q3,B5),K0,1],r3=[o1(Y5,BC,K5),K0,1],tz;function e0($,O,T,Z,f){function j(...W){if(!(this instanceof j))throw TypeError(I3);MC(this,O(...W))}function z(W,C){return Object.defineProperties(function(...J){return W.call(this,F(this),...J)},tZ(C))}function F(W){let C=X0(W);if(!C||C.branding!==$)throw TypeError(I3);return C}return Object.defineProperties(j.prototype,{...$F(p0(z,T)),...i1(p0(z,Z)),...FT("Temporal."+$)}),Object.defineProperties(j,{...i1(f),...tZ($)}),[j,(W)=>{let C=Object.create(j.prototype);return MC(C,W),C},F]}function NC($){return $=$.concat("id").sort(),(O)=>{if(!OF(O,$))throw TypeError(i6);return O}}function y$($){if(X0($)||$.calendar!==void 0||$.timeZone!==void 0)throw TypeError(m6);return $}function rT($,O){let T={};for(let Z in $)T[Z]=({o:f},j)=>{let z=X0(j)||{},{branding:F}=z,W=F===t1||O.includes(F)?z:M0(j);return f[Z](W)};return T}function $j($){let O={};for(let T in $)O[T]=(Z)=>{let{calendar:f}=Z;return(j=f,typeof j=="string"?b$(j):(z=j,Object.assign(Object.create(g5),{i:z})))[T](Z);var j,z};return O}function b1(){throw TypeError(c6)}function EO({calendar:$}){return typeof $=="string"?new Cj($):$}function LC($,O){if(O=n(O),z0($)){let Z=X0($);if(Z&&Z.branding===w$)return k(O),Z;let f=_C($);return Y3(fZ(f||v),!f,$,O)}let T=JW(b$,$);return k(O),T}function EC($,O,T){return Z=O.call($,S0(F0(T))),bf(DO(Z));var Z}function tT($,O=wC){let T=Object.keys(O).sort(),Z={};for(let f of T)Z[f]=b(O[f],$,ZC($[f]));return Z}function q($,O){return typeof $=="string"?nT($):tT($,O)}function e($){return q($,e3)}function r0($){if(z0($)){let O=X0($);if(O)switch(O.branding){case uT:return O;case Y1:return F0(O.epochNanoseconds)}}return jW($)}function QC($,O,T){let Z=O.l(r0(T).epochNanoseconds,$);return Z?S0(F0(Z)):null}function p($){return z0($)?(X0($)||{}).timeZone||c5($):((O)=>bT(UW(h(O))))($)}function P1($,O){if(z0($)){let T=X0($)||{};switch(T.branding){case sT:return k(O),T;case e1:return k(O),l0(T);case Y1:return k(O),L3(e,T)}return uW($,O)}return k(O),DW($)}function Oj($){return $===void 0?void 0:P1($)}function g$($,O){if(O=n(O),z0($)){let Z=X0($);return Z&&Z.branding===H$?(k(O),Z):D3(TZ(xO($)),$,O)}let T=CW(b$,$);return k(O),T}function A1($,O){if(O=n(O),z0($)){let Z=X0($)||{};switch(Z.branding){case e1:return k(O),Z;case t1:return k(O),o({...Z,...c0});case Y1:return k(O),B3(e,Z)}return sW(ZZ(xO($)),$,O)}let T=WW($);return k(O),T}function M0($,O){if(O=n(O),z0($)){let Z=X0($)||{};switch(Z.branding){case t1:return k(O),Z;case e1:return k(O),r(Z);case Y1:return k(O),K3(e,Z)}return J3(ZZ(xO($)),$,O)}let T=HT($);return k(O),T}function xC($,O,T){return i0(O.call($,d(r(T,$))))}function $1($){return(O)=>typeof O=="string"?b$(O):((T,Z)=>{let f=Object.keys(Z).sort(),j={};for(let z of f)j[z]=b(Z[z],T,T[z]);return j})(O,$)}function l($){if(z0($)){let O=X0($);return O&&O.branding===aT?O:aW($)}return YW($)}function NO($){if($!==void 0){if(z0($)){let O=X0($)||{};switch(O.branding){case Y1:case t1:return O;case e1:return r(O)}let T=xO($);return{...lW(p,q,ZZ(T),$),calendar:T}}return zW($)}}function xO($){return _C($)||v}function _C($){let{calendar:O}=$;if(O!==void 0)return Y0(O)}function Y0($){return z0($)?(X0($)||{}).calendar||O7($):((O)=>UO(XW(h(O))))($)}function k$($,O){if(O=n(O),z0($)){let T=X0($);if(T&&T.branding===Y1)return YO(O),T;let Z=xO($);return dW(p,q,ZZ(Z),Z,$,O)}return FW($,O)}function SC($){return p0((O)=>(T)=>O(t3(T)),$)}function t3($){return L0($,e)}function Q5(){let $=_1.prototype,O=Object.getOwnPropertyDescriptors($),T=Object.getOwnPropertyDescriptors(_1),Z=function(f,j={}){if(!(this instanceof Z))return new Z(f,j);Jj.set(this,((z,F={})=>{let W=new _1(z,F),C=W.resolvedOptions(),J=C.locale,Y=w0(Object.keys(F),C),D=A0(I5),U=(...X)=>{let G,B=X.map((L,M)=>{let Q=X0(L),E=(Q||{}).branding;if(M&&G&&G!==E)throw TypeError(d6);return G=E,Q});return G?D(G)(J,Y,...B):[W,...X]};return U.u=W,U})(f,j))};for(let f in O){let j=O[f],z=f.startsWith("format")&&S5(f);typeof j.value=="function"?j.value=f==="constructor"?Z:z||M5(f):z&&(j.get=function(){return z.bind(this)})}return T.prototype.value=Object.create($,O),Object.defineProperties(Z,T),Z}function S5($){return function(...O){let T=Jj.get(this),[Z,...f]=T(...O);return Z[$](...f)}}function M5($){return function(...O){return Jj.get(this).u[$](...O)}}function I5($){let O=V5[$];if(!O)throw TypeError(l6($));return C1(O,A0(Q3))}var V5={Instant:s3,PlainDateTime:u3,PlainDate:a3,PlainTime:n3,PlainYearMonth:o3,PlainMonthDay:r3},N5=C1(s3),E5=C1(KC),x5=C1(u3),_5=C1(a3),P5=C1(n3),A5=C1(o3),H5=C1(r3),Tj={era:WF,eraYear:Tf,year:DO,month:i0,daysInMonth:i0,daysInYear:i0,inLeapYear:TC,monthsInYear:i0},$Z={monthCode:h},Zj={day:i0},PC={dayOfWeek:i0,dayOfYear:i0,weekOfYear:CF,yearOfWeek:Tf,daysInWeek:i0},AC=Object.assign({},Tj,$Z,Zj,PC),eT=new WeakMap,X0=eT.get.bind(eT),MC=eT.set.bind(eT),w5={...rT(Tj,[H$]),...rT(PC,[]),...rT($Z,[H$,w$]),...rT(Zj,[w$])},fj=$j(AC),b5=$j({...Tj,...$Z}),v5=$j({...$Z,...Zj}),_O={calendarId:($)=>W0($.calendar)},g5=p0(($,O)=>function(T){let{i:Z}=this;return $(Z[O](d(r(T,Z))))},AC),k5=CO(($)=>(O)=>O[$],R.concat("sign")),jj=CO(($,O)=>(T)=>T[s0[O]],D1),HC={epochSeconds:wF,epochMilliseconds:QT,epochMicroseconds:bF,epochNanoseconds:vF},PO=b(eZ,new Set(["branding"])),[R5,R$,y5]=e0(w$,b(W6,Y0),{..._O,...v5},{getISOFields:PO,getCalendar:EO,with($,O,T){return R$(eW(t5,$,this,y$(O),T))},equals:($,O)=>PW($,LC(O)),toPlainDate($,O){return d(I6(AO,$,this,O))},toLocaleString($,O,T){let[Z,f]=H5(O,T,$);return Z.format(f)},toString:_f,toJSON:($)=>_f($),valueOf:b1},{from:($,O)=>R$(LC($,O))}),wC={getOffsetNanosecondsFor:EC,getPossibleInstantsFor($,O,T){let Z=[...O.call($,D0(o(T,v)))].map((j)=>q5(j).epochNanoseconds),f=Z.length;return f>1&&(Z.sort(B0),vf(k0(g0(Z[0],Z[f-1])))),Z}},e3={getOffsetNanosecondsFor:EC},[m5,S0,q5]=e0(uT,Z6,HC,{add:($,O)=>S0(gf(0,$,l(O))),subtract:($,O)=>S0(gf(1,$,l(O))),until:($,O,T)=>c(T3(0,$,r0(O),T)),since:($,O,T)=>c(T3(1,$,r0(O),T)),round:($,O)=>S0(RF($,O)),equals:($,O)=>VW($,r0(O)),toZonedDateTime($,O){let T=F1(O);return t(G3($,p(T.timeZone),Y0(T.calendar)))},toZonedDateTimeISO:($,O)=>t(G3($,p(O))),toLocaleString($,O,T){let[Z,f]=N5(O,T,$);return Z.format(f)},toString:($,O)=>If(p,e,$,O),toJSON:($)=>If(p,e,$),valueOf:b1},{from:($)=>S0(r0($)),fromEpochSeconds:($)=>S0(E6($)),fromEpochMilliseconds:($)=>S0(x6($)),fromEpochMicroseconds:($)=>S0(_6($)),fromEpochNanoseconds:($)=>S0(P6($)),compare:($,O)=>ef(r0($),r0(O))}),[OZ,oD]=e0("TimeZone",($)=>{let O=MW($);return{branding:"TimeZone",id:O,o:nT(O)}},{id:($)=>$.id},{getPossibleInstantsFor:({o:$},O)=>$.getPossibleInstantsFor(A1(O)).map((T)=>S0(F0(T))),getOffsetNanosecondsFor:({o:$},O)=>$.getOffsetNanosecondsFor(r0(O).epochNanoseconds),getOffsetStringFor($,O){let T=r0(O).epochNanoseconds,Z=tT(this,e3).getOffsetNanosecondsFor(T);return d1(Z)},getPlainDateTimeFor($,O,T=v){let Z=r0(O).epochNanoseconds,f=tT(this,e3).getOffsetNanosecondsFor(Z);return D0(o(V1(Z,f),Y0(T)))},getInstantFor($,O,T){let Z=A1(O),f=Yf(T),j=tT(this);return S0(F0(H0(j,Z,f)))},getNextTransition:({o:$},O)=>QC(1,$,O),getPreviousTransition:({o:$},O)=>QC(-1,$,O),equals($,O){return!!gT(this,p(O))},toString:($)=>$.id,toJSON:($)=>$.id},{from($){let O=p($);return typeof O=="string"?new OZ(O):O}}),c5=NC(Object.keys(wC)),[p5,H1]=e0(sT,C6,jj,{getISOFields:PO,with($,O,T){return H1($6(this,y$(O),T))},add:($,O)=>H1(qf(0,$,l(O))),subtract:($,O)=>H1(qf(1,$,l(O))),until:($,O,T)=>c(F3(0,$,P1(O),T)),since:($,O,T)=>c(F3(1,$,P1(O),T)),round:($,O)=>H1(qF($,O)),equals:($,O)=>AW($,P1(O)),toZonedDateTime:($,O)=>t(V6(p,M0,q,$,O)),toPlainDateTime:($,O)=>D0(N6($,M0(O))),toLocaleString($,O,T){let[Z,f]=P5(O,T,$);return Z.format(f)},toString:Pf,toJSON:($)=>Pf($),valueOf:b1},{from:($,O)=>H1(P1($,O)),compare:($,O)=>vT(P1($),P1(O))}),[i5,w1,h5]=e0(H$,b(F6,Y0),{..._O,...b5},{getISOFields:PO,getCalendar:EO,with($,O,T){return w1(tW(r5,$,this,y$(O),T))},add:($,O,T)=>w1(mf(IC,0,$,l(O),T)),subtract:($,O,T)=>w1(mf(IC,1,$,l(O),T)),until:($,O,T)=>c(z3(VC,0,$,g$(O),T)),since:($,O,T)=>c(z3(VC,1,$,g$(O),T)),equals:($,O)=>_W($,g$(O)),toPlainDate($,O){return d(M6(AO,$,this,O))},toLocaleString($,O,T){let[Z,f]=A5(O,T,$);return Z.format(f)},toString:xf,toJSON:($)=>xf($),valueOf:b1},{from:($,O)=>w1(g$($,O)),compare:($,O)=>a1(g$($),g$(O))}),[l5,D0]=e0(e1,b(j6,Y0),{..._O,...fj,...jj},{getISOFields:PO,getCalendar:EO,with($,O,T){return D0(oW(AO,$,this,y$(O),T))},withCalendar:($,O)=>D0(mT($,Y0(O))),withPlainDate:($,O)=>D0(b6($,M0(O))),withPlainTime:($,O)=>D0(w6($,Oj(O))),add:($,O,T)=>D0(Rf(O$,0,$,l(O),T)),subtract:($,O,T)=>D0(Rf(O$,1,$,l(O),T)),until:($,O,T)=>c(f3(t0,0,$,A1(O),T)),since:($,O,T)=>c(f3(t0,1,$,A1(O),T)),round:($,O)=>D0(mF($,O)),equals:($,O)=>EW($,A1(O)),toZonedDateTime:($,O,T)=>t(U6(q,$,p(O),T)),toPlainDate:($)=>d(r($)),toPlainTime:($)=>H1(l0($)),toPlainYearMonth($){return w1(G6(TZ,$,this))},toPlainMonthDay($){return R$(B6(fZ,$,this))},toLocaleString($,O,T){let[Z,f]=x5(O,T,$);return Z.format(f)},toString:Nf,toJSON:($)=>Nf($),valueOf:b1},{from:($,O)=>D0(A1($,O)),compare:($,O)=>O3(A1($),A1(O))}),[d5,d,bC]=e0(t1,b(z6,Y0),{..._O,...fj},{getISOFields:PO,getCalendar:EO,with($,O,T){return d(rW(AO,$,this,y$(O),T))},withCalendar:($,O)=>d(mT($,Y0(O))),add:($,O,T)=>d(yf(O$,0,$,l(O),T)),subtract:($,O,T)=>d(yf(O$,1,$,l(O),T)),until:($,O,T)=>c(j3(t0,0,$,M0(O),T)),since:($,O,T)=>c(j3(t0,1,$,M0(O),T)),equals:($,O)=>xW($,M0(O)),toZonedDateTime($,O){let T=!z0(O)||O instanceof OZ?{timeZone:O}:O;return t(K6(p,P1,q,$,T))},toPlainDateTime:($,O)=>D0(L6($,Oj(O))),toPlainYearMonth($){return w1(Q6(TZ,$,this))},toPlainMonthDay($){return R$(S6(fZ,$,this))},toLocaleString($,O,T){let[Z,f]=_5(O,T,$);return Z.format(f)},toString:Ef,toJSON:($)=>Ef($),valueOf:b1},{from:($,O)=>d(M0($,O)),compare:($,O)=>a1(M0($),M0(O))}),zj={fields($,O,T){return[...O.call($,T)]}},vC=Object.assign({dateFromFields($,O,T,Z){return bC(O.call($,Object.assign(Object.create(null),T),Z))}},zj),gC=Object.assign({yearMonthFromFields($,O,T,Z){return h5(O.call($,Object.assign(Object.create(null),T),Z))}},zj),kC=Object.assign({monthDayFromFields($,O,T,Z){return y5(O.call($,Object.assign(Object.create(null),T),Z))}},zj),Fj={mergeFields($,O,T,Z){return F1(O.call($,Object.assign(Object.create(null),T),Object.assign(Object.create(null),Z)))}},s5=Object.assign({},vC,Fj),u5=Object.assign({},gC,Fj),a5=Object.assign({},kC,Fj),Wj={dateAdd($,O,T,Z,f){return bC(O.call($,d(r(T,$)),c(i(Z)),f))}},RC=Object.assign({},Wj,{dateUntil($,O,T,Z,f,j){return $7(O.call($,d(r(T,$)),d(r(Z,$)),Object.assign(Object.create(null),j,{largestUnit:QO[f]})))}}),n5=Object.assign({},Wj,{day:xC}),o5=Object.assign({},RC,{day:xC}),TZ=$1(gC),ZZ=$1(vC),fZ=$1(kC),r5=$1(u5),AO=$1(s5),t5=$1(a5),O$=$1(Wj),t0=$1(RC),IC=$1(n5),VC=$1(o5),[e5,c,$7]=e0(aT,J6,{...k5,blank:TW},{with:($,O)=>c(O6($,O)),negated:($)=>c(PT($)),abs:($)=>c(OW($)),add:($,O,T)=>c(df(NO,t0,q,0,$,l(O),T)),subtract:($,O,T)=>c(df(NO,t0,q,1,$,l(O),T)),round:($,O)=>c($W(NO,t0,q,$,O)),total:($,O)=>kF(NO,t0,q,$,O),toLocaleString($,O,T){return Intl.DurationFormat?new Intl.DurationFormat(O,T).format(this):VT($)},toString:VT,toJSON:($)=>VT($),valueOf:b1},{from:($)=>c(l($)),compare:($,O,T)=>IW(NO,O$,q,l($),l(O),T)}),yC={toString:($)=>$.id,toJSON:($)=>$.id,...w5,dateAdd:({id:$,o:O},T,Z,f)=>d(r(O.dateAdd(M0(T),l(Z),f),$)),dateUntil:({o:$},O,T,Z)=>c(i($.dateUntil(M0(O),M0(T),xF(Z)))),dateFromFields:({id:$,o:O},T,Z)=>d(J3(O,T,Z,FF($))),yearMonthFromFields:({id:$,o:O},T,Z)=>w1(D3(O,T,Z,jF($))),monthDayFromFields:({id:$,o:O},T,Z)=>R$(Y3(O,0,T,Z,zF($))),fields({o:$},O){let T=new Set(d0),Z=[];for(let f of O){if(h(f),!T.has(f))throw RangeError(M3(f));T.delete(f),Z.push(f)}return $.fields(Z)},mergeFields:({o:$},O,T)=>$.mergeFields($f(Zf(O)),$f(Zf(T)))},[Cj]=e0("Calendar",($)=>{let O=yW($);return{branding:"Calendar",id:O,o:b$(O)}},{id:($)=>$.id},yC,{from($){let O=Y0($);return typeof O=="string"?new Cj(O):O}}),O7=NC(Object.keys(yC).slice(4)),[T7,t]=e0(Y1,b(f6,Y0,p),{...HC,..._O,...SC(fj),...SC(jj),offset:($)=>d1(t3($).offsetNanoseconds),offsetNanoseconds:($)=>t3($).offsetNanoseconds,timeZoneId:($)=>W0($.timeZone),hoursInDay:($)=>cF(q,$)},{getISOFields:($)=>tF(e,$),getCalendar:EO,getTimeZone:({timeZone:$})=>typeof $=="string"?new OZ($):$,with($,O,T){return t(nW(AO,q,$,this,y$(O),T))},withCalendar:($,O)=>t(mT($,Y0(O))),withTimeZone:($,O)=>t(v6($,p(O))),withPlainDate:($,O)=>t(H6(q,$,M0(O))),withPlainTime:($,O)=>t(A6(q,$,Oj(O))),add:($,O,T)=>t(kf(O$,q,0,$,l(O),T)),subtract:($,O,T)=>t(kf(O$,q,1,$,l(O),T)),until:($,O,T)=>c(i(Z3(t0,q,0,$,k$(O),T))),since:($,O,T)=>c(i(Z3(t0,q,1,$,k$(O),T))),round:($,O)=>t(yF(q,$,O)),startOfDay:($)=>t(pF(q,$)),equals:($,O)=>NW($,k$(O)),toInstant:($)=>S0(D6($)),toPlainDateTime:($)=>D0(B3(e,$)),toPlainDate:($)=>d(K3(e,$)),toPlainTime:($)=>H1(L3(e,$)),toPlainYearMonth($){return w1(Y6(TZ,$,this))},toPlainMonthDay($){return R$(X6(fZ,$,this))},toLocaleString($,O,T={}){let[Z,f]=E5(O,T,$);return Z.format(f)},toString:($,O)=>Vf(e,$,O),toJSON:($)=>Vf(e,$),valueOf:b1},{from:($,O)=>t(k$($,O)),compare:($,O)=>$3(k$($),k$(O))}),Z7=Object.defineProperties({},{...FT("Temporal.Now"),...i1({timeZoneId:()=>J1(),instant:()=>S0(F0(BO())),zonedDateTime:($,O=J1())=>t(J0(BO(),p(O),Y0($))),zonedDateTimeISO:($=J1())=>t(J0(BO(),p($),v)),plainDateTime:($,O=J1())=>D0(o(P$(e(p(O))),Y0($))),plainDateTimeISO:($=J1())=>D0(o(P$(e(p($))),v)),plainDate:($,O=J1())=>d(r(P$(e(p(O))),Y0($))),plainDateISO:($=J1())=>d(r(P$(e(p($))),v)),plainTimeISO:($=J1())=>H1(l0(P$(e(p($)))))})}),m$=Object.defineProperties({},{...FT("Temporal"),...i1({PlainYearMonth:i5,PlainMonthDay:R5,PlainDate:d5,PlainTime:p5,PlainDateTime:l5,ZonedDateTime:T7,Instant:m5,Calendar:Cj,TimeZone:OZ,Duration:e5,Now:Z7})}),f7=Q5(),Jj=new WeakMap,j7=Object.defineProperties(Object.create(Intl),i1({DateTimeFormat:f7}));var Dj="intended_url";class Yj extends x{schema={email:{required:"Email is required",string:"Invalid email",email:"Invalid email"},password:{required:"Password is required"}}}class mC extends x{schema={email:{required:"Email is required",email:"Invalid email"}}}class qC extends x{schema={password:{required:"Password is required",password:"Invalid password"}}}class $0 extends HZ{async me(){let $=await T$.user();if(!$)throw new wZ;return $}async verifyEmail($=new x){let O=await $.input(),{userProvider:T}=K(w),Z=await T.findUserByVerificationToken(O.get("token"));if(!Z)return{email:null};return await T.verifyUser(Z.email),{email:Z.email}}async signInWithMagicLink($=new x){let O=K(w),{userProvider:T}=O,Z=$.search.get("token"),f=decodeURIComponent($.search.get("email")).toLowerCase().trim(),j=null;try{j=await T.findUserMagicLinkToken({email:f,token:Z})}catch(F){return console.log(F),{error:JSON.stringify(F)}}if(!j)return{error:"Invalid token"};await T.verifyUser(f),await T.deleteMagicLinkToken(f);let z=await O.createOrUpdateSession({email:f});return $.ctx().setCookie("access_token",z.token,K(w).accessTokenCookieOptions($,z.expiresAt)),await O.config.onSignIn(z,$.search.toJSON()),{session:z}}async signInWithPinV2($=new x){let O=K(w),{userProvider:T}=O,Z=await $.input(),{email:f,pin:j}=Z.toJSON(),z=f.toLowerCase().trim();if(!await T.findUserMagicLinkToken({email:z,pin:j}))throw new E0({pin:["Invalid pin"]});await T.deleteMagicLinkToken(z),await T.verifyUser(z);let W=await O.createOrUpdateSessionV2({email:z});return $.ctx().setCookie("access_token",W.token,K(w).accessTokenCookieOptions($,W.expiresAt)),await O.config.onSignIn(W,$.search.toJSON()),W}async signInWithPin($=new x){let O=K(w),{userProvider:T}=O,Z=await $.input(),{email:f,pin:j}=Z.toJSON(),z=f.toLowerCase().trim();if(!await T.findUserMagicLinkToken({email:z,pin:j}))throw new E0({pin:["Invalid pin"]});await T.deleteMagicLinkToken(z),await T.verifyUser(z);let W=await O.createOrUpdateSession({email:z});return $.ctx().setCookie("access_token",W.token,K(w).accessTokenCookieOptions($,W.expiresAt)),await O.config.onSignIn(W,$.search.toJSON()),{session:W}}async signInV2($=new Yj){let O=await $.input(),{email:T,password:Z}=O.toJSON(),f=T.toLowerCase().trim(),j=K(w),z=await j.userProvider.findUserByEmailAddress(f,j.config.verifyEmail);if(!z)throw new E0({invalid_credentials:["Invalid credentials"]});if(!await j.config.verifyPassword(Z,z.password))throw new E0({invalid_credentials:["Invalid credentials"]});let W=await j.createOrUpdateSessionV2({email:z.email,id:z.id});$.ctx().setCookie("access_token",W.token,K(w).accessTokenCookieOptions($,W.expiresAt)),await j.config.onSignIn(z,$.search.toJSON());let{password:C,...J}=z;return J}async signIn($=new Yj){let O=await $.input(),{email:T,password:Z}=O.toJSON(),f=T.toLowerCase().trim(),j=K(w),z=await j.userProvider.findUserByEmailAddress(f,j.config.verifyEmail);if(!z)throw new E0({invalid_credentials:["Invalid credentials"]});if(!await j.config.verifyPassword(Z,z.password))throw new E0({invalid_credentials:["Invalid credentials"]});let W=await j.createOrUpdateSession({email:z.email,id:z.id});$.ctx().setCookie("access_token",W.token,K(w).accessTokenCookieOptions($,W.expiresAt)),await j.config.onSignIn(z,$.search.toJSON());let{password:C,...J}=z;return J}async signUp(){let $=K(w),{userProvider:O,config:T}=$,Z=new T.signUpRequest,f=await Z.input(),{email:j,password:z,name:F,invitationId:W}=f.toJSON(),C=j.toLowerCase().trim();if(await O.findUserByEmailAddress(C,!1))throw new E0({email:["Email address already exists"]});let Y=await T.hashPassword(z),D=K(a).detectLocale(Z),U;if(W)U=await O.findInvitation(W,C);let X,G="";if(U)X=await O.transaction(async()=>{await O.deleteInvitationById(W);let B=await O.createUser({email:C,name:F,password:Y,emailVerifiedAt:new Date,locale:D});return await O.createAccount({organizationId:U.organizationId,userId:B.id,organizationRole:U.role}),await T.onUserCreated(B),B});else G=await T.generateEmailVerificationToken(C),X=await O.transaction(async()=>{let B=await O.createUser({email:C,name:F,password:Y,verificationToken:G,locale:D});return await T.onUserCreated(B),B});return await T.onSignUp(X,G,Z.search.toJSON()),X}async signOut($=new x){let O=$.cookies.get("access_token")??$.headers.get("access_token"),{userProvider:T,config:Z}=K(w),f=O?await T.findSession({token:O,userAgent:$.headers.get("User-Agent")}):null;if(await T.deleteSession({token:O}),$.ctx().setCookie("access_token","",K(w).accessTokenCookieOptions($,new Date(0))),K(w).cookieDomain($))$.ctx().setCookie("access_token","",{...K(w).accessTokenCookieOptions($,new Date(0)),domain:void 0});if(f?.user)f.user.extension=await Z.extendSession(f.user),await Z.onSignOut(f.user);return{}}async forgotPassword($=new mC){let T=(await $.input()).get("email").toLowerCase().trim(),{userProvider:Z,config:f}=K(w),j=await Z.findUserByEmailAddress(T,f.verifyEmail);if(!j)return{};let z=await f.generateForgotPasswordToken(j);return await Z.createPasswordResetToken({user:j,token:z}),await f.onForgotPassword(j,z),{}}async resetPassword($=new qC){let{userProvider:O,config:T}=K(w),Z=await $.input(),{password:f,token:j}=Z.toJSON(),z=await O.findPasswordResetToken({token:j});if(!z)throw new E0({token:["Invalid token"]});if(m$.Instant.from(z.createdAt.toISOString()).add({hours:24}).until(m$.Now.instant()).sign>=0)throw new E0({token:["Token expired"]});await O.deletePasswordResetToken({token:j});let W=await O.findUserByEmailAddress(z.user.email,T.verifyEmail);if(!W)throw new E0({email:["User not found"]});let C=await T.hashPassword(f);return await O.updateUserPassword({id:W.id,password:C}),await O.deleteAllUserSessions(W.id),await T.onResetPassword(W),{}}async changePassword($=new x){let{userProvider:O,config:T}=K(w),Z=await T$.user(),f=await $.input(),{oldPassword:j,newPassword:z}=f.toJSON(),{password:F}=await O.findUserByEmailAddress(Z.email,T.verifyEmail);if(!await T.verifyPassword(j,F))throw new E0({oldPassword:["Incorrect password"]});let C=await T.hashPassword(z);return await O.updateUserPassword({id:Z.id,password:C}),await O.deleteAllUserSessions(Z.id),{}}async oauthRedirect($=new x){let{provider:O}=$.params,T=K(w).config.oauthProviders[O];if(!T)throw Error(`Invalid provider: ${O}`);let Z=$O($.search.get(Y$),"");if(Z)$.ctx().setCookie(Dj,encodeURIComponent(Z),{httpOnly:!0,sameSite:"Lax",secure:Sz($.rawRequest),maxAge:600});return{destination:await T.getRedirectUrl($)}}async oauthCallback($=new x){let{provider:O}=$.params,T=K(w),{userProvider:Z,config:f}=T,j=f.oauthProviders[O],{email:z,name:F,username:W,providerId:C}=await j.onCallback($),J=C?await Z.findUserBySocialAccount(O,C):null,Y="signin";if(!J){if(!z)return console.error("Authentication error: No email returned from OAuth provider callback"),{session:null};let G=K(a).detectLocale($);try{let B=await this.linkOAuthAccount({provider:O,providerId:C,email:z,name:F,username:W,locale:G});if(B)J=B.user,Y=B.action}catch(B){let L=C?await Z.findUserBySocialAccount(O,C):null;if(!L)throw B;J=L}if(!J)return{session:null}}let D=await T.createOrUpdateSessionV2({email:J.email,id:J.id});if($.ctx().setCookie("access_token",D.token,K(w).accessTokenCookieOptions($,D.expiresAt)),Y==="signup")await f.onSignUp(J,"",$.search.toJSON());else await f.onSignIn(J,$.search.toJSON());let U=$.cookies.get(Dj),X=f.redirectPath;if(U){try{X=$O(decodeURIComponent(U),X)}catch{}$.ctx().setCookie(Dj,"",{maxAge:-1})}return{session:D,redirectTo:X}}async linkOAuthAccount($){let{provider:O,providerId:T,email:Z,name:f,username:j,locale:z}=$,{userProvider:F,config:W}=K(w),C=(D)=>({provider:O,userId:D,email:Z,username:j,providerId:T,expiresAt:new Date,accessToken:"",refreshToken:""}),J=await F.findUserByEmailAddress(Z,!1);if(J){if(!T)return{user:J,action:"signin"};let D=await F.findSocialAccounts(J.id,O);if(D.some((X)=>X.providerId===T))return{user:J,action:"signin"};if(D.some((X)=>X.providerId))return console.error(`Authentication error: user ${J.id} is already linked to a different ${O} account`),null;let U=D[0];if(U){if(!await F.claimSocialAccount(U,T))throw Error(`${O} account link changed concurrently`)}else await F.createSocialAccount(C(J.id));return{user:J,action:"signin"}}return{user:await F.transaction(async()=>{let D=await F.createUser({email:Z,name:f,locale:z,emailVerifiedAt:new Date});if(T)await F.createSocialAccount(C(D.id));return await W.onUserCreated(D),D}),action:"signup"}}async createMagicLinkToken($=new x){let T=(await $.input()).get("email").toLowerCase().trim(),Z=K(w),{user:f,pin:j,token:z}=await Z.createMagicLinkToken(T);if(f)return await Z.config.onMagicLinkCreated(f,{email:T,pin:j,token:z}),{email:T};return{email:null}}}class cC extends B1{middlewares=["cache:private"];routes={"/:provider":this.view("_Redirect",[$0,"oauthRedirect"]),"/:provider/callback":this.view("auth/OauthCallback",[$0,"oauthCallback"])}}class Xj extends B1{middlewares=["cache:private"];routes={"/sign-in/magic-link":this.view("auth/MagicLinkSignIn",[$0,"signInWithMagicLink"]),"/oauth":cC}}class Uj extends N0{middlewares=["cache:private"];routes={"/sign-in":this.post($0,"signIn"),"/sign-in-v2":this.post($0,"signInV2"),"/sign-up":this.post($0,"signUp"),"/sign-out":this.post($0,"signOut"),"/forgot-password":this.post($0,"forgotPassword"),"/reset-password":this.post($0,"resetPassword"),"/change-password":this.post($0,"changePassword"),"/verify-email":this.post($0,"verifyEmail"),"/me":this.get($0,"me").middleware(["auth"]),"/magic-link":this.post($0,"createMagicLinkToken"),"/sign-in-with-pin":this.post($0,"signInWithPin"),"/sign-in-with-pin-v2":this.post($0,"signInWithPinV2")}}class Gj extends N0{middlewares=["cache:private,0,no-store"];routes={"/set-locale/:locale":this.get(async()=>{let O=new x().params.locale;return await K(a).onLocaleChange(O),{locale:O}}),"/translations/:locale/:scope*":this.get(async()=>{let $=new x,O=`/${$.params.scope??""}`,T=$.params.locale,Z=K(a),f=T??Z.detectLocale($),j=Z.getPageTranslations(f,O);return $.ctx().setCookie("i18n-locale",f,{expires:new Date(Date.now()+31536000000)}),{[f]:j}})}}class Bj{}class Kj extends Bj{async resize($,O){let{height:T,width:Z,quality:f,fit:j}=O;return await(await jZ("The Sharp image optimization driver"))($).resize(Z>0?Z:void 0,T>0?T:void 0,{fit:j}).webp({quality:f>0?f:80,force:!0}).toBuffer()}}function EY($){return $}function pC(){return{driver:new Kj}}class Lj extends N0{routes={"/resize":this.file(async()=>{let $=new x,O=new URL($.rawRequest.url),T=O.searchParams.get("url"),Z=Number(O.searchParams.get("w")),f=Number(O.searchParams.get("h")),j=O.searchParams.get("fit")??"cover",z=Number(O.searchParams.get("q"));if(!T)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});let W=`${T.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${T}`,C=await fetch(W);if(!C.ok)return new Response(JSON.stringify({error:"Image not found",info:W}),{headers:{"Content-Type":"application/json"},status:404});let J=Buffer.from(await C.arrayBuffer()),Y=await K(iC).resize(J,{height:f,width:Z,fit:j,quality:z});C.headers.delete("Content-Type"),C.headers.delete("Content-Length");let D=new Headers(C.headers);return D.set("Content-Type","image/webp"),D.set("Content-Length",`${Y.byteLength}`),new Response(new Uint8Array(Y),{headers:D})})}}class iC{static token="image";driver;constructor($={}){this.driver=$.driver??pC().driver}resize($,O){return this.driver.resize($,O)}}import{mkdir as Qj,readdir as z7,access as F7}from"fs/promises";async function Sj($){try{return await F7($),!0}catch{return!1}}class HO{config;static token="log";writer;isReady=!1;flushTimeout;fileSize=0;writerSize=0;isCreatingFile=!1;bootPromise=null;currentLogFilePath;get logsDirPath(){return`${Mj()}/storage/logs`}constructor($){this.config=$}boot(){if(!this.bootPromise)this.bootPromise=this.createStorage().catch(($)=>{console.error("Log storage unavailable, file logging disabled",$)}).then(()=>{this.isReady=!0});return this.bootPromise}async createStorage(){let $=`${Mj()}/storage`;if(!await Sj($))await Qj($);if(!await Sj(this.logsDirPath))await Qj(this.logsDirPath);await this.newLogFile()}async newLogFile(){if(!await Sj(this.logsDirPath))await Qj(this.logsDirPath);if(this.isCreatingFile=!0,this.currentLogFilePath){this.writer.flush(),this.writer.end(),this.writer=null;let T=new File([await Bun.file(this.currentLogFilePath).arrayBuffer()],this.currentLogFilePath.split("/").pop(),{type:"text/plain"});this.config.onLogFileClosed(T),this.fileSize=0,this.writerSize=0}let O=(await z7(this.logsDirPath)).sort().reverse()[0];if(O){let T=Bun.file(`${this.logsDirPath}/${O}`);if(T.size<this.config.maxFileSize)this.currentLogFilePath=`${this.logsDirPath}/${O}`,this.writer=T.writer(),this.writer.write(await T.text()),this.writer.write(`
3
- `),this.writer.flush(),this.fileSize=T.size}if(!this.writer){let T=`${new Date(Date.now()).toISOString()}.log`.replaceAll(":","-");this.currentLogFilePath=`${this.logsDirPath}/${T}`;let Z=Bun.file(`${this.logsDirPath}/${T}`);this.writer=Z.writer(),this.fileSize=0,this.writerSize=0}this.isCreatingFile=!1}async log($,O,T={}){if(!this.isReady)await this.boot();let Z=N.getStore(),f={};if(Z)f={url:Z.req.rawRequest.url,method:Z.req.rawRequest.method,headers:Z.req.rawRequest.headers,body:Z.req.rawRequest.body};let j={timestamp:new Date(Date.now()).toISOString(),env:Bun.env.NODE_ENV,level:$,message:O,metadata:{...f,...T}},z="";try{z=JSON.stringify(j)}catch(F){console.log("Error parsing log object",F)}try{let F=this.config.onLogCreated(j);if(F instanceof Promise)F.catch((W)=>console.error("Error in onLogCreated",W))}catch(F){console.error("Error in onLogCreated",F)}if(!this.writer)return;this.writerSize+=z.length,this.fileSize+=z.length;try{this.writer.write(z),this.writer.write(`
4
- `),this.tryFlush()}catch(F){console.error("Error writing log",F)}}async tryFlush(){if(this.fileSize>this.config.maxFileSize){if(!this.isCreatingFile)await this.newLogFile()}if(this.writerSize>this.config.maxFileSize/2)await this.writer.flush(),this.writerSize=0,await this.newLogFile();else clearTimeout(this.flushTimeout),this.flushTimeout=setTimeout(async()=>{await this.writer.flush(),this.writerSize=0},100)}}class Ij extends N0{middlewares=["cache:private,0"];routes={"/live":this.get(async()=>{let $=Bun.file(K(HO).currentLogFilePath);return new Response(await $.text(),{headers:{"Content-Type":"text/plain"}})})}}function W7($){let O=new Map;for(let T of $)if(typeof T==="string"){let[Z,f=""]=T.split(":");if(Z.startsWith("-")){if(O.has(Z.replace("-","")))O.delete(Z.replace("-",""))}else O.set(Z,f.split(",").filter(Boolean))}else O.set(T,[]);return O}class wO{config;static token="middleware";constructor($){this.config=$}get aliases(){return this.config.aliases}assertGlobalMiddleware(){for(let $ of this.config.global){if(typeof $!=="string")continue;let[O]=$.split(":");if(O.startsWith("-"))throw Error(`Global middleware "${$}" cancels an alias, but nothing is inherited into the global list. Remove it.`);if(!this.aliases[O])throw Error(`Global middleware "${O}" 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 O=new x;return Array.from(W7($).entries()).map(([T,Z])=>{if(typeof T==="string"){let f=this.aliases[T];if(f){let j=new f(O);return()=>j.run.call(j,...Z)}}else{if(pO(T)){let f=new T(O);return f.run.bind(f)}return T}}).filter(Boolean).reduce((T,Z)=>{return async()=>{return{...await T(),...await Z()}}},()=>Promise.resolve({}))()}}function hY($){return $}function hC(){return{onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{}}}function lC(){return{partialRendering:!0,onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{},onStreamComplete:()=>{}}}function C7($){return"run"in $}function J7($){return Object.hasOwn($,"get")||Object.hasOwn($,"post")||Object.hasOwn($,"put")||Object.hasOwn($,"delete")}function D7($){return Object.hasOwn($,"first")&&Object.hasOwn($,"second")}function Y7($){if("__brand"in $)return $.__brand==="ApiRouter";return!1}function X7($){if("__internal_brand"in $)return $.__internal_brand==="ProxyHandler";return!1}function U7($){if("__internal_brand"in $)return $.__internal_brand==="StreamHandler";return!1}function Vj($,O="",T=[]){let Z={};function f(j,z,F,W,C){let J=j==="/"?"":j,Y=O==="/"?"":O,D=(`${Y}${J}`===""?"/":`${Y}${J}`).replaceAll("//","/");if(!Z[D])Z[D]={};Z[D][z.toUpperCase()]={exec:F,middleware:[...T,...W],...C?{source:C}:{}},Z[D].OPTIONS={exec:()=>{let X=new x().ctx().headers;return new Response(null,{headers:X,status:204})},middleware:[]}}for(let[j,z]of Object.entries($)){if(X7(z)){let F=z;for(let W of["GET","POST","PUT","DELETE"])f(j,W,F.run.bind(F),[]);continue}if(C7(z)){let F=z,W=F.method,C=F.middlewares,J=F.run.bind(F);if(f(j,W,J,C,F.source),U7(z))f(j,"HEAD",J,C,F.source)}if(J7(z))for(let[F,W]of Object.entries(z)){let C=W.middlewares,J=W.run.bind(W);f(j,F,J,C,W.source)}if(Y7(z)){let F=new z,W=Vj(F.routes,`${O}${j}`,F.middlewares);for(let[C,J]of Object.entries(W))Z[C.replaceAll("//","/")]=J}if(D7(z)){let{first:F,second:W}=z;for(let[C,J]of Object.entries(F)){let Y=J.middlewares,D=J.run.bind(J),[U,...X]=j.split("/").reverse();if(!U.startsWith(":"))throw Error("Resource route must end with a dynamic segment");f(X.reverse().join("/"),C,D,Y,J.source)}for(let[C,J]of Object.entries(W)){let Y=J.middlewares,D=J.run.bind(J);f(j,C,D,Y,J.source)}}}return Object.fromEntries(Object.entries(Z).sort(([j],[z])=>{let F=j.split("/").length+j.split(":").length,W=z.split("/").length+z.split(":").length;return F-W}))}function zZ($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function Nj($,O){if($==="/")return O;if(O==="/")return $;return`${$}${O}`}function Ej($){let O=zZ($);return O.length>1?O.replace(/\/$/,""):O}function dC($,O){return O.map((T)=>({...T,path:Ej(Nj($,T.path))}))}function FZ($){let O={};for(let[T,Z]of Object.entries($))if("run"in Z){let f=Z;if("children"in f){let j=new f.children,z=FZ(j.routes);for(let[F,{exec:W,middleware:C,segments:J,features:Y}]of Object.entries(z)){let D=Nj(T,F),U=(X)=>f.run.call(f,X,T);O[zZ(D)]={exec:[U,...W],middleware:[...f.middlewares,...C],features:[...f.featureGates,...Y],viewPath:f.viewPath,segments:[{path:Ej(T),viewPath:f.viewPath,...f.alwaysRuns?{alwaysRun:!0}:{}},...dC(T,J)]}}}else{let j=(z)=>f.run.call(f,z,T);O[zZ(T)]={exec:[j],middleware:f.middlewares,features:f.featureGates,viewPath:f.viewPath,segments:[{path:Ej(T),viewPath:f.viewPath}]}}}else{let f=new Z,j=FZ(f.routes);for(let[z,{exec:F,middleware:W,viewPath:C,segments:J,features:Y}]of Object.entries(j)){let D=Nj(T,z);O[zZ(D)]={exec:F,middleware:[...f.middlewares,...W],features:[...f.featureGates,...Y],viewPath:C,segments:dC(T,J)}}}return Object.fromEntries(Object.entries(O).sort(([T],[Z])=>{let f=T.split("/").length+T.split(":").length,j=Z.split("/").length+Z.split(":").length;return f-j}))}var G7=Object.defineProperty,V=($,O)=>G7($,"name",{value:O,configurable:!0}),p$=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor($,O,T,Z,f,j){this.type=$,this.name=O,this.prefix=T,this.value=Z,this.suffix=f,this.modifier=j}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};V(p$,"Part");var B7=/[$_\p{ID_Start}]/u,K7=/[$_\u200C\u200D\p{ID_Continue}]/u,_j=".*";function sC($,O){return(O?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test($)}V(sC,"isASCII");function Hj($,O=!1){let T=[],Z=0;for(;Z<$.length;){let f=$[Z],j=V(function(z){if(!O)throw TypeError(z);T.push({type:"INVALID_CHAR",index:Z,value:$[Z++]})},"ErrorOrInvalid");if(f==="*"){T.push({type:"ASTERISK",index:Z,value:$[Z++]});continue}if(f==="+"||f==="?"){T.push({type:"OTHER_MODIFIER",index:Z,value:$[Z++]});continue}if(f==="\\"){T.push({type:"ESCAPED_CHAR",index:Z++,value:$[Z++]});continue}if(f==="{"){T.push({type:"OPEN",index:Z,value:$[Z++]});continue}if(f==="}"){T.push({type:"CLOSE",index:Z,value:$[Z++]});continue}if(f===":"){let z="",F=Z+1;for(;F<$.length;){let W=$.substr(F,1);if(F===Z+1&&B7.test(W)||F!==Z+1&&K7.test(W)){z+=$[F++];continue}break}if(!z){j(`Missing parameter name at ${Z}`);continue}T.push({type:"NAME",index:Z,value:z}),Z=F;continue}if(f==="("){let z=1,F="",W=Z+1,C=!1;if($[W]==="?"){j(`Pattern cannot start with "?" at ${W}`);continue}for(;W<$.length;){if(!sC($[W],!1)){j(`Invalid character '${$[W]}' at ${W}.`),C=!0;break}if($[W]==="\\"){F+=$[W++]+$[W++];continue}if($[W]===")"){if(z--,z===0){W++;break}}else if($[W]==="("&&(z++,$[W+1]!=="?")){j(`Capturing groups are not allowed at ${W}`),C=!0;break}F+=$[W++]}if(C)continue;if(z){j(`Unbalanced pattern at ${Z}`);continue}if(!F){j(`Missing pattern at ${Z}`);continue}T.push({type:"REGEX",index:Z,value:F}),Z=W;continue}T.push({type:"CHAR",index:Z,value:$[Z++]})}return T.push({type:"END",index:Z,value:""}),T}V(Hj,"lexer");function wj($,O={}){let T=Hj($);O.delimiter??="/#?",O.prefixes??="./";let Z=`[^${b0(O.delimiter)}]+?`,f=[],j=0,z=0,F="",W=new Set,C=V((Q)=>{if(z<T.length&&T[z].type===Q)return T[z++].value},"tryConsume"),J=V(()=>C("OTHER_MODIFIER")??C("ASTERISK"),"tryConsumeModifier"),Y=V((Q)=>{let E=C(Q);if(E!==void 0)return E;let{type:_,index:S}=T[z];throw TypeError(`Unexpected ${_} at ${S}, expected ${Q}`)},"mustConsume"),D=V(()=>{let Q="",E;for(;E=C("CHAR")??C("ESCAPED_CHAR");)Q+=E;return Q},"consumeText"),U=V((Q)=>Q,"DefaultEncodePart"),X=O.encodePart||U,G="",B=V((Q)=>{G+=Q},"appendToPendingFixedValue"),L=V(()=>{G.length&&(f.push(new p$(3,"","",X(G),"",3)),G="")},"maybeAddPartFromPendingFixedValue"),M=V((Q,E,_,S,I)=>{let P=3;switch(I){case"?":P=1;break;case"*":P=0;break;case"+":P=2;break}if(!E&&!_&&P===3){B(Q);return}if(L(),!E&&!_){if(!Q)return;f.push(new p$(3,"","",X(Q),"",P));return}let A;_?_==="*"?A=_j:A=_:A=Z;let T0=2;A===Z?(T0=1,A=""):A===_j&&(T0=0,A="");let g;if(E?g=E:_&&(g=j++),W.has(g))throw TypeError(`Duplicate name '${g}'.`);W.add(g),f.push(new p$(T0,g,X(Q),A,X(S),P))},"addPart");for(;z<T.length;){let Q=C("CHAR"),E=C("NAME"),_=C("REGEX");if(!E&&!_&&(_=C("ASTERISK")),E||_){let I=Q??"";O.prefixes.indexOf(I)===-1&&(B(I),I=""),L();let P=J();M(I,E,_,"",P);continue}let S=Q??C("ESCAPED_CHAR");if(S){B(S);continue}if(C("OPEN")){let I=D(),P=C("NAME"),A=C("REGEX");!P&&!A&&(A=C("ASTERISK"));let T0=D();Y("CLOSE");let g=J();M(I,P,A,T0,g);continue}L(),Y("END")}return f}V(wj,"parse");function b0($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}V(b0,"escapeString");function Pj($){return $&&$.ignoreCase?"ui":"u"}V(Pj,"flags");function uC($,O,T){return bj(wj($,T),O,T)}V(uC,"stringToRegexp");function Z$($){switch($){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}V(Z$,"modifierToString");function bj($,O,T={}){T.delimiter??="/#?",T.prefixes??="./",T.sensitive??=!1,T.strict??=!1,T.end??=!0,T.start??=!0,T.endsWith="";let Z=T.start?"^":"";for(let F of $){if(F.type===3){F.modifier===3?Z+=b0(F.value):Z+=`(?:${b0(F.value)})${Z$(F.modifier)}`;continue}O&&O.push(F.name);let W=`[^${b0(T.delimiter)}]+?`,C=F.value;if(F.type===1?C=W:F.type===0&&(C=_j),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?Z+=`(${C})${Z$(F.modifier)}`:Z+=`((?:${C})${Z$(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){Z+=`(?:${b0(F.prefix)}(${C})${b0(F.suffix)})`,Z+=Z$(F.modifier);continue}Z+=`(?:${b0(F.prefix)}`,Z+=`((?:${C})(?:`,Z+=b0(F.suffix),Z+=b0(F.prefix),Z+=`(?:${C}))*)${b0(F.suffix)})`,F.modifier===0&&(Z+="?")}let f=`[${b0(T.endsWith)}]|$`,j=`[${b0(T.delimiter)}]`;if(T.end)return T.strict||(Z+=`${j}?`),T.endsWith.length?Z+=`(?=${f})`:Z+="$",new RegExp(Z,Pj(T));T.strict||(Z+=`(?:${j}(?=${f}))?`);let z=!1;if($.length){let F=$[$.length-1];F.type===3&&F.modifier===3&&(z=T.delimiter.indexOf(F)>-1)}return z||(Z+=`(?=${j}|${f})`),new RegExp(Z,Pj(T))}V(bj,"partsToRegexp");var g1={delimiter:"",prefixes:"",sensitive:!0,strict:!0},L7={delimiter:".",prefixes:"",sensitive:!0,strict:!0},Q7={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function aC($,O){return $.length?$[0]==="/"?!0:!O||$.length<2?!1:($[0]=="\\"||$[0]=="{")&&$[1]=="/":!1}V(aC,"isAbsolutePathname");function vj($,O){return $.startsWith(O)?$.substring(O.length,$.length):$}V(vj,"maybeStripPrefix");function nC($,O){return $.endsWith(O)?$.substr(0,$.length-O.length):$}V(nC,"maybeStripSuffix");function gj($){return!$||$.length<2?!1:$[0]==="["||($[0]==="\\"||$[0]==="{")&&$[1]==="["}V(gj,"treatAsIPv6Hostname");var oC=["ftp","file","http","https","ws","wss"];function kj($){if(!$)return!0;for(let O of oC)if($.test(O))return!0;return!1}V(kj,"isSpecialScheme");function rC($,O){if($=vj($,"#"),O||$==="")return $;let T=new URL("https://example.com");return T.hash=$,T.hash?T.hash.substring(1,T.hash.length):""}V(rC,"canonicalizeHash");function tC($,O){if($=vj($,"?"),O||$==="")return $;let T=new URL("https://example.com");return T.search=$,T.search?T.search.substring(1,T.search.length):""}V(tC,"canonicalizeSearch");function eC($,O){return O||$===""?$:gj($)?mj($):yj($)}V(eC,"canonicalizeHostname");function $8($,O){if(O||$==="")return $;let T=new URL("https://example.com");return T.password=$,T.password}V($8,"canonicalizePassword");function O8($,O){if(O||$==="")return $;let T=new URL("https://example.com");return T.username=$,T.username}V(O8,"canonicalizeUsername");function T8($,O,T){if(T||$==="")return $;if(O&&!oC.includes(O))return new URL(`${O}:${$}`).pathname;let Z=$[0]=="/";return $=new URL(Z?$:"/-"+$,"https://example.com").pathname,Z||($=$.substring(2,$.length)),$}V(T8,"canonicalizePathname");function Z8($,O,T){return Rj(O)===$&&($=""),T||$===""?$:qj($)}V(Z8,"canonicalizePort");function f8($,O){return $=nC($,":"),O||$===""?$:WZ($)}V(f8,"canonicalizeProtocol");function Rj($){switch($){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}V(Rj,"defaultPortForProtocol");function WZ($){if($==="")return $;if(/^[-+.A-Za-z0-9]*$/.test($))return $.toLowerCase();throw TypeError(`Invalid protocol '${$}'.`)}V(WZ,"protocolEncodeCallback");function j8($){if($==="")return $;let O=new URL("https://example.com");return O.username=$,O.username}V(j8,"usernameEncodeCallback");function z8($){if($==="")return $;let O=new URL("https://example.com");return O.password=$,O.password}V(z8,"passwordEncodeCallback");function yj($){if($==="")return $;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test($))throw TypeError(`Invalid hostname '${$}'`);let O=new URL("https://example.com");return O.hostname=$,O.hostname}V(yj,"hostnameEncodeCallback");function mj($){if($==="")return $;if(/[^0-9a-fA-F[\]:]/g.test($))throw TypeError(`Invalid IPv6 hostname '${$}'`);return $.toLowerCase()}V(mj,"ipv6HostnameEncodeCallback");function qj($){if($===""||/^[0-9]*$/.test($)&&parseInt($)<=65535)return $;throw TypeError(`Invalid port '${$}'.`)}V(qj,"portEncodeCallback");function F8($){if($==="")return $;let O=new URL("https://example.com");return O.pathname=$[0]!=="/"?"/-"+$:$,$[0]!=="/"?O.pathname.substring(2,O.pathname.length):O.pathname}V(F8,"standardURLPathnameEncodeCallback");function W8($){return $===""?$:new URL(`data:${$}`).pathname}V(W8,"pathURLPathnameEncodeCallback");function C8($){if($==="")return $;let O=new URL("https://example.com");return O.search=$,O.search.substring(1,O.search.length)}V(C8,"searchEncodeCallback");function J8($){if($==="")return $;let O=new URL("https://example.com");return O.hash=$,O.hash.substring(1,O.hash.length)}V(J8,"hashEncodeCallback");var D8=class{#j;#Z=[];#O={};#$=0;#f=1;#C=0;#F=0;#X=0;#U=0;#G=!1;constructor($){this.#j=$}get result(){return this.#O}parse(){for(this.#Z=Hj(this.#j,!0);this.#$<this.#Z.length;this.#$+=this.#f){if(this.#f=1,this.#Z[this.#$].type==="END"){if(this.#F===0){this.#Q(),this.#J()?this.#T(9,1):this.#D()?this.#T(8,1):this.#T(7,0);continue}else if(this.#F===2){this.#Y(5);continue}this.#T(10,0);break}if(this.#X>0)if(this.#x())this.#X-=1;else continue;if(this.#E()){this.#X+=1;continue}switch(this.#F){case 0:this.#S()&&this.#Y(1);break;case 1:if(this.#S()){this.#A();let $=7,O=1;this.#I()?($=2,O=3):this.#G&&($=2),this.#T($,O)}break;case 2:this.#K()?this.#Y(3):(this.#L()||this.#D()||this.#J())&&this.#Y(5);break;case 3:this.#V()?this.#T(4,1):this.#K()&&this.#T(5,1);break;case 4:this.#K()&&this.#T(5,1);break;case 5:this.#_()?this.#U+=1:this.#P()&&(this.#U-=1),this.#N()&&!this.#U?this.#T(6,1):this.#L()?this.#T(7,0):this.#D()?this.#T(8,1):this.#J()&&this.#T(9,1);break;case 6:this.#L()?this.#T(7,0):this.#D()?this.#T(8,1):this.#J()&&this.#T(9,1);break;case 7:this.#D()?this.#T(8,1):this.#J()&&this.#T(9,1);break;case 8:this.#J()&&this.#T(9,1);break;case 9:break;case 10:break}}this.#O.hostname!==void 0&&this.#O.port===void 0&&(this.#O.port="")}#T($,O){switch(this.#F){case 0:break;case 1:this.#O.protocol=this.#W();break;case 2:break;case 3:this.#O.username=this.#W();break;case 4:this.#O.password=this.#W();break;case 5:this.#O.hostname=this.#W();break;case 6:this.#O.port=this.#W();break;case 7:this.#O.pathname=this.#W();break;case 8:this.#O.search=this.#W();break;case 9:this.#O.hash=this.#W();break;case 10:break}this.#F!==0&&$!==10&&([1,2,3,4].includes(this.#F)&&[6,7,8,9].includes($)&&(this.#O.hostname??=""),[1,2,3,4,5,6].includes(this.#F)&&[8,9].includes($)&&(this.#O.pathname??=this.#G?"/":""),[1,2,3,4,5,6,7].includes(this.#F)&&$===9&&(this.#O.search??="")),this.#M($,O)}#M($,O){this.#F=$,this.#C=this.#$+O,this.#$+=O,this.#f=0}#Q(){this.#$=this.#C,this.#f=0}#Y($){this.#Q(),this.#F=$}#B($){return $<0&&($=this.#Z.length-$),$<this.#Z.length?this.#Z[$]:this.#Z[this.#Z.length-1]}#z($,O){let T=this.#B($);return T.value===O&&(T.type==="CHAR"||T.type==="ESCAPED_CHAR"||T.type==="INVALID_CHAR")}#S(){return this.#z(this.#$,":")}#I(){return this.#z(this.#$+1,"/")&&this.#z(this.#$+2,"/")}#K(){return this.#z(this.#$,"@")}#V(){return this.#z(this.#$,":")}#N(){return this.#z(this.#$,":")}#L(){return this.#z(this.#$,"/")}#D(){if(this.#z(this.#$,"?"))return!0;if(this.#Z[this.#$].value!=="?")return!1;let $=this.#B(this.#$-1);return $.type!=="NAME"&&$.type!=="REGEX"&&$.type!=="CLOSE"&&$.type!=="ASTERISK"}#J(){return this.#z(this.#$,"#")}#E(){return this.#Z[this.#$].type=="OPEN"}#x(){return this.#Z[this.#$].type=="CLOSE"}#_(){return this.#z(this.#$,"[")}#P(){return this.#z(this.#$,"]")}#W(){let $=this.#Z[this.#$],O=this.#B(this.#C).index;return this.#j.substring(O,$.index)}#A(){let $={};Object.assign($,g1),$.encodePart=WZ;let O=uC(this.#W(),void 0,$);this.#G=kj(O)}};V(D8,"Parser");var xj=["protocol","username","password","hostname","port","pathname","search","hash"],v1="*";function Aj($,O){if(typeof $!="string")throw TypeError("parameter 1 is not of type 'string'.");let T=new URL($,O);return{protocol:T.protocol.substring(0,T.protocol.length-1),username:T.username,password:T.password,hostname:T.hostname,port:T.port,pathname:T.pathname,search:T.search!==""?T.search.substring(1,T.search.length):void 0,hash:T.hash!==""?T.hash.substring(1,T.hash.length):void 0}}V(Aj,"extractValues");function O1($,O){return O?c$($):$}V(O1,"processBaseURLString");function q$($,O,T){let Z;if(typeof O.baseURL=="string")try{Z=new URL(O.baseURL),O.protocol===void 0&&($.protocol=O1(Z.protocol.substring(0,Z.protocol.length-1),T)),!T&&O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.username===void 0&&($.username=O1(Z.username,T)),!T&&O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.username===void 0&&O.password===void 0&&($.password=O1(Z.password,T)),O.protocol===void 0&&O.hostname===void 0&&($.hostname=O1(Z.hostname,T)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&($.port=O1(Z.port,T)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.pathname===void 0&&($.pathname=O1(Z.pathname,T)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.pathname===void 0&&O.search===void 0&&($.search=O1(Z.search.substring(1,Z.search.length),T)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.pathname===void 0&&O.search===void 0&&O.hash===void 0&&($.hash=O1(Z.hash.substring(1,Z.hash.length),T))}catch{throw TypeError(`invalid baseURL '${O.baseURL}'.`)}if(typeof O.protocol=="string"&&($.protocol=f8(O.protocol,T)),typeof O.username=="string"&&($.username=O8(O.username,T)),typeof O.password=="string"&&($.password=$8(O.password,T)),typeof O.hostname=="string"&&($.hostname=eC(O.hostname,T)),typeof O.port=="string"&&($.port=Z8(O.port,$.protocol,T)),typeof O.pathname=="string"){if($.pathname=O.pathname,Z&&!aC($.pathname,T)){let f=Z.pathname.lastIndexOf("/");f>=0&&($.pathname=O1(Z.pathname.substring(0,f+1),T)+$.pathname)}$.pathname=T8($.pathname,$.protocol,T)}return typeof O.search=="string"&&($.search=tC(O.search,T)),typeof O.hash=="string"&&($.hash=rC(O.hash,T)),$}V(q$,"applyInit");function c$($){return $.replace(/([+*?:{}()\\])/g,"\\$1")}V(c$,"escapePatternString");function Y8($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}V(Y8,"escapeRegexpString");function X8($,O){O.delimiter??="/#?",O.prefixes??="./",O.sensitive??=!1,O.strict??=!1,O.end??=!0,O.start??=!0,O.endsWith="";let T=".*",Z=`[^${Y8(O.delimiter)}]+?`,f=/[$_\u200C\u200D\p{ID_Continue}]/u,j="";for(let z=0;z<$.length;++z){let F=$[z];if(F.type===3){if(F.modifier===3){j+=c$(F.value);continue}j+=`{${c$(F.value)}}${Z$(F.modifier)}`;continue}let W=F.hasCustomName(),C=!!F.suffix.length||!!F.prefix.length&&(F.prefix.length!==1||!O.prefixes.includes(F.prefix)),J=z>0?$[z-1]:null,Y=z<$.length-1?$[z+1]:null;if(!C&&W&&F.type===1&&F.modifier===3&&Y&&!Y.prefix.length&&!Y.suffix.length)if(Y.type===3){let D=Y.value.length>0?Y.value[0]:"";C=f.test(D)}else C=!Y.hasCustomName();if(!C&&!F.prefix.length&&J&&J.type===3){let D=J.value[J.value.length-1];C=O.prefixes.includes(D)}C&&(j+="{"),j+=c$(F.prefix),W&&(j+=`:${F.name}`),F.type===2?j+=`(${F.value})`:F.type===1?W||(j+=`(${Z})`):F.type===0&&(!W&&(!J||J.type===3||J.modifier!==3||C||F.prefix!=="")?j+="*":j+=`(${T})`),F.type===1&&W&&F.suffix.length&&f.test(F.suffix[0])&&(j+="\\"),j+=c$(F.suffix),C&&(j+="}"),F.modifier!==3&&(j+=Z$(F.modifier))}return j}V(X8,"partsToPattern");var cj=class{#j;#Z={};#O={};#$={};#f={};#C=!1;constructor($={},O,T){try{let Z;if(typeof O=="string"?Z=O:T=O,typeof $=="string"){let F=new D8($);if(F.parse(),$=F.result,Z===void 0&&typeof $.protocol!="string")throw TypeError("A base URL must be provided for a relative constructor string.");$.baseURL=Z}else{if(!$||typeof $!="object")throw TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(Z)throw TypeError("parameter 1 is not of type 'string'.")}typeof T>"u"&&(T={ignoreCase:!1});let f={ignoreCase:T.ignoreCase===!0},j={pathname:v1,protocol:v1,username:v1,password:v1,hostname:v1,port:v1,search:v1,hash:v1};this.#j=q$(j,$,!0),Rj(this.#j.protocol)===this.#j.port&&(this.#j.port="");let z;for(z of xj){if(!(z in this.#j))continue;let F={},W=this.#j[z];switch(this.#O[z]=[],z){case"protocol":Object.assign(F,g1),F.encodePart=WZ;break;case"username":Object.assign(F,g1),F.encodePart=j8;break;case"password":Object.assign(F,g1),F.encodePart=z8;break;case"hostname":Object.assign(F,L7),gj(W)?F.encodePart=mj:F.encodePart=yj;break;case"port":Object.assign(F,g1),F.encodePart=qj;break;case"pathname":kj(this.#Z.protocol)?(Object.assign(F,Q7,f),F.encodePart=F8):(Object.assign(F,g1,f),F.encodePart=W8);break;case"search":Object.assign(F,g1,f),F.encodePart=C8;break;case"hash":Object.assign(F,g1,f),F.encodePart=J8;break}try{this.#f[z]=wj(W,F),this.#Z[z]=bj(this.#f[z],this.#O[z],F),this.#$[z]=X8(this.#f[z],F),this.#C=this.#C||this.#f[z].some((C)=>C.type===2)}catch{throw TypeError(`invalid ${z} pattern '${this.#j[z]}'.`)}}}catch(Z){throw TypeError(`Failed to construct 'URLPattern': ${Z.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test($={},O){let T={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&O)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return!1;try{typeof $=="object"?T=q$(T,$,!1):T=q$(T,Aj($,O),!1)}catch{return!1}let Z;for(Z of xj)if(!this.#Z[Z].exec(T[Z]))return!1;return!0}exec($={},O){let T={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&O)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return;try{typeof $=="object"?T=q$(T,$,!1):T=q$(T,Aj($,O),!1)}catch{return null}let Z={};O?Z.inputs=[$,O]:Z.inputs=[$];let f;for(f of xj){let j=this.#Z[f].exec(T[f]);if(!j)return null;let z={};for(let[F,W]of this.#O[f].entries())if(typeof W=="string"||typeof W=="number"){let C=j[F+1];z[W]=C}Z[f]={input:T[f]??"",groups:z}}return Z}static compareComponent($,O,T){let Z=V((F,W)=>{for(let C of["type","modifier","prefix","value","suffix"]){if(F[C]<W[C])return-1;if(F[C]===W[C])continue;return 1}return 0},"comparePart"),f=new p$(3,"","","","",3),j=new p$(0,"","","","",3),z=V((F,W)=>{let C=0;for(;C<Math.min(F.length,W.length);++C){let J=Z(F[C],W[C]);if(J)return J}return F.length===W.length?0:Z(F[C]??f,W[C]??f)},"comparePartList");return!O.#$[$]&&!T.#$[$]?0:O.#$[$]&&!T.#$[$]?z(O.#f[$],[j]):!O.#$[$]&&T.#$[$]?z([j],T.#f[$]):z(O.#f[$],T.#f[$])}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.#C}};V(cj,"URLPattern");function bO($,O){for(let[T,Z]of Object.entries($)){let f=new cj({pathname:T});if(f.test({pathname:O}))return{routePath:T,params:f.exec({pathname:O})?.pathname.groups??{},route:Z}}return null}var f$={startIndex:0,carriedViews:[]};function U8($,O){let T=u($.path,O);return T.includes("*")?null:T}function S7($,O){if(!$)return f$;if($.search!==O.search)return f$;let T=Math.min($.segments.length,O.segments.length-1),Z=0;while(Z<T){let f=$.segments[Z],j=O.segments[Z];if(j.alwaysRun)break;if(f.viewPath!==j.viewPath)break;let z=U8(f,$.params),F=U8(j,O.params);if(z===null||F===null||z!==F)break;Z++}if(Z===0)return f$;return{startIndex:Z,carriedViews:O.segments.slice(0,Z).map(({viewPath:f})=>f)}}function M7($,O){let[,T,...Z]=$.split("/");if(!O.includes(T))return $;let f=`/${Z.join("/")}`;return f==="/"?"/":f.replace(/\/$/,"")}function G8($){let{flatViewRoutes:O,supportedLocales:T,from:Z,origin:f,to:j}=$;if(!Z)return f$;let z;try{z=new URL(Z,f)}catch{return f$}if(z.origin!==f)return f$;let F=bO(O,M7(z.pathname,T));if(!F)return f$;return S7({segments:F.route.segments,params:F.params,search:z.search},j)}var pj="x-gemi-from";import{createElement as a$,Fragment as c7}from"react";function I7($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function CZ($){let O={};for(let[T,Z]of Object.entries($))if("run"in Z){let f=Z.viewPath;if("children"in Z){O[T]=[f];let j=new Z.children,z=CZ(j.routes);for(let[F,W]of Object.entries(z)){let C=T==="/"?F:`${T}${F}`,J=F==="/"&&T!=="/"?T:C;O[J]=[f,...W]}if(O[T].length===1)delete O[T]}else O[T]=[f]}else{let f=new Z,j=CZ(f.routes);for(let[z,F]of Object.entries(j)){let W=T==="/"?z:`${T}${z}`,C=z==="/"&&T!=="/"?T:W;O[C]=F}}return Object.fromEntries(Object.entries(O).map(([T,Z])=>[I7(T),Z]))}function JZ($){let O=[];for(let[T,Z]of Object.entries($))if("run"in Z){let f=Z.viewPath;if(f==="__")continue;if(f==="REDIRECT")continue;if(f==="FILE")continue;if("children"in Z){let j=new Z.children,z=JZ(j.routes);O.push([f,z])}else O.push([f,[]])}else{let f=new Z,j=JZ(f.routes);O.push(...j)}return O}function ij($){let O=[];for(let[T,Z]of $)O.push(T,...ij(Z).flat());return Array.from(new Set(O))}class k1 extends O0{static getFacadeAccessor(){return HO}static debug($,O){this.getFacadeRoot().log("debug",$,O)}static info($,O){this.getFacadeRoot().log("info",$,O)}static notice($,O){this.getFacadeRoot().log("notice",$,O)}static warning($,O){this.getFacadeRoot().log("warning",$,O)}static error($,O){this.getFacadeRoot().log("error",$,O)}static critical($,O){this.getFacadeRoot().log("critical",$,O)}static alert($,O){this.getFacadeRoot().log("alert",$,O)}static emergency($,O){this.getFacadeRoot().log("emergency",$,O)}}class i$ extends O0{static getFacadeAccessor(){return a}static getSupportedLocales(){return this.getFacadeRoot().supportedLocales}static getDefaultLocale(){return this.getFacadeRoot().defaultLocale}static locale(){let $=this.getFacadeRoot(),O=N.getStore();if(O)return O.locale??$.detectLocale(O.req);return $.defaultLocale}static setLocale($=i$.locale()){let O=this.getFacadeRoot(),T=$;if(!O.supportedLocales.includes($))T=O.defaultLocale;let Z=N.getStore();return Z.setCookie("i18n-locale",T,{expires:new Date(Date.now()+31536000000),secure:!1,httpOnly:!1}),Z.setLocale(T),T}}class hj{id;static token="kernel.id";constructor($=crypto.randomUUID()){this.id=$}}var V7=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),N7=new Set(["svg","math"]);function B8($){return $===32||$===9||$===10||$===12||$===13}function K8($){return $>=65&&$<=90||$>=97&&$<=122}function DZ($){return $>=65&&$<=90?$+32:$}function L8(){let $="data",O="",T=!1,Z="",f=0,j=0,z=!1,F=0,W=0,C=()=>$==="data"&&F===0&&W===0,J=()=>{if(!T&&V7.has(O)){$="rawText",Z=`</${O}`,f=0,O="";return}if($="data",O==="template")if(T)F=Math.max(0,F-1);else F+=1;else if(N7.has(O)){if(T)W=Math.max(0,W-1);else if(!z)W+=1}O=""},Y=(D)=>{switch($){case"data":if(D===60)$="tagOpen";return;case"tagOpen":if(D===33)$="bang",j=0;else if(D===47)$="endTagOpen";else if(K8(D))$="tagName",T=!1,z=!1,O=String.fromCharCode(DZ(D));else if(D===63)$="bogus";else if(D===60)$="tagOpen";else $="data";return;case"endTagOpen":if(K8(D))$="tagName",T=!0,z=!1,O=String.fromCharCode(DZ(D));else if(D===62)$="data";else $="bogus";return;case"tagName":if(B8(D)||D===47)$="inTag",z=D===47;else if(D===62)J();else O+=String.fromCharCode(DZ(D));return;case"inTag":if(D===62){J();return}if(z=D===47,D===34)$="attrDouble";else if(D===39)$="attrSingle";return;case"attrDouble":if(D===34)$="inTag";z=!1;return;case"attrSingle":if(D===39)$="inTag";z=!1;return;case"bang":if(D===45){if(j+=1,j===2)$="comment",j=0}else if(D===62)$="data";else $="bogus";return;case"bogus":if(D===62)$="data";return;case"comment":if(D===45)j=j<2?j+1:2;else if(D===62&&j>=2)$="data",j=0;else j=0;return;case"rawText":{if(f<Z.length){if(DZ(D)===Z.charCodeAt(f))f+=1;else f=D===60?1:0;return}if(D===62)$="data",O="";else if(B8(D)||D===47)$="inTag",O="";else f=D===60?1:0;return}}};return{scanToInsertionPoint(D){for(let U=0;U<D.length;U++){if(C())return U;Y(D[U])}return D.length},write(D){for(let U=0;U<D.length;U++)Y(D[U])},isSafe:C}}function j$($){let O=JSON.stringify($);if(O===void 0)return"undefined";return O.replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function E7($){return`<script>(self.__GEMI_STREAM__=self.__GEMI_STREAM__||[]).push(${j$([$.path,$.variantKey,$.data])})</script>`}function x7($){return`<script>(self.__GEMI_DICT__=self.__GEMI_DICT__||[]).push(${j$([$.id,$.locale,$.strings])})</script>`}function lj($,O,T={},Z){let f=new TextEncoder,j=[],z=!1,F=!1,W=()=>{if(F)return;F=!0,T.onClose?.()};O.onSettle((X)=>{if(X.status!=="resolved")return;j.push(E7(X))}),Z?.onUse((X)=>{j.push(x7(X))});let C=$.getReader(),J=L8(),Y=(X,G)=>{X.enqueue(G),T.onChunk?.(G)},D=(X)=>{while(j.length>0){let G=f.encode(j.shift());J.write(G),Y(X,G)}},U=(X,G)=>{if(j.length===0){J.write(G),Y(X,G);return}let B=J.scanToInsertionPoint(G);if(B>0)Y(X,G.subarray(0,B));if(J.isSafe())D(X);let L=G.subarray(B);if(L.length>0)J.write(L),Y(X,L)};return new ReadableStream({async pull(X){let G;try{G=await C.read()}catch(M){throw W(),M}let{done:B,value:L}=G;if(B){D(X),X.close(),W();return}if(!z){if(z=!0,J.write(L),Y(X,L),T.onShell?.(),J.isSafe())D(X);return}U(X,L)},cancel(X){return W(),C.cancel(X)}})}var _7=/bot|crawler|spider|crawling|slurp|bingpreview|mediapartners|headless|lighthouse|prerender|facebookexternalhit|whatsapp|telegram|discord|twitterbot|linkedinbot/i;function YZ($){if(!$)return!1;return _7.test($)}async function S8($,O=()=>{}){let T=N.getStore(),Z=T?.req??null,f=null;if(Z?.rawRequest?.url)try{f=new URL(Z.rawRequest.url).pathname}catch{f=null}return{user:T?.user??null,attributes:await P7($,O),request:{path:f,routePath:Z?.routePath??null,locale:T?.locale??null},anonymousId:Q8(),isBot:YZ(Z?.rawRequest?.headers?.get("user-agent")??null),now:new Date}}function M8($){return{user:$.user??null,attributes:$.attributes??{},request:{path:null,routePath:null,locale:null},anonymousId:$.subjectId??null,isBot:!1,now:new Date}}async function P7($,O){if(!$.context)return{};try{let T=N.getStore();return await $.context(T?.req??null)??{}}catch(T){return O(`The \`context\` hook in app/config/features.ts threw; evaluating with no attributes. ${T instanceof Error?T.message:String(T)}`),{}}}function I8($,O){return`${$}:${O}`}function dj($){let O=new Bun.CryptoHasher("sha1").update($).digest("hex"),T=Number.parseInt(O.slice(0,8),16);return Math.floor(T/4294967296*1e4)}function V8($,O){if(O>=100)return!0;if(O<=0)return!1;return $<Math.round(O*100)}function N8($,O,T,Z){if(Z.unavailable)return{value:!1,reason:"unavailable"};if(Z.active!==!0)return{value:!1,reason:"inactive"};if(O.when){let j;try{j=O.when(T)}catch(z){return Z.warn?.(`The \`when\` for feature "${$}" threw; treating it as off. ${z instanceof Error?z.message:String(z)}`),{value:!1,reason:"error"}}if(typeof j==="boolean")return{value:j,reason:"attributed"}}if(O.rollout===void 0)return{value:!0,reason:"on"};if(T.isBot)return{value:!1,reason:"bot"};let f=H7($,O,T,Z.buckets);return V8(f,O.rollout)?{value:!0,reason:"rollout"}:{value:!1,reason:"excluded"}}function A7($){let O=$.user?.publicId??$.user?.id;if(O!==void 0&&O!==null)return String(O);return $.anonymousId??""}function H7($,O,T,Z){let f=I8(O.salt??$,A7(T));if(!Z)return dj(f);let j=Z.get(f);if(j!==void 0)return j;let z=dj(f);return Z.set(f,z),z}class E8 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 sj{source;declared;ttlMs;warn;snapshot=null;inflight=null;lastFailureLoggedAt=0;generation=0;lastError=null;retryAfter=0;constructor($,O,T,Z=()=>{}){this.source=$;this.declared=O;this.ttlMs=T;this.warn=Z}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,O=await this.refresh();if(this.generation===$)throw new E8(this.lastError);return O}peek(){return this.snapshot}async load(){try{let $=await this.source.load();return this.snapshot={active:this.readSwitches($),loadedAt:Date.now(),unavailable:!1},this.generation++,this.lastError=null,this.retryAfter=0,this.snapshot}catch($){return this.handleFailure($)}}readSwitches($){let O=new Map;for(let T of $??[]){let Z=typeof T?.key==="string"?T.key:null;if(!Z){this.warn("Ignoring a feature row with no `key`.");continue}if(!(Z in this.declared)){this.warn(`Feature row "${Z}" is not declared in app/features, so it is ignored. Delete the row, or declare the feature.`);continue}O.set(Z,T.active===!0)}return O}handleFailure($){let O=$ instanceof Error?$.message:String($),T=Date.now();if(this.lastError=$,this.retryAfter=T+this.ttlMs,T-this.lastFailureLoggedAt>=this.ttlMs)this.lastFailureLoggedAt=T,this.warn(`Could not load feature switches: ${O}`);if(this.snapshot)return this.snapshot;return this.snapshot={active:new Map,loadedAt:T,unavailable:!0},this.snapshot}}class x8{manager;ctx;constructor($,O){this.manager=$;this.ctx=O}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 h${config;log;static token="features";store;declared;warnedAboutSize=!1;constructor($,O=()=>{}){this.config=$;this.log=O;this.declared=$.features??{},this.store=new sj($.source,this.declared,Math.max(0,$.ttl)*1000,this.log)}declarations(){return this.declared}async list(){let{active:$,unavailable:O}=await this.switches();return{unavailable:O,features:Object.entries(this.declared).map(([T,Z])=>({key:T,describe:Z.describe,rollout:Z.rollout,targeted:Z.when!==void 0,serverOnly:Z.serverOnly,salt:Z.salt,active:$.get(T)}))}}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{N.getStore()?.featureEvaluations?.clear()}}async enabled($){return(await this.explain($)).value}async explain($){let O=await this.requestContext();return await this.evaluateIn($,O,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(),O=await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!0});return this.warnIfOversized(Object.keys(O).length),O}for($){return new x8(this,M8($))}async evaluateIn($,O,T){let Z=this.memoFor(O),f=Z?.get($);if(f)return f;let j=this.declared[$];if(!j)return{value:!1,reason:"undeclared"};let{active:z,unavailable:F}=await this.switchFor($),W=N8($,j,O,{active:z,unavailable:F,buckets:T,warn:this.log});return Z?.set($,W),this.notify($,W,O),W}async evaluateAllIn($,O,T){let Z={};for(let[f,j]of Object.entries(this.declared)){if(T.clientOnly&&j.serverOnly)continue;Z[f]=(await this.evaluateIn(f,$,O)).value}return Z}async switches(){if(!this.config.enabled)return{active:new Map,unavailable:!1};if(Object.keys(this.declared).length===0)return{active:new Map,unavailable:!1};let $=await this.store.get();return{active:$.active,unavailable:$.unavailable}}async switchFor($){if(!this.config.enabled)return{active:!1,unavailable:!1};let O=await this.store.get();return{active:O.active.get($),unavailable:O.unavailable}}async requestContext(){let $=N.getStore();if($?.featureContext)return $.featureContext;let O=await S8(this.config,this.log);if($)$.featureContext=O;return O}memoFor($){let O=N.getStore();if(!O||O.featureContext!==$)return null;return O.featureEvaluations??=new Map,O.featureEvaluations}requestBuckets(){let $=N.getStore();if(!$)return new Map;return $.featureBuckets??=new Map,$.featureBuckets}notify($,O,T){if(!this.config.onEvaluate)return;try{this.config.onEvaluate($,O,T)}catch(Z){this.log(`The \`onEvaluate\` hook in app/config/features.ts threw for "${$}". ${Z instanceof Error?Z.message:String(Z)}`)}}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 _8($){return Object.fromEntries(Object.entries($).filter(([,O])=>{return O!==null&&O!==void 0}))}var w7=50;class l${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($,O){return[$,O].filter((T)=>T.length>0).join("?")}markRenderStart(){if(this.renderStartedAt===null)this.renderStartedAt=performance.now()}markShell(){if(this.shellAt===null)this.shellAt=this.elapsed()}summarize($){let O=this.elapsed();return{shellAt:this.shellAt??O,settledAt:O,aborted:$,queries:Array.from(this.entries.values(),(T)=>({path:T.path,variantKey:T.variantKey,startedAt:T.startedAt,settledAt:T.settledAt,status:T.status,source:T.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 O="";try{let f=JSON.stringify($.data)?.length??0;O=f>=1024?`${(f/1024).toFixed(1)} kB`:`${f} B`}catch{O="an unserializable payload"}let T=($.settledAt??0)-$.startedAt,Z=$.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 (${T}ms, resolved ${O}) could not overlap the others. It still streamed. If the query belongs on this route, \`Query.prefetch("${$.patternPath}"${Z})\` 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 ${O}. 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($,O){return this.entries.get(this.keyFor($,O))}ensure($,O={},T="render"){let Z=O.params??{},f=new URLSearchParams(_8(O.search??{}));f.delete("json"),f.sort();let j=u($,Z),z=f.toString(),F=this.keyFor(j,z),W=this.entries.get(F);if(W)return W;let C;if(T==="render"&&this.renderStartedAt!==null){let U=Math.round(performance.now()-this.renderStartedAt);if(U>w7)C=U}let J,Y=new Promise((U)=>{J=U}),D={path:j,patternPath:$,variantKey:z,lateBy:C,status:"pending",promise:Y,source:T,startedAt:this.elapsed()};return this.entries.set(F,D),this.fetcher($,Z,f).then((U)=>{D.status="resolved",D.data=U},(U)=>{D.status="rejected",D.error=U}).then(()=>{if(D.settledAt=this.elapsed(),this.maybeLogLateDiscovery(D),D.status==="rejected"&&this.failListener)this.failListener(D);if(this.settleListener)this.settleListener(D);else this.settledBacklog.push(D);J()}),D}async allSettled(){let $=0;while($!==this.entries.size)$=this.entries.size,await Promise.all(Array.from(this.entries.values(),(O)=>O.promise))}snapshotResolved(){let $={};for(let[O,T]of this.entries){if(T.status!=="resolved")continue;this.shipped.add(O),$[T.path]??={},$[T.path][T.variantKey]=T.data}return $}onSettle($){this.settleListener=(T)=>{if(this.shipped.has(this.keyFor(T.path,T.variantKey)))return;$(T)};let O=this.settledBacklog;this.settledBacklog=[];for(let T of O)this.settleListener(T)}}class z$ extends Error{path;variantKey;status;body;constructor($,O,T,Z){super(typeof Z?.message==="string"?Z.message:`Request to /api${$} failed with status ${T}`);this.path=$;this.variantKey=O;this.status=T;this.body=Z;this.name="QueryError"}}function d$(){let $=JSON.stringify({error:{message:"Forbidden"}});return new Response($,{status:403,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}function uj(){return{status:403,error:{message:"Forbidden"}}}function vO($){let O=s$.getStore();return(T,Z,f)=>{let j=new URL($.url).origin,z=[u(T,Z),f.toString()].filter((J)=>J.length>0).join("?"),F=new Request(`${j}/${z}`,{headers:$.headers}),W=P8($);if(W)u$(F,W);let C=new x(F,Z);return s$.run(O,()=>N.run(C,async()=>{try{let J=await K(u0).dispatchers(W).api.getRouteData(T);if(J instanceof Response){let Y=await J.json().catch(()=>null);if(!J.ok)throw new z$(u(T,Z),f.toString(),J.status,Y);return Y}return J}catch(J){if(J instanceof z$)throw J;let Y=new z$(u(T,Z),f.toString(),500,{message:J instanceof Error?J.message:String(J)});throw Y.cause=J,Y}}))}}var b7=new Set(["script","style","template","title"]),v7=/\shidden([\s=/]|$)/i,g7=/"[^"]*"|'[^']*'/g;function k7($){let O=0,T=0,Z=0,f=0;while(f<$.length){let j=$.indexOf("<",f),z=j===-1?$.length:j;if(z>f){let Y=$.slice(f,z).replace(/\s+/g,"").length;if(Z>0)T+=Y;else O+=Y}if(j===-1)break;if($.startsWith("<!--",j)){let Y=$.indexOf("-->",j+4);f=Y===-1?$.length:Y+3;continue}let F=$.indexOf(">",j);if(F===-1)break;let W=$.slice(j+1,F);f=F+1;let C=/^\/?([a-zA-Z][a-zA-Z0-9-]*)/.exec(W)?.[1]?.toLowerCase();if(!C)continue;let J=W.startsWith("/");if(!J&&b7.has(C)&&!W.endsWith("/")){let Y=$.indexOf(`</${C}`,f);f=Y===-1?$.length:Y;continue}if(C!=="div")continue;if(J){if(Z>0)Z-=1}else if(Z>0)Z+=1;else if(v7.test(W.replace(g7,'""')))Z=1}return{shellChars:O,deferredChars:T}}var R7=1000,y7=64;function m7($){return $>=1000?`${($/1000).toFixed(1)} kB`:`${$} chars`}function q7($,O){if(O.deferredChars<R7)return null;if(O.shellChars>=y7)return null;return`[gemi] GET ${$} streams ${m7(O.deferredChars)} of its `+`content behind reveal scripts \u2014 a no-JS visitor sees ~${O.shellChars} chars. If this is a public/content route, add "no-stream" to its middleware.`}function A8($=console.warn){let O=new Set;return{shouldObserve(T){return!O.has(T)},report(T,Z){if(O.has(T))return;let f=q7(T,Z);if(!f)return;O.add(T),$(f)}}}function H8(){let $=new TextDecoder,O="";return{onChunk(T){O+=$.decode(T,{stream:!0})},measure(){return O+=$.decode(),k7(O)}}}function w8($,O,T=1e4,Z){let f=new TextEncoder,j=()=>{};return new ReadableStream({start(z){let F=!1,W=(J)=>{if(F)return;F=!0,clearTimeout(C);try{z.close()}catch{}Z?.({aborted:J})};j=W,z.enqueue(f.encode(`${JSON.stringify($)}
5
- `)),O.onSettle((J)=>{if(F||J.status!=="resolved")return;z.enqueue(f.encode(`${JSON.stringify([J.path,J.variantKey,J.data])}
6
- `))});let C=setTimeout(()=>W(!0),T);O.allSettled().then(()=>W(!1),()=>W(!1))},cancel(){j(!1)}})}var p7=async()=>(await import("./chunk-rm5qa99y.js")).default,aj,nj=async(...$)=>{return aj??=import("react-dom/server.browser").catch((O)=>{throw aj=void 0,O}),(await aj).renderToReadableStream(...$)},i7=1e4,h7=`
7
- !function(){try{var d=document.documentElement,c=d.classList;
8
- c.remove('light','dark');
9
- var e=localStorage.getItem('theme');
10
- if('system'===e||(!e&&'system'===defaultTheme)){
11
- var t='(prefers-color-scheme: dark)',m=window.matchMedia(t);
12
- if(m.media!==t||m.matches){d.style.colorScheme='dark';c.add('dark')}
13
- else{d.style.colorScheme='light';c.add('light')}
14
- }else if(e){
15
- c.add(e||'')
16
- }}catch(e){}}()
17
- `;async function l7($,O,T){let Z=`${T==="italic"?"italic,":""}wght@${T==="italic"?"1,":""}${O}`,z=(await(await fetch(`https://fonts.googleapis.com/css2?family=${$}:${Z}&display=swap`,{headers:{"User-Agent":"Mozilla/5.0 Firefox/1.0"}})).text()).match(/url\(([^)]+)\)/)?.[1];return await fetch(z).then((F)=>F.arrayBuffer())}var tj="/assets";function d7($){return $===tj||$.startsWith(`${tj}/`)}function s7($){let O=$.filter(d7);if(O.length>0){let T=O.length>1;throw Error(`View route path${T?"s":""} ${O.map((Z)=>`"${Z}"`).join(", ")} use${T?"":"s"} the reserved "${tj}" prefix. The client build output is served from there before the router runs, so the route would never match. Mount it somewhere else.`)}}function u7($){let O=K(u0).resolver;return{...$.domain,root:O.root,origin:O.publicOrigin($.rawRequest)}}function oj($){let{status:O=400,error:T}=$;return new Response(T?.message,{...$,status:O})}function a7($){let{status:O=400,data:T,directive:Z,headers:f}=$;return new Response(JSON.stringify({data:T,directive:Z}),{headers:f,status:O})}class RO{static token="router.view";flatViewRoutes={};routeManifest={};clientRouteManifest={};componentTree=[];flatComponentTree=[];root=null;shellReporter=A8();preloadCache=new WeakMap;hooks;partialRendering;constructor($){let O=lC();this.partialRendering=$.partialRendering??O.partialRendering,this.hooks={onRequestStart:$.onRequestStart??O.onRequestStart,onRequestEnd:$.onRequestEnd??O.onRequestEnd,onRequestFail:$.onRequestFail??O.onRequestFail,onStreamComplete:$.onStreamComplete??O.onStreamComplete};let T={"/":$.rootRouter,"/auth":Xj};this.flatViewRoutes=FZ(T),s7(Object.keys(this.flatViewRoutes)),this.routeManifest=CZ(T),this.clientRouteManifest=Object.fromEntries(Object.entries(this.routeManifest).filter(([,Z])=>Z.at(-1)!=="FILE")),this.componentTree=JZ(T),this.flatComponentTree=ij(this.componentTree),this.root=$.root}async passesFeatureGates($){let O=K(h$);for(let T of $)if(!await O.enabled(T))return!1;return!0}async onRequestEnd($){return rj(),await this.hooks.onRequestEnd($)}completeStream($,O){let T=(Z)=>{k1.error(Z?.message??'Error in "onStreamComplete" event handler',{err:JSON.stringify(Z)})};try{Promise.resolve(this.hooks.onStreamComplete($,O)).catch(T)}catch(Z){T(Z)}}modulePreloadLinks($){let{clientEntry:O,modulePreloadManifest:T,views:Z,routeKey:f}=$,j=()=>{let W=new Set(O?.preload??[]);for(let C of Z)for(let J of T?.[C]??[])W.add(J);return[...W].map((C)=>a$("link",{key:`modulepreload:${C}`,rel:"modulepreload",href:C}))};if(!T)return j();let z=this.preloadCache.get(T);if(!z||z.clientEntry!==O)z={clientEntry:O,byRoute:new Map},this.preloadCache.set(T,z);let F=z.byRoute.get(f);if(!F)F=j(),z.byRoute.set(f,F);return F}async render($){let{req:O,runInRequestScope:T,csrfTokenHMAC:Z,currentPathName:f,headers:j,i18n:z,params:F,pathname:W,serverQueries:C,userAgent:J,noStream:Y,url:D,user:U,viewData:X,breadcrumbs:G,urlLocaleSegment:B,meta:L,isOgRequest:M,appId:Q,features:E}=$,_=W.replace(`/${B}`,""),S={kind:"view",data:{meta:L,pageData:{[_]:X},__csrf:Z.toString("base64"),prefetchedData:{},i18n:z,auth:{user:U},routeManifest:this.clientRouteManifest,breadcrumbs:G,router:{urlLocaleSegment:B,pathname:f,params:F,currentPath:W,searchParams:D.search,is404:!f?!0:!1,domain:O.domain?u7(O):null},appId:Q,features:E,componentTree:[["404",[]],...this.componentTree]},head:{}},I=this.root,P=this.routeManifest[f];return async(A)=>{let{bootstrapModules:T0=[],loaders:g,getStyles:y,viewImportMap:Z0,cssManifest:LZ,ogMap:yO,viewModules:F$,clientEntry:Z1,modulePreloadManifest:R1,assetBase:f0}=A,r$=Z1?[]:T0,mO=(V0)=>[V0,`window.loaders=${g}`,...Z1?[`import(${JSON.stringify(Z1.module)}).catch(function(e){setTimeout(function(){throw e})})`]:[]].join(";");if(M){let V0=null,J$=null;for(let D$ of P??[])if(typeof yO[D$]==="function")J$=D$,V0=yO[D$];if(!V0)return new Response("Not found",{status:404});let f2=Object.values(S.data.pageData)[0];try{await nj(a$(V0,f2[J$]),{onError:()=>{}})}catch(D$){let{fonts:j2,...z2}=D$.satoriOptions,F2=await Promise.all(j2.map((cO)=>{return l7(cO.name,cO.weight,cO.style).then((Y2)=>({...cO,data:Y2}))})),Wz=new Headers(j);Wz.set("Content-Type","image/png");let[W2,C2]=await Promise.all([p7(),jZ("Rendering an OG image")]),J2=await W2(D$.jsx,{...z2,fonts:F2}),D2=await C2(Buffer.from(J2)).png({compressionLevel:0,effort:10}).toBuffer();return new Response(new Uint8Array(D2),{headers:Wz})}return new Response("data")}if(S.data.cssManifest=LZ,S.data.modulePreloadManifest=R1??{},f0&&f0!=="/")S.data.assetBase=f0;let W$=this.modulePreloadLinks({clientEntry:Z1,modulePreloadManifest:R1,views:P??["404"],routeKey:f??"404"}),t$=await y(P);S.data.prefetchedData=C.snapshotResolved(),C.markRenderStart();let U1=new AbortController,qO=setTimeout(()=>U1.abort(),i7),H=YZ(J)||Y,I0=Bun.env.NODE_ENV!=="production"&&!H&&f&&this.shellReporter.shouldObserve(f)?H8():null,C$=g8();try{let V0=await nj(a$(c7,{children:[...W$,...t$,a$("script",{key:"theme-script",dangerouslySetInnerHTML:{__html:h7}}),a$(I,{data:S.data,viewImportMap:Z0,viewModules:F$,serverQueries:C,dictionarySink:C$,key:"root"})]}),{bootstrapScriptContent:mO(`window.__GEMI_DATA__ = ${j$(S.data)}`),bootstrapModules:r$,signal:U1.signal,...H?{progressiveChunkSize:Number.MAX_SAFE_INTEGER}:{},onError(J$){if(Bun.env.NODE_ENV!=="production")console.error(J$)}});if(V0.allReady.catch(()=>{}).finally(()=>clearTimeout(qO)),H)await V0.allReady.catch(()=>{});return new Response(lj(V0,C,{onShell:H?void 0:()=>C.markShell(),onChunk:I0?.onChunk,onClose:()=>T(()=>{if(this.completeStream(O,C.summarize(U1.signal.aborted)),I0)this.shellReporter.report(f,I0.measure())})},C$),{status:!f?404:200,headers:j})}catch(V0){if(clearTimeout(qO),Bun.env.NODE_ENV==="production")throw T(()=>this.completeStream(O,C.summarize(U1.signal.aborted))),V0;let J$=await nj(a$("div"),{bootstrapScriptContent:mO(`window.error= ${j$(V0.message)}; window.stack_trace=${j$(V0.stack)};window.__GEMI_DATA__ = ${j$(S.data)}`),bootstrapModules:Bun.env.NODE_ENV==="development"?["/render-error.js",...r$]:r$});return new Response(lj(J$,C,{onClose:()=>T(()=>this.completeStream(O,C.summarize(U1.signal.aborted)))}),{status:!f?404:200,headers:j})}}}async handleViewRequest($,O){let T=new URL($.url),Z=T.pathname.endsWith(".json"),f=T.pathname.endsWith(".og"),j=T.pathname.replace(".json","").replace(".og",""),[,z,...F]=j.split("/"),W=`/${F.join("/")}`,C=null,J=null,Y=K(a);if(!Y.supportedLocales.includes(z))W=j;else C=z,J=z;let U=J===null&&bO(this.flatViewRoutes,W)!==null;if(Y.isLocaleAware&&!f&&J===null&&!U){let S=b8(z,Y.supportedLocales,Y.defaultLocale);if(S){let I=F.length?`/${F.join("/")}`:"";return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${S}${I}${Z?".json":""}${T.search}`}})}}if(Y.isLocaleAware&&!f){let S=K(a).detectLocale(new x($,{},"view",W));if(J===null&&S!==Y.defaultLocale){let I=T.pathname==="/"?"":T.pathname;return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${S}${I}${T.search}`}})}}W=W.replace("//","/");let X=[],G=[],B=null,L={},M=null,Q=!1,E=[];try{let S=bO(this.flatViewRoutes,W);if(S){if(B=S.routePath,L=S.params,X=S.route.exec,G=S.route.middleware,E=S.route.features,Q=G.includes("no-stream"),Z&&this.partialRendering){let I=$.headers.get(pj),P=G8({flatViewRoutes:this.flatViewRoutes,supportedLocales:K(a).supportedLocales,from:I,origin:T.origin,to:{segments:S.route.segments,params:L,search:T.search}});if(P.startIndex>0)X=X.slice(P.startIndex),M={from:I,carriedViews:P.carriedViews}}}}catch(S){throw S}let _=new x($,L,"view",B);return this.hooks.onRequestStart(_),await N.run(_,async()=>{let S=null,I=N.getStore(),P=s$.getStore(),A=(y)=>s$.run(P,()=>N.runWith(I,y));I.serverQueries=new l$(vO($));let T0=new Set;if(I.serverQueries.onQueryFail((y)=>{T0.add(y.error);try{A(()=>Promise.resolve(this.hooks.onRequestFail(g,y.error)).catch(()=>{}))}catch{}}),J){let y=J.replaceAll("/","");i$.setLocale(y)}else i$.setLocale();let g=I.req;rj();try{let y=!1;try{await K(wO).runMiddleware(G)}catch(H){if(!n$(H))throw H;y=!0}if(y||E.length>0&&!await this.passesFeatureGates(E))B=null,X=[],g.routePath="";let Z0=K(a),LZ=Z0.isEnabled,yO=Z0.isLocaleAware,F$={};if(yO){let H=null;if(J)H=J.replaceAll("/",""),I.setLocale(H);else H=Z0.detectLocale(new x($,g.params)),I.setLocale(H);let I0=LZ?Z0.getPageTranslations(H,g.routePath):{};F$={supportedLocales:Z0.supportedLocales,currentLocale:H,dictionary:{[H]:I0},defaultLocale:Z0.defaultLocale}}await v8(F$.currentLocale??"");let Z1;try{Z1=await Promise.all(X.map((H)=>H(g)))}catch(H){if(!n$(H))throw H;B=null,X=[],g.routePath="",Z1=[]}let{cookies:R1,headers:f0}=I;S={data:Z1,cookies:R1,headers:f0,user:I.user,prefetchedData:I.serverQueries.snapshotResolved(),currentPathName:B,params:g.params,urlLocaleSegment:C,meta:I.renderMeta(),appId:K(hj).id,features:await K(h$).forClient()};let{params:r$,user:mO}=S,W$={},t$={};for(let H of Z1??[]){let[I0,C$]=Object.entries(H)?.[0]??[];if(!I0||!C$)continue;t$[`${I0}:${B}`]=C$.breadcrumb,W$[I0]=C$}let U1=W$.FILE;if(U1){for(let H of R1)f0.append("Set-Cookie",H.toString());try{await this.onRequestEnd(g)}catch(H){k1.error(H?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(H)})}return await _Z(U1,f0)}if(Z){f0.set("Content-Type","application/x-ndjson; charset=utf-8"),f0.append("Vary",pj),R1.forEach((I0)=>f0.append("Set-Cookie",I0.toString())),await this.hooks.onRequestEnd(g);let H={meta:M&&!I.metadata.touched?null:S.meta,data:{[W]:W$},breadcrumbs:t$,prefetchedData:I.serverQueries.snapshotResolved(),i18n:F$,features:S.features,is404:!B,appId:S.appId,partial:M};return new Response(w8(H,I.serverQueries,void 0,({aborted:I0})=>A(()=>this.completeStream(g,I.serverQueries.summarize(I0)))),{headers:f0})}if(f0.set("Content-Type","text/html; charset=utf-8"),!Q)f0.append("Vary","User-Agent");for(let H of R1)f0.append("Set-Cookie",H.toString());let qO=Bun.CSRF.generate(process.env.SECRET);f0.append("Set-Cookie",`csrf_token=${qO}; HttpOnly; Secure; SameSite=Strict; Expires=${new Date(Date.now()+86400000).toUTCString()}`);try{await this.onRequestEnd(g)}catch(H){k1.error(H?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(H)})}return await this.render({req:g,runInRequestScope:A,csrfTokenHMAC:Buffer.from(""),currentPathName:B,headers:f0,i18n:F$,params:r$,pathname:T.pathname,serverQueries:I.serverQueries,userAgent:$.headers.get("user-agent"),noStream:Q,url:T,user:mO,viewData:W$,breadcrumbs:t$,urlLocaleSegment:C,meta:S.meta,appId:S.appId,features:S.features,isOgRequest:f})}catch(y){if(y.kind===gO)if(Z)return a7(y.payload.viewData??y.payload.api);else return oj(y.payload.view);if(!T0.has(y))this.hooks.onRequestFail(g,y);if(kO(y))return console.error(y),Z?d$():oj(uj());if(y instanceof z$&&y.status===403)return Z?d$():oj(uj());throw y}},O)}}function $z(){let $=JSON.stringify({error:{message:"Not found"}});return new Response($,{status:404,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}class c8 extends N0{routes={"/api-routes":this.get(()=>{let $=K(UZ).flatRoutes,O=[];for(let[T,Z]of Object.entries($))for(let[f,j]of Object.entries(Z)){let{exec:z,middleware:F}=j;O.push({path:T,method:f,middleware:F})}return O}),"/view-routes":this.get(()=>{let $=K(RO).flatViewRoutes,O=[];for(let[T,{middleware:Z,viewPath:f}]of Object.entries($))O.push({path:T,method:"GET",viewPath:f,middleware:Z});return O})}}var XZ="access_token";function n7($,O){let T=$.body.getReader(),Z=!1,f=()=>{if(Z)return;Z=!0;try{O()}catch(z){console.error(z)}},j=new ReadableStream({async pull(z){let F;try{F=await T.read()}catch(W){f(),z.error(W);return}if(F.done){f();try{z.close()}catch{}return}try{z.enqueue(F.value)}catch{}},async cancel(z){try{await T.cancel(z)}finally{f()}}},{highWaterMark:0});return new Response(j,{status:$.status,statusText:$.statusText,headers:$.headers})}function k8($){let{status:O=400,data:T,headers:Z}=$,f=new Headers({"Content-Type":"application/json",...Z});if(!f.has("Cache-Control"))f.set("Cache-Control","no-store");return new Response(JSON.stringify(T),{status:O,headers:f})}function R8($,O,T){let Z=[];O?.forEach((z,F)=>Z.push([F,z]));let f=[...typeof O?.getSetCookie==="function"?O.getSetCookie():[],...Array.from(T??[])];if(Z.length===0&&f.length===0)return $;let j=(z)=>{for(let[F,W]of Z){if(F.toLowerCase()==="set-cookie")continue;if(!z.has(F))z.set(F,W)}for(let F of f)z.append("Set-Cookie",F)};try{return j($.headers),$}catch{let z=new Headers($.headers);return j(z),new Response($.body,{status:$.status,statusText:$.statusText,headers:z})}}class UZ{static token="router.api";flatRoutes={};onRequestStart;onRequestEnd;onRequestFail;constructor($){let O=hC();this.onRequestStart=$.onRequestStart??O.onRequestStart,this.onRequestEnd=$.onRequestEnd??O.onRequestEnd,this.onRequestFail=$.onRequestFail??O.onRequestFail,this.flatRoutes=Vj({"/":$.rootRouter,"/auth":Uj,"/__gemi__/services/i18n":Gj,"/__gemi__/services/logs":Ij,"/__gemi__/services/image":Lj,"/__gemi__/debug":c8})}getRouteHandlerAndParams($){let O=new URL($.url),T=q8(O.pathname),Z={},f;for(let[j]of Object.entries(this.flatRoutes))try{let z=new URLPattern({pathname:j});if(z.test({pathname:T})){f=j,Z=z.exec({pathname:T})?.pathname.groups;break}}catch(z){console.error(z)}return{params:Z,path:f}}async runRouteMiddleware($,O){let Z=this.flatRoutes[$][O.rawRequest.method].middleware;try{await K(wO).runMiddleware(Z)}catch(f){if(f.kind===gO)return k8(f.payload.api);else{if(n$(f))return $z();if(this.onRequestFail(O,f),console.error(f),kO(f))return d$();throw f}}}async getRouteData($){let O=this.flatRoutes[$],T=N.getStore(),Z=O[T.req.rawRequest.method].exec??(()=>Promise.resolve({})),f={};try{f=await Z()}catch(j){if(j.kind===gO)return k8(j.payload.api);if(n$(j))return $z();if(this.onRequestFail(T.req,j),console.error(j),kO(j))return d$();throw j}return f}isFrameworkRoute($){return $.startsWith("/__gemi__")}async endRequest($,O,T){let Z=async()=>{try{if(!this.isFrameworkRoute(T))await this.onRequestEnd(O)}catch(f){k1.error(f?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(f)})}finally{$.destroy()}};if(!$.hasPendingWork()){await Z();return}$.whenIdle().then(Z).catch((f)=>{console.error(f)})}isOpenEndedBody($,O){return $.method!=="HEAD"&&O.body!==null&&!O.headers.has("Content-Length")}async handleApiRequest($,O){let{params:T,path:Z}=this.getRouteHandlerAndParams($),f=this.flatRoutes[Z];if(!f||!f[$.method])return new Response(JSON.stringify({error:{message:"Not found"}}),{status:404});let j=new x($,T,"api",Z);if(!this.isFrameworkRoute(Z))this.onRequestStart(j);return await N.run(j,async()=>{let z=N.getStore(),F=!1,W=async()=>{F=!0,await this.endRequest(z,j,Z)};try{let C=K(a);if(C.isEnabled){let X=C.detectLocale(j);z.setLocale(X)}z.setRequest(j);let J=await this.runRouteMiddleware(Z,j);if(J instanceof Response){let X=R8(J,z.headers,z.cookies);return await W(),X}let Y=await this.getRouteData(Z),D=z.headers,U=z.cookies;if(Y instanceof Response){let X=R8(Y,D,U);if(this.isOpenEndedBody($,X)){let G=n7(X,()=>this.endRequest(z,j,Z));return F=!0,G}return await W(),X}return D.set("Content-Type","application/json"),U.forEach((X)=>D.append("Set-Cookie",X.toString())),await W(),new Response(JSON.stringify(Y),{headers:D})}catch(C){if(!F)try{await W()}catch(J){console.error(J)}throw C}},O)}async dispatchAs($,O,T,Z){let f=new URL($.rawRequest.url).origin,j=new URL(`${f}/api${T}`),z=`/api${T.split(/[?#]/)[0]}`;if(!T.startsWith("/")||j.origin!==f||j.pathname!==z||j.hash!==""||j.pathname.startsWith("/api/__gemi__")||j.pathname==="/api/auth"||j.pathname.startsWith("/api/auth/"))throw Error(`dispatchAs: "${T}" is not an app api path. Pass the route's own path, without "/api", with every param encoded.`);let F=new Headers,W=$.cookies.get(XZ);if(W)F.set("Cookie",`${XZ}=${W}`);let C=$.headers.get(XZ);if(C)F.set(XZ,C);let J=$.headers.get("User-Agent");if(J)F.set("User-Agent",J);let Y;if(Z instanceof FormData)Y=Z;else if(Z!==void 0)F.set("Content-Type","application/json"),Y=JSON.stringify(Z);let D=new Request(j,{method:O,headers:F,body:Y});if(y8(D,dO($)),$.domain)u$(D,$.domain);return N.exit(()=>m8.exit(()=>this.handleApiRequest(D)))}}var Tz="",p8="*";var Oz=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;function i8($){return $.startsWith(":")}function T1($){if(!$)return null;try{return new URL(`http://${$.trim()}`).hostname.toLowerCase().replace(/\.$/,"")||null}catch{return null}}function o7($){try{let O=new URL(`http://${$.trim()}`),T=O.hostname.toLowerCase().replace(/\.$/,"");return T?O.port?`${T}:${O.port}`:T:null}catch{return null}}function r7($){let O=T1($.root),T=$.root?.trim().toLowerCase().replace(/\.$/,"");if(!O||O!==T||!O.split(".").every((j)=>Oz.test(j)))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<16)throw Error("`route.domains.ask.secret` must be at least 16 characters. A guessable one is worse than leaving `ask` out.");let Z=new Set,f=null;for(let j of $.groups??[]){let{subdomain:z}=j;if(Z.has(z))throw Error(`\`route.domains\` declares the subdomain "${z}" twice.`);if(Z.add(z),i8(z)){if(!/^:[A-Za-z_][A-Za-z0-9_]*$/.test(z))throw Error(`"${z}" is not a valid param subdomain. It must be a single \`:name\` label.`);if(f)throw Error(`\`route.domains\` declares two param subdomains, "${f.subdomain}" and "${z}"; a host could match either.`);f=j;continue}if(j.exists)throw Error(`The subdomain "${z}" is fixed, so \`exists\` has no param to check. It only applies to a \`:param\` subdomain.`);if(!z.split(".").every((F)=>Oz.test(F)))throw Error(`"${z}" is not a valid subdomain.`)}if($.custom&&!Z.has($.custom.group))throw Error(`\`route.domains.custom.group\` is "${$.custom.group}", but no group declares that subdomain.`);if($.ask&&f&&!f.exists)throw Error(`\`route.domains.ask\` is set, so "${f.subdomain}" needs an \`exists\` to say which tenants are real. Without one every host under the root would be approved for a certificate.`)}class Zz{root;trustProxy;fixed=new Map;param=null;custom;cacheTtlMs;cache=new Map;inFlight=new Map;askSecret;constructor($){r7($),this.root=T1($.root),this.trustProxy=$.trustProxy??!1;for(let O of $.groups??[])if(i8(O.subdomain))this.param={...O,name:O.subdomain.slice(1)};else this.fixed.set(O.subdomain.toLowerCase(),O);this.custom=$.custom??null,this.cacheTtlMs=this.custom?.cacheTtlMs??60000,this.askSecret=$.ask?.secret??null}hostOf($){if(this.trustProxy){let O=$.headers.get("x-forwarded-host")?.split(",")[0],T=T1(O);if(T)return T}return T1(new URL($.url).host)}publicOrigin($){let O=new URL($.url),T=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),Z=T==="http"||T==="https"?T:O.protocol.replace(/:$/,"");if(!this.trustProxy)return`${Z}://${O.host}`;let f=$.headers.get("x-forwarded-host")?.split(",")[0]?.trim(),j=f&&T1(f)?o7(f):null;return`${Z}://${j??O.host}`}async resolve($){let O=this.hostOf($);if(!O)return null;let T=await this.match(O,$);if(T)return T;if(this.custom?.fallback&&!this.isUnderRoot(O))return{host:O,group:"*",params:{},custom:!0};return null}async allows($,O){let T=T1($);return T?await this.match(T,O)!==null:!1}isUnderRoot($){return $===this.root||$.endsWith(`.${this.root}`)}async match($,O){if($===this.root)return{host:$,group:"",params:{},custom:!1};if($.endsWith(`.${this.root}`)){let Z=$.slice(0,-(this.root.length+1)),f=this.fixed.get(Z);if(f)return{host:$,group:f.subdomain,params:{},custom:!1};if(this.param&&Oz.test(Z)){let j={[this.param.name]:Z};if(this.param.exists&&!await this.param.exists(j,O))return null;return{host:$,group:this.param.subdomain,params:j,custom:!1}}return null}if(!this.custom)return null;let T=await this.resolveCustom($);return T?{host:$,group:this.custom.group,params:T,custom:!0}:null}async resolveCustom($){let O=Date.now(),T=this.cache.get($);if(T&&T.expiresAt>O)return this.cache.delete($),this.cache.set($,T),T.value;let Z=this.inFlight.get($);if(Z)return Z;let f=(async()=>await this.custom.resolve($)??null)();this.inFlight.set($,f);let j;try{j=await f}finally{this.inFlight.delete($)}if(this.cacheTtlMs>0){if(this.cache.size>=1e4)this.cache.delete(this.cache.keys().next().value);this.cache.delete($),this.cache.set($,{value:j,expiresAt:Date.now()+this.cacheTtlMs})}return j}forget($){if($===void 0)this.cache.clear();else{let O=T1($);if(O)this.cache.delete(O)}}}var e7="/__gemi__/domains/ask";function $J($,O){if($===null)return!1;let T=Buffer.from($,"utf8"),Z=Buffer.from(O,"utf8");return T.length===Z.length&&t7(T,Z)}class u0{static token="router.domains";resolver;acceptsCustomDomains;groups=new Map;constructor($,O){this.groups.set(Tz,$);let{domains:T}=O;if(this.acceptsCustomDomains=Boolean(T?.custom),!T){this.resolver=null;return}this.resolver=new Zz(T);let Z=(f)=>({api:f.api?new UZ({...O.api,...f.api}):$.api,view:f.view?new RO({...O.view,...f.view}):$.view});for(let f of T.groups??[])this.groups.set(f.subdomain,Z(f));if(T.custom?.fallback)this.groups.set(p8,Z(T.custom.fallback))}async route($){if(!this.resolver)return this.dispatchers(null);let O=await this.resolver.resolve($);if(!O)return null;return u$($,O),this.dispatchers(O)}async ask($){if(!this.resolver?.askSecret||$.method!=="GET")return null;let O=new URL($.url);if(O.pathname!==e7)return null;if(!$J(O.searchParams.get("secret"),this.resolver.askSecret))return null;let T=O.searchParams.get("domain"),Z=T?await this.resolver.allows(T,$):!1;return new Response(null,{status:Z?200:404})}dispatchers($){return this.groups.get($?.group??Tz)}viewDispatchers(){return Array.from(new Set(Array.from(this.groups.values(),($)=>$.view)))}}function h8($){let O=new Date($??0).getTime();return Number.isFinite(O)?O:0}var TJ=600000;class w{static token="auth";config;provider;constructor($={},O=new qZ){this.config=l8(Rz($),$),this.provider=O}get userProvider(){return this.provider}accessTokenCookieOptions($,O){return{expires:O,secure:this.publicOrigin($).startsWith("https://"),httpOnly:!0,domain:this.cookieDomain($)}}publicOrigin($){let O=K().bound(u0)?K(u0).resolver:null;return O?O.publicOrigin($.rawRequest):new URL($.rawRequest.url).origin}cookieDomain($){let O=this.config.cookieDomain;if(!O)return;let T=O==="root"?K(u0).resolver?.root:T1(O);if(!T)throw Error('`auth.cookieDomain` is "root", but `route.domains` is not configured.');let Z=$.domain?.host??T1(new URL($.rawRequest.url).host);return Z===T||Z?.endsWith(`.${T}`)?T:void 0}async getSession($,O){if(!$)return null;if(!vz($))return this.config.migrateLegacySession?this.convertLegacySession($,O,this.config.migrateLegacySession):null;let T=await this.userProvider.findSession({token:$,userAgent:O});if(!T?.user)return null;let Z=Date.now(),f=h8(T.expiresAt),j=h8(T.absoluteExpiresAt);if(f<=Z||j<=Z)return await this.userProvider.deleteSession({token:$}),null;let F=await this.slideSession(T,Z);return F.user.extension=await this.config.extendSession(F.user),F}async convertLegacySession($,O,T){let Z=N.getStore()?.req;if(!Z)return null;let f=Date.now(),j=Math.floor(f/TJ),z=null,F=await this.userProvider.findSession({token:$,userAgent:O});if(F?.user){if(!await T(F,{token:$,req:Z,userAgent:O}))return null;z=gZ($,j);try{await this.userProvider.createSessionV2({token:z,userId:F.user.id,userAgent:O,...this.freshLifetime(f)})}catch(C){if(!(await this.userProvider.findSession({token:z,userAgent:O}))?.user)throw C}await this.userProvider.deleteSession({token:$})}else for(let C of[j,j-1]){let J=gZ($,C);if((await this.userProvider.findSession({token:J,userAgent:O}))?.user){z=J;break}}if(!z)return null;let W=await this.getSession(z,O);if(W)Z.ctx().setCookie("access_token",z,this.accessTokenCookieOptions(Z,new Date(W.expiresAt)));return W}requestCarryingCookie($){let O=N.getStore()?.req;return O?.cookies.get("access_token")===$?O:null}async slideSession($,O){let T=this.config.sessionExpiresInHours*3600000;if(new Date($.expiresAt).getTime()-O>=T/2)return $;let Z=new Date(Math.min(O+T,new Date($.absoluteExpiresAt).getTime())),f=await this.userProvider.updateSession({token:$.token,expiresAt:Z}),j=this.requestCarryingCookie($.token);if(j)j.ctx().setCookie("access_token",$.token,this.accessTokenCookieOptions(j,Z));if(!f)return $;return{...$,expiresAt:f.expiresAt??Z}}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 O=await this.userProvider.findUserByEmailAddress($,!1);if(!O)throw Error(`User not found with email: ${$}`);let T=await this.createOrUpdateSession({email:$,id:O.id}),Z=new x;if(Z.ctx().setCookie("access_token",T.token,this.accessTokenCookieOptions(Z,T.expiresAt)),T?.user)T.user.extension=await this.config.extendSession(T.user);return T}catch(O){console.log(O)}}async createOrUpdateSessionV2($){let O=await this.createOrUpdateSession($),T=null;if(O?.user)T=await this.config.extendSession(O.user),O.user.extension=T;return O}async createOrUpdateSession($){let O=new x,T=$.id??(await this.userProvider.findUserByEmailAddress($.email,!1))?.id;if(!T)throw new m1;let Z=Bun.env.NODE_ENV==="development"?"local":O.headers.get("User-Agent"),f=kz(T),j=await this.userProvider.createSessionV2({token:f,userId:T,userAgent:Z,...this.freshLifetime(Date.now())}),z=await this.userProvider.findSession({token:f,userAgent:Z??""});return z?.user?z:j}async createMagicLinkToken($){let O=await this.userProvider.findUserByEmailAddress($,!1);if(O){await this.userProvider.deleteMagicLinkToken($);let T=await this.config.generateMagicLinkToken($),Z=(Number.parseInt(OJ(4).toString("hex"),16)%1e6).toString().padStart(6,"0");return await this.userProvider.createMagicLinkToken({email:$,token:T,pin:Z}),{user:O,email:$,pin:Z,token:T}}return{}}}import{AsyncLocalStorage as ZJ}from"async_hooks";class fz{config;static token="broadcast";publishCb;context=new ZJ;constructor($){this.config=$}get channels(){return this.config.channels}onPublish($){this.publishCb=$}publish(...$){let[O,T,Z]=$;this.publishCb(O,T,Z)}async handleMessage($,O){let T=JSON.parse(O);if(T.type==="subscribe"){let Z=Object.entries(this.channels).sort(([f],[j])=>f.length-j.length);for(let[f,j]of Z){let z=new URLPattern({pathname:f});if(z.test({pathname:T.topic})){let F=z.exec({pathname:T.topic})?.pathname.groups,W=new j;if(await W.subscribe.call(W,F))$.subscribe(T.topic);break}}}if(T.type==="broadcast")$.publish(T.topic,JSON.stringify({topic:T.topic,data:T.payload}));if(T.type==="unsubscribe")$.unsubscribe(T.topic)}run($,O){let T=d8($.get("Cookie"));this.context.run({headers:$,cookies:T},O)}}class GZ extends O0{static getFacadeAccessor(){return fz}static channel($,O){let T=this.getFacadeRoot(),Z=T.channels[$];if(!Z)return console.error(`Channel ${$} not found`),{publish:()=>{}};let f=new Z;return{publish:(j,z=!1)=>{let F=u($,O);T.publish(F,JSON.stringify({topic:F,data:f.publish(j)}),z)}}}}class T$ extends O0{static getFacadeAccessor(){return w}static async user(){let $=N.getStore(),O=GZ.getFacadeRoot().context.getStore(),T="",Z="";if($?.req)T=$.req.cookies.get("access_token"),Z=$.req.headers.get("User-Agent");if(O?.cookies)Z=O.headers.get("User-Agent"),T=O.cookies.get("access_token");let f=$?.user;if(!f)f=(await this.getFacadeRoot().getSession(T,Z))?.user,$?.setUser(f);if(f)return f;throw new m1({redirectTo:lO($?.req,this.getFacadeRoot().config.signInPath)})}static intendedUrl($){let O=N.getStore()?.req;return $O(O?.search.get(Y$),$??this.getFacadeRoot().config.redirectPath)}static async guard($){let O=await T$.user();if(!await $(O))throw new bZ}static async guardSafe($){let O=await T$.user();try{return await $(O)}catch(T){return!1}}static async authenticate($){return await this.getFacadeRoot().authenticate($)}static async createMagicLink($){return await this.getFacadeRoot().createMagicLinkToken($)}}class BZ{static ensure($,O={}){let T=N.getStore();if(T.req.kind==="api")throw Error("Query.prefetch() cannot be called from an API request");return T.serverQueries??=new l$(vO(T.req.rawRequest)),T.serverQueries.ensure($,O,"prefetch")}static async instant($,...O){let T=BZ.ensure($,O[0]);if(await T.promise,T.status==="rejected")throw T.error;return T.data}static prefetch($,...O){BZ.ensure($,O[0])}static noPrefetch(){let $=N.getStore();if($.req.kind==="api")throw Error("Query.noPrefetch() cannot be called from an API request");$.serverQueries??=new l$(vO($.req.rawRequest)),$.serverQueries.muteDiscoveryHints()}}function s8($,O,T="/"){let Z=new URL($.origin),f=O.host?O.host:O.subdomain?`${O.subdomain}.${$.root}`:$.root,j=new URL(T.startsWith("/")?T:`/${T}`,Z),z=fJ(f);if(!z)throw Error(`"${f}" 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(j.hostname=z.hostname,z.port)j.port=z.port;return j.toString()}function fJ($){try{let O=new URL(`http://${$.trim()}`);return O.host===$.trim().toLowerCase()&&O.pathname==="/"?{hostname:O.hostname,port:O.port}:null}catch{return null}}class u8{static absolute($,...O){return`${process.env.HOST_NAME}${u(String($),O[0]??{})}`}static relative($,...O){return u(String($),O[0]??{})}static forDomain($,O,...T){let Z=K(u0).resolver;if(!Z)throw Error("`Url.forDomain` needs `route.domains` to be configured.");let f=N.getStore()?.req?.rawRequest,j=f?Z.publicOrigin(f):process.env.HOST_NAME;if(!j)throw Error("`Url.forDomain` outside a request needs `HOST_NAME` for the protocol.");return s8({root:Z.root,origin:j},$,u(String(O),T[0]??{}))}}class a8{name="Meta";static description($){N.getStore().metadata.description($)}static title($){N.getStore().metadata.title($)}static openGraph($){N.getStore().metadata.openGraph($)}}var jJ={set($,O,T){N.getStore().setCookie($,O,T)},setIfAbsent($,O,T){if(N.getStore().req.cookies.has($))return!1;return N.getStore().setCookie($,O,T),!0},delete($,O){N.getStore().deleteCookie($,O)}};class jz{config;static token="redis";instance=null;constructor($={}){this.config=$}get client(){return this.instance??=new(zJ())(this.config.url,this.config.options)}set client($){this.instance=$}}function zJ(){let $=globalThis.Bun?.RedisClient;if(typeof $!=="function")throw Error("Redis requires Bun's built-in Redis client, which this runtime does not provide. Run the app under Bun, or bind your own client for the 'redis' token.");return $}class X1 extends O0{static getFacadeAccessor(){return jz}static get client(){return this.getFacadeRoot().client}static get($){return X1.client.get($)}static set($,O){return X1.client.set($,O)}static del(...$){return X1.client.del(...$)}static exists($){return X1.client.exists($)}static incr($){return X1.client.incr($)}static expire($,O){return X1.client.expire($,O)}static ttl($){return X1.client.ttl($)}}class n8 extends O0{static getFacadeAccessor(){return X$}static consume($,O={}){return this.getFacadeRoot().consume($,O)}}class o8 extends O0{static getFacadeAccessor(){return h$}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 refresh(){return this.getFacadeRoot().refresh()}static invalidate(){return this.getFacadeRoot().invalidate()}}class KZ{bound;constructor($){this.bound=$}get name(){return this.bound??zz()}get sql(){return this.connection().sql}get dialect(){return this.connection().dialect}async query($){return await this.run($,"query")}async execute($){let O=await this.run($,"execute");return Number(O?.count??0)}async transaction($){let O=this.name,T=this.connection(O);return $2(T.sql,(Z)=>t8(O,()=>$(Z)),{slowTransactionThreshold:T.config.slowTransactionThreshold,connection:O})}async schema(){let $=this.connection(),{introspect:O}=await import("./chunk-ezd59jpg.js");return O(this.handle()??$.sql,$.dialect)}run($,O){let T=this.connection(),{text:Z,values:f}=T2($,O2(T.dialect),O);return(this.handle()??T.sql).unsafe(Z,f)}handle(){let $=r8();if($===void 0)return;return zz()===this.name?$:void 0}connection($=this.name){return e8($),K(Fz).connection($)}}var o$=new KZ;class Z2 extends O0{static getFacadeAccessor(){return Fz}static connection($){return new KZ($)}static get sql(){return o$.sql}static get dialect(){return o$.dialect}static query($){return o$.query($)}static execute($){return o$.execute($)}static transaction($){return o$.transaction($)}static schema(){return o$.schema()}static close(){return this.getFacadeRoot().close()}}export{G1 as kc,e$ as lc,IZ as mc,N0 as nc,EZ as oc,Gz as pc,hO as qc,_Z as rc,B1 as sc,v0 as tc,B2 as uc,K2 as vc,vZ as wc,vz as xc,kz as yc,lD as zc,Rz as Ac,qZ as Bc,fz as Cc,GZ as Dc,T$ as Ec,i$ as Fc,BZ as Gc,u8 as Hc,HO as Ic,k1 as Jc,a8 as Kc,jJ as Lc,jz as Mc,X1 as Nc,X$ as Oc,n8 as Pc,I8 as Qc,dj as Rc,V8 as Sc,N8 as Tc,A7 as Uc,E8 as Vc,sj as Wc,x8 as Xc,h$ as Yc,o8 as Zc,KZ as _c,Z2 as $c,Bj as ad,Kj as bd,EY as cd,pC as dd,iC as ed,wO as fd,hY as gd,hC as hd,lC as id,cj as jd,hj as kd,d$ as ld,uj as md,tj as nd,d7 as od,oj as pd,a7 as qd,RO as rd,PZ as sd,_z as td,dO as ud,$z as vd,k8 as wd,R8 as xd,UZ as yd,u0 as zd,w as Ad,Mz as Bd,Iz as Cd,Vz as Dd,Az as Ed,Hz as Fd,wz as Gd};
18
-
19
- //# debugId=42CCDE05DFFF165E64756E2164756E21
@@ -1,54 +0,0 @@
1
- // @bun
2
- class I extends Error{argument;model;operation;constructor(z,G,H,V){super(`gemi ORM does not support '${z}' yet (${G}.${H}). `+V);this.argument=z;this.model=G;this.operation=H;this.name="UnsupportedQueryError"}}class R extends I{constructor(z,G,H,V){super(z,G,H,V);this.name="InvalidArgumentError",this.message=`Invalid '${z}' (${G}.${H}). ${V}`}}class D extends I{constructor(z,G,H,V){super(z,G,H,V);this.name="UnsupportedByDesignError",this.message=`gemi ORM does not implement '${z}' (${G}.${H}), and this is a decision rather than a gap. ${V}`}}class w extends Error{field;model;constructor(z,G,H){super(`'${z}' is not a field on model ${G}. Known fields: ${H.join(", ")}.`);this.field=z;this.model=G;this.name="UnknownFieldError"}}class j extends Error{field;value;constructor(z,G){super(`Could not decode the value ${JSON.stringify(String(G))} from column '${z.column}' as ${z.type}. The column's contents do not match `+"the Prisma schema \u2014 was it written by something other than Prisma or "+"the gemi ORM?");this.field=z;this.value=G;this.name="DecodeError"}}class M extends Error{model;operation;constructor(z,G){super(`No ${z} found (${z}.${G}).`);this.model=z;this.operation=G;this.name="RecordNotFoundError"}}function r(z){if(z instanceof M)return!0;return typeof z==="object"&&z!==null&&z.name==="RecordNotFoundError"}class b extends Error{model;operation;fields;constraint;constructor(z,G,H,V,Y){super(`Unique constraint violated on ${z}.${G}`+(H.length>0?` for ${H.join(", ")}`:"")+(V?` (constraint '${V}')`:"")+`. A ${z} with those values already exists.`,Y);this.model=z;this.operation=G;this.fields=H;this.constraint=V;this.name="UniqueConstraintError"}}function l(z){if(z instanceof b)return!0;return typeof z==="object"&&z!==null&&z.name==="UniqueConstraintError"}class E extends Error{model;operation;dialect;constructor(z,G,H){super(`${z}.${G} needs RETURNING to report its result, and the '${H}' dialect does not support it. The fallback \u2014 `+"lastInsertRowid plus a re-select \u2014 is not implemented.");this.model=z;this.operation=G;this.dialect=H;this.name="ReturningUnsupportedError"}}class P extends Error{model;operation;reason;constructor(z,G,H="denied"){super(H==="no-user"?`${z}.${G} is governed by a policy and there is no user in scope. If this is a cron tick, a queue worker or a script, say so at the call site: Model.asSystem(() => ...). Policies are never skipped just because a user failed to turn up.`:`${z}.${G} was denied by ${z}'s policy.`);this.model=z;this.operation=G;this.reason=H;this.name="PolicyDeniedError"}}function a(z){if(z instanceof P)return!0;return typeof z==="object"&&z!==null&&z.name==="PolicyDeniedError"}class k extends Error{model;operation;fields;constructor(z,G,H){let V=H.map((Y)=>`'${Y}'`).join(", ");super(`${z}.${G} writes ${V}, which ${z}'s policy also `+"scopes on \u2014 so this update can move a row outside the scope that "+`selected it, where the caller can no longer read or repair it.
3
-
4
- Add an onUpdate to that policy. It may reassert the column (data => ({ ...data, ${H[0]}: ctx.user.${H[0]} })), reject `+"the write, or allow it explicitly with (_ctx, data) => data \u2014 all "+"three are fine, and the point is that the policy says which.");this.model=z;this.operation=G;this.fields=H;this.name="ScopeEscapeError"}}class y extends Error{model;registered;queried;carries;constructor(z,G,H,V="queried"){super(V==="narrowing"?`${H} extends ${G}, which owns the model '${z}', and carries policies of its own on top of it. A class that narrows an existing model is a view, and the registry holds one `+`class per name \u2014 so registering ${H} would apply its narrowing to every nested read of ${z}, and leaving ${G} registered would skip ${H}'s policies entirely. Neither is a thing to choose for you.
5
-
6
- Keep the view out of the modules you hand to Kernel.models, and query it directly where you want it:
7
-
8
- ${H}.findMany(\u2026) // narrowed, at the call site
9
-
10
- `+`If it is not a view but the model itself, move the policies onto ${G} \u2014 the class the model's name resolves to \u2014 and `+`${H} inherits them everywhere.
11
- `:V==="queried"?`${H} carries policies but the registry resolves '${z}' to ${G}. Nested relation reads go through the registry, so they would run on ${G} and skip every policy on ${H} \u2014 scoped at the root, unscoped inside an include. `+`Register the class that carries the policy:
12
-
13
- import { register } from "gemi/orm"
14
- export class ${H} extends ${G} { \u2026 }
15
- `+` register("${z}", ${H})
16
- `:`This query goes through ${H}, but the registry resolves '${z}' to ${G}, which carries policies ${H} does not. Nested relation reads would be scoped and this query is `+"not \u2014 the same policy applying to some queries and not others. "+`Query ${G} instead:
17
-
18
- ${G}.findMany(\u2026)
19
-
20
- `+"If skipping policies is intended, say so at the call site \u2014 that "+`is what Model.asSystem() is for, and it is the only way to do it that a reader can see.
21
- `);this.model=z;this.registered=G;this.queried=H;this.carries=V;this.name="UnregisteredPolicyClassError"}}class h extends Error{model;index;reason;found;suggestion;constructor(z,G,H,V,Y,W,B){let J=`${z}.$policies[${G}]`,F=Y.length>1?`${Y.slice(0,-1).join(", ")} or ${Y[Y.length-1]}`:Y[0]??"";super(H==="not-a-policy"?`${J} is ${V}, which is not a policy. An entry is either a `+"policy object \u2014 { scope, onCreate, \u2026 } \u2014 or a class the ORM "+`constructs with no arguments.
22
-
23
- A policy that only sometimes applies belongs in the array rather than in the entry:
24
-
25
- static $policies = [...(multiTenant ? [tenantScope] : [])]
26
- `:H==="not-constructable"?`${J} is ${V}, and a function entry is instantiated with `+"no arguments \u2014 so an arrow function, a plain function, or a "+`factory that was never called cannot be one.
27
-
28
- If it is a factory, call it:
29
-
30
- static $policies = [softDeletes({ field: "deletedAt" })]
31
- `:H==="constructor-threw"?`${J} is ${V}
32
-
33
- A class entry is constructed with no arguments. If this one needs some, construct it yourself and put the instance in the array:
34
-
35
- static $policies = [new TenantPolicy({ field: "orgId" })]
36
-
37
- If the constructor reaches for something that is not ready yet, note that it runs on the first query through this model, not at boot.
38
- `:H==="hook-not-callable"?`${J} has a ${V}, and every hook is called \u2014 so this `+`would throw on the first query that reached it rather than doing whatever it was meant to do. Give it a function, or leave the key out.
39
- `:`${J} has none of ${F}, so it would never run. The model carries a visible $policies array and nothing in it `+"applies to any query \u2014 which for a scope means the model "+`reads unscoped. ${V}`+(W?` Is '${W.key}' meant to be \`${W.hook}\`?`:"")+`
40
- `,B);this.model=z;this.index=G;this.reason=H;this.found=V;this.suggestion=W;this.name="InvalidPolicyEntryError"}}class q extends Error{model;candidates;constructor(z,G){let H=G.map((V)=>`'${V}'`).join(", ");super(`Two classes in one module claim the model '${z}' \u2014 ${H} \u2014 and `+`neither extends the other, so there is no way to tell which one nested relation reads should run.
41
-
42
- Say which, and registerModels will leave it alone:
43
-
44
- import { register } from "gemi/orm"
45
- register("${z}", ${G[0]})
46
-
47
- A class that is only a typed view over the same rows belongs in a module you do not hand to registerModels.`);this.model=z;this.candidates=G;this.name="AmbiguousModelRegistrationError"}}class _ extends Error{model;operation;required;limit;dialect;constructor(z,G,H,V,Y,W){super(`${z}.${G} would bind ${H} parameters, and the '${Y}' driver accepts at most ${V} in one statement. ${W}`+(G==="createMany"?" A createMany over the ceiling is normally split across statements inside one transaction, so reaching this means splitting cannot help: a single row binds more than the driver accepts.":" Splitting is not something this operation can do for you \u2014 one "+"statement has to carry one answer. Narrow the query."));this.model=z;this.operation=G;this.required=H;this.limit=V;this.dialect=Y;this.name="ParameterLimitError"}}class x extends Error{model;operation;field;constructor(z,G,H){super(`${z}.${G} is missing a value for '${H}', which is required and has no default.`);this.model=z;this.operation=G;this.field=H;this.name="MissingRequiredValueError"}}class g extends Error{relation;model;constructor(z,G,H){super(`'${z}' is not a relation on model ${G}. `+(H.length>0?`Known relations: ${H.join(", ")}.`:`${G} declares no relations.`));this.relation=z;this.model=G;this.name="UnknownRelationError"}}class f extends Error{model;limit;constructor(z,G){super(`The include tree nests more than ${G} relations deep (at model ${z}). Deeply nested includes are legal, so this is a guard against a generated or malformed argument tree rather than a limit on `+"modelling \u2014 every level costs at least one query.");this.model=z;this.limit=G;this.name="RelationDepthExceededError"}}class p extends Error{model;relation;target;constructor(z,G,H,V){super(`${z}.${G} points at model '${H}', which nothing has registered. The generated artifact and the registry disagree: re-run \`prisma generate\`, and check that app/models/generated/index.ts is imported. `+(V.length>0?`Registered models: ${V.join(", ")}.`:"Nothing is registered at all."));this.model=z;this.relation=G;this.target=H;this.name="UnregisteredRelationTargetError"}}class c extends Error{model;relation;constructor(z,G,H){super(`Cannot resolve how ${z}.${G} joins: ${H} This means `+"app/models/generated is stale or hand-edited \u2014 re-run "+"`prisma generate`.");this.model=z;this.relation=G;this.name="MalformedRelationError"}}class m extends Error{constructor(z,G){super(`No model is registered under the name '${z}'. `+(G.length>0?`Registered models: ${G.join(", ")}.`:"Nothing is registered \u2014 is app/models/generated/index.ts imported?"));this.name="ModelNotRegisteredError"}}class v extends Error{constructor(z){super(`${z} has no $schema. Model subclasses must extend a generated base class from app/models/generated/models.ts.`);this.name="MissingModelSchemaError"}}function Gz(){return{now:new Date,resolved:{}}}var s={now:new Date(0),resolved:{}};function Hz(z){return(G,H=s)=>{let V=[];for(let Y=0;Y<z.length;Y++)V.push(z[Y](G,H));return V}}var C="\x00";function Z(z){return{text:z,binders:[]}}function X(z,G=""){return{text:C+G,binders:[z]}}function Vz(z){return z.text.split(C)}function Wz(z,G){return{text:z.join(C),binders:G}}function $(...z){return N(z,"")}function N(z,G){let H="",V=[];for(let Y=0;Y<z.length;Y++){if(Y>0)H+=G;H+=z[Y].text;for(let W of z[Y].binders)V.push(W)}return{text:H,binders:V}}function Yz(z,G,H){let V=z.text.split(C),Y=V.length-1;if(Y!==z.binders.length)throw Error(`Compiled ${Y} parameter placeholders but collected ${z.binders.length} binders.`);if(Y>G.maxBoundParameters)throw new _(H.model,H.operation,Y,G.maxBoundParameters,G.name,G.bindsListAsOneParameter?"That is one parameter per value in the statement.":`That is one parameter per value, and on ${G.name} each element of an 'in' list counts separately.`);let W=V[0];for(let B=0;B<Y;B++)W+=G.placeholder(B)+V[B+1];return{text:W,binders:z.binders}}class K{name="postgres";supportsInsensitiveMode=!0;bindsListAsOneParameter=!0;supportsReturning=!0;maxBoundParameters=65535;typesParametersFromStatement=!0;quoteIdent(z){if(z.includes("\x00"))throw Error(`Refusing to quote the identifier ${JSON.stringify(z)}: it contains a NUL byte, which is reserved as the parameter marker.`);return`"${z.replace(/"/g,'""')}"`}placeholder(z){return`$${z+1}`}inList(z,G,H,V){return $(Z(`${z} ${G?"<> all":"= any"} (`),X((W,B)=>O(V(W,B))),Z(")"))}static COMPOSITE_IN_TYPES={Int:"int",BigInt:"bigint",String:"text",Boolean:"boolean"};canBindCompositeIn(z){return z.length>0&&z.every((G)=>K.COMPOSITE_IN_TYPES[G])}compositeIn(z,G,H){let V=z.map((Y,W)=>$(X((B,J)=>O(H(B,J).map((F)=>F[W]))),Z(`::${K.COMPOSITE_IN_TYPES[G[W]]}[]`)));return $(Z(`(${z.join(", ")}) in (select * from unnest(`),...V.flatMap((Y,W)=>W===0?[Y]:[Z(", "),Y]),Z("))"))}listFilters=new Set(["equals","has","hasEvery","hasSome","isEmpty"]);listHas(z,G){return $(G,Z(` = any(${z})`))}listHasEvery(z,G){return $(Z(`${z} @> `),G)}listHasSome(z,G){return $(Z(`${z} && `),G)}listIsEmpty(z,G){return $(Z(`${z} ${G?"=":"<>"} `),X(()=>O([])))}listPush(z,G){return $(Z(`array_cat(${z}, `),G,Z(")"))}jsonPathSyntax="array";jsonFilters=new Set(["equals","not","string_contains","string_starts_with","string_ends_with","array_contains","lt","lte","gt","gte"]);jsonComparesAsText=!0;jsonExtract(z,G,H){return $(Z(`${z} ${H?"#>>":"#>"} `),X((V,Y)=>O(G(V,Y))))}jsonValueAt(z,G){return $(Z("("),this.jsonExtract(z,G,!1),Z(")::jsonb"))}jsonArrayContains(z,G,H){return $(Z("("),this.jsonExtract(z,G,!1),Z(") @> "),X((V,Y)=>{let W=H(V,Y);if(W===null||W===void 0)return null;return typeof W==="string"||typeof W==="object"?W:JSON.stringify(W)}),Z("::jsonb"))}like(z,G,H){return $(Z(`${z} ${G?"ilike":"like"} `),X(H))}ignoreConflicts(){return Z(" on conflict do nothing")}paginate(z,G){let H=[];if(z)H.push($(Z(" limit "),X(z)));if(G)H.push($(Z(" offset "),X(G)));return $(...H)}constraintViolation(z){let G=z;if(!G)return null;if(String(G.errno??G.code??"")!=="23505")return null;let V=typeof G.constraint==="string"&&G.constraint!==""?G.constraint:void 0,Y=typeof G.detail==="string"?G.detail:"",W=/\((.+?)\)=/.exec(Y);return{kind:"unique",columns:W?(W[1].match(/"(?:[^"]|"")*"|[^,]+/g)??[]).map((J)=>J.trim()).filter((J)=>J!=="").map((J)=>/^".*"$/s.test(J)?J.slice(1,-1).replace(/""/g,'"'):J):[],constraint:V}}castParameter(z){if(z.isList)return"";return z.type==="Json"?"::text::jsonb":""}encode(z,G){if(z===null||z===void 0)return null;if(G.isList){if(!Array.isArray(z))throw Error(`gemi ORM bug: a non-array reached the parameter binder for the scalar list '${G.column}' (received ${typeof z}). Every path that binds a list is supposed to have checked its operand.`);return O(G.type==="Json"?z.map((H)=>H===null||H===void 0?null:JSON.stringify(H)):z)}return z}encodeUntyped(z){return z}needsDecode(z){return z.isList===!0||z.type==="BigInt"||z.type==="Bytes"}decode(z,G){if(z===null||z===void 0)return null;if(G.isList)return this.decodeList(z,G);return this.decodeScalar(z,G)}decodeList(z,G){let H=Array.isArray(z)?z:typeof z==="string"?d(z,G):ArrayBuffer.isView(z)?Array.from(z):null;if(H===null)throw new j(G,z);return H.map((V)=>V===null||V===void 0?null:this.decodeScalar(V,G))}decodeScalar(z,G){switch(G.type){case"BigInt":if(typeof z==="bigint")return z;try{return BigInt(z)}catch{throw new j(G,z)}case"Json":return z;case"Bytes":return Buffer.isBuffer(z)?new Uint8Array(z.buffer,z.byteOffset,z.byteLength):z;default:return z}}}function O(z){let G="{";for(let H=0;H<z.length;H++){if(H>0)G+=",";G+=u(z[H])}return G+"}"}function u(z){if(z===null||z===void 0)return"NULL";if(z instanceof Date)return`"${z.toISOString()}"`;if(ArrayBuffer.isView(z)){let H="";for(let V of new Uint8Array(z.buffer,z.byteOffset,z.byteLength))H+=V.toString(16).padStart(2,"0");return`"\\\\x${H}"`}return`"${(typeof z==="string"?z:String(z)).replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`}function d(z,G){if(!z.startsWith("{")||!z.endsWith("}"))throw new j(G,z);if(z==="{}")return[];let H=[],V=1,Y=z.length-1;while(V<=Y){let W="",B=!1;if(z[V]==='"'){B=!0,V++;while(V<Y&&z[V]!=='"')W+=z[V]==="\\"?z[++V]:z[V],V++;V++}else while(V<Y&&z[V]!==","){if(z[V]==="{")throw new j(G,z);W+=z[V],V++}if(H.push(!B&&W.toUpperCase()==="NULL"?null:W),V<Y&&z[V]!==",")throw new j(G,z);V++}if(G.type!=="Json")return H;return H.map((W)=>{if(W===null)return null;try{return JSON.parse(W)}catch{throw new j(G,W)}})}var i={"Prisma.DbNull":"db","Prisma.JsonNull":"json","Prisma.AnyNull":"any"};function U(z){return new class{toString(){return z}}}var Xz=U("Prisma.DbNull"),n=U("Prisma.JsonNull"),jz=U("Prisma.AnyNull"),Fz=n;function A(z){if(typeof z!=="object"||z===null)return null;for(let H in z)return null;if(Object.getOwnPropertyNames(z).length>0)return null;let G;try{G=String(z)}catch{return null}return i[G]??null}var o=/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(\.\d+)?$/;function t(z,G){if(z instanceof Date)return z;let H;if(typeof z==="number")H=new Date(z);else if(typeof z==="bigint")H=new Date(Number(z));else if(typeof z==="string")H=new Date(o.test(z)?`${z.replace(" ","T")}Z`:z);else throw new j(G,z);if(Number.isNaN(H.getTime()))throw new j(G,z);return H}class S{name="sqlite";supportsInsensitiveMode=!1;bindsListAsOneParameter=!1;supportsReturning=!0;maxBoundParameters=32766;typesParametersFromStatement=!1;quoteIdent(z){if(z.includes("\x00"))throw Error(`Refusing to quote the identifier ${JSON.stringify(z)}: it contains a NUL byte, which is reserved as the parameter marker.`);return`"${z.replace(/"/g,'""')}"`}placeholder(z){return"?"}inList(z,G,H,V){let Y=G?"not in":"in",W=[];for(let B=0;B<H;B++)W.push(X((J,F)=>V(J,F)[B]));return $(Z(`${z} ${Y} (`),N(W,", "),Z(")"))}canBindCompositeIn(){return!1}compositeIn(){throw Error("SQLite cannot bind a composite `in`; `canBindCompositeIn` is the guard.")}listFilters=new Set;listHas(){throw Error(Q("has"))}listHasEvery(){throw Error(Q("hasEvery"))}listHasSome(){throw Error(Q("hasSome"))}listIsEmpty(){throw Error(Q("isEmpty"))}listPush(){throw Error(Q("push"))}jsonPathSyntax="jsonpath";jsonFilters=new Set(["equals","not","string_contains","string_starts_with","string_ends_with"]);jsonComparesAsText=!1;jsonExtract(z,G,H){return $(Z(`json_extract(${z}, `),X(G),Z(")"))}jsonValueAt(z,G){return $(Z(`(${z} -> `),X(G),Z(")"))}jsonArrayContains(){throw Error("SQLite cannot express array_contains; `jsonFilters` is the guard.")}like(z,G,H){return $(Z(`${z} like `),X(H))}ignoreConflicts(){return null}paginate(z,G){if(!z&&!G)return Z("");if(!G)return $(Z(" limit "),X(z));return $(Z(" limit "),X(z??(()=>-1)),Z(" offset "),X(G))}constraintViolation(z){let G=z?.code;if(G!=="SQLITE_CONSTRAINT_UNIQUE"&&G!=="SQLITE_CONSTRAINT_PRIMARYKEY")return null;let H=String(z.message??""),V=/constraint failed:\s*(.+)$/.exec(H);if(!V)return{kind:"unique",columns:[]};return{kind:"unique",columns:V[1].split(",").map((W)=>W.trim()).map((W)=>{let B=W.indexOf(".");return B===-1?W:W.slice(B+1)}).filter((W)=>W!=="")}}castParameter(z){return""}encode(z,G){if(z===null||z===void 0)return null;switch(G.type){case"DateTime":return z instanceof Date?z.getTime():z;case"Boolean":return typeof z==="boolean"?z?1:0:z;case"Json":{let H=A(z);if(H==="db")return null;if(H==="json")return"null";if(H==="any")throw Error("gemi ORM bug: Prisma.AnyNull reached the SQLite encoder. It is a filter operand only, and both the filter and write paths are supposed to have handled it before this point.")}return JSON.stringify(z);default:return z}}encodeUntyped(z){if(z instanceof Date)return z.getTime();if(typeof z==="boolean")return z?1:0;return z}needsDecode(z){switch(z.type){case"DateTime":case"Boolean":case"BigInt":case"Json":return!0;default:return!1}}decode(z,G){if(z===null||z===void 0)return null;switch(G.type){case"DateTime":return t(z,G);case"Boolean":if(typeof z==="boolean")return z;return Number(z)!==0;case"BigInt":if(typeof z==="bigint")return z;try{return BigInt(z)}catch{throw new j(G,z)}case"Json":try{return typeof z==="string"?JSON.parse(z):z}catch{throw new j(G,z)}default:return z}}}function Q(z){return`SQLite has no array type, so it cannot express '${z}' on a scalar list; \`listFilters\` is the guard.`}class L extends Error{constructor(z){super(`The gemi ORM does not support the '${z}' dialect. Only sqlite `+"and postgres are implemented \u2014 see the supported matrix in "+`docs/orm.md.
48
-
49
- The *connection* is fine: Bun's client speaks ${z}, so raw SQL through DB.query / DB.sql and transactions all work. It is the query compiler that has no ${z} dialect, so every model operation raises this.
50
-
51
- Point DATABASE_URL at Postgres or SQLite to use the ORM, or keep using Prisma's own client for this database.`);this.name="UnsupportedDialectError"}}function Sz(z){return T[z]!==null}function Tz(){return Object.keys(T)}var T={sqlite:new S,postgres:new K,mysql:null,mariadb:null};function Mz(z){let G=T[z];if(G===null)throw new L(z);return G}
52
- export{I as Rd,R as Sd,D as Td,w as Ud,j as Vd,M as Wd,r as Xd,b as Yd,l as Zd,E as _d,P as $d,a as ae,k as be,y as ce,h as de,q as ee,_ as fe,x as ge,g as he,f as ie,p as je,c as ke,m as le,v as me,Gz as ne,Hz as oe,Z as pe,X as qe,Vz as re,Wz as se,$ as te,N as ue,Yz as ve,K as we,Xz as xe,n as ye,jz as ze,Fz as Ae,A as Be,S as Ce,L as De,Sz as Ee,Tz as Fe,Mz as Ge};
53
-
54
- //# debugId=CE3A0BBC7D4BFD9464756E2164756E21