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