gemi 0.86.0 → 0.86.1
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/auth/AuthController.d.ts +5 -0
- package/dist/auth/AuthController.d.ts.map +1 -1
- package/dist/auth/UserProvider.d.ts.map +1 -1
- package/dist/{chunk-ptkt4h2j.js → chunk-6nnq3rjj.js} +2 -2
- package/dist/{chunk-ptkt4h2j.js.map → chunk-6nnq3rjj.js.map} +1 -1
- package/dist/{chunk-eptv0nvv.js → chunk-gs8x0k68.js} +1 -1
- package/dist/{chunk-1wby1sr2.js → chunk-hmh79ezn.js} +1 -1
- package/dist/chunk-tag4fdmj.js +17 -0
- package/dist/{chunk-xx2zg6sk.js.map → chunk-tag4fdmj.js.map} +4 -4
- package/dist/{chunk-2dzqrf0z.js → chunk-z6cgama8.js} +1 -1
- package/dist/facades/index.js +1 -1
- package/dist/http/index.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/kernel/index.js +1 -1
- package/dist/orm/compile/unique.d.ts +16 -0
- package/dist/orm/compile/unique.d.ts.map +1 -1
- package/dist/orm/compile/where.d.ts.map +1 -1
- package/dist/orm/index.js +3 -3
- package/dist/orm/index.js.map +4 -4
- package/dist/server/index.js +1 -1
- package/dist/services/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-xx2zg6sk.js +0 -17
- /package/dist/{chunk-eptv0nvv.js.map → chunk-gs8x0k68.js.map} +0 -0
- /package/dist/{chunk-1wby1sr2.js.map → chunk-hmh79ezn.js.map} +0 -0
- /package/dist/{chunk-2dzqrf0z.js.map → chunk-z6cgama8.js.map} +0 -0
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{wa as I}from"../chunk-8z37k28d.js";import{xa as A}from"../chunk-dadygfkf.js";import{Ag as H,Bg as O,Cg as W,xg as b,zg as V}from"../chunk-gx0x772p.js";import{Gg as k}from"../chunk-cbycz5z3.js";import"../chunk-ndat0nf0.js";import{Ng as $}from"../chunk-9tsw1bmt.js";var X=Symbol.for("gemi.server.devGeneration"),L={graceMs:1e4,providerTimeoutMs:5000};class Q{app;inFlight=0;waiters=new Set;constructor(z){this.app=z}track(z){return async(B,J)=>{this.inFlight++;try{return await z(B,J)}finally{if(this.inFlight--,this.inFlight===0)this.wake()}}}get pending(){return this.inFlight}async retire({graceMs:z,providerTimeoutMs:B}){try{await this.idle(z),await Promise.resolve().then(()=>this.app.shutdown({timeoutMs:B}))}catch(J){Z(J)}}idle(z){if(this.inFlight===0)return Promise.resolve();return new Promise((B)=>{let J=()=>{clearTimeout(K),this.waiters.delete(J),B()},K=setTimeout(J,z);this.waiters.add(J)})}wake(){for(let z of this.waiters)z()}}function Y(z,B=L){let J=globalThis,K=J[X];if(J[X]=z,!K||K===z||typeof K.retire!=="function")return Promise.resolve();let _=K.retire.bind(K);return Promise.resolve().then(()=>_(B)).catch(Z)}function Z(z){console.error("[gemi] Shutting down the application a reload replaced failed:",z)}class P{app;instrumentation;handleSignals;server;stopping;settings;constructor(z){this.app=new A({kernel:z.kernel}),this.handleSignals=z.handleSignals??!0,this.instrumentation=O(z.instrumentation??((B,J)=>J(B)))}async start(){process.env.ROOT_DIR=k();let z=Bun.env.NODE_ENV==="production";if(z){if(this.handleSignals)W(()=>this.stop());this.settings=V()}try{await this.app.waitForBoot()}catch(B){if(!z)this.app.shutdown({timeoutMs:L.providerTimeoutMs});throw B}if(z){let{httpProd:B}=await import("../chunk-
|
|
2
|
+
import{wa as I}from"../chunk-8z37k28d.js";import{xa as A}from"../chunk-dadygfkf.js";import{Ag as H,Bg as O,Cg as W,xg as b,zg as V}from"../chunk-gx0x772p.js";import{Gg as k}from"../chunk-cbycz5z3.js";import"../chunk-ndat0nf0.js";import{Ng as $}from"../chunk-9tsw1bmt.js";var X=Symbol.for("gemi.server.devGeneration"),L={graceMs:1e4,providerTimeoutMs:5000};class Q{app;inFlight=0;waiters=new Set;constructor(z){this.app=z}track(z){return async(B,J)=>{this.inFlight++;try{return await z(B,J)}finally{if(this.inFlight--,this.inFlight===0)this.wake()}}}get pending(){return this.inFlight}async retire({graceMs:z,providerTimeoutMs:B}){try{await this.idle(z),await Promise.resolve().then(()=>this.app.shutdown({timeoutMs:B}))}catch(J){Z(J)}}idle(z){if(this.inFlight===0)return Promise.resolve();return new Promise((B)=>{let J=()=>{clearTimeout(K),this.waiters.delete(J),B()},K=setTimeout(J,z);this.waiters.add(J)})}wake(){for(let z of this.waiters)z()}}function Y(z,B=L){let J=globalThis,K=J[X];if(J[X]=z,!K||K===z||typeof K.retire!=="function")return Promise.resolve();let _=K.retire.bind(K);return Promise.resolve().then(()=>_(B)).catch(Z)}function Z(z){console.error("[gemi] Shutting down the application a reload replaced failed:",z)}class P{app;instrumentation;handleSignals;server;stopping;settings;constructor(z){this.app=new A({kernel:z.kernel}),this.handleSignals=z.handleSignals??!0,this.instrumentation=O(z.instrumentation??((B,J)=>J(B)))}async start(){process.env.ROOT_DIR=k();let z=Bun.env.NODE_ENV==="production";if(z){if(this.handleSignals)W(()=>this.stop());this.settings=V()}try{await this.app.waitForBoot()}catch(B){if(!z)this.app.shutdown({timeoutMs:L.providerTimeoutMs});throw B}if(z){let{httpProd:B}=await import("../chunk-gs8x0k68.js");this.server=await B(this.app,this.instrumentation.bind(this))}else{I();let{httpDev:B}=await import("../chunk-z6cgama8.js"),J=new Q(this.app);this.server=await B(this.app,J.track(this.instrumentation.bind(this))),Y(J)}return this.server}stop(z={}){return this.stopping??=H({server:this.server,shutdownProviders:(B)=>this.app.shutdown(B),settings:{...this.settings??V(),...z}}),this.stopping}}export{b as isShuttingDown,P as Server};
|
|
3
3
|
|
|
4
4
|
//# debugId=1F7A55197DAF148D64756E2164756E21
|
package/dist/services/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ya as gW}from"../chunk-zytmxty5.js";import{Ab as AW,Bb as yW,Cb as VW,Za as u6,_a as BW,ab as xW,bb as NW,cb as LW,db as DW,eb as FW,fb as OW,gb as HW,hb as U,ib as UW,jb as SW,kb as fW,lb as RW,mb as kW,nb as _W,ob as CW,pb as vW,qb as s4,rb as a4,sb as g1,tb as bW,ub as IW,vb as TW,wb as qW,xb as hW,yb as PW,zb as wW}from"../chunk-
|
|
2
|
+
import{Ya as gW}from"../chunk-zytmxty5.js";import{Ab as AW,Bb as yW,Cb as VW,Za as u6,_a as BW,ab as xW,bb as NW,cb as LW,db as DW,eb as FW,fb as OW,gb as HW,hb as U,ib as UW,jb as SW,kb as fW,lb as RW,mb as kW,nb as _W,ob as CW,pb as vW,qb as s4,rb as a4,sb as g1,tb as bW,ub as IW,vb as TW,wb as qW,xb as hW,yb as PW,zb as wW}from"../chunk-hmh79ezn.js";import"../chunk-w312e9nx.js";import{Kb as o6,Lb as s6,Mb as a6,Nb as t6,Ob as r6,Pb as e6,Qb as WW,Rb as YW,Sb as JW,Tb as ZW,Ub as GW,Vb as $W,Wb as QW,Xb as KW,Yb as XW,Zb as zW}from"../chunk-1yq1e6sb.js";import{$b as p6,_b as d6,ac as l6,bc as n6,cc as i6}from"../chunk-saqfc6vp.js";import{hc as MW,ic as jW}from"../chunk-p0m3qgs5.js";import"../chunk-z4k18gnp.js";import{Ac as G6,Ad as y6,Bc as $6,Lc as x6,Nc as M6,Oc as j6,Pc as N6,Qc as L6,Rc as D6,Sc as F6,Tc as O6,Uc as d4,Vc as H6,Wc as U6,Xc as S6,Yc as f6,Zc as R6,bd as k6,cd as _6,dd as C6,ed as v6,fd as b6,gd as I6,hd as T6,id as q6,jd as h6,kd as P6,qc as b0,rd as w6,vc as e0,wc as W6,xc as Y6,yc as J6,yd as A6,zc as Z6}from"../chunk-tag4fdmj.js";import"../chunk-ha705bcz.js";import"../chunk-k5j65f2c.js";import{Pe as V1,Qe as A1,Re as Y1,bf as g,cf as w,gf as J1,hf as L1,if as Q6,jf as K6,kf as X6,lf as z6,nf as B6,pf as D1}from"../chunk-174jkg6d.js";import"../chunk-jhe0t7yj.js";import"../chunk-1jcp8m8h.js";import"../chunk-trdwxm5x.js";import"../chunk-1w5a11cd.js";import"../chunk-4ysar3ev.js";import"../chunk-dwqh79e5.js";import{kg as V6,lg as g6,mg as c6,ng as E6,og as m6}from"../chunk-pmmrhak1.js";import"../chunk-7n5775qx.js";import{tg as c}from"../chunk-d3jkypc7.js";import"../chunk-8gexb1gt.js";import"../chunk-swhyp0yw.js";import"../chunk-gx0x772p.js";import"../chunk-cbycz5z3.js";import"../chunk-ndat0nf0.js";import{Ng as l4}from"../chunk-9tsw1bmt.js";import{Buffer as p4}from"buffer";class n4 extends J1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-2yw23zhn.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Y}={}){Y?.throwIfAborted();let J,Z,G,$=process.env.BUCKET_NAME;if(W instanceof Blob)J=W,G=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Z=W.type;else J=W.body,G=W.name,$=W.bucket??$,Z=W.contentType||(J instanceof Blob||J instanceof File?J.type:void 0);Z=Z||void 0;let Q=J instanceof p4?J:J instanceof Blob||J instanceof File?p4.from(await J.arrayBuffer()):"",{sdk:K,client:z}=await this.connect();return Y?.throwIfAborted(),await z.send(new K.PutObjectCommand({Bucket:$,Key:G,Body:Q,ContentType:Z}),{abortSignal:Y}),G}async delete(W){let Y=typeof W==="string"?W:W.name,J=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Y)throw Error("Object name has to be specified");let{sdk:Z,client:G}=await this.connect();try{await G.send(new Z.DeleteObjectCommand({Bucket:J,Key:Y}))}catch($){if($?.name==="NoSuchKey"||$?.$metadata?.httpStatusCode===404)return;throw $}}async list(W){let{sdk:Y,client:J}=await this.connect();return await J.send(new Y.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Y}={}){Y?.throwIfAborted();let J=process.env.BUCKET_NAME,Z;if(typeof W==="string")Z=W;else J=W.bucket??J,Z=W.name;if(!Z)throw Error("Object name has to be specified");let{sdk:G,client:$}=await this.connect();Y?.throwIfAborted();let Q=await $.send(new G.GetObjectCommand({Bucket:J,Key:Z}),{abortSignal:Y}),K=L1(Q.Body.transformToWebStream(),Y);return Y?.throwIfAborted(),new Response(K,{headers:{"Content-Type":Q.ContentType,"Content-Length":Q.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":Q.LastModified?.toUTCString()||"",ETag:Q.ETag||""}})}async read(W){let Y=typeof W==="string"?{name:W}:W,J=Y.bucket??process.env.BUCKET_NAME,{name:Z,range:G=null}=Y;if(!Z)throw Error("Object name has to be specified");let{sdk:$,client:Q}=await this.connect(),K;try{K=await Q.send(new $.GetObjectCommand({Bucket:J,Key:Z,Range:G?A1(G):void 0}))}catch(M){if(M?.name==="InvalidRange"||M?.$metadata?.httpStatusCode===416)throw new g(await this.size({name:Z,bucket:J}));if(M?.name==="NoSuchKey"||M?.$metadata?.httpStatusCode===404)throw new w(Z);throw M}let z=Y1(K.ContentRange),X=Boolean(z)&&K.$metadata?.httpStatusCode===206,x=z?.total??K.ContentLength??0;return{body:K.Body.transformToWebStream(),start:z?.start??0,end:z?.end??x-1,total:x,partial:X,type:K.ContentType??"application/octet-stream",etag:K.ETag||void 0,lastModified:K.LastModified,name:Z}}async size(W){let Y=typeof W==="string"?W:W.name,J=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:Z,client:G}=await this.connect();try{return(await G.send(new Z.HeadObjectCommand({Bucket:J,Key:Y}))).ContentLength??0}catch($){if($?.name==="NotFound"||$?.$metadata?.httpStatusCode===404)throw new w(Y);throw $}}}import{Buffer as i4}from"buffer";import{Readable as q0}from"stream";function y1(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function h0(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class o4 extends J1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Y=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Y)return W.BlobServiceClient.fromConnectionString(Y);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Y){if(!W)throw Error("Object name has to be specified");let J=Y??this.config.container??process.env.BUCKET_NAME;if(!J)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient(J).getBlockBlobClient(W)}async put(W,{signal:Y}={}){Y?.throwIfAborted();let J,Z,G,$;if(W instanceof Blob)J=W,G=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,Z=W.type;else J=W.body,G=W.name,$=W.bucket,Z=W.contentType??(J instanceof Blob||J instanceof File?J.type:void 0);let Q=J instanceof i4?J:i4.from(await J.arrayBuffer()),K=await this.blob(G,$);return Y?.throwIfAborted(),await K.uploadData(Q,{blobHTTPHeaders:Z?{blobContentType:Z}:void 0,abortSignal:Y}),G}async list(W){let Y=this.config.container??process.env.BUCKET_NAME,Z=(await this.serviceClient()).getContainerClient(Y),G=[];for await(let $ of Z.listBlobsFlat({prefix:W}))G.push($.name);return G}async fetch(W,{signal:Y}={}){Y?.throwIfAborted();let J=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Y);return new Response(J.body,{headers:{"Content-Type":J.type,"Content-Length":String(J.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":J.lastModified?.toUTCString()??"",ETag:J.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Y){let{name:J,bucket:Z,range:G=null}=W,$=await this.blob(J,Z);Y?.throwIfAborted();let Q,K,z=G?.kind==="suffix"||G?.kind==="offset"&&G.end===null&&G.start===0;if(G&&z){let b=await this.size({name:J,bucket:Z}),W1=V1(G,b);if(!W1)throw new g(b);Q=W1.start,K=W1.length}else if(G?.kind==="offset")Q=G.start,K=G.end===null?void 0:G.end-G.start+1;let X;try{X=await $.download(Q,K,Y?{abortSignal:Y}:void 0)}catch(b){if(h0(b))throw new g(await this.size({name:J,bucket:Z}));if(y1(b))throw new w(J);throw b}let x=Y1(X.contentRange),M=Boolean(x),R=x?.total??X.contentLength??0,v=await P0(X);if(v instanceof ReadableStream)v=L1(v,Y);return Y?.throwIfAborted(),{body:v,start:x?.start??0,end:x?.end??R-1,total:R,partial:M,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:J}}async size(W){let Y=typeof W==="string"?W:W.name,J=typeof W==="string"?void 0:W.bucket,Z=await this.blob(Y,J);try{return(await Z.getProperties()).contentLength??0}catch(G){if(y1(G))throw new w(Y);throw G}}async delete(W){let Y=typeof W==="string"?W:W.name,J=typeof W==="string"?void 0:W.bucket,Z=await this.blob(Y,J);try{await Z.delete()}catch(G){if(y1(G))return;throw G}}}async function P0(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return q0.toWeb(W.readableStreamBody);return null}var w0=`
|
|
3
3
|
local currentKey = KEYS[1]
|
|
4
4
|
local previousKey = KEYS[2]
|
|
5
5
|
local limit = tonumber(ARGV[1])
|
package/package.json
CHANGED
package/dist/chunk-xx2zg6sk.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Jd as s4,Qd as K5}from"./chunk-ha705bcz.js";import{He as B5,Xd as r$,ae as cO}from"./chunk-k5j65f2c.js";import{$e as p3,Ie as y3,Me as oW,Ne as R4,Oe as w3,Pe as A3,Se as E3,Te as P3,Ue as a$,Ve as cW,We as Z5,Xe as B4,Ye as k0,_e as _,af as c3,bf as b3,df as y1,ef as w0,ff as F3,nf as $W,of as W$,pf as C5}from"./chunk-174jkg6d.js";import{rf as pO,sf as m1,tf as K1,uf as m4}from"./chunk-jhe0t7yj.js";import{vf as wW,wf as f4,xf as x}from"./chunk-1jcp8m8h.js";import{Af as zO,Bf as F5,Cf as U5,Lf as G5,yf as rW,zf as fO}from"./chunk-trdwxm5x.js";import{_f as WO}from"./chunk-1w5a11cd.js";import{dg as uW,ig as sW}from"./chunk-4ysar3ev.js";import{jg as z5}from"./chunk-dwqh79e5.js";import{pg as dW,qg as s}from"./chunk-7n5775qx.js";import{tg as K}from"./chunk-d3jkypc7.js";import{ug as n$}from"./chunk-8gexb1gt.js";import{Ig as tW}from"./chunk-ndat0nf0.js";import{Ng as W4}from"./chunk-9tsw1bmt.js";import{randomBytes as AC}from"crypto";function sO($){return typeof $==="function"&&$.prototype!==void 0}function j1($){return typeof $==="string"?[$]:$}function nO($,O){let Z=O?"attachment":"inline",T=$.replace(/["\\]/g,"").replace(/[^\x20-\x7e]/g,"_");return`${Z}; filename="${T}"; filename*=UTF-8''${encodeURIComponent($)}`}function E5($){return"total"in $&&"partial"in $&&"body"in $}function OO($){return new Response(null,{status:416,headers:{"Accept-Ranges":"bytes","Content-Range":P3($),"Content-Length":"0","Cache-Control":"no-store"}})}async function P5($){if($ instanceof Blob)return{body:$,start:0,end:$.size-1,total:$.size,partial:!1,type:$.type,name:$.name,download:!1,status:200,extraHeaders:{}};if(E5($))return{body:$.body,start:$.start,end:$.end,total:$.total,partial:$.partial,type:$.type,name:$.name,download:!1,etag:$.etag,lastModified:$.lastModified,status:200,extraHeaders:{}};let O=$.file,Z=O instanceof Blob?O:null,T=$.total??Z?.size??-1;return{body:O,start:$.start??0,end:$.end??T-1,total:T,partial:$.partial??!1,type:$.type??Z?.type??"",name:$.name??O?.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}}}async function H3($,O){if($ instanceof Response)return $;if(!$)return new Response("Not found",{status:404});let Z=await P5($),{body:T,start:j,end:f,total:z,partial:W}=Z;if(T instanceof Blob&&"exists"in T&&typeof T.exists==="function"){if(!await T.exists())return new Response("Not found",{status:404})}let{range:J}=O;if(J){if(z<=0)return OO(Math.max(z,0));if(!W){if(T instanceof Blob){let X=A3(J,z);if(!X)return OO(z);T=T.slice(X.start,X.end+1),j=X.start,f=X.end,W=!0}}}let Y=Boolean(J)&&W,C=Y?206:Z.status,D=new Headers;if(D.set("Accept-Ranges","bytes"),D.set("Content-Type",Z.type||"application/octet-stream"),Y)D.set("Content-Range",E3(j,f,z)),D.set("Content-Length",String(f-j+1));else if(z>=0)D.set("Content-Length",String(z));if(Z.name)D.set("Content-Disposition",nO(Z.name,Z.download));if(Z.etag)D.set("ETag",Z.etag);if(Z.lastModified)D.set("Last-Modified",Z.lastModified.toUTCString());for(let[X,U]of Object.entries(Z.extraHeaders))D.set(X,U);if((O.method??"GET").toUpperCase()==="HEAD"){if(T&&"cancel"in T&&typeof T.cancel==="function")await T.cancel();return new Response(null,{status:C,headers:D})}return new Response(T,{status:C,headers:D})}function G4($){return sO($)}class u{method;handler;methodName;__internal_brand="RouteHandler";middlewares=[];constructor($,O,Z){this.method=$;this.handler=O;this.methodName=Z;this.handler=O,this.methodName=Z,this.method=$}get source(){if(!G4(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(G4(this.handler)){let O=new this.handler;return O[this.methodName].bind(O)()}return this.handler()}middleware($){return this.middlewares=j1($),this}}class K4{url;headers;__internal_brand="ProxyHandler";middlewares=[];constructor($,O){this.url=$;this.headers=O}middleware($){return this.middlewares=j1($),this}run(){let $=new _,O=$.headers.toJSON();for(let Z of B4($.rawRequest))delete O[Z];return fetch(this.url,{method:$.rawRequest.method,headers:{...O,...this.headers},body:$.rawRequest.body})}}class Q4{constructor(...$){return new u(...$)}}class V4 extends u{__internal_brand="StreamHandler";async run($){let O=x.getStore(),Z=O?.req?.rawRequest,T=w3(Z?.headers.get("Range"));if(O)O.rangeRequest=T;try{let j=await super.run($);return await H3(j,{range:T,method:Z?.method})}catch(j){if(j instanceof b3)return OO(j.total);throw j}finally{if(O)O.rangeRequest=null}}}class I4{constructor(...$){return new V4(...$)}}class L4{__internal_brand="ResourceRoutes";first;second;constructor($){this.first={get:new u("GET",$,"list"),post:new u("POST",$,"store")},this.second={get:new u("GET",$,"show"),put:new u("PUT",$,"update"),delete:new u("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 S0{static __brand="ApiRouter";routes={};middlewares=[];middleware($){}get($,O){return new u("GET",$,O)}post($,O){return new u("POST",$,O)}put($,O){return new u("PUT",$,O)}patch($,O){return new u("PATCH",$,O)}delete($,O){return new u("DELETE",$,O)}resource($){return new L4($)}agent($){return H5($,this)}file($,O){return new Q4("GET",$,O)}stream($,O){return new I4("GET",$,O)}proxy($,O={}){return new K4($,O)}}function H5($,O){let Z={stream:new u("POST",$,"stream"),attach:new u("POST",$,"attach"),stop:new u("POST",$,"stop"),upload:new u("POST",$,"upload")};return class extends S0{static __internal_brand="AgentRoute";static controller=$;static handlers=Z;constructor(){super();this.middlewares=[...O?.middlewares??[]]}routes={"/":Z.stream,"/attach":Z.attach,"/stop":Z.stop,"/files":Z.upload};static middleware(j){if(j.stream)Z.stream.middleware(j.stream);if(j.attach)Z.attach.middleware(j.attach);if(j.stop)Z.stop.middleware(j.stop);if(j.upload)Z.upload.middleware(j.upload);return this}}}class v3{method;url;meta;__internal_brand="McpRoute";constructor($,O,Z){this.method=$;this.url=O;this.meta=Z}}class M4{static __brand="McpRouter";routes={};fromApiRoute($,O,Z){return new v3($,O,Z)}}function T0($,O){return $.replace(/:([^/]+[*?]?)/g,(Z,T)=>{let j=T.endsWith("?")||T.endsWith("*"),f=j?T.slice(0,-1):T,z=O[f];if(z===void 0){if(j)return"";if(import.meta.env.DEV)throw Error(`Missing parameter: ${f}`);console.error(`Missing parameter: ${f} in URL: ${$}`)}return String(z)}).replace(/\/\//g,"/").replace(/\/$/,"")}class g3 extends m1{constructor($,O=307){super("Redirect error");this.name="RedirectError",this.payload={api:{status:200,data:{},directive:{kind:"Redirect",path:$}},view:{status:O,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:$}}}}}class aO{static to($,...O){let[Z={}]=O,{search:T={},params:j={},permanent:f,status:z}={params:{},status:307,permanent:!1,...Z},W=new URLSearchParams(T).toString();throw new g3([T0($,j)||"/",W.toString()].filter(Boolean).join("?"),z??(f?301:307))}static external($,O=307){throw new g3($,O)}}var S4=Symbol.for("gemi.HttpResponse");class ZO{kind;body;status;headers;[S4]=!0;constructor($,O,Z,T){this.kind=$;this.body=O;this.status=Z;this.headers=T}static json($,O={}){let Z=O.status??200;return w5(Z),new ZO("json",$,Z,new Headers(O.headers))}get ok(){return this.status>=200&&this.status<300}toResponse($,O){let Z=$,T=this.serialize(Z);for(let j of O)Z.append("Set-Cookie",j);this.headers.forEach((j,f)=>{if(f.toLowerCase()!=="set-cookie")Z.set(f,j)});for(let j of this.headers.getSetCookie())Z.append("Set-Cookie",j);if(this.status>=400&&!this.headers.has("Cache-Control"))Z.set("Cache-Control","no-store");return new Response(T,{status:this.status,headers:Z})}serialize($){switch(this.kind){case"json":return $.set("Content-Type","application/json"),JSON.stringify(this.body)??null}}}function w5($){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&&$[S4]===!0}class x4{kind="redirect";viewPath="REDIRECT";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>({});else if(typeof $==="function")this.handler=$;else{let[O,Z]=$;this.handler=(T)=>{return new O()[Z](T)}}}async run($,O){let{destination:Z,permanent:T=!1,status:j=307}=await this.handler($);if(!Z)throw Error(`Redirect destination is required see ${O}`);return aO.to(Z,{permanent:T,status:j}),{}}middleware($){return this.middlewares=j1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}async function R3($,O){if($ instanceof Response)return $;let Z=$ instanceof Blob,T=Z?$:$.file,j=Z?$.name:$.name??$.file?.name,f=(Z?$.type:$.type??$.file?.type)||"",z=Z?!1:$.download??!1,W=Z?200:$.status??200;if(!Z)for(let[J,Y]of Object.entries($.headers??{}))O.set(J,Y);if(T instanceof Blob&&"exists"in T&&typeof T.exists==="function"){if(!await T.exists())return new Response("Not found",{status:404})}if(O.set("Content-Type",f||"application/octet-stream"),T instanceof Blob)O.set("Content-Length",String(T.size));if(j)O.set("Content-Disposition",nO(j,z));return new Response(T instanceof Blob?T.stream():T,{status:W,headers:O})}class N4{kind="file";viewPath="FILE";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>null;else if(typeof $==="function")this.handler=$;else{let[O,Z]=$;this.handler=(T)=>{return new O()[Z](T)}}}async run($,O){let Z=await this.handler($);if(!Z)throw Error(`File route handler must return a file see ${O}`);return{FILE:Z}}middleware($){return this.middlewares=j1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}function _4($,O){if(F$($))throw Error(`The handler of view "${O}" returned an HttpResponse. HttpResponse is for api routes; a view handler returns its props.`);return $}class A4{viewPath;middlewares=[];featureGates=[];handler;constructor($,O){this.viewPath=$;if(!O)this.handler=()=>({});else if(typeof O==="function")this.handler=O;else{let[Z,T]=O;this.handler=(j)=>{return new Z()[T](j)}}}async run($,O){let Z=_4(await this.handler($),this.viewPath);return{[this.viewPath]:{...Z,breadcrumb:{label:Z?.breadcrumb??"",href:O}}}}middleware($){return this.middlewares=j1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class E4{viewPath;children;middlewares=[];featureGates=[];alwaysRuns=!1;handler=()=>({});constructor($,O,Z){this.viewPath=$;if(typeof O==="function")this.handler=O,this.children=class extends B1{routes=Z??{}};else if(Array.isArray(O)){let[T,j]=O;this.handler=(f)=>{return new T()[j](f)},this.children=class extends B1{routes=Z??{}}}else this.children=class extends B1{routes=O},this.handler=()=>({})}async run($,O){let Z=_4(await this.handler($),this.viewPath);return{[this.viewPath]:{...Z,breadcrumb:{label:Z?.breadcrumb??"",href:O}}}}alwaysRun(){return this.alwaysRuns=!0,this}middleware($){return this.middlewares=j1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class B1{middlewares=[];featureGates=[];routes={};view($,O){return new A4($,O)}file($){return new N4($)}redirect($){return new x4($)}layout($,O,Z){return new E4($,O,Z)}}class b0{req;config={};constructor($){this.req=$}run(...$){return{}}static configure($){let O=this;return class extends O{config=$}}}function b5($){return $}function v5(){return{aliases:{},global:[]}}var U$="redirect";function TO($,O="/"){if(typeof $!=="string"||!$.startsWith("/"))return O;if(/[\u0000-\u001f\u007f\\]/.test($)||$.startsWith("//"))return O;try{let Z=new URL($,"http://gemi.invalid");if(Z.origin!=="http://gemi.invalid")return O;let T=`${Z.search}${Z.hash}`.replaceAll("/","%2F"),j=`${Z.pathname}${T}`.replaceAll(":","%3A");return j.startsWith("//")?O:j}catch{return O}}function P4($){let O=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();return O?O==="https":new URL($.url).protocol==="https:"}function g5($,O=!0){let Z=new URL($.rawRequest.url),T=Z.pathname.replace(/\.(json|og)$/,""),[,j,...f]=T.split("/");if(K(s).supportedLocales.includes(j))T=`/${f.join("/")}`;return O?`${T}${Z.search}`:T}function R5($,O){let Z=(T)=>T.replace(/\/+$/,"")||"/";return Z($)===Z(O)}function oO($,O){let Z=O||K(w).config.signInPath,T=/^[a-z][a-z\d+.-]*:/i.test(Z);if(T?!/^https?:\/\//i.test(Z):!Z.startsWith("/"))throw Error(`\`auth.signInPath\` must be a path like "/auth/sign-in", or an http(s) URL for sign-in hosted elsewhere. Got "${Z}". A route's own \`"auth:<path>"\` cannot carry a URL, because the alias parser splits it on the colon.`);let j=new URL(Z,"http://gemi.invalid");if($?.kind==="view"){let f=g5($,!T);if(T||!R5(new URL(f,j).pathname,j.pathname))j.searchParams.set(U$,f)}return T?j.href:`${j.pathname}${j.search}`}var jO="access_token";function k3($){return $?.cookies?.get("access_token")||$?.headers?.get("access_token")||null}async function rO($,O){let Z=k3(O);if(!Z)return null;return(await $.getSession(Z,O.headers.get("User-Agent")))?.user??null}class H4 extends b0{async run($){let O=x.getStore(),Z=O.req;if(O.user)return{};let T=await rO(K(w),Z);if(!T)throw new y1({redirectTo:oO(Z,$)});return O.setUser(T),{}}}class w4 extends b0{async run(...$){let[O="public",Z="864000",...T]=$,j=`${O}, max-age=${Z}${T.length>0?", ":""}${T.join(", ")}`;if($.length===0)j="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="public")j="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="private")j="private, max-age=0, stale-while-revalidate=300, stale-if-error=600";if(this.req.rawRequest.method==="GET")this.req.ctx().setHeaders("Cache-Control",j);return{}}}var k5={"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 b4 extends b0{config={origins:{"":{"Access-Control-Allow-Methods":"GET, HEAD, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Authorization, X-Requested-With","Access-Control-Allow-Credentials":"true"}}};run(){let $=this.req,O=$.rawRequest.headers.get("Origin");if(this.config.origins[O]){$.ctx().setHeaders("Access-Control-Allow-Origin",O);let Z={...k5,...this.config.origins[O]};for(let[T,j]of Object.entries(Z))$.ctx().setHeaders(T,j)}return{}}}class G${config;static token="ratelimiter";constructor($){this.config=$}get driver(){return this.config.driver}async consume($,O={}){let Z=O.limit??this.config.limit,T=O.window??this.config.window,j=O.cost??1;if(v4("window",T),v4("limit",Z),!Number.isFinite(j)||j<0)throw Error(`Rate limiter cost must be zero or greater, got ${j}`);return await this.config.driver.consume({key:$,limit:Z,window:T*1000,cost:j})}}function v4($,O){if(!Number.isFinite(O)||O<=0)throw Error(`Rate limiter ${$} must be greater than zero, got ${O}`)}class q3 extends m1{constructor($){super("Rate limit exceeded");let O={"Content-Type":"application/json",...$?q4($):{}};this.payload={api:{status:429,data:{error:K1("rate_limit","Rate limit exceeded",429)},headers:O},view:{error:{message:"Rate limit exceeded"},status:429,headers:O}}}}class k4 extends b0{async run($,O){let Z=q5();if(!Z)return{};let T=await Z.consume(this.key(),{limit:g4($)??this.config.limit,window:g4(O)??this.config.window});if(this.config.headers!==!1){let j=this.req.ctx?.();if(j)for(let[f,z]of Object.entries(q4(T)))j.setHeaders(f,z)}if(!T.allowed)throw new q3(T);return{}}key(){if(this.config.key)return this.config.key(this.req);return`${tO(this.req)}:${this.req.routePath??"*"}`}}function q5(){try{let $=K();return $.bound(G$)?$.make(G$):null}catch{return null}}function tO($){let O=R4($.rawRequest);if(O!==void 0)return O;let Z=$.headers.get("x-forwarded-for");if(Z){let[T]=Z.split(",");if(T?.trim())return T.trim()}return $.headers.get("x-real-ip")?.trim()||"unknown"}function q4($){let O={"X-RateLimit-Limit":String($.limit),"X-RateLimit-Remaining":String($.remaining),"X-RateLimit-Reset":String(Math.ceil($.resetAt/1000))};if(!$.allowed)O["Retry-After"]=String(Math.max(1,Math.ceil($.retryAfter/1000)));return O}function g4($){if($===void 0||$===null||$==="")return;let O=Number($);if(!Number.isFinite(O)||O<=0)return;return O}class y4 extends b0{async run(){let $=this.req.cookies.get("csrf_token");if(!$)throw new m3;if(!["POST","PUT","PATCH","DELETE"].includes(this.req.rawRequest.method))return{};if(!Bun.CSRF.verify($,{secret:process.env.SECRET}))throw new m3;return{}}}class m3 extends m1{constructor(){super("Invalid CSRF token");this.name="InvalidCSRFTokenError"}payload={api:{status:403,data:{error:m4("csrf","Invalid CSRF token",403)}},view:{}}}class p4{policiesList={};constructor(){let $=this.register();for(let O of $){let Z=new O;this.policiesList[O.name]=Z}}register(){return[]}}class c4{all($,O){return!0}}import{createHmac as i4,randomBytes as m5}from"crypto";var i3="v2.";function h3($){return $.startsWith(i3)}function h4(){let $=process.env.SECRET;if(!$)throw Error("Signing in needs a secret to mint session tokens with. Set SECRET in the environment.");return $}function l4($){let O=m5(16).toString("hex"),Z=i4("sha256",h4()).update(`${$}:${O}`).digest("hex");return`${i3}${Z}`}function eO($,O){let Z=i4("sha256",h4()).update(`legacy-session:${O}:${$}`).digest("hex");return`${i3}${Z}`}import{randomBytes as d3}from"crypto";class l3 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"}}}async function y5($,O){if(typeof O!=="string"||O==="")return!1;try{return await Bun.password.verify($,O)}catch{return!1}}function L9($){return $}function d4($={}){return{basePath:"/auth",verifyEmail:!0,redirectPath:"/dashboard",signInPath:"/auth/sign-in",sessionExpiresInHours:24,sessionAbsoluteExpiresInHours:672,cookieDomain:null,migrateLegacySession:null,signUpRequest:l3,oauthProviders:{},verifyPassword:y5,hashPassword:async(O)=>await Bun.password.hash(O),generateForgotPasswordToken:async()=>d3(32).toString("hex"),generateEmailVerificationToken:()=>{if(!($.verifyEmail??!0))return"";return d3(32).toString("hex")},generateMagicLinkToken:()=>d3(32).toString("hex"),extendSession:()=>({}),onUserCreated:async()=>{},onSignUp:()=>{},onSignIn:()=>{},onSignOut:()=>{},onForgotPassword:()=>{},onResetPassword:()=>{},onMagicLinkCreated:()=>{}}}function u3($){if($&&typeof $==="object")delete $.password;return $}function p5(){return new Proxy({},{get:($,O)=>s4(O)})}var u4=new WeakMap;function n4($){if($&&typeof $==="object"){for(let O of Object.values($))n4(O);Object.freeze($)}return $}var c5={select:{id:!0,publicId:!0,email:!0,name:!0,locale:!0,globalRole:!0,accounts:{select:{id:!0,publicId:!0,organizationRole:!0,organization:!0}}}},i5=n4({token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:c5});class s3{models;constructor($=p5()){this.models=$}run($){return this.models.User.asSystem($)}sessionSelect(){return i5}transaction($){return this.models.User.transaction($)}withLegacySessionLock($,O){let Z=this.models.User.$connection??zO(),T=K(WO).connection(Z),j=()=>this.transaction(async()=>{if(T.dialect==="postgres"){let W=`gemi:legacy-session:${$}`;await fO()`SELECT pg_advisory_xact_lock(hashtextextended(${W}, 0))`}return O()});if(T.dialect!=="sqlite"||fO())return j();let z=(u4.get(T)??Promise.resolve()).then(j,j);return u4.set(T,z.catch(()=>{})),z}async createUser($){let O=await this.run(()=>this.models.User.create({data:$}));return u3(O)}async updateUserPassword($){let O=await this.run(()=>this.models.User.update({where:{id:$.id},data:{password:$.password}}));return u3(O)}async findUserByEmailAddress($,O){return await this.run(()=>this.models.User.findUnique({where:O?{email:$,emailVerifiedAt:{not:null}}:{email:$}}))}async findUserByVerificationToken($){return await this.run(()=>this.models.User.findFirst({where:{verificationToken:$}}))}async verifyUser($){return await this.run(()=>this.models.User.update({where:{email:$},data:{emailVerifiedAt:new Date}}))}async createSession($){return await this.run(()=>this.models.Session.create({data:$,include:{user:!0}}))}async createSessionV2($){return await this.run(()=>this.models.Session.create({data:$,select:this.sessionSelect()}))}async findSession($){if(!$.token)return null;try{return await this.run(()=>this.models.Session.findUnique({where:{token:$.token},select:this.sessionSelect()}))}catch(O){return console.error("findSession failed:",O),null}}async updateSession($){return await this.run(()=>this.models.Session.update({where:{token:$.token},data:{expiresAt:$.expiresAt},select:this.sessionSelect()}))}async deleteSession($){if(!$.token)return;await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}))}async claimLegacySession($){if(!$.token)return!1;let{count:O}=await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}));return O>0}async deleteAllUserSessions($){await this.run(()=>this.models.Session.deleteMany({where:{userId:$}}))}async createPasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.create({data:{token:$.token,user:{connect:{id:$.user.id}}}}))}async findPasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.findUnique({where:{token:$.token},include:{user:!0}}))}async deletePasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.delete({where:{token:$.token}}))}async findInvitation($,O){return await this.run(()=>this.models.OrganizationInvitation.findFirst({where:{publicId:$,email:O}}))}async deleteInvitationById($){await this.run(()=>this.models.OrganizationInvitation.delete({where:{publicId:$}}))}async createAccount($){return await this.run(()=>this.models.Account.create({data:{userId:$.userId,organizationId:$.organizationId,organizationRole:$.organizationRole}}))}async createMagicLinkToken($){return await this.run(()=>this.models.MagicLinkToken.create({data:{email:$.email,token:$.token,pin:$.pin}}))}async findUserMagicLinkToken($){return await this.run(()=>$.token?this.models.MagicLinkToken.findUnique({where:{token_email:{token:$.token,email:$.email}}}):this.models.MagicLinkToken.findUnique({where:{pin_email:{pin:$.pin,email:$.email}}}))}async deleteMagicLinkToken($){await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{email:$}}))}async createSocialAccount($){return await this.run(()=>this.models.SocialAccount.create({data:$}))}async findUserBySocialAccount($,O){if(!O)return null;let Z=await this.run(()=>this.models.SocialAccount.findFirst({where:{provider:$,providerId:O},include:{user:!0}}));return Z?u3(Z.user):null}async findSocialAccounts($,O){return await this.run(()=>this.models.SocialAccount.findMany({where:{userId:$,provider:O},orderBy:{id:"asc"}}))}async claimSocialAccount($,O){let{count:Z}=await this.run(()=>this.models.SocialAccount.updateMany({where:{id:$.id,providerId:$.providerId},data:{providerId:O}}));return Z===1}}import{randomBytes as NY}from"crypto";function x0($,O,Z,T,j){return q0(O,C6($,O),Z,T,j)}function q0($,O,Z,T,j,f){let z=t3(O,Z,T);if(j&&O!==z)throw RangeError(s8($,O,Z,T,f));return z}function C6($,O){let Z=$[O];if(Z===void 0)throw TypeError(Aj(O));return Z}function f0($){return $!==null&&/object|function/.test(typeof $)}function A0($,O=Map){let Z=new O;return(T,...j)=>{if(Z.has(T))return Z.get(T);let f=$(T,...j);return Z.set(T,f),f}}function zT($){return h1({name:$},1)}function h1($,O){return c0((Z)=>({value:Z,configurable:1,writable:!O}),$)}function X6($){return c0((O)=>({get:O,configurable:1}),$)}function GZ($){return{[Symbol.toStringTag]:{value:$,configurable:1}}}function M$($,O){let Z={},T=$.length;for(let j of O)Z[$[--T]]=j;return Z}function c0($,O,Z){let T={};for(let j in O)T[j]=$(O[j],j,Z);return T}function BO($,O,Z){let T={};for(let j=0;j<O.length;j++){let f=O[j];T[f]=$(f,j,Z)}return T}function h5($,O,Z){let T={};for(let j=0;j<$.length;j++)T[O[j]]=Z[$[j]];return T}function P0($,O){let Z={};for(let T of $)Z[T]=O[T];return Z}function WT($,O){let Z={};for(let T in O)$.has(T)||(Z[T]=O[T]);return Z}function JT($){$={...$};let O=Object.keys($);for(let Z of O)$[Z]===void 0&&delete $[Z];return $}function D6($,O){for(let Z of O)if(!(Z in $))return 0;return 1}function F6($,O,Z){for(let T of $)if(O[T]!==Z[T])return 0;return 1}function U6($,O,Z){let T={...Z};for(let j=0;j<O;j++)T[$[j]]=0;return T}function b($,...O){return(...Z)=>$(...O,...Z)}function a4($){return $[0].toUpperCase()+$.substring(1)}function KO($){return $.slice().sort()}function zZ($,O){return String(O).padStart($,"0")}function Q1($,O){return Math.sign($-O)}function t3($,O,Z){return Math.min(Math.max($,O),Z)}function z1($,O){return[Math.floor($/O),YO($,O)]}function YO($,O){return($%O+O)%O}function L1($,O){return[BZ($,O),YT($,O)]}function BZ($,O){return Math.trunc($/O)||0}function YT($,O){return $%O||0}function $Z($){return Math.abs($%1)===0.5}function G6($,O,Z){let T=0,j=0;for(let W=0;W<=O;W++){let J=$[Z[W]],Y=a0[W],C=m/Y,[D,X]=L1(J,C);T+=X*Y,j+=D}let[f,z]=L1(T,m);return[j+f,z]}function KZ($,O,Z){let T={};for(let j=O;j>=0;j--){let f=a0[j];T[Z[j]]=BZ($,f),$=YT($,f)}return T}function B6($){return $===v?rZ:[]}function K6($){return $===v?AO:[]}function Q6($){return $===v?["year","day"]:[]}function V6($){if($!==void 0)return h($)}function I6($){if($!==void 0)return i0($)}function CT($){if($!==void 0)return QO($)}function i0($){return S6(QO($))}function QO($){return M6(g7($))}function XT($){if($==null)throw TypeError("Cannot be null or undefined");return $}function L6($,O){if(O==null)throw RangeError(Aj($));return O}function J1($){if(!f0($))throw TypeError(u8);return $}function QZ($,O,Z=$){if(typeof O!==$)throw TypeError(xO(Z,O));return O}function M6($,O="number"){if(!Number.isInteger($))throw RangeError(f7(O,$));return $||0}function S6($,O="number"){if($<=0)throw RangeError(z7(O,$));return $}function DT($){if(typeof $=="symbol")throw TypeError(C7);return String($)}function WZ($,O){return f0($)?String($):h($,O)}function VZ($){if(typeof $=="string")return BigInt($);if(typeof $!="bigint")throw TypeError(Y7($));return $}function x6($,O="number"){if(typeof $=="bigint")throw TypeError(J7(O));if($=Number($),!Number.isFinite($))throw RangeError(W7(O,$));return $}function F0($,O){return Math.trunc(x6($,O))||0}function N6($,O){return M6(x6($,O),O)}function o4($,O){return S6(F0($,O),O)}function FT($,O){let[Z,T]=L1(O,m),j=$+Z,f=Math.sign(j);return f&&f===-Math.sign(T)&&(j-=f,T+=f*m),[j,T]}function K$($,O,Z=1){return FT($[0]+O[0]*Z,$[1]+O[1]*Z)}function Q$($,O){return FT($[0],$[1]+O)}function v0($,O){return K$(O,$,-1)}function G0($,O){return Q1($[0],O[0])||Q1($[1],O[1])}function _6($,O,Z){return G0($,O)===-1||G0($,Z)===1}function IZ($,O=1){let Z=BigInt(m/O);return[Number($/Z),Number($%Z)*O]}function V$($,O=1){let Z=m/O,[T,j]=L1($,Z);return[T,j*O]}function A6($,O=1){let[Z,T]=$,j=Math.floor(T/O),f=m/O;return BigInt(Z)*BigInt(f)+BigInt(j)}function g0($,O=1,Z){let[T,j]=$,[f,z]=L1(j,O);return T*(m/O)+(f+(Z?z/O:0))}function UT($,O,Z=z1){let[T,j]=$,[f,z]=Z(j,O);return[T*(m/O)+f,z]}function GT($,O){let Z=$.formatToParts(O),T={};for(let j of Z)T[j.type]=j.value;return T}function BT($){return x0($,"isoYear",GO,UO,1),$.isoYear===GO?x0($,"isoMonth",4,12,1):$.isoYear===UO&&x0($,"isoMonth",1,9,1),$}function V1($){return Y1({...$,...p0,isoHour:12}),$}function Y1($){let O=x0($,"isoYear",GO,UO,1),Z=O===GO?1:O===UO?-1:0;return Z&&R0(U0({...$,isoDay:$.isoDay+Z,isoNanosecond:$.isoNanosecond-Z})),$}function R0($){if(!$||_6($,c7,p7))throw RangeError(sZ);return $}function M1($){return G6($,5,u0)[1]}function LZ($){let[O,Z]=z1($,m);return[KZ(Z,5,u0),O]}function E6($){return P6($)[0]}function P6($){return UT($,y0)}function B0($){return S$($.isoYear,$.isoMonth,$.isoDay,$.isoHour,$.isoMinute,$.isoSecond,$.isoMillisecond)}function U0($){let O=B0($);if(O!==void 0){let[Z,T]=L1(O,_0);return[Z,T*o0+($.isoMicrosecond||0)*t1+($.isoNanosecond||0)]}}function KT($,O){let[Z,T]=LZ(M1($)-O);return R0(U0({...$,isoDay:$.isoDay+T,...Z}))}function JZ(...$){return S$(...$)/jz}function S$(...$){let[O,Z]=H6(...$),T=O.valueOf();if(!isNaN(T))return T-Z*_0}function H6($,O=1,Z=1,T=0,j=0,f=0,z=0){let W=$===GO?1:$===UO?-1:0,J=new Date;return J.setUTCHours(T,j,f,z),J.setUTCFullYear($,O-1,Z+W),[J,W]}function x1($,O){let[Z,T]=Q$($,O);T<0&&(T+=m,Z-=1);let[j,f]=z1(T,o0),[z,W]=z1(f,t1);return MZ(Z*_0+j,z,W)}function MZ($,O=0,Z=0){let T=Math.ceil(Math.max(0,Math.abs($)-y7)/_0)*Math.sign($),j=new Date($-T*_0);return M$(eZ,[j.getUTCFullYear(),j.getUTCMonth()+1,j.getUTCDate()+T,j.getUTCHours(),j.getUTCMinutes(),j.getUTCSeconds(),j.getUTCMilliseconds(),O,Z])}function w6($){return[$.isoYear,$.isoMonth,$.isoDay]}function b6(){return f1}function QT($,O){switch(O){case 2:return VT($)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function v6($){return VT($)?366:365}function VT($){return $%4==0&&($%100!=0||$%400==0)}function g6($){let[O,Z]=H6($.isoYear,$.isoMonth,$.isoDay);return YO(O.getUTCDay()-Z,7)||7}function R6({isoYear:$}){return $<1?["bce",1-$]:["ce",$]}function l5($){let O=B0($);if(O<h7)return R6($);let Z=GT(dj(I$),O),{era:T,eraYear:j}=u2(Z,I$);return[T,j]}function SZ($){return l1($),xZ($,1),$}function l1($){return k6($,1),$}function r4($){return F6(qj,$,k6($))}function k6($,O){let{isoYear:Z}=$,T=x0($,"isoMonth",1,b6(),O);return{isoYear:Z,isoMonth:T,isoDay:x0($,"isoDay",1,QT(Z,T),O)}}function xZ($,O){return M$(u0,[x0($,"isoHour",0,23,O),x0($,"isoMinute",0,59,O),x0($,"isoSecond",0,59,O),x0($,"isoMillisecond",0,999,O),x0($,"isoMicrosecond",0,999,O),x0($,"isoNanosecond",0,999,O)])}function R($){return $===void 0?0:Lz(J1($))}function VO($,O=0){$=h0($);let Z=Mz($),T=e7($,O);return[Lz($),T,Z]}function IT($){return Mz(h0($))}function q6($){return $=h0($),pj($,9,6,1)}function x$($,O,Z,T=9,j=0,f=4){O=h0(O);let z=pj(O,T,j),W=ST(O),J=PO(O,f),Y=EO(O,T,j,1);return z==null?z=Math.max(Z,Y):c6(z,Y),W=xT(W,Y,1),$&&(J=((C)=>C<4?(C+2)%4:C)(J)),[z,Y,W,J]}function NZ($,O=6,Z){let T=ST($=NT($,UZ)),j=PO($,7),f=EO($,O);return f=L6(UZ,f),T=xT(T,f,void 0,Z),[f,T,j]}function LT($){return cj(h0($))}function m6($,O){return MT(h0($),O)}function MT($,O=4){let Z=p6($);return[PO($,4),...y6(EO($,O),Z)]}function y6($,O){return $!=null?[a0[$],$<4?9-3*$:-1]:[O===void 0?1:10**(9-O),O]}function ST($){let O=$[CO];return O===void 0?1:F0(O,CO)}function xT($,O,Z,T){let j=T?m:a0[O+1];if(j){let f=a0[O];if(j%(($=q0(CO,$,1,j/f-(T?0:1),1))*f))throw RangeError(xO(CO,$))}else $=q0(CO,$,1,Z?1e9:1,1);return $}function p6($){let O=$[r3];if(O!==void 0){if(typeof O!="number"){if(DT(O)==="auto")return;throw RangeError(xO(r3,O))}O=q0(r3,Math.floor(O),0,9,1)}return O}function h0($){return $===void 0?{}:J1($)}function NT($,O){return typeof $=="string"?{[O]:$}:J1($)}function n($){if($!==void 0){if(f0($))return Object.assign(Object.create(null),$);throw TypeError(u8)}}function _Z($,O){return $&&Object.assign(Object.create(null),$,{overflow:d7[O]})}function _T($,O,Z=9,T=0,j){let f=O[$];if(f===void 0)return j?T:void 0;if(f=DT(f),f==="auto")return j?T:null;let z=ZT[f];if(z===void 0&&(z=q7[f]),z===void 0)throw RangeError(o8($,f,ZT));return q0($,z,T,Z,1,_O),z}function d1($,O,Z,T=0){let j=Z[$];if(j===void 0)return T;let f=DT(j),z=O[f];if(z===void 0)throw RangeError(o8($,f,O));return z}function c6($,O){if(O>$)throw RangeError(P7)}function z0($){return{branding:O3,epochNanoseconds:$}}function Y0($,O,Z){return{branding:F1,calendar:Z,timeZone:O,epochNanoseconds:$}}function a($,O=$.calendar){return{branding:$$,calendar:O,...P0(Kz,$)}}function o($,O=$.calendar){return{branding:e1,calendar:O,...P0(mj,$)}}function c1($,O=$.calendar){return{branding:b$,calendar:O,...P0(mj,$)}}function YZ($,O=$.calendar){return{branding:v$,calendar:O,...P0(mj,$)}}function l0($){return{branding:$3,...P0(Bz,$)}}function i($){return{branding:Z3,sign:N1($),...P0(gj,$)}}function i6($){return E6($.epochNanoseconds)}function AZ($){return UT($.epochNanoseconds,o0)[0]}function h6($){return A6($.epochNanoseconds,t1)}function l6($){return A6($.epochNanoseconds)}function d6($){return $.epochNanoseconds}function W0($){return typeof $=="string"?$:h($.id)}function N$($,O){return $===O||W0($)===W0(O)}function u6($,O,Z,T,j){let f=i1(T),[z,W]=((B,Q)=>{let L=Q((B=NT(B,fT))[Vz]),V=t7(B);return V=L6(fT,V),[V,L]})(j,$);if(DO(Math.max(z,f),W))return t4(T,z);if(!W)throw RangeError(nZ);let[J,Y,C]=vZ(O,Z,W),D=oT(C),X=gZ(C),U=rT(C),F=X(Y,J,T),G=U(Y,J,F,z);return DO(z,W)?t4(G,z):((B,Q,L,V,N,A,I)=>{let M=N1(B),[E,P]=AT(V,kj(L,B),L,M,N,A,I),$0=ET(Q,E,P);return B[k[L]]+$0*M})(G,D(F),z,Y,J,D,X)}function t4($,O){return g0(j0($),a0[O],1)}function AT($,O,Z,T,j,f,z){let W=k[Z],J={...O,[W]:O[W]+T},Y=z($,j,O),C=z($,j,J);return[f(Y),f(C)]}function ET($,O,Z){let T=g0(v0(O,Z));if(!T)throw RangeError(NO);return g0(v0(O,$))/T}function s6($,O){let[Z,T,j]=NZ(O,5,1);return z0(PZ($.epochNanoseconds,Z,T,j,1))}function n6($,O,Z){let{epochNanoseconds:T,timeZone:j,calendar:f}=O,[z,W,J]=NZ(Z);if(z===0&&W===1)return O;let Y=$(j);if(z===6)T=((C,D,X,U)=>{let F=K0(X,D),[G,B]=C(F),Q=X.epochNanoseconds,L=E0(D,G),V=E0(D,B);if(_6(Q,L,V))throw RangeError(NO);return T2(ET(Q,L,V),U)?V:L})(O2,Y,O,J);else{let C=Y.getOffsetNanosecondsFor(T);T=s1(Y,e6(x1(T,C),z,W,J),C,2,0,1)}return Y0(T,j,f)}function a6($,O){return a(e6($,...NZ(O)),$.calendar)}function o6($,O){let[Z,T,j]=NZ(O,5);var f;return l0((f=j,PT($,IO(Z,T),f)[0]))}function r6($,O){let Z=$(O.timeZone),T=K0(O,Z),[j,f]=O2(T),z=g0(v0(E0(Z,j),E0(Z,f)),oZ,1);if(z<=0)throw RangeError(NO);return z}function t6($,O){let{timeZone:Z,calendar:T}=O,j=((f,z,W)=>E0(z,f(K0(W,z))))(Z2,$(Z),O);return Y0(j,Z,T)}function e6($,O,Z,T){return $2($,IO(O,Z),T)}function $2($,O,Z){let[T,j]=PT($,O,Z);return Y1({...n1($,j),...T})}function PT($,O,Z){return LZ(S1(M1($),O,Z))}function CZ($){return S1($,aZ,7)}function IO($,O){return a0[$]*O}function O2($){let O=Z2($);return[O,n1(O,1)]}function Z2($){return m7(6,$)}function d5($,O,Z){let T=Math.min(i1($),6);return A$(HZ(j0($,T),O,Z),T)}function EZ($,O,Z,T,j,f,z,W,J,Y){if(T===0&&j===1)return $;let C=DO(T,W)?RZ(W)&&T<6&&Z>=6?s5:u5:n5,[D,X,U]=C($,O,Z,T,j,f,z,W,J,Y);return U&&T!==7&&(D=((F,G,B,Q,L,V,N,A)=>{let I=N1(F);for(let M=Q+1;M<=B;M++){if(M===7&&B!==7)continue;let E=kj(M,F);E[k[M]]+=I;let P=g0(v0(N(A(L,V,E)),G));if(P&&Math.sign(P)!==I)break;F=E}return F})(D,X,Z,Math.max(6,T),z,W,J,Y)),D}function PZ($,O,Z,T,j){if(O===6){let f=((z)=>z[0]+z[1]/m)($);return[S1(f,Z,T),0]}return HZ($,IO(O,Z),T,j)}function HZ($,O,Z,T){let[j,f]=$;T&&f<0&&(f+=m,j-=1);let[z,W]=z1(S1(f,O,Z),m);return FT(j+z,W)}function S1($,O,Z){return T2($/O,Z)*O}function T2($,O){return ZJ[O]($)}function u5($,O,Z,T,j,f){let z=N1($),W=j0($),J=PZ(W,T,j,f),Y=v0(W,J),C=Math.sign(J[0]-W[0])===z,D=A$(J,Math.min(Z,6));return[{...$,...D},K$(O,Y),C]}function s5($,O,Z,T,j,f,z,W,J,Y){let C=N1($),D=g0(j0($,5)),X=IO(T,j),U=S1(D,X,f),[F,G]=AT(z,{...$,...Rj},6,C,W,J,Y),B=U-g0(v0(F,G)),Q=0;B&&Math.sign(B)!==C?O=Q$(F,U):(Q+=C,U=S1(B,X,f),O=Q$(G,U));let L=qZ(U);return[{...$,...L,days:$.days+Q},O,Boolean(Q)]}function n5($,O,Z,T,j,f,z,W,J,Y){let C=N1($),D=k[T],X=kj(T,$);T===7&&($={...$,weeks:$.weeks+Math.trunc($.days/7)});let U=BZ($[D],j)*j;X[D]=U;let[F,G]=AT(z,X,T,j*C,W,J,Y),B=U+ET(O,F,G)*C*j,Q=S1(B,j,f),L=Math.sign(Q-B)===C;return X[D]=Q,[X,L?G:F,L]}function HT($,O,Z,T){let[j,f,z,W]=((Y)=>{let C=MT(Y=h0(Y));return[Y.timeZone,...C]})(T),J=j!==void 0;return((Y,C,D,X,U,F)=>{D=HZ(D,U,X,1);let G=C.getOffsetNanosecondsFor(D);return qT(x1(D,G),F)+(Y?u1(CZ(G)):"Z")})(J,O(J?$(j):O$),Z.epochNanoseconds,f,z,W)}function wT($,O,Z){let[T,j,f,z,W,J]=((Y)=>{Y=h0(Y);let C=cj(Y),D=p6(Y),X=OJ(Y),U=PO(Y,4),F=EO(Y,4);return[C,$J(Y),X,U,...y6(F,D)]})(Z);return((Y,C,D,X,U,F,G,B,Q,L)=>{X=HZ(X,Q,B,1);let V=Y(D).getOffsetNanosecondsFor(X);return qT(x1(X,V),L)+u1(CZ(V),G)+((N,A)=>A!==1?"["+(A===2?"!":"")+W0(N)+"]":"")(D,F)+mT(C,U)})($,O.calendar,O.timeZone,O.epochNanoseconds,T,j,f,z,W,J)}function bT($,O){let[Z,T,j,f]=((Y)=>(Y=h0(Y),[cj(Y),...MT(Y)]))(O);return z=$.calendar,W=Z,J=f,qT($2($,j,T),J)+mT(z,W);var z,W,J}function vT($,O){return Z=$.calendar,T=$,j=LT(O),XZ(T)+mT(Z,j);var Z,T,j}function gT($,O){return j2($.calendar,f2,$,LT(O))}function RT($,O){return j2($.calendar,a5,$,LT(O))}function kT($,O){let[Z,T,j]=m6(O);return f=j,z2(PT($,T,Z)[0],f);var f}function wZ($,O){let[Z,T,j]=m6(O,3);return T>1&&($={...$,...d5($,T,Z)}),((f,z)=>{let{sign:W}=f,J=W===-1?Q0(f):f,{hours:Y,minutes:C}=J,[D,X]=UT(j0(J,3),y0,L1);U2(D);let U=yT(X,z),F=z>=0||!W||U;return(W<0?"-":"")+"P"+e4({Y:p1(J.years),M:p1(J.months),W:p1(J.weeks),D:p1(J.days)})+(Y||C||D||F?"T"+e4({H:p1(Y),M:p1(C),S:p1(D,F)+U}):"")})($,j)}function j2($,O,Z,T){let j=W0($),f=T>1||T===0&&j!==v;return T===1?j===v?O(Z):XZ(Z):f?XZ(Z)+W2(j,T===2):O(Z)}function e4($){let O=[];for(let Z in $){let T=$[Z];T&&O.push(T,Z)}return O.join("")}function qT($,O){return XZ($)+"T"+z2($,O)}function XZ($){return f2($)+"-"+m0($.isoDay)}function f2($){let{isoYear:O}=$;return(O<0||O>9999?J2(O)+zZ(6,Math.abs(O)):zZ(4,O))+"-"+m0($.isoMonth)}function a5($){return m0($.isoMonth)+"-"+m0($.isoDay)}function z2($,O){let Z=[m0($.isoHour),m0($.isoMinute)];return O!==-1&&Z.push(m0($.isoSecond)+((T,j,f,z)=>yT(T*o0+j*t1+f,z))($.isoMillisecond,$.isoMicrosecond,$.isoNanosecond,O)),Z.join(":")}function u1($,O=0){if(O===1)return"";let[Z,T]=z1(Math.abs($),oZ),[j,f]=z1(T,aZ),[z,W]=z1(f,y0);return J2($)+m0(Z)+":"+m0(j)+(z||W?":"+m0(z)+yT(W):"")}function mT($,O){if(O!==1){let Z=W0($);if(O>1||O===0&&Z!==v)return W2(Z,O===2)}return""}function W2($,O){return"["+(O?"!":"")+"u-ca="+$+"]"}function yT($,O){let Z=zZ(9,$);return Z=O===void 0?Z.replace(fJ,""):Z.slice(0,O),Z?"."+Z:""}function J2($){return $<0?"-":"+"}function p1($,O){return $||O?$.toLocaleString("fullwide",{useGrouping:0}):""}function o5($,O){let{epochNanoseconds:Z}=$,T=(O.getOffsetNanosecondsFor?O:O($.timeZone)).getOffsetNanosecondsFor(Z),j=x1(Z,T);return{calendar:$.calendar,...j,offsetNanoseconds:T}}function Y2($,O){let Z=K0(O,$);return{calendar:O.calendar,...P0(Kz,Z),offset:u1(Z.offsetNanoseconds),timeZone:O.timeZone}}function s1($,O,Z,T=0,j=0,f,z){if(Z!==void 0&&T===1&&(T===1||z))return KT(O,Z);let W=$.getPossibleInstantsFor(O);if(Z!==void 0&&T!==3){let J=((Y,C,D,X)=>{let U=U0(C);X&&(D=CZ(D));for(let F of Y){let G=g0(v0(F,U));if(X&&(G=CZ(G)),G===D)return F}})(W,O,Z,f);if(J!==void 0)return J;if(T===0)throw RangeError(S7)}return z?U0(O):E0($,O,j,W)}function E0($,O,Z=0,T=$.getPossibleInstantsFor(O)){if(T.length===1)return T[0];if(Z===1)throw RangeError(x7);if(T.length)return T[Z===3?1:0];let j=U0(O),f=((W,J)=>{let Y=W.getOffsetNanosecondsFor(Q$(J,-m));return cT(W.getOffsetNanosecondsFor(Q$(J,m))-Y)})($,j),z=f*(Z===2?-1:1);return(T=$.getPossibleInstantsFor(x1(j,z)))[Z===2?0:T.length-1]}function pT($){if(Math.abs($)>=m)throw RangeError(L7);return $}function cT($){if($>m)throw RangeError(M7);return $}function iT($,O,Z){return z0(R0(K$(O.epochNanoseconds,((T)=>{if(G2(T))throw RangeError(A7);return j0(T,5)})($?Q0(Z):Z))))}function hT($,O,Z,T,j,f=Object.create(null)){let z=O(T.timeZone),W=$(T.calendar);return{...T,...nT(z,W,T,Z?Q0(j):j,f)}}function lT($,O,Z,T,j=Object.create(null)){let{calendar:f}=Z;return a(aT($(f),Z,O?Q0(T):T,j),f)}function dT($,O,Z,T,j){let{calendar:f}=Z;return o(bZ($(f),Z,O?Q0(T):T,j),f)}function uT($,O,Z,T,j=Object.create(null)){let f=Z.calendar,z=$(f),W=XO(z,Z);O&&(T=kZ(T)),T.sign<0&&(W=z.dateAdd(W,{...J0,months:1}),W=n1(W,-1));let J=z.dateAdd(W,T,j);return c1(XO(z,J),f)}function sT($,O,Z){return l0(C2(O,$?Q0(Z):Z)[0])}function nT($,O,Z,T,j){let f=j0(T,5),z=Z.epochNanoseconds;if(G2(T)){let W=K0(Z,$);z=K$(E0($,{...bZ(O,W,{...T,...Rj},j),...P0(u0,W)}),f)}else z=K$(z,f),R(j);return{epochNanoseconds:R0(z)}}function aT($,O,Z,T){let[j,f]=C2(O,Z);return Y1({...bZ($,O,{...Z,...Rj,days:Z.days+f},T),...j})}function bZ($,O,Z,T){if(Z.years||Z.months||Z.weeks)return $.dateAdd(O,Z,T);R(T);let j=Z.days+j0(Z,5)[0];return j?V1(n1(O,j)):O}function XO($,O,Z=1){return n1(O,Z-$.day(O))}function C2($,O){let[Z,T]=j0(O,5),[j,f]=LZ(M1($)+T);return[j,Z+f]}function n1($,O){return O?{...$,...MZ(B0($)+O*_0)}:$}function vZ($,O,Z){let T=$(Z.calendar);return RZ(Z)?[Z,T,O(Z.timeZone)]:[{...Z,...p0},T]}function oT($){return $?d6:U0}function gZ($){return $?b(nT,$):aT}function rT($){return $?b(t5,$):e5}function RZ($){return $&&$.epochNanoseconds}function DO($,O){return $<=6-(RZ(O)?1:0)}function tT($,O,Z,T,j,f,z){let W=$(h0(z).relativeTo),J=Math.max(i1(j),i1(f));if(DO(J,W))return i(_$(((G,B,Q,L)=>{let V=K$(j0(G),j0(B),L?-1:1);if(!Number.isFinite(V[0]))throw RangeError(sZ);return{...J0,...A$(V,Q)}})(j,f,J,T)));if(!W)throw RangeError(nZ);T&&(f=Q0(f));let[Y,C,D]=vZ(O,Z,W),X=gZ(D),U=rT(D),F=X(C,Y,j);return i(U(C,Y,X(C,F,f),J))}function X2($,O,Z,T,j){let f=i1(T),[z,W,J,Y,C]=((I,M,E)=>{I=NT(I,UZ);let P=pj(I),$0=E(I[Vz]),g=ST(I),q=PO(I,7),O0=EO(I);if(P===void 0&&O0===void 0)throw RangeError(E7);return O0==null&&(O0=0),P==null&&(P=Math.max(O0,M)),c6(P,O0),g=xT(g,O0,1),[P,O0,g,q,$0]})(j,f,$),D=Math.max(f,z);if(!RZ(C)&&D<=6)return i(_$(((I,M,E,P,$0)=>{let g=PZ(j0(I),E,P,$0);return{...J0,...A$(g,M)}})(T,z,W,J,Y)));if(!C)throw RangeError(nZ);let[X,U,F]=vZ(O,Z,C),G=oT(F),B=gZ(F),Q=rT(F),L=B(U,X,T),V=Q(U,X,L,z),N=T.sign,A=N1(V);if(N&&A&&N!==A)throw RangeError(NO);return A&&(V=EZ(V,G(L),z,W,J,Y,U,X,G,B)),i(V)}function D2($){return $.sign===-1?kZ($):$}function kZ($){return i(Q0($))}function Q0($){let O={};for(let Z of k)O[Z]=-1*$[Z]||0;return O}function F2($){return!$.sign}function N1($,O=k){let Z=0;for(let T of O){let j=Math.sign($[T]);if(j){if(Z&&Z!==j)throw RangeError(_7);Z=j}}return Z}function _$($){for(let O of k7)q0(O,$[O],-z6,z6,1);return U2(g0(j0($),y0)),$}function U2($){if(!Number.isSafeInteger($))throw RangeError(N7)}function j0($,O=6){return G6($,O,k)}function A$($,O=6){let[Z,T]=$,j=KZ(T,O,k);if(j[k[O]]+=Z*(m/a0[O]),!Number.isFinite(j[k[O]]))throw RangeError(sZ);return j}function qZ($,O=5){return KZ($,O,k)}function G2($){return Boolean(N1($,Gz))}function i1($){let O=9;for(;O>0&&!$[k[O]];O--);return O}function r5($,O){return[$,O]}function $6($){let O=Math.floor($/jZ)*jZ;return[O,O+jZ]}function B2($){let O=_1($=WZ($));if(!O)throw RangeError(N0($));let Z;if(O.m)Z=0;else{if(!O.offset)throw RangeError(N0($));Z=E$(O.offset)}return O.timeZone&&Zj(O.timeZone,1),z0(KT(SZ(O),Z))}function K2($){let O=_1(h($));if(!O)throw RangeError(N0($));if(O.timeZone)return _2(O,O.offset?E$(O.offset):void 0);if(O.m)throw RangeError(N0($));return E2(O)}function Q2($,O){let Z=_1(h($));if(!Z||!Z.timeZone)throw RangeError(N0($));let{offset:T}=Z,j=T?E$(T):void 0,[,f,z]=VO(O);return _2(Z,j,f,z)}function E$($){let O=Zj($);if(O===void 0)throw RangeError(N0($));return O}function V2($){let O=_1(h($));if(!O||O.m)throw RangeError(N0($));return a(A2(O))}function mZ($){let O=_1(h($));if(!O||O.m)throw RangeError(N0($));return o(O.p?A2(O):E2(O))}function I2($,O){let Z=$j(h(O));if(Z)return eT(Z),c1(BT(l1(Z)));let T=mZ(O);return c1(XO($(T.calendar),T))}function eT($){if($.calendar!==v)throw RangeError(W1($.calendar))}function L2($,O){let Z=Oj(h(O));if(Z)return eT(Z),YZ(l1(Z));let T=mZ(O),{calendar:j}=T,f=$(j),[z,W,J]=f.h(T),[Y,C]=f.I(z,W),[D,X]=f.N(Y,C,J);return YZ(V1(f.P(D,X,J)),j)}function M2($){let O,Z=((T)=>{let j=CJ.exec(T);return j?(yZ(j[10]),w2(j)):void 0})(h($));if(!Z){if(Z=_1($),!Z)throw RangeError(N0($));if(!Z.p)throw RangeError(N0($));if(Z.m)throw RangeError(W1("Z"));eT(Z)}if((O=$j($))&&r4(O))throw RangeError(N0($));if((O=Oj($))&&r4(O))throw RangeError(N0($));return l0(xZ(Z,1))}function S2($){let O=((Z)=>{let T=FJ.exec(Z);return T?((j)=>{function f(C,D,X){let U=0,F=0;if(X&&([U,J]=z1(J,a0[X])),C!==void 0){if(W)throw RangeError(W1(C));F=((G)=>{let B=parseInt(G);if(!Number.isFinite(B))throw RangeError(W1(G));return B})(C),z=1,D&&(J=Tj(D)*(a0[X]/y0),W=1)}return U+F}let z=0,W=0,J=0,Y={...M$(k,[f(j[2]),f(j[3]),f(j[4]),f(j[5]),f(j[6],j[7],5),f(j[8],j[9],4),f(j[10],j[11],3)]),...KZ(J,2,k)};if(!z)throw RangeError(n8(k));return jj(j[1])<0&&(Y=Q0(Y)),Y})(T):void 0})(h($));if(!O)throw RangeError(N0($));return i(_$(O))}function x2($){let O=_1($)||$j($)||Oj($);return O?O.calendar:$}function N2($){let O=_1($);return O&&(O.timeZone||O.m&&O$||O.offset)||$}function _2($,O,Z=0,T=0){let j=pZ($.timeZone),f=T3(j);return Y0(s1(f,SZ($),O,Z,T,!f.v,$.m),j,LO($.calendar))}function A2($){return P2(Y1(SZ($)))}function E2($){return P2(V1(l1($)))}function P2($){return{...$,calendar:LO($.calendar)}}function _1($){let O=YJ.exec($);return O?((Z)=>{let T=Z[10],j=(T||"").toUpperCase()==="Z";return{isoYear:H2(Z),isoMonth:parseInt(Z[4]),isoDay:parseInt(Z[5]),...w2(Z.slice(5)),...yZ(Z[16]),p:Boolean(Z[6]),m:j,offset:j?void 0:T}})(O):void 0}function $j($){let O=WJ.exec($);return O?((Z)=>({isoYear:H2(Z),isoMonth:parseInt(Z[4]),isoDay:1,...yZ(Z[5])}))(O):void 0}function Oj($){let O=JJ.exec($);return O?((Z)=>({isoYear:L$,isoMonth:parseInt(Z[1]),isoDay:parseInt(Z[2]),...yZ(Z[3])}))(O):void 0}function Zj($,O){let Z=XJ.exec($);return Z?((T,j)=>{let f=T[4]||T[5];if(j&&f)throw RangeError(W1(f));return pT((B$(T[2])*oZ+B$(T[3])*aZ+B$(T[4])*y0+Tj(T[5]||""))*jj(T[1]))})(Z,O):void 0}function H2($){let O=jj($[1]),Z=parseInt($[2]||$[3]);if(O<0&&!Z)throw RangeError(W1(-0));return O*Z}function w2($){let O=B$($[3]);return{...LZ(Tj($[4]||""))[0],isoHour:B$($[1]),isoMinute:B$($[2]),isoSecond:O===60?59:O}}function yZ($){let O,Z,T=[];if($.replace(DJ,(j,f,z)=>{let W=Boolean(f),[J,Y]=z.split("=").reverse();if(Y){if(Y==="u-ca")T.push(J),O||(O=W);else if(W||/[A-Z]/.test(Y))throw RangeError(W1(j))}else{if(Z)throw RangeError(W1(j));Z=J}return""}),T.length>1&&O)throw RangeError(W1($));return{timeZone:Z,calendar:T[0]||v}}function Tj($){return parseInt($.padEnd(9,"0"))}function P$($){return new RegExp(`^${$}$`,"i")}function jj($){return $&&$!=="+"?-1:1}function B$($){return $===void 0?0:parseInt($)}function b2($){return pZ(h($))}function pZ($){let O=fj($);return typeof O=="number"?u1(O):O?((Z)=>{if(GJ.test(Z))throw RangeError(I7);return Z.toLowerCase().split("/").map((T,j)=>(T.length<=3||/\d/.test(T))&&!/etc|yap/.test(T)?T.toUpperCase():T.replace(/baja|dumont|[a-z]+/g,(f,z)=>f.length<=2&&!j||f==="in"||f==="chat"?f.toUpperCase():f.length>2||!z?a4(f).replace(/island|noronha|murdo|rivadavia|urville/,a4):f)).join("/")})($):O$}function O6($){let O=fj($);return typeof O=="number"?O:O?O.resolvedOptions().timeZone:O$}function fj($){let O=Zj($=$.toUpperCase(),1);return O!==void 0?O:$!==O$?UJ($):void 0}function zj($,O){return G0($.epochNanoseconds,O.epochNanoseconds)}function Wj($,O){return G0($.epochNanoseconds,O.epochNanoseconds)}function v2($,O,Z,T,j,f){let z=$(h0(f).relativeTo),W=Math.max(i1(T),i1(j));if(F6(k,T,j))return 0;if(DO(W,z))return G0(j0(T),j0(j));if(!z)throw RangeError(nZ);let[J,Y,C]=vZ(O,Z,z),D=oT(C),X=gZ(C);return G0(D(X(Y,J,T)),D(X(Y,J,j)))}function Jj($,O){return a1($,O)||cZ($,O)}function a1($,O){return Q1(B0($),B0(O))}function cZ($,O){return Q1(M1($),M1(O))}function g2($,O){return!zj($,O)}function R2($,O){return!Wj($,O)&&!!iZ($.timeZone,O.timeZone)&&N$($.calendar,O.calendar)}function k2($,O){return!Jj($,O)&&N$($.calendar,O.calendar)}function q2($,O){return!a1($,O)&&N$($.calendar,O.calendar)}function m2($,O){return!a1($,O)&&N$($.calendar,O.calendar)}function y2($,O){return!a1($,O)&&N$($.calendar,O.calendar)}function p2($,O){return!cZ($,O)}function iZ($,O){if($===O)return 1;let Z=W0($),T=W0(O);if(Z===T)return 1;try{return O6(Z)===O6(T)}catch(j){}}function Yj($,O,Z,T){let j=x$($,n(T),3,5),f=hZ(O.epochNanoseconds,Z.epochNanoseconds,...j);return i($?Q0(f):f)}function Cj($,O,Z,T,j,f){let z=dZ(T.calendar,j.calendar),W=n(f),[J,Y,C,D]=x$(Z,W,5),X=T.epochNanoseconds,U=j.epochNanoseconds,F=G0(U,X),G;if(F)if(J<6)G=hZ(X,U,J,Y,C,D);else{let B=O(((L,V)=>{if(!iZ(L,V))throw RangeError($z);return L})(T.timeZone,j.timeZone)),Q=$(z);G=i2(Q,B,T,j,F,J,W),G=EZ(G,U,J,Y,C,D,Q,T,d6,b(nT,B))}else G=J0;return i(Z?Q0(G):G)}function Xj($,O,Z,T,j){let f=dZ(Z.calendar,T.calendar),z=n(j),[W,J,Y,C]=x$(O,z,6),D=U0(Z),X=U0(T),U=G0(X,D),F;if(U)if(W<=6)F=hZ(D,X,W,J,Y,C);else{let G=$(f);F=h2(G,Z,T,U,W,z),F=EZ(F,X,W,J,Y,C,G,Z,U0,aT)}else F=J0;return i(O?Q0(F):F)}function Dj($,O,Z,T,j){let f=dZ(Z.calendar,T.calendar),z=n(j);return c2(O,()=>$(f),Z,T,...x$(O,z,6,9,6),z)}function Fj($,O,Z,T,j){let f=dZ(Z.calendar,T.calendar),z=n(j),W=x$(O,z,9,9,8),J=$(f);return c2(O,()=>J,XO(J,Z),XO(J,T),...W,z)}function c2($,O,Z,T,j,f,z,W,J){let Y=U0(Z),C=U0(T),D;if(G0(C,Y))if(j===6)D=hZ(Y,C,j,f,z,W);else{let X=O();D=X.dateUntil(Z,T,j,J),f===6&&z===1||(D=EZ(D,C,j,f,z,W,X,Z,U0,bZ))}else D=J0;return i($?Q0(D):D)}function Uj($,O,Z,T){let j=n(T),[f,z,W,J]=x$($,j,5,5),Y=S1(Gj(O,Z),IO(z,W),J),C={...J0,...qZ(Y,f)};return i($?Q0(C):C)}function t5($,O,Z,T,j,f){let z=G0(T.epochNanoseconds,Z.epochNanoseconds);return z?j<6?l2(Z.epochNanoseconds,T.epochNanoseconds,j):i2(O,$,Z,T,z,j,f):J0}function e5($,O,Z,T,j){let f=U0(O),z=U0(Z),W=G0(z,f);return W?T<=6?l2(f,z,T):h2($,O,Z,W,T,j):J0}function i2($,O,Z,T,j,f,z){let[W,J,Y]=((X,U,F,G)=>{function B(){return M={...n1(V,A++*-G),...L},E=E0(X,M),G0(N,E)===-G}let Q=K0(U,X),L=P0(u0,Q),V=K0(F,X),N=F.epochNanoseconds,A=0,I=Gj(Q,V),M,E;if(Math.sign(I)===-G&&A++,B()&&(G===-1||B()))throw RangeError(NO);let P=g0(v0(E,N));return[Q,M,P]})(O,Z,T,j);var C,D;return{...f===6?(C=W,D=J,{...J0,days:d2(C,D)}):$.dateUntil(W,J,f,z),...qZ(Y)}}function h2($,O,Z,T,j,f){let[z,W,J]=((Y,C,D)=>{let X=C,U=Gj(Y,C);return Math.sign(U)===-D&&(X=n1(C,-D),U+=m*D),[Y,X,U]})(O,Z,T);return{...$.dateUntil(z,W,j,f),...qZ(J)}}function hZ($,O,Z,T,j,f){return{...J0,...A$(PZ(v0($,O),T,j,f),Z)}}function l2($,O,Z){return{...J0,...A$(v0($,O),Z)}}function d2($,O){return lZ(B0($),B0(O))}function lZ($,O){return Math.trunc((O-$)/_0)}function Gj($,O){return M1(O)-M1($)}function dZ($,O){if(!N$($,O))throw RangeError(Hj);return $}function $7($){function O(j){return((f,z)=>({...u2(f,z),F:f.month,day:parseInt(f.day)}))(GT(Z,j),T)}let Z=dj($),T=DZ($);return{id:$,O:O7(O),B:Z7(O)}}function O7($){return A0((O)=>{let Z=B0(O);return $(Z)},WeakMap)}function Z7($){let O=$(0).year-i7;return A0((Z)=>{let T,j=S$(Z-O),f=[],z=[];do j+=400*_0;while((T=$(j)).year<=Z);do j+=(1-T.day)*_0,T.year===Z&&(f.push(j),z.push(T.F)),j-=_0;while((T=$(j)).year>=Z);return{k:f.reverse(),C:Tz(z.reverse())}})}function u2($,O){let Z,T,j=s2($);if($.era){let f=Dz[O];f!==void 0&&(Z=O==="islamic"?"ah":$.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),Z==="bc"||Z==="b"?Z="bce":Z!=="ad"&&Z!=="a"||(Z="ce"),T=j,j=t2(T,f[Z]||0))}return{era:Z,eraYear:T,year:j}}function s2($){return parseInt($.relatedYear||$.year)}function e3($){let{year:O,F:Z,day:T}=this.O($),{C:j}=this.B(O);return[O,j[Z]+1,T]}function FO($,O=1,Z=1){return this.B($).k[O-1]+(Z-1)*_0}function OZ($){let O=T6(this,$),Z=T6(this,$-1),T=O.length;if(T>Z.length){let j=e2(this);if(j<0)return-j;for(let f=0;f<T;f++)if(O[f]!==Z[f])return f+1}}function ZZ($){return lZ(FO.call(this,$),FO.call(this,$+1))}function Z6($,O){let{k:Z}=this.B($),T=O+1,j=Z;return T>Z.length&&(T=1,j=this.B($+1).k),lZ(Z[O-1],j[T-1])}function TZ($){return this.B($).k.length}function T6($,O){return Object.keys($.B(O).C)}function n2($){return LO(h($))}function LO($){if(($=$.toLowerCase())!==v&&$!==tZ&&DZ($)!==DZ(dj($).resolvedOptions().calendar))throw RangeError(V7($));return $}function DZ($){return $==="islamicc"&&($="islamic"),$.split("-")[0]}function a2($){return this.R($)[0]}function o2($){return this.R($)[1]}function Bj($){let[O]=this.h($);return lZ(this.q(O),B0($))+1}function r2($){let O=KJ.exec($);if(!O)throw RangeError(K7($));return[parseInt(O[1]),Boolean(O[2])]}function FZ($,O,Z){return $+(O||Z&&$>=Z?1:0)}function $T($,O){return $-(O&&$>=O?1:0)}function t2($,O){return(O+$)*(Math.sign(O)||1)||0}function OT($){return Dz[$8($)]}function e2($){return v7[$8($)]}function $8($){return DZ($.id||v)}function O8($,O,Z,T){let j=A1(Z,T,d0,[],Jz);if(j.timeZone!==void 0){let f=Z.dateFromFields(j),z=o1(j),W=$(j.timeZone);return{epochNanoseconds:s1(O(W),{...f,...z},j.offset!==void 0?E$(j.offset):void 0),timeZone:W}}return{...Z.dateFromFields(j),...p0}}function Z8($,O,Z,T,j,f){let z=A1(Z,j,d0,zz,Jz),W=$(z.timeZone),[J,Y,C]=VO(f),D=Z.dateFromFields(z,_Z(f,J)),X=o1(z,J);return Y0(s1(O(W),{...D,...X},z.offset!==void 0?E$(z.offset):void 0,Y,C),W,T)}function T8($,O,Z){let T=A1($,O,d0,[],D1),j=R(Z);return a(Y1({...$.dateFromFields(T,_Z(Z,j)),...o1(T,j)}))}function Kj($,O,Z,T=[]){let j=A1($,O,d0,T);return $.dateFromFields(j,Z)}function Qj($,O,Z,T){let j=A1($,O,vj,T);return $.yearMonthFromFields(j,Z)}function Vj($,O,Z,T,j=[]){let f=A1($,Z,d0,j);return O&&f.month!==void 0&&f.monthCode===void 0&&f.year===void 0&&(f.year=L$),$.monthDayFromFields(f,T)}function j8($,O){let Z=R(O);return l0(o1(n0($,TT,[],1),Z))}function f8($){let O=n0($,gj);return i(_$({...J0,...O}))}function A1($,O,Z,T=[],j=[]){return n0(O,[...$.fields(Z),...j].sort(),T)}function n0($,O,Z,T=!Z){let j={},f,z=0;for(let W of O){if(W===f)throw RangeError(X7(W));if(W==="constructor"||W==="__proto__")throw RangeError(Ej(W));let J=$[W];if(J!==void 0)z=1,W6[W]&&(J=W6[W](J,W)),j[W]=J;else if(Z){if(Z.includes(W))throw TypeError(Aj(W));j[W]=Xz[W]}f=W}if(T&&!z)throw TypeError(n8(O));return j}function o1($,O){return xZ(LJ({...Xz,...$}),O)}function z8($,O,Z,T,j,f){let z=n(f),{calendar:W,timeZone:J}=Z;return Y0(((Y,C,D,X,U)=>{let F=MO(Y,D,X,d0,Wz,fz),[G,B,Q]=VO(U,2);return s1(C,{...Y.dateFromFields(F,_Z(U,G)),...o1(F,G)},E$(F.offset),B,Q)})($(W),O(J),T,j,z),J,W)}function W8($,O,Z,T,j){let f=n(j);return a(((z,W,J,Y)=>{let C=MO(z,W,J,d0,D1),D=R(Y);return Y1({...z.dateFromFields(C,_Z(Y,D)),...o1(C,D)})})($(O.calendar),Z,T,f))}function J8($,O,Z,T,j){let f=n(j);return((z,W,J,Y)=>{let C=MO(z,W,J,d0);return z.dateFromFields(C,Y)})($(O.calendar),Z,T,f)}function Y8($,O,Z,T,j){let f=n(j);return c1(((z,W,J,Y)=>{let C=MO(z,W,J,vj);return z.yearMonthFromFields(C,Y)})($(O.calendar),Z,T,f))}function C8($,O,Z,T,j){let f=n(j);return((z,W,J,Y)=>{let C=MO(z,W,J,d0);return z.monthDayFromFields(C,Y)})($(O.calendar),Z,T,f)}function X8($,O,Z){return l0(((T,j,f)=>{let z=R(f);return o1({...P0(TT,T),...n0(j,TT)},z)})($,O,Z))}function D8($,O){return i((Z=$,T=O,_$({...Z,...n0(T,gj)})));var Z,T}function MO($,O,Z,T,j=[],f=[]){let z=[...$.fields(T),...j].sort(),W=n0(O,z,f),J=n0(Z,z);return W=$.mergeFields(W,J),n0(W,z,[])}function Ij($,O){let Z=A1($,O,Cz);return $.monthDayFromFields(Z)}function Lj($,O,Z){let T=A1($,O,Yz);return $.yearMonthFromFields(T,Z)}function F8($,O,Z,T,j){O=P0(Z=$.fields(Z),O),T=n0(T,j=$.fields(j),[]);let f=$.mergeFields(O,T);return f=n0(f,[...Z,...j].sort(),[]),$.dateFromFields(f)}function n3($,O){let{era:Z,eraYear:T,year:j}=O,f=OT($);if(Z!==void 0||T!==void 0){if(Z===void 0||T===void 0)throw TypeError(F7);if(!f)throw RangeError(D7);let z=f[Z];if(z===void 0)throw RangeError(G7(Z));let W=t2(T,z);if(j!==void 0&&j!==W)throw RangeError(U7);j=W}else if(j===void 0)throw TypeError(B7(f));return j}function a3($,O,Z,T){let{month:j,monthCode:f}=O;if(f!==void 0){let z=((W,J,Y,C)=>{let D=W.U(Y),[X,U]=r2(J),F=FZ(X,U,D);if(U){let G=e2(W);if(G===void 0)throw RangeError(JO);if(G>0){if(F>G)throw RangeError(JO);if(D===void 0){if(C===1)throw RangeError(JO);F--}}else{if(F!==-G)throw RangeError(JO);if(D===void 0&&C===1)throw RangeError(JO)}}return F})($,f,Z,T);if(j!==void 0&&j!==z)throw RangeError(t8);j=z,T=1}else if(j===void 0)throw TypeError(Q7);return q0("month",j,1,$.L(Z),T)}function j6($,O,Z,T,j){return x0(O,"day",1,$.j(T,Z),j)}function o3($,O,Z,T){let j=0,f=[];for(let z of Z)O[z]!==void 0?j=1:f.push(z);if(Object.assign($,O),j)for(let z of T||f)delete $[z]}function U8($){return z0(R0(IZ(VZ($))))}function G8($,O,Z,T,j=v){return Y0(R0(IZ(VZ(Z))),O(T),$(j))}function B8($,O,Z,T,j=0,f=0,z=0,W=0,J=0,Y=0,C=v){return a(Y1(SZ(c0(F0,M$(eZ,[O,Z,T,j,f,z,W,J,Y])))),$(C))}function K8($,O,Z,T,j=v){return o(V1(l1(c0(F0,{isoYear:O,isoMonth:Z,isoDay:T}))),$(j))}function Q8($,O,Z,T=v,j=1){let f=F0(O),z=F0(Z),W=$(T);return c1(BT(l1({isoYear:f,isoMonth:z,isoDay:F0(j)})),W)}function V8($,O,Z,T=v,j=L$){let f=F0(O),z=F0(Z),W=$(T);return YZ(V1(l1({isoYear:F0(j),isoMonth:f,isoDay:z})),W)}function I8($=0,O=0,Z=0,T=0,j=0,f=0){return l0(xZ(c0(F0,M$(u0,[$,O,Z,T,j,f])),1))}function L8($=0,O=0,Z=0,T=0,j=0,f=0,z=0,W=0,J=0,Y=0){return i(_$(c0(N6,M$(k,[$,O,Z,T,j,f,z,W,J,Y]))))}function Mj($,O,Z=v){return Y0($.epochNanoseconds,O,Z)}function M8($){return z0($.epochNanoseconds)}function Sj($,O){return a(K0(O,$))}function xj($,O){return o(K0(O,$))}function S8($,O,Z){return Lj($(O.calendar),Z)}function x8($,O,Z){return Ij($(O.calendar),Z)}function Nj($,O){return l0(K0(O,$))}function N8($,O,Z,T){let j=((f,z,W,J)=>{let Y=IT(J);return E0(f(z),W,Y)})($,Z,O,T);return Y0(R0(j),Z,O.calendar)}function _8($,O,Z){let T=$(O.calendar);return c1({...O,...Lj(T,Z)})}function A8($,O,Z){return Ij($(O.calendar),Z)}function E8($,O,Z,T,j){let f=$(j.timeZone),z=j.plainTime,W=z!==void 0?O(z):p0;return Y0(E0(Z(f),{...T,...W}),f,T.calendar)}function P8($,O=p0){return a(Y1({...$,...O}))}function H8($,O,Z){return Lj($(O.calendar),Z)}function w8($,O,Z){return Ij($(O.calendar),Z)}function b8($,O,Z,T){return((j,f,z)=>F8(j,f,Yz,J1(z),AO))($(O.calendar),Z,T)}function v8($,O,Z,T){return((j,f,z)=>F8(j,f,Cz,J1(z),rZ))($(O.calendar),Z,T)}function g8($,O,Z,T,j){let f=J1(j),z=O(f.plainDate),W=$(f.timeZone);return Y0(E0(Z(W),{...z,...T}),W,z.calendar)}function R8($,O){return a(Y1({...$,...O}))}function k8($){return z0(R0(V$($,y0)))}function q8($){return z0(R0(V$($,o0)))}function m8($){return z0(R0(IZ(VZ($),t1)))}function y8($){return z0(R0(IZ(VZ($))))}function p8($,O,Z=p0){let T=O.timeZone,j=$(T),f={...K0(O,j),...Z};return Y0(s1(j,f,f.offsetNanoseconds,2),T,O.calendar)}function c8($,O,Z){let T=O.timeZone,j=$(T),f={...K0(O,j),...Z},z=d8(O.calendar,Z.calendar);return Y0(s1(j,f,f.offsetNanoseconds,2),T,z)}function i8($,O=p0){return a({...$,...O})}function h8($,O){return a({...$,...O},d8($.calendar,O.calendar))}function uZ($,O){return{...$,calendar:O}}function l8($,O){return{...$,timeZone:O}}function d8($,O){if($===O)return $;let Z=W0($),T=W0(O);if(Z===T||Z===v)return O;if(T===v)return $;throw RangeError(Hj)}function T7($,O){return(Z)=>Z===v?$:Z===tZ||Z===I$?Object.assign(Object.create($),{id:Z}):Object.assign(Object.create(O),BJ(Z))}function r1($,O,Z){let T=new Set(Z);return(j)=>(((f,z)=>{for(let W of z)if(W in f)return 1;return 0})(j=WT(T,j),$)||Object.assign(j,O),Z&&(j.timeZone=O$,["full","long"].includes(j.timeStyle)&&(j.timeStyle="medium")),j)}function C1($,O=_j){let[Z,,,T]=$;return(j,f=qJ,...z)=>{let W=O(T&&T(...z),j,f,Z),J=W.resolvedOptions();return[W,...j7($,J,z)]}}function _j($,O,Z,T){if(Z=T(Z),$){if(Z.timeZone!==void 0)throw TypeError(H7);Z.timeZone=$}return new E1(O,Z)}function j7($,O,Z){let[,T,j]=$;return Z.map((f)=>(f.calendar&&((z,W,J)=>{if((J||z!==v)&&z!==W)throw RangeError(Hj)})(W0(f.calendar),O.calendar,j),T(f,O)))}function H$($){let O=SO();return x1(O,$.getOffsetNanosecondsFor(O))}function SO(){return V$(Date.now(),o0)}function X1(){return Y6||(Y6=new E1().resolvedOptions().timeZone)}var f7=($,O)=>`Non-integer ${$}: ${O}`,z7=($,O)=>`Non-positive ${$}: ${O}`,W7=($,O)=>`Non-finite ${$}: ${O}`,J7=($)=>`Cannot convert bigint to ${$}`,Y7=($)=>`Invalid bigint: ${$}`,C7="Cannot convert Symbol to string",u8="Invalid object",s8=($,O,Z,T,j)=>j?s8($,j[O],j[Z],j[T]):xO($,O)+`; must be between ${Z}-${T}`,xO=($,O)=>`Invalid ${$}: ${O}`,Aj=($)=>`Missing ${$}`,Ej=($)=>`Invalid field ${$}`,X7=($)=>`Duplicate field ${$}`,n8=($)=>"No valid fields: "+$.join(),a8="Invalid bag",o8=($,O,Z)=>xO($,O)+"; must be "+Object.keys(Z).join(),r8="Cannot use valueOf",Pj="Invalid calling context",D7="Forbidden era/eraYear",F7="Mismatching era/eraYear",U7="Mismatching year/eraYear",G7=($)=>`Invalid era: ${$}`,B7=($)=>"Missing year"+($?"/era/eraYear":""),K7=($)=>`Invalid monthCode: ${$}`,t8="Mismatching month/monthCode",Q7="Missing month/monthCode",f6="Cannot guess year",JO="Invalid leap month",e8="Invalid protocol",NO="Invalid protocol results",Hj="Mismatching Calendars",V7=($)=>`Invalid Calendar: ${$}`,$z="Mismatching TimeZones",I7="Forbidden ICU TimeZone",L7="Out-of-bounds offset",M7="Out-of-bounds TimeZone gap",S7="Invalid TimeZone offset",x7="Ambiguous offset",sZ="Out-of-bounds date",N7="Out-of-bounds duration",_7="Cannot mix duration signs",nZ="Missing relativeTo",A7="Cannot use large units",E7="Required smallestUnit or largestUnit",P7="smallestUnit > largestUnit",N0=($)=>`Cannot parse: ${$}`,W1=($)=>`Invalid substring: ${$}`,Oz=($)=>`Cannot format ${$}`,Zz="Mismatching types for formatting",H7="Cannot specify TimeZone",Tz=b(BO,($,O)=>O),w$=b(BO,($,O,Z)=>Z),m0=b(zZ,2),ZT={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},_O=Object.keys(ZT),_0=86400000,jz=1000,t1=1000,o0=1e6,y0=1e9,aZ=60000000000,oZ=3600000000000,m=86400000000000,a0=[1,t1,o0,y0,aZ,oZ,m],D1=_O.slice(0,6),TT=KO(D1),fz=["offset"],zz=["timeZone"],Wz=D1.concat(fz),Jz=Wz.concat(zz),jT=["era","eraYear"],w7=jT.concat(["year"]),rZ=["year"],wj=["monthCode"],bj=["month"].concat(wj),AO=["day"],vj=bj.concat(rZ),Yz=wj.concat(rZ),d0=AO.concat(vj),b7=AO.concat(bj),Cz=AO.concat(wj),Xz=w$(D1,0),v="iso8601",tZ="gregory",I$="japanese",Dz={[tZ]:{bce:-1,ce:0},[I$]:{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}},v7={chinese:13,dangi:13,hebrew:-6},h=b(QZ,"string"),Fz=b(QZ,"boolean"),g7=b(QZ,"number"),Uz=b(QZ,"function"),k=_O.map(($)=>$+"s"),gj=KO(k),R7=k.slice(0,6),Gz=k.slice(6),k7=Gz.slice(1),q7=Tz(k),J0=w$(k,0),Rj=w$(R7,0),kj=b(U6,k),u0=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],qj=["isoDay","isoMonth","isoYear"],eZ=u0.concat(qj),mj=KO(qj),Bz=KO(u0),Kz=KO(eZ),p0=w$(Bz,0),m7=b(U6,eZ),E1=Intl.DateTimeFormat,Qz="en-GB",yj=1e8,y7=yj*_0,p7=[yj,0],c7=[-yj,0],UO=275760,GO=-271821,i7=1970,L$=1972,f1=12,h7=S$(1868,9,8),l7=A0(l5,WeakMap),UZ="smallestUnit",fT="unit",CO="roundingIncrement",r3="fractionalSecondDigits",Vz="relativeTo",Iz={constrain:0,reject:1},d7=Object.keys(Iz),u7={compatible:0,reject:1,earlier:2,later:3},s7={reject:0,use:1,prefer:2,ignore:3},n7={auto:0,never:1,critical:2,always:3},a7={auto:0,never:1,critical:2},o7={auto:0,never:1},r7={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},EO=b(_T,UZ),pj=b(_T,"largestUnit"),t7=b(_T,fT),Lz=b(d1,"overflow",Iz),Mz=b(d1,"disambiguation",u7),e7=b(d1,"offset",s7),cj=b(d1,"calendarName",n7),$J=b(d1,"timeZoneName",a7),OJ=b(d1,"offset",o7),PO=b(d1,"roundingMode",r7),b$="PlainYearMonth",v$="PlainMonthDay",e1="PlainDate",$$="PlainDateTime",$3="PlainTime",F1="ZonedDateTime",O3="Instant",Z3="Duration",ZJ=[Math.floor,($)=>$Z($)?Math.floor($):Math.round($),Math.ceil,($)=>$Z($)?Math.ceil($):Math.round($),Math.trunc,($)=>$Z($)?Math.trunc($)||0:Math.round($),($)=>$<0?Math.floor($):Math.ceil($),($)=>Math.sign($)*Math.round(Math.abs($))||0,($)=>$Z($)?($=Math.trunc($)||0)+$%2:Math.round($)],O$="UTC",jZ=5184000,TJ=JZ(1847),jJ=JZ(new Date().getUTCFullYear()+10),fJ=/0+$/,K0=A0(o5,WeakMap),z6=4294967295,T3=A0(($)=>{let O=fj($);return typeof O=="object"?new xz(O):new Sz(O||0)});class Sz{constructor($){this.v=$}getOffsetNanosecondsFor(){return this.v}getPossibleInstantsFor($){return[KT($,this.v)]}l(){}}class xz{constructor($){this.$=((O)=>{function Z(J){let Y=t3(J,z,W),[C,D]=$6(Y),X=j(C),U=j(D);return X===U?X:T(f(C,D),X,U,J)}function T(J,Y,C,D){let X,U;for(;(D===void 0||(X=D<J[0]?Y:D>=J[1]?C:void 0)===void 0)&&(U=J[1]-J[0]);){let F=J[0]+Math.floor(U/2);O(F)===C?J[1]=F:J[0]=F+1}return X}let j=A0(O),f=A0(r5),z=TJ,W=jJ;return{G(J){let Y=Z(J-86400),C=Z(J+86400),D=J-Y,X=J-C;if(Y===C)return[D];let U=Z(D);return U===Z(X)?[J-U]:Y>C?[D,X]:[]},V:Z,l(J,Y){let C=t3(J,z,W),[D,X]=$6(C),U=jZ*Y,F=Y<0?()=>X>z||(z=C,0):()=>D<W||(W=C,0);for(;F();){let G=j(D),B=j(X);if(G!==B){let Q=f(D,X);T(Q,G,B);let L=Q[0];if((Q1(L,J)||1)===Y)return L}D+=U,X+=U}}}})(((O)=>(Z)=>{let T=GT(O,Z*jz);return JZ(s2(T),parseInt(T.month),parseInt(T.day),parseInt(T.hour),parseInt(T.minute),parseInt(T.second))-Z})($))}getOffsetNanosecondsFor($){return this.$.V(E6($))*y0}getPossibleInstantsFor($){let[O,Z]=[JZ((T=$).isoYear,T.isoMonth,T.isoDay,T.isoHour,T.isoMinute,T.isoSecond),T.isoMillisecond*o0+T.isoMicrosecond*t1+T.isoNanosecond];var T;return this.$.G(O).map((j)=>R0(Q$(V$(j,y0),Z)))}l($,O){let[Z,T]=P6($),j=this.$.l(Z+(O>0||T?1:0),O);if(j!==void 0)return V$(j,y0)}}var ij="([+\u2212-])",fZ="(?:[.,](\\d{1,9}))?",Nz=`(?:(?:${ij}(\\d{6}))|(\\d{4}))-?(\\d{2})`,hj="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+fZ+")?)?",lj=ij+hj,zJ=Nz+"-?(\\d{2})(?:[T ]"+hj+"(Z|"+lj+")?)?",_z="\\[(!?)([^\\]]*)\\]",j3=`((?:${_z}){0,9})`,WJ=P$(Nz+j3),JJ=P$("(?:--)?(\\d{2})-?(\\d{2})"+j3),YJ=P$(zJ+j3),CJ=P$("T?"+hj+"(?:"+lj+")?"+j3),XJ=P$(lj),DJ=new RegExp(_z,"g"),FJ=P$(`${ij}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${fZ}H)?(?:(\\d+)${fZ}M)?(?:(\\d+)${fZ}S)?)?`),UJ=A0(($)=>new E1(Qz,{timeZone:$,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),GJ=/^(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$/,BJ=A0($7),dj=A0(($)=>new E1(Qz,{calendar:$,timeZone:O$,era:"short",year:"numeric",month:"short",day:"numeric"})),KJ=/^M(\d{2})(L?)$/,QJ={era:WZ,eraYear:F0,year:F0,month:o4,monthCode:WZ,day:o4},VJ=w$(D1,F0),IJ=w$(k,N6),W6=Object.assign({},QJ,VJ,IJ,{offset:WZ}),LJ=b(h5,D1,u0),J6={dateAdd($,O,Z){let T=R(Z),j,{years:f,months:z,weeks:W,days:J}=O;if(J+=j0(O,5)[0],f||z)j=((Y,C,D,X,U)=>{let[F,G,B]=Y.h(C);if(D){let[Q,L]=Y.I(F,G);F+=D,G=FZ(Q,L,Y.U(F)),G=q0("month",G,1,Y.L(F),U)}return X&&([F,G]=Y._(F,G,X)),B=q0("day",B,1,Y.j(F,G),U),Y.q(F,G,B)})(this,$,f,z,T);else{if(!W&&!J)return $;j=B0($)}return j+=(7*W+J)*_0,V1(MZ(j))},dateUntil($,O,Z){if(Z<=7){let J=0,Y=d2({...$,...p0},{...O,...p0});return Z===7&&([J,Y]=L1(Y,7)),{...J0,weeks:J,days:Y}}let T=this.h($),j=this.h(O),[f,z,W]=((J,Y,C,D,X,U,F)=>{let G=X-Y,B=U-C,Q=F-D;if(G||B){let L=Math.sign(G||B),V=J.j(X,U),N=0;if(Math.sign(Q)===-L){let A=V;[X,U]=J._(X,U,-L),G=X-Y,B=U-C,V=J.j(X,U),N=L<0?-A:V}if(Q=F-Math.min(D,V)+N,G){let[A,I]=J.I(Y,C),[M,E]=J.I(X,U);if(B=M-A||Number(E)-Number(I),Math.sign(B)===-L){let P=L<0&&-J.L(X);G=(X-=L)-Y,B=U-FZ(A,I,J.U(X))+(P||J.L(X))}}}return[G,B,Q]})(this,...T,...j);return Z===8&&(z+=this.J(f,T[0]),f=0),{...J0,years:f,months:z,days:W}},dateFromFields($,O){let Z=R(O),T=n3(this,$),j=a3(this,$,T,Z),f=j6(this,$,j,T,Z);return o(V1(this.P(T,j,f)),this.id||v)},yearMonthFromFields($,O){let Z=R(O),T=n3(this,$),j=a3(this,$,T,Z);return c1(BT(this.P(T,j,1)),this.id||v)},monthDayFromFields($,O){let Z=R(O),T=!this.id,{monthCode:j,year:f,month:z}=$,W,J,Y,C,D;if(j!==void 0){[W,J]=r2(j),D=C6($,"day");let X=this.N(W,J,D);if(!X)throw RangeError(f6);if([Y,C]=X,z!==void 0&&z!==C)throw RangeError(t8);T&&(C=q0("month",C,1,f1,1),D=q0("day",D,1,QT(f!==void 0?f:Y,C),Z))}else{Y=f===void 0&&T?L$:n3(this,$),C=a3(this,$,Y,Z),D=j6(this,$,C,Y,Z);let X=this.U(Y);J=C===X,W=$T(C,X);let U=this.N(W,J,D);if(!U)throw RangeError(f6);[Y,C]=U}return YZ(V1(this.P(Y,C,D)),this.id||v)},fields($){return OT(this)&&$.includes("year")?[...$,...jT]:$},mergeFields($,O){let Z=Object.assign(Object.create(null),$);return o3(Z,O,bj),OT(this)&&(o3(Z,O,w7),this.id===I$&&o3(Z,O,b7,jT)),Z},inLeapYear($){let[O]=this.h($);return this.K(O)},monthsInYear($){let[O]=this.h($);return this.L(O)},daysInMonth($){let[O,Z]=this.h($);return this.j(O,Z)},daysInYear($){let[O]=this.h($);return this.X(O)},dayOfYear:Bj,era($){return this.ee($)[0]},eraYear($){return this.ee($)[1]},monthCode($){let[O,Z]=this.h($),[T,j]=this.I(O,Z);return((f,z)=>"M"+m0(f)+(z?"L":""))(T,j)},dayOfWeek:g6,daysInWeek(){return 7}},MJ={dayOfYear:Bj,h:w6,q:S$},SJ=Object.assign({},MJ,{weekOfYear:a2,yearOfWeek:o2,R($){function O(U){return(7-U<T?7:0)-U}function Z(U){let F=v6(X+U),G=U||1,B=O(YO(J+F*G,7));return C=(F+(B-Y)*G)/7}let T=this.id?1:4,j=g6($),f=this.dayOfYear($),z=YO(j-1,7),W=f-1,J=YO(z-W,7),Y=O(J),C,D=Math.floor((W-Y)/7)+1,X=$.isoYear;return D?D>Z(0)&&(D=1,X++):(D=Z(-1),X--),[D,X,C]}}),xJ={dayOfYear:Bj,h:e3,q:FO,weekOfYear:a2,yearOfWeek:o2,R(){return[]}},g$=T7(Object.assign({},J6,SJ,{h:w6,ee($){return this.id===tZ?R6($):this.id===I$?l7($):[]},I:($,O)=>[O,0],N($,O){if(!O)return[L$,$]},K:VT,U(){},L:b6,J:($)=>$*f1,j:QT,X:v6,P:($,O,Z)=>({isoYear:$,isoMonth:O,isoDay:Z}),q:S$,_:($,O,Z)=>($+=BZ(Z,f1),(O+=YT(Z,f1))<1?($--,O+=f1):O>f1&&($++,O-=f1),[$,O]),year($){return $.isoYear},month($){return $.isoMonth},day:($)=>$.isoDay}),Object.assign({},J6,xJ,{h:e3,ee($){let O=this.O($);return[O.era,O.eraYear]},I($,O){let Z=OZ.call(this,$);return[$T(O,Z),Z===O]},N($,O,Z){let[T,j,f]=e3.call(this,{isoYear:L$,isoMonth:f1,isoDay:31}),z=OZ.call(this,T),W=j===z;(Q1($,$T(j,z))||Q1(Number(O),Number(W))||Q1(Z,f))===1&&T--;for(let J=0;J<100;J++){let Y=T-J,C=OZ.call(this,Y),D=FZ($,O,C);if(O===(D===C)&&Z<=Z6.call(this,Y,D))return[Y,D]}},K($){let O=ZZ.call(this,$);return O>ZZ.call(this,$-1)&&O>ZZ.call(this,$+1)},U:OZ,L:TZ,J($,O){let Z=O+$,T=Math.sign($),j=T<0?-1:0,f=0;for(let z=O;z!==Z;z+=T)f+=TZ.call(this,z+j);return f},j:Z6,X:ZZ,P($,O,Z){return MZ(FO.call(this,$,O,Z))},q:FO,_($,O,Z){if(Z){if(O+=Z,!Number.isSafeInteger(O))throw RangeError(sZ);if(Z<0)for(;O<1;)O+=TZ.call(this,--$);else{let T;for(;O>(T=TZ.call(this,$));)O-=T,$++}}return[$,O]},year($){return this.O($).year},month($){let{year:O,F:Z}=this.O($),{C:T}=this.B(O);return T[Z]+1},day($){return this.O($).day}})),I1="numeric",R$=["timeZoneName"],Az={month:I1,day:I1},uj={year:I1,month:I1},sj=Object.assign({},uj,{day:I1}),nj={hour:I1,minute:I1,second:I1},aj=Object.assign({},sj,nj),NJ=Object.assign({},aj,{timeZoneName:"short"}),_J=Object.keys(uj),AJ=Object.keys(Az),EJ=Object.keys(sj),PJ=Object.keys(nj),oj=["dateStyle"],HJ=_J.concat(oj),wJ=AJ.concat(oj),rj=EJ.concat(oj,["weekday"]),HO=PJ.concat(["dayPeriod","timeStyle"]),tj=rj.concat(HO),bJ=tj.concat(R$),vJ=R$.concat(HO),gJ=R$.concat(rj),RJ=R$.concat(["day","weekday"],HO),kJ=R$.concat(["year","weekday"],HO),qJ={},ej=[r1(tj,aj),AZ],Ez=[r1(bJ,NJ),AZ,0,($,O)=>{let Z=W0($.timeZone);if(O&&W0(O.timeZone)!==Z)throw RangeError($z);return Z}],$f=[r1(tj,aj,R$),B0],Of=[r1(rj,sj,vJ),B0],Zf=[r1(HO,nj,gJ),($)=>M1($)/o0],Tf=[r1(HJ,uj,RJ),B0,1],jf=[r1(wJ,Az,kJ),B0,1],Y6;function e0($,O,Z,T,j){function f(...J){if(!(this instanceof f))throw TypeError(Pj);bz(this,O(...J))}function z(J,Y){return Object.defineProperties(function(...C){return J.call(this,W(this),...C)},zT(Y))}function W(J){let Y=D0(J);if(!Y||Y.branding!==$)throw TypeError(Pj);return Y}return Object.defineProperties(f.prototype,{...X6(c0(z,Z)),...h1(c0(z,T)),...GZ("Temporal."+$)}),Object.defineProperties(f,{...h1(j),...zT($)}),[f,(J)=>{let Y=Object.create(f.prototype);return bz(Y,J),Y},W]}function Rz($){return $=$.concat("id").sort(),(O)=>{if(!D6(O,$))throw TypeError(e8);return O}}function y$($){if(D0($)||$.calendar!==void 0||$.timeZone!==void 0)throw TypeError(a8);return $}function f3($,O){let Z={};for(let T in $)Z[T]=({o:j},f)=>{let z=D0(f)||{},{branding:W}=z,J=W===e1||O.includes(W)?z:I0(f);return j[T](J)};return Z}function Wf($){let O={};for(let Z in $)O[Z]=(T)=>{let{calendar:j}=T;return(f=j,typeof f=="string"?g$(f):(z=f,Object.assign(Object.create(eJ),{i:z})))[Z](T);var f,z};return O}function v1(){throw TypeError(r8)}function bO({calendar:$}){return typeof $=="string"?new Bf($):$}function Pz($,O){if(O=n(O),f0($)){let T=D0($);if(T&&T.branding===v$)return R(O),T;let j=mz($);return Vj(D3(j||v),!j,$,O)}let Z=L2(g$,$);return R(O),Z}function kz($,O,Z){return T=O.call($,V0(z0(Z))),pT(QO(T));var T}function z3($,O=iz){let Z=Object.keys(O).sort(),T={};for(let j of Z)T[j]=b(O[j],$,Uz($[j]));return T}function y($,O){return typeof $=="string"?T3($):z3($,O)}function t($){return y($,zf)}function r0($){if(f0($)){let O=D0($);if(O)switch(O.branding){case O3:return O;case F1:return z0(O.epochNanoseconds)}}return B2($)}function Hz($,O,Z){let T=O.l(r0(Z).epochNanoseconds,$);return T?V0(z0(T)):null}function c($){return f0($)?(D0($)||{}).timeZone||fY($):((O)=>pZ(N2(h(O))))($)}function P1($,O){if(f0($)){let Z=D0($)||{};switch(Z.branding){case $3:return R(O),Z;case $$:return R(O),l0(Z);case F1:return R(O),Nj(t,Z)}return j8($,O)}return R(O),M2($)}function Jf($){return $===void 0?void 0:P1($)}function k$($,O){if(O=n(O),f0($)){let T=D0($);return T&&T.branding===b$?(R(O),T):Qj(C3(vO($)),$,O)}let Z=I2(g$,$);return R(O),Z}function H1($,O){if(O=n(O),f0($)){let T=D0($)||{};switch(T.branding){case $$:return R(O),T;case e1:return R(O),a({...T,...p0});case F1:return R(O),Sj(t,T)}return T8(X3(vO($)),$,O)}let Z=V2($);return R(O),Z}function I0($,O){if(O=n(O),f0($)){let T=D0($)||{};switch(T.branding){case e1:return R(O),T;case $$:return R(O),o(T);case F1:return R(O),xj(t,T)}return Kj(X3(vO($)),$,O)}let Z=mZ($);return R(O),Z}function qz($,O,Z){return i0(O.call($,d(o(Z,$))))}function $1($){return(O)=>typeof O=="string"?g$(O):((Z,T)=>{let j=Object.keys(T).sort(),f={};for(let z of j)f[z]=b(T[z],Z,Z[z]);return f})(O,$)}function l($){if(f0($)){let O=D0($);return O&&O.branding===Z3?O:f8($)}return S2($)}function wO($){if($!==void 0){if(f0($)){let O=D0($)||{};switch(O.branding){case F1:case e1:return O;case $$:return o(O)}let Z=vO($);return{...O8(c,y,X3(Z),$),calendar:Z}}return K2($)}}function vO($){return mz($)||v}function mz($){let{calendar:O}=$;if(O!==void 0)return X0(O)}function X0($){return f0($)?(D0($)||{}).calendar||IY($):((O)=>LO(x2(h(O))))($)}function q$($,O){if(O=n(O),f0($)){let Z=D0($);if(Z&&Z.branding===F1)return VO(O),Z;let T=vO($);return Z8(c,y,X3(T),T,$,O)}return Q2($,O)}function wz($){return c0((O)=>(Z)=>O(ff(Z)),$)}function ff($){return K0($,t)}function mJ(){let $=E1.prototype,O=Object.getOwnPropertyDescriptors($),Z=Object.getOwnPropertyDescriptors(E1),T=function(j,f={}){if(!(this instanceof T))return new T(j,f);Kf.set(this,((z,W={})=>{let J=new E1(z,W),Y=J.resolvedOptions(),C=Y.locale,D=P0(Object.keys(W),Y),X=A0(cJ),U=(...F)=>{let G,B=F.map((Q,L)=>{let V=D0(Q),N=(V||{}).branding;if(L&&G&&G!==N)throw TypeError(Zz);return G=N,V});return G?X(G)(C,D,...B):[J,...F]};return U.u=J,U})(j,f))};for(let j in O){let f=O[j],z=j.startsWith("format")&&yJ(j);typeof f.value=="function"?f.value=j==="constructor"?T:z||pJ(j):z&&(f.get=function(){return z.bind(this)})}return Z.prototype.value=Object.create($,O),Object.defineProperties(T,Z),T}function yJ($){return function(...O){let Z=Kf.get(this),[T,...j]=Z(...O);return T[$](...j)}}function pJ($){return function(...O){return Kf.get(this).u[$](...O)}}function cJ($){let O=iJ[$];if(!O)throw TypeError(Oz($));return C1(O,A0(_j))}var iJ={Instant:ej,PlainDateTime:$f,PlainDate:Of,PlainTime:Zf,PlainYearMonth:Tf,PlainMonthDay:jf},hJ=C1(ej),lJ=C1(Ez),dJ=C1($f),uJ=C1(Of),sJ=C1(Zf),nJ=C1(Tf),aJ=C1(jf),Yf={era:V6,eraYear:CT,year:QO,month:i0,daysInMonth:i0,daysInYear:i0,inLeapYear:Fz,monthsInYear:i0},J3={monthCode:h},Cf={day:i0},yz={dayOfWeek:i0,dayOfYear:i0,weekOfYear:I6,yearOfWeek:CT,daysInWeek:i0},pz=Object.assign({},Yf,J3,Cf,yz),W3=new WeakMap,D0=W3.get.bind(W3),bz=W3.set.bind(W3),oJ={...f3(Yf,[b$]),...f3(yz,[]),...f3(J3,[b$,v$]),...f3(Cf,[v$])},Xf=Wf(pz),rJ=Wf({...Yf,...J3}),tJ=Wf({...J3,...Cf}),gO={calendarId:($)=>W0($.calendar)},eJ=c0(($,O)=>function(Z){let{i:T}=this;return $(T[O](d(o(Z,T))))},pz),$Y=BO(($)=>(O)=>O[$],k.concat("sign")),Df=BO(($,O)=>(Z)=>Z[u0[O]],D1),cz={epochSeconds:i6,epochMilliseconds:AZ,epochMicroseconds:h6,epochNanoseconds:l6},RO=b(WT,new Set(["branding"])),[OY,m$,ZY]=e0(v$,b(V8,X0),{...gO,...tJ},{getISOFields:RO,getCalendar:bO,with($,O,Z){return m$(C8(KY,$,this,y$(O),Z))},equals:($,O)=>y2($,Pz(O)),toPlainDate($,O){return d(v8(kO,$,this,O))},toLocaleString($,O,Z){let[T,j]=aJ(O,Z,$);return T.format(j)},toString:RT,toJSON:($)=>RT($),valueOf:v1},{from:($,O)=>m$(Pz($,O))}),iz={getOffsetNanosecondsFor:kz,getPossibleInstantsFor($,O,Z){let T=[...O.call($,C0(a(Z,v)))].map((f)=>jY(f).epochNanoseconds),j=T.length;return j>1&&(T.sort(G0),cT(g0(v0(T[0],T[j-1])))),T}},zf={getOffsetNanosecondsFor:kz},[TY,V0,jY]=e0(O3,U8,cz,{add:($,O)=>V0(iT(0,$,l(O))),subtract:($,O)=>V0(iT(1,$,l(O))),until:($,O,Z)=>p(Yj(0,$,r0(O),Z)),since:($,O,Z)=>p(Yj(1,$,r0(O),Z)),round:($,O)=>V0(s6($,O)),equals:($,O)=>g2($,r0(O)),toZonedDateTime($,O){let Z=J1(O);return r(Mj($,c(Z.timeZone),X0(Z.calendar)))},toZonedDateTimeISO:($,O)=>r(Mj($,c(O))),toLocaleString($,O,Z){let[T,j]=hJ(O,Z,$);return T.format(j)},toString:($,O)=>HT(c,t,$,O),toJSON:($)=>HT(c,t,$),valueOf:v1},{from:($)=>V0(r0($)),fromEpochSeconds:($)=>V0(k8($)),fromEpochMilliseconds:($)=>V0(q8($)),fromEpochMicroseconds:($)=>V0(m8($)),fromEpochNanoseconds:($)=>V0(y8($)),compare:($,O)=>zj(r0($),r0(O))}),[Y3,H9]=e0("TimeZone",($)=>{let O=b2($);return{branding:"TimeZone",id:O,o:T3(O)}},{id:($)=>$.id},{getPossibleInstantsFor:({o:$},O)=>$.getPossibleInstantsFor(H1(O)).map((Z)=>V0(z0(Z))),getOffsetNanosecondsFor:({o:$},O)=>$.getOffsetNanosecondsFor(r0(O).epochNanoseconds),getOffsetStringFor($,O){let Z=r0(O).epochNanoseconds,T=z3(this,zf).getOffsetNanosecondsFor(Z);return u1(T)},getPlainDateTimeFor($,O,Z=v){let T=r0(O).epochNanoseconds,j=z3(this,zf).getOffsetNanosecondsFor(T);return C0(a(x1(T,j),X0(Z)))},getInstantFor($,O,Z){let T=H1(O),j=IT(Z),f=z3(this);return V0(z0(E0(f,T,j)))},getNextTransition:({o:$},O)=>Hz(1,$,O),getPreviousTransition:({o:$},O)=>Hz(-1,$,O),equals($,O){return!!iZ(this,c(O))},toString:($)=>$.id,toJSON:($)=>$.id},{from($){let O=c($);return typeof O=="string"?new Y3(O):O}}),fY=Rz(Object.keys(iz)),[zY,w1]=e0($3,I8,Df,{getISOFields:RO,with($,O,Z){return w1(X8(this,y$(O),Z))},add:($,O)=>w1(sT(0,$,l(O))),subtract:($,O)=>w1(sT(1,$,l(O))),until:($,O,Z)=>p(Uj(0,$,P1(O),Z)),since:($,O,Z)=>p(Uj(1,$,P1(O),Z)),round:($,O)=>w1(o6($,O)),equals:($,O)=>p2($,P1(O)),toZonedDateTime:($,O)=>r(g8(c,I0,y,$,O)),toPlainDateTime:($,O)=>C0(R8($,I0(O))),toLocaleString($,O,Z){let[T,j]=sJ(O,Z,$);return T.format(j)},toString:kT,toJSON:($)=>kT($),valueOf:v1},{from:($,O)=>w1(P1($,O)),compare:($,O)=>cZ(P1($),P1(O))}),[WY,b1,JY]=e0(b$,b(Q8,X0),{...gO,...rJ},{getISOFields:RO,getCalendar:bO,with($,O,Z){return b1(Y8(BY,$,this,y$(O),Z))},add:($,O,Z)=>b1(uT(vz,0,$,l(O),Z)),subtract:($,O,Z)=>b1(uT(vz,1,$,l(O),Z)),until:($,O,Z)=>p(Fj(gz,0,$,k$(O),Z)),since:($,O,Z)=>p(Fj(gz,1,$,k$(O),Z)),equals:($,O)=>m2($,k$(O)),toPlainDate($,O){return d(b8(kO,$,this,O))},toLocaleString($,O,Z){let[T,j]=nJ(O,Z,$);return T.format(j)},toString:gT,toJSON:($)=>gT($),valueOf:v1},{from:($,O)=>b1(k$($,O)),compare:($,O)=>a1(k$($),k$(O))}),[YY,C0]=e0($$,b(B8,X0),{...gO,...Xf,...Df},{getISOFields:RO,getCalendar:bO,with($,O,Z){return C0(W8(kO,$,this,y$(O),Z))},withCalendar:($,O)=>C0(uZ($,X0(O))),withPlainDate:($,O)=>C0(h8($,I0(O))),withPlainTime:($,O)=>C0(i8($,Jf(O))),add:($,O,Z)=>C0(lT(Z$,0,$,l(O),Z)),subtract:($,O,Z)=>C0(lT(Z$,1,$,l(O),Z)),until:($,O,Z)=>p(Xj(t0,0,$,H1(O),Z)),since:($,O,Z)=>p(Xj(t0,1,$,H1(O),Z)),round:($,O)=>C0(a6($,O)),equals:($,O)=>k2($,H1(O)),toZonedDateTime:($,O,Z)=>r(N8(y,$,c(O),Z)),toPlainDate:($)=>d(o($)),toPlainTime:($)=>w1(l0($)),toPlainYearMonth($){return b1(_8(C3,$,this))},toPlainMonthDay($){return m$(A8(D3,$,this))},toLocaleString($,O,Z){let[T,j]=dJ(O,Z,$);return T.format(j)},toString:bT,toJSON:($)=>bT($),valueOf:v1},{from:($,O)=>C0(H1($,O)),compare:($,O)=>Jj(H1($),H1(O))}),[CY,d,hz]=e0(e1,b(K8,X0),{...gO,...Xf},{getISOFields:RO,getCalendar:bO,with($,O,Z){return d(J8(kO,$,this,y$(O),Z))},withCalendar:($,O)=>d(uZ($,X0(O))),add:($,O,Z)=>d(dT(Z$,0,$,l(O),Z)),subtract:($,O,Z)=>d(dT(Z$,1,$,l(O),Z)),until:($,O,Z)=>p(Dj(t0,0,$,I0(O),Z)),since:($,O,Z)=>p(Dj(t0,1,$,I0(O),Z)),equals:($,O)=>q2($,I0(O)),toZonedDateTime($,O){let Z=!f0(O)||O instanceof Y3?{timeZone:O}:O;return r(E8(c,P1,y,$,Z))},toPlainDateTime:($,O)=>C0(P8($,Jf(O))),toPlainYearMonth($){return b1(H8(C3,$,this))},toPlainMonthDay($){return m$(w8(D3,$,this))},toLocaleString($,O,Z){let[T,j]=uJ(O,Z,$);return T.format(j)},toString:vT,toJSON:($)=>vT($),valueOf:v1},{from:($,O)=>d(I0($,O)),compare:($,O)=>a1(I0($),I0(O))}),Ff={fields($,O,Z){return[...O.call($,Z)]}},lz=Object.assign({dateFromFields($,O,Z,T){return hz(O.call($,Object.assign(Object.create(null),Z),T))}},Ff),dz=Object.assign({yearMonthFromFields($,O,Z,T){return JY(O.call($,Object.assign(Object.create(null),Z),T))}},Ff),uz=Object.assign({monthDayFromFields($,O,Z,T){return ZY(O.call($,Object.assign(Object.create(null),Z),T))}},Ff),Uf={mergeFields($,O,Z,T){return J1(O.call($,Object.assign(Object.create(null),Z),Object.assign(Object.create(null),T)))}},XY=Object.assign({},lz,Uf),DY=Object.assign({},dz,Uf),FY=Object.assign({},uz,Uf),Gf={dateAdd($,O,Z,T,j){return hz(O.call($,d(o(Z,$)),p(i(T)),j))}},sz=Object.assign({},Gf,{dateUntil($,O,Z,T,j,f){return VY(O.call($,d(o(Z,$)),d(o(T,$)),Object.assign(Object.create(null),f,{largestUnit:_O[j]})))}}),UY=Object.assign({},Gf,{day:qz}),GY=Object.assign({},sz,{day:qz}),C3=$1(dz),X3=$1(lz),D3=$1(uz),BY=$1(DY),kO=$1(XY),KY=$1(FY),Z$=$1(Gf),t0=$1(sz),vz=$1(UY),gz=$1(GY),[QY,p,VY]=e0(Z3,L8,{...$Y,blank:F2},{with:($,O)=>p(D8($,O)),negated:($)=>p(kZ($)),abs:($)=>p(D2($)),add:($,O,Z)=>p(tT(wO,t0,y,0,$,l(O),Z)),subtract:($,O,Z)=>p(tT(wO,t0,y,1,$,l(O),Z)),round:($,O)=>p(X2(wO,t0,y,$,O)),total:($,O)=>u6(wO,t0,y,$,O),toLocaleString($,O,Z){return Intl.DurationFormat?new Intl.DurationFormat(O,Z).format(this):wZ($)},toString:wZ,toJSON:($)=>wZ($),valueOf:v1},{from:($)=>p(l($)),compare:($,O,Z)=>v2(wO,Z$,y,l($),l(O),Z)}),nz={toString:($)=>$.id,toJSON:($)=>$.id,...oJ,dateAdd:({id:$,o:O},Z,T,j)=>d(o(O.dateAdd(I0(Z),l(T),j),$)),dateUntil:({o:$},O,Z,T)=>p(i($.dateUntil(I0(O),I0(Z),q6(T)))),dateFromFields:({id:$,o:O},Z,T)=>d(Kj(O,Z,T,Q6($))),yearMonthFromFields:({id:$,o:O},Z,T)=>b1(Qj(O,Z,T,B6($))),monthDayFromFields:({id:$,o:O},Z,T)=>m$(Vj(O,0,Z,T,K6($))),fields({o:$},O){let Z=new Set(d0),T=[];for(let j of O){if(h(j),!Z.has(j))throw RangeError(Ej(j));Z.delete(j),T.push(j)}return $.fields(T)},mergeFields:({o:$},O,Z)=>$.mergeFields(JT(XT(O)),JT(XT(Z)))},[Bf]=e0("Calendar",($)=>{let O=n2($);return{branding:"Calendar",id:O,o:g$(O)}},{id:($)=>$.id},nz,{from($){let O=X0($);return typeof O=="string"?new Bf(O):O}}),IY=Rz(Object.keys(nz).slice(4)),[LY,r]=e0(F1,b(G8,X0,c),{...cz,...gO,...wz(Xf),...wz(Df),offset:($)=>u1(ff($).offsetNanoseconds),offsetNanoseconds:($)=>ff($).offsetNanoseconds,timeZoneId:($)=>W0($.timeZone),hoursInDay:($)=>r6(y,$)},{getISOFields:($)=>Y2(t,$),getCalendar:bO,getTimeZone:({timeZone:$})=>typeof $=="string"?new Y3($):$,with($,O,Z){return r(z8(kO,y,$,this,y$(O),Z))},withCalendar:($,O)=>r(uZ($,X0(O))),withTimeZone:($,O)=>r(l8($,c(O))),withPlainDate:($,O)=>r(c8(y,$,I0(O))),withPlainTime:($,O)=>r(p8(y,$,Jf(O))),add:($,O,Z)=>r(hT(Z$,y,0,$,l(O),Z)),subtract:($,O,Z)=>r(hT(Z$,y,1,$,l(O),Z)),until:($,O,Z)=>p(i(Cj(t0,y,0,$,q$(O),Z))),since:($,O,Z)=>p(i(Cj(t0,y,1,$,q$(O),Z))),round:($,O)=>r(n6(y,$,O)),startOfDay:($)=>r(t6(y,$)),equals:($,O)=>R2($,q$(O)),toInstant:($)=>V0(M8($)),toPlainDateTime:($)=>C0(Sj(t,$)),toPlainDate:($)=>d(xj(t,$)),toPlainTime:($)=>w1(Nj(t,$)),toPlainYearMonth($){return b1(S8(C3,$,this))},toPlainMonthDay($){return m$(x8(D3,$,this))},toLocaleString($,O,Z={}){let[T,j]=lJ(O,Z,$);return T.format(j)},toString:($,O)=>wT(t,$,O),toJSON:($)=>wT(t,$),valueOf:v1},{from:($,O)=>r(q$($,O)),compare:($,O)=>Wj(q$($),q$(O))}),MY=Object.defineProperties({},{...GZ("Temporal.Now"),...h1({timeZoneId:()=>X1(),instant:()=>V0(z0(SO())),zonedDateTime:($,O=X1())=>r(Y0(SO(),c(O),X0($))),zonedDateTimeISO:($=X1())=>r(Y0(SO(),c($),v)),plainDateTime:($,O=X1())=>C0(a(H$(t(c(O))),X0($))),plainDateTimeISO:($=X1())=>C0(a(H$(t(c($))),v)),plainDate:($,O=X1())=>d(o(H$(t(c(O))),X0($))),plainDateISO:($=X1())=>d(o(H$(t(c($))),v)),plainTimeISO:($=X1())=>w1(l0(H$(t(c($)))))})}),p$=Object.defineProperties({},{...GZ("Temporal"),...h1({PlainYearMonth:WY,PlainMonthDay:OY,PlainDate:CY,PlainTime:zY,PlainDateTime:YY,ZonedDateTime:LY,Instant:TY,Calendar:Bf,TimeZone:Y3,Duration:QY,Now:MY})}),SY=mJ(),Kf=new WeakMap,xY=Object.defineProperties(Object.create(Intl),h1({DateTimeFormat:SY}));var Qf=new WeakMap;function _Y($){let O=Qf.get($);if(!O)O=$(NY(32).toString("hex")),Qf.set($,O),O.catch(()=>Qf.delete($));return O}async function Vf($,O,Z){if(typeof Z==="string"&&Z!=="")return await $.verifyPassword(O,Z);try{await $.verifyPassword(O,await _Y($.hashPassword))}catch{}return!1}var If="intended_url";class Lf extends _{schema={email:{required:"Email is required",string:"Invalid email",email:"Invalid email"},password:{required:"Password is required"}}}class az extends _{schema={email:{required:"Email is required",email:"Invalid email"}}}class oz extends _{schema={password:{required:"Password is required",password:"Invalid password"}}}class e extends y3{async me(){let $=await T$.user();if(!$)throw new p3;return $}async verifyEmail($=new _){let O=await $.input(),{userProvider:Z}=K(w),T=await Z.findUserByVerificationToken(O.get("token"));if(!T)return{email:null};return await Z.verifyUser(T.email),{email:T.email}}async signInWithMagicLink($=new _){let O=K(w),{userProvider:Z}=O,T=$.search.get("token"),j=decodeURIComponent($.search.get("email")).toLowerCase().trim(),f=null;try{f=await Z.findUserMagicLinkToken({email:j,token:T})}catch(W){return console.log(W),{error:JSON.stringify(W)}}if(!f)return{error:"Invalid token"};await Z.verifyUser(j),await Z.deleteMagicLinkToken(j);let z=await O.createOrUpdateSession({email:j});return $.ctx().setCookie("access_token",z.token,K(w).accessTokenCookieOptions($,z.expiresAt)),await O.config.onSignIn(z,$.search.toJSON()),{session:z}}async signInWithPinV2($=new _){let O=K(w),{userProvider:Z}=O,T=await $.input(),{email:j,pin:f}=T.toJSON(),z=j.toLowerCase().trim();if(!await Z.findUserMagicLinkToken({email:z,pin:f}))throw new k0({pin:["Invalid pin"]});await Z.deleteMagicLinkToken(z),await Z.verifyUser(z);let J=await O.createOrUpdateSessionV2({email:z});return $.ctx().setCookie("access_token",J.token,K(w).accessTokenCookieOptions($,J.expiresAt)),await O.config.onSignIn(J,$.search.toJSON()),J}async signInWithPin($=new _){let O=K(w),{userProvider:Z}=O,T=await $.input(),{email:j,pin:f}=T.toJSON(),z=j.toLowerCase().trim();if(!await Z.findUserMagicLinkToken({email:z,pin:f}))throw new k0({pin:["Invalid pin"]});await Z.deleteMagicLinkToken(z),await Z.verifyUser(z);let J=await O.createOrUpdateSession({email:z});return $.ctx().setCookie("access_token",J.token,K(w).accessTokenCookieOptions($,J.expiresAt)),await O.config.onSignIn(J,$.search.toJSON()),{session:J}}async signInV2($=new Lf){let O=await $.input(),{email:Z,password:T}=O.toJSON(),j=Z.toLowerCase().trim(),f=K(w),z=await f.userProvider.findUserByEmailAddress(j,f.config.verifyEmail),W=await Vf(f.config,T,z?.password);if(!z||!W)throw new k0({invalid_credentials:["Invalid credentials"]});let J=await f.createOrUpdateSessionV2({email:z.email,id:z.id});$.ctx().setCookie("access_token",J.token,K(w).accessTokenCookieOptions($,J.expiresAt)),await f.config.onSignIn(z,$.search.toJSON());let{password:Y,...C}=z;return C}async signIn($=new Lf){let O=await $.input(),{email:Z,password:T}=O.toJSON(),j=Z.toLowerCase().trim(),f=K(w),z=await f.userProvider.findUserByEmailAddress(j,f.config.verifyEmail),W=await Vf(f.config,T,z?.password);if(!z||!W)throw new k0({invalid_credentials:["Invalid credentials"]});let J=await f.createOrUpdateSession({email:z.email,id:z.id});$.ctx().setCookie("access_token",J.token,K(w).accessTokenCookieOptions($,J.expiresAt)),await f.config.onSignIn(z,$.search.toJSON());let{password:Y,...C}=z;return C}async signUp(){let $=K(w),{userProvider:O,config:Z}=$,T=new Z.signUpRequest,j=await T.input(),{email:f,password:z,name:W,invitationId:J}=j.toJSON(),Y=f.toLowerCase().trim();if(await O.findUserByEmailAddress(Y,!1))throw new k0({email:["Email address already exists"]});let D=await Z.hashPassword(z),X=K(s).detectLocale(T),U;if(J)U=await O.findInvitation(J,Y);let F,G="";if(U)F=await O.transaction(async()=>{await O.deleteInvitationById(J);let B=await O.createUser({email:Y,name:W,password:D,emailVerifiedAt:new Date,locale:X});return await O.createAccount({organizationId:U.organizationId,userId:B.id,organizationRole:U.role}),await Z.onUserCreated(B),B});else G=await Z.generateEmailVerificationToken(Y),F=await O.transaction(async()=>{let B=await O.createUser({email:Y,name:W,password:D,verificationToken:G,locale:X});return await Z.onUserCreated(B),B});return await Z.onSignUp(F,G,T.search.toJSON()),F}async signOut($=new _){let O=k3($),Z=K(w),{config:T}=Z,j=await Z.revokeSession(O,$.headers.get("User-Agent"));if($.ctx().setCookie("access_token","",K(w).accessTokenCookieOptions($,new Date(0))),K(w).cookieDomain($))$.ctx().setCookie("access_token","",{...K(w).accessTokenCookieOptions($,new Date(0)),domain:void 0});if(j?.user)j.user.extension=await T.extendSession(j.user),await T.onSignOut(j.user);return{}}async forgotPassword($=new az){let Z=(await $.input()).get("email").toLowerCase().trim(),{userProvider:T,config:j}=K(w),f=await T.findUserByEmailAddress(Z,j.verifyEmail);if(!f)return{};let z=await j.generateForgotPasswordToken(f);return await T.createPasswordResetToken({user:f,token:z}),await j.onForgotPassword(f,z),{}}async resetPassword($=new oz){let{userProvider:O,config:Z}=K(w),T=await $.input(),{password:j,token:f}=T.toJSON(),z=await O.findPasswordResetToken({token:f});if(!z)throw new k0({token:["Invalid token"]});if(p$.Instant.from(z.createdAt.toISOString()).add({hours:24}).until(p$.Now.instant()).sign>=0)throw new k0({token:["Token expired"]});await O.deletePasswordResetToken({token:f});let J=await O.findUserByEmailAddress(z.user.email,Z.verifyEmail);if(!J)throw new k0({email:["User not found"]});let Y=await Z.hashPassword(j);return await O.updateUserPassword({id:J.id,password:Y}),await O.deleteAllUserSessions(J.id),await Z.onResetPassword(J),{}}async changePassword($=new _){let{userProvider:O,config:Z}=K(w),T=await T$.user(),j=await $.input(),{oldPassword:f,newPassword:z}=j.toJSON(),W=await O.findUserByEmailAddress(T.email,Z.verifyEmail);if(!await Vf(Z,f,W?.password))throw new k0({oldPassword:["Incorrect password"]});let Y=await Z.hashPassword(z);return await O.updateUserPassword({id:T.id,password:Y}),await O.deleteAllUserSessions(T.id),{}}async oauthRedirect($=new _){let{provider:O}=$.params,Z=K(w).config.oauthProviders[O];if(!Z)throw Error(`Invalid provider: ${O}`);let T=TO($.search.get(U$),"");if(T)$.ctx().setCookie(If,encodeURIComponent(T),{httpOnly:!0,sameSite:"Lax",secure:P4($.rawRequest),maxAge:600});return{destination:await Z.getRedirectUrl($)}}async oauthCallback($=new _){let{provider:O}=$.params,Z=K(w),{userProvider:T,config:j}=Z,f=j.oauthProviders[O],{email:z,name:W,username:J,providerId:Y}=await f.onCallback($),C=Y?await T.findUserBySocialAccount(O,Y):null,D="signin";if(!C){if(!z)return console.error("Authentication error: No email returned from OAuth provider callback"),{session:null};let G=K(s).detectLocale($);try{let B=await this.linkOAuthAccount({provider:O,providerId:Y,email:z,name:W,username:J,locale:G});if(B)C=B.user,D=B.action}catch(B){let Q=Y?await T.findUserBySocialAccount(O,Y):null;if(!Q)throw B;C=Q}if(!C)return{session:null}}let X=await Z.createOrUpdateSessionV2({email:C.email,id:C.id});if($.ctx().setCookie("access_token",X.token,K(w).accessTokenCookieOptions($,X.expiresAt)),D==="signup")await j.onSignUp(C,"",$.search.toJSON());else await j.onSignIn(C,$.search.toJSON());let U=$.cookies.get(If),F=j.redirectPath;if(U){try{F=TO(decodeURIComponent(U),F)}catch{}$.ctx().setCookie(If,"",{maxAge:-1})}return{session:X,redirectTo:F}}async linkOAuthAccount($){let{provider:O,providerId:Z,email:T,name:j,username:f,locale:z}=$,{userProvider:W,config:J}=K(w),Y=(X)=>({provider:O,userId:X,email:T,username:f,providerId:Z,expiresAt:new Date,accessToken:"",refreshToken:""}),C=await W.findUserByEmailAddress(T,!1);if(C){if(!Z)return{user:C,action:"signin"};let X=await W.findSocialAccounts(C.id,O);if(X.some((F)=>F.providerId===Z))return{user:C,action:"signin"};if(X.some((F)=>F.providerId))return console.error(`Authentication error: user ${C.id} is already linked to a different ${O} account`),null;let U=X[0];if(U){if(!await W.claimSocialAccount(U,Z))throw Error(`${O} account link changed concurrently`)}else await W.createSocialAccount(Y(C.id));return{user:C,action:"signin"}}return{user:await W.transaction(async()=>{let X=await W.createUser({email:T,name:j,locale:z,emailVerifiedAt:new Date});if(Z)await W.createSocialAccount(Y(X.id));return await J.onUserCreated(X),X}),action:"signup"}}async createMagicLinkToken($=new _){let Z=(await $.input()).get("email").toLowerCase().trim(),T=K(w),{user:j,pin:f,token:z}=await T.createMagicLinkToken(Z);if(j)return await T.config.onMagicLinkCreated(j,{email:Z,pin:f,token:z}),{email:Z};return{email:null}}}class rz extends B1{middlewares=["cache:private"];routes={"/:provider":this.view("_Redirect",[e,"oauthRedirect"]),"/:provider/callback":this.view("auth/OauthCallback",[e,"oauthCallback"])}}class Mf extends B1{middlewares=["cache:private"];routes={"/sign-in/magic-link":this.view("auth/MagicLinkSignIn",[e,"signInWithMagicLink"]),"/oauth":rz}}class Sf extends S0{middlewares=["cache:private"];routes={"/sign-in":this.post(e,"signIn"),"/sign-in-v2":this.post(e,"signInV2"),"/sign-up":this.post(e,"signUp"),"/sign-out":this.post(e,"signOut"),"/forgot-password":this.post(e,"forgotPassword"),"/reset-password":this.post(e,"resetPassword"),"/change-password":this.post(e,"changePassword"),"/verify-email":this.post(e,"verifyEmail"),"/me":this.get(e,"me").middleware(["auth"]),"/magic-link":this.post(e,"createMagicLinkToken"),"/sign-in-with-pin":this.post(e,"signInWithPin"),"/sign-in-with-pin-v2":this.post(e,"signInWithPinV2")}}class xf extends S0{middlewares=["cache:private,0,no-store"];routes={"/set-locale/:locale":this.get(async()=>{let O=new _().params.locale;return await K(s).onLocaleChange(O),{locale:O}}),"/translations/:locale/:scope*":this.get(async()=>{let $=new _,O=`/${$.params.scope??""}`,Z=$.params.locale,T=K(s),j=Z??T.detectLocale($),f=T.getPageTranslations(j,O);return $.ctx().setCookie("i18n-locale",j,{expires:new Date(Date.now()+31536000000)}),{[j]:f}})}}class Nf{}class _f extends Nf{async resize($,O){let{height:Z,width:T,quality:j,fit:f}=O;return await(await F3("The Sharp image optimization driver"))($).resize(T>0?T:void 0,Z>0?Z:void 0,{fit:f}).webp({quality:j>0?j:80,force:!0}).toBuffer()}}function WD($){return $}function tz(){return{driver:new _f}}class Af extends S0{routes={"/resize":this.file(async()=>{let $=new _,O=new URL($.rawRequest.url),Z=O.searchParams.get("url"),T=Number(O.searchParams.get("w")),j=Number(O.searchParams.get("h")),f=O.searchParams.get("fit")??"cover",z=Number(O.searchParams.get("q"));if(!Z)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});let J=`${Z.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${Z}`,Y=await fetch(J);if(!Y.ok)return new Response(JSON.stringify({error:"Image not found",info:J}),{headers:{"Content-Type":"application/json"},status:404});let C=Buffer.from(await Y.arrayBuffer()),D=await K(ez).resize(C,{height:j,width:T,fit:f,quality:z});Y.headers.delete("Content-Type"),Y.headers.delete("Content-Length");let X=new Headers(Y.headers);return X.set("Content-Type","image/webp"),X.set("Content-Length",`${D.byteLength}`),new Response(new Uint8Array(D),{headers:X})})}}class ez{static token="image";driver;constructor($={}){this.driver=$.driver??tz().driver}resize($,O){return this.driver.resize($,O)}}class Ef extends S0{middlewares=["cache:private,0"];routes={"/live":this.get(async()=>{let $=Bun.file(K($W).currentLogFilePath);return new Response(await $.text(),{headers:{"Content-Type":"text/plain"}})})}}function AY($){let O=new Map;for(let Z of $)if(typeof Z==="string"){let[T,j=""]=Z.split(":");if(T.startsWith("-")){if(O.has(T.replace("-","")))O.delete(T.replace("-",""))}else O.set(T,j.split(",").filter(Boolean))}else O.set(Z,[]);return O}class qO{config;static token="middleware";constructor($){this.config=$}get aliases(){return this.config.aliases}assertGlobalMiddleware(){for(let $ of this.config.global){if(typeof $!=="string")continue;let[O]=$.split(":");if(O.startsWith("-"))throw Error(`Global middleware "${$}" cancels an alias, but nothing is inherited into the global list. Remove it.`);if(!this.aliases[O])throw Error(`Global middleware "${O}" is not a registered alias. Add it to \`aliases\` in the middleware config, or list the class itself.`)}}runGlobalMiddleware(){return this.runMiddleware(this.config.global)}runMiddleware($){let O=new _;return Array.from(AY($).entries()).map(([Z,T])=>{if(typeof Z==="string"){let j=this.aliases[Z];if(j){let f=new j(O);return()=>f.run.call(f,...T)}}else{if(sO(Z)){let j=new Z(O);return j.run.bind(j)}return Z}}).filter(Boolean).reduce((Z,T)=>{return async()=>{return{...await Z(),...await T()}}},()=>Promise.resolve({}))()}}function LD($){return $}function OW(){return{onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{}}}function ZW(){return{partialRendering:!0,onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{},onStreamComplete:()=>{}}}function EY($){return"run"in $}function PY($){return Object.hasOwn($,"get")||Object.hasOwn($,"post")||Object.hasOwn($,"put")||Object.hasOwn($,"delete")}function HY($){return Object.hasOwn($,"first")&&Object.hasOwn($,"second")}function wY($){if("__brand"in $)return $.__brand==="ApiRouter";return!1}function bY($){if("__internal_brand"in $)return $.__internal_brand==="ProxyHandler";return!1}function vY($){if("__internal_brand"in $)return $.__internal_brand==="StreamHandler";return!1}function Pf($,O="",Z=[]){let T={};function j(f,z,W,J,Y){let C=f==="/"?"":f,D=O==="/"?"":O,X=(`${D}${C}`===""?"/":`${D}${C}`).replaceAll("//","/");if(!T[X])T[X]={};T[X][z.toUpperCase()]={exec:W,middleware:[...Z,...J],...Y?{source:Y}:{}},T[X].OPTIONS={exec:()=>{let F=new _().ctx().headers;return new Response(null,{headers:F,status:204})},middleware:[]}}for(let[f,z]of Object.entries($)){if(bY(z)){let W=z;for(let J of["GET","POST","PUT","DELETE"])j(f,J,W.run.bind(W),W.middlewares);continue}if(EY(z)){let W=z,J=W.method,Y=W.middlewares,C=W.run.bind(W);if(j(f,J,C,Y,W.source),vY(z))j(f,"HEAD",C,Y,W.source)}if(PY(z))for(let[W,J]of Object.entries(z)){let Y=J.middlewares,C=J.run.bind(J);j(f,W,C,Y,J.source)}if(wY(z)){let W=new z,J=Pf(W.routes,`${O}${f}`,W.middlewares);for(let[Y,C]of Object.entries(J))T[Y.replaceAll("//","/")]=C}if(HY(z)){let{first:W,second:J}=z;for(let[Y,C]of Object.entries(W)){let D=C.middlewares,X=C.run.bind(C),[U,...F]=f.split("/").reverse();if(!U.startsWith(":"))throw Error("Resource route must end with a dynamic segment");j(F.reverse().join("/"),Y,X,D,C.source)}for(let[Y,C]of Object.entries(J)){let D=C.middlewares,X=C.run.bind(C);j(f,Y,X,D,C.source)}}}return Object.fromEntries(Object.entries(T).sort(([f],[z])=>{let W=f.split("/").length+f.split(":").length,J=z.split("/").length+z.split(":").length;return W-J}))}function U3($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function Hf($,O){if($==="/")return O;if(O==="/")return $;return`${$}${O}`}function wf($){let O=U3($);return O.length>1?O.replace(/\/$/,""):O}function TW($,O){return O.map((Z)=>({...Z,path:wf(Hf($,Z.path))}))}function G3($){let O={};for(let[Z,T]of Object.entries($))if("run"in T){let j=T;if("children"in j){let f=new j.children,z=G3(f.routes);for(let[W,{exec:J,middleware:Y,segments:C,features:D}]of Object.entries(z)){let X=Hf(Z,W),U=(F)=>j.run.call(j,F,Z);O[U3(X)]={exec:[U,...J],middleware:[...j.middlewares,...Y],features:[...j.featureGates,...D],viewPath:j.viewPath,segments:[{path:wf(Z),viewPath:j.viewPath,...j.alwaysRuns?{alwaysRun:!0}:{}},...TW(Z,C)]}}}else{let f=(z)=>j.run.call(j,z,Z);O[U3(Z)]={exec:[f],middleware:j.middlewares,features:j.featureGates,viewPath:j.viewPath,segments:[{path:wf(Z),viewPath:j.viewPath}]}}}else{let j=new T,f=G3(j.routes);for(let[z,{exec:W,middleware:J,viewPath:Y,segments:C,features:D}]of Object.entries(f)){let X=Hf(Z,z);O[U3(X)]={exec:W,middleware:[...j.middlewares,...J],features:[...j.featureGates,...D],viewPath:Y,segments:TW(Z,C)}}}return Object.fromEntries(Object.entries(O).sort(([Z],[T])=>{let j=Z.split("/").length+Z.split(":").length,f=T.split("/").length+T.split(":").length;return j-f}))}var gY=Object.defineProperty,S=($,O)=>gY($,"name",{value:O,configurable:!0}),h$=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor($,O,Z,T,j,f){this.type=$,this.name=O,this.prefix=Z,this.value=T,this.suffix=j,this.modifier=f}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};S(h$,"Part");var RY=/[$_\p{ID_Start}]/u,kY=/[$_\u200C\u200D\p{ID_Continue}]/u,vf=".*";function jW($,O){return(O?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test($)}S(jW,"isASCII");function kf($,O=!1){let Z=[],T=0;for(;T<$.length;){let j=$[T],f=S(function(z){if(!O)throw TypeError(z);Z.push({type:"INVALID_CHAR",index:T,value:$[T++]})},"ErrorOrInvalid");if(j==="*"){Z.push({type:"ASTERISK",index:T,value:$[T++]});continue}if(j==="+"||j==="?"){Z.push({type:"OTHER_MODIFIER",index:T,value:$[T++]});continue}if(j==="\\"){Z.push({type:"ESCAPED_CHAR",index:T++,value:$[T++]});continue}if(j==="{"){Z.push({type:"OPEN",index:T,value:$[T++]});continue}if(j==="}"){Z.push({type:"CLOSE",index:T,value:$[T++]});continue}if(j===":"){let z="",W=T+1;for(;W<$.length;){let J=$.substr(W,1);if(W===T+1&&RY.test(J)||W!==T+1&&kY.test(J)){z+=$[W++];continue}break}if(!z){f(`Missing parameter name at ${T}`);continue}Z.push({type:"NAME",index:T,value:z}),T=W;continue}if(j==="("){let z=1,W="",J=T+1,Y=!1;if($[J]==="?"){f(`Pattern cannot start with "?" at ${J}`);continue}for(;J<$.length;){if(!jW($[J],!1)){f(`Invalid character '${$[J]}' at ${J}.`),Y=!0;break}if($[J]==="\\"){W+=$[J++]+$[J++];continue}if($[J]===")"){if(z--,z===0){J++;break}}else if($[J]==="("&&(z++,$[J+1]!=="?")){f(`Capturing groups are not allowed at ${J}`),Y=!0;break}W+=$[J++]}if(Y)continue;if(z){f(`Unbalanced pattern at ${T}`);continue}if(!W){f(`Missing pattern at ${T}`);continue}Z.push({type:"REGEX",index:T,value:W}),T=J;continue}Z.push({type:"CHAR",index:T,value:$[T++]})}return Z.push({type:"END",index:T,value:""}),Z}S(kf,"lexer");function qf($,O={}){let Z=kf($);O.delimiter??="/#?",O.prefixes??="./";let T=`[^${H0(O.delimiter)}]+?`,j=[],f=0,z=0,W="",J=new Set,Y=S((V)=>{if(z<Z.length&&Z[z].type===V)return Z[z++].value},"tryConsume"),C=S(()=>Y("OTHER_MODIFIER")??Y("ASTERISK"),"tryConsumeModifier"),D=S((V)=>{let N=Y(V);if(N!==void 0)return N;let{type:A,index:I}=Z[z];throw TypeError(`Unexpected ${A} at ${I}, expected ${V}`)},"mustConsume"),X=S(()=>{let V="",N;for(;N=Y("CHAR")??Y("ESCAPED_CHAR");)V+=N;return V},"consumeText"),U=S((V)=>V,"DefaultEncodePart"),F=O.encodePart||U,G="",B=S((V)=>{G+=V},"appendToPendingFixedValue"),Q=S(()=>{G.length&&(j.push(new h$(3,"","",F(G),"",3)),G="")},"maybeAddPartFromPendingFixedValue"),L=S((V,N,A,I,M)=>{let E=3;switch(M){case"?":E=1;break;case"*":E=0;break;case"+":E=2;break}if(!N&&!A&&E===3){B(V);return}if(Q(),!N&&!A){if(!V)return;j.push(new h$(3,"","",F(V),"",E));return}let P;A?A==="*"?P=vf:P=A:P=T;let $0=2;P===T?($0=1,P=""):P===vf&&($0=0,P="");let g;if(N?g=N:A&&(g=f++),J.has(g))throw TypeError(`Duplicate name '${g}'.`);J.add(g),j.push(new h$($0,g,F(V),P,F(I),E))},"addPart");for(;z<Z.length;){let V=Y("CHAR"),N=Y("NAME"),A=Y("REGEX");if(!N&&!A&&(A=Y("ASTERISK")),N||A){let M=V??"";O.prefixes.indexOf(M)===-1&&(B(M),M=""),Q();let E=C();L(M,N,A,"",E);continue}let I=V??Y("ESCAPED_CHAR");if(I){B(I);continue}if(Y("OPEN")){let M=X(),E=Y("NAME"),P=Y("REGEX");!E&&!P&&(P=Y("ASTERISK"));let $0=X();D("CLOSE");let g=C();L(M,E,P,$0,g);continue}Q(),D("END")}return j}S(qf,"parse");function H0($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}S(H0,"escapeString");function gf($){return $&&$.ignoreCase?"ui":"u"}S(gf,"flags");function fW($,O,Z){return mf(qf($,Z),O,Z)}S(fW,"stringToRegexp");function j$($){switch($){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}S(j$,"modifierToString");function mf($,O,Z={}){Z.delimiter??="/#?",Z.prefixes??="./",Z.sensitive??=!1,Z.strict??=!1,Z.end??=!0,Z.start??=!0,Z.endsWith="";let T=Z.start?"^":"";for(let W of $){if(W.type===3){W.modifier===3?T+=H0(W.value):T+=`(?:${H0(W.value)})${j$(W.modifier)}`;continue}O&&O.push(W.name);let J=`[^${H0(Z.delimiter)}]+?`,Y=W.value;if(W.type===1?Y=J:W.type===0&&(Y=vf),!W.prefix.length&&!W.suffix.length){W.modifier===3||W.modifier===1?T+=`(${Y})${j$(W.modifier)}`:T+=`((?:${Y})${j$(W.modifier)})`;continue}if(W.modifier===3||W.modifier===1){T+=`(?:${H0(W.prefix)}(${Y})${H0(W.suffix)})`,T+=j$(W.modifier);continue}T+=`(?:${H0(W.prefix)}`,T+=`((?:${Y})(?:`,T+=H0(W.suffix),T+=H0(W.prefix),T+=`(?:${Y}))*)${H0(W.suffix)})`,W.modifier===0&&(T+="?")}let j=`[${H0(Z.endsWith)}]|$`,f=`[${H0(Z.delimiter)}]`;if(Z.end)return Z.strict||(T+=`${f}?`),Z.endsWith.length?T+=`(?=${j})`:T+="$",new RegExp(T,gf(Z));Z.strict||(T+=`(?:${f}(?=${j}))?`);let z=!1;if($.length){let W=$[$.length-1];W.type===3&&W.modifier===3&&(z=Z.delimiter.indexOf(W)>-1)}return z||(T+=`(?=${f}|${j})`),new RegExp(T,gf(Z))}S(mf,"partsToRegexp");var R1={delimiter:"",prefixes:"",sensitive:!0,strict:!0},qY={delimiter:".",prefixes:"",sensitive:!0,strict:!0},mY={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function zW($,O){return $.length?$[0]==="/"?!0:!O||$.length<2?!1:($[0]=="\\"||$[0]=="{")&&$[1]=="/":!1}S(zW,"isAbsolutePathname");function yf($,O){return $.startsWith(O)?$.substring(O.length,$.length):$}S(yf,"maybeStripPrefix");function WW($,O){return $.endsWith(O)?$.substr(0,$.length-O.length):$}S(WW,"maybeStripSuffix");function pf($){return!$||$.length<2?!1:$[0]==="["||($[0]==="\\"||$[0]==="{")&&$[1]==="["}S(pf,"treatAsIPv6Hostname");var JW=["ftp","file","http","https","ws","wss"];function cf($){if(!$)return!0;for(let O of JW)if($.test(O))return!0;return!1}S(cf,"isSpecialScheme");function YW($,O){if($=yf($,"#"),O||$==="")return $;let Z=new URL("https://example.com");return Z.hash=$,Z.hash?Z.hash.substring(1,Z.hash.length):""}S(YW,"canonicalizeHash");function CW($,O){if($=yf($,"?"),O||$==="")return $;let Z=new URL("https://example.com");return Z.search=$,Z.search?Z.search.substring(1,Z.search.length):""}S(CW,"canonicalizeSearch");function XW($,O){return O||$===""?$:pf($)?df($):lf($)}S(XW,"canonicalizeHostname");function DW($,O){if(O||$==="")return $;let Z=new URL("https://example.com");return Z.password=$,Z.password}S(DW,"canonicalizePassword");function FW($,O){if(O||$==="")return $;let Z=new URL("https://example.com");return Z.username=$,Z.username}S(FW,"canonicalizeUsername");function UW($,O,Z){if(Z||$==="")return $;if(O&&!JW.includes(O))return new URL(`${O}:${$}`).pathname;let T=$[0]=="/";return $=new URL(T?$:"/-"+$,"https://example.com").pathname,T||($=$.substring(2,$.length)),$}S(UW,"canonicalizePathname");function GW($,O,Z){return hf(O)===$&&($=""),Z||$===""?$:uf($)}S(GW,"canonicalizePort");function BW($,O){return $=WW($,":"),O||$===""?$:B3($)}S(BW,"canonicalizeProtocol");function hf($){switch($){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}S(hf,"defaultPortForProtocol");function B3($){if($==="")return $;if(/^[-+.A-Za-z0-9]*$/.test($))return $.toLowerCase();throw TypeError(`Invalid protocol '${$}'.`)}S(B3,"protocolEncodeCallback");function KW($){if($==="")return $;let O=new URL("https://example.com");return O.username=$,O.username}S(KW,"usernameEncodeCallback");function QW($){if($==="")return $;let O=new URL("https://example.com");return O.password=$,O.password}S(QW,"passwordEncodeCallback");function lf($){if($==="")return $;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test($))throw TypeError(`Invalid hostname '${$}'`);let O=new URL("https://example.com");return O.hostname=$,O.hostname}S(lf,"hostnameEncodeCallback");function df($){if($==="")return $;if(/[^0-9a-fA-F[\]:]/g.test($))throw TypeError(`Invalid IPv6 hostname '${$}'`);return $.toLowerCase()}S(df,"ipv6HostnameEncodeCallback");function uf($){if($===""||/^[0-9]*$/.test($)&&parseInt($)<=65535)return $;throw TypeError(`Invalid port '${$}'.`)}S(uf,"portEncodeCallback");function VW($){if($==="")return $;let O=new URL("https://example.com");return O.pathname=$[0]!=="/"?"/-"+$:$,$[0]!=="/"?O.pathname.substring(2,O.pathname.length):O.pathname}S(VW,"standardURLPathnameEncodeCallback");function IW($){return $===""?$:new URL(`data:${$}`).pathname}S(IW,"pathURLPathnameEncodeCallback");function LW($){if($==="")return $;let O=new URL("https://example.com");return O.search=$,O.search.substring(1,O.search.length)}S(LW,"searchEncodeCallback");function MW($){if($==="")return $;let O=new URL("https://example.com");return O.hash=$,O.hash.substring(1,O.hash.length)}S(MW,"hashEncodeCallback");var SW=class{#f;#T=[];#O={};#$=0;#j=1;#Y=0;#W=0;#F=0;#U=0;#G=!1;constructor($){this.#f=$}get result(){return this.#O}parse(){for(this.#T=kf(this.#f,!0);this.#$<this.#T.length;this.#$+=this.#j){if(this.#j=1,this.#T[this.#$].type==="END"){if(this.#W===0){this.#V(),this.#C()?this.#Z(9,1):this.#X()?this.#Z(8,1):this.#Z(7,0);continue}else if(this.#W===2){this.#D(5);continue}this.#Z(10,0);break}if(this.#F>0)if(this.#_())this.#F-=1;else continue;if(this.#N()){this.#F+=1;continue}switch(this.#W){case 0:this.#I()&&this.#D(1);break;case 1:if(this.#I()){this.#P();let $=7,O=1;this.#M()?($=2,O=3):this.#G&&($=2),this.#Z($,O)}break;case 2:this.#K()?this.#D(3):(this.#Q()||this.#X()||this.#C())&&this.#D(5);break;case 3:this.#S()?this.#Z(4,1):this.#K()&&this.#Z(5,1);break;case 4:this.#K()&&this.#Z(5,1);break;case 5:this.#A()?this.#U+=1:this.#E()&&(this.#U-=1),this.#x()&&!this.#U?this.#Z(6,1):this.#Q()?this.#Z(7,0):this.#X()?this.#Z(8,1):this.#C()&&this.#Z(9,1);break;case 6:this.#Q()?this.#Z(7,0):this.#X()?this.#Z(8,1):this.#C()&&this.#Z(9,1);break;case 7:this.#X()?this.#Z(8,1):this.#C()&&this.#Z(9,1);break;case 8:this.#C()&&this.#Z(9,1);break;case 9:break;case 10:break}}this.#O.hostname!==void 0&&this.#O.port===void 0&&(this.#O.port="")}#Z($,O){switch(this.#W){case 0:break;case 1:this.#O.protocol=this.#J();break;case 2:break;case 3:this.#O.username=this.#J();break;case 4:this.#O.password=this.#J();break;case 5:this.#O.hostname=this.#J();break;case 6:this.#O.port=this.#J();break;case 7:this.#O.pathname=this.#J();break;case 8:this.#O.search=this.#J();break;case 9:this.#O.hash=this.#J();break;case 10:break}this.#W!==0&&$!==10&&([1,2,3,4].includes(this.#W)&&[6,7,8,9].includes($)&&(this.#O.hostname??=""),[1,2,3,4,5,6].includes(this.#W)&&[8,9].includes($)&&(this.#O.pathname??=this.#G?"/":""),[1,2,3,4,5,6,7].includes(this.#W)&&$===9&&(this.#O.search??="")),this.#L($,O)}#L($,O){this.#W=$,this.#Y=this.#$+O,this.#$+=O,this.#j=0}#V(){this.#$=this.#Y,this.#j=0}#D($){this.#V(),this.#W=$}#B($){return $<0&&($=this.#T.length-$),$<this.#T.length?this.#T[$]:this.#T[this.#T.length-1]}#z($,O){let Z=this.#B($);return Z.value===O&&(Z.type==="CHAR"||Z.type==="ESCAPED_CHAR"||Z.type==="INVALID_CHAR")}#I(){return this.#z(this.#$,":")}#M(){return this.#z(this.#$+1,"/")&&this.#z(this.#$+2,"/")}#K(){return this.#z(this.#$,"@")}#S(){return this.#z(this.#$,":")}#x(){return this.#z(this.#$,":")}#Q(){return this.#z(this.#$,"/")}#X(){if(this.#z(this.#$,"?"))return!0;if(this.#T[this.#$].value!=="?")return!1;let $=this.#B(this.#$-1);return $.type!=="NAME"&&$.type!=="REGEX"&&$.type!=="CLOSE"&&$.type!=="ASTERISK"}#C(){return this.#z(this.#$,"#")}#N(){return this.#T[this.#$].type=="OPEN"}#_(){return this.#T[this.#$].type=="CLOSE"}#A(){return this.#z(this.#$,"[")}#E(){return this.#z(this.#$,"]")}#J(){let $=this.#T[this.#$],O=this.#B(this.#Y).index;return this.#f.substring(O,$.index)}#P(){let $={};Object.assign($,R1),$.encodePart=B3;let O=fW(this.#J(),void 0,$);this.#G=cf(O)}};S(SW,"Parser");var bf=["protocol","username","password","hostname","port","pathname","search","hash"],g1="*";function Rf($,O){if(typeof $!="string")throw TypeError("parameter 1 is not of type 'string'.");let Z=new URL($,O);return{protocol:Z.protocol.substring(0,Z.protocol.length-1),username:Z.username,password:Z.password,hostname:Z.hostname,port:Z.port,pathname:Z.pathname,search:Z.search!==""?Z.search.substring(1,Z.search.length):void 0,hash:Z.hash!==""?Z.hash.substring(1,Z.hash.length):void 0}}S(Rf,"extractValues");function O1($,O){return O?i$($):$}S(O1,"processBaseURLString");function c$($,O,Z){let T;if(typeof O.baseURL=="string")try{T=new URL(O.baseURL),O.protocol===void 0&&($.protocol=O1(T.protocol.substring(0,T.protocol.length-1),Z)),!Z&&O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.username===void 0&&($.username=O1(T.username,Z)),!Z&&O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.username===void 0&&O.password===void 0&&($.password=O1(T.password,Z)),O.protocol===void 0&&O.hostname===void 0&&($.hostname=O1(T.hostname,Z)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&($.port=O1(T.port,Z)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.pathname===void 0&&($.pathname=O1(T.pathname,Z)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.pathname===void 0&&O.search===void 0&&($.search=O1(T.search.substring(1,T.search.length),Z)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.pathname===void 0&&O.search===void 0&&O.hash===void 0&&($.hash=O1(T.hash.substring(1,T.hash.length),Z))}catch{throw TypeError(`invalid baseURL '${O.baseURL}'.`)}if(typeof O.protocol=="string"&&($.protocol=BW(O.protocol,Z)),typeof O.username=="string"&&($.username=FW(O.username,Z)),typeof O.password=="string"&&($.password=DW(O.password,Z)),typeof O.hostname=="string"&&($.hostname=XW(O.hostname,Z)),typeof O.port=="string"&&($.port=GW(O.port,$.protocol,Z)),typeof O.pathname=="string"){if($.pathname=O.pathname,T&&!zW($.pathname,Z)){let j=T.pathname.lastIndexOf("/");j>=0&&($.pathname=O1(T.pathname.substring(0,j+1),Z)+$.pathname)}$.pathname=UW($.pathname,$.protocol,Z)}return typeof O.search=="string"&&($.search=CW(O.search,Z)),typeof O.hash=="string"&&($.hash=YW(O.hash,Z)),$}S(c$,"applyInit");function i$($){return $.replace(/([+*?:{}()\\])/g,"\\$1")}S(i$,"escapePatternString");function xW($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}S(xW,"escapeRegexpString");function NW($,O){O.delimiter??="/#?",O.prefixes??="./",O.sensitive??=!1,O.strict??=!1,O.end??=!0,O.start??=!0,O.endsWith="";let Z=".*",T=`[^${xW(O.delimiter)}]+?`,j=/[$_\u200C\u200D\p{ID_Continue}]/u,f="";for(let z=0;z<$.length;++z){let W=$[z];if(W.type===3){if(W.modifier===3){f+=i$(W.value);continue}f+=`{${i$(W.value)}}${j$(W.modifier)}`;continue}let J=W.hasCustomName(),Y=!!W.suffix.length||!!W.prefix.length&&(W.prefix.length!==1||!O.prefixes.includes(W.prefix)),C=z>0?$[z-1]:null,D=z<$.length-1?$[z+1]:null;if(!Y&&J&&W.type===1&&W.modifier===3&&D&&!D.prefix.length&&!D.suffix.length)if(D.type===3){let X=D.value.length>0?D.value[0]:"";Y=j.test(X)}else Y=!D.hasCustomName();if(!Y&&!W.prefix.length&&C&&C.type===3){let X=C.value[C.value.length-1];Y=O.prefixes.includes(X)}Y&&(f+="{"),f+=i$(W.prefix),J&&(f+=`:${W.name}`),W.type===2?f+=`(${W.value})`:W.type===1?J||(f+=`(${T})`):W.type===0&&(!J&&(!C||C.type===3||C.modifier!==3||Y||W.prefix!=="")?f+="*":f+=`(${Z})`),W.type===1&&J&&W.suffix.length&&j.test(W.suffix[0])&&(f+="\\"),f+=i$(W.suffix),Y&&(f+="}"),W.modifier!==3&&(f+=j$(W.modifier))}return f}S(NW,"partsToPattern");var sf=class{#f;#T={};#O={};#$={};#j={};#Y=!1;constructor($={},O,Z){try{let T;if(typeof O=="string"?T=O:Z=O,typeof $=="string"){let W=new SW($);if(W.parse(),$=W.result,T===void 0&&typeof $.protocol!="string")throw TypeError("A base URL must be provided for a relative constructor string.");$.baseURL=T}else{if(!$||typeof $!="object")throw TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(T)throw TypeError("parameter 1 is not of type 'string'.")}typeof Z>"u"&&(Z={ignoreCase:!1});let j={ignoreCase:Z.ignoreCase===!0},f={pathname:g1,protocol:g1,username:g1,password:g1,hostname:g1,port:g1,search:g1,hash:g1};this.#f=c$(f,$,!0),hf(this.#f.protocol)===this.#f.port&&(this.#f.port="");let z;for(z of bf){if(!(z in this.#f))continue;let W={},J=this.#f[z];switch(this.#O[z]=[],z){case"protocol":Object.assign(W,R1),W.encodePart=B3;break;case"username":Object.assign(W,R1),W.encodePart=KW;break;case"password":Object.assign(W,R1),W.encodePart=QW;break;case"hostname":Object.assign(W,qY),pf(J)?W.encodePart=df:W.encodePart=lf;break;case"port":Object.assign(W,R1),W.encodePart=uf;break;case"pathname":cf(this.#T.protocol)?(Object.assign(W,mY,j),W.encodePart=VW):(Object.assign(W,R1,j),W.encodePart=IW);break;case"search":Object.assign(W,R1,j),W.encodePart=LW;break;case"hash":Object.assign(W,R1,j),W.encodePart=MW;break}try{this.#j[z]=qf(J,W),this.#T[z]=mf(this.#j[z],this.#O[z],W),this.#$[z]=NW(this.#j[z],W),this.#Y=this.#Y||this.#j[z].some((Y)=>Y.type===2)}catch{throw TypeError(`invalid ${z} pattern '${this.#f[z]}'.`)}}}catch(T){throw TypeError(`Failed to construct 'URLPattern': ${T.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test($={},O){let Z={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&O)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return!1;try{typeof $=="object"?Z=c$(Z,$,!1):Z=c$(Z,Rf($,O),!1)}catch{return!1}let T;for(T of bf)if(!this.#T[T].exec(Z[T]))return!1;return!0}exec($={},O){let Z={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&O)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return;try{typeof $=="object"?Z=c$(Z,$,!1):Z=c$(Z,Rf($,O),!1)}catch{return null}let T={};O?T.inputs=[$,O]:T.inputs=[$];let j;for(j of bf){let f=this.#T[j].exec(Z[j]);if(!f)return null;let z={};for(let[W,J]of this.#O[j].entries())if(typeof J=="string"||typeof J=="number"){let Y=f[W+1];z[J]=Y}T[j]={input:Z[j]??"",groups:z}}return T}static compareComponent($,O,Z){let T=S((W,J)=>{for(let Y of["type","modifier","prefix","value","suffix"]){if(W[Y]<J[Y])return-1;if(W[Y]===J[Y])continue;return 1}return 0},"comparePart"),j=new h$(3,"","","","",3),f=new h$(0,"","","","",3),z=S((W,J)=>{let Y=0;for(;Y<Math.min(W.length,J.length);++Y){let C=T(W[Y],J[Y]);if(C)return C}return W.length===J.length?0:T(W[Y]??j,J[Y]??j)},"comparePartList");return!O.#$[$]&&!Z.#$[$]?0:O.#$[$]&&!Z.#$[$]?z(O.#j[$],[f]):!O.#$[$]&&Z.#$[$]?z([f],Z.#j[$]):z(O.#j[$],Z.#j[$])}get protocol(){return this.#$.protocol}get username(){return this.#$.username}get password(){return this.#$.password}get hostname(){return this.#$.hostname}get port(){return this.#$.port}get pathname(){return this.#$.pathname}get search(){return this.#$.search}get hash(){return this.#$.hash}get hasRegExpGroups(){return this.#Y}};S(sf,"URLPattern");function mO($,O){for(let[Z,T]of Object.entries($)){let j=new sf({pathname:Z});if(j.test({pathname:O}))return{routePath:Z,params:j.exec({pathname:O})?.pathname.groups??{},route:T}}return null}var f$={startIndex:0,carriedViews:[]};function _W($,O){let Z=T0($.path,O);return Z.includes("*")?null:Z}function yY($,O){if(!$)return f$;if($.search!==O.search)return f$;let Z=Math.min($.segments.length,O.segments.length-1),T=0;while(T<Z){let j=$.segments[T],f=O.segments[T];if(f.alwaysRun)break;if(j.viewPath!==f.viewPath)break;let z=_W(j,$.params),W=_W(f,O.params);if(z===null||W===null||z!==W)break;T++}if(T===0)return f$;return{startIndex:T,carriedViews:O.segments.slice(0,T).map(({viewPath:j})=>j)}}function pY($,O){let[,Z,...T]=$.split("/");if(!O.includes(Z))return $;let j=`/${T.join("/")}`;return j==="/"?"/":j.replace(/\/$/,"")}function AW($){let{flatViewRoutes:O,supportedLocales:Z,from:T,origin:j,to:f}=$;if(!T)return f$;let z;try{z=new URL(T,j)}catch{return f$}if(z.origin!==j)return f$;let W=mO(O,pY(z.pathname,Z));if(!W)return f$;return yY({segments:W.route.segments,params:W.params,search:z.search},f)}var nf="x-gemi-from";import{createElement as o$,Fragment as YC}from"react";function cY($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function K3($){let O={};for(let[Z,T]of Object.entries($))if("run"in T){let j=T.viewPath;if("children"in T){O[Z]=[j];let f=new T.children,z=K3(f.routes);for(let[W,J]of Object.entries(z)){let Y=Z==="/"?W:`${Z}${W}`,C=W==="/"&&Z!=="/"?Z:Y;O[C]=[j,...J]}if(O[Z].length===1)delete O[Z]}else O[Z]=[j]}else{let j=new T,f=K3(j.routes);for(let[z,W]of Object.entries(f)){let J=Z==="/"?z:`${Z}${z}`,Y=z==="/"&&Z!=="/"?Z:J;O[Y]=W}}return Object.fromEntries(Object.entries(O).map(([Z,T])=>[cY(Z),T]))}function Q3($){let O=[];for(let[Z,T]of Object.entries($))if("run"in T){let j=T.viewPath;if(j==="__")continue;if(j==="REDIRECT")continue;if(j==="FILE")continue;if("children"in T){let f=new T.children,z=Q3(f.routes);O.push([j,z])}else O.push([j,[]])}else{let j=new T,f=Q3(j.routes);O.push(...f)}return O}function af($){let O=[];for(let[Z,T]of $)O.push(Z,...af(T).flat());return Array.from(new Set(O))}class l$ extends w0{static getFacadeAccessor(){return s}static getSupportedLocales(){return this.getFacadeRoot().supportedLocales}static getDefaultLocale(){return this.getFacadeRoot().defaultLocale}static locale(){let $=this.getFacadeRoot(),O=x.getStore();if(O)return O.locale??$.detectLocale(O.req);return $.defaultLocale}static setLocale($=l$.locale()){let O=this.getFacadeRoot(),Z=$;if(!O.supportedLocales.includes($))Z=O.defaultLocale;let T=x.getStore();return T.setCookie("i18n-locale",Z,{expires:new Date(Date.now()+31536000000),secure:!1,httpOnly:!1}),T.setLocale(Z),Z}}class of{id;static token="kernel.id";constructor($=crypto.randomUUID()){this.id=$}}var iY=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),hY=new Set(["svg","math"]);function EW($){return $===32||$===9||$===10||$===12||$===13}function PW($){return $>=65&&$<=90||$>=97&&$<=122}function V3($){return $>=65&&$<=90?$+32:$}function HW(){let $="data",O="",Z=!1,T="",j=0,f=0,z=!1,W=0,J=0,Y=()=>$==="data"&&W===0&&J===0,C=()=>{if(!Z&&iY.has(O)){$="rawText",T=`</${O}`,j=0,O="";return}if($="data",O==="template")if(Z)W=Math.max(0,W-1);else W+=1;else if(hY.has(O)){if(Z)J=Math.max(0,J-1);else if(!z)J+=1}O=""},D=(X)=>{switch($){case"data":if(X===60)$="tagOpen";return;case"tagOpen":if(X===33)$="bang",f=0;else if(X===47)$="endTagOpen";else if(PW(X))$="tagName",Z=!1,z=!1,O=String.fromCharCode(V3(X));else if(X===63)$="bogus";else if(X===60)$="tagOpen";else $="data";return;case"endTagOpen":if(PW(X))$="tagName",Z=!0,z=!1,O=String.fromCharCode(V3(X));else if(X===62)$="data";else $="bogus";return;case"tagName":if(EW(X)||X===47)$="inTag",z=X===47;else if(X===62)C();else O+=String.fromCharCode(V3(X));return;case"inTag":if(X===62){C();return}if(z=X===47,X===34)$="attrDouble";else if(X===39)$="attrSingle";return;case"attrDouble":if(X===34)$="inTag";z=!1;return;case"attrSingle":if(X===39)$="inTag";z=!1;return;case"bang":if(X===45){if(f+=1,f===2)$="comment",f=0}else if(X===62)$="data";else $="bogus";return;case"bogus":if(X===62)$="data";return;case"comment":if(X===45)f=f<2?f+1:2;else if(X===62&&f>=2)$="data",f=0;else f=0;return;case"rawText":{if(j<T.length){if(V3(X)===T.charCodeAt(j))j+=1;else j=X===60?1:0;return}if(X===62)$="data",O="";else if(EW(X)||X===47)$="inTag",O="";else j=X===60?1:0;return}}};return{scanToInsertionPoint(X){for(let U=0;U<X.length;U++){if(Y())return U;D(X[U])}return X.length},write(X){for(let U=0;U<X.length;U++)D(X[U])},isSafe:Y}}function z$($){let O=JSON.stringify($);if(O===void 0)return"undefined";return O.replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function lY($){return`<script>(self.__GEMI_STREAM__=self.__GEMI_STREAM__||[]).push(${z$([$.path,$.variantKey,$.data])})</script>`}function dY($){return`<script>(self.__GEMI_DICT__=self.__GEMI_DICT__||[]).push(${z$([$.id,$.locale,$.strings])})</script>`}function rf($,O,Z={},T){let j=new TextEncoder,f=[],z=!1,W=!1,J=()=>{if(W)return;W=!0,Z.onClose?.()};O.onSettle((F)=>{if(F.status!=="resolved")return;f.push(lY(F))}),T?.onUse((F)=>{f.push(dY(F))});let Y=$.getReader(),C=HW(),D=(F,G)=>{F.enqueue(G),Z.onChunk?.(G)},X=(F)=>{while(f.length>0){let G=j.encode(f.shift());C.write(G),D(F,G)}},U=(F,G)=>{if(f.length===0){C.write(G),D(F,G);return}let B=C.scanToInsertionPoint(G);if(B>0)D(F,G.subarray(0,B));if(C.isSafe())X(F);let Q=G.subarray(B);if(Q.length>0)C.write(Q),D(F,Q)};return new ReadableStream({async pull(F){let G;try{G=await Y.read()}catch(L){throw J(),L}let{done:B,value:Q}=G;if(B){X(F),F.close(),J();return}if(!z){if(z=!0,C.write(Q),D(F,Q),Z.onShell?.(),C.isSafe())X(F);return}U(F,Q)},cancel(F){return J(),Y.cancel(F)}})}var uY=/bot|crawler|spider|crawling|slurp|bingpreview|mediapartners|headless|lighthouse|prerender|facebookexternalhit|whatsapp|telegram|discord|twitterbot|linkedinbot/i;function I3($){if(!$)return!1;return uY.test($)}async function bW($,O=()=>{}){let Z=x.getStore(),T=Z?.req??null,j=null;if(T?.rawRequest?.url)try{j=new URL(T.rawRequest.url).pathname}catch{j=null}return{user:Z?.user??null,attributes:await sY($,O),request:{path:j,routePath:T?.routePath??null,locale:Z?.locale??null},anonymousId:wW(),isBot:I3(T?.rawRequest?.headers?.get("user-agent")??null),now:new Date}}function vW($){return{user:$.user??null,attributes:$.attributes??{},request:{path:null,routePath:null,locale:null},anonymousId:$.subjectId??null,isBot:!1,now:new Date}}async function sY($,O){if(!$.context)return{};try{let Z=x.getStore();return await $.context(Z?.req??null)??{}}catch(Z){return O(`The \`context\` hook in app/config/features.ts threw; evaluating with no attributes. ${Z instanceof Error?Z.message:String(Z)}`),{}}}function gW($,O){return`${$}:${O}`}function tf($){let O=new Bun.CryptoHasher("sha1").update($).digest("hex"),Z=Number.parseInt(O.slice(0,8),16);return Math.floor(Z/4294967296*1e4)}function RW($,O){if(O>=100)return!0;if(O<=0)return!1;return $<Math.round(O*100)}function kW($,O,Z,T){if(T.unavailable)return{value:!1,reason:"unavailable"};if(T.active!==!0)return{value:!1,reason:"inactive"};if(O.when){let f;try{f=O.when(Z)}catch(z){return T.warn?.(`The \`when\` for feature "${$}" threw; treating it as off. ${z instanceof Error?z.message:String(z)}`),{value:!1,reason:"error"}}if(typeof f==="boolean")return{value:f,reason:"attributed"}}if(O.rollout===void 0)return{value:!0,reason:"on"};if(Z.isBot)return{value:!1,reason:"bot"};let j=aY($,O,Z,T.buckets);return RW(j,O.rollout)?{value:!0,reason:"rollout"}:{value:!1,reason:"excluded"}}function nY($){let O=$.user?.publicId??$.user?.id;if(O!==void 0&&O!==null)return String(O);return $.anonymousId??""}function aY($,O,Z,T){let j=gW(O.salt??$,nY(Z));if(!T)return tf(j);let f=T.get(j);if(f!==void 0)return f;let z=tf(j);return T.set(j,z),z}class qW 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 ef{source;declared;ttlMs;warn;snapshot=null;inflight=null;lastFailureLoggedAt=0;generation=0;lastError=null;retryAfter=0;constructor($,O,Z,T=()=>{}){this.source=$;this.declared=O;this.ttlMs=Z;this.warn=T}async get(){let $=this.snapshot;if($&&Date.now()-$.loadedAt<this.ttlMs)return $;if($){if(Date.now()>=this.retryAfter)this.refresh().catch(()=>{});return $}return await this.refresh()}refresh(){return this.inflight??=this.load().finally(()=>{this.inflight=null}),this.inflight}async invalidate(){await this.inflight?.catch(()=>{});let $=this.generation,O=await this.refresh();if(this.generation===$)throw new qW(this.lastError);return O}peek(){return this.snapshot}async load(){try{let $=await this.source.load(),{active:O,audit:Z}=this.readRows($);return this.snapshot={active:O,audit:Z,loadedAt:Date.now(),unavailable:!1},this.generation++,this.lastError=null,this.retryAfter=0,this.snapshot}catch($){return this.handleFailure($)}}readRows($){let O=new Map,Z=new Map;for(let T of $??[]){let j=typeof T?.key==="string"?T.key:null;if(!j){this.warn("Ignoring a feature row with no `key`.");continue}if(!(j in this.declared)){this.warn(`Feature row "${j}" is not declared in app/features, so it is ignored. Delete the row, or declare the feature.`);continue}O.set(j,T.active===!0);let f=oY(T);if(f)Z.set(j,f)}return{active:O,audit:Z}}handleFailure($){let O=$ instanceof Error?$.message:String($),Z=Date.now();if(this.lastError=$,this.retryAfter=Z+this.ttlMs,Z-this.lastFailureLoggedAt>=this.ttlMs)this.lastFailureLoggedAt=Z,this.warn(`Could not load feature switches: ${O}`);if(this.snapshot)return this.snapshot;return this.snapshot={active:new Map,audit:new Map,loadedAt:Z,unavailable:!0},this.snapshot}}function oY($){let O={},Z=$.updatedBy;if(typeof Z==="string")O.updatedBy=Z;else if(Z===null)O.updatedBy=null;let T=$.updatedAt;if(T instanceof Date||typeof T==="string"||typeof T==="number"){let j=T instanceof Date?T:new Date(T);if(!Number.isNaN(j.getTime()))O.updatedAt=j}return"updatedBy"in O||"updatedAt"in O?O:null}class rY{}class tY 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 $4 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 mW 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 yW{manager;ctx;constructor($,O){this.manager=$;this.ctx=O}async enabled($){return(await this.explain($)).value}async explain($){return await this.manager.evaluateIn($,this.ctx,new Map)}async all(){return await this.manager.evaluateAllIn(this.ctx,new Map,{clientOnly:!1})}}class d${config;log;static token="features";store;declared;warnedAboutSize=!1;warnedAboutActor=!1;constructor($,O=()=>{}){this.config=$;this.log=O;this.declared=$.features??{},this.store=new ef($.source,this.declared,Math.max(0,$.ttl)*1000,this.log)}declarations(){return this.declared}async list(){let{active:$,audit:O,unavailable:Z}=await this.switches();return{unavailable:Z,features:Object.entries(this.declared).map(([T,j])=>({key:T,describe:j.describe,rollout:j.rollout,targeted:j.when!==void 0,serverOnly:j.serverOnly,salt:j.salt,active:$.get(T),...O.get(T)}))}}async refresh(){if(!this.config.enabled)return;if(Object.keys(this.declared).length===0)return;await this.store.refresh()}async invalidate(){try{if(this.config.enabled&&Object.keys(this.declared).length>0)await this.store.invalidate()}finally{x.getStore()?.featureEvaluations?.clear()}}async set($,O,Z={}){if(typeof $!=="string"||!Object.hasOwn(this.declared,$))throw new mW(String($));if(typeof O!=="boolean")throw TypeError(`Features.set("${$}", \u2026) takes a boolean, not ${O===null?"null":typeof O}.`);let T=eY(Z.actor),j=this.config.source;if(typeof j.write!=="function")throw new $4(j.constructor?.name||"an anonymous source");let{actorRecorded:f}=await j.write($,O,{actor:T});if(T!==null&&!f&&!this.warnedAboutActor)this.warnedAboutActor=!0,this.log('Features.set() was given an actor, but the feature source has nowhere to record it. For the database source, add a nullable `updatedBy String?` column to the feature flag model to keep "last changed by".');await this.invalidate()}async enabled($){return(await this.explain($)).value}async explain($){let O=await this.requestContext();return await this.evaluateIn($,O,this.requestBuckets())}async all(){let $=await this.requestContext();return await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!1})}async forClient(){if(!this.config.enabled)return{};let $=await this.requestContext(),O=await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!0});return this.warnIfOversized(Object.keys(O).length),O}for($){return new yW(this,vW($))}async evaluateIn($,O,Z){let T=this.memoFor(O),j=T?.get($);if(j)return j;let f=this.declared[$];if(!f)return{value:!1,reason:"undeclared"};let{active:z,unavailable:W}=await this.switchFor($),J=kW($,f,O,{active:z,unavailable:W,buckets:Z,warn:this.log});return T?.set($,J),this.notify($,J,O),J}async evaluateAllIn($,O,Z){let T={};for(let[j,f]of Object.entries(this.declared)){if(Z.clientOnly&&f.serverOnly)continue;T[j]=(await this.evaluateIn(j,$,O)).value}return T}async switches(){if(!this.config.enabled||Object.keys(this.declared).length===0)return{active:new Map,audit:new Map,unavailable:!1};let $=await this.store.get();return{active:$.active,audit:$.audit,unavailable:$.unavailable}}async switchFor($){if(!this.config.enabled)return{active:!1,unavailable:!1};let O=await this.store.get();return{active:O.active.get($),unavailable:O.unavailable}}async requestContext(){let $=x.getStore();if($?.featureContext)return $.featureContext;let O=await bW(this.config,this.log);if($)$.featureContext=O;return O}memoFor($){let O=x.getStore();if(!O||O.featureContext!==$)return null;return O.featureEvaluations??=new Map,O.featureEvaluations}requestBuckets(){let $=x.getStore();if(!$)return new Map;return $.featureBuckets??=new Map,$.featureBuckets}notify($,O,Z){if(!this.config.onEvaluate)return;try{this.config.onEvaluate($,O,Z)}catch(T){this.log(`The \`onEvaluate\` hook in app/config/features.ts threw for "${$}". ${T instanceof Error?T.message:String(T)}`)}}warnIfOversized($){if(this.warnedAboutSize||$<=this.config.maxClientFlags)return;this.warnedAboutSize=!0,this.log(`${$} client-visible features are embedded in every document. Mark the ones only the server reads with \`serverOnly: true\` to keep them out of the payload.`)}}function eY($){if($===void 0||$===null)return null;if(typeof $==="string"){if($.length>0)return $}else if(typeof $==="object"){let{publicId:O,id:Z}=$;if(typeof O==="string"&&O.length>0)return O;if(typeof Z==="string"&&Z.length>0||typeof Z==="number")return String(Z)}throw TypeError("Features.set() was given an `actor` that identifies nobody. Pass a string, or a user with a `publicId` or an `id`.")}function pW($){return Object.fromEntries(Object.entries($).filter(([,O])=>{return O!==null&&O!==void 0}))}var $C=50;class u${fetcher;entries=new Map;settleListener=null;failListener=null;shellAt=null;settledBacklog=[];shipped=new Set;requestStartedAt=performance.now();renderStartedAt=null;discoveryHintsMuted=!1;constructor($){this.fetcher=$}elapsed(){return Math.round(performance.now()-this.requestStartedAt)}keyFor($,O){return[$,O].filter((Z)=>Z.length>0).join("?")}markRenderStart(){if(this.renderStartedAt===null)this.renderStartedAt=performance.now()}markShell(){if(this.shellAt===null)this.shellAt=this.elapsed()}summarize($){let O=this.elapsed();return{shellAt:this.shellAt??O,settledAt:O,aborted:$,queries:Array.from(this.entries.values(),(Z)=>({path:Z.path,variantKey:Z.variantKey,startedAt:Z.startedAt,settledAt:Z.settledAt,status:Z.status,source:Z.source}))}}onQueryFail($){this.failListener=$}muteDiscoveryHints(){this.discoveryHintsMuted=!0}maybeLogLateDiscovery($){if(!$.lateBy||this.discoveryHintsMuted)return;if($.status!=="resolved")return;if(Bun.env.NODE_ENV==="production")return;let O="";try{let j=JSON.stringify($.data)?.length??0;O=j>=1024?`${(j/1024).toFixed(1)} kB`:`${j} B`}catch{O="an unserializable payload"}let Z=($.settledAt??0)-$.startedAt,T=$.variantKey?`, { search: ${JSON.stringify(Object.fromEntries(new URLSearchParams($.variantKey)))} }`:"";console.warn(`[gemi] useQuery("${$.patternPath}") was discovered ${$.lateBy}ms into the `+`server render \u2014 under a suspended segment, so its fetch (${Z}ms, resolved ${O}) could not overlap the others. It still streamed. If the query belongs on this route, \`Query.prefetch("${$.patternPath}"${T})\` in the view `+"handler starts it at request time \u2014 but note prefetched data is also re-fetched and "+`streamed into every client-side navigation payload for the route, even when the client already holds it, so weigh that bandwidth against the ${O}. If the data is only needed conditionally (a closed popover, a hidden tab), \`{ lazy: true }\` + \`trigger()\` avoids running it here at all. \`Query.noPrefetch()\` in the handler marks the omission intentional and silences this hint for the route.`)}read($,O){return this.entries.get(this.keyFor($,O))}ensure($,O={},Z="render"){let T=O.params??{},j=new URLSearchParams(pW(O.search??{}));j.delete("json"),j.sort();let f=T0($,T),z=j.toString(),W=this.keyFor(f,z),J=this.entries.get(W);if(J)return J;let Y;if(Z==="render"&&this.renderStartedAt!==null){let U=Math.round(performance.now()-this.renderStartedAt);if(U>$C)Y=U}let C,D=new Promise((U)=>{C=U}),X={path:f,patternPath:$,variantKey:z,lateBy:Y,status:"pending",promise:D,source:Z,startedAt:this.elapsed()};return this.entries.set(W,X),this.fetcher($,T,j).then((U)=>{X.status="resolved",X.data=U},(U)=>{X.status="rejected",X.error=U}).then(()=>{if(X.settledAt=this.elapsed(),this.maybeLogLateDiscovery(X),X.status==="rejected"&&this.failListener)this.failListener(X);if(this.settleListener)this.settleListener(X);else this.settledBacklog.push(X);C()}),X}async allSettled(){let $=0;while($!==this.entries.size)$=this.entries.size,await Promise.all(Array.from(this.entries.values(),(O)=>O.promise))}snapshotResolved(){let $={};for(let[O,Z]of this.entries){if(Z.status!=="resolved")continue;this.shipped.add(O),$[Z.path]??={},$[Z.path][Z.variantKey]=Z.data}return $}onSettle($){this.settleListener=(Z)=>{if(this.shipped.has(this.keyFor(Z.path,Z.variantKey)))return;$(Z)};let O=this.settledBacklog;this.settledBacklog=[];for(let Z of O)this.settleListener(Z)}}class k1 extends Error{path;variantKey;status;body;retryAfter;constructor($,O,Z,T,j){super(typeof T?.message==="string"?T.message:`Request to /api${$} failed with status ${Z}`);this.path=$;this.variantKey=O;this.status=Z;this.body=T;this.retryAfter=j;this.name="QueryError"}}function s$(){let $=JSON.stringify({error:K1("permission","Forbidden",403)});return new Response($,{status:403,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}function O4(){return{status:403,error:{message:"Forbidden"}}}function yO($){let O=n$.getStore();return(Z,T,j)=>{let f=new URL($.url).origin,z=[T0(Z,T),j.toString()].filter((C)=>C.length>0).join("?"),W=new Request(`${f}/${z}`,{headers:$.headers,signal:$.signal}),J=cW($);if(J)a$(W,J);let Y=new _(W,T);return n$.run(O,()=>x.run(Y,async()=>{try{let C=await K(s0).dispatchers(J).api.getRouteData(Z);if(F$(C)){if(!C.ok)throw new k1(T0(Z,T),j.toString(),C.status,C.body);return C.body}if(C instanceof Response){let D=await C.json().catch(()=>null);if(!C.ok)throw new k1(T0(Z,T),j.toString(),C.status,D);return D}return C}catch(C){if(C instanceof k1)throw C;let D=new k1(T0(Z,T),j.toString(),500,{message:C instanceof Error?C.message:String(C)});throw D.cause=C,D}}))}}var OC=new Set(["script","style","template","title"]),ZC=/\shidden([\s=/]|$)/i,TC=/"[^"]*"|'[^']*'/g;function jC($){let O=0,Z=0,T=0,j=0;while(j<$.length){let f=$.indexOf("<",j),z=f===-1?$.length:f;if(z>j){let D=$.slice(j,z).replace(/\s+/g,"").length;if(T>0)Z+=D;else O+=D}if(f===-1)break;if($.startsWith("<!--",f)){let D=$.indexOf("-->",f+4);j=D===-1?$.length:D+3;continue}let W=$.indexOf(">",f);if(W===-1)break;let J=$.slice(f+1,W);j=W+1;let Y=/^\/?([a-zA-Z][a-zA-Z0-9-]*)/.exec(J)?.[1]?.toLowerCase();if(!Y)continue;let C=J.startsWith("/");if(!C&&OC.has(Y)&&!J.endsWith("/")){let D=$.indexOf(`</${Y}`,j);j=D===-1?$.length:D;continue}if(Y!=="div")continue;if(C){if(T>0)T-=1}else if(T>0)T+=1;else if(ZC.test(J.replace(TC,'""')))T=1}return{shellChars:O,deferredChars:Z}}var fC=1000,zC=64;function WC($){return $>=1000?`${($/1000).toFixed(1)} kB`:`${$} chars`}function JC($,O){if(O.deferredChars<fC)return null;if(O.shellChars>=zC)return null;return`[gemi] GET ${$} streams ${WC(O.deferredChars)} of its `+`content behind reveal scripts \u2014 a no-JS visitor sees ~${O.shellChars} chars. If this is a public/content route, add "no-stream" to its middleware.`}function iW($=console.warn){let O=new Set;return{shouldObserve(Z){return!O.has(Z)},report(Z,T){if(O.has(Z))return;let j=JC(Z,T);if(!j)return;O.add(Z),$(j)}}}function hW(){let $=new TextDecoder,O="";return{onChunk(Z){O+=$.decode(Z,{stream:!0})},measure(){return O+=$.decode(),jC(O)}}}function lW($,O,Z=1e4,T){let j=new TextEncoder,f=()=>{};return new ReadableStream({start(z){let W=!1,J=(C)=>{if(W)return;W=!0,clearTimeout(Y);try{z.close()}catch{}T?.({aborted:C})};f=J,z.enqueue(j.encode(`${JSON.stringify($)}
|
|
3
|
-
`)),O.onSettle((C)=>{if(W||C.status!=="resolved")return;z.enqueue(j.encode(`${JSON.stringify([C.path,C.variantKey,C.data])}
|
|
4
|
-
`))});let Y=setTimeout(()=>J(!0),Z);O.allSettled().then(()=>J(!1),()=>J(!1))},cancel(){f(!1)}})}var CC=async()=>(await import("./chunk-wwzg4dmy.js")).default,Z4,T4=async(...$)=>{return Z4??=import("react-dom/server.browser").catch((O)=>{throw Z4=void 0,O}),(await Z4).renderToReadableStream(...$)},XC=1e4,DC=`
|
|
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 FC($,O,Z){let T=`${Z==="italic"?"italic,":""}wght@${Z==="italic"?"1,":""}${O}`,z=(await(await fetch(`https://fonts.googleapis.com/css2?family=${$}:${T}&display=swap`,{headers:{"User-Agent":"Mozilla/5.0 Firefox/1.0"}})).text()).match(/url\(([^)]+)\)/)?.[1];return await fetch(z).then((W)=>W.arrayBuffer())}var z4="/assets";function UC($){return $===z4||$.startsWith(`${z4}/`)}function GC($){let O=$.filter(UC);if(O.length>0){let Z=O.length>1;throw Error(`View route path${Z?"s":""} ${O.map((T)=>`"${T}"`).join(", ")} use${Z?"":"s"} the reserved "${z4}" prefix. The client build output is served from there before the router runs, so the route would never match. Mount it somewhere else.`)}}function BC($){let O=K(s0).resolver;return{...$.domain,root:O.root,origin:O.publicOrigin($.rawRequest)}}function j4($){let{status:O=400,error:Z}=$;return new Response(Z?.message,{...$,status:O})}function KC($){let{status:O=400,data:Z,directive:T,headers:j}=$;return new Response(JSON.stringify({data:Z,directive:T}),{headers:j,status:O})}class iO{static token="router.view";flatViewRoutes={};routeManifest={};clientRouteManifest={};componentTree=[];flatComponentTree=[];root=null;shellReporter=iW();preloadCache=new WeakMap;hooks;partialRendering;constructor($){let O=ZW();this.partialRendering=$.partialRendering??O.partialRendering,this.hooks={onRequestStart:$.onRequestStart??O.onRequestStart,onRequestEnd:$.onRequestEnd??O.onRequestEnd,onRequestFail:$.onRequestFail??O.onRequestFail,onStreamComplete:$.onStreamComplete??O.onStreamComplete};let Z={"/":$.rootRouter,"/auth":Mf};this.flatViewRoutes=G3(Z),GC(Object.keys(this.flatViewRoutes)),this.routeManifest=K3(Z),this.clientRouteManifest=Object.fromEntries(Object.entries(this.routeManifest).filter(([,T])=>T.at(-1)!=="FILE")),this.componentTree=Q3(Z),this.flatComponentTree=af(this.componentTree),this.root=$.root}async passesFeatureGates($){let O=K(d$);for(let Z of $)if(!await O.enabled(Z))return!1;return!0}async onRequestEnd($){return f4(),await this.hooks.onRequestEnd($)}completeStream($,O){let Z=(T)=>{W$.error(T?.message??'Error in "onStreamComplete" event handler',{err:JSON.stringify(T)})};try{Promise.resolve(this.hooks.onStreamComplete($,O)).catch(Z)}catch(T){Z(T)}}modulePreloadLinks($){let{clientEntry:O,modulePreloadManifest:Z,views:T,routeKey:j}=$,f=()=>{let J=new Set(O?.preload??[]);for(let Y of T)for(let C of Z?.[Y]??[])J.add(C);return[...J].map((Y)=>o$("link",{key:`modulepreload:${Y}`,rel:"modulepreload",href:Y}))};if(!Z)return f();let z=this.preloadCache.get(Z);if(!z||z.clientEntry!==O)z={clientEntry:O,byRoute:new Map},this.preloadCache.set(Z,z);let W=z.byRoute.get(j);if(!W)W=f(),z.byRoute.set(j,W);return W}async render($){let{req:O,runInRequestScope:Z,csrfTokenHMAC:T,currentPathName:j,headers:f,i18n:z,params:W,pathname:J,serverQueries:Y,userAgent:C,noStream:D,url:X,user:U,viewData:F,breadcrumbs:G,urlLocaleSegment:B,meta:Q,isOgRequest:L,appId:V,features:N}=$,A=J.replace(`/${B}`,""),I={kind:"view",data:{meta:Q,pageData:{[A]:F},__csrf:T.toString("base64"),prefetchedData:{},i18n:z,auth:{user:U},routeManifest:this.clientRouteManifest,breadcrumbs:G,router:{urlLocaleSegment:B,pathname:j,params:W,currentPath:J,searchParams:X.search,is404:!j?!0:!1,domain:O.domain?BC(O):null},appId:V,features:N,componentTree:[["404",[]],...this.componentTree]},head:{}},M=this.root,E=this.routeManifest[j];return async(P)=>{let{bootstrapModules:$0=[],loaders:g,getStyles:q,viewImportMap:O0,cssManifest:_3,ogMap:hO,viewModules:J$,clientEntry:T1,modulePreloadManifest:q1,assetBase:Z0}=P,e$=T1?[]:$0,lO=(M0)=>[M0,`window.loaders=${g}`,...T1?[`import(${JSON.stringify(T1.module)}).catch(function(e){setTimeout(function(){throw e})})`]:[]].join(";");if(L){let M0=null,X$=null;for(let D$ of E??[])if(typeof hO[D$]==="function")X$=D$,M0=hO[D$];if(!M0)return new Response("Not found",{status:404});let V5=Object.values(I.data.pageData)[0];try{await T4(o$(M0,V5[X$]),{onError:()=>{}})}catch(D$){let{fonts:I5,...L5}=D$.satoriOptions,M5=await Promise.all(I5.map((uO)=>{return FC(uO.name,uO.weight,uO.style).then((A5)=>({...uO,data:A5}))})),U4=new Headers(f);U4.set("Content-Type","image/png");let[S5,x5]=await Promise.all([CC(),F3("Rendering an OG image")]),N5=await S5(D$.jsx,{...L5,fonts:M5}),_5=await x5(Buffer.from(N5)).png({compressionLevel:0,effort:10}).toBuffer();return new Response(new Uint8Array(_5),{headers:U4})}return new Response("data")}if(I.data.cssManifest=_3,I.data.modulePreloadManifest=q1??{},Z0&&Z0!=="/")I.data.assetBase=Z0;let Y$=this.modulePreloadLinks({clientEntry:T1,modulePreloadManifest:q1,views:E??["404"],routeKey:j??"404"}),$O=await q(E);I.data.prefetchedData=Y.snapshotResolved(),Y.markRenderStart();let G1=new AbortController,dO=setTimeout(()=>G1.abort(),XC),H=I3(C)||D,L0=Bun.env.NODE_ENV!=="production"&&!H&&j&&this.shellReporter.shouldObserve(j)?hW():null,C$=sW();try{let M0=await T4(o$(YC,{children:[...Y$,...$O,o$("script",{key:"theme-script",dangerouslySetInnerHTML:{__html:DC}}),o$(M,{data:I.data,viewImportMap:O0,viewModules:J$,serverQueries:Y,dictionarySink:C$,key:"root"})]}),{bootstrapScriptContent:lO(`window.__GEMI_DATA__ = ${z$(I.data)}`),bootstrapModules:e$,signal:G1.signal,...H?{progressiveChunkSize:Number.MAX_SAFE_INTEGER}:{},onError(X$){if(Bun.env.NODE_ENV!=="production")console.error(X$)}});if(M0.allReady.catch(()=>{}).finally(()=>clearTimeout(dO)),H)await M0.allReady.catch(()=>{});return new Response(rf(M0,Y,{onShell:H?void 0:()=>Y.markShell(),onChunk:L0?.onChunk,onClose:()=>Z(()=>{if(this.completeStream(O,Y.summarize(G1.signal.aborted)),L0)this.shellReporter.report(j,L0.measure())})},C$),{status:!j?404:200,headers:f})}catch(M0){if(clearTimeout(dO),Bun.env.NODE_ENV==="production")throw Z(()=>this.completeStream(O,Y.summarize(G1.signal.aborted))),M0;let X$=await T4(o$("div"),{bootstrapScriptContent:lO(`window.error= ${z$(M0.message)}; window.stack_trace=${z$(M0.stack)};window.__GEMI_DATA__ = ${z$(I.data)}`),bootstrapModules:Bun.env.NODE_ENV==="development"?["/render-error.js",...e$]:e$});return new Response(rf(X$,Y,{onClose:()=>Z(()=>this.completeStream(O,Y.summarize(G1.signal.aborted)))}),{status:!j?404:200,headers:f})}}}async handleViewRequest($,O){let Z=new URL($.url),T=Z.pathname.endsWith(".json"),j=Z.pathname.endsWith(".og"),f=Z.pathname.replace(".json","").replace(".og",""),[,z,...W]=f.split("/"),J=`/${W.join("/")}`,Y=null,C=null,D=K(s);if(!D.supportedLocales.includes(z))J=f;else Y=z,C=z;let U=C===null&&mO(this.flatViewRoutes,J)!==null;if(D.isLocaleAware&&!j&&C===null&&!U){let I=dW(z,D.supportedLocales,D.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}${T?".json":""}${Z.search}`}})}}if(D.isLocaleAware&&!j){let I=K(s).detectLocale(new _($,{},"view",J));if(C===null&&I!==D.defaultLocale){let M=Z.pathname==="/"?"":Z.pathname;return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${I}${M}${Z.search}`}})}}J=J.replace("//","/");let F=[],G=[],B=null,Q={},L=null,V=!1,N=[];try{let I=mO(this.flatViewRoutes,J);if(I){if(B=I.routePath,Q=I.params,F=I.route.exec,G=I.route.middleware,N=I.route.features,V=G.includes("no-stream"),T&&this.partialRendering){let M=$.headers.get(nf),E=AW({flatViewRoutes:this.flatViewRoutes,supportedLocales:K(s).supportedLocales,from:M,origin:Z.origin,to:{segments:I.route.segments,params:Q,search:Z.search}});if(E.startIndex>0)F=F.slice(E.startIndex),L={from:M,carriedViews:E.carriedViews}}}}catch(I){throw I}let A=new _($,Q,"view",B);return this.hooks.onRequestStart(A),await x.run(A,async()=>{let I=null,M=x.getStore(),E=n$.getStore(),P=(q)=>n$.run(E,()=>x.runWith(M,q));M.serverQueries=new u$(yO($));let $0=new Set;if(M.serverQueries.onQueryFail((q)=>{$0.add(q.error);try{P(()=>Promise.resolve(this.hooks.onRequestFail(g,q.error)).catch(()=>{}))}catch{}}),C){let q=C.replaceAll("/","");l$.setLocale(q)}else l$.setLocale();let g=M.req;f4();try{let q=!1;try{await K(qO).runMiddleware(G)}catch(H){if(!r$(H))throw H;q=!0}if(q||N.length>0&&!await this.passesFeatureGates(N))B=null,F=[],g.routePath="";let O0=K(s),_3=O0.isEnabled,hO=O0.isLocaleAware,J$={};if(hO){let H=null;if(C)H=C.replaceAll("/",""),M.setLocale(H);else H=O0.detectLocale(new _($,g.params)),M.setLocale(H);let L0=_3?O0.getPageTranslations(H,g.routePath):{};J$={supportedLocales:O0.supportedLocales,currentLocale:H,dictionary:{[H]:L0},defaultLocale:O0.defaultLocale}}await uW(J$.currentLocale??"");let T1;try{T1=await Promise.all(F.map((H)=>H(g)))}catch(H){if(!r$(H))throw H;B=null,F=[],g.routePath="",T1=[]}let{cookies:q1,headers:Z0}=M;I={data:T1,cookies:q1,headers:Z0,user:M.user,prefetchedData:M.serverQueries.snapshotResolved(),currentPathName:B,params:g.params,urlLocaleSegment:Y,meta:M.renderMeta(),appId:K(of).id,features:await K(d$).forClient()};let{params:e$,user:lO}=I,Y$={},$O={};for(let H of T1??[]){let[L0,C$]=Object.entries(H)?.[0]??[];if(!L0||!C$)continue;$O[`${L0}:${B}`]=C$.breadcrumb,Y$[L0]=C$}let G1=Y$.FILE;if(G1){for(let H of q1)Z0.append("Set-Cookie",H.toString());try{await this.onRequestEnd(g)}catch(H){W$.error(H?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(H)})}return await R3(G1,Z0)}if(T){Z0.set("Content-Type","application/x-ndjson; charset=utf-8"),Z0.append("Vary",nf),q1.forEach((L0)=>Z0.append("Set-Cookie",L0.toString())),await this.hooks.onRequestEnd(g);let H={meta:L&&!M.metadata.touched?null:I.meta,data:{[J]:Y$},breadcrumbs:$O,prefetchedData:M.serverQueries.snapshotResolved(),i18n:J$,features:I.features,is404:!B,appId:I.appId,partial:L};return new Response(lW(H,M.serverQueries,void 0,({aborted:L0})=>P(()=>this.completeStream(g,M.serverQueries.summarize(L0)))),{headers:Z0})}if(Z0.set("Content-Type","text/html; charset=utf-8"),!V)Z0.append("Vary","User-Agent");for(let H of q1)Z0.append("Set-Cookie",H.toString());let dO=Bun.CSRF.generate(process.env.SECRET);Z0.append("Set-Cookie",`csrf_token=${dO}; HttpOnly; Secure; SameSite=Strict; Expires=${new Date(Date.now()+86400000).toUTCString()}`);try{await this.onRequestEnd(g)}catch(H){W$.error(H?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(H)})}return await this.render({req:g,runInRequestScope:P,csrfTokenHMAC:Buffer.from(""),currentPathName:B,headers:Z0,i18n:J$,params:e$,pathname:Z.pathname,serverQueries:M.serverQueries,userAgent:$.headers.get("user-agent"),noStream:V,url:Z,user:lO,viewData:Y$,breadcrumbs:$O,urlLocaleSegment:Y,meta:I.meta,appId:I.appId,features:I.features,isOgRequest:j})}catch(q){if(q.kind===pO)if(T)return KC(q.payload.viewData??q.payload.api);else return j4(q.payload.view);if(!$0.has(q))this.hooks.onRequestFail(g,q);if(cO(q))return console.error(q),T?s$():j4(O4());if(q instanceof k1&&q.status===403)return T?s$():j4(O4());throw q}},O)}}function J4(){let $=JSON.stringify({error:K1("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 eW extends S0{routes={"/api-routes":this.get(()=>{let $=K(L3).flatRoutes,O=[];for(let[Z,T]of Object.entries($))for(let[j,f]of Object.entries(T)){let{exec:z,middleware:W}=f;O.push({path:Z,method:j,middleware:W})}return O}),"/view-routes":this.get(()=>{let $=K(iO).flatViewRoutes,O=[];for(let[Z,{middleware:T,viewPath:j}]of Object.entries($))O.push({path:Z,method:"GET",viewPath:j,middleware:T});return O})}}function QC($,O){let Z=$.body.getReader(),T=!1,j=()=>{if(T)return;T=!0;try{O()}catch(z){console.error(z)}},f=new ReadableStream({async pull(z){let W;try{W=await Z.read()}catch(J){j(),z.error(J);return}if(W.done){j();try{z.close()}catch{}return}try{z.enqueue(W.value)}catch{}},async cancel(z){try{await Z.cancel(z)}finally{j()}}},{highWaterMark:0});return new Response(f,{status:$.status,statusText:$.statusText,headers:$.headers})}function nW($){let{status:O=400,data:Z,headers:T}=$,j=new Headers({"Content-Type":"application/json",...T});if(!j.has("Cache-Control"))j.set("Cache-Control","no-store");return new Response(JSON.stringify(Z),{status:O,headers:j})}function aW($,O,Z){let T=[];O?.forEach((z,W)=>T.push([W,z]));let j=[...typeof O?.getSetCookie==="function"?O.getSetCookie():[],...Array.from(Z??[])];if(T.length===0&&j.length===0)return $;let f=(z)=>{for(let[W,J]of T){if(W.toLowerCase()==="set-cookie")continue;if(!z.has(W))z.set(W,J)}for(let W of j)z.append("Set-Cookie",W)};try{return f($.headers),$}catch{let z=new Headers($.headers);return f(z),new Response($.body,{status:$.status,statusText:$.statusText,headers:z})}}class L3{static token="router.api";flatRoutes={};onRequestStart;onRequestEnd;onRequestFail;constructor($){let O=OW();this.onRequestStart=$.onRequestStart??O.onRequestStart,this.onRequestEnd=$.onRequestEnd??O.onRequestEnd,this.onRequestFail=$.onRequestFail??O.onRequestFail,this.flatRoutes=Pf({"/":$.rootRouter,"/auth":Sf,"/__gemi__/services/i18n":xf,"/__gemi__/services/logs":Ef,"/__gemi__/services/image":Af,"/__gemi__/debug":eW})}getRouteHandlerAndParams($){let O=new URL($.url),Z=tW(O.pathname),T={},j;for(let[f]of Object.entries(this.flatRoutes))try{let z=new URLPattern({pathname:f});if(z.test({pathname:Z})){j=f,T=z.exec({pathname:Z})?.pathname.groups;break}}catch(z){console.error(z)}return{params:T,path:j}}async runRouteMiddleware($,O){let T=this.flatRoutes[$][O.rawRequest.method].middleware;try{await K(qO).runMiddleware(T)}catch(j){if(j.kind===pO)return nW(j.payload.api);else{if(r$(j))return J4();if(this.onRequestFail(O,j),console.error(j),cO(j))return s$();throw j}}}async getRouteData($){let O=this.flatRoutes[$],Z=x.getStore(),T=O[Z.req.rawRequest.method].exec??(()=>Promise.resolve({})),j={};try{j=await T()}catch(f){if(f.kind===pO)return nW(f.payload.api);if(r$(f))return J4();if(this.onRequestFail(Z.req,f),console.error(f),cO(f))return s$();throw f}return j}isFrameworkRoute($){return $.startsWith("/__gemi__")}async endRequest($,O,Z){let T=async()=>{try{if(!this.isFrameworkRoute(Z))await this.onRequestEnd(O)}catch(j){W$.error(j?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(j)})}finally{$.destroy()}};if(!$.hasPendingWork()){await T();return}$.whenIdle().then(T).catch((j)=>{console.error(j)})}isOpenEndedBody($,O){return $.method!=="HEAD"&&O.body!==null&&!O.headers.has("Content-Length")}async handleApiRequest($,O){let{params:Z,path:T}=this.getRouteHandlerAndParams($),j=this.flatRoutes[T];if(!j||!j[$.method])return new Response(JSON.stringify({error:K1("not_found","Not found",404)}),{status:404});let f=new _($,Z,"api",T);if(!this.isFrameworkRoute(T))this.onRequestStart(f);return await x.run(f,async()=>{let z=x.getStore(),W=!1,J=async()=>{W=!0,await this.endRequest(z,f,T)};try{let Y=K(s);if(Y.isEnabled){let G=Y.detectLocale(f);z.setLocale(G)}z.setRequest(f);let C=await this.runRouteMiddleware(T,f);if(C instanceof Response){let G=aW(C,z.headers,z.cookies);return await J(),G}let D=await this.getRouteData(T),X=z.headers,U=z.cookies;if(D instanceof Response){let G=aW(D,X,U);if(this.isOpenEndedBody($,G)){let B=QC(G,()=>this.endRequest(z,f,T));return W=!0,B}return await J(),G}let F=(F$(D)?D:ZO.json(D)).toResponse(X,U);return await J(),F}catch(Y){if(!W)try{await J()}catch(C){console.error(C)}throw Y}},O)}async dispatchAs($,O,Z,T){let j=new URL($.rawRequest.url).origin,f=new URL(`${j}/api${Z}`),z=`/api${Z.split(/[?#]/)[0]}`;if(!Z.startsWith("/")||f.origin!==j||f.pathname!==z||f.hash!==""||f.pathname.startsWith("/api/__gemi__")||f.pathname==="/api/auth"||f.pathname.startsWith("/api/auth/"))throw Error(`dispatchAs: "${Z}" is not an app api path. Pass the route's own path, without "/api", with every param encoded.`);let W=new Headers,J=$.cookies.get(jO);if(J)W.set("Cookie",`${jO}=${J}`);let Y=$.headers.get(jO);if(Y)W.set(jO,Y);let C=$.headers.get("User-Agent");if(C)W.set("User-Agent",C);let D;if(T instanceof FormData)D=T;else if(T!==void 0)W.set("Content-Type","application/json"),D=JSON.stringify(T);let X=new Request(f,{method:O,headers:W,body:D});if(oW(X,tO($)),$.domain)a$(X,$.domain);return x.exit(()=>rW.exit(()=>this.handleApiRequest(X)))}}import{timingSafeEqual as VC}from"crypto";var S3="",X4="*",IC=60000,LC=1e4,Y4=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,M3=16,$5=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,C4="x-forwarded-host";function O5($){return $.startsWith(":")}function D4($,O){if($===null)return!1;let Z=Buffer.from($,"utf8"),T=Buffer.from(O,"utf8");return Z.length===T.length&&VC(Z,T)}function MC($){if(!$)return null;if($===!0)return{header:C4,secret:null};return{header:($.hostHeader??C4).toLowerCase(),secret:$.secret?{header:$.secret.header.toLowerCase(),value:$.secret.value}:null}}function SC($){if(!$||$===!0)return;let{hostHeader:O,secret:Z}=$;if(O!==void 0&&(typeof O!=="string"||!$5.test(O)))throw Error(`\`route.domains.trustProxy.hostHeader\` must be a single header name, e.g. "x-forwarded-host". Got ${JSON.stringify(O)}.`);if(!Z)return;if(typeof Z.header!=="string"||!$5.test(Z.header))throw Error(`\`route.domains.trustProxy.secret.header\` must be a header name. Got "${Z.header}".`);if(Z.header.toLowerCase()===(O??C4).toLowerCase())throw Error("`route.domains.trustProxy.secret.header` names the same header as `hostHeader`; the secret needs a header of its own.");if(typeof Z.value!=="string"||Z.value.length<M3)throw Error(`\`route.domains.trustProxy.secret.value\` must be at least ${M3} characters. A guessable one lets any client name its own host.`)}function Z1($){if(!$)return null;try{return new URL(`http://${$.trim()}`).hostname.toLowerCase().replace(/\.$/,"")||null}catch{return null}}function xC($){try{let O=new URL(`http://${$.trim()}`),Z=O.hostname.toLowerCase().replace(/\.$/,"");return Z?O.port?`${Z}:${O.port}`:Z:null}catch{return null}}function NC($){let O=Z1($.root),Z=$.root?.trim().toLowerCase().replace(/\.$/,"");if(!O||O!==Z||!O.split(".").every((f)=>Y4.test(f)))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<M3)throw Error(`\`route.domains.ask.secret\` must be at least ${M3} characters. A guessable one is worse than leaving \`ask\` out.`);SC($.trustProxy);let T=new Set,j=null;for(let f of $.groups??[]){let{subdomain:z}=f;if(T.has(z))throw Error(`\`route.domains\` declares the subdomain "${z}" twice.`);if(T.add(z),O5(z)){if(!/^:[A-Za-z_][A-Za-z0-9_]*$/.test(z))throw Error(`"${z}" is not a valid param subdomain. It must be a single \`:name\` label.`);if(j)throw Error(`\`route.domains\` declares two param subdomains, "${j.subdomain}" and "${z}"; a host could match either.`);j=f;continue}if(f.exists)throw Error(`The subdomain "${z}" is fixed, so \`exists\` has no param to check. It only applies to a \`:param\` subdomain.`);if(!z.split(".").every((W)=>Y4.test(W)))throw Error(`"${z}" is not a valid subdomain.`)}if($.custom&&!T.has($.custom.group))throw Error(`\`route.domains.custom.group\` is "${$.custom.group}", but no group declares that subdomain.`);if($.ask&&j&&!j.exists)throw Error(`\`route.domains.ask\` is set, so "${j.subdomain}" needs an \`exists\` to say which tenants are real. Without one every host under the root would be approved for a certificate.`)}class F4{root;hostTrust;fixed=new Map;param=null;custom;cacheTtlMs;cache=new Map;inFlight=new Map;askSecret;proxySecretHeader;constructor($){NC($),this.root=Z1($.root),this.hostTrust=MC($.trustProxy);for(let O of $.groups??[])if(O5(O.subdomain))this.param={...O,name:O.subdomain.slice(1)};else this.fixed.set(O.subdomain.toLowerCase(),O);this.custom=$.custom??null,this.cacheTtlMs=this.custom?.cacheTtlMs??IC,this.askSecret=$.ask?.secret??null,this.proxySecretHeader=this.hostTrust?.secret?.header??null}forwardedHost($){let O=this.hostTrust;if(!O)return null;if(O.secret&&!D4($.headers.get(O.secret.header),O.secret.value))return null;return $.headers.get(O.header)?.split(",")[0]?.trim()||null}hostOf($){return Z1(this.forwardedHost($))??Z1(new URL($.url).host)}publicOrigin($){let O=new URL($.url),Z=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),T=Z==="http"||Z==="https"?Z:O.protocol.replace(/:$/,""),j=this.forwardedHost($),f=j&&Z1(j)?xC(j):null;return`${T}://${f??O.host}`}async resolve($){let O=this.hostOf($);if(!O)return null;let Z=await this.match(O,$);if(Z)return Z;if(this.custom?.fallback&&!this.isUnderRoot(O))return{host:O,group:X4,params:{},custom:!0};return null}async allows($,O){let Z=Z1($);return Z?await this.match(Z,O)!==null:!1}isUnderRoot($){return $===this.root||$.endsWith(`.${this.root}`)}async match($,O){if($===this.root)return{host:$,group:S3,params:{},custom:!1};if($.endsWith(`.${this.root}`)){let T=$.slice(0,-(this.root.length+1)),j=this.fixed.get(T);if(j)return{host:$,group:j.subdomain,params:{},custom:!1};if(this.param&&Y4.test(T)){let f={[this.param.name]:T};if(this.param.exists&&!await this.param.exists(f,O))return null;return{host:$,group:this.param.subdomain,params:f,custom:!1}}return null}if(!this.custom)return null;let Z=await this.resolveCustom($);return Z?{host:$,group:this.custom.group,params:Z,custom:!0}:null}async resolveCustom($){let O=Date.now(),Z=this.cache.get($);if(Z&&Z.expiresAt>O)return this.cache.delete($),this.cache.set($,Z),Z.value;let T=this.inFlight.get($);if(T)return T;let j=(async()=>await this.custom.resolve($)??null)();this.inFlight.set($,j);let f;try{f=await j}finally{this.inFlight.delete($)}if(this.cacheTtlMs>0){if(this.cache.size>=LC)this.cache.delete(this.cache.keys().next().value);this.cache.delete($),this.cache.set($,{value:f,expiresAt:Date.now()+this.cacheTtlMs})}return f}forget($){if($===void 0)this.cache.clear();else{let O=Z1($);if(O)this.cache.delete(O)}}}var _C="/__gemi__/domains/ask";class s0{static token="router.domains";resolver;acceptsCustomDomains;groups=new Map;constructor($,O){this.groups.set(S3,$);let{domains:Z}=O;if(this.acceptsCustomDomains=Boolean(Z?.custom),!Z){this.resolver=null;return}this.resolver=new F4(Z);let T=(j)=>({api:j.api?new L3({...O.api,...j.api}):$.api,view:j.view?new iO({...O.view,...j.view}):$.view});for(let j of Z.groups??[])this.groups.set(j.subdomain,T(j));if(Z.custom?.fallback)this.groups.set(X4,T(Z.custom.fallback))}async route($){if(!this.resolver)return this.dispatchers(null);if(this.resolver.proxySecretHeader)Z5($,this.resolver.proxySecretHeader);let O=await this.resolver.resolve($);if(!O)return null;return a$($,O),this.dispatchers(O)}async ask($){if(!this.resolver?.askSecret||$.method!=="GET")return null;let O=new URL($.url);if(O.pathname!==_C)return null;if(!D4(O.searchParams.get("secret"),this.resolver.askSecret))return null;let Z=O.searchParams.get("domain"),T=Z?await this.resolver.allows(Z,$):!1;return new Response(null,{status:T?200:404})}dispatchers($){return this.groups.get($?.group??S3)}viewDispatchers(){return Array.from(new Set(Array.from(this.groups.values(),($)=>$.view)))}}function T5($){let O=new Date($??0).getTime();return Number.isFinite(O)?O:0}var j5=600000;function f5($,O){return[eO($,O),eO($,O-1)]}class w{static token="auth";config;provider;constructor($={},O=new s3){this.config=z5(d4($),$),this.provider=O}get userProvider(){return this.provider}accessTokenCookieOptions($,O){return{expires:O,secure:this.publicOrigin($).startsWith("https://"),httpOnly:!0,domain:this.cookieDomain($)}}publicOrigin($){let O=K().bound(s0)?K(s0).resolver:null;return O?O.publicOrigin($.rawRequest):new URL($.rawRequest.url).origin}cookieDomain($){let O=this.config.cookieDomain;if(!O)return;let Z=O==="root"?K(s0).resolver?.root:Z1(O);if(!Z)throw Error('`auth.cookieDomain` is "root", but `route.domains` is not configured.');let T=$.domain?.host??Z1(new URL($.rawRequest.url).host);return T===Z||T?.endsWith(`.${Z}`)?Z:void 0}async getSession($,O){if(!$)return null;if(!h3($))return this.config.migrateLegacySession?this.convertLegacySession($,O,this.config.migrateLegacySession):null;let Z=await this.userProvider.findSession({token:$,userAgent:O});if(!Z?.user)return null;let T=Date.now(),j=T5(Z.expiresAt),f=T5(Z.absoluteExpiresAt);if(j<=T||f<=T)return await this.userProvider.deleteSession({token:$}),null;let W=await this.slideSession(Z,T);return W.user.extension=await this.config.extendSession(W.user),W}async convertLegacySession($,O,Z){let T=x.getStore()?.req;if(!T)return null;let j=Date.now(),f=Math.floor(j/j5),z=null,W=await this.userProvider.findSession({token:$,userAgent:O});if(W?.user){if(!await Z(W,{token:$,req:T,userAgent:O}))return null;let Y=eO($,f),C=W.user.id;if(await this.userProvider.withLegacySessionLock($,async()=>{if(!await this.userProvider.claimLegacySession({token:$}))return!1;return await this.userProvider.createSessionV2({token:Y,userId:C,userAgent:O,...this.freshLifetime(j)}),!0}))z=Y}if(!z){for(let Y of f5($,f))if((await this.userProvider.findSession({token:Y,userAgent:O}))?.user){z=Y;break}}if(!z)return null;let J=await this.getSession(z,O);if(J)T.ctx().setCookie("access_token",z,this.accessTokenCookieOptions(T,new Date(J.expiresAt)));return J}async revokeSession($,O){if(!$)return await this.userProvider.deleteSession({token:$}),null;if(h3($)||!this.config.migrateLegacySession){let j=await this.userProvider.findSession({token:$,userAgent:O});return await this.userProvider.deleteSession({token:$}),j}let Z=Math.floor(Date.now()/j5),T=f5($,Z);return this.userProvider.withLegacySessionLock($,async()=>{let j=await this.userProvider.findSession({token:$,userAgent:O});for(let f of T){if(j?.user)break;j=await this.userProvider.findSession({token:f,userAgent:O})}await this.userProvider.deleteSession({token:$});for(let f of T)await this.userProvider.deleteSession({token:f});return j})}requestCarryingCookie($){let O=x.getStore()?.req;return O?.cookies.get("access_token")===$?O:null}async slideSession($,O){let Z=this.config.sessionExpiresInHours*3600000;if(new Date($.expiresAt).getTime()-O>=Z/2)return $;let T=new Date(Math.min(O+Z,new Date($.absoluteExpiresAt).getTime())),j=await this.userProvider.updateSession({token:$.token,expiresAt:T}),f=this.requestCarryingCookie($.token);if(f)f.ctx().setCookie("access_token",$.token,this.accessTokenCookieOptions(f,T));if(!j)return $;return{...$,expiresAt:j.expiresAt??T}}freshLifetime($){return{expiresAt:new Date($+this.config.sessionExpiresInHours*3600000),absoluteExpiresAt:new Date($+this.config.sessionAbsoluteExpiresInHours*3600000)}}async generateMagicLink($){}async upsertSession($){await this.userProvider.findSession({token:"",userAgent:""})}async authenticate($){try{let O=await this.userProvider.findUserByEmailAddress($,!1);if(!O)throw Error(`User not found with email: ${$}`);let Z=await this.createOrUpdateSession({email:$,id:O.id}),T=new _;if(T.ctx().setCookie("access_token",Z.token,this.accessTokenCookieOptions(T,Z.expiresAt)),Z?.user)Z.user.extension=await this.config.extendSession(Z.user);return Z}catch(O){console.log(O)}}async createOrUpdateSessionV2($){let O=await this.createOrUpdateSession($),Z=null;if(O?.user)Z=await this.config.extendSession(O.user),O.user.extension=Z;return O}async createOrUpdateSession($){let O=new _,Z=$.id??(await this.userProvider.findUserByEmailAddress($.email,!1))?.id;if(!Z)throw new y1;let T=Bun.env.NODE_ENV==="development"?"local":O.headers.get("User-Agent"),j=l4(Z),f=await this.userProvider.createSessionV2({token:j,userId:Z,userAgent:T,...this.freshLifetime(Date.now())}),z=await this.userProvider.findSession({token:j,userAgent:T??""});return z?.user?z:f}async createMagicLinkToken($){let O=await this.userProvider.findUserByEmailAddress($,!1);if(O){await this.userProvider.deleteMagicLinkToken($);let Z=await this.config.generateMagicLinkToken($),T=(Number.parseInt(AC(4).toString("hex"),16)%1e6).toString().padStart(6,"0");return await this.userProvider.createMagicLinkToken({email:$,token:Z,pin:T}),{user:O,email:$,pin:T,token:Z}}return{}}}class T$ extends w0{static getFacadeAccessor(){return w}static async user(){let $=x.getStore(),O=$?.user;if(!O){if(O=await rO(this.getFacadeRoot(),$?.req),O)$?.setUser(O)}if(O)return O;throw new y1({redirectTo:oO($?.req,this.getFacadeRoot().config.signInPath)})}static intendedUrl($){let O=x.getStore()?.req;return TO(O?.search.get(U$),$??this.getFacadeRoot().config.redirectPath)}static async guard($){let O=await T$.user();if(!await $(O))throw new c3}static async guardSafe($){let O=await T$.user();try{return await $(O)}catch(Z){return!1}}static async authenticate($){return await this.getFacadeRoot().authenticate($)}static async createMagicLink($){return await this.getFacadeRoot().createMagicLinkToken($)}}class x3{static ensure($,O={}){let Z=x.getStore();if(Z.req.kind==="api")throw Error("Query.prefetch() cannot be called from an API request");return Z.serverQueries??=new u$(yO(Z.req.rawRequest)),Z.serverQueries.ensure($,O,"prefetch")}static async instant($,...O){let Z=x3.ensure($,O[0]);if(await Z.promise,Z.status==="rejected")throw Z.error;return Z.data}static prefetch($,...O){x3.ensure($,O[0])}static noPrefetch(){let $=x.getStore();if($.req.kind==="api")throw Error("Query.noPrefetch() cannot be called from an API request");$.serverQueries??=new u$(yO($.req.rawRequest)),$.serverQueries.muteDiscoveryHints()}}function W5($,O,Z="/"){let T=new URL($.origin),j=O.host?O.host:O.subdomain?`${O.subdomain}.${$.root}`:$.root,f=new URL(Z.startsWith("/")?Z:`/${Z}`,T),z=EC(j);if(!z)throw Error(`"${j}" 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(f.hostname=z.hostname,z.port)f.port=z.port;return f.toString()}function EC($){try{let O=new URL(`http://${$.trim()}`);return O.host===$.trim().toLowerCase()&&O.pathname==="/"?{hostname:O.hostname,port:O.port}:null}catch{return null}}class J5{static absolute($,...O){return`${process.env.HOST_NAME}${T0(String($),O[0]??{})}`}static relative($,...O){return T0(String($),O[0]??{})}static forDomain($,O,...Z){let T=K(s0).resolver;if(!T)throw Error("`Url.forDomain` needs `route.domains` to be configured.");let j=x.getStore()?.req?.rawRequest,f=j?T.publicOrigin(j):process.env.HOST_NAME;if(!f)throw Error("`Url.forDomain` outside a request needs `HOST_NAME` for the protocol.");return W5({root:T.root,origin:f},$,T0(String(O),Z[0]??{}))}}class Y5{name="Meta";static description($){x.getStore().metadata.description($)}static title($){x.getStore().metadata.title($)}static openGraph($){x.getStore().metadata.openGraph($)}}var PC={set($,O,Z){x.getStore().setCookie($,O,Z)},setIfAbsent($,O,Z){if(x.getStore().req.cookies.has($))return!1;return x.getStore().setCookie($,O,Z),!0},delete($,O){x.getStore().deleteCookie($,O)}};class U1 extends w0{static getFacadeAccessor(){return C5}static get client(){return this.getFacadeRoot().client}static get($){return U1.client.get($)}static set($,O){return U1.client.set($,O)}static del(...$){return U1.client.del(...$)}static exists($){return U1.client.exists($)}static incr($){return U1.client.incr($)}static expire($,O){return U1.client.expire($,O)}static ttl($){return U1.client.ttl($)}}class X5 extends w0{static getFacadeAccessor(){return G$}static consume($,O={}){return this.getFacadeRoot().consume($,O)}}class D5 extends w0{static getFacadeAccessor(){return d$}static enabled($){return this.getFacadeRoot().enabled($)}static all(){return this.getFacadeRoot().forClient()}static explain($){return this.getFacadeRoot().explain($)}static for($){return this.getFacadeRoot().for($)}static list(){return this.getFacadeRoot().list()}static set($,O,Z){return this.getFacadeRoot().set($,O,Z)}static refresh(){return this.getFacadeRoot().refresh()}static invalidate(){return this.getFacadeRoot().invalidate()}}class N3{bound;constructor($){this.bound=$}get name(){return this.bound??zO()}get sql(){return this.connection().sql}get dialect(){return this.connection().dialect}async query($){return await this.run($,"query")}async execute($){let O=await this.run($,"execute");return Number(O?.count??0)}async transaction($){let O=this.name,Z=this.connection(O);return G5(Z.sql,(T)=>F5(O,()=>$(T)),{slowTransactionThreshold:Z.config.slowTransactionThreshold,connection:O})}async schema(){let $=this.connection(),{introspect:O}=await import("./chunk-c3gzpjba.js");return O(this.handle()??$.sql,$.dialect)}run($,O){let Z=this.connection(),{text:T,values:j}=K5($,B5(Z.dialect),O);return(this.handle()??Z.sql).unsafe(T,j)}handle(){let $=fO();if($===void 0)return;return zO()===this.name?$:void 0}connection($=this.name){return U5($),K(WO).connection($)}}var t$=new N3;class Q5 extends w0{static getFacadeAccessor(){return WO}static connection($){return new N3($)}static get sql(){return t$.sql}static get dialect(){return t$.dialect}static query($){return t$.query($)}static execute($){return t$.execute($)}static transaction($){return t$.transaction($)}static schema(){return t$.schema()}static close(){return this.getFacadeRoot().close()}}export{j1 as kc,OO as lc,H3 as mc,S0 as nc,v3 as oc,M4 as pc,aO as qc,ZO as rc,R3 as sc,B1 as tc,b0 as uc,b5 as vc,v5 as wc,i3 as xc,h3 as yc,l4 as zc,L9 as Ac,d4 as Bc,i5 as Cc,s3 as Dc,T$ as Ec,l$ as Fc,x3 as Gc,J5 as Hc,Y5 as Ic,PC as Jc,U1 as Kc,G$ as Lc,X5 as Mc,gW as Nc,tf as Oc,RW as Pc,kW as Qc,nY as Rc,qW as Sc,ef as Tc,rY as Uc,tY as Vc,$4 as Wc,mW as Xc,yW as Yc,d$ as Zc,D5 as _c,N3 as $c,Q5 as ad,Nf as bd,_f as cd,WD as dd,tz as ed,ez as fd,qO as gd,LD as hd,OW as id,ZW as jd,of as kd,s$ as ld,O4 as md,z4 as nd,UC as od,j4 as pd,KC as qd,iO as rd,q3 as sd,k4 as td,tO as ud,J4 as vd,nW as wd,aW as xd,L3 as yd,s0 as zd,w as Ad,H4 as Bd,w4 as Cd,b4 as Dd,y4 as Ed,p4 as Fd,c4 as Gd};
|
|
16
|
-
|
|
17
|
-
//# debugId=C5C1901E23F1F89764756E2164756E21
|
|
File without changes
|
|
File without changes
|
|
File without changes
|