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