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