gemi 0.67.0 → 0.69.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 (202) hide show
  1. package/dist/ai/Agent.d.ts +66 -17
  2. package/dist/ai/Agent.d.ts.map +1 -1
  3. package/dist/ai/AgentController.d.ts +22 -1
  4. package/dist/ai/AgentController.d.ts.map +1 -1
  5. package/dist/ai/client/index.d.ts +1 -1
  6. package/dist/ai/client/index.d.ts.map +1 -1
  7. package/dist/ai/client/index.js +32 -1
  8. package/dist/ai/client/index.js.map +1 -1
  9. package/dist/ai/index.d.ts +1 -1
  10. package/dist/ai/index.d.ts.map +1 -1
  11. package/dist/ai/index.js +10 -10
  12. package/dist/ai/index.js.map +5 -5
  13. package/dist/ai/live/harness.d.ts +0 -3
  14. package/dist/ai/live/harness.d.ts.map +1 -1
  15. package/dist/ai/types.d.ts +27 -0
  16. package/dist/ai/types.d.ts.map +1 -1
  17. package/dist/ai/useChat.d.ts +18 -1
  18. package/dist/ai/useChat.d.ts.map +1 -1
  19. package/dist/app/index.js +1 -1
  20. package/dist/broadcasting/index.js +1 -1
  21. package/dist/bun/plugin.js +1 -1
  22. package/dist/bun/preload.js +1 -1
  23. package/dist/{chunk-ex9ns7pf.js → chunk-0fmntznb.js} +4 -4
  24. package/dist/{chunk-ex9ns7pf.js.map → chunk-0fmntznb.js.map} +1 -1
  25. package/dist/{chunk-fmcq21hg.js → chunk-0nbrg1hn.js} +2 -2
  26. package/dist/{chunk-fmcq21hg.js.map → chunk-0nbrg1hn.js.map} +1 -1
  27. package/dist/{chunk-hrtkjv41.js → chunk-0qrnp119.js} +2 -2
  28. package/dist/{chunk-hrtkjv41.js.map → chunk-0qrnp119.js.map} +1 -1
  29. package/dist/{chunk-tn71d46d.js → chunk-17grdzh5.js} +2 -2
  30. package/dist/{chunk-tn71d46d.js.map → chunk-17grdzh5.js.map} +1 -1
  31. package/dist/{chunk-pcxxnnad.js → chunk-1ethvybg.js} +3 -3
  32. package/dist/{chunk-pcxxnnad.js.map → chunk-1ethvybg.js.map} +1 -1
  33. package/dist/{chunk-8bjxk57p.js → chunk-36p6nrgf.js} +2 -2
  34. package/dist/{chunk-8bjxk57p.js.map → chunk-36p6nrgf.js.map} +1 -1
  35. package/dist/{chunk-r069158p.js → chunk-3f0ncrd4.js} +2 -2
  36. package/dist/{chunk-r069158p.js.map → chunk-3f0ncrd4.js.map} +1 -1
  37. package/dist/{chunk-p5m0da00.js → chunk-43xykgzb.js} +2 -2
  38. package/dist/{chunk-p5m0da00.js.map → chunk-43xykgzb.js.map} +1 -1
  39. package/dist/{chunk-xzexftx1.js → chunk-4hw93e3y.js} +1 -1
  40. package/dist/{chunk-70y8wajy.js → chunk-5hyfe7b3.js} +2 -2
  41. package/dist/{chunk-70y8wajy.js.map → chunk-5hyfe7b3.js.map} +1 -1
  42. package/dist/{chunk-ks94h71z.js → chunk-5yqdkz6y.js} +2 -2
  43. package/dist/{chunk-ks94h71z.js.map → chunk-5yqdkz6y.js.map} +1 -1
  44. package/dist/chunk-654312qd.js +5 -0
  45. package/dist/{chunk-adj6dnvj.js.map → chunk-654312qd.js.map} +1 -1
  46. package/dist/{chunk-nxh5a3eb.js → chunk-6pfkdsev.js} +3 -3
  47. package/dist/{chunk-nxh5a3eb.js.map → chunk-6pfkdsev.js.map} +1 -1
  48. package/dist/{chunk-w34j3cd3.js → chunk-73xm7k9y.js} +3 -3
  49. package/dist/{chunk-w34j3cd3.js.map → chunk-73xm7k9y.js.map} +1 -1
  50. package/dist/{chunk-dmr7yzyr.js → chunk-74mm850r.js} +2 -2
  51. package/dist/{chunk-dmr7yzyr.js.map → chunk-74mm850r.js.map} +1 -1
  52. package/dist/{chunk-e1fkxt82.js → chunk-777rbaaz.js} +2 -2
  53. package/dist/{chunk-e1fkxt82.js.map → chunk-777rbaaz.js.map} +1 -1
  54. package/dist/{chunk-e0v4byjp.js → chunk-79hpx0e7.js} +2 -2
  55. package/dist/{chunk-e0v4byjp.js.map → chunk-79hpx0e7.js.map} +1 -1
  56. package/dist/{chunk-3pwn2r6s.js → chunk-8fhzh26j.js} +2 -2
  57. package/dist/{chunk-3pwn2r6s.js.map → chunk-8fhzh26j.js.map} +1 -1
  58. package/dist/{chunk-rnztqasa.js → chunk-8n6saxe6.js} +2 -2
  59. package/dist/{chunk-rnztqasa.js.map → chunk-8n6saxe6.js.map} +1 -1
  60. package/dist/{chunk-ftaxfq7p.js → chunk-8n8efq3e.js} +3 -3
  61. package/dist/{chunk-ftaxfq7p.js.map → chunk-8n8efq3e.js.map} +1 -1
  62. package/dist/{chunk-sqc6fkqt.js → chunk-9f3d16m8.js} +2 -2
  63. package/dist/{chunk-sqc6fkqt.js.map → chunk-9f3d16m8.js.map} +1 -1
  64. package/dist/{chunk-8jpvj3cj.js → chunk-9nv0nzj0.js} +2 -2
  65. package/dist/{chunk-8jpvj3cj.js.map → chunk-9nv0nzj0.js.map} +1 -1
  66. package/dist/{chunk-7wgk7q33.js → chunk-9rthn2hy.js} +2 -2
  67. package/dist/{chunk-7wgk7q33.js.map → chunk-9rthn2hy.js.map} +1 -1
  68. package/dist/{chunk-r6v21jn6.js → chunk-9x3gr8k7.js} +2 -2
  69. package/dist/{chunk-r6v21jn6.js.map → chunk-9x3gr8k7.js.map} +1 -1
  70. package/dist/{chunk-9x5eefh0.js → chunk-ayvkarte.js} +2 -2
  71. package/dist/{chunk-9x5eefh0.js.map → chunk-ayvkarte.js.map} +1 -1
  72. package/dist/{chunk-45g3hd0e.js → chunk-dvc9dgtg.js} +2 -2
  73. package/dist/{chunk-45g3hd0e.js.map → chunk-dvc9dgtg.js.map} +1 -1
  74. package/dist/{chunk-r77f1482.js → chunk-e2ycfg1s.js} +10 -10
  75. package/dist/{chunk-r77f1482.js.map → chunk-e2ycfg1s.js.map} +3 -3
  76. package/dist/{chunk-2dvjj3ad.js → chunk-e5vt4nq9.js} +2 -2
  77. package/dist/{chunk-2dvjj3ad.js.map → chunk-e5vt4nq9.js.map} +1 -1
  78. package/dist/{chunk-6waph5k8.js → chunk-fqc43fvj.js} +1 -1
  79. package/dist/{chunk-m44ar4he.js → chunk-gapx8ft1.js} +2 -2
  80. package/dist/{chunk-m44ar4he.js.map → chunk-gapx8ft1.js.map} +1 -1
  81. package/dist/{chunk-3mp9p38x.js → chunk-gcg79mg1.js} +2 -2
  82. package/dist/{chunk-3mp9p38x.js.map → chunk-gcg79mg1.js.map} +1 -1
  83. package/dist/{chunk-2ghpxrw1.js → chunk-h0mazdqm.js} +1 -1
  84. package/dist/{chunk-7xc64j6p.js → chunk-heq6gzp4.js} +2 -2
  85. package/dist/{chunk-7xc64j6p.js.map → chunk-heq6gzp4.js.map} +1 -1
  86. package/dist/{chunk-q1nq7n6y.js → chunk-jctjvgat.js} +2 -2
  87. package/dist/{chunk-q1nq7n6y.js.map → chunk-jctjvgat.js.map} +1 -1
  88. package/dist/{chunk-rq2k9frr.js → chunk-jecwqesm.js} +2 -2
  89. package/dist/{chunk-rq2k9frr.js.map → chunk-jecwqesm.js.map} +1 -1
  90. package/dist/{chunk-5pm9zvtp.js → chunk-jvktxnxa.js} +2 -2
  91. package/dist/{chunk-5pm9zvtp.js.map → chunk-jvktxnxa.js.map} +1 -1
  92. package/dist/{chunk-qqchc40s.js → chunk-k2hjegjw.js} +2 -2
  93. package/dist/{chunk-qqchc40s.js.map → chunk-k2hjegjw.js.map} +1 -1
  94. package/dist/{chunk-g2ywq30n.js → chunk-kqqj907k.js} +2 -2
  95. package/dist/{chunk-g2ywq30n.js.map → chunk-kqqj907k.js.map} +1 -1
  96. package/dist/{chunk-aq09ta7k.js → chunk-kwkjpape.js} +2 -2
  97. package/dist/{chunk-aq09ta7k.js.map → chunk-kwkjpape.js.map} +1 -1
  98. package/dist/{chunk-zqpskwk9.js → chunk-m88haz1d.js} +2 -2
  99. package/dist/{chunk-zqpskwk9.js.map → chunk-m88haz1d.js.map} +1 -1
  100. package/dist/{chunk-7zg1mt1g.js → chunk-mes9ks69.js} +2 -2
  101. package/dist/{chunk-7zg1mt1g.js.map → chunk-mes9ks69.js.map} +1 -1
  102. package/dist/{chunk-ka2qqsys.js → chunk-mjdt9c94.js} +2 -2
  103. package/dist/{chunk-ka2qqsys.js.map → chunk-mjdt9c94.js.map} +1 -1
  104. package/dist/{chunk-z6gzasra.js → chunk-mkvprcnv.js} +2 -2
  105. package/dist/{chunk-z6gzasra.js.map → chunk-mkvprcnv.js.map} +1 -1
  106. package/dist/{chunk-jkjt3e06.js → chunk-mwm0zfn6.js} +2 -2
  107. package/dist/{chunk-jkjt3e06.js.map → chunk-mwm0zfn6.js.map} +1 -1
  108. package/dist/{chunk-j3p8c0xp.js → chunk-ny5w6a89.js} +2 -2
  109. package/dist/{chunk-j3p8c0xp.js.map → chunk-ny5w6a89.js.map} +3 -3
  110. package/dist/{chunk-rnjbja88.js → chunk-pc3rjntj.js} +2 -2
  111. package/dist/{chunk-rnjbja88.js.map → chunk-pc3rjntj.js.map} +1 -1
  112. package/dist/{chunk-9ch1q7nd.js → chunk-pzhzjx6h.js} +2 -2
  113. package/dist/{chunk-9ch1q7nd.js.map → chunk-pzhzjx6h.js.map} +1 -1
  114. package/dist/chunk-qz8n10v1.js +5 -0
  115. package/dist/{chunk-z7vmrf00.js.map → chunk-qz8n10v1.js.map} +5 -4
  116. package/dist/chunk-rnpc26wd.js +19 -0
  117. package/dist/{chunk-43asnfa8.js.map → chunk-rnpc26wd.js.map} +6 -5
  118. package/dist/{chunk-7438nrkm.js → chunk-t29t96a3.js} +3 -3
  119. package/dist/{chunk-7438nrkm.js.map → chunk-t29t96a3.js.map} +1 -1
  120. package/dist/{chunk-9zmcz7yq.js → chunk-w8jp1t7b.js} +2 -2
  121. package/dist/{chunk-9zmcz7yq.js.map → chunk-w8jp1t7b.js.map} +1 -1
  122. package/dist/{chunk-5g1j29p2.js → chunk-wdvv88da.js} +2 -2
  123. package/dist/{chunk-5g1j29p2.js.map → chunk-wdvv88da.js.map} +1 -1
  124. package/dist/{chunk-2bb3rdqq.js → chunk-ws6qmce0.js} +3 -3
  125. package/dist/{chunk-2bb3rdqq.js.map → chunk-ws6qmce0.js.map} +1 -1
  126. package/dist/{chunk-pxc51549.js → chunk-wz67xydv.js} +2 -2
  127. package/dist/{chunk-pxc51549.js.map → chunk-wz67xydv.js.map} +1 -1
  128. package/dist/{chunk-wzqxtrpt.js → chunk-xgcydqxz.js} +2 -2
  129. package/dist/{chunk-wzqxtrpt.js.map → chunk-xgcydqxz.js.map} +1 -1
  130. package/dist/{chunk-pb0m0ryf.js → chunk-xkg2sm12.js} +3 -3
  131. package/dist/{chunk-pb0m0ryf.js.map → chunk-xkg2sm12.js.map} +1 -1
  132. package/dist/chunk-y2jz8gqp.js +55 -0
  133. package/dist/{chunk-sksks0tz.js.map → chunk-y2jz8gqp.js.map} +6 -5
  134. package/dist/{chunk-731etrh2.js → chunk-ynabq1zf.js} +2 -2
  135. package/dist/{chunk-731etrh2.js.map → chunk-ynabq1zf.js.map} +1 -1
  136. package/dist/{chunk-v6q4990x.js → chunk-yp0ah93s.js} +3 -3
  137. package/dist/{chunk-v6q4990x.js.map → chunk-yp0ah93s.js.map} +1 -1
  138. package/dist/{chunk-87c0cy5v.js → chunk-zds05es5.js} +2 -2
  139. package/dist/{chunk-87c0cy5v.js.map → chunk-zds05es5.js.map} +1 -1
  140. package/dist/{chunk-fxkh2rfd.js → chunk-znxsf63g.js} +2 -2
  141. package/dist/{chunk-fxkh2rfd.js.map → chunk-znxsf63g.js.map} +1 -1
  142. package/dist/{chunk-fd7wfcft.js → chunk-zxbmpn71.js} +2 -2
  143. package/dist/{chunk-fd7wfcft.js.map → chunk-zxbmpn71.js.map} +1 -1
  144. package/dist/config/index.js +1 -1
  145. package/dist/console/run.js +2 -2
  146. package/dist/console/run.js.map +1 -1
  147. package/dist/container/index.js +2 -2
  148. package/dist/container/index.js.map +1 -1
  149. package/dist/database/index.js +2 -2
  150. package/dist/database/index.js.map +1 -1
  151. package/dist/email/index.js +2 -2
  152. package/dist/email/index.js.map +1 -1
  153. package/dist/facades/index.js +2 -2
  154. package/dist/facades/index.js.map +1 -1
  155. package/dist/foundation/index.js +2 -2
  156. package/dist/foundation/index.js.map +1 -1
  157. package/dist/http/HttpRequest.d.ts +0 -11
  158. package/dist/http/HttpRequest.d.ts.map +1 -1
  159. package/dist/http/index.js +2 -2
  160. package/dist/http/index.js.map +1 -1
  161. package/dist/http/validate.d.ts +23 -0
  162. package/dist/http/validate.d.ts.map +1 -0
  163. package/dist/i18n/dictionaryRuntime.js +2 -2
  164. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  165. package/dist/i18n/index.js +2 -2
  166. package/dist/i18n/index.js.map +1 -1
  167. package/dist/kernel/index.js +3 -3
  168. package/dist/kernel/index.js.map +3 -3
  169. package/dist/orm/errors.d.ts +17 -0
  170. package/dist/orm/errors.d.ts.map +1 -1
  171. package/dist/orm/index.d.ts +1 -1
  172. package/dist/orm/index.d.ts.map +1 -1
  173. package/dist/orm/index.js +3 -3
  174. package/dist/orm/index.js.map +2 -2
  175. package/dist/server/hmrPort.d.ts +14 -0
  176. package/dist/server/hmrPort.d.ts.map +1 -0
  177. package/dist/server/httpDev.d.ts.map +1 -1
  178. package/dist/server/index.js +2 -2
  179. package/dist/server/index.js.map +1 -1
  180. package/dist/services/index.js +2 -2
  181. package/dist/services/index.js.map +1 -1
  182. package/dist/services/mcp/McpRegistry.d.ts +13 -3
  183. package/dist/services/mcp/McpRegistry.d.ts.map +1 -1
  184. package/dist/services/mcp/toAgentTools.d.ts +12 -3
  185. package/dist/services/mcp/toAgentTools.d.ts.map +1 -1
  186. package/dist/services/queue/work.js +2 -2
  187. package/dist/services/queue/work.js.map +1 -1
  188. package/dist/services/router/ApiRouteDispatcher.d.ts.map +1 -1
  189. package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
  190. package/dist/services/router/globalMiddleware.d.ts.map +1 -1
  191. package/dist/services/router/notFound.d.ts +19 -0
  192. package/dist/services/router/notFound.d.ts.map +1 -0
  193. package/dist/support/index.js +2 -2
  194. package/dist/support/index.js.map +1 -1
  195. package/package.json +1 -1
  196. package/dist/chunk-43asnfa8.js +0 -19
  197. package/dist/chunk-adj6dnvj.js +0 -5
  198. package/dist/chunk-sksks0tz.js +0 -55
  199. package/dist/chunk-z7vmrf00.js +0 -5
  200. /package/dist/{chunk-xzexftx1.js.map → chunk-4hw93e3y.js.map} +0 -0
  201. /package/dist/{chunk-6waph5k8.js.map → chunk-fqc43fvj.js.map} +0 -0
  202. /package/dist/{chunk-2ghpxrw1.js.map → chunk-h0mazdqm.js.map} +0 -0
@@ -0,0 +1,19 @@
1
+ // @bun
2
+ import{Gd as gz,Nd as e8}from"./chunk-t29t96a3.js";import{De as r8,Ud as a$,Zd as kT}from"./chunk-e2ycfg1s.js";import{$e as T0,Ee as HZ,Ge as i8,Ie as g8,Je as Az,Ke as VZ,Le as SZ,Oe as QZ,Pe as MZ,Qe as u$,Re as N8,Se as gT,Te as m1,Ue as N0,Ve as E,We as wZ,Xe as bZ,Ye as AZ,_e as y1,af as jZ}from"./chunk-qz8n10v1.js";import{hf as B8,if as aj,jf as A}from"./chunk-kqqj907k.js";import{kf as p8}from"./chunk-zds05es5.js";import{lf as k8,mf as n8,nf as fz,of as a8,pf as o8,yf as t8}from"./chunk-8n8efq3e.js";import{Kf as jz}from"./chunk-heq6gzp4.js";import{Sf as H8,Xf as w8}from"./chunk-5hyfe7b3.js";import{bg as P8,cg as n}from"./chunk-17grdzh5.js";import{fg as K}from"./chunk-1ethvybg.js";import{gg as s$}from"./chunk-43xykgzb.js";import{sg as Sj}from"./chunk-e5vt4nq9.js";import{ug as R8}from"./chunk-pzhzjx6h.js";import{zg as tj}from"./chunk-9x3gr8k7.js";import{randomBytes as $J}from"crypto";function pT($){return typeof $==="function"&&$.prototype!==void 0}function G1($){return typeof $==="string"?[$]:$}function iT($,T){let O=T?"attachment":"inline",Z=$.replace(/["\\]/g,"").replace(/[^\x20-\x7e]/g,"_");return`${O}; filename="${Z}"; filename*=UTF-8''${encodeURIComponent($)}`}function J2($){return"total"in $&&"partial"in $&&"body"in $}function e$($){return new Response(null,{status:416,headers:{"Accept-Ranges":"bytes","Content-Range":MZ($),"Content-Length":"0","Cache-Control":"no-store"}})}async function D2($){if($ instanceof Blob)return{body:$,start:0,end:$.size-1,total:$.size,partial:!1,type:$.type,name:$.name,download:!1,status:200,extraHeaders:{}};if(J2($))return{body:$.body,start:$.start,end:$.end,total:$.total,partial:$.partial,type:$.type,name:$.name,download:!1,etag:$.etag,lastModified:$.lastModified,status:200,extraHeaders:{}};let T=$.file,O=T instanceof Blob?T:null,Z=$.total??O?.size??-1;return{body:T,start:$.start??0,end:$.end??Z-1,total:Z,partial:$.partial??!1,type:$.type??O?.type??"",name:$.name??T?.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}}}async function IZ($,T){if($ instanceof Response)return $;if(!$)return new Response("Not found",{status:404});let O=await D2($),{body:Z,start:f,end:j,total:z,partial:F}=O;if(Z instanceof Blob&&"exists"in Z&&typeof Z.exists==="function"){if(!await Z.exists())return new Response("Not found",{status:404})}let{range:W}=T;if(W){if(z<=0)return e$(Math.max(z,0));if(!F){if(Z instanceof Blob){let D=SZ(W,z);if(!D)return e$(z);Z=Z.slice(D.start,D.end+1),f=D.start,j=D.end,F=!0}}}let C=Boolean(W)&&F,J=C?206:O.status,Y=new Headers;if(Y.set("Accept-Ranges","bytes"),Y.set("Content-Type",O.type||"application/octet-stream"),C)Y.set("Content-Range",QZ(f,j,z)),Y.set("Content-Length",String(j-f+1));else if(z>=0)Y.set("Content-Length",String(z));if(O.name)Y.set("Content-Disposition",iT(O.name,O.download));if(O.etag)Y.set("ETag",O.etag);if(O.lastModified)Y.set("Last-Modified",O.lastModified.toUTCString());for(let[D,U]of Object.entries(O.extraHeaders))Y.set(D,U);if((T.method??"GET").toUpperCase()==="HEAD"){if(Z&&"cancel"in Z&&typeof Z.cancel==="function")await Z.cancel();return new Response(null,{status:J,headers:Y})}return new Response(Z,{status:J,headers:Y})}function Fz($){return pT($)}class s{method;handler;methodName;__internal_brand="RouteHandler";middlewares=[];constructor($,T,O){this.method=$;this.handler=T;this.methodName=O;this.handler=T,this.methodName=O,this.method=$}get source(){if(!Fz(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(Fz(this.handler)){let T=new this.handler;return T[this.methodName].bind(T)()}return this.handler()}middleware($){return this.middlewares=G1($),this}}class Wz{url;headers;__internal_brand="ProxyHandler";constructor($,T){this.url=$;this.headers=T}run(){let $=new E;return fetch(this.url,{method:$.rawRequest.method,headers:{...$.headers.toJSON(),...this.headers},body:$.rawRequest.body})}}class Cz{constructor(...$){return new s(...$)}}class Jz extends s{__internal_brand="StreamHandler";async run($){let T=A.getStore(),O=T?.req?.rawRequest,Z=VZ(O?.headers.get("Range"));if(T)T.rangeRequest=Z;try{let f=await super.run($);return await IZ(f,{range:Z,method:O?.method})}catch(f){if(f instanceof AZ)return e$(f.total);throw f}finally{if(T)T.rangeRequest=null}}}class Dz{constructor(...$){return new Jz(...$)}}class Yz{__internal_brand="ResourceRoutes";first;second;constructor($){this.first={get:new s("GET",$,"list"),post:new s("POST",$,"store")},this.second={get:new s("GET",$,"show"),put:new s("PUT",$,"update"),delete:new s("DELETE",$,"delete")}}middleware($){if($.list)this.first.get.middleware($.list);if($.store)this.first.post.middleware($.store);if($.show)this.second.get.middleware($.show);if($.update)this.second.put.middleware($.update);if($.delete)this.second.delete.middleware($.delete);return this}}class A0{static __brand="ApiRouter";routes={};middlewares=[];middleware($){}get($,T){return new s("GET",$,T)}post($,T){return new s("POST",$,T)}put($,T){return new s("PUT",$,T)}patch($,T){return new s("PATCH",$,T)}delete($,T){return new s("DELETE",$,T)}resource($){return new Yz($)}agent($){return Y2($,this)}file($,T){return new Cz("GET",$,T)}stream($,T){return new Dz("GET",$,T)}proxy($,T={}){return new Wz($,T)}}function Y2($,T){let O={stream:new s("POST",$,"stream"),attach:new s("POST",$,"attach"),stop:new s("POST",$,"stop"),upload:new s("POST",$,"upload")};return class extends A0{static __internal_brand="AgentRoute";static controller=$;static handlers=O;constructor(){super();this.middlewares=[...T?.middlewares??[]]}routes={"/":O.stream,"/attach":O.attach,"/stop":O.stop,"/files":O.upload};static middleware(f){if(f.stream)O.stream.middleware(f.stream);if(f.attach)O.attach.middleware(f.attach);if(f.stop)O.stop.middleware(f.stop);if(f.upload)O.upload.middleware(f.upload);return this}}}class NZ{method;url;meta;__internal_brand="McpRoute";constructor($,T,O){this.method=$;this.url=T;this.meta=O}}class Xz{static __brand="McpRouter";routes={};fromApiRoute($,T,O){return new NZ($,T,O)}}function u($,T){return $.replace(/:([^/]+[*?]?)/g,(O,Z)=>{let f=Z.endsWith("?")||Z.endsWith("*"),j=f?Z.slice(0,-1):Z,z=T[j];if(z===void 0){if(f)return"";if(import.meta.env.DEV)throw Error(`Missing parameter: ${j}`);console.error(`Missing parameter: ${j} in URL: ${$}`)}return String(z)}).replace(/\/\//g,"/").replace(/\/$/,"")}class EZ extends m1{constructor($,T=307){super("Redirect error");this.name="RedirectError",this.payload={api:{status:200,data:{},directive:{kind:"Redirect",path:$}},view:{status:T,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:$}}}}}class hT{static to($,...T){let[O={}]=T,{search:Z={},params:f={},permanent:j,status:z}={params:{},status:307,permanent:!1,...O},F=new URLSearchParams(Z).toString();throw new EZ([u($,f)||"/",F.toString()].filter(Boolean).join("?"),z??(j?301:307))}static external($,T=307){throw new EZ($,T)}}class Uz{kind="redirect";viewPath="REDIRECT";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>({});else if(typeof $==="function")this.handler=$;else{let[T,O]=$;this.handler=(Z)=>{return new T()[O](Z)}}}async run($,T){let{destination:O,permanent:Z=!1,status:f=307}=await this.handler($);if(!O)throw Error(`Redirect destination is required see ${T}`);return hT.to(O,{permanent:Z,status:f}),{}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}async function xZ($,T){if($ instanceof Response)return $;let O=$ instanceof Blob,Z=O?$:$.file,f=O?$.name:$.name??$.file?.name,j=(O?$.type:$.type??$.file?.type)||"",z=O?!1:$.download??!1,F=O?200:$.status??200;if(!O)for(let[W,C]of Object.entries($.headers??{}))T.set(W,C);if(Z instanceof Blob&&"exists"in Z&&typeof Z.exists==="function"){if(!await Z.exists())return new Response("Not found",{status:404})}if(T.set("Content-Type",j||"application/octet-stream"),Z instanceof Blob)T.set("Content-Length",String(Z.size));if(f)T.set("Content-Disposition",iT(f,z));return new Response(Z instanceof Blob?Z.stream():Z,{status:F,headers:T})}class Gz{kind="file";viewPath="FILE";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>null;else if(typeof $==="function")this.handler=$;else{let[T,O]=$;this.handler=(Z)=>{return new T()[O](Z)}}}async run($,T){let O=await this.handler($);if(!O)throw Error(`File route handler must return a file see ${T}`);return{FILE:O}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class Bz{viewPath;middlewares=[];featureGates=[];handler;constructor($,T){this.viewPath=$;if(!T)this.handler=()=>({});else if(typeof T==="function")this.handler=T;else{let[O,Z]=T;this.handler=(f)=>{return new O()[Z](f)}}}async run($,T){let O=await this.handler($);return{[this.viewPath]:{...O,breadcrumb:{label:O?.breadcrumb??"",href:T}}}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class Kz{viewPath;children;middlewares=[];featureGates=[];alwaysRuns=!1;handler=()=>({});constructor($,T,O){this.viewPath=$;if(typeof T==="function")this.handler=T,this.children=class extends B1{routes=O??{}};else if(Array.isArray(T)){let[Z,f]=T;this.handler=(j)=>{return new Z()[f](j)},this.children=class extends B1{routes=O??{}}}else this.children=class extends B1{routes=T},this.handler=()=>({})}async run($,T){let O=await this.handler($);return{[this.viewPath]:{...O,breadcrumb:{label:O?.breadcrumb??"",href:T}}}}alwaysRun(){return this.alwaysRuns=!0,this}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class B1{middlewares=[];featureGates=[];routes={};view($,T){return new Bz($,T)}file($){return new Gz($)}redirect($){return new Uz($)}layout($,T,O){return new Kz($,T,O)}}class v0{req;config={};constructor($){this.req=$}run(...$){return{}}static configure($){let T=this;return class extends T{config=$}}}function X2($){return $}function U2(){return{aliases:{},global:[]}}var Y$="redirect";function $T($,T="/"){if(typeof $!=="string"||!$.startsWith("/"))return T;if(/[\u0000-\u001f\u007f\\]/.test($)||$.startsWith("//"))return T;try{let O=new URL($,"http://gemi.invalid");if(O.origin!=="http://gemi.invalid")return T;let Z=`${O.search}${O.hash}`.replaceAll("/","%2F"),f=`${O.pathname}${Z}`.replaceAll(":","%3A");return f.startsWith("//")?T:f}catch{return T}}function Lz($){let T=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();return T?T==="https":new URL($.url).protocol==="https:"}function G2($,T=!0){let O=new URL($.rawRequest.url),Z=O.pathname.replace(/\.(json|og)$/,""),[,f,...j]=Z.split("/");if(K(n).supportedLocales.includes(f))Z=`/${j.join("/")}`;return T?`${Z}${O.search}`:Z}function B2($,T){let O=(Z)=>Z.replace(/\/+$/,"")||"/";return O($)===O(T)}function lT($,T){let O=T||K(w).config.signInPath,Z=/^[a-z][a-z\d+.-]*:/i.test(O);if(Z?!/^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 f=new URL(O,"http://gemi.invalid");if($?.kind==="view"){let j=G2($,!Z);if(Z||!B2(new URL(j,f).pathname,f.pathname))f.searchParams.set(Y$,j)}return Z?f.href:`${f.pathname}${f.search}`}class Sz extends v0{async run($){let T=A.getStore(),O=T.req,Z=()=>new y1({redirectTo:lT(O,$)}),f=O.cookies.get("access_token"),j=O.headers.get("access_token"),z=f||j;if(!z)throw Z();let F=T.user;if(!F){let W=await K(w).getSession(z,O.headers.get("User-Agent"));if(!W)throw Z();F=W?.user,T.setUser(F)}return{}}}class Qz extends v0{async run(...$){let[T="public",O="864000",...Z]=$,f=`${T}, max-age=${O}${Z.length>0?", ":""}${Z.join(", ")}`;if($.length===0)f="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="public")f="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="private")f="private, max-age=0, stale-while-revalidate=300, stale-if-error=600";if(this.req.rawRequest.method==="GET")this.req.ctx().setHeaders("Cache-Control",f);return{}}}var K2={"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 Mz extends v0{config={origins:{"":{"Access-Control-Allow-Methods":"GET, HEAD, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Authorization, X-Requested-With","Access-Control-Allow-Credentials":"true"}}};run(){let $=this.req,T=$.rawRequest.headers.get("Origin");if(this.config.origins[T]){$.ctx().setHeaders("Access-Control-Allow-Origin",T);let O={...K2,...this.config.origins[T]};for(let[Z,f]of Object.entries(O))$.ctx().setHeaders(Z,f)}return{}}}class X${config;static token="ratelimiter";constructor($){this.config=$}get driver(){return this.config.driver}async consume($,T={}){let O=T.limit??this.config.limit,Z=T.window??this.config.window,f=T.cost??1;if(Iz("window",Z),Iz("limit",O),!Number.isFinite(f)||f<0)throw Error(`Rate limiter cost must be zero or greater, got ${f}`);return await this.config.driver.consume({key:$,limit:O,window:Z*1000,cost:f})}}function Iz($,T){if(!Number.isFinite(T)||T<=0)throw Error(`Rate limiter ${$} must be greater than zero, got ${T}`)}class _Z extends m1{constructor($){super("Rate limit exceeded");let T={"Content-Type":"application/json",...$?Ez($):{}};this.payload={api:{status:429,data:{error:{message:"Rate limit exceeded"}},headers:T},view:{error:{message:"Rate limit exceeded"},status:429,headers:T}}}}class Nz extends v0{async run($,T){let O=L2();if(!O)return{};let Z=await O.consume(this.key(),{limit:Vz($)??this.config.limit,window:Vz(T)??this.config.window});if(this.config.headers!==!1){let f=this.req.ctx?.();if(f)for(let[j,z]of Object.entries(Ez(Z)))f.setHeaders(j,z)}if(!Z.allowed)throw new _Z(Z);return{}}key(){if(this.config.key)return this.config.key(this.req);return`${dT(this.req)}:${this.req.routePath??"*"}`}}function L2(){try{let $=K();return $.bound(X$)?$.make(X$):null}catch{return null}}function dT($){let T=Az($.rawRequest);if(T!==void 0)return T;let O=$.headers.get("x-forwarded-for");if(O){let[Z]=O.split(",");if(Z?.trim())return Z.trim()}return $.headers.get("x-real-ip")?.trim()||"unknown"}function Ez($){let T={"X-RateLimit-Limit":String($.limit),"X-RateLimit-Remaining":String($.remaining),"X-RateLimit-Reset":String(Math.ceil($.resetAt/1000))};if(!$.allowed)T["Retry-After"]=String(Math.max(1,Math.ceil($.retryAfter/1000)));return T}function Vz($){if($===void 0||$===null||$==="")return;let T=Number($);if(!Number.isFinite(T)||T<=0)return;return T}class xz extends v0{async run(){let $=this.req.cookies.get("csrf_token");if(!$)throw new PZ;if(!["POST","PUT","PATCH","DELETE"].includes(this.req.rawRequest.method))return{};if(!Bun.CSRF.verify($,{secret:process.env.SECRET}))throw new PZ;return{}}}class PZ extends m1{constructor(){super("Invalid CSRF token");this.name="InvalidCSRFTokenError"}payload={api:{status:403,data:{error:"Invalid CSRF token"}},view:{}}}class _z{policiesList={};constructor(){let $=this.register();for(let T of $){let O=new T;this.policiesList[T.name]=O}}register(){return[]}}class Pz{all($,T){return!0}}import{createHmac as S2,randomBytes as Q2}from"crypto";var Hz="v2.";function wz($){return $.startsWith(Hz)}function M2(){let $=process.env.SECRET;if(!$)throw Error("Signing in needs a secret to mint session tokens with. Set SECRET in the environment.");return $}function bz($){let T=Q2(16).toString("hex"),O=S2("sha256",M2()).update(`${$}:${T}`).digest("hex");return`${Hz}${O}`}import{randomBytes as gZ}from"crypto";class vZ extends E{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 iD($){return $}function vz($={}){return{basePath:"/auth",verifyEmail:!0,redirectPath:"/dashboard",signInPath:"/auth/sign-in",sessionExpiresInHours:24,sessionAbsoluteExpiresInHours:672,cookieDomain:null,signUpRequest:vZ,oauthProviders:{},verifyPassword:async(T,O)=>await Bun.password.verify(T,O),hashPassword:async(T)=>await Bun.password.hash(T),generateForgotPasswordToken:async()=>gZ(32).toString("hex"),generateEmailVerificationToken:()=>{if(!($.verifyEmail??!0))return"";return gZ(32).toString("hex")},generateMagicLinkToken:()=>gZ(32).toString("hex"),extendSession:()=>({}),onUserCreated:async()=>{},onSignUp:()=>{},onSignIn:()=>{},onSignOut:()=>{},onForgotPassword:()=>{},onResetPassword:()=>{},onMagicLinkCreated:()=>{}}}function kZ($){if($&&typeof $==="object")delete $.password;return $}function I2(){return new Proxy({},{get:($,T)=>gz(T)})}var RZ={select:{id:!0,publicId:!0,email:!0,name:!0,locale:!0,globalRole:!0,accounts:{select:{id:!0,publicId:!0,organizationRole:!0,organization:!0}}}};class mZ{models;constructor($=I2()){this.models=$}run($){return this.models.User.asSystem($)}transaction($){return this.models.User.transaction($)}async createUser($){let T=await this.run(()=>this.models.User.create({data:$}));return kZ(T)}async updateUserPassword($){let T=await this.run(()=>this.models.User.update({where:{id:$.id},data:{password:$.password}}));return kZ(T)}async findUserByEmailAddress($,T){return await this.run(()=>this.models.User.findUnique({where:T?{email:$,emailVerifiedAt:{not:null}}:{email:$}}))}async findUserByVerificationToken($){return await this.run(()=>this.models.User.findFirst({where:{verificationToken:$}}))}async verifyUser($){return await this.run(()=>this.models.User.update({where:{email:$},data:{emailVerifiedAt:new Date}}))}async createSession($){return await this.run(()=>this.models.Session.create({data:$,include:{user:!0}}))}async createSessionV2($){return await this.run(()=>this.models.Session.create({data:$,select:{token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:RZ}}))}async findSession($){if(!$.token)return null;try{return await this.run(()=>this.models.Session.findUnique({where:{token:$.token},select:{token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:RZ}}))}catch(T){return console.error("findSession failed:",T),null}}async updateSession($){return await this.run(()=>this.models.Session.update({where:{token:$.token},data:{expiresAt:$.expiresAt},select:{token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:RZ}}))}async deleteSession($){if(!$.token)return;await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}))}async deleteAllUserSessions($){await this.run(()=>this.models.Session.deleteMany({where:{userId:$}}))}async createPasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.create({data:{token:$.token,user:{connect:{id:$.user.id}}}}))}async findPasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.findUnique({where:{token:$.token},include:{user:!0}}))}async deletePasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.delete({where:{token:$.token}}))}async findInvitation($,T){return await this.run(()=>this.models.OrganizationInvitation.findFirst({where:{publicId:$,email:T}}))}async deleteInvitationById($){await this.run(()=>this.models.OrganizationInvitation.delete({where:{publicId:$}}))}async createAccount($){return await this.run(()=>this.models.Account.create({data:{userId:$.userId,organizationId:$.organizationId,organizationRole:$.organizationRole}}))}async createMagicLinkToken($){return await this.run(()=>this.models.MagicLinkToken.create({data:{email:$.email,token:$.token,pin:$.pin}}))}async findUserMagicLinkToken($){return await this.run(()=>$.token?this.models.MagicLinkToken.findUnique({where:{token_email:{token:$.token,email:$.email}}}):this.models.MagicLinkToken.findUnique({where:{pin_email:{pin:$.pin,email:$.email}}}))}async deleteMagicLinkToken($){await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{email:$}}))}async createSocialAccount($){return await this.run(()=>this.models.SocialAccount.create({data:$}))}async findUserBySocialAccount($,T){if(!T)return null;let O=await this.run(()=>this.models.SocialAccount.findFirst({where:{provider:$,providerId:T},include:{user:!0}}));return O?kZ(O.user):null}async findSocialAccounts($,T){return await this.run(()=>this.models.SocialAccount.findMany({where:{userId:$,provider:T},orderBy:{id:"asc"}}))}async claimSocialAccount($,T){let{count:O}=await this.run(()=>this.models.SocialAccount.updateMany({where:{id:$.id,providerId:$.providerId},data:{providerId:T}}));return O===1}}import{timingSafeEqual as t7}from"crypto";function E0($,T,O,Z,f){return m0(T,oz($,T),O,Z,f)}function m0($,T,O,Z,f,j){let z=iZ(T,O,Z);if(f&&T!==z)throw RangeError(v6($,T,O,Z,j));return z}function oz($,T){let O=$[T];if(O===void 0)throw TypeError(L3(T));return O}function z0($){return $!==null&&/object|function/.test(typeof $)}function P0($,T=Map){let O=new T;return(Z,...f)=>{if(O.has(Z))return O.get(Z);let j=$(Z,...f);return O.set(Z,j),j}}function oZ($){return i1({name:$},1)}function i1($,T){return p0((O)=>({value:O,configurable:1,writable:!T}),$)}function tz($){return p0((T)=>({get:T,configurable:1}),$)}function FO($){return{[Symbol.toStringTag]:{value:$,configurable:1}}}function Q$($,T){let O={},Z=$.length;for(let f of T)O[$[--Z]]=f;return O}function p0($,T,O){let Z={};for(let f in T)Z[f]=$(T[f],f,O);return Z}function CT($,T,O){let Z={};for(let f=0;f<T.length;f++){let j=T[f];Z[j]=$(j,f,O)}return Z}function V2($,T,O){let Z={};for(let f=0;f<$.length;f++)Z[T[f]]=O[$[f]];return Z}function w0($,T){let O={};for(let Z of $)O[Z]=T[Z];return O}function tZ($,T){let O={};for(let Z in T)$.has(Z)||(O[Z]=T[Z]);return O}function rZ($){$={...$};let T=Object.keys($);for(let O of T)$[O]===void 0&&delete $[O];return $}function rz($,T){for(let O of T)if(!(O in $))return 0;return 1}function ez($,T,O){for(let Z of $)if(T[Z]!==O[Z])return 0;return 1}function $F($,T,O){let Z={...O};for(let f=0;f<T;f++)Z[$[f]]=0;return Z}function b($,...T){return(...O)=>$(...T,...O)}function kz($){return $[0].toUpperCase()+$.substring(1)}function JT($){return $.slice().sort()}function rT($,T){return String(T).padStart($,"0")}function K1($,T){return Math.sign($-T)}function iZ($,T,O){return Math.min(Math.max($,T),O)}function j1($,T){return[Math.floor($/T),OT($,T)]}function OT($,T){return($%T+T)%T}function Q1($,T){return[WO($,T),eZ($,T)]}function WO($,T){return Math.trunc($/T)||0}function eZ($,T){return $%T||0}function sT($){return Math.abs($%1)===0.5}function TF($,T,O){let Z=0,f=0;for(let F=0;F<=T;F++){let W=$[O[F]],C=a0[F],J=y/C,[Y,D]=Q1(W,J);Z+=D*C,f+=Y}let[j,z]=Q1(Z,y);return[f+j,z]}function CO($,T,O){let Z={};for(let f=T;f>=0;f--){let j=a0[f];Z[O[f]]=WO($,j),$=eZ($,j)}return Z}function OF($){return $===v?hO:[]}function ZF($){return $===v?QT:[]}function fF($){return $===v?["year","day"]:[]}function jF($){if($!==void 0)return h($)}function zF($){if($!==void 0)return i0($)}function $f($){if($!==void 0)return DT($)}function i0($){return CF(DT($))}function DT($){return WF(U4($))}function Tf($){if($==null)throw TypeError("Cannot be null or undefined");return $}function FF($,T){if(T==null)throw RangeError(L3($));return T}function F1($){if(!z0($))throw TypeError(b6);return $}function JO($,T,O=$){if(typeof T!==$)throw TypeError(KT(O,T));return T}function WF($,T="number"){if(!Number.isInteger($))throw RangeError(q2(T,$));return $||0}function CF($,T="number"){if($<=0)throw RangeError(c2(T,$));return $}function Of($){if(typeof $=="symbol")throw TypeError(l2);return String($)}function eT($,T){return z0($)?String($):h($,T)}function DO($){if(typeof $=="string")return BigInt($);if(typeof $!="bigint")throw TypeError(h2($));return $}function JF($,T="number"){if(typeof $=="bigint")throw TypeError(i2(T));if($=Number($),!Number.isFinite($))throw RangeError(p2(T,$));return $}function U0($,T){return Math.trunc(JF($,T))||0}function DF($,T){return WF(JF($,T),T)}function Rz($,T){return CF(U0($,T),T)}function Zf($,T){let[O,Z]=Q1(T,y),f=$+O,j=Math.sign(f);return j&&j===-Math.sign(Z)&&(f-=j,Z+=j*y),[f,Z]}function G$($,T,O=1){return Zf($[0]+T[0]*O,$[1]+T[1]*O)}function B$($,T){return Zf($[0],$[1]+T)}function g0($,T){return G$(T,$,-1)}function B0($,T){return K1($[0],T[0])||K1($[1],T[1])}function YF($,T,O){return B0($,T)===-1||B0($,O)===1}function YO($,T=1){let O=BigInt(y/T);return[Number($/O),Number($%O)*T]}function K$($,T=1){let O=y/T,[Z,f]=Q1($,O);return[Z,f*T]}function XF($,T=1){let[O,Z]=$,f=Math.floor(Z/T),j=y/T;return BigInt(O)*BigInt(j)+BigInt(f)}function k0($,T=1,O){let[Z,f]=$,[j,z]=Q1(f,T);return Z*(y/T)+(j+(O?z/T:0))}function ff($,T,O=j1){let[Z,f]=$,[j,z]=O(f,T);return[Z*(y/T)+j,z]}function jf($,T){let O=$.formatToParts(T),Z={};for(let f of O)Z[f.type]=f.value;return Z}function zf($){return E0($,"isoYear",WT,FT,1),$.isoYear===WT?E0($,"isoMonth",4,12,1):$.isoYear===FT&&E0($,"isoMonth",1,9,1),$}function L1($){return W1({...$,...c0,isoHour:12}),$}function W1($){let T=E0($,"isoYear",WT,FT,1),O=T===WT?1:T===FT?-1:0;return O&&R0(G0({...$,isoDay:$.isoDay+O,isoNanosecond:$.isoNanosecond-O})),$}function R0($){if(!$||YF($,M4,Q4))throw RangeError(qO);return $}function M1($){return TF($,5,s0)[1]}function XO($){let[T,O]=j1($,y);return[CO(O,5,s0),T]}function UF($){return GF($)[0]}function GF($){return ff($,q0)}function K0($){return M$($.isoYear,$.isoMonth,$.isoDay,$.isoHour,$.isoMinute,$.isoSecond,$.isoMillisecond)}function G0($){let T=K0($);if(T!==void 0){let[O,Z]=Q1(T,_0);return[O,Z*o0+($.isoMicrosecond||0)*t1+($.isoNanosecond||0)]}}function Ff($,T){let[O,Z]=XO(M1($)-T);return R0(G0({...$,isoDay:$.isoDay+Z,...O}))}function $O(...$){return M$(...$)/l6}function M$(...$){let[T,O]=BF(...$),Z=T.valueOf();if(!isNaN(Z))return Z-O*_0}function BF($,T=1,O=1,Z=0,f=0,j=0,z=0){let F=$===WT?1:$===FT?-1:0,W=new Date;return W.setUTCHours(Z,f,j,z),W.setUTCFullYear($,T-1,O+F),[W,F]}function V1($,T){let[O,Z]=B$($,T);Z<0&&(Z+=y,O-=1);let[f,j]=j1(Z,o0),[z,F]=j1(j,t1);return UO(O*_0+f,z,F)}function UO($,T=0,O=0){let Z=Math.ceil(Math.max(0,Math.abs($)-S4)/_0)*Math.sign($),f=new Date($-Z*_0);return Q$(dO,[f.getUTCFullYear(),f.getUTCMonth()+1,f.getUTCDate()+Z,f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds(),f.getUTCMilliseconds(),T,O])}function KF($){return[$.isoYear,$.isoMonth,$.isoDay]}function LF(){return f1}function Wf($,T){switch(T){case 2:return Cf($)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function SF($){return Cf($)?366:365}function Cf($){return $%4==0&&($%100!=0||$%400==0)}function QF($){let[T,O]=BF($.isoYear,$.isoMonth,$.isoDay);return OT(T.getUTCDay()-O,7)||7}function MF({isoYear:$}){return $<1?["bce",1-$]:["ce",$]}function A2($){let T=K0($);if(T<V4)return MF($);let O=jf(R3(L$),T),{era:Z,eraYear:f}=bW(O,L$);return[Z,f]}function GO($){return h1($),BO($,1),$}function h1($){return IF($,1),$}function mz($){return ez(_3,$,IF($))}function IF($,T){let{isoYear:O}=$,Z=E0($,"isoMonth",1,LF(),T);return{isoYear:O,isoMonth:Z,isoDay:E0($,"isoDay",1,Wf(O,Z),T)}}function BO($,T){return Q$(s0,[E0($,"isoHour",0,23,T),E0($,"isoMinute",0,59,T),E0($,"isoSecond",0,59,T),E0($,"isoMillisecond",0,999,T),E0($,"isoMicrosecond",0,999,T),E0($,"isoNanosecond",0,999,T)])}function k($){return $===void 0?0:FC(F1($))}function YT($,T=0){$=h0($);let O=WC($),Z=v4($,T);return[FC($),Z,O]}function Jf($){return WC(h0($))}function VF($){return $=h0($),w3($,9,6,1)}function I$($,T,O,Z=9,f=0,j=4){T=h0(T);let z=w3(T,Z,f),F=Xf(T),W=IT(T,j),C=MT(T,Z,f,1);return z==null?z=Math.max(O,C):xF(z,C),F=Uf(F,C,1),$&&(W=((J)=>J<4?(J+2)%4:J)(W)),[z,C,F,W]}function KO($,T=6,O){let Z=Xf($=Gf($,zO)),f=IT($,7),j=MT($,T);return j=FF(zO,j),Z=Uf(Z,j,void 0,O),[j,Z,f]}function Df($){return b3(h0($))}function AF($,T){return Yf(h0($),T)}function Yf($,T=4){let O=EF($);return[IT($,4),...NF(MT($,T),O)]}function NF($,T){return $!=null?[a0[$],$<4?9-3*$:-1]:[T===void 0?1:10**(9-T),T]}function Xf($){let T=$[ZT];return T===void 0?1:U0(T,ZT)}function Uf($,T,O,Z){let f=Z?y:a0[T+1];if(f){let j=a0[T];if(f%(($=m0(ZT,$,1,f/j-(Z?0:1),1))*j))throw RangeError(KT(ZT,$))}else $=m0(ZT,$,1,O?1e9:1,1);return $}function EF($){let T=$[pZ];if(T!==void 0){if(typeof T!="number"){if(Of(T)==="auto")return;throw RangeError(KT(pZ,T))}T=m0(pZ,Math.floor(T),0,9,1)}return T}function h0($){return $===void 0?{}:F1($)}function Gf($,T){return typeof $=="string"?{[T]:$}:F1($)}function a($){if($!==void 0){if(z0($))return Object.assign(Object.create(null),$);throw TypeError(b6)}}function LO($,T){return $&&Object.assign(Object.create(null),$,{overflow:N4[T]})}function Bf($,T,O=9,Z=0,f){let j=T[$];if(j===void 0)return f?Z:void 0;if(j=Of(j),j==="auto")return f?Z:null;let z=sZ[j];if(z===void 0&&(z=K4[j]),z===void 0)throw RangeError(R6($,j,sZ));return m0($,z,Z,O,1,ST),z}function l1($,T,O,Z=0){let f=O[$];if(f===void 0)return Z;let j=Of(f),z=T[j];if(z===void 0)throw RangeError(R6($,j,T));return z}function xF($,T){if(T>$)throw RangeError(C4)}function F0($){return{branding:uO,epochNanoseconds:$}}function J0($,T,O){return{branding:Y1,calendar:O,timeZone:T,epochNanoseconds:$}}function o($,T=$.calendar){return{branding:e1,calendar:T,...w0(ZC,$)}}function t($,T=$.calendar){return{branding:r1,calendar:T,...w0(P3,$)}}function c1($,T=$.calendar){return{branding:H$,calendar:T,...w0(P3,$)}}function TO($,T=$.calendar){return{branding:w$,calendar:T,...w0(P3,$)}}function l0($){return{branding:sO,...w0(OC,$)}}function i($){return{branding:nO,sign:A1($),...w0(N3,$)}}function _F($){return UF($.epochNanoseconds)}function SO($){return ff($.epochNanoseconds,o0)[0]}function PF($){return XF($.epochNanoseconds,t1)}function HF($){return XF($.epochNanoseconds)}function wF($){return $.epochNanoseconds}function W0($){return typeof $=="string"?$:h($.id)}function V$($,T){return $===T||W0($)===W0(T)}function bF($,T,O,Z,f){let j=p1(Z),[z,F]=((B,L)=>{let M=L((B=Gf(B,aZ))[jC]),S=b4(B);return S=FF(aZ,S),[S,M]})(f,$);if(jT(Math.max(z,j),F))return yz(Z,z);if(!F)throw RangeError(cO);let[W,C,J]=NO(T,O,F),Y=cf(J),D=EO(J),U=pf(J),X=D(C,W,Z),G=U(C,W,X,z);return jT(z,F)?yz(G,z):((B,L,M,S,N,x,Q)=>{let I=A1(B),[_,P]=Kf(S,x3(M,B),M,I,N,x,Q),O0=Lf(L,_,P);return B[R[M]]+O0*I})(G,Y(X),z,C,W,Y,D)}function yz($,T){return k0(j0($),a0[T],1)}function Kf($,T,O,Z,f,j,z){let F=R[O],W={...T,[F]:T[F]+Z},C=z($,f,T),J=z($,f,W);return[j(C),j(J)]}function Lf($,T,O){let Z=k0(g0(T,O));if(!Z)throw RangeError(LT);return k0(g0(T,$))/Z}function vF($,T){let[O,Z,f]=KO(T,5,1);return F0(MO($.epochNanoseconds,O,Z,f,1))}function gF($,T,O){let{epochNanoseconds:Z,timeZone:f,calendar:j}=T,[z,F,W]=KO(O);if(z===0&&F===1)return T;let C=$(f);if(z===6)Z=((J,Y,D,U)=>{let X=L0(D,Y),[G,B]=J(X),L=D.epochNanoseconds,M=H0(Y,G),S=H0(Y,B);if(YF(L,M,S))throw RangeError(LT);return hF(Lf(L,M,S),U)?S:M})(pF,C,T,W);else{let J=C.getOffsetNanosecondsFor(Z);Z=s1(C,qF(V1(Z,J),z,F,W),J,2,0,1)}return J0(Z,f,j)}function kF($,T){return o(qF($,...KO(T)),$.calendar)}function RF($,T){let[O,Z,f]=KO(T,5);var j;return l0((j=f,Sf($,XT(O,Z),j)[0]))}function mF($,T){let O=$(T.timeZone),Z=L0(T,O),[f,j]=pF(Z),z=k0(g0(H0(O,f),H0(O,j)),iO,1);if(z<=0)throw RangeError(LT);return z}function yF($,T){let{timeZone:O,calendar:Z}=T,f=((j,z,F)=>H0(z,j(L0(F,z))))(iF,$(O),T);return J0(f,O,Z)}function qF($,T,O,Z){return cF($,XT(T,O),Z)}function cF($,T,O){let[Z,f]=Sf($,T,O);return W1({...u1($,f),...Z})}function Sf($,T,O){return XO(I1(M1($),T,O))}function OO($){return I1($,pO,7)}function XT($,T){return a0[$]*T}function pF($){let T=iF($);return[T,u1(T,1)]}function iF($){return L4(6,$)}function N2($,T,O){let Z=Math.min(p1($),6);return N$(IO(j0($,Z),T,O),Z)}function QO($,T,O,Z,f,j,z,F,W,C){if(Z===0&&f===1)return $;let J=jT(Z,F)?xO(F)&&Z<6&&O>=6?x2:E2:_2,[Y,D,U]=J($,T,O,Z,f,j,z,F,W,C);return U&&Z!==7&&(Y=((X,G,B,L,M,S,N,x)=>{let Q=A1(X);for(let I=L+1;I<=B;I++){if(I===7&&B!==7)continue;let _=x3(I,X);_[R[I]]+=Q;let P=k0(g0(N(x(M,S,_)),G));if(P&&Math.sign(P)!==Q)break;X=_}return X})(Y,D,O,Math.max(6,Z),z,F,W,C)),Y}function MO($,T,O,Z,f){if(T===6){let j=((z)=>z[0]+z[1]/y)($);return[I1(j,O,Z),0]}return IO($,XT(T,O),Z,f)}function IO($,T,O,Z){let[f,j]=$;Z&&j<0&&(j+=y,f-=1);let[z,F]=j1(I1(j,T,O),y);return Zf(f+z,F)}function I1($,T,O){return hF($/T,O)*T}function hF($,T){return R4[T]($)}function E2($,T,O,Z,f,j){let z=A1($),F=j0($),W=MO(F,Z,f,j),C=g0(F,W),J=Math.sign(W[0]-F[0])===z,Y=N$(W,Math.min(O,6));return[{...$,...Y},G$(T,C),J]}function x2($,T,O,Z,f,j,z,F,W,C){let J=A1($),Y=k0(j0($,5)),D=XT(Z,f),U=I1(Y,D,j),[X,G]=Kf(z,{...$,...E3},6,J,F,W,C),B=U-k0(g0(X,G)),L=0;B&&Math.sign(B)!==J?T=B$(X,U):(L+=J,U=I1(B,D,j),T=B$(G,U));let M=PO(U);return[{...$,...M,days:$.days+L},T,Boolean(L)]}function _2($,T,O,Z,f,j,z,F,W,C){let J=A1($),Y=R[Z],D=x3(Z,$);Z===7&&($={...$,weeks:$.weeks+Math.trunc($.days/7)});let U=WO($[Y],f)*f;D[Y]=U;let[X,G]=Kf(z,D,Z,f*J,F,W,C),B=U+Lf(T,X,G)*J*f,L=I1(B,f,j),M=Math.sign(L-B)===J;return D[Y]=L,[D,M?G:X,M]}function Qf($,T,O,Z){let[f,j,z,F]=((C)=>{let J=Yf(C=h0(C));return[C.timeZone,...J]})(Z),W=f!==void 0;return((C,J,Y,D,U,X)=>{Y=IO(Y,U,D,1);let G=J.getOffsetNanosecondsFor(Y);return xf(V1(Y,G),X)+(C?d1(OO(G)):"Z")})(W,T(W?$(f):$$),O.epochNanoseconds,j,z,F)}function Mf($,T,O){let[Z,f,j,z,F,W]=((C)=>{C=h0(C);let J=b3(C),Y=EF(C),D=k4(C),U=IT(C,4),X=MT(C,4);return[J,g4(C),D,U,...NF(X,Y)]})(O);return((C,J,Y,D,U,X,G,B,L,M)=>{D=IO(D,L,B,1);let S=C(Y).getOffsetNanosecondsFor(D);return xf(V1(D,S),M)+d1(OO(S),G)+((N,x)=>x!==1?"["+(x===2?"!":"")+W0(N)+"]":"")(Y,X)+_f(J,U)})($,T.calendar,T.timeZone,T.epochNanoseconds,Z,f,j,z,F,W)}function If($,T){let[O,Z,f,j]=((C)=>(C=h0(C),[b3(C),...Yf(C)]))(T);return z=$.calendar,F=O,W=j,xf(cF($,f,Z),W)+_f(z,F);var z,F,W}function Vf($,T){return O=$.calendar,Z=$,f=Df(T),ZO(Z)+_f(O,f);var O,Z,f}function Af($,T){return lF($.calendar,dF,$,Df(T))}function Nf($,T){return lF($.calendar,P2,$,Df(T))}function Ef($,T){let[O,Z,f]=AF(T);return j=f,sF(Sf($,Z,O)[0],j);var j}function VO($,T){let[O,Z,f]=AF(T,3);return Z>1&&($={...$,...N2($,Z,O)}),((j,z)=>{let{sign:F}=j,W=F===-1?S0(j):j,{hours:C,minutes:J}=W,[Y,D]=ff(j0(W,3),q0,Q1);$W(Y);let U=Pf(D,z),X=z>=0||!F||U;return(F<0?"-":"")+"P"+qz({Y:q1(W.years),M:q1(W.months),W:q1(W.weeks),D:q1(W.days)})+(C||J||Y||X?"T"+qz({H:q1(C),M:q1(J),S:q1(Y,X)+U}):"")})($,f)}function lF($,T,O,Z){let f=W0($),j=Z>1||Z===0&&f!==v;return Z===1?f===v?T(O):ZO(O):j?ZO(O)+uF(f,Z===2):T(O)}function qz($){let T=[];for(let O in $){let Z=$[O];Z&&T.push(Z,O)}return T.join("")}function xf($,T){return ZO($)+"T"+sF($,T)}function ZO($){return dF($)+"-"+y0($.isoDay)}function dF($){let{isoYear:T}=$;return(T<0||T>9999?nF(T)+rT(6,Math.abs(T)):rT(4,T))+"-"+y0($.isoMonth)}function P2($){return y0($.isoMonth)+"-"+y0($.isoDay)}function sF($,T){let O=[y0($.isoHour),y0($.isoMinute)];return T!==-1&&O.push(y0($.isoSecond)+((Z,f,j,z)=>Pf(Z*o0+f*t1+j,z))($.isoMillisecond,$.isoMicrosecond,$.isoNanosecond,T)),O.join(":")}function d1($,T=0){if(T===1)return"";let[O,Z]=j1(Math.abs($),iO),[f,j]=j1(Z,pO),[z,F]=j1(j,q0);return nF($)+y0(O)+":"+y0(f)+(z||F?":"+y0(z)+Pf(F):"")}function _f($,T){if(T!==1){let O=W0($);if(T>1||T===0&&O!==v)return uF(O,T===2)}return""}function uF($,T){return"["+(T?"!":"")+"u-ca="+$+"]"}function Pf($,T){let O=rT(9,$);return O=T===void 0?O.replace(q4,""):O.slice(0,T),O?"."+O:""}function nF($){return $<0?"-":"+"}function q1($,T){return $||T?$.toLocaleString("fullwide",{useGrouping:0}):""}function H2($,T){let{epochNanoseconds:O}=$,Z=(T.getOffsetNanosecondsFor?T:T($.timeZone)).getOffsetNanosecondsFor(O),f=V1(O,Z);return{calendar:$.calendar,...f,offsetNanoseconds:Z}}function aF($,T){let O=L0(T,$);return{calendar:T.calendar,...w0(ZC,O),offset:d1(O.offsetNanoseconds),timeZone:T.timeZone}}function s1($,T,O,Z=0,f=0,j,z){if(O!==void 0&&Z===1&&(Z===1||z))return Ff(T,O);let F=$.getPossibleInstantsFor(T);if(O!==void 0&&Z!==3){let W=((C,J,Y,D)=>{let U=G0(J);D&&(Y=OO(Y));for(let X of C){let G=k0(g0(X,U));if(D&&(G=OO(G)),G===Y)return X}})(F,T,O,j);if(W!==void 0)return W;if(Z===0)throw RangeError(Z4)}return z?G0(T):H0($,T,f,F)}function H0($,T,O=0,Z=$.getPossibleInstantsFor(T)){if(Z.length===1)return Z[0];if(O===1)throw RangeError(f4);if(Z.length)return Z[O===3?1:0];let f=G0(T),j=((F,W)=>{let C=F.getOffsetNanosecondsFor(B$(W,-y));return wf(F.getOffsetNanosecondsFor(B$(W,y))-C)})($,f),z=j*(O===2?-1:1);return(Z=$.getPossibleInstantsFor(V1(f,z)))[O===2?0:Z.length-1]}function Hf($){if(Math.abs($)>=y)throw RangeError(T4);return $}function wf($){if($>y)throw RangeError(O4);return $}function bf($,T,O){return F0(R0(G$(T.epochNanoseconds,((Z)=>{if(TW(Z))throw RangeError(F4);return j0(Z,5)})($?S0(O):O))))}function vf($,T,O,Z,f,j=Object.create(null)){let z=T(Z.timeZone),F=$(Z.calendar);return{...Z,...yf(z,F,Z,O?S0(f):f,j)}}function gf($,T,O,Z,f=Object.create(null)){let{calendar:j}=O;return o(qf($(j),O,T?S0(Z):Z,f),j)}function kf($,T,O,Z,f){let{calendar:j}=O;return t(AO($(j),O,T?S0(Z):Z,f),j)}function Rf($,T,O,Z,f=Object.create(null)){let j=O.calendar,z=$(j),F=fT(z,O);T&&(Z=_O(Z)),Z.sign<0&&(F=z.dateAdd(F,{...C0,months:1}),F=u1(F,-1));let W=z.dateAdd(F,Z,f);return c1(fT(z,W),j)}function mf($,T,O){return l0(oF(T,$?S0(O):O)[0])}function yf($,T,O,Z,f){let j=j0(Z,5),z=O.epochNanoseconds;if(TW(Z)){let F=L0(O,$);z=G$(H0($,{...AO(T,F,{...Z,...E3},f),...w0(s0,F)}),j)}else z=G$(z,j),k(f);return{epochNanoseconds:R0(z)}}function qf($,T,O,Z){let[f,j]=oF(T,O);return W1({...AO($,T,{...O,...E3,days:O.days+j},Z),...f})}function AO($,T,O,Z){if(O.years||O.months||O.weeks)return $.dateAdd(T,O,Z);k(Z);let f=O.days+j0(O,5)[0];return f?L1(u1(T,f)):T}function fT($,T,O=1){return u1(T,O-$.day(T))}function oF($,T){let[O,Z]=j0(T,5),[f,j]=XO(M1($)+Z);return[f,O+j]}function u1($,T){return T?{...$,...UO(K0($)+T*_0)}:$}function NO($,T,O){let Z=$(O.calendar);return xO(O)?[O,Z,T(O.timeZone)]:[{...O,...c0},Z]}function cf($){return $?wF:G0}function EO($){return $?b(yf,$):qf}function pf($){return $?b(b2,$):v2}function xO($){return $&&$.epochNanoseconds}function jT($,T){return $<=6-(xO(T)?1:0)}function hf($,T,O,Z,f,j,z){let F=$(h0(z).relativeTo),W=Math.max(p1(f),p1(j));if(jT(W,F))return i(A$(((G,B,L,M)=>{let S=G$(j0(G),j0(B),M?-1:1);if(!Number.isFinite(S[0]))throw RangeError(qO);return{...C0,...N$(S,L)}})(f,j,W,Z)));if(!F)throw RangeError(cO);Z&&(j=S0(j));let[C,J,Y]=NO(T,O,F),D=EO(Y),U=pf(Y),X=D(J,C,f);return i(U(J,C,D(J,X,j),W))}function tF($,T,O,Z,f){let j=p1(Z),[z,F,W,C,J]=((Q,I,_)=>{Q=Gf(Q,zO);let P=w3(Q),O0=_(Q[jC]),g=Xf(Q),m=IT(Q,7),Z0=MT(Q);if(P===void 0&&Z0===void 0)throw RangeError(W4);return Z0==null&&(Z0=0),P==null&&(P=Math.max(Z0,I)),xF(P,Z0),g=Uf(g,Z0,1),[P,Z0,g,m,O0]})(f,j,$),Y=Math.max(j,z);if(!xO(J)&&Y<=6)return i(A$(((Q,I,_,P,O0)=>{let g=MO(j0(Q),_,P,O0);return{...C0,...N$(g,I)}})(Z,z,F,W,C)));if(!J)throw RangeError(cO);let[D,U,X]=NO(T,O,J),G=cf(X),B=EO(X),L=pf(X),M=B(U,D,Z),S=L(U,D,M,z),N=Z.sign,x=A1(S);if(N&&x&&N!==x)throw RangeError(LT);return x&&(S=QO(S,G(M),z,F,W,C,U,D,G,B)),i(S)}function rF($){return $.sign===-1?_O($):$}function _O($){return i(S0($))}function S0($){let T={};for(let O of R)T[O]=-1*$[O]||0;return T}function eF($){return!$.sign}function A1($,T=R){let O=0;for(let Z of T){let f=Math.sign($[Z]);if(f){if(O&&O!==f)throw RangeError(z4);O=f}}return O}function A$($){for(let T of B4)m0(T,$[T],-sz,sz,1);return $W(k0(j0($),q0)),$}function $W($){if(!Number.isSafeInteger($))throw RangeError(j4)}function j0($,T=6){return TF($,T,R)}function N$($,T=6){let[O,Z]=$,f=CO(Z,T,R);if(f[R[T]]+=O*(y/a0[T]),!Number.isFinite(f[R[T]]))throw RangeError(qO);return f}function PO($,T=5){return CO($,T,R)}function TW($){return Boolean(A1($,TC))}function p1($){let T=9;for(;T>0&&!$[R[T]];T--);return T}function w2($,T){return[$,T]}function cz($){let T=Math.floor($/oT)*oT;return[T,T+oT]}function OW($){let T=N1($=eT($));if(!T)throw RangeError(x0($));let O;if(T.m)O=0;else{if(!T.offset)throw RangeError(x0($));O=E$(T.offset)}return T.timeZone&&uf(T.timeZone,1),F0(Ff(GO(T),O))}function ZW($){let T=N1(h($));if(!T)throw RangeError(x0($));if(T.timeZone)return YW(T,T.offset?E$(T.offset):void 0);if(T.m)throw RangeError(x0($));return UW(T)}function fW($,T){let O=N1(h($));if(!O||!O.timeZone)throw RangeError(x0($));let{offset:Z}=O,f=Z?E$(Z):void 0,[,j,z]=YT(T);return YW(O,f,j,z)}function E$($){let T=uf($);if(T===void 0)throw RangeError(x0($));return T}function jW($){let T=N1(h($));if(!T||T.m)throw RangeError(x0($));return o(XW(T))}function HO($){let T=N1(h($));if(!T||T.m)throw RangeError(x0($));return t(T.p?XW(T):UW(T))}function zW($,T){let O=df(h(T));if(O)return lf(O),c1(zf(h1(O)));let Z=HO(T);return c1(fT($(Z.calendar),Z))}function lf($){if($.calendar!==v)throw RangeError(z1($.calendar))}function FW($,T){let O=sf(h(T));if(O)return lf(O),TO(h1(O));let Z=HO(T),{calendar:f}=Z,j=$(f),[z,F,W]=j.h(Z),[C,J]=j.I(z,F),[Y,D]=j.N(C,J,W);return TO(L1(j.P(Y,D,W)),f)}function WW($){let T,O=((Z)=>{let f=l4.exec(Z);return f?(wO(f[10]),KW(f)):void 0})(h($));if(!O){if(O=N1($),!O)throw RangeError(x0($));if(!O.p)throw RangeError(x0($));if(O.m)throw RangeError(z1("Z"));lf(O)}if((T=df($))&&mz(T))throw RangeError(x0($));if((T=sf($))&&mz(T))throw RangeError(x0($));return l0(BO(O,1))}function CW($){let T=((O)=>{let Z=u4.exec(O);return Z?((f)=>{function j(J,Y,D){let U=0,X=0;if(D&&([U,W]=j1(W,a0[D])),J!==void 0){if(F)throw RangeError(z1(J));X=((G)=>{let B=parseInt(G);if(!Number.isFinite(B))throw RangeError(z1(G));return B})(J),z=1,Y&&(W=nf(Y)*(a0[D]/q0),F=1)}return U+X}let z=0,F=0,W=0,C={...Q$(R,[j(f[2]),j(f[3]),j(f[4]),j(f[5]),j(f[6],f[7],5),j(f[8],f[9],4),j(f[10],f[11],3)]),...CO(W,2,R)};if(!z)throw RangeError(g6(R));return af(f[1])<0&&(C=S0(C)),C})(Z):void 0})(h($));if(!T)throw RangeError(x0($));return i(A$(T))}function JW($){let T=N1($)||df($)||sf($);return T?T.calendar:$}function DW($){let T=N1($);return T&&(T.timeZone||T.m&&$$||T.offset)||$}function YW($,T,O=0,Z=0){let f=bO($.timeZone),j=aO(f);return J0(s1(j,GO($),T,O,Z,!j.v,$.m),f,UT($.calendar))}function XW($){return GW(W1(GO($)))}function UW($){return GW(L1(h1($)))}function GW($){return{...$,calendar:UT($.calendar)}}function N1($){let T=h4.exec($);return T?((O)=>{let Z=O[10],f=(Z||"").toUpperCase()==="Z";return{isoYear:BW(O),isoMonth:parseInt(O[4]),isoDay:parseInt(O[5]),...KW(O.slice(5)),...wO(O[16]),p:Boolean(O[6]),m:f,offset:f?void 0:Z}})(T):void 0}function df($){let T=p4.exec($);return T?((O)=>({isoYear:BW(O),isoMonth:parseInt(O[4]),isoDay:1,...wO(O[5])}))(T):void 0}function sf($){let T=i4.exec($);return T?((O)=>({isoYear:S$,isoMonth:parseInt(O[1]),isoDay:parseInt(O[2]),...wO(O[3])}))(T):void 0}function uf($,T){let O=d4.exec($);return O?((Z,f)=>{let j=Z[4]||Z[5];if(f&&j)throw RangeError(z1(j));return Hf((U$(Z[2])*iO+U$(Z[3])*pO+U$(Z[4])*q0+nf(Z[5]||""))*af(Z[1]))})(O,T):void 0}function BW($){let T=af($[1]),O=parseInt($[2]||$[3]);if(T<0&&!O)throw RangeError(z1(-0));return T*O}function KW($){let T=U$($[3]);return{...XO(nf($[4]||""))[0],isoHour:U$($[1]),isoMinute:U$($[2]),isoSecond:T===60?59:T}}function wO($){let T,O,Z=[];if($.replace(s4,(f,j,z)=>{let F=Boolean(j),[W,C]=z.split("=").reverse();if(C){if(C==="u-ca")Z.push(W),T||(T=F);else if(F||/[A-Z]/.test(C))throw RangeError(z1(f))}else{if(O)throw RangeError(z1(f));O=W}return""}),Z.length>1&&T)throw RangeError(z1($));return{timeZone:O,calendar:Z[0]||v}}function nf($){return parseInt($.padEnd(9,"0"))}function x$($){return new RegExp(`^${$}$`,"i")}function af($){return $&&$!=="+"?-1:1}function U$($){return $===void 0?0:parseInt($)}function LW($){return bO(h($))}function bO($){let T=of($);return typeof T=="number"?d1(T):T?((O)=>{if(a4.test(O))throw RangeError($4);return O.toLowerCase().split("/").map((Z,f)=>(Z.length<=3||/\d/.test(Z))&&!/etc|yap/.test(Z)?Z.toUpperCase():Z.replace(/baja|dumont|[a-z]+/g,(j,z)=>j.length<=2&&!f||j==="in"||j==="chat"?j.toUpperCase():j.length>2||!z?kz(j).replace(/island|noronha|murdo|rivadavia|urville/,kz):j)).join("/")})($):$$}function pz($){let T=of($);return typeof T=="number"?T:T?T.resolvedOptions().timeZone:$$}function of($){let T=uf($=$.toUpperCase(),1);return T!==void 0?T:$!==$$?n4($):void 0}function tf($,T){return B0($.epochNanoseconds,T.epochNanoseconds)}function rf($,T){return B0($.epochNanoseconds,T.epochNanoseconds)}function SW($,T,O,Z,f,j){let z=$(h0(j).relativeTo),F=Math.max(p1(Z),p1(f));if(ez(R,Z,f))return 0;if(jT(F,z))return B0(j0(Z),j0(f));if(!z)throw RangeError(cO);let[W,C,J]=NO(T,O,z),Y=cf(J),D=EO(J);return B0(Y(D(C,W,Z)),Y(D(C,W,f)))}function ef($,T){return n1($,T)||vO($,T)}function n1($,T){return K1(K0($),K0(T))}function vO($,T){return K1(M1($),M1(T))}function QW($,T){return!tf($,T)}function MW($,T){return!rf($,T)&&!!gO($.timeZone,T.timeZone)&&V$($.calendar,T.calendar)}function IW($,T){return!ef($,T)&&V$($.calendar,T.calendar)}function VW($,T){return!n1($,T)&&V$($.calendar,T.calendar)}function AW($,T){return!n1($,T)&&V$($.calendar,T.calendar)}function NW($,T){return!n1($,T)&&V$($.calendar,T.calendar)}function EW($,T){return!vO($,T)}function gO($,T){if($===T)return 1;let O=W0($),Z=W0(T);if(O===Z)return 1;try{return pz(O)===pz(Z)}catch(f){}}function $3($,T,O,Z){let f=I$($,a(Z),3,5),j=kO(T.epochNanoseconds,O.epochNanoseconds,...f);return i($?S0(j):j)}function T3($,T,O,Z,f,j){let z=mO(Z.calendar,f.calendar),F=a(j),[W,C,J,Y]=I$(O,F,5),D=Z.epochNanoseconds,U=f.epochNanoseconds,X=B0(U,D),G;if(X)if(W<6)G=kO(D,U,W,C,J,Y);else{let B=T(((M,S)=>{if(!gO(M,S))throw RangeError(c6);return M})(Z.timeZone,f.timeZone)),L=$(z);G=_W(L,B,Z,f,X,W,F),G=QO(G,U,W,C,J,Y,L,Z,wF,b(yf,B))}else G=C0;return i(O?S0(G):G)}function O3($,T,O,Z,f){let j=mO(O.calendar,Z.calendar),z=a(f),[F,W,C,J]=I$(T,z,6),Y=G0(O),D=G0(Z),U=B0(D,Y),X;if(U)if(F<=6)X=kO(Y,D,F,W,C,J);else{let G=$(j);X=PW(G,O,Z,U,F,z),X=QO(X,D,F,W,C,J,G,O,G0,qf)}else X=C0;return i(T?S0(X):X)}function Z3($,T,O,Z,f){let j=mO(O.calendar,Z.calendar),z=a(f);return xW(T,()=>$(j),O,Z,...I$(T,z,6,9,6),z)}function f3($,T,O,Z,f){let j=mO(O.calendar,Z.calendar),z=a(f),F=I$(T,z,9,9,8),W=$(j);return xW(T,()=>W,fT(W,O),fT(W,Z),...F,z)}function xW($,T,O,Z,f,j,z,F,W){let C=G0(O),J=G0(Z),Y;if(B0(J,C))if(f===6)Y=kO(C,J,f,j,z,F);else{let D=T();Y=D.dateUntil(O,Z,f,W),j===6&&z===1||(Y=QO(Y,J,f,j,z,F,D,O,G0,AO))}else Y=C0;return i($?S0(Y):Y)}function j3($,T,O,Z){let f=a(Z),[j,z,F,W]=I$($,f,5,5),C=I1(z3(T,O),XT(z,F),W),J={...C0,...PO(C,j)};return i($?S0(J):J)}function b2($,T,O,Z,f,j){let z=B0(Z.epochNanoseconds,O.epochNanoseconds);return z?f<6?HW(O.epochNanoseconds,Z.epochNanoseconds,f):_W(T,$,O,Z,z,f,j):C0}function v2($,T,O,Z,f){let j=G0(T),z=G0(O),F=B0(z,j);return F?Z<=6?HW(j,z,Z):PW($,T,O,F,Z,f):C0}function _W($,T,O,Z,f,j,z){let[F,W,C]=((D,U,X,G)=>{function B(){return I={...u1(S,x++*-G),...M},_=H0(D,I),B0(N,_)===-G}let L=L0(U,D),M=w0(s0,L),S=L0(X,D),N=X.epochNanoseconds,x=0,Q=z3(L,S),I,_;if(Math.sign(Q)===-G&&x++,B()&&(G===-1||B()))throw RangeError(LT);let P=k0(g0(_,N));return[L,I,P]})(T,O,Z,f);var J,Y;return{...j===6?(J=F,Y=W,{...C0,days:wW(J,Y)}):$.dateUntil(F,W,j,z),...PO(C)}}function PW($,T,O,Z,f,j){let[z,F,W]=((C,J,Y)=>{let D=J,U=z3(C,J);return Math.sign(U)===-Y&&(D=u1(J,-Y),U+=y*Y),[C,D,U]})(T,O,Z);return{...$.dateUntil(z,F,f,j),...PO(W)}}function kO($,T,O,Z,f,j){return{...C0,...N$(MO(g0($,T),Z,f,j),O)}}function HW($,T,O){return{...C0,...N$(g0($,T),O)}}function wW($,T){return RO(K0($),K0(T))}function RO($,T){return Math.trunc((T-$)/_0)}function z3($,T){return M1(T)-M1($)}function mO($,T){if(!V$($,T))throw RangeError(M3);return $}function g2($){function T(f){return((j,z)=>({...bW(j,z),F:j.month,day:parseInt(j.day)}))(jf(O,f),Z)}let O=R3($),Z=fO($);return{id:$,O:k2(T),B:R2(T)}}function k2($){return P0((T)=>{let O=K0(T);return $(O)},WeakMap)}function R2($){let T=$(0).year-I4;return P0((O)=>{let Z,f=M$(O-T),j=[],z=[];do f+=400*_0;while((Z=$(f)).year<=O);do f+=(1-Z.day)*_0,Z.year===O&&(j.push(f),z.push(Z.F)),f-=_0;while((Z=$(f)).year>=O);return{k:j.reverse(),C:h6(z.reverse())}})}function bW($,T){let O,Z,f=vW($);if($.era){let j=r6[T];j!==void 0&&(O=T==="islamic"?"ah":$.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),O==="bc"||O==="b"?O="bce":O!=="ad"&&O!=="a"||(O="ce"),Z=f,f=yW(Z,j[O]||0))}return{era:O,eraYear:Z,year:f}}function vW($){return parseInt($.relatedYear||$.year)}function hZ($){let{year:T,F:O,day:Z}=this.O($),{C:f}=this.B(T);return[T,f[O]+1,Z]}function zT($,T=1,O=1){return this.B($).k[T-1]+(O-1)*_0}function uT($){let T=hz(this,$),O=hz(this,$-1),Z=T.length;if(Z>O.length){let f=qW(this);if(f<0)return-f;for(let j=0;j<Z;j++)if(T[j]!==O[j])return j+1}}function nT($){return RO(zT.call(this,$),zT.call(this,$+1))}function iz($,T){let{k:O}=this.B($),Z=T+1,f=O;return Z>O.length&&(Z=1,f=this.B($+1).k),RO(O[T-1],f[Z-1])}function aT($){return this.B($).k.length}function hz($,T){return Object.keys($.B(T).C)}function gW($){return UT(h($))}function UT($){if(($=$.toLowerCase())!==v&&$!==lO&&fO($)!==fO(R3($).resolvedOptions().calendar))throw RangeError(e2($));return $}function fO($){return $==="islamicc"&&($="islamic"),$.split("-")[0]}function kW($){return this.R($)[0]}function RW($){return this.R($)[1]}function F3($){let[T]=this.h($);return RO(this.q(T),K0($))+1}function mW($){let T=t4.exec($);if(!T)throw RangeError(t2($));return[parseInt(T[1]),Boolean(T[2])]}function jO($,T,O){return $+(T||O&&$>=O?1:0)}function lZ($,T){return $-(T&&$>=T?1:0)}function yW($,T){return(T+$)*(Math.sign(T)||1)||0}function dZ($){return r6[cW($)]}function qW($){return X4[cW($)]}function cW($){return fO($.id||v)}function pW($,T,O,Z){let f=E1(O,Z,d0,[],n6);if(f.timeZone!==void 0){let j=O.dateFromFields(f),z=a1(f),F=$(f.timeZone);return{epochNanoseconds:s1(T(F),{...j,...z},f.offset!==void 0?E$(f.offset):void 0),timeZone:F}}return{...O.dateFromFields(f),...c0}}function iW($,T,O,Z,f,j){let z=E1(O,f,d0,s6,n6),F=$(z.timeZone),[W,C,J]=YT(j),Y=O.dateFromFields(z,LO(j,W)),D=a1(z,W);return J0(s1(T(F),{...Y,...D},z.offset!==void 0?E$(z.offset):void 0,C,J),F,Z)}function hW($,T,O){let Z=E1($,T,d0,[],D1),f=k(O);return o(W1({...$.dateFromFields(Z,LO(O,f)),...a1(Z,f)}))}function W3($,T,O,Z=[]){let f=E1($,T,d0,Z);return $.dateFromFields(f,O)}function C3($,T,O,Z){let f=E1($,T,A3,Z);return $.yearMonthFromFields(f,O)}function J3($,T,O,Z,f=[]){let j=E1($,O,d0,f);return T&&j.month!==void 0&&j.monthCode===void 0&&j.year===void 0&&(j.year=S$),$.monthDayFromFields(j,Z)}function lW($,T){let O=k(T);return l0(a1(n0($,uZ,[],1),O))}function dW($){let T=n0($,N3);return i(A$({...C0,...T}))}function E1($,T,O,Z=[],f=[]){return n0(T,[...$.fields(O),...f].sort(),Z)}function n0($,T,O,Z=!O){let f={},j,z=0;for(let F of T){if(F===j)throw RangeError(d2(F));if(F==="constructor"||F==="__proto__")throw RangeError(S3(F));let W=$[F];if(W!==void 0)z=1,uz[F]&&(W=uz[F](W,F)),f[F]=W;else if(O){if(O.includes(F))throw TypeError(L3(F));f[F]=t6[F]}j=F}if(Z&&!z)throw TypeError(g6(T));return f}function a1($,T){return BO(T5({...t6,...$}),T)}function sW($,T,O,Z,f,j){let z=a(j),{calendar:F,timeZone:W}=O;return J0(((C,J,Y,D,U)=>{let X=GT(C,Y,D,d0,u6,d6),[G,B,L]=YT(U,2);return s1(J,{...C.dateFromFields(X,LO(U,G)),...a1(X,G)},E$(X.offset),B,L)})($(F),T(W),Z,f,z),W,F)}function uW($,T,O,Z,f){let j=a(f);return o(((z,F,W,C)=>{let J=GT(z,F,W,d0,D1),Y=k(C);return W1({...z.dateFromFields(J,LO(C,Y)),...a1(J,Y)})})($(T.calendar),O,Z,j))}function nW($,T,O,Z,f){let j=a(f);return((z,F,W,C)=>{let J=GT(z,F,W,d0);return z.dateFromFields(J,C)})($(T.calendar),O,Z,j)}function aW($,T,O,Z,f){let j=a(f);return c1(((z,F,W,C)=>{let J=GT(z,F,W,A3);return z.yearMonthFromFields(J,C)})($(T.calendar),O,Z,j))}function oW($,T,O,Z,f){let j=a(f);return((z,F,W,C)=>{let J=GT(z,F,W,d0);return z.monthDayFromFields(J,C)})($(T.calendar),O,Z,j)}function tW($,T,O){return l0(((Z,f,j)=>{let z=k(j);return a1({...w0(uZ,Z),...n0(f,uZ)},z)})($,T,O))}function rW($,T){return i((O=$,Z=T,A$({...O,...n0(Z,N3)})));var O,Z}function GT($,T,O,Z,f=[],j=[]){let z=[...$.fields(Z),...f].sort(),F=n0(T,z,j),W=n0(O,z);return F=$.mergeFields(F,W),n0(F,z,[])}function D3($,T){let O=E1($,T,o6);return $.monthDayFromFields(O)}function Y3($,T,O){let Z=E1($,T,a6);return $.yearMonthFromFields(Z,O)}function eW($,T,O,Z,f){T=w0(O=$.fields(O),T),Z=n0(Z,f=$.fields(f),[]);let j=$.mergeFields(T,Z);return j=n0(j,[...O,...f].sort(),[]),$.dateFromFields(j)}function yZ($,T){let{era:O,eraYear:Z,year:f}=T,j=dZ($);if(O!==void 0||Z!==void 0){if(O===void 0||Z===void 0)throw TypeError(u2);if(!j)throw RangeError(s2);let z=j[O];if(z===void 0)throw RangeError(a2(O));let F=yW(Z,z);if(f!==void 0&&f!==F)throw RangeError(n2);f=F}else if(f===void 0)throw TypeError(o2(j));return f}function qZ($,T,O,Z){let{month:f,monthCode:j}=T;if(j!==void 0){let z=((F,W,C,J)=>{let Y=F.U(C),[D,U]=mW(W),X=jO(D,U,Y);if(U){let G=qW(F);if(G===void 0)throw RangeError(TT);if(G>0){if(X>G)throw RangeError(TT);if(Y===void 0){if(J===1)throw RangeError(TT);X--}}else{if(X!==-G)throw RangeError(TT);if(Y===void 0&&J===1)throw RangeError(TT)}}return X})($,j,O,Z);if(f!==void 0&&f!==z)throw RangeError(y6);f=z,Z=1}else if(f===void 0)throw TypeError(r2);return m0("month",f,1,$.L(O),Z)}function lz($,T,O,Z,f){return E0(T,"day",1,$.j(Z,O),f)}function cZ($,T,O,Z){let f=0,j=[];for(let z of O)T[z]!==void 0?f=1:j.push(z);if(Object.assign($,T),f)for(let z of Z||j)delete $[z]}function $6($){return F0(R0(YO(DO($))))}function T6($,T,O,Z,f=v){return J0(R0(YO(DO(O))),T(Z),$(f))}function O6($,T,O,Z,f=0,j=0,z=0,F=0,W=0,C=0,J=v){return o(W1(GO(p0(U0,Q$(dO,[T,O,Z,f,j,z,F,W,C])))),$(J))}function Z6($,T,O,Z,f=v){return t(L1(h1(p0(U0,{isoYear:T,isoMonth:O,isoDay:Z}))),$(f))}function f6($,T,O,Z=v,f=1){let j=U0(T),z=U0(O),F=$(Z);return c1(zf(h1({isoYear:j,isoMonth:z,isoDay:U0(f)})),F)}function j6($,T,O,Z=v,f=S$){let j=U0(T),z=U0(O),F=$(Z);return TO(L1(h1({isoYear:U0(f),isoMonth:j,isoDay:z})),F)}function z6($=0,T=0,O=0,Z=0,f=0,j=0){return l0(BO(p0(U0,Q$(s0,[$,T,O,Z,f,j])),1))}function F6($=0,T=0,O=0,Z=0,f=0,j=0,z=0,F=0,W=0,C=0){return i(A$(p0(DF,Q$(R,[$,T,O,Z,f,j,z,F,W,C]))))}function X3($,T,O=v){return J0($.epochNanoseconds,T,O)}function W6($){return F0($.epochNanoseconds)}function U3($,T){return o(L0(T,$))}function G3($,T){return t(L0(T,$))}function C6($,T,O){return Y3($(T.calendar),O)}function J6($,T,O){return D3($(T.calendar),O)}function B3($,T){return l0(L0(T,$))}function D6($,T,O,Z){let f=((j,z,F,W)=>{let C=Jf(W);return H0(j(z),F,C)})($,O,T,Z);return J0(R0(f),O,T.calendar)}function Y6($,T,O){let Z=$(T.calendar);return c1({...T,...Y3(Z,O)})}function X6($,T,O){return D3($(T.calendar),O)}function U6($,T,O,Z,f){let j=$(f.timeZone),z=f.plainTime,F=z!==void 0?T(z):c0;return J0(H0(O(j),{...Z,...F}),j,Z.calendar)}function G6($,T=c0){return o(W1({...$,...T}))}function B6($,T,O){return Y3($(T.calendar),O)}function K6($,T,O){return D3($(T.calendar),O)}function L6($,T,O,Z){return((f,j,z)=>eW(f,j,a6,F1(z),QT))($(T.calendar),O,Z)}function S6($,T,O,Z){return((f,j,z)=>eW(f,j,o6,F1(z),hO))($(T.calendar),O,Z)}function Q6($,T,O,Z,f){let j=F1(f),z=T(j.plainDate),F=$(j.timeZone);return J0(H0(O(F),{...z,...Z}),F,z.calendar)}function M6($,T){return o(W1({...$,...T}))}function I6($){return F0(R0(K$($,q0)))}function V6($){return F0(R0(K$($,o0)))}function A6($){return F0(R0(YO(DO($),t1)))}function N6($){return F0(R0(YO(DO($))))}function E6($,T,O=c0){let Z=T.timeZone,f=$(Z),j={...L0(T,f),...O};return J0(s1(f,j,j.offsetNanoseconds,2),Z,T.calendar)}function x6($,T,O){let Z=T.timeZone,f=$(Z),j={...L0(T,f),...O},z=w6(T.calendar,O.calendar);return J0(s1(f,j,j.offsetNanoseconds,2),Z,z)}function _6($,T=c0){return o({...$,...T})}function P6($,T){return o({...$,...T},w6($.calendar,T.calendar))}function yO($,T){return{...$,calendar:T}}function H6($,T){return{...$,timeZone:T}}function w6($,T){if($===T)return $;let O=W0($),Z=W0(T);if(O===Z||O===v)return T;if(Z===v)return $;throw RangeError(M3)}function m2($,T){return(O)=>O===v?$:O===lO||O===L$?Object.assign(Object.create($),{id:O}):Object.assign(Object.create(T),o4(O))}function o1($,T,O){let Z=new Set(O);return(f)=>(((j,z)=>{for(let F of z)if(F in j)return 1;return 0})(f=tZ(Z,f),$)||Object.assign(f,T),O&&(f.timeZone=$$,["full","long"].includes(f.timeStyle)&&(f.timeStyle="medium")),f)}function C1($,T=K3){let[O,,,Z]=$;return(f,j=K5,...z)=>{let F=T(Z&&Z(...z),f,j,O),W=F.resolvedOptions();return[F,...y2($,W,z)]}}function K3($,T,O,Z){if(O=Z(O),$){if(O.timeZone!==void 0)throw TypeError(J4);O.timeZone=$}return new x1(T,O)}function y2($,T,O){let[,Z,f]=$;return O.map((j)=>(j.calendar&&((z,F,W)=>{if((W||z!==v)&&z!==F)throw RangeError(M3)})(W0(j.calendar),T.calendar,f),Z(j,T)))}function _$($){let T=BT();return V1(T,$.getOffsetNanosecondsFor(T))}function BT(){return K$(Date.now(),o0)}function J1(){return az||(az=new x1().resolvedOptions().timeZone)}var q2=($,T)=>`Non-integer ${$}: ${T}`,c2=($,T)=>`Non-positive ${$}: ${T}`,p2=($,T)=>`Non-finite ${$}: ${T}`,i2=($)=>`Cannot convert bigint to ${$}`,h2=($)=>`Invalid bigint: ${$}`,l2="Cannot convert Symbol to string",b6="Invalid object",v6=($,T,O,Z,f)=>f?v6($,f[T],f[O],f[Z]):KT($,T)+`; must be between ${O}-${Z}`,KT=($,T)=>`Invalid ${$}: ${T}`,L3=($)=>`Missing ${$}`,S3=($)=>`Invalid field ${$}`,d2=($)=>`Duplicate field ${$}`,g6=($)=>"No valid fields: "+$.join(),k6="Invalid bag",R6=($,T,O)=>KT($,T)+"; must be "+Object.keys(O).join(),m6="Cannot use valueOf",Q3="Invalid calling context",s2="Forbidden era/eraYear",u2="Mismatching era/eraYear",n2="Mismatching year/eraYear",a2=($)=>`Invalid era: ${$}`,o2=($)=>"Missing year"+($?"/era/eraYear":""),t2=($)=>`Invalid monthCode: ${$}`,y6="Mismatching month/monthCode",r2="Missing month/monthCode",dz="Cannot guess year",TT="Invalid leap month",q6="Invalid protocol",LT="Invalid protocol results",M3="Mismatching Calendars",e2=($)=>`Invalid Calendar: ${$}`,c6="Mismatching TimeZones",$4="Forbidden ICU TimeZone",T4="Out-of-bounds offset",O4="Out-of-bounds TimeZone gap",Z4="Invalid TimeZone offset",f4="Ambiguous offset",qO="Out-of-bounds date",j4="Out-of-bounds duration",z4="Cannot mix duration signs",cO="Missing relativeTo",F4="Cannot use large units",W4="Required smallestUnit or largestUnit",C4="smallestUnit > largestUnit",x0=($)=>`Cannot parse: ${$}`,z1=($)=>`Invalid substring: ${$}`,p6=($)=>`Cannot format ${$}`,i6="Mismatching types for formatting",J4="Cannot specify TimeZone",h6=b(CT,($,T)=>T),P$=b(CT,($,T,O)=>O),y0=b(rT,2),sZ={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},ST=Object.keys(sZ),_0=86400000,l6=1000,t1=1000,o0=1e6,q0=1e9,pO=60000000000,iO=3600000000000,y=86400000000000,a0=[1,t1,o0,q0,pO,iO,y],D1=ST.slice(0,6),uZ=JT(D1),d6=["offset"],s6=["timeZone"],u6=D1.concat(d6),n6=u6.concat(s6),nZ=["era","eraYear"],D4=nZ.concat(["year"]),hO=["year"],I3=["monthCode"],V3=["month"].concat(I3),QT=["day"],A3=V3.concat(hO),a6=I3.concat(hO),d0=QT.concat(A3),Y4=QT.concat(V3),o6=QT.concat(I3),t6=P$(D1,0),v="iso8601",lO="gregory",L$="japanese",r6={[lO]:{bce:-1,ce:0},[L$]:{bce:-1,ce:0,meiji:1867,taisho:1911,showa:1925,heisei:1988,reiwa:2018},ethioaa:{era0:0},ethiopic:{era0:0,era1:5500},coptic:{era0:-1,era1:0},roc:{beforeroc:-1,minguo:0},buddhist:{be:0},islamic:{ah:0},indian:{saka:0},persian:{ap:0}},X4={chinese:13,dangi:13,hebrew:-6},h=b(JO,"string"),e6=b(JO,"boolean"),U4=b(JO,"number"),$C=b(JO,"function"),R=ST.map(($)=>$+"s"),N3=JT(R),G4=R.slice(0,6),TC=R.slice(6),B4=TC.slice(1),K4=h6(R),C0=P$(R,0),E3=P$(G4,0),x3=b($F,R),s0=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],_3=["isoDay","isoMonth","isoYear"],dO=s0.concat(_3),P3=JT(_3),OC=JT(s0),ZC=JT(dO),c0=P$(OC,0),L4=b($F,dO),x1=Intl.DateTimeFormat,fC="en-GB",H3=1e8,S4=H3*_0,Q4=[H3,0],M4=[-H3,0],FT=275760,WT=-271821,I4=1970,S$=1972,f1=12,V4=M$(1868,9,8),A4=P0(A2,WeakMap),zO="smallestUnit",aZ="unit",ZT="roundingIncrement",pZ="fractionalSecondDigits",jC="relativeTo",zC={constrain:0,reject:1},N4=Object.keys(zC),E4={compatible:0,reject:1,earlier:2,later:3},x4={reject:0,use:1,prefer:2,ignore:3},_4={auto:0,never:1,critical:2,always:3},P4={auto:0,never:1,critical:2},H4={auto:0,never:1},w4={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},MT=b(Bf,zO),w3=b(Bf,"largestUnit"),b4=b(Bf,aZ),FC=b(l1,"overflow",zC),WC=b(l1,"disambiguation",E4),v4=b(l1,"offset",x4),b3=b(l1,"calendarName",_4),g4=b(l1,"timeZoneName",P4),k4=b(l1,"offset",H4),IT=b(l1,"roundingMode",w4),H$="PlainYearMonth",w$="PlainMonthDay",r1="PlainDate",e1="PlainDateTime",sO="PlainTime",Y1="ZonedDateTime",uO="Instant",nO="Duration",R4=[Math.floor,($)=>sT($)?Math.floor($):Math.round($),Math.ceil,($)=>sT($)?Math.ceil($):Math.round($),Math.trunc,($)=>sT($)?Math.trunc($)||0:Math.round($),($)=>$<0?Math.floor($):Math.ceil($),($)=>Math.sign($)*Math.round(Math.abs($))||0,($)=>sT($)?($=Math.trunc($)||0)+$%2:Math.round($)],$$="UTC",oT=5184000,m4=$O(1847),y4=$O(new Date().getUTCFullYear()+10),q4=/0+$/,L0=P0(H2,WeakMap),sz=4294967295,aO=P0(($)=>{let T=of($);return typeof T=="object"?new JC(T):new CC(T||0)});class CC{constructor($){this.v=$}getOffsetNanosecondsFor(){return this.v}getPossibleInstantsFor($){return[Ff($,this.v)]}l(){}}class JC{constructor($){this.$=((T)=>{function O(W){let C=iZ(W,z,F),[J,Y]=cz(C),D=f(J),U=f(Y);return D===U?D:Z(j(J,Y),D,U,W)}function Z(W,C,J,Y){let D,U;for(;(Y===void 0||(D=Y<W[0]?C:Y>=W[1]?J:void 0)===void 0)&&(U=W[1]-W[0]);){let X=W[0]+Math.floor(U/2);T(X)===J?W[1]=X:W[0]=X+1}return D}let f=P0(T),j=P0(w2),z=m4,F=y4;return{G(W){let C=O(W-86400),J=O(W+86400),Y=W-C,D=W-J;if(C===J)return[Y];let U=O(Y);return U===O(D)?[W-U]:C>J?[Y,D]:[]},V:O,l(W,C){let J=iZ(W,z,F),[Y,D]=cz(J),U=oT*C,X=C<0?()=>D>z||(z=J,0):()=>Y<F||(F=J,0);for(;X();){let G=f(Y),B=f(D);if(G!==B){let L=j(Y,D);Z(L,G,B);let M=L[0];if((K1(M,W)||1)===C)return M}Y+=U,D+=U}}}})(((T)=>(O)=>{let Z=jf(T,O*l6);return $O(vW(Z),parseInt(Z.month),parseInt(Z.day),parseInt(Z.hour),parseInt(Z.minute),parseInt(Z.second))-O})($))}getOffsetNanosecondsFor($){return this.$.V(UF($))*q0}getPossibleInstantsFor($){let[T,O]=[$O((Z=$).isoYear,Z.isoMonth,Z.isoDay,Z.isoHour,Z.isoMinute,Z.isoSecond),Z.isoMillisecond*o0+Z.isoMicrosecond*t1+Z.isoNanosecond];var Z;return this.$.G(T).map((f)=>R0(B$(K$(f,q0),O)))}l($,T){let[O,Z]=GF($),f=this.$.l(O+(T>0||Z?1:0),T);if(f!==void 0)return K$(f,q0)}}var v3="([+\u2212-])",tT="(?:[.,](\\d{1,9}))?",DC=`(?:(?:${v3}(\\d{6}))|(\\d{4}))-?(\\d{2})`,g3="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+tT+")?)?",k3=v3+g3,c4=DC+"-?(\\d{2})(?:[T ]"+g3+"(Z|"+k3+")?)?",YC="\\[(!?)([^\\]]*)\\]",oO=`((?:${YC}){0,9})`,p4=x$(DC+oO),i4=x$("(?:--)?(\\d{2})-?(\\d{2})"+oO),h4=x$(c4+oO),l4=x$("T?"+g3+"(?:"+k3+")?"+oO),d4=x$(k3),s4=new RegExp(YC,"g"),u4=x$(`${v3}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${tT}H)?(?:(\\d+)${tT}M)?(?:(\\d+)${tT}S)?)?`),n4=P0(($)=>new x1(fC,{timeZone:$,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),a4=/^(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$/,o4=P0(g2),R3=P0(($)=>new x1(fC,{calendar:$,timeZone:$$,era:"short",year:"numeric",month:"short",day:"numeric"})),t4=/^M(\d{2})(L?)$/,r4={era:eT,eraYear:U0,year:U0,month:Rz,monthCode:eT,day:Rz},e4=P$(D1,U0),$5=P$(R,DF),uz=Object.assign({},r4,e4,$5,{offset:eT}),T5=b(V2,D1,s0),nz={dateAdd($,T,O){let Z=k(O),f,{years:j,months:z,weeks:F,days:W}=T;if(W+=j0(T,5)[0],j||z)f=((C,J,Y,D,U)=>{let[X,G,B]=C.h(J);if(Y){let[L,M]=C.I(X,G);X+=Y,G=jO(L,M,C.U(X)),G=m0("month",G,1,C.L(X),U)}return D&&([X,G]=C._(X,G,D)),B=m0("day",B,1,C.j(X,G),U),C.q(X,G,B)})(this,$,j,z,Z);else{if(!F&&!W)return $;f=K0($)}return f+=(7*F+W)*_0,L1(UO(f))},dateUntil($,T,O){if(O<=7){let W=0,C=wW({...$,...c0},{...T,...c0});return O===7&&([W,C]=Q1(C,7)),{...C0,weeks:W,days:C}}let Z=this.h($),f=this.h(T),[j,z,F]=((W,C,J,Y,D,U,X)=>{let G=D-C,B=U-J,L=X-Y;if(G||B){let M=Math.sign(G||B),S=W.j(D,U),N=0;if(Math.sign(L)===-M){let x=S;[D,U]=W._(D,U,-M),G=D-C,B=U-J,S=W.j(D,U),N=M<0?-x:S}if(L=X-Math.min(Y,S)+N,G){let[x,Q]=W.I(C,J),[I,_]=W.I(D,U);if(B=I-x||Number(_)-Number(Q),Math.sign(B)===-M){let P=M<0&&-W.L(D);G=(D-=M)-C,B=U-jO(x,Q,W.U(D))+(P||W.L(D))}}}return[G,B,L]})(this,...Z,...f);return O===8&&(z+=this.J(j,Z[0]),j=0),{...C0,years:j,months:z,days:F}},dateFromFields($,T){let O=k(T),Z=yZ(this,$),f=qZ(this,$,Z,O),j=lz(this,$,f,Z,O);return t(L1(this.P(Z,f,j)),this.id||v)},yearMonthFromFields($,T){let O=k(T),Z=yZ(this,$),f=qZ(this,$,Z,O);return c1(zf(this.P(Z,f,1)),this.id||v)},monthDayFromFields($,T){let O=k(T),Z=!this.id,{monthCode:f,year:j,month:z}=$,F,W,C,J,Y;if(f!==void 0){[F,W]=mW(f),Y=oz($,"day");let D=this.N(F,W,Y);if(!D)throw RangeError(dz);if([C,J]=D,z!==void 0&&z!==J)throw RangeError(y6);Z&&(J=m0("month",J,1,f1,1),Y=m0("day",Y,1,Wf(j!==void 0?j:C,J),O))}else{C=j===void 0&&Z?S$:yZ(this,$),J=qZ(this,$,C,O),Y=lz(this,$,J,C,O);let D=this.U(C);W=J===D,F=lZ(J,D);let U=this.N(F,W,Y);if(!U)throw RangeError(dz);[C,J]=U}return TO(L1(this.P(C,J,Y)),this.id||v)},fields($){return dZ(this)&&$.includes("year")?[...$,...nZ]:$},mergeFields($,T){let O=Object.assign(Object.create(null),$);return cZ(O,T,V3),dZ(this)&&(cZ(O,T,D4),this.id===L$&&cZ(O,T,Y4,nZ)),O},inLeapYear($){let[T]=this.h($);return this.K(T)},monthsInYear($){let[T]=this.h($);return this.L(T)},daysInMonth($){let[T,O]=this.h($);return this.j(T,O)},daysInYear($){let[T]=this.h($);return this.X(T)},dayOfYear:F3,era($){return this.ee($)[0]},eraYear($){return this.ee($)[1]},monthCode($){let[T,O]=this.h($),[Z,f]=this.I(T,O);return((j,z)=>"M"+y0(j)+(z?"L":""))(Z,f)},dayOfWeek:QF,daysInWeek(){return 7}},O5={dayOfYear:F3,h:KF,q:M$},Z5=Object.assign({},O5,{weekOfYear:kW,yearOfWeek:RW,R($){function T(U){return(7-U<Z?7:0)-U}function O(U){let X=SF(D+U),G=U||1,B=T(OT(W+X*G,7));return J=(X+(B-C)*G)/7}let Z=this.id?1:4,f=QF($),j=this.dayOfYear($),z=OT(f-1,7),F=j-1,W=OT(z-F,7),C=T(W),J,Y=Math.floor((F-C)/7)+1,D=$.isoYear;return Y?Y>O(0)&&(Y=1,D++):(Y=O(-1),D--),[Y,D,J]}}),f5={dayOfYear:F3,h:hZ,q:zT,weekOfYear:kW,yearOfWeek:RW,R(){return[]}},b$=m2(Object.assign({},nz,Z5,{h:KF,ee($){return this.id===lO?MF($):this.id===L$?A4($):[]},I:($,T)=>[T,0],N($,T){if(!T)return[S$,$]},K:Cf,U(){},L:LF,J:($)=>$*f1,j:Wf,X:SF,P:($,T,O)=>({isoYear:$,isoMonth:T,isoDay:O}),q:M$,_:($,T,O)=>($+=WO(O,f1),(T+=eZ(O,f1))<1?($--,T+=f1):T>f1&&($++,T-=f1),[$,T]),year($){return $.isoYear},month($){return $.isoMonth},day:($)=>$.isoDay}),Object.assign({},nz,f5,{h:hZ,ee($){let T=this.O($);return[T.era,T.eraYear]},I($,T){let O=uT.call(this,$);return[lZ(T,O),O===T]},N($,T,O){let[Z,f,j]=hZ.call(this,{isoYear:S$,isoMonth:f1,isoDay:31}),z=uT.call(this,Z),F=f===z;(K1($,lZ(f,z))||K1(Number(T),Number(F))||K1(O,j))===1&&Z--;for(let W=0;W<100;W++){let C=Z-W,J=uT.call(this,C),Y=jO($,T,J);if(T===(Y===J)&&O<=iz.call(this,C,Y))return[C,Y]}},K($){let T=nT.call(this,$);return T>nT.call(this,$-1)&&T>nT.call(this,$+1)},U:uT,L:aT,J($,T){let O=T+$,Z=Math.sign($),f=Z<0?-1:0,j=0;for(let z=T;z!==O;z+=Z)j+=aT.call(this,z+f);return j},j:iz,X:nT,P($,T,O){return UO(zT.call(this,$,T,O))},q:zT,_($,T,O){if(O){if(T+=O,!Number.isSafeInteger(T))throw RangeError(qO);if(O<0)for(;T<1;)T+=aT.call(this,--$);else{let Z;for(;T>(Z=aT.call(this,$));)T-=Z,$++}}return[$,T]},year($){return this.O($).year},month($){let{year:T,F:O}=this.O($),{C:Z}=this.B(T);return Z[O]+1},day($){return this.O($).day}})),S1="numeric",v$=["timeZoneName"],XC={month:S1,day:S1},m3={year:S1,month:S1},y3=Object.assign({},m3,{day:S1}),q3={hour:S1,minute:S1,second:S1},c3=Object.assign({},y3,q3),j5=Object.assign({},c3,{timeZoneName:"short"}),z5=Object.keys(m3),F5=Object.keys(XC),W5=Object.keys(y3),C5=Object.keys(q3),p3=["dateStyle"],J5=z5.concat(p3),D5=F5.concat(p3),i3=W5.concat(p3,["weekday"]),VT=C5.concat(["dayPeriod","timeStyle"]),h3=i3.concat(VT),Y5=h3.concat(v$),X5=v$.concat(VT),U5=v$.concat(i3),G5=v$.concat(["day","weekday"],VT),B5=v$.concat(["year","weekday"],VT),K5={},l3=[o1(h3,c3),SO],UC=[o1(Y5,j5),SO,0,($,T)=>{let O=W0($.timeZone);if(T&&W0(T.timeZone)!==O)throw RangeError(c6);return O}],d3=[o1(h3,c3,v$),K0],s3=[o1(i3,y3,X5),K0],u3=[o1(VT,q3,U5),($)=>M1($)/o0],n3=[o1(J5,m3,G5),K0,1],a3=[o1(D5,XC,B5),K0,1],az;function e0($,T,O,Z,f){function j(...W){if(!(this instanceof j))throw TypeError(Q3);LC(this,T(...W))}function z(W,C){return Object.defineProperties(function(...J){return W.call(this,F(this),...J)},oZ(C))}function F(W){let C=X0(W);if(!C||C.branding!==$)throw TypeError(Q3);return C}return Object.defineProperties(j.prototype,{...tz(p0(z,O)),...i1(p0(z,Z)),...FO("Temporal."+$)}),Object.defineProperties(j,{...i1(f),...oZ($)}),[j,(W)=>{let C=Object.create(j.prototype);return LC(C,W),C},F]}function MC($){return $=$.concat("id").sort(),(T)=>{if(!rz(T,$))throw TypeError(q6);return T}}function m$($){if(X0($)||$.calendar!==void 0||$.timeZone!==void 0)throw TypeError(k6);return $}function tO($,T){let O={};for(let Z in $)O[Z]=({o:f},j)=>{let z=X0(j)||{},{branding:F}=z,W=F===r1||T.includes(F)?z:M0(j);return f[Z](W)};return O}function r3($){let T={};for(let O in $)T[O]=(Z)=>{let{calendar:f}=Z;return(j=f,typeof j=="string"?b$(j):(z=j,Object.assign(Object.create(v5),{i:z})))[O](Z);var j,z};return T}function b1(){throw TypeError(m6)}function NT({calendar:$}){return typeof $=="string"?new Fj($):$}function GC($,T){if(T=a(T),z0($)){let Z=X0($);if(Z&&Z.branding===w$)return k(T),Z;let f=AC($);return J3(fZ(f||v),!f,$,T)}let O=FW(b$,$);return k(T),O}function IC($,T,O){return Z=T.call($,Q0(F0(O))),Hf(DT(Z));var Z}function rO($,T=_C){let O=Object.keys(T).sort(),Z={};for(let f of O)Z[f]=b(T[f],$,$C($[f]));return Z}function q($,T){return typeof $=="string"?aO($):rO($,T)}function e($){return q($,t3)}function t0($){if(z0($)){let T=X0($);if(T)switch(T.branding){case uO:return T;case Y1:return F0(T.epochNanoseconds)}}return OW($)}function BC($,T,O){let Z=T.l(t0(O).epochNanoseconds,$);return Z?Q0(F0(Z)):null}function p($){return z0($)?(X0($)||{}).timeZone||q5($):((T)=>bO(DW(h(T))))($)}function _1($,T){if(z0($)){let O=X0($)||{};switch(O.branding){case sO:return k(T),O;case e1:return k(T),l0(O);case Y1:return k(T),B3(e,O)}return lW($,T)}return k(T),WW($)}function e3($){return $===void 0?void 0:_1($)}function g$($,T){if(T=a(T),z0($)){let Z=X0($);return Z&&Z.branding===H$?(k(T),Z):C3(OZ(ET($)),$,T)}let O=zW(b$,$);return k(T),O}function P1($,T){if(T=a(T),z0($)){let Z=X0($)||{};switch(Z.branding){case e1:return k(T),Z;case r1:return k(T),o({...Z,...c0});case Y1:return k(T),U3(e,Z)}return hW(ZZ(ET($)),$,T)}let O=jW($);return k(T),O}function M0($,T){if(T=a(T),z0($)){let Z=X0($)||{};switch(Z.branding){case r1:return k(T),Z;case e1:return k(T),t(Z);case Y1:return k(T),G3(e,Z)}return W3(ZZ(ET($)),$,T)}let O=HO($);return k(T),O}function VC($,T,O){return i0(T.call($,d(t(O,$))))}function $1($){return(T)=>typeof T=="string"?b$(T):((O,Z)=>{let f=Object.keys(Z).sort(),j={};for(let z of f)j[z]=b(Z[z],O,O[z]);return j})(T,$)}function l($){if(z0($)){let T=X0($);return T&&T.branding===nO?T:dW($)}return CW($)}function AT($){if($!==void 0){if(z0($)){let T=X0($)||{};switch(T.branding){case Y1:case r1:return T;case e1:return t(T)}let O=ET($);return{...pW(p,q,ZZ(O),$),calendar:O}}return ZW($)}}function ET($){return AC($)||v}function AC($){let{calendar:T}=$;if(T!==void 0)return Y0(T)}function Y0($){return z0($)?(X0($)||{}).calendar||$7($):((T)=>UT(JW(h(T))))($)}function k$($,T){if(T=a(T),z0($)){let O=X0($);if(O&&O.branding===Y1)return YT(T),O;let Z=ET($);return iW(p,q,ZZ(Z),Z,$,T)}return fW($,T)}function KC($){return p0((T)=>(O)=>T(o3(O)),$)}function o3($){return L0($,e)}function L5(){let $=x1.prototype,T=Object.getOwnPropertyDescriptors($),O=Object.getOwnPropertyDescriptors(x1),Z=function(f,j={}){if(!(this instanceof Z))return new Z(f,j);Wj.set(this,((z,F={})=>{let W=new x1(z,F),C=W.resolvedOptions(),J=C.locale,Y=w0(Object.keys(F),C),D=P0(M5),U=(...X)=>{let G,B=X.map((L,M)=>{let S=X0(L),N=(S||{}).branding;if(M&&G&&G!==N)throw TypeError(i6);return G=N,S});return G?D(G)(J,Y,...B):[W,...X]};return U.u=W,U})(f,j))};for(let f in T){let j=T[f],z=f.startsWith("format")&&S5(f);typeof j.value=="function"?j.value=f==="constructor"?Z:z||Q5(f):z&&(j.get=function(){return z.bind(this)})}return O.prototype.value=Object.create($,T),Object.defineProperties(Z,O),Z}function S5($){return function(...T){let O=Wj.get(this),[Z,...f]=O(...T);return Z[$](...f)}}function Q5($){return function(...T){return Wj.get(this).u[$](...T)}}function M5($){let T=I5[$];if(!T)throw TypeError(p6($));return C1(T,P0(K3))}var I5={Instant:l3,PlainDateTime:d3,PlainDate:s3,PlainTime:u3,PlainYearMonth:n3,PlainMonthDay:a3},V5=C1(l3),A5=C1(UC),N5=C1(d3),E5=C1(s3),x5=C1(u3),_5=C1(n3),P5=C1(a3),$j={era:jF,eraYear:$f,year:DT,month:i0,daysInMonth:i0,daysInYear:i0,inLeapYear:e6,monthsInYear:i0},$Z={monthCode:h},Tj={day:i0},NC={dayOfWeek:i0,dayOfYear:i0,weekOfYear:zF,yearOfWeek:$f,daysInWeek:i0},EC=Object.assign({},$j,$Z,Tj,NC),eO=new WeakMap,X0=eO.get.bind(eO),LC=eO.set.bind(eO),H5={...tO($j,[H$]),...tO(NC,[]),...tO($Z,[H$,w$]),...tO(Tj,[w$])},Oj=r3(EC),w5=r3({...$j,...$Z}),b5=r3({...$Z,...Tj}),xT={calendarId:($)=>W0($.calendar)},v5=p0(($,T)=>function(O){let{i:Z}=this;return $(Z[T](d(t(O,Z))))},EC),g5=CT(($)=>(T)=>T[$],R.concat("sign")),Zj=CT(($,T)=>(O)=>O[s0[T]],D1),xC={epochSeconds:_F,epochMilliseconds:SO,epochMicroseconds:PF,epochNanoseconds:HF},_T=b(tZ,new Set(["branding"])),[k5,R$,R5]=e0(w$,b(j6,Y0),{...xT,...b5},{getISOFields:_T,getCalendar:NT,with($,T,O){return R$(oW(t5,$,this,m$(T),O))},equals:($,T)=>NW($,GC(T)),toPlainDate($,T){return d(S6(PT,$,this,T))},toLocaleString($,T,O){let[Z,f]=P5(T,O,$);return Z.format(f)},toString:Nf,toJSON:($)=>Nf($),valueOf:b1},{from:($,T)=>R$(GC($,T))}),_C={getOffsetNanosecondsFor:IC,getPossibleInstantsFor($,T,O){let Z=[...T.call($,D0(o(O,v)))].map((j)=>y5(j).epochNanoseconds),f=Z.length;return f>1&&(Z.sort(B0),wf(k0(g0(Z[0],Z[f-1])))),Z}},t3={getOffsetNanosecondsFor:IC},[m5,Q0,y5]=e0(uO,$6,xC,{add:($,T)=>Q0(bf(0,$,l(T))),subtract:($,T)=>Q0(bf(1,$,l(T))),until:($,T,O)=>c($3(0,$,t0(T),O)),since:($,T,O)=>c($3(1,$,t0(T),O)),round:($,T)=>Q0(vF($,T)),equals:($,T)=>QW($,t0(T)),toZonedDateTime($,T){let O=F1(T);return r(X3($,p(O.timeZone),Y0(O.calendar)))},toZonedDateTimeISO:($,T)=>r(X3($,p(T))),toLocaleString($,T,O){let[Z,f]=V5(T,O,$);return Z.format(f)},toString:($,T)=>Qf(p,e,$,T),toJSON:($)=>Qf(p,e,$),valueOf:b1},{from:($)=>Q0(t0($)),fromEpochSeconds:($)=>Q0(I6($)),fromEpochMilliseconds:($)=>Q0(V6($)),fromEpochMicroseconds:($)=>Q0(A6($)),fromEpochNanoseconds:($)=>Q0(N6($)),compare:($,T)=>tf(t0($),t0(T))}),[TZ,nD]=e0("TimeZone",($)=>{let T=LW($);return{branding:"TimeZone",id:T,o:aO(T)}},{id:($)=>$.id},{getPossibleInstantsFor:({o:$},T)=>$.getPossibleInstantsFor(P1(T)).map((O)=>Q0(F0(O))),getOffsetNanosecondsFor:({o:$},T)=>$.getOffsetNanosecondsFor(t0(T).epochNanoseconds),getOffsetStringFor($,T){let O=t0(T).epochNanoseconds,Z=rO(this,t3).getOffsetNanosecondsFor(O);return d1(Z)},getPlainDateTimeFor($,T,O=v){let Z=t0(T).epochNanoseconds,f=rO(this,t3).getOffsetNanosecondsFor(Z);return D0(o(V1(Z,f),Y0(O)))},getInstantFor($,T,O){let Z=P1(T),f=Jf(O),j=rO(this);return Q0(F0(H0(j,Z,f)))},getNextTransition:({o:$},T)=>BC(1,$,T),getPreviousTransition:({o:$},T)=>BC(-1,$,T),equals($,T){return!!gO(this,p(T))},toString:($)=>$.id,toJSON:($)=>$.id},{from($){let T=p($);return typeof T=="string"?new TZ(T):T}}),q5=MC(Object.keys(_C)),[c5,H1]=e0(sO,z6,Zj,{getISOFields:_T,with($,T,O){return H1(tW(this,m$(T),O))},add:($,T)=>H1(mf(0,$,l(T))),subtract:($,T)=>H1(mf(1,$,l(T))),until:($,T,O)=>c(j3(0,$,_1(T),O)),since:($,T,O)=>c(j3(1,$,_1(T),O)),round:($,T)=>H1(RF($,T)),equals:($,T)=>EW($,_1(T)),toZonedDateTime:($,T)=>r(Q6(p,M0,q,$,T)),toPlainDateTime:($,T)=>D0(M6($,M0(T))),toLocaleString($,T,O){let[Z,f]=x5(T,O,$);return Z.format(f)},toString:Ef,toJSON:($)=>Ef($),valueOf:b1},{from:($,T)=>H1(_1($,T)),compare:($,T)=>vO(_1($),_1(T))}),[p5,w1,i5]=e0(H$,b(f6,Y0),{...xT,...w5},{getISOFields:_T,getCalendar:NT,with($,T,O){return w1(aW(o5,$,this,m$(T),O))},add:($,T,O)=>w1(Rf(SC,0,$,l(T),O)),subtract:($,T,O)=>w1(Rf(SC,1,$,l(T),O)),until:($,T,O)=>c(f3(QC,0,$,g$(T),O)),since:($,T,O)=>c(f3(QC,1,$,g$(T),O)),equals:($,T)=>AW($,g$(T)),toPlainDate($,T){return d(L6(PT,$,this,T))},toLocaleString($,T,O){let[Z,f]=_5(T,O,$);return Z.format(f)},toString:Af,toJSON:($)=>Af($),valueOf:b1},{from:($,T)=>w1(g$($,T)),compare:($,T)=>n1(g$($),g$(T))}),[h5,D0]=e0(e1,b(O6,Y0),{...xT,...Oj,...Zj},{getISOFields:_T,getCalendar:NT,with($,T,O){return D0(uW(PT,$,this,m$(T),O))},withCalendar:($,T)=>D0(yO($,Y0(T))),withPlainDate:($,T)=>D0(P6($,M0(T))),withPlainTime:($,T)=>D0(_6($,e3(T))),add:($,T,O)=>D0(gf(T$,0,$,l(T),O)),subtract:($,T,O)=>D0(gf(T$,1,$,l(T),O)),until:($,T,O)=>c(O3(r0,0,$,P1(T),O)),since:($,T,O)=>c(O3(r0,1,$,P1(T),O)),round:($,T)=>D0(kF($,T)),equals:($,T)=>IW($,P1(T)),toZonedDateTime:($,T,O)=>r(D6(q,$,p(T),O)),toPlainDate:($)=>d(t($)),toPlainTime:($)=>H1(l0($)),toPlainYearMonth($){return w1(Y6(OZ,$,this))},toPlainMonthDay($){return R$(X6(fZ,$,this))},toLocaleString($,T,O){let[Z,f]=N5(T,O,$);return Z.format(f)},toString:If,toJSON:($)=>If($),valueOf:b1},{from:($,T)=>D0(P1($,T)),compare:($,T)=>ef(P1($),P1(T))}),[l5,d,PC]=e0(r1,b(Z6,Y0),{...xT,...Oj},{getISOFields:_T,getCalendar:NT,with($,T,O){return d(nW(PT,$,this,m$(T),O))},withCalendar:($,T)=>d(yO($,Y0(T))),add:($,T,O)=>d(kf(T$,0,$,l(T),O)),subtract:($,T,O)=>d(kf(T$,1,$,l(T),O)),until:($,T,O)=>c(Z3(r0,0,$,M0(T),O)),since:($,T,O)=>c(Z3(r0,1,$,M0(T),O)),equals:($,T)=>VW($,M0(T)),toZonedDateTime($,T){let O=!z0(T)||T instanceof TZ?{timeZone:T}:T;return r(U6(p,_1,q,$,O))},toPlainDateTime:($,T)=>D0(G6($,e3(T))),toPlainYearMonth($){return w1(B6(OZ,$,this))},toPlainMonthDay($){return R$(K6(fZ,$,this))},toLocaleString($,T,O){let[Z,f]=E5(T,O,$);return Z.format(f)},toString:Vf,toJSON:($)=>Vf($),valueOf:b1},{from:($,T)=>d(M0($,T)),compare:($,T)=>n1(M0($),M0(T))}),fj={fields($,T,O){return[...T.call($,O)]}},HC=Object.assign({dateFromFields($,T,O,Z){return PC(T.call($,Object.assign(Object.create(null),O),Z))}},fj),wC=Object.assign({yearMonthFromFields($,T,O,Z){return i5(T.call($,Object.assign(Object.create(null),O),Z))}},fj),bC=Object.assign({monthDayFromFields($,T,O,Z){return R5(T.call($,Object.assign(Object.create(null),O),Z))}},fj),jj={mergeFields($,T,O,Z){return F1(T.call($,Object.assign(Object.create(null),O),Object.assign(Object.create(null),Z)))}},d5=Object.assign({},HC,jj),s5=Object.assign({},wC,jj),u5=Object.assign({},bC,jj),zj={dateAdd($,T,O,Z,f){return PC(T.call($,d(t(O,$)),c(i(Z)),f))}},vC=Object.assign({},zj,{dateUntil($,T,O,Z,f,j){return e5(T.call($,d(t(O,$)),d(t(Z,$)),Object.assign(Object.create(null),j,{largestUnit:ST[f]})))}}),n5=Object.assign({},zj,{day:VC}),a5=Object.assign({},vC,{day:VC}),OZ=$1(wC),ZZ=$1(HC),fZ=$1(bC),o5=$1(s5),PT=$1(d5),t5=$1(u5),T$=$1(zj),r0=$1(vC),SC=$1(n5),QC=$1(a5),[r5,c,e5]=e0(nO,F6,{...g5,blank:eF},{with:($,T)=>c(rW($,T)),negated:($)=>c(_O($)),abs:($)=>c(rF($)),add:($,T,O)=>c(hf(AT,r0,q,0,$,l(T),O)),subtract:($,T,O)=>c(hf(AT,r0,q,1,$,l(T),O)),round:($,T)=>c(tF(AT,r0,q,$,T)),total:($,T)=>bF(AT,r0,q,$,T),toLocaleString($,T,O){return Intl.DurationFormat?new Intl.DurationFormat(T,O).format(this):VO($)},toString:VO,toJSON:($)=>VO($),valueOf:b1},{from:($)=>c(l($)),compare:($,T,O)=>SW(AT,T$,q,l($),l(T),O)}),gC={toString:($)=>$.id,toJSON:($)=>$.id,...H5,dateAdd:({id:$,o:T},O,Z,f)=>d(t(T.dateAdd(M0(O),l(Z),f),$)),dateUntil:({o:$},T,O,Z)=>c(i($.dateUntil(M0(T),M0(O),VF(Z)))),dateFromFields:({id:$,o:T},O,Z)=>d(W3(T,O,Z,fF($))),yearMonthFromFields:({id:$,o:T},O,Z)=>w1(C3(T,O,Z,OF($))),monthDayFromFields:({id:$,o:T},O,Z)=>R$(J3(T,0,O,Z,ZF($))),fields({o:$},T){let O=new Set(d0),Z=[];for(let f of T){if(h(f),!O.has(f))throw RangeError(S3(f));O.delete(f),Z.push(f)}return $.fields(Z)},mergeFields:({o:$},T,O)=>$.mergeFields(rZ(Tf(T)),rZ(Tf(O)))},[Fj]=e0("Calendar",($)=>{let T=gW($);return{branding:"Calendar",id:T,o:b$(T)}},{id:($)=>$.id},gC,{from($){let T=Y0($);return typeof T=="string"?new Fj(T):T}}),$7=MC(Object.keys(gC).slice(4)),[T7,r]=e0(Y1,b(T6,Y0,p),{...xC,...xT,...KC(Oj),...KC(Zj),offset:($)=>d1(o3($).offsetNanoseconds),offsetNanoseconds:($)=>o3($).offsetNanoseconds,timeZoneId:($)=>W0($.timeZone),hoursInDay:($)=>mF(q,$)},{getISOFields:($)=>aF(e,$),getCalendar:NT,getTimeZone:({timeZone:$})=>typeof $=="string"?new TZ($):$,with($,T,O){return r(sW(PT,q,$,this,m$(T),O))},withCalendar:($,T)=>r(yO($,Y0(T))),withTimeZone:($,T)=>r(H6($,p(T))),withPlainDate:($,T)=>r(x6(q,$,M0(T))),withPlainTime:($,T)=>r(E6(q,$,e3(T))),add:($,T,O)=>r(vf(T$,q,0,$,l(T),O)),subtract:($,T,O)=>r(vf(T$,q,1,$,l(T),O)),until:($,T,O)=>c(i(T3(r0,q,0,$,k$(T),O))),since:($,T,O)=>c(i(T3(r0,q,1,$,k$(T),O))),round:($,T)=>r(gF(q,$,T)),startOfDay:($)=>r(yF(q,$)),equals:($,T)=>MW($,k$(T)),toInstant:($)=>Q0(W6($)),toPlainDateTime:($)=>D0(U3(e,$)),toPlainDate:($)=>d(G3(e,$)),toPlainTime:($)=>H1(B3(e,$)),toPlainYearMonth($){return w1(C6(OZ,$,this))},toPlainMonthDay($){return R$(J6(fZ,$,this))},toLocaleString($,T,O={}){let[Z,f]=A5(T,O,$);return Z.format(f)},toString:($,T)=>Mf(e,$,T),toJSON:($)=>Mf(e,$),valueOf:b1},{from:($,T)=>r(k$($,T)),compare:($,T)=>rf(k$($),k$(T))}),O7=Object.defineProperties({},{...FO("Temporal.Now"),...i1({timeZoneId:()=>J1(),instant:()=>Q0(F0(BT())),zonedDateTime:($,T=J1())=>r(J0(BT(),p(T),Y0($))),zonedDateTimeISO:($=J1())=>r(J0(BT(),p($),v)),plainDateTime:($,T=J1())=>D0(o(_$(e(p(T))),Y0($))),plainDateTimeISO:($=J1())=>D0(o(_$(e(p($))),v)),plainDate:($,T=J1())=>d(t(_$(e(p(T))),Y0($))),plainDateISO:($=J1())=>d(t(_$(e(p($))),v)),plainTimeISO:($=J1())=>H1(l0(_$(e(p($)))))})}),y$=Object.defineProperties({},{...FO("Temporal"),...i1({PlainYearMonth:p5,PlainMonthDay:k5,PlainDate:l5,PlainTime:c5,PlainDateTime:h5,ZonedDateTime:T7,Instant:m5,Calendar:Fj,TimeZone:TZ,Duration:r5,Now:O7})}),Z7=L5(),Wj=new WeakMap,f7=Object.defineProperties(Object.create(Intl),i1({DateTimeFormat:Z7}));var Cj="intended_url";class Jj extends E{schema={email:{required:"Email is required",string:"Invalid email",email:"Invalid email"},password:{required:"Password is required"}}}class kC extends E{schema={email:{required:"Email is required",email:"Invalid email"}}}class RC extends E{schema={password:{required:"Password is required",password:"Invalid password"}}}class $0 extends HZ{async me(){let $=await O$.user();if(!$)throw new wZ;return $}async verifyEmail($=new E){let T=await $.input(),{userProvider:O}=K(w),Z=await O.findUserByVerificationToken(T.get("token"));if(!Z)return{email:null};return await O.verifyUser(Z.email),{email:Z.email}}async signInWithMagicLink($=new E){let T=K(w),{userProvider:O}=T,Z=$.search.get("token"),f=decodeURIComponent($.search.get("email")).toLowerCase().trim(),j=null;try{j=await O.findUserMagicLinkToken({email:f,token:Z})}catch(F){return console.log(F),{error:JSON.stringify(F)}}if(!j)return{error:"Invalid token"};await O.verifyUser(f),await O.deleteMagicLinkToken(f);let z=await T.createOrUpdateSession({email:f});return $.ctx().setCookie("access_token",z.token,K(w).accessTokenCookieOptions($,z.expiresAt)),await T.config.onSignIn(z,$.search.toJSON()),{session:z}}async signInWithPinV2($=new E){let T=K(w),{userProvider:O}=T,Z=await $.input(),{email:f,pin:j}=Z.toJSON(),z=f.toLowerCase().trim();if(!await O.findUserMagicLinkToken({email:z,pin:j}))throw new N0({pin:["Invalid pin"]});await O.deleteMagicLinkToken(z),await O.verifyUser(z);let W=await T.createOrUpdateSessionV2({email:z});return $.ctx().setCookie("access_token",W.token,K(w).accessTokenCookieOptions($,W.expiresAt)),await T.config.onSignIn(W,$.search.toJSON()),W}async signInWithPin($=new E){let T=K(w),{userProvider:O}=T,Z=await $.input(),{email:f,pin:j}=Z.toJSON(),z=f.toLowerCase().trim();if(!await O.findUserMagicLinkToken({email:z,pin:j}))throw new N0({pin:["Invalid pin"]});await O.deleteMagicLinkToken(z),await O.verifyUser(z);let W=await T.createOrUpdateSession({email:z});return $.ctx().setCookie("access_token",W.token,K(w).accessTokenCookieOptions($,W.expiresAt)),await T.config.onSignIn(W,$.search.toJSON()),{session:W}}async signInV2($=new Jj){let T=await $.input(),{email:O,password:Z}=T.toJSON(),f=O.toLowerCase().trim(),j=K(w),z=await j.userProvider.findUserByEmailAddress(f,j.config.verifyEmail);if(!z)throw new N0({invalid_credentials:["Invalid credentials"]});if(!await j.config.verifyPassword(Z,z.password))throw new N0({invalid_credentials:["Invalid credentials"]});let W=await j.createOrUpdateSessionV2({email:z.email,id:z.id});$.ctx().setCookie("access_token",W.token,K(w).accessTokenCookieOptions($,W.expiresAt)),await j.config.onSignIn(z,$.search.toJSON());let{password:C,...J}=z;return J}async signIn($=new Jj){let T=await $.input(),{email:O,password:Z}=T.toJSON(),f=O.toLowerCase().trim(),j=K(w),z=await j.userProvider.findUserByEmailAddress(f,j.config.verifyEmail);if(!z)throw new N0({invalid_credentials:["Invalid credentials"]});if(!await j.config.verifyPassword(Z,z.password))throw new N0({invalid_credentials:["Invalid credentials"]});let W=await j.createOrUpdateSession({email:z.email,id:z.id});$.ctx().setCookie("access_token",W.token,K(w).accessTokenCookieOptions($,W.expiresAt)),await j.config.onSignIn(z,$.search.toJSON());let{password:C,...J}=z;return J}async signUp(){let $=K(w),{userProvider:T,config:O}=$,Z=new O.signUpRequest,f=await Z.input(),{email:j,password:z,name:F,invitationId:W}=f.toJSON(),C=j.toLowerCase().trim();if(await T.findUserByEmailAddress(C,!1))throw new N0({email:["Email address already exists"]});let Y=await O.hashPassword(z),D=K(n).detectLocale(Z),U;if(W)U=await T.findInvitation(W,C);let X,G="";if(U)X=await T.transaction(async()=>{await T.deleteInvitationById(W);let B=await T.createUser({email:C,name:F,password:Y,emailVerifiedAt:new Date,locale:D});return await T.createAccount({organizationId:U.organizationId,userId:B.id,organizationRole:U.role}),await O.onUserCreated(B),B});else G=await O.generateEmailVerificationToken(C),X=await T.transaction(async()=>{let B=await T.createUser({email:C,name:F,password:Y,verificationToken:G,locale:D});return await O.onUserCreated(B),B});return await O.onSignUp(X,G,Z.search.toJSON()),X}async signOut($=new E){let T=$.cookies.get("access_token")??$.headers.get("access_token"),{userProvider:O,config:Z}=K(w),f=T?await O.findSession({token:T,userAgent:$.headers.get("User-Agent")}):null;if(await O.deleteSession({token:T}),$.ctx().setCookie("access_token","",K(w).accessTokenCookieOptions($,new Date(0))),K(w).cookieDomain($))$.ctx().setCookie("access_token","",{...K(w).accessTokenCookieOptions($,new Date(0)),domain:void 0});if(f?.user)f.user.extension=await Z.extendSession(f.user),await Z.onSignOut(f.user);return{}}async forgotPassword($=new kC){let O=(await $.input()).get("email").toLowerCase().trim(),{userProvider:Z,config:f}=K(w),j=await Z.findUserByEmailAddress(O,f.verifyEmail);if(!j)return{};let z=await f.generateForgotPasswordToken(j);return await Z.createPasswordResetToken({user:j,token:z}),await f.onForgotPassword(j,z),{}}async resetPassword($=new RC){let{userProvider:T,config:O}=K(w),Z=await $.input(),{password:f,token:j}=Z.toJSON(),z=await T.findPasswordResetToken({token:j});if(!z)throw new N0({token:["Invalid token"]});if(y$.Instant.from(z.createdAt.toISOString()).add({hours:24}).until(y$.Now.instant()).sign>=0)throw new N0({token:["Token expired"]});await T.deletePasswordResetToken({token:j});let W=await T.findUserByEmailAddress(z.user.email,O.verifyEmail);if(!W)throw new N0({email:["User not found"]});let C=await O.hashPassword(f);return await T.updateUserPassword({id:W.id,password:C}),await T.deleteAllUserSessions(W.id),await O.onResetPassword(W),{}}async changePassword($=new E){let{userProvider:T,config:O}=K(w),Z=await O$.user(),f=await $.input(),{oldPassword:j,newPassword:z}=f.toJSON(),{password:F}=await T.findUserByEmailAddress(Z.email,O.verifyEmail);if(!await O.verifyPassword(j,F))throw new N0({oldPassword:["Incorrect password"]});let C=await O.hashPassword(z);return await T.updateUserPassword({id:Z.id,password:C}),await T.deleteAllUserSessions(Z.id),{}}async oauthRedirect($=new E){let{provider:T}=$.params,O=K(w).config.oauthProviders[T];if(!O)throw Error(`Invalid provider: ${T}`);let Z=$T($.search.get(Y$),"");if(Z)$.ctx().setCookie(Cj,encodeURIComponent(Z),{httpOnly:!0,sameSite:"Lax",secure:Lz($.rawRequest),maxAge:600});return{destination:await O.getRedirectUrl($)}}async oauthCallback($=new E){let{provider:T}=$.params,O=K(w),{userProvider:Z,config:f}=O,j=f.oauthProviders[T],{email:z,name:F,username:W,providerId:C}=await j.onCallback($),J=C?await Z.findUserBySocialAccount(T,C):null,Y="signin";if(!J){if(!z)return console.error("Authentication error: No email returned from OAuth provider callback"),{session:null};let G=K(n).detectLocale($);try{let B=await this.linkOAuthAccount({provider:T,providerId:C,email:z,name:F,username:W,locale:G});if(B)J=B.user,Y=B.action}catch(B){let L=C?await Z.findUserBySocialAccount(T,C):null;if(!L)throw B;J=L}if(!J)return{session:null}}let D=await O.createOrUpdateSessionV2({email:J.email,id:J.id});if($.ctx().setCookie("access_token",D.token,K(w).accessTokenCookieOptions($,D.expiresAt)),Y==="signup")await f.onSignUp(J,"",$.search.toJSON());else await f.onSignIn(J,$.search.toJSON());let U=$.cookies.get(Cj),X=f.redirectPath;if(U){try{X=$T(decodeURIComponent(U),X)}catch{}$.ctx().setCookie(Cj,"",{maxAge:-1})}return{session:D,redirectTo:X}}async linkOAuthAccount($){let{provider:T,providerId:O,email:Z,name:f,username:j,locale:z}=$,{userProvider:F,config:W}=K(w),C=(D)=>({provider:T,userId:D,email:Z,username:j,providerId:O,expiresAt:new Date,accessToken:"",refreshToken:""}),J=await F.findUserByEmailAddress(Z,!1);if(J){if(!O)return{user:J,action:"signin"};let D=await F.findSocialAccounts(J.id,T);if(D.some((X)=>X.providerId===O))return{user:J,action:"signin"};if(D.some((X)=>X.providerId))return console.error(`Authentication error: user ${J.id} is already linked to a different ${T} account`),null;let U=D[0];if(U){if(!await F.claimSocialAccount(U,O))throw Error(`${T} account link changed concurrently`)}else await F.createSocialAccount(C(J.id));return{user:J,action:"signin"}}return{user:await F.transaction(async()=>{let D=await F.createUser({email:Z,name:f,locale:z,emailVerifiedAt:new Date});if(O)await F.createSocialAccount(C(D.id));return await W.onUserCreated(D),D}),action:"signup"}}async createMagicLinkToken($=new E){let O=(await $.input()).get("email").toLowerCase().trim(),Z=K(w),{user:f,pin:j,token:z}=await Z.createMagicLinkToken(O);if(f)return await Z.config.onMagicLinkCreated(f,{email:O,pin:j,token:z}),{email:O};return{email:null}}}class mC extends B1{middlewares=["cache:private"];routes={"/:provider":this.view("_Redirect",[$0,"oauthRedirect"]),"/:provider/callback":this.view("auth/OauthCallback",[$0,"oauthCallback"])}}class Dj extends B1{middlewares=["cache:private"];routes={"/sign-in/magic-link":this.view("auth/MagicLinkSignIn",[$0,"signInWithMagicLink"]),"/oauth":mC}}class Yj extends A0{middlewares=["cache:private"];routes={"/sign-in":this.post($0,"signIn"),"/sign-in-v2":this.post($0,"signInV2"),"/sign-up":this.post($0,"signUp"),"/sign-out":this.post($0,"signOut"),"/forgot-password":this.post($0,"forgotPassword"),"/reset-password":this.post($0,"resetPassword"),"/change-password":this.post($0,"changePassword"),"/verify-email":this.post($0,"verifyEmail"),"/me":this.get($0,"me").middleware(["auth"]),"/magic-link":this.post($0,"createMagicLinkToken"),"/sign-in-with-pin":this.post($0,"signInWithPin"),"/sign-in-with-pin-v2":this.post($0,"signInWithPinV2")}}class Xj extends A0{middlewares=["cache:private,0,no-store"];routes={"/set-locale/:locale":this.get(async()=>{let T=new E().params.locale;return await K(n).onLocaleChange(T),{locale:T}}),"/translations/:locale/:scope*":this.get(async()=>{let $=new E,T=`/${$.params.scope??""}`,O=$.params.locale,Z=K(n),f=O??Z.detectLocale($),j=Z.getPageTranslations(f,T);return $.ctx().setCookie("i18n-locale",f,{expires:new Date(Date.now()+31536000000)}),{[f]:j}})}}class Uj{}class Gj extends Uj{async resize($,T){let{height:O,width:Z,quality:f,fit:j}=T;return await(await jZ("The Sharp image optimization driver"))($).resize(Z>0?Z:void 0,O>0?O:void 0,{fit:j}).webp({quality:f>0?f:80,force:!0}).toBuffer()}}function VY($){return $}function yC(){return{driver:new Gj}}class Bj extends A0{routes={"/resize":this.file(async()=>{let $=new E,T=new URL($.rawRequest.url),O=T.searchParams.get("url"),Z=Number(T.searchParams.get("w")),f=Number(T.searchParams.get("h")),j=T.searchParams.get("fit")??"cover",z=Number(T.searchParams.get("q"));if(!O)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});let W=`${O.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${O}`,C=await fetch(W);if(!C.ok)return new Response(JSON.stringify({error:"Image not found",info:W}),{headers:{"Content-Type":"application/json"},status:404});let J=Buffer.from(await C.arrayBuffer()),Y=await K(qC).resize(J,{height:f,width:Z,fit:j,quality:z});C.headers.delete("Content-Type"),C.headers.delete("Content-Length");let D=new Headers(C.headers);return D.set("Content-Type","image/webp"),D.set("Content-Length",`${Y.byteLength}`),new Response(new Uint8Array(Y),{headers:D})})}}class qC{static token="image";driver;constructor($={}){this.driver=$.driver??yC().driver}resize($,T){return this.driver.resize($,T)}}import{mkdir as Kj,readdir as j7,access as z7}from"fs/promises";async function Lj($){try{return await z7($),!0}catch{return!1}}class HT{config;static token="log";writer;isReady=!1;flushTimeout;fileSize=0;writerSize=0;isCreatingFile=!1;bootPromise=null;currentLogFilePath;get logsDirPath(){return`${Sj()}/storage/logs`}constructor($){this.config=$}boot(){if(!this.bootPromise)this.bootPromise=this.createStorage().catch(($)=>{console.error("Log storage unavailable, file logging disabled",$)}).then(()=>{this.isReady=!0});return this.bootPromise}async createStorage(){let $=`${Sj()}/storage`;if(!await Lj($))await Kj($);if(!await Lj(this.logsDirPath))await Kj(this.logsDirPath);await this.newLogFile()}async newLogFile(){if(!await Lj(this.logsDirPath))await Kj(this.logsDirPath);if(this.isCreatingFile=!0,this.currentLogFilePath){this.writer.flush(),this.writer.end(),this.writer=null;let O=new File([await Bun.file(this.currentLogFilePath).arrayBuffer()],this.currentLogFilePath.split("/").pop(),{type:"text/plain"});this.config.onLogFileClosed(O),this.fileSize=0,this.writerSize=0}let T=(await j7(this.logsDirPath)).sort().reverse()[0];if(T){let O=Bun.file(`${this.logsDirPath}/${T}`);if(O.size<this.config.maxFileSize)this.currentLogFilePath=`${this.logsDirPath}/${T}`,this.writer=O.writer(),this.writer.write(await O.text()),this.writer.write(`
3
+ `),this.writer.flush(),this.fileSize=O.size}if(!this.writer){let O=`${new Date(Date.now()).toISOString()}.log`.replaceAll(":","-");this.currentLogFilePath=`${this.logsDirPath}/${O}`;let Z=Bun.file(`${this.logsDirPath}/${O}`);this.writer=Z.writer(),this.fileSize=0,this.writerSize=0}this.isCreatingFile=!1}async log($,T,O={}){if(!this.isReady)await this.boot();let Z=A.getStore(),f={};if(Z)f={url:Z.req.rawRequest.url,method:Z.req.rawRequest.method,headers:Z.req.rawRequest.headers,body:Z.req.rawRequest.body};let j={timestamp:new Date(Date.now()).toISOString(),env:Bun.env.NODE_ENV,level:$,message:T,metadata:{...f,...O}},z="";try{z=JSON.stringify(j)}catch(F){console.log("Error parsing log object",F)}try{let F=this.config.onLogCreated(j);if(F instanceof Promise)F.catch((W)=>console.error("Error in onLogCreated",W))}catch(F){console.error("Error in onLogCreated",F)}if(!this.writer)return;this.writerSize+=z.length,this.fileSize+=z.length;try{this.writer.write(z),this.writer.write(`
4
+ `),this.tryFlush()}catch(F){console.error("Error writing log",F)}}async tryFlush(){if(this.fileSize>this.config.maxFileSize){if(!this.isCreatingFile)await this.newLogFile()}if(this.writerSize>this.config.maxFileSize/2)await this.writer.flush(),this.writerSize=0,await this.newLogFile();else clearTimeout(this.flushTimeout),this.flushTimeout=setTimeout(async()=>{await this.writer.flush(),this.writerSize=0},100)}}class Qj extends A0{middlewares=["cache:private,0"];routes={"/live":this.get(async()=>{let $=Bun.file(K(HT).currentLogFilePath);return new Response(await $.text(),{headers:{"Content-Type":"text/plain"}})})}}function F7($){let T=new Map;for(let O of $)if(typeof O==="string"){let[Z,f=""]=O.split(":");if(Z.startsWith("-")){if(T.has(Z.replace("-","")))T.delete(Z.replace("-",""))}else T.set(Z,f.split(",").filter(Boolean))}else T.set(O,[]);return T}class wT{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[T]=$.split(":");if(T.startsWith("-"))throw Error(`Global middleware "${$}" cancels an alias, but nothing is inherited into the global list. Remove it.`);if(!this.aliases[T])throw Error(`Global middleware "${T}" 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 T=new E;return Array.from(F7($).entries()).map(([O,Z])=>{if(typeof O==="string"){let f=this.aliases[O];if(f){let j=new f(T);return()=>j.run.call(j,...Z)}}else{if(pT(O)){let f=new O(T);return f.run.bind(f)}return O}}).filter(Boolean).reduce((O,Z)=>{return async()=>{return{...await O(),...await Z()}}},()=>Promise.resolve({}))()}}function pY($){return $}function cC(){return{onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{}}}function pC(){return{partialRendering:!0,onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{},onStreamComplete:()=>{}}}function W7($){return"run"in $}function C7($){return Object.hasOwn($,"get")||Object.hasOwn($,"post")||Object.hasOwn($,"put")||Object.hasOwn($,"delete")}function J7($){return Object.hasOwn($,"first")&&Object.hasOwn($,"second")}function D7($){if("__brand"in $)return $.__brand==="ApiRouter";return!1}function Y7($){if("__internal_brand"in $)return $.__internal_brand==="ProxyHandler";return!1}function X7($){if("__internal_brand"in $)return $.__internal_brand==="StreamHandler";return!1}function Mj($,T="",O=[]){let Z={};function f(j,z,F,W,C){let J=j==="/"?"":j,Y=T==="/"?"":T,D=(`${Y}${J}`===""?"/":`${Y}${J}`).replaceAll("//","/");if(!Z[D])Z[D]={};Z[D][z.toUpperCase()]={exec:F,middleware:[...O,...W],...C?{source:C}:{}},Z[D].OPTIONS={exec:()=>{let X=new E().ctx().headers;return new Response(null,{headers:X,status:204})},middleware:[]}}for(let[j,z]of Object.entries($)){if(Y7(z)){let F=z;for(let W of["GET","POST","PUT","DELETE"])f(j,W,F.run.bind(F),[]);continue}if(W7(z)){let F=z,W=F.method,C=F.middlewares,J=F.run.bind(F);if(f(j,W,J,C,F.source),X7(z))f(j,"HEAD",J,C,F.source)}if(C7(z))for(let[F,W]of Object.entries(z)){let C=W.middlewares,J=W.run.bind(W);f(j,F,J,C,W.source)}if(D7(z)){let F=new z,W=Mj(F.routes,`${T}${j}`,F.middlewares);for(let[C,J]of Object.entries(W))Z[C.replaceAll("//","/")]=J}if(J7(z)){let{first:F,second:W}=z;for(let[C,J]of Object.entries(F)){let Y=J.middlewares,D=J.run.bind(J),[U,...X]=j.split("/").reverse();if(!U.startsWith(":"))throw Error("Resource route must end with a dynamic segment");f(X.reverse().join("/"),C,D,Y,J.source)}for(let[C,J]of Object.entries(W)){let Y=J.middlewares,D=J.run.bind(J);f(j,C,D,Y,J.source)}}}return Object.fromEntries(Object.entries(Z).sort(([j],[z])=>{let F=j.split("/").length+j.split(":").length,W=z.split("/").length+z.split(":").length;return F-W}))}function zZ($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function Ij($,T){if($==="/")return T;if(T==="/")return $;return`${$}${T}`}function Vj($){let T=zZ($);return T.length>1?T.replace(/\/$/,""):T}function iC($,T){return T.map((O)=>({...O,path:Vj(Ij($,O.path))}))}function FZ($){let T={};for(let[O,Z]of Object.entries($))if("run"in Z){let f=Z;if("children"in f){let j=new f.children,z=FZ(j.routes);for(let[F,{exec:W,middleware:C,segments:J,features:Y}]of Object.entries(z)){let D=Ij(O,F),U=(X)=>f.run.call(f,X,O);T[zZ(D)]={exec:[U,...W],middleware:[...f.middlewares,...C],features:[...f.featureGates,...Y],viewPath:f.viewPath,segments:[{path:Vj(O),viewPath:f.viewPath,...f.alwaysRuns?{alwaysRun:!0}:{}},...iC(O,J)]}}}else{let j=(z)=>f.run.call(f,z,O);T[zZ(O)]={exec:[j],middleware:f.middlewares,features:f.featureGates,viewPath:f.viewPath,segments:[{path:Vj(O),viewPath:f.viewPath}]}}}else{let f=new Z,j=FZ(f.routes);for(let[z,{exec:F,middleware:W,viewPath:C,segments:J,features:Y}]of Object.entries(j)){let D=Ij(O,z);T[zZ(D)]={exec:F,middleware:[...f.middlewares,...W],features:[...f.featureGates,...Y],viewPath:C,segments:iC(O,J)}}}return Object.fromEntries(Object.entries(T).sort(([O],[Z])=>{let f=O.split("/").length+O.split(":").length,j=Z.split("/").length+Z.split(":").length;return f-j}))}var U7=Object.defineProperty,V=($,T)=>U7($,"name",{value:T,configurable:!0}),p$=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor($,T,O,Z,f,j){this.type=$,this.name=T,this.prefix=O,this.value=Z,this.suffix=f,this.modifier=j}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};V(p$,"Part");var G7=/[$_\p{ID_Start}]/u,B7=/[$_\u200C\u200D\p{ID_Continue}]/u,Nj=".*";function hC($,T){return(T?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test($)}V(hC,"isASCII");function _j($,T=!1){let O=[],Z=0;for(;Z<$.length;){let f=$[Z],j=V(function(z){if(!T)throw TypeError(z);O.push({type:"INVALID_CHAR",index:Z,value:$[Z++]})},"ErrorOrInvalid");if(f==="*"){O.push({type:"ASTERISK",index:Z,value:$[Z++]});continue}if(f==="+"||f==="?"){O.push({type:"OTHER_MODIFIER",index:Z,value:$[Z++]});continue}if(f==="\\"){O.push({type:"ESCAPED_CHAR",index:Z++,value:$[Z++]});continue}if(f==="{"){O.push({type:"OPEN",index:Z,value:$[Z++]});continue}if(f==="}"){O.push({type:"CLOSE",index:Z,value:$[Z++]});continue}if(f===":"){let z="",F=Z+1;for(;F<$.length;){let W=$.substr(F,1);if(F===Z+1&&G7.test(W)||F!==Z+1&&B7.test(W)){z+=$[F++];continue}break}if(!z){j(`Missing parameter name at ${Z}`);continue}O.push({type:"NAME",index:Z,value:z}),Z=F;continue}if(f==="("){let z=1,F="",W=Z+1,C=!1;if($[W]==="?"){j(`Pattern cannot start with "?" at ${W}`);continue}for(;W<$.length;){if(!hC($[W],!1)){j(`Invalid character '${$[W]}' at ${W}.`),C=!0;break}if($[W]==="\\"){F+=$[W++]+$[W++];continue}if($[W]===")"){if(z--,z===0){W++;break}}else if($[W]==="("&&(z++,$[W+1]!=="?")){j(`Capturing groups are not allowed at ${W}`),C=!0;break}F+=$[W++]}if(C)continue;if(z){j(`Unbalanced pattern at ${Z}`);continue}if(!F){j(`Missing pattern at ${Z}`);continue}O.push({type:"REGEX",index:Z,value:F}),Z=W;continue}O.push({type:"CHAR",index:Z,value:$[Z++]})}return O.push({type:"END",index:Z,value:""}),O}V(_j,"lexer");function Pj($,T={}){let O=_j($);T.delimiter??="/#?",T.prefixes??="./";let Z=`[^${b0(T.delimiter)}]+?`,f=[],j=0,z=0,F="",W=new Set,C=V((S)=>{if(z<O.length&&O[z].type===S)return O[z++].value},"tryConsume"),J=V(()=>C("OTHER_MODIFIER")??C("ASTERISK"),"tryConsumeModifier"),Y=V((S)=>{let N=C(S);if(N!==void 0)return N;let{type:x,index:Q}=O[z];throw TypeError(`Unexpected ${x} at ${Q}, expected ${S}`)},"mustConsume"),D=V(()=>{let S="",N;for(;N=C("CHAR")??C("ESCAPED_CHAR");)S+=N;return S},"consumeText"),U=V((S)=>S,"DefaultEncodePart"),X=T.encodePart||U,G="",B=V((S)=>{G+=S},"appendToPendingFixedValue"),L=V(()=>{G.length&&(f.push(new p$(3,"","",X(G),"",3)),G="")},"maybeAddPartFromPendingFixedValue"),M=V((S,N,x,Q,I)=>{let _=3;switch(I){case"?":_=1;break;case"*":_=0;break;case"+":_=2;break}if(!N&&!x&&_===3){B(S);return}if(L(),!N&&!x){if(!S)return;f.push(new p$(3,"","",X(S),"",_));return}let P;x?x==="*"?P=Nj:P=x:P=Z;let O0=2;P===Z?(O0=1,P=""):P===Nj&&(O0=0,P="");let g;if(N?g=N:x&&(g=j++),W.has(g))throw TypeError(`Duplicate name '${g}'.`);W.add(g),f.push(new p$(O0,g,X(S),P,X(Q),_))},"addPart");for(;z<O.length;){let S=C("CHAR"),N=C("NAME"),x=C("REGEX");if(!N&&!x&&(x=C("ASTERISK")),N||x){let I=S??"";T.prefixes.indexOf(I)===-1&&(B(I),I=""),L();let _=J();M(I,N,x,"",_);continue}let Q=S??C("ESCAPED_CHAR");if(Q){B(Q);continue}if(C("OPEN")){let I=D(),_=C("NAME"),P=C("REGEX");!_&&!P&&(P=C("ASTERISK"));let O0=D();Y("CLOSE");let g=J();M(I,_,P,O0,g);continue}L(),Y("END")}return f}V(Pj,"parse");function b0($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}V(b0,"escapeString");function Ej($){return $&&$.ignoreCase?"ui":"u"}V(Ej,"flags");function lC($,T,O){return Hj(Pj($,O),T,O)}V(lC,"stringToRegexp");function Z$($){switch($){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}V(Z$,"modifierToString");function Hj($,T,O={}){O.delimiter??="/#?",O.prefixes??="./",O.sensitive??=!1,O.strict??=!1,O.end??=!0,O.start??=!0,O.endsWith="";let Z=O.start?"^":"";for(let F of $){if(F.type===3){F.modifier===3?Z+=b0(F.value):Z+=`(?:${b0(F.value)})${Z$(F.modifier)}`;continue}T&&T.push(F.name);let W=`[^${b0(O.delimiter)}]+?`,C=F.value;if(F.type===1?C=W:F.type===0&&(C=Nj),!F.prefix.length&&!F.suffix.length){F.modifier===3||F.modifier===1?Z+=`(${C})${Z$(F.modifier)}`:Z+=`((?:${C})${Z$(F.modifier)})`;continue}if(F.modifier===3||F.modifier===1){Z+=`(?:${b0(F.prefix)}(${C})${b0(F.suffix)})`,Z+=Z$(F.modifier);continue}Z+=`(?:${b0(F.prefix)}`,Z+=`((?:${C})(?:`,Z+=b0(F.suffix),Z+=b0(F.prefix),Z+=`(?:${C}))*)${b0(F.suffix)})`,F.modifier===0&&(Z+="?")}let f=`[${b0(O.endsWith)}]|$`,j=`[${b0(O.delimiter)}]`;if(O.end)return O.strict||(Z+=`${j}?`),O.endsWith.length?Z+=`(?=${f})`:Z+="$",new RegExp(Z,Ej(O));O.strict||(Z+=`(?:${j}(?=${f}))?`);let z=!1;if($.length){let F=$[$.length-1];F.type===3&&F.modifier===3&&(z=O.delimiter.indexOf(F)>-1)}return z||(Z+=`(?=${j}|${f})`),new RegExp(Z,Ej(O))}V(Hj,"partsToRegexp");var g1={delimiter:"",prefixes:"",sensitive:!0,strict:!0},K7={delimiter:".",prefixes:"",sensitive:!0,strict:!0},L7={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function dC($,T){return $.length?$[0]==="/"?!0:!T||$.length<2?!1:($[0]=="\\"||$[0]=="{")&&$[1]=="/":!1}V(dC,"isAbsolutePathname");function wj($,T){return $.startsWith(T)?$.substring(T.length,$.length):$}V(wj,"maybeStripPrefix");function sC($,T){return $.endsWith(T)?$.substr(0,$.length-T.length):$}V(sC,"maybeStripSuffix");function bj($){return!$||$.length<2?!1:$[0]==="["||($[0]==="\\"||$[0]==="{")&&$[1]==="["}V(bj,"treatAsIPv6Hostname");var uC=["ftp","file","http","https","ws","wss"];function vj($){if(!$)return!0;for(let T of uC)if($.test(T))return!0;return!1}V(vj,"isSpecialScheme");function nC($,T){if($=wj($,"#"),T||$==="")return $;let O=new URL("https://example.com");return O.hash=$,O.hash?O.hash.substring(1,O.hash.length):""}V(nC,"canonicalizeHash");function aC($,T){if($=wj($,"?"),T||$==="")return $;let O=new URL("https://example.com");return O.search=$,O.search?O.search.substring(1,O.search.length):""}V(aC,"canonicalizeSearch");function oC($,T){return T||$===""?$:bj($)?Rj($):kj($)}V(oC,"canonicalizeHostname");function tC($,T){if(T||$==="")return $;let O=new URL("https://example.com");return O.password=$,O.password}V(tC,"canonicalizePassword");function rC($,T){if(T||$==="")return $;let O=new URL("https://example.com");return O.username=$,O.username}V(rC,"canonicalizeUsername");function eC($,T,O){if(O||$==="")return $;if(T&&!uC.includes(T))return new URL(`${T}:${$}`).pathname;let Z=$[0]=="/";return $=new URL(Z?$:"/-"+$,"https://example.com").pathname,Z||($=$.substring(2,$.length)),$}V(eC,"canonicalizePathname");function $8($,T,O){return gj(T)===$&&($=""),O||$===""?$:mj($)}V($8,"canonicalizePort");function T8($,T){return $=sC($,":"),T||$===""?$:WZ($)}V(T8,"canonicalizeProtocol");function gj($){switch($){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}V(gj,"defaultPortForProtocol");function WZ($){if($==="")return $;if(/^[-+.A-Za-z0-9]*$/.test($))return $.toLowerCase();throw TypeError(`Invalid protocol '${$}'.`)}V(WZ,"protocolEncodeCallback");function O8($){if($==="")return $;let T=new URL("https://example.com");return T.username=$,T.username}V(O8,"usernameEncodeCallback");function Z8($){if($==="")return $;let T=new URL("https://example.com");return T.password=$,T.password}V(Z8,"passwordEncodeCallback");function kj($){if($==="")return $;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test($))throw TypeError(`Invalid hostname '${$}'`);let T=new URL("https://example.com");return T.hostname=$,T.hostname}V(kj,"hostnameEncodeCallback");function Rj($){if($==="")return $;if(/[^0-9a-fA-F[\]:]/g.test($))throw TypeError(`Invalid IPv6 hostname '${$}'`);return $.toLowerCase()}V(Rj,"ipv6HostnameEncodeCallback");function mj($){if($===""||/^[0-9]*$/.test($)&&parseInt($)<=65535)return $;throw TypeError(`Invalid port '${$}'.`)}V(mj,"portEncodeCallback");function f8($){if($==="")return $;let T=new URL("https://example.com");return T.pathname=$[0]!=="/"?"/-"+$:$,$[0]!=="/"?T.pathname.substring(2,T.pathname.length):T.pathname}V(f8,"standardURLPathnameEncodeCallback");function j8($){return $===""?$:new URL(`data:${$}`).pathname}V(j8,"pathURLPathnameEncodeCallback");function z8($){if($==="")return $;let T=new URL("https://example.com");return T.search=$,T.search.substring(1,T.search.length)}V(z8,"searchEncodeCallback");function F8($){if($==="")return $;let T=new URL("https://example.com");return T.hash=$,T.hash.substring(1,T.hash.length)}V(F8,"hashEncodeCallback");var W8=class{#j;#Z=[];#T={};#$=0;#f=1;#C=0;#F=0;#X=0;#U=0;#G=!1;constructor($){this.#j=$}get result(){return this.#T}parse(){for(this.#Z=_j(this.#j,!0);this.#$<this.#Z.length;this.#$+=this.#f){if(this.#f=1,this.#Z[this.#$].type==="END"){if(this.#F===0){this.#S(),this.#J()?this.#O(9,1):this.#D()?this.#O(8,1):this.#O(7,0);continue}else if(this.#F===2){this.#Y(5);continue}this.#O(10,0);break}if(this.#X>0)if(this.#E())this.#X-=1;else continue;if(this.#N()){this.#X+=1;continue}switch(this.#F){case 0:this.#Q()&&this.#Y(1);break;case 1:if(this.#Q()){this.#P();let $=7,T=1;this.#I()?($=2,T=3):this.#G&&($=2),this.#O($,T)}break;case 2:this.#K()?this.#Y(3):(this.#L()||this.#D()||this.#J())&&this.#Y(5);break;case 3:this.#V()?this.#O(4,1):this.#K()&&this.#O(5,1);break;case 4:this.#K()&&this.#O(5,1);break;case 5:this.#x()?this.#U+=1:this.#_()&&(this.#U-=1),this.#A()&&!this.#U?this.#O(6,1):this.#L()?this.#O(7,0):this.#D()?this.#O(8,1):this.#J()&&this.#O(9,1);break;case 6:this.#L()?this.#O(7,0):this.#D()?this.#O(8,1):this.#J()&&this.#O(9,1);break;case 7:this.#D()?this.#O(8,1):this.#J()&&this.#O(9,1);break;case 8:this.#J()&&this.#O(9,1);break;case 9:break;case 10:break}}this.#T.hostname!==void 0&&this.#T.port===void 0&&(this.#T.port="")}#O($,T){switch(this.#F){case 0:break;case 1:this.#T.protocol=this.#W();break;case 2:break;case 3:this.#T.username=this.#W();break;case 4:this.#T.password=this.#W();break;case 5:this.#T.hostname=this.#W();break;case 6:this.#T.port=this.#W();break;case 7:this.#T.pathname=this.#W();break;case 8:this.#T.search=this.#W();break;case 9:this.#T.hash=this.#W();break;case 10:break}this.#F!==0&&$!==10&&([1,2,3,4].includes(this.#F)&&[6,7,8,9].includes($)&&(this.#T.hostname??=""),[1,2,3,4,5,6].includes(this.#F)&&[8,9].includes($)&&(this.#T.pathname??=this.#G?"/":""),[1,2,3,4,5,6,7].includes(this.#F)&&$===9&&(this.#T.search??="")),this.#M($,T)}#M($,T){this.#F=$,this.#C=this.#$+T,this.#$+=T,this.#f=0}#S(){this.#$=this.#C,this.#f=0}#Y($){this.#S(),this.#F=$}#B($){return $<0&&($=this.#Z.length-$),$<this.#Z.length?this.#Z[$]:this.#Z[this.#Z.length-1]}#z($,T){let O=this.#B($);return O.value===T&&(O.type==="CHAR"||O.type==="ESCAPED_CHAR"||O.type==="INVALID_CHAR")}#Q(){return this.#z(this.#$,":")}#I(){return this.#z(this.#$+1,"/")&&this.#z(this.#$+2,"/")}#K(){return this.#z(this.#$,"@")}#V(){return this.#z(this.#$,":")}#A(){return this.#z(this.#$,":")}#L(){return this.#z(this.#$,"/")}#D(){if(this.#z(this.#$,"?"))return!0;if(this.#Z[this.#$].value!=="?")return!1;let $=this.#B(this.#$-1);return $.type!=="NAME"&&$.type!=="REGEX"&&$.type!=="CLOSE"&&$.type!=="ASTERISK"}#J(){return this.#z(this.#$,"#")}#N(){return this.#Z[this.#$].type=="OPEN"}#E(){return this.#Z[this.#$].type=="CLOSE"}#x(){return this.#z(this.#$,"[")}#_(){return this.#z(this.#$,"]")}#W(){let $=this.#Z[this.#$],T=this.#B(this.#C).index;return this.#j.substring(T,$.index)}#P(){let $={};Object.assign($,g1),$.encodePart=WZ;let T=lC(this.#W(),void 0,$);this.#G=vj(T)}};V(W8,"Parser");var Aj=["protocol","username","password","hostname","port","pathname","search","hash"],v1="*";function xj($,T){if(typeof $!="string")throw TypeError("parameter 1 is not of type 'string'.");let O=new URL($,T);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}}V(xj,"extractValues");function T1($,T){return T?c$($):$}V(T1,"processBaseURLString");function q$($,T,O){let Z;if(typeof T.baseURL=="string")try{Z=new URL(T.baseURL),T.protocol===void 0&&($.protocol=T1(Z.protocol.substring(0,Z.protocol.length-1),O)),!O&&T.protocol===void 0&&T.hostname===void 0&&T.port===void 0&&T.username===void 0&&($.username=T1(Z.username,O)),!O&&T.protocol===void 0&&T.hostname===void 0&&T.port===void 0&&T.username===void 0&&T.password===void 0&&($.password=T1(Z.password,O)),T.protocol===void 0&&T.hostname===void 0&&($.hostname=T1(Z.hostname,O)),T.protocol===void 0&&T.hostname===void 0&&T.port===void 0&&($.port=T1(Z.port,O)),T.protocol===void 0&&T.hostname===void 0&&T.port===void 0&&T.pathname===void 0&&($.pathname=T1(Z.pathname,O)),T.protocol===void 0&&T.hostname===void 0&&T.port===void 0&&T.pathname===void 0&&T.search===void 0&&($.search=T1(Z.search.substring(1,Z.search.length),O)),T.protocol===void 0&&T.hostname===void 0&&T.port===void 0&&T.pathname===void 0&&T.search===void 0&&T.hash===void 0&&($.hash=T1(Z.hash.substring(1,Z.hash.length),O))}catch{throw TypeError(`invalid baseURL '${T.baseURL}'.`)}if(typeof T.protocol=="string"&&($.protocol=T8(T.protocol,O)),typeof T.username=="string"&&($.username=rC(T.username,O)),typeof T.password=="string"&&($.password=tC(T.password,O)),typeof T.hostname=="string"&&($.hostname=oC(T.hostname,O)),typeof T.port=="string"&&($.port=$8(T.port,$.protocol,O)),typeof T.pathname=="string"){if($.pathname=T.pathname,Z&&!dC($.pathname,O)){let f=Z.pathname.lastIndexOf("/");f>=0&&($.pathname=T1(Z.pathname.substring(0,f+1),O)+$.pathname)}$.pathname=eC($.pathname,$.protocol,O)}return typeof T.search=="string"&&($.search=aC(T.search,O)),typeof T.hash=="string"&&($.hash=nC(T.hash,O)),$}V(q$,"applyInit");function c$($){return $.replace(/([+*?:{}()\\])/g,"\\$1")}V(c$,"escapePatternString");function C8($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}V(C8,"escapeRegexpString");function J8($,T){T.delimiter??="/#?",T.prefixes??="./",T.sensitive??=!1,T.strict??=!1,T.end??=!0,T.start??=!0,T.endsWith="";let O=".*",Z=`[^${C8(T.delimiter)}]+?`,f=/[$_\u200C\u200D\p{ID_Continue}]/u,j="";for(let z=0;z<$.length;++z){let F=$[z];if(F.type===3){if(F.modifier===3){j+=c$(F.value);continue}j+=`{${c$(F.value)}}${Z$(F.modifier)}`;continue}let W=F.hasCustomName(),C=!!F.suffix.length||!!F.prefix.length&&(F.prefix.length!==1||!T.prefixes.includes(F.prefix)),J=z>0?$[z-1]:null,Y=z<$.length-1?$[z+1]:null;if(!C&&W&&F.type===1&&F.modifier===3&&Y&&!Y.prefix.length&&!Y.suffix.length)if(Y.type===3){let D=Y.value.length>0?Y.value[0]:"";C=f.test(D)}else C=!Y.hasCustomName();if(!C&&!F.prefix.length&&J&&J.type===3){let D=J.value[J.value.length-1];C=T.prefixes.includes(D)}C&&(j+="{"),j+=c$(F.prefix),W&&(j+=`:${F.name}`),F.type===2?j+=`(${F.value})`:F.type===1?W||(j+=`(${Z})`):F.type===0&&(!W&&(!J||J.type===3||J.modifier!==3||C||F.prefix!=="")?j+="*":j+=`(${O})`),F.type===1&&W&&F.suffix.length&&f.test(F.suffix[0])&&(j+="\\"),j+=c$(F.suffix),C&&(j+="}"),F.modifier!==3&&(j+=Z$(F.modifier))}return j}V(J8,"partsToPattern");var yj=class{#j;#Z={};#T={};#$={};#f={};#C=!1;constructor($={},T,O){try{let Z;if(typeof T=="string"?Z=T:O=T,typeof $=="string"){let F=new W8($);if(F.parse(),$=F.result,Z===void 0&&typeof $.protocol!="string")throw TypeError("A base URL must be provided for a relative constructor string.");$.baseURL=Z}else{if(!$||typeof $!="object")throw TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(Z)throw TypeError("parameter 1 is not of type 'string'.")}typeof O>"u"&&(O={ignoreCase:!1});let f={ignoreCase:O.ignoreCase===!0},j={pathname:v1,protocol:v1,username:v1,password:v1,hostname:v1,port:v1,search:v1,hash:v1};this.#j=q$(j,$,!0),gj(this.#j.protocol)===this.#j.port&&(this.#j.port="");let z;for(z of Aj){if(!(z in this.#j))continue;let F={},W=this.#j[z];switch(this.#T[z]=[],z){case"protocol":Object.assign(F,g1),F.encodePart=WZ;break;case"username":Object.assign(F,g1),F.encodePart=O8;break;case"password":Object.assign(F,g1),F.encodePart=Z8;break;case"hostname":Object.assign(F,K7),bj(W)?F.encodePart=Rj:F.encodePart=kj;break;case"port":Object.assign(F,g1),F.encodePart=mj;break;case"pathname":vj(this.#Z.protocol)?(Object.assign(F,L7,f),F.encodePart=f8):(Object.assign(F,g1,f),F.encodePart=j8);break;case"search":Object.assign(F,g1,f),F.encodePart=z8;break;case"hash":Object.assign(F,g1,f),F.encodePart=F8;break}try{this.#f[z]=Pj(W,F),this.#Z[z]=Hj(this.#f[z],this.#T[z],F),this.#$[z]=J8(this.#f[z],F),this.#C=this.#C||this.#f[z].some((C)=>C.type===2)}catch{throw TypeError(`invalid ${z} pattern '${this.#j[z]}'.`)}}}catch(Z){throw TypeError(`Failed to construct 'URLPattern': ${Z.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test($={},T){let O={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&T)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return!1;try{typeof $=="object"?O=q$(O,$,!1):O=q$(O,xj($,T),!1)}catch{return!1}let Z;for(Z of Aj)if(!this.#Z[Z].exec(O[Z]))return!1;return!0}exec($={},T){let O={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&T)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return;try{typeof $=="object"?O=q$(O,$,!1):O=q$(O,xj($,T),!1)}catch{return null}let Z={};T?Z.inputs=[$,T]:Z.inputs=[$];let f;for(f of Aj){let j=this.#Z[f].exec(O[f]);if(!j)return null;let z={};for(let[F,W]of this.#T[f].entries())if(typeof W=="string"||typeof W=="number"){let C=j[F+1];z[W]=C}Z[f]={input:O[f]??"",groups:z}}return Z}static compareComponent($,T,O){let Z=V((F,W)=>{for(let C of["type","modifier","prefix","value","suffix"]){if(F[C]<W[C])return-1;if(F[C]===W[C])continue;return 1}return 0},"comparePart"),f=new p$(3,"","","","",3),j=new p$(0,"","","","",3),z=V((F,W)=>{let C=0;for(;C<Math.min(F.length,W.length);++C){let J=Z(F[C],W[C]);if(J)return J}return F.length===W.length?0:Z(F[C]??f,W[C]??f)},"comparePartList");return!T.#$[$]&&!O.#$[$]?0:T.#$[$]&&!O.#$[$]?z(T.#f[$],[j]):!T.#$[$]&&O.#$[$]?z([j],O.#f[$]):z(T.#f[$],O.#f[$])}get protocol(){return this.#$.protocol}get username(){return this.#$.username}get password(){return this.#$.password}get hostname(){return this.#$.hostname}get port(){return this.#$.port}get pathname(){return this.#$.pathname}get search(){return this.#$.search}get hash(){return this.#$.hash}get hasRegExpGroups(){return this.#C}};V(yj,"URLPattern");function bT($,T){for(let[O,Z]of Object.entries($)){let f=new yj({pathname:O});if(f.test({pathname:T}))return{routePath:O,params:f.exec({pathname:T})?.pathname.groups??{},route:Z}}return null}var f$={startIndex:0,carriedViews:[]};function D8($,T){let O=u($.path,T);return O.includes("*")?null:O}function S7($,T){if(!$)return f$;if($.search!==T.search)return f$;let O=Math.min($.segments.length,T.segments.length-1),Z=0;while(Z<O){let f=$.segments[Z],j=T.segments[Z];if(j.alwaysRun)break;if(f.viewPath!==j.viewPath)break;let z=D8(f,$.params),F=D8(j,T.params);if(z===null||F===null||z!==F)break;Z++}if(Z===0)return f$;return{startIndex:Z,carriedViews:T.segments.slice(0,Z).map(({viewPath:f})=>f)}}function Q7($,T){let[,O,...Z]=$.split("/");if(!T.includes(O))return $;let f=`/${Z.join("/")}`;return f==="/"?"/":f.replace(/\/$/,"")}function Y8($){let{flatViewRoutes:T,supportedLocales:O,from:Z,origin:f,to:j}=$;if(!Z)return f$;let z;try{z=new URL(Z,f)}catch{return f$}if(z.origin!==f)return f$;let F=bT(T,Q7(z.pathname,O));if(!F)return f$;return S7({segments:F.route.segments,params:F.params,search:z.search},j)}var qj="x-gemi-from";import{createElement as n$,Fragment as q7}from"react";function M7($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function CZ($){let T={};for(let[O,Z]of Object.entries($))if("run"in Z){let f=Z.viewPath;if("children"in Z){T[O]=[f];let j=new Z.children,z=CZ(j.routes);for(let[F,W]of Object.entries(z)){let C=O==="/"?F:`${O}${F}`,J=F==="/"&&O!=="/"?O:C;T[J]=[f,...W]}if(T[O].length===1)delete T[O]}else T[O]=[f]}else{let f=new Z,j=CZ(f.routes);for(let[z,F]of Object.entries(j)){let W=O==="/"?z:`${O}${z}`,C=z==="/"&&O!=="/"?O:W;T[C]=F}}return Object.fromEntries(Object.entries(T).map(([O,Z])=>[M7(O),Z]))}function JZ($){let T=[];for(let[O,Z]of Object.entries($))if("run"in Z){let f=Z.viewPath;if(f==="__")continue;if(f==="REDIRECT")continue;if(f==="FILE")continue;if("children"in Z){let j=new Z.children,z=JZ(j.routes);T.push([f,z])}else T.push([f,[]])}else{let f=new Z,j=JZ(f.routes);T.push(...j)}return T}function cj($){let T=[];for(let[O,Z]of $)T.push(O,...cj(Z).flat());return Array.from(new Set(T))}class k1 extends T0{static getFacadeAccessor(){return HT}static debug($,T){this.getFacadeRoot().log("debug",$,T)}static info($,T){this.getFacadeRoot().log("info",$,T)}static notice($,T){this.getFacadeRoot().log("notice",$,T)}static warning($,T){this.getFacadeRoot().log("warning",$,T)}static error($,T){this.getFacadeRoot().log("error",$,T)}static critical($,T){this.getFacadeRoot().log("critical",$,T)}static alert($,T){this.getFacadeRoot().log("alert",$,T)}static emergency($,T){this.getFacadeRoot().log("emergency",$,T)}}class i$ extends T0{static getFacadeAccessor(){return n}static getSupportedLocales(){return this.getFacadeRoot().supportedLocales}static getDefaultLocale(){return this.getFacadeRoot().defaultLocale}static locale(){let $=this.getFacadeRoot(),T=A.getStore();if(T)return T.locale??$.detectLocale(T.req);return $.defaultLocale}static setLocale($=i$.locale()){let T=this.getFacadeRoot(),O=$;if(!T.supportedLocales.includes($))O=T.defaultLocale;let Z=A.getStore();return Z.setCookie("i18n-locale",O,{expires:new Date(Date.now()+31536000000),secure:!1,httpOnly:!1}),Z.setLocale(O),O}}class pj{id;static token="kernel.id";constructor($=crypto.randomUUID()){this.id=$}}var I7=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),V7=new Set(["svg","math"]);function X8($){return $===32||$===9||$===10||$===12||$===13}function U8($){return $>=65&&$<=90||$>=97&&$<=122}function DZ($){return $>=65&&$<=90?$+32:$}function G8(){let $="data",T="",O=!1,Z="",f=0,j=0,z=!1,F=0,W=0,C=()=>$==="data"&&F===0&&W===0,J=()=>{if(!O&&I7.has(T)){$="rawText",Z=`</${T}`,f=0,T="";return}if($="data",T==="template")if(O)F=Math.max(0,F-1);else F+=1;else if(V7.has(T)){if(O)W=Math.max(0,W-1);else if(!z)W+=1}T=""},Y=(D)=>{switch($){case"data":if(D===60)$="tagOpen";return;case"tagOpen":if(D===33)$="bang",j=0;else if(D===47)$="endTagOpen";else if(U8(D))$="tagName",O=!1,z=!1,T=String.fromCharCode(DZ(D));else if(D===63)$="bogus";else if(D===60)$="tagOpen";else $="data";return;case"endTagOpen":if(U8(D))$="tagName",O=!0,z=!1,T=String.fromCharCode(DZ(D));else if(D===62)$="data";else $="bogus";return;case"tagName":if(X8(D)||D===47)$="inTag",z=D===47;else if(D===62)J();else T+=String.fromCharCode(DZ(D));return;case"inTag":if(D===62){J();return}if(z=D===47,D===34)$="attrDouble";else if(D===39)$="attrSingle";return;case"attrDouble":if(D===34)$="inTag";z=!1;return;case"attrSingle":if(D===39)$="inTag";z=!1;return;case"bang":if(D===45){if(j+=1,j===2)$="comment",j=0}else if(D===62)$="data";else $="bogus";return;case"bogus":if(D===62)$="data";return;case"comment":if(D===45)j=j<2?j+1:2;else if(D===62&&j>=2)$="data",j=0;else j=0;return;case"rawText":{if(f<Z.length){if(DZ(D)===Z.charCodeAt(f))f+=1;else f=D===60?1:0;return}if(D===62)$="data",T="";else if(X8(D)||D===47)$="inTag",T="";else f=D===60?1:0;return}}};return{scanToInsertionPoint(D){for(let U=0;U<D.length;U++){if(C())return U;Y(D[U])}return D.length},write(D){for(let U=0;U<D.length;U++)Y(D[U])},isSafe:C}}function j$($){let T=JSON.stringify($);if(T===void 0)return"undefined";return T.replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function A7($){return`<script>(self.__GEMI_STREAM__=self.__GEMI_STREAM__||[]).push(${j$([$.path,$.variantKey,$.data])})</script>`}function N7($){return`<script>(self.__GEMI_DICT__=self.__GEMI_DICT__||[]).push(${j$([$.id,$.locale,$.strings])})</script>`}function ij($,T,O={},Z){let f=new TextEncoder,j=[],z=!1,F=!1,W=()=>{if(F)return;F=!0,O.onClose?.()};T.onSettle((X)=>{if(X.status!=="resolved")return;j.push(A7(X))}),Z?.onUse((X)=>{j.push(N7(X))});let C=$.getReader(),J=G8(),Y=(X,G)=>{X.enqueue(G),O.onChunk?.(G)},D=(X)=>{while(j.length>0){let G=f.encode(j.shift());J.write(G),Y(X,G)}},U=(X,G)=>{if(j.length===0){J.write(G),Y(X,G);return}let B=J.scanToInsertionPoint(G);if(B>0)Y(X,G.subarray(0,B));if(J.isSafe())D(X);let L=G.subarray(B);if(L.length>0)J.write(L),Y(X,L)};return new ReadableStream({async pull(X){let G;try{G=await C.read()}catch(M){throw W(),M}let{done:B,value:L}=G;if(B){D(X),X.close(),W();return}if(!z){if(z=!0,J.write(L),Y(X,L),O.onShell?.(),J.isSafe())D(X);return}U(X,L)},cancel(X){return W(),C.cancel(X)}})}var E7=/bot|crawler|spider|crawling|slurp|bingpreview|mediapartners|headless|lighthouse|prerender|facebookexternalhit|whatsapp|telegram|discord|twitterbot|linkedinbot/i;function YZ($){if(!$)return!1;return E7.test($)}async function K8($,T=()=>{}){let O=A.getStore(),Z=O?.req??null,f=null;if(Z?.rawRequest?.url)try{f=new URL(Z.rawRequest.url).pathname}catch{f=null}return{user:O?.user??null,attributes:await x7($,T),request:{path:f,routePath:Z?.routePath??null,locale:O?.locale??null},anonymousId:B8(),isBot:YZ(Z?.rawRequest?.headers?.get("user-agent")??null),now:new Date}}function L8($){return{user:$.user??null,attributes:$.attributes??{},request:{path:null,routePath:null,locale:null},anonymousId:$.subjectId??null,isBot:!1,now:new Date}}async function x7($,T){if(!$.context)return{};try{let O=A.getStore();return await $.context(O?.req??null)??{}}catch(O){return T(`The \`context\` hook in app/config/features.ts threw; evaluating with no attributes. ${O instanceof Error?O.message:String(O)}`),{}}}function S8($,T){return`${$}:${T}`}function hj($){let T=new Bun.CryptoHasher("sha1").update($).digest("hex"),O=Number.parseInt(T.slice(0,8),16);return Math.floor(O/4294967296*1e4)}function Q8($,T){if(T>=100)return!0;if(T<=0)return!1;return $<Math.round(T*100)}function M8($,T,O,Z){if(Z.unavailable)return{value:!1,reason:"unavailable"};if(Z.active!==!0)return{value:!1,reason:"inactive"};if(T.when){let j;try{j=T.when(O)}catch(z){return Z.warn?.(`The \`when\` for feature "${$}" threw; treating it as off. ${z instanceof Error?z.message:String(z)}`),{value:!1,reason:"error"}}if(typeof j==="boolean")return{value:j,reason:"attributed"}}if(T.rollout===void 0)return{value:!0,reason:"on"};if(O.isBot)return{value:!1,reason:"bot"};let f=P7($,T,O,Z.buckets);return Q8(f,T.rollout)?{value:!0,reason:"rollout"}:{value:!1,reason:"excluded"}}function _7($){let T=$.user?.publicId??$.user?.id;if(T!==void 0&&T!==null)return String(T);return $.anonymousId??""}function P7($,T,O,Z){let f=S8(T.salt??$,_7(O));if(!Z)return hj(f);let j=Z.get(f);if(j!==void 0)return j;let z=hj(f);return Z.set(f,z),z}class I8 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 lj{source;declared;ttlMs;warn;snapshot=null;inflight=null;lastFailureLoggedAt=0;generation=0;lastError=null;retryAfter=0;constructor($,T,O,Z=()=>{}){this.source=$;this.declared=T;this.ttlMs=O;this.warn=Z}async get(){let $=this.snapshot;if($&&Date.now()-$.loadedAt<this.ttlMs)return $;if($){if(Date.now()>=this.retryAfter)this.refresh().catch(()=>{});return $}return await this.refresh()}refresh(){return this.inflight??=this.load().finally(()=>{this.inflight=null}),this.inflight}async invalidate(){await this.inflight?.catch(()=>{});let $=this.generation,T=await this.refresh();if(this.generation===$)throw new I8(this.lastError);return T}peek(){return this.snapshot}async load(){try{let $=await this.source.load();return this.snapshot={active:this.readSwitches($),loadedAt:Date.now(),unavailable:!1},this.generation++,this.lastError=null,this.retryAfter=0,this.snapshot}catch($){return this.handleFailure($)}}readSwitches($){let T=new Map;for(let O of $??[]){let Z=typeof O?.key==="string"?O.key:null;if(!Z){this.warn("Ignoring a feature row with no `key`.");continue}if(!(Z in this.declared)){this.warn(`Feature row "${Z}" is not declared in app/features, so it is ignored. Delete the row, or declare the feature.`);continue}T.set(Z,O.active===!0)}return T}handleFailure($){let T=$ 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: ${T}`);if(this.snapshot)return this.snapshot;return this.snapshot={active:new Map,loadedAt:O,unavailable:!0},this.snapshot}}class V8{manager;ctx;constructor($,T){this.manager=$;this.ctx=T}async enabled($){return(await this.explain($)).value}async explain($){return await this.manager.evaluateIn($,this.ctx,new Map)}async all(){return await this.manager.evaluateAllIn(this.ctx,new Map,{clientOnly:!1})}}class h${config;log;static token="features";store;declared;warnedAboutSize=!1;constructor($,T=()=>{}){this.config=$;this.log=T;this.declared=$.features??{},this.store=new lj($.source,this.declared,Math.max(0,$.ttl)*1000,this.log)}declarations(){return this.declared}async list(){let{active:$,unavailable:T}=await this.switches();return{unavailable:T,features:Object.entries(this.declared).map(([O,Z])=>({key:O,describe:Z.describe,rollout:Z.rollout,targeted:Z.when!==void 0,serverOnly:Z.serverOnly,salt:Z.salt,active:$.get(O)}))}}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{A.getStore()?.featureEvaluations?.clear()}}async enabled($){return(await this.explain($)).value}async explain($){let T=await this.requestContext();return await this.evaluateIn($,T,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(),T=await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!0});return this.warnIfOversized(Object.keys(T).length),T}for($){return new V8(this,L8($))}async evaluateIn($,T,O){let Z=this.memoFor(T),f=Z?.get($);if(f)return f;let j=this.declared[$];if(!j)return{value:!1,reason:"undeclared"};let{active:z,unavailable:F}=await this.switchFor($),W=M8($,j,T,{active:z,unavailable:F,buckets:O,warn:this.log});return Z?.set($,W),this.notify($,W,T),W}async evaluateAllIn($,T,O){let Z={};for(let[f,j]of Object.entries(this.declared)){if(O.clientOnly&&j.serverOnly)continue;Z[f]=(await this.evaluateIn(f,$,T)).value}return Z}async switches(){if(!this.config.enabled)return{active:new Map,unavailable:!1};if(Object.keys(this.declared).length===0)return{active:new Map,unavailable:!1};let $=await this.store.get();return{active:$.active,unavailable:$.unavailable}}async switchFor($){if(!this.config.enabled)return{active:!1,unavailable:!1};let T=await this.store.get();return{active:T.active.get($),unavailable:T.unavailable}}async requestContext(){let $=A.getStore();if($?.featureContext)return $.featureContext;let T=await K8(this.config,this.log);if($)$.featureContext=T;return T}memoFor($){let T=A.getStore();if(!T||T.featureContext!==$)return null;return T.featureEvaluations??=new Map,T.featureEvaluations}requestBuckets(){let $=A.getStore();if(!$)return new Map;return $.featureBuckets??=new Map,$.featureBuckets}notify($,T,O){if(!this.config.onEvaluate)return;try{this.config.onEvaluate($,T,O)}catch(Z){this.log(`The \`onEvaluate\` hook in app/config/features.ts threw for "${$}". ${Z instanceof Error?Z.message:String(Z)}`)}}warnIfOversized($){if(this.warnedAboutSize||$<=this.config.maxClientFlags)return;this.warnedAboutSize=!0,this.log(`${$} client-visible features are embedded in every document. Mark the ones only the server reads with \`serverOnly: true\` to keep them out of the payload.`)}}function A8($){return Object.fromEntries(Object.entries($).filter(([,T])=>{return T!==null&&T!==void 0}))}var H7=50;class l${fetcher;entries=new Map;settleListener=null;failListener=null;shellAt=null;settledBacklog=[];shipped=new Set;requestStartedAt=performance.now();renderStartedAt=null;discoveryHintsMuted=!1;constructor($){this.fetcher=$}elapsed(){return Math.round(performance.now()-this.requestStartedAt)}keyFor($,T){return[$,T].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 T=this.elapsed();return{shellAt:this.shellAt??T,settledAt:T,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 T="";try{let f=JSON.stringify($.data)?.length??0;T=f>=1024?`${(f/1024).toFixed(1)} kB`:`${f} B`}catch{T="an unserializable payload"}let O=($.settledAt??0)-$.startedAt,Z=$.variantKey?`, { search: ${JSON.stringify(Object.fromEntries(new URLSearchParams($.variantKey)))} }`:"";console.warn(`[gemi] useQuery("${$.patternPath}") was discovered ${$.lateBy}ms into the `+`server render \u2014 under a suspended segment, so its fetch (${O}ms, resolved ${T}) could not overlap the others. It still streamed. If the query belongs on this route, \`Query.prefetch("${$.patternPath}"${Z})\` in the view `+"handler starts it at request time \u2014 but note prefetched data is also re-fetched and "+`streamed into every client-side navigation payload for the route, even when the client already holds it, so weigh that bandwidth against the ${T}. 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($,T){return this.entries.get(this.keyFor($,T))}ensure($,T={},O="render"){let Z=T.params??{},f=new URLSearchParams(A8(T.search??{}));f.delete("json"),f.sort();let j=u($,Z),z=f.toString(),F=this.keyFor(j,z),W=this.entries.get(F);if(W)return W;let C;if(O==="render"&&this.renderStartedAt!==null){let U=Math.round(performance.now()-this.renderStartedAt);if(U>H7)C=U}let J,Y=new Promise((U)=>{J=U}),D={path:j,patternPath:$,variantKey:z,lateBy:C,status:"pending",promise:Y,source:O,startedAt:this.elapsed()};return this.entries.set(F,D),this.fetcher($,Z,f).then((U)=>{D.status="resolved",D.data=U},(U)=>{D.status="rejected",D.error=U}).then(()=>{if(D.settledAt=this.elapsed(),this.maybeLogLateDiscovery(D),D.status==="rejected"&&this.failListener)this.failListener(D);if(this.settleListener)this.settleListener(D);else this.settledBacklog.push(D);J()}),D}async allSettled(){let $=0;while($!==this.entries.size)$=this.entries.size,await Promise.all(Array.from(this.entries.values(),(T)=>T.promise))}snapshotResolved(){let $={};for(let[T,O]of this.entries){if(O.status!=="resolved")continue;this.shipped.add(T),$[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 T=this.settledBacklog;this.settledBacklog=[];for(let O of T)this.settleListener(O)}}class z$ extends Error{path;variantKey;status;body;constructor($,T,O,Z){super(typeof Z?.message==="string"?Z.message:`Request to /api${$} failed with status ${O}`);this.path=$;this.variantKey=T;this.status=O;this.body=Z;this.name="QueryError"}}function d$(){let $=JSON.stringify({error:{message:"Forbidden"}});return new Response($,{status:403,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}function dj(){return{status:403,error:{message:"Forbidden"}}}function vT($){let T=s$.getStore();return(O,Z,f)=>{let j=new URL($.url).origin,z=[u(O,Z),f.toString()].filter((J)=>J.length>0).join("?"),F=new Request(`${j}/${z}`,{headers:$.headers}),W=N8($);if(W)u$(F,W);let C=new E(F,Z);return s$.run(T,()=>A.run(C,async()=>{try{let J=await K(u0).dispatchers(W).api.getRouteData(O);if(J instanceof Response){let Y=await J.json().catch(()=>null);if(!J.ok)throw new z$(u(O,Z),f.toString(),J.status,Y);return Y}return J}catch(J){if(J instanceof z$)throw J;let Y=new z$(u(O,Z),f.toString(),500,{message:J instanceof Error?J.message:String(J)});throw Y.cause=J,Y}}))}}var w7=new Set(["script","style","template","title"]),b7=/\shidden([\s=/]|$)/i,v7=/"[^"]*"|'[^']*'/g;function g7($){let T=0,O=0,Z=0,f=0;while(f<$.length){let j=$.indexOf("<",f),z=j===-1?$.length:j;if(z>f){let Y=$.slice(f,z).replace(/\s+/g,"").length;if(Z>0)O+=Y;else T+=Y}if(j===-1)break;if($.startsWith("<!--",j)){let Y=$.indexOf("-->",j+4);f=Y===-1?$.length:Y+3;continue}let F=$.indexOf(">",j);if(F===-1)break;let W=$.slice(j+1,F);f=F+1;let C=/^\/?([a-zA-Z][a-zA-Z0-9-]*)/.exec(W)?.[1]?.toLowerCase();if(!C)continue;let J=W.startsWith("/");if(!J&&w7.has(C)&&!W.endsWith("/")){let Y=$.indexOf(`</${C}`,f);f=Y===-1?$.length:Y;continue}if(C!=="div")continue;if(J){if(Z>0)Z-=1}else if(Z>0)Z+=1;else if(b7.test(W.replace(v7,'""')))Z=1}return{shellChars:T,deferredChars:O}}var k7=1000,R7=64;function m7($){return $>=1000?`${($/1000).toFixed(1)} kB`:`${$} chars`}function y7($,T){if(T.deferredChars<k7)return null;if(T.shellChars>=R7)return null;return`[gemi] GET ${$} streams ${m7(T.deferredChars)} of its `+`content behind reveal scripts \u2014 a no-JS visitor sees ~${T.shellChars} chars. If this is a public/content route, add "no-stream" to its middleware.`}function E8($=console.warn){let T=new Set;return{shouldObserve(O){return!T.has(O)},report(O,Z){if(T.has(O))return;let f=y7(O,Z);if(!f)return;T.add(O),$(f)}}}function x8(){let $=new TextDecoder,T="";return{onChunk(O){T+=$.decode(O,{stream:!0})},measure(){return T+=$.decode(),g7(T)}}}function _8($,T,O=1e4,Z){let f=new TextEncoder,j=()=>{};return new ReadableStream({start(z){let F=!1,W=(J)=>{if(F)return;F=!0,clearTimeout(C);try{z.close()}catch{}Z?.({aborted:J})};j=W,z.enqueue(f.encode(`${JSON.stringify($)}
5
+ `)),T.onSettle((J)=>{if(F||J.status!=="resolved")return;z.enqueue(f.encode(`${JSON.stringify([J.path,J.variantKey,J.data])}
6
+ `))});let C=setTimeout(()=>W(!0),O);T.allSettled().then(()=>W(!1),()=>W(!1))},cancel(){j(!1)}})}var c7=async()=>(await import("./chunk-yp0ah93s.js")).default,sj,uj=async(...$)=>{return sj??=import("react-dom/server.browser").catch((T)=>{throw sj=void 0,T}),(await sj).renderToReadableStream(...$)},p7=1e4,i7=`
7
+ !function(){try{var d=document.documentElement,c=d.classList;
8
+ c.remove('light','dark');
9
+ var e=localStorage.getItem('theme');
10
+ if('system'===e||(!e&&'system'===defaultTheme)){
11
+ var t='(prefers-color-scheme: dark)',m=window.matchMedia(t);
12
+ if(m.media!==t||m.matches){d.style.colorScheme='dark';c.add('dark')}
13
+ else{d.style.colorScheme='light';c.add('light')}
14
+ }else if(e){
15
+ c.add(e||'')
16
+ }}catch(e){}}()
17
+ `;async function h7($,T,O){let Z=`${O==="italic"?"italic,":""}wght@${O==="italic"?"1,":""}${T}`,z=(await(await fetch(`https://fonts.googleapis.com/css2?family=${$}:${Z}&display=swap`,{headers:{"User-Agent":"Mozilla/5.0 Firefox/1.0"}})).text()).match(/url\(([^)]+)\)/)?.[1];return await fetch(z).then((F)=>F.arrayBuffer())}var oj="/assets";function l7($){return $===oj||$.startsWith(`${oj}/`)}function d7($){let T=$.filter(l7);if(T.length>0){let O=T.length>1;throw Error(`View route path${O?"s":""} ${T.map((Z)=>`"${Z}"`).join(", ")} use${O?"":"s"} the reserved "${oj}" prefix. The client build output is served from there before the router runs, so the route would never match. Mount it somewhere else.`)}}function s7($){let T=K(u0).resolver;return{...$.domain,root:T.root,origin:T.publicOrigin($.rawRequest)}}function nj($){let{status:T=400,error:O}=$;return new Response(O?.message,{...$,status:T})}function u7($){let{status:T=400,data:O,directive:Z,headers:f}=$;return new Response(JSON.stringify({data:O,directive:Z}),{headers:f,status:T})}class RT{static token="router.view";flatViewRoutes={};routeManifest={};clientRouteManifest={};componentTree=[];flatComponentTree=[];root=null;shellReporter=E8();preloadCache=new WeakMap;hooks;partialRendering;constructor($){let T=pC();this.partialRendering=$.partialRendering??T.partialRendering,this.hooks={onRequestStart:$.onRequestStart??T.onRequestStart,onRequestEnd:$.onRequestEnd??T.onRequestEnd,onRequestFail:$.onRequestFail??T.onRequestFail,onStreamComplete:$.onStreamComplete??T.onStreamComplete};let O={"/":$.rootRouter,"/auth":Dj};this.flatViewRoutes=FZ(O),d7(Object.keys(this.flatViewRoutes)),this.routeManifest=CZ(O),this.clientRouteManifest=Object.fromEntries(Object.entries(this.routeManifest).filter(([,Z])=>Z.at(-1)!=="FILE")),this.componentTree=JZ(O),this.flatComponentTree=cj(this.componentTree),this.root=$.root}async passesFeatureGates($){let T=K(h$);for(let O of $)if(!await T.enabled(O))return!1;return!0}async onRequestEnd($){return aj(),await this.hooks.onRequestEnd($)}completeStream($,T){let O=(Z)=>{k1.error(Z?.message??'Error in "onStreamComplete" event handler',{err:JSON.stringify(Z)})};try{Promise.resolve(this.hooks.onStreamComplete($,T)).catch(O)}catch(Z){O(Z)}}modulePreloadLinks($){let{clientEntry:T,modulePreloadManifest:O,views:Z,routeKey:f}=$,j=()=>{let W=new Set(T?.preload??[]);for(let C of Z)for(let J of O?.[C]??[])W.add(J);return[...W].map((C)=>n$("link",{key:`modulepreload:${C}`,rel:"modulepreload",href:C}))};if(!O)return j();let z=this.preloadCache.get(O);if(!z||z.clientEntry!==T)z={clientEntry:T,byRoute:new Map},this.preloadCache.set(O,z);let F=z.byRoute.get(f);if(!F)F=j(),z.byRoute.set(f,F);return F}async render($){let{req:T,runInRequestScope:O,csrfTokenHMAC:Z,currentPathName:f,headers:j,i18n:z,params:F,pathname:W,serverQueries:C,userAgent:J,noStream:Y,url:D,user:U,viewData:X,breadcrumbs:G,urlLocaleSegment:B,meta:L,isOgRequest:M,appId:S,features:N}=$,x=W.replace(`/${B}`,""),Q={kind:"view",data:{meta:L,pageData:{[x]:X},__csrf:Z.toString("base64"),prefetchedData:{},i18n:z,auth:{user:U},routeManifest:this.clientRouteManifest,breadcrumbs:G,router:{urlLocaleSegment:B,pathname:f,params:F,currentPath:W,searchParams:D.search,is404:!f?!0:!1,domain:T.domain?s7(T):null},appId:S,features:N,componentTree:[["404",[]],...this.componentTree]},head:{}},I=this.root,_=this.routeManifest[f];return async(P)=>{let{bootstrapModules:O0=[],loaders:g,getStyles:m,viewImportMap:Z0,cssManifest:LZ,ogMap:mT,viewModules:F$,clientEntry:Z1,modulePreloadManifest:R1,assetBase:f0}=P,t$=Z1?[]:O0,yT=(V0)=>[V0,`window.loaders=${g}`,...Z1?[`import(${JSON.stringify(Z1.module)}).catch(function(e){setTimeout(function(){throw e})})`]:[]].join(";");if(M){let V0=null,J$=null;for(let D$ of _??[])if(typeof mT[D$]==="function")J$=D$,V0=mT[D$];if(!V0)return new Response("Not found",{status:404});let T2=Object.values(Q.data.pageData)[0];try{await uj(n$(V0,T2[J$]),{onError:()=>{}})}catch(D$){let{fonts:O2,...Z2}=D$.satoriOptions,f2=await Promise.all(O2.map((cT)=>{return h7(cT.name,cT.weight,cT.style).then((C2)=>({...cT,data:C2}))})),zz=new Headers(j);zz.set("Content-Type","image/png");let[j2,z2]=await Promise.all([c7(),jZ("Rendering an OG image")]),F2=await j2(D$.jsx,{...Z2,fonts:f2}),W2=await z2(Buffer.from(F2)).png({compressionLevel:0,effort:10}).toBuffer();return new Response(new Uint8Array(W2),{headers:zz})}return new Response("data")}if(Q.data.cssManifest=LZ,Q.data.modulePreloadManifest=R1??{},f0&&f0!=="/")Q.data.assetBase=f0;let W$=this.modulePreloadLinks({clientEntry:Z1,modulePreloadManifest:R1,views:_??["404"],routeKey:f??"404"}),r$=await m(_);Q.data.prefetchedData=C.snapshotResolved(),C.markRenderStart();let U1=new AbortController,qT=setTimeout(()=>U1.abort(),p7),H=YZ(J)||Y,I0=Bun.env.NODE_ENV!=="production"&&!H&&f&&this.shellReporter.shouldObserve(f)?x8():null,C$=w8();try{let V0=await uj(n$(q7,{children:[...W$,...r$,n$("script",{key:"theme-script",dangerouslySetInnerHTML:{__html:i7}}),n$(I,{data:Q.data,viewImportMap:Z0,viewModules:F$,serverQueries:C,dictionarySink:C$,key:"root"})]}),{bootstrapScriptContent:yT(`window.__GEMI_DATA__ = ${j$(Q.data)}`),bootstrapModules:t$,signal:U1.signal,...H?{progressiveChunkSize:Number.MAX_SAFE_INTEGER}:{},onError(J$){if(Bun.env.NODE_ENV!=="production")console.error(J$)}});if(V0.allReady.catch(()=>{}).finally(()=>clearTimeout(qT)),H)await V0.allReady.catch(()=>{});return new Response(ij(V0,C,{onShell:H?void 0:()=>C.markShell(),onChunk:I0?.onChunk,onClose:()=>O(()=>{if(this.completeStream(T,C.summarize(U1.signal.aborted)),I0)this.shellReporter.report(f,I0.measure())})},C$),{status:!f?404:200,headers:j})}catch(V0){if(clearTimeout(qT),Bun.env.NODE_ENV==="production")throw O(()=>this.completeStream(T,C.summarize(U1.signal.aborted))),V0;let J$=await uj(n$("div"),{bootstrapScriptContent:yT(`window.error= ${j$(V0.message)}; window.stack_trace=${j$(V0.stack)};window.__GEMI_DATA__ = ${j$(Q.data)}`),bootstrapModules:Bun.env.NODE_ENV==="development"?["/render-error.js",...t$]:t$});return new Response(ij(J$,C,{onClose:()=>O(()=>this.completeStream(T,C.summarize(U1.signal.aborted)))}),{status:!f?404:200,headers:j})}}}async handleViewRequest($,T){let O=new URL($.url),Z=O.pathname.endsWith(".json"),f=O.pathname.endsWith(".og"),j=O.pathname.replace(".json","").replace(".og",""),[,z,...F]=j.split("/"),W=`/${F.join("/")}`,C=null,J=null,Y=K(n);if(!Y.supportedLocales.includes(z))W=j;else C=z,J=z;let U=J===null&&bT(this.flatViewRoutes,W)!==null;if(Y.isLocaleAware&&!f&&J===null&&!U){let Q=P8(z,Y.supportedLocales,Y.defaultLocale);if(Q){let I=F.length?`/${F.join("/")}`:"";return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${Q}${I}${Z?".json":""}${O.search}`}})}}if(Y.isLocaleAware&&!f){let Q=K(n).detectLocale(new E($,{},"view",W));if(J===null&&Q!==Y.defaultLocale){let I=O.pathname==="/"?"":O.pathname;return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${Q}${I}${O.search}`}})}}W=W.replace("//","/");let X=[],G=[],B=null,L={},M=null,S=!1,N=[];try{let Q=bT(this.flatViewRoutes,W);if(Q){if(B=Q.routePath,L=Q.params,X=Q.route.exec,G=Q.route.middleware,N=Q.route.features,S=G.includes("no-stream"),Z&&this.partialRendering){let I=$.headers.get(qj),_=Y8({flatViewRoutes:this.flatViewRoutes,supportedLocales:K(n).supportedLocales,from:I,origin:O.origin,to:{segments:Q.route.segments,params:L,search:O.search}});if(_.startIndex>0)X=X.slice(_.startIndex),M={from:I,carriedViews:_.carriedViews}}}}catch(Q){throw Q}let x=new E($,L,"view",B);return this.hooks.onRequestStart(x),await A.run(x,async()=>{let Q=null,I=A.getStore(),_=s$.getStore(),P=(m)=>s$.run(_,()=>A.runWith(I,m));I.serverQueries=new l$(vT($));let O0=new Set;if(I.serverQueries.onQueryFail((m)=>{O0.add(m.error);try{P(()=>Promise.resolve(this.hooks.onRequestFail(g,m.error)).catch(()=>{}))}catch{}}),J){let m=J.replaceAll("/","");i$.setLocale(m)}else i$.setLocale();let g=I.req;aj();try{let m=!1;try{await K(wT).runMiddleware(G)}catch(H){if(!a$(H))throw H;m=!0}if(m||N.length>0&&!await this.passesFeatureGates(N))B=null,X=[],g.routePath="";let Z0=K(n),LZ=Z0.isEnabled,mT=Z0.isLocaleAware,F$={};if(mT){let H=null;if(J)H=J.replaceAll("/",""),I.setLocale(H);else H=Z0.detectLocale(new E($,g.params)),I.setLocale(H);let I0=LZ?Z0.getPageTranslations(H,g.routePath):{};F$={supportedLocales:Z0.supportedLocales,currentLocale:H,dictionary:{[H]:I0},defaultLocale:Z0.defaultLocale}}await H8(F$.currentLocale??"");let Z1;try{Z1=await Promise.all(X.map((H)=>H(g)))}catch(H){if(!a$(H))throw H;B=null,X=[],g.routePath="",Z1=[]}let{cookies:R1,headers:f0}=I;Q={data:Z1,cookies:R1,headers:f0,user:I.user,prefetchedData:I.serverQueries.snapshotResolved(),currentPathName:B,params:g.params,urlLocaleSegment:C,meta:I.renderMeta(),appId:K(pj).id,features:await K(h$).forClient()};let{params:t$,user:yT}=Q,W$={},r$={};for(let H of Z1??[]){let[I0,C$]=Object.entries(H)?.[0]??[];if(!I0||!C$)continue;r$[`${I0}:${B}`]=C$.breadcrumb,W$[I0]=C$}let U1=W$.FILE;if(U1){for(let H of R1)f0.append("Set-Cookie",H.toString());try{await this.onRequestEnd(g)}catch(H){k1.error(H?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(H)})}return await xZ(U1,f0)}if(Z){f0.set("Content-Type","application/x-ndjson; charset=utf-8"),f0.append("Vary",qj),R1.forEach((I0)=>f0.append("Set-Cookie",I0.toString())),await this.hooks.onRequestEnd(g);let H={meta:M&&!I.metadata.touched?null:Q.meta,data:{[W]:W$},breadcrumbs:r$,prefetchedData:I.serverQueries.snapshotResolved(),i18n:F$,features:Q.features,is404:!B,appId:Q.appId,partial:M};return new Response(_8(H,I.serverQueries,void 0,({aborted:I0})=>P(()=>this.completeStream(g,I.serverQueries.summarize(I0)))),{headers:f0})}if(f0.set("Content-Type","text/html; charset=utf-8"),!S)f0.append("Vary","User-Agent");for(let H of R1)f0.append("Set-Cookie",H.toString());let qT=Bun.CSRF.generate(process.env.SECRET);f0.append("Set-Cookie",`csrf_token=${qT}; HttpOnly; Secure; SameSite=Strict; Expires=${new Date(Date.now()+86400000).toUTCString()}`);try{await this.onRequestEnd(g)}catch(H){k1.error(H?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(H)})}return await this.render({req:g,runInRequestScope:P,csrfTokenHMAC:Buffer.from(""),currentPathName:B,headers:f0,i18n:F$,params:t$,pathname:O.pathname,serverQueries:I.serverQueries,userAgent:$.headers.get("user-agent"),noStream:S,url:O,user:yT,viewData:W$,breadcrumbs:r$,urlLocaleSegment:C,meta:Q.meta,appId:Q.appId,features:Q.features,isOgRequest:f})}catch(m){if(m.kind===gT)if(Z)return u7(m.payload.viewData??m.payload.api);else return nj(m.payload.view);if(!O0.has(m))this.hooks.onRequestFail(g,m);if(kT(m))return console.error(m),Z?d$():nj(dj());if(m instanceof z$&&m.status===403)return Z?d$():nj(dj());throw m}},T)}}function rj(){let $=JSON.stringify({error:{message:"Not found"}});return new Response($,{status:404,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}class m8 extends A0{routes={"/api-routes":this.get(()=>{let $=K(UZ).flatRoutes,T=[];for(let[O,Z]of Object.entries($))for(let[f,j]of Object.entries(Z)){let{exec:z,middleware:F}=j;T.push({path:O,method:f,middleware:F})}return T}),"/view-routes":this.get(()=>{let $=K(RT).flatViewRoutes,T=[];for(let[O,{middleware:Z,viewPath:f}]of Object.entries($))T.push({path:O,method:"GET",viewPath:f,middleware:Z});return T})}}var XZ="access_token";function n7($,T){let O=$.body.getReader(),Z=!1,f=()=>{if(Z)return;Z=!0;try{T()}catch(z){console.error(z)}},j=new ReadableStream({async pull(z){let F;try{F=await O.read()}catch(W){f(),z.error(W);return}if(F.done){f();try{z.close()}catch{}return}try{z.enqueue(F.value)}catch{}},async cancel(z){try{await O.cancel(z)}finally{f()}}},{highWaterMark:0});return new Response(j,{status:$.status,statusText:$.statusText,headers:$.headers})}function b8($){let{status:T=400,data:O,headers:Z}=$,f=new Headers({"Content-Type":"application/json",...Z});if(!f.has("Cache-Control"))f.set("Cache-Control","no-store");return new Response(JSON.stringify(O),{status:T,headers:f})}function v8($,T,O){let Z=[];T?.forEach((z,F)=>Z.push([F,z]));let f=[...typeof T?.getSetCookie==="function"?T.getSetCookie():[],...Array.from(O??[])];if(Z.length===0&&f.length===0)return $;let j=(z)=>{for(let[F,W]of Z){if(F.toLowerCase()==="set-cookie")continue;if(!z.has(F))z.set(F,W)}for(let F of f)z.append("Set-Cookie",F)};try{return j($.headers),$}catch{let z=new Headers($.headers);return j(z),new Response($.body,{status:$.status,statusText:$.statusText,headers:z})}}class UZ{static token="router.api";flatRoutes={};onRequestStart;onRequestEnd;onRequestFail;constructor($){let T=cC();this.onRequestStart=$.onRequestStart??T.onRequestStart,this.onRequestEnd=$.onRequestEnd??T.onRequestEnd,this.onRequestFail=$.onRequestFail??T.onRequestFail,this.flatRoutes=Mj({"/":$.rootRouter,"/auth":Yj,"/__gemi__/services/i18n":Xj,"/__gemi__/services/logs":Qj,"/__gemi__/services/image":Bj,"/__gemi__/debug":m8})}getRouteHandlerAndParams($){let T=new URL($.url),O=R8(T.pathname),Z={},f;for(let[j]of Object.entries(this.flatRoutes))try{let z=new URLPattern({pathname:j});if(z.test({pathname:O})){f=j,Z=z.exec({pathname:O})?.pathname.groups;break}}catch(z){console.error(z)}return{params:Z,path:f}}async runRouteMiddleware($,T){let Z=this.flatRoutes[$][T.rawRequest.method].middleware;try{await K(wT).runMiddleware(Z)}catch(f){if(f.kind===gT)return b8(f.payload.api);else{if(a$(f))return rj();if(this.onRequestFail(T,f),console.error(f),kT(f))return d$();throw f}}}async getRouteData($){let T=this.flatRoutes[$],O=A.getStore(),Z=T[O.req.rawRequest.method].exec??(()=>Promise.resolve({})),f={};try{f=await Z()}catch(j){if(j.kind===gT)return b8(j.payload.api);if(a$(j))return rj();if(this.onRequestFail(O.req,j),console.error(j),kT(j))return d$();throw j}return f}isFrameworkRoute($){return $.startsWith("/__gemi__")}async endRequest($,T,O){let Z=async()=>{try{if(!this.isFrameworkRoute(O))await this.onRequestEnd(T)}catch(f){k1.error(f?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(f)})}finally{$.destroy()}};if(!$.hasPendingWork()){await Z();return}$.whenIdle().then(Z).catch((f)=>{console.error(f)})}isOpenEndedBody($,T){return $.method!=="HEAD"&&T.body!==null&&!T.headers.has("Content-Length")}async handleApiRequest($,T){let{params:O,path:Z}=this.getRouteHandlerAndParams($),f=this.flatRoutes[Z];if(!f||!f[$.method])return new Response(JSON.stringify({error:{message:"Not found"}}),{status:404});let j=new E($,O,"api",Z);if(!this.isFrameworkRoute(Z))this.onRequestStart(j);return await A.run(j,async()=>{let z=A.getStore(),F=!1,W=async()=>{F=!0,await this.endRequest(z,j,Z)};try{let C=K(n);if(C.isEnabled){let X=C.detectLocale(j);z.setLocale(X)}z.setRequest(j);let J=await this.runRouteMiddleware(Z,j);if(J instanceof Response){let X=v8(J,z.headers,z.cookies);return await W(),X}let Y=await this.getRouteData(Z),D=z.headers,U=z.cookies;if(Y instanceof Response){let X=v8(Y,D,U);if(this.isOpenEndedBody($,X)){let G=n7(X,()=>this.endRequest(z,j,Z));return F=!0,G}return await W(),X}return D.set("Content-Type","application/json"),U.forEach((X)=>D.append("Set-Cookie",X.toString())),await W(),new Response(JSON.stringify(Y),{headers:D})}catch(C){if(!F)try{await W()}catch(J){console.error(J)}throw C}},T)}async dispatchAs($,T,O,Z){let f=new URL($.rawRequest.url).origin,j=new URL(`${f}/api${O}`),z=`/api${O.split(/[?#]/)[0]}`;if(!O.startsWith("/")||j.origin!==f||j.pathname!==z||j.hash!==""||j.pathname.startsWith("/api/__gemi__")||j.pathname==="/api/auth"||j.pathname.startsWith("/api/auth/"))throw Error(`dispatchAs: "${O}" is not an app api path. Pass the route's own path, without "/api", with every param encoded.`);let F=new Headers,W=$.cookies.get(XZ);if(W)F.set("Cookie",`${XZ}=${W}`);let C=$.headers.get(XZ);if(C)F.set(XZ,C);let J=$.headers.get("User-Agent");if(J)F.set("User-Agent",J);let Y;if(Z instanceof FormData)Y=Z;else if(Z!==void 0)F.set("Content-Type","application/json"),Y=JSON.stringify(Z);let D=new Request(j,{method:T,headers:F,body:Y});if(g8(D,dT($)),$.domain)u$(D,$.domain);return A.exit(()=>k8.exit(()=>this.handleApiRequest(D)))}}var $z="",y8="*";var ej=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;function q8($){return $.startsWith(":")}function O1($){if(!$)return null;try{return new URL(`http://${$.trim()}`).hostname.toLowerCase().replace(/\.$/,"")||null}catch{return null}}function a7($){try{let T=new URL(`http://${$.trim()}`),O=T.hostname.toLowerCase().replace(/\.$/,"");return O?T.port?`${O}:${T.port}`:O:null}catch{return null}}function o7($){let T=O1($.root),O=$.root?.trim().toLowerCase().replace(/\.$/,"");if(!T||T!==O||!T.split(".").every((j)=>ej.test(j)))throw Error(`\`route.domains.root\` must be a bare hostname, e.g. "example.com" \u2014 no scheme, port or path. Got "${$.root}".`);if($.custom&&($.custom.cacheTtlMs??0)<0)throw Error(`\`route.domains.custom.cacheTtlMs\` is ${$.custom.cacheTtlMs}; it cannot be negative. Use 0 to disable the cache.`);if($.ask&&$.ask.secret.length<16)throw Error("`route.domains.ask.secret` must be at least 16 characters. A guessable one is worse than leaving `ask` out.");let Z=new Set,f=null;for(let j of $.groups??[]){let{subdomain:z}=j;if(Z.has(z))throw Error(`\`route.domains\` declares the subdomain "${z}" twice.`);if(Z.add(z),q8(z)){if(!/^:[A-Za-z_][A-Za-z0-9_]*$/.test(z))throw Error(`"${z}" is not a valid param subdomain. It must be a single \`:name\` label.`);if(f)throw Error(`\`route.domains\` declares two param subdomains, "${f.subdomain}" and "${z}"; a host could match either.`);f=j;continue}if(j.exists)throw Error(`The subdomain "${z}" is fixed, so \`exists\` has no param to check. It only applies to a \`:param\` subdomain.`);if(!z.split(".").every((F)=>ej.test(F)))throw Error(`"${z}" is not a valid subdomain.`)}if($.custom&&!Z.has($.custom.group))throw Error(`\`route.domains.custom.group\` is "${$.custom.group}", but no group declares that subdomain.`);if($.ask&&f&&!f.exists)throw Error(`\`route.domains.ask\` is set, so "${f.subdomain}" needs an \`exists\` to say which tenants are real. Without one every host under the root would be approved for a certificate.`)}class Tz{root;trustProxy;fixed=new Map;param=null;custom;cacheTtlMs;cache=new Map;inFlight=new Map;askSecret;constructor($){o7($),this.root=O1($.root),this.trustProxy=$.trustProxy??!1;for(let T of $.groups??[])if(q8(T.subdomain))this.param={...T,name:T.subdomain.slice(1)};else this.fixed.set(T.subdomain.toLowerCase(),T);this.custom=$.custom??null,this.cacheTtlMs=this.custom?.cacheTtlMs??60000,this.askSecret=$.ask?.secret??null}hostOf($){if(this.trustProxy){let T=$.headers.get("x-forwarded-host")?.split(",")[0],O=O1(T);if(O)return O}return O1(new URL($.url).host)}publicOrigin($){let T=new URL($.url),O=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),Z=O==="http"||O==="https"?O:T.protocol.replace(/:$/,"");if(!this.trustProxy)return`${Z}://${T.host}`;let f=$.headers.get("x-forwarded-host")?.split(",")[0]?.trim(),j=f&&O1(f)?a7(f):null;return`${Z}://${j??T.host}`}async resolve($){let T=this.hostOf($);if(!T)return null;let O=await this.match(T,$);if(O)return O;if(this.custom?.fallback&&!this.isUnderRoot(T))return{host:T,group:"*",params:{},custom:!0};return null}async allows($,T){let O=O1($);return O?await this.match(O,T)!==null:!1}isUnderRoot($){return $===this.root||$.endsWith(`.${this.root}`)}async match($,T){if($===this.root)return{host:$,group:"",params:{},custom:!1};if($.endsWith(`.${this.root}`)){let Z=$.slice(0,-(this.root.length+1)),f=this.fixed.get(Z);if(f)return{host:$,group:f.subdomain,params:{},custom:!1};if(this.param&&ej.test(Z)){let j={[this.param.name]:Z};if(this.param.exists&&!await this.param.exists(j,T))return null;return{host:$,group:this.param.subdomain,params:j,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 T=Date.now(),O=this.cache.get($);if(O&&O.expiresAt>T)return this.cache.delete($),this.cache.set($,O),O.value;let Z=this.inFlight.get($);if(Z)return Z;let f=(async()=>await this.custom.resolve($)??null)();this.inFlight.set($,f);let j;try{j=await f}finally{this.inFlight.delete($)}if(this.cacheTtlMs>0){if(this.cache.size>=1e4)this.cache.delete(this.cache.keys().next().value);this.cache.delete($),this.cache.set($,{value:j,expiresAt:Date.now()+this.cacheTtlMs})}return j}forget($){if($===void 0)this.cache.clear();else{let T=O1($);if(T)this.cache.delete(T)}}}var r7="/__gemi__/domains/ask";function e7($,T){if($===null)return!1;let O=Buffer.from($,"utf8"),Z=Buffer.from(T,"utf8");return O.length===Z.length&&t7(O,Z)}class u0{static token="router.domains";resolver;acceptsCustomDomains;groups=new Map;constructor($,T){this.groups.set($z,$);let{domains:O}=T;if(this.acceptsCustomDomains=Boolean(O?.custom),!O){this.resolver=null;return}this.resolver=new Tz(O);let Z=(f)=>({api:f.api?new UZ({...T.api,...f.api}):$.api,view:f.view?new RT({...T.view,...f.view}):$.view});for(let f of O.groups??[])this.groups.set(f.subdomain,Z(f));if(O.custom?.fallback)this.groups.set(y8,Z(O.custom.fallback))}async route($){if(!this.resolver)return this.dispatchers(null);let T=await this.resolver.resolve($);if(!T)return null;return u$($,T),this.dispatchers(T)}async ask($){if(!this.resolver?.askSecret||$.method!=="GET")return null;let T=new URL($.url);if(T.pathname!==r7)return null;if(!e7(T.searchParams.get("secret"),this.resolver.askSecret))return null;let O=T.searchParams.get("domain"),Z=O?await this.resolver.allows(O,$):!1;return new Response(null,{status:Z?200:404})}dispatchers($){return this.groups.get($?.group??$z)}viewDispatchers(){return Array.from(new Set(Array.from(this.groups.values(),($)=>$.view)))}}function c8($){let T=new Date($??0).getTime();return Number.isFinite(T)?T:0}class w{static token="auth";config;provider;constructor($={},T=new mZ){this.config=p8(vz($),$),this.provider=T}get userProvider(){return this.provider}accessTokenCookieOptions($,T){return{expires:T,secure:this.publicOrigin($).startsWith("https://"),httpOnly:!0,domain:this.cookieDomain($)}}publicOrigin($){let T=K().bound(u0)?K(u0).resolver:null;return T?T.publicOrigin($.rawRequest):new URL($.rawRequest.url).origin}cookieDomain($){let T=this.config.cookieDomain;if(!T)return;let O=T==="root"?K(u0).resolver?.root:O1(T);if(!O)throw Error('`auth.cookieDomain` is "root", but `route.domains` is not configured.');let Z=$.domain?.host??O1(new URL($.rawRequest.url).host);return Z===O||Z?.endsWith(`.${O}`)?O:void 0}async getSession($,T){if(!$||!wz($))return null;let O=await this.userProvider.findSession({token:$,userAgent:T});if(!O?.user)return null;let Z=Date.now(),f=c8(O.expiresAt),j=c8(O.absoluteExpiresAt);if(f<=Z||j<=Z)return await this.userProvider.deleteSession({token:$}),null;let F=await this.slideSession(O,Z);return F.user.extension=await this.config.extendSession(F.user),F}requestCarryingCookie($){let T=A.getStore()?.req;return T?.cookies.get("access_token")===$?T:null}async slideSession($,T){let O=this.config.sessionExpiresInHours*3600000;if(new Date($.expiresAt).getTime()-T>=O/2)return $;let Z=new Date(Math.min(T+O,new Date($.absoluteExpiresAt).getTime())),f=await this.userProvider.updateSession({token:$.token,expiresAt:Z}),j=this.requestCarryingCookie($.token);if(j)j.ctx().setCookie("access_token",$.token,this.accessTokenCookieOptions(j,Z));return f??$}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 T=await this.userProvider.findUserByEmailAddress($,!1);if(!T)throw Error(`User not found with email: ${$}`);let O=await this.createOrUpdateSession({email:$,id:T.id}),Z=new E;if(Z.ctx().setCookie("access_token",O.token,this.accessTokenCookieOptions(Z,O.expiresAt)),O?.user)O.user.extension=await this.config.extendSession(O.user);return O}catch(T){console.log(T)}}async createOrUpdateSessionV2($){let T=await this.createOrUpdateSession($),O=null;if(T?.user)O=await this.config.extendSession(T.user),T.user.extension=O;return T}async createOrUpdateSession($){let T=new E,O=$.id??(await this.userProvider.findUserByEmailAddress($.email,!1))?.id;if(!O)throw new y1;return await this.userProvider.createSessionV2({token:bz(O),userId:O,userAgent:Bun.env.NODE_ENV==="development"?"local":T.headers.get("User-Agent"),...this.freshLifetime(Date.now())})}async createMagicLinkToken($){let T=await this.userProvider.findUserByEmailAddress($,!1);if(T){await this.userProvider.deleteMagicLinkToken($);let O=await this.config.generateMagicLinkToken($),Z=(Number.parseInt($J(4).toString("hex"),16)%1e6).toString().padStart(6,"0");return await this.userProvider.createMagicLinkToken({email:$,token:O,pin:Z}),{user:T,email:$,pin:Z,token:O}}return{}}}import{AsyncLocalStorage as TJ}from"async_hooks";class Oz{config;static token="broadcast";publishCb;context=new TJ;constructor($){this.config=$}get channels(){return this.config.channels}onPublish($){this.publishCb=$}publish(...$){let[T,O,Z]=$;this.publishCb(T,O,Z)}async handleMessage($,T){let O=JSON.parse(T);if(O.type==="subscribe"){let Z=Object.entries(this.channels).sort(([f],[j])=>f.length-j.length);for(let[f,j]of Z){let z=new URLPattern({pathname:f});if(z.test({pathname:O.topic})){let F=z.exec({pathname:O.topic})?.pathname.groups,W=new j;if(await W.subscribe.call(W,F))$.subscribe(O.topic);break}}}if(O.type==="broadcast")$.publish(O.topic,JSON.stringify({topic:O.topic,data:O.payload}));if(O.type==="unsubscribe")$.unsubscribe(O.topic)}run($,T){let O=i8($.get("Cookie"));this.context.run({headers:$,cookies:O},T)}}class GZ extends T0{static getFacadeAccessor(){return Oz}static channel($,T){let O=this.getFacadeRoot(),Z=O.channels[$];if(!Z)return console.error(`Channel ${$} not found`),{publish:()=>{}};let f=new Z;return{publish:(j,z=!1)=>{let F=u($,T);O.publish(F,JSON.stringify({topic:F,data:f.publish(j)}),z)}}}}class O$ extends T0{static getFacadeAccessor(){return w}static async user(){let $=A.getStore(),T=GZ.getFacadeRoot().context.getStore(),O="",Z="";if($?.req)O=$.req.cookies.get("access_token"),Z=$.req.headers.get("User-Agent");if(T?.cookies)Z=T.headers.get("User-Agent"),O=T.cookies.get("access_token");let f=$?.user;if(!f)f=(await this.getFacadeRoot().getSession(O,Z))?.user,$?.setUser(f);if(f)return f;throw new y1({redirectTo:lT($?.req,this.getFacadeRoot().config.signInPath)})}static intendedUrl($){let T=A.getStore()?.req;return $T(T?.search.get(Y$),$??this.getFacadeRoot().config.redirectPath)}static async guard($){let T=await O$.user();if(!await $(T))throw new bZ}static async guardSafe($){let T=await O$.user();try{return await $(T)}catch(O){return!1}}static async authenticate($){return await this.getFacadeRoot().authenticate($)}static async createMagicLink($){return await this.getFacadeRoot().createMagicLinkToken($)}}class BZ{static ensure($,T={}){let O=A.getStore();if(O.req.kind==="api")throw Error("Query.prefetch() cannot be called from an API request");return O.serverQueries??=new l$(vT(O.req.rawRequest)),O.serverQueries.ensure($,T,"prefetch")}static async instant($,...T){let O=BZ.ensure($,T[0]);if(await O.promise,O.status==="rejected")throw O.error;return O.data}static prefetch($,...T){BZ.ensure($,T[0])}static noPrefetch(){let $=A.getStore();if($.req.kind==="api")throw Error("Query.noPrefetch() cannot be called from an API request");$.serverQueries??=new l$(vT($.req.rawRequest)),$.serverQueries.muteDiscoveryHints()}}function h8($,T,O="/"){let Z=new URL($.origin),f=T.host?T.host:T.subdomain?`${T.subdomain}.${$.root}`:$.root,j=new URL(O.startsWith("/")?O:`/${O}`,Z),z=OJ(f);if(!z)throw Error(`"${f}" is not a hostname, so there is no URL for it. Give a bare host, optionally with a port \u2014 no scheme, path or credentials.`);if(j.hostname=z.hostname,z.port)j.port=z.port;return j.toString()}function OJ($){try{let T=new URL(`http://${$.trim()}`);return T.host===$.trim().toLowerCase()&&T.pathname==="/"?{hostname:T.hostname,port:T.port}:null}catch{return null}}class l8{static absolute($,...T){return`${process.env.HOST_NAME}${u(String($),T[0]??{})}`}static relative($,...T){return u(String($),T[0]??{})}static forDomain($,T,...O){let Z=K(u0).resolver;if(!Z)throw Error("`Url.forDomain` needs `route.domains` to be configured.");let f=A.getStore()?.req?.rawRequest,j=f?Z.publicOrigin(f):process.env.HOST_NAME;if(!j)throw Error("`Url.forDomain` outside a request needs `HOST_NAME` for the protocol.");return h8({root:Z.root,origin:j},$,u(String(T),O[0]??{}))}}class d8{name="Meta";static description($){A.getStore().metadata.description($)}static title($){A.getStore().metadata.title($)}static openGraph($){A.getStore().metadata.openGraph($)}}var ZJ={set($,T,O){A.getStore().setCookie($,T,O)},setIfAbsent($,T,O){if(A.getStore().req.cookies.has($))return!1;return A.getStore().setCookie($,T,O),!0},delete($,T){A.getStore().deleteCookie($,T)}};class Zz{config;static token="redis";instance=null;constructor($={}){this.config=$}get client(){return this.instance??=new(fJ())(this.config.url,this.config.options)}set client($){this.instance=$}}function fJ(){let $=globalThis.Bun?.RedisClient;if(typeof $!=="function")throw Error("Redis requires Bun's built-in Redis client, which this runtime does not provide. Run the app under Bun, or bind your own client for the 'redis' token.");return $}class X1 extends T0{static getFacadeAccessor(){return Zz}static get client(){return this.getFacadeRoot().client}static get($){return X1.client.get($)}static set($,T){return X1.client.set($,T)}static del(...$){return X1.client.del(...$)}static exists($){return X1.client.exists($)}static incr($){return X1.client.incr($)}static expire($,T){return X1.client.expire($,T)}static ttl($){return X1.client.ttl($)}}class s8 extends T0{static getFacadeAccessor(){return X$}static consume($,T={}){return this.getFacadeRoot().consume($,T)}}class u8 extends T0{static getFacadeAccessor(){return h$}static enabled($){return this.getFacadeRoot().enabled($)}static all(){return this.getFacadeRoot().forClient()}static explain($){return this.getFacadeRoot().explain($)}static for($){return this.getFacadeRoot().for($)}static list(){return this.getFacadeRoot().list()}static refresh(){return this.getFacadeRoot().refresh()}static invalidate(){return this.getFacadeRoot().invalidate()}}class KZ{bound;constructor($){this.bound=$}get name(){return this.bound??fz()}get sql(){return this.connection().sql}get dialect(){return this.connection().dialect}async query($){return await this.run($,"query")}async execute($){let T=await this.run($,"execute");return Number(T?.count??0)}async transaction($){let T=this.name,O=this.connection(T);return t8(O.sql,(Z)=>a8(T,()=>$(Z)),{slowTransactionThreshold:O.config.slowTransactionThreshold,connection:T})}async schema(){let $=this.connection(),{introspect:T}=await import("./chunk-fqc43fvj.js");return T(this.handle()??$.sql,$.dialect)}run($,T){let O=this.connection(),{text:Z,values:f}=e8($,r8(O.dialect),T);return(this.handle()??O.sql).unsafe(Z,f)}handle(){let $=n8();if($===void 0)return;return fz()===this.name?$:void 0}connection($=this.name){return o8($),K(jz).connection($)}}var o$=new KZ;class $2 extends T0{static getFacadeAccessor(){return jz}static connection($){return new KZ($)}static get sql(){return o$.sql}static get dialect(){return o$.dialect}static query($){return o$.query($)}static execute($){return o$.execute($)}static transaction($){return o$.transaction($)}static schema(){return o$.schema()}static close(){return this.getFacadeRoot().close()}}export{G1 as kc,e$ as lc,IZ as mc,A0 as nc,NZ as oc,Xz as pc,hT as qc,xZ as rc,B1 as sc,v0 as tc,X2 as uc,U2 as vc,iD as wc,vz as xc,mZ as yc,Oz as zc,GZ as Ac,O$ as Bc,i$ as Cc,BZ as Dc,l8 as Ec,HT as Fc,k1 as Gc,d8 as Hc,ZJ as Ic,Zz as Jc,X1 as Kc,X$ as Lc,s8 as Mc,S8 as Nc,hj as Oc,Q8 as Pc,M8 as Qc,_7 as Rc,I8 as Sc,lj as Tc,V8 as Uc,h$ as Vc,u8 as Wc,KZ as Xc,$2 as Yc,Uj as Zc,Gj as _c,VY as $c,yC as ad,qC as bd,wT as cd,pY as dd,cC as ed,pC as fd,yj as gd,pj as hd,d$ as id,dj as jd,oj as kd,l7 as ld,nj as md,u7 as nd,RT as od,_Z as pd,Nz as qd,dT as rd,rj as sd,b8 as td,v8 as ud,UZ as vd,u0 as wd,w as xd,Sz as yd,Qz as zd,Mz as Ad,xz as Bd,_z as Cd,Pz as Dd};
18
+
19
+ //# debugId=EA09CF6157AEB2EE64756E2164756E21