gemi 0.63.0 → 0.65.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/Agent.d.ts +73 -0
- package/dist/ai/Agent.d.ts.map +1 -1
- package/dist/ai/AgentController.d.ts +75 -6
- package/dist/ai/AgentController.d.ts.map +1 -1
- package/dist/ai/AgentProvider.d.ts +5 -1
- package/dist/ai/AgentProvider.d.ts.map +1 -1
- package/dist/ai/Schema.d.ts +62 -0
- package/dist/ai/Schema.d.ts.map +1 -1
- package/dist/ai/client/index.js +10 -4
- package/dist/ai/client/index.js.map +1 -1
- package/dist/ai/client/reducer.d.ts.map +1 -1
- package/dist/ai/index.d.ts +2 -1
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +12 -12
- package/dist/ai/index.js.map +6 -6
- package/dist/ai/live/harness.d.ts +5 -3
- package/dist/ai/live/harness.d.ts.map +1 -1
- package/dist/ai/types.d.ts +29 -1
- package/dist/ai/types.d.ts.map +1 -1
- package/dist/ai/useChat.d.ts +60 -4
- package/dist/ai/useChat.d.ts.map +1 -1
- package/dist/app/index.js +1 -1
- package/dist/auth/AuthController.d.ts.map +1 -1
- package/dist/auth/AuthManager.d.ts +38 -4
- package/dist/auth/AuthManager.d.ts.map +1 -1
- package/dist/auth/UserProvider.d.ts.map +1 -1
- package/dist/auth/config.d.ts.map +1 -1
- package/dist/auth/sessionToken.d.ts +38 -0
- package/dist/auth/sessionToken.d.ts.map +1 -0
- package/dist/auth/types.d.ts +1 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/bin/gemi.js +9 -1
- package/dist/bin/gemi.js.map +3 -3
- package/dist/broadcasting/index.js +1 -1
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/{chunk-jv9k1qfr.js → chunk-2bb3rdqq.js} +3 -3
- package/dist/{chunk-jv9k1qfr.js.map → chunk-2bb3rdqq.js.map} +1 -1
- package/dist/{chunk-e785380d.js → chunk-2dvjj3ad.js} +2 -2
- package/dist/{chunk-e785380d.js.map → chunk-2dvjj3ad.js.map} +1 -1
- package/dist/{chunk-rj3fnc4h.js → chunk-2ghpxrw1.js} +1 -1
- package/dist/{chunk-dqbm9vd0.js → chunk-3mp9p38x.js} +2 -2
- package/dist/{chunk-dqbm9vd0.js.map → chunk-3mp9p38x.js.map} +1 -1
- package/dist/{chunk-cdpeh7tt.js → chunk-3pwn2r6s.js} +2 -2
- package/dist/{chunk-cdpeh7tt.js.map → chunk-3pwn2r6s.js.map} +1 -1
- package/dist/{chunk-7qfzrkab.js → chunk-45g3hd0e.js} +2 -2
- package/dist/{chunk-7qfzrkab.js.map → chunk-45g3hd0e.js.map} +1 -1
- package/dist/{chunk-wqmzad46.js → chunk-5g1j29p2.js} +2 -2
- package/dist/{chunk-wqmzad46.js.map → chunk-5g1j29p2.js.map} +1 -1
- package/dist/{chunk-bxtx4y4w.js → chunk-5pm9zvtp.js} +2 -2
- package/dist/{chunk-bxtx4y4w.js.map → chunk-5pm9zvtp.js.map} +1 -1
- package/dist/{chunk-pbx9p6g0.js → chunk-6waph5k8.js} +1 -1
- package/dist/{chunk-nnc40mf3.js → chunk-70y8wajy.js} +2 -2
- package/dist/{chunk-nnc40mf3.js.map → chunk-70y8wajy.js.map} +1 -1
- package/dist/{chunk-71yhw8aw.js → chunk-731etrh2.js} +2 -2
- package/dist/{chunk-71yhw8aw.js.map → chunk-731etrh2.js.map} +1 -1
- package/dist/{chunk-1s1cd1e8.js → chunk-7438nrkm.js} +3 -3
- package/dist/{chunk-1s1cd1e8.js.map → chunk-7438nrkm.js.map} +1 -1
- package/dist/{chunk-ssg20z9s.js → chunk-7wgk7q33.js} +3 -3
- package/dist/{chunk-ssg20z9s.js.map → chunk-7wgk7q33.js.map} +1 -1
- package/dist/chunk-7xc64j6p.js +5 -0
- package/dist/chunk-7xc64j6p.js.map +14 -0
- package/dist/{chunk-jmse5hec.js → chunk-7zg1mt1g.js} +2 -2
- package/dist/{chunk-jmse5hec.js.map → chunk-7zg1mt1g.js.map} +1 -1
- package/dist/{chunk-0qchadp1.js → chunk-87c0cy5v.js} +2 -2
- package/dist/{chunk-0qchadp1.js.map → chunk-87c0cy5v.js.map} +1 -1
- package/dist/{chunk-773qa4av.js → chunk-8bjxk57p.js} +2 -2
- package/dist/{chunk-773qa4av.js.map → chunk-8bjxk57p.js.map} +1 -1
- package/dist/{chunk-81yzec62.js → chunk-8jpvj3cj.js} +2 -2
- package/dist/{chunk-81yzec62.js.map → chunk-8jpvj3cj.js.map} +1 -1
- package/dist/{chunk-9e5c5e15.js → chunk-9ch1q7nd.js} +2 -2
- package/dist/{chunk-9e5c5e15.js.map → chunk-9ch1q7nd.js.map} +1 -1
- package/dist/{chunk-9e5v1t73.js → chunk-9x5eefh0.js} +2 -2
- package/dist/{chunk-9e5v1t73.js.map → chunk-9x5eefh0.js.map} +1 -1
- package/dist/{chunk-62xjrz5e.js → chunk-9zmcz7yq.js} +2 -2
- package/dist/{chunk-62xjrz5e.js.map → chunk-9zmcz7yq.js.map} +1 -1
- package/dist/{chunk-0amv13g6.js → chunk-a85fn4zf.js} +3 -3
- package/dist/{chunk-0amv13g6.js.map → chunk-a85fn4zf.js.map} +1 -1
- package/dist/chunk-adj6dnvj.js +5 -0
- package/dist/{chunk-dq2hgzje.js.map → chunk-adj6dnvj.js.map} +1 -1
- package/dist/{chunk-exwbtfe9.js → chunk-aq09ta7k.js} +2 -2
- package/dist/{chunk-exwbtfe9.js.map → chunk-aq09ta7k.js.map} +1 -1
- package/dist/{chunk-43xw9n4f.js → chunk-dmr7yzyr.js} +2 -2
- package/dist/{chunk-43xw9n4f.js.map → chunk-dmr7yzyr.js.map} +1 -1
- package/dist/{chunk-q4wdg0y3.js → chunk-e0v4byjp.js} +2 -2
- package/dist/{chunk-ptjexzn1.js.map → chunk-e0v4byjp.js.map} +1 -1
- package/dist/{chunk-8wpccvbt.js → chunk-e1fkxt82.js} +2 -2
- package/dist/{chunk-8wpccvbt.js.map → chunk-e1fkxt82.js.map} +1 -1
- package/dist/{chunk-xadk41cs.js → chunk-ex9ns7pf.js} +4 -4
- package/dist/{chunk-xadk41cs.js.map → chunk-ex9ns7pf.js.map} +1 -1
- package/dist/{chunk-95d8jj11.js → chunk-fd7wfcft.js} +2 -2
- package/dist/{chunk-95d8jj11.js.map → chunk-fd7wfcft.js.map} +1 -1
- package/dist/{chunk-maxd55a0.js → chunk-fk127cwf.js} +2 -2
- package/dist/{chunk-maxd55a0.js.map → chunk-fk127cwf.js.map} +2 -2
- package/dist/{chunk-kx7vgcjp.js → chunk-fmcq21hg.js} +3 -3
- package/dist/{chunk-kx7vgcjp.js.map → chunk-fmcq21hg.js.map} +1 -1
- package/dist/{chunk-k1wkvrj0.js → chunk-ftaxfq7p.js} +3 -3
- package/dist/{chunk-k1wkvrj0.js.map → chunk-ftaxfq7p.js.map} +1 -1
- package/dist/{chunk-zdj2wmbj.js → chunk-fxkh2rfd.js} +2 -2
- package/dist/{chunk-zdj2wmbj.js.map → chunk-fxkh2rfd.js.map} +1 -1
- package/dist/{chunk-9k5daets.js → chunk-g2ywq30n.js} +2 -2
- package/dist/{chunk-9k5daets.js.map → chunk-g2ywq30n.js.map} +1 -1
- package/dist/chunk-hq496pa4.js +5 -0
- package/dist/chunk-hq496pa4.js.map +10 -0
- package/dist/{chunk-4sv5zpb4.js → chunk-hrtkjv41.js} +2 -2
- package/dist/{chunk-4sv5zpb4.js.map → chunk-hrtkjv41.js.map} +1 -1
- package/dist/{chunk-tq92xqkk.js → chunk-j3b3qerv.js} +2 -2
- package/dist/{chunk-tq92xqkk.js.map → chunk-j3b3qerv.js.map} +1 -1
- package/dist/{chunk-dhe1hsyz.js → chunk-jkjt3e06.js} +2 -2
- package/dist/{chunk-dhe1hsyz.js.map → chunk-jkjt3e06.js.map} +1 -1
- package/dist/{chunk-5wzyx4ts.js → chunk-ks94h71z.js} +2 -2
- package/dist/{chunk-5wzyx4ts.js.map → chunk-ks94h71z.js.map} +1 -1
- package/dist/{chunk-rhr8qavq.js → chunk-m44ar4he.js} +2 -2
- package/dist/{chunk-rhr8qavq.js.map → chunk-m44ar4he.js.map} +1 -1
- package/dist/{chunk-0081bz9c.js → chunk-nxg51m0q.js} +2 -2
- package/dist/{chunk-0081bz9c.js.map → chunk-nxg51m0q.js.map} +1 -1
- package/dist/{chunk-qrfp7pg2.js → chunk-nxh5a3eb.js} +3 -3
- package/dist/{chunk-qrfp7pg2.js.map → chunk-nxh5a3eb.js.map} +1 -1
- package/dist/{chunk-qcbtr7hm.js → chunk-p0m3qgs5.js} +2 -2
- package/dist/{chunk-qcbtr7hm.js.map → chunk-p0m3qgs5.js.map} +1 -1
- package/dist/{chunk-jk8mn861.js → chunk-p5m0da00.js} +2 -2
- package/dist/{chunk-jk8mn861.js.map → chunk-p5m0da00.js.map} +1 -1
- package/dist/{chunk-fv223805.js → chunk-pb0m0ryf.js} +3 -3
- package/dist/{chunk-fv223805.js.map → chunk-pb0m0ryf.js.map} +1 -1
- package/dist/{chunk-7hbhbht2.js → chunk-pcxxnnad.js} +3 -3
- package/dist/{chunk-7hbhbht2.js.map → chunk-pcxxnnad.js.map} +1 -1
- package/dist/{chunk-2d92pev2.js → chunk-pxc51549.js} +2 -2
- package/dist/{chunk-2d92pev2.js.map → chunk-pxc51549.js.map} +1 -1
- package/dist/{chunk-454c7vn3.js → chunk-q1nq7n6y.js} +2 -2
- package/dist/{chunk-454c7vn3.js.map → chunk-q1nq7n6y.js.map} +1 -1
- package/dist/{chunk-48qybp63.js → chunk-qqchc40s.js} +2 -2
- package/dist/{chunk-48qybp63.js.map → chunk-qqchc40s.js.map} +1 -1
- package/dist/{chunk-feyr4851.js → chunk-r069158p.js} +2 -2
- package/dist/{chunk-feyr4851.js.map → chunk-r069158p.js.map} +1 -1
- package/dist/{chunk-ptjexzn1.js → chunk-r6v21jn6.js} +2 -2
- package/dist/{chunk-q4wdg0y3.js.map → chunk-r6v21jn6.js.map} +1 -1
- package/dist/{chunk-6j129573.js → chunk-r77f1482.js} +2 -2
- package/dist/{chunk-6j129573.js.map → chunk-r77f1482.js.map} +1 -1
- package/dist/{chunk-jmbdr550.js → chunk-rnjbja88.js} +2 -2
- package/dist/{chunk-jmbdr550.js.map → chunk-rnjbja88.js.map} +1 -1
- package/dist/{chunk-q8msf1gf.js → chunk-rq2k9frr.js} +2 -2
- package/dist/{chunk-q8msf1gf.js.map → chunk-rq2k9frr.js.map} +1 -1
- package/dist/chunk-se5ekvgb.js +19 -0
- package/dist/{chunk-anfs5mwm.js.map → chunk-se5ekvgb.js.map} +12 -11
- package/dist/{chunk-v6v03hy7.js → chunk-sqc6fkqt.js} +2 -2
- package/dist/{chunk-v6v03hy7.js.map → chunk-sqc6fkqt.js.map} +1 -1
- package/dist/{chunk-78cvy4je.js → chunk-tn71d46d.js} +2 -2
- package/dist/{chunk-78cvy4je.js.map → chunk-tn71d46d.js.map} +1 -1
- package/dist/{chunk-hkhxkeeb.js → chunk-v6q4990x.js} +3 -3
- package/dist/{chunk-hkhxkeeb.js.map → chunk-v6q4990x.js.map} +1 -1
- package/dist/{chunk-e41vdprh.js → chunk-w34j3cd3.js} +3 -3
- package/dist/{chunk-e41vdprh.js.map → chunk-w34j3cd3.js.map} +1 -1
- package/dist/{chunk-35fbxgjh.js → chunk-wzqxtrpt.js} +2 -2
- package/dist/{chunk-35fbxgjh.js.map → chunk-wzqxtrpt.js.map} +1 -1
- package/dist/{chunk-39p7ge47.js → chunk-x917yccy.js} +2 -2
- package/dist/{chunk-39p7ge47.js.map → chunk-x917yccy.js.map} +1 -1
- package/dist/{chunk-z2fnf49p.js → chunk-xzexftx1.js} +1 -1
- package/dist/{chunk-dfv5eqma.js → chunk-z4k18gnp.js} +2 -2
- package/dist/{chunk-dfv5eqma.js.map → chunk-z4k18gnp.js.map} +1 -1
- package/dist/{chunk-b6948dnh.js → chunk-z6gzasra.js} +2 -2
- package/dist/{chunk-b6948dnh.js.map → chunk-z6gzasra.js.map} +1 -1
- package/dist/{chunk-p57x55qd.js → chunk-zqpskwk9.js} +2 -2
- package/dist/{chunk-p57x55qd.js.map → chunk-zqpskwk9.js.map} +1 -1
- package/dist/chunks/ThemeProvider-Bz-y1g2i.js.map +1 -1
- package/dist/client/ClientRouter.d.ts.map +1 -1
- package/dist/client/Link.d.ts +3 -2
- package/dist/client/Link.d.ts.map +1 -1
- package/dist/client/Redirect.d.ts +3 -3
- package/dist/client/Redirect.d.ts.map +1 -1
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +5 -7
- package/dist/client/index.js.map +1 -1
- package/dist/client/types.d.ts +72 -2
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/useNavigate.d.ts +29 -6
- package/dist/client/useNavigate.d.ts.map +1 -1
- package/dist/client/usePrefetch.d.ts +13 -3
- package/dist/client/usePrefetch.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/Connection.d.ts.map +1 -1
- package/dist/database/index.d.ts +1 -0
- package/dist/database/index.d.ts.map +1 -1
- package/dist/database/index.js +2 -2
- package/dist/database/index.js.map +1 -1
- package/dist/database/sqlitePath.d.ts +46 -0
- package/dist/database/sqlitePath.d.ts.map +1 -0
- package/dist/email/index.js +2 -2
- package/dist/email/index.js.map +1 -1
- package/dist/facades/Auth.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/ApiRouter.d.ts +1 -1
- package/dist/http/ApiRouter.d.ts.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/i18n/dictionaryRuntime.js +2 -2
- package/dist/i18n/dictionaryRuntime.js.map +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +1 -1
- package/dist/kernel/index.js +2 -2
- package/dist/kernel/index.js.map +1 -1
- package/dist/orm/index.js +2 -2
- package/dist/orm/index.js.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/index.js +2 -2
- package/dist/services/index.js.map +1 -1
- package/dist/services/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/ai/Agent.test-d.d.ts +0 -2
- package/dist/ai/Agent.test-d.d.ts.map +0 -1
- package/dist/ai/Schema.test-d.d.ts +0 -2
- package/dist/ai/Schema.test-d.d.ts.map +0 -1
- package/dist/ai/client/reducer.test-d.d.ts +0 -2
- package/dist/ai/client/reducer.test-d.d.ts.map +0 -1
- package/dist/ai/example.d.ts +0 -129
- package/dist/ai/example.d.ts.map +0 -1
- package/dist/chunk-4728yrmt.js +0 -5
- package/dist/chunk-4728yrmt.js.map +0 -10
- package/dist/chunk-anfs5mwm.js +0 -19
- package/dist/chunk-dq2hgzje.js +0 -5
- package/dist/chunk-f9ccncar.js +0 -5
- package/dist/chunk-f9ccncar.js.map +0 -13
- package/dist/client/useDictionary.test-d.d.ts +0 -2
- package/dist/client/useDictionary.test-d.d.ts.map +0 -1
- package/dist/console/builder.test-d.d.ts +0 -2
- package/dist/console/builder.test-d.d.ts.map +0 -1
- package/dist/http/ApiRouter.test-d.d.ts +0 -2
- package/dist/http/ApiRouter.test-d.d.ts.map +0 -1
- package/dist/http/McpRouter.test-d.d.ts +0 -2
- package/dist/http/McpRouter.test-d.d.ts.map +0 -1
- package/dist/services/events/FakeEventManager.test-d.d.ts +0 -2
- package/dist/services/events/FakeEventManager.test-d.d.ts.map +0 -1
- package/dist/services/events/Listener.test-d.d.ts +0 -2
- package/dist/services/events/Listener.test-d.d.ts.map +0 -1
- /package/dist/{chunk-rj3fnc4h.js.map → chunk-2ghpxrw1.js.map} +0 -0
- /package/dist/{chunk-pbx9p6g0.js.map → chunk-6waph5k8.js.map} +0 -0
- /package/dist/{chunk-z2fnf49p.js.map → chunk-xzexftx1.js.map} +0 -0
package/dist/chunk-anfs5mwm.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ed as _6,Ld as s8}from"./chunk-1s1cd1e8.js";import{Ae as d8,Wd as gT}from"./chunk-6j129573.js";import{Be as e3,De as k8,Fe as _8,Ge as M6,He as s3,Ie as p3,Le as h3,Me as l3,Ne as d$,Oe as L8,Pe as vT,Qe as f$,Re as H0,Se as A,Te as $F,Ue as TF,Ve as u3,Xe as _T,Ye as T0,Ze as ZZ}from"./chunk-0amv13g6.js";import{ef as J8,ff as sF,gf as N}from"./chunk-9k5daets.js";import{hf as g8}from"./chunk-0qchadp1.js";import{if as P8,jf as i8,kf as $j,lf as p8,mf as h8,vf as l8}from"./chunk-k1wkvrj0.js";import{Gf as Tj}from"./chunk-f9ccncar.js";import{Of as N8,Tf as E8}from"./chunk-nnc40mf3.js";import{Zf as V8,_f as e}from"./chunk-78cvy4je.js";import{bg as S}from"./chunk-7hbhbht2.js";import{cg as l$}from"./chunk-jk8mn861.js";import{og as BF}from"./chunk-e785380d.js";import{qg as H8}from"./chunk-9e5c5e15.js";import{vg as nF}from"./chunk-ptjexzn1.js";import{randomBytes as l7}from"crypto";function V0($,T,O,Z,f){return y0(T,Lj($,T),O,Z,f)}function y0($,T,O,Z,f,F){let j=MZ(T,O,Z);if(f&&T!==j)throw RangeError(OW($,T,O,Z,F));return j}function Lj($,T){let O=$[T];if(O===void 0)throw TypeError(tf(T));return O}function f0($){return $!==null&&/object|function/.test(typeof $)}function A0($,T=Map){let O=new T;return(Z,...f)=>{if(O.has(Z))return O.get(Z);let F=$(Z,...f);return O.set(Z,F),F}}function PZ($){return l1({name:$},1)}function l1($,T){return i0((O)=>({value:O,configurable:1,writable:!T}),$)}function Ij($){return i0((T)=>({get:T,configurable:1}),$)}function $O($){return{[Symbol.toStringTag]:{value:$,configurable:1}}}function S$($,T){let O={},Z=$.length;for(let f of T)O[$[--Z]]=f;return O}function i0($,T,O){let Z={};for(let f in T)Z[f]=$(T[f],f,O);return Z}function FT($,T,O){let Z={};for(let f=0;f<T.length;f++){let F=T[f];Z[F]=$(F,f,O)}return Z}function Z2($,T,O){let Z={};for(let f=0;f<$.length;f++)Z[T[f]]=O[$[f]];return Z}function _0($,T){let O={};for(let Z of $)O[Z]=T[Z];return O}function HZ($,T){let O={};for(let Z in T)$.has(Z)||(O[Z]=T[Z]);return O}function wZ($){$={...$};let T=Object.keys($);for(let O of T)$[O]===void 0&&delete $[O];return $}function Mj($,T){for(let O of T)if(!(O in $))return 0;return 1}function Qj($,T,O){for(let Z of $)if(T[Z]!==O[Z])return 0;return 1}function Vj($,T,O){let Z={...O};for(let f=0;f<T;f++)Z[$[f]]=0;return Z}function H($,...T){return(...O)=>$(...T,...O)}function fj($){return $[0].toUpperCase()+$.substring(1)}function jT($){return $.slice().sort()}function dT($,T){return String(T).padStart($,"0")}function G1($,T){return Math.sign($-T)}function MZ($,T,O){return Math.min(Math.max($,T),O)}function j1($,T){return[Math.floor($/T),r$($,T)]}function r$($,T){return($%T+T)%T}function K1($,T){return[TO($,T),bZ($,T)]}function TO($,T){return Math.trunc($/T)||0}function bZ($,T){return $%T||0}function qT($){return Math.abs($%1)===0.5}function Nj($,T,O){let Z=0,f=0;for(let C=0;C<=T;C++){let z=$[O[C]],W=a0[C],J=m/W,[Y,D]=K1(z,J);Z+=D*W,f+=Y}let[F,j]=K1(Z,m);return[f+F,j]}function OO($,T,O){let Z={};for(let f=T;f>=0;f--){let F=a0[f];Z[O[f]]=TO($,F),$=bZ($,F)}return Z}function Ej($){return $===b?RO:[]}function Aj($){return $===b?BT:[]}function xj($){return $===b?["year","day"]:[]}function _j($){if($!==void 0)return h($)}function Pj($){if($!==void 0)return p0($)}function vZ($){if($!==void 0)return CT($)}function p0($){return bj(CT($))}function CT($){return wj(n2($))}function gZ($){if($==null)throw TypeError("Cannot be null or undefined");return $}function Hj($,T){if(T==null)throw RangeError(tf($));return T}function z1($){if(!f0($))throw TypeError(TW);return $}function ZO($,T,O=$){if(typeof T!==$)throw TypeError(XT(O,T));return T}function wj($,T="number"){if(!Number.isInteger($))throw RangeError(L2(T,$));return $||0}function bj($,T="number"){if($<=0)throw RangeError(I2(T,$));return $}function kZ($){if(typeof $=="symbol")throw TypeError(N2);return String($)}function sT($,T){return f0($)?String($):h($,T)}function fO($){if(typeof $=="string")return BigInt($);if(typeof $!="bigint")throw TypeError(V2($));return $}function vj($,T="number"){if(typeof $=="bigint")throw TypeError(Q2(T));if($=Number($),!Number.isFinite($))throw RangeError(M2(T,$));return $}function U0($,T){return Math.trunc(vj($,T))||0}function gj($,T){return wj(vj($,T),T)}function Fj($,T){return bj(U0($,T),T)}function RZ($,T){let[O,Z]=K1(T,m),f=$+O,F=Math.sign(f);return F&&F===-Math.sign(Z)&&(f-=F,Z+=F*m),[f,Z]}function Y$($,T,O=1){return RZ($[0]+T[0]*O,$[1]+T[1]*O)}function X$($,T){return RZ($[0],$[1]+T)}function b0($,T){return Y$(T,$,-1)}function B0($,T){return G1($[0],T[0])||G1($[1],T[1])}function kj($,T,O){return B0($,T)===-1||B0($,O)===1}function FO($,T=1){let O=BigInt(m/T);return[Number($/O),Number($%O)*T]}function U$($,T=1){let O=m/T,[Z,f]=K1($,O);return[Z,f*T]}function Rj($,T=1){let[O,Z]=$,f=Math.floor(Z/T),F=m/T;return BigInt(O)*BigInt(F)+BigInt(f)}function v0($,T=1,O){let[Z,f]=$,[F,j]=K1(f,T);return Z*(m/T)+(F+(O?j/T:0))}function yZ($,T,O=j1){let[Z,f]=$,[F,j]=O(f,T);return[Z*(m/T)+F,j]}function mZ($,T){let O=$.formatToParts(T),Z={};for(let f of O)Z[f.type]=f.value;return Z}function qZ($){return V0($,"isoYear",fT,ZT,1),$.isoYear===fT?V0($,"isoMonth",4,12,1):$.isoYear===ZT&&V0($,"isoMonth",1,9,1),$}function B1($){return W1({...$,...c0,isoHour:12}),$}function W1($){let T=V0($,"isoYear",fT,ZT,1),O=T===fT?1:T===ZT?-1:0;return O&&g0(G0({...$,isoDay:$.isoDay+O,isoNanosecond:$.isoNanosecond-O})),$}function g0($){if(!$||kj($,T4,$4))throw RangeError(bO);return $}function L1($){return Nj($,5,s0)[1]}function jO($){let[T,O]=j1($,m);return[OO(O,5,s0),T]}function yj($){return mj($)[0]}function mj($){return yZ($,q0)}function S0($){return K$($.isoYear,$.isoMonth,$.isoDay,$.isoHour,$.isoMinute,$.isoSecond,$.isoMillisecond)}function G0($){let T=S0($);if(T!==void 0){let[O,Z]=K1(T,E0);return[O,Z*o0+($.isoMicrosecond||0)*e1+($.isoNanosecond||0)]}}function cZ($,T){let[O,Z]=jO(L1($)-T);return g0(G0({...$,isoDay:$.isoDay+Z,...O}))}function uT(...$){return K$(...$)/XW}function K$(...$){let[T,O]=qj(...$),Z=T.valueOf();if(!isNaN(Z))return Z-O*E0}function qj($,T=1,O=1,Z=0,f=0,F=0,j=0){let C=$===fT?1:$===ZT?-1:0,z=new Date;return z.setUTCHours(Z,f,F,j),z.setUTCFullYear($,T-1,O+C),[z,C]}function M1($,T){let[O,Z]=X$($,T);Z<0&&(Z+=m,O-=1);let[f,F]=j1(Z,o0),[j,C]=j1(F,e1);return CO(O*E0+f,j,C)}function CO($,T=0,O=0){let Z=Math.ceil(Math.max(0,Math.abs($)-e2)/E0)*Math.sign($),f=new Date($-Z*E0);return S$(mO,[f.getUTCFullYear(),f.getUTCMonth()+1,f.getUTCDate()+Z,f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds(),f.getUTCMilliseconds(),T,O])}function cj($){return[$.isoYear,$.isoMonth,$.isoDay]}function ij(){return F1}function iZ($,T){switch(T){case 2:return pZ($)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function pj($){return pZ($)?366:365}function pZ($){return $%4==0&&($%100!=0||$%400==0)}function hj($){let[T,O]=qj($.isoYear,$.isoMonth,$.isoDay);return r$(T.getUTCDay()-O,7)||7}function lj({isoYear:$}){return $<1?["bce",1-$]:["ce",$]}function f2($){let T=S0($);if(T<Z4)return lj($);let O=mZ(G3(G$),T),{era:Z,eraYear:f}=Tz(O,G$);return[Z,f]}function zO($){return d1($),WO($,1),$}function d1($){return dj($,1),$}function jj($){return Qj(C3,$,dj($))}function dj($,T){let{isoYear:O}=$,Z=V0($,"isoMonth",1,ij(),T);return{isoYear:O,isoMonth:Z,isoDay:V0($,"isoDay",1,iZ(O,Z),T)}}function WO($,T){return S$(s0,[V0($,"isoHour",0,23,T),V0($,"isoMinute",0,59,T),V0($,"isoSecond",0,59,T),V0($,"isoMillisecond",0,999,T),V0($,"isoMicrosecond",0,999,T),V0($,"isoNanosecond",0,999,T)])}function k($){return $===void 0?0:HW(z1($))}function zT($,T=0){$=h0($);let O=wW($),Z=X4($,T);return[HW($),Z,O]}function hZ($){return wW(h0($))}function sj($){return $=h0($),J3($,9,6,1)}function L$($,T,O,Z=9,f=0,F=4){T=h0(T);let j=J3(T,Z,f),C=sZ(T),z=KT(T,F),W=ST(T,Z,f,1);return j==null?j=Math.max(O,W):oj(j,W),C=uZ(C,W,1),$&&(z=((J)=>J<4?(J+2)%4:J)(z)),[j,W,C,z]}function JO($,T=6,O){let Z=sZ($=nZ($,eT)),f=KT($,7),F=ST($,T);return F=Hj(eT,F),Z=uZ(Z,F,void 0,O),[F,Z,f]}function lZ($){return D3(h0($))}function uj($,T){return dZ(h0($),T)}function dZ($,T=4){let O=aj($);return[KT($,4),...nj(ST($,T),O)]}function nj($,T){return $!=null?[a0[$],$<4?9-3*$:-1]:[T===void 0?1:10**(9-T),T]}function sZ($){let T=$[e$];return T===void 0?1:U0(T,e$)}function uZ($,T,O,Z){let f=Z?m:a0[T+1];if(f){let F=a0[T];if(f%(($=y0(e$,$,1,f/F-(Z?0:1),1))*F))throw RangeError(XT(e$,$))}else $=y0(e$,$,1,O?1e9:1,1);return $}function aj($){let T=$[IZ];if(T!==void 0){if(typeof T!="number"){if(kZ(T)==="auto")return;throw RangeError(XT(IZ,T))}T=y0(IZ,Math.floor(T),0,9,1)}return T}function h0($){return $===void 0?{}:z1($)}function nZ($,T){return typeof $=="string"?{[T]:$}:z1($)}function s($){if($!==void 0){if(f0($))return Object.assign(Object.create(null),$);throw TypeError(TW)}}function DO($,T){return $&&Object.assign(Object.create(null),$,{overflow:F4[T]})}function aZ($,T,O=9,Z=0,f){let F=T[$];if(F===void 0)return f?Z:void 0;if(F=kZ(F),F==="auto")return f?Z:null;let j=EZ[F];if(j===void 0&&(j=t2[F]),j===void 0)throw RangeError(FW($,F,EZ));return y0($,j,Z,O,1,GT),j}function s1($,T,O,Z=0){let f=O[$];if(f===void 0)return Z;let F=kZ(f),j=T[F];if(j===void 0)throw RangeError(FW($,F,T));return j}function oj($,T){if(T>$)throw RangeError(h2)}function F0($){return{branding:cO,epochNanoseconds:$}}function W0($,T,O){return{branding:X1,calendar:O,timeZone:T,epochNanoseconds:$}}function u($,T=$.calendar){return{branding:T$,calendar:T,..._0(AW,$)}}function n($,T=$.calendar){return{branding:$$,calendar:T,..._0(z3,$)}}function p1($,T=$.calendar){return{branding:x$,calendar:T,..._0(z3,$)}}function nT($,T=$.calendar){return{branding:_$,calendar:T,..._0(z3,$)}}function l0($){return{branding:qO,..._0(EW,$)}}function p($){return{branding:iO,sign:Q1($),..._0(f3,$)}}function tj($){return yj($.epochNanoseconds)}function YO($){return yZ($.epochNanoseconds,o0)[0]}function rj($){return Rj($.epochNanoseconds,e1)}function ej($){return Rj($.epochNanoseconds)}function $C($){return $.epochNanoseconds}function C0($){return typeof $=="string"?$:h($.id)}function I$($,T){return $===T||C0($)===C0(T)}function TC($,T,O,Z,f){let F=h1(Z),[j,C]=((B,K)=>{let M=K((B=nZ(B,_Z))[_W]),L=Y4(B);return L=Hj(_Z,L),[L,M]})(f,$);if(TT(Math.max(j,F),C))return Cj(Z,j);if(!C)throw RangeError(vO);let[z,W,J]=KO(T,O,C),Y=Lf(J),D=LO(J),U=If(J),X=D(W,z,Z),G=U(W,z,X,j);return TT(j,C)?Cj(G,j):((B,K,M,L,E,x,I)=>{let Q=Q1(B),[_,P]=oZ(L,j3(M,B),M,Q,E,x,I),O0=tZ(K,_,P);return B[y[M]]+O0*Q})(G,Y(X),j,W,z,Y,D)}function Cj($,T){return v0(Z0($),a0[T],1)}function oZ($,T,O,Z,f,F,j){let C=y[O],z={...T,[C]:T[C]+Z},W=j($,f,T),J=j($,f,z);return[F(W),F(J)]}function tZ($,T,O){let Z=v0(b0(T,O));if(!Z)throw RangeError(UT);return v0(b0(T,$))/Z}function OC($,T){let[O,Z,f]=JO(T,5,1);return F0(UO($.epochNanoseconds,O,Z,f,1))}function ZC($,T,O){let{epochNanoseconds:Z,timeZone:f,calendar:F}=T,[j,C,z]=JO(O);if(j===0&&C===1)return T;let W=$(f);if(j===6)Z=((J,Y,D,U)=>{let X=K0(D,Y),[G,B]=J(X),K=D.epochNanoseconds,M=x0(Y,G),L=x0(Y,B);if(kj(K,M,L))throw RangeError(UT);return YC(tZ(K,M,L),U)?L:M})(JC,W,T,z);else{let J=W.getOffsetNanosecondsFor(Z);Z=n1(W,zC(M1(Z,J),j,C,z),J,2,0,1)}return W0(Z,f,F)}function fC($,T){return u(zC($,...JO(T)),$.calendar)}function FC($,T){let[O,Z,f]=JO(T,5);var F;return l0((F=f,rZ($,WT(O,Z),F)[0]))}function jC($,T){let O=$(T.timeZone),Z=K0(T,O),[f,F]=JC(Z),j=v0(b0(x0(O,f),x0(O,F)),kO,1);if(j<=0)throw RangeError(UT);return j}function CC($,T){let{timeZone:O,calendar:Z}=T,f=((F,j,C)=>x0(j,F(K0(C,j))))(DC,$(O),T);return W0(f,O,Z)}function zC($,T,O,Z){return WC($,WT(T,O),Z)}function WC($,T,O){let[Z,f]=rZ($,T,O);return W1({...a1($,f),...Z})}function rZ($,T,O){return jO(I1(L1($),T,O))}function aT($){return I1($,gO,7)}function WT($,T){return a0[$]*T}function JC($){let T=DC($);return[T,a1(T,1)]}function DC($){return r2(6,$)}function F2($,T,O){let Z=Math.min(h1($),6);return Q$(GO(Z0($,Z),T,O),Z)}function XO($,T,O,Z,f,F,j,C,z,W){if(Z===0&&f===1)return $;let J=TT(Z,C)?IO(C)&&Z<6&&O>=6?C2:j2:z2,[Y,D,U]=J($,T,O,Z,f,F,j,C,z,W);return U&&Z!==7&&(Y=((X,G,B,K,M,L,E,x)=>{let I=Q1(X);for(let Q=K+1;Q<=B;Q++){if(Q===7&&B!==7)continue;let _=j3(Q,X);_[y[Q]]+=I;let P=v0(b0(E(x(M,L,_)),G));if(P&&Math.sign(P)!==I)break;X=_}return X})(Y,D,O,Math.max(6,Z),j,C,z,W)),Y}function UO($,T,O,Z,f){if(T===6){let F=((j)=>j[0]+j[1]/m)($);return[I1(F,O,Z),0]}return GO($,WT(T,O),Z,f)}function GO($,T,O,Z){let[f,F]=$;Z&&F<0&&(F+=m,f-=1);let[j,C]=j1(I1(F,T,O),m);return RZ(f+j,C)}function I1($,T,O){return YC($/T,O)*T}function YC($,T){return B4[T]($)}function j2($,T,O,Z,f,F){let j=Q1($),C=Z0($),z=UO(C,Z,f,F),W=b0(C,z),J=Math.sign(z[0]-C[0])===j,Y=Q$(z,Math.min(O,6));return[{...$,...Y},Y$(T,W),J]}function C2($,T,O,Z,f,F,j,C,z,W){let J=Q1($),Y=v0(Z0($,5)),D=WT(Z,f),U=I1(Y,D,F),[X,G]=oZ(j,{...$,...F3},6,J,C,z,W),B=U-v0(b0(X,G)),K=0;B&&Math.sign(B)!==J?T=X$(X,U):(K+=J,U=I1(B,D,F),T=X$(G,U));let M=QO(U);return[{...$,...M,days:$.days+K},T,Boolean(K)]}function z2($,T,O,Z,f,F,j,C,z,W){let J=Q1($),Y=y[Z],D=j3(Z,$);Z===7&&($={...$,weeks:$.weeks+Math.trunc($.days/7)});let U=TO($[Y],f)*f;D[Y]=U;let[X,G]=oZ(j,D,Z,f*J,C,z,W),B=U+tZ(T,X,G)*J*f,K=I1(B,f,F),M=Math.sign(K-B)===J;return D[Y]=K,[D,M?G:X,M]}function eZ($,T,O,Z){let[f,F,j,C]=((W)=>{let J=dZ(W=h0(W));return[W.timeZone,...J]})(Z),z=f!==void 0;return((W,J,Y,D,U,X)=>{Y=GO(Y,U,D,1);let G=J.getOffsetNanosecondsFor(Y);return jf(M1(Y,G),X)+(W?u1(aT(G)):"Z")})(z,T(z?$(f):O$),O.epochNanoseconds,F,j,C)}function $f($,T,O){let[Z,f,F,j,C,z]=((W)=>{W=h0(W);let J=D3(W),Y=aj(W),D=G4(W),U=KT(W,4),X=ST(W,4);return[J,U4(W),D,U,...nj(X,Y)]})(O);return((W,J,Y,D,U,X,G,B,K,M)=>{D=GO(D,K,B,1);let L=W(Y).getOffsetNanosecondsFor(D);return jf(M1(D,L),M)+u1(aT(L),G)+((E,x)=>x!==1?"["+(x===2?"!":"")+C0(E)+"]":"")(Y,X)+Cf(J,U)})($,T.calendar,T.timeZone,T.epochNanoseconds,Z,f,F,j,C,z)}function Tf($,T){let[O,Z,f,F]=((W)=>(W=h0(W),[D3(W),...dZ(W)]))(T);return j=$.calendar,C=O,z=F,jf(WC($,f,Z),z)+Cf(j,C);var j,C,z}function Of($,T){return O=$.calendar,Z=$,f=lZ(T),oT(Z)+Cf(O,f);var O,Z,f}function Zf($,T){return XC($.calendar,UC,$,lZ(T))}function ff($,T){return XC($.calendar,W2,$,lZ(T))}function Ff($,T){let[O,Z,f]=uj(T);return F=f,GC(rZ($,Z,O)[0],F);var F}function BO($,T){let[O,Z,f]=uj(T,3);return Z>1&&($={...$,...F2($,Z,O)}),((F,j)=>{let{sign:C}=F,z=C===-1?L0(F):F,{hours:W,minutes:J}=z,[Y,D]=yZ(Z0(z,3),q0,K1);VC(Y);let U=zf(D,j),X=j>=0||!C||U;return(C<0?"-":"")+"P"+zj({Y:i1(z.years),M:i1(z.months),W:i1(z.weeks),D:i1(z.days)})+(W||J||Y||X?"T"+zj({H:i1(W),M:i1(J),S:i1(Y,X)+U}):"")})($,f)}function XC($,T,O,Z){let f=C0($),F=Z>1||Z===0&&f!==b;return Z===1?f===b?T(O):oT(O):F?oT(O)+BC(f,Z===2):T(O)}function zj($){let T=[];for(let O in $){let Z=$[O];Z&&T.push(Z,O)}return T.join("")}function jf($,T){return oT($)+"T"+GC($,T)}function oT($){return UC($)+"-"+m0($.isoDay)}function UC($){let{isoYear:T}=$;return(T<0||T>9999?SC(T)+dT(6,Math.abs(T)):dT(4,T))+"-"+m0($.isoMonth)}function W2($){return m0($.isoMonth)+"-"+m0($.isoDay)}function GC($,T){let O=[m0($.isoHour),m0($.isoMinute)];return T!==-1&&O.push(m0($.isoSecond)+((Z,f,F,j)=>zf(Z*o0+f*e1+F,j))($.isoMillisecond,$.isoMicrosecond,$.isoNanosecond,T)),O.join(":")}function u1($,T=0){if(T===1)return"";let[O,Z]=j1(Math.abs($),kO),[f,F]=j1(Z,gO),[j,C]=j1(F,q0);return SC($)+m0(O)+":"+m0(f)+(j||C?":"+m0(j)+zf(C):"")}function Cf($,T){if(T!==1){let O=C0($);if(T>1||T===0&&O!==b)return BC(O,T===2)}return""}function BC($,T){return"["+(T?"!":"")+"u-ca="+$+"]"}function zf($,T){let O=dT(9,$);return O=T===void 0?O.replace(L4,""):O.slice(0,T),O?"."+O:""}function SC($){return $<0?"-":"+"}function i1($,T){return $||T?$.toLocaleString("fullwide",{useGrouping:0}):""}function J2($,T){let{epochNanoseconds:O}=$,Z=(T.getOffsetNanosecondsFor?T:T($.timeZone)).getOffsetNanosecondsFor(O),f=M1(O,Z);return{calendar:$.calendar,...f,offsetNanoseconds:Z}}function KC($,T){let O=K0(T,$);return{calendar:T.calendar,..._0(AW,O),offset:u1(O.offsetNanoseconds),timeZone:T.timeZone}}function n1($,T,O,Z=0,f=0,F,j){if(O!==void 0&&Z===1&&(Z===1||j))return cZ(T,O);let C=$.getPossibleInstantsFor(T);if(O!==void 0&&Z!==3){let z=((W,J,Y,D)=>{let U=G0(J);D&&(Y=aT(Y));for(let X of W){let G=v0(b0(X,U));if(D&&(G=aT(G)),G===Y)return X}})(C,T,O,F);if(z!==void 0)return z;if(Z===0)throw RangeError(y2)}return j?G0(T):x0($,T,f,C)}function x0($,T,O=0,Z=$.getPossibleInstantsFor(T)){if(Z.length===1)return Z[0];if(O===1)throw RangeError(m2);if(Z.length)return Z[O===3?1:0];let f=G0(T),F=((C,z)=>{let W=C.getOffsetNanosecondsFor(X$(z,-m));return Jf(C.getOffsetNanosecondsFor(X$(z,m))-W)})($,f),j=F*(O===2?-1:1);return(Z=$.getPossibleInstantsFor(M1(f,j)))[O===2?0:Z.length-1]}function Wf($){if(Math.abs($)>=m)throw RangeError(k2);return $}function Jf($){if($>m)throw RangeError(R2);return $}function Df($,T,O){return F0(g0(Y$(T.epochNanoseconds,((Z)=>{if(NC(Z))throw RangeError(i2);return Z0(Z,5)})($?L0(O):O))))}function Yf($,T,O,Z,f,F=Object.create(null)){let j=T(Z.timeZone),C=$(Z.calendar);return{...Z,...Sf(j,C,Z,O?L0(f):f,F)}}function Xf($,T,O,Z,f=Object.create(null)){let{calendar:F}=O;return u(Kf($(F),O,T?L0(Z):Z,f),F)}function Uf($,T,O,Z,f){let{calendar:F}=O;return n(SO($(F),O,T?L0(Z):Z,f),F)}function Gf($,T,O,Z,f=Object.create(null)){let F=O.calendar,j=$(F),C=$T(j,O);T&&(Z=MO(Z)),Z.sign<0&&(C=j.dateAdd(C,{...z0,months:1}),C=a1(C,-1));let z=j.dateAdd(C,Z,f);return p1($T(j,z),F)}function Bf($,T,O){return l0(LC(T,$?L0(O):O)[0])}function Sf($,T,O,Z,f){let F=Z0(Z,5),j=O.epochNanoseconds;if(NC(Z)){let C=K0(O,$);j=Y$(x0($,{...SO(T,C,{...Z,...F3},f),..._0(s0,C)}),F)}else j=Y$(j,F),k(f);return{epochNanoseconds:g0(j)}}function Kf($,T,O,Z){let[f,F]=LC(T,O);return W1({...SO($,T,{...O,...F3,days:O.days+F},Z),...f})}function SO($,T,O,Z){if(O.years||O.months||O.weeks)return $.dateAdd(T,O,Z);k(Z);let f=O.days+Z0(O,5)[0];return f?B1(a1(T,f)):T}function $T($,T,O=1){return a1(T,O-$.day(T))}function LC($,T){let[O,Z]=Z0(T,5),[f,F]=jO(L1($)+Z);return[f,O+F]}function a1($,T){return T?{...$,...CO(S0($)+T*E0)}:$}function KO($,T,O){let Z=$(O.calendar);return IO(O)?[O,Z,T(O.timeZone)]:[{...O,...c0},Z]}function Lf($){return $?$C:G0}function LO($){return $?H(Sf,$):Kf}function If($){return $?H(Y2,$):X2}function IO($){return $&&$.epochNanoseconds}function TT($,T){return $<=6-(IO(T)?1:0)}function Mf($,T,O,Z,f,F,j){let C=$(h0(j).relativeTo),z=Math.max(h1(f),h1(F));if(TT(z,C))return p(M$(((G,B,K,M)=>{let L=Y$(Z0(G),Z0(B),M?-1:1);if(!Number.isFinite(L[0]))throw RangeError(bO);return{...z0,...Q$(L,K)}})(f,F,z,Z)));if(!C)throw RangeError(vO);Z&&(F=L0(F));let[W,J,Y]=KO(T,O,C),D=LO(Y),U=If(Y),X=D(J,W,f);return p(U(J,W,D(J,X,F),z))}function IC($,T,O,Z,f){let F=h1(Z),[j,C,z,W,J]=((I,Q,_)=>{I=nZ(I,eT);let P=J3(I),O0=_(I[_W]),v=sZ(I),g=KT(I,7),R0=ST(I);if(P===void 0&&R0===void 0)throw RangeError(p2);return R0==null&&(R0=0),P==null&&(P=Math.max(R0,Q)),oj(P,R0),v=uZ(v,R0,1),[P,R0,v,g,O0]})(f,F,$),Y=Math.max(F,j);if(!IO(J)&&Y<=6)return p(M$(((I,Q,_,P,O0)=>{let v=UO(Z0(I),_,P,O0);return{...z0,...Q$(v,Q)}})(Z,j,C,z,W)));if(!J)throw RangeError(vO);let[D,U,X]=KO(T,O,J),G=Lf(X),B=LO(X),K=If(X),M=B(U,D,Z),L=K(U,D,M,j),E=Z.sign,x=Q1(L);if(E&&x&&E!==x)throw RangeError(UT);return x&&(L=XO(L,G(M),j,C,z,W,U,D,G,B)),p(L)}function MC($){return $.sign===-1?MO($):$}function MO($){return p(L0($))}function L0($){let T={};for(let O of y)T[O]=-1*$[O]||0;return T}function QC($){return!$.sign}function Q1($,T=y){let O=0;for(let Z of T){let f=Math.sign($[Z]);if(f){if(O&&O!==f)throw RangeError(c2);O=f}}return O}function M$($){for(let T of o2)y0(T,$[T],-Gj,Gj,1);return VC(v0(Z0($),q0)),$}function VC($){if(!Number.isSafeInteger($))throw RangeError(q2)}function Z0($,T=6){return Nj($,T,y)}function Q$($,T=6){let[O,Z]=$,f=OO(Z,T,y);if(f[y[T]]+=O*(m/a0[T]),!Number.isFinite(f[y[T]]))throw RangeError(bO);return f}function QO($,T=5){return OO($,T,y)}function NC($){return Boolean(Q1($,NW))}function h1($){let T=9;for(;T>0&&!$[y[T]];T--);return T}function D2($,T){return[$,T]}function Wj($){let T=Math.floor($/hT)*hT;return[T,T+hT]}function EC($){let T=V1($=sT($));if(!T)throw RangeError(N0($));let O;if(T.m)O=0;else{if(!T.offset)throw RangeError(N0($));O=V$(T.offset)}return T.timeZone&&Ef(T.timeZone,1),F0(cZ(zO(T),O))}function AC($){let T=V1(h($));if(!T)throw RangeError(N0($));if(T.timeZone)return kC(T,T.offset?V$(T.offset):void 0);if(T.m)throw RangeError(N0($));return yC(T)}function xC($,T){let O=V1(h($));if(!O||!O.timeZone)throw RangeError(N0($));let{offset:Z}=O,f=Z?V$(Z):void 0,[,F,j]=zT(T);return kC(O,f,F,j)}function V$($){let T=Ef($);if(T===void 0)throw RangeError(N0($));return T}function _C($){let T=V1(h($));if(!T||T.m)throw RangeError(N0($));return u(RC(T))}function VO($){let T=V1(h($));if(!T||T.m)throw RangeError(N0($));return n(T.p?RC(T):yC(T))}function PC($,T){let O=Vf(h(T));if(O)return Qf(O),p1(qZ(d1(O)));let Z=VO(T);return p1($T($(Z.calendar),Z))}function Qf($){if($.calendar!==b)throw RangeError(C1($.calendar))}function HC($,T){let O=Nf(h(T));if(O)return Qf(O),nT(d1(O));let Z=VO(T),{calendar:f}=Z,F=$(f),[j,C,z]=F.h(Z),[W,J]=F.I(j,C),[Y,D]=F.N(W,J,z);return nT(B1(F.P(Y,D,z)),f)}function wC($){let T,O=((Z)=>{let f=N4.exec(Z);return f?(NO(f[10]),cC(f)):void 0})(h($));if(!O){if(O=V1($),!O)throw RangeError(N0($));if(!O.p)throw RangeError(N0($));if(O.m)throw RangeError(C1("Z"));Qf(O)}if((T=Vf($))&&jj(T))throw RangeError(N0($));if((T=Nf($))&&jj(T))throw RangeError(N0($));return l0(WO(O,1))}function bC($){let T=((O)=>{let Z=x4.exec(O);return Z?((f)=>{function F(J,Y,D){let U=0,X=0;if(D&&([U,z]=j1(z,a0[D])),J!==void 0){if(C)throw RangeError(C1(J));X=((G)=>{let B=parseInt(G);if(!Number.isFinite(B))throw RangeError(C1(G));return B})(J),j=1,Y&&(z=Af(Y)*(a0[D]/q0),C=1)}return U+X}let j=0,C=0,z=0,W={...S$(y,[F(f[2]),F(f[3]),F(f[4]),F(f[5]),F(f[6],f[7],5),F(f[8],f[9],4),F(f[10],f[11],3)]),...OO(z,2,y)};if(!j)throw RangeError(ZW(y));return xf(f[1])<0&&(W=L0(W)),W})(Z):void 0})(h($));if(!T)throw RangeError(N0($));return p(M$(T))}function vC($){let T=V1($)||Vf($)||Nf($);return T?T.calendar:$}function gC($){let T=V1($);return T&&(T.timeZone||T.m&&O$||T.offset)||$}function kC($,T,O=0,Z=0){let f=EO($.timeZone),F=pO(f);return W0(n1(F,zO($),T,O,Z,!F.v,$.m),f,JT($.calendar))}function RC($){return mC(W1(zO($)))}function yC($){return mC(B1(d1($)))}function mC($){return{...$,calendar:JT($.calendar)}}function V1($){let T=V4.exec($);return T?((O)=>{let Z=O[10],f=(Z||"").toUpperCase()==="Z";return{isoYear:qC(O),isoMonth:parseInt(O[4]),isoDay:parseInt(O[5]),...cC(O.slice(5)),...NO(O[16]),p:Boolean(O[6]),m:f,offset:f?void 0:Z}})(T):void 0}function Vf($){let T=M4.exec($);return T?((O)=>({isoYear:qC(O),isoMonth:parseInt(O[4]),isoDay:1,...NO(O[5])}))(T):void 0}function Nf($){let T=Q4.exec($);return T?((O)=>({isoYear:B$,isoMonth:parseInt(O[1]),isoDay:parseInt(O[2]),...NO(O[3])}))(T):void 0}function Ef($,T){let O=E4.exec($);return O?((Z,f)=>{let F=Z[4]||Z[5];if(f&&F)throw RangeError(C1(F));return Wf((D$(Z[2])*kO+D$(Z[3])*gO+D$(Z[4])*q0+Af(Z[5]||""))*xf(Z[1]))})(O,T):void 0}function qC($){let T=xf($[1]),O=parseInt($[2]||$[3]);if(T<0&&!O)throw RangeError(C1(-0));return T*O}function cC($){let T=D$($[3]);return{...jO(Af($[4]||""))[0],isoHour:D$($[1]),isoMinute:D$($[2]),isoSecond:T===60?59:T}}function NO($){let T,O,Z=[];if($.replace(A4,(f,F,j)=>{let C=Boolean(F),[z,W]=j.split("=").reverse();if(W){if(W==="u-ca")Z.push(z),T||(T=C);else if(C||/[A-Z]/.test(W))throw RangeError(C1(f))}else{if(O)throw RangeError(C1(f));O=z}return""}),Z.length>1&&T)throw RangeError(C1($));return{timeZone:O,calendar:Z[0]||b}}function Af($){return parseInt($.padEnd(9,"0"))}function N$($){return new RegExp(`^${$}$`,"i")}function xf($){return $&&$!=="+"?-1:1}function D$($){return $===void 0?0:parseInt($)}function iC($){return EO(h($))}function EO($){let T=_f($);return typeof T=="number"?u1(T):T?((O)=>{if(P4.test(O))throw RangeError(g2);return O.toLowerCase().split("/").map((Z,f)=>(Z.length<=3||/\d/.test(Z))&&!/etc|yap/.test(Z)?Z.toUpperCase():Z.replace(/baja|dumont|[a-z]+/g,(F,j)=>F.length<=2&&!f||F==="in"||F==="chat"?F.toUpperCase():F.length>2||!j?fj(F).replace(/island|noronha|murdo|rivadavia|urville/,fj):F)).join("/")})($):O$}function Jj($){let T=_f($);return typeof T=="number"?T:T?T.resolvedOptions().timeZone:O$}function _f($){let T=Ef($=$.toUpperCase(),1);return T!==void 0?T:$!==O$?_4($):void 0}function Pf($,T){return B0($.epochNanoseconds,T.epochNanoseconds)}function Hf($,T){return B0($.epochNanoseconds,T.epochNanoseconds)}function pC($,T,O,Z,f,F){let j=$(h0(F).relativeTo),C=Math.max(h1(Z),h1(f));if(Qj(y,Z,f))return 0;if(TT(C,j))return B0(Z0(Z),Z0(f));if(!j)throw RangeError(vO);let[z,W,J]=KO(T,O,j),Y=Lf(J),D=LO(J);return B0(Y(D(W,z,Z)),Y(D(W,z,f)))}function wf($,T){return o1($,T)||AO($,T)}function o1($,T){return G1(S0($),S0(T))}function AO($,T){return G1(L1($),L1(T))}function hC($,T){return!Pf($,T)}function lC($,T){return!Hf($,T)&&!!xO($.timeZone,T.timeZone)&&I$($.calendar,T.calendar)}function dC($,T){return!wf($,T)&&I$($.calendar,T.calendar)}function sC($,T){return!o1($,T)&&I$($.calendar,T.calendar)}function uC($,T){return!o1($,T)&&I$($.calendar,T.calendar)}function nC($,T){return!o1($,T)&&I$($.calendar,T.calendar)}function aC($,T){return!AO($,T)}function xO($,T){if($===T)return 1;let O=C0($),Z=C0(T);if(O===Z)return 1;try{return Jj(O)===Jj(Z)}catch(f){}}function bf($,T,O,Z){let f=L$($,s(Z),3,5),F=_O(T.epochNanoseconds,O.epochNanoseconds,...f);return p($?L0(F):F)}function vf($,T,O,Z,f,F){let j=HO(Z.calendar,f.calendar),C=s(F),[z,W,J,Y]=L$(O,C,5),D=Z.epochNanoseconds,U=f.epochNanoseconds,X=B0(U,D),G;if(X)if(z<6)G=_O(D,U,z,W,J,Y);else{let B=T(((M,L)=>{if(!xO(M,L))throw RangeError(WW);return M})(Z.timeZone,f.timeZone)),K=$(j);G=tC(K,B,Z,f,X,z,C),G=XO(G,U,z,W,J,Y,K,Z,$C,H(Sf,B))}else G=z0;return p(O?L0(G):G)}function gf($,T,O,Z,f){let F=HO(O.calendar,Z.calendar),j=s(f),[C,z,W,J]=L$(T,j,6),Y=G0(O),D=G0(Z),U=B0(D,Y),X;if(U)if(C<=6)X=_O(Y,D,C,z,W,J);else{let G=$(F);X=rC(G,O,Z,U,C,j),X=XO(X,D,C,z,W,J,G,O,G0,Kf)}else X=z0;return p(T?L0(X):X)}function kf($,T,O,Z,f){let F=HO(O.calendar,Z.calendar),j=s(f);return oC(T,()=>$(F),O,Z,...L$(T,j,6,9,6),j)}function Rf($,T,O,Z,f){let F=HO(O.calendar,Z.calendar),j=s(f),C=L$(T,j,9,9,8),z=$(F);return oC(T,()=>z,$T(z,O),$T(z,Z),...C,j)}function oC($,T,O,Z,f,F,j,C,z){let W=G0(O),J=G0(Z),Y;if(B0(J,W))if(f===6)Y=_O(W,J,f,F,j,C);else{let D=T();Y=D.dateUntil(O,Z,f,z),F===6&&j===1||(Y=XO(Y,J,f,F,j,C,D,O,G0,SO))}else Y=z0;return p($?L0(Y):Y)}function yf($,T,O,Z){let f=s(Z),[F,j,C,z]=L$($,f,5,5),W=I1(mf(T,O),WT(j,C),z),J={...z0,...QO(W,F)};return p($?L0(J):J)}function Y2($,T,O,Z,f,F){let j=B0(Z.epochNanoseconds,O.epochNanoseconds);return j?f<6?eC(O.epochNanoseconds,Z.epochNanoseconds,f):tC(T,$,O,Z,j,f,F):z0}function X2($,T,O,Z,f){let F=G0(T),j=G0(O),C=B0(j,F);return C?Z<=6?eC(F,j,Z):rC($,T,O,C,Z,f):z0}function tC($,T,O,Z,f,F,j){let[C,z,W]=((D,U,X,G)=>{function B(){return Q={...a1(L,x++*-G),...M},_=x0(D,Q),B0(E,_)===-G}let K=K0(U,D),M=_0(s0,K),L=K0(X,D),E=X.epochNanoseconds,x=0,I=mf(K,L),Q,_;if(Math.sign(I)===-G&&x++,B()&&(G===-1||B()))throw RangeError(UT);let P=v0(b0(_,E));return[K,Q,P]})(T,O,Z,f);var J,Y;return{...F===6?(J=C,Y=z,{...z0,days:$z(J,Y)}):$.dateUntil(C,z,F,j),...QO(W)}}function rC($,T,O,Z,f,F){let[j,C,z]=((W,J,Y)=>{let D=J,U=mf(W,J);return Math.sign(U)===-Y&&(D=a1(J,-Y),U+=m*Y),[W,D,U]})(T,O,Z);return{...$.dateUntil(j,C,f,F),...QO(z)}}function _O($,T,O,Z,f,F){return{...z0,...Q$(UO(b0($,T),Z,f,F),O)}}function eC($,T,O){return{...z0,...Q$(b0($,T),O)}}function $z($,T){return PO(S0($),S0(T))}function PO($,T){return Math.trunc((T-$)/E0)}function mf($,T){return L1(T)-L1($)}function HO($,T){if(!I$($,T))throw RangeError($3);return $}function U2($){function T(f){return((F,j)=>({...Tz(F,j),F:F.month,day:parseInt(F.day)}))(mZ(O,f),Z)}let O=G3($),Z=tT($);return{id:$,O:G2(T),B:B2(T)}}function G2($){return A0((T)=>{let O=S0(T);return $(O)},WeakMap)}function B2($){let T=$(0).year-O4;return A0((O)=>{let Z,f=K$(O-T),F=[],j=[];do f+=400*E0;while((Z=$(f)).year<=O);do f+=(1-Z.day)*E0,Z.year===O&&(F.push(f),j.push(Z.F)),f-=E0;while((Z=$(f)).year>=O);return{k:F.reverse(),C:YW(j.reverse())}})}function Tz($,T){let O,Z,f=Oz($);if($.era){let F=MW[T];F!==void 0&&(O=T==="islamic"?"ah":$.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),O==="bc"||O==="b"?O="bce":O!=="ad"&&O!=="a"||(O="ce"),Z=f,f=Cz(Z,F[O]||0))}return{era:O,eraYear:Z,year:f}}function Oz($){return parseInt($.relatedYear||$.year)}function QZ($){let{year:T,F:O,day:Z}=this.O($),{C:f}=this.B(T);return[T,f[O]+1,Z]}function OT($,T=1,O=1){return this.B($).k[T-1]+(O-1)*E0}function cT($){let T=Yj(this,$),O=Yj(this,$-1),Z=T.length;if(Z>O.length){let f=zz(this);if(f<0)return-f;for(let F=0;F<Z;F++)if(T[F]!==O[F])return F+1}}function iT($){return PO(OT.call(this,$),OT.call(this,$+1))}function Dj($,T){let{k:O}=this.B($),Z=T+1,f=O;return Z>O.length&&(Z=1,f=this.B($+1).k),PO(O[T-1],f[Z-1])}function pT($){return this.B($).k.length}function Yj($,T){return Object.keys($.B(T).C)}function Zz($){return JT(h($))}function JT($){if(($=$.toLowerCase())!==b&&$!==yO&&tT($)!==tT(G3($).resolvedOptions().calendar))throw RangeError(v2($));return $}function tT($){return $==="islamicc"&&($="islamic"),$.split("-")[0]}function fz($){return this.R($)[0]}function Fz($){return this.R($)[1]}function qf($){let[T]=this.h($);return PO(this.q(T),S0($))+1}function jz($){let T=w4.exec($);if(!T)throw RangeError(w2($));return[parseInt(T[1]),Boolean(T[2])]}function rT($,T,O){return $+(T||O&&$>=O?1:0)}function VZ($,T){return $-(T&&$>=T?1:0)}function Cz($,T){return(T+$)*(Math.sign(T)||1)||0}function NZ($){return MW[Wz($)]}function zz($){return u2[Wz($)]}function Wz($){return tT($.id||b)}function Jz($,T,O,Z){let f=N1(O,Z,d0,[],SW);if(f.timeZone!==void 0){let F=O.dateFromFields(f),j=t1(f),C=$(f.timeZone);return{epochNanoseconds:n1(T(C),{...F,...j},f.offset!==void 0?V$(f.offset):void 0),timeZone:C}}return{...O.dateFromFields(f),...c0}}function Dz($,T,O,Z,f,F){let j=N1(O,f,d0,GW,SW),C=$(j.timeZone),[z,W,J]=zT(F),Y=O.dateFromFields(j,DO(F,z)),D=t1(j,z);return W0(n1(T(C),{...Y,...D},j.offset!==void 0?V$(j.offset):void 0,W,J),C,Z)}function Yz($,T,O){let Z=N1($,T,d0,[],Y1),f=k(O);return u(W1({...$.dateFromFields(Z,DO(O,f)),...t1(Z,f)}))}function cf($,T,O,Z=[]){let f=N1($,T,d0,Z);return $.dateFromFields(f,O)}function pf($,T,O,Z){let f=N1($,T,Z3,Z);return $.yearMonthFromFields(f,O)}function hf($,T,O,Z,f=[]){let F=N1($,O,d0,f);return T&&F.month!==void 0&&F.monthCode===void 0&&F.year===void 0&&(F.year=B$),$.monthDayFromFields(F,Z)}function Xz($,T){let O=k(T);return l0(t1(n0($,AZ,[],1),O))}function Uz($){let T=n0($,f3);return p(M$({...z0,...T}))}function N1($,T,O,Z=[],f=[]){return n0(T,[...$.fields(O),...f].sort(),Z)}function n0($,T,O,Z=!O){let f={},F,j=0;for(let C of T){if(C===F)throw RangeError(E2(C));if(C==="constructor"||C==="__proto__")throw RangeError(rf(C));let z=$[C];if(z!==void 0)j=1,Bj[C]&&(z=Bj[C](z,C)),f[C]=z;else if(O){if(O.includes(C))throw TypeError(tf(C));f[C]=IW[C]}F=C}if(Z&&!j)throw TypeError(ZW(T));return f}function t1($,T){return WO(k4({...IW,...$}),T)}function Gz($,T,O,Z,f,F){let j=s(F),{calendar:C,timeZone:z}=O;return W0(((W,J,Y,D,U)=>{let X=DT(W,Y,D,d0,BW,UW),[G,B,K]=zT(U,2);return n1(J,{...W.dateFromFields(X,DO(U,G)),...t1(X,G)},V$(X.offset),B,K)})($(C),T(z),Z,f,j),z,C)}function Bz($,T,O,Z,f){let F=s(f);return u(((j,C,z,W)=>{let J=DT(j,C,z,d0,Y1),Y=k(W);return W1({...j.dateFromFields(J,DO(W,Y)),...t1(J,Y)})})($(T.calendar),O,Z,F))}function Sz($,T,O,Z,f){let F=s(f);return((j,C,z,W)=>{let J=DT(j,C,z,d0);return j.dateFromFields(J,W)})($(T.calendar),O,Z,F)}function Kz($,T,O,Z,f){let F=s(f);return p1(((j,C,z,W)=>{let J=DT(j,C,z,Z3);return j.yearMonthFromFields(J,W)})($(T.calendar),O,Z,F))}function Lz($,T,O,Z,f){let F=s(f);return((j,C,z,W)=>{let J=DT(j,C,z,d0);return j.monthDayFromFields(J,W)})($(T.calendar),O,Z,F)}function Iz($,T,O){return l0(((Z,f,F)=>{let j=k(F);return t1({..._0(AZ,Z),...n0(f,AZ)},j)})($,T,O))}function Mz($,T){return p((O=$,Z=T,M$({...O,...n0(Z,f3)})));var O,Z}function DT($,T,O,Z,f=[],F=[]){let j=[...$.fields(Z),...f].sort(),C=n0(T,j,F),z=n0(O,j);return C=$.mergeFields(C,z),n0(C,j,[])}function lf($,T){let O=N1($,T,LW);return $.monthDayFromFields(O)}function df($,T,O){let Z=N1($,T,KW);return $.yearMonthFromFields(Z,O)}function Qz($,T,O,Z,f){T=_0(O=$.fields(O),T),Z=n0(Z,f=$.fields(f),[]);let F=$.mergeFields(T,Z);return F=n0(F,[...O,...f].sort(),[]),$.dateFromFields(F)}function SZ($,T){let{era:O,eraYear:Z,year:f}=T,F=NZ($);if(O!==void 0||Z!==void 0){if(O===void 0||Z===void 0)throw TypeError(x2);if(!F)throw RangeError(A2);let j=F[O];if(j===void 0)throw RangeError(P2(O));let C=Cz(Z,j);if(f!==void 0&&f!==C)throw RangeError(_2);f=C}else if(f===void 0)throw TypeError(H2(F));return f}function KZ($,T,O,Z){let{month:f,monthCode:F}=T;if(F!==void 0){let j=((C,z,W,J)=>{let Y=C.U(W),[D,U]=jz(z),X=rT(D,U,Y);if(U){let G=zz(C);if(G===void 0)throw RangeError(t$);if(G>0){if(X>G)throw RangeError(t$);if(Y===void 0){if(J===1)throw RangeError(t$);X--}}else{if(X!==-G)throw RangeError(t$);if(Y===void 0&&J===1)throw RangeError(t$)}}return X})($,F,O,Z);if(f!==void 0&&f!==j)throw RangeError(CW);f=j,Z=1}else if(f===void 0)throw TypeError(b2);return y0("month",f,1,$.L(O),Z)}function Xj($,T,O,Z,f){return V0(T,"day",1,$.j(Z,O),f)}function LZ($,T,O,Z){let f=0,F=[];for(let j of O)T[j]!==void 0?f=1:F.push(j);if(Object.assign($,T),f)for(let j of Z||F)delete $[j]}function Vz($){return F0(g0(FO(fO($))))}function Nz($,T,O,Z,f=b){return W0(g0(FO(fO(O))),T(Z),$(f))}function Ez($,T,O,Z,f=0,F=0,j=0,C=0,z=0,W=0,J=b){return u(W1(zO(i0(U0,S$(mO,[T,O,Z,f,F,j,C,z,W])))),$(J))}function Az($,T,O,Z,f=b){return n(B1(d1(i0(U0,{isoYear:T,isoMonth:O,isoDay:Z}))),$(f))}function xz($,T,O,Z=b,f=1){let F=U0(T),j=U0(O),C=$(Z);return p1(qZ(d1({isoYear:F,isoMonth:j,isoDay:U0(f)})),C)}function _z($,T,O,Z=b,f=B$){let F=U0(T),j=U0(O),C=$(Z);return nT(B1(d1({isoYear:U0(f),isoMonth:F,isoDay:j})),C)}function Pz($=0,T=0,O=0,Z=0,f=0,F=0){return l0(WO(i0(U0,S$(s0,[$,T,O,Z,f,F])),1))}function Hz($=0,T=0,O=0,Z=0,f=0,F=0,j=0,C=0,z=0,W=0){return p(M$(i0(gj,S$(y,[$,T,O,Z,f,F,j,C,z,W]))))}function sf($,T,O=b){return W0($.epochNanoseconds,T,O)}function wz($){return F0($.epochNanoseconds)}function uf($,T){return u(K0(T,$))}function nf($,T){return n(K0(T,$))}function bz($,T,O){return df($(T.calendar),O)}function vz($,T,O){return lf($(T.calendar),O)}function af($,T){return l0(K0(T,$))}function gz($,T,O,Z){let f=((F,j,C,z)=>{let W=hZ(z);return x0(F(j),C,W)})($,O,T,Z);return W0(g0(f),O,T.calendar)}function kz($,T,O){let Z=$(T.calendar);return p1({...T,...df(Z,O)})}function Rz($,T,O){return lf($(T.calendar),O)}function yz($,T,O,Z,f){let F=$(f.timeZone),j=f.plainTime,C=j!==void 0?T(j):c0;return W0(x0(O(F),{...Z,...C}),F,Z.calendar)}function mz($,T=c0){return u(W1({...$,...T}))}function qz($,T,O){return df($(T.calendar),O)}function cz($,T,O){return lf($(T.calendar),O)}function iz($,T,O,Z){return((f,F,j)=>Qz(f,F,KW,z1(j),BT))($(T.calendar),O,Z)}function pz($,T,O,Z){return((f,F,j)=>Qz(f,F,LW,z1(j),RO))($(T.calendar),O,Z)}function hz($,T,O,Z,f){let F=z1(f),j=T(F.plainDate),C=$(F.timeZone);return W0(x0(O(C),{...j,...Z}),C,j.calendar)}function lz($,T){return u(W1({...$,...T}))}function dz($){return F0(g0(U$($,q0)))}function sz($){return F0(g0(U$($,o0)))}function uz($){return F0(g0(FO(fO($),e1)))}function nz($){return F0(g0(FO(fO($))))}function az($,T,O=c0){let Z=T.timeZone,f=$(Z),F={...K0(T,f),...O};return W0(n1(f,F,F.offsetNanoseconds,2),Z,T.calendar)}function oz($,T,O){let Z=T.timeZone,f=$(Z),F={...K0(T,f),...O},j=$W(T.calendar,O.calendar);return W0(n1(f,F,F.offsetNanoseconds,2),Z,j)}function tz($,T=c0){return u({...$,...T})}function rz($,T){return u({...$,...T},$W($.calendar,T.calendar))}function wO($,T){return{...$,calendar:T}}function ez($,T){return{...$,timeZone:T}}function $W($,T){if($===T)return $;let O=C0($),Z=C0(T);if(O===Z||O===b)return T;if(Z===b)return $;throw RangeError($3)}function S2($,T){return(O)=>O===b?$:O===yO||O===G$?Object.assign(Object.create($),{id:O}):Object.assign(Object.create(T),H4(O))}function r1($,T,O){let Z=new Set(O);return(f)=>(((F,j)=>{for(let C of j)if(C in F)return 1;return 0})(f=HZ(Z,f),$)||Object.assign(f,T),O&&(f.timeZone=O$,["full","long"].includes(f.timeStyle)&&(f.timeStyle="medium")),f)}function J1($,T=of){let[O,,,Z]=$;return(f,F=t4,...j)=>{let C=T(Z&&Z(...j),f,F,O),z=C.resolvedOptions();return[C,...K2($,z,j)]}}function of($,T,O,Z){if(O=Z(O),$){if(O.timeZone!==void 0)throw TypeError(l2);O.timeZone=$}return new E1(T,O)}function K2($,T,O){let[,Z,f]=$;return O.map((F)=>(F.calendar&&((j,C,z)=>{if((z||j!==b)&&j!==C)throw RangeError($3)})(C0(F.calendar),T.calendar,f),Z(F,T)))}function E$($){let T=YT();return M1(T,$.getOffsetNanosecondsFor(T))}function YT(){return U$(Date.now(),o0)}function D1(){return Kj||(Kj=new E1().resolvedOptions().timeZone)}var L2=($,T)=>`Non-integer ${$}: ${T}`,I2=($,T)=>`Non-positive ${$}: ${T}`,M2=($,T)=>`Non-finite ${$}: ${T}`,Q2=($)=>`Cannot convert bigint to ${$}`,V2=($)=>`Invalid bigint: ${$}`,N2="Cannot convert Symbol to string",TW="Invalid object",OW=($,T,O,Z,f)=>f?OW($,f[T],f[O],f[Z]):XT($,T)+`; must be between ${O}-${Z}`,XT=($,T)=>`Invalid ${$}: ${T}`,tf=($)=>`Missing ${$}`,rf=($)=>`Invalid field ${$}`,E2=($)=>`Duplicate field ${$}`,ZW=($)=>"No valid fields: "+$.join(),fW="Invalid bag",FW=($,T,O)=>XT($,T)+"; must be "+Object.keys(O).join(),jW="Cannot use valueOf",ef="Invalid calling context",A2="Forbidden era/eraYear",x2="Mismatching era/eraYear",_2="Mismatching year/eraYear",P2=($)=>`Invalid era: ${$}`,H2=($)=>"Missing year"+($?"/era/eraYear":""),w2=($)=>`Invalid monthCode: ${$}`,CW="Mismatching month/monthCode",b2="Missing month/monthCode",Uj="Cannot guess year",t$="Invalid leap month",zW="Invalid protocol",UT="Invalid protocol results",$3="Mismatching Calendars",v2=($)=>`Invalid Calendar: ${$}`,WW="Mismatching TimeZones",g2="Forbidden ICU TimeZone",k2="Out-of-bounds offset",R2="Out-of-bounds TimeZone gap",y2="Invalid TimeZone offset",m2="Ambiguous offset",bO="Out-of-bounds date",q2="Out-of-bounds duration",c2="Cannot mix duration signs",vO="Missing relativeTo",i2="Cannot use large units",p2="Required smallestUnit or largestUnit",h2="smallestUnit > largestUnit",N0=($)=>`Cannot parse: ${$}`,C1=($)=>`Invalid substring: ${$}`,JW=($)=>`Cannot format ${$}`,DW="Mismatching types for formatting",l2="Cannot specify TimeZone",YW=H(FT,($,T)=>T),A$=H(FT,($,T,O)=>O),m0=H(dT,2),EZ={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},GT=Object.keys(EZ),E0=86400000,XW=1000,e1=1000,o0=1e6,q0=1e9,gO=60000000000,kO=3600000000000,m=86400000000000,a0=[1,e1,o0,q0,gO,kO,m],Y1=GT.slice(0,6),AZ=jT(Y1),UW=["offset"],GW=["timeZone"],BW=Y1.concat(UW),SW=BW.concat(GW),xZ=["era","eraYear"],d2=xZ.concat(["year"]),RO=["year"],T3=["monthCode"],O3=["month"].concat(T3),BT=["day"],Z3=O3.concat(RO),KW=T3.concat(RO),d0=BT.concat(Z3),s2=BT.concat(O3),LW=BT.concat(T3),IW=A$(Y1,0),b="iso8601",yO="gregory",G$="japanese",MW={[yO]:{bce:-1,ce:0},[G$]:{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}},u2={chinese:13,dangi:13,hebrew:-6},h=H(ZO,"string"),QW=H(ZO,"boolean"),n2=H(ZO,"number"),VW=H(ZO,"function"),y=GT.map(($)=>$+"s"),f3=jT(y),a2=y.slice(0,6),NW=y.slice(6),o2=NW.slice(1),t2=YW(y),z0=A$(y,0),F3=A$(a2,0),j3=H(Vj,y),s0=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],C3=["isoDay","isoMonth","isoYear"],mO=s0.concat(C3),z3=jT(C3),EW=jT(s0),AW=jT(mO),c0=A$(EW,0),r2=H(Vj,mO),E1=Intl.DateTimeFormat,xW="en-GB",W3=1e8,e2=W3*E0,$4=[W3,0],T4=[-W3,0],ZT=275760,fT=-271821,O4=1970,B$=1972,F1=12,Z4=K$(1868,9,8),f4=A0(f2,WeakMap),eT="smallestUnit",_Z="unit",e$="roundingIncrement",IZ="fractionalSecondDigits",_W="relativeTo",PW={constrain:0,reject:1},F4=Object.keys(PW),j4={compatible:0,reject:1,earlier:2,later:3},C4={reject:0,use:1,prefer:2,ignore:3},z4={auto:0,never:1,critical:2,always:3},W4={auto:0,never:1,critical:2},J4={auto:0,never:1},D4={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},ST=H(aZ,eT),J3=H(aZ,"largestUnit"),Y4=H(aZ,_Z),HW=H(s1,"overflow",PW),wW=H(s1,"disambiguation",j4),X4=H(s1,"offset",C4),D3=H(s1,"calendarName",z4),U4=H(s1,"timeZoneName",W4),G4=H(s1,"offset",J4),KT=H(s1,"roundingMode",D4),x$="PlainYearMonth",_$="PlainMonthDay",$$="PlainDate",T$="PlainDateTime",qO="PlainTime",X1="ZonedDateTime",cO="Instant",iO="Duration",B4=[Math.floor,($)=>qT($)?Math.floor($):Math.round($),Math.ceil,($)=>qT($)?Math.ceil($):Math.round($),Math.trunc,($)=>qT($)?Math.trunc($)||0:Math.round($),($)=>$<0?Math.floor($):Math.ceil($),($)=>Math.sign($)*Math.round(Math.abs($))||0,($)=>qT($)?($=Math.trunc($)||0)+$%2:Math.round($)],O$="UTC",hT=5184000,S4=uT(1847),K4=uT(new Date().getUTCFullYear()+10),L4=/0+$/,K0=A0(J2,WeakMap),Gj=4294967295,pO=A0(($)=>{let T=_f($);return typeof T=="object"?new vW(T):new bW(T||0)});class bW{constructor($){this.v=$}getOffsetNanosecondsFor(){return this.v}getPossibleInstantsFor($){return[cZ($,this.v)]}l(){}}class vW{constructor($){this.$=((T)=>{function O(z){let W=MZ(z,j,C),[J,Y]=Wj(W),D=f(J),U=f(Y);return D===U?D:Z(F(J,Y),D,U,z)}function Z(z,W,J,Y){let D,U;for(;(Y===void 0||(D=Y<z[0]?W:Y>=z[1]?J:void 0)===void 0)&&(U=z[1]-z[0]);){let X=z[0]+Math.floor(U/2);T(X)===J?z[1]=X:z[0]=X+1}return D}let f=A0(T),F=A0(D2),j=S4,C=K4;return{G(z){let W=O(z-86400),J=O(z+86400),Y=z-W,D=z-J;if(W===J)return[Y];let U=O(Y);return U===O(D)?[z-U]:W>J?[Y,D]:[]},V:O,l(z,W){let J=MZ(z,j,C),[Y,D]=Wj(J),U=hT*W,X=W<0?()=>D>j||(j=J,0):()=>Y<C||(C=J,0);for(;X();){let G=f(Y),B=f(D);if(G!==B){let K=F(Y,D);Z(K,G,B);let M=K[0];if((G1(M,z)||1)===W)return M}Y+=U,D+=U}}}})(((T)=>(O)=>{let Z=mZ(T,O*XW);return uT(Oz(Z),parseInt(Z.month),parseInt(Z.day),parseInt(Z.hour),parseInt(Z.minute),parseInt(Z.second))-O})($))}getOffsetNanosecondsFor($){return this.$.V(yj($))*q0}getPossibleInstantsFor($){let[T,O]=[uT((Z=$).isoYear,Z.isoMonth,Z.isoDay,Z.isoHour,Z.isoMinute,Z.isoSecond),Z.isoMillisecond*o0+Z.isoMicrosecond*e1+Z.isoNanosecond];var Z;return this.$.G(T).map((f)=>g0(X$(U$(f,q0),O)))}l($,T){let[O,Z]=mj($),f=this.$.l(O+(T>0||Z?1:0),T);if(f!==void 0)return U$(f,q0)}}var Y3="([+\u2212-])",lT="(?:[.,](\\d{1,9}))?",gW=`(?:(?:${Y3}(\\d{6}))|(\\d{4}))-?(\\d{2})`,X3="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+lT+")?)?",U3=Y3+X3,I4=gW+"-?(\\d{2})(?:[T ]"+X3+"(Z|"+U3+")?)?",kW="\\[(!?)([^\\]]*)\\]",hO=`((?:${kW}){0,9})`,M4=N$(gW+hO),Q4=N$("(?:--)?(\\d{2})-?(\\d{2})"+hO),V4=N$(I4+hO),N4=N$("T?"+X3+"(?:"+U3+")?"+hO),E4=N$(U3),A4=new RegExp(kW,"g"),x4=N$(`${Y3}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${lT}H)?(?:(\\d+)${lT}M)?(?:(\\d+)${lT}S)?)?`),_4=A0(($)=>new E1(xW,{timeZone:$,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),P4=/^(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$/,H4=A0(U2),G3=A0(($)=>new E1(xW,{calendar:$,timeZone:O$,era:"short",year:"numeric",month:"short",day:"numeric"})),w4=/^M(\d{2})(L?)$/,b4={era:sT,eraYear:U0,year:U0,month:Fj,monthCode:sT,day:Fj},v4=A$(Y1,U0),g4=A$(y,gj),Bj=Object.assign({},b4,v4,g4,{offset:sT}),k4=H(Z2,Y1,s0),Sj={dateAdd($,T,O){let Z=k(O),f,{years:F,months:j,weeks:C,days:z}=T;if(z+=Z0(T,5)[0],F||j)f=((W,J,Y,D,U)=>{let[X,G,B]=W.h(J);if(Y){let[K,M]=W.I(X,G);X+=Y,G=rT(K,M,W.U(X)),G=y0("month",G,1,W.L(X),U)}return D&&([X,G]=W._(X,G,D)),B=y0("day",B,1,W.j(X,G),U),W.q(X,G,B)})(this,$,F,j,Z);else{if(!C&&!z)return $;f=S0($)}return f+=(7*C+z)*E0,B1(CO(f))},dateUntil($,T,O){if(O<=7){let z=0,W=$z({...$,...c0},{...T,...c0});return O===7&&([z,W]=K1(W,7)),{...z0,weeks:z,days:W}}let Z=this.h($),f=this.h(T),[F,j,C]=((z,W,J,Y,D,U,X)=>{let G=D-W,B=U-J,K=X-Y;if(G||B){let M=Math.sign(G||B),L=z.j(D,U),E=0;if(Math.sign(K)===-M){let x=L;[D,U]=z._(D,U,-M),G=D-W,B=U-J,L=z.j(D,U),E=M<0?-x:L}if(K=X-Math.min(Y,L)+E,G){let[x,I]=z.I(W,J),[Q,_]=z.I(D,U);if(B=Q-x||Number(_)-Number(I),Math.sign(B)===-M){let P=M<0&&-z.L(D);G=(D-=M)-W,B=U-rT(x,I,z.U(D))+(P||z.L(D))}}}return[G,B,K]})(this,...Z,...f);return O===8&&(j+=this.J(F,Z[0]),F=0),{...z0,years:F,months:j,days:C}},dateFromFields($,T){let O=k(T),Z=SZ(this,$),f=KZ(this,$,Z,O),F=Xj(this,$,f,Z,O);return n(B1(this.P(Z,f,F)),this.id||b)},yearMonthFromFields($,T){let O=k(T),Z=SZ(this,$),f=KZ(this,$,Z,O);return p1(qZ(this.P(Z,f,1)),this.id||b)},monthDayFromFields($,T){let O=k(T),Z=!this.id,{monthCode:f,year:F,month:j}=$,C,z,W,J,Y;if(f!==void 0){[C,z]=jz(f),Y=Lj($,"day");let D=this.N(C,z,Y);if(!D)throw RangeError(Uj);if([W,J]=D,j!==void 0&&j!==J)throw RangeError(CW);Z&&(J=y0("month",J,1,F1,1),Y=y0("day",Y,1,iZ(F!==void 0?F:W,J),O))}else{W=F===void 0&&Z?B$:SZ(this,$),J=KZ(this,$,W,O),Y=Xj(this,$,J,W,O);let D=this.U(W);z=J===D,C=VZ(J,D);let U=this.N(C,z,Y);if(!U)throw RangeError(Uj);[W,J]=U}return nT(B1(this.P(W,J,Y)),this.id||b)},fields($){return NZ(this)&&$.includes("year")?[...$,...xZ]:$},mergeFields($,T){let O=Object.assign(Object.create(null),$);return LZ(O,T,O3),NZ(this)&&(LZ(O,T,d2),this.id===G$&&LZ(O,T,s2,xZ)),O},inLeapYear($){let[T]=this.h($);return this.K(T)},monthsInYear($){let[T]=this.h($);return this.L(T)},daysInMonth($){let[T,O]=this.h($);return this.j(T,O)},daysInYear($){let[T]=this.h($);return this.X(T)},dayOfYear:qf,era($){return this.ee($)[0]},eraYear($){return this.ee($)[1]},monthCode($){let[T,O]=this.h($),[Z,f]=this.I(T,O);return((F,j)=>"M"+m0(F)+(j?"L":""))(Z,f)},dayOfWeek:hj,daysInWeek(){return 7}},R4={dayOfYear:qf,h:cj,q:K$},y4=Object.assign({},R4,{weekOfYear:fz,yearOfWeek:Fz,R($){function T(U){return(7-U<Z?7:0)-U}function O(U){let X=pj(D+U),G=U||1,B=T(r$(z+X*G,7));return J=(X+(B-W)*G)/7}let Z=this.id?1:4,f=hj($),F=this.dayOfYear($),j=r$(f-1,7),C=F-1,z=r$(j-C,7),W=T(z),J,Y=Math.floor((C-W)/7)+1,D=$.isoYear;return Y?Y>O(0)&&(Y=1,D++):(Y=O(-1),D--),[Y,D,J]}}),m4={dayOfYear:qf,h:QZ,q:OT,weekOfYear:fz,yearOfWeek:Fz,R(){return[]}},P$=S2(Object.assign({},Sj,y4,{h:cj,ee($){return this.id===yO?lj($):this.id===G$?f4($):[]},I:($,T)=>[T,0],N($,T){if(!T)return[B$,$]},K:pZ,U(){},L:ij,J:($)=>$*F1,j:iZ,X:pj,P:($,T,O)=>({isoYear:$,isoMonth:T,isoDay:O}),q:K$,_:($,T,O)=>($+=TO(O,F1),(T+=bZ(O,F1))<1?($--,T+=F1):T>F1&&($++,T-=F1),[$,T]),year($){return $.isoYear},month($){return $.isoMonth},day:($)=>$.isoDay}),Object.assign({},Sj,m4,{h:QZ,ee($){let T=this.O($);return[T.era,T.eraYear]},I($,T){let O=cT.call(this,$);return[VZ(T,O),O===T]},N($,T,O){let[Z,f,F]=QZ.call(this,{isoYear:B$,isoMonth:F1,isoDay:31}),j=cT.call(this,Z),C=f===j;(G1($,VZ(f,j))||G1(Number(T),Number(C))||G1(O,F))===1&&Z--;for(let z=0;z<100;z++){let W=Z-z,J=cT.call(this,W),Y=rT($,T,J);if(T===(Y===J)&&O<=Dj.call(this,W,Y))return[W,Y]}},K($){let T=iT.call(this,$);return T>iT.call(this,$-1)&&T>iT.call(this,$+1)},U:cT,L:pT,J($,T){let O=T+$,Z=Math.sign($),f=Z<0?-1:0,F=0;for(let j=T;j!==O;j+=Z)F+=pT.call(this,j+f);return F},j:Dj,X:iT,P($,T,O){return CO(OT.call(this,$,T,O))},q:OT,_($,T,O){if(O){if(T+=O,!Number.isSafeInteger(T))throw RangeError(bO);if(O<0)for(;T<1;)T+=pT.call(this,--$);else{let Z;for(;T>(Z=pT.call(this,$));)T-=Z,$++}}return[$,T]},year($){return this.O($).year},month($){let{year:T,F:O}=this.O($),{C:Z}=this.B(T);return Z[O]+1},day($){return this.O($).day}})),S1="numeric",H$=["timeZoneName"],RW={month:S1,day:S1},B3={year:S1,month:S1},S3=Object.assign({},B3,{day:S1}),K3={hour:S1,minute:S1,second:S1},L3=Object.assign({},S3,K3),q4=Object.assign({},L3,{timeZoneName:"short"}),c4=Object.keys(B3),i4=Object.keys(RW),p4=Object.keys(S3),h4=Object.keys(K3),I3=["dateStyle"],l4=c4.concat(I3),d4=i4.concat(I3),M3=p4.concat(I3,["weekday"]),LT=h4.concat(["dayPeriod","timeStyle"]),Q3=M3.concat(LT),s4=Q3.concat(H$),u4=H$.concat(LT),n4=H$.concat(M3),a4=H$.concat(["day","weekday"],LT),o4=H$.concat(["year","weekday"],LT),t4={},V3=[r1(Q3,L3),YO],yW=[r1(s4,q4),YO,0,($,T)=>{let O=C0($.timeZone);if(T&&C0(T.timeZone)!==O)throw RangeError(WW);return O}],N3=[r1(Q3,L3,H$),S0],E3=[r1(M3,S3,u4),S0],A3=[r1(LT,K3,n4),($)=>L1($)/o0],x3=[r1(l4,B3,a4),S0,1],_3=[r1(d4,RW,o4),S0,1],Kj;function e0($,T,O,Z,f){function F(...z){if(!(this instanceof F))throw TypeError(ef);iW(this,T(...z))}function j(z,W){return Object.defineProperties(function(...J){return z.call(this,C(this),...J)},PZ(W))}function C(z){let W=Y0(z);if(!W||W.branding!==$)throw TypeError(ef);return W}return Object.defineProperties(F.prototype,{...Ij(i0(j,O)),...l1(i0(j,Z)),...$O("Temporal."+$)}),Object.defineProperties(F,{...l1(f),...PZ($)}),[F,(z)=>{let W=Object.create(F.prototype);return iW(W,z),W},C]}function lW($){return $=$.concat("id").sort(),(T)=>{if(!Mj(T,$))throw TypeError(zW);return T}}function g$($){if(Y0($)||$.calendar!==void 0||$.timeZone!==void 0)throw TypeError(fW);return $}function lO($,T){let O={};for(let Z in $)O[Z]=({o:f},F)=>{let j=Y0(F)||{},{branding:C}=j,z=C===$$||T.includes(C)?j:M0(F);return f[Z](z)};return O}function w3($){let T={};for(let O in $)T[O]=(Z)=>{let{calendar:f}=Z;return(F=f,typeof F=="string"?P$(F):(j=F,Object.assign(Object.create(X5),{i:j})))[O](Z);var F,j};return T}function H1(){throw TypeError(jW)}function MT({calendar:$}){return typeof $=="string"?new c3($):$}function mW($,T){if(T=s(T),f0($)){let Z=Y0($);if(Z&&Z.branding===_$)return k(T),Z;let f=uW($);return hf(tO(f||b),!f,$,T)}let O=HC(P$,$);return k(T),O}function dW($,T,O){return Z=T.call($,I0(F0(O))),Wf(CT(Z));var Z}function dO($,T=tW){let O=Object.keys(T).sort(),Z={};for(let f of O)Z[f]=H(T[f],$,VW($[f]));return Z}function q($,T){return typeof $=="string"?pO($):dO($,T)}function o($){return q($,H3)}function t0($){if(f0($)){let T=Y0($);if(T)switch(T.branding){case cO:return T;case X1:return F0(T.epochNanoseconds)}}return EC($)}function qW($,T,O){let Z=T.l(t0(O).epochNanoseconds,$);return Z?I0(F0(Z)):null}function i($){return f0($)?(Y0($)||{}).timeZone||L5($):((T)=>EO(gC(h(T))))($)}function A1($,T){if(f0($)){let O=Y0($)||{};switch(O.branding){case qO:return k(T),O;case T$:return k(T),l0(O);case X1:return k(T),af(o,O)}return Xz($,T)}return k(T),wC($)}function b3($){return $===void 0?void 0:A1($)}function w$($,T){if(T=s(T),f0($)){let Z=Y0($);return Z&&Z.branding===x$?(k(T),Z):pf(aO(QT($)),$,T)}let O=PC(P$,$);return k(T),O}function x1($,T){if(T=s(T),f0($)){let Z=Y0($)||{};switch(Z.branding){case T$:return k(T),Z;case $$:return k(T),u({...Z,...c0});case X1:return k(T),uf(o,Z)}return Yz(oO(QT($)),$,T)}let O=_C($);return k(T),O}function M0($,T){if(T=s(T),f0($)){let Z=Y0($)||{};switch(Z.branding){case $$:return k(T),Z;case T$:return k(T),n(Z);case X1:return k(T),nf(o,Z)}return cf(oO(QT($)),$,T)}let O=VO($);return k(T),O}function sW($,T,O){return p0(T.call($,d(n(O,$))))}function $1($){return(T)=>typeof T=="string"?P$(T):((O,Z)=>{let f=Object.keys(Z).sort(),F={};for(let j of f)F[j]=H(Z[j],O,O[j]);return F})(T,$)}function l($){if(f0($)){let T=Y0($);return T&&T.branding===iO?T:Uz($)}return bC($)}function IT($){if($!==void 0){if(f0($)){let T=Y0($)||{};switch(T.branding){case X1:case $$:return T;case T$:return n(T)}let O=QT($);return{...Jz(i,q,oO(O),$),calendar:O}}return AC($)}}function QT($){return uW($)||b}function uW($){let{calendar:T}=$;if(T!==void 0)return D0(T)}function D0($){return f0($)?(Y0($)||{}).calendar||g5($):((T)=>JT(vC(h(T))))($)}function b$($,T){if(T=s(T),f0($)){let O=Y0($);if(O&&O.branding===X1)return zT(T),O;let Z=QT($);return Dz(i,q,oO(Z),Z,$,T)}return xC($,T)}function cW($){return i0((T)=>(O)=>T(P3(O)),$)}function P3($){return K0($,o)}function r4(){let $=E1.prototype,T=Object.getOwnPropertyDescriptors($),O=Object.getOwnPropertyDescriptors(E1),Z=function(f,F={}){if(!(this instanceof Z))return new Z(f,F);i3.set(this,((j,C={})=>{let z=new E1(j,C),W=z.resolvedOptions(),J=W.locale,Y=_0(Object.keys(C),W),D=A0(T5),U=(...X)=>{let G,B=X.map((K,M)=>{let L=Y0(K),E=(L||{}).branding;if(M&&G&&G!==E)throw TypeError(DW);return G=E,L});return G?D(G)(J,Y,...B):[z,...X]};return U.u=z,U})(f,F))};for(let f in T){let F=T[f],j=f.startsWith("format")&&e4(f);typeof F.value=="function"?F.value=f==="constructor"?Z:j||$5(f):j&&(F.get=function(){return j.bind(this)})}return O.prototype.value=Object.create($,T),Object.defineProperties(Z,O),Z}function e4($){return function(...T){let O=i3.get(this),[Z,...f]=O(...T);return Z[$](...f)}}function $5($){return function(...T){return i3.get(this).u[$](...T)}}function T5($){let T=O5[$];if(!T)throw TypeError(JW($));return J1(T,A0(of))}var O5={Instant:V3,PlainDateTime:N3,PlainDate:E3,PlainTime:A3,PlainYearMonth:x3,PlainMonthDay:_3},Z5=J1(V3),f5=J1(yW),F5=J1(N3),j5=J1(E3),C5=J1(A3),z5=J1(x3),W5=J1(_3),v3={era:_j,eraYear:vZ,year:CT,month:p0,daysInMonth:p0,daysInYear:p0,inLeapYear:QW,monthsInYear:p0},uO={monthCode:h},g3={day:p0},nW={dayOfWeek:p0,dayOfYear:p0,weekOfYear:Pj,yearOfWeek:vZ,daysInWeek:p0},aW=Object.assign({},v3,uO,g3,nW),sO=new WeakMap,Y0=sO.get.bind(sO),iW=sO.set.bind(sO),J5={...lO(v3,[x$]),...lO(nW,[]),...lO(uO,[x$,_$]),...lO(g3,[_$])},k3=w3(aW),D5=w3({...v3,...uO}),Y5=w3({...uO,...g3}),VT={calendarId:($)=>C0($.calendar)},X5=i0(($,T)=>function(O){let{i:Z}=this;return $(Z[T](d(n(O,Z))))},aW),U5=FT(($)=>(T)=>T[$],y.concat("sign")),R3=FT(($,T)=>(O)=>O[s0[T]],Y1),oW={epochSeconds:tj,epochMilliseconds:YO,epochMicroseconds:rj,epochNanoseconds:ej},NT=H(HZ,new Set(["branding"])),[G5,v$,B5]=e0(_$,H(_z,D0),{...VT,...Y5},{getISOFields:NT,getCalendar:MT,with($,T,O){return v$(Lz(w5,$,this,g$(T),O))},equals:($,T)=>nC($,mW(T)),toPlainDate($,T){return d(pz(ET,$,this,T))},toLocaleString($,T,O){let[Z,f]=W5(T,O,$);return Z.format(f)},toString:ff,toJSON:($)=>ff($),valueOf:H1},{from:($,T)=>v$(mW($,T))}),tW={getOffsetNanosecondsFor:dW,getPossibleInstantsFor($,T,O){let Z=[...T.call($,J0(u(O,b)))].map((F)=>K5(F).epochNanoseconds),f=Z.length;return f>1&&(Z.sort(B0),Jf(v0(b0(Z[0],Z[f-1])))),Z}},H3={getOffsetNanosecondsFor:dW},[S5,I0,K5]=e0(cO,Vz,oW,{add:($,T)=>I0(Df(0,$,l(T))),subtract:($,T)=>I0(Df(1,$,l(T))),until:($,T,O)=>c(bf(0,$,t0(T),O)),since:($,T,O)=>c(bf(1,$,t0(T),O)),round:($,T)=>I0(OC($,T)),equals:($,T)=>hC($,t0(T)),toZonedDateTime($,T){let O=z1(T);return a(sf($,i(O.timeZone),D0(O.calendar)))},toZonedDateTimeISO:($,T)=>a(sf($,i(T))),toLocaleString($,T,O){let[Z,f]=Z5(T,O,$);return Z.format(f)},toString:($,T)=>eZ(i,o,$,T),toJSON:($)=>eZ(i,o,$),valueOf:H1},{from:($)=>I0(t0($)),fromEpochSeconds:($)=>I0(dz($)),fromEpochMilliseconds:($)=>I0(sz($)),fromEpochMicroseconds:($)=>I0(uz($)),fromEpochNanoseconds:($)=>I0(nz($)),compare:($,T)=>Pf(t0($),t0(T))}),[nO,t7]=e0("TimeZone",($)=>{let T=iC($);return{branding:"TimeZone",id:T,o:pO(T)}},{id:($)=>$.id},{getPossibleInstantsFor:({o:$},T)=>$.getPossibleInstantsFor(x1(T)).map((O)=>I0(F0(O))),getOffsetNanosecondsFor:({o:$},T)=>$.getOffsetNanosecondsFor(t0(T).epochNanoseconds),getOffsetStringFor($,T){let O=t0(T).epochNanoseconds,Z=dO(this,H3).getOffsetNanosecondsFor(O);return u1(Z)},getPlainDateTimeFor($,T,O=b){let Z=t0(T).epochNanoseconds,f=dO(this,H3).getOffsetNanosecondsFor(Z);return J0(u(M1(Z,f),D0(O)))},getInstantFor($,T,O){let Z=x1(T),f=hZ(O),F=dO(this);return I0(F0(x0(F,Z,f)))},getNextTransition:({o:$},T)=>qW(1,$,T),getPreviousTransition:({o:$},T)=>qW(-1,$,T),equals($,T){return!!xO(this,i(T))},toString:($)=>$.id,toJSON:($)=>$.id},{from($){let T=i($);return typeof T=="string"?new nO(T):T}}),L5=lW(Object.keys(tW)),[I5,_1]=e0(qO,Pz,R3,{getISOFields:NT,with($,T,O){return _1(Iz(this,g$(T),O))},add:($,T)=>_1(Bf(0,$,l(T))),subtract:($,T)=>_1(Bf(1,$,l(T))),until:($,T,O)=>c(yf(0,$,A1(T),O)),since:($,T,O)=>c(yf(1,$,A1(T),O)),round:($,T)=>_1(FC($,T)),equals:($,T)=>aC($,A1(T)),toZonedDateTime:($,T)=>a(hz(i,M0,q,$,T)),toPlainDateTime:($,T)=>J0(lz($,M0(T))),toLocaleString($,T,O){let[Z,f]=C5(T,O,$);return Z.format(f)},toString:Ff,toJSON:($)=>Ff($),valueOf:H1},{from:($,T)=>_1(A1($,T)),compare:($,T)=>AO(A1($),A1(T))}),[M5,P1,Q5]=e0(x$,H(xz,D0),{...VT,...D5},{getISOFields:NT,getCalendar:MT,with($,T,O){return P1(Kz(H5,$,this,g$(T),O))},add:($,T,O)=>P1(Gf(pW,0,$,l(T),O)),subtract:($,T,O)=>P1(Gf(pW,1,$,l(T),O)),until:($,T,O)=>c(Rf(hW,0,$,w$(T),O)),since:($,T,O)=>c(Rf(hW,1,$,w$(T),O)),equals:($,T)=>uC($,w$(T)),toPlainDate($,T){return d(iz(ET,$,this,T))},toLocaleString($,T,O){let[Z,f]=z5(T,O,$);return Z.format(f)},toString:Zf,toJSON:($)=>Zf($),valueOf:H1},{from:($,T)=>P1(w$($,T)),compare:($,T)=>o1(w$($),w$(T))}),[V5,J0]=e0(T$,H(Ez,D0),{...VT,...k3,...R3},{getISOFields:NT,getCalendar:MT,with($,T,O){return J0(Bz(ET,$,this,g$(T),O))},withCalendar:($,T)=>J0(wO($,D0(T))),withPlainDate:($,T)=>J0(rz($,M0(T))),withPlainTime:($,T)=>J0(tz($,b3(T))),add:($,T,O)=>J0(Xf(Z$,0,$,l(T),O)),subtract:($,T,O)=>J0(Xf(Z$,1,$,l(T),O)),until:($,T,O)=>c(gf(r0,0,$,x1(T),O)),since:($,T,O)=>c(gf(r0,1,$,x1(T),O)),round:($,T)=>J0(fC($,T)),equals:($,T)=>dC($,x1(T)),toZonedDateTime:($,T,O)=>a(gz(q,$,i(T),O)),toPlainDate:($)=>d(n($)),toPlainTime:($)=>_1(l0($)),toPlainYearMonth($){return P1(kz(aO,$,this))},toPlainMonthDay($){return v$(Rz(tO,$,this))},toLocaleString($,T,O){let[Z,f]=F5(T,O,$);return Z.format(f)},toString:Tf,toJSON:($)=>Tf($),valueOf:H1},{from:($,T)=>J0(x1($,T)),compare:($,T)=>wf(x1($),x1(T))}),[N5,d,rW]=e0($$,H(Az,D0),{...VT,...k3},{getISOFields:NT,getCalendar:MT,with($,T,O){return d(Sz(ET,$,this,g$(T),O))},withCalendar:($,T)=>d(wO($,D0(T))),add:($,T,O)=>d(Uf(Z$,0,$,l(T),O)),subtract:($,T,O)=>d(Uf(Z$,1,$,l(T),O)),until:($,T,O)=>c(kf(r0,0,$,M0(T),O)),since:($,T,O)=>c(kf(r0,1,$,M0(T),O)),equals:($,T)=>sC($,M0(T)),toZonedDateTime($,T){let O=!f0(T)||T instanceof nO?{timeZone:T}:T;return a(yz(i,A1,q,$,O))},toPlainDateTime:($,T)=>J0(mz($,b3(T))),toPlainYearMonth($){return P1(qz(aO,$,this))},toPlainMonthDay($){return v$(cz(tO,$,this))},toLocaleString($,T,O){let[Z,f]=j5(T,O,$);return Z.format(f)},toString:Of,toJSON:($)=>Of($),valueOf:H1},{from:($,T)=>d(M0($,T)),compare:($,T)=>o1(M0($),M0(T))}),y3={fields($,T,O){return[...T.call($,O)]}},eW=Object.assign({dateFromFields($,T,O,Z){return rW(T.call($,Object.assign(Object.create(null),O),Z))}},y3),$6=Object.assign({yearMonthFromFields($,T,O,Z){return Q5(T.call($,Object.assign(Object.create(null),O),Z))}},y3),T6=Object.assign({monthDayFromFields($,T,O,Z){return B5(T.call($,Object.assign(Object.create(null),O),Z))}},y3),m3={mergeFields($,T,O,Z){return z1(T.call($,Object.assign(Object.create(null),O),Object.assign(Object.create(null),Z)))}},E5=Object.assign({},eW,m3),A5=Object.assign({},$6,m3),x5=Object.assign({},T6,m3),q3={dateAdd($,T,O,Z,f){return rW(T.call($,d(n(O,$)),c(p(Z)),f))}},O6=Object.assign({},q3,{dateUntil($,T,O,Z,f,F){return v5(T.call($,d(n(O,$)),d(n(Z,$)),Object.assign(Object.create(null),F,{largestUnit:GT[f]})))}}),_5=Object.assign({},q3,{day:sW}),P5=Object.assign({},O6,{day:sW}),aO=$1($6),oO=$1(eW),tO=$1(T6),H5=$1(A5),ET=$1(E5),w5=$1(x5),Z$=$1(q3),r0=$1(O6),pW=$1(_5),hW=$1(P5),[b5,c,v5]=e0(iO,Hz,{...U5,blank:QC},{with:($,T)=>c(Mz($,T)),negated:($)=>c(MO($)),abs:($)=>c(MC($)),add:($,T,O)=>c(Mf(IT,r0,q,0,$,l(T),O)),subtract:($,T,O)=>c(Mf(IT,r0,q,1,$,l(T),O)),round:($,T)=>c(IC(IT,r0,q,$,T)),total:($,T)=>TC(IT,r0,q,$,T),toLocaleString($,T,O){return Intl.DurationFormat?new Intl.DurationFormat(T,O).format(this):BO($)},toString:BO,toJSON:($)=>BO($),valueOf:H1},{from:($)=>c(l($)),compare:($,T,O)=>pC(IT,Z$,q,l($),l(T),O)}),Z6={toString:($)=>$.id,toJSON:($)=>$.id,...J5,dateAdd:({id:$,o:T},O,Z,f)=>d(n(T.dateAdd(M0(O),l(Z),f),$)),dateUntil:({o:$},T,O,Z)=>c(p($.dateUntil(M0(T),M0(O),sj(Z)))),dateFromFields:({id:$,o:T},O,Z)=>d(cf(T,O,Z,xj($))),yearMonthFromFields:({id:$,o:T},O,Z)=>P1(pf(T,O,Z,Ej($))),monthDayFromFields:({id:$,o:T},O,Z)=>v$(hf(T,0,O,Z,Aj($))),fields({o:$},T){let O=new Set(d0),Z=[];for(let f of T){if(h(f),!O.has(f))throw RangeError(rf(f));O.delete(f),Z.push(f)}return $.fields(Z)},mergeFields:({o:$},T,O)=>$.mergeFields(wZ(gZ(T)),wZ(gZ(O)))},[c3]=e0("Calendar",($)=>{let T=Zz($);return{branding:"Calendar",id:T,o:P$(T)}},{id:($)=>$.id},Z6,{from($){let T=D0($);return typeof T=="string"?new c3(T):T}}),g5=lW(Object.keys(Z6).slice(4)),[k5,a]=e0(X1,H(Nz,D0,i),{...oW,...VT,...cW(k3),...cW(R3),offset:($)=>u1(P3($).offsetNanoseconds),offsetNanoseconds:($)=>P3($).offsetNanoseconds,timeZoneId:($)=>C0($.timeZone),hoursInDay:($)=>jC(q,$)},{getISOFields:($)=>KC(o,$),getCalendar:MT,getTimeZone:({timeZone:$})=>typeof $=="string"?new nO($):$,with($,T,O){return a(Gz(ET,q,$,this,g$(T),O))},withCalendar:($,T)=>a(wO($,D0(T))),withTimeZone:($,T)=>a(ez($,i(T))),withPlainDate:($,T)=>a(oz(q,$,M0(T))),withPlainTime:($,T)=>a(az(q,$,b3(T))),add:($,T,O)=>a(Yf(Z$,q,0,$,l(T),O)),subtract:($,T,O)=>a(Yf(Z$,q,1,$,l(T),O)),until:($,T,O)=>c(p(vf(r0,q,0,$,b$(T),O))),since:($,T,O)=>c(p(vf(r0,q,1,$,b$(T),O))),round:($,T)=>a(ZC(q,$,T)),startOfDay:($)=>a(CC(q,$)),equals:($,T)=>lC($,b$(T)),toInstant:($)=>I0(wz($)),toPlainDateTime:($)=>J0(uf(o,$)),toPlainDate:($)=>d(nf(o,$)),toPlainTime:($)=>_1(af(o,$)),toPlainYearMonth($){return P1(bz(aO,$,this))},toPlainMonthDay($){return v$(vz(tO,$,this))},toLocaleString($,T,O={}){let[Z,f]=f5(T,O,$);return Z.format(f)},toString:($,T)=>$f(o,$,T),toJSON:($)=>$f(o,$),valueOf:H1},{from:($,T)=>a(b$($,T)),compare:($,T)=>Hf(b$($),b$(T))}),R5=Object.defineProperties({},{...$O("Temporal.Now"),...l1({timeZoneId:()=>D1(),instant:()=>I0(F0(YT())),zonedDateTime:($,T=D1())=>a(W0(YT(),i(T),D0($))),zonedDateTimeISO:($=D1())=>a(W0(YT(),i($),b)),plainDateTime:($,T=D1())=>J0(u(E$(o(i(T))),D0($))),plainDateTimeISO:($=D1())=>J0(u(E$(o(i($))),b)),plainDate:($,T=D1())=>d(n(E$(o(i(T))),D0($))),plainDateISO:($=D1())=>d(n(E$(o(i($))),b)),plainTimeISO:($=D1())=>_1(l0(E$(o(i($)))))})}),T1=Object.defineProperties({},{...$O("Temporal"),...l1({PlainYearMonth:M5,PlainMonthDay:G5,PlainDate:N5,PlainTime:I5,PlainDateTime:V5,ZonedDateTime:k5,Instant:S5,Calendar:c3,TimeZone:nO,Duration:b5,Now:R5})}),y5=r4(),i3=new WeakMap,m5=Object.defineProperties(Object.create(Intl),l1({DateTimeFormat:y5}));function rO($){return typeof $==="function"&&$.prototype!==void 0}function w1($){return typeof $==="string"?[$]:$}function eO($,T){let O=T?"attachment":"inline",Z=$.replace(/["\\]/g,"").replace(/[^\x20-\x7e]/g,"_");return`${O}; filename="${Z}"; filename*=UTF-8''${encodeURIComponent($)}`}function q5($){return"total"in $&&"partial"in $&&"body"in $}function AT($){return new Response(null,{status:416,headers:{"Accept-Ranges":"bytes","Content-Range":l3($),"Content-Length":"0","Cache-Control":"no-store"}})}async function c5($){if($ instanceof Blob)return{body:$,start:0,end:$.size-1,total:$.size,partial:!1,type:$.type,name:$.name,download:!1,status:200,extraHeaders:{}};if(q5($))return{body:$.body,start:$.start,end:$.end,total:$.total,partial:$.partial,type:$.type,name:$.name,download:!1,etag:$.etag,lastModified:$.lastModified,status:200,extraHeaders:{}};let T=$.file,O=T instanceof Blob?T:null,Z=$.total??O?.size??-1;return{body:T,start:$.start??0,end:$.end??Z-1,total:Z,partial:$.partial??!1,type:$.type??O?.type??"",name:$.name??T?.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}}}async function d3($,T){if($ instanceof Response)return $;if(!$)return new Response("Not found",{status:404});let O=await c5($),{body:Z,start:f,end:F,total:j,partial:C}=O;if(Z instanceof Blob&&"exists"in Z&&typeof Z.exists==="function"){if(!await Z.exists())return new Response("Not found",{status:404})}let{range:z}=T;if(z){if(j<=0)return AT(Math.max(j,0));if(!C){if(Z instanceof Blob){let D=p3(z,j);if(!D)return AT(j);Z=Z.slice(D.start,D.end+1),f=D.start,F=D.end,C=!0}}}let W=Boolean(z)&&C,J=W?206:O.status,Y=new Headers;if(Y.set("Accept-Ranges","bytes"),Y.set("Content-Type",O.type||"application/octet-stream"),W)Y.set("Content-Range",h3(f,F,j)),Y.set("Content-Length",String(F-f+1));else if(j>=0)Y.set("Content-Length",String(j));if(O.name)Y.set("Content-Disposition",eO(O.name,O.download));if(O.etag)Y.set("ETag",O.etag);if(O.lastModified)Y.set("Last-Modified",O.lastModified.toUTCString());for(let[D,U]of Object.entries(O.extraHeaders))Y.set(D,U);if((T.method??"GET").toUpperCase()==="HEAD"){if(Z&&"cancel"in Z&&typeof Z.cancel==="function")await Z.cancel();return new Response(null,{status:J,headers:Y})}return new Response(Z,{status:J,headers:Y})}function f6($){return rO($)}class t{method;handler;methodName;__internal_brand="RouteHandler";middlewares=[];constructor($,T,O){this.method=$;this.handler=T;this.methodName=O;this.handler=T,this.methodName=O,this.method=$}get source(){if(!f6(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(f6(this.handler)){let T=new this.handler;return T[this.methodName].bind(T)()}return this.handler()}middleware($){return this.middlewares=w1($),this}}class F6{url;headers;__internal_brand="ProxyHandler";constructor($,T){this.url=$;this.headers=T}run(){let $=new A;return fetch(this.url,{method:$.rawRequest.method,headers:{...$.headers.toJSON(),...this.headers},body:$.rawRequest.body})}}class j6{constructor(...$){return new t(...$)}}class C6 extends t{__internal_brand="StreamHandler";async run($){let T=N.getStore(),O=T?.req?.rawRequest,Z=s3(O?.headers.get("Range"));if(T)T.rangeRequest=Z;try{let f=await super.run($);return await d3(f,{range:Z,method:O?.method})}catch(f){if(f instanceof u3)return AT(f.total);throw f}finally{if(T)T.rangeRequest=null}}}class z6{constructor(...$){return new C6(...$)}}class W6{__internal_brand="ResourceRoutes";first;second;constructor($){this.first={get:new t("GET",$,"list"),post:new t("POST",$,"store")},this.second={get:new t("GET",$,"show"),put:new t("PUT",$,"update"),delete:new t("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 P0{static __brand="ApiRouter";routes={};middlewares=[];middleware($){}get($,T){return new t("GET",$,T)}post($,T){return new t("POST",$,T)}put($,T){return new t("PUT",$,T)}patch($,T){return new t("PATCH",$,T)}delete($,T){return new t("DELETE",$,T)}resource($){return new W6($)}agent($){return i5($,this)}file($,T){return new j6("GET",$,T)}stream($,T){return new z6("GET",$,T)}proxy($,T={}){return new F6($,T)}}function i5($,T){let O={stream:new t("POST",$,"stream"),attach:new t("POST",$,"attach"),stop:new t("POST",$,"stop"),upload:new t("POST",$,"upload")};return class extends P0{static __internal_brand="AgentRoute";static controller=$;static handlers=O;constructor(){super();this.middlewares=[...T?.middlewares??[]]}routes={"/":O.stream,"/attach":O.attach,"/stop":O.stop,"/files":O.upload};static middleware(f){if(f.stream)O.stream.middleware(f.stream);if(f.attach)O.attach.middleware(f.attach);if(f.stop)O.stop.middleware(f.stop);if(f.upload)O.upload.middleware(f.upload);return this}}}class n3{method;url;meta;__internal_brand="McpRoute";constructor($,T,O){this.method=$;this.url=T;this.meta=O}}class J6{static __brand="McpRouter";routes={};fromApiRoute($,T,O){return new n3($,T,O)}}function r($,T){return $.replace(/:([^/]+[*?]?)/g,(O,Z)=>{let f=Z.endsWith("?")||Z.endsWith("*"),F=f?Z.slice(0,-1):Z,j=T[F];if(j===void 0){if(f)return"";if(import.meta.env.DEV)throw Error(`Missing parameter: ${F}`);console.error(`Missing parameter: ${F} in URL: ${$}`)}return String(j)}).replace(/\/\//g,"/").replace(/\/$/,"")}class a3 extends f${constructor($,T=307){super("Redirect error");this.name="RedirectError",this.payload={api:{status:200,data:{},directive:{kind:"Redirect",path:$}},view:{status:T,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:$}}}}}class $Z{static to($,...T){let[O={}]=T,{search:Z={},params:f={},permanent:F,status:j}={params:{},status:307,permanent:!1,...O},C=new URLSearchParams(Z).toString();throw new a3([r($,f)||"/",C.toString()].filter(Boolean).join("?"),j??(F?301:307))}static external($,T=307){throw new a3($,T)}}class D6{kind="redirect";viewPath="REDIRECT";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>({});else if(typeof $==="function")this.handler=$;else{let[T,O]=$;this.handler=(Z)=>{return new T()[O](Z)}}}async run($,T){let{destination:O,permanent:Z=!1,status:f=307}=await this.handler($);if(!O)throw Error(`Redirect destination is required see ${T}`);return $Z.to(O,{permanent:Z,status:f}),{}}middleware($){return this.middlewares=w1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}async function o3($,T){if($ instanceof Response)return $;let O=$ instanceof Blob,Z=O?$:$.file,f=O?$.name:$.name??$.file?.name,F=(O?$.type:$.type??$.file?.type)||"",j=O?!1:$.download??!1,C=O?200:$.status??200;if(!O)for(let[z,W]of Object.entries($.headers??{}))T.set(z,W);if(Z instanceof Blob&&"exists"in Z&&typeof Z.exists==="function"){if(!await Z.exists())return new Response("Not found",{status:404})}if(T.set("Content-Type",F||"application/octet-stream"),Z instanceof Blob)T.set("Content-Length",String(Z.size));if(f)T.set("Content-Disposition",eO(f,j));return new Response(Z instanceof Blob?Z.stream():Z,{status:C,headers:T})}class Y6{kind="file";viewPath="FILE";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>null;else if(typeof $==="function")this.handler=$;else{let[T,O]=$;this.handler=(Z)=>{return new T()[O](Z)}}}async run($,T){let O=await this.handler($);if(!O)throw Error(`File route handler must return a file see ${T}`);return{FILE:O}}middleware($){return this.middlewares=w1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class X6{viewPath;middlewares=[];featureGates=[];handler;constructor($,T){this.viewPath=$;if(!T)this.handler=()=>({});else if(typeof T==="function")this.handler=T;else{let[O,Z]=T;this.handler=(f)=>{return new O()[Z](f)}}}async run($,T){let O=await this.handler($);return{[this.viewPath]:{...O,breadcrumb:{label:O?.breadcrumb??"",href:T}}}}middleware($){return this.middlewares=w1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class U6{viewPath;children;middlewares=[];featureGates=[];alwaysRuns=!1;handler=()=>({});constructor($,T,O){this.viewPath=$;if(typeof T==="function")this.handler=T,this.children=class extends b1{routes=O??{}};else if(Array.isArray(T)){let[Z,f]=T;this.handler=(F)=>{return new Z()[f](F)},this.children=class extends b1{routes=O??{}}}else this.children=class extends b1{routes=T},this.handler=()=>({})}async run($,T){let O=await this.handler($);return{[this.viewPath]:{...O,breadcrumb:{label:O?.breadcrumb??"",href:T}}}}alwaysRun(){return this.alwaysRuns=!0,this}middleware($){return this.middlewares=w1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class b1{middlewares=[];featureGates=[];routes={};view($,T){return new X6($,T)}file($){return new Y6($)}redirect($){return new D6($)}layout($,T,O){return new U6($,T,O)}}class k0{req;config={};constructor($){this.req=$}run(...$){return{}}static configure($){let T=this;return class extends T{config=$}}}function p5($){return $}function h5(){return{aliases:{},global:[]}}var k$="redirect";function xT($,T="/"){if(typeof $!=="string"||!$.startsWith("/"))return T;if(/[\u0000-\u001f\u007f\\]/.test($)||$.startsWith("//"))return T;try{let O=new URL($,"http://gemi.invalid");if(O.origin!=="http://gemi.invalid")return T;let Z=`${O.search}${O.hash}`.replaceAll("/","%2F"),f=`${O.pathname}${Z}`.replaceAll(":","%3A");return f.startsWith("//")?T:f}catch{return T}}function G6($){let T=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();return T?T==="https":new URL($.url).protocol==="https:"}function l5($,T=!0){let O=new URL($.rawRequest.url),Z=O.pathname.replace(/\.(json|og)$/,""),[,f,...F]=Z.split("/");if(S(e).supportedLocales.includes(f))Z=`/${F.join("/")}`;return T?`${Z}${O.search}`:Z}function d5($,T){let O=(Z)=>Z.replace(/\/+$/,"")||"/";return O($)===O(T)}function TZ($,T){let O=T||S(w).config.signInPath,Z=/^[a-z][a-z\d+.-]*:/i.test(O);if(Z?!/^https?:\/\//i.test(O):!O.startsWith("/"))throw Error(`\`auth.signInPath\` must be a path like "/auth/sign-in", or an http(s) URL for sign-in hosted elsewhere. Got "${O}". A route's own \`"auth:<path>"\` cannot carry a URL, because the alias parser splits it on the colon.`);let f=new URL(O,"http://gemi.invalid");if($?.kind==="view"){let F=l5($,!Z);if(Z||!d5(new URL(F,f).pathname,f.pathname))f.searchParams.set(k$,F)}return Z?f.href:`${f.pathname}${f.search}`}class B6 extends k0{async run($){let T=N.getStore(),O=T.req,Z=()=>new _T({redirectTo:TZ(O,$)}),f=O.cookies.get("access_token"),F=O.headers.get("access_token"),j=f||F;if(!j)throw Z();let C=T.user;if(!C){let z=await S(w).getSession(j,O.headers.get("User-Agent"));if(!z)throw Z();C=z?.user,T.setUser(C)}return{}}}class S6 extends k0{async run(...$){let[T="public",O="864000",...Z]=$,f=`${T}, max-age=${O}${Z.length>0?", ":""}${Z.join(", ")}`;if($.length===0)f="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="public")f="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="private")f="private, max-age=0, stale-while-revalidate=300, stale-if-error=600";if(this.req.rawRequest.method==="GET")this.req.ctx().setHeaders("Cache-Control",f);return{}}}var s5={"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 K6 extends k0{config={origins:{"":{"Access-Control-Allow-Methods":"GET, HEAD, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Authorization, X-Requested-With","Access-Control-Allow-Credentials":"true"}}};run(){let $=this.req,T=$.rawRequest.headers.get("Origin");if(this.config.origins[T]){$.ctx().setHeaders("Access-Control-Allow-Origin",T);let O={...s5,...this.config.origins[T]};for(let[Z,f]of Object.entries(O))$.ctx().setHeaders(Z,f)}return{}}}class R${config;static token="ratelimiter";constructor($){this.config=$}get driver(){return this.config.driver}async consume($,T={}){let O=T.limit??this.config.limit,Z=T.window??this.config.window,f=T.cost??1;if(L6("window",Z),L6("limit",O),!Number.isFinite(f)||f<0)throw Error(`Rate limiter cost must be zero or greater, got ${f}`);return await this.config.driver.consume({key:$,limit:O,window:Z*1000,cost:f})}}function L6($,T){if(!Number.isFinite(T)||T<=0)throw Error(`Rate limiter ${$} must be greater than zero, got ${T}`)}class t3 extends f${constructor($){super("Rate limit exceeded");let T={"Content-Type":"application/json",...$?V6($):{}};this.payload={api:{status:429,data:{error:{message:"Rate limit exceeded"}},headers:T},view:{error:{message:"Rate limit exceeded"},status:429,headers:T}}}}class Q6 extends k0{async run($,T){let O=u5();if(!O)return{};let Z=await O.consume(this.key(),{limit:I6($)??this.config.limit,window:I6(T)??this.config.window});if(this.config.headers!==!1){let f=this.req.ctx?.();if(f)for(let[F,j]of Object.entries(V6(Z)))f.setHeaders(F,j)}if(!Z.allowed)throw new t3(Z);return{}}key(){if(this.config.key)return this.config.key(this.req);return`${OZ(this.req)}:${this.req.routePath??"*"}`}}function u5(){try{let $=S();return $.bound(R$)?$.make(R$):null}catch{return null}}function OZ($){let T=M6($.rawRequest);if(T!==void 0)return T;let O=$.headers.get("x-forwarded-for");if(O){let[Z]=O.split(",");if(Z?.trim())return Z.trim()}return $.headers.get("x-real-ip")?.trim()||"unknown"}function V6($){let T={"X-RateLimit-Limit":String($.limit),"X-RateLimit-Remaining":String($.remaining),"X-RateLimit-Reset":String(Math.ceil($.resetAt/1000))};if(!$.allowed)T["Retry-After"]=String(Math.max(1,Math.ceil($.retryAfter/1000)));return T}function I6($){if($===void 0||$===null||$==="")return;let T=Number($);if(!Number.isFinite(T)||T<=0)return;return T}class N6 extends k0{async run(){let $=this.req.cookies.get("csrf_token");if(!$)throw new r3;if(!["POST","PUT","PATCH","DELETE"].includes(this.req.rawRequest.method))return{};if(!Bun.CSRF.verify($,{secret:process.env.SECRET}))throw new r3;return{}}}class r3 extends f${constructor(){super("Invalid CSRF token");this.name="InvalidCSRFTokenError"}payload={api:{status:403,data:{error:"Invalid CSRF token"}},view:{}}}class E6{policiesList={};constructor(){let $=this.register();for(let T of $){let O=new T;this.policiesList[T.name]=O}}register(){return[]}}class A6{all($,T){return!0}}class OF extends A{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 RD($){return $}function x6($={}){return{basePath:"/auth",verifyEmail:!0,redirectPath:"/dashboard",signInPath:"/auth/sign-in",sessionExpiresInHours:24,sessionAbsoluteExpiresInHours:672,cookieDomain:null,signUpRequest:OF,oauthProviders:{},verifyPassword:async(T,O)=>await Bun.password.verify(T,O),hashPassword:async(T)=>await Bun.password.hash(T),generateForgotPasswordToken:async(T)=>{let O=new Bun.CryptoHasher("sha256");return O.update(`${T.email}${Date.now()}`),O.digest("hex")},generateEmailVerificationToken:(T)=>{if(!($.verifyEmail??!0))return"";let O=new Bun.CryptoHasher("sha256");return O.update(`${T}${Date.now()}`),O.digest("hex")},generateMagicLinkToken:(T)=>{let O=new Bun.CryptoHasher("sha256");return O.update(`${T}${Date.now()}`),O.digest("hex")},extendSession:()=>({}),onUserCreated:async()=>{},onSignUp:()=>{},onSignIn:()=>{},onSignOut:()=>{},onForgotPassword:()=>{},onResetPassword:()=>{},onMagicLinkCreated:()=>{}}}function ZF($){if($&&typeof $==="object")delete $.password;return $}function n5(){return new Proxy({},{get:($,T)=>_6(T)})}var fF={select:{id:!0,publicId:!0,email:!0,name:!0,locale:!0,globalRole:!0,accounts:{select:{id:!0,publicId:!0,organizationRole:!0,organization:!0}}}};class FF{models;constructor($=n5()){this.models=$}run($){return this.models.User.asSystem($)}transaction($){return this.models.User.transaction($)}async createUser($){let T=await this.run(()=>this.models.User.create({data:$}));return ZF(T)}async updateUserPassword($){let T=await this.run(()=>this.models.User.update({where:{id:$.id},data:{password:$.password}}));return ZF(T)}async findUserByEmailAddress($,T){return await this.run(()=>this.models.User.findUnique({where:T?{email:$,emailVerifiedAt:{not:null}}:{email:$}}))}async findUserByVerificationToken($){return await this.run(()=>this.models.User.findFirst({where:{verificationToken:$}}))}async verifyUser($){return await this.run(()=>this.models.User.update({where:{email:$},data:{emailVerifiedAt:new Date}}))}async createSession($){return await this.run(()=>this.models.Session.create({data:$,include:{user:!0}}))}async createSessionV2($){return await this.run(()=>this.models.Session.create({data:$,select:{token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:fF}}))}async findSession($){if(!$.token)return null;try{return await this.run(()=>this.models.Session.findUnique({where:{token:$.token},select:{token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:fF}}))}catch(T){return console.error("findSession failed:",T),null}}async updateSession($){return await this.run(()=>this.models.Session.update({where:{token:$.token},data:{expiresAt:$.expiresAt},select:{token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:fF}}))}async deleteSession($){await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}))}async deleteAllUserSessions($){await this.run(()=>this.models.Session.deleteMany({where:{userId:$}}))}async createPasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.create({data:{token:$.token,user:{connect:{id:$.user.id}}}}))}async findPasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.findUnique({where:{token:$.token},include:{user:!0}}))}async deletePasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.delete({where:{token:$.token}}))}async findInvitation($,T){return await this.run(()=>this.models.OrganizationInvitation.findFirst({where:{publicId:$,email:T}}))}async deleteInvitationById($){await this.run(()=>this.models.OrganizationInvitation.delete({where:{publicId:$}}))}async createAccount($){return await this.run(()=>this.models.Account.create({data:{userId:$.userId,organizationId:$.organizationId,organizationRole:$.organizationRole}}))}async createMagicLinkToken($){return await this.run(()=>this.models.MagicLinkToken.create({data:{email:$.email,token:$.token,pin:$.pin}}))}async findUserMagicLinkToken($){return await this.run(()=>$.token?this.models.MagicLinkToken.findUnique({where:{token_email:{token:$.token,email:$.email}}}):this.models.MagicLinkToken.findUnique({where:{pin_email:{pin:$.pin,email:$.email}}}))}async deleteMagicLinkToken($){await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{email:$}}))}async createSocialAccount($){return await this.run(()=>this.models.SocialAccount.create({data:$}))}async findUserBySocialAccount($,T){if(!T)return null;let O=await this.run(()=>this.models.SocialAccount.findFirst({where:{provider:$,providerId:T},include:{user:!0}}));return O?ZF(O.user):null}async findSocialAccounts($,T){return await this.run(()=>this.models.SocialAccount.findMany({where:{userId:$,provider:T},orderBy:{id:"asc"}}))}async claimSocialAccount($,T){let{count:O}=await this.run(()=>this.models.SocialAccount.updateMany({where:{id:$.id,providerId:$.providerId},data:{providerId:T}}));return O===1}}import{timingSafeEqual as i7}from"crypto";var jF="intended_url";class CF extends A{schema={email:{required:"Email is required",string:"Invalid email",email:"Invalid email"},password:{required:"Password is required"}}}class P6 extends A{schema={email:{required:"Email is required",email:"Invalid email"}}}class H6 extends A{schema={password:{required:"Password is required",password:"Invalid password"}}}class $0 extends e3{async me(){let $=await v1.user();if(!$)throw new $F;return $}async verifyEmail($=new A){let T=await $.input(),{userProvider:O}=S(w),Z=await O.findUserByVerificationToken(T.get("token"));if(!Z)return{email:null};return await O.verifyUser(Z.email),{email:Z.email}}async signInWithMagicLink($=new A){let T=S(w),{userProvider:O}=T,Z=$.search.get("token"),f=decodeURIComponent($.search.get("email")).toLowerCase().trim(),F=null;try{F=await O.findUserMagicLinkToken({email:f,token:Z})}catch(C){return console.log(C),{error:JSON.stringify(C)}}if(!F)return{error:"Invalid token"};await O.verifyUser(f),await O.deleteMagicLinkToken(f);let j=await T.createOrUpdateSession({email:f});return $.ctx().setCookie("access_token",j.token,S(w).accessTokenCookieOptions($,j.expiresAt)),await T.config.onSignIn(j,$.search.toJSON()),{session:j}}async signInWithPinV2($=new A){let T=S(w),{userProvider:O}=T,Z=await $.input(),{email:f,pin:F}=Z.toJSON(),j=f.toLowerCase().trim();if(!await O.findUserMagicLinkToken({email:j,pin:F}))throw new H0({pin:["Invalid pin"]});await O.deleteMagicLinkToken(j),await O.verifyUser(j);let z=await T.createOrUpdateSessionV2({email:j});return $.ctx().setCookie("access_token",z.token,S(w).accessTokenCookieOptions($,z.expiresAt)),await T.config.onSignIn(z,$.search.toJSON()),z}async signInWithPin($=new A){let T=S(w),{userProvider:O}=T,Z=await $.input(),{email:f,pin:F}=Z.toJSON(),j=f.toLowerCase().trim();if(!await O.findUserMagicLinkToken({email:j,pin:F}))throw new H0({pin:["Invalid pin"]});await O.deleteMagicLinkToken(j),await O.verifyUser(j);let z=await T.createOrUpdateSession({email:j});return $.ctx().setCookie("access_token",z.token,S(w).accessTokenCookieOptions($,z.expiresAt)),await T.config.onSignIn(z,$.search.toJSON()),{session:z}}async signInV2($=new CF){let T=await $.input(),{email:O,password:Z}=T.toJSON(),f=O.toLowerCase().trim(),F=S(w),j=await F.userProvider.findUserByEmailAddress(f,F.config.verifyEmail);if(!j)throw new H0({invalid_credentials:["Invalid credentials"]});if(!await F.config.verifyPassword(Z,j.password))throw new H0({invalid_credentials:["Invalid credentials"]});let z=await F.createOrUpdateSessionV2({email:j.email,id:j.id});$.ctx().setCookie("access_token",z.token,S(w).accessTokenCookieOptions($,z.expiresAt)),await F.config.onSignIn(j,$.search.toJSON());let{password:W,...J}=j;return J}async signIn($=new CF){let T=await $.input(),{email:O,password:Z}=T.toJSON(),f=O.toLowerCase().trim(),F=S(w),j=await F.userProvider.findUserByEmailAddress(f,F.config.verifyEmail);if(!j)throw new H0({invalid_credentials:["Invalid credentials"]});if(!await F.config.verifyPassword(Z,j.password))throw new H0({invalid_credentials:["Invalid credentials"]});let z=await F.createOrUpdateSession({email:j.email,id:j.id});$.ctx().setCookie("access_token",z.token,S(w).accessTokenCookieOptions($,z.expiresAt)),await F.config.onSignIn(j,$.search.toJSON());let{password:W,...J}=j;return J}async signUp(){let $=S(w),{userProvider:T,config:O}=$,Z=new O.signUpRequest,f=await Z.input(),{email:F,password:j,name:C,invitationId:z}=f.toJSON(),W=F.toLowerCase().trim();if(await T.findUserByEmailAddress(W,!1))throw new H0({email:["Email address already exists"]});let Y=await O.hashPassword(j),D=S(e).detectLocale(Z),U;if(z)U=await T.findInvitation(z,W);let X,G="";if(U)X=await T.transaction(async()=>{await T.deleteInvitationById(z);let B=await T.createUser({email:W,name:C,password:Y,emailVerifiedAt:new Date,locale:D});return await T.createAccount({organizationId:U.organizationId,userId:B.id,organizationRole:U.role}),await O.onUserCreated(B),B});else G=await O.generateEmailVerificationToken(W),X=await T.transaction(async()=>{let B=await T.createUser({email:W,name:C,password:Y,verificationToken:G,locale:D});return await O.onUserCreated(B),B});return await O.onSignUp(X,G,Z.search.toJSON()),X}async signOut($=new A){let T=$.cookies.get("access_token"),O=await v1.user(),{userProvider:Z,config:f}=S(w);if(await Z.deleteSession({token:T}),$.ctx().setCookie("access_token","",S(w).accessTokenCookieOptions($,new Date(0))),S(w).cookieDomain($))$.ctx().setCookie("access_token","",{...S(w).accessTokenCookieOptions($,new Date(0)),domain:void 0});return await f.onSignOut(O),{}}async forgotPassword($=new P6){let O=(await $.input()).get("email").toLowerCase().trim(),{userProvider:Z,config:f}=S(w),F=await Z.findUserByEmailAddress(O,f.verifyEmail);if(!F)return{};let j=await f.generateForgotPasswordToken(F);return await Z.createPasswordResetToken({user:F,token:j}),await f.onForgotPassword(F,j),{}}async resetPassword($=new H6){let{userProvider:T,config:O}=S(w),Z=await $.input(),{password:f,token:F}=Z.toJSON(),j=await T.findPasswordResetToken({token:F});if(!j)throw new H0({token:["Invalid token"]});if(T1.Instant.from(j.createdAt.toISOString()).add({hours:24}).until(T1.Now.instant()).sign>=0)throw new H0({token:["Token expired"]});await T.deletePasswordResetToken({token:F});let z=await T.findUserByEmailAddress(j.user.email,O.verifyEmail);if(!z)throw new H0({email:["User not found"]});let W=await O.hashPassword(f);return await T.updateUserPassword({id:z.id,password:W}),await T.deleteAllUserSessions(z.id),await O.onResetPassword(z),{}}async changePassword($=new A){let{userProvider:T,config:O}=S(w),Z=await v1.user(),f=await $.input(),{oldPassword:F,newPassword:j}=f.toJSON(),{password:C}=await T.findUserByEmailAddress(Z.email,O.verifyEmail);if(!await O.verifyPassword(F,C))throw new H0({oldPassword:["Incorrect password"]});let W=await O.hashPassword(j);return await T.updateUserPassword({id:Z.id,password:W}),await T.deleteAllUserSessions(Z.id),{}}async oauthRedirect($=new A){let{provider:T}=$.params,O=S(w).config.oauthProviders[T];if(!O)throw Error(`Invalid provider: ${T}`);let Z=xT($.search.get(k$),"");if(Z)$.ctx().setCookie(jF,encodeURIComponent(Z),{httpOnly:!0,sameSite:"Lax",secure:G6($.rawRequest),maxAge:600});return{destination:await O.getRedirectUrl($)}}async oauthCallback($=new A){let{provider:T}=$.params,O=S(w),{userProvider:Z,config:f}=O,F=f.oauthProviders[T],{email:j,name:C,username:z,providerId:W}=await F.onCallback($),J=W?await Z.findUserBySocialAccount(T,W):null,Y="signin";if(!J){if(!j)return console.error("Authentication error: No email returned from OAuth provider callback"),{session:null};let G=S(e).detectLocale($);try{let B=await this.linkOAuthAccount({provider:T,providerId:W,email:j,name:C,username:z,locale:G});if(B)J=B.user,Y=B.action}catch(B){let K=W?await Z.findUserBySocialAccount(T,W):null;if(!K)throw B;J=K}if(!J)return{session:null}}let D=await O.createOrUpdateSessionV2({email:J.email,id:J.id});if($.ctx().setCookie("access_token",D.token,S(w).accessTokenCookieOptions($,D.expiresAt)),Y==="signup")await f.onSignUp(J,"",$.search.toJSON());else await f.onSignIn(J,$.search.toJSON());let U=$.cookies.get(jF),X=f.redirectPath;if(U){try{X=xT(decodeURIComponent(U),X)}catch{}$.ctx().setCookie(jF,"",{maxAge:-1})}return{session:D,redirectTo:X}}async linkOAuthAccount($){let{provider:T,providerId:O,email:Z,name:f,username:F,locale:j}=$,{userProvider:C,config:z}=S(w),W=(D)=>({provider:T,userId:D,email:Z,username:F,providerId:O,expiresAt:new Date,accessToken:"",refreshToken:""}),J=await C.findUserByEmailAddress(Z,!1);if(J){if(!O)return{user:J,action:"signin"};let D=await C.findSocialAccounts(J.id,T);if(D.some((X)=>X.providerId===O))return{user:J,action:"signin"};if(D.some((X)=>X.providerId))return console.error(`Authentication error: user ${J.id} is already linked to a different ${T} account`),null;let U=D[0];if(U){if(!await C.claimSocialAccount(U,O))throw Error(`${T} account link changed concurrently`)}else await C.createSocialAccount(W(J.id));return{user:J,action:"signin"}}return{user:await C.transaction(async()=>{let D=await C.createUser({email:Z,name:f,locale:j,emailVerifiedAt:new Date});if(O)await C.createSocialAccount(W(D.id));return await z.onUserCreated(D),D}),action:"signup"}}async createMagicLinkToken($=new A){let O=(await $.input()).get("email").toLowerCase().trim(),Z=S(w),{user:f,pin:F,token:j}=await Z.createMagicLinkToken(O);if(f)return await Z.config.onMagicLinkCreated(f,{email:O,pin:F,token:j}),{email:O};return{email:null}}}class w6 extends b1{middlewares=["cache:private"];routes={"/:provider":this.view("_Redirect",[$0,"oauthRedirect"]),"/:provider/callback":this.view("auth/OauthCallback",[$0,"oauthCallback"])}}class zF extends b1{middlewares=["cache:private"];routes={"/sign-in/magic-link":this.view("auth/MagicLinkSignIn",[$0,"signInWithMagicLink"]),"/oauth":w6}}class WF extends P0{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 JF extends P0{middlewares=["cache:private,0,no-store"];routes={"/set-locale/:locale":this.get(async()=>{let T=new A().params.locale;return await S(e).onLocaleChange(T),{locale:T}}),"/translations/:locale/:scope*":this.get(async()=>{let $=new A,T=`/${$.params.scope??""}`,O=$.params.locale,Z=S(e),f=O??Z.detectLocale($),F=Z.getPageTranslations(f,T);return $.ctx().setCookie("i18n-locale",f,{expires:new Date(Date.now()+31536000000)}),{[f]:F}})}}class DF{}class YF extends DF{async resize($,T){let{height:O,width:Z,quality:f,fit:F}=T;return await(await ZZ("The Sharp image optimization driver"))($).resize(Z>0?Z:void 0,O>0?O:void 0,{fit:F}).webp({quality:f>0?f:80,force:!0}).toBuffer()}}function JY($){return $}function b6(){return{driver:new YF}}class XF extends P0{routes={"/resize":this.file(async()=>{let $=new A,T=new URL($.rawRequest.url),O=T.searchParams.get("url"),Z=Number(T.searchParams.get("w")),f=Number(T.searchParams.get("h")),F=T.searchParams.get("fit")??"cover",j=Number(T.searchParams.get("q"));if(!O)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});let z=`${O.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${O}`,W=await fetch(z);if(!W.ok)return new Response(JSON.stringify({error:"Image not found",info:z}),{headers:{"Content-Type":"application/json"},status:404});let J=Buffer.from(await W.arrayBuffer()),Y=await S(v6).resize(J,{height:f,width:Z,fit:F,quality:j});W.headers.delete("Content-Type"),W.headers.delete("Content-Length");let D=new Headers(W.headers);return D.set("Content-Type","image/webp"),D.set("Content-Length",`${Y.byteLength}`),new Response(new Uint8Array(Y),{headers:D})})}}class v6{static token="image";driver;constructor($={}){this.driver=$.driver??b6().driver}resize($,T){return this.driver.resize($,T)}}import{mkdir as UF,readdir as a5,access as o5}from"fs/promises";async function GF($){try{return await o5($),!0}catch{return!1}}class PT{config;static token="log";writer;isReady=!1;flushTimeout;fileSize=0;writerSize=0;isCreatingFile=!1;bootPromise=null;currentLogFilePath;get logsDirPath(){return`${BF()}/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 $=`${BF()}/storage`;if(!await GF($))await UF($);if(!await GF(this.logsDirPath))await UF(this.logsDirPath);await this.newLogFile()}async newLogFile(){if(!await GF(this.logsDirPath))await UF(this.logsDirPath);if(this.isCreatingFile=!0,this.currentLogFilePath){this.writer.flush(),this.writer.end(),this.writer=null;let O=new File([await Bun.file(this.currentLogFilePath).arrayBuffer()],this.currentLogFilePath.split("/").pop(),{type:"text/plain"});this.config.onLogFileClosed(O),this.fileSize=0,this.writerSize=0}let T=(await a5(this.logsDirPath)).sort().reverse()[0];if(T){let O=Bun.file(`${this.logsDirPath}/${T}`);if(O.size<this.config.maxFileSize)this.currentLogFilePath=`${this.logsDirPath}/${T}`,this.writer=O.writer(),this.writer.write(await O.text()),this.writer.write(`
|
|
3
|
-
`),this.writer.flush(),this.fileSize=O.size}if(!this.writer){let O=`${new Date(Date.now()).toISOString()}.log`.replaceAll(":","-");this.currentLogFilePath=`${this.logsDirPath}/${O}`;let Z=Bun.file(`${this.logsDirPath}/${O}`);this.writer=Z.writer(),this.fileSize=0,this.writerSize=0}this.isCreatingFile=!1}async log($,T,O={}){if(!this.isReady)await this.boot();let Z=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 F={timestamp:new Date(Date.now()).toISOString(),env:Bun.env.NODE_ENV,level:$,message:T,metadata:{...f,...O}},j="";try{j=JSON.stringify(F)}catch(C){console.log("Error parsing log object",C)}try{let C=this.config.onLogCreated(F);if(C instanceof Promise)C.catch((z)=>console.error("Error in onLogCreated",z))}catch(C){console.error("Error in onLogCreated",C)}if(!this.writer)return;this.writerSize+=j.length,this.fileSize+=j.length;try{this.writer.write(j),this.writer.write(`
|
|
4
|
-
`),this.tryFlush()}catch(C){console.error("Error writing log",C)}}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 SF extends P0{middlewares=["cache:private,0"];routes={"/live":this.get(async()=>{let $=Bun.file(S(PT).currentLogFilePath);return new Response(await $.text(),{headers:{"Content-Type":"text/plain"}})})}}function t5($){let T=new Map;for(let O of $)if(typeof O==="string"){let[Z,f=""]=O.split(":");if(Z.startsWith("-")){if(T.has(Z.replace("-","")))T.delete(Z.replace("-",""))}else T.set(Z,f.split(",").filter(Boolean))}else T.set(O,[]);return T}class HT{config;static token="middleware";constructor($){this.config=$}get aliases(){return this.config.aliases}assertGlobalMiddleware(){for(let $ of this.config.global){if(typeof $!=="string")continue;let[T]=$.split(":");if(T.startsWith("-"))throw Error(`Global middleware "${$}" cancels an alias, but nothing is inherited into the global list. Remove it.`);if(!this.aliases[T])throw Error(`Global middleware "${T}" is not a registered alias. Add it to \`aliases\` in the middleware config, or list the class itself.`)}}runGlobalMiddleware(){return this.runMiddleware(this.config.global)}runMiddleware($){let T=new A;return Array.from(t5($).entries()).map(([O,Z])=>{if(typeof O==="string"){let f=this.aliases[O];if(f){let F=new f(T);return()=>F.run.call(F,...Z)}}else{if(rO(O)){let f=new O(T);return f.run.bind(f)}return O}}).filter(Boolean).reduce((O,Z)=>{return async()=>{return{...await O(),...await Z()}}},()=>Promise.resolve({}))()}}function _Y($){return $}function g6(){return{onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{}}}function k6(){return{partialRendering:!0,onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{},onStreamComplete:()=>{}}}function r5($){return"run"in $}function e5($){return Object.hasOwn($,"get")||Object.hasOwn($,"post")||Object.hasOwn($,"put")||Object.hasOwn($,"delete")}function $7($){return Object.hasOwn($,"first")&&Object.hasOwn($,"second")}function T7($){if("__brand"in $)return $.__brand==="ApiRouter";return!1}function O7($){if("__internal_brand"in $)return $.__internal_brand==="ProxyHandler";return!1}function Z7($){if("__internal_brand"in $)return $.__internal_brand==="StreamHandler";return!1}function KF($,T="",O=[]){let Z={};function f(F,j,C,z,W){let J=F==="/"?"":F,Y=T==="/"?"":T,D=(`${Y}${J}`===""?"/":`${Y}${J}`).replaceAll("//","/");if(!Z[D])Z[D]={};Z[D][j.toUpperCase()]={exec:C,middleware:[...O,...z],...W?{source:W}:{}},Z[D].OPTIONS={exec:()=>{let X=new A().ctx().headers;return new Response(null,{headers:X,status:204})},middleware:[]}}for(let[F,j]of Object.entries($)){if(O7(j)){let C=j;for(let z of["GET","POST","PUT","DELETE"])f(F,z,C.run.bind(C),[]);continue}if(r5(j)){let C=j,z=C.method,W=C.middlewares,J=C.run.bind(C);if(f(F,z,J,W,C.source),Z7(j))f(F,"HEAD",J,W,C.source)}if(e5(j))for(let[C,z]of Object.entries(j)){let W=z.middlewares,J=z.run.bind(z);f(F,C,J,W,z.source)}if(T7(j)){let C=new j,z=KF(C.routes,`${T}${F}`,C.middlewares);for(let[W,J]of Object.entries(z))Z[W.replaceAll("//","/")]=J}if($7(j)){let{first:C,second:z}=j;for(let[W,J]of Object.entries(C)){let Y=J.middlewares,D=J.run.bind(J),[U,...X]=F.split("/").reverse();if(!U.startsWith(":"))throw Error("Resource route must end with a dynamic segment");f(X.reverse().join("/"),W,D,Y,J.source)}for(let[W,J]of Object.entries(z)){let Y=J.middlewares,D=J.run.bind(J);f(F,W,D,Y,J.source)}}}return Object.fromEntries(Object.entries(Z).sort(([F],[j])=>{let C=F.split("/").length+F.split(":").length,z=j.split("/").length+j.split(":").length;return C-z}))}function fZ($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function LF($,T){if($==="/")return T;if(T==="/")return $;return`${$}${T}`}function IF($){let T=fZ($);return T.length>1?T.replace(/\/$/,""):T}function R6($,T){return T.map((O)=>({...O,path:IF(LF($,O.path))}))}function FZ($){let T={};for(let[O,Z]of Object.entries($))if("run"in Z){let f=Z;if("children"in f){let F=new f.children,j=FZ(F.routes);for(let[C,{exec:z,middleware:W,segments:J,features:Y}]of Object.entries(j)){let D=LF(O,C),U=(X)=>f.run.call(f,X,O);T[fZ(D)]={exec:[U,...z],middleware:[...f.middlewares,...W],features:[...f.featureGates,...Y],viewPath:f.viewPath,segments:[{path:IF(O),viewPath:f.viewPath,...f.alwaysRuns?{alwaysRun:!0}:{}},...R6(O,J)]}}}else{let F=(j)=>f.run.call(f,j,O);T[fZ(O)]={exec:[F],middleware:f.middlewares,features:f.featureGates,viewPath:f.viewPath,segments:[{path:IF(O),viewPath:f.viewPath}]}}}else{let f=new Z,F=FZ(f.routes);for(let[j,{exec:C,middleware:z,viewPath:W,segments:J,features:Y}]of Object.entries(F)){let D=LF(O,j);T[fZ(D)]={exec:C,middleware:[...f.middlewares,...z],features:[...f.featureGates,...Y],viewPath:W,segments:R6(O,J)}}}return Object.fromEntries(Object.entries(T).sort(([O],[Z])=>{let f=O.split("/").length+O.split(":").length,F=Z.split("/").length+Z.split(":").length;return f-F}))}var f7=Object.defineProperty,V=($,T)=>f7($,"name",{value:T,configurable:!0}),q$=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor($,T,O,Z,f,F){this.type=$,this.name=T,this.prefix=O,this.value=Z,this.suffix=f,this.modifier=F}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};V(q$,"Part");var F7=/[$_\p{ID_Start}]/u,j7=/[$_\u200C\u200D\p{ID_Continue}]/u,QF=".*";function y6($,T){return(T?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test($)}V(y6,"isASCII");function EF($,T=!1){let O=[],Z=0;for(;Z<$.length;){let f=$[Z],F=V(function(j){if(!T)throw TypeError(j);O.push({type:"INVALID_CHAR",index:Z,value:$[Z++]})},"ErrorOrInvalid");if(f==="*"){O.push({type:"ASTERISK",index:Z,value:$[Z++]});continue}if(f==="+"||f==="?"){O.push({type:"OTHER_MODIFIER",index:Z,value:$[Z++]});continue}if(f==="\\"){O.push({type:"ESCAPED_CHAR",index:Z++,value:$[Z++]});continue}if(f==="{"){O.push({type:"OPEN",index:Z,value:$[Z++]});continue}if(f==="}"){O.push({type:"CLOSE",index:Z,value:$[Z++]});continue}if(f===":"){let j="",C=Z+1;for(;C<$.length;){let z=$.substr(C,1);if(C===Z+1&&F7.test(z)||C!==Z+1&&j7.test(z)){j+=$[C++];continue}break}if(!j){F(`Missing parameter name at ${Z}`);continue}O.push({type:"NAME",index:Z,value:j}),Z=C;continue}if(f==="("){let j=1,C="",z=Z+1,W=!1;if($[z]==="?"){F(`Pattern cannot start with "?" at ${z}`);continue}for(;z<$.length;){if(!y6($[z],!1)){F(`Invalid character '${$[z]}' at ${z}.`),W=!0;break}if($[z]==="\\"){C+=$[z++]+$[z++];continue}if($[z]===")"){if(j--,j===0){z++;break}}else if($[z]==="("&&(j++,$[z+1]!=="?")){F(`Capturing groups are not allowed at ${z}`),W=!0;break}C+=$[z++]}if(W)continue;if(j){F(`Unbalanced pattern at ${Z}`);continue}if(!C){F(`Missing pattern at ${Z}`);continue}O.push({type:"REGEX",index:Z,value:C}),Z=z;continue}O.push({type:"CHAR",index:Z,value:$[Z++]})}return O.push({type:"END",index:Z,value:""}),O}V(EF,"lexer");function AF($,T={}){let O=EF($);T.delimiter??="/#?",T.prefixes??="./";let Z=`[^${w0(T.delimiter)}]+?`,f=[],F=0,j=0,C="",z=new Set,W=V((L)=>{if(j<O.length&&O[j].type===L)return O[j++].value},"tryConsume"),J=V(()=>W("OTHER_MODIFIER")??W("ASTERISK"),"tryConsumeModifier"),Y=V((L)=>{let E=W(L);if(E!==void 0)return E;let{type:x,index:I}=O[j];throw TypeError(`Unexpected ${x} at ${I}, expected ${L}`)},"mustConsume"),D=V(()=>{let L="",E;for(;E=W("CHAR")??W("ESCAPED_CHAR");)L+=E;return L},"consumeText"),U=V((L)=>L,"DefaultEncodePart"),X=T.encodePart||U,G="",B=V((L)=>{G+=L},"appendToPendingFixedValue"),K=V(()=>{G.length&&(f.push(new q$(3,"","",X(G),"",3)),G="")},"maybeAddPartFromPendingFixedValue"),M=V((L,E,x,I,Q)=>{let _=3;switch(Q){case"?":_=1;break;case"*":_=0;break;case"+":_=2;break}if(!E&&!x&&_===3){B(L);return}if(K(),!E&&!x){if(!L)return;f.push(new q$(3,"","",X(L),"",_));return}let P;x?x==="*"?P=QF:P=x:P=Z;let O0=2;P===Z?(O0=1,P=""):P===QF&&(O0=0,P="");let v;if(E?v=E:x&&(v=F++),z.has(v))throw TypeError(`Duplicate name '${v}'.`);z.add(v),f.push(new q$(O0,v,X(L),P,X(I),_))},"addPart");for(;j<O.length;){let L=W("CHAR"),E=W("NAME"),x=W("REGEX");if(!E&&!x&&(x=W("ASTERISK")),E||x){let Q=L??"";T.prefixes.indexOf(Q)===-1&&(B(Q),Q=""),K();let _=J();M(Q,E,x,"",_);continue}let I=L??W("ESCAPED_CHAR");if(I){B(I);continue}if(W("OPEN")){let Q=D(),_=W("NAME"),P=W("REGEX");!_&&!P&&(P=W("ASTERISK"));let O0=D();Y("CLOSE");let v=J();M(Q,_,P,O0,v);continue}K(),Y("END")}return f}V(AF,"parse");function w0($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}V(w0,"escapeString");function VF($){return $&&$.ignoreCase?"ui":"u"}V(VF,"flags");function m6($,T,O){return xF(AF($,O),T,O)}V(m6,"stringToRegexp");function F$($){switch($){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}V(F$,"modifierToString");function xF($,T,O={}){O.delimiter??="/#?",O.prefixes??="./",O.sensitive??=!1,O.strict??=!1,O.end??=!0,O.start??=!0,O.endsWith="";let Z=O.start?"^":"";for(let C of $){if(C.type===3){C.modifier===3?Z+=w0(C.value):Z+=`(?:${w0(C.value)})${F$(C.modifier)}`;continue}T&&T.push(C.name);let z=`[^${w0(O.delimiter)}]+?`,W=C.value;if(C.type===1?W=z:C.type===0&&(W=QF),!C.prefix.length&&!C.suffix.length){C.modifier===3||C.modifier===1?Z+=`(${W})${F$(C.modifier)}`:Z+=`((?:${W})${F$(C.modifier)})`;continue}if(C.modifier===3||C.modifier===1){Z+=`(?:${w0(C.prefix)}(${W})${w0(C.suffix)})`,Z+=F$(C.modifier);continue}Z+=`(?:${w0(C.prefix)}`,Z+=`((?:${W})(?:`,Z+=w0(C.suffix),Z+=w0(C.prefix),Z+=`(?:${W}))*)${w0(C.suffix)})`,C.modifier===0&&(Z+="?")}let f=`[${w0(O.endsWith)}]|$`,F=`[${w0(O.delimiter)}]`;if(O.end)return O.strict||(Z+=`${F}?`),O.endsWith.length?Z+=`(?=${f})`:Z+="$",new RegExp(Z,VF(O));O.strict||(Z+=`(?:${F}(?=${f}))?`);let j=!1;if($.length){let C=$[$.length-1];C.type===3&&C.modifier===3&&(j=O.delimiter.indexOf(C)>-1)}return j||(Z+=`(?=${F}|${f})`),new RegExp(Z,VF(O))}V(xF,"partsToRegexp");var k1={delimiter:"",prefixes:"",sensitive:!0,strict:!0},C7={delimiter:".",prefixes:"",sensitive:!0,strict:!0},z7={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function q6($,T){return $.length?$[0]==="/"?!0:!T||$.length<2?!1:($[0]=="\\"||$[0]=="{")&&$[1]=="/":!1}V(q6,"isAbsolutePathname");function _F($,T){return $.startsWith(T)?$.substring(T.length,$.length):$}V(_F,"maybeStripPrefix");function c6($,T){return $.endsWith(T)?$.substr(0,$.length-T.length):$}V(c6,"maybeStripSuffix");function PF($){return!$||$.length<2?!1:$[0]==="["||($[0]==="\\"||$[0]==="{")&&$[1]==="["}V(PF,"treatAsIPv6Hostname");var i6=["ftp","file","http","https","ws","wss"];function HF($){if(!$)return!0;for(let T of i6)if($.test(T))return!0;return!1}V(HF,"isSpecialScheme");function p6($,T){if($=_F($,"#"),T||$==="")return $;let O=new URL("https://example.com");return O.hash=$,O.hash?O.hash.substring(1,O.hash.length):""}V(p6,"canonicalizeHash");function h6($,T){if($=_F($,"?"),T||$==="")return $;let O=new URL("https://example.com");return O.search=$,O.search?O.search.substring(1,O.search.length):""}V(h6,"canonicalizeSearch");function l6($,T){return T||$===""?$:PF($)?vF($):bF($)}V(l6,"canonicalizeHostname");function d6($,T){if(T||$==="")return $;let O=new URL("https://example.com");return O.password=$,O.password}V(d6,"canonicalizePassword");function s6($,T){if(T||$==="")return $;let O=new URL("https://example.com");return O.username=$,O.username}V(s6,"canonicalizeUsername");function u6($,T,O){if(O||$==="")return $;if(T&&!i6.includes(T))return new URL(`${T}:${$}`).pathname;let Z=$[0]=="/";return $=new URL(Z?$:"/-"+$,"https://example.com").pathname,Z||($=$.substring(2,$.length)),$}V(u6,"canonicalizePathname");function n6($,T,O){return wF(T)===$&&($=""),O||$===""?$:gF($)}V(n6,"canonicalizePort");function a6($,T){return $=c6($,":"),T||$===""?$:jZ($)}V(a6,"canonicalizeProtocol");function wF($){switch($){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}V(wF,"defaultPortForProtocol");function jZ($){if($==="")return $;if(/^[-+.A-Za-z0-9]*$/.test($))return $.toLowerCase();throw TypeError(`Invalid protocol '${$}'.`)}V(jZ,"protocolEncodeCallback");function o6($){if($==="")return $;let T=new URL("https://example.com");return T.username=$,T.username}V(o6,"usernameEncodeCallback");function t6($){if($==="")return $;let T=new URL("https://example.com");return T.password=$,T.password}V(t6,"passwordEncodeCallback");function bF($){if($==="")return $;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test($))throw TypeError(`Invalid hostname '${$}'`);let T=new URL("https://example.com");return T.hostname=$,T.hostname}V(bF,"hostnameEncodeCallback");function vF($){if($==="")return $;if(/[^0-9a-fA-F[\]:]/g.test($))throw TypeError(`Invalid IPv6 hostname '${$}'`);return $.toLowerCase()}V(vF,"ipv6HostnameEncodeCallback");function gF($){if($===""||/^[0-9]*$/.test($)&&parseInt($)<=65535)return $;throw TypeError(`Invalid port '${$}'.`)}V(gF,"portEncodeCallback");function r6($){if($==="")return $;let T=new URL("https://example.com");return T.pathname=$[0]!=="/"?"/-"+$:$,$[0]!=="/"?T.pathname.substring(2,T.pathname.length):T.pathname}V(r6,"standardURLPathnameEncodeCallback");function e6($){return $===""?$:new URL(`data:${$}`).pathname}V(e6,"pathURLPathnameEncodeCallback");function $8($){if($==="")return $;let T=new URL("https://example.com");return T.search=$,T.search.substring(1,T.search.length)}V($8,"searchEncodeCallback");function T8($){if($==="")return $;let T=new URL("https://example.com");return T.hash=$,T.hash.substring(1,T.hash.length)}V(T8,"hashEncodeCallback");var O8=class{#F;#Z=[];#T={};#$=0;#f=1;#W=0;#C=0;#X=0;#U=0;#G=!1;constructor($){this.#F=$}get result(){return this.#T}parse(){for(this.#Z=EF(this.#F,!0);this.#$<this.#Z.length;this.#$+=this.#f){if(this.#f=1,this.#Z[this.#$].type==="END"){if(this.#C===0){this.#L(),this.#J()?this.#O(9,1):this.#D()?this.#O(8,1):this.#O(7,0);continue}else if(this.#C===2){this.#Y(5);continue}this.#O(10,0);break}if(this.#X>0)if(this.#A())this.#X-=1;else continue;if(this.#E()){this.#X+=1;continue}switch(this.#C){case 0:this.#I()&&this.#Y(1);break;case 1:if(this.#I()){this.#P();let $=7,T=1;this.#Q()?($=2,T=3):this.#G&&($=2),this.#O($,T)}break;case 2:this.#S()?this.#Y(3):(this.#K()||this.#D()||this.#J())&&this.#Y(5);break;case 3:this.#V()?this.#O(4,1):this.#S()&&this.#O(5,1);break;case 4:this.#S()&&this.#O(5,1);break;case 5:this.#x()?this.#U+=1:this.#_()&&(this.#U-=1),this.#N()&&!this.#U?this.#O(6,1):this.#K()?this.#O(7,0):this.#D()?this.#O(8,1):this.#J()&&this.#O(9,1);break;case 6:this.#K()?this.#O(7,0):this.#D()?this.#O(8,1):this.#J()&&this.#O(9,1);break;case 7:this.#D()?this.#O(8,1):this.#J()&&this.#O(9,1);break;case 8:this.#J()&&this.#O(9,1);break;case 9:break;case 10:break}}this.#T.hostname!==void 0&&this.#T.port===void 0&&(this.#T.port="")}#O($,T){switch(this.#C){case 0:break;case 1:this.#T.protocol=this.#z();break;case 2:break;case 3:this.#T.username=this.#z();break;case 4:this.#T.password=this.#z();break;case 5:this.#T.hostname=this.#z();break;case 6:this.#T.port=this.#z();break;case 7:this.#T.pathname=this.#z();break;case 8:this.#T.search=this.#z();break;case 9:this.#T.hash=this.#z();break;case 10:break}this.#C!==0&&$!==10&&([1,2,3,4].includes(this.#C)&&[6,7,8,9].includes($)&&(this.#T.hostname??=""),[1,2,3,4,5,6].includes(this.#C)&&[8,9].includes($)&&(this.#T.pathname??=this.#G?"/":""),[1,2,3,4,5,6,7].includes(this.#C)&&$===9&&(this.#T.search??="")),this.#M($,T)}#M($,T){this.#C=$,this.#W=this.#$+T,this.#$+=T,this.#f=0}#L(){this.#$=this.#W,this.#f=0}#Y($){this.#L(),this.#C=$}#B($){return $<0&&($=this.#Z.length-$),$<this.#Z.length?this.#Z[$]:this.#Z[this.#Z.length-1]}#j($,T){let O=this.#B($);return O.value===T&&(O.type==="CHAR"||O.type==="ESCAPED_CHAR"||O.type==="INVALID_CHAR")}#I(){return this.#j(this.#$,":")}#Q(){return this.#j(this.#$+1,"/")&&this.#j(this.#$+2,"/")}#S(){return this.#j(this.#$,"@")}#V(){return this.#j(this.#$,":")}#N(){return this.#j(this.#$,":")}#K(){return this.#j(this.#$,"/")}#D(){if(this.#j(this.#$,"?"))return!0;if(this.#Z[this.#$].value!=="?")return!1;let $=this.#B(this.#$-1);return $.type!=="NAME"&&$.type!=="REGEX"&&$.type!=="CLOSE"&&$.type!=="ASTERISK"}#J(){return this.#j(this.#$,"#")}#E(){return this.#Z[this.#$].type=="OPEN"}#A(){return this.#Z[this.#$].type=="CLOSE"}#x(){return this.#j(this.#$,"[")}#_(){return this.#j(this.#$,"]")}#z(){let $=this.#Z[this.#$],T=this.#B(this.#W).index;return this.#F.substring(T,$.index)}#P(){let $={};Object.assign($,k1),$.encodePart=jZ;let T=m6(this.#z(),void 0,$);this.#G=HF(T)}};V(O8,"Parser");var MF=["protocol","username","password","hostname","port","pathname","search","hash"],g1="*";function NF($,T){if(typeof $!="string")throw TypeError("parameter 1 is not of type 'string'.");let O=new URL($,T);return{protocol:O.protocol.substring(0,O.protocol.length-1),username:O.username,password:O.password,hostname:O.hostname,port:O.port,pathname:O.pathname,search:O.search!==""?O.search.substring(1,O.search.length):void 0,hash:O.hash!==""?O.hash.substring(1,O.hash.length):void 0}}V(NF,"extractValues");function O1($,T){return T?m$($):$}V(O1,"processBaseURLString");function y$($,T,O){let Z;if(typeof T.baseURL=="string")try{Z=new URL(T.baseURL),T.protocol===void 0&&($.protocol=O1(Z.protocol.substring(0,Z.protocol.length-1),O)),!O&&T.protocol===void 0&&T.hostname===void 0&&T.port===void 0&&T.username===void 0&&($.username=O1(Z.username,O)),!O&&T.protocol===void 0&&T.hostname===void 0&&T.port===void 0&&T.username===void 0&&T.password===void 0&&($.password=O1(Z.password,O)),T.protocol===void 0&&T.hostname===void 0&&($.hostname=O1(Z.hostname,O)),T.protocol===void 0&&T.hostname===void 0&&T.port===void 0&&($.port=O1(Z.port,O)),T.protocol===void 0&&T.hostname===void 0&&T.port===void 0&&T.pathname===void 0&&($.pathname=O1(Z.pathname,O)),T.protocol===void 0&&T.hostname===void 0&&T.port===void 0&&T.pathname===void 0&&T.search===void 0&&($.search=O1(Z.search.substring(1,Z.search.length),O)),T.protocol===void 0&&T.hostname===void 0&&T.port===void 0&&T.pathname===void 0&&T.search===void 0&&T.hash===void 0&&($.hash=O1(Z.hash.substring(1,Z.hash.length),O))}catch{throw TypeError(`invalid baseURL '${T.baseURL}'.`)}if(typeof T.protocol=="string"&&($.protocol=a6(T.protocol,O)),typeof T.username=="string"&&($.username=s6(T.username,O)),typeof T.password=="string"&&($.password=d6(T.password,O)),typeof T.hostname=="string"&&($.hostname=l6(T.hostname,O)),typeof T.port=="string"&&($.port=n6(T.port,$.protocol,O)),typeof T.pathname=="string"){if($.pathname=T.pathname,Z&&!q6($.pathname,O)){let f=Z.pathname.lastIndexOf("/");f>=0&&($.pathname=O1(Z.pathname.substring(0,f+1),O)+$.pathname)}$.pathname=u6($.pathname,$.protocol,O)}return typeof T.search=="string"&&($.search=h6(T.search,O)),typeof T.hash=="string"&&($.hash=p6(T.hash,O)),$}V(y$,"applyInit");function m$($){return $.replace(/([+*?:{}()\\])/g,"\\$1")}V(m$,"escapePatternString");function Z8($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}V(Z8,"escapeRegexpString");function f8($,T){T.delimiter??="/#?",T.prefixes??="./",T.sensitive??=!1,T.strict??=!1,T.end??=!0,T.start??=!0,T.endsWith="";let O=".*",Z=`[^${Z8(T.delimiter)}]+?`,f=/[$_\u200C\u200D\p{ID_Continue}]/u,F="";for(let j=0;j<$.length;++j){let C=$[j];if(C.type===3){if(C.modifier===3){F+=m$(C.value);continue}F+=`{${m$(C.value)}}${F$(C.modifier)}`;continue}let z=C.hasCustomName(),W=!!C.suffix.length||!!C.prefix.length&&(C.prefix.length!==1||!T.prefixes.includes(C.prefix)),J=j>0?$[j-1]:null,Y=j<$.length-1?$[j+1]:null;if(!W&&z&&C.type===1&&C.modifier===3&&Y&&!Y.prefix.length&&!Y.suffix.length)if(Y.type===3){let D=Y.value.length>0?Y.value[0]:"";W=f.test(D)}else W=!Y.hasCustomName();if(!W&&!C.prefix.length&&J&&J.type===3){let D=J.value[J.value.length-1];W=T.prefixes.includes(D)}W&&(F+="{"),F+=m$(C.prefix),z&&(F+=`:${C.name}`),C.type===2?F+=`(${C.value})`:C.type===1?z||(F+=`(${Z})`):C.type===0&&(!z&&(!J||J.type===3||J.modifier!==3||W||C.prefix!=="")?F+="*":F+=`(${O})`),C.type===1&&z&&C.suffix.length&&f.test(C.suffix[0])&&(F+="\\"),F+=m$(C.suffix),W&&(F+="}"),C.modifier!==3&&(F+=F$(C.modifier))}return F}V(f8,"partsToPattern");var kF=class{#F;#Z={};#T={};#$={};#f={};#W=!1;constructor($={},T,O){try{let Z;if(typeof T=="string"?Z=T:O=T,typeof $=="string"){let C=new O8($);if(C.parse(),$=C.result,Z===void 0&&typeof $.protocol!="string")throw TypeError("A base URL must be provided for a relative constructor string.");$.baseURL=Z}else{if(!$||typeof $!="object")throw TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(Z)throw TypeError("parameter 1 is not of type 'string'.")}typeof O>"u"&&(O={ignoreCase:!1});let f={ignoreCase:O.ignoreCase===!0},F={pathname:g1,protocol:g1,username:g1,password:g1,hostname:g1,port:g1,search:g1,hash:g1};this.#F=y$(F,$,!0),wF(this.#F.protocol)===this.#F.port&&(this.#F.port="");let j;for(j of MF){if(!(j in this.#F))continue;let C={},z=this.#F[j];switch(this.#T[j]=[],j){case"protocol":Object.assign(C,k1),C.encodePart=jZ;break;case"username":Object.assign(C,k1),C.encodePart=o6;break;case"password":Object.assign(C,k1),C.encodePart=t6;break;case"hostname":Object.assign(C,C7),PF(z)?C.encodePart=vF:C.encodePart=bF;break;case"port":Object.assign(C,k1),C.encodePart=gF;break;case"pathname":HF(this.#Z.protocol)?(Object.assign(C,z7,f),C.encodePart=r6):(Object.assign(C,k1,f),C.encodePart=e6);break;case"search":Object.assign(C,k1,f),C.encodePart=$8;break;case"hash":Object.assign(C,k1,f),C.encodePart=T8;break}try{this.#f[j]=AF(z,C),this.#Z[j]=xF(this.#f[j],this.#T[j],C),this.#$[j]=f8(this.#f[j],C),this.#W=this.#W||this.#f[j].some((W)=>W.type===2)}catch{throw TypeError(`invalid ${j} pattern '${this.#F[j]}'.`)}}}catch(Z){throw TypeError(`Failed to construct 'URLPattern': ${Z.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test($={},T){let O={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&T)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return!1;try{typeof $=="object"?O=y$(O,$,!1):O=y$(O,NF($,T),!1)}catch{return!1}let Z;for(Z of MF)if(!this.#Z[Z].exec(O[Z]))return!1;return!0}exec($={},T){let O={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&T)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return;try{typeof $=="object"?O=y$(O,$,!1):O=y$(O,NF($,T),!1)}catch{return null}let Z={};T?Z.inputs=[$,T]:Z.inputs=[$];let f;for(f of MF){let F=this.#Z[f].exec(O[f]);if(!F)return null;let j={};for(let[C,z]of this.#T[f].entries())if(typeof z=="string"||typeof z=="number"){let W=F[C+1];j[z]=W}Z[f]={input:O[f]??"",groups:j}}return Z}static compareComponent($,T,O){let Z=V((C,z)=>{for(let W of["type","modifier","prefix","value","suffix"]){if(C[W]<z[W])return-1;if(C[W]===z[W])continue;return 1}return 0},"comparePart"),f=new q$(3,"","","","",3),F=new q$(0,"","","","",3),j=V((C,z)=>{let W=0;for(;W<Math.min(C.length,z.length);++W){let J=Z(C[W],z[W]);if(J)return J}return C.length===z.length?0:Z(C[W]??f,z[W]??f)},"comparePartList");return!T.#$[$]&&!O.#$[$]?0:T.#$[$]&&!O.#$[$]?j(T.#f[$],[F]):!T.#$[$]&&O.#$[$]?j([F],O.#f[$]):j(T.#f[$],O.#f[$])}get protocol(){return this.#$.protocol}get username(){return this.#$.username}get password(){return this.#$.password}get hostname(){return this.#$.hostname}get port(){return this.#$.port}get pathname(){return this.#$.pathname}get search(){return this.#$.search}get hash(){return this.#$.hash}get hasRegExpGroups(){return this.#W}};V(kF,"URLPattern");function wT($,T){for(let[O,Z]of Object.entries($)){let f=new kF({pathname:O});if(f.test({pathname:T}))return{routePath:O,params:f.exec({pathname:T})?.pathname.groups??{},route:Z}}return null}var j$={startIndex:0,carriedViews:[]};function F8($,T){let O=r($.path,T);return O.includes("*")?null:O}function W7($,T){if(!$)return j$;if($.search!==T.search)return j$;let O=Math.min($.segments.length,T.segments.length-1),Z=0;while(Z<O){let f=$.segments[Z],F=T.segments[Z];if(F.alwaysRun)break;if(f.viewPath!==F.viewPath)break;let j=F8(f,$.params),C=F8(F,T.params);if(j===null||C===null||j!==C)break;Z++}if(Z===0)return j$;return{startIndex:Z,carriedViews:T.segments.slice(0,Z).map(({viewPath:f})=>f)}}function J7($,T){let[,O,...Z]=$.split("/");if(!T.includes(O))return $;let f=`/${Z.join("/")}`;return f==="/"?"/":f.replace(/\/$/,"")}function j8($){let{flatViewRoutes:T,supportedLocales:O,from:Z,origin:f,to:F}=$;if(!Z)return j$;let j;try{j=new URL(Z,f)}catch{return j$}if(j.origin!==f)return j$;let C=wT(T,J7(j.pathname,O));if(!C)return j$;return W7({segments:C.route.segments,params:C.params,search:j.search},F)}var RF="x-gemi-from";import{createElement as s$,Fragment as P7}from"react";function D7($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function CZ($){let T={};for(let[O,Z]of Object.entries($))if("run"in Z){let f=Z.viewPath;if("children"in Z){T[O]=[f];let F=new Z.children,j=CZ(F.routes);for(let[C,z]of Object.entries(j)){let W=O==="/"?C:`${O}${C}`,J=C==="/"&&O!=="/"?O:W;T[J]=[f,...z]}if(T[O].length===1)delete T[O]}else T[O]=[f]}else{let f=new Z,F=CZ(f.routes);for(let[j,C]of Object.entries(F)){let z=O==="/"?j:`${O}${j}`,W=j==="/"&&O!=="/"?O:z;T[W]=C}}return Object.fromEntries(Object.entries(T).map(([O,Z])=>[D7(O),Z]))}function zZ($){let T=[];for(let[O,Z]of Object.entries($))if("run"in Z){let f=Z.viewPath;if(f==="__")continue;if(f==="REDIRECT")continue;if(f==="FILE")continue;if("children"in Z){let F=new Z.children,j=zZ(F.routes);T.push([f,j])}else T.push([f,[]])}else{let f=new Z,F=zZ(f.routes);T.push(...F)}return T}function yF($){let T=[];for(let[O,Z]of $)T.push(O,...yF(Z).flat());return Array.from(new Set(T))}class R1 extends T0{static getFacadeAccessor(){return PT}static debug($,T){this.getFacadeRoot().log("debug",$,T)}static info($,T){this.getFacadeRoot().log("info",$,T)}static notice($,T){this.getFacadeRoot().log("notice",$,T)}static warning($,T){this.getFacadeRoot().log("warning",$,T)}static error($,T){this.getFacadeRoot().log("error",$,T)}static critical($,T){this.getFacadeRoot().log("critical",$,T)}static alert($,T){this.getFacadeRoot().log("alert",$,T)}static emergency($,T){this.getFacadeRoot().log("emergency",$,T)}}class c$ extends T0{static getFacadeAccessor(){return e}static getSupportedLocales(){return this.getFacadeRoot().supportedLocales}static getDefaultLocale(){return this.getFacadeRoot().defaultLocale}static locale(){let $=this.getFacadeRoot(),T=N.getStore();if(T)return T.locale??$.detectLocale(T.req);return $.defaultLocale}static setLocale($=c$.locale()){let T=this.getFacadeRoot(),O=$;if(!T.supportedLocales.includes($))O=T.defaultLocale;let Z=N.getStore();return Z.setCookie("i18n-locale",O,{expires:new Date(Date.now()+31536000000),secure:!1,httpOnly:!1}),Z.setLocale(O),O}}class mF{id;static token="kernel.id";constructor($=crypto.randomUUID()){this.id=$}}var Y7=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),X7=new Set(["svg","math"]);function C8($){return $===32||$===9||$===10||$===12||$===13}function z8($){return $>=65&&$<=90||$>=97&&$<=122}function WZ($){return $>=65&&$<=90?$+32:$}function W8(){let $="data",T="",O=!1,Z="",f=0,F=0,j=!1,C=0,z=0,W=()=>$==="data"&&C===0&&z===0,J=()=>{if(!O&&Y7.has(T)){$="rawText",Z=`</${T}`,f=0,T="";return}if($="data",T==="template")if(O)C=Math.max(0,C-1);else C+=1;else if(X7.has(T)){if(O)z=Math.max(0,z-1);else if(!j)z+=1}T=""},Y=(D)=>{switch($){case"data":if(D===60)$="tagOpen";return;case"tagOpen":if(D===33)$="bang",F=0;else if(D===47)$="endTagOpen";else if(z8(D))$="tagName",O=!1,j=!1,T=String.fromCharCode(WZ(D));else if(D===63)$="bogus";else if(D===60)$="tagOpen";else $="data";return;case"endTagOpen":if(z8(D))$="tagName",O=!0,j=!1,T=String.fromCharCode(WZ(D));else if(D===62)$="data";else $="bogus";return;case"tagName":if(C8(D)||D===47)$="inTag",j=D===47;else if(D===62)J();else T+=String.fromCharCode(WZ(D));return;case"inTag":if(D===62){J();return}if(j=D===47,D===34)$="attrDouble";else if(D===39)$="attrSingle";return;case"attrDouble":if(D===34)$="inTag";j=!1;return;case"attrSingle":if(D===39)$="inTag";j=!1;return;case"bang":if(D===45){if(F+=1,F===2)$="comment",F=0}else if(D===62)$="data";else $="bogus";return;case"bogus":if(D===62)$="data";return;case"comment":if(D===45)F=F<2?F+1:2;else if(D===62&&F>=2)$="data",F=0;else F=0;return;case"rawText":{if(f<Z.length){if(WZ(D)===Z.charCodeAt(f))f+=1;else f=D===60?1:0;return}if(D===62)$="data",T="";else if(C8(D)||D===47)$="inTag",T="";else f=D===60?1:0;return}}};return{scanToInsertionPoint(D){for(let U=0;U<D.length;U++){if(W())return U;Y(D[U])}return D.length},write(D){for(let U=0;U<D.length;U++)Y(D[U])},isSafe:W}}function C$($){let T=JSON.stringify($);if(T===void 0)return"undefined";return T.replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function U7($){return`<script>(self.__GEMI_STREAM__=self.__GEMI_STREAM__||[]).push(${C$([$.path,$.variantKey,$.data])})</script>`}function G7($){return`<script>(self.__GEMI_DICT__=self.__GEMI_DICT__||[]).push(${C$([$.id,$.locale,$.strings])})</script>`}function qF($,T,O={},Z){let f=new TextEncoder,F=[],j=!1,C=!1,z=()=>{if(C)return;C=!0,O.onClose?.()};T.onSettle((X)=>{if(X.status!=="resolved")return;F.push(U7(X))}),Z?.onUse((X)=>{F.push(G7(X))});let W=$.getReader(),J=W8(),Y=(X,G)=>{X.enqueue(G),O.onChunk?.(G)},D=(X)=>{while(F.length>0){let G=f.encode(F.shift());J.write(G),Y(X,G)}},U=(X,G)=>{if(F.length===0){J.write(G),Y(X,G);return}let B=J.scanToInsertionPoint(G);if(B>0)Y(X,G.subarray(0,B));if(J.isSafe())D(X);let K=G.subarray(B);if(K.length>0)J.write(K),Y(X,K)};return new ReadableStream({async pull(X){let G;try{G=await W.read()}catch(M){throw z(),M}let{done:B,value:K}=G;if(B){D(X),X.close(),z();return}if(!j){if(j=!0,J.write(K),Y(X,K),O.onShell?.(),J.isSafe())D(X);return}U(X,K)},cancel(X){return z(),W.cancel(X)}})}var B7=/bot|crawler|spider|crawling|slurp|bingpreview|mediapartners|headless|lighthouse|prerender|facebookexternalhit|whatsapp|telegram|discord|twitterbot|linkedinbot/i;function JZ($){if(!$)return!1;return B7.test($)}async function D8($,T=()=>{}){let O=N.getStore(),Z=O?.req??null,f=null;if(Z?.rawRequest?.url)try{f=new URL(Z.rawRequest.url).pathname}catch{f=null}return{user:O?.user??null,attributes:await S7($,T),request:{path:f,routePath:Z?.routePath??null,locale:O?.locale??null},anonymousId:J8(),isBot:JZ(Z?.rawRequest?.headers?.get("user-agent")??null),now:new Date}}function Y8($){return{user:$.user??null,attributes:$.attributes??{},request:{path:null,routePath:null,locale:null},anonymousId:$.subjectId??null,isBot:!1,now:new Date}}async function S7($,T){if(!$.context)return{};try{let O=N.getStore();return await $.context(O?.req??null)??{}}catch(O){return T(`The \`context\` hook in app/config/features.ts threw; evaluating with no attributes. ${O instanceof Error?O.message:String(O)}`),{}}}function X8($,T){return`${$}:${T}`}function cF($){let T=new Bun.CryptoHasher("sha1").update($).digest("hex"),O=Number.parseInt(T.slice(0,8),16);return Math.floor(O/4294967296*1e4)}function U8($,T){if(T>=100)return!0;if(T<=0)return!1;return $<Math.round(T*100)}function G8($,T,O,Z){if(Z.unavailable)return{value:!1,reason:"unavailable"};if(Z.active!==!0)return{value:!1,reason:"inactive"};if(T.when){let F;try{F=T.when(O)}catch(j){return Z.warn?.(`The \`when\` for feature "${$}" threw; treating it as off. ${j instanceof Error?j.message:String(j)}`),{value:!1,reason:"error"}}if(typeof F==="boolean")return{value:F,reason:"attributed"}}if(T.rollout===void 0)return{value:!0,reason:"on"};if(O.isBot)return{value:!1,reason:"bot"};let f=L7($,T,O,Z.buckets);return U8(f,T.rollout)?{value:!0,reason:"rollout"}:{value:!1,reason:"excluded"}}function K7($){let T=$.user?.publicId??$.user?.id;if(T!==void 0&&T!==null)return String(T);return $.anonymousId??""}function L7($,T,O,Z){let f=X8(T.salt??$,K7(O));if(!Z)return cF(f);let F=Z.get(f);if(F!==void 0)return F;let j=cF(f);return Z.set(f,j),j}class B8 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 iF{source;declared;ttlMs;warn;snapshot=null;inflight=null;lastFailureLoggedAt=0;generation=0;lastError=null;retryAfter=0;constructor($,T,O,Z=()=>{}){this.source=$;this.declared=T;this.ttlMs=O;this.warn=Z}async get(){let $=this.snapshot;if($&&Date.now()-$.loadedAt<this.ttlMs)return $;if($){if(Date.now()>=this.retryAfter)this.refresh().catch(()=>{});return $}return await this.refresh()}refresh(){return this.inflight??=this.load().finally(()=>{this.inflight=null}),this.inflight}async invalidate(){await this.inflight?.catch(()=>{});let $=this.generation,T=await this.refresh();if(this.generation===$)throw new B8(this.lastError);return T}peek(){return this.snapshot}async load(){try{let $=await this.source.load();return this.snapshot={active:this.readSwitches($),loadedAt:Date.now(),unavailable:!1},this.generation++,this.lastError=null,this.retryAfter=0,this.snapshot}catch($){return this.handleFailure($)}}readSwitches($){let T=new Map;for(let O of $??[]){let Z=typeof O?.key==="string"?O.key:null;if(!Z){this.warn("Ignoring a feature row with no `key`.");continue}if(!(Z in this.declared)){this.warn(`Feature row "${Z}" is not declared in app/features, so it is ignored. Delete the row, or declare the feature.`);continue}T.set(Z,O.active===!0)}return T}handleFailure($){let T=$ instanceof Error?$.message:String($),O=Date.now();if(this.lastError=$,this.retryAfter=O+this.ttlMs,O-this.lastFailureLoggedAt>=this.ttlMs)this.lastFailureLoggedAt=O,this.warn(`Could not load feature switches: ${T}`);if(this.snapshot)return this.snapshot;return this.snapshot={active:new Map,loadedAt:O,unavailable:!0},this.snapshot}}class S8{manager;ctx;constructor($,T){this.manager=$;this.ctx=T}async enabled($){return(await this.explain($)).value}async explain($){return await this.manager.evaluateIn($,this.ctx,new Map)}async all(){return await this.manager.evaluateAllIn(this.ctx,new Map,{clientOnly:!1})}}class i${config;log;static token="features";store;declared;warnedAboutSize=!1;constructor($,T=()=>{}){this.config=$;this.log=T;this.declared=$.features??{},this.store=new iF($.source,this.declared,Math.max(0,$.ttl)*1000,this.log)}declarations(){return this.declared}async list(){let{active:$,unavailable:T}=await this.switches();return{unavailable:T,features:Object.entries(this.declared).map(([O,Z])=>({key:O,describe:Z.describe,rollout:Z.rollout,targeted:Z.when!==void 0,serverOnly:Z.serverOnly,salt:Z.salt,active:$.get(O)}))}}async refresh(){if(!this.config.enabled)return;if(Object.keys(this.declared).length===0)return;await this.store.refresh()}async invalidate(){try{if(this.config.enabled&&Object.keys(this.declared).length>0)await this.store.invalidate()}finally{N.getStore()?.featureEvaluations?.clear()}}async enabled($){return(await this.explain($)).value}async explain($){let T=await this.requestContext();return await this.evaluateIn($,T,this.requestBuckets())}async all(){let $=await this.requestContext();return await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!1})}async forClient(){if(!this.config.enabled)return{};let $=await this.requestContext(),T=await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!0});return this.warnIfOversized(Object.keys(T).length),T}for($){return new S8(this,Y8($))}async evaluateIn($,T,O){let Z=this.memoFor(T),f=Z?.get($);if(f)return f;let F=this.declared[$];if(!F)return{value:!1,reason:"undeclared"};let{active:j,unavailable:C}=await this.switchFor($),z=G8($,F,T,{active:j,unavailable:C,buckets:O,warn:this.log});return Z?.set($,z),this.notify($,z,T),z}async evaluateAllIn($,T,O){let Z={};for(let[f,F]of Object.entries(this.declared)){if(O.clientOnly&&F.serverOnly)continue;Z[f]=(await this.evaluateIn(f,$,T)).value}return Z}async switches(){if(!this.config.enabled)return{active:new Map,unavailable:!1};if(Object.keys(this.declared).length===0)return{active:new Map,unavailable:!1};let $=await this.store.get();return{active:$.active,unavailable:$.unavailable}}async switchFor($){if(!this.config.enabled)return{active:!1,unavailable:!1};let T=await this.store.get();return{active:T.active.get($),unavailable:T.unavailable}}async requestContext(){let $=N.getStore();if($?.featureContext)return $.featureContext;let T=await D8(this.config,this.log);if($)$.featureContext=T;return T}memoFor($){let T=N.getStore();if(!T||T.featureContext!==$)return null;return T.featureEvaluations??=new Map,T.featureEvaluations}requestBuckets(){let $=N.getStore();if(!$)return new Map;return $.featureBuckets??=new Map,$.featureBuckets}notify($,T,O){if(!this.config.onEvaluate)return;try{this.config.onEvaluate($,T,O)}catch(Z){this.log(`The \`onEvaluate\` hook in app/config/features.ts threw for "${$}". ${Z instanceof Error?Z.message:String(Z)}`)}}warnIfOversized($){if(this.warnedAboutSize||$<=this.config.maxClientFlags)return;this.warnedAboutSize=!0,this.log(`${$} client-visible features are embedded in every document. Mark the ones only the server reads with \`serverOnly: true\` to keep them out of the payload.`)}}function K8($){return Object.fromEntries(Object.entries($).filter(([,T])=>{return T!==null&&T!==void 0}))}var I7=50;class p${fetcher;entries=new Map;settleListener=null;failListener=null;shellAt=null;settledBacklog=[];shipped=new Set;requestStartedAt=performance.now();renderStartedAt=null;discoveryHintsMuted=!1;constructor($){this.fetcher=$}elapsed(){return Math.round(performance.now()-this.requestStartedAt)}keyFor($,T){return[$,T].filter((O)=>O.length>0).join("?")}markRenderStart(){if(this.renderStartedAt===null)this.renderStartedAt=performance.now()}markShell(){if(this.shellAt===null)this.shellAt=this.elapsed()}summarize($){let T=this.elapsed();return{shellAt:this.shellAt??T,settledAt:T,aborted:$,queries:Array.from(this.entries.values(),(O)=>({path:O.path,variantKey:O.variantKey,startedAt:O.startedAt,settledAt:O.settledAt,status:O.status,source:O.source}))}}onQueryFail($){this.failListener=$}muteDiscoveryHints(){this.discoveryHintsMuted=!0}maybeLogLateDiscovery($){if(!$.lateBy||this.discoveryHintsMuted)return;if($.status!=="resolved")return;if(Bun.env.NODE_ENV==="production")return;let T="";try{let f=JSON.stringify($.data)?.length??0;T=f>=1024?`${(f/1024).toFixed(1)} kB`:`${f} B`}catch{T="an unserializable payload"}let O=($.settledAt??0)-$.startedAt,Z=$.variantKey?`, { search: ${JSON.stringify(Object.fromEntries(new URLSearchParams($.variantKey)))} }`:"";console.warn(`[gemi] useQuery("${$.patternPath}") was discovered ${$.lateBy}ms into the `+`server render \u2014 under a suspended segment, so its fetch (${O}ms, resolved ${T}) could not overlap the others. It still streamed. If the query belongs on this route, \`Query.prefetch("${$.patternPath}"${Z})\` in the view `+"handler starts it at request time \u2014 but note prefetched data is also re-fetched and "+`streamed into every client-side navigation payload for the route, even when the client already holds it, so weigh that bandwidth against the ${T}. If the data is only needed conditionally (a closed popover, a hidden tab), \`{ lazy: true }\` + \`trigger()\` avoids running it here at all. \`Query.noPrefetch()\` in the handler marks the omission intentional and silences this hint for the route.`)}read($,T){return this.entries.get(this.keyFor($,T))}ensure($,T={},O="render"){let Z=T.params??{},f=new URLSearchParams(K8(T.search??{}));f.delete("json"),f.sort();let F=r($,Z),j=f.toString(),C=this.keyFor(F,j),z=this.entries.get(C);if(z)return z;let W;if(O==="render"&&this.renderStartedAt!==null){let U=Math.round(performance.now()-this.renderStartedAt);if(U>I7)W=U}let J,Y=new Promise((U)=>{J=U}),D={path:F,patternPath:$,variantKey:j,lateBy:W,status:"pending",promise:Y,source:O,startedAt:this.elapsed()};return this.entries.set(C,D),this.fetcher($,Z,f).then((U)=>{D.status="resolved",D.data=U},(U)=>{D.status="rejected",D.error=U}).then(()=>{if(D.settledAt=this.elapsed(),this.maybeLogLateDiscovery(D),D.status==="rejected"&&this.failListener)this.failListener(D);if(this.settleListener)this.settleListener(D);else this.settledBacklog.push(D);J()}),D}async allSettled(){let $=0;while($!==this.entries.size)$=this.entries.size,await Promise.all(Array.from(this.entries.values(),(T)=>T.promise))}snapshotResolved(){let $={};for(let[T,O]of this.entries){if(O.status!=="resolved")continue;this.shipped.add(T),$[O.path]??={},$[O.path][O.variantKey]=O.data}return $}onSettle($){this.settleListener=(O)=>{if(this.shipped.has(this.keyFor(O.path,O.variantKey)))return;$(O)};let T=this.settledBacklog;this.settledBacklog=[];for(let O of T)this.settleListener(O)}}class z$ extends Error{path;variantKey;status;body;constructor($,T,O,Z){super(typeof Z?.message==="string"?Z.message:`Request to /api${$} failed with status ${O}`);this.path=$;this.variantKey=T;this.status=O;this.body=Z;this.name="QueryError"}}function h$(){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 pF(){return{status:403,error:{message:"Forbidden"}}}function bT($){let T=l$.getStore();return(O,Z,f)=>{let F=new URL($.url).origin,j=[r(O,Z),f.toString()].filter((J)=>J.length>0).join("?"),C=new Request(`${F}/${j}`,{headers:$.headers}),z=L8($);if(z)d$(C,z);let W=new A(C,Z);return l$.run(T,()=>N.run(W,async()=>{try{let J=await S(u0).dispatchers(z).api.getRouteData(O);if(J instanceof Response){let Y=await J.json().catch(()=>null);if(!J.ok)throw new z$(r(O,Z),f.toString(),J.status,Y);return Y}return J}catch(J){if(J instanceof z$)throw J;let Y=new z$(r(O,Z),f.toString(),500,{message:J instanceof Error?J.message:String(J)});throw Y.cause=J,Y}}))}}var M7=new Set(["script","style","template","title"]),Q7=/\shidden([\s=/]|$)/i,V7=/"[^"]*"|'[^']*'/g;function N7($){let T=0,O=0,Z=0,f=0;while(f<$.length){let F=$.indexOf("<",f),j=F===-1?$.length:F;if(j>f){let Y=$.slice(f,j).replace(/\s+/g,"").length;if(Z>0)O+=Y;else T+=Y}if(F===-1)break;if($.startsWith("<!--",F)){let Y=$.indexOf("-->",F+4);f=Y===-1?$.length:Y+3;continue}let C=$.indexOf(">",F);if(C===-1)break;let z=$.slice(F+1,C);f=C+1;let W=/^\/?([a-zA-Z][a-zA-Z0-9-]*)/.exec(z)?.[1]?.toLowerCase();if(!W)continue;let J=z.startsWith("/");if(!J&&M7.has(W)&&!z.endsWith("/")){let Y=$.indexOf(`</${W}`,f);f=Y===-1?$.length:Y;continue}if(W!=="div")continue;if(J){if(Z>0)Z-=1}else if(Z>0)Z+=1;else if(Q7.test(z.replace(V7,'""')))Z=1}return{shellChars:T,deferredChars:O}}var E7=1000,A7=64;function x7($){return $>=1000?`${($/1000).toFixed(1)} kB`:`${$} chars`}function _7($,T){if(T.deferredChars<E7)return null;if(T.shellChars>=A7)return null;return`[gemi] GET ${$} streams ${x7(T.deferredChars)} of its `+`content behind reveal scripts \u2014 a no-JS visitor sees ~${T.shellChars} chars. If this is a public/content route, add "no-stream" to its middleware.`}function I8($=console.warn){let T=new Set;return{shouldObserve(O){return!T.has(O)},report(O,Z){if(T.has(O))return;let f=_7(O,Z);if(!f)return;T.add(O),$(f)}}}function M8(){let $=new TextDecoder,T="";return{onChunk(O){T+=$.decode(O,{stream:!0})},measure(){return T+=$.decode(),N7(T)}}}function Q8($,T,O=1e4,Z){let f=new TextEncoder,F=()=>{};return new ReadableStream({start(j){let C=!1,z=(J)=>{if(C)return;C=!0,clearTimeout(W);try{j.close()}catch{}Z?.({aborted:J})};F=z,j.enqueue(f.encode(`${JSON.stringify($)}
|
|
5
|
-
`)),T.onSettle((J)=>{if(C||J.status!=="resolved")return;j.enqueue(f.encode(`${JSON.stringify([J.path,J.variantKey,J.data])}
|
|
6
|
-
`))});let W=setTimeout(()=>z(!0),O);T.allSettled().then(()=>z(!1),()=>z(!1))},cancel(){F(!1)}})}var H7=async()=>(await import("./chunk-hkhxkeeb.js")).default,hF,lF=async(...$)=>{return hF??=import("react-dom/server.browser").catch((T)=>{throw hF=void 0,T}),(await hF).renderToReadableStream(...$)},w7=1e4,b7=`
|
|
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 v7($,T,O){let Z=`${O==="italic"?"italic,":""}wght@${O==="italic"?"1,":""}${T}`,j=(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(j).then((C)=>C.arrayBuffer())}var uF="/assets";function g7($){return $===uF||$.startsWith(`${uF}/`)}function k7($){let T=$.filter(g7);if(T.length>0){let O=T.length>1;throw Error(`View route path${O?"s":""} ${T.map((Z)=>`"${Z}"`).join(", ")} use${O?"":"s"} the reserved "${uF}" prefix. The client build output is served from there before the router runs, so the route would never match. Mount it somewhere else.`)}}function R7($){let T=S(u0).resolver;return{...$.domain,root:T.root,origin:T.publicOrigin($.rawRequest)}}function dF($){let{status:T=400,error:O}=$;return new Response(O?.message,{...$,status:T})}function y7($){let{status:T=400,data:O,directive:Z,headers:f}=$;return new Response(JSON.stringify({data:O,directive:Z}),{headers:f,status:T})}class kT{static token="router.view";flatViewRoutes={};routeManifest={};clientRouteManifest={};componentTree=[];flatComponentTree=[];root=null;shellReporter=I8();preloadCache=new WeakMap;hooks;partialRendering;constructor($){let T=k6();this.partialRendering=$.partialRendering??T.partialRendering,this.hooks={onRequestStart:$.onRequestStart??T.onRequestStart,onRequestEnd:$.onRequestEnd??T.onRequestEnd,onRequestFail:$.onRequestFail??T.onRequestFail,onStreamComplete:$.onStreamComplete??T.onStreamComplete};let O={"/":$.rootRouter,"/auth":zF};this.flatViewRoutes=FZ(O),k7(Object.keys(this.flatViewRoutes)),this.routeManifest=CZ(O),this.clientRouteManifest=Object.fromEntries(Object.entries(this.routeManifest).filter(([,Z])=>Z.at(-1)!=="FILE")),this.componentTree=zZ(O),this.flatComponentTree=yF(this.componentTree),this.root=$.root}async passesFeatureGates($){let T=S(i$);for(let O of $)if(!await T.enabled(O))return!1;return!0}async onRequestEnd($){return sF(),await this.hooks.onRequestEnd($)}completeStream($,T){let O=(Z)=>{R1.error(Z?.message??'Error in "onStreamComplete" event handler',{err:JSON.stringify(Z)})};try{Promise.resolve(this.hooks.onStreamComplete($,T)).catch(O)}catch(Z){O(Z)}}modulePreloadLinks($){let{clientEntry:T,modulePreloadManifest:O,views:Z,routeKey:f}=$,F=()=>{let z=new Set(T?.preload??[]);for(let W of Z)for(let J of O?.[W]??[])z.add(J);return[...z].map((W)=>s$("link",{key:`modulepreload:${W}`,rel:"modulepreload",href:W}))};if(!O)return F();let j=this.preloadCache.get(O);if(!j||j.clientEntry!==T)j={clientEntry:T,byRoute:new Map},this.preloadCache.set(O,j);let C=j.byRoute.get(f);if(!C)C=F(),j.byRoute.set(f,C);return C}async render($){let{req:T,runInRequestScope:O,csrfTokenHMAC:Z,currentPathName:f,headers:F,i18n:j,params:C,pathname:z,serverQueries:W,userAgent:J,noStream:Y,url:D,user:U,viewData:X,breadcrumbs:G,urlLocaleSegment:B,meta:K,isOgRequest:M,appId:L,features:E}=$,x=z.replace(`/${B}`,""),I={kind:"view",data:{meta:K,pageData:{[x]:X},__csrf:Z.toString("base64"),prefetchedData:{},i18n:j,auth:{user:U},routeManifest:this.clientRouteManifest,breadcrumbs:G,router:{urlLocaleSegment:B,pathname:f,params:C,currentPath:z,searchParams:D.search,is404:!f?!0:!1,domain:T.domain?R7(T):null},appId:L,features:E,componentTree:[["404",[]],...this.componentTree]},head:{}},Q=this.root,_=this.routeManifest[f];return async(P)=>{let{bootstrapModules:O0=[],loaders:v,getStyles:g,viewImportMap:R0,cssManifest:BZ,ogMap:y1,viewModules:RT,clientEntry:f1,modulePreloadManifest:j0,assetBase:n$}=P,a$=f1?[]:O0,m1=(Q0)=>[Q0,`window.loaders=${v}`,...f1?[`import(${JSON.stringify(f1.module)}).catch(function(e){setTimeout(function(){throw e})})`]:[]].join(";");if(M){let Q0=null,W$=null;for(let J$ of _??[])if(typeof y1[J$]==="function")W$=J$,Q0=y1[J$];if(!Q0)return new Response("Not found",{status:404});let n8=Object.values(I.data.pageData)[0];try{await lF(s$(Q0,n8[W$]),{onError:()=>{}})}catch(J$){let{fonts:a8,...o8}=J$.satoriOptions,t8=await Promise.all(a8.map((mT)=>{return v7(mT.name,mT.weight,mT.style).then((O2)=>({...mT,data:O2}))})),Zj=new Headers(F);Zj.set("Content-Type","image/png");let[r8,e8]=await Promise.all([H7(),ZZ("Rendering an OG image")]),$2=await r8(J$.jsx,{...o8,fonts:t8}),T2=await e8(Buffer.from($2)).png({compressionLevel:0,effort:10}).toBuffer();return new Response(new Uint8Array(T2),{headers:Zj})}return new Response("data")}if(I.data.cssManifest=BZ,I.data.modulePreloadManifest=j0??{},n$&&n$!=="/")I.data.assetBase=n$;let o$=this.modulePreloadLinks({clientEntry:f1,modulePreloadManifest:j0,views:_??["404"],routeKey:f??"404"}),yT=await g(_);I.data.prefetchedData=W.snapshotResolved(),W.markRenderStart();let q1=new AbortController,R=setTimeout(()=>q1.abort(),w7),X0=JZ(J)||Y,c1=Bun.env.NODE_ENV!=="production"&&!X0&&f&&this.shellReporter.shouldObserve(f)?M8():null,Oj=E8();try{let Q0=await lF(s$(P7,{children:[...o$,...yT,s$("script",{key:"theme-script",dangerouslySetInnerHTML:{__html:b7}}),s$(Q,{data:I.data,viewImportMap:R0,viewModules:RT,serverQueries:W,dictionarySink:Oj,key:"root"})]}),{bootstrapScriptContent:m1(`window.__GEMI_DATA__ = ${C$(I.data)}`),bootstrapModules:a$,signal:q1.signal,...X0?{progressiveChunkSize:Number.MAX_SAFE_INTEGER}:{},onError(W$){if(Bun.env.NODE_ENV!=="production")console.error(W$)}});if(Q0.allReady.catch(()=>{}).finally(()=>clearTimeout(R)),X0)await Q0.allReady.catch(()=>{});return new Response(qF(Q0,W,{onShell:X0?void 0:()=>W.markShell(),onChunk:c1?.onChunk,onClose:()=>O(()=>{if(this.completeStream(T,W.summarize(q1.signal.aborted)),c1)this.shellReporter.report(f,c1.measure())})},Oj),{status:!f?404:200,headers:F})}catch(Q0){if(clearTimeout(R),Bun.env.NODE_ENV==="production")throw O(()=>this.completeStream(T,W.summarize(q1.signal.aborted))),Q0;let W$=await lF(s$("div"),{bootstrapScriptContent:m1(`window.error= ${C$(Q0.message)}; window.stack_trace=${C$(Q0.stack)};window.__GEMI_DATA__ = ${C$(I.data)}`),bootstrapModules:Bun.env.NODE_ENV==="development"?["/render-error.js",...a$]:a$});return new Response(qF(W$,W,{onClose:()=>O(()=>this.completeStream(T,W.summarize(q1.signal.aborted)))}),{status:!f?404:200,headers:F})}}}async handleViewRequest($,T){let O=new URL($.url),Z=O.pathname.endsWith(".json"),f=O.pathname.endsWith(".og"),F=O.pathname.replace(".json","").replace(".og",""),[,j,...C]=F.split("/"),z=`/${C.join("/")}`,W=null,J=null,Y=S(e);if(!Y.supportedLocales.includes(j))z=F;else W=j,J=j;let U=J===null&&wT(this.flatViewRoutes,z)!==null;if(Y.isLocaleAware&&!f&&J===null&&!U){let I=V8(j,Y.supportedLocales,Y.defaultLocale);if(I){let Q=C.length?`/${C.join("/")}`:"";return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${I}${Q}${Z?".json":""}${O.search}`}})}}if(Y.isLocaleAware&&!f){let I=S(e).detectLocale(new A($,{},"view",z));if(J===null&&I!==Y.defaultLocale){let Q=O.pathname==="/"?"":O.pathname;return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${I}${Q}${O.search}`}})}}z=z.replace("//","/");let X=[],G=[],B=null,K={},M=null,L=!1,E=[];try{let I=wT(this.flatViewRoutes,z);if(I){if(B=I.routePath,K=I.params,X=I.route.exec,G=I.route.middleware,E=I.route.features,L=G.includes("no-stream"),Z&&this.partialRendering){let Q=$.headers.get(RF),_=j8({flatViewRoutes:this.flatViewRoutes,supportedLocales:S(e).supportedLocales,from:Q,origin:O.origin,to:{segments:I.route.segments,params:K,search:O.search}});if(_.startIndex>0)X=X.slice(_.startIndex),M={from:Q,carriedViews:_.carriedViews}}}}catch(I){throw I}let x=new A($,K,"view",B);return this.hooks.onRequestStart(x),await N.run(x,async()=>{let I=null,Q=N.getStore(),_=l$.getStore(),P=(g)=>l$.run(_,()=>N.runWith(Q,g));Q.serverQueries=new p$(bT($));let O0=new Set;if(Q.serverQueries.onQueryFail((g)=>{O0.add(g.error);try{P(()=>Promise.resolve(this.hooks.onRequestFail(v,g.error)).catch(()=>{}))}catch{}}),J){let g=J.replaceAll("/","");c$.setLocale(g)}else c$.setLocale();let v=Q.req;sF();try{if(await S(HT).runMiddleware(G),E.length>0&&!await this.passesFeatureGates(E))B=null,X=[],v.routePath="";let g=S(e),R0=g.isEnabled,BZ=g.isLocaleAware,y1={};if(BZ){let R=null;if(J)R=J.replaceAll("/",""),Q.setLocale(R);else R=g.detectLocale(new A($,v.params)),Q.setLocale(R);let X0=R0?g.getPageTranslations(R,v.routePath):{};y1={supportedLocales:g.supportedLocales,currentLocale:R,dictionary:{[R]:X0},defaultLocale:g.defaultLocale}}await N8(y1.currentLocale??"");let RT=await Promise.all(X.map((R)=>R(v))),f1=Q.cookies,j0=Q.headers;I={data:RT,cookies:f1,headers:j0,user:Q.user,prefetchedData:Q.serverQueries.snapshotResolved(),currentPathName:B,params:v.params,urlLocaleSegment:W,meta:Q.renderMeta(),appId:S(mF).id,features:await S(i$).forClient()};let{params:n$,user:a$}=I,m1={},o$={};for(let R of RT??[]){let[X0,c1]=Object.entries(R)?.[0]??[];if(!X0||!c1)continue;o$[`${X0}:${B}`]=c1.breadcrumb,m1[X0]=c1}let yT=m1.FILE;if(yT){for(let R of f1)j0.append("Set-Cookie",R.toString());try{await this.onRequestEnd(v)}catch(R){R1.error(R?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(R)})}return await o3(yT,j0)}if(Z){j0.set("Content-Type","application/x-ndjson; charset=utf-8"),j0.append("Vary",RF),f1.forEach((X0)=>j0.append("Set-Cookie",X0.toString())),await this.hooks.onRequestEnd(v);let R={meta:M&&!Q.metadata.touched?null:I.meta,data:{[z]:m1},breadcrumbs:o$,prefetchedData:Q.serverQueries.snapshotResolved(),i18n:y1,features:I.features,is404:!B,appId:I.appId,partial:M};return new Response(Q8(R,Q.serverQueries,void 0,({aborted:X0})=>P(()=>this.completeStream(v,Q.serverQueries.summarize(X0)))),{headers:j0})}if(j0.set("Content-Type","text/html; charset=utf-8"),!L)j0.append("Vary","User-Agent");for(let R of f1)j0.append("Set-Cookie",R.toString());let q1=Bun.CSRF.generate(process.env.SECRET);j0.append("Set-Cookie",`csrf_token=${q1}; HttpOnly; Secure; SameSite=Strict; Expires=${new Date(Date.now()+86400000).toUTCString()}`);try{await this.onRequestEnd(v)}catch(R){R1.error(R?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(R)})}return await this.render({req:v,runInRequestScope:P,csrfTokenHMAC:Buffer.from(""),currentPathName:B,headers:j0,i18n:y1,params:n$,pathname:O.pathname,serverQueries:Q.serverQueries,userAgent:$.headers.get("user-agent"),noStream:L,url:O,user:a$,viewData:m1,breadcrumbs:o$,urlLocaleSegment:W,meta:I.meta,appId:I.appId,features:I.features,isOgRequest:f})}catch(g){if(g.kind===vT)if(Z)return y7(g.payload.viewData??g.payload.api);else return dF(g.payload.view);if(!O0.has(g))this.hooks.onRequestFail(v,g);if(gT(g))return console.error(g),Z?h$():dF(pF());if(g instanceof z$&&g.status===403)return Z?h$():dF(pF());throw g}},T)}}class w8 extends P0{routes={"/api-routes":this.get(()=>{let $=S(YZ).flatRoutes,T=[];for(let[O,Z]of Object.entries($))for(let[f,F]of Object.entries(Z)){let{exec:j,middleware:C}=F;T.push({path:O,method:f,middleware:C})}return T}),"/view-routes":this.get(()=>{let $=S(kT).flatViewRoutes,T=[];for(let[O,{middleware:Z,viewPath:f}]of Object.entries($))T.push({path:O,method:"GET",viewPath:f,middleware:Z});return T})}}var DZ="access_token";function m7($,T){let O=$.body.getReader(),Z=!1,f=()=>{if(Z)return;Z=!0;try{T()}catch(j){console.error(j)}},F=new ReadableStream({async pull(j){let C;try{C=await O.read()}catch(z){f(),j.error(z);return}if(C.done){f();try{j.close()}catch{}return}try{j.enqueue(C.value)}catch{}},async cancel(j){try{await O.cancel(j)}finally{f()}}},{highWaterMark:0});return new Response(F,{status:$.status,statusText:$.statusText,headers:$.headers})}function A8($){let{status:T=400,data:O,headers:Z}=$,f=new Headers({"Content-Type":"application/json",...Z});if(!f.has("Cache-Control"))f.set("Cache-Control","no-store");return new Response(JSON.stringify(O),{status:T,headers:f})}function x8($,T,O){let Z=[];T?.forEach((j,C)=>Z.push([C,j]));let f=[...typeof T?.getSetCookie==="function"?T.getSetCookie():[],...Array.from(O??[])];if(Z.length===0&&f.length===0)return $;let F=(j)=>{for(let[C,z]of Z){if(C.toLowerCase()==="set-cookie")continue;if(!j.has(C))j.set(C,z)}for(let C of f)j.append("Set-Cookie",C)};try{return F($.headers),$}catch{let j=new Headers($.headers);return F(j),new Response($.body,{status:$.status,statusText:$.statusText,headers:j})}}class YZ{static token="router.api";flatRoutes={};onRequestStart;onRequestEnd;onRequestFail;constructor($){let T=g6();this.onRequestStart=$.onRequestStart??T.onRequestStart,this.onRequestEnd=$.onRequestEnd??T.onRequestEnd,this.onRequestFail=$.onRequestFail??T.onRequestFail,this.flatRoutes=KF({"/":$.rootRouter,"/auth":WF,"/__gemi__/services/i18n":JF,"/__gemi__/services/logs":SF,"/__gemi__/services/image":XF,"/__gemi__/debug":w8})}getRouteHandlerAndParams($){let T=new URL($.url),O=H8(T.pathname),Z={},f;for(let[F]of Object.entries(this.flatRoutes))try{let j=new URLPattern({pathname:F});if(j.test({pathname:O})){f=F,Z=j.exec({pathname:O})?.pathname.groups;break}}catch(j){console.error(j)}return{params:Z,path:f}}async runRouteMiddleware($,T){let Z=this.flatRoutes[$][T.rawRequest.method].middleware;try{await S(HT).runMiddleware(Z)}catch(f){if(f.kind===vT)return A8(f.payload.api);else{if(this.onRequestFail(T,f),console.error(f),gT(f))return h$();throw f}}}async getRouteData($){let T=this.flatRoutes[$],O=N.getStore(),Z=T[O.req.rawRequest.method].exec??(()=>Promise.resolve({})),f={};try{f=await Z()}catch(F){if(F.kind===vT)return A8(F.payload.api);if(this.onRequestFail(O.req,F),console.error(F),gT(F))return h$();throw F}return f}isFrameworkRoute($){return $.startsWith("/__gemi__")}async endRequest($,T,O){let Z=async()=>{try{if(!this.isFrameworkRoute(O))await this.onRequestEnd(T)}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($,T){return $.method!=="HEAD"&&T.body!==null&&!T.headers.has("Content-Length")}async handleApiRequest($,T){let{params:O,path:Z}=this.getRouteHandlerAndParams($),f=this.flatRoutes[Z];if(!f||!f[$.method])return new Response(JSON.stringify({error:{message:"Not found"}}),{status:404});let F=new A($,O,"api",Z);if(!this.isFrameworkRoute(Z))this.onRequestStart(F);return await N.run(F,async()=>{let j=N.getStore(),C=!1,z=async()=>{C=!0,await this.endRequest(j,F,Z)};try{let W=S(e);if(W.isEnabled){let X=W.detectLocale(F);j.setLocale(X)}j.setRequest(F);let J=await this.runRouteMiddleware(Z,F);if(J instanceof Response){let X=x8(J,j.headers,j.cookies);return await z(),X}let Y=await this.getRouteData(Z),D=j.headers,U=j.cookies;if(Y instanceof Response){let X=x8(Y,D,U);if(this.isOpenEndedBody($,X)){let G=m7(X,()=>this.endRequest(j,F,Z));return C=!0,G}return await z(),X}return D.set("Content-Type","application/json"),U.forEach((X)=>D.append("Set-Cookie",X.toString())),await z(),new Response(JSON.stringify(Y),{headers:D})}catch(W){if(!C)try{await z()}catch(J){console.error(J)}throw W}},T)}async dispatchAs($,T,O,Z){let f=new URL($.rawRequest.url).origin,F=new URL(`${f}/api${O}`),j=`/api${O.split(/[?#]/)[0]}`;if(!O.startsWith("/")||F.origin!==f||F.pathname!==j||F.hash!==""||F.pathname.startsWith("/api/__gemi__")||F.pathname==="/api/auth"||F.pathname.startsWith("/api/auth/"))throw Error(`dispatchAs: "${O}" is not an app api path. Pass the route's own path, without "/api", with every param encoded.`);let C=new Headers,z=$.cookies.get(DZ);if(z)C.set("Cookie",`${DZ}=${z}`);let W=$.headers.get(DZ);if(W)C.set(DZ,W);let J=$.headers.get("User-Agent");if(J)C.set("User-Agent",J);let Y;if(Z instanceof FormData)Y=Z;else if(Z!==void 0)C.set("Content-Type","application/json"),Y=JSON.stringify(Z);let D=new Request(F,{method:T,headers:C,body:Y});if(_8(D,OZ($)),$.domain)d$(D,$.domain);return N.exit(()=>P8.exit(()=>this.handleApiRequest(D)))}}var oF="",b8="*";var aF=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;function v8($){return $.startsWith(":")}function Z1($){if(!$)return null;try{return new URL(`http://${$.trim()}`).hostname.toLowerCase().replace(/\.$/,"")||null}catch{return null}}function q7($){try{let T=new URL(`http://${$.trim()}`),O=T.hostname.toLowerCase().replace(/\.$/,"");return O?T.port?`${O}:${T.port}`:O:null}catch{return null}}function c7($){let T=Z1($.root),O=$.root?.trim().toLowerCase().replace(/\.$/,"");if(!T||T!==O||!T.split(".").every((F)=>aF.test(F)))throw Error(`\`route.domains.root\` must be a bare hostname, e.g. "example.com" \u2014 no scheme, port or path. Got "${$.root}".`);if($.custom&&($.custom.cacheTtlMs??0)<0)throw Error(`\`route.domains.custom.cacheTtlMs\` is ${$.custom.cacheTtlMs}; it cannot be negative. Use 0 to disable the cache.`);if($.ask&&$.ask.secret.length<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 F of $.groups??[]){let{subdomain:j}=F;if(Z.has(j))throw Error(`\`route.domains\` declares the subdomain "${j}" twice.`);if(Z.add(j),v8(j)){if(!/^:[A-Za-z_][A-Za-z0-9_]*$/.test(j))throw Error(`"${j}" is not a valid param subdomain. It must be a single \`:name\` label.`);if(f)throw Error(`\`route.domains\` declares two param subdomains, "${f.subdomain}" and "${j}"; a host could match either.`);f=F;continue}if(F.exists)throw Error(`The subdomain "${j}" is fixed, so \`exists\` has no param to check. It only applies to a \`:param\` subdomain.`);if(!j.split(".").every((C)=>aF.test(C)))throw Error(`"${j}" 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 tF{root;trustProxy;fixed=new Map;param=null;custom;cacheTtlMs;cache=new Map;inFlight=new Map;askSecret;constructor($){c7($),this.root=Z1($.root),this.trustProxy=$.trustProxy??!1;for(let T of $.groups??[])if(v8(T.subdomain))this.param={...T,name:T.subdomain.slice(1)};else this.fixed.set(T.subdomain.toLowerCase(),T);this.custom=$.custom??null,this.cacheTtlMs=this.custom?.cacheTtlMs??60000,this.askSecret=$.ask?.secret??null}hostOf($){if(this.trustProxy){let T=$.headers.get("x-forwarded-host")?.split(",")[0],O=Z1(T);if(O)return O}return Z1(new URL($.url).host)}publicOrigin($){let T=new URL($.url),O=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),Z=O==="http"||O==="https"?O:T.protocol.replace(/:$/,"");if(!this.trustProxy)return`${Z}://${T.host}`;let f=$.headers.get("x-forwarded-host")?.split(",")[0]?.trim(),F=f&&Z1(f)?q7(f):null;return`${Z}://${F??T.host}`}async resolve($){let T=this.hostOf($);if(!T)return null;let O=await this.match(T,$);if(O)return O;if(this.custom?.fallback&&!this.isUnderRoot(T))return{host:T,group:"*",params:{},custom:!0};return null}async allows($,T){let O=Z1($);return O?await this.match(O,T)!==null:!1}isUnderRoot($){return $===this.root||$.endsWith(`.${this.root}`)}async match($,T){if($===this.root)return{host:$,group:"",params:{},custom:!1};if($.endsWith(`.${this.root}`)){let Z=$.slice(0,-(this.root.length+1)),f=this.fixed.get(Z);if(f)return{host:$,group:f.subdomain,params:{},custom:!1};if(this.param&&aF.test(Z)){let F={[this.param.name]:Z};if(this.param.exists&&!await this.param.exists(F,T))return null;return{host:$,group:this.param.subdomain,params:F,custom:!1}}return null}if(!this.custom)return null;let O=await this.resolveCustom($);return O?{host:$,group:this.custom.group,params:O,custom:!0}:null}async resolveCustom($){let T=Date.now(),O=this.cache.get($);if(O&&O.expiresAt>T)return this.cache.delete($),this.cache.set($,O),O.value;let Z=this.inFlight.get($);if(Z)return Z;let f=(async()=>await this.custom.resolve($)??null)();this.inFlight.set($,f);let F;try{F=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:F,expiresAt:Date.now()+this.cacheTtlMs})}return F}forget($){if($===void 0)this.cache.clear();else{let T=Z1($);if(T)this.cache.delete(T)}}}var p7="/__gemi__/domains/ask";function h7($,T){if($===null)return!1;let O=Buffer.from($,"utf8"),Z=Buffer.from(T,"utf8");return O.length===Z.length&&i7(O,Z)}class u0{static token="router.domains";resolver;acceptsCustomDomains;groups=new Map;constructor($,T){this.groups.set(oF,$);let{domains:O}=T;if(this.acceptsCustomDomains=Boolean(O?.custom),!O){this.resolver=null;return}this.resolver=new tF(O);let Z=(f)=>({api:f.api?new YZ({...T.api,...f.api}):$.api,view:f.view?new kT({...T.view,...f.view}):$.view});for(let f of O.groups??[])this.groups.set(f.subdomain,Z(f));if(O.custom?.fallback)this.groups.set(b8,Z(O.custom.fallback))}async route($){if(!this.resolver)return this.dispatchers(null);let T=await this.resolver.resolve($);if(!T)return null;return d$($,T),this.dispatchers(T)}async ask($){if(!this.resolver?.askSecret||$.method!=="GET")return null;let T=new URL($.url);if(T.pathname!==p7)return null;if(!h7(T.searchParams.get("secret"),this.resolver.askSecret))return null;let O=T.searchParams.get("domain"),Z=O?await this.resolver.allows(O,$):!1;return new Response(null,{status:Z?200:404})}dispatchers($){return this.groups.get($?.group??oF)}viewDispatchers(){return Array.from(new Set(Array.from(this.groups.values(),($)=>$.view)))}}class w{static token="auth";config;provider;constructor($={},T=new FF){this.config=g8(x6($),$),this.provider=T}get userProvider(){return this.provider}accessTokenCookieOptions($,T){return{expires:T,secure:this.publicOrigin($).startsWith("https://"),httpOnly:!0,domain:this.cookieDomain($)}}publicOrigin($){let T=S().bound(u0)?S(u0).resolver:null;return T?T.publicOrigin($.rawRequest):new URL($.rawRequest.url).origin}cookieDomain($){let T=this.config.cookieDomain;if(!T)return;let O=T==="root"?S(u0).resolver?.root:Z1(T);if(!O)throw Error('`auth.cookieDomain` is "root", but `route.domains` is not configured.');let Z=$.domain?.host??Z1(new URL($.rawRequest.url).host);return Z===O||Z?.endsWith(`.${O}`)?O:void 0}async getSession($,T){let O=await this.userProvider.findSession({token:$,userAgent:T}),Z=null;if(O?.user)Z=await this.config.extendSession(O.user),O.user.extension=Z;return O}async generateMagicLink($){}async upsertSession($){await this.userProvider.findSession({token:"",userAgent:""})}async authenticate($){try{let T=await this.userProvider.findUserByEmailAddress($,!1);if(!T)throw Error(`User not found with email: ${$}`);let O=await this.createOrUpdateSession({email:$,id:T.id}),Z=new A;if(Z.ctx().setCookie("access_token",O.token,this.accessTokenCookieOptions(Z,O.expiresAt)),O?.user)O.user.extension=await this.config.extendSession(O.user);return O}catch(T){console.log(T)}}async createOrUpdateSessionV2($){let T=await this.createOrUpdateSession($),O=null;if(T?.user)O=await this.config.extendSession(T.user),T.user.extension=O;return T}async createOrUpdateSession($){let T=new A,O=T.headers.get("User-Agent"),Z=new Bun.CryptoHasher("sha256");Z.update(`${$.email}${O}`);let f=Z.digest("hex"),F=await this.userProvider.findSession({token:f,userAgent:Bun.env.NODE_ENV==="development"?"local":T.headers.get("User-Agent")});if(!F){let j=$.id;if(!j){let{id:C}=await this.userProvider.findUserByEmailAddress($.email,!1);j=C}F=await this.userProvider.createSessionV2({token:f,userId:j,userAgent:Bun.env.NODE_ENV==="development"?"local":T.headers.get("User-Agent"),expiresAt:new Date(T1.Now.instant().add({hours:this.config.sessionExpiresInHours}).toString()),absoluteExpiresAt:new Date(T1.Now.instant().add({hours:this.config.sessionAbsoluteExpiresInHours}).toString())})}else F=await this.userProvider.updateSession({token:f,expiresAt:new Date(T1.Now.instant().add({hours:this.config.sessionExpiresInHours}).toString())});return F}async createMagicLinkToken($){let T=await this.userProvider.findUserByEmailAddress($,!1);if(T){await this.userProvider.deleteMagicLinkToken($);let O=await this.config.generateMagicLinkToken($),Z=(Number.parseInt(l7(4).toString("hex"),16)%1e6).toString().padStart(6,"0");return await this.userProvider.createMagicLinkToken({email:$,token:O,pin:Z}),{user:T,email:$,pin:Z,token:O}}return{}}}import{AsyncLocalStorage as d7}from"async_hooks";class rF{config;static token="broadcast";publishCb;context=new d7;constructor($){this.config=$}get channels(){return this.config.channels}onPublish($){this.publishCb=$}publish(...$){let[T,O,Z]=$;this.publishCb(T,O,Z)}async handleMessage($,T){let O=JSON.parse(T);if(O.type==="subscribe"){let Z=Object.entries(this.channels).sort(([f],[F])=>f.length-F.length);for(let[f,F]of Z){let j=new URLPattern({pathname:f});if(j.test({pathname:O.topic})){let C=j.exec({pathname:O.topic})?.pathname.groups,z=new F;if(await z.subscribe.call(z,C))$.subscribe(O.topic);break}}}if(O.type==="broadcast")$.publish(O.topic,JSON.stringify({topic:O.topic,data:O.payload}));if(O.type==="unsubscribe")$.unsubscribe(O.topic)}run($,T){let O=k8($.get("Cookie"));this.context.run({headers:$,cookies:O},T)}}class XZ extends T0{static getFacadeAccessor(){return rF}static channel($,T){let O=this.getFacadeRoot(),Z=O.channels[$];if(!Z)return console.error(`Channel ${$} not found`),{publish:()=>{}};let f=new Z;return{publish:(F,j=!1)=>{let C=r($,T);O.publish(C,JSON.stringify({topic:C,data:f.publish(F)}),j)}}}}class v1 extends T0{static getFacadeAccessor(){return w}static async user(){let $=N.getStore(),T=XZ.getFacadeRoot().context.getStore(),O="",Z="";if($?.req)O=$.req.cookies.get("access_token"),Z=$.req.headers.get("User-Agent");if(T?.cookies)Z=T.headers.get("User-Agent"),O=T.cookies.get("access_token");let f=$?.user;if(!f)f=(await this.getFacadeRoot().getSession(O,Z))?.user,$?.setUser(f);if(f)return f;throw new _T({redirectTo:TZ($?.req,this.getFacadeRoot().config.signInPath)})}static intendedUrl($){let T=N.getStore()?.req;return xT(T?.search.get(k$),$??this.getFacadeRoot().config.redirectPath)}static async guard($){let T=await v1.user();if(!await $(T))throw new TF}static async guardSafe($){let T=await v1.user();try{return await $(T)}catch(O){return!1}}static async authenticate($){return await this.getFacadeRoot().authenticate($)}static async createMagicLink($){return await this.getFacadeRoot().createMagicLinkToken($)}}class UZ{static ensure($,T={}){let O=N.getStore();if(O.req.kind==="api")throw Error("Query.prefetch() cannot be called from an API request");return O.serverQueries??=new p$(bT(O.req.rawRequest)),O.serverQueries.ensure($,T,"prefetch")}static async instant($,...T){let O=UZ.ensure($,T[0]);if(await O.promise,O.status==="rejected")throw O.error;return O.data}static prefetch($,...T){UZ.ensure($,T[0])}static noPrefetch(){let $=N.getStore();if($.req.kind==="api")throw Error("Query.noPrefetch() cannot be called from an API request");$.serverQueries??=new p$(bT($.req.rawRequest)),$.serverQueries.muteDiscoveryHints()}}function R8($,T,O="/"){let Z=new URL($.origin),f=T.host?T.host:T.subdomain?`${T.subdomain}.${$.root}`:$.root,F=new URL(O.startsWith("/")?O:`/${O}`,Z),j=s7(f);if(!j)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(F.hostname=j.hostname,j.port)F.port=j.port;return F.toString()}function s7($){try{let T=new URL(`http://${$.trim()}`);return T.host===$.trim().toLowerCase()&&T.pathname==="/"?{hostname:T.hostname,port:T.port}:null}catch{return null}}class y8{static absolute($,...T){return`${process.env.HOST_NAME}${r(String($),T[0]??{})}`}static relative($,...T){return r(String($),T[0]??{})}static forDomain($,T,...O){let Z=S(u0).resolver;if(!Z)throw Error("`Url.forDomain` needs `route.domains` to be configured.");let f=N.getStore()?.req?.rawRequest,F=f?Z.publicOrigin(f):process.env.HOST_NAME;if(!F)throw Error("`Url.forDomain` outside a request needs `HOST_NAME` for the protocol.");return R8({root:Z.root,origin:F},$,r(String(T),O[0]??{}))}}class m8{name="Meta";static description($){N.getStore().metadata.description($)}static title($){N.getStore().metadata.title($)}static openGraph($){N.getStore().metadata.openGraph($)}}var u7={set($,T,O){N.getStore().setCookie($,T,O)},setIfAbsent($,T,O){if(N.getStore().req.cookies.has($))return!1;return N.getStore().setCookie($,T,O),!0},delete($,T){N.getStore().deleteCookie($,T)}};class eF{config;static token="redis";instance=null;constructor($={}){this.config=$}get client(){return this.instance??=new(n7())(this.config.url,this.config.options)}set client($){this.instance=$}}function n7(){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 U1 extends T0{static getFacadeAccessor(){return eF}static get client(){return this.getFacadeRoot().client}static get($){return U1.client.get($)}static set($,T){return U1.client.set($,T)}static del(...$){return U1.client.del(...$)}static exists($){return U1.client.exists($)}static incr($){return U1.client.incr($)}static expire($,T){return U1.client.expire($,T)}static ttl($){return U1.client.ttl($)}}class q8 extends T0{static getFacadeAccessor(){return R$}static consume($,T={}){return this.getFacadeRoot().consume($,T)}}class c8 extends T0{static getFacadeAccessor(){return i$}static enabled($){return this.getFacadeRoot().enabled($)}static all(){return this.getFacadeRoot().forClient()}static explain($){return this.getFacadeRoot().explain($)}static for($){return this.getFacadeRoot().for($)}static list(){return this.getFacadeRoot().list()}static refresh(){return this.getFacadeRoot().refresh()}static invalidate(){return this.getFacadeRoot().invalidate()}}class GZ{bound;constructor($){this.bound=$}get name(){return this.bound??$j()}get sql(){return this.connection().sql}get dialect(){return this.connection().dialect}async query($){return await this.run($,"query")}async execute($){let T=await this.run($,"execute");return Number(T?.count??0)}async transaction($){let T=this.name,O=this.connection(T);return l8(O.sql,(Z)=>p8(T,()=>$(Z)),{slowTransactionThreshold:O.config.slowTransactionThreshold,connection:T})}async schema(){let $=this.connection(),{introspect:T}=await import("./chunk-pbx9p6g0.js");return T(this.handle()??$.sql,$.dialect)}run($,T){let O=this.connection(),{text:Z,values:f}=s8($,d8(O.dialect),T);return(this.handle()??O.sql).unsafe(Z,f)}handle(){let $=i8();if($===void 0)return;return $j()===this.name?$:void 0}connection($=this.name){return h8($),S(Tj).connection($)}}var u$=new GZ;class u8 extends T0{static getFacadeAccessor(){return Tj}static connection($){return new GZ($)}static get sql(){return u$.sql}static get dialect(){return u$.dialect}static query($){return u$.query($)}static execute($){return u$.execute($)}static transaction($){return u$.transaction($)}static schema(){return u$.schema()}static close(){return this.getFacadeRoot().close()}}export{w1 as jc,AT as kc,d3 as lc,P0 as mc,n3 as nc,J6 as oc,$Z as pc,o3 as qc,b1 as rc,k0 as sc,p5 as tc,h5 as uc,RD as vc,x6 as wc,FF as xc,rF as yc,XZ as zc,v1 as Ac,c$ as Bc,UZ as Cc,y8 as Dc,PT as Ec,R1 as Fc,m8 as Gc,u7 as Hc,eF as Ic,U1 as Jc,R$ as Kc,q8 as Lc,X8 as Mc,cF as Nc,U8 as Oc,G8 as Pc,K7 as Qc,B8 as Rc,iF as Sc,S8 as Tc,i$ as Uc,c8 as Vc,GZ as Wc,u8 as Xc,DF as Yc,YF as Zc,JY as _c,b6 as $c,v6 as ad,HT as bd,_Y as cd,g6 as dd,k6 as ed,kF as fd,mF as gd,h$ as hd,pF as id,uF as jd,g7 as kd,dF as ld,y7 as md,kT as nd,t3 as od,Q6 as pd,OZ as qd,A8 as rd,x8 as sd,YZ as td,u0 as ud,w as vd,B6 as wd,S6 as xd,K6 as yd,N6 as zd,E6 as Ad,A6 as Bd};
|
|
18
|
-
|
|
19
|
-
//# debugId=796811F134AD9E2664756E2164756E21
|
package/dist/chunk-dq2hgzje.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{hc as o}from"./chunk-qcbtr7hm.js";import{ic as i}from"./chunk-dfv5eqma.js";import{hf as t}from"./chunk-0qchadp1.js";import{_f as r}from"./chunk-78cvy4je.js";class n extends i{register(){this.app.singleton(r,()=>new r(t(o(),this.app.config.get("translation",{}))))}}
|
|
3
|
-
export{n as Wa};
|
|
4
|
-
|
|
5
|
-
//# debugId=6E4CA963D0B0FD9364756E2164756E21
|
package/dist/chunk-f9ccncar.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
class Z extends Error{constructor(z){super(`Could not infer a database dialect from "${z}". Expected a URL starting with postgres://, postgresql://, mysql://, mariadb://, `+"sqlite://, or file: \u2014 or a SQLite path such as ./dev.db or :memory:.");this.name="UnknownDatabaseUrlError"}}class $ extends Error{constructor(z){super(z===void 0||z==="default"?"No database URL configured. Set the DATABASE_URL environment variable, or set `url` in app/config/database.ts.":`The "${z}" database connection has no \`url\`. Set one under \`connections.${z}\` in app/config/database.ts.`);this.name="MissingDatabaseUrlError"}}var x={"postgres:":"postgres","postgresql:":"postgres","mysql:":"mysql","mariadb:":"mariadb","sqlite:":"sqlite","file:":"sqlite"},H=[".db",".sqlite",".sqlite3"];function W(z){let B=z.trim();if(B==="")throw new Z(z);if(B===":memory:")return"sqlite";let G=B.indexOf(":");if(G!==-1){let K=B.slice(0,G+1).toLowerCase(),V=x[K];if(V)return V}if(P(B))return"sqlite";throw new Z(z)}function P(z){if(z.startsWith("./")||z.startsWith("../")||z.startsWith("/"))return!0;let B=z.toLowerCase();return H.some((G)=>B.endsWith(G))}function b(z){return z==="sqlite"}function y(z){return z==="mysql"||z==="mariadb"}var{SQL:X}=globalThis.Bun;var J="default";class j extends Error{constructor(z,B){super(`No database connection named "${z}". Configured: ${B.map((G)=>`"${G}"`).join(", ")}. Declare it under \`connections\` in app/config/database.ts.`);this.name="UnknownConnectionError"}}class M extends Error{constructor(z){super(`"${z}" is the name of the connection declared by the top-level \`url\` and \`options\`, so it cannot also appear under \`connections\`. Rename it, or move its settings up to the top level.`);this.name="ReservedConnectionNameError"}}class Q extends Error{open;requested;constructor(z,B){super(`A transaction is open on the "${z}" connection, and this statement names "${B}". A transaction cannot span two connections: the statement would run outside it and stay committed when the transaction rolls back. Move this query outside the transaction, or run the whole unit on one connection.`);this.open=z;this.requested=B;this.name="CrossConnectionTransactionError"}}class Y{name;config;sql;dialect;url;ready;constructor(z,B={}){this.name=z;this.config=B;let G=B.url;if(!G)throw new $(z);this.url=G,this.dialect=B.dialect??W(G),this.sql=B.options?new X(G,B.options):new X(G),this.ready=this.configure()}async configure(){if(this.dialect!=="sqlite")return;await this.sql.unsafe("pragma foreign_keys = ON")}get query(){return this.sql}async close(){this.ready.catch(()=>{}),await this.sql.close()}}class q{config;static token="database";name=J;pools=new Map;ready;constructor(z={}){this.config=z;let{connections:B={},...G}=z;this.pools.set(J,new Y(J,G));try{this.build(B,G.slowTransactionThreshold)}catch(K){for(let V of this.pools.values())V.ready.catch(()=>{}),V.close().catch(()=>{});throw K}this.ready=Promise.all([...this.pools.values()].map((K)=>K.ready)).then(()=>{return})}build(z,B){for(let[G,K]of Object.entries(z)){if(G===J)throw new M(G);this.pools.set(G,new Y(G,{slowTransactionThreshold:B,...K}))}}connection(z=J){if(z===J)return this;let B=this.pools.get(z);if(!B)throw new j(z,this.connectionNames);return B}get connectionNames(){return[...this.pools.keys()]}get sql(){return this.default.sql}get dialect(){return this.default.dialect}get url(){return this.default.url}get query(){return this.sql}async close(){this.ready.catch(()=>{}),await Promise.all([...this.pools.values()].map((z)=>z.close()))}get default(){return this.pools.get(J)}}function _(z){return z}function w(){return{url:process.env.DATABASE_URL,dialect:void 0,options:void 0,slowTransactionThreshold:R,connections:void 0}}var R=2000;
|
|
3
|
-
export{Z as wf,$ as xf,W as yf,b as zf,y as Af,J as Bf,j as Cf,M as Df,Q as Ef,Y as Ff,q as Gf,_ as Hf,w as If,R as Jf};
|
|
4
|
-
|
|
5
|
-
//# debugId=FF3653F64371C6CE64756E2164756E21
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../database/dialect.ts", "../database/Connection.ts", "../database/DatabaseManager.ts", "../database/config.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"// The SQL dialects Bun's `SQL` client can talk to. Bun infers the *connection*\n// from the URL protocol on its own, but it does not tell us which dialect it\n// picked — and gemi needs to know, because the SQL it generates differs per\n// dialect (`RETURNING` support, upsert syntax, autoincrement, boolean and\n// timestamp types). So we infer it a second time, here, for query generation.\nexport type Dialect = \"sqlite\" | \"postgres\" | \"mysql\" | \"mariadb\";\n\nexport class UnknownDatabaseUrlError extends Error {\n constructor(url: string) {\n super(\n `Could not infer a database dialect from \"${url}\". Expected a URL ` +\n `starting with postgres://, postgresql://, mysql://, mariadb://, ` +\n `sqlite://, or file: — or a SQLite path such as ./dev.db or :memory:.`,\n );\n this.name = \"UnknownDatabaseUrlError\";\n }\n}\n\nexport class MissingDatabaseUrlError extends Error {\n // The connection's name, when it is not the default one. A named connection\n // has no environment variable behind it and no top-level `url` to fall back\n // on, so the generic message would send whoever reads it to check\n // `DATABASE_URL`, which is set and is not what is missing.\n constructor(connection?: string) {\n super(\n connection === undefined || connection === \"default\"\n ? \"No database URL configured. Set the DATABASE_URL environment \" +\n \"variable, or set `url` in app/config/database.ts.\"\n : `The \"${connection}\" database connection has no \\`url\\`. Set one ` +\n `under \\`connections.${connection}\\` in app/config/database.ts.`,\n );\n this.name = \"MissingDatabaseUrlError\";\n }\n}\n\nconst PROTOCOLS: Record<string, Dialect> = {\n \"postgres:\": \"postgres\",\n \"postgresql:\": \"postgres\",\n \"mysql:\": \"mysql\",\n \"mariadb:\": \"mariadb\",\n \"sqlite:\": \"sqlite\",\n \"file:\": \"sqlite\",\n};\n\nconst SQLITE_FILE_EXTENSIONS = [\".db\", \".sqlite\", \".sqlite3\"];\n\n// Infer the dialect from a connection string. Accepts every form Bun's `SQL`\n// accepts, including the bare SQLite paths (`./dev.db`, `:memory:`) that have no\n// protocol at all.\n//\n// Note this deliberately does NOT default to postgres the way `new SQL(...)`\n// does. Guessing the dialect wrong means generating SQL that fails at runtime\n// against a database that connected fine, which is a far more confusing failure\n// than refusing to guess.\nexport function inferDialect(url: string): Dialect {\n const trimmed = url.trim();\n\n if (trimmed === \"\") {\n throw new UnknownDatabaseUrlError(url);\n }\n\n // `:memory:` is SQLite's in-memory database. It looks like a protocol to\n // `new URL()` but isn't one, so it has to be checked before parsing.\n if (trimmed === \":memory:\") {\n return \"sqlite\";\n }\n\n const separator = trimmed.indexOf(\":\");\n if (separator !== -1) {\n const protocol = trimmed.slice(0, separator + 1).toLowerCase();\n const dialect = PROTOCOLS[protocol];\n if (dialect) {\n return dialect;\n }\n }\n\n // No recognised protocol. Bun treats a bare path as a SQLite file, so we do\n // too — but only when it actually looks like one, rather than treating every\n // unrecognised string as SQLite.\n if (looksLikeSqlitePath(trimmed)) {\n return \"sqlite\";\n }\n\n throw new UnknownDatabaseUrlError(url);\n}\n\nfunction looksLikeSqlitePath(value: string): boolean {\n if (value.startsWith(\"./\") || value.startsWith(\"../\") || value.startsWith(\"/\")) {\n return true;\n }\n const lower = value.toLowerCase();\n return SQLITE_FILE_EXTENSIONS.some((extension) => lower.endsWith(extension));\n}\n\n// True when the dialect stores a SQLite database, i.e. a local file rather than\n// a networked server. Callers use this to decide whether `db:setup` should\n// create a file, and which DDL flavour to emit.\nexport function isSqlite(dialect: Dialect): boolean {\n return dialect === \"sqlite\";\n}\n\n// MariaDB is wire-compatible with MySQL and takes the same SQL in everything\n// gemi generates, so query builders collapse the two.\nexport function isMysqlFamily(dialect: Dialect): boolean {\n return dialect === \"mysql\" || dialect === \"mariadb\";\n}\n",
|
|
6
|
-
"import { SQL } from \"bun\";\nimport type { ConnectionConfig } from \"./config\";\nimport { MissingDatabaseUrlError, inferDialect, type Dialect } from \"./dialect\";\n\n/**\n * The name of the connection an application gets without asking for one: the\n * `url` / `options` pair at the top level of `app/config/database.ts`.\n *\n * A constant rather than the string spelled at each site, because it is\n * compared in five places across three layers — the manager resolving a name,\n * the ORM deciding whether a query names a different pool than the open\n * transaction, and the facade — and a typo in any one of them reads as \"that\n * connection is not configured\" rather than as a typo.\n */\nexport const DEFAULT_CONNECTION = \"default\";\n\n/**\n * What every layer above `database/` is allowed to know about a connection.\n *\n * `DatabaseManager` implements this itself and *is* the default connection —\n * see the note on `DatabaseManager.connection`. So this interface is the one\n * shape the ORM and the `DB` facade read, whether they are looking at the\n * default pool or at a named one, and neither has to branch on which it got.\n */\nexport interface DatabaseConnection {\n /** `\"default\"`, or the key this connection was declared under. */\n readonly name: string;\n readonly url: string;\n readonly dialect: Dialect;\n readonly sql: SQL;\n readonly ready: Promise<void>;\n readonly config: ConnectionConfig;\n}\n\n/** A connection named in the config that the manager has no pool for. */\nexport class UnknownConnectionError extends Error {\n constructor(name: string, known: readonly string[]) {\n super(\n `No database connection named \"${name}\". Configured: ` +\n `${known.map((one) => `\"${one}\"`).join(\", \")}. Declare it under ` +\n `\\`connections\\` in app/config/database.ts.`,\n );\n this.name = \"UnknownConnectionError\";\n }\n}\n\n/**\n * A `connections` entry that would shadow the top-level `url`.\n *\n * Refused rather than merged, because the two spellings would be a silent\n * either/or: whichever the manager happened to build last would win, and the\n * losing half of the config would go on describing a pool nothing uses.\n */\nexport class ReservedConnectionNameError extends Error {\n constructor(name: string) {\n super(\n `\"${name}\" is the name of the connection declared by the top-level ` +\n `\\`url\\` and \\`options\\`, so it cannot also appear under ` +\n `\\`connections\\`. Rename it, or move its settings up to the top level.`,\n );\n this.name = \"ReservedConnectionNameError\";\n }\n}\n\n/**\n * A statement that named one connection while a transaction was open on\n * another.\n *\n * **The whole reason named connections refuse rather than route.** A\n * transaction lives on one reserved connection of one pool; there is no\n * mechanism by which a second pool's statement could join it, and no rollback\n * that could take it back. So the alternatives to this error are both worse\n * than an error:\n *\n * - Run it on the other pool anyway, *outside* the transaction. The caller\n * wrote `Model.transaction`, the block rolls back, and that one statement\n * stays committed. Half the work landed and nothing said so.\n * - Run it on the open handle, ignoring the name. Then the statement went to\n * the wrong database, which the ORM cannot even detect afterwards — the\n * tables are usually the same shape.\n *\n * There is no third answer at this layer; two-phase commit is not what a second\n * pool for analytics is asking for. So the failure is made loud and early, at\n * the call that would have straddled the two, and the fix is always the same\n * shape: move that query outside the transaction, or do the whole unit on one\n * connection.\n */\nexport class CrossConnectionTransactionError extends Error {\n constructor(\n /** The connection the open transaction belongs to. */\n public readonly open: string,\n /** The connection the refused statement named. */\n public readonly requested: string,\n ) {\n super(\n `A transaction is open on the \"${open}\" connection, and this statement ` +\n `names \"${requested}\". A transaction cannot span two connections: ` +\n `the statement would run outside it and stay committed when the ` +\n `transaction rolls back. Move this query outside the transaction, or ` +\n `run the whole unit on one connection.`,\n );\n this.name = \"CrossConnectionTransactionError\";\n }\n}\n\n/**\n * One pool: a URL, its dialect, and Bun's client for it.\n *\n * Extracted from `DatabaseManager` when a second connection became\n * configurable (#327). The manager kept the lifecycle — which names exist, how\n * they are resolved, closing them all — and this kept everything that is true\n * of a connection *one at a time*, so the two do not have to be written twice.\n *\n * Safe to build eagerly, like the manager it came from: Bun's client connects\n * on the first query, not at construction. A named connection an application\n * declares and never queries therefore costs an object.\n */\nexport class Connection implements DatabaseConnection {\n public readonly sql: SQL;\n public readonly dialect: Dialect;\n public readonly url: string;\n\n /**\n * Resolves once the connection has been configured, or rejects if it could\n * not be. Only SQLite has anything to do; elsewhere it is already resolved.\n *\n * Exposed so a caller that needs the guarantee can wait for it. Nothing has\n * to: SQLite queues statements on one connection in the order they were\n * issued, so the pragma below is ahead of anything a caller sends after the\n * constructor returns. That ordering is asserted in `DatabaseManager.test.ts`\n * rather than assumed, because it is the load-bearing half.\n */\n public readonly ready: Promise<void>;\n\n constructor(\n public readonly name: string,\n public readonly config: ConnectionConfig = {},\n ) {\n const url = config.url;\n if (!url) {\n throw new MissingDatabaseUrlError(name);\n }\n\n this.url = url;\n // An explicit `dialect` wins, for URLs whose protocol we can't read (a\n // pooler on a custom scheme). Otherwise infer, which throws rather than\n // guessing — see the note in dialect.ts.\n this.dialect = config.dialect ?? inferDialect(url);\n this.sql = config.options\n ? new SQL(url, config.options as any)\n : new SQL(url);\n this.ready = this.configure();\n }\n\n /**\n * `pragma foreign_keys = ON`, which SQLite leaves **off** by default — and so\n * does Bun's driver, which reports `0` on a fresh connection.\n *\n * Without it SQLite enforces nothing at all. Not \"cascades do not fire\":\n * nothing. An insert naming a parent that does not exist is accepted, a\n * dangling reference survives the parent's deletion, and `ON DELETE RESTRICT`\n * does not restrict — while the migrations declare all three. Postgres\n * enforces them always, and Prisma turns the pragma on for every SQLite\n * connection it opens, so leaving it off meant development and production\n * disagreed about whether the schema's constraints were real.\n *\n * It is also why this is more than a dialect gap. The differential harness\n * compares gemi against Prisma on one database per dialect; with the pragma\n * off on one side, the two were being asked to agree while running under\n * different integrity rules, so an entire class of divergence was invisible\n * to the instrument rather than merely untested.\n *\n * **Per connection, not per database**, which is what makes this a live\n * assumption rather than a one-line fix: Bun serves SQLite from a single\n * connection today, so setting it once holds for every later statement. If\n * that ever becomes a pool, one statement's worth of enforcement would move\n * to whichever connection happened to serve it. `DatabaseManager.test.ts`\n * pins both halves — the value, and that it is the same across concurrent\n * queries — so the day it changes is a failing test rather than a silent\n * regression.\n *\n * That per-connection wording is now literal in a second sense: a named\n * SQLite connection is a *different* Bun client, so it needs the pragma of\n * its own. Running it from this constructor is what makes that automatic —\n * the alternative, doing it once for the default connection, was correct\n * exactly while there was only one.\n *\n * Issued outside any transaction. SQLite documents the pragma as a no-op\n * inside one, so a lazy \"set it on first use\" would be correct exactly until\n * the first use happened to be a transaction.\n */\n private async configure(): Promise<void> {\n if (this.dialect !== \"sqlite\") return;\n await this.sql.unsafe(\"pragma foreign_keys = ON\");\n }\n\n // Escape hatch matching Bun's own API, so `connection.query` reads like `sql`\n // does in Bun's docs: connection.query`select * from users where id = ${id}`\n get query(): SQL {\n return this.sql;\n }\n\n async close(): Promise<void> {\n // A close that races the constructor's `pragma` leaves that statement to\n // settle against a client that is going away, and it settles as a rejection\n // — `ERR_SQLITE_CONNECTION_CLOSED`, from a promise nobody is holding, which\n // arrives as an unhandled rejection naming neither the close nor the\n // pragma. The caller asked for this connection to go away, so that\n // rejection is expected rather than something to surface. Marked handled\n // here rather than suppressed globally, and only on the way out.\n this.ready.catch(() => {});\n await this.sql.close();\n }\n}\n",
|
|
7
|
-
"import type { SQL } from \"bun\";\nimport type { ConnectionConfig, DatabaseConfig } from \"./config\";\nimport {\n Connection,\n DEFAULT_CONNECTION,\n ReservedConnectionNameError,\n UnknownConnectionError,\n type DatabaseConnection,\n} from \"./Connection\";\nimport type { Dialect } from \"./dialect\";\n\n// Wraps Bun's `SQL` client. Bun ships one client that speaks SQLite, Postgres,\n// MySQL and MariaDB, so gemi does not need a driver per database — it needs to\n// know *which* one is in use, which is what `dialect` carries.\n//\n// Safe to build eagerly: Bun's client connects on the first query, not at\n// construction. (`RedisManager` used to be cited here as the parallel case. As\n// of #403 it builds its client in a memoizing getter instead — not because\n// eager construction was unsafe, but because naming Bun's `RedisClient` at\n// module scope is what made `gemi/services` unloadable off Bun. `Connection`\n// still imports `SQL` as a value for the same reason, which is the remaining\n// half of #396.) It is still bound as a lazy singleton,\n// so an app that never touches the database never resolves it and never has to\n// have DATABASE_URL set.\n//\n// Since #327 it holds *connections*, plural: the top-level `url` and `options`\n// build the one called `\"default\"`, and each key under `connections` builds\n// another. What it does not do is decide which one a query uses — that is the\n// ORM's ambient scope and the `DB` facade, because the choice is per query\n// rather than per application. See `connection` below.\nexport class DatabaseManager implements DatabaseConnection {\n static token = \"database\";\n\n /**\n * This object *is* the default connection, so it answers to the name.\n *\n * Not a formality: `connection(\"default\")` returns `this` rather than the\n * `Connection` in the map, which is what keeps every existing reader —\n * `DB.sql`, `db.dialect`, and the test harnesses that wrap the manager in a\n * Proxy to count statements — looking at the same object the ORM executes\n * through. A second object for the default pool would have quietly bypassed\n * all of them while every test still passed.\n */\n public readonly name = DEFAULT_CONNECTION;\n\n /**\n * Every pool this manager owns, keyed by name and including the default one.\n *\n * Private because the map is the manager's bookkeeping — `connection()` is\n * the way in, and it is the only path that knows the default is `this`.\n */\n private readonly pools = new Map<string, Connection>();\n\n /**\n * Resolves once **every** connection has been configured, or rejects if one\n * could not be. Only SQLite has anything to do; elsewhere it is already\n * resolved.\n *\n * All of them rather than the default alone, because the thing a caller waits\n * on this for — SQLite's `pragma foreign_keys` — is per client, so a second\n * SQLite connection has its own and a caller awaiting one manager-level\n * promise means all of them.\n */\n public readonly ready: Promise<void>;\n\n constructor(public config: DatabaseConfig = {}) {\n const { connections = {}, ...primary } = config;\n\n // The default first, so a `MissingDatabaseUrlError` from a missing\n // `DATABASE_URL` still comes out of construction the way it always has,\n // rather than after a named connection has already opened a client.\n this.pools.set(\n DEFAULT_CONNECTION,\n new Connection(DEFAULT_CONNECTION, primary),\n );\n\n // A connection that is built before the one whose config is wrong is still\n // a live client with an open handle, and on the throwing path nothing else\n // will ever hold it: the manager never becomes a value, so nobody can call\n // `close`. Left alone, the pragma this constructor issues for a SQLite\n // connection settles against a client being torn down and surfaces as an\n // unhandled rejection with no configuration error anywhere near it.\n try {\n this.build(connections, primary.slowTransactionThreshold);\n } catch (error) {\n for (const pool of this.pools.values()) {\n // The in-flight configuration first: it is what rejects when the client\n // under it goes away, and this is the only place that can say the\n // rejection was expected.\n pool.ready.catch(() => {});\n pool.close().catch(() => {});\n }\n throw error;\n }\n\n // Built once here rather than derived per read, so that a connection whose\n // configuration rejects produces one unhandled rejection at most instead of\n // a fresh one per access.\n this.ready = Promise.all(\n [...this.pools.values()].map((pool) => pool.ready),\n ).then(() => undefined);\n }\n\n private build(\n connections: Record<string, ConnectionConfig>,\n slowTransactionThreshold: number | false | undefined,\n ): void {\n for (const [name, connection] of Object.entries(connections)) {\n if (name === DEFAULT_CONNECTION)\n throw new ReservedConnectionNameError(name);\n\n this.pools.set(\n name,\n new Connection(name, {\n // The threshold is the one setting a named connection is likely to\n // want *unchanged*: it is a development diagnostic about holding a\n // pooled connection, and that concern does not stop applying because\n // the pool has a name. `url`, `options` and `dialect` are deliberately\n // not inherited — a connection that borrowed the default's URL by\n // omission would be a second pool onto the same database created by a\n // typo in a key.\n slowTransactionThreshold,\n ...connection,\n }),\n );\n }\n }\n\n /**\n * The connection called `name`, or the default one when called with nothing.\n *\n * Throws rather than falling back to the default for an unknown name, and\n * that is the important half. A fallback would make `Model.on(\"analitycs\")`\n * run on the hot path — the exact pool the caller was trying to stay off —\n * and the only symptom would be the incident it was meant to prevent,\n * arriving weeks later with nothing pointing back at the typo.\n */\n connection(name: string = DEFAULT_CONNECTION): DatabaseConnection {\n // `this`, not `pools.get(DEFAULT_CONNECTION)` — see `name` above.\n if (name === DEFAULT_CONNECTION) return this;\n\n const found = this.pools.get(name);\n if (!found) throw new UnknownConnectionError(name, this.connectionNames);\n return found;\n }\n\n /** Every configured name, default first. For error messages and diagnostics. */\n get connectionNames(): string[] {\n return [...this.pools.keys()];\n }\n\n /**\n * The default connection's client. Unchanged in meaning: an application that\n * never names a connection sees exactly what it saw before #327.\n */\n get sql(): SQL {\n return this.default.sql;\n }\n\n get dialect(): Dialect {\n return this.default.dialect;\n }\n\n get url(): string {\n return this.default.url;\n }\n\n // Escape hatch matching Bun's own API, so `db.query` reads like `sql` does in\n // Bun's docs: db.query`select * from users where id = ${id}`\n get query(): SQL {\n return this.sql;\n }\n\n /** Closes every connection, not only the default one. */\n async close(): Promise<void> {\n // The aggregate promise needs the same treatment each connection's own\n // `ready` gets in `Connection.close` — it is derived from them, so a\n // rejection there arrives here as a second, separately unhandled one.\n this.ready.catch(() => {});\n await Promise.all([...this.pools.values()].map((pool) => pool.close()));\n }\n\n private get default(): Connection {\n return this.pools.get(DEFAULT_CONNECTION)!;\n }\n}\n",
|
|
8
|
-
"import type { SQL } from \"bun\";\nimport type { Dialect } from \"./dialect\";\n\n// One connection: a URL, the dialect to compile for, and the pool behind it.\n//\n// Split out of `DatabaseConfig` when a second connection became configurable\n// (#327), so that a named connection is described by exactly the same fields\n// the default one is — rather than by a smaller, second-class shape that would\n// need widening the first time somebody's analytics pool needed a `dialect`\n// override or a threshold of its own.\nexport interface ConnectionConfig {\n // Connection string. Defaults to the `DATABASE_URL` environment variable.\n // The dialect is inferred from it — `postgres://`, `mysql://`, `mariadb://`,\n // `sqlite://`, `file:`, or a SQLite path like `./dev.db` or `:memory:`.\n url?: string;\n\n // Override the inferred dialect. Only needed when the URL doesn't carry a\n // recognisable protocol — a proxy or connection pooler fronting Postgres on a\n // custom scheme, say. Wrong values here produce SQL that fails at runtime\n // against a database that connected fine, so leave it unset unless inference\n // actually gets it wrong.\n dialect?: Dialect;\n\n // Options passed straight through to Bun's `SQL` client (pool size, timeouts,\n // TLS, ...). See https://bun.sh/docs/api/sql.\n options?: Record<string, unknown>;\n\n // How long a transaction may run, in milliseconds, before development warns\n // that it is still holding a pooled connection. `false` turns the warning off.\n //\n // A diagnostic, not a limit: nothing here cancels or shortens a transaction.\n // It only fires in development — the cost of a long transaction is paid by\n // unrelated queries blocking on connection acquisition, and that is a problem\n // worth catching while the callback is still in front of you.\n //\n // Raise it for a seed script or a data migration whose transactions are\n // legitimately long; `false` if the noise is not worth it at all. A value\n // that is not a positive finite number falls back to the 2s default rather\n // than disabling, so the warning cannot be lost to a typo — say `false` when\n // you mean off.\n //\n // Per connection, and this is the field most likely to differ between two of\n // them: a connection that exists *because* its queries are slow will warn on\n // every transaction it opens if it inherits the hot path's threshold, and a\n // warning that always fires is one nobody reads. A named connection that\n // does not set it inherits the top-level value.\n slowTransactionThreshold?: number | false;\n}\n\n// Config key: `database`.\n//\n// The top-level `url` / `options` / `dialect` describe the connection called\n// `\"default\"` — the one every query uses unless it says otherwise. `connections`\n// declares the others.\nexport interface DatabaseConfig extends ConnectionConfig {\n // Additional connections, keyed by the name `DB.connection(name)` and\n // `Model.on(name)` take.\n //\n // The case this exists for is two pools against **one** database with\n // opposite workloads — a hot path that must never block, and an analytics\n // path whose queries legitimately run for seconds:\n //\n // export default defineDatabaseConfig({\n // url: process.env.DATABASE_URL,\n // options: { max: 12 },\n //\n // connections: {\n // analytics: {\n // url: process.env.DATABASE_URL,\n // options: { max: 3, idleTimeout: 60, connectionTimeout: 45 },\n // slowTransactionThreshold: 60_000,\n // },\n // },\n // })\n //\n // A value that protects one of those is the wrong value for the other, which\n // is the entire reason they cannot be one pool with one setting. The same URL\n // twice is normal here and is not a mistake: what differs is the pool, not\n // the database.\n //\n // Two consequences worth knowing before declaring one, both of them\n // structural rather than incidental:\n //\n // - **A transaction cannot span two connections.** A statement that names one\n // while a transaction is open on another raises\n // `CrossConnectionTransactionError` rather than quietly running outside the\n // transaction.\n // - **Every connection is a real pool**, counted separately against whatever\n // connection cap the server or the pooler enforces. Two pools of 12 is 24\n // connections, not 12.\n connections?: Record<string, ConnectionConfig>;\n}\n\nexport function defineDatabaseConfig(config: DatabaseConfig): DatabaseConfig {\n return config;\n}\n\nexport function databaseConfigDefaults(): DatabaseConfig {\n return {\n url: process.env.DATABASE_URL,\n dialect: undefined,\n options: undefined,\n slowTransactionThreshold: SLOW_TRANSACTION_THRESHOLD,\n connections: undefined,\n };\n}\n\n// The default warning threshold, in milliseconds. Exported so the ORM can fall\n// back to the same number when a `DatabaseManager` was built without going\n// through `withDefaults` — a test constructing one directly, say — rather than\n// keeping a second copy of it that can drift.\nexport const SLOW_TRANSACTION_THRESHOLD = 2_000;\n\nexport type { SQL };\n"
|
|
9
|
-
],
|
|
10
|
-
"mappings": ";AAOO,MAAM,UAAgC,KAAM,CACjD,WAAW,CAAC,EAAa,CACvB,MACE,4CAA4C,sFAE1C,2EACJ,EACA,KAAK,KAAO,0BAEhB,CAEO,MAAM,UAAgC,KAAM,CAKjD,WAAW,CAAC,EAAqB,CAC/B,MACE,IAAe,QAAa,IAAe,UACvC,iHAEA,QAAQ,sEACiB,gCAC/B,EACA,KAAK,KAAO,0BAEhB,CAEA,IAAM,EAAqC,CACzC,YAAa,WACb,cAAe,WACf,SAAU,QACV,WAAY,UACZ,UAAW,SACX,QAAS,QACX,EAEM,EAAyB,CAAC,MAAO,UAAW,UAAU,EAUrD,SAAS,CAAY,CAAC,EAAsB,CACjD,IAAM,EAAU,EAAI,KAAK,EAEzB,GAAI,IAAY,GACd,MAAM,IAAI,EAAwB,CAAG,EAKvC,GAAI,IAAY,WACd,MAAO,SAGT,IAAM,EAAY,EAAQ,QAAQ,GAAG,EACrC,GAAI,IAAc,GAAI,CACpB,IAAM,EAAW,EAAQ,MAAM,EAAG,EAAY,CAAC,EAAE,YAAY,EACvD,EAAU,EAAU,GAC1B,GAAI,EACF,OAAO,EAOX,GAAI,EAAoB,CAAO,EAC7B,MAAO,SAGT,MAAM,IAAI,EAAwB,CAAG,EAGvC,SAAS,CAAmB,CAAC,EAAwB,CACnD,GAAI,EAAM,WAAW,IAAI,GAAK,EAAM,WAAW,KAAK,GAAK,EAAM,WAAW,GAAG,EAC3E,MAAO,GAET,IAAM,EAAQ,EAAM,YAAY,EAChC,OAAO,EAAuB,KAAK,CAAC,IAAc,EAAM,SAAS,CAAS,CAAC,EAMtE,SAAS,CAAQ,CAAC,EAA2B,CAClD,OAAO,IAAY,SAKd,SAAS,CAAa,CAAC,EAA2B,CACvD,OAAO,IAAY,SAAW,IAAY,UCxG5C,0BAcO,IAAM,EAAqB,UAqB3B,MAAM,UAA+B,KAAM,CAChD,WAAW,CAAC,EAAc,EAA0B,CAClD,MACE,iCAAiC,mBAC5B,EAAM,IAAI,CAAC,IAAQ,IAAI,IAAM,EAAE,KAAK,IAAI,gEAE/C,EACA,KAAK,KAAO,yBAEhB,CASO,MAAM,UAAoC,KAAM,CACrD,WAAW,CAAC,EAAc,CACxB,MACE,IAAI,0LAGN,EACA,KAAK,KAAO,8BAEhB,CAyBO,MAAM,UAAwC,KAAM,CAGvC,KAEA,UAJlB,WAAW,CAEO,EAEA,EAChB,CACA,MACE,iCAAiC,4CACrB,yNAId,EAVgB,YAEA,iBAShB,KAAK,KAAO,kCAEhB,CAcO,MAAM,CAAyC,CAkBlC,KACA,OAlBF,IACA,QACA,IAYA,MAEhB,WAAW,CACO,EACA,EAA2B,CAAC,EAC5C,CAFgB,YACA,cAEhB,IAAM,EAAM,EAAO,IACnB,GAAI,CAAC,EACH,MAAM,IAAI,EAAwB,CAAI,EAGxC,KAAK,IAAM,EAIX,KAAK,QAAU,EAAO,SAAW,EAAa,CAAG,EACjD,KAAK,IAAM,EAAO,QACd,IAAI,EAAI,EAAK,EAAO,OAAc,EAClC,IAAI,EAAI,CAAG,EACf,KAAK,MAAQ,KAAK,UAAU,OAwChB,UAAS,EAAkB,CACvC,GAAI,KAAK,UAAY,SAAU,OAC/B,MAAM,KAAK,IAAI,OAAO,0BAA0B,KAK9C,MAAK,EAAQ,CACf,OAAO,KAAK,SAGR,MAAK,EAAkB,CAQ3B,KAAK,MAAM,MAAM,IAAM,EAAE,EACzB,MAAM,KAAK,IAAI,MAAM,EAEzB,CCvLO,MAAM,CAA8C,CAmCtC,aAlCZ,OAAQ,WAYC,KAAO,EAQN,MAAQ,IAAI,IAYb,MAEhB,WAAW,CAAQ,EAAyB,CAAC,EAAG,CAA7B,cACjB,IAAQ,cAAc,CAAC,KAAM,GAAY,EAKzC,KAAK,MAAM,IACT,EACA,IAAI,EAAW,EAAoB,CAAO,CAC5C,EAQA,GAAI,CACF,KAAK,MAAM,EAAa,EAAQ,wBAAwB,EACxD,MAAO,EAAO,CACd,QAAW,KAAQ,KAAK,MAAM,OAAO,EAInC,EAAK,MAAM,MAAM,IAAM,EAAE,EACzB,EAAK,MAAM,EAAE,MAAM,IAAM,EAAE,EAE7B,MAAM,EAMR,KAAK,MAAQ,QAAQ,IACnB,CAAC,GAAG,KAAK,MAAM,OAAO,CAAC,EAAE,IAAI,CAAC,IAAS,EAAK,KAAK,CACnD,EAAE,KAAK,IAAG,CAAG,OAAS,EAGhB,KAAK,CACX,EACA,EACM,CACN,QAAY,EAAM,KAAe,OAAO,QAAQ,CAAW,EAAG,CAC5D,GAAI,IAAS,EACX,MAAM,IAAI,EAA4B,CAAI,EAE5C,KAAK,MAAM,IACT,EACA,IAAI,EAAW,EAAM,CAQnB,8BACG,CACL,CAAC,CACH,GAaJ,UAAU,CAAC,EAAe,EAAwC,CAEhE,GAAI,IAAS,EAAoB,OAAO,KAExC,IAAM,EAAQ,KAAK,MAAM,IAAI,CAAI,EACjC,GAAI,CAAC,EAAO,MAAM,IAAI,EAAuB,EAAM,KAAK,eAAe,EACvE,OAAO,KAIL,gBAAe,EAAa,CAC9B,MAAO,CAAC,GAAG,KAAK,MAAM,KAAK,CAAC,KAO1B,IAAG,EAAQ,CACb,OAAO,KAAK,QAAQ,OAGlB,QAAO,EAAY,CACrB,OAAO,KAAK,QAAQ,WAGlB,IAAG,EAAW,CAChB,OAAO,KAAK,QAAQ,OAKlB,MAAK,EAAQ,CACf,OAAO,KAAK,SAIR,MAAK,EAAkB,CAI3B,KAAK,MAAM,MAAM,IAAM,EAAE,EACzB,MAAM,QAAQ,IAAI,CAAC,GAAG,KAAK,MAAM,OAAO,CAAC,EAAE,IAAI,CAAC,IAAS,EAAK,MAAM,CAAC,CAAC,KAG5D,QAAO,EAAe,CAChC,OAAO,KAAK,MAAM,IAAI,CAAkB,EAE5C,CC5FO,SAAS,CAAoB,CAAC,EAAwC,CAC3E,OAAO,EAGF,SAAS,CAAsB,EAAmB,CACvD,MAAO,CACL,IAAK,QAAQ,IAAI,aACjB,QAAS,OACT,QAAS,OACT,yBAA0B,EAC1B,YAAa,MACf,EAOK,IAAM,EAA6B",
|
|
11
|
-
"debugId": "FF3653F64371C6CE64756E2164756E21",
|
|
12
|
-
"names": []
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.test-d.d.ts","sourceRoot":"","sources":["../../client/useDictionary.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"builder.test-d.d.ts","sourceRoot":"","sources":["../../console/builder.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApiRouter.test-d.d.ts","sourceRoot":"","sources":["../../http/ApiRouter.test-d.ts"],"names":[],"mappings":""}
|