gemi 0.76.0 → 0.77.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 (179) 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/broadcasting/index.js +1 -1
  5. package/dist/bun/plugin.js +1 -1
  6. package/dist/bun/preload.js +1 -1
  7. package/dist/{chunk-fy2f8sq8.js → chunk-0472aphj.js} +2 -2
  8. package/dist/{chunk-fy2f8sq8.js.map → chunk-0472aphj.js.map} +1 -1
  9. package/dist/{chunk-bm97dwbp.js → chunk-0da5t7vs.js} +2 -2
  10. package/dist/{chunk-bm97dwbp.js.map → chunk-0da5t7vs.js.map} +1 -1
  11. package/dist/{chunk-17q5kheg.js → chunk-0pqsp84p.js} +2 -2
  12. package/dist/{chunk-17q5kheg.js.map → chunk-0pqsp84p.js.map} +1 -1
  13. package/dist/{chunk-8ef9n5pk.js → chunk-1712rv0r.js} +2 -2
  14. package/dist/{chunk-8ef9n5pk.js.map → chunk-1712rv0r.js.map} +1 -1
  15. package/dist/{chunk-9gn3x603.js → chunk-1ap69pez.js} +1 -1
  16. package/dist/{chunk-a1n0thja.js → chunk-1qwkhbc4.js} +2 -2
  17. package/dist/{chunk-a1n0thja.js.map → chunk-1qwkhbc4.js.map} +1 -1
  18. package/dist/{chunk-qn7rr4bw.js → chunk-27pnn95c.js} +2 -2
  19. package/dist/{chunk-qn7rr4bw.js.map → chunk-27pnn95c.js.map} +1 -1
  20. package/dist/{chunk-q60vevbt.js → chunk-34s3tfgk.js} +3 -3
  21. package/dist/{chunk-q60vevbt.js.map → chunk-34s3tfgk.js.map} +1 -1
  22. package/dist/{chunk-9h0cz1f0.js → chunk-3hfwbp2m.js} +2 -2
  23. package/dist/{chunk-9h0cz1f0.js.map → chunk-3hfwbp2m.js.map} +1 -1
  24. package/dist/{chunk-3dd2gwrj.js → chunk-3jyz4378.js} +2 -2
  25. package/dist/{chunk-3dd2gwrj.js.map → chunk-3jyz4378.js.map} +1 -1
  26. package/dist/{chunk-t20b1xn4.js → chunk-443yr2km.js} +3 -3
  27. package/dist/{chunk-t20b1xn4.js.map → chunk-443yr2km.js.map} +1 -1
  28. package/dist/{chunk-xrd9xx3c.js → chunk-4h7z32zp.js} +3 -3
  29. package/dist/{chunk-xrd9xx3c.js.map → chunk-4h7z32zp.js.map} +1 -1
  30. package/dist/{chunk-3nxkn558.js → chunk-5ddn8mfj.js} +2 -2
  31. package/dist/{chunk-3nxkn558.js.map → chunk-5ddn8mfj.js.map} +1 -1
  32. package/dist/{chunk-pxfw8dg1.js → chunk-6h5gvcs8.js} +2 -2
  33. package/dist/{chunk-pxfw8dg1.js.map → chunk-6h5gvcs8.js.map} +1 -1
  34. package/dist/{chunk-7e4rhaqs.js → chunk-7yhsy039.js} +2 -2
  35. package/dist/{chunk-7e4rhaqs.js.map → chunk-7yhsy039.js.map} +1 -1
  36. package/dist/{chunk-zat41156.js → chunk-989rzqd6.js} +3 -3
  37. package/dist/{chunk-zat41156.js.map → chunk-989rzqd6.js.map} +1 -1
  38. package/dist/{chunk-hny56r47.js → chunk-9z3y20ms.js} +2 -2
  39. package/dist/{chunk-hny56r47.js.map → chunk-9z3y20ms.js.map} +1 -1
  40. package/dist/{chunk-yqb9cpkx.js → chunk-axxbkm30.js} +2 -2
  41. package/dist/{chunk-yqb9cpkx.js.map → chunk-axxbkm30.js.map} +1 -1
  42. package/dist/{chunk-mc7nbgct.js → chunk-b941c34r.js} +2 -2
  43. package/dist/{chunk-mc7nbgct.js.map → chunk-b941c34r.js.map} +1 -1
  44. package/dist/{chunk-62pzr6vf.js → chunk-bdfdjnht.js} +3 -3
  45. package/dist/{chunk-62pzr6vf.js.map → chunk-bdfdjnht.js.map} +1 -1
  46. package/dist/chunk-cr9f0s09.js +5 -0
  47. package/dist/{chunk-krjkgg9v.js.map → chunk-cr9f0s09.js.map} +1 -1
  48. package/dist/{chunk-0yfgptrq.js → chunk-dgqqv3pb.js} +2 -2
  49. package/dist/{chunk-0yfgptrq.js.map → chunk-dgqqv3pb.js.map} +1 -1
  50. package/dist/{chunk-j9r5w8xf.js → chunk-dmdmt3gw.js} +2 -2
  51. package/dist/{chunk-j9r5w8xf.js.map → chunk-dmdmt3gw.js.map} +1 -1
  52. package/dist/chunk-e8z3nyd5.js +19 -0
  53. package/dist/{chunk-ytt205yt.js.map → chunk-e8z3nyd5.js.map} +8 -7
  54. package/dist/{chunk-8rqdeyhv.js → chunk-e97kq9tn.js} +2 -2
  55. package/dist/{chunk-8rqdeyhv.js.map → chunk-e97kq9tn.js.map} +1 -1
  56. package/dist/{chunk-evbvpfv6.js → chunk-eekg7k6d.js} +1 -1
  57. package/dist/{chunk-26rqzgsr.js → chunk-ezae18wm.js} +2 -2
  58. package/dist/{chunk-26rqzgsr.js.map → chunk-ezae18wm.js.map} +1 -1
  59. package/dist/{chunk-dsgb59xm.js → chunk-f2hkhw76.js} +2 -2
  60. package/dist/{chunk-dsgb59xm.js.map → chunk-f2hkhw76.js.map} +1 -1
  61. package/dist/{chunk-d6dz2706.js → chunk-fd0n8sav.js} +2 -2
  62. package/dist/{chunk-1x8gzkpq.js.map → chunk-fd0n8sav.js.map} +1 -1
  63. package/dist/{chunk-3sdrj0ma.js → chunk-fmhkn266.js} +2 -2
  64. package/dist/{chunk-3sdrj0ma.js.map → chunk-fmhkn266.js.map} +1 -1
  65. package/dist/{chunk-9ecgk1c5.js → chunk-fms4fcd1.js} +2 -2
  66. package/dist/{chunk-9ecgk1c5.js.map → chunk-fms4fcd1.js.map} +1 -1
  67. package/dist/{chunk-f90k29w1.js → chunk-fvn78g6k.js} +2 -2
  68. package/dist/{chunk-f90k29w1.js.map → chunk-fvn78g6k.js.map} +1 -1
  69. package/dist/{chunk-8ypzxfvx.js → chunk-gzs2y282.js} +2 -2
  70. package/dist/{chunk-8ypzxfvx.js.map → chunk-gzs2y282.js.map} +1 -1
  71. package/dist/{chunk-gpys09rg.js → chunk-j1w19cec.js} +3 -3
  72. package/dist/{chunk-gpys09rg.js.map → chunk-j1w19cec.js.map} +1 -1
  73. package/dist/{chunk-8jgj7vdp.js → chunk-j8nbjpkg.js} +2 -2
  74. package/dist/{chunk-8jgj7vdp.js.map → chunk-j8nbjpkg.js.map} +1 -1
  75. package/dist/{chunk-achgw308.js → chunk-jcq0tbdv.js} +2 -2
  76. package/dist/{chunk-achgw308.js.map → chunk-jcq0tbdv.js.map} +1 -1
  77. package/dist/{chunk-9sqw5bjy.js → chunk-m2bmwre5.js} +2 -2
  78. package/dist/{chunk-9sqw5bjy.js.map → chunk-m2bmwre5.js.map} +1 -1
  79. package/dist/{chunk-pp9c3f5m.js → chunk-mmhf39tr.js} +2 -2
  80. package/dist/{chunk-pp9c3f5m.js.map → chunk-mmhf39tr.js.map} +1 -1
  81. package/dist/{chunk-15gc8m24.js → chunk-n03frt02.js} +2 -2
  82. package/dist/{chunk-15gc8m24.js.map → chunk-n03frt02.js.map} +1 -1
  83. package/dist/{chunk-wtwkzgec.js → chunk-njh95es7.js} +2 -2
  84. package/dist/{chunk-wtwkzgec.js.map → chunk-njh95es7.js.map} +1 -1
  85. package/dist/{chunk-ngq4n2b3.js → chunk-q0nqypca.js} +2 -2
  86. package/dist/{chunk-ngq4n2b3.js.map → chunk-q0nqypca.js.map} +1 -1
  87. package/dist/{chunk-jpej3172.js → chunk-q623tx9p.js} +2 -2
  88. package/dist/{chunk-jpej3172.js.map → chunk-q623tx9p.js.map} +1 -1
  89. package/dist/{chunk-dz7b35tn.js → chunk-qgvg10ad.js} +3 -3
  90. package/dist/{chunk-dz7b35tn.js.map → chunk-qgvg10ad.js.map} +1 -1
  91. package/dist/{chunk-9p5vwn4d.js → chunk-qjgfrsw7.js} +2 -2
  92. package/dist/{chunk-9p5vwn4d.js.map → chunk-qjgfrsw7.js.map} +1 -1
  93. package/dist/{chunk-371tt28q.js → chunk-rkx6qhwg.js} +4 -4
  94. package/dist/{chunk-371tt28q.js.map → chunk-rkx6qhwg.js.map} +1 -1
  95. package/dist/{chunk-1k0gv92y.js → chunk-rv9k5bqn.js} +2 -2
  96. package/dist/{chunk-1k0gv92y.js.map → chunk-rv9k5bqn.js.map} +1 -1
  97. package/dist/{chunk-407t1q1d.js → chunk-s7hv9qgp.js} +2 -2
  98. package/dist/{chunk-407t1q1d.js.map → chunk-s7hv9qgp.js.map} +1 -1
  99. package/dist/{chunk-wbxmwzdb.js → chunk-sbqy6r29.js} +1 -1
  100. package/dist/{chunk-a82m12q4.js → chunk-sp4wwg7s.js} +3 -3
  101. package/dist/{chunk-a82m12q4.js.map → chunk-sp4wwg7s.js.map} +1 -1
  102. package/dist/{chunk-3eejq348.js → chunk-sqvw7rv2.js} +3 -3
  103. package/dist/{chunk-3eejq348.js.map → chunk-sqvw7rv2.js.map} +1 -1
  104. package/dist/{chunk-1yr8qejy.js → chunk-ss7ymqfm.js} +2 -2
  105. package/dist/{chunk-1yr8qejy.js.map → chunk-ss7ymqfm.js.map} +1 -1
  106. package/dist/{chunk-cr2wpeh5.js → chunk-sww4kgk4.js} +2 -2
  107. package/dist/{chunk-cr2wpeh5.js.map → chunk-sww4kgk4.js.map} +1 -1
  108. package/dist/{chunk-4z5qqq1t.js → chunk-tnt0ybj9.js} +2 -2
  109. package/dist/{chunk-4z5qqq1t.js.map → chunk-tnt0ybj9.js.map} +1 -1
  110. package/dist/{chunk-pjcdekm1.js → chunk-tpdsfr2k.js} +2 -2
  111. package/dist/{chunk-pjcdekm1.js.map → chunk-tpdsfr2k.js.map} +1 -1
  112. package/dist/{chunk-th77kbcq.js → chunk-vr84mhmq.js} +2 -2
  113. package/dist/{chunk-th77kbcq.js.map → chunk-vr84mhmq.js.map} +1 -1
  114. package/dist/{chunk-p2ny6anh.js → chunk-waax3j1k.js} +2 -2
  115. package/dist/{chunk-p2ny6anh.js.map → chunk-waax3j1k.js.map} +1 -1
  116. package/dist/{chunk-1x8gzkpq.js → chunk-xzp2ptj5.js} +2 -2
  117. package/dist/{chunk-d6dz2706.js.map → chunk-xzp2ptj5.js.map} +1 -1
  118. package/dist/{chunk-ywf0kz71.js → chunk-yaz93haz.js} +2 -2
  119. package/dist/{chunk-ywf0kz71.js.map → chunk-yaz93haz.js.map} +1 -1
  120. package/dist/{chunk-1rnzaqpm.js → chunk-yernnzqs.js} +2 -2
  121. package/dist/{chunk-1rnzaqpm.js.map → chunk-yernnzqs.js.map} +1 -1
  122. package/dist/{chunk-a4xxmmct.js → chunk-zjg31baf.js} +2 -2
  123. package/dist/{chunk-a4xxmmct.js.map → chunk-zjg31baf.js.map} +1 -1
  124. package/dist/{chunk-14pybfjk.js → chunk-zkty5j42.js} +2 -2
  125. package/dist/{chunk-14pybfjk.js.map → chunk-zkty5j42.js.map} +1 -1
  126. package/dist/{chunk-g2hwd2ts.js → chunk-zzh52t0y.js} +2 -2
  127. package/dist/{chunk-g2hwd2ts.js.map → chunk-zzh52t0y.js.map} +1 -1
  128. package/dist/client/MutationError.d.ts +16 -1
  129. package/dist/client/MutationError.d.ts.map +1 -1
  130. package/dist/client/index.js +94 -76
  131. package/dist/client/index.js.map +1 -1
  132. package/dist/client/useMutation.d.ts +1 -1
  133. package/dist/client/useMutation.d.ts.map +1 -1
  134. package/dist/config/index.js +1 -1
  135. package/dist/console/run.js +2 -2
  136. package/dist/console/run.js.map +1 -1
  137. package/dist/container/index.js +2 -2
  138. package/dist/container/index.js.map +1 -1
  139. package/dist/database/index.js +2 -2
  140. package/dist/database/index.js.map +1 -1
  141. package/dist/email/index.js +2 -2
  142. package/dist/email/index.js.map +1 -1
  143. package/dist/facades/index.js +2 -2
  144. package/dist/facades/index.js.map +1 -1
  145. package/dist/foundation/index.js +2 -2
  146. package/dist/foundation/index.js.map +1 -1
  147. package/dist/http/ApiRouter.d.ts +3 -2
  148. package/dist/http/ApiRouter.d.ts.map +1 -1
  149. package/dist/http/HttpResponse.d.ts +83 -0
  150. package/dist/http/HttpResponse.d.ts.map +1 -0
  151. package/dist/http/ViewRouter.d.ts.map +1 -1
  152. package/dist/http/index.d.ts +1 -0
  153. package/dist/http/index.d.ts.map +1 -1
  154. package/dist/http/index.js +2 -2
  155. package/dist/http/index.js.map +1 -1
  156. package/dist/i18n/dictionaryRuntime.js +2 -2
  157. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  158. package/dist/i18n/index.js +2 -2
  159. package/dist/i18n/index.js.map +1 -1
  160. package/dist/kernel/index.js +2 -2
  161. package/dist/kernel/index.js.map +1 -1
  162. package/dist/orm/index.js +2 -2
  163. package/dist/orm/index.js.map +1 -1
  164. package/dist/server/index.js +2 -2
  165. package/dist/server/index.js.map +1 -1
  166. package/dist/services/index.js +2 -2
  167. package/dist/services/index.js.map +1 -1
  168. package/dist/services/queue/work.js +2 -2
  169. package/dist/services/queue/work.js.map +1 -1
  170. package/dist/services/router/ApiRouteDispatcher.d.ts.map +1 -1
  171. package/dist/services/router/serverQueryFetcher.d.ts.map +1 -1
  172. package/dist/support/index.js +2 -2
  173. package/dist/support/index.js.map +1 -1
  174. package/package.json +1 -1
  175. package/dist/chunk-krjkgg9v.js +0 -5
  176. package/dist/chunk-ytt205yt.js +0 -19
  177. /package/dist/{chunk-9gn3x603.js.map → chunk-1ap69pez.js.map} +0 -0
  178. /package/dist/{chunk-evbvpfv6.js.map → chunk-eekg7k6d.js.map} +0 -0
  179. /package/dist/{chunk-wbxmwzdb.js.map → chunk-sbqy6r29.js.map} +0 -0
@@ -0,0 +1,19 @@
1
+ // @bun
2
+ import{Nd as oW,Ud as V5}from"./chunk-34s3tfgk.js";import{$d as o$,Le as Q5,ee as pO}from"./chunk-q0nqypca.js";import{$e as LW,Me as q3,Oe as Y5,Qe as t4,Re as yW,Se as b3,Te as _3,We as E3,Xe as P3,Ye as n$,Ze as h4,_e as f5,af as yO,bf as q1,cf as k0,ef as A,ff as y3,gf as p3,hf as w3,jf as y1,kf as O0,lf as F3}from"./chunk-4h7z32zp.js";import{sf as v4,tf as zW,uf as N}from"./chunk-gzs2y282.js";import{vf as J5}from"./chunk-1712rv0r.js";import{Af as B5,Jf as K5,wf as e4,xf as TO,yf as fO,zf as G5}from"./chunk-bdfdjnht.js";import{Yf as jO}from"./chunk-jcq0tbdv.js";import{bg as n4,gg as a4}from"./chunk-axxbkm30.js";import{mg as s4,ng as n}from"./chunk-qjgfrsw7.js";import{qg as K}from"./chunk-989rzqd6.js";import{rg as s$}from"./chunk-0da5t7vs.js";import{Dg as Hj}from"./chunk-yaz93haz.js";import{Fg as $5}from"./chunk-7yhsy039.js";import{Kg as YW}from"./chunk-xzp2ptj5.js";import{randomBytes as bX}from"crypto";function uO($){return typeof $==="function"&&$.prototype!==void 0}function G1($){return typeof $==="string"?[$]:$}function sO($,O){let Z=O?"attachment":"inline",T=$.replace(/["\\]/g,"").replace(/[^\x20-\x7e]/g,"_");return`${Z}; filename="${T}"; filename*=UTF-8''${encodeURIComponent($)}`}function H5($){return"total"in $&&"partial"in $&&"body"in $}function $O($){return new Response(null,{status:416,headers:{"Accept-Ranges":"bytes","Content-Range":P3($),"Content-Length":"0","Cache-Control":"no-store"}})}async function b5($){if($ instanceof Blob)return{body:$,start:0,end:$.size-1,total:$.size,partial:!1,type:$.type,name:$.name,download:!1,status:200,extraHeaders:{}};if(H5($))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,Z=O instanceof Blob?O:null,T=$.total??Z?.size??-1;return{body:O,start:$.start??0,end:$.end??T-1,total:T,partial:$.partial??!1,type:$.type??Z?.type??"",name:$.name??O?.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}}}async function H3($,O){if($ instanceof Response)return $;if(!$)return new Response("Not found",{status:404});let Z=await b5($),{body:T,start:f,end:j,total:W,partial:z}=Z;if(T instanceof Blob&&"exists"in T&&typeof T.exists==="function"){if(!await T.exists())return new Response("Not found",{status:404})}let{range:J}=O;if(J){if(W<=0)return $O(Math.max(W,0));if(!z){if(T instanceof Blob){let F=_3(J,W);if(!F)return $O(W);T=T.slice(F.start,F.end+1),f=F.start,j=F.end,z=!0}}}let Y=Boolean(J)&&z,X=Y?206:Z.status,C=new Headers;if(C.set("Accept-Ranges","bytes"),C.set("Content-Type",Z.type||"application/octet-stream"),Y)C.set("Content-Range",E3(f,j,W)),C.set("Content-Length",String(j-f+1));else if(W>=0)C.set("Content-Length",String(W));if(Z.name)C.set("Content-Disposition",sO(Z.name,Z.download));if(Z.etag)C.set("ETag",Z.etag);if(Z.lastModified)C.set("Last-Modified",Z.lastModified.toUTCString());for(let[F,U]of Object.entries(Z.extraHeaders))C.set(F,U);if((O.method??"GET").toUpperCase()==="HEAD"){if(T&&"cancel"in T&&typeof T.cancel==="function")await T.cancel();return new Response(null,{status:X,headers:C})}return new Response(T,{status:X,headers:C})}function VW($){return uO($)}class s{method;handler;methodName;__internal_brand="RouteHandler";middlewares=[];constructor($,O,Z){this.method=$;this.handler=O;this.methodName=Z;this.handler=O,this.methodName=Z,this.method=$}get source(){if(!VW(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(VW(this.handler)){let O=new this.handler;return O[this.methodName].bind(O)()}return this.handler()}middleware($){return this.middlewares=G1($),this}}class IW{url;headers;__internal_brand="ProxyHandler";constructor($,O){this.url=$;this.headers=O}run(){let $=new A,O=$.headers.toJSON();for(let Z of LW($.rawRequest))delete O[Z];return fetch(this.url,{method:$.rawRequest.method,headers:{...O,...this.headers},body:$.rawRequest.body})}}class SW{constructor(...$){return new s(...$)}}class MW extends s{__internal_brand="StreamHandler";async run($){let O=N.getStore(),Z=O?.req?.rawRequest,T=b3(Z?.headers.get("Range"));if(O)O.rangeRequest=T;try{let f=await super.run($);return await H3(f,{range:T,method:Z?.method})}catch(f){if(f instanceof w3)return $O(f.total);throw f}finally{if(O)O.rangeRequest=null}}}class NW{constructor(...$){return new MW(...$)}}class xW{__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 xW($)}agent($){return w5($,this)}file($,O){return new SW("GET",$,O)}stream($,O){return new NW("GET",$,O)}proxy($,O={}){return new IW($,O)}}function w5($,O){let Z={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=Z;constructor(){super();this.middlewares=[...O?.middlewares??[]]}routes={"/":Z.stream,"/attach":Z.attach,"/stop":Z.stop,"/files":Z.upload};static middleware(f){if(f.stream)Z.stream.middleware(f.stream);if(f.attach)Z.attach.middleware(f.attach);if(f.stop)Z.stop.middleware(f.stop);if(f.upload)Z.upload.middleware(f.upload);return this}}}class v3{method;url;meta;__internal_brand="McpRoute";constructor($,O,Z){this.method=$;this.url=O;this.meta=Z}}class AW{static __brand="McpRouter";routes={};fromApiRoute($,O,Z){return new v3($,O,Z)}}function h($,O){return $.replace(/:([^/]+[*?]?)/g,(Z,T)=>{let f=T.endsWith("?")||T.endsWith("*"),j=f?T.slice(0,-1):T,W=O[j];if(W===void 0){if(f)return"";if(import.meta.env.DEV)throw Error(`Missing parameter: ${j}`);console.error(`Missing parameter: ${j} in URL: ${$}`)}return String(W)}).replace(/\/\//g,"/").replace(/\/$/,"")}class g3 extends q1{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 nO{static to($,...O){let[Z={}]=O,{search:T={},params:f={},permanent:j,status:W}={params:{},status:307,permanent:!1,...Z},z=new URLSearchParams(T).toString();throw new g3([h($,f)||"/",z.toString()].filter(Boolean).join("?"),W??(j?301:307))}static external($,O=307){throw new g3($,O)}}var _W=Symbol.for("gemi.HttpResponse");class OO{kind;body;status;headers;[_W]=!0;constructor($,O,Z,T){this.kind=$;this.body=O;this.status=Z;this.headers=T}static json($,O={}){let Z=O.status??200;return v5(Z),new OO("json",$,Z,new Headers(O.headers))}get ok(){return this.status>=200&&this.status<300}toResponse($,O){let Z=$,T=this.serialize(Z);for(let f of O)Z.append("Set-Cookie",f);this.headers.forEach((f,j)=>{if(j.toLowerCase()!=="set-cookie")Z.set(j,f)});for(let f of this.headers.getSetCookie())Z.append("Set-Cookie",f);if(this.status>=400&&!this.headers.has("Cache-Control"))Z.set("Cache-Control","no-store");return new Response(T,{status:this.status,headers:Z})}serialize($){switch(this.kind){case"json":return $.set("Content-Type","application/json"),JSON.stringify(this.body)??null}}}function v5($){if(!Number.isInteger($)||$<200||$>599)throw RangeError(`HttpResponse: status must be an integer from 200 to 599, got ${$}.`);if($===204||$===205||$===304)throw RangeError(`HttpResponse.json: a ${$} response has no body.`)}function C$($){return typeof $==="object"&&$!==null&&$[_W]===!0}class EW{kind="redirect";viewPath="REDIRECT";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>({});else if(typeof $==="function")this.handler=$;else{let[O,Z]=$;this.handler=(T)=>{return new O()[Z](T)}}}async run($,O){let{destination:Z,permanent:T=!1,status:f=307}=await this.handler($);if(!Z)throw Error(`Redirect destination is required see ${O}`);return nO.to(Z,{permanent:T,status:f}),{}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}async function R3($,O){if($ instanceof Response)return $;let Z=$ instanceof Blob,T=Z?$:$.file,f=Z?$.name:$.name??$.file?.name,j=(Z?$.type:$.type??$.file?.type)||"",W=Z?!1:$.download??!1,z=Z?200:$.status??200;if(!Z)for(let[J,Y]of Object.entries($.headers??{}))O.set(J,Y);if(T instanceof Blob&&"exists"in T&&typeof T.exists==="function"){if(!await T.exists())return new Response("Not found",{status:404})}if(O.set("Content-Type",j||"application/octet-stream"),T instanceof Blob)O.set("Content-Length",String(T.size));if(f)O.set("Content-Disposition",sO(f,W));return new Response(T instanceof Blob?T.stream():T,{status:z,headers:O})}class PW{kind="file";viewPath="FILE";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>null;else if(typeof $==="function")this.handler=$;else{let[O,Z]=$;this.handler=(T)=>{return new O()[Z](T)}}}async run($,O){let Z=await this.handler($);if(!Z)throw Error(`File route handler must return a file see ${O}`);return{FILE:Z}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}function HW($,O){if(C$($))throw Error(`The handler of view "${O}" returned an HttpResponse. HttpResponse is for api routes; a view handler returns its props.`);return $}class bW{viewPath;middlewares=[];featureGates=[];handler;constructor($,O){this.viewPath=$;if(!O)this.handler=()=>({});else if(typeof O==="function")this.handler=O;else{let[Z,T]=O;this.handler=(f)=>{return new Z()[T](f)}}}async run($,O){let Z=HW(await this.handler($),this.viewPath);return{[this.viewPath]:{...Z,breadcrumb:{label:Z?.breadcrumb??"",href:O}}}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class wW{viewPath;children;middlewares=[];featureGates=[];alwaysRuns=!1;handler=()=>({});constructor($,O,Z){this.viewPath=$;if(typeof O==="function")this.handler=O,this.children=class extends B1{routes=Z??{}};else if(Array.isArray(O)){let[T,f]=O;this.handler=(j)=>{return new T()[f](j)},this.children=class extends B1{routes=Z??{}}}else this.children=class extends B1{routes=O},this.handler=()=>({})}async run($,O){let Z=HW(await this.handler($),this.viewPath);return{[this.viewPath]:{...Z,breadcrumb:{label:Z?.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 bW($,O)}file($){return new PW($)}redirect($){return new EW($)}layout($,O,Z){return new wW($,O,Z)}}class w0{req;config={};constructor($){this.req=$}run(...$){return{}}static configure($){let O=this;return class extends O{config=$}}}function g5($){return $}function R5(){return{aliases:{},global:[]}}var D$="redirect";function ZO($,O="/"){if(typeof $!=="string"||!$.startsWith("/"))return O;if(/[\u0000-\u001f\u007f\\]/.test($)||$.startsWith("//"))return O;try{let Z=new URL($,"http://gemi.invalid");if(Z.origin!=="http://gemi.invalid")return O;let T=`${Z.search}${Z.hash}`.replaceAll("/","%2F"),f=`${Z.pathname}${T}`.replaceAll(":","%3A");return f.startsWith("//")?O:f}catch{return O}}function vW($){let O=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();return O?O==="https":new URL($.url).protocol==="https:"}function k5($,O=!0){let Z=new URL($.rawRequest.url),T=Z.pathname.replace(/\.(json|og)$/,""),[,f,...j]=T.split("/");if(K(n).supportedLocales.includes(f))T=`/${j.join("/")}`;return O?`${T}${Z.search}`:T}function m5($,O){let Z=(T)=>T.replace(/\/+$/,"")||"/";return Z($)===Z(O)}function aO($,O){let Z=O||K(b).config.signInPath,T=/^[a-z][a-z\d+.-]*:/i.test(Z);if(T?!/^https?:\/\//i.test(Z):!Z.startsWith("/"))throw Error(`\`auth.signInPath\` must be a path like "/auth/sign-in", or an http(s) URL for sign-in hosted elsewhere. Got "${Z}". A route's own \`"auth:<path>"\` cannot carry a URL, because the alias parser splits it on the colon.`);let f=new URL(Z,"http://gemi.invalid");if($?.kind==="view"){let j=k5($,!T);if(T||!m5(new URL(j,f).pathname,f.pathname))f.searchParams.set(D$,j)}return T?f.href:`${f.pathname}${f.search}`}class gW extends w0{async run($){let O=N.getStore(),Z=O.req,T=()=>new y1({redirectTo:aO(Z,$)}),f=Z.cookies.get("access_token"),j=Z.headers.get("access_token"),W=f||j;if(!W)throw T();let z=O.user;if(!z){let J=await K(b).getSession(W,Z.headers.get("User-Agent"));if(!J)throw T();z=J?.user,O.setUser(z)}return{}}}class RW extends w0{async run(...$){let[O="public",Z="864000",...T]=$,f=`${O}, max-age=${Z}${T.length>0?", ":""}${T.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 q5={"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 kW extends w0{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 Z={...q5,...this.config.origins[O]};for(let[T,f]of Object.entries(Z))$.ctx().setHeaders(T,f)}return{}}}class U${config;static token="ratelimiter";constructor($){this.config=$}get driver(){return this.config.driver}async consume($,O={}){let Z=O.limit??this.config.limit,T=O.window??this.config.window,f=O.cost??1;if(mW("window",T),mW("limit",Z),!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:Z,window:T*1000,cost:f})}}function mW($,O){if(!Number.isFinite(O)||O<=0)throw Error(`Rate limiter ${$} must be greater than zero, got ${O}`)}class k3 extends q1{constructor($){super("Rate limit exceeded");let O={"Content-Type":"application/json",...$?cW($):{}};this.payload={api:{status:429,data:{error:{message:"Rate limit exceeded"}},headers:O},view:{error:{message:"Rate limit exceeded"},status:429,headers:O}}}}class pW extends w0{async run($,O){let Z=y5();if(!Z)return{};let T=await Z.consume(this.key(),{limit:qW($)??this.config.limit,window:qW(O)??this.config.window});if(this.config.headers!==!1){let f=this.req.ctx?.();if(f)for(let[j,W]of Object.entries(cW(T)))f.setHeaders(j,W)}if(!T.allowed)throw new k3(T);return{}}key(){if(this.config.key)return this.config.key(this.req);return`${oO(this.req)}:${this.req.routePath??"*"}`}}function y5(){try{let $=K();return $.bound(U$)?$.make(U$):null}catch{return null}}function oO($){let O=yW($.rawRequest);if(O!==void 0)return O;let Z=$.headers.get("x-forwarded-for");if(Z){let[T]=Z.split(",");if(T?.trim())return T.trim()}return $.headers.get("x-real-ip")?.trim()||"unknown"}function cW($){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 qW($){if($===void 0||$===null||$==="")return;let O=Number($);if(!Number.isFinite(O)||O<=0)return;return O}class iW extends w0{async run(){let $=this.req.cookies.get("csrf_token");if(!$)throw new m3;if(!["POST","PUT","PATCH","DELETE"].includes(this.req.rawRequest.method))return{};if(!Bun.CSRF.verify($,{secret:process.env.SECRET}))throw new m3;return{}}}class m3 extends q1{constructor(){super("Invalid CSRF token");this.name="InvalidCSRFTokenError"}payload={api:{status:403,data:{error:"Invalid CSRF token"}},view:{}}}class hW{policiesList={};constructor(){let $=this.register();for(let O of $){let Z=new O;this.policiesList[O.name]=Z}}register(){return[]}}class lW{all($,O){return!0}}import{createHmac as dW,randomBytes as p5}from"crypto";var c3="v2.";function i3($){return $.startsWith(c3)}function uW(){let $=process.env.SECRET;if(!$)throw Error("Signing in needs a secret to mint session tokens with. Set SECRET in the environment.");return $}function sW($){let O=p5(16).toString("hex"),Z=dW("sha256",uW()).update(`${$}:${O}`).digest("hex");return`${c3}${Z}`}function rO($,O){let Z=dW("sha256",uW()).update(`legacy-session:${O}:${$}`).digest("hex");return`${c3}${Z}`}import{randomBytes as l3}from"crypto";class h3 extends A{schema={name:{string:"Invalid name",required:"Name is required","min:2":"Name must be at least 3 characters"},email:{string:"Invalid email",required:"Email is required",email:"Invalid email"},password:{"min:8":"Password must be at least 9 characters"}}}async function c5($,O){if(typeof O!=="string"||O==="")return!1;try{return await Bun.password.verify($,O)}catch{return!1}}function x9($){return $}function nW($={}){return{basePath:"/auth",verifyEmail:!0,redirectPath:"/dashboard",signInPath:"/auth/sign-in",sessionExpiresInHours:24,sessionAbsoluteExpiresInHours:672,cookieDomain:null,migrateLegacySession:null,signUpRequest:h3,oauthProviders:{},verifyPassword:c5,hashPassword:async(O)=>await Bun.password.hash(O),generateForgotPasswordToken:async()=>l3(32).toString("hex"),generateEmailVerificationToken:()=>{if(!($.verifyEmail??!0))return"";return l3(32).toString("hex")},generateMagicLinkToken:()=>l3(32).toString("hex"),extendSession:()=>({}),onUserCreated:async()=>{},onSignUp:()=>{},onSignIn:()=>{},onSignOut:()=>{},onForgotPassword:()=>{},onResetPassword:()=>{},onMagicLinkCreated:()=>{}}}function d3($){if($&&typeof $==="object")delete $.password;return $}function i5(){return new Proxy({},{get:($,O)=>oW(O)})}var aW=new WeakMap;function rW($){if($&&typeof $==="object"){for(let O of Object.values($))rW(O);Object.freeze($)}return $}var h5={select:{id:!0,publicId:!0,email:!0,name:!0,locale:!0,globalRole:!0,accounts:{select:{id:!0,publicId:!0,organizationRole:!0,organization:!0}}}},l5=rW({token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:h5});class u3{models;constructor($=i5()){this.models=$}run($){return this.models.User.asSystem($)}sessionSelect(){return l5}transaction($){return this.models.User.transaction($)}withLegacySessionLock($,O){let Z=this.models.User.$connection??fO(),T=K(jO).connection(Z),f=()=>this.transaction(async()=>{if(T.dialect==="postgres"){let z=`gemi:legacy-session:${$}`;await TO()`SELECT pg_advisory_xact_lock(hashtextextended(${z}, 0))`}return O()});if(T.dialect!=="sqlite"||TO())return f();let W=(aW.get(T)??Promise.resolve()).then(f,f);return aW.set(T,W.catch(()=>{})),W}async createUser($){let O=await this.run(()=>this.models.User.create({data:$}));return d3(O)}async updateUserPassword($){let O=await this.run(()=>this.models.User.update({where:{id:$.id},data:{password:$.password}}));return d3(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:this.sessionSelect()}))}async findSession($){if(!$.token)return null;try{return await this.run(()=>this.models.Session.findUnique({where:{token:$.token},select:this.sessionSelect()}))}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:this.sessionSelect()}))}async deleteSession($){if(!$.token)return;await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}))}async claimLegacySession($){if(!$.token)return!1;let{count:O}=await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}));return O>0}async deleteAllUserSessions($){await this.run(()=>this.models.Session.deleteMany({where:{userId:$}}))}async createPasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.create({data:{token:$.token,user:{connect:{id:$.user.id}}}}))}async findPasswordResetToken($){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 Z=await this.run(()=>this.models.SocialAccount.findFirst({where:{provider:$,providerId:O},include:{user:!0}}));return Z?d3(Z.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:Z}=await this.run(()=>this.models.SocialAccount.updateMany({where:{id:$.id,providerId:$.providerId},data:{providerId:O}}));return Z===1}}import{randomBytes as _Y}from"crypto";function x0($,O,Z,T,f){return m0(O,D6($,O),Z,T,f)}function m0($,O,Z,T,f,j){let W=r3(O,Z,T);if(f&&O!==W)throw RangeError(o8($,O,Z,T,j));return W}function D6($,O){let Z=$[O];if(Z===void 0)throw TypeError(Af(O));return Z}function W0($){return $!==null&&/object|function/.test(typeof $)}function E0($,O=Map){let Z=new O;return(T,...f)=>{if(Z.has(T))return Z.get(T);let j=$(T,...f);return Z.set(T,j),j}}function jT($){return h1({name:$},1)}function h1($,O){return c0((Z)=>({value:Z,configurable:1,writable:!O}),$)}function U6($){return c0((O)=>({get:O,configurable:1}),$)}function DZ($){return{[Symbol.toStringTag]:{value:$,configurable:1}}}function I$($,O){let Z={},T=$.length;for(let f of O)Z[$[--T]]=f;return Z}function c0($,O,Z){let T={};for(let f in O)T[f]=$(O[f],f,Z);return T}function UO($,O,Z){let T={};for(let f=0;f<O.length;f++){let j=O[f];T[j]=$(j,f,Z)}return T}function d5($,O,Z){let T={};for(let f=0;f<$.length;f++)T[O[f]]=Z[$[f]];return T}function H0($,O){let Z={};for(let T of $)Z[T]=O[T];return Z}function WT($,O){let Z={};for(let T in O)$.has(T)||(Z[T]=O[T]);return Z}function zT($){$={...$};let O=Object.keys($);for(let Z of O)$[Z]===void 0&&delete $[Z];return $}function G6($,O){for(let Z of O)if(!(Z in $))return 0;return 1}function B6($,O,Z){for(let T of $)if(O[T]!==Z[T])return 0;return 1}function K6($,O,Z){let T={...Z};for(let f=0;f<O;f++)T[$[f]]=0;return T}function w($,...O){return(...Z)=>$(...O,...Z)}function tW($){return $[0].toUpperCase()+$.substring(1)}function GO($){return $.slice().sort()}function fZ($,O){return String(O).padStart($,"0")}function K1($,O){return Math.sign($-O)}function r3($,O,Z){return Math.min(Math.max($,O),Z)}function j1($,O){return[Math.floor($/O),zO($,O)]}function zO($,O){return($%O+O)%O}function L1($,O){return[UZ($,O),JT($,O)]}function UZ($,O){return Math.trunc($/O)||0}function JT($,O){return $%O||0}function tO($){return Math.abs($%1)===0.5}function Q6($,O,Z){let T=0,f=0;for(let z=0;z<=O;z++){let J=$[Z[z]],Y=a0[z],X=q/Y,[C,F]=L1(J,X);T+=F*Y,f+=C}let[j,W]=L1(T,q);return[f+j,W]}function GZ($,O,Z){let T={};for(let f=O;f>=0;f--){let j=a0[f];T[Z[f]]=UZ($,j),$=JT($,j)}return T}function V6($){return $===v?aZ:[]}function L6($){return $===v?xO:[]}function I6($){return $===v?["year","day"]:[]}function S6($){if($!==void 0)return l($)}function M6($){if($!==void 0)return i0($)}function YT($){if($!==void 0)return BO($)}function i0($){return A6(BO($))}function BO($){return x6(kJ($))}function XT($){if($==null)throw TypeError("Cannot be null or undefined");return $}function N6($,O){if(O==null)throw RangeError(Af($));return O}function z1($){if(!W0($))throw TypeError(a8);return $}function BZ($,O,Z=$){if(typeof O!==$)throw TypeError(SO(Z,O));return O}function x6($,O="number"){if(!Number.isInteger($))throw RangeError(zJ(O,$));return $||0}function A6($,O="number"){if($<=0)throw RangeError(JJ(O,$));return $}function FT($){if(typeof $=="symbol")throw TypeError(CJ);return String($)}function jZ($,O){return W0($)?String($):l($,O)}function KZ($){if(typeof $=="string")return BigInt($);if(typeof $!="bigint")throw TypeError(FJ($));return $}function _6($,O="number"){if(typeof $=="bigint")throw TypeError(XJ(O));if($=Number($),!Number.isFinite($))throw RangeError(YJ(O,$));return $}function U0($,O){return Math.trunc(_6($,O))||0}function E6($,O){return x6(_6($,O),O)}function eW($,O){return A6(U0($,O),O)}function CT($,O){let[Z,T]=L1(O,q),f=$+Z,j=Math.sign(f);return j&&j===-Math.sign(T)&&(f-=j,T+=j*q),[f,T]}function B$($,O,Z=1){return CT($[0]+O[0]*Z,$[1]+O[1]*Z)}function K$($,O){return CT($[0],$[1]+O)}function v0($,O){return B$(O,$,-1)}function B0($,O){return K1($[0],O[0])||K1($[1],O[1])}function P6($,O,Z){return B0($,O)===-1||B0($,Z)===1}function QZ($,O=1){let Z=BigInt(q/O);return[Number($/Z),Number($%Z)*O]}function Q$($,O=1){let Z=q/O,[T,f]=L1($,Z);return[T,f*O]}function H6($,O=1){let[Z,T]=$,f=Math.floor(T/O),j=q/O;return BigInt(Z)*BigInt(j)+BigInt(f)}function g0($,O=1,Z){let[T,f]=$,[j,W]=L1(f,O);return T*(q/O)+(j+(Z?W/O:0))}function DT($,O,Z=j1){let[T,f]=$,[j,W]=Z(f,O);return[T*(q/O)+j,W]}function UT($,O){let Z=$.formatToParts(O),T={};for(let f of Z)T[f.type]=f.value;return T}function GT($){return x0($,"isoYear",DO,CO,1),$.isoYear===DO?x0($,"isoMonth",4,12,1):$.isoYear===CO&&x0($,"isoMonth",1,9,1),$}function Q1($){return J1({...$,...p0,isoHour:12}),$}function J1($){let O=x0($,"isoYear",DO,CO,1),Z=O===DO?1:O===CO?-1:0;return Z&&R0(G0({...$,isoDay:$.isoDay+Z,isoNanosecond:$.isoNanosecond-Z})),$}function R0($){if(!$||P6($,hJ,iJ))throw RangeError(dZ);return $}function I1($){return Q6($,5,u0)[1]}function VZ($){let[O,Z]=j1($,q);return[GZ(Z,5,u0),O]}function b6($){return w6($)[0]}function w6($){return DT($,y0)}function K0($){return S$($.isoYear,$.isoMonth,$.isoDay,$.isoHour,$.isoMinute,$.isoSecond,$.isoMillisecond)}function G0($){let O=K0($);if(O!==void 0){let[Z,T]=L1(O,_0);return[Z,T*o0+($.isoMicrosecond||0)*t1+($.isoNanosecond||0)]}}function BT($,O){let[Z,T]=VZ(I1($)-O);return R0(G0({...$,isoDay:$.isoDay+T,...Z}))}function WZ(...$){return S$(...$)/zz}function S$(...$){let[O,Z]=v6(...$),T=O.valueOf();if(!isNaN(T))return T-Z*_0}function v6($,O=1,Z=1,T=0,f=0,j=0,W=0){let z=$===DO?1:$===CO?-1:0,J=new Date;return J.setUTCHours(T,f,j,W),J.setUTCFullYear($,O-1,Z+z),[J,z]}function M1($,O){let[Z,T]=K$($,O);T<0&&(T+=q,Z-=1);let[f,j]=j1(T,o0),[W,z]=j1(j,t1);return LZ(Z*_0+f,W,z)}function LZ($,O=0,Z=0){let T=Math.ceil(Math.max(0,Math.abs($)-cJ)/_0)*Math.sign($),f=new Date($-T*_0);return I$(rZ,[f.getUTCFullYear(),f.getUTCMonth()+1,f.getUTCDate()+T,f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds(),f.getUTCMilliseconds(),O,Z])}function g6($){return[$.isoYear,$.isoMonth,$.isoDay]}function R6(){return f1}function KT($,O){switch(O){case 2:return QT($)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function k6($){return QT($)?366:365}function QT($){return $%4==0&&($%100!=0||$%400==0)}function m6($){let[O,Z]=v6($.isoYear,$.isoMonth,$.isoDay);return zO(O.getUTCDay()-Z,7)||7}function q6({isoYear:$}){return $<1?["bce",1-$]:["ce",$]}function u5($){let O=K0($);if(O<dJ)return q6($);let Z=UT(df(V$),O),{era:T,eraYear:f}=a2(Z,V$);return[T,f]}function IZ($){return l1($),SZ($,1),$}function l1($){return y6($,1),$}function $6($){return B6(kf,$,y6($))}function y6($,O){let{isoYear:Z}=$,T=x0($,"isoMonth",1,R6(),O);return{isoYear:Z,isoMonth:T,isoDay:x0($,"isoDay",1,KT(Z,T),O)}}function SZ($,O){return I$(u0,[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 R($){return $===void 0?0:Nz(z1($))}function KO($,O=0){$=h0($);let Z=xz($),T=O7($,O);return[Nz($),T,Z]}function VT($){return xz(h0($))}function p6($){return $=h0($),yf($,9,6,1)}function M$($,O,Z,T=9,f=0,j=4){O=h0(O);let W=yf(O,T,f),z=ST(O),J=_O(O,j),Y=AO(O,T,f,1);return W==null?W=Math.max(Z,Y):l6(W,Y),z=MT(z,Y,1),$&&(J=((X)=>X<4?(X+2)%4:X)(J)),[W,Y,z,J]}function MZ($,O=6,Z){let T=ST($=NT($,CZ)),f=_O($,7),j=AO($,O);return j=N6(CZ,j),T=MT(T,j,void 0,Z),[j,T,f]}function LT($){return pf(h0($))}function c6($,O){return IT(h0($),O)}function IT($,O=4){let Z=h6($);return[_O($,4),...i6(AO($,O),Z)]}function i6($,O){return $!=null?[a0[$],$<4?9-3*$:-1]:[O===void 0?1:10**(9-O),O]}function ST($){let O=$[JO];return O===void 0?1:U0(O,JO)}function MT($,O,Z,T){let f=T?q:a0[O+1];if(f){let j=a0[O];if(f%(($=m0(JO,$,1,f/j-(T?0:1),1))*j))throw RangeError(SO(JO,$))}else $=m0(JO,$,1,Z?1e9:1,1);return $}function h6($){let O=$[o3];if(O!==void 0){if(typeof O!="number"){if(FT(O)==="auto")return;throw RangeError(SO(o3,O))}O=m0(o3,Math.floor(O),0,9,1)}return O}function h0($){return $===void 0?{}:z1($)}function NT($,O){return typeof $=="string"?{[O]:$}:z1($)}function a($){if($!==void 0){if(W0($))return Object.assign(Object.create(null),$);throw TypeError(a8)}}function NZ($,O){return $&&Object.assign(Object.create(null),$,{overflow:sJ[O]})}function xT($,O,Z=9,T=0,f){let j=O[$];if(j===void 0)return f?T:void 0;if(j=FT(j),j==="auto")return f?T:null;let W=OT[j];if(W===void 0&&(W=yJ[j]),W===void 0)throw RangeError(e8($,j,OT));return m0($,W,T,Z,1,NO),W}function d1($,O,Z,T=0){let f=Z[$];if(f===void 0)return T;let j=FT(f),W=O[j];if(W===void 0)throw RangeError(e8($,j,O));return W}function l6($,O){if(O>$)throw RangeError(bJ)}function z0($){return{branding:eZ,epochNanoseconds:$}}function X0($,O,Z){return{branding:C1,calendar:Z,timeZone:O,epochNanoseconds:$}}function o($,O=$.calendar){return{branding:$$,calendar:O,...H0(Lz,$)}}function r($,O=$.calendar){return{branding:e1,calendar:O,...H0(mf,$)}}function c1($,O=$.calendar){return{branding:b$,calendar:O,...H0(mf,$)}}function zZ($,O=$.calendar){return{branding:w$,calendar:O,...H0(mf,$)}}function l0($){return{branding:tZ,...H0(Vz,$)}}function i($){return{branding:$3,sign:N1($),...H0(vf,$)}}function d6($){return b6($.epochNanoseconds)}function xZ($){return DT($.epochNanoseconds,o0)[0]}function u6($){return H6($.epochNanoseconds,t1)}function s6($){return H6($.epochNanoseconds)}function n6($){return $.epochNanoseconds}function J0($){return typeof $=="string"?$:l($.id)}function N$($,O){return $===O||J0($)===J0(O)}function a6($,O,Z,T,f){let j=i1(T),[W,z]=((B,Q)=>{let I=Q((B=NT(B,fT))[Sz]),V=$7(B);return V=N6(fT,V),[V,I]})(f,$);if(XO(Math.max(W,j),z))return O6(T,W);if(!z)throw RangeError(uZ);let[J,Y,X]=bZ(O,Z,z),C=aT(X),F=wZ(X),U=oT(X),D=F(Y,J,T),G=U(Y,J,D,W);return XO(W,z)?O6(G,W):((B,Q,I,V,x,_,L)=>{let S=N1(B),[E,P]=AT(V,Rf(I,B),I,S,x,_,L),Z0=_T(Q,E,P);return B[k[I]]+Z0*S})(G,C(D),W,Y,J,C,F)}function O6($,O){return g0(j0($),a0[O],1)}function AT($,O,Z,T,f,j,W){let z=k[Z],J={...O,[z]:O[z]+T},Y=W($,f,O),X=W($,f,J);return[j(Y),j(X)]}function _T($,O,Z){let T=g0(v0(O,Z));if(!T)throw RangeError(MO);return g0(v0(O,$))/T}function o6($,O){let[Z,T,f]=MZ(O,5,1);return z0(_Z($.epochNanoseconds,Z,T,f,1))}function r6($,O,Z){let{epochNanoseconds:T,timeZone:f,calendar:j}=O,[W,z,J]=MZ(Z);if(W===0&&z===1)return O;let Y=$(f);if(W===6)T=((X,C,F,U)=>{let D=Q0(F,C),[G,B]=X(D),Q=F.epochNanoseconds,I=P0(C,G),V=P0(C,B);if(P6(Q,I,V))throw RangeError(MO);return W2(_T(Q,I,V),U)?V:I})(f2,Y,O,J);else{let X=Y.getOffsetNanosecondsFor(T);T=s1(Y,Z2(M1(T,X),W,z,J),X,2,0,1)}return X0(T,f,j)}function t6($,O){return o(Z2($,...MZ(O)),$.calendar)}function e6($,O){let[Z,T,f]=MZ(O,5);var j;return l0((j=f,ET($,QO(Z,T),j)[0]))}function $2($,O){let Z=$(O.timeZone),T=Q0(O,Z),[f,j]=f2(T),W=g0(v0(P0(Z,f),P0(Z,j)),nZ,1);if(W<=0)throw RangeError(MO);return W}function O2($,O){let{timeZone:Z,calendar:T}=O,f=((j,W,z)=>P0(W,j(Q0(z,W))))(j2,$(Z),O);return X0(f,Z,T)}function Z2($,O,Z,T){return T2($,QO(O,Z),T)}function T2($,O,Z){let[T,f]=ET($,O,Z);return J1({...n1($,f),...T})}function ET($,O,Z){return VZ(S1(I1($),O,Z))}function JZ($){return S1($,sZ,7)}function QO($,O){return a0[$]*O}function f2($){let O=j2($);return[O,n1(O,1)]}function j2($){return pJ(6,$)}function s5($,O,Z){let T=Math.min(i1($),6);return A$(EZ(j0($,T),O,Z),T)}function AZ($,O,Z,T,f,j,W,z,J,Y){if(T===0&&f===1)return $;let X=XO(T,z)?vZ(z)&&T<6&&Z>=6?a5:n5:o5,[C,F,U]=X($,O,Z,T,f,j,W,z,J,Y);return U&&T!==7&&(C=((D,G,B,Q,I,V,x,_)=>{let L=N1(D);for(let S=Q+1;S<=B;S++){if(S===7&&B!==7)continue;let E=Rf(S,D);E[k[S]]+=L;let P=g0(v0(x(_(I,V,E)),G));if(P&&Math.sign(P)!==L)break;D=E}return D})(C,F,Z,Math.max(6,T),W,z,J,Y)),C}function _Z($,O,Z,T,f){if(O===6){let j=((W)=>W[0]+W[1]/q)($);return[S1(j,Z,T),0]}return EZ($,QO(O,Z),T,f)}function EZ($,O,Z,T){let[f,j]=$;T&&j<0&&(j+=q,f-=1);let[W,z]=j1(S1(j,O,Z),q);return CT(f+W,z)}function S1($,O,Z){return W2($/O,Z)*O}function W2($,O){return f7[O]($)}function n5($,O,Z,T,f,j){let W=N1($),z=j0($),J=_Z(z,T,f,j),Y=v0(z,J),X=Math.sign(J[0]-z[0])===W,C=A$(J,Math.min(Z,6));return[{...$,...C},B$(O,Y),X]}function a5($,O,Z,T,f,j,W,z,J,Y){let X=N1($),C=g0(j0($,5)),F=QO(T,f),U=S1(C,F,j),[D,G]=AT(W,{...$,...gf},6,X,z,J,Y),B=U-g0(v0(D,G)),Q=0;B&&Math.sign(B)!==X?O=K$(D,U):(Q+=X,U=S1(B,F,j),O=K$(G,U));let I=RZ(U);return[{...$,...I,days:$.days+Q},O,Boolean(Q)]}function o5($,O,Z,T,f,j,W,z,J,Y){let X=N1($),C=k[T],F=Rf(T,$);T===7&&($={...$,weeks:$.weeks+Math.trunc($.days/7)});let U=UZ($[C],f)*f;F[C]=U;let[D,G]=AT(W,F,T,f*X,z,J,Y),B=U+_T(O,D,G)*X*f,Q=S1(B,f,j),I=Math.sign(Q-B)===X;return F[C]=Q,[F,I?G:D,I]}function PT($,O,Z,T){let[f,j,W,z]=((Y)=>{let X=IT(Y=h0(Y));return[Y.timeZone,...X]})(T),J=f!==void 0;return((Y,X,C,F,U,D)=>{C=EZ(C,U,F,1);let G=X.getOffsetNanosecondsFor(C);return kT(M1(C,G),D)+(Y?u1(JZ(G)):"Z")})(J,O(J?$(f):O$),Z.epochNanoseconds,j,W,z)}function HT($,O,Z){let[T,f,j,W,z,J]=((Y)=>{Y=h0(Y);let X=pf(Y),C=h6(Y),F=T7(Y),U=_O(Y,4),D=AO(Y,4);return[X,Z7(Y),F,U,...i6(D,C)]})(Z);return((Y,X,C,F,U,D,G,B,Q,I)=>{F=EZ(F,Q,B,1);let V=Y(C).getOffsetNanosecondsFor(F);return kT(M1(F,V),I)+u1(JZ(V),G)+((x,_)=>_!==1?"["+(_===2?"!":"")+J0(x)+"]":"")(C,D)+mT(X,U)})($,O.calendar,O.timeZone,O.epochNanoseconds,T,f,j,W,z,J)}function bT($,O){let[Z,T,f,j]=((Y)=>(Y=h0(Y),[pf(Y),...IT(Y)]))(O);return W=$.calendar,z=Z,J=j,kT(T2($,f,T),J)+mT(W,z);var W,z,J}function wT($,O){return Z=$.calendar,T=$,f=LT(O),YZ(T)+mT(Z,f);var Z,T,f}function vT($,O){return z2($.calendar,J2,$,LT(O))}function gT($,O){return z2($.calendar,r5,$,LT(O))}function RT($,O){let[Z,T,f]=c6(O);return j=f,Y2(ET($,T,Z)[0],j);var j}function PZ($,O){let[Z,T,f]=c6(O,3);return T>1&&($={...$,...s5($,T,Z)}),((j,W)=>{let{sign:z}=j,J=z===-1?V0(j):j,{hours:Y,minutes:X}=J,[C,F]=DT(j0(J,3),y0,L1);K2(C);let U=qT(F,W),D=W>=0||!z||U;return(z<0?"-":"")+"P"+Z6({Y:p1(J.years),M:p1(J.months),W:p1(J.weeks),D:p1(J.days)})+(Y||X||C||D?"T"+Z6({H:p1(Y),M:p1(X),S:p1(C,D)+U}):"")})($,f)}function z2($,O,Z,T){let f=J0($),j=T>1||T===0&&f!==v;return T===1?f===v?O(Z):YZ(Z):j?YZ(Z)+X2(f,T===2):O(Z)}function Z6($){let O=[];for(let Z in $){let T=$[Z];T&&O.push(T,Z)}return O.join("")}function kT($,O){return YZ($)+"T"+Y2($,O)}function YZ($){return J2($)+"-"+q0($.isoDay)}function J2($){let{isoYear:O}=$;return(O<0||O>9999?F2(O)+fZ(6,Math.abs(O)):fZ(4,O))+"-"+q0($.isoMonth)}function r5($){return q0($.isoMonth)+"-"+q0($.isoDay)}function Y2($,O){let Z=[q0($.isoHour),q0($.isoMinute)];return O!==-1&&Z.push(q0($.isoSecond)+((T,f,j,W)=>qT(T*o0+f*t1+j,W))($.isoMillisecond,$.isoMicrosecond,$.isoNanosecond,O)),Z.join(":")}function u1($,O=0){if(O===1)return"";let[Z,T]=j1(Math.abs($),nZ),[f,j]=j1(T,sZ),[W,z]=j1(j,y0);return F2($)+q0(Z)+":"+q0(f)+(W||z?":"+q0(W)+qT(z):"")}function mT($,O){if(O!==1){let Z=J0($);if(O>1||O===0&&Z!==v)return X2(Z,O===2)}return""}function X2($,O){return"["+(O?"!":"")+"u-ca="+$+"]"}function qT($,O){let Z=fZ(9,$);return Z=O===void 0?Z.replace(z7,""):Z.slice(0,O),Z?"."+Z:""}function F2($){return $<0?"-":"+"}function p1($,O){return $||O?$.toLocaleString("fullwide",{useGrouping:0}):""}function t5($,O){let{epochNanoseconds:Z}=$,T=(O.getOffsetNanosecondsFor?O:O($.timeZone)).getOffsetNanosecondsFor(Z),f=M1(Z,T);return{calendar:$.calendar,...f,offsetNanoseconds:T}}function C2($,O){let Z=Q0(O,$);return{calendar:O.calendar,...H0(Lz,Z),offset:u1(Z.offsetNanoseconds),timeZone:O.timeZone}}function s1($,O,Z,T=0,f=0,j,W){if(Z!==void 0&&T===1&&(T===1||W))return BT(O,Z);let z=$.getPossibleInstantsFor(O);if(Z!==void 0&&T!==3){let J=((Y,X,C,F)=>{let U=G0(X);F&&(C=JZ(C));for(let D of Y){let G=g0(v0(D,U));if(F&&(G=JZ(G)),G===C)return D}})(z,O,Z,j);if(J!==void 0)return J;if(T===0)throw RangeError(xJ)}return W?G0(O):P0($,O,f,z)}function P0($,O,Z=0,T=$.getPossibleInstantsFor(O)){if(T.length===1)return T[0];if(Z===1)throw RangeError(AJ);if(T.length)return T[Z===3?1:0];let f=G0(O),j=((z,J)=>{let Y=z.getOffsetNanosecondsFor(K$(J,-q));return pT(z.getOffsetNanosecondsFor(K$(J,q))-Y)})($,f),W=j*(Z===2?-1:1);return(T=$.getPossibleInstantsFor(M1(f,W)))[Z===2?0:T.length-1]}function yT($){if(Math.abs($)>=q)throw RangeError(MJ);return $}function pT($){if($>q)throw RangeError(NJ);return $}function cT($,O,Z){return z0(R0(B$(O.epochNanoseconds,((T)=>{if(Q2(T))throw RangeError(PJ);return j0(T,5)})($?V0(Z):Z))))}function iT($,O,Z,T,f,j=Object.create(null)){let W=O(T.timeZone),z=$(T.calendar);return{...T,...sT(W,z,T,Z?V0(f):f,j)}}function hT($,O,Z,T,f=Object.create(null)){let{calendar:j}=Z;return o(nT($(j),Z,O?V0(T):T,f),j)}function lT($,O,Z,T,f){let{calendar:j}=Z;return r(HZ($(j),Z,O?V0(T):T,f),j)}function dT($,O,Z,T,f=Object.create(null)){let j=Z.calendar,W=$(j),z=YO(W,Z);O&&(T=gZ(T)),T.sign<0&&(z=W.dateAdd(z,{...Y0,months:1}),z=n1(z,-1));let J=W.dateAdd(z,T,f);return c1(YO(W,J),j)}function uT($,O,Z){return l0(D2(O,$?V0(Z):Z)[0])}function sT($,O,Z,T,f){let j=j0(T,5),W=Z.epochNanoseconds;if(Q2(T)){let z=Q0(Z,$);W=B$(P0($,{...HZ(O,z,{...T,...gf},f),...H0(u0,z)}),j)}else W=B$(W,j),R(f);return{epochNanoseconds:R0(W)}}function nT($,O,Z,T){let[f,j]=D2(O,Z);return J1({...HZ($,O,{...Z,...gf,days:Z.days+j},T),...f})}function HZ($,O,Z,T){if(Z.years||Z.months||Z.weeks)return $.dateAdd(O,Z,T);R(T);let f=Z.days+j0(Z,5)[0];return f?Q1(n1(O,f)):O}function YO($,O,Z=1){return n1(O,Z-$.day(O))}function D2($,O){let[Z,T]=j0(O,5),[f,j]=VZ(I1($)+T);return[f,Z+j]}function n1($,O){return O?{...$,...LZ(K0($)+O*_0)}:$}function bZ($,O,Z){let T=$(Z.calendar);return vZ(Z)?[Z,T,O(Z.timeZone)]:[{...Z,...p0},T]}function aT($){return $?n6:G0}function wZ($){return $?w(sT,$):nT}function oT($){return $?w($J,$):OJ}function vZ($){return $&&$.epochNanoseconds}function XO($,O){return $<=6-(vZ(O)?1:0)}function rT($,O,Z,T,f,j,W){let z=$(h0(W).relativeTo),J=Math.max(i1(f),i1(j));if(XO(J,z))return i(x$(((G,B,Q,I)=>{let V=B$(j0(G),j0(B),I?-1:1);if(!Number.isFinite(V[0]))throw RangeError(dZ);return{...Y0,...A$(V,Q)}})(f,j,J,T)));if(!z)throw RangeError(uZ);T&&(j=V0(j));let[Y,X,C]=bZ(O,Z,z),F=wZ(C),U=oT(C),D=F(X,Y,f);return i(U(X,Y,F(X,D,j),J))}function U2($,O,Z,T,f){let j=i1(T),[W,z,J,Y,X]=((L,S,E)=>{L=NT(L,CZ);let P=yf(L),Z0=E(L[Sz]),g=ST(L),m=_O(L,7),T0=AO(L);if(P===void 0&&T0===void 0)throw RangeError(HJ);return T0==null&&(T0=0),P==null&&(P=Math.max(T0,S)),l6(P,T0),g=MT(g,T0,1),[P,T0,g,m,Z0]})(f,j,$),C=Math.max(j,W);if(!vZ(X)&&C<=6)return i(x$(((L,S,E,P,Z0)=>{let g=_Z(j0(L),E,P,Z0);return{...Y0,...A$(g,S)}})(T,W,z,J,Y)));if(!X)throw RangeError(uZ);let[F,U,D]=bZ(O,Z,X),G=aT(D),B=wZ(D),Q=oT(D),I=B(U,F,T),V=Q(U,F,I,W),x=T.sign,_=N1(V);if(x&&_&&x!==_)throw RangeError(MO);return _&&(V=AZ(V,G(I),W,z,J,Y,U,F,G,B)),i(V)}function G2($){return $.sign===-1?gZ($):$}function gZ($){return i(V0($))}function V0($){let O={};for(let Z of k)O[Z]=-1*$[Z]||0;return O}function B2($){return!$.sign}function N1($,O=k){let Z=0;for(let T of O){let f=Math.sign($[T]);if(f){if(Z&&Z!==f)throw RangeError(EJ);Z=f}}return Z}function x$($){for(let O of qJ)m0(O,$[O],-Y6,Y6,1);return K2(g0(j0($),y0)),$}function K2($){if(!Number.isSafeInteger($))throw RangeError(_J)}function j0($,O=6){return Q6($,O,k)}function A$($,O=6){let[Z,T]=$,f=GZ(T,O,k);if(f[k[O]]+=Z*(q/a0[O]),!Number.isFinite(f[k[O]]))throw RangeError(dZ);return f}function RZ($,O=5){return GZ($,O,k)}function Q2($){return Boolean(N1($,Qz))}function i1($){let O=9;for(;O>0&&!$[k[O]];O--);return O}function e5($,O){return[$,O]}function T6($){let O=Math.floor($/ZZ)*ZZ;return[O,O+ZZ]}function V2($){let O=x1($=jZ($));if(!O)throw RangeError(A0($));let Z;if(O.m)Z=0;else{if(!O.offset)throw RangeError(A0($));Z=_$(O.offset)}return O.timeZone&&Of(O.timeZone,1),z0(BT(IZ(O),Z))}function L2($){let O=x1(l($));if(!O)throw RangeError(A0($));if(O.timeZone)return P2(O,O.offset?_$(O.offset):void 0);if(O.m)throw RangeError(A0($));return b2(O)}function I2($,O){let Z=x1(l($));if(!Z||!Z.timeZone)throw RangeError(A0($));let{offset:T}=Z,f=T?_$(T):void 0,[,j,W]=KO(O);return P2(Z,f,j,W)}function _$($){let O=Of($);if(O===void 0)throw RangeError(A0($));return O}function S2($){let O=x1(l($));if(!O||O.m)throw RangeError(A0($));return o(H2(O))}function kZ($){let O=x1(l($));if(!O||O.m)throw RangeError(A0($));return r(O.p?H2(O):b2(O))}function M2($,O){let Z=eT(l(O));if(Z)return tT(Z),c1(GT(l1(Z)));let T=kZ(O);return c1(YO($(T.calendar),T))}function tT($){if($.calendar!==v)throw RangeError(W1($.calendar))}function N2($,O){let Z=$f(l(O));if(Z)return tT(Z),zZ(l1(Z));let T=kZ(O),{calendar:f}=T,j=$(f),[W,z,J]=j.h(T),[Y,X]=j.I(W,z),[C,F]=j.N(Y,X,J);return zZ(Q1(j.P(C,F,J)),f)}function x2($){let O,Z=((T)=>{let f=C7.exec(T);return f?(mZ(f[10]),g2(f)):void 0})(l($));if(!Z){if(Z=x1($),!Z)throw RangeError(A0($));if(!Z.p)throw RangeError(A0($));if(Z.m)throw RangeError(W1("Z"));tT(Z)}if((O=eT($))&&$6(O))throw RangeError(A0($));if((O=$f($))&&$6(O))throw RangeError(A0($));return l0(SZ(Z,1))}function A2($){let O=((Z)=>{let T=G7.exec(Z);return T?((f)=>{function j(X,C,F){let U=0,D=0;if(F&&([U,J]=j1(J,a0[F])),X!==void 0){if(z)throw RangeError(W1(X));D=((G)=>{let B=parseInt(G);if(!Number.isFinite(B))throw RangeError(W1(G));return B})(X),W=1,C&&(J=Zf(C)*(a0[F]/y0),z=1)}return U+D}let W=0,z=0,J=0,Y={...I$(k,[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)]),...GZ(J,2,k)};if(!W)throw RangeError(r8(k));return Tf(f[1])<0&&(Y=V0(Y)),Y})(T):void 0})(l($));if(!O)throw RangeError(A0($));return i(x$(O))}function _2($){let O=x1($)||eT($)||$f($);return O?O.calendar:$}function E2($){let O=x1($);return O&&(O.timeZone||O.m&&O$||O.offset)||$}function P2($,O,Z=0,T=0){let f=qZ($.timeZone),j=O3(f);return X0(s1(j,IZ($),O,Z,T,!j.v,$.m),f,VO($.calendar))}function H2($){return w2(J1(IZ($)))}function b2($){return w2(Q1(l1($)))}function w2($){return{...$,calendar:VO($.calendar)}}function x1($){let O=F7.exec($);return O?((Z)=>{let T=Z[10],f=(T||"").toUpperCase()==="Z";return{isoYear:v2(Z),isoMonth:parseInt(Z[4]),isoDay:parseInt(Z[5]),...g2(Z.slice(5)),...mZ(Z[16]),p:Boolean(Z[6]),m:f,offset:f?void 0:T}})(O):void 0}function eT($){let O=Y7.exec($);return O?((Z)=>({isoYear:v2(Z),isoMonth:parseInt(Z[4]),isoDay:1,...mZ(Z[5])}))(O):void 0}function $f($){let O=X7.exec($);return O?((Z)=>({isoYear:L$,isoMonth:parseInt(Z[1]),isoDay:parseInt(Z[2]),...mZ(Z[3])}))(O):void 0}function Of($,O){let Z=D7.exec($);return Z?((T,f)=>{let j=T[4]||T[5];if(f&&j)throw RangeError(W1(j));return yT((G$(T[2])*nZ+G$(T[3])*sZ+G$(T[4])*y0+Zf(T[5]||""))*Tf(T[1]))})(Z,O):void 0}function v2($){let O=Tf($[1]),Z=parseInt($[2]||$[3]);if(O<0&&!Z)throw RangeError(W1(-0));return O*Z}function g2($){let O=G$($[3]);return{...VZ(Zf($[4]||""))[0],isoHour:G$($[1]),isoMinute:G$($[2]),isoSecond:O===60?59:O}}function mZ($){let O,Z,T=[];if($.replace(U7,(f,j,W)=>{let z=Boolean(j),[J,Y]=W.split("=").reverse();if(Y){if(Y==="u-ca")T.push(J),O||(O=z);else if(z||/[A-Z]/.test(Y))throw RangeError(W1(f))}else{if(Z)throw RangeError(W1(f));Z=J}return""}),T.length>1&&O)throw RangeError(W1($));return{timeZone:Z,calendar:T[0]||v}}function Zf($){return parseInt($.padEnd(9,"0"))}function E$($){return new RegExp(`^${$}$`,"i")}function Tf($){return $&&$!=="+"?-1:1}function G$($){return $===void 0?0:parseInt($)}function R2($){return qZ(l($))}function qZ($){let O=ff($);return typeof O=="number"?u1(O):O?((Z)=>{if(K7.test(Z))throw RangeError(SJ);return Z.toLowerCase().split("/").map((T,f)=>(T.length<=3||/\d/.test(T))&&!/etc|yap/.test(T)?T.toUpperCase():T.replace(/baja|dumont|[a-z]+/g,(j,W)=>j.length<=2&&!f||j==="in"||j==="chat"?j.toUpperCase():j.length>2||!W?tW(j).replace(/island|noronha|murdo|rivadavia|urville/,tW):j)).join("/")})($):O$}function f6($){let O=ff($);return typeof O=="number"?O:O?O.resolvedOptions().timeZone:O$}function ff($){let O=Of($=$.toUpperCase(),1);return O!==void 0?O:$!==O$?B7($):void 0}function jf($,O){return B0($.epochNanoseconds,O.epochNanoseconds)}function Wf($,O){return B0($.epochNanoseconds,O.epochNanoseconds)}function k2($,O,Z,T,f,j){let W=$(h0(j).relativeTo),z=Math.max(i1(T),i1(f));if(B6(k,T,f))return 0;if(XO(z,W))return B0(j0(T),j0(f));if(!W)throw RangeError(uZ);let[J,Y,X]=bZ(O,Z,W),C=aT(X),F=wZ(X);return B0(C(F(Y,J,T)),C(F(Y,J,f)))}function zf($,O){return a1($,O)||yZ($,O)}function a1($,O){return K1(K0($),K0(O))}function yZ($,O){return K1(I1($),I1(O))}function m2($,O){return!jf($,O)}function q2($,O){return!Wf($,O)&&!!pZ($.timeZone,O.timeZone)&&N$($.calendar,O.calendar)}function y2($,O){return!zf($,O)&&N$($.calendar,O.calendar)}function p2($,O){return!a1($,O)&&N$($.calendar,O.calendar)}function c2($,O){return!a1($,O)&&N$($.calendar,O.calendar)}function i2($,O){return!a1($,O)&&N$($.calendar,O.calendar)}function h2($,O){return!yZ($,O)}function pZ($,O){if($===O)return 1;let Z=J0($),T=J0(O);if(Z===T)return 1;try{return f6(Z)===f6(T)}catch(f){}}function Jf($,O,Z,T){let f=M$($,a(T),3,5),j=cZ(O.epochNanoseconds,Z.epochNanoseconds,...f);return i($?V0(j):j)}function Yf($,O,Z,T,f,j){let W=hZ(T.calendar,f.calendar),z=a(j),[J,Y,X,C]=M$(Z,z,5),F=T.epochNanoseconds,U=f.epochNanoseconds,D=B0(U,F),G;if(D)if(J<6)G=cZ(F,U,J,Y,X,C);else{let B=O(((I,V)=>{if(!pZ(I,V))throw RangeError(Tz);return I})(T.timeZone,f.timeZone)),Q=$(W);G=d2(Q,B,T,f,D,J,z),G=AZ(G,U,J,Y,X,C,Q,T,n6,w(sT,B))}else G=Y0;return i(Z?V0(G):G)}function Xf($,O,Z,T,f){let j=hZ(Z.calendar,T.calendar),W=a(f),[z,J,Y,X]=M$(O,W,6),C=G0(Z),F=G0(T),U=B0(F,C),D;if(U)if(z<=6)D=cZ(C,F,z,J,Y,X);else{let G=$(j);D=u2(G,Z,T,U,z,W),D=AZ(D,F,z,J,Y,X,G,Z,G0,nT)}else D=Y0;return i(O?V0(D):D)}function Ff($,O,Z,T,f){let j=hZ(Z.calendar,T.calendar),W=a(f);return l2(O,()=>$(j),Z,T,...M$(O,W,6,9,6),W)}function Cf($,O,Z,T,f){let j=hZ(Z.calendar,T.calendar),W=a(f),z=M$(O,W,9,9,8),J=$(j);return l2(O,()=>J,YO(J,Z),YO(J,T),...z,W)}function l2($,O,Z,T,f,j,W,z,J){let Y=G0(Z),X=G0(T),C;if(B0(X,Y))if(f===6)C=cZ(Y,X,f,j,W,z);else{let F=O();C=F.dateUntil(Z,T,f,J),j===6&&W===1||(C=AZ(C,X,f,j,W,z,F,Z,G0,HZ))}else C=Y0;return i($?V0(C):C)}function Df($,O,Z,T){let f=a(T),[j,W,z,J]=M$($,f,5,5),Y=S1(Uf(O,Z),QO(W,z),J),X={...Y0,...RZ(Y,j)};return i($?V0(X):X)}function $J($,O,Z,T,f,j){let W=B0(T.epochNanoseconds,Z.epochNanoseconds);return W?f<6?s2(Z.epochNanoseconds,T.epochNanoseconds,f):d2(O,$,Z,T,W,f,j):Y0}function OJ($,O,Z,T,f){let j=G0(O),W=G0(Z),z=B0(W,j);return z?T<=6?s2(j,W,T):u2($,O,Z,z,T,f):Y0}function d2($,O,Z,T,f,j,W){let[z,J,Y]=((F,U,D,G)=>{function B(){return S={...n1(V,_++*-G),...I},E=P0(F,S),B0(x,E)===-G}let Q=Q0(U,F),I=H0(u0,Q),V=Q0(D,F),x=D.epochNanoseconds,_=0,L=Uf(Q,V),S,E;if(Math.sign(L)===-G&&_++,B()&&(G===-1||B()))throw RangeError(MO);let P=g0(v0(E,x));return[Q,S,P]})(O,Z,T,f);var X,C;return{...j===6?(X=z,C=J,{...Y0,days:n2(X,C)}):$.dateUntil(z,J,j,W),...RZ(Y)}}function u2($,O,Z,T,f,j){let[W,z,J]=((Y,X,C)=>{let F=X,U=Uf(Y,X);return Math.sign(U)===-C&&(F=n1(X,-C),U+=q*C),[Y,F,U]})(O,Z,T);return{...$.dateUntil(W,z,f,j),...RZ(J)}}function cZ($,O,Z,T,f,j){return{...Y0,...A$(_Z(v0($,O),T,f,j),Z)}}function s2($,O,Z){return{...Y0,...A$(v0($,O),Z)}}function n2($,O){return iZ(K0($),K0(O))}function iZ($,O){return Math.trunc((O-$)/_0)}function Uf($,O){return I1(O)-I1($)}function hZ($,O){if(!N$($,O))throw RangeError(Pf);return $}function ZJ($){function O(f){return((j,W)=>({...a2(j,W),F:j.month,day:parseInt(j.day)}))(UT(Z,f),T)}let Z=df($),T=XZ($);return{id:$,O:TJ(O),B:fJ(O)}}function TJ($){return E0((O)=>{let Z=K0(O);return $(Z)},WeakMap)}function fJ($){let O=$(0).year-lJ;return E0((Z)=>{let T,f=S$(Z-O),j=[],W=[];do f+=400*_0;while((T=$(f)).year<=Z);do f+=(1-T.day)*_0,T.year===Z&&(j.push(f),W.push(T.F)),f-=_0;while((T=$(f)).year>=Z);return{k:j.reverse(),C:Wz(W.reverse())}})}function a2($,O){let Z,T,f=o2($);if($.era){let j=Gz[O];j!==void 0&&(Z=O==="islamic"?"ah":$.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),Z==="bc"||Z==="b"?Z="bce":Z!=="ad"&&Z!=="a"||(Z="ce"),T=f,f=O8(T,j[Z]||0))}return{era:Z,eraYear:T,year:f}}function o2($){return parseInt($.relatedYear||$.year)}function t3($){let{year:O,F:Z,day:T}=this.O($),{C:f}=this.B(O);return[O,f[Z]+1,T]}function FO($,O=1,Z=1){return this.B($).k[O-1]+(Z-1)*_0}function eO($){let O=W6(this,$),Z=W6(this,$-1),T=O.length;if(T>Z.length){let f=Z8(this);if(f<0)return-f;for(let j=0;j<T;j++)if(O[j]!==Z[j])return j+1}}function $Z($){return iZ(FO.call(this,$),FO.call(this,$+1))}function j6($,O){let{k:Z}=this.B($),T=O+1,f=Z;return T>Z.length&&(T=1,f=this.B($+1).k),iZ(Z[O-1],f[T-1])}function OZ($){return this.B($).k.length}function W6($,O){return Object.keys($.B(O).C)}function r2($){return VO(l($))}function VO($){if(($=$.toLowerCase())!==v&&$!==oZ&&XZ($)!==XZ(df($).resolvedOptions().calendar))throw RangeError(IJ($));return $}function XZ($){return $==="islamicc"&&($="islamic"),$.split("-")[0]}function t2($){return this.R($)[0]}function e2($){return this.R($)[1]}function Gf($){let[O]=this.h($);return iZ(this.q(O),K0($))+1}function $8($){let O=V7.exec($);if(!O)throw RangeError(VJ($));return[parseInt(O[1]),Boolean(O[2])]}function FZ($,O,Z){return $+(O||Z&&$>=Z?1:0)}function e3($,O){return $-(O&&$>=O?1:0)}function O8($,O){return(O+$)*(Math.sign(O)||1)||0}function $T($){return Gz[T8($)]}function Z8($){return RJ[T8($)]}function T8($){return XZ($.id||v)}function f8($,O,Z,T){let f=A1(Z,T,d0,[],Fz);if(f.timeZone!==void 0){let j=Z.dateFromFields(f),W=o1(f),z=$(f.timeZone);return{epochNanoseconds:s1(O(z),{...j,...W},f.offset!==void 0?_$(f.offset):void 0),timeZone:z}}return{...Z.dateFromFields(f),...p0}}function j8($,O,Z,T,f,j){let W=A1(Z,f,d0,Yz,Fz),z=$(W.timeZone),[J,Y,X]=KO(j),C=Z.dateFromFields(W,NZ(j,J)),F=o1(W,J);return X0(s1(O(z),{...C,...F},W.offset!==void 0?_$(W.offset):void 0,Y,X),z,T)}function W8($,O,Z){let T=A1($,O,d0,[],F1),f=R(Z);return o(J1({...$.dateFromFields(T,NZ(Z,f)),...o1(T,f)}))}function Bf($,O,Z,T=[]){let f=A1($,O,d0,T);return $.dateFromFields(f,Z)}function Kf($,O,Z,T){let f=A1($,O,wf,T);return $.yearMonthFromFields(f,Z)}function Qf($,O,Z,T,f=[]){let j=A1($,Z,d0,f);return O&&j.month!==void 0&&j.monthCode===void 0&&j.year===void 0&&(j.year=L$),$.monthDayFromFields(j,T)}function z8($,O){let Z=R(O);return l0(o1(n0($,ZT,[],1),Z))}function J8($){let O=n0($,vf);return i(x$({...Y0,...O}))}function A1($,O,Z,T=[],f=[]){return n0(O,[...$.fields(Z),...f].sort(),T)}function n0($,O,Z,T=!Z){let f={},j,W=0;for(let z of O){if(z===j)throw RangeError(DJ(z));if(z==="constructor"||z==="__proto__")throw RangeError(_f(z));let J=$[z];if(J!==void 0)W=1,X6[z]&&(J=X6[z](J,z)),f[z]=J;else if(Z){if(Z.includes(z))throw TypeError(Af(z));f[z]=Uz[z]}j=z}if(T&&!W)throw TypeError(r8(O));return f}function o1($,O){return SZ(M7({...Uz,...$}),O)}function Y8($,O,Z,T,f,j){let W=a(j),{calendar:z,timeZone:J}=Z;return X0(((Y,X,C,F,U)=>{let D=LO(Y,C,F,d0,Xz,Jz),[G,B,Q]=KO(U,2);return s1(X,{...Y.dateFromFields(D,NZ(U,G)),...o1(D,G)},_$(D.offset),B,Q)})($(z),O(J),T,f,W),J,z)}function X8($,O,Z,T,f){let j=a(f);return o(((W,z,J,Y)=>{let X=LO(W,z,J,d0,F1),C=R(Y);return J1({...W.dateFromFields(X,NZ(Y,C)),...o1(X,C)})})($(O.calendar),Z,T,j))}function F8($,O,Z,T,f){let j=a(f);return((W,z,J,Y)=>{let X=LO(W,z,J,d0);return W.dateFromFields(X,Y)})($(O.calendar),Z,T,j)}function C8($,O,Z,T,f){let j=a(f);return c1(((W,z,J,Y)=>{let X=LO(W,z,J,wf);return W.yearMonthFromFields(X,Y)})($(O.calendar),Z,T,j))}function D8($,O,Z,T,f){let j=a(f);return((W,z,J,Y)=>{let X=LO(W,z,J,d0);return W.monthDayFromFields(X,Y)})($(O.calendar),Z,T,j)}function U8($,O,Z){return l0(((T,f,j)=>{let W=R(j);return o1({...H0(ZT,T),...n0(f,ZT)},W)})($,O,Z))}function G8($,O){return i((Z=$,T=O,x$({...Z,...n0(T,vf)})));var Z,T}function LO($,O,Z,T,f=[],j=[]){let W=[...$.fields(T),...f].sort(),z=n0(O,W,j),J=n0(Z,W);return z=$.mergeFields(z,J),n0(z,W,[])}function Vf($,O){let Z=A1($,O,Dz);return $.monthDayFromFields(Z)}function Lf($,O,Z){let T=A1($,O,Cz);return $.yearMonthFromFields(T,Z)}function B8($,O,Z,T,f){O=H0(Z=$.fields(Z),O),T=n0(T,f=$.fields(f),[]);let j=$.mergeFields(O,T);return j=n0(j,[...Z,...f].sort(),[]),$.dateFromFields(j)}function s3($,O){let{era:Z,eraYear:T,year:f}=O,j=$T($);if(Z!==void 0||T!==void 0){if(Z===void 0||T===void 0)throw TypeError(GJ);if(!j)throw RangeError(UJ);let W=j[Z];if(W===void 0)throw RangeError(KJ(Z));let z=O8(T,W);if(f!==void 0&&f!==z)throw RangeError(BJ);f=z}else if(f===void 0)throw TypeError(QJ(j));return f}function n3($,O,Z,T){let{month:f,monthCode:j}=O;if(j!==void 0){let W=((z,J,Y,X)=>{let C=z.U(Y),[F,U]=$8(J),D=FZ(F,U,C);if(U){let G=Z8(z);if(G===void 0)throw RangeError(WO);if(G>0){if(D>G)throw RangeError(WO);if(C===void 0){if(X===1)throw RangeError(WO);D--}}else{if(D!==-G)throw RangeError(WO);if(C===void 0&&X===1)throw RangeError(WO)}}return D})($,j,Z,T);if(f!==void 0&&f!==W)throw RangeError(Oz);f=W,T=1}else if(f===void 0)throw TypeError(LJ);return m0("month",f,1,$.L(Z),T)}function z6($,O,Z,T,f){return x0(O,"day",1,$.j(T,Z),f)}function a3($,O,Z,T){let f=0,j=[];for(let W of Z)O[W]!==void 0?f=1:j.push(W);if(Object.assign($,O),f)for(let W of T||j)delete $[W]}function K8($){return z0(R0(QZ(KZ($))))}function Q8($,O,Z,T,f=v){return X0(R0(QZ(KZ(Z))),O(T),$(f))}function V8($,O,Z,T,f=0,j=0,W=0,z=0,J=0,Y=0,X=v){return o(J1(IZ(c0(U0,I$(rZ,[O,Z,T,f,j,W,z,J,Y])))),$(X))}function L8($,O,Z,T,f=v){return r(Q1(l1(c0(U0,{isoYear:O,isoMonth:Z,isoDay:T}))),$(f))}function I8($,O,Z,T=v,f=1){let j=U0(O),W=U0(Z),z=$(T);return c1(GT(l1({isoYear:j,isoMonth:W,isoDay:U0(f)})),z)}function S8($,O,Z,T=v,f=L$){let j=U0(O),W=U0(Z),z=$(T);return zZ(Q1(l1({isoYear:U0(f),isoMonth:j,isoDay:W})),z)}function M8($=0,O=0,Z=0,T=0,f=0,j=0){return l0(SZ(c0(U0,I$(u0,[$,O,Z,T,f,j])),1))}function N8($=0,O=0,Z=0,T=0,f=0,j=0,W=0,z=0,J=0,Y=0){return i(x$(c0(E6,I$(k,[$,O,Z,T,f,j,W,z,J,Y]))))}function If($,O,Z=v){return X0($.epochNanoseconds,O,Z)}function x8($){return z0($.epochNanoseconds)}function Sf($,O){return o(Q0(O,$))}function Mf($,O){return r(Q0(O,$))}function A8($,O,Z){return Lf($(O.calendar),Z)}function _8($,O,Z){return Vf($(O.calendar),Z)}function Nf($,O){return l0(Q0(O,$))}function E8($,O,Z,T){let f=((j,W,z,J)=>{let Y=VT(J);return P0(j(W),z,Y)})($,Z,O,T);return X0(R0(f),Z,O.calendar)}function P8($,O,Z){let T=$(O.calendar);return c1({...O,...Lf(T,Z)})}function H8($,O,Z){return Vf($(O.calendar),Z)}function b8($,O,Z,T,f){let j=$(f.timeZone),W=f.plainTime,z=W!==void 0?O(W):p0;return X0(P0(Z(j),{...T,...z}),j,T.calendar)}function w8($,O=p0){return o(J1({...$,...O}))}function v8($,O,Z){return Lf($(O.calendar),Z)}function g8($,O,Z){return Vf($(O.calendar),Z)}function R8($,O,Z,T){return((f,j,W)=>B8(f,j,Cz,z1(W),xO))($(O.calendar),Z,T)}function k8($,O,Z,T){return((f,j,W)=>B8(f,j,Dz,z1(W),aZ))($(O.calendar),Z,T)}function m8($,O,Z,T,f){let j=z1(f),W=O(j.plainDate),z=$(j.timeZone);return X0(P0(Z(z),{...W,...T}),z,W.calendar)}function q8($,O){return o(J1({...$,...O}))}function y8($){return z0(R0(Q$($,y0)))}function p8($){return z0(R0(Q$($,o0)))}function c8($){return z0(R0(QZ(KZ($),t1)))}function i8($){return z0(R0(QZ(KZ($))))}function h8($,O,Z=p0){let T=O.timeZone,f=$(T),j={...Q0(O,f),...Z};return X0(s1(f,j,j.offsetNanoseconds,2),T,O.calendar)}function l8($,O,Z){let T=O.timeZone,f=$(T),j={...Q0(O,f),...Z},W=n8(O.calendar,Z.calendar);return X0(s1(f,j,j.offsetNanoseconds,2),T,W)}function d8($,O=p0){return o({...$,...O})}function u8($,O){return o({...$,...O},n8($.calendar,O.calendar))}function lZ($,O){return{...$,calendar:O}}function s8($,O){return{...$,timeZone:O}}function n8($,O){if($===O)return $;let Z=J0($),T=J0(O);if(Z===T||Z===v)return O;if(T===v)return $;throw RangeError(Pf)}function jJ($,O){return(Z)=>Z===v?$:Z===oZ||Z===V$?Object.assign(Object.create($),{id:Z}):Object.assign(Object.create(O),Q7(Z))}function r1($,O,Z){let T=new Set(Z);return(f)=>(((j,W)=>{for(let z of W)if(z in j)return 1;return 0})(f=WT(T,f),$)||Object.assign(f,O),Z&&(f.timeZone=O$,["full","long"].includes(f.timeStyle)&&(f.timeStyle="medium")),f)}function Y1($,O=xf){let[Z,,,T]=$;return(f,j=y7,...W)=>{let z=O(T&&T(...W),f,j,Z),J=z.resolvedOptions();return[z,...WJ($,J,W)]}}function xf($,O,Z,T){if(Z=T(Z),$){if(Z.timeZone!==void 0)throw TypeError(wJ);Z.timeZone=$}return new _1(O,Z)}function WJ($,O,Z){let[,T,f]=$;return Z.map((j)=>(j.calendar&&((W,z,J)=>{if((J||W!==v)&&W!==z)throw RangeError(Pf)})(J0(j.calendar),O.calendar,f),T(j,O)))}function P$($){let O=IO();return M1(O,$.getOffsetNanosecondsFor(O))}function IO(){return Q$(Date.now(),o0)}function X1(){return C6||(C6=new _1().resolvedOptions().timeZone)}var zJ=($,O)=>`Non-integer ${$}: ${O}`,JJ=($,O)=>`Non-positive ${$}: ${O}`,YJ=($,O)=>`Non-finite ${$}: ${O}`,XJ=($)=>`Cannot convert bigint to ${$}`,FJ=($)=>`Invalid bigint: ${$}`,CJ="Cannot convert Symbol to string",a8="Invalid object",o8=($,O,Z,T,f)=>f?o8($,f[O],f[Z],f[T]):SO($,O)+`; must be between ${Z}-${T}`,SO=($,O)=>`Invalid ${$}: ${O}`,Af=($)=>`Missing ${$}`,_f=($)=>`Invalid field ${$}`,DJ=($)=>`Duplicate field ${$}`,r8=($)=>"No valid fields: "+$.join(),t8="Invalid bag",e8=($,O,Z)=>SO($,O)+"; must be "+Object.keys(Z).join(),$z="Cannot use valueOf",Ef="Invalid calling context",UJ="Forbidden era/eraYear",GJ="Mismatching era/eraYear",BJ="Mismatching year/eraYear",KJ=($)=>`Invalid era: ${$}`,QJ=($)=>"Missing year"+($?"/era/eraYear":""),VJ=($)=>`Invalid monthCode: ${$}`,Oz="Mismatching month/monthCode",LJ="Missing month/monthCode",J6="Cannot guess year",WO="Invalid leap month",Zz="Invalid protocol",MO="Invalid protocol results",Pf="Mismatching Calendars",IJ=($)=>`Invalid Calendar: ${$}`,Tz="Mismatching TimeZones",SJ="Forbidden ICU TimeZone",MJ="Out-of-bounds offset",NJ="Out-of-bounds TimeZone gap",xJ="Invalid TimeZone offset",AJ="Ambiguous offset",dZ="Out-of-bounds date",_J="Out-of-bounds duration",EJ="Cannot mix duration signs",uZ="Missing relativeTo",PJ="Cannot use large units",HJ="Required smallestUnit or largestUnit",bJ="smallestUnit > largestUnit",A0=($)=>`Cannot parse: ${$}`,W1=($)=>`Invalid substring: ${$}`,fz=($)=>`Cannot format ${$}`,jz="Mismatching types for formatting",wJ="Cannot specify TimeZone",Wz=w(UO,($,O)=>O),H$=w(UO,($,O,Z)=>Z),q0=w(fZ,2),OT={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},NO=Object.keys(OT),_0=86400000,zz=1000,t1=1000,o0=1e6,y0=1e9,sZ=60000000000,nZ=3600000000000,q=86400000000000,a0=[1,t1,o0,y0,sZ,nZ,q],F1=NO.slice(0,6),ZT=GO(F1),Jz=["offset"],Yz=["timeZone"],Xz=F1.concat(Jz),Fz=Xz.concat(Yz),TT=["era","eraYear"],vJ=TT.concat(["year"]),aZ=["year"],Hf=["monthCode"],bf=["month"].concat(Hf),xO=["day"],wf=bf.concat(aZ),Cz=Hf.concat(aZ),d0=xO.concat(wf),gJ=xO.concat(bf),Dz=xO.concat(Hf),Uz=H$(F1,0),v="iso8601",oZ="gregory",V$="japanese",Gz={[oZ]:{bce:-1,ce:0},[V$]:{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}},RJ={chinese:13,dangi:13,hebrew:-6},l=w(BZ,"string"),Bz=w(BZ,"boolean"),kJ=w(BZ,"number"),Kz=w(BZ,"function"),k=NO.map(($)=>$+"s"),vf=GO(k),mJ=k.slice(0,6),Qz=k.slice(6),qJ=Qz.slice(1),yJ=Wz(k),Y0=H$(k,0),gf=H$(mJ,0),Rf=w(K6,k),u0=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],kf=["isoDay","isoMonth","isoYear"],rZ=u0.concat(kf),mf=GO(kf),Vz=GO(u0),Lz=GO(rZ),p0=H$(Vz,0),pJ=w(K6,rZ),_1=Intl.DateTimeFormat,Iz="en-GB",qf=1e8,cJ=qf*_0,iJ=[qf,0],hJ=[-qf,0],CO=275760,DO=-271821,lJ=1970,L$=1972,f1=12,dJ=S$(1868,9,8),uJ=E0(u5,WeakMap),CZ="smallestUnit",fT="unit",JO="roundingIncrement",o3="fractionalSecondDigits",Sz="relativeTo",Mz={constrain:0,reject:1},sJ=Object.keys(Mz),nJ={compatible:0,reject:1,earlier:2,later:3},aJ={reject:0,use:1,prefer:2,ignore:3},oJ={auto:0,never:1,critical:2,always:3},rJ={auto:0,never:1,critical:2},tJ={auto:0,never:1},eJ={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},AO=w(xT,CZ),yf=w(xT,"largestUnit"),$7=w(xT,fT),Nz=w(d1,"overflow",Mz),xz=w(d1,"disambiguation",nJ),O7=w(d1,"offset",aJ),pf=w(d1,"calendarName",oJ),Z7=w(d1,"timeZoneName",rJ),T7=w(d1,"offset",tJ),_O=w(d1,"roundingMode",eJ),b$="PlainYearMonth",w$="PlainMonthDay",e1="PlainDate",$$="PlainDateTime",tZ="PlainTime",C1="ZonedDateTime",eZ="Instant",$3="Duration",f7=[Math.floor,($)=>tO($)?Math.floor($):Math.round($),Math.ceil,($)=>tO($)?Math.ceil($):Math.round($),Math.trunc,($)=>tO($)?Math.trunc($)||0:Math.round($),($)=>$<0?Math.floor($):Math.ceil($),($)=>Math.sign($)*Math.round(Math.abs($))||0,($)=>tO($)?($=Math.trunc($)||0)+$%2:Math.round($)],O$="UTC",ZZ=5184000,j7=WZ(1847),W7=WZ(new Date().getUTCFullYear()+10),z7=/0+$/,Q0=E0(t5,WeakMap),Y6=4294967295,O3=E0(($)=>{let O=ff($);return typeof O=="object"?new _z(O):new Az(O||0)});class Az{constructor($){this.v=$}getOffsetNanosecondsFor(){return this.v}getPossibleInstantsFor($){return[BT($,this.v)]}l(){}}class _z{constructor($){this.$=((O)=>{function Z(J){let Y=r3(J,W,z),[X,C]=T6(Y),F=f(X),U=f(C);return F===U?F:T(j(X,C),F,U,J)}function T(J,Y,X,C){let F,U;for(;(C===void 0||(F=C<J[0]?Y:C>=J[1]?X:void 0)===void 0)&&(U=J[1]-J[0]);){let D=J[0]+Math.floor(U/2);O(D)===X?J[1]=D:J[0]=D+1}return F}let f=E0(O),j=E0(e5),W=j7,z=W7;return{G(J){let Y=Z(J-86400),X=Z(J+86400),C=J-Y,F=J-X;if(Y===X)return[C];let U=Z(C);return U===Z(F)?[J-U]:Y>X?[C,F]:[]},V:Z,l(J,Y){let X=r3(J,W,z),[C,F]=T6(X),U=ZZ*Y,D=Y<0?()=>F>W||(W=X,0):()=>C<z||(z=X,0);for(;D();){let G=f(C),B=f(F);if(G!==B){let Q=j(C,F);T(Q,G,B);let I=Q[0];if((K1(I,J)||1)===Y)return I}C+=U,F+=U}}}})(((O)=>(Z)=>{let T=UT(O,Z*zz);return WZ(o2(T),parseInt(T.month),parseInt(T.day),parseInt(T.hour),parseInt(T.minute),parseInt(T.second))-Z})($))}getOffsetNanosecondsFor($){return this.$.V(b6($))*y0}getPossibleInstantsFor($){let[O,Z]=[WZ((T=$).isoYear,T.isoMonth,T.isoDay,T.isoHour,T.isoMinute,T.isoSecond),T.isoMillisecond*o0+T.isoMicrosecond*t1+T.isoNanosecond];var T;return this.$.G(O).map((f)=>R0(K$(Q$(f,y0),Z)))}l($,O){let[Z,T]=w6($),f=this.$.l(Z+(O>0||T?1:0),O);if(f!==void 0)return Q$(f,y0)}}var cf="([+\u2212-])",TZ="(?:[.,](\\d{1,9}))?",Ez=`(?:(?:${cf}(\\d{6}))|(\\d{4}))-?(\\d{2})`,hf="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+TZ+")?)?",lf=cf+hf,J7=Ez+"-?(\\d{2})(?:[T ]"+hf+"(Z|"+lf+")?)?",Pz="\\[(!?)([^\\]]*)\\]",Z3=`((?:${Pz}){0,9})`,Y7=E$(Ez+Z3),X7=E$("(?:--)?(\\d{2})-?(\\d{2})"+Z3),F7=E$(J7+Z3),C7=E$("T?"+hf+"(?:"+lf+")?"+Z3),D7=E$(lf),U7=new RegExp(Pz,"g"),G7=E$(`${cf}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${TZ}H)?(?:(\\d+)${TZ}M)?(?:(\\d+)${TZ}S)?)?`),B7=E0(($)=>new _1(Iz,{timeZone:$,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),K7=/^(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$/,Q7=E0(ZJ),df=E0(($)=>new _1(Iz,{calendar:$,timeZone:O$,era:"short",year:"numeric",month:"short",day:"numeric"})),V7=/^M(\d{2})(L?)$/,L7={era:jZ,eraYear:U0,year:U0,month:eW,monthCode:jZ,day:eW},I7=H$(F1,U0),S7=H$(k,E6),X6=Object.assign({},L7,I7,S7,{offset:jZ}),M7=w(d5,F1,u0),F6={dateAdd($,O,Z){let T=R(Z),f,{years:j,months:W,weeks:z,days:J}=O;if(J+=j0(O,5)[0],j||W)f=((Y,X,C,F,U)=>{let[D,G,B]=Y.h(X);if(C){let[Q,I]=Y.I(D,G);D+=C,G=FZ(Q,I,Y.U(D)),G=m0("month",G,1,Y.L(D),U)}return F&&([D,G]=Y._(D,G,F)),B=m0("day",B,1,Y.j(D,G),U),Y.q(D,G,B)})(this,$,j,W,T);else{if(!z&&!J)return $;f=K0($)}return f+=(7*z+J)*_0,Q1(LZ(f))},dateUntil($,O,Z){if(Z<=7){let J=0,Y=n2({...$,...p0},{...O,...p0});return Z===7&&([J,Y]=L1(Y,7)),{...Y0,weeks:J,days:Y}}let T=this.h($),f=this.h(O),[j,W,z]=((J,Y,X,C,F,U,D)=>{let G=F-Y,B=U-X,Q=D-C;if(G||B){let I=Math.sign(G||B),V=J.j(F,U),x=0;if(Math.sign(Q)===-I){let _=V;[F,U]=J._(F,U,-I),G=F-Y,B=U-X,V=J.j(F,U),x=I<0?-_:V}if(Q=D-Math.min(C,V)+x,G){let[_,L]=J.I(Y,X),[S,E]=J.I(F,U);if(B=S-_||Number(E)-Number(L),Math.sign(B)===-I){let P=I<0&&-J.L(F);G=(F-=I)-Y,B=U-FZ(_,L,J.U(F))+(P||J.L(F))}}}return[G,B,Q]})(this,...T,...f);return Z===8&&(W+=this.J(j,T[0]),j=0),{...Y0,years:j,months:W,days:z}},dateFromFields($,O){let Z=R(O),T=s3(this,$),f=n3(this,$,T,Z),j=z6(this,$,f,T,Z);return r(Q1(this.P(T,f,j)),this.id||v)},yearMonthFromFields($,O){let Z=R(O),T=s3(this,$),f=n3(this,$,T,Z);return c1(GT(this.P(T,f,1)),this.id||v)},monthDayFromFields($,O){let Z=R(O),T=!this.id,{monthCode:f,year:j,month:W}=$,z,J,Y,X,C;if(f!==void 0){[z,J]=$8(f),C=D6($,"day");let F=this.N(z,J,C);if(!F)throw RangeError(J6);if([Y,X]=F,W!==void 0&&W!==X)throw RangeError(Oz);T&&(X=m0("month",X,1,f1,1),C=m0("day",C,1,KT(j!==void 0?j:Y,X),Z))}else{Y=j===void 0&&T?L$:s3(this,$),X=n3(this,$,Y,Z),C=z6(this,$,X,Y,Z);let F=this.U(Y);J=X===F,z=e3(X,F);let U=this.N(z,J,C);if(!U)throw RangeError(J6);[Y,X]=U}return zZ(Q1(this.P(Y,X,C)),this.id||v)},fields($){return $T(this)&&$.includes("year")?[...$,...TT]:$},mergeFields($,O){let Z=Object.assign(Object.create(null),$);return a3(Z,O,bf),$T(this)&&(a3(Z,O,vJ),this.id===V$&&a3(Z,O,gJ,TT)),Z},inLeapYear($){let[O]=this.h($);return this.K(O)},monthsInYear($){let[O]=this.h($);return this.L(O)},daysInMonth($){let[O,Z]=this.h($);return this.j(O,Z)},daysInYear($){let[O]=this.h($);return this.X(O)},dayOfYear:Gf,era($){return this.ee($)[0]},eraYear($){return this.ee($)[1]},monthCode($){let[O,Z]=this.h($),[T,f]=this.I(O,Z);return((j,W)=>"M"+q0(j)+(W?"L":""))(T,f)},dayOfWeek:m6,daysInWeek(){return 7}},N7={dayOfYear:Gf,h:g6,q:S$},x7=Object.assign({},N7,{weekOfYear:t2,yearOfWeek:e2,R($){function O(U){return(7-U<T?7:0)-U}function Z(U){let D=k6(F+U),G=U||1,B=O(zO(J+D*G,7));return X=(D+(B-Y)*G)/7}let T=this.id?1:4,f=m6($),j=this.dayOfYear($),W=zO(f-1,7),z=j-1,J=zO(W-z,7),Y=O(J),X,C=Math.floor((z-Y)/7)+1,F=$.isoYear;return C?C>Z(0)&&(C=1,F++):(C=Z(-1),F--),[C,F,X]}}),A7={dayOfYear:Gf,h:t3,q:FO,weekOfYear:t2,yearOfWeek:e2,R(){return[]}},v$=jJ(Object.assign({},F6,x7,{h:g6,ee($){return this.id===oZ?q6($):this.id===V$?uJ($):[]},I:($,O)=>[O,0],N($,O){if(!O)return[L$,$]},K:QT,U(){},L:R6,J:($)=>$*f1,j:KT,X:k6,P:($,O,Z)=>({isoYear:$,isoMonth:O,isoDay:Z}),q:S$,_:($,O,Z)=>($+=UZ(Z,f1),(O+=JT(Z,f1))<1?($--,O+=f1):O>f1&&($++,O-=f1),[$,O]),year($){return $.isoYear},month($){return $.isoMonth},day:($)=>$.isoDay}),Object.assign({},F6,A7,{h:t3,ee($){let O=this.O($);return[O.era,O.eraYear]},I($,O){let Z=eO.call(this,$);return[e3(O,Z),Z===O]},N($,O,Z){let[T,f,j]=t3.call(this,{isoYear:L$,isoMonth:f1,isoDay:31}),W=eO.call(this,T),z=f===W;(K1($,e3(f,W))||K1(Number(O),Number(z))||K1(Z,j))===1&&T--;for(let J=0;J<100;J++){let Y=T-J,X=eO.call(this,Y),C=FZ($,O,X);if(O===(C===X)&&Z<=j6.call(this,Y,C))return[Y,C]}},K($){let O=$Z.call(this,$);return O>$Z.call(this,$-1)&&O>$Z.call(this,$+1)},U:eO,L:OZ,J($,O){let Z=O+$,T=Math.sign($),f=T<0?-1:0,j=0;for(let W=O;W!==Z;W+=T)j+=OZ.call(this,W+f);return j},j:j6,X:$Z,P($,O,Z){return LZ(FO.call(this,$,O,Z))},q:FO,_($,O,Z){if(Z){if(O+=Z,!Number.isSafeInteger(O))throw RangeError(dZ);if(Z<0)for(;O<1;)O+=OZ.call(this,--$);else{let T;for(;O>(T=OZ.call(this,$));)O-=T,$++}}return[$,O]},year($){return this.O($).year},month($){let{year:O,F:Z}=this.O($),{C:T}=this.B(O);return T[Z]+1},day($){return this.O($).day}})),V1="numeric",g$=["timeZoneName"],Hz={month:V1,day:V1},uf={year:V1,month:V1},sf=Object.assign({},uf,{day:V1}),nf={hour:V1,minute:V1,second:V1},af=Object.assign({},sf,nf),_7=Object.assign({},af,{timeZoneName:"short"}),E7=Object.keys(uf),P7=Object.keys(Hz),H7=Object.keys(sf),b7=Object.keys(nf),of=["dateStyle"],w7=E7.concat(of),v7=P7.concat(of),rf=H7.concat(of,["weekday"]),EO=b7.concat(["dayPeriod","timeStyle"]),tf=rf.concat(EO),g7=tf.concat(g$),R7=g$.concat(EO),k7=g$.concat(rf),m7=g$.concat(["day","weekday"],EO),q7=g$.concat(["year","weekday"],EO),y7={},ef=[r1(tf,af),xZ],bz=[r1(g7,_7),xZ,0,($,O)=>{let Z=J0($.timeZone);if(O&&J0(O.timeZone)!==Z)throw RangeError(Tz);return Z}],$j=[r1(tf,af,g$),K0],Oj=[r1(rf,sf,R7),K0],Zj=[r1(EO,nf,k7),($)=>I1($)/o0],Tj=[r1(w7,uf,m7),K0,1],fj=[r1(v7,Hz,q7),K0,1],C6;function e0($,O,Z,T,f){function j(...J){if(!(this instanceof j))throw TypeError(Ef);Rz(this,O(...J))}function W(J,Y){return Object.defineProperties(function(...X){return J.call(this,z(this),...X)},jT(Y))}function z(J){let Y=D0(J);if(!Y||Y.branding!==$)throw TypeError(Ef);return Y}return Object.defineProperties(j.prototype,{...U6(c0(W,Z)),...h1(c0(W,T)),...DZ("Temporal."+$)}),Object.defineProperties(j,{...h1(f),...jT($)}),[j,(J)=>{let Y=Object.create(j.prototype);return Rz(Y,J),Y},z]}function qz($){return $=$.concat("id").sort(),(O)=>{if(!G6(O,$))throw TypeError(Zz);return O}}function q$($){if(D0($)||$.calendar!==void 0||$.timeZone!==void 0)throw TypeError(t8);return $}function T3($,O){let Z={};for(let T in $)Z[T]=({o:f},j)=>{let W=D0(j)||{},{branding:z}=W,J=z===e1||O.includes(z)?W:I0(j);return f[T](J)};return Z}function zj($){let O={};for(let Z in $)O[Z]=(T)=>{let{calendar:f}=T;return(j=f,typeof j=="string"?v$(j):(W=j,Object.assign(Object.create(OY),{i:W})))[Z](T);var j,W};return O}function w1(){throw TypeError($z)}function HO({calendar:$}){return typeof $=="string"?new Bj($):$}function wz($,O){if(O=a(O),W0($)){let T=D0($);if(T&&T.branding===w$)return R(O),T;let f=cz($);return Qf(X3(f||v),!f,$,O)}let Z=N2(v$,$);return R(O),Z}function yz($,O,Z){return T=O.call($,L0(z0(Z))),yT(BO(T));var T}function f3($,O=dz){let Z=Object.keys(O).sort(),T={};for(let f of Z)T[f]=w(O[f],$,Kz($[f]));return T}function y($,O){return typeof $=="string"?O3($):f3($,O)}function e($){return y($,Wj)}function r0($){if(W0($)){let O=D0($);if(O)switch(O.branding){case eZ:return O;case C1:return z0(O.epochNanoseconds)}}return V2($)}function vz($,O,Z){let T=O.l(r0(Z).epochNanoseconds,$);return T?L0(z0(T)):null}function c($){return W0($)?(D0($)||{}).timeZone||zY($):((O)=>qZ(E2(l(O))))($)}function E1($,O){if(W0($)){let Z=D0($)||{};switch(Z.branding){case tZ:return R(O),Z;case $$:return R(O),l0(Z);case C1:return R(O),Nf(e,Z)}return z8($,O)}return R(O),x2($)}function Jj($){return $===void 0?void 0:E1($)}function R$($,O){if(O=a(O),W0($)){let T=D0($);return T&&T.branding===b$?(R(O),T):Kf(J3(bO($)),$,O)}let Z=M2(v$,$);return R(O),Z}function P1($,O){if(O=a(O),W0($)){let T=D0($)||{};switch(T.branding){case $$:return R(O),T;case e1:return R(O),o({...T,...p0});case C1:return R(O),Sf(e,T)}return W8(Y3(bO($)),$,O)}let Z=S2($);return R(O),Z}function I0($,O){if(O=a(O),W0($)){let T=D0($)||{};switch(T.branding){case e1:return R(O),T;case $$:return R(O),r(T);case C1:return R(O),Mf(e,T)}return Bf(Y3(bO($)),$,O)}let Z=kZ($);return R(O),Z}function pz($,O,Z){return i0(O.call($,u(r(Z,$))))}function $1($){return(O)=>typeof O=="string"?v$(O):((Z,T)=>{let f=Object.keys(T).sort(),j={};for(let W of f)j[W]=w(T[W],Z,Z[W]);return j})(O,$)}function d($){if(W0($)){let O=D0($);return O&&O.branding===$3?O:J8($)}return A2($)}function PO($){if($!==void 0){if(W0($)){let O=D0($)||{};switch(O.branding){case C1:case e1:return O;case $$:return r(O)}let Z=bO($);return{...f8(c,y,Y3(Z),$),calendar:Z}}return L2($)}}function bO($){return cz($)||v}function cz($){let{calendar:O}=$;if(O!==void 0)return C0(O)}function C0($){return W0($)?(D0($)||{}).calendar||SY($):((O)=>VO(_2(l(O))))($)}function k$($,O){if(O=a(O),W0($)){let Z=D0($);if(Z&&Z.branding===C1)return KO(O),Z;let T=bO($);return j8(c,y,Y3(T),T,$,O)}return I2($,O)}function gz($){return c0((O)=>(Z)=>O(jj(Z)),$)}function jj($){return Q0($,e)}function p7(){let $=_1.prototype,O=Object.getOwnPropertyDescriptors($),Z=Object.getOwnPropertyDescriptors(_1),T=function(f,j={}){if(!(this instanceof T))return new T(f,j);Kj.set(this,((W,z={})=>{let J=new _1(W,z),Y=J.resolvedOptions(),X=Y.locale,C=H0(Object.keys(z),Y),F=E0(h7),U=(...D)=>{let G,B=D.map((Q,I)=>{let V=D0(Q),x=(V||{}).branding;if(I&&G&&G!==x)throw TypeError(jz);return G=x,V});return G?F(G)(X,C,...B):[J,...D]};return U.u=J,U})(f,j))};for(let f in O){let j=O[f],W=f.startsWith("format")&&c7(f);typeof j.value=="function"?j.value=f==="constructor"?T:W||i7(f):W&&(j.get=function(){return W.bind(this)})}return Z.prototype.value=Object.create($,O),Object.defineProperties(T,Z),T}function c7($){return function(...O){let Z=Kj.get(this),[T,...f]=Z(...O);return T[$](...f)}}function i7($){return function(...O){return Kj.get(this).u[$](...O)}}function h7($){let O=l7[$];if(!O)throw TypeError(fz($));return Y1(O,E0(xf))}var l7={Instant:ef,PlainDateTime:$j,PlainDate:Oj,PlainTime:Zj,PlainYearMonth:Tj,PlainMonthDay:fj},d7=Y1(ef),u7=Y1(bz),s7=Y1($j),n7=Y1(Oj),a7=Y1(Zj),o7=Y1(Tj),r7=Y1(fj),Yj={era:S6,eraYear:YT,year:BO,month:i0,daysInMonth:i0,daysInYear:i0,inLeapYear:Bz,monthsInYear:i0},W3={monthCode:l},Xj={day:i0},iz={dayOfWeek:i0,dayOfYear:i0,weekOfYear:M6,yearOfWeek:YT,daysInWeek:i0},hz=Object.assign({},Yj,W3,Xj,iz),j3=new WeakMap,D0=j3.get.bind(j3),Rz=j3.set.bind(j3),t7={...T3(Yj,[b$]),...T3(iz,[]),...T3(W3,[b$,w$]),...T3(Xj,[w$])},Fj=zj(hz),e7=zj({...Yj,...W3}),$Y=zj({...W3,...Xj}),wO={calendarId:($)=>J0($.calendar)},OY=c0(($,O)=>function(Z){let{i:T}=this;return $(T[O](u(r(Z,T))))},hz),ZY=UO(($)=>(O)=>O[$],k.concat("sign")),Cj=UO(($,O)=>(Z)=>Z[u0[O]],F1),lz={epochSeconds:d6,epochMilliseconds:xZ,epochMicroseconds:u6,epochNanoseconds:s6},vO=w(WT,new Set(["branding"])),[TY,m$,fY]=e0(w$,w(S8,C0),{...wO,...$Y},{getISOFields:vO,getCalendar:HO,with($,O,Z){return m$(D8(VY,$,this,q$(O),Z))},equals:($,O)=>i2($,wz(O)),toPlainDate($,O){return u(k8(gO,$,this,O))},toLocaleString($,O,Z){let[T,f]=r7(O,Z,$);return T.format(f)},toString:gT,toJSON:($)=>gT($),valueOf:w1},{from:($,O)=>m$(wz($,O))}),dz={getOffsetNanosecondsFor:yz,getPossibleInstantsFor($,O,Z){let T=[...O.call($,F0(o(Z,v)))].map((j)=>WY(j).epochNanoseconds),f=T.length;return f>1&&(T.sort(B0),pT(g0(v0(T[0],T[f-1])))),T}},Wj={getOffsetNanosecondsFor:yz},[jY,L0,WY]=e0(eZ,K8,lz,{add:($,O)=>L0(cT(0,$,d(O))),subtract:($,O)=>L0(cT(1,$,d(O))),until:($,O,Z)=>p(Jf(0,$,r0(O),Z)),since:($,O,Z)=>p(Jf(1,$,r0(O),Z)),round:($,O)=>L0(o6($,O)),equals:($,O)=>m2($,r0(O)),toZonedDateTime($,O){let Z=z1(O);return t(If($,c(Z.timeZone),C0(Z.calendar)))},toZonedDateTimeISO:($,O)=>t(If($,c(O))),toLocaleString($,O,Z){let[T,f]=d7(O,Z,$);return T.format(f)},toString:($,O)=>PT(c,e,$,O),toJSON:($)=>PT(c,e,$),valueOf:w1},{from:($)=>L0(r0($)),fromEpochSeconds:($)=>L0(y8($)),fromEpochMilliseconds:($)=>L0(p8($)),fromEpochMicroseconds:($)=>L0(c8($)),fromEpochNanoseconds:($)=>L0(i8($)),compare:($,O)=>jf(r0($),r0(O))}),[z3,g9]=e0("TimeZone",($)=>{let O=R2($);return{branding:"TimeZone",id:O,o:O3(O)}},{id:($)=>$.id},{getPossibleInstantsFor:({o:$},O)=>$.getPossibleInstantsFor(P1(O)).map((Z)=>L0(z0(Z))),getOffsetNanosecondsFor:({o:$},O)=>$.getOffsetNanosecondsFor(r0(O).epochNanoseconds),getOffsetStringFor($,O){let Z=r0(O).epochNanoseconds,T=f3(this,Wj).getOffsetNanosecondsFor(Z);return u1(T)},getPlainDateTimeFor($,O,Z=v){let T=r0(O).epochNanoseconds,f=f3(this,Wj).getOffsetNanosecondsFor(T);return F0(o(M1(T,f),C0(Z)))},getInstantFor($,O,Z){let T=P1(O),f=VT(Z),j=f3(this);return L0(z0(P0(j,T,f)))},getNextTransition:({o:$},O)=>vz(1,$,O),getPreviousTransition:({o:$},O)=>vz(-1,$,O),equals($,O){return!!pZ(this,c(O))},toString:($)=>$.id,toJSON:($)=>$.id},{from($){let O=c($);return typeof O=="string"?new z3(O):O}}),zY=qz(Object.keys(dz)),[JY,H1]=e0(tZ,M8,Cj,{getISOFields:vO,with($,O,Z){return H1(U8(this,q$(O),Z))},add:($,O)=>H1(uT(0,$,d(O))),subtract:($,O)=>H1(uT(1,$,d(O))),until:($,O,Z)=>p(Df(0,$,E1(O),Z)),since:($,O,Z)=>p(Df(1,$,E1(O),Z)),round:($,O)=>H1(e6($,O)),equals:($,O)=>h2($,E1(O)),toZonedDateTime:($,O)=>t(m8(c,I0,y,$,O)),toPlainDateTime:($,O)=>F0(q8($,I0(O))),toLocaleString($,O,Z){let[T,f]=a7(O,Z,$);return T.format(f)},toString:RT,toJSON:($)=>RT($),valueOf:w1},{from:($,O)=>H1(E1($,O)),compare:($,O)=>yZ(E1($),E1(O))}),[YY,b1,XY]=e0(b$,w(I8,C0),{...wO,...e7},{getISOFields:vO,getCalendar:HO,with($,O,Z){return b1(C8(QY,$,this,q$(O),Z))},add:($,O,Z)=>b1(dT(kz,0,$,d(O),Z)),subtract:($,O,Z)=>b1(dT(kz,1,$,d(O),Z)),until:($,O,Z)=>p(Cf(mz,0,$,R$(O),Z)),since:($,O,Z)=>p(Cf(mz,1,$,R$(O),Z)),equals:($,O)=>c2($,R$(O)),toPlainDate($,O){return u(R8(gO,$,this,O))},toLocaleString($,O,Z){let[T,f]=o7(O,Z,$);return T.format(f)},toString:vT,toJSON:($)=>vT($),valueOf:w1},{from:($,O)=>b1(R$($,O)),compare:($,O)=>a1(R$($),R$(O))}),[FY,F0]=e0($$,w(V8,C0),{...wO,...Fj,...Cj},{getISOFields:vO,getCalendar:HO,with($,O,Z){return F0(X8(gO,$,this,q$(O),Z))},withCalendar:($,O)=>F0(lZ($,C0(O))),withPlainDate:($,O)=>F0(u8($,I0(O))),withPlainTime:($,O)=>F0(d8($,Jj(O))),add:($,O,Z)=>F0(hT(Z$,0,$,d(O),Z)),subtract:($,O,Z)=>F0(hT(Z$,1,$,d(O),Z)),until:($,O,Z)=>p(Xf(t0,0,$,P1(O),Z)),since:($,O,Z)=>p(Xf(t0,1,$,P1(O),Z)),round:($,O)=>F0(t6($,O)),equals:($,O)=>y2($,P1(O)),toZonedDateTime:($,O,Z)=>t(E8(y,$,c(O),Z)),toPlainDate:($)=>u(r($)),toPlainTime:($)=>H1(l0($)),toPlainYearMonth($){return b1(P8(J3,$,this))},toPlainMonthDay($){return m$(H8(X3,$,this))},toLocaleString($,O,Z){let[T,f]=s7(O,Z,$);return T.format(f)},toString:bT,toJSON:($)=>bT($),valueOf:w1},{from:($,O)=>F0(P1($,O)),compare:($,O)=>zf(P1($),P1(O))}),[CY,u,uz]=e0(e1,w(L8,C0),{...wO,...Fj},{getISOFields:vO,getCalendar:HO,with($,O,Z){return u(F8(gO,$,this,q$(O),Z))},withCalendar:($,O)=>u(lZ($,C0(O))),add:($,O,Z)=>u(lT(Z$,0,$,d(O),Z)),subtract:($,O,Z)=>u(lT(Z$,1,$,d(O),Z)),until:($,O,Z)=>p(Ff(t0,0,$,I0(O),Z)),since:($,O,Z)=>p(Ff(t0,1,$,I0(O),Z)),equals:($,O)=>p2($,I0(O)),toZonedDateTime($,O){let Z=!W0(O)||O instanceof z3?{timeZone:O}:O;return t(b8(c,E1,y,$,Z))},toPlainDateTime:($,O)=>F0(w8($,Jj(O))),toPlainYearMonth($){return b1(v8(J3,$,this))},toPlainMonthDay($){return m$(g8(X3,$,this))},toLocaleString($,O,Z){let[T,f]=n7(O,Z,$);return T.format(f)},toString:wT,toJSON:($)=>wT($),valueOf:w1},{from:($,O)=>u(I0($,O)),compare:($,O)=>a1(I0($),I0(O))}),Dj={fields($,O,Z){return[...O.call($,Z)]}},sz=Object.assign({dateFromFields($,O,Z,T){return uz(O.call($,Object.assign(Object.create(null),Z),T))}},Dj),nz=Object.assign({yearMonthFromFields($,O,Z,T){return XY(O.call($,Object.assign(Object.create(null),Z),T))}},Dj),az=Object.assign({monthDayFromFields($,O,Z,T){return fY(O.call($,Object.assign(Object.create(null),Z),T))}},Dj),Uj={mergeFields($,O,Z,T){return z1(O.call($,Object.assign(Object.create(null),Z),Object.assign(Object.create(null),T)))}},DY=Object.assign({},sz,Uj),UY=Object.assign({},nz,Uj),GY=Object.assign({},az,Uj),Gj={dateAdd($,O,Z,T,f){return uz(O.call($,u(r(Z,$)),p(i(T)),f))}},oz=Object.assign({},Gj,{dateUntil($,O,Z,T,f,j){return IY(O.call($,u(r(Z,$)),u(r(T,$)),Object.assign(Object.create(null),j,{largestUnit:NO[f]})))}}),BY=Object.assign({},Gj,{day:pz}),KY=Object.assign({},oz,{day:pz}),J3=$1(nz),Y3=$1(sz),X3=$1(az),QY=$1(UY),gO=$1(DY),VY=$1(GY),Z$=$1(Gj),t0=$1(oz),kz=$1(BY),mz=$1(KY),[LY,p,IY]=e0($3,N8,{...ZY,blank:B2},{with:($,O)=>p(G8($,O)),negated:($)=>p(gZ($)),abs:($)=>p(G2($)),add:($,O,Z)=>p(rT(PO,t0,y,0,$,d(O),Z)),subtract:($,O,Z)=>p(rT(PO,t0,y,1,$,d(O),Z)),round:($,O)=>p(U2(PO,t0,y,$,O)),total:($,O)=>a6(PO,t0,y,$,O),toLocaleString($,O,Z){return Intl.DurationFormat?new Intl.DurationFormat(O,Z).format(this):PZ($)},toString:PZ,toJSON:($)=>PZ($),valueOf:w1},{from:($)=>p(d($)),compare:($,O,Z)=>k2(PO,Z$,y,d($),d(O),Z)}),rz={toString:($)=>$.id,toJSON:($)=>$.id,...t7,dateAdd:({id:$,o:O},Z,T,f)=>u(r(O.dateAdd(I0(Z),d(T),f),$)),dateUntil:({o:$},O,Z,T)=>p(i($.dateUntil(I0(O),I0(Z),p6(T)))),dateFromFields:({id:$,o:O},Z,T)=>u(Bf(O,Z,T,I6($))),yearMonthFromFields:({id:$,o:O},Z,T)=>b1(Kf(O,Z,T,V6($))),monthDayFromFields:({id:$,o:O},Z,T)=>m$(Qf(O,0,Z,T,L6($))),fields({o:$},O){let Z=new Set(d0),T=[];for(let f of O){if(l(f),!Z.has(f))throw RangeError(_f(f));Z.delete(f),T.push(f)}return $.fields(T)},mergeFields:({o:$},O,Z)=>$.mergeFields(zT(XT(O)),zT(XT(Z)))},[Bj]=e0("Calendar",($)=>{let O=r2($);return{branding:"Calendar",id:O,o:v$(O)}},{id:($)=>$.id},rz,{from($){let O=C0($);return typeof O=="string"?new Bj(O):O}}),SY=qz(Object.keys(rz).slice(4)),[MY,t]=e0(C1,w(Q8,C0,c),{...lz,...wO,...gz(Fj),...gz(Cj),offset:($)=>u1(jj($).offsetNanoseconds),offsetNanoseconds:($)=>jj($).offsetNanoseconds,timeZoneId:($)=>J0($.timeZone),hoursInDay:($)=>$2(y,$)},{getISOFields:($)=>C2(e,$),getCalendar:HO,getTimeZone:({timeZone:$})=>typeof $=="string"?new z3($):$,with($,O,Z){return t(Y8(gO,y,$,this,q$(O),Z))},withCalendar:($,O)=>t(lZ($,C0(O))),withTimeZone:($,O)=>t(s8($,c(O))),withPlainDate:($,O)=>t(l8(y,$,I0(O))),withPlainTime:($,O)=>t(h8(y,$,Jj(O))),add:($,O,Z)=>t(iT(Z$,y,0,$,d(O),Z)),subtract:($,O,Z)=>t(iT(Z$,y,1,$,d(O),Z)),until:($,O,Z)=>p(i(Yf(t0,y,0,$,k$(O),Z))),since:($,O,Z)=>p(i(Yf(t0,y,1,$,k$(O),Z))),round:($,O)=>t(r6(y,$,O)),startOfDay:($)=>t(O2(y,$)),equals:($,O)=>q2($,k$(O)),toInstant:($)=>L0(x8($)),toPlainDateTime:($)=>F0(Sf(e,$)),toPlainDate:($)=>u(Mf(e,$)),toPlainTime:($)=>H1(Nf(e,$)),toPlainYearMonth($){return b1(A8(J3,$,this))},toPlainMonthDay($){return m$(_8(X3,$,this))},toLocaleString($,O,Z={}){let[T,f]=u7(O,Z,$);return T.format(f)},toString:($,O)=>HT(e,$,O),toJSON:($)=>HT(e,$),valueOf:w1},{from:($,O)=>t(k$($,O)),compare:($,O)=>Wf(k$($),k$(O))}),NY=Object.defineProperties({},{...DZ("Temporal.Now"),...h1({timeZoneId:()=>X1(),instant:()=>L0(z0(IO())),zonedDateTime:($,O=X1())=>t(X0(IO(),c(O),C0($))),zonedDateTimeISO:($=X1())=>t(X0(IO(),c($),v)),plainDateTime:($,O=X1())=>F0(o(P$(e(c(O))),C0($))),plainDateTimeISO:($=X1())=>F0(o(P$(e(c($))),v)),plainDate:($,O=X1())=>u(r(P$(e(c(O))),C0($))),plainDateISO:($=X1())=>u(r(P$(e(c($))),v)),plainTimeISO:($=X1())=>H1(l0(P$(e(c($)))))})}),y$=Object.defineProperties({},{...DZ("Temporal"),...h1({PlainYearMonth:YY,PlainMonthDay:TY,PlainDate:CY,PlainTime:JY,PlainDateTime:FY,ZonedDateTime:MY,Instant:jY,Calendar:Bj,TimeZone:z3,Duration:LY,Now:NY})}),xY=p7(),Kj=new WeakMap,AY=Object.defineProperties(Object.create(Intl),h1({DateTimeFormat:xY}));var Qj=new WeakMap;function EY($){let O=Qj.get($);if(!O)O=$(_Y(32).toString("hex")),Qj.set($,O),O.catch(()=>Qj.delete($));return O}async function Vj($,O,Z){if(typeof Z==="string"&&Z!=="")return await $.verifyPassword(O,Z);try{await $.verifyPassword(O,await EY($.hashPassword))}catch{}return!1}var Lj="intended_url";class Ij extends A{schema={email:{required:"Email is required",string:"Invalid email",email:"Invalid email"},password:{required:"Password is required"}}}class tz extends A{schema={email:{required:"Email is required",email:"Invalid email"}}}class ez extends A{schema={password:{required:"Password is required",password:"Invalid password"}}}class $0 extends q3{async me(){let $=await T$.user();if(!$)throw new y3;return $}async verifyEmail($=new A){let O=await $.input(),{userProvider:Z}=K(b),T=await Z.findUserByVerificationToken(O.get("token"));if(!T)return{email:null};return await Z.verifyUser(T.email),{email:T.email}}async signInWithMagicLink($=new A){let O=K(b),{userProvider:Z}=O,T=$.search.get("token"),f=decodeURIComponent($.search.get("email")).toLowerCase().trim(),j=null;try{j=await Z.findUserMagicLinkToken({email:f,token:T})}catch(z){return console.log(z),{error:JSON.stringify(z)}}if(!j)return{error:"Invalid token"};await Z.verifyUser(f),await Z.deleteMagicLinkToken(f);let W=await O.createOrUpdateSession({email:f});return $.ctx().setCookie("access_token",W.token,K(b).accessTokenCookieOptions($,W.expiresAt)),await O.config.onSignIn(W,$.search.toJSON()),{session:W}}async signInWithPinV2($=new A){let O=K(b),{userProvider:Z}=O,T=await $.input(),{email:f,pin:j}=T.toJSON(),W=f.toLowerCase().trim();if(!await Z.findUserMagicLinkToken({email:W,pin:j}))throw new k0({pin:["Invalid pin"]});await Z.deleteMagicLinkToken(W),await Z.verifyUser(W);let J=await O.createOrUpdateSessionV2({email:W});return $.ctx().setCookie("access_token",J.token,K(b).accessTokenCookieOptions($,J.expiresAt)),await O.config.onSignIn(J,$.search.toJSON()),J}async signInWithPin($=new A){let O=K(b),{userProvider:Z}=O,T=await $.input(),{email:f,pin:j}=T.toJSON(),W=f.toLowerCase().trim();if(!await Z.findUserMagicLinkToken({email:W,pin:j}))throw new k0({pin:["Invalid pin"]});await Z.deleteMagicLinkToken(W),await Z.verifyUser(W);let J=await O.createOrUpdateSession({email:W});return $.ctx().setCookie("access_token",J.token,K(b).accessTokenCookieOptions($,J.expiresAt)),await O.config.onSignIn(J,$.search.toJSON()),{session:J}}async signInV2($=new Ij){let O=await $.input(),{email:Z,password:T}=O.toJSON(),f=Z.toLowerCase().trim(),j=K(b),W=await j.userProvider.findUserByEmailAddress(f,j.config.verifyEmail),z=await Vj(j.config,T,W?.password);if(!W||!z)throw new k0({invalid_credentials:["Invalid credentials"]});let J=await j.createOrUpdateSessionV2({email:W.email,id:W.id});$.ctx().setCookie("access_token",J.token,K(b).accessTokenCookieOptions($,J.expiresAt)),await j.config.onSignIn(W,$.search.toJSON());let{password:Y,...X}=W;return X}async signIn($=new Ij){let O=await $.input(),{email:Z,password:T}=O.toJSON(),f=Z.toLowerCase().trim(),j=K(b),W=await j.userProvider.findUserByEmailAddress(f,j.config.verifyEmail),z=await Vj(j.config,T,W?.password);if(!W||!z)throw new k0({invalid_credentials:["Invalid credentials"]});let J=await j.createOrUpdateSession({email:W.email,id:W.id});$.ctx().setCookie("access_token",J.token,K(b).accessTokenCookieOptions($,J.expiresAt)),await j.config.onSignIn(W,$.search.toJSON());let{password:Y,...X}=W;return X}async signUp(){let $=K(b),{userProvider:O,config:Z}=$,T=new Z.signUpRequest,f=await T.input(),{email:j,password:W,name:z,invitationId:J}=f.toJSON(),Y=j.toLowerCase().trim();if(await O.findUserByEmailAddress(Y,!1))throw new k0({email:["Email address already exists"]});let C=await Z.hashPassword(W),F=K(n).detectLocale(T),U;if(J)U=await O.findInvitation(J,Y);let D,G="";if(U)D=await O.transaction(async()=>{await O.deleteInvitationById(J);let B=await O.createUser({email:Y,name:z,password:C,emailVerifiedAt:new Date,locale:F});return await O.createAccount({organizationId:U.organizationId,userId:B.id,organizationRole:U.role}),await Z.onUserCreated(B),B});else G=await Z.generateEmailVerificationToken(Y),D=await O.transaction(async()=>{let B=await O.createUser({email:Y,name:z,password:C,verificationToken:G,locale:F});return await Z.onUserCreated(B),B});return await Z.onSignUp(D,G,T.search.toJSON()),D}async signOut($=new A){let O=$.cookies.get("access_token")??$.headers.get("access_token"),Z=K(b),{config:T}=Z,f=await Z.revokeSession(O,$.headers.get("User-Agent"));if($.ctx().setCookie("access_token","",K(b).accessTokenCookieOptions($,new Date(0))),K(b).cookieDomain($))$.ctx().setCookie("access_token","",{...K(b).accessTokenCookieOptions($,new Date(0)),domain:void 0});if(f?.user)f.user.extension=await T.extendSession(f.user),await T.onSignOut(f.user);return{}}async forgotPassword($=new tz){let Z=(await $.input()).get("email").toLowerCase().trim(),{userProvider:T,config:f}=K(b),j=await T.findUserByEmailAddress(Z,f.verifyEmail);if(!j)return{};let W=await f.generateForgotPasswordToken(j);return await T.createPasswordResetToken({user:j,token:W}),await f.onForgotPassword(j,W),{}}async resetPassword($=new ez){let{userProvider:O,config:Z}=K(b),T=await $.input(),{password:f,token:j}=T.toJSON(),W=await O.findPasswordResetToken({token:j});if(!W)throw new k0({token:["Invalid token"]});if(y$.Instant.from(W.createdAt.toISOString()).add({hours:24}).until(y$.Now.instant()).sign>=0)throw new k0({token:["Token expired"]});await O.deletePasswordResetToken({token:j});let J=await O.findUserByEmailAddress(W.user.email,Z.verifyEmail);if(!J)throw new k0({email:["User not found"]});let Y=await Z.hashPassword(f);return await O.updateUserPassword({id:J.id,password:Y}),await O.deleteAllUserSessions(J.id),await Z.onResetPassword(J),{}}async changePassword($=new A){let{userProvider:O,config:Z}=K(b),T=await T$.user(),f=await $.input(),{oldPassword:j,newPassword:W}=f.toJSON(),z=await O.findUserByEmailAddress(T.email,Z.verifyEmail);if(!await Vj(Z,j,z?.password))throw new k0({oldPassword:["Incorrect password"]});let Y=await Z.hashPassword(W);return await O.updateUserPassword({id:T.id,password:Y}),await O.deleteAllUserSessions(T.id),{}}async oauthRedirect($=new A){let{provider:O}=$.params,Z=K(b).config.oauthProviders[O];if(!Z)throw Error(`Invalid provider: ${O}`);let T=ZO($.search.get(D$),"");if(T)$.ctx().setCookie(Lj,encodeURIComponent(T),{httpOnly:!0,sameSite:"Lax",secure:vW($.rawRequest),maxAge:600});return{destination:await Z.getRedirectUrl($)}}async oauthCallback($=new A){let{provider:O}=$.params,Z=K(b),{userProvider:T,config:f}=Z,j=f.oauthProviders[O],{email:W,name:z,username:J,providerId:Y}=await j.onCallback($),X=Y?await T.findUserBySocialAccount(O,Y):null,C="signin";if(!X){if(!W)return console.error("Authentication error: No email returned from OAuth provider callback"),{session:null};let G=K(n).detectLocale($);try{let B=await this.linkOAuthAccount({provider:O,providerId:Y,email:W,name:z,username:J,locale:G});if(B)X=B.user,C=B.action}catch(B){let Q=Y?await T.findUserBySocialAccount(O,Y):null;if(!Q)throw B;X=Q}if(!X)return{session:null}}let F=await Z.createOrUpdateSessionV2({email:X.email,id:X.id});if($.ctx().setCookie("access_token",F.token,K(b).accessTokenCookieOptions($,F.expiresAt)),C==="signup")await f.onSignUp(X,"",$.search.toJSON());else await f.onSignIn(X,$.search.toJSON());let U=$.cookies.get(Lj),D=f.redirectPath;if(U){try{D=ZO(decodeURIComponent(U),D)}catch{}$.ctx().setCookie(Lj,"",{maxAge:-1})}return{session:F,redirectTo:D}}async linkOAuthAccount($){let{provider:O,providerId:Z,email:T,name:f,username:j,locale:W}=$,{userProvider:z,config:J}=K(b),Y=(F)=>({provider:O,userId:F,email:T,username:j,providerId:Z,expiresAt:new Date,accessToken:"",refreshToken:""}),X=await z.findUserByEmailAddress(T,!1);if(X){if(!Z)return{user:X,action:"signin"};let F=await z.findSocialAccounts(X.id,O);if(F.some((D)=>D.providerId===Z))return{user:X,action:"signin"};if(F.some((D)=>D.providerId))return console.error(`Authentication error: user ${X.id} is already linked to a different ${O} account`),null;let U=F[0];if(U){if(!await z.claimSocialAccount(U,Z))throw Error(`${O} account link changed concurrently`)}else await z.createSocialAccount(Y(X.id));return{user:X,action:"signin"}}return{user:await z.transaction(async()=>{let F=await z.createUser({email:T,name:f,locale:W,emailVerifiedAt:new Date});if(Z)await z.createSocialAccount(Y(F.id));return await J.onUserCreated(F),F}),action:"signup"}}async createMagicLinkToken($=new A){let Z=(await $.input()).get("email").toLowerCase().trim(),T=K(b),{user:f,pin:j,token:W}=await T.createMagicLinkToken(Z);if(f)return await T.config.onMagicLinkCreated(f,{email:Z,pin:j,token:W}),{email:Z};return{email:null}}}class $4 extends B1{middlewares=["cache:private"];routes={"/:provider":this.view("_Redirect",[$0,"oauthRedirect"]),"/:provider/callback":this.view("auth/OauthCallback",[$0,"oauthCallback"])}}class Sj extends B1{middlewares=["cache:private"];routes={"/sign-in/magic-link":this.view("auth/MagicLinkSignIn",[$0,"signInWithMagicLink"]),"/oauth":$4}}class Mj 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 Nj extends N0{middlewares=["cache:private,0,no-store"];routes={"/set-locale/:locale":this.get(async()=>{let O=new A().params.locale;return await K(n).onLocaleChange(O),{locale:O}}),"/translations/:locale/:scope*":this.get(async()=>{let $=new A,O=`/${$.params.scope??""}`,Z=$.params.locale,T=K(n),f=Z??T.detectLocale($),j=T.getPageTranslations(f,O);return $.ctx().setCookie("i18n-locale",f,{expires:new Date(Date.now()+31536000000)}),{[f]:j}})}}class xj{}class Aj extends xj{async resize($,O){let{height:Z,width:T,quality:f,fit:j}=O;return await(await F3("The Sharp image optimization driver"))($).resize(T>0?T:void 0,Z>0?Z:void 0,{fit:j}).webp({quality:f>0?f:80,force:!0}).toBuffer()}}function XC($){return $}function O4(){return{driver:new Aj}}class _j extends N0{routes={"/resize":this.file(async()=>{let $=new A,O=new URL($.rawRequest.url),Z=O.searchParams.get("url"),T=Number(O.searchParams.get("w")),f=Number(O.searchParams.get("h")),j=O.searchParams.get("fit")??"cover",W=Number(O.searchParams.get("q"));if(!Z)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});let J=`${Z.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${Z}`,Y=await fetch(J);if(!Y.ok)return new Response(JSON.stringify({error:"Image not found",info:J}),{headers:{"Content-Type":"application/json"},status:404});let X=Buffer.from(await Y.arrayBuffer()),C=await K(Z4).resize(X,{height:f,width:T,fit:j,quality:W});Y.headers.delete("Content-Type"),Y.headers.delete("Content-Length");let F=new Headers(Y.headers);return F.set("Content-Type","image/webp"),F.set("Content-Length",`${C.byteLength}`),new Response(new Uint8Array(C),{headers:F})})}}class Z4{static token="image";driver;constructor($={}){this.driver=$.driver??O4().driver}resize($,O){return this.driver.resize($,O)}}import{mkdir as Ej,readdir as PY,access as HY}from"fs/promises";async function Pj($){try{return await HY($),!0}catch{return!1}}class RO{config;static token="log";writer;isReady=!1;flushTimeout;fileSize=0;writerSize=0;isCreatingFile=!1;bootPromise=null;currentLogFilePath;get logsDirPath(){return`${Hj()}/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 $=`${Hj()}/storage`;if(!await Pj($))await Ej($);if(!await Pj(this.logsDirPath))await Ej(this.logsDirPath);await this.newLogFile()}async newLogFile(){if(!await Pj(this.logsDirPath))await Ej(this.logsDirPath);if(this.isCreatingFile=!0,this.currentLogFilePath){this.writer.flush(),this.writer.end(),this.writer=null;let Z=new File([await Bun.file(this.currentLogFilePath).arrayBuffer()],this.currentLogFilePath.split("/").pop(),{type:"text/plain"});this.config.onLogFileClosed(Z),this.fileSize=0,this.writerSize=0}let O=(await PY(this.logsDirPath)).sort().reverse()[0];if(O){let Z=Bun.file(`${this.logsDirPath}/${O}`);if(Z.size<this.config.maxFileSize)this.currentLogFilePath=`${this.logsDirPath}/${O}`,this.writer=Z.writer(),this.writer.write(await Z.text()),this.writer.write(`
3
+ `),this.writer.flush(),this.fileSize=Z.size}if(!this.writer){let Z=`${new Date(Date.now()).toISOString()}.log`.replaceAll(":","-");this.currentLogFilePath=`${this.logsDirPath}/${Z}`;let T=Bun.file(`${this.logsDirPath}/${Z}`);this.writer=T.writer(),this.fileSize=0,this.writerSize=0}this.isCreatingFile=!1}async log($,O,Z={}){if(!this.isReady)await this.boot();let T=N.getStore(),f={};if(T)f={url:T.req.rawRequest.url,method:T.req.rawRequest.method,headers:T.req.rawRequest.headers,body:T.req.rawRequest.body};let j={timestamp:new Date(Date.now()).toISOString(),env:Bun.env.NODE_ENV,level:$,message:O,metadata:{...f,...Z}},W="";try{W=JSON.stringify(j)}catch(z){console.log("Error parsing log object",z)}try{let z=this.config.onLogCreated(j);if(z instanceof Promise)z.catch((J)=>console.error("Error in onLogCreated",J))}catch(z){console.error("Error in onLogCreated",z)}if(!this.writer)return;this.writerSize+=W.length,this.fileSize+=W.length;try{this.writer.write(W),this.writer.write(`
4
+ `),this.tryFlush()}catch(z){console.error("Error writing log",z)}}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 bj extends N0{middlewares=["cache:private,0"];routes={"/live":this.get(async()=>{let $=Bun.file(K(RO).currentLogFilePath);return new Response(await $.text(),{headers:{"Content-Type":"text/plain"}})})}}function bY($){let O=new Map;for(let Z of $)if(typeof Z==="string"){let[T,f=""]=Z.split(":");if(T.startsWith("-")){if(O.has(T.replace("-","")))O.delete(T.replace("-",""))}else O.set(T,f.split(",").filter(Boolean))}else O.set(Z,[]);return O}class kO{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 A;return Array.from(bY($).entries()).map(([Z,T])=>{if(typeof Z==="string"){let f=this.aliases[Z];if(f){let j=new f(O);return()=>j.run.call(j,...T)}}else{if(uO(Z)){let f=new Z(O);return f.run.bind(f)}return Z}}).filter(Boolean).reduce((Z,T)=>{return async()=>{return{...await Z(),...await T()}}},()=>Promise.resolve({}))()}}function EC($){return $}function T4(){return{onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{}}}function f4(){return{partialRendering:!0,onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{},onStreamComplete:()=>{}}}function wY($){return"run"in $}function vY($){return Object.hasOwn($,"get")||Object.hasOwn($,"post")||Object.hasOwn($,"put")||Object.hasOwn($,"delete")}function gY($){return Object.hasOwn($,"first")&&Object.hasOwn($,"second")}function RY($){if("__brand"in $)return $.__brand==="ApiRouter";return!1}function kY($){if("__internal_brand"in $)return $.__internal_brand==="ProxyHandler";return!1}function mY($){if("__internal_brand"in $)return $.__internal_brand==="StreamHandler";return!1}function wj($,O="",Z=[]){let T={};function f(j,W,z,J,Y){let X=j==="/"?"":j,C=O==="/"?"":O,F=(`${C}${X}`===""?"/":`${C}${X}`).replaceAll("//","/");if(!T[F])T[F]={};T[F][W.toUpperCase()]={exec:z,middleware:[...Z,...J],...Y?{source:Y}:{}},T[F].OPTIONS={exec:()=>{let D=new A().ctx().headers;return new Response(null,{headers:D,status:204})},middleware:[]}}for(let[j,W]of Object.entries($)){if(kY(W)){let z=W;for(let J of["GET","POST","PUT","DELETE"])f(j,J,z.run.bind(z),[]);continue}if(wY(W)){let z=W,J=z.method,Y=z.middlewares,X=z.run.bind(z);if(f(j,J,X,Y,z.source),mY(W))f(j,"HEAD",X,Y,z.source)}if(vY(W))for(let[z,J]of Object.entries(W)){let Y=J.middlewares,X=J.run.bind(J);f(j,z,X,Y,J.source)}if(RY(W)){let z=new W,J=wj(z.routes,`${O}${j}`,z.middlewares);for(let[Y,X]of Object.entries(J))T[Y.replaceAll("//","/")]=X}if(gY(W)){let{first:z,second:J}=W;for(let[Y,X]of Object.entries(z)){let C=X.middlewares,F=X.run.bind(X),[U,...D]=j.split("/").reverse();if(!U.startsWith(":"))throw Error("Resource route must end with a dynamic segment");f(D.reverse().join("/"),Y,F,C,X.source)}for(let[Y,X]of Object.entries(J)){let C=X.middlewares,F=X.run.bind(X);f(j,Y,F,C,X.source)}}}return Object.fromEntries(Object.entries(T).sort(([j],[W])=>{let z=j.split("/").length+j.split(":").length,J=W.split("/").length+W.split(":").length;return z-J}))}function C3($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function vj($,O){if($==="/")return O;if(O==="/")return $;return`${$}${O}`}function gj($){let O=C3($);return O.length>1?O.replace(/\/$/,""):O}function j4($,O){return O.map((Z)=>({...Z,path:gj(vj($,Z.path))}))}function D3($){let O={};for(let[Z,T]of Object.entries($))if("run"in T){let f=T;if("children"in f){let j=new f.children,W=D3(j.routes);for(let[z,{exec:J,middleware:Y,segments:X,features:C}]of Object.entries(W)){let F=vj(Z,z),U=(D)=>f.run.call(f,D,Z);O[C3(F)]={exec:[U,...J],middleware:[...f.middlewares,...Y],features:[...f.featureGates,...C],viewPath:f.viewPath,segments:[{path:gj(Z),viewPath:f.viewPath,...f.alwaysRuns?{alwaysRun:!0}:{}},...j4(Z,X)]}}}else{let j=(W)=>f.run.call(f,W,Z);O[C3(Z)]={exec:[j],middleware:f.middlewares,features:f.featureGates,viewPath:f.viewPath,segments:[{path:gj(Z),viewPath:f.viewPath}]}}}else{let f=new T,j=D3(f.routes);for(let[W,{exec:z,middleware:J,viewPath:Y,segments:X,features:C}]of Object.entries(j)){let F=vj(Z,W);O[C3(F)]={exec:z,middleware:[...f.middlewares,...J],features:[...f.featureGates,...C],viewPath:Y,segments:j4(Z,X)}}}return Object.fromEntries(Object.entries(O).sort(([Z],[T])=>{let f=Z.split("/").length+Z.split(":").length,j=T.split("/").length+T.split(":").length;return f-j}))}var qY=Object.defineProperty,M=($,O)=>qY($,"name",{value:O,configurable:!0}),i$=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor($,O,Z,T,f,j){this.type=$,this.name=O,this.prefix=Z,this.value=T,this.suffix=f,this.modifier=j}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};M(i$,"Part");var yY=/[$_\p{ID_Start}]/u,pY=/[$_\u200C\u200D\p{ID_Continue}]/u,kj=".*";function W4($,O){return(O?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test($)}M(W4,"isASCII");function yj($,O=!1){let Z=[],T=0;for(;T<$.length;){let f=$[T],j=M(function(W){if(!O)throw TypeError(W);Z.push({type:"INVALID_CHAR",index:T,value:$[T++]})},"ErrorOrInvalid");if(f==="*"){Z.push({type:"ASTERISK",index:T,value:$[T++]});continue}if(f==="+"||f==="?"){Z.push({type:"OTHER_MODIFIER",index:T,value:$[T++]});continue}if(f==="\\"){Z.push({type:"ESCAPED_CHAR",index:T++,value:$[T++]});continue}if(f==="{"){Z.push({type:"OPEN",index:T,value:$[T++]});continue}if(f==="}"){Z.push({type:"CLOSE",index:T,value:$[T++]});continue}if(f===":"){let W="",z=T+1;for(;z<$.length;){let J=$.substr(z,1);if(z===T+1&&yY.test(J)||z!==T+1&&pY.test(J)){W+=$[z++];continue}break}if(!W){j(`Missing parameter name at ${T}`);continue}Z.push({type:"NAME",index:T,value:W}),T=z;continue}if(f==="("){let W=1,z="",J=T+1,Y=!1;if($[J]==="?"){j(`Pattern cannot start with "?" at ${J}`);continue}for(;J<$.length;){if(!W4($[J],!1)){j(`Invalid character '${$[J]}' at ${J}.`),Y=!0;break}if($[J]==="\\"){z+=$[J++]+$[J++];continue}if($[J]===")"){if(W--,W===0){J++;break}}else if($[J]==="("&&(W++,$[J+1]!=="?")){j(`Capturing groups are not allowed at ${J}`),Y=!0;break}z+=$[J++]}if(Y)continue;if(W){j(`Unbalanced pattern at ${T}`);continue}if(!z){j(`Missing pattern at ${T}`);continue}Z.push({type:"REGEX",index:T,value:z}),T=J;continue}Z.push({type:"CHAR",index:T,value:$[T++]})}return Z.push({type:"END",index:T,value:""}),Z}M(yj,"lexer");function pj($,O={}){let Z=yj($);O.delimiter??="/#?",O.prefixes??="./";let T=`[^${b0(O.delimiter)}]+?`,f=[],j=0,W=0,z="",J=new Set,Y=M((V)=>{if(W<Z.length&&Z[W].type===V)return Z[W++].value},"tryConsume"),X=M(()=>Y("OTHER_MODIFIER")??Y("ASTERISK"),"tryConsumeModifier"),C=M((V)=>{let x=Y(V);if(x!==void 0)return x;let{type:_,index:L}=Z[W];throw TypeError(`Unexpected ${_} at ${L}, expected ${V}`)},"mustConsume"),F=M(()=>{let V="",x;for(;x=Y("CHAR")??Y("ESCAPED_CHAR");)V+=x;return V},"consumeText"),U=M((V)=>V,"DefaultEncodePart"),D=O.encodePart||U,G="",B=M((V)=>{G+=V},"appendToPendingFixedValue"),Q=M(()=>{G.length&&(f.push(new i$(3,"","",D(G),"",3)),G="")},"maybeAddPartFromPendingFixedValue"),I=M((V,x,_,L,S)=>{let E=3;switch(S){case"?":E=1;break;case"*":E=0;break;case"+":E=2;break}if(!x&&!_&&E===3){B(V);return}if(Q(),!x&&!_){if(!V)return;f.push(new i$(3,"","",D(V),"",E));return}let P;_?_==="*"?P=kj:P=_:P=T;let Z0=2;P===T?(Z0=1,P=""):P===kj&&(Z0=0,P="");let g;if(x?g=x:_&&(g=j++),J.has(g))throw TypeError(`Duplicate name '${g}'.`);J.add(g),f.push(new i$(Z0,g,D(V),P,D(L),E))},"addPart");for(;W<Z.length;){let V=Y("CHAR"),x=Y("NAME"),_=Y("REGEX");if(!x&&!_&&(_=Y("ASTERISK")),x||_){let S=V??"";O.prefixes.indexOf(S)===-1&&(B(S),S=""),Q();let E=X();I(S,x,_,"",E);continue}let L=V??Y("ESCAPED_CHAR");if(L){B(L);continue}if(Y("OPEN")){let S=F(),E=Y("NAME"),P=Y("REGEX");!E&&!P&&(P=Y("ASTERISK"));let Z0=F();C("CLOSE");let g=X();I(S,E,P,Z0,g);continue}Q(),C("END")}return f}M(pj,"parse");function b0($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}M(b0,"escapeString");function mj($){return $&&$.ignoreCase?"ui":"u"}M(mj,"flags");function z4($,O,Z){return cj(pj($,Z),O,Z)}M(z4,"stringToRegexp");function f$($){switch($){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}M(f$,"modifierToString");function cj($,O,Z={}){Z.delimiter??="/#?",Z.prefixes??="./",Z.sensitive??=!1,Z.strict??=!1,Z.end??=!0,Z.start??=!0,Z.endsWith="";let T=Z.start?"^":"";for(let z of $){if(z.type===3){z.modifier===3?T+=b0(z.value):T+=`(?:${b0(z.value)})${f$(z.modifier)}`;continue}O&&O.push(z.name);let J=`[^${b0(Z.delimiter)}]+?`,Y=z.value;if(z.type===1?Y=J:z.type===0&&(Y=kj),!z.prefix.length&&!z.suffix.length){z.modifier===3||z.modifier===1?T+=`(${Y})${f$(z.modifier)}`:T+=`((?:${Y})${f$(z.modifier)})`;continue}if(z.modifier===3||z.modifier===1){T+=`(?:${b0(z.prefix)}(${Y})${b0(z.suffix)})`,T+=f$(z.modifier);continue}T+=`(?:${b0(z.prefix)}`,T+=`((?:${Y})(?:`,T+=b0(z.suffix),T+=b0(z.prefix),T+=`(?:${Y}))*)${b0(z.suffix)})`,z.modifier===0&&(T+="?")}let f=`[${b0(Z.endsWith)}]|$`,j=`[${b0(Z.delimiter)}]`;if(Z.end)return Z.strict||(T+=`${j}?`),Z.endsWith.length?T+=`(?=${f})`:T+="$",new RegExp(T,mj(Z));Z.strict||(T+=`(?:${j}(?=${f}))?`);let W=!1;if($.length){let z=$[$.length-1];z.type===3&&z.modifier===3&&(W=Z.delimiter.indexOf(z)>-1)}return W||(T+=`(?=${j}|${f})`),new RegExp(T,mj(Z))}M(cj,"partsToRegexp");var g1={delimiter:"",prefixes:"",sensitive:!0,strict:!0},cY={delimiter:".",prefixes:"",sensitive:!0,strict:!0},iY={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function J4($,O){return $.length?$[0]==="/"?!0:!O||$.length<2?!1:($[0]=="\\"||$[0]=="{")&&$[1]=="/":!1}M(J4,"isAbsolutePathname");function ij($,O){return $.startsWith(O)?$.substring(O.length,$.length):$}M(ij,"maybeStripPrefix");function Y4($,O){return $.endsWith(O)?$.substr(0,$.length-O.length):$}M(Y4,"maybeStripSuffix");function hj($){return!$||$.length<2?!1:$[0]==="["||($[0]==="\\"||$[0]==="{")&&$[1]==="["}M(hj,"treatAsIPv6Hostname");var X4=["ftp","file","http","https","ws","wss"];function lj($){if(!$)return!0;for(let O of X4)if($.test(O))return!0;return!1}M(lj,"isSpecialScheme");function F4($,O){if($=ij($,"#"),O||$==="")return $;let Z=new URL("https://example.com");return Z.hash=$,Z.hash?Z.hash.substring(1,Z.hash.length):""}M(F4,"canonicalizeHash");function C4($,O){if($=ij($,"?"),O||$==="")return $;let Z=new URL("https://example.com");return Z.search=$,Z.search?Z.search.substring(1,Z.search.length):""}M(C4,"canonicalizeSearch");function D4($,O){return O||$===""?$:hj($)?sj($):uj($)}M(D4,"canonicalizeHostname");function U4($,O){if(O||$==="")return $;let Z=new URL("https://example.com");return Z.password=$,Z.password}M(U4,"canonicalizePassword");function G4($,O){if(O||$==="")return $;let Z=new URL("https://example.com");return Z.username=$,Z.username}M(G4,"canonicalizeUsername");function B4($,O,Z){if(Z||$==="")return $;if(O&&!X4.includes(O))return new URL(`${O}:${$}`).pathname;let T=$[0]=="/";return $=new URL(T?$:"/-"+$,"https://example.com").pathname,T||($=$.substring(2,$.length)),$}M(B4,"canonicalizePathname");function K4($,O,Z){return dj(O)===$&&($=""),Z||$===""?$:nj($)}M(K4,"canonicalizePort");function Q4($,O){return $=Y4($,":"),O||$===""?$:U3($)}M(Q4,"canonicalizeProtocol");function dj($){switch($){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}M(dj,"defaultPortForProtocol");function U3($){if($==="")return $;if(/^[-+.A-Za-z0-9]*$/.test($))return $.toLowerCase();throw TypeError(`Invalid protocol '${$}'.`)}M(U3,"protocolEncodeCallback");function V4($){if($==="")return $;let O=new URL("https://example.com");return O.username=$,O.username}M(V4,"usernameEncodeCallback");function L4($){if($==="")return $;let O=new URL("https://example.com");return O.password=$,O.password}M(L4,"passwordEncodeCallback");function uj($){if($==="")return $;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test($))throw TypeError(`Invalid hostname '${$}'`);let O=new URL("https://example.com");return O.hostname=$,O.hostname}M(uj,"hostnameEncodeCallback");function sj($){if($==="")return $;if(/[^0-9a-fA-F[\]:]/g.test($))throw TypeError(`Invalid IPv6 hostname '${$}'`);return $.toLowerCase()}M(sj,"ipv6HostnameEncodeCallback");function nj($){if($===""||/^[0-9]*$/.test($)&&parseInt($)<=65535)return $;throw TypeError(`Invalid port '${$}'.`)}M(nj,"portEncodeCallback");function I4($){if($==="")return $;let O=new URL("https://example.com");return O.pathname=$[0]!=="/"?"/-"+$:$,$[0]!=="/"?O.pathname.substring(2,O.pathname.length):O.pathname}M(I4,"standardURLPathnameEncodeCallback");function S4($){return $===""?$:new URL(`data:${$}`).pathname}M(S4,"pathURLPathnameEncodeCallback");function M4($){if($==="")return $;let O=new URL("https://example.com");return O.search=$,O.search.substring(1,O.search.length)}M(M4,"searchEncodeCallback");function N4($){if($==="")return $;let O=new URL("https://example.com");return O.hash=$,O.hash.substring(1,O.hash.length)}M(N4,"hashEncodeCallback");var x4=class{#j;#T=[];#O={};#$=0;#f=1;#Y=0;#z=0;#D=0;#U=0;#G=!1;constructor($){this.#j=$}get result(){return this.#O}parse(){for(this.#T=yj(this.#j,!0);this.#$<this.#T.length;this.#$+=this.#f){if(this.#f=1,this.#T[this.#$].type==="END"){if(this.#z===0){this.#V(),this.#X()?this.#Z(9,1):this.#F()?this.#Z(8,1):this.#Z(7,0);continue}else if(this.#z===2){this.#C(5);continue}this.#Z(10,0);break}if(this.#D>0)if(this.#A())this.#D-=1;else continue;if(this.#x()){this.#D+=1;continue}switch(this.#z){case 0:this.#L()&&this.#C(1);break;case 1:if(this.#L()){this.#P();let $=7,O=1;this.#S()?($=2,O=3):this.#G&&($=2),this.#Z($,O)}break;case 2:this.#K()?this.#C(3):(this.#Q()||this.#F()||this.#X())&&this.#C(5);break;case 3:this.#M()?this.#Z(4,1):this.#K()&&this.#Z(5,1);break;case 4:this.#K()&&this.#Z(5,1);break;case 5:this.#_()?this.#U+=1:this.#E()&&(this.#U-=1),this.#N()&&!this.#U?this.#Z(6,1):this.#Q()?this.#Z(7,0):this.#F()?this.#Z(8,1):this.#X()&&this.#Z(9,1);break;case 6:this.#Q()?this.#Z(7,0):this.#F()?this.#Z(8,1):this.#X()&&this.#Z(9,1);break;case 7:this.#F()?this.#Z(8,1):this.#X()&&this.#Z(9,1);break;case 8:this.#X()&&this.#Z(9,1);break;case 9:break;case 10:break}}this.#O.hostname!==void 0&&this.#O.port===void 0&&(this.#O.port="")}#Z($,O){switch(this.#z){case 0:break;case 1:this.#O.protocol=this.#J();break;case 2:break;case 3:this.#O.username=this.#J();break;case 4:this.#O.password=this.#J();break;case 5:this.#O.hostname=this.#J();break;case 6:this.#O.port=this.#J();break;case 7:this.#O.pathname=this.#J();break;case 8:this.#O.search=this.#J();break;case 9:this.#O.hash=this.#J();break;case 10:break}this.#z!==0&&$!==10&&([1,2,3,4].includes(this.#z)&&[6,7,8,9].includes($)&&(this.#O.hostname??=""),[1,2,3,4,5,6].includes(this.#z)&&[8,9].includes($)&&(this.#O.pathname??=this.#G?"/":""),[1,2,3,4,5,6,7].includes(this.#z)&&$===9&&(this.#O.search??="")),this.#I($,O)}#I($,O){this.#z=$,this.#Y=this.#$+O,this.#$+=O,this.#f=0}#V(){this.#$=this.#Y,this.#f=0}#C($){this.#V(),this.#z=$}#B($){return $<0&&($=this.#T.length-$),$<this.#T.length?this.#T[$]:this.#T[this.#T.length-1]}#W($,O){let Z=this.#B($);return Z.value===O&&(Z.type==="CHAR"||Z.type==="ESCAPED_CHAR"||Z.type==="INVALID_CHAR")}#L(){return this.#W(this.#$,":")}#S(){return this.#W(this.#$+1,"/")&&this.#W(this.#$+2,"/")}#K(){return this.#W(this.#$,"@")}#M(){return this.#W(this.#$,":")}#N(){return this.#W(this.#$,":")}#Q(){return this.#W(this.#$,"/")}#F(){if(this.#W(this.#$,"?"))return!0;if(this.#T[this.#$].value!=="?")return!1;let $=this.#B(this.#$-1);return $.type!=="NAME"&&$.type!=="REGEX"&&$.type!=="CLOSE"&&$.type!=="ASTERISK"}#X(){return this.#W(this.#$,"#")}#x(){return this.#T[this.#$].type=="OPEN"}#A(){return this.#T[this.#$].type=="CLOSE"}#_(){return this.#W(this.#$,"[")}#E(){return this.#W(this.#$,"]")}#J(){let $=this.#T[this.#$],O=this.#B(this.#Y).index;return this.#j.substring(O,$.index)}#P(){let $={};Object.assign($,g1),$.encodePart=U3;let O=z4(this.#J(),void 0,$);this.#G=lj(O)}};M(x4,"Parser");var Rj=["protocol","username","password","hostname","port","pathname","search","hash"],v1="*";function qj($,O){if(typeof $!="string")throw TypeError("parameter 1 is not of type 'string'.");let Z=new URL($,O);return{protocol:Z.protocol.substring(0,Z.protocol.length-1),username:Z.username,password:Z.password,hostname:Z.hostname,port:Z.port,pathname:Z.pathname,search:Z.search!==""?Z.search.substring(1,Z.search.length):void 0,hash:Z.hash!==""?Z.hash.substring(1,Z.hash.length):void 0}}M(qj,"extractValues");function O1($,O){return O?c$($):$}M(O1,"processBaseURLString");function p$($,O,Z){let T;if(typeof O.baseURL=="string")try{T=new URL(O.baseURL),O.protocol===void 0&&($.protocol=O1(T.protocol.substring(0,T.protocol.length-1),Z)),!Z&&O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.username===void 0&&($.username=O1(T.username,Z)),!Z&&O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.username===void 0&&O.password===void 0&&($.password=O1(T.password,Z)),O.protocol===void 0&&O.hostname===void 0&&($.hostname=O1(T.hostname,Z)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&($.port=O1(T.port,Z)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.pathname===void 0&&($.pathname=O1(T.pathname,Z)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.pathname===void 0&&O.search===void 0&&($.search=O1(T.search.substring(1,T.search.length),Z)),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(T.hash.substring(1,T.hash.length),Z))}catch{throw TypeError(`invalid baseURL '${O.baseURL}'.`)}if(typeof O.protocol=="string"&&($.protocol=Q4(O.protocol,Z)),typeof O.username=="string"&&($.username=G4(O.username,Z)),typeof O.password=="string"&&($.password=U4(O.password,Z)),typeof O.hostname=="string"&&($.hostname=D4(O.hostname,Z)),typeof O.port=="string"&&($.port=K4(O.port,$.protocol,Z)),typeof O.pathname=="string"){if($.pathname=O.pathname,T&&!J4($.pathname,Z)){let f=T.pathname.lastIndexOf("/");f>=0&&($.pathname=O1(T.pathname.substring(0,f+1),Z)+$.pathname)}$.pathname=B4($.pathname,$.protocol,Z)}return typeof O.search=="string"&&($.search=C4(O.search,Z)),typeof O.hash=="string"&&($.hash=F4(O.hash,Z)),$}M(p$,"applyInit");function c$($){return $.replace(/([+*?:{}()\\])/g,"\\$1")}M(c$,"escapePatternString");function A4($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}M(A4,"escapeRegexpString");function _4($,O){O.delimiter??="/#?",O.prefixes??="./",O.sensitive??=!1,O.strict??=!1,O.end??=!0,O.start??=!0,O.endsWith="";let Z=".*",T=`[^${A4(O.delimiter)}]+?`,f=/[$_\u200C\u200D\p{ID_Continue}]/u,j="";for(let W=0;W<$.length;++W){let z=$[W];if(z.type===3){if(z.modifier===3){j+=c$(z.value);continue}j+=`{${c$(z.value)}}${f$(z.modifier)}`;continue}let J=z.hasCustomName(),Y=!!z.suffix.length||!!z.prefix.length&&(z.prefix.length!==1||!O.prefixes.includes(z.prefix)),X=W>0?$[W-1]:null,C=W<$.length-1?$[W+1]:null;if(!Y&&J&&z.type===1&&z.modifier===3&&C&&!C.prefix.length&&!C.suffix.length)if(C.type===3){let F=C.value.length>0?C.value[0]:"";Y=f.test(F)}else Y=!C.hasCustomName();if(!Y&&!z.prefix.length&&X&&X.type===3){let F=X.value[X.value.length-1];Y=O.prefixes.includes(F)}Y&&(j+="{"),j+=c$(z.prefix),J&&(j+=`:${z.name}`),z.type===2?j+=`(${z.value})`:z.type===1?J||(j+=`(${T})`):z.type===0&&(!J&&(!X||X.type===3||X.modifier!==3||Y||z.prefix!=="")?j+="*":j+=`(${Z})`),z.type===1&&J&&z.suffix.length&&f.test(z.suffix[0])&&(j+="\\"),j+=c$(z.suffix),Y&&(j+="}"),z.modifier!==3&&(j+=f$(z.modifier))}return j}M(_4,"partsToPattern");var aj=class{#j;#T={};#O={};#$={};#f={};#Y=!1;constructor($={},O,Z){try{let T;if(typeof O=="string"?T=O:Z=O,typeof $=="string"){let z=new x4($);if(z.parse(),$=z.result,T===void 0&&typeof $.protocol!="string")throw TypeError("A base URL must be provided for a relative constructor string.");$.baseURL=T}else{if(!$||typeof $!="object")throw TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(T)throw TypeError("parameter 1 is not of type 'string'.")}typeof Z>"u"&&(Z={ignoreCase:!1});let f={ignoreCase:Z.ignoreCase===!0},j={pathname:v1,protocol:v1,username:v1,password:v1,hostname:v1,port:v1,search:v1,hash:v1};this.#j=p$(j,$,!0),dj(this.#j.protocol)===this.#j.port&&(this.#j.port="");let W;for(W of Rj){if(!(W in this.#j))continue;let z={},J=this.#j[W];switch(this.#O[W]=[],W){case"protocol":Object.assign(z,g1),z.encodePart=U3;break;case"username":Object.assign(z,g1),z.encodePart=V4;break;case"password":Object.assign(z,g1),z.encodePart=L4;break;case"hostname":Object.assign(z,cY),hj(J)?z.encodePart=sj:z.encodePart=uj;break;case"port":Object.assign(z,g1),z.encodePart=nj;break;case"pathname":lj(this.#T.protocol)?(Object.assign(z,iY,f),z.encodePart=I4):(Object.assign(z,g1,f),z.encodePart=S4);break;case"search":Object.assign(z,g1,f),z.encodePart=M4;break;case"hash":Object.assign(z,g1,f),z.encodePart=N4;break}try{this.#f[W]=pj(J,z),this.#T[W]=cj(this.#f[W],this.#O[W],z),this.#$[W]=_4(this.#f[W],z),this.#Y=this.#Y||this.#f[W].some((Y)=>Y.type===2)}catch{throw TypeError(`invalid ${W} pattern '${this.#j[W]}'.`)}}}catch(T){throw TypeError(`Failed to construct 'URLPattern': ${T.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test($={},O){let Z={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"?Z=p$(Z,$,!1):Z=p$(Z,qj($,O),!1)}catch{return!1}let T;for(T of Rj)if(!this.#T[T].exec(Z[T]))return!1;return!0}exec($={},O){let Z={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"?Z=p$(Z,$,!1):Z=p$(Z,qj($,O),!1)}catch{return null}let T={};O?T.inputs=[$,O]:T.inputs=[$];let f;for(f of Rj){let j=this.#T[f].exec(Z[f]);if(!j)return null;let W={};for(let[z,J]of this.#O[f].entries())if(typeof J=="string"||typeof J=="number"){let Y=j[z+1];W[J]=Y}T[f]={input:Z[f]??"",groups:W}}return T}static compareComponent($,O,Z){let T=M((z,J)=>{for(let Y of["type","modifier","prefix","value","suffix"]){if(z[Y]<J[Y])return-1;if(z[Y]===J[Y])continue;return 1}return 0},"comparePart"),f=new i$(3,"","","","",3),j=new i$(0,"","","","",3),W=M((z,J)=>{let Y=0;for(;Y<Math.min(z.length,J.length);++Y){let X=T(z[Y],J[Y]);if(X)return X}return z.length===J.length?0:T(z[Y]??f,J[Y]??f)},"comparePartList");return!O.#$[$]&&!Z.#$[$]?0:O.#$[$]&&!Z.#$[$]?W(O.#f[$],[j]):!O.#$[$]&&Z.#$[$]?W([j],Z.#f[$]):W(O.#f[$],Z.#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.#Y}};M(aj,"URLPattern");function mO($,O){for(let[Z,T]of Object.entries($)){let f=new aj({pathname:Z});if(f.test({pathname:O}))return{routePath:Z,params:f.exec({pathname:O})?.pathname.groups??{},route:T}}return null}var j$={startIndex:0,carriedViews:[]};function E4($,O){let Z=h($.path,O);return Z.includes("*")?null:Z}function hY($,O){if(!$)return j$;if($.search!==O.search)return j$;let Z=Math.min($.segments.length,O.segments.length-1),T=0;while(T<Z){let f=$.segments[T],j=O.segments[T];if(j.alwaysRun)break;if(f.viewPath!==j.viewPath)break;let W=E4(f,$.params),z=E4(j,O.params);if(W===null||z===null||W!==z)break;T++}if(T===0)return j$;return{startIndex:T,carriedViews:O.segments.slice(0,T).map(({viewPath:f})=>f)}}function lY($,O){let[,Z,...T]=$.split("/");if(!O.includes(Z))return $;let f=`/${T.join("/")}`;return f==="/"?"/":f.replace(/\/$/,"")}function P4($){let{flatViewRoutes:O,supportedLocales:Z,from:T,origin:f,to:j}=$;if(!T)return j$;let W;try{W=new URL(T,f)}catch{return j$}if(W.origin!==f)return j$;let z=mO(O,lY(W.pathname,Z));if(!z)return j$;return hY({segments:z.route.segments,params:z.params,search:W.search},j)}var oj="x-gemi-from";import{createElement as a$,Fragment as DX}from"react";function dY($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function G3($){let O={};for(let[Z,T]of Object.entries($))if("run"in T){let f=T.viewPath;if("children"in T){O[Z]=[f];let j=new T.children,W=G3(j.routes);for(let[z,J]of Object.entries(W)){let Y=Z==="/"?z:`${Z}${z}`,X=z==="/"&&Z!=="/"?Z:Y;O[X]=[f,...J]}if(O[Z].length===1)delete O[Z]}else O[Z]=[f]}else{let f=new T,j=G3(f.routes);for(let[W,z]of Object.entries(j)){let J=Z==="/"?W:`${Z}${W}`,Y=W==="/"&&Z!=="/"?Z:J;O[Y]=z}}return Object.fromEntries(Object.entries(O).map(([Z,T])=>[dY(Z),T]))}function B3($){let O=[];for(let[Z,T]of Object.entries($))if("run"in T){let f=T.viewPath;if(f==="__")continue;if(f==="REDIRECT")continue;if(f==="FILE")continue;if("children"in T){let j=new T.children,W=B3(j.routes);O.push([f,W])}else O.push([f,[]])}else{let f=new T,j=B3(f.routes);O.push(...j)}return O}function rj($){let O=[];for(let[Z,T]of $)O.push(Z,...rj(T).flat());return Array.from(new Set(O))}class R1 extends O0{static getFacadeAccessor(){return RO}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 h$ extends O0{static getFacadeAccessor(){return n}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($=h$.locale()){let O=this.getFacadeRoot(),Z=$;if(!O.supportedLocales.includes($))Z=O.defaultLocale;let T=N.getStore();return T.setCookie("i18n-locale",Z,{expires:new Date(Date.now()+31536000000),secure:!1,httpOnly:!1}),T.setLocale(Z),Z}}class tj{id;static token="kernel.id";constructor($=crypto.randomUUID()){this.id=$}}var uY=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),sY=new Set(["svg","math"]);function H4($){return $===32||$===9||$===10||$===12||$===13}function b4($){return $>=65&&$<=90||$>=97&&$<=122}function K3($){return $>=65&&$<=90?$+32:$}function w4(){let $="data",O="",Z=!1,T="",f=0,j=0,W=!1,z=0,J=0,Y=()=>$==="data"&&z===0&&J===0,X=()=>{if(!Z&&uY.has(O)){$="rawText",T=`</${O}`,f=0,O="";return}if($="data",O==="template")if(Z)z=Math.max(0,z-1);else z+=1;else if(sY.has(O)){if(Z)J=Math.max(0,J-1);else if(!W)J+=1}O=""},C=(F)=>{switch($){case"data":if(F===60)$="tagOpen";return;case"tagOpen":if(F===33)$="bang",j=0;else if(F===47)$="endTagOpen";else if(b4(F))$="tagName",Z=!1,W=!1,O=String.fromCharCode(K3(F));else if(F===63)$="bogus";else if(F===60)$="tagOpen";else $="data";return;case"endTagOpen":if(b4(F))$="tagName",Z=!0,W=!1,O=String.fromCharCode(K3(F));else if(F===62)$="data";else $="bogus";return;case"tagName":if(H4(F)||F===47)$="inTag",W=F===47;else if(F===62)X();else O+=String.fromCharCode(K3(F));return;case"inTag":if(F===62){X();return}if(W=F===47,F===34)$="attrDouble";else if(F===39)$="attrSingle";return;case"attrDouble":if(F===34)$="inTag";W=!1;return;case"attrSingle":if(F===39)$="inTag";W=!1;return;case"bang":if(F===45){if(j+=1,j===2)$="comment",j=0}else if(F===62)$="data";else $="bogus";return;case"bogus":if(F===62)$="data";return;case"comment":if(F===45)j=j<2?j+1:2;else if(F===62&&j>=2)$="data",j=0;else j=0;return;case"rawText":{if(f<T.length){if(K3(F)===T.charCodeAt(f))f+=1;else f=F===60?1:0;return}if(F===62)$="data",O="";else if(H4(F)||F===47)$="inTag",O="";else f=F===60?1:0;return}}};return{scanToInsertionPoint(F){for(let U=0;U<F.length;U++){if(Y())return U;C(F[U])}return F.length},write(F){for(let U=0;U<F.length;U++)C(F[U])},isSafe:Y}}function W$($){let O=JSON.stringify($);if(O===void 0)return"undefined";return O.replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function nY($){return`<script>(self.__GEMI_STREAM__=self.__GEMI_STREAM__||[]).push(${W$([$.path,$.variantKey,$.data])})</script>`}function aY($){return`<script>(self.__GEMI_DICT__=self.__GEMI_DICT__||[]).push(${W$([$.id,$.locale,$.strings])})</script>`}function ej($,O,Z={},T){let f=new TextEncoder,j=[],W=!1,z=!1,J=()=>{if(z)return;z=!0,Z.onClose?.()};O.onSettle((D)=>{if(D.status!=="resolved")return;j.push(nY(D))}),T?.onUse((D)=>{j.push(aY(D))});let Y=$.getReader(),X=w4(),C=(D,G)=>{D.enqueue(G),Z.onChunk?.(G)},F=(D)=>{while(j.length>0){let G=f.encode(j.shift());X.write(G),C(D,G)}},U=(D,G)=>{if(j.length===0){X.write(G),C(D,G);return}let B=X.scanToInsertionPoint(G);if(B>0)C(D,G.subarray(0,B));if(X.isSafe())F(D);let Q=G.subarray(B);if(Q.length>0)X.write(Q),C(D,Q)};return new ReadableStream({async pull(D){let G;try{G=await Y.read()}catch(I){throw J(),I}let{done:B,value:Q}=G;if(B){F(D),D.close(),J();return}if(!W){if(W=!0,X.write(Q),C(D,Q),Z.onShell?.(),X.isSafe())F(D);return}U(D,Q)},cancel(D){return J(),Y.cancel(D)}})}var oY=/bot|crawler|spider|crawling|slurp|bingpreview|mediapartners|headless|lighthouse|prerender|facebookexternalhit|whatsapp|telegram|discord|twitterbot|linkedinbot/i;function Q3($){if(!$)return!1;return oY.test($)}async function g4($,O=()=>{}){let Z=N.getStore(),T=Z?.req??null,f=null;if(T?.rawRequest?.url)try{f=new URL(T.rawRequest.url).pathname}catch{f=null}return{user:Z?.user??null,attributes:await rY($,O),request:{path:f,routePath:T?.routePath??null,locale:Z?.locale??null},anonymousId:v4(),isBot:Q3(T?.rawRequest?.headers?.get("user-agent")??null),now:new Date}}function R4($){return{user:$.user??null,attributes:$.attributes??{},request:{path:null,routePath:null,locale:null},anonymousId:$.subjectId??null,isBot:!1,now:new Date}}async function rY($,O){if(!$.context)return{};try{let Z=N.getStore();return await $.context(Z?.req??null)??{}}catch(Z){return O(`The \`context\` hook in app/config/features.ts threw; evaluating with no attributes. ${Z instanceof Error?Z.message:String(Z)}`),{}}}function k4($,O){return`${$}:${O}`}function $W($){let O=new Bun.CryptoHasher("sha1").update($).digest("hex"),Z=Number.parseInt(O.slice(0,8),16);return Math.floor(Z/4294967296*1e4)}function m4($,O){if(O>=100)return!0;if(O<=0)return!1;return $<Math.round(O*100)}function q4($,O,Z,T){if(T.unavailable)return{value:!1,reason:"unavailable"};if(T.active!==!0)return{value:!1,reason:"inactive"};if(O.when){let j;try{j=O.when(Z)}catch(W){return T.warn?.(`The \`when\` for feature "${$}" threw; treating it as off. ${W instanceof Error?W.message:String(W)}`),{value:!1,reason:"error"}}if(typeof j==="boolean")return{value:j,reason:"attributed"}}if(O.rollout===void 0)return{value:!0,reason:"on"};if(Z.isBot)return{value:!1,reason:"bot"};let f=eY($,O,Z,T.buckets);return m4(f,O.rollout)?{value:!0,reason:"rollout"}:{value:!1,reason:"excluded"}}function tY($){let O=$.user?.publicId??$.user?.id;if(O!==void 0&&O!==null)return String(O);return $.anonymousId??""}function eY($,O,Z,T){let f=k4(O.salt??$,tY(Z));if(!T)return $W(f);let j=T.get(f);if(j!==void 0)return j;let W=$W(f);return T.set(f,W),W}class y4 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 OW{source;declared;ttlMs;warn;snapshot=null;inflight=null;lastFailureLoggedAt=0;generation=0;lastError=null;retryAfter=0;constructor($,O,Z,T=()=>{}){this.source=$;this.declared=O;this.ttlMs=Z;this.warn=T}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 y4(this.lastError);return O}peek(){return this.snapshot}async load(){try{let $=await this.source.load(),{active:O,audit:Z}=this.readRows($);return this.snapshot={active:O,audit:Z,loadedAt:Date.now(),unavailable:!1},this.generation++,this.lastError=null,this.retryAfter=0,this.snapshot}catch($){return this.handleFailure($)}}readRows($){let O=new Map,Z=new Map;for(let T of $??[]){let f=typeof T?.key==="string"?T.key:null;if(!f){this.warn("Ignoring a feature row with no `key`.");continue}if(!(f in this.declared)){this.warn(`Feature row "${f}" is not declared in app/features, so it is ignored. Delete the row, or declare the feature.`);continue}O.set(f,T.active===!0);let j=$X(T);if(j)Z.set(f,j)}return{active:O,audit:Z}}handleFailure($){let O=$ instanceof Error?$.message:String($),Z=Date.now();if(this.lastError=$,this.retryAfter=Z+this.ttlMs,Z-this.lastFailureLoggedAt>=this.ttlMs)this.lastFailureLoggedAt=Z,this.warn(`Could not load feature switches: ${O}`);if(this.snapshot)return this.snapshot;return this.snapshot={active:new Map,audit:new Map,loadedAt:Z,unavailable:!0},this.snapshot}}function $X($){let O={},Z=$.updatedBy;if(typeof Z==="string")O.updatedBy=Z;else if(Z===null)O.updatedBy=null;let T=$.updatedAt;if(T instanceof Date||typeof T==="string"||typeof T==="number"){let f=T instanceof Date?T:new Date(T);if(!Number.isNaN(f.getTime()))O.updatedAt=f}return"updatedBy"in O||"updatedAt"in O?O:null}class OX{}class ZX extends Error{modelName;kind="FeatureModelMissing";constructor($){super(`No "${$}" model is registered, so every feature stays off. Add the model to prisma/schema.prisma and export it from app/models \u2014 see docs/feature-flags.md.`);this.modelName=$}}class ZW extends Error{sourceName;kind="FeatureSourceReadOnly";constructor($){super(`The feature source (${$}) is read-only, so Features.set() cannot write to it. Change the switch where that source reads from, or give the source a write() method.`);this.sourceName=$}}class p4 extends Error{key;kind="UndeclaredFeature";constructor($){super(`"${$}" is not declared in app/features, so it cannot be switched. A row for it would be ignored \u2014 declare the feature first.`);this.key=$}}class c4{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 l${config;log;static token="features";store;declared;warnedAboutSize=!1;warnedAboutActor=!1;constructor($,O=()=>{}){this.config=$;this.log=O;this.declared=$.features??{},this.store=new OW($.source,this.declared,Math.max(0,$.ttl)*1000,this.log)}declarations(){return this.declared}async list(){let{active:$,audit:O,unavailable:Z}=await this.switches();return{unavailable:Z,features:Object.entries(this.declared).map(([T,f])=>({key:T,describe:f.describe,rollout:f.rollout,targeted:f.when!==void 0,serverOnly:f.serverOnly,salt:f.salt,active:$.get(T),...O.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 set($,O,Z={}){if(typeof $!=="string"||!Object.hasOwn(this.declared,$))throw new p4(String($));if(typeof O!=="boolean")throw TypeError(`Features.set("${$}", \u2026) takes a boolean, not ${O===null?"null":typeof O}.`);let T=TX(Z.actor),f=this.config.source;if(typeof f.write!=="function")throw new ZW(f.constructor?.name||"an anonymous source");let{actorRecorded:j}=await f.write($,O,{actor:T});if(T!==null&&!j&&!this.warnedAboutActor)this.warnedAboutActor=!0,this.log('Features.set() was given an actor, but the feature source has nowhere to record it. For the database source, add a nullable `updatedBy String?` column to the feature flag model to keep "last changed by".');await this.invalidate()}async enabled($){return(await this.explain($)).value}async explain($){let 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 c4(this,R4($))}async evaluateIn($,O,Z){let T=this.memoFor(O),f=T?.get($);if(f)return f;let j=this.declared[$];if(!j)return{value:!1,reason:"undeclared"};let{active:W,unavailable:z}=await this.switchFor($),J=q4($,j,O,{active:W,unavailable:z,buckets:Z,warn:this.log});return T?.set($,J),this.notify($,J,O),J}async evaluateAllIn($,O,Z){let T={};for(let[f,j]of Object.entries(this.declared)){if(Z.clientOnly&&j.serverOnly)continue;T[f]=(await this.evaluateIn(f,$,O)).value}return T}async switches(){if(!this.config.enabled||Object.keys(this.declared).length===0)return{active:new Map,audit:new Map,unavailable:!1};let $=await this.store.get();return{active:$.active,audit:$.audit,unavailable:$.unavailable}}async switchFor($){if(!this.config.enabled)return{active:!1,unavailable:!1};let 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 g4(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,Z){if(!this.config.onEvaluate)return;try{this.config.onEvaluate($,O,Z)}catch(T){this.log(`The \`onEvaluate\` hook in app/config/features.ts threw for "${$}". ${T instanceof Error?T.message:String(T)}`)}}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 TX($){if($===void 0||$===null)return null;if(typeof $==="string"){if($.length>0)return $}else if(typeof $==="object"){let{publicId:O,id:Z}=$;if(typeof O==="string"&&O.length>0)return O;if(typeof Z==="string"&&Z.length>0||typeof Z==="number")return String(Z)}throw TypeError("Features.set() was given an `actor` that identifies nobody. Pass a string, or a user with a `publicId` or an `id`.")}function i4($){return Object.fromEntries(Object.entries($).filter(([,O])=>{return O!==null&&O!==void 0}))}var fX=50;class d${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((Z)=>Z.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(),(Z)=>({path:Z.path,variantKey:Z.variantKey,startedAt:Z.startedAt,settledAt:Z.settledAt,status:Z.status,source:Z.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 Z=($.settledAt??0)-$.startedAt,T=$.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 (${Z}ms, resolved ${O}) could not overlap the others. It still streamed. If the query belongs on this route, \`Query.prefetch("${$.patternPath}"${T})\` 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={},Z="render"){let T=O.params??{},f=new URLSearchParams(i4(O.search??{}));f.delete("json"),f.sort();let j=h($,T),W=f.toString(),z=this.keyFor(j,W),J=this.entries.get(z);if(J)return J;let Y;if(Z==="render"&&this.renderStartedAt!==null){let U=Math.round(performance.now()-this.renderStartedAt);if(U>fX)Y=U}let X,C=new Promise((U)=>{X=U}),F={path:j,patternPath:$,variantKey:W,lateBy:Y,status:"pending",promise:C,source:Z,startedAt:this.elapsed()};return this.entries.set(z,F),this.fetcher($,T,f).then((U)=>{F.status="resolved",F.data=U},(U)=>{F.status="rejected",F.error=U}).then(()=>{if(F.settledAt=this.elapsed(),this.maybeLogLateDiscovery(F),F.status==="rejected"&&this.failListener)this.failListener(F);if(this.settleListener)this.settleListener(F);else this.settledBacklog.push(F);X()}),F}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,Z]of this.entries){if(Z.status!=="resolved")continue;this.shipped.add(O),$[Z.path]??={},$[Z.path][Z.variantKey]=Z.data}return $}onSettle($){this.settleListener=(Z)=>{if(this.shipped.has(this.keyFor(Z.path,Z.variantKey)))return;$(Z)};let O=this.settledBacklog;this.settledBacklog=[];for(let Z of O)this.settleListener(Z)}}class k1 extends Error{path;variantKey;status;body;retryAfter;constructor($,O,Z,T,f){super(typeof T?.message==="string"?T.message:`Request to /api${$} failed with status ${Z}`);this.path=$;this.variantKey=O;this.status=Z;this.body=T;this.retryAfter=f;this.name="QueryError"}}function u$(){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 TW(){return{status:403,error:{message:"Forbidden"}}}function qO($){let O=s$.getStore();return(Z,T,f)=>{let j=new URL($.url).origin,W=[h(Z,T),f.toString()].filter((X)=>X.length>0).join("?"),z=new Request(`${j}/${W}`,{headers:$.headers}),J=h4($);if(J)n$(z,J);let Y=new A(z,T);return s$.run(O,()=>N.run(Y,async()=>{try{let X=await K(s0).dispatchers(J).api.getRouteData(Z);if(C$(X)){if(!X.ok)throw new k1(h(Z,T),f.toString(),X.status,X.body);return X.body}if(X instanceof Response){let C=await X.json().catch(()=>null);if(!X.ok)throw new k1(h(Z,T),f.toString(),X.status,C);return C}return X}catch(X){if(X instanceof k1)throw X;let C=new k1(h(Z,T),f.toString(),500,{message:X instanceof Error?X.message:String(X)});throw C.cause=X,C}}))}}var jX=new Set(["script","style","template","title"]),WX=/\shidden([\s=/]|$)/i,zX=/"[^"]*"|'[^']*'/g;function JX($){let O=0,Z=0,T=0,f=0;while(f<$.length){let j=$.indexOf("<",f),W=j===-1?$.length:j;if(W>f){let C=$.slice(f,W).replace(/\s+/g,"").length;if(T>0)Z+=C;else O+=C}if(j===-1)break;if($.startsWith("<!--",j)){let C=$.indexOf("-->",j+4);f=C===-1?$.length:C+3;continue}let z=$.indexOf(">",j);if(z===-1)break;let J=$.slice(j+1,z);f=z+1;let Y=/^\/?([a-zA-Z][a-zA-Z0-9-]*)/.exec(J)?.[1]?.toLowerCase();if(!Y)continue;let X=J.startsWith("/");if(!X&&jX.has(Y)&&!J.endsWith("/")){let C=$.indexOf(`</${Y}`,f);f=C===-1?$.length:C;continue}if(Y!=="div")continue;if(X){if(T>0)T-=1}else if(T>0)T+=1;else if(WX.test(J.replace(zX,'""')))T=1}return{shellChars:O,deferredChars:Z}}var YX=1000,XX=64;function FX($){return $>=1000?`${($/1000).toFixed(1)} kB`:`${$} chars`}function CX($,O){if(O.deferredChars<YX)return null;if(O.shellChars>=XX)return null;return`[gemi] GET ${$} streams ${FX(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 l4($=console.warn){let O=new Set;return{shouldObserve(Z){return!O.has(Z)},report(Z,T){if(O.has(Z))return;let f=CX(Z,T);if(!f)return;O.add(Z),$(f)}}}function d4(){let $=new TextDecoder,O="";return{onChunk(Z){O+=$.decode(Z,{stream:!0})},measure(){return O+=$.decode(),JX(O)}}}function u4($,O,Z=1e4,T){let f=new TextEncoder,j=()=>{};return new ReadableStream({start(W){let z=!1,J=(X)=>{if(z)return;z=!0,clearTimeout(Y);try{W.close()}catch{}T?.({aborted:X})};j=J,W.enqueue(f.encode(`${JSON.stringify($)}
5
+ `)),O.onSettle((X)=>{if(z||X.status!=="resolved")return;W.enqueue(f.encode(`${JSON.stringify([X.path,X.variantKey,X.data])}
6
+ `))});let Y=setTimeout(()=>J(!0),Z);O.allSettled().then(()=>J(!1),()=>J(!1))},cancel(){j(!1)}})}var UX=async()=>(await import("./chunk-443yr2km.js")).default,fW,jW=async(...$)=>{return fW??=import("react-dom/server.browser").catch((O)=>{throw fW=void 0,O}),(await fW).renderToReadableStream(...$)},GX=1e4,BX=`
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 KX($,O,Z){let T=`${Z==="italic"?"italic,":""}wght@${Z==="italic"?"1,":""}${O}`,W=(await(await fetch(`https://fonts.googleapis.com/css2?family=${$}:${T}&display=swap`,{headers:{"User-Agent":"Mozilla/5.0 Firefox/1.0"}})).text()).match(/url\(([^)]+)\)/)?.[1];return await fetch(W).then((z)=>z.arrayBuffer())}var JW="/assets";function QX($){return $===JW||$.startsWith(`${JW}/`)}function VX($){let O=$.filter(QX);if(O.length>0){let Z=O.length>1;throw Error(`View route path${Z?"s":""} ${O.map((T)=>`"${T}"`).join(", ")} use${Z?"":"s"} the reserved "${JW}" prefix. The client build output is served from there before the router runs, so the route would never match. Mount it somewhere else.`)}}function LX($){let O=K(s0).resolver;return{...$.domain,root:O.root,origin:O.publicOrigin($.rawRequest)}}function WW($){let{status:O=400,error:Z}=$;return new Response(Z?.message,{...$,status:O})}function IX($){let{status:O=400,data:Z,directive:T,headers:f}=$;return new Response(JSON.stringify({data:Z,directive:T}),{headers:f,status:O})}class cO{static token="router.view";flatViewRoutes={};routeManifest={};clientRouteManifest={};componentTree=[];flatComponentTree=[];root=null;shellReporter=l4();preloadCache=new WeakMap;hooks;partialRendering;constructor($){let O=f4();this.partialRendering=$.partialRendering??O.partialRendering,this.hooks={onRequestStart:$.onRequestStart??O.onRequestStart,onRequestEnd:$.onRequestEnd??O.onRequestEnd,onRequestFail:$.onRequestFail??O.onRequestFail,onStreamComplete:$.onStreamComplete??O.onStreamComplete};let Z={"/":$.rootRouter,"/auth":Sj};this.flatViewRoutes=D3(Z),VX(Object.keys(this.flatViewRoutes)),this.routeManifest=G3(Z),this.clientRouteManifest=Object.fromEntries(Object.entries(this.routeManifest).filter(([,T])=>T.at(-1)!=="FILE")),this.componentTree=B3(Z),this.flatComponentTree=rj(this.componentTree),this.root=$.root}async passesFeatureGates($){let O=K(l$);for(let Z of $)if(!await O.enabled(Z))return!1;return!0}async onRequestEnd($){return zW(),await this.hooks.onRequestEnd($)}completeStream($,O){let Z=(T)=>{R1.error(T?.message??'Error in "onStreamComplete" event handler',{err:JSON.stringify(T)})};try{Promise.resolve(this.hooks.onStreamComplete($,O)).catch(Z)}catch(T){Z(T)}}modulePreloadLinks($){let{clientEntry:O,modulePreloadManifest:Z,views:T,routeKey:f}=$,j=()=>{let J=new Set(O?.preload??[]);for(let Y of T)for(let X of Z?.[Y]??[])J.add(X);return[...J].map((Y)=>a$("link",{key:`modulepreload:${Y}`,rel:"modulepreload",href:Y}))};if(!Z)return j();let W=this.preloadCache.get(Z);if(!W||W.clientEntry!==O)W={clientEntry:O,byRoute:new Map},this.preloadCache.set(Z,W);let z=W.byRoute.get(f);if(!z)z=j(),W.byRoute.set(f,z);return z}async render($){let{req:O,runInRequestScope:Z,csrfTokenHMAC:T,currentPathName:f,headers:j,i18n:W,params:z,pathname:J,serverQueries:Y,userAgent:X,noStream:C,url:F,user:U,viewData:D,breadcrumbs:G,urlLocaleSegment:B,meta:Q,isOgRequest:I,appId:V,features:x}=$,_=J.replace(`/${B}`,""),L={kind:"view",data:{meta:Q,pageData:{[_]:D},__csrf:T.toString("base64"),prefetchedData:{},i18n:W,auth:{user:U},routeManifest:this.clientRouteManifest,breadcrumbs:G,router:{urlLocaleSegment:B,pathname:f,params:z,currentPath:J,searchParams:F.search,is404:!f?!0:!1,domain:O.domain?LX(O):null},appId:V,features:x,componentTree:[["404",[]],...this.componentTree]},head:{}},S=this.root,E=this.routeManifest[f];return async(P)=>{let{bootstrapModules:Z0=[],loaders:g,getStyles:m,viewImportMap:T0,cssManifest:A3,ogMap:iO,viewModules:z$,clientEntry:T1,modulePreloadManifest:m1,assetBase:f0}=P,t$=T1?[]:Z0,hO=(M0)=>[M0,`window.loaders=${g}`,...T1?[`import(${JSON.stringify(T1.module)}).catch(function(e){setTimeout(function(){throw e})})`]:[]].join(";");if(I){let M0=null,X$=null;for(let F$ of E??[])if(typeof iO[F$]==="function")X$=F$,M0=iO[F$];if(!M0)return new Response("Not found",{status:404});let I5=Object.values(L.data.pageData)[0];try{await jW(a$(M0,I5[X$]),{onError:()=>{}})}catch(F$){let{fonts:S5,...M5}=F$.satoriOptions,N5=await Promise.all(S5.map((dO)=>{return KX(dO.name,dO.weight,dO.style).then((P5)=>({...dO,data:P5}))})),QW=new Headers(j);QW.set("Content-Type","image/png");let[x5,A5]=await Promise.all([UX(),F3("Rendering an OG image")]),_5=await x5(F$.jsx,{...M5,fonts:N5}),E5=await A5(Buffer.from(_5)).png({compressionLevel:0,effort:10}).toBuffer();return new Response(new Uint8Array(E5),{headers:QW})}return new Response("data")}if(L.data.cssManifest=A3,L.data.modulePreloadManifest=m1??{},f0&&f0!=="/")L.data.assetBase=f0;let J$=this.modulePreloadLinks({clientEntry:T1,modulePreloadManifest:m1,views:E??["404"],routeKey:f??"404"}),e$=await m(E);L.data.prefetchedData=Y.snapshotResolved(),Y.markRenderStart();let U1=new AbortController,lO=setTimeout(()=>U1.abort(),GX),H=Q3(X)||C,S0=Bun.env.NODE_ENV!=="production"&&!H&&f&&this.shellReporter.shouldObserve(f)?d4():null,Y$=a4();try{let M0=await jW(a$(DX,{children:[...J$,...e$,a$("script",{key:"theme-script",dangerouslySetInnerHTML:{__html:BX}}),a$(S,{data:L.data,viewImportMap:T0,viewModules:z$,serverQueries:Y,dictionarySink:Y$,key:"root"})]}),{bootstrapScriptContent:hO(`window.__GEMI_DATA__ = ${W$(L.data)}`),bootstrapModules:t$,signal:U1.signal,...H?{progressiveChunkSize:Number.MAX_SAFE_INTEGER}:{},onError(X$){if(Bun.env.NODE_ENV!=="production")console.error(X$)}});if(M0.allReady.catch(()=>{}).finally(()=>clearTimeout(lO)),H)await M0.allReady.catch(()=>{});return new Response(ej(M0,Y,{onShell:H?void 0:()=>Y.markShell(),onChunk:S0?.onChunk,onClose:()=>Z(()=>{if(this.completeStream(O,Y.summarize(U1.signal.aborted)),S0)this.shellReporter.report(f,S0.measure())})},Y$),{status:!f?404:200,headers:j})}catch(M0){if(clearTimeout(lO),Bun.env.NODE_ENV==="production")throw Z(()=>this.completeStream(O,Y.summarize(U1.signal.aborted))),M0;let X$=await jW(a$("div"),{bootstrapScriptContent:hO(`window.error= ${W$(M0.message)}; window.stack_trace=${W$(M0.stack)};window.__GEMI_DATA__ = ${W$(L.data)}`),bootstrapModules:Bun.env.NODE_ENV==="development"?["/render-error.js",...t$]:t$});return new Response(ej(X$,Y,{onClose:()=>Z(()=>this.completeStream(O,Y.summarize(U1.signal.aborted)))}),{status:!f?404:200,headers:j})}}}async handleViewRequest($,O){let Z=new URL($.url),T=Z.pathname.endsWith(".json"),f=Z.pathname.endsWith(".og"),j=Z.pathname.replace(".json","").replace(".og",""),[,W,...z]=j.split("/"),J=`/${z.join("/")}`,Y=null,X=null,C=K(n);if(!C.supportedLocales.includes(W))J=j;else Y=W,X=W;let U=X===null&&mO(this.flatViewRoutes,J)!==null;if(C.isLocaleAware&&!f&&X===null&&!U){let L=s4(W,C.supportedLocales,C.defaultLocale);if(L){let S=z.length?`/${z.join("/")}`:"";return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${L}${S}${T?".json":""}${Z.search}`}})}}if(C.isLocaleAware&&!f){let L=K(n).detectLocale(new A($,{},"view",J));if(X===null&&L!==C.defaultLocale){let S=Z.pathname==="/"?"":Z.pathname;return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${L}${S}${Z.search}`}})}}J=J.replace("//","/");let D=[],G=[],B=null,Q={},I=null,V=!1,x=[];try{let L=mO(this.flatViewRoutes,J);if(L){if(B=L.routePath,Q=L.params,D=L.route.exec,G=L.route.middleware,x=L.route.features,V=G.includes("no-stream"),T&&this.partialRendering){let S=$.headers.get(oj),E=P4({flatViewRoutes:this.flatViewRoutes,supportedLocales:K(n).supportedLocales,from:S,origin:Z.origin,to:{segments:L.route.segments,params:Q,search:Z.search}});if(E.startIndex>0)D=D.slice(E.startIndex),I={from:S,carriedViews:E.carriedViews}}}}catch(L){throw L}let _=new A($,Q,"view",B);return this.hooks.onRequestStart(_),await N.run(_,async()=>{let L=null,S=N.getStore(),E=s$.getStore(),P=(m)=>s$.run(E,()=>N.runWith(S,m));S.serverQueries=new d$(qO($));let Z0=new Set;if(S.serverQueries.onQueryFail((m)=>{Z0.add(m.error);try{P(()=>Promise.resolve(this.hooks.onRequestFail(g,m.error)).catch(()=>{}))}catch{}}),X){let m=X.replaceAll("/","");h$.setLocale(m)}else h$.setLocale();let g=S.req;zW();try{let m=!1;try{await K(kO).runMiddleware(G)}catch(H){if(!o$(H))throw H;m=!0}if(m||x.length>0&&!await this.passesFeatureGates(x))B=null,D=[],g.routePath="";let T0=K(n),A3=T0.isEnabled,iO=T0.isLocaleAware,z$={};if(iO){let H=null;if(X)H=X.replaceAll("/",""),S.setLocale(H);else H=T0.detectLocale(new A($,g.params)),S.setLocale(H);let S0=A3?T0.getPageTranslations(H,g.routePath):{};z$={supportedLocales:T0.supportedLocales,currentLocale:H,dictionary:{[H]:S0},defaultLocale:T0.defaultLocale}}await n4(z$.currentLocale??"");let T1;try{T1=await Promise.all(D.map((H)=>H(g)))}catch(H){if(!o$(H))throw H;B=null,D=[],g.routePath="",T1=[]}let{cookies:m1,headers:f0}=S;L={data:T1,cookies:m1,headers:f0,user:S.user,prefetchedData:S.serverQueries.snapshotResolved(),currentPathName:B,params:g.params,urlLocaleSegment:Y,meta:S.renderMeta(),appId:K(tj).id,features:await K(l$).forClient()};let{params:t$,user:hO}=L,J$={},e$={};for(let H of T1??[]){let[S0,Y$]=Object.entries(H)?.[0]??[];if(!S0||!Y$)continue;e$[`${S0}:${B}`]=Y$.breadcrumb,J$[S0]=Y$}let U1=J$.FILE;if(U1){for(let H of m1)f0.append("Set-Cookie",H.toString());try{await this.onRequestEnd(g)}catch(H){R1.error(H?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(H)})}return await R3(U1,f0)}if(T){f0.set("Content-Type","application/x-ndjson; charset=utf-8"),f0.append("Vary",oj),m1.forEach((S0)=>f0.append("Set-Cookie",S0.toString())),await this.hooks.onRequestEnd(g);let H={meta:I&&!S.metadata.touched?null:L.meta,data:{[J]:J$},breadcrumbs:e$,prefetchedData:S.serverQueries.snapshotResolved(),i18n:z$,features:L.features,is404:!B,appId:L.appId,partial:I};return new Response(u4(H,S.serverQueries,void 0,({aborted:S0})=>P(()=>this.completeStream(g,S.serverQueries.summarize(S0)))),{headers:f0})}if(f0.set("Content-Type","text/html; charset=utf-8"),!V)f0.append("Vary","User-Agent");for(let H of m1)f0.append("Set-Cookie",H.toString());let lO=Bun.CSRF.generate(process.env.SECRET);f0.append("Set-Cookie",`csrf_token=${lO}; HttpOnly; Secure; SameSite=Strict; Expires=${new Date(Date.now()+86400000).toUTCString()}`);try{await this.onRequestEnd(g)}catch(H){R1.error(H?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(H)})}return await this.render({req:g,runInRequestScope:P,csrfTokenHMAC:Buffer.from(""),currentPathName:B,headers:f0,i18n:z$,params:t$,pathname:Z.pathname,serverQueries:S.serverQueries,userAgent:$.headers.get("user-agent"),noStream:V,url:Z,user:hO,viewData:J$,breadcrumbs:e$,urlLocaleSegment:Y,meta:L.meta,appId:L.appId,features:L.features,isOgRequest:f})}catch(m){if(m.kind===yO)if(T)return IX(m.payload.viewData??m.payload.api);else return WW(m.payload.view);if(!Z0.has(m))this.hooks.onRequestFail(g,m);if(pO(m))return console.error(m),T?u$():WW(TW());if(m instanceof k1&&m.status===403)return T?u$():WW(TW());throw m}},O)}}function XW(){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 O5 extends N0{routes={"/api-routes":this.get(()=>{let $=K(L3).flatRoutes,O=[];for(let[Z,T]of Object.entries($))for(let[f,j]of Object.entries(T)){let{exec:W,middleware:z}=j;O.push({path:Z,method:f,middleware:z})}return O}),"/view-routes":this.get(()=>{let $=K(cO).flatViewRoutes,O=[];for(let[Z,{middleware:T,viewPath:f}]of Object.entries($))O.push({path:Z,method:"GET",viewPath:f,middleware:T});return O})}}var V3="access_token";function SX($,O){let Z=$.body.getReader(),T=!1,f=()=>{if(T)return;T=!0;try{O()}catch(W){console.error(W)}},j=new ReadableStream({async pull(W){let z;try{z=await Z.read()}catch(J){f(),W.error(J);return}if(z.done){f();try{W.close()}catch{}return}try{W.enqueue(z.value)}catch{}},async cancel(W){try{await Z.cancel(W)}finally{f()}}},{highWaterMark:0});return new Response(j,{status:$.status,statusText:$.statusText,headers:$.headers})}function o4($){let{status:O=400,data:Z,headers:T}=$,f=new Headers({"Content-Type":"application/json",...T});if(!f.has("Cache-Control"))f.set("Cache-Control","no-store");return new Response(JSON.stringify(Z),{status:O,headers:f})}function r4($,O,Z){let T=[];O?.forEach((W,z)=>T.push([z,W]));let f=[...typeof O?.getSetCookie==="function"?O.getSetCookie():[],...Array.from(Z??[])];if(T.length===0&&f.length===0)return $;let j=(W)=>{for(let[z,J]of T){if(z.toLowerCase()==="set-cookie")continue;if(!W.has(z))W.set(z,J)}for(let z of f)W.append("Set-Cookie",z)};try{return j($.headers),$}catch{let W=new Headers($.headers);return j(W),new Response($.body,{status:$.status,statusText:$.statusText,headers:W})}}class L3{static token="router.api";flatRoutes={};onRequestStart;onRequestEnd;onRequestFail;constructor($){let O=T4();this.onRequestStart=$.onRequestStart??O.onRequestStart,this.onRequestEnd=$.onRequestEnd??O.onRequestEnd,this.onRequestFail=$.onRequestFail??O.onRequestFail,this.flatRoutes=wj({"/":$.rootRouter,"/auth":Mj,"/__gemi__/services/i18n":Nj,"/__gemi__/services/logs":bj,"/__gemi__/services/image":_j,"/__gemi__/debug":O5})}getRouteHandlerAndParams($){let O=new URL($.url),Z=$5(O.pathname),T={},f;for(let[j]of Object.entries(this.flatRoutes))try{let W=new URLPattern({pathname:j});if(W.test({pathname:Z})){f=j,T=W.exec({pathname:Z})?.pathname.groups;break}}catch(W){console.error(W)}return{params:T,path:f}}async runRouteMiddleware($,O){let T=this.flatRoutes[$][O.rawRequest.method].middleware;try{await K(kO).runMiddleware(T)}catch(f){if(f.kind===yO)return o4(f.payload.api);else{if(o$(f))return XW();if(this.onRequestFail(O,f),console.error(f),pO(f))return u$();throw f}}}async getRouteData($){let O=this.flatRoutes[$],Z=N.getStore(),T=O[Z.req.rawRequest.method].exec??(()=>Promise.resolve({})),f={};try{f=await T()}catch(j){if(j.kind===yO)return o4(j.payload.api);if(o$(j))return XW();if(this.onRequestFail(Z.req,j),console.error(j),pO(j))return u$();throw j}return f}isFrameworkRoute($){return $.startsWith("/__gemi__")}async endRequest($,O,Z){let T=async()=>{try{if(!this.isFrameworkRoute(Z))await this.onRequestEnd(O)}catch(f){R1.error(f?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(f)})}finally{$.destroy()}};if(!$.hasPendingWork()){await T();return}$.whenIdle().then(T).catch((f)=>{console.error(f)})}isOpenEndedBody($,O){return $.method!=="HEAD"&&O.body!==null&&!O.headers.has("Content-Length")}async handleApiRequest($,O){let{params:Z,path:T}=this.getRouteHandlerAndParams($),f=this.flatRoutes[T];if(!f||!f[$.method])return new Response(JSON.stringify({error:{message:"Not found"}}),{status:404});let j=new A($,Z,"api",T);if(!this.isFrameworkRoute(T))this.onRequestStart(j);return await N.run(j,async()=>{let W=N.getStore(),z=!1,J=async()=>{z=!0,await this.endRequest(W,j,T)};try{let Y=K(n);if(Y.isEnabled){let G=Y.detectLocale(j);W.setLocale(G)}W.setRequest(j);let X=await this.runRouteMiddleware(T,j);if(X instanceof Response){let G=r4(X,W.headers,W.cookies);return await J(),G}let C=await this.getRouteData(T),F=W.headers,U=W.cookies;if(C instanceof Response){let G=r4(C,F,U);if(this.isOpenEndedBody($,G)){let B=SX(G,()=>this.endRequest(W,j,T));return z=!0,B}return await J(),G}let D=(C$(C)?C:OO.json(C)).toResponse(F,U);return await J(),D}catch(Y){if(!z)try{await J()}catch(X){console.error(X)}throw Y}},O)}async dispatchAs($,O,Z,T){let f=new URL($.rawRequest.url).origin,j=new URL(`${f}/api${Z}`),W=`/api${Z.split(/[?#]/)[0]}`;if(!Z.startsWith("/")||j.origin!==f||j.pathname!==W||j.hash!==""||j.pathname.startsWith("/api/__gemi__")||j.pathname==="/api/auth"||j.pathname.startsWith("/api/auth/"))throw Error(`dispatchAs: "${Z}" is not an app api path. Pass the route's own path, without "/api", with every param encoded.`);let z=new Headers,J=$.cookies.get(V3);if(J)z.set("Cookie",`${V3}=${J}`);let Y=$.headers.get(V3);if(Y)z.set(V3,Y);let X=$.headers.get("User-Agent");if(X)z.set("User-Agent",X);let C;if(T instanceof FormData)C=T;else if(T!==void 0)z.set("Content-Type","application/json"),C=JSON.stringify(T);let F=new Request(j,{method:O,headers:z,body:C});if(t4(F,oO($)),$.domain)n$(F,$.domain);return N.exit(()=>e4.exit(()=>this.handleApiRequest(F)))}}import{timingSafeEqual as MX}from"crypto";var S3="",DW="*",NX=60000,xX=1e4,FW=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,I3=16,Z5=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,CW="x-forwarded-host";function T5($){return $.startsWith(":")}function UW($,O){if($===null)return!1;let Z=Buffer.from($,"utf8"),T=Buffer.from(O,"utf8");return Z.length===T.length&&MX(Z,T)}function AX($){if(!$)return null;if($===!0)return{header:CW,secret:null};return{header:($.hostHeader??CW).toLowerCase(),secret:$.secret?{header:$.secret.header.toLowerCase(),value:$.secret.value}:null}}function _X($){if(!$||$===!0)return;let{hostHeader:O,secret:Z}=$;if(O!==void 0&&(typeof O!=="string"||!Z5.test(O)))throw Error(`\`route.domains.trustProxy.hostHeader\` must be a single header name, e.g. "x-forwarded-host". Got ${JSON.stringify(O)}.`);if(!Z)return;if(typeof Z.header!=="string"||!Z5.test(Z.header))throw Error(`\`route.domains.trustProxy.secret.header\` must be a header name. Got "${Z.header}".`);if(Z.header.toLowerCase()===(O??CW).toLowerCase())throw Error("`route.domains.trustProxy.secret.header` names the same header as `hostHeader`; the secret needs a header of its own.");if(typeof Z.value!=="string"||Z.value.length<I3)throw Error(`\`route.domains.trustProxy.secret.value\` must be at least ${I3} characters. A guessable one lets any client name its own host.`)}function Z1($){if(!$)return null;try{return new URL(`http://${$.trim()}`).hostname.toLowerCase().replace(/\.$/,"")||null}catch{return null}}function EX($){try{let O=new URL(`http://${$.trim()}`),Z=O.hostname.toLowerCase().replace(/\.$/,"");return Z?O.port?`${Z}:${O.port}`:Z:null}catch{return null}}function PX($){let O=Z1($.root),Z=$.root?.trim().toLowerCase().replace(/\.$/,"");if(!O||O!==Z||!O.split(".").every((j)=>FW.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<I3)throw Error(`\`route.domains.ask.secret\` must be at least ${I3} characters. A guessable one is worse than leaving \`ask\` out.`);_X($.trustProxy);let T=new Set,f=null;for(let j of $.groups??[]){let{subdomain:W}=j;if(T.has(W))throw Error(`\`route.domains\` declares the subdomain "${W}" twice.`);if(T.add(W),T5(W)){if(!/^:[A-Za-z_][A-Za-z0-9_]*$/.test(W))throw Error(`"${W}" 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 "${W}"; a host could match either.`);f=j;continue}if(j.exists)throw Error(`The subdomain "${W}" is fixed, so \`exists\` has no param to check. It only applies to a \`:param\` subdomain.`);if(!W.split(".").every((z)=>FW.test(z)))throw Error(`"${W}" is not a valid subdomain.`)}if($.custom&&!T.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 GW{root;hostTrust;fixed=new Map;param=null;custom;cacheTtlMs;cache=new Map;inFlight=new Map;askSecret;proxySecretHeader;constructor($){PX($),this.root=Z1($.root),this.hostTrust=AX($.trustProxy);for(let O of $.groups??[])if(T5(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??NX,this.askSecret=$.ask?.secret??null,this.proxySecretHeader=this.hostTrust?.secret?.header??null}forwardedHost($){let O=this.hostTrust;if(!O)return null;if(O.secret&&!UW($.headers.get(O.secret.header),O.secret.value))return null;return $.headers.get(O.header)?.split(",")[0]?.trim()||null}hostOf($){return Z1(this.forwardedHost($))??Z1(new URL($.url).host)}publicOrigin($){let O=new URL($.url),Z=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),T=Z==="http"||Z==="https"?Z:O.protocol.replace(/:$/,""),f=this.forwardedHost($),j=f&&Z1(f)?EX(f):null;return`${T}://${j??O.host}`}async resolve($){let O=this.hostOf($);if(!O)return null;let Z=await this.match(O,$);if(Z)return Z;if(this.custom?.fallback&&!this.isUnderRoot(O))return{host:O,group:DW,params:{},custom:!0};return null}async allows($,O){let Z=Z1($);return Z?await this.match(Z,O)!==null:!1}isUnderRoot($){return $===this.root||$.endsWith(`.${this.root}`)}async match($,O){if($===this.root)return{host:$,group:S3,params:{},custom:!1};if($.endsWith(`.${this.root}`)){let T=$.slice(0,-(this.root.length+1)),f=this.fixed.get(T);if(f)return{host:$,group:f.subdomain,params:{},custom:!1};if(this.param&&FW.test(T)){let j={[this.param.name]:T};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 Z=await this.resolveCustom($);return Z?{host:$,group:this.custom.group,params:Z,custom:!0}:null}async resolveCustom($){let O=Date.now(),Z=this.cache.get($);if(Z&&Z.expiresAt>O)return this.cache.delete($),this.cache.set($,Z),Z.value;let T=this.inFlight.get($);if(T)return T;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>=xX)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=Z1($);if(O)this.cache.delete(O)}}}var HX="/__gemi__/domains/ask";class s0{static token="router.domains";resolver;acceptsCustomDomains;groups=new Map;constructor($,O){this.groups.set(S3,$);let{domains:Z}=O;if(this.acceptsCustomDomains=Boolean(Z?.custom),!Z){this.resolver=null;return}this.resolver=new GW(Z);let T=(f)=>({api:f.api?new L3({...O.api,...f.api}):$.api,view:f.view?new cO({...O.view,...f.view}):$.view});for(let f of Z.groups??[])this.groups.set(f.subdomain,T(f));if(Z.custom?.fallback)this.groups.set(DW,T(Z.custom.fallback))}async route($){if(!this.resolver)return this.dispatchers(null);if(this.resolver.proxySecretHeader)f5($,this.resolver.proxySecretHeader);let O=await this.resolver.resolve($);if(!O)return null;return n$($,O),this.dispatchers(O)}async ask($){if(!this.resolver?.askSecret||$.method!=="GET")return null;let O=new URL($.url);if(O.pathname!==HX)return null;if(!UW(O.searchParams.get("secret"),this.resolver.askSecret))return null;let Z=O.searchParams.get("domain"),T=Z?await this.resolver.allows(Z,$):!1;return new Response(null,{status:T?200:404})}dispatchers($){return this.groups.get($?.group??S3)}viewDispatchers(){return Array.from(new Set(Array.from(this.groups.values(),($)=>$.view)))}}function j5($){let O=new Date($??0).getTime();return Number.isFinite(O)?O:0}var W5=600000;function z5($,O){return[rO($,O),rO($,O-1)]}class b{static token="auth";config;provider;constructor($={},O=new u3){this.config=J5(nW($),$),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(s0)?K(s0).resolver:null;return O?O.publicOrigin($.rawRequest):new URL($.rawRequest.url).origin}cookieDomain($){let O=this.config.cookieDomain;if(!O)return;let Z=O==="root"?K(s0).resolver?.root:Z1(O);if(!Z)throw Error('`auth.cookieDomain` is "root", but `route.domains` is not configured.');let T=$.domain?.host??Z1(new URL($.rawRequest.url).host);return T===Z||T?.endsWith(`.${Z}`)?Z:void 0}async getSession($,O){if(!$)return null;if(!i3($))return this.config.migrateLegacySession?this.convertLegacySession($,O,this.config.migrateLegacySession):null;let Z=await this.userProvider.findSession({token:$,userAgent:O});if(!Z?.user)return null;let T=Date.now(),f=j5(Z.expiresAt),j=j5(Z.absoluteExpiresAt);if(f<=T||j<=T)return await this.userProvider.deleteSession({token:$}),null;let z=await this.slideSession(Z,T);return z.user.extension=await this.config.extendSession(z.user),z}async convertLegacySession($,O,Z){let T=N.getStore()?.req;if(!T)return null;let f=Date.now(),j=Math.floor(f/W5),W=null,z=await this.userProvider.findSession({token:$,userAgent:O});if(z?.user){if(!await Z(z,{token:$,req:T,userAgent:O}))return null;let Y=rO($,j),X=z.user.id;if(await this.userProvider.withLegacySessionLock($,async()=>{if(!await this.userProvider.claimLegacySession({token:$}))return!1;return await this.userProvider.createSessionV2({token:Y,userId:X,userAgent:O,...this.freshLifetime(f)}),!0}))W=Y}if(!W){for(let Y of z5($,j))if((await this.userProvider.findSession({token:Y,userAgent:O}))?.user){W=Y;break}}if(!W)return null;let J=await this.getSession(W,O);if(J)T.ctx().setCookie("access_token",W,this.accessTokenCookieOptions(T,new Date(J.expiresAt)));return J}async revokeSession($,O){if(!$)return await this.userProvider.deleteSession({token:$}),null;if(i3($)||!this.config.migrateLegacySession){let f=await this.userProvider.findSession({token:$,userAgent:O});return await this.userProvider.deleteSession({token:$}),f}let Z=Math.floor(Date.now()/W5),T=z5($,Z);return this.userProvider.withLegacySessionLock($,async()=>{let f=await this.userProvider.findSession({token:$,userAgent:O});for(let j of T){if(f?.user)break;f=await this.userProvider.findSession({token:j,userAgent:O})}await this.userProvider.deleteSession({token:$});for(let j of T)await this.userProvider.deleteSession({token:j});return f})}requestCarryingCookie($){let O=N.getStore()?.req;return O?.cookies.get("access_token")===$?O:null}async slideSession($,O){let Z=this.config.sessionExpiresInHours*3600000;if(new Date($.expiresAt).getTime()-O>=Z/2)return $;let T=new Date(Math.min(O+Z,new Date($.absoluteExpiresAt).getTime())),f=await this.userProvider.updateSession({token:$.token,expiresAt:T}),j=this.requestCarryingCookie($.token);if(j)j.ctx().setCookie("access_token",$.token,this.accessTokenCookieOptions(j,T));if(!f)return $;return{...$,expiresAt:f.expiresAt??T}}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 Z=await this.createOrUpdateSession({email:$,id:O.id}),T=new A;if(T.ctx().setCookie("access_token",Z.token,this.accessTokenCookieOptions(T,Z.expiresAt)),Z?.user)Z.user.extension=await this.config.extendSession(Z.user);return Z}catch(O){console.log(O)}}async createOrUpdateSessionV2($){let O=await this.createOrUpdateSession($),Z=null;if(O?.user)Z=await this.config.extendSession(O.user),O.user.extension=Z;return O}async createOrUpdateSession($){let O=new A,Z=$.id??(await this.userProvider.findUserByEmailAddress($.email,!1))?.id;if(!Z)throw new y1;let T=Bun.env.NODE_ENV==="development"?"local":O.headers.get("User-Agent"),f=sW(Z),j=await this.userProvider.createSessionV2({token:f,userId:Z,userAgent:T,...this.freshLifetime(Date.now())}),W=await this.userProvider.findSession({token:f,userAgent:T??""});return W?.user?W:j}async createMagicLinkToken($){let O=await this.userProvider.findUserByEmailAddress($,!1);if(O){await this.userProvider.deleteMagicLinkToken($);let Z=await this.config.generateMagicLinkToken($),T=(Number.parseInt(bX(4).toString("hex"),16)%1e6).toString().padStart(6,"0");return await this.userProvider.createMagicLinkToken({email:$,token:Z,pin:T}),{user:O,email:$,pin:T,token:Z}}return{}}}import{AsyncLocalStorage as wX}from"async_hooks";class BW{config;static token="broadcast";publishCb;context=new wX;constructor($){this.config=$}get channels(){return this.config.channels}onPublish($){this.publishCb=$}publish(...$){let[O,Z,T]=$;this.publishCb(O,Z,T)}async handleMessage($,O){let Z=JSON.parse(O);if(Z.type==="subscribe"){let T=Object.entries(this.channels).sort(([f],[j])=>f.length-j.length);for(let[f,j]of T){let W=new URLPattern({pathname:f});if(W.test({pathname:Z.topic})){let z=W.exec({pathname:Z.topic})?.pathname.groups,J=new j;if(await J.subscribe.call(J,z))$.subscribe(Z.topic);break}}}if(Z.type==="broadcast")$.publish(Z.topic,JSON.stringify({topic:Z.topic,data:Z.payload}));if(Z.type==="unsubscribe")$.unsubscribe(Z.topic)}run($,O){let Z=Y5($.get("Cookie"));this.context.run({headers:$,cookies:Z},O)}}class M3 extends O0{static getFacadeAccessor(){return BW}static channel($,O){let Z=this.getFacadeRoot(),T=Z.channels[$];if(!T)return console.error(`Channel ${$} not found`),{publish:()=>{}};let f=new T;return{publish:(j,W=!1)=>{let z=h($,O);Z.publish(z,JSON.stringify({topic:z,data:f.publish(j)}),W)}}}}class T$ extends O0{static getFacadeAccessor(){return b}static async user(){let $=N.getStore(),O=M3.getFacadeRoot().context.getStore(),Z="",T="";if($?.req)Z=$.req.cookies.get("access_token"),T=$.req.headers.get("User-Agent");if(O?.cookies)T=O.headers.get("User-Agent"),Z=O.cookies.get("access_token");let f=$?.user;if(!f)f=(await this.getFacadeRoot().getSession(Z,T))?.user,$?.setUser(f);if(f)return f;throw new y1({redirectTo:aO($?.req,this.getFacadeRoot().config.signInPath)})}static intendedUrl($){let O=N.getStore()?.req;return ZO(O?.search.get(D$),$??this.getFacadeRoot().config.redirectPath)}static async guard($){let O=await T$.user();if(!await $(O))throw new p3}static async guardSafe($){let O=await T$.user();try{return await $(O)}catch(Z){return!1}}static async authenticate($){return await this.getFacadeRoot().authenticate($)}static async createMagicLink($){return await this.getFacadeRoot().createMagicLinkToken($)}}class N3{static ensure($,O={}){let Z=N.getStore();if(Z.req.kind==="api")throw Error("Query.prefetch() cannot be called from an API request");return Z.serverQueries??=new d$(qO(Z.req.rawRequest)),Z.serverQueries.ensure($,O,"prefetch")}static async instant($,...O){let Z=N3.ensure($,O[0]);if(await Z.promise,Z.status==="rejected")throw Z.error;return Z.data}static prefetch($,...O){N3.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 d$(qO($.req.rawRequest)),$.serverQueries.muteDiscoveryHints()}}function X5($,O,Z="/"){let T=new URL($.origin),f=O.host?O.host:O.subdomain?`${O.subdomain}.${$.root}`:$.root,j=new URL(Z.startsWith("/")?Z:`/${Z}`,T),W=vX(f);if(!W)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=W.hostname,W.port)j.port=W.port;return j.toString()}function vX($){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 F5{static absolute($,...O){return`${process.env.HOST_NAME}${h(String($),O[0]??{})}`}static relative($,...O){return h(String($),O[0]??{})}static forDomain($,O,...Z){let T=K(s0).resolver;if(!T)throw Error("`Url.forDomain` needs `route.domains` to be configured.");let f=N.getStore()?.req?.rawRequest,j=f?T.publicOrigin(f):process.env.HOST_NAME;if(!j)throw Error("`Url.forDomain` outside a request needs `HOST_NAME` for the protocol.");return X5({root:T.root,origin:j},$,h(String(O),Z[0]??{}))}}class C5{name="Meta";static description($){N.getStore().metadata.description($)}static title($){N.getStore().metadata.title($)}static openGraph($){N.getStore().metadata.openGraph($)}}var gX={set($,O,Z){N.getStore().setCookie($,O,Z)},setIfAbsent($,O,Z){if(N.getStore().req.cookies.has($))return!1;return N.getStore().setCookie($,O,Z),!0},delete($,O){N.getStore().deleteCookie($,O)}};class KW{config;static token="redis";instance=null;constructor($={}){this.config=$}get client(){return this.instance??=new(RX())(this.config.url,this.config.options)}set client($){this.instance=$}}function RX(){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 D1 extends O0{static getFacadeAccessor(){return KW}static get client(){return this.getFacadeRoot().client}static get($){return D1.client.get($)}static set($,O){return D1.client.set($,O)}static del(...$){return D1.client.del(...$)}static exists($){return D1.client.exists($)}static incr($){return D1.client.incr($)}static expire($,O){return D1.client.expire($,O)}static ttl($){return D1.client.ttl($)}}class D5 extends O0{static getFacadeAccessor(){return U$}static consume($,O={}){return this.getFacadeRoot().consume($,O)}}class U5 extends O0{static getFacadeAccessor(){return l$}static enabled($){return this.getFacadeRoot().enabled($)}static all(){return this.getFacadeRoot().forClient()}static explain($){return this.getFacadeRoot().explain($)}static for($){return this.getFacadeRoot().for($)}static list(){return this.getFacadeRoot().list()}static set($,O,Z){return this.getFacadeRoot().set($,O,Z)}static refresh(){return this.getFacadeRoot().refresh()}static invalidate(){return this.getFacadeRoot().invalidate()}}class x3{bound;constructor($){this.bound=$}get name(){return this.bound??fO()}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,Z=this.connection(O);return K5(Z.sql,(T)=>G5(O,()=>$(T)),{slowTransactionThreshold:Z.config.slowTransactionThreshold,connection:O})}async schema(){let $=this.connection(),{introspect:O}=await import("./chunk-eekg7k6d.js");return O(this.handle()??$.sql,$.dialect)}run($,O){let Z=this.connection(),{text:T,values:f}=V5($,Q5(Z.dialect),O);return(this.handle()??Z.sql).unsafe(T,f)}handle(){let $=TO();if($===void 0)return;return fO()===this.name?$:void 0}connection($=this.name){return B5($),K(jO).connection($)}}var r$=new x3;class L5 extends O0{static getFacadeAccessor(){return jO}static connection($){return new x3($)}static get sql(){return r$.sql}static get dialect(){return r$.dialect}static query($){return r$.query($)}static execute($){return r$.execute($)}static transaction($){return r$.transaction($)}static schema(){return r$.schema()}static close(){return this.getFacadeRoot().close()}}export{G1 as ic,$O as jc,H3 as kc,N0 as lc,v3 as mc,AW as nc,nO as oc,OO as pc,R3 as qc,B1 as rc,w0 as sc,g5 as tc,R5 as uc,c3 as vc,i3 as wc,sW as xc,x9 as yc,nW as zc,l5 as Ac,u3 as Bc,BW as Cc,M3 as Dc,T$ as Ec,h$ as Fc,N3 as Gc,F5 as Hc,RO as Ic,R1 as Jc,C5 as Kc,gX as Lc,KW as Mc,D1 as Nc,U$ as Oc,D5 as Pc,k4 as Qc,$W as Rc,m4 as Sc,q4 as Tc,tY as Uc,y4 as Vc,OW as Wc,OX as Xc,ZX as Yc,ZW as Zc,p4 as _c,c4 as $c,l$ as ad,U5 as bd,x3 as cd,L5 as dd,xj as ed,Aj as fd,XC as gd,O4 as hd,Z4 as id,kO as jd,EC as kd,T4 as ld,f4 as md,aj as nd,tj as od,u$ as pd,TW as qd,JW as rd,QX as sd,WW as td,IX as ud,cO as vd,k3 as wd,pW as xd,oO as yd,XW as zd,o4 as Ad,r4 as Bd,L3 as Cd,s0 as Dd,b as Ed,gW as Fd,RW as Gd,kW as Hd,iW as Id,hW as Jd,lW as Kd};
18
+
19
+ //# debugId=5271E0505B498F7164756E2164756E21