From 0d3d93c27635ffa1975acf89b04227386095d02a Mon Sep 17 00:00:00 2001 From: subframe7536 Date: Tue, 6 Jun 2023 09:01:43 +0000 Subject: [PATCH] deploy: 75274b77b3680c0de5d4ca7b4073ce82e0267a69 --- .../{index-a60bf07e.js => index-c9ae33ff.js} | 20 +++++++++---------- ...72c1.js => officialWasmWorker-b264d8ca.js} | 2 +- ...er-eaa67eb7.js => sqljsWorker-342e964b.js} | 2 +- ...{worker-cda8cefb.js => worker-72ad2512.js} | 4 ++-- index.html | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) rename assets/{index-a60bf07e.js => index-c9ae33ff.js} (60%) rename assets/{officialWasmWorker-94e472c1.js => officialWasmWorker-b264d8ca.js} (96%) rename assets/{sqljsWorker-eaa67eb7.js => sqljsWorker-342e964b.js} (89%) rename assets/{worker-cda8cefb.js => worker-72ad2512.js} (83%) diff --git a/assets/index-a60bf07e.js b/assets/index-c9ae33ff.js similarity index 60% rename from assets/index-a60bf07e.js rename to assets/index-c9ae33ff.js index b64b4d7..1a3aea8 100644 --- a/assets/index-a60bf07e.js +++ b/assets/index-c9ae33ff.js @@ -1,15 +1,15 @@ -var Om=Object.defineProperty;var Wm=(t,e,n)=>e in t?Om(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Yt=(t,e,n)=>(Wm(t,typeof e!="symbol"?e+"":e,n),n),Tl=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var r=(t,e,n)=>(Tl(t,e,"read from private field"),n?n.call(t):e.get(t)),k=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},P=(t,e,n,i)=>(Tl(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n);var Oe=(t,e,n)=>(Tl(t,e,"access private method"),n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const m of l.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&i(m)}).observe(document,{childList:!0,subtree:!0});function n(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function i(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();function bf(t,e){const n=Object.create(null),i=t.split(",");for(let a=0;a!!n[a.toLowerCase()]:a=>!!n[a]}function Nf(t){if(Ie(t)){const e={};for(let n=0;n{if(n){const i=n.split(Am);i.length>1&&(e[i[0].trim()]=i[1].trim())}}),e}function vf(t){let e="";if(Lt(t))e=t;else if(Ie(t))for(let n=0;nLt(t)?t:t==null?"":Ie(t)||yt(t)&&(t.toString===Ed||!ke(t.toString))?JSON.stringify(t,vd,2):String(t),vd=(t,e)=>e&&e.__v_isRef?vd(t,e.value):eo(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((n,[i,a])=>(n[`${i} =>`]=a,n),{})}:_d(e)?{[`Set(${e.size})`]:[...e.values()]}:yt(e)&&!Ie(e)&&!Cd(e)?String(e):e,lt={},Zs=[],mr=()=>{},Lm=()=>!1,Pm=/^on[^a-z]/,sl=t=>Pm.test(t),_f=t=>t.startsWith("onUpdate:"),on=Object.assign,xf=(t,e)=>{const n=t.indexOf(e);n>-1&&t.splice(n,1)},Mm=Object.prototype.hasOwnProperty,Be=(t,e)=>Mm.call(t,e),Ie=Array.isArray,eo=t=>ol(t)==="[object Map]",_d=t=>ol(t)==="[object Set]",ke=t=>typeof t=="function",Lt=t=>typeof t=="string",Ef=t=>typeof t=="symbol",yt=t=>t!==null&&typeof t=="object",xd=t=>yt(t)&&ke(t.then)&&ke(t.catch),Ed=Object.prototype.toString,ol=t=>Ed.call(t),Bm=t=>ol(t).slice(8,-1),Cd=t=>ol(t)==="[object Object]",Cf=t=>Lt(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,Ju=bf(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),al=t=>{const e=Object.create(null);return n=>e[n]||(e[n]=t(n))},Fm=/-(\w)/g,Ro=al(t=>t.replace(Fm,(e,n)=>n?n.toUpperCase():"")),Um=/\B([A-Z])/g,Qo=al(t=>t.replace(Um,"-$1").toLowerCase()),qd=al(t=>t.charAt(0).toUpperCase()+t.slice(1)),kl=al(t=>t?`on${qd(t)}`:""),Ia=(t,e)=>!Object.is(t,e),Sl=(t,e)=>{for(let n=0;n{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})},$m=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let rh;const Qm=()=>rh||(rh=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});let er;class jm{constructor(e=!1){this.detached=e,this._active=!0,this.effects=[],this.cleanups=[],this.parent=er,!e&&er&&(this.index=(er.scopes||(er.scopes=[])).push(this)-1)}get active(){return this._active}run(e){if(this._active){const n=er;try{return er=this,e()}finally{er=n}}}on(){er=this}off(){er=this.parent}stop(e){if(this._active){let n,i;for(n=0,i=this.effects.length;n{const e=new Set(t);return e.w=0,e.n=0,e},Od=t=>(t.w&_i)>0,Wd=t=>(t.n&_i)>0,zm=({deps:t})=>{if(t.length)for(let e=0;e{const{deps:e}=t;if(e.length){let n=0;for(let i=0;i{(I==="length"||I>=v)&&g.push(d)})}else switch(n!==void 0&&g.push(m.get(n)),e){case"add":Ie(t)?Cf(n)&&g.push(m.get("length")):(g.push(m.get(vs)),eo(t)&&g.push(m.get(Vl)));break;case"delete":Ie(t)||(g.push(m.get(vs)),eo(t)&&g.push(m.get(Vl)));break;case"set":eo(t)&&g.push(m.get(vs));break}if(g.length===1)g[0]&&zl(g[0]);else{const v=[];for(const d of g)d&&v.push(...d);zl(qf(v))}}function zl(t,e){const n=Ie(t)?t:[...t];for(const i of n)i.computed&&sh(i);for(const i of n)i.computed||sh(i)}function sh(t,e){(t!==fr||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const Jm=bf("__proto__,__v_isRef,__isVue"),Td=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(Ef)),Gm=Wf(),Xm=Wf(!1,!0),Ym=Wf(!0),oh=Zm();function Zm(){const t={};return["includes","indexOf","lastIndexOf"].forEach(e=>{t[e]=function(...n){const i=Fe(this);for(let l=0,m=this.length;l{t[e]=function(...n){jo();const i=Fe(this)[e].apply(this,n);return Ho(),i}}),t}function ey(t){const e=Fe(this);return xn(e,"has",t),e.hasOwnProperty(t)}function Wf(t=!1,e=!1){return function(i,a,l){if(a==="__v_isReactive")return!t;if(a==="__v_isReadonly")return t;if(a==="__v_isShallow")return e;if(a==="__v_raw"&&l===(t?e?yy:Ld:e?Dd:Rd).get(i))return i;const m=Ie(i);if(!t){if(m&&Be(oh,a))return Reflect.get(oh,a,l);if(a==="hasOwnProperty")return ey}const g=Reflect.get(i,a,l);return(Ef(a)?Td.has(a):Jm(a))||(t||xn(i,"get",a),e)?g:rn(g)?m&&Cf(a)?g:g.value:yt(g)?t?Pd(g):Tf(g):g}}const ty=kd(),ny=kd(!0);function kd(t=!1){return function(n,i,a,l){let m=n[i];if(Do(m)&&rn(m)&&!rn(a))return!1;if(!t&&(!ac(a)&&!Do(a)&&(m=Fe(m),a=Fe(a)),!Ie(n)&&rn(m)&&!rn(a)))return m.value=a,!0;const g=Ie(n)&&Cf(i)?Number(i)t,ul=t=>Reflect.getPrototypeOf(t);function Bu(t,e,n=!1,i=!1){t=t.__v_raw;const a=Fe(t),l=Fe(e);n||(e!==l&&xn(a,"get",e),xn(a,"get",l));const{has:m}=ul(a),g=i?If:n?Sf:Aa;if(m.call(a,e))return g(t.get(e));if(m.call(a,l))return g(t.get(l));t!==a&&t.get(e)}function Fu(t,e=!1){const n=this.__v_raw,i=Fe(n),a=Fe(t);return e||(t!==a&&xn(i,"has",t),xn(i,"has",a)),t===a?n.has(t):n.has(t)||n.has(a)}function Uu(t,e=!1){return t=t.__v_raw,!e&&xn(Fe(t),"iterate",vs),Reflect.get(t,"size",t)}function ah(t){t=Fe(t);const e=Fe(this);return ul(e).has.call(e,t)||(e.add(t),Hr(e,"add",t,t)),this}function uh(t,e){e=Fe(e);const n=Fe(this),{has:i,get:a}=ul(n);let l=i.call(n,t);l||(t=Fe(t),l=i.call(n,t));const m=a.call(n,t);return n.set(t,e),l?Ia(e,m)&&Hr(n,"set",t,e):Hr(n,"add",t,e),this}function ch(t){const e=Fe(this),{has:n,get:i}=ul(e);let a=n.call(e,t);a||(t=Fe(t),a=n.call(e,t)),i&&i.call(e,t);const l=e.delete(t);return a&&Hr(e,"delete",t,void 0),l}function lh(){const t=Fe(this),e=t.size!==0,n=t.clear();return e&&Hr(t,"clear",void 0,void 0),n}function $u(t,e){return function(i,a){const l=this,m=l.__v_raw,g=Fe(m),v=e?If:t?Sf:Aa;return!t&&xn(g,"iterate",vs),m.forEach((d,I)=>i.call(a,v(d),v(I),l))}}function Qu(t,e,n){return function(...i){const a=this.__v_raw,l=Fe(a),m=eo(l),g=t==="entries"||t===Symbol.iterator&&m,v=t==="keys"&&m,d=a[t](...i),I=n?If:e?Sf:Aa;return!e&&xn(l,"iterate",v?Vl:vs),{next(){const{value:B,done:D}=d.next();return D?{value:B,done:D}:{value:g?[I(B[0]),I(B[1])]:I(B),done:D}},[Symbol.iterator](){return this}}}}function ri(t){return function(...e){return t==="delete"?!1:this}}function uy(){const t={get(l){return Bu(this,l)},get size(){return Uu(this)},has:Fu,add:ah,set:uh,delete:ch,clear:lh,forEach:$u(!1,!1)},e={get(l){return Bu(this,l,!1,!0)},get size(){return Uu(this)},has:Fu,add:ah,set:uh,delete:ch,clear:lh,forEach:$u(!1,!0)},n={get(l){return Bu(this,l,!0)},get size(){return Uu(this,!0)},has(l){return Fu.call(this,l,!0)},add:ri("add"),set:ri("set"),delete:ri("delete"),clear:ri("clear"),forEach:$u(!0,!1)},i={get(l){return Bu(this,l,!0,!0)},get size(){return Uu(this,!0)},has(l){return Fu.call(this,l,!0)},add:ri("add"),set:ri("set"),delete:ri("delete"),clear:ri("clear"),forEach:$u(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(l=>{t[l]=Qu(l,!1,!1),n[l]=Qu(l,!0,!1),e[l]=Qu(l,!1,!0),i[l]=Qu(l,!0,!0)}),[t,n,e,i]}const[cy,ly,fy,hy]=uy();function Af(t,e){const n=e?t?hy:fy:t?ly:cy;return(i,a,l)=>a==="__v_isReactive"?!t:a==="__v_isReadonly"?t:a==="__v_raw"?i:Reflect.get(Be(n,a)&&a in i?n:i,a,l)}const dy={get:Af(!1,!1)},py={get:Af(!1,!0)},my={get:Af(!0,!1)},Rd=new WeakMap,Dd=new WeakMap,Ld=new WeakMap,yy=new WeakMap;function wy(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function gy(t){return t.__v_skip||!Object.isExtensible(t)?0:wy(Bm(t))}function Tf(t){return Do(t)?t:kf(t,!1,Sd,dy,Rd)}function by(t){return kf(t,!1,ay,py,Dd)}function Pd(t){return kf(t,!0,oy,my,Ld)}function kf(t,e,n,i,a){if(!yt(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const l=a.get(t);if(l)return l;const m=gy(t);if(m===0)return t;const g=new Proxy(t,m===2?i:n);return a.set(t,g),g}function to(t){return Do(t)?to(t.__v_raw):!!(t&&t.__v_isReactive)}function Do(t){return!!(t&&t.__v_isReadonly)}function ac(t){return!!(t&&t.__v_isShallow)}function Md(t){return to(t)||Do(t)}function Fe(t){const e=t&&t.__v_raw;return e?Fe(e):t}function Bd(t){return oc(t,"__v_skip",!0),t}const Aa=t=>yt(t)?Tf(t):t,Sf=t=>yt(t)?Pd(t):t;function Fd(t){bi&&fr&&(t=Fe(t),Ad(t.dep||(t.dep=qf())))}function Ud(t,e){t=Fe(t);const n=t.dep;n&&zl(n)}function rn(t){return!!(t&&t.__v_isRef===!0)}function Ny(t){return vy(t,!1)}function vy(t,e){return rn(t)?t:new _y(t,e)}class _y{constructor(e,n){this.__v_isShallow=n,this.dep=void 0,this.__v_isRef=!0,this._rawValue=n?e:Fe(e),this._value=n?e:Aa(e)}get value(){return Fd(this),this._value}set value(e){const n=this.__v_isShallow||ac(e)||Do(e);e=n?e:Fe(e),Ia(e,this._rawValue)&&(this._rawValue=e,this._value=n?e:Aa(e),Ud(this))}}function $d(t){return rn(t)?t.value:t}const xy={get:(t,e,n)=>$d(Reflect.get(t,e,n)),set:(t,e,n,i)=>{const a=t[e];return rn(a)&&!rn(n)?(a.value=n,!0):Reflect.set(t,e,n,i)}};function Qd(t){return to(t)?t:new Proxy(t,xy)}var jd;class Ey{constructor(e,n,i,a){this._setter=n,this.dep=void 0,this.__v_isRef=!0,this[jd]=!1,this._dirty=!0,this.effect=new Of(e,()=>{this._dirty||(this._dirty=!0,Ud(this))}),this.effect.computed=this,this.effect.active=this._cacheable=!a,this.__v_isReadonly=i}get value(){const e=Fe(this);return Fd(e),(e._dirty||!e._cacheable)&&(e._dirty=!1,e._value=e.effect.run()),e._value}set value(e){this._setter(e)}}jd="__v_isReadonly";function Cy(t,e,n=!1){let i,a;const l=ke(t);return l?(i=t,a=mr):(i=t.get,a=t.set),new Ey(i,a,l||!a,n)}function Ni(t,e,n,i){let a;try{a=i?t(...i):t()}catch(l){cl(l,e,n)}return a}function Hn(t,e,n,i){if(ke(t)){const l=Ni(t,e,n,i);return l&&xd(l)&&l.catch(m=>{cl(m,e,n)}),l}const a=[];for(let l=0;l>>1;ka(nn[i])Wr&&nn.splice(e,1)}function Ay(t){Ie(t)?no.push(...t):(!Dr||!Dr.includes(t,t.allowRecurse?Ji+1:Ji))&&no.push(t),Vd()}function fh(t,e=Ta?Wr+1:0){for(;eka(n)-ka(i)),Ji=0;Jit.id==null?1/0:t.id,Ty=(t,e)=>{const n=ka(t)-ka(e);if(n===0){if(t.pre&&!e.pre)return-1;if(e.pre&&!t.pre)return 1}return n};function Kd(t){Kl=!1,Ta=!0,nn.sort(Ty);const e=mr;try{for(Wr=0;WrLt(ne)?ne.trim():ne)),B&&(a=n.map($m))}let g,v=i[g=kl(e)]||i[g=kl(Ro(e))];!v&&l&&(v=i[g=kl(Qo(e))]),v&&Hn(v,t,6,a);const d=i[g+"Once"];if(d){if(!t.emitted)t.emitted={};else if(t.emitted[g])return;t.emitted[g]=!0,Hn(d,t,6,a)}}function Jd(t,e,n=!1){const i=e.emitsCache,a=i.get(t);if(a!==void 0)return a;const l=t.emits;let m={},g=!1;if(!ke(t)){const v=d=>{const I=Jd(d,e,!0);I&&(g=!0,on(m,I))};!n&&e.mixins.length&&e.mixins.forEach(v),t.extends&&v(t.extends),t.mixins&&t.mixins.forEach(v)}return!l&&!g?(yt(t)&&i.set(t,null),null):(Ie(l)?l.forEach(v=>m[v]=null):on(m,l),yt(t)&&i.set(t,m),m)}function ll(t,e){return!t||!sl(e)?!1:(e=e.slice(2).replace(/Once$/,""),Be(t,e[0].toLowerCase()+e.slice(1))||Be(t,Qo(e))||Be(t,e))}let hr=null,Gd=null;function uc(t){const e=hr;return hr=t,Gd=t&&t.type.__scopeId||null,e}function Sy(t,e=hr,n){if(!e||t._n)return t;const i=(...a)=>{i._d&&Nh(-1);const l=uc(e);let m;try{m=t(...a)}finally{uc(l),i._d&&Nh(1)}return m};return i._n=!0,i._c=!0,i._d=!0,i}function Rl(t){const{type:e,vnode:n,proxy:i,withProxy:a,props:l,propsOptions:[m],slots:g,attrs:v,emit:d,render:I,renderCache:B,data:D,setupState:ne,ctx:te,inheritAttrs:b}=t;let C,N;const O=uc(t);try{if(n.shapeFlag&4){const ee=a||i;C=qr(I.call(ee,ee,B,l,ne,D,te)),N=v}else{const ee=e;C=qr(ee.length>1?ee(l,{attrs:v,slots:g,emit:d}):ee(l,null)),N=e.props?v:Ry(v)}}catch(ee){va.length=0,cl(ee,t,1),C=_s(Ur)}let T=C;if(N&&b!==!1){const ee=Object.keys(N),{shapeFlag:Ne}=T;ee.length&&Ne&7&&(m&&ee.some(_f)&&(N=Dy(N,m)),T=xi(T,N))}return n.dirs&&(T=xi(T),T.dirs=T.dirs?T.dirs.concat(n.dirs):n.dirs),n.transition&&(T.transition=n.transition),C=T,uc(O),C}const Ry=t=>{let e;for(const n in t)(n==="class"||n==="style"||sl(n))&&((e||(e={}))[n]=t[n]);return e},Dy=(t,e)=>{const n={};for(const i in t)(!_f(i)||!(i.slice(9)in e))&&(n[i]=t[i]);return n};function Ly(t,e,n){const{props:i,children:a,component:l}=t,{props:m,children:g,patchFlag:v}=e,d=l.emitsOptions;if(e.dirs||e.transition)return!0;if(n&&v>=0){if(v&1024)return!0;if(v&16)return i?hh(i,m,d):!!m;if(v&8){const I=e.dynamicProps;for(let B=0;Bt.__isSuspense;function By(t,e){e&&e.pendingBranch?Ie(t)?e.effects.push(...t):e.effects.push(t):Ay(t)}function Fy(t,e){if(qt){let n=qt.provides;const i=qt.parent&&qt.parent.provides;i===n&&(n=qt.provides=Object.create(i)),n[t]=e}}function Gu(t,e,n=!1){const i=qt||hr;if(i){const a=i.parent==null?i.vnode.appContext&&i.vnode.appContext.provides:i.parent.provides;if(a&&t in a)return a[t];if(arguments.length>1)return n&&ke(e)?e.call(i.proxy):e}}const ju={};function Dl(t,e,n){return Xd(t,e,n)}function Xd(t,e,{immediate:n,deep:i,flush:a,onTrack:l,onTrigger:m}=lt){const g=Vm()===(qt==null?void 0:qt.scope)?qt:null;let v,d=!1,I=!1;if(rn(t)?(v=()=>t.value,d=ac(t)):to(t)?(v=()=>t,i=!0):Ie(t)?(I=!0,d=t.some(T=>to(T)||ac(T)),v=()=>t.map(T=>{if(rn(T))return T.value;if(to(T))return Ks(T);if(ke(T))return Ni(T,g,2)})):ke(t)?e?v=()=>Ni(t,g,2):v=()=>{if(!(g&&g.isUnmounted))return B&&B(),Hn(t,g,3,[D])}:v=mr,e&&i){const T=v;v=()=>Ks(T())}let B,D=T=>{B=N.onStop=()=>{Ni(T,g,4)}},ne;if(Da)if(D=mr,e?n&&Hn(e,g,3,[v(),I?[]:void 0,D]):v(),a==="sync"){const T=Bw();ne=T.__watcherHandles||(T.__watcherHandles=[])}else return mr;let te=I?new Array(t.length).fill(ju):ju;const b=()=>{if(N.active)if(e){const T=N.run();(i||d||(I?T.some((ee,Ne)=>Ia(ee,te[Ne])):Ia(T,te)))&&(B&&B(),Hn(e,g,3,[T,te===ju?void 0:I&&te[0]===ju?[]:te,D]),te=T)}else N.run()};b.allowRecurse=!!e;let C;a==="sync"?C=b:a==="post"?C=()=>bn(b,g&&g.suspense):(b.pre=!0,g&&(b.id=g.uid),C=()=>Df(b));const N=new Of(v,C);e?n?b():te=N.run():a==="post"?bn(N.run.bind(N),g&&g.suspense):N.run();const O=()=>{N.stop(),g&&g.scope&&xf(g.scope.effects,N)};return ne&&ne.push(O),O}function Uy(t,e,n){const i=this.proxy,a=Lt(t)?t.includes(".")?Yd(i,t):()=>i[t]:t.bind(i,i);let l;ke(e)?l=e:(l=e.handler,n=e);const m=qt;Lo(this);const g=Xd(a,l.bind(i),n);return m?Lo(m):xs(),g}function Yd(t,e){const n=e.split(".");return()=>{let i=t;for(let a=0;a{Ks(n,e)});else if(Cd(t))for(const n in t)Ks(t[n],e);return t}function $y(){const t={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return np(()=>{t.isMounted=!0}),rp(()=>{t.isUnmounting=!0}),t}const Fn=[Function,Array],Qy={name:"BaseTransition",props:{mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:Fn,onEnter:Fn,onAfterEnter:Fn,onEnterCancelled:Fn,onBeforeLeave:Fn,onLeave:Fn,onAfterLeave:Fn,onLeaveCancelled:Fn,onBeforeAppear:Fn,onAppear:Fn,onAfterAppear:Fn,onAppearCancelled:Fn},setup(t,{slots:e}){const n=Tw(),i=$y();let a;return()=>{const l=e.default&&ep(e.default(),!0);if(!l||!l.length)return;let m=l[0];if(l.length>1){for(const b of l)if(b.type!==Ur){m=b;break}}const g=Fe(t),{mode:v}=g;if(i.isLeaving)return Ll(m);const d=dh(m);if(!d)return Ll(m);const I=Jl(d,g,i,n);Gl(d,I);const B=n.subTree,D=B&&dh(B);let ne=!1;const{getTransitionKey:te}=d.type;if(te){const b=te();a===void 0?a=b:b!==a&&(a=b,ne=!0)}if(D&&D.type!==Ur&&(!Gi(d,D)||ne)){const b=Jl(D,g,i,n);if(Gl(D,b),v==="out-in")return i.isLeaving=!0,b.afterLeave=()=>{i.isLeaving=!1,n.update.active!==!1&&n.update()},Ll(m);v==="in-out"&&d.type!==Ur&&(b.delayLeave=(C,N,O)=>{const T=Zd(i,D);T[String(D.key)]=D,C._leaveCb=()=>{N(),C._leaveCb=void 0,delete I.delayedLeave},I.delayedLeave=O})}return m}}},jy=Qy;function Zd(t,e){const{leavingVNodes:n}=t;let i=n.get(e.type);return i||(i=Object.create(null),n.set(e.type,i)),i}function Jl(t,e,n,i){const{appear:a,mode:l,persisted:m=!1,onBeforeEnter:g,onEnter:v,onAfterEnter:d,onEnterCancelled:I,onBeforeLeave:B,onLeave:D,onAfterLeave:ne,onLeaveCancelled:te,onBeforeAppear:b,onAppear:C,onAfterAppear:N,onAppearCancelled:O}=e,T=String(t.key),ee=Zd(n,t),Ne=(xe,tt)=>{xe&&Hn(xe,i,9,tt)},ae=(xe,tt)=>{const ze=tt[1];Ne(xe,tt),Ie(xe)?xe.every(Ot=>Ot.length<=1)&&ze():xe.length<=1&&ze()},_e={mode:l,persisted:m,beforeEnter(xe){let tt=g;if(!n.isMounted)if(a)tt=b||g;else return;xe._leaveCb&&xe._leaveCb(!0);const ze=ee[T];ze&&Gi(t,ze)&&ze.el._leaveCb&&ze.el._leaveCb(),Ne(tt,[xe])},enter(xe){let tt=v,ze=d,Ot=I;if(!n.isMounted)if(a)tt=C||v,ze=N||d,Ot=O||I;else return;let Wt=!1;const Qe=xe._enterCb=Kt=>{Wt||(Wt=!0,Kt?Ne(Ot,[xe]):Ne(ze,[xe]),_e.delayedLeave&&_e.delayedLeave(),xe._enterCb=void 0)};tt?ae(tt,[xe,Qe]):Qe()},leave(xe,tt){const ze=String(t.key);if(xe._enterCb&&xe._enterCb(!0),n.isUnmounting)return tt();Ne(B,[xe]);let Ot=!1;const Wt=xe._leaveCb=Qe=>{Ot||(Ot=!0,tt(),Qe?Ne(te,[xe]):Ne(ne,[xe]),xe._leaveCb=void 0,ee[ze]===t&&delete ee[ze])};ee[ze]=t,D?ae(D,[xe,Wt]):Wt()},clone(xe){return Jl(xe,e,n,i)}};return _e}function Ll(t){if(fl(t))return t=xi(t),t.children=null,t}function dh(t){return fl(t)?t.children?t.children[0]:void 0:t}function Gl(t,e){t.shapeFlag&6&&t.component?Gl(t.component.subTree,e):t.shapeFlag&128?(t.ssContent.transition=e.clone(t.ssContent),t.ssFallback.transition=e.clone(t.ssFallback)):t.transition=e}function ep(t,e=!1,n){let i=[],a=0;for(let l=0;l1)for(let l=0;l!!t.type.__asyncLoader,fl=t=>t.type.__isKeepAlive;function Vy(t,e){tp(t,"a",e)}function zy(t,e){tp(t,"da",e)}function tp(t,e,n=qt){const i=t.__wdc||(t.__wdc=()=>{let a=n;for(;a;){if(a.isDeactivated)return;a=a.parent}return t()});if(hl(e,i,n),n){let a=n.parent;for(;a&&a.parent;)fl(a.parent.vnode)&&Ky(i,e,n,a),a=a.parent}}function Ky(t,e,n,i){const a=hl(e,t,i,!0);ip(()=>{xf(i[e],a)},n)}function hl(t,e,n=qt,i=!1){if(n){const a=n[t]||(n[t]=[]),l=e.__weh||(e.__weh=(...m)=>{if(n.isUnmounted)return;jo(),Lo(n);const g=Hn(e,n,t,m);return xs(),Ho(),g});return i?a.unshift(l):a.push(l),l}}const zr=t=>(e,n=qt)=>(!Da||t==="sp")&&hl(t,(...i)=>e(...i),n),Jy=zr("bm"),np=zr("m"),Gy=zr("bu"),Xy=zr("u"),rp=zr("bum"),ip=zr("um"),Yy=zr("sp"),Zy=zr("rtg"),ew=zr("rtc");function tw(t,e=qt){hl("ec",t,e)}function Hi(t,e,n,i){const a=t.dirs,l=e&&e.dirs;for(let m=0;mt?pp(t)?Bf(t)||t.proxy:Xl(t.parent):null,Na=on(Object.create(null),{$:t=>t,$el:t=>t.vnode.el,$data:t=>t.data,$props:t=>t.props,$attrs:t=>t.attrs,$slots:t=>t.slots,$refs:t=>t.refs,$parent:t=>Xl(t.parent),$root:t=>Xl(t.root),$emit:t=>t.emit,$options:t=>Lf(t),$forceUpdate:t=>t.f||(t.f=()=>Df(t.update)),$nextTick:t=>t.n||(t.n=Oy.bind(t.proxy)),$watch:t=>Uy.bind(t)}),Pl=(t,e)=>t!==lt&&!t.__isScriptSetup&&Be(t,e),rw={get({_:t},e){const{ctx:n,setupState:i,data:a,props:l,accessCache:m,type:g,appContext:v}=t;let d;if(e[0]!=="$"){const ne=m[e];if(ne!==void 0)switch(ne){case 1:return i[e];case 2:return a[e];case 4:return n[e];case 3:return l[e]}else{if(Pl(i,e))return m[e]=1,i[e];if(a!==lt&&Be(a,e))return m[e]=2,a[e];if((d=t.propsOptions[0])&&Be(d,e))return m[e]=3,l[e];if(n!==lt&&Be(n,e))return m[e]=4,n[e];Yl&&(m[e]=0)}}const I=Na[e];let B,D;if(I)return e==="$attrs"&&xn(t,"get",e),I(t);if((B=g.__cssModules)&&(B=B[e]))return B;if(n!==lt&&Be(n,e))return m[e]=4,n[e];if(D=v.config.globalProperties,Be(D,e))return D[e]},set({_:t},e,n){const{data:i,setupState:a,ctx:l}=t;return Pl(a,e)?(a[e]=n,!0):i!==lt&&Be(i,e)?(i[e]=n,!0):Be(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(l[e]=n,!0)},has({_:{data:t,setupState:e,accessCache:n,ctx:i,appContext:a,propsOptions:l}},m){let g;return!!n[m]||t!==lt&&Be(t,m)||Pl(e,m)||(g=l[0])&&Be(g,m)||Be(i,m)||Be(Na,m)||Be(a.config.globalProperties,m)},defineProperty(t,e,n){return n.get!=null?t._.accessCache[e]=0:Be(n,"value")&&this.set(t,e,n.value,null),Reflect.defineProperty(t,e,n)}};let Yl=!0;function iw(t){const e=Lf(t),n=t.proxy,i=t.ctx;Yl=!1,e.beforeCreate&&ph(e.beforeCreate,t,"bc");const{data:a,computed:l,methods:m,watch:g,provide:v,inject:d,created:I,beforeMount:B,mounted:D,beforeUpdate:ne,updated:te,activated:b,deactivated:C,beforeDestroy:N,beforeUnmount:O,destroyed:T,unmounted:ee,render:Ne,renderTracked:ae,renderTriggered:_e,errorCaptured:xe,serverPrefetch:tt,expose:ze,inheritAttrs:Ot,components:Wt,directives:Qe,filters:Kt}=e;if(d&&sw(d,i,null,t.appContext.config.unwrapInjectedRef),m)for(const ge in m){const qe=m[ge];ke(qe)&&(i[ge]=qe.bind(n))}if(a){const ge=a.call(n,n);yt(ge)&&(t.data=Tf(ge))}if(Yl=!0,l)for(const ge in l){const qe=l[ge],ut=ke(qe)?qe.bind(n,n):ke(qe.get)?qe.get.bind(n,n):mr,we=!ke(qe)&&ke(qe.set)?qe.set.bind(n):mr,Re=Pw({get:ut,set:we});Object.defineProperty(i,ge,{enumerable:!0,configurable:!0,get:()=>Re.value,set:Pt=>Re.value=Pt})}if(g)for(const ge in g)sp(g[ge],i,n,ge);if(v){const ge=ke(v)?v.call(n):v;Reflect.ownKeys(ge).forEach(qe=>{Fy(qe,ge[qe])})}I&&ph(I,t,"c");function wt(ge,qe){Ie(qe)?qe.forEach(ut=>ge(ut.bind(n))):qe&&ge(qe.bind(n))}if(wt(Jy,B),wt(np,D),wt(Gy,ne),wt(Xy,te),wt(Vy,b),wt(zy,C),wt(tw,xe),wt(ew,ae),wt(Zy,_e),wt(rp,O),wt(ip,ee),wt(Yy,tt),Ie(ze))if(ze.length){const ge=t.exposed||(t.exposed={});ze.forEach(qe=>{Object.defineProperty(ge,qe,{get:()=>n[qe],set:ut=>n[qe]=ut})})}else t.exposed||(t.exposed={});Ne&&t.render===mr&&(t.render=Ne),Ot!=null&&(t.inheritAttrs=Ot),Wt&&(t.components=Wt),Qe&&(t.directives=Qe)}function sw(t,e,n=mr,i=!1){Ie(t)&&(t=Zl(t));for(const a in t){const l=t[a];let m;yt(l)?"default"in l?m=Gu(l.from||a,l.default,!0):m=Gu(l.from||a):m=Gu(l),rn(m)&&i?Object.defineProperty(e,a,{enumerable:!0,configurable:!0,get:()=>m.value,set:g=>m.value=g}):e[a]=m}}function ph(t,e,n){Hn(Ie(t)?t.map(i=>i.bind(e.proxy)):t.bind(e.proxy),e,n)}function sp(t,e,n,i){const a=i.includes(".")?Yd(n,i):()=>n[i];if(Lt(t)){const l=e[t];ke(l)&&Dl(a,l)}else if(ke(t))Dl(a,t.bind(n));else if(yt(t))if(Ie(t))t.forEach(l=>sp(l,e,n,i));else{const l=ke(t.handler)?t.handler.bind(n):e[t.handler];ke(l)&&Dl(a,l,t)}}function Lf(t){const e=t.type,{mixins:n,extends:i}=e,{mixins:a,optionsCache:l,config:{optionMergeStrategies:m}}=t.appContext,g=l.get(e);let v;return g?v=g:!a.length&&!n&&!i?v=e:(v={},a.length&&a.forEach(d=>cc(v,d,m,!0)),cc(v,e,m)),yt(e)&&l.set(e,v),v}function cc(t,e,n,i=!1){const{mixins:a,extends:l}=e;l&&cc(t,l,n,!0),a&&a.forEach(m=>cc(t,m,n,!0));for(const m in e)if(!(i&&m==="expose")){const g=ow[m]||n&&n[m];t[m]=g?g(t[m],e[m]):e[m]}return t}const ow={data:mh,props:Ki,emits:Ki,methods:Ki,computed:Ki,beforeCreate:un,created:un,beforeMount:un,mounted:un,beforeUpdate:un,updated:un,beforeDestroy:un,beforeUnmount:un,destroyed:un,unmounted:un,activated:un,deactivated:un,errorCaptured:un,serverPrefetch:un,components:Ki,directives:Ki,watch:uw,provide:mh,inject:aw};function mh(t,e){return e?t?function(){return on(ke(t)?t.call(this,this):t,ke(e)?e.call(this,this):e)}:e:t}function aw(t,e){return Ki(Zl(t),Zl(e))}function Zl(t){if(Ie(t)){const e={};for(let n=0;n0)&&!(m&16)){if(m&8){const I=t.vnode.dynamicProps;for(let B=0;B{v=!0;const[D,ne]=ap(B,e,!0);on(m,D),ne&&g.push(...ne)};!n&&e.mixins.length&&e.mixins.forEach(I),t.extends&&I(t.extends),t.mixins&&t.mixins.forEach(I)}if(!l&&!v)return yt(t)&&i.set(t,Zs),Zs;if(Ie(l))for(let I=0;I-1,ne[1]=b<0||te-1||Be(ne,"default"))&&g.push(B)}}}const d=[m,g];return yt(t)&&i.set(t,d),d}function yh(t){return t[0]!=="$"}function wh(t){const e=t&&t.toString().match(/^\s*(function|class) (\w+)/);return e?e[2]:t===null?"null":""}function gh(t,e){return wh(t)===wh(e)}function bh(t,e){return Ie(e)?e.findIndex(n=>gh(n,t)):ke(e)&&gh(e,t)?0:-1}const up=t=>t[0]==="_"||t==="$stable",Pf=t=>Ie(t)?t.map(qr):[qr(t)],fw=(t,e,n)=>{if(e._n)return e;const i=Sy((...a)=>Pf(e(...a)),n);return i._c=!1,i},cp=(t,e,n)=>{const i=t._ctx;for(const a in t){if(up(a))continue;const l=t[a];if(ke(l))e[a]=fw(a,l,i);else if(l!=null){const m=Pf(l);e[a]=()=>m}}},lp=(t,e)=>{const n=Pf(e);t.slots.default=()=>n},hw=(t,e)=>{if(t.vnode.shapeFlag&32){const n=e._;n?(t.slots=Fe(e),oc(e,"_",n)):cp(e,t.slots={})}else t.slots={},e&&lp(t,e);oc(t.slots,pl,1)},dw=(t,e,n)=>{const{vnode:i,slots:a}=t;let l=!0,m=lt;if(i.shapeFlag&32){const g=e._;g?n&&g===1?l=!1:(on(a,e),!n&&g===1&&delete a._):(l=!e.$stable,cp(e,a)),m=e}else e&&(lp(t,e),m={default:1});if(l)for(const g in a)!up(g)&&!(g in m)&&delete a[g]};function fp(){return{app:null,config:{isNativeTag:Lm,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}let pw=0;function mw(t,e){return function(i,a=null){ke(i)||(i=Object.assign({},i)),a!=null&&!yt(a)&&(a=null);const l=fp(),m=new Set;let g=!1;const v=l.app={_uid:pw++,_component:i,_props:a,_container:null,_context:l,_instance:null,version:Fw,get config(){return l.config},set config(d){},use(d,...I){return m.has(d)||(d&&ke(d.install)?(m.add(d),d.install(v,...I)):ke(d)&&(m.add(d),d(v,...I))),v},mixin(d){return l.mixins.includes(d)||l.mixins.push(d),v},component(d,I){return I?(l.components[d]=I,v):l.components[d]},directive(d,I){return I?(l.directives[d]=I,v):l.directives[d]},mount(d,I,B){if(!g){const D=_s(i,a);return D.appContext=l,I&&e?e(D,d):t(D,d,B),g=!0,v._container=d,d.__vue_app__=v,Bf(D.component)||D.component.proxy}},unmount(){g&&(t(null,v._container),delete v._container.__vue_app__)},provide(d,I){return l.provides[d]=I,v}};return v}}function tf(t,e,n,i,a=!1){if(Ie(t)){t.forEach((D,ne)=>tf(D,e&&(Ie(e)?e[ne]:e),n,i,a));return}if(Xu(i)&&!a)return;const l=i.shapeFlag&4?Bf(i.component)||i.component.proxy:i.el,m=a?null:l,{i:g,r:v}=t,d=e&&e.r,I=g.refs===lt?g.refs={}:g.refs,B=g.setupState;if(d!=null&&d!==v&&(Lt(d)?(I[d]=null,Be(B,d)&&(B[d]=null)):rn(d)&&(d.value=null)),ke(v))Ni(v,g,12,[m,I]);else{const D=Lt(v),ne=rn(v);if(D||ne){const te=()=>{if(t.f){const b=D?Be(B,v)?B[v]:I[v]:v.value;a?Ie(b)&&xf(b,l):Ie(b)?b.includes(l)||b.push(l):D?(I[v]=[l],Be(B,v)&&(B[v]=I[v])):(v.value=[l],t.k&&(I[t.k]=v.value))}else D?(I[v]=m,Be(B,v)&&(B[v]=m)):ne&&(v.value=m,t.k&&(I[t.k]=m))};m?(te.id=-1,bn(te,n)):te()}}}const bn=By;function yw(t){return ww(t)}function ww(t,e){const n=Qm();n.__VUE__=!0;const{insert:i,remove:a,patchProp:l,createElement:m,createText:g,createComment:v,setText:d,setElementText:I,parentNode:B,nextSibling:D,setScopeId:ne=mr,insertStaticContent:te}=t,b=(x,q,R,F=null,K=null,Y=null,j=!1,z=null,re=!!q.dynamicChildren)=>{if(x===q)return;x&&!Gi(x,q)&&(F=fe(x),Pt(x,K,Y,!0),x=null),q.patchFlag===-2&&(re=!1,q.dynamicChildren=null);const{type:J,ref:ce,shapeFlag:oe}=q;switch(J){case dl:C(x,q,R,F);break;case Ur:N(x,q,R,F);break;case Ml:x==null&&O(q,R,F,j);break;case lr:Wt(x,q,R,F,K,Y,j,z,re);break;default:oe&1?Ne(x,q,R,F,K,Y,j,z,re):oe&6?Qe(x,q,R,F,K,Y,j,z,re):(oe&64||oe&128)&&J.process(x,q,R,F,K,Y,j,z,re,zn)}ce!=null&&K&&tf(ce,x&&x.ref,Y,q||x,!q)},C=(x,q,R,F)=>{if(x==null)i(q.el=g(q.children),R,F);else{const K=q.el=x.el;q.children!==x.children&&d(K,q.children)}},N=(x,q,R,F)=>{x==null?i(q.el=v(q.children||""),R,F):q.el=x.el},O=(x,q,R,F)=>{[x.el,x.anchor]=te(x.children,q,R,F,x.el,x.anchor)},T=({el:x,anchor:q},R,F)=>{let K;for(;x&&x!==q;)K=D(x),i(x,R,F),x=K;i(q,R,F)},ee=({el:x,anchor:q})=>{let R;for(;x&&x!==q;)R=D(x),a(x),x=R;a(q)},Ne=(x,q,R,F,K,Y,j,z,re)=>{j=j||q.type==="svg",x==null?ae(q,R,F,K,Y,j,z,re):tt(x,q,K,Y,j,z,re)},ae=(x,q,R,F,K,Y,j,z)=>{let re,J;const{type:ce,props:oe,shapeFlag:ue,transition:be,dirs:Ee}=x;if(re=x.el=m(x.type,Y,oe&&oe.is,oe),ue&8?I(re,x.children):ue&16&&xe(x.children,re,null,F,K,Y&&ce!=="foreignObject",j,z),Ee&&Hi(x,null,F,"created"),_e(re,x,x.scopeId,j,F),oe){for(const Le in oe)Le!=="value"&&!Ju(Le)&&l(re,Le,null,oe[Le],Y,x.children,F,K,pn);"value"in oe&&l(re,"value",null,oe.value),(J=oe.onVnodeBeforeMount)&&Nr(J,F,x)}Ee&&Hi(x,null,F,"beforeMount");const je=(!K||K&&!K.pendingBranch)&&be&&!be.persisted;je&&be.beforeEnter(re),i(re,q,R),((J=oe&&oe.onVnodeMounted)||je||Ee)&&bn(()=>{J&&Nr(J,F,x),je&&be.enter(re),Ee&&Hi(x,null,F,"mounted")},K)},_e=(x,q,R,F,K)=>{if(R&&ne(x,R),F)for(let Y=0;Y{for(let J=re;J{const z=q.el=x.el;let{patchFlag:re,dynamicChildren:J,dirs:ce}=q;re|=x.patchFlag&16;const oe=x.props||lt,ue=q.props||lt;let be;R&&Vi(R,!1),(be=ue.onVnodeBeforeUpdate)&&Nr(be,R,q,x),ce&&Hi(q,x,R,"beforeUpdate"),R&&Vi(R,!0);const Ee=K&&q.type!=="foreignObject";if(J?ze(x.dynamicChildren,J,z,R,F,Ee,Y):j||qe(x,q,z,null,R,F,Ee,Y,!1),re>0){if(re&16)Ot(z,q,oe,ue,R,F,K);else if(re&2&&oe.class!==ue.class&&l(z,"class",null,ue.class,K),re&4&&l(z,"style",oe.style,ue.style,K),re&8){const je=q.dynamicProps;for(let Le=0;Le{be&&Nr(be,R,q,x),ce&&Hi(q,x,R,"updated")},F)},ze=(x,q,R,F,K,Y,j)=>{for(let z=0;z{if(R!==F){if(R!==lt)for(const z in R)!Ju(z)&&!(z in F)&&l(x,z,R[z],null,j,q.children,K,Y,pn);for(const z in F){if(Ju(z))continue;const re=F[z],J=R[z];re!==J&&z!=="value"&&l(x,z,J,re,j,q.children,K,Y,pn)}"value"in F&&l(x,"value",R.value,F.value)}},Wt=(x,q,R,F,K,Y,j,z,re)=>{const J=q.el=x?x.el:g(""),ce=q.anchor=x?x.anchor:g("");let{patchFlag:oe,dynamicChildren:ue,slotScopeIds:be}=q;be&&(z=z?z.concat(be):be),x==null?(i(J,R,F),i(ce,R,F),xe(q.children,R,ce,K,Y,j,z,re)):oe>0&&oe&64&&ue&&x.dynamicChildren?(ze(x.dynamicChildren,ue,R,K,Y,j,z),(q.key!=null||K&&q===K.subTree)&&hp(x,q,!0)):qe(x,q,R,ce,K,Y,j,z,re)},Qe=(x,q,R,F,K,Y,j,z,re)=>{q.slotScopeIds=z,x==null?q.shapeFlag&512?K.ctx.activate(q,R,F,j,re):Kt(q,R,F,K,Y,j,re):dn(x,q,re)},Kt=(x,q,R,F,K,Y,j)=>{const z=x.component=Aw(x,F,K);if(fl(x)&&(z.ctx.renderer=zn),kw(z),z.asyncDep){if(K&&K.registerDep(z,wt),!x.el){const re=z.subTree=_s(Ur);N(null,re,q,R)}return}wt(z,x,q,R,K,Y,j)},dn=(x,q,R)=>{const F=q.component=x.component;if(Ly(x,q,R))if(F.asyncDep&&!F.asyncResolved){ge(F,q,R);return}else F.next=q,Iy(F.update),F.update();else q.el=x.el,F.vnode=q},wt=(x,q,R,F,K,Y,j)=>{const z=()=>{if(x.isMounted){let{next:ce,bu:oe,u:ue,parent:be,vnode:Ee}=x,je=ce,Le;Vi(x,!1),ce?(ce.el=Ee.el,ge(x,ce,j)):ce=Ee,oe&&Sl(oe),(Le=ce.props&&ce.props.onVnodeBeforeUpdate)&&Nr(Le,be,ce,Ee),Vi(x,!0);const it=Rl(x),me=x.subTree;x.subTree=it,b(me,it,B(me.el),fe(me),x,K,Y),ce.el=it.el,je===null&&Py(x,it.el),ue&&bn(ue,K),(Le=ce.props&&ce.props.onVnodeUpdated)&&bn(()=>Nr(Le,be,ce,Ee),K)}else{let ce;const{el:oe,props:ue}=q,{bm:be,m:Ee,parent:je}=x,Le=Xu(q);if(Vi(x,!1),be&&Sl(be),!Le&&(ce=ue&&ue.onVnodeBeforeMount)&&Nr(ce,je,q),Vi(x,!0),oe&&Ke){const it=()=>{x.subTree=Rl(x),Ke(oe,x.subTree,x,K,null)};Le?q.type.__asyncLoader().then(()=>!x.isUnmounted&&it()):it()}else{const it=x.subTree=Rl(x);b(null,it,R,F,x,K,Y),q.el=it.el}if(Ee&&bn(Ee,K),!Le&&(ce=ue&&ue.onVnodeMounted)){const it=q;bn(()=>Nr(ce,je,it),K)}(q.shapeFlag&256||je&&Xu(je.vnode)&&je.vnode.shapeFlag&256)&&x.a&&bn(x.a,K),x.isMounted=!0,q=R=F=null}},re=x.effect=new Of(z,()=>Df(J),x.scope),J=x.update=()=>re.run();J.id=x.uid,Vi(x,!0),J()},ge=(x,q,R)=>{q.component=x;const F=x.vnode.props;x.vnode=q,x.next=null,lw(x,q.props,F,R),dw(x,q.children,R),jo(),fh(),Ho()},qe=(x,q,R,F,K,Y,j,z,re=!1)=>{const J=x&&x.children,ce=x?x.shapeFlag:0,oe=q.children,{patchFlag:ue,shapeFlag:be}=q;if(ue>0){if(ue&128){we(J,oe,R,F,K,Y,j,z,re);return}else if(ue&256){ut(J,oe,R,F,K,Y,j,z,re);return}}be&8?(ce&16&&pn(J,K,Y),oe!==J&&I(R,oe)):ce&16?be&16?we(J,oe,R,F,K,Y,j,z,re):pn(J,K,Y,!0):(ce&8&&I(R,""),be&16&&xe(oe,R,F,K,Y,j,z,re))},ut=(x,q,R,F,K,Y,j,z,re)=>{x=x||Zs,q=q||Zs;const J=x.length,ce=q.length,oe=Math.min(J,ce);let ue;for(ue=0;uece?pn(x,K,Y,!0,!1,oe):xe(q,R,F,K,Y,j,z,re,oe)},we=(x,q,R,F,K,Y,j,z,re)=>{let J=0;const ce=q.length;let oe=x.length-1,ue=ce-1;for(;J<=oe&&J<=ue;){const be=x[J],Ee=q[J]=re?oi(q[J]):qr(q[J]);if(Gi(be,Ee))b(be,Ee,R,null,K,Y,j,z,re);else break;J++}for(;J<=oe&&J<=ue;){const be=x[oe],Ee=q[ue]=re?oi(q[ue]):qr(q[ue]);if(Gi(be,Ee))b(be,Ee,R,null,K,Y,j,z,re);else break;oe--,ue--}if(J>oe){if(J<=ue){const be=ue+1,Ee=beue)for(;J<=oe;)Pt(x[J],K,Y,!0),J++;else{const be=J,Ee=J,je=new Map;for(J=Ee;J<=ue;J++){const le=q[J]=re?oi(q[J]):qr(q[J]);le.key!=null&&je.set(le.key,J)}let Le,it=0;const me=ue-Ee+1;let Cn=!1,qi=0;const Gt=new Array(me);for(J=0;J=me){Pt(le,K,Y,!0);continue}let Mt;if(le.key!=null)Mt=je.get(le.key);else for(Le=Ee;Le<=ue;Le++)if(Gt[Le-Ee]===0&&Gi(le,q[Le])){Mt=Le;break}Mt===void 0?Pt(le,K,Y,!0):(Gt[Mt-Ee]=J+1,Mt>=qi?qi=Mt:Cn=!0,b(le,q[Mt],R,null,K,Y,j,z,re),it++)}const qs=Cn?gw(Gt):Zs;for(Le=qs.length-1,J=me-1;J>=0;J--){const le=Ee+J,Mt=q[le],Z=le+1{const{el:Y,type:j,transition:z,children:re,shapeFlag:J}=x;if(J&6){Re(x.component.subTree,q,R,F);return}if(J&128){x.suspense.move(q,R,F);return}if(J&64){j.move(x,q,R,zn);return}if(j===lr){i(Y,q,R);for(let oe=0;oez.enter(Y),K);else{const{leave:oe,delayLeave:ue,afterLeave:be}=z,Ee=()=>i(Y,q,R),je=()=>{oe(Y,()=>{Ee(),be&&be()})};ue?ue(Y,Ee,je):je()}else i(Y,q,R)},Pt=(x,q,R,F=!1,K=!1)=>{const{type:Y,props:j,ref:z,children:re,dynamicChildren:J,shapeFlag:ce,patchFlag:oe,dirs:ue}=x;if(z!=null&&tf(z,null,R,x,!0),ce&256){q.ctx.deactivate(x);return}const be=ce&1&&ue,Ee=!Xu(x);let je;if(Ee&&(je=j&&j.onVnodeBeforeUnmount)&&Nr(je,q,x),ce&6)En(x.component,R,F);else{if(ce&128){x.suspense.unmount(R,F);return}be&&Hi(x,null,q,"beforeUnmount"),ce&64?x.type.remove(x,q,R,K,zn,F):J&&(Y!==lr||oe>0&&oe&64)?pn(J,q,R,!1,!0):(Y===lr&&oe&384||!K&&ce&16)&&pn(re,q,R),F&&Tr(x)}(Ee&&(je=j&&j.onVnodeUnmounted)||be)&&bn(()=>{je&&Nr(je,q,x),be&&Hi(x,null,q,"unmounted")},R)},Tr=x=>{const{type:q,el:R,anchor:F,transition:K}=x;if(q===lr){Cs(R,F);return}if(q===Ml){ee(x);return}const Y=()=>{a(R),K&&!K.persisted&&K.afterLeave&&K.afterLeave()};if(x.shapeFlag&1&&K&&!K.persisted){const{leave:j,delayLeave:z}=K,re=()=>j(R,Y);z?z(x.el,Y,re):re()}else Y()},Cs=(x,q)=>{let R;for(;x!==q;)R=D(x),a(x),x=R;a(q)},En=(x,q,R)=>{const{bum:F,scope:K,update:Y,subTree:j,um:z}=x;F&&Sl(F),K.stop(),Y&&(Y.active=!1,Pt(j,x,q,R)),z&&bn(z,q),bn(()=>{x.isUnmounted=!0},q),q&&q.pendingBranch&&!q.isUnmounted&&x.asyncDep&&!x.asyncResolved&&x.suspenseId===q.pendingId&&(q.deps--,q.deps===0&&q.resolve())},pn=(x,q,R,F=!1,K=!1,Y=0)=>{for(let j=Y;jx.shapeFlag&6?fe(x.component.subTree):x.shapeFlag&128?x.suspense.next():D(x.anchor||x.el),Me=(x,q,R)=>{x==null?q._vnode&&Pt(q._vnode,null,null,!0):b(q._vnode||null,x,q,null,null,null,R),fh(),zd(),q._vnode=x},zn={p:b,um:Pt,m:Re,r:Tr,mt:Kt,mc:xe,pc:qe,pbc:ze,n:fe,o:t};let Jt,Ke;return e&&([Jt,Ke]=e(zn)),{render:Me,hydrate:Jt,createApp:mw(Me,Jt)}}function Vi({effect:t,update:e},n){t.allowRecurse=e.allowRecurse=n}function hp(t,e,n=!1){const i=t.children,a=e.children;if(Ie(i)&&Ie(a))for(let l=0;l>1,t[n[g]]0&&(e[i]=n[l-1]),n[l]=i)}}for(l=n.length,m=n[l-1];l-- >0;)n[l]=m,m=e[m];return n}const bw=t=>t.__isTeleport,lr=Symbol(void 0),dl=Symbol(void 0),Ur=Symbol(void 0),Ml=Symbol(void 0),va=[];let dr=null;function Nw(t=!1){va.push(dr=t?null:[])}function vw(){va.pop(),dr=va[va.length-1]||null}let Sa=1;function Nh(t){Sa+=t}function _w(t){return t.dynamicChildren=Sa>0?dr||Zs:null,vw(),Sa>0&&dr&&dr.push(t),t}function xw(t,e,n,i,a,l){return _w(Ct(t,e,n,i,a,l,!0))}function Ew(t){return t?t.__v_isVNode===!0:!1}function Gi(t,e){return t.type===e.type&&t.key===e.key}const pl="__vInternal",dp=({key:t})=>t??null,Yu=({ref:t,ref_key:e,ref_for:n})=>t!=null?Lt(t)||rn(t)||ke(t)?{i:hr,r:t,k:e,f:!!n}:t:null;function Ct(t,e=null,n=null,i=0,a=null,l=t===lr?0:1,m=!1,g=!1){const v={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&dp(e),ref:e&&Yu(e),scopeId:Gd,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetAnchor:null,staticCount:0,shapeFlag:l,patchFlag:i,dynamicProps:a,dynamicChildren:null,appContext:null,ctx:hr};return g?(Mf(v,n),l&128&&t.normalize(v)):n&&(v.shapeFlag|=Lt(n)?8:16),Sa>0&&!m&&dr&&(v.patchFlag>0||l&6)&&v.patchFlag!==32&&dr.push(v),v}const _s=Cw;function Cw(t,e=null,n=null,i=0,a=null,l=!1){if((!t||t===nw)&&(t=Ur),Ew(t)){const g=xi(t,e,!0);return n&&Mf(g,n),Sa>0&&!l&&dr&&(g.shapeFlag&6?dr[dr.indexOf(t)]=g:dr.push(g)),g.patchFlag|=-2,g}if(Lw(t)&&(t=t.__vccOpts),e){e=qw(e);let{class:g,style:v}=e;g&&!Lt(g)&&(e.class=vf(g)),yt(v)&&(Md(v)&&!Ie(v)&&(v=on({},v)),e.style=Nf(v))}const m=Lt(t)?1:My(t)?128:bw(t)?64:yt(t)?4:ke(t)?2:0;return Ct(t,e,n,i,a,m,l,!0)}function qw(t){return t?Md(t)||pl in t?on({},t):t:null}function xi(t,e,n=!1){const{props:i,ref:a,patchFlag:l,children:m}=t,g=e?Ow(i||{},e):i;return{__v_isVNode:!0,__v_skip:!0,type:t.type,props:g,key:g&&dp(g),ref:e&&e.ref?n&&a?Ie(a)?a.concat(Yu(e)):[a,Yu(e)]:Yu(e):a,scopeId:t.scopeId,slotScopeIds:t.slotScopeIds,children:m,target:t.target,targetAnchor:t.targetAnchor,staticCount:t.staticCount,shapeFlag:t.shapeFlag,patchFlag:e&&t.type!==lr?l===-1?16:l|16:l,dynamicProps:t.dynamicProps,dynamicChildren:t.dynamicChildren,appContext:t.appContext,dirs:t.dirs,transition:t.transition,component:t.component,suspense:t.suspense,ssContent:t.ssContent&&xi(t.ssContent),ssFallback:t.ssFallback&&xi(t.ssFallback),el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce}}function Ra(t=" ",e=0){return _s(dl,null,t,e)}function qr(t){return t==null||typeof t=="boolean"?_s(Ur):Ie(t)?_s(lr,null,t.slice()):typeof t=="object"?oi(t):_s(dl,null,String(t))}function oi(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:xi(t)}function Mf(t,e){let n=0;const{shapeFlag:i}=t;if(e==null)e=null;else if(Ie(e))n=16;else if(typeof e=="object")if(i&65){const a=e.default;a&&(a._c&&(a._d=!1),Mf(t,a()),a._c&&(a._d=!0));return}else{n=32;const a=e._;!a&&!(pl in e)?e._ctx=hr:a===3&&hr&&(hr.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else ke(e)?(e={default:e,_ctx:hr},n=32):(e=String(e),i&64?(n=16,e=[Ra(e)]):n=8);t.children=e,t.shapeFlag|=n}function Ow(...t){const e={};for(let n=0;nqt||hr,Lo=t=>{qt=t,t.scope.on()},xs=()=>{qt&&qt.scope.off(),qt=null};function pp(t){return t.vnode.shapeFlag&4}let Da=!1;function kw(t,e=!1){Da=e;const{props:n,children:i}=t.vnode,a=pp(t);cw(t,n,a,e),hw(t,i);const l=a?Sw(t,e):void 0;return Da=!1,l}function Sw(t,e){const n=t.type;t.accessCache=Object.create(null),t.proxy=Bd(new Proxy(t.ctx,rw));const{setup:i}=n;if(i){const a=t.setupContext=i.length>1?Dw(t):null;Lo(t),jo();const l=Ni(i,t,0,[t.props,a]);if(Ho(),xs(),xd(l)){if(l.then(xs,xs),e)return l.then(m=>{vh(t,m,e)}).catch(m=>{cl(m,t,0)});t.asyncDep=l}else vh(t,l,e)}else mp(t,e)}function vh(t,e,n){ke(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:yt(e)&&(t.setupState=Qd(e)),mp(t,n)}let _h;function mp(t,e,n){const i=t.type;if(!t.render){if(!e&&_h&&!i.render){const a=i.template||Lf(t).template;if(a){const{isCustomElement:l,compilerOptions:m}=t.appContext.config,{delimiters:g,compilerOptions:v}=i,d=on(on({isCustomElement:l,delimiters:g},m),v);i.render=_h(a,d)}}t.render=i.render||mr}Lo(t),jo(),iw(t),Ho(),xs()}function Rw(t){return new Proxy(t.attrs,{get(e,n){return xn(t,"get","$attrs"),e[n]}})}function Dw(t){const e=i=>{t.exposed=i||{}};let n;return{get attrs(){return n||(n=Rw(t))},slots:t.slots,emit:t.emit,expose:e}}function Bf(t){if(t.exposed)return t.exposeProxy||(t.exposeProxy=new Proxy(Qd(Bd(t.exposed)),{get(e,n){if(n in e)return e[n];if(n in Na)return Na[n](t)},has(e,n){return n in e||n in Na}}))}function Lw(t){return ke(t)&&"__vccOpts"in t}const Pw=(t,e)=>Cy(t,e,Da),Mw=Symbol(""),Bw=()=>Gu(Mw),Fw="3.2.47",Uw="http://www.w3.org/2000/svg",Xi=typeof document<"u"?document:null,xh=Xi&&Xi.createElement("template"),$w={insert:(t,e,n)=>{e.insertBefore(t,n||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,n,i)=>{const a=e?Xi.createElementNS(Uw,t):Xi.createElement(t,n?{is:n}:void 0);return t==="select"&&i&&i.multiple!=null&&a.setAttribute("multiple",i.multiple),a},createText:t=>Xi.createTextNode(t),createComment:t=>Xi.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>Xi.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,n,i,a,l){const m=n?n.previousSibling:e.lastChild;if(a&&(a===l||a.nextSibling))for(;e.insertBefore(a.cloneNode(!0),n),!(a===l||!(a=a.nextSibling)););else{xh.innerHTML=i?`${t}`:t;const g=xh.content;if(i){const v=g.firstChild;for(;v.firstChild;)g.appendChild(v.firstChild);g.removeChild(v)}e.insertBefore(g,n)}return[m?m.nextSibling:e.firstChild,n?n.previousSibling:e.lastChild]}};function Qw(t,e,n){const i=t._vtc;i&&(e=(e?[e,...i]:[...i]).join(" ")),e==null?t.removeAttribute("class"):n?t.setAttribute("class",e):t.className=e}function jw(t,e,n){const i=t.style,a=Lt(n);if(n&&!a){if(e&&!Lt(e))for(const l in e)n[l]==null&&nf(i,l,"");for(const l in n)nf(i,l,n[l])}else{const l=i.display;a?e!==n&&(i.cssText=n):e&&t.removeAttribute("style"),"_vod"in t&&(i.display=l)}}const Eh=/\s*!important$/;function nf(t,e,n){if(Ie(n))n.forEach(i=>nf(t,e,i));else if(n==null&&(n=""),e.startsWith("--"))t.setProperty(e,n);else{const i=Hw(t,e);Eh.test(n)?t.setProperty(Qo(i),n.replace(Eh,""),"important"):t[i]=n}}const Ch=["Webkit","Moz","ms"],Bl={};function Hw(t,e){const n=Bl[e];if(n)return n;let i=Ro(e);if(i!=="filter"&&i in t)return Bl[e]=i;i=qd(i);for(let a=0;aFl||(Yw.then(()=>Fl=0),Fl=Date.now());function eg(t,e){const n=i=>{if(!i._vts)i._vts=Date.now();else if(i._vts<=n.attached)return;Hn(tg(i,n.value),e,5,[i])};return n.value=t,n.attached=Zw(),n}function tg(t,e){if(Ie(e)){const n=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{n.call(t),t._stopped=!0},e.map(i=>a=>!a._stopped&&i&&i(a))}else return e}const Wh=/^on[a-z]/,ng=(t,e,n,i,a=!1,l,m,g,v)=>{e==="class"?Qw(t,i,a):e==="style"?jw(t,n,i):sl(e)?_f(e)||Gw(t,e,n,i,m):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):rg(t,e,i,a))?zw(t,e,i,l,m,g,v):(e==="true-value"?t._trueValue=i:e==="false-value"&&(t._falseValue=i),Vw(t,e,i,a))};function rg(t,e,n,i){return i?!!(e==="innerHTML"||e==="textContent"||e in t&&Wh.test(e)&&ke(n)):e==="spellcheck"||e==="draggable"||e==="translate"||e==="form"||e==="list"&&t.tagName==="INPUT"||e==="type"&&t.tagName==="TEXTAREA"||Wh.test(e)&&Lt(n)?!1:e in t}const ig={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String};jy.props;const sg=on({patchProp:ng},$w);let Ih;function og(){return Ih||(Ih=yw(sg))}const ag=(...t)=>{const e=og().createApp(...t),{mount:n}=e;return e.mount=i=>{const a=ug(i);if(!a)return;const l=e._component;!ke(l)&&!l.render&&!l.template&&(l.template=a.innerHTML),a.innerHTML="";const m=n(a,!1,a instanceof SVGElement);return a instanceof Element&&(a.removeAttribute("v-cloak"),a.setAttribute("data-v-app","")),m},e};function ug(t){return Lt(t)?document.querySelector(t):t}function _a(t){return typeof t>"u"||t===void 0}function yr(t){return typeof t=="string"}function cg(t){return typeof t=="number"}function yp(t){return typeof t=="boolean"}function wp(t){return t===null}function lg(t){return t instanceof Date}function fg(t){return typeof t=="bigint"}function Vn(t){return typeof t=="function"}function Ir(t){return typeof t=="object"&&t!==null}function p(t){return Object.freeze(t)}function wu(t){return Array.isArray(t)}function Po(t){return t}const Et=p({is(t){return t.kind==="AlterTableNode"},create(t){return p({kind:"AlterTableNode",table:t})},cloneWithTableProps(t,e){return p({...t,...e})},cloneWithColumnAlteration(t,e){return p({...t,columnAlterations:t.columnAlterations?[...t.columnAlterations,e]:[e]})}}),mt=p({is(t){return t.kind==="IdentifierNode"},create(t){return p({kind:"IdentifierNode",name:t})}}),ii=p({is(t){return t.kind==="CreateIndexNode"},create(t){return p({kind:"CreateIndexNode",name:mt.create(t)})},cloneWith(t,e){return p({...t,...e})},cloneWithColumns(t,e){return p({...t,columns:[...t.columns||[],...e]})}}),gp=p({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return p({kind:"CreateSchemaNode",schema:mt.create(t),...e})},cloneWith(t,e){return p({...t,...e})}}),hg=["preserve rows","delete rows","drop"],Zn=p({is(t){return t.kind==="CreateTableNode"},create(t){return p({kind:"CreateTableNode",table:t,columns:p([])})},cloneWithColumn(t,e){return p({...t,columns:p([...t.columns,e])})},cloneWithConstraint(t,e){return p({...t,constraints:t.constraints?p([...t.constraints,e]):p([e])})},cloneWithFrontModifier(t,e){return p({...t,frontModifiers:t.frontModifiers?p([...t.frontModifiers,e]):p([e])})},cloneWithEndModifier(t,e){return p({...t,endModifiers:t.endModifiers?p([...t.endModifiers,e]):p([e])})},cloneWith(t,e){return p({...t,...e})}}),Ei=p({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return p({kind:"SchemableIdentifierNode",identifier:mt.create(t)})},createWithSchema(t,e){return p({kind:"SchemableIdentifierNode",schema:mt.create(t),identifier:mt.create(e)})}}),Zu=p({is(t){return t.kind==="DropIndexNode"},create(t,e){return p({kind:"DropIndexNode",name:Ei.create(t),...e})},cloneWith(t,e){return p({...t,...e})}}),rf=p({is(t){return t.kind==="DropSchemaNode"},create(t,e){return p({kind:"DropSchemaNode",schema:mt.create(t),...e})},cloneWith(t,e){return p({...t,...e})}}),sf=p({is(t){return t.kind==="DropTableNode"},create(t,e){return p({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return p({...t,...e})}}),Es=p({is(t){return t.kind==="AliasNode"},create(t,e){return p({kind:"AliasNode",node:t,alias:e})}}),vi=p({is(t){return t.kind==="TableNode"},create(t){return p({kind:"TableNode",table:Ei.create(t)})},createWithSchema(t,e){return p({kind:"TableNode",table:Ei.createWithSchema(t,e)})}});function hn(t){return Ir(t)&&Vn(t.toOperationNode)}function dg(t){return Ir(t)&&"expressionType"in t&&hn(t)}function pg(t){return Ir(t)&&"expression"in t&&yr(t.alias)&&hn(t)}const Sr=p({is(t){return t.kind==="SelectModifierNode"},create(t){return p({kind:"SelectModifierNode",modifier:t})},createWithExpression(t){return p({kind:"SelectModifierNode",rawModifier:t})}}),La=p({is(t){return t.kind==="AndNode"},create(t,e){return p({kind:"AndNode",left:t,right:e})}}),Pa=p({is(t){return t.kind==="OrNode"},create(t,e){return p({kind:"OrNode",left:t,right:e})}}),ma=p({is(t){return t.kind==="OnNode"},create(t){return p({kind:"OnNode",on:t})},cloneWithOperation(t,e,n){return p({...t,on:e==="And"?La.create(t.on,n):Pa.create(t.on,n)})}}),jn=p({is(t){return t.kind==="JoinNode"},create(t,e){return p({kind:"JoinNode",joinType:t,table:e,on:void 0})},createWithOn(t,e,n){return p({kind:"JoinNode",joinType:t,table:e,on:ma.create(n)})},cloneWithOn(t,e){return p({...t,on:t.on?ma.cloneWithOperation(t.on,"And",e):ma.create(e)})},cloneWithOrOn(t,e){return p({...t,on:t.on?ma.cloneWithOperation(t.on,"Or",e):ma.create(e)})}}),ml=p({is(t){return t.kind==="BinaryOperationNode"},create(t,e,n){return p({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:n})}}),en=p({is(t){return t.kind==="RawNode"},create(t,e){return p({kind:"RawNode",sqlFragments:p(t),parameters:p(e)})},createWithSql(t){return en.create([t],[])},createWithChild(t){return en.create(["",""],[t])},createWithChildren(t){return en.create(new Array(t.length+1).fill(""),t)}}),bp=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->"],mg=["+","-","*","/","%","^","&","|","#","<<",">>"],Np=[...bp,...mg,"&&","||"],yg=["exists","not exists"],wg=["not","-",...yg],gg=[...Np,...wg],Ff=p({is(t){return t.kind==="OperatorNode"},create(t){return p({kind:"OperatorNode",operator:t})}});function vp(t){return yr(t)&&Np.includes(t)}function _p(t){return yr(t)&&bp.includes(t)}const ro=p({is(t){return t.kind==="ParensNode"},create(t){return p({kind:"ParensNode",node:t})}}),Nt=p({is(t){return t.kind==="ColumnNode"},create(t){return p({kind:"ColumnNode",column:mt.create(t)})}}),Uf=p({is(t){return t.kind==="SelectAllNode"},create(){return p({kind:"SelectAllNode"})}}),yl=p({is(t){return t.kind==="ReferenceNode"},create(t,e){return p({kind:"ReferenceNode",table:t,column:e})},createSelectAll(t){return p({kind:"ReferenceNode",table:t,column:Uf.create()})}}),bg=p({is(t){return t.kind==="OrderByItemNode"},create(t,e){return p({kind:"OrderByItemNode",orderBy:t,direction:e})}});function Ng(t){return t==="asc"||t==="desc"}function wl(t,e){return bg.create(vg(t),_g(e))}function vg(t){return Vr(t)}function _g(t){if(t)return t==="asc"||t==="desc"?en.createWithSql(t):t.toOperationNode()}function xp(t){return yr(t)?Mo(t):t.toOperationNode()}function Ma(t){return wu(t)?t.map(e=>Vr(e)):[Vr(t)]}function Vr(t){return xl(t)?_l(t):xp(t)}function Mo(t){const e=".";if(t.includes(e)){const n=t.split(e).map($f);if(n.length===3)return Eg(n);if(n.length===2)return Cg(n);throw new Error(`invalid column reference ${t}`)}else return Nt.create(t)}function xg(t){const e=" as ";if(t.includes(e)){const[n,i]=t.split(e).map($f);return Es.create(Mo(n),mt.create(i))}else return Mo(t)}function Ep(t){return Nt.create(t)}function Ah(t){const e=" ";if(t.includes(e)){const[n,i]=t.split(e).map($f);if(!Ng(i))throw new Error(`invalid order direction "${i}" next to "${n}"`);return wl(n,i)}else return Ep(t)}function Eg(t){const[e,n,i]=t;return yl.create(vi.createWithSchema(e,n),Nt.create(i))}function Cg(t){const[e,n]=t;return yl.create(vi.create(e),Nt.create(n))}function $f(t){return t.trim()}const Cp=p({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return p({kind:"PrimitiveValueListNode",values:p([...t])})}}),Qf=p({is(t){return t.kind==="ValueListNode"},create(t){return p({kind:"ValueListNode",values:p(t)})}}),Ar=p({is(t){return t.kind==="ValueNode"},create(t){return p({kind:"ValueNode",value:t})},createImmediate(t){return p({kind:"ValueNode",value:t,immediate:!0})}});function qp(t){return wu(t)?qg(t):$r(t)}function $r(t){return xl(t)?_l(t):Ar.create(t)}function qg(t){return t.some(xl)?Qf.create(t.map(e=>$r(e))):Cp.create(t)}const Bo=p({is(t){return t.kind==="OrderByNode"},create(t){return p({kind:"OrderByNode",items:p([t])})},cloneWithItem(t,e){return p({...t,items:p([...t.items,e])})}}),Th=p({is(t){return t.kind==="PartitionByNode"},create(t){return p({kind:"PartitionByNode",items:p(t)})},cloneWithItems(t,e){return p({...t,items:p([...t.items,...e])})}}),of=p({is(t){return t.kind==="OverNode"},create(){return p({kind:"OverNode"})},cloneWithOrderByItem(t,e){return p({...t,orderBy:t.orderBy?Bo.cloneWithItem(t.orderBy,e):Bo.create(e)})},cloneWithPartitionByItems(t,e){return p({...t,partitionBy:t.partitionBy?Th.cloneWithItems(t.partitionBy,e):Th.create(e)})}}),lc=p({is(t){return t.kind==="FromNode"},create(t){return p({kind:"FromNode",froms:p(t)})},cloneWithFroms(t,e){return p({...t,froms:p([...t.froms,...e])})}}),kh=p({is(t){return t.kind==="GroupByNode"},create(t){return p({kind:"GroupByNode",items:p(t)})},cloneWithItems(t,e){return p({...t,items:p([...t.items,...e])})}}),Hu=p({is(t){return t.kind==="HavingNode"},create(t){return p({kind:"HavingNode",having:t})},cloneWithOperation(t,e,n){return p({...t,having:e==="And"?La.create(t.having,n):Pa.create(t.having,n)})}}),We=p({is(t){return t.kind==="SelectQueryNode"},create(t,e){return p({kind:"SelectQueryNode",from:lc.create(t),...e&&{with:e}})},cloneWithSelections(t,e){return p({...t,selections:t.selections?p([...t.selections,...e]):p(e)})},cloneWithDistinctOn(t,e){return p({...t,distinctOn:t.distinctOn?p([...t.distinctOn,...e]):p(e)})},cloneWithFrontModifier(t,e){return p({...t,frontModifiers:t.frontModifiers?p([...t.frontModifiers,e]):p([e])})},cloneWithEndModifier(t,e){return p({...t,endModifiers:t.endModifiers?p([...t.endModifiers,e]):p([e])})},cloneWithOrderByItem(t,e){return p({...t,orderBy:t.orderBy?Bo.cloneWithItem(t.orderBy,e):Bo.create(e)})},cloneWithGroupByItems(t,e){return p({...t,groupBy:t.groupBy?kh.cloneWithItems(t.groupBy,e):kh.create(e)})},cloneWithLimit(t,e){return p({...t,limit:e})},cloneWithOffset(t,e){return p({...t,offset:e})},cloneWithHaving(t,e){return p({...t,having:t.having?Hu.cloneWithOperation(t.having,"And",e):Hu.create(e)})},cloneWithOrHaving(t,e){return p({...t,having:t.having?Hu.cloneWithOperation(t.having,"Or",e):Hu.create(e)})},cloneWithSetOperation(t,e){return p({...t,setOperations:t.setOperations?p([...t.setOperations,e]):p([e])})},cloneWithoutSelections(t){return p({...t,selections:[]})},cloneWithoutLimit(t){return p({...t,limit:void 0})},cloneWithoutOffset(t){return p({...t,offset:void 0})},cloneWithoutOrderBy(t){return p({...t,orderBy:void 0})}}),Op=p({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return p({kind:"UnaryOperationNode",operator:t,operand:e})}});function sn(t){return jf("exists",t)}function Vt(t){return jf("not exists",t)}function jf(t,e){return Op.create(Ff.create(t),Vr(e))}function $e(t,e){Object.defineProperties(t.prototype,{then:{enumerable:!1,value:()=>{throw new Error(e)}}})}var ft;const tr=class{constructor(e){k(this,ft,void 0);P(this,ft,p(e))}on(...e){return new tr({...r(this,ft),joinNode:jn.cloneWithOn(r(this,ft).joinNode,jh(e))})}orOn(...e){return new tr({...r(this,ft),joinNode:jn.cloneWithOrOn(r(this,ft).joinNode,jh(e))})}onRef(e,n,i){return new tr({...r(this,ft),joinNode:jn.cloneWithOn(r(this,ft).joinNode,zt(e,n,i))})}orOnRef(e,n,i){return new tr({...r(this,ft),joinNode:jn.cloneWithOrOn(r(this,ft).joinNode,zt(e,n,i))})}onExists(e){return new tr({...r(this,ft),joinNode:jn.cloneWithOn(r(this,ft).joinNode,sn(e))})}onNotExists(e){return new tr({...r(this,ft),joinNode:jn.cloneWithOn(r(this,ft).joinNode,Vt(e))})}orOnExists(e){return new tr({...r(this,ft),joinNode:jn.cloneWithOrOn(r(this,ft).joinNode,sn(e))})}orOnNotExists(e){return new tr({...r(this,ft),joinNode:jn.cloneWithOrOn(r(this,ft).joinNode,Vt(e))})}onTrue(){return new tr({...r(this,ft),joinNode:jn.cloneWithOn(r(this,ft).joinNode,en.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return r(this,ft).joinNode}};let fc=tr;ft=new WeakMap;$e(fc,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const Og=p({is(t){return t.kind==="PartitionByItemNode"},create(t){return p({kind:"PartitionByItemNode",partitionBy:t})}});function Wg(t){return Ma(t).map(Og.create)}var rs;const Rc=class{constructor(e){k(this,rs,void 0);P(this,rs,p(e))}orderBy(e,n){return new Rc({overNode:of.cloneWithOrderByItem(r(this,rs).overNode,wl(e,n))})}partitionBy(e){return new Rc({overNode:of.cloneWithPartitionByItems(r(this,rs).overNode,Wg(e))})}$call(e){return e(this)}toOperationNode(){return r(this,rs).overNode}};let hc=Rc;rs=new WeakMap;$e(hc,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");const xa=p({is(t){return t.kind==="SelectionNode"},create(t){return p({kind:"SelectionNode",selection:t})},createSelectAll(){return p({kind:"SelectionNode",selection:Uf.create()})},createSelectAllFromTable(t){return p({kind:"SelectionNode",selection:yl.createSelectAll(t)})}});var io;class Ig{constructor(e){k(this,io,void 0);P(this,io,e)}get dynamicReference(){return r(this,io)}get refType(){}toOperationNode(){return xp(r(this,io))}}io=new WeakMap;function Ag(t){return Ir(t)&&hn(t)&&yr(t.dynamicReference)}function gu(t){return Vn(t)?gu(t(Qr())):wu(t)?t.map(e=>Sh(e)):[Sh(t)]}function Sh(t){return yr(t)?xa.create(xg(t)):Ag(t)?xa.create(t.toOperationNode()):xa.create(Hp(t))}function bu(t){return t?Array.isArray(t)?t.map(Rh):[Rh(t)]:[xa.createSelectAll()]}function Rh(t){if(yr(t))return xa.createSelectAllFromTable(_n(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const Tg=p({is(t){return t.kind==="ValuesNode"},create(t){return p({kind:"ValuesNode",values:p(t)})}}),kg=p({is(t){return t.kind==="DefaultInsertValueNode"},create(){return p({kind:"DefaultInsertValueNode"})}});function Sg(t){const e=Vn(t)?t(Qr()):t,n=wu(e)?e:p([e]);return Rg(n)}function Rg(t){const e=Dg(t);return[p([...e.keys()].map(Nt.create)),Tg.create(t.map(n=>Lg(n,e)))]}function Dg(t){const e=new Map;for(const n of t){const i=Object.keys(n);for(const a of i)!e.has(a)&&n[a]!==void 0&&e.set(a,e.size)}return e}function Lg(t,e){const n=Object.keys(t),i=Array.from({length:e.size});let a=!1;for(const m of n){const g=e.get(m);if(_a(g))continue;const v=t[m];(_a(v)||xl(v))&&(a=!0),i[g]=v}if(n.length_a(g)?m:$r(g)))}return Cp.create(i)}const Or=p({is(t){return t.kind==="InsertQueryNode"},create(t,e,n){return p({kind:"InsertQueryNode",into:t,...e&&{with:e},replace:n})},cloneWith(t,e){return p({...t,...e})}}),dc=p({is(t){return t.kind==="UpdateQueryNode"},create(t,e){return p({kind:"UpdateQueryNode",table:t,...e&&{with:e}})},cloneWithFromItems(t,e){return p({...t,from:t.from?lc.cloneWithFroms(t.from,e):lc.create(e)})},cloneWithUpdates(t,e){return p({...t,updates:t.updates?p([...t.updates,...e]):e})}}),Dh=p({is(t){return t.kind==="UsingNode"},create(t){return p({kind:"UsingNode",tables:p(t)})},cloneWithTables(t,e){return p({...t,tables:p([...t.tables,...e])})}}),Ea=p({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return p({kind:"DeleteQueryNode",from:lc.create(t),...e&&{with:e}})},cloneWithOrderByItem(t,e){return p({...t,orderBy:t.orderBy?Bo.cloneWithItem(t.orderBy,e):Bo.create(e)})},cloneWithLimit(t,e){return p({...t,limit:e})},cloneWithUsing(t,e){return p({...t,using:t.using!==void 0?Dh.cloneWithTables(t.using,e):Dh.create(e)})}}),tn=p({is(t){return t.kind==="WhereNode"},create(t){return p({kind:"WhereNode",where:t})},cloneWithOperation(t,e,n){return p({...t,where:e==="And"?La.create(t.where,n):Pa.create(t.where,n)})}}),Lh=p({is(t){return t.kind==="ReturningNode"},create(t){return p({kind:"ReturningNode",selections:p(t)})},cloneWithSelections(t,e){return p({...t,selections:t.selections?p([...t.selections,...e]):p(e)})}}),Pg=p({is(t){return t.kind==="ExplainNode"},create(t,e){return p({kind:"ExplainNode",format:t,options:e})}}),ye=p({is(t){return We.is(t)||Or.is(t)||dc.is(t)||Ea.is(t)},cloneWithWhere(t,e){return p({...t,where:t.where?tn.cloneWithOperation(t.where,"And",e):tn.create(e)})},cloneWithOrWhere(t,e){return p({...t,where:t.where?tn.cloneWithOperation(t.where,"Or",e):tn.create(e)})},cloneWithJoin(t,e){return p({...t,joins:t.joins?p([...t.joins,e]):p([e])})},cloneWithReturning(t,e){return p({...t,returning:t.returning?Lh.cloneWithSelections(t.returning,e):Lh.create(e)})},cloneWithoutWhere(t){return p({...t,where:void 0})},cloneWithExplain(t,e,n){return p({...t,explain:Pg.create(e,n==null?void 0:n.toOperationNode())})}}),Mg=p({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return p({kind:"ColumnUpdateNode",column:t,value:e})}});function Hf(t){const e=Vn(t)?t(Qr()):t;return Object.entries(e).filter(([n,i])=>i!==void 0).map(([n,i])=>Mg.create(Nt.create(n),$r(i)))}const Bg=p({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return p({kind:"OnDuplicateKeyNode",updates:t})}});var ja,Ha;class Wp{constructor(e,n){k(this,ja,void 0);k(this,Ha,void 0);P(this,ja,e),P(this,Ha,n)}get insertId(){return r(this,ja)}get numInsertedOrUpdatedRows(){return r(this,Ha)}}ja=new WeakMap,Ha=new WeakMap;for(const t of["insertId","numInsertedOrUpdatedRows"])Object.defineProperty(Wp.prototype,t,{enumerable:!0});class gl extends Error{constructor(n){super("no result");Yt(this,"node");this.node=n}}function bl(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const at=p({is(t){return t.kind==="OnConflictNode"},create(){return p({kind:"OnConflictNode"})},cloneWith(t,e){return p({...t,...e})},cloneWithIndexWhere(t,e){return p({...t,indexWhere:t.indexWhere?tn.cloneWithOperation(t.indexWhere,"And",e):tn.create(e)})},cloneWithIndexOrWhere(t,e){return p({...t,indexWhere:t.indexWhere?tn.cloneWithOperation(t.indexWhere,"Or",e):tn.create(e)})},cloneWithUpdateWhere(t,e){return p({...t,updateWhere:t.updateWhere?tn.cloneWithOperation(t.updateWhere,"And",e):tn.create(e)})},cloneWithUpdateOrWhere(t,e){return p({...t,updateWhere:t.updateWhere?tn.cloneWithOperation(t.updateWhere,"Or",e):tn.create(e)})},cloneWithoutIndexWhere(t){return p({...t,indexWhere:void 0})},cloneWithoutUpdateWhere(t){return p({...t,updateWhere:void 0})}});var Se;const cn=class{constructor(e){k(this,Se,void 0);P(this,Se,p(e))}column(e){const n=Nt.create(e);return new cn({...r(this,Se),onConflictNode:at.cloneWith(r(this,Se).onConflictNode,{columns:r(this,Se).onConflictNode.columns?p([...r(this,Se).onConflictNode.columns,n]):p([n])})})}columns(e){const n=e.map(Nt.create);return new cn({...r(this,Se),onConflictNode:at.cloneWith(r(this,Se).onConflictNode,{columns:r(this,Se).onConflictNode.columns?p([...r(this,Se).onConflictNode.columns,...n]):p(n)})})}constraint(e){return new cn({...r(this,Se),onConflictNode:at.cloneWith(r(this,Se).onConflictNode,{constraint:mt.create(e)})})}expression(e){return new cn({...r(this,Se),onConflictNode:at.cloneWith(r(this,Se).onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new cn({...r(this,Se),onConflictNode:at.cloneWithIndexWhere(r(this,Se).onConflictNode,Rn(e))})}whereRef(e,n,i){return new cn({...r(this,Se),onConflictNode:at.cloneWithIndexWhere(r(this,Se).onConflictNode,zt(e,n,i))})}orWhere(...e){return new cn({...r(this,Se),onConflictNode:at.cloneWithIndexOrWhere(r(this,Se).onConflictNode,Rn(e))})}orWhereRef(e,n,i){return new cn({...r(this,Se),onConflictNode:at.cloneWithIndexOrWhere(r(this,Se).onConflictNode,zt(e,n,i))})}whereExists(e){return new cn({...r(this,Se),onConflictNode:at.cloneWithIndexWhere(r(this,Se).onConflictNode,sn(e))})}whereNotExists(e){return new cn({...r(this,Se),onConflictNode:at.cloneWithIndexWhere(r(this,Se).onConflictNode,Vt(e))})}orWhereExists(e){return new cn({...r(this,Se),onConflictNode:at.cloneWithIndexOrWhere(r(this,Se).onConflictNode,sn(e))})}orWhereNotExists(e){return new cn({...r(this,Se),onConflictNode:at.cloneWithIndexOrWhere(r(this,Se).onConflictNode,Vt(e))})}clearWhere(){return new cn({...r(this,Se),onConflictNode:at.cloneWithoutIndexWhere(r(this,Se).onConflictNode)})}doNothing(){return new Ip({...r(this,Se),onConflictNode:at.cloneWith(r(this,Se).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new mc({...r(this,Se),onConflictNode:at.cloneWith(r(this,Se).onConflictNode,{updates:Hf(e)})})}$call(e){return e(this)}};let pc=cn;Se=new WeakMap;$e(pc,"don't await OnConflictBuilder instances.");var Va;class Ip{constructor(e){k(this,Va,void 0);P(this,Va,p(e))}toOperationNode(){return r(this,Va).onConflictNode}}Va=new WeakMap;$e(Ip,"don't await OnConflictDoNothingBuilder instances.");var ht;const nr=class{constructor(e){k(this,ht,void 0);P(this,ht,p(e))}where(...e){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateWhere(r(this,ht).onConflictNode,Rn(e))})}whereRef(e,n,i){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateWhere(r(this,ht).onConflictNode,zt(e,n,i))})}orWhere(...e){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateOrWhere(r(this,ht).onConflictNode,Rn(e))})}orWhereRef(e,n,i){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateOrWhere(r(this,ht).onConflictNode,zt(e,n,i))})}whereExists(e){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateWhere(r(this,ht).onConflictNode,sn(e))})}whereNotExists(e){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateWhere(r(this,ht).onConflictNode,Vt(e))})}orWhereExists(e){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateOrWhere(r(this,ht).onConflictNode,sn(e))})}orWhereNotExists(e){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateOrWhere(r(this,ht).onConflictNode,Vt(e))})}clearWhere(){return new nr({...r(this,ht),onConflictNode:at.cloneWithoutUpdateWhere(r(this,ht).onConflictNode)})}$call(e){return e(this)}toOperationNode(){return r(this,ht).onConflictNode}};let mc=nr;ht=new WeakMap;$e(mc,"don't await OnConflictUpdateBuilder instances.");var Te;const Tt=class{constructor(e){k(this,Te,void 0);P(this,Te,p(e))}values(e){const[n,i]=Sg(e);return new Tt({...r(this,Te),queryNode:Or.cloneWith(r(this,Te).queryNode,{columns:n,values:i})})}columns(e){return new Tt({...r(this,Te),queryNode:Or.cloneWith(r(this,Te).queryNode,{columns:p(e.map(Nt.create))})})}expression(e){return new Tt({...r(this,Te),queryNode:Or.cloneWith(r(this,Te).queryNode,{values:_l(e)})})}ignore(){return new Tt({...r(this,Te),queryNode:Or.cloneWith(r(this,Te).queryNode,{ignore:!0})})}onConflict(e){return new Tt({...r(this,Te),queryNode:Or.cloneWith(r(this,Te).queryNode,{onConflict:e(new pc({onConflictNode:at.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new Tt({...r(this,Te),queryNode:Or.cloneWith(r(this,Te).queryNode,{onDuplicateKey:Bg.create(Hf(e))})})}returning(e){return new Tt({...r(this,Te),queryNode:ye.cloneWithReturning(r(this,Te).queryNode,gu(e))})}returningAll(){return new Tt({...r(this,Te),queryNode:ye.cloneWithReturning(r(this,Te).queryNode,bu())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,n){return e?n(this):new Tt({...r(this,Te)})}if(e,n){return e?n(this):new Tt({...r(this,Te)})}$castTo(){return new Tt(r(this,Te))}castTo(){return this.$castTo()}$narrowType(){return new Tt(r(this,Te))}$assertType(){return new Tt(r(this,Te))}assertType(){return new Tt(r(this,Te))}withPlugin(e){return new Tt({...r(this,Te),executor:r(this,Te).executor.withPlugin(e)})}toOperationNode(){return r(this,Te).executor.transformQuery(r(this,Te).queryNode,r(this,Te).queryId)}compile(){return r(this,Te).executor.compileQuery(this.toOperationNode(),r(this,Te).queryId)}async execute(){const e=this.compile(),n=e.query,i=await r(this,Te).executor.executeQuery(e,r(this,Te).queryId);return r(this,Te).executor.adapter.supportsReturning&&n.returning?i.rows:[new Wp(i.insertId,i.numAffectedRows??i.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=gl){const n=await this.executeTakeFirst();if(n===void 0)throw bl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),i=r(this,Te).executor.stream(n,e,r(this,Te).queryId);for await(const a of i)yield*a.rows}async explain(e,n){return await new Tt({...r(this,Te),queryNode:ye.cloneWithExplain(r(this,Te).queryNode,e,n)}).execute()}};let Ba=Tt;Te=new WeakMap;$e(Ba,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");var za;class Ap{constructor(e){k(this,za,void 0);P(this,za,e)}get numDeletedRows(){return r(this,za)}}za=new WeakMap;Object.defineProperty(Ap.prototype,"numDeletedRows",{enumerable:!0});const Tp=p({is(t){return t.kind==="LimitNode"},create(t){return p({kind:"LimitNode",limit:Ar.create(t)})}});var de;const Xe=class{constructor(e){k(this,de,void 0);P(this,de,p(e))}where(...e){return new Xe({...r(this,de),queryNode:ye.cloneWithWhere(r(this,de).queryNode,Rn(e))})}whereRef(e,n,i){return new Xe({...r(this,de),queryNode:ye.cloneWithWhere(r(this,de).queryNode,zt(e,n,i))})}orWhere(...e){return new Xe({...r(this,de),queryNode:ye.cloneWithOrWhere(r(this,de).queryNode,Rn(e))})}orWhereRef(e,n,i){return new Xe({...r(this,de),queryNode:ye.cloneWithOrWhere(r(this,de).queryNode,zt(e,n,i))})}whereExists(e){return new Xe({...r(this,de),queryNode:ye.cloneWithWhere(r(this,de).queryNode,sn(e))})}whereNotExists(e){return new Xe({...r(this,de),queryNode:ye.cloneWithWhere(r(this,de).queryNode,Vt(e))})}orWhereExists(e){return new Xe({...r(this,de),queryNode:ye.cloneWithOrWhere(r(this,de).queryNode,sn(e))})}orWhereNotExists(e){return new Xe({...r(this,de),queryNode:ye.cloneWithOrWhere(r(this,de).queryNode,Vt(e))})}clearWhere(){return new Xe({...r(this,de),queryNode:ye.cloneWithoutWhere(r(this,de).queryNode)})}using(e){return new Xe({...r(this,de),queryNode:Ea.cloneWithUsing(r(this,de).queryNode,Uo(e))})}innerJoin(...e){return new Xe({...r(this,de),queryNode:ye.cloneWithJoin(r(this,de).queryNode,vn("InnerJoin",e))})}leftJoin(...e){return new Xe({...r(this,de),queryNode:ye.cloneWithJoin(r(this,de).queryNode,vn("LeftJoin",e))})}rightJoin(...e){return new Xe({...r(this,de),queryNode:ye.cloneWithJoin(r(this,de).queryNode,vn("RightJoin",e))})}fullJoin(...e){return new Xe({...r(this,de),queryNode:ye.cloneWithJoin(r(this,de).queryNode,vn("FullJoin",e))})}returning(e){return new Xe({...r(this,de),queryNode:ye.cloneWithReturning(r(this,de).queryNode,gu(e))})}returningAll(e){return new Xe({...r(this,de),queryNode:ye.cloneWithReturning(r(this,de).queryNode,bu(e))})}orderBy(e,n){return new Xe({...r(this,de),queryNode:Ea.cloneWithOrderByItem(r(this,de).queryNode,wl(e,n))})}limit(e){return new Xe({...r(this,de),queryNode:Ea.cloneWithLimit(r(this,de).queryNode,Tp.create(e))})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,n){return e?n(this):new Xe({...r(this,de)})}if(e,n){return this.$if(e,n)}$castTo(){return new Xe(r(this,de))}castTo(){return this.$castTo()}$narrowType(){return new Xe(r(this,de))}$assertType(){return new Xe(r(this,de))}assertType(){return new Xe(r(this,de))}withPlugin(e){return new Xe({...r(this,de),executor:r(this,de).executor.withPlugin(e)})}toOperationNode(){return r(this,de).executor.transformQuery(r(this,de).queryNode,r(this,de).queryId)}compile(){return r(this,de).executor.compileQuery(this.toOperationNode(),r(this,de).queryId)}async execute(){const e=this.compile(),n=e.query,i=await r(this,de).executor.executeQuery(e,r(this,de).queryId);return r(this,de).executor.adapter.supportsReturning&&n.returning?i.rows:[new Ap(i.numAffectedRows??i.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=gl){const n=await this.executeTakeFirst();if(n===void 0)throw bl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),i=r(this,de).executor.stream(n,e,r(this,de).queryId);for await(const a of i)yield*a.rows}async explain(e,n){return await new Xe({...r(this,de),queryNode:ye.cloneWithExplain(r(this,de).queryNode,e,n)}).execute()}};let yc=Xe;de=new WeakMap;$e(yc,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");var Ka;class kp{constructor(e){k(this,Ka,void 0);P(this,Ka,e)}get numUpdatedRows(){return r(this,Ka)}}Ka=new WeakMap;Object.defineProperty(kp.prototype,"numUpdatedRows",{enumerable:!0});var pe;const nt=class{constructor(e){k(this,pe,void 0);P(this,pe,p(e))}where(...e){return new nt({...r(this,pe),queryNode:ye.cloneWithWhere(r(this,pe).queryNode,Rn(e))})}whereRef(e,n,i){return new nt({...r(this,pe),queryNode:ye.cloneWithWhere(r(this,pe).queryNode,zt(e,n,i))})}orWhere(...e){return new nt({...r(this,pe),queryNode:ye.cloneWithOrWhere(r(this,pe).queryNode,Rn(e))})}orWhereRef(e,n,i){return new nt({...r(this,pe),queryNode:ye.cloneWithOrWhere(r(this,pe).queryNode,zt(e,n,i))})}whereExists(e){return new nt({...r(this,pe),queryNode:ye.cloneWithWhere(r(this,pe).queryNode,sn(e))})}whereNotExists(e){return new nt({...r(this,pe),queryNode:ye.cloneWithWhere(r(this,pe).queryNode,Vt(e))})}orWhereExists(e){return new nt({...r(this,pe),queryNode:ye.cloneWithOrWhere(r(this,pe).queryNode,sn(e))})}orWhereNotExists(e){return new nt({...r(this,pe),queryNode:ye.cloneWithOrWhere(r(this,pe).queryNode,Vt(e))})}clearWhere(){return new nt({...r(this,pe),queryNode:ye.cloneWithoutWhere(r(this,pe).queryNode)})}from(e){return new nt({...r(this,pe),queryNode:dc.cloneWithFromItems(r(this,pe).queryNode,Uo(e))})}innerJoin(...e){return new nt({...r(this,pe),queryNode:ye.cloneWithJoin(r(this,pe).queryNode,vn("InnerJoin",e))})}leftJoin(...e){return new nt({...r(this,pe),queryNode:ye.cloneWithJoin(r(this,pe).queryNode,vn("LeftJoin",e))})}rightJoin(...e){return new nt({...r(this,pe),queryNode:ye.cloneWithJoin(r(this,pe).queryNode,vn("RightJoin",e))})}fullJoin(...e){return new nt({...r(this,pe),queryNode:ye.cloneWithJoin(r(this,pe).queryNode,vn("FullJoin",e))})}set(e){return new nt({...r(this,pe),queryNode:dc.cloneWithUpdates(r(this,pe).queryNode,Hf(e))})}returning(e){return new nt({...r(this,pe),queryNode:ye.cloneWithReturning(r(this,pe).queryNode,gu(e))})}returningAll(){return new nt({...r(this,pe),queryNode:ye.cloneWithReturning(r(this,pe).queryNode,bu())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,n){return e?n(this):new nt({...r(this,pe)})}if(e,n){return this.$if(e,n)}$castTo(){return new nt(r(this,pe))}castTo(){return this.$castTo()}$narrowType(){return new nt(r(this,pe))}$assertType(){return new nt(r(this,pe))}assertType(){return new nt(r(this,pe))}withPlugin(e){return new nt({...r(this,pe),executor:r(this,pe).executor.withPlugin(e)})}toOperationNode(){return r(this,pe).executor.transformQuery(r(this,pe).queryNode,r(this,pe).queryId)}compile(){return r(this,pe).executor.compileQuery(this.toOperationNode(),r(this,pe).queryId)}async execute(){const e=this.compile(),n=e.query,i=await r(this,pe).executor.executeQuery(e,r(this,pe).queryId);return r(this,pe).executor.adapter.supportsReturning&&n.returning?i.rows:[new kp(i.numAffectedRows??i.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=gl){const n=await this.executeTakeFirst();if(n===void 0)throw bl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),i=r(this,pe).executor.stream(n,e,r(this,pe).queryId);for await(const a of i)yield*a.rows}async explain(e,n){return await new nt({...r(this,pe),queryNode:ye.cloneWithExplain(r(this,pe).queryNode,e,n)}).execute()}};let wc=nt;pe=new WeakMap;$e(wc,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");const Fg=p({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return p({kind:"CommonTableExpressionNode",name:t,expression:e})}}),Ph=p({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return p({kind:"CommonTableExpressionNameNode",table:vi.create(t),columns:e?p(e.map(Nt.create)):void 0})}});function Mh(t,e){const n=e(Gg());return Fg.create(Ug(t),n.toOperationNode())}function Ug(t){if(t.includes("(")){const e=t.split(/[\(\)]/),n=e[0],i=e[1].split(",").map(a=>a.trim());return Ph.create(n,i)}else return Ph.create(t)}const Vu=p({is(t){return t.kind==="WithNode"},create(t,e){return p({kind:"WithNode",expressions:p([t]),...e})},cloneWithExpression(t,e){return p({...t,expressions:p([...t.expressions,e])})}}),Bh=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function $g(t){let e="";for(let n=0;nthis.transformNode(n)))}transformSelectQuery(e){return{kind:"SelectQueryNode",from:this.transformNode(e.from),selections:this.transformNodeList(e.selections),distinctOn:this.transformNodeList(e.distinctOn),joins:this.transformNodeList(e.joins),groupBy:this.transformNode(e.groupBy),orderBy:this.transformNode(e.orderBy),where:this.transformNode(e.where),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),limit:this.transformNode(e.limit),offset:this.transformNode(e.offset),with:this.transformNode(e.with),having:this.transformNode(e.having),explain:this.transformNode(e.explain),setOperations:this.transformNodeList(e.setOperations)}}transformSelection(e){return{kind:"SelectionNode",selection:this.transformNode(e.selection)}}transformColumn(e){return{kind:"ColumnNode",column:this.transformNode(e.column)}}transformAlias(e){return{kind:"AliasNode",node:this.transformNode(e.node),alias:this.transformNode(e.alias)}}transformTable(e){return{kind:"TableNode",table:this.transformNode(e.table)}}transformFrom(e){return{kind:"FromNode",froms:this.transformNodeList(e.froms)}}transformReference(e){return{kind:"ReferenceNode",table:this.transformNode(e.table),column:this.transformNode(e.column)}}transformAnd(e){return{kind:"AndNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformOr(e){return{kind:"OrNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformValueList(e){return{kind:"ValueListNode",values:this.transformNodeList(e.values)}}transformParens(e){return{kind:"ParensNode",node:this.transformNode(e.node)}}transformJoin(e){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table),on:this.transformNode(e.on)}}transformRaw(e){return{kind:"RawNode",sqlFragments:p([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters)}}transformWhere(e){return{kind:"WhereNode",where:this.transformNode(e.where)}}transformInsertQuery(e){return{kind:"InsertQueryNode",into:this.transformNode(e.into),columns:this.transformNodeList(e.columns),values:this.transformNode(e.values),returning:this.transformNode(e.returning),onConflict:this.transformNode(e.onConflict),onDuplicateKey:this.transformNode(e.onDuplicateKey),with:this.transformNode(e.with),ignore:e.ignore,replace:e.replace,explain:this.transformNode(e.explain)}}transformValues(e){return{kind:"ValuesNode",values:this.transformNodeList(e.values)}}transformDeleteQuery(e){return{kind:"DeleteQueryNode",from:this.transformNode(e.from),using:this.transformNode(e.using),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),returning:this.transformNode(e.returning),with:this.transformNode(e.with),orderBy:this.transformNode(e.orderBy),limit:this.transformNode(e.limit),explain:this.transformNode(e.explain)}}transformReturning(e){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections)}}transformCreateTable(e){return{kind:"CreateTableNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),constraints:this.transformNodeList(e.constraints),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers)}}transformColumnDefinition(e){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),references:this.transformNode(e.references),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo),check:this.transformNode(e.check),generated:this.transformNode(e.generated),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers)}}transformAddColumn(e){return{kind:"AddColumnNode",column:this.transformNode(e.column)}}transformDropTable(e){return{kind:"DropTableNode",table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e){return{kind:"OrderByNode",items:this.transformNodeList(e.items)}}transformOrderByItem(e){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy),direction:this.transformNode(e.direction)}}transformGroupBy(e){return{kind:"GroupByNode",items:this.transformNodeList(e.items)}}transformGroupByItem(e){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy)}}transformUpdateQuery(e){return{kind:"UpdateQueryNode",table:this.transformNode(e.table),from:this.transformNode(e.from),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),updates:this.transformNodeList(e.updates),returning:this.transformNode(e.returning),with:this.transformNode(e.with),explain:this.transformNode(e.explain)}}transformColumnUpdate(e){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column),value:this.transformNode(e.value)}}transformLimit(e){return{kind:"LimitNode",limit:this.transformNode(e.limit)}}transformOffset(e){return{kind:"OffsetNode",offset:this.transformNode(e.offset)}}transformOnConflict(e){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns),constraint:this.transformNode(e.constraint),indexExpression:this.transformNode(e.indexExpression),indexWhere:this.transformNode(e.indexWhere),updates:this.transformNodeList(e.updates),updateWhere:this.transformNode(e.updateWhere),doNothing:e.doNothing}}transformOnDuplicateKey(e){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates)}}transformCreateIndex(e){return{kind:"CreateIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists,where:this.transformNode(e.where)}}transformList(e){return{kind:"ListNode",items:this.transformNodeList(e.items)}}transformDropIndex(e){return{kind:"DropIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformUniqueConstraint(e){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformForeignKeyConstraint(e){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns),references:this.transformNode(e.references),name:this.transformNode(e.name),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformSetOperation(e){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression),all:e.all}}transformReferences(e){return{kind:"ReferencesNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression),name:this.transformNode(e.name)}}transformWith(e){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions),recursive:e.recursive}}transformCommonTableExpression(e){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name),expression:this.transformNode(e.expression)}}transformCommonTableExpressionName(e){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns)}}transformHaving(e){return{kind:"HavingNode",having:this.transformNode(e.having)}}transformCreateSchema(e){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema),ifNotExists:e.ifNotExists}}transformDropSchema(e){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e){return{kind:"AlterTableNode",table:this.transformNode(e.table),renameTo:this.transformNode(e.renameTo),setSchema:this.transformNode(e.setSchema),columnAlterations:this.transformNodeList(e.columnAlterations),addConstraint:this.transformNode(e.addConstraint),dropConstraint:this.transformNode(e.dropConstraint)}}transformDropColumn(e){return{kind:"DropColumnNode",column:this.transformNode(e.column)}}transformRenameColumn(e){return{kind:"RenameColumnNode",column:this.transformNode(e.column),renameTo:this.transformNode(e.renameTo)}}transformAlterColumn(e){return{kind:"AlterColumnNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),dataTypeExpression:this.transformNode(e.dataTypeExpression),setDefault:this.transformNode(e.setDefault),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e){return{kind:"ModifyColumnNode",column:this.transformNode(e.column)}}transformAddConstraint(e){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint)}}transformDropConstraint(e){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName),ifExists:e.ifExists,modifier:e.modifier}}transformCreateView(e){return{kind:"CreateViewNode",name:this.transformNode(e.name),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns),as:this.transformNode(e.as)}}transformDropView(e){return{kind:"DropViewNode",name:this.transformNode(e.name),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression)}}transformDefaultValue(e){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue)}}transformOn(e){return{kind:"OnNode",on:this.transformNode(e.on)}}transformSelectModifier(e){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier)}}transformCreateType(e){return{kind:"CreateTypeNode",name:this.transformNode(e.name),enum:this.transformNode(e.enum)}}transformDropType(e){return{kind:"DropTypeNode",name:this.transformNode(e.name),ifExists:e.ifExists}}transformExplain(e){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options)}}transformSchemableIdentifier(e){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema),identifier:this.transformNode(e.identifier)}}transformAggregateFunction(e){return{kind:"AggregateFunctionNode",aggregated:this.transformNodeList(e.aggregated),distinct:e.distinct,filter:this.transformNode(e.filter),func:e.func,over:this.transformNode(e.over)}}transformOver(e){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy),partitionBy:this.transformNode(e.partitionBy)}}transformPartitionBy(e){return{kind:"PartitionByNode",items:this.transformNodeList(e.items)}}transformPartitionByItem(e){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy)}}transformBinaryOperation(e){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand),operator:this.transformNode(e.operator),rightOperand:this.transformNode(e.rightOperand)}}transformUnaryOperation(e){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator),operand:this.transformNode(e.operand)}}transformUsing(e){return{kind:"UsingNode",tables:this.transformNodeList(e.tables)}}transformFunction(e){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments)}}transformCase(e){return{kind:"CaseNode",value:this.transformNode(e.value),when:this.transformNodeList(e.when),else:this.transformNode(e.else),isStatement:e.isStatement}}transformWhen(e){return{kind:"WhenNode",condition:this.transformNode(e.condition),result:this.transformNode(e.result)}}transformDataType(e){return e}transformSelectAll(e){return e}transformIdentifier(e){return e}transformValue(e){return e}transformPrimitiveValueList(e){return e}transformOperator(e){return e}transformDefaultInsertValue(e){return e}}Dc=new WeakMap;const Hg=p({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0});var oo,is,Lc,Sp,Pc,Rp,ss,ga,Ja,af,Mc,Dp;class Vg extends Vf{constructor(n){super();k(this,Lc);k(this,Pc);k(this,ss);k(this,Ja);k(this,Mc);k(this,oo,void 0);k(this,is,new Set);P(this,oo,n)}transformNodeImpl(n){if(!Oe(this,Lc,Sp).call(this,n))return super.transformNodeImpl(n);const i=Oe(this,Pc,Rp).call(this,n);for(const l of i)r(this,is).add(l);const a=super.transformNodeImpl(n);for(const l of i)r(this,is).delete(l);return a}transformSchemableIdentifier(n){const i=super.transformSchemableIdentifier(n);return i.schema||!r(this,is).has(n.identifier.name)?i:{...i,schema:mt.create(r(this,oo))}}transformReferences(n){const i=super.transformReferences(n);return i.table.table.schema?i:{...i,table:vi.createWithSchema(r(this,oo),i.table.table.identifier.name)}}}oo=new WeakMap,is=new WeakMap,Lc=new WeakSet,Sp=function(n){return n.kind in Hg},Pc=new WeakSet,Rp=function(n){const i=new Set;if("name"in n&&n.name&&Ei.is(n.name)&&Oe(this,Ja,af).call(this,n.name,i),"from"in n&&n.from)for(const a of n.from.froms)Oe(this,ss,ga).call(this,a,i);if("into"in n&&n.into&&Oe(this,ss,ga).call(this,n.into,i),"table"in n&&n.table&&Oe(this,ss,ga).call(this,n.table,i),"joins"in n&&n.joins)for(const a of n.joins)Oe(this,ss,ga).call(this,a.table,i);return"with"in n&&n.with&&Oe(this,Mc,Dp).call(this,n.with,i),i},ss=new WeakSet,ga=function(n,i){const a=vi.is(n)?n:Es.is(n)&&vi.is(n.node)?n.node:null;a&&Oe(this,Ja,af).call(this,a.table,i)},Ja=new WeakSet,af=function(n,i){r(this,is).has(n.identifier.name)||i.add(n.identifier.name)},Mc=new WeakSet,Dp=function(n,i){for(const a of n.expressions)i.delete(a.name.table.table.identifier.name)};var Ga;class Nu{constructor(e){k(this,Ga,void 0);P(this,Ga,new Vg(e))}transformQuery(e){return r(this,Ga).transformNode(e.node)}async transformResult(e){return e.result}}Ga=new WeakMap;var rt;const es=class{constructor(e){k(this,rt,void 0);P(this,rt,p(e))}selectFrom(e){return new Fo({queryId:et(),executor:r(this,rt).executor,queryNode:We.create(Uo(e),r(this,rt).withNode)})}insertInto(e){return new Ba({queryId:et(),executor:r(this,rt).executor,queryNode:Or.create(_n(e),r(this,rt).withNode)})}replaceInto(e){return new Ba({queryId:et(),executor:r(this,rt).executor,queryNode:Or.create(_n(e),r(this,rt).withNode,!0)})}deleteFrom(e){return new yc({queryId:et(),executor:r(this,rt).executor,queryNode:Ea.create(Uo(e),r(this,rt).withNode)})}updateTable(e){return new wc({queryId:et(),executor:r(this,rt).executor,queryNode:dc.create(Ua(e),r(this,rt).withNode)})}with(e,n){const i=Mh(e,n);return new es({...r(this,rt),withNode:r(this,rt).withNode?Vu.cloneWithExpression(r(this,rt).withNode,i):Vu.create(i)})}withRecursive(e,n){const i=Mh(e,n);return new es({...r(this,rt),withNode:r(this,rt).withNode?Vu.cloneWithExpression(r(this,rt).withNode,i):Vu.create(i,{recursive:!0})})}withPlugin(e){return new es({...r(this,rt),executor:r(this,rt).executor.withPlugin(e)})}withoutPlugins(){return new es({...r(this,rt),executor:r(this,rt).executor.withoutPlugins()})}withSchema(e){return new es({...r(this,rt),executor:r(this,rt).executor.withPluginAtFront(new Nu(e))})}};let gc=es;rt=new WeakMap;var Xa,ao,uo;class Fh{constructor(){k(this,Xa,void 0);k(this,ao,void 0);k(this,uo,void 0);Yt(this,"resolve",e=>{r(this,ao)&&r(this,ao).call(this,e)});Yt(this,"reject",e=>{r(this,uo)&&r(this,uo).call(this,e)});P(this,Xa,new Promise((e,n)=>{P(this,uo,n),P(this,ao,e)}))}get promise(){return r(this,Xa)}}Xa=new WeakMap,ao=new WeakMap,uo=new WeakMap;const Uh=new Set;function zg(t){Uh.has(t)||(Uh.add(t),console.log(t))}const Kg=p([]);var os,Ya,uf;class Lp{constructor(e=Kg){k(this,Ya);k(this,os,void 0);P(this,os,e)}get plugins(){return r(this,os)}transformQuery(e,n){for(const i of r(this,os)){const a=i.transformQuery({node:e,queryId:n});if(a.kind===e.kind)e=a;else throw new Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${e.kind}`,`but it returned a ${a.kind}`].join(" "))}return e}async executeQuery(e,n){return await this.provideConnection(async i=>{const a=await i.executeQuery(e),l=await Oe(this,Ya,uf).call(this,a,n);return Jg(a,l),l})}async*stream(e,n,i){const a=new Fh,l=new Fh;this.provideConnection(async g=>(a.resolve(g),await l.promise)).catch(g=>a.reject(g));const m=await a.promise;try{for await(const g of m.streamQuery(e,n))yield await Oe(this,Ya,uf).call(this,g,i)}finally{l.resolve()}}}os=new WeakMap,Ya=new WeakSet,uf=async function(e,n){for(const i of r(this,os))e=await i.transformResult({result:e,queryId:n});return e};function Jg(t,e){const{numAffectedRows:n}=t;n===void 0&&t.numUpdatedOrDeletedRows===void 0||n!==void 0&&e.numAffectedRows!==void 0||zg("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class Js extends Lp{get adapter(){throw new Error("this query cannot be compiled to SQL")}compileQuery(){throw new Error("this query cannot be compiled to SQL")}provideConnection(){throw new Error("this query cannot be executed")}withConnectionProvider(){throw new Error("this query cannot have a connection provider")}withPlugin(e){return new Js([...this.plugins,e])}withPlugins(e){return new Js([...this.plugins,...e])}withPluginAtFront(e){return new Js([e,...this.plugins])}withoutPlugins(){return new Js([])}}const Nl=new Js;function $h(){return new Fo({queryId:et(),executor:Nl,queryNode:We.create(Uo([]))})}function Gg(){return new gc({executor:Nl})}function Pp(t,e){return new fc({joinNode:jn.create(t,Ua(e))})}function Xg(){return new hc({overNode:of.create()})}const zf=p({is(t){return t.kind==="WhenNode"},create(t){return p({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return p({...t,result:e})}}),pr=p({is(t){return t.kind==="CaseNode"},create(t){return p({kind:"CaseNode",value:t})},cloneWithWhen(t,e){return p({...t,when:p(t.when?[...t.when,e]:[e])})},cloneWithThen(t,e){return p({...t,when:t.when?p([...t.when.slice(0,-1),zf.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return p({...t,...e})}});function cf(t,e,n){if(!vp(e)&&!hn(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return eb(e,n)?tb(t,e,n):ml.create(Vr(t),Kf(e),qp(n))}function Yg(t,e,n){if(!vp(e)&&!hn(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return ml.create(Vr(t),Kf(e),Vr(n))}function Zg(t,e,n){if(!_p(e)&&!hn(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return cf(t,e,n)}function zt(t,e,n){if(!_p(e)&&!hn(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return Yg(t,e,n)}function Rn(t){return vl("where",t)}function Qh(t){return vl("having",t)}function jh(t){return vl("on",t)}function Mp(t){return vl("when",t)}function vl(t,e){if(e.length===3)return Zg(e[0],e[1],e[2]);if(e.length===1)return nb(t,e[0]);throw Bp(t,e)}function eb(t,e){return(t==="is"||t==="is not")&&(wp(e)||yp(e))}function tb(t,e,n){return ml.create(Vr(t),Kf(e),Ar.createImmediate(n))}function Kf(t){if(yr(t)&&gg.includes(t))return Ff.create(t);if(hn(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function nb(t,e){if(Vn(e)){if(t==="when")throw new Error("when method doesn't accept a callback as an argument");return rb[t](e)}else if(hn(e)){const n=e.toOperationNode();if(en.is(n)||ml.is(n)||Op.is(n)||ro.is(n)||pr.is(n))return n}else if(t==="when")return Ar.create(e);throw Bp(t,e)}function Bp(t,e){return new Error(`invalid arguments passed to a '${t}' method: ${JSON.stringify(e)}`)}const rb=p({where(t){const e=$h(),n=Qr(),a=t(Object.assign(e,n)).toOperationNode();if(We.is(a)){if(!a.where)throw new Error("no `where` methods called inside a group callback");return ro.create(a.where.where)}else return a},having(t){const e=$h(),n=Qr(),a=t(Object.assign(e,n)).toOperationNode();if(We.is(a)){if(!a.having)throw new Error("no `having` methods called inside a group callback");return ro.create(a.having.having)}else return a},on(t){const e=Pp("InnerJoin","table"),n=Qr(),a=t(Object.assign(e,n)).toOperationNode();if(jn.is(a)){if(!a.on)throw new Error("no `on` methods called inside a group callback");return ro.create(a.on.on)}else return a}});function vn(t,e){if(e.length===3)return sb(t,e[0],e[1],e[2]);if(e.length===2)return ib(t,e[0],e[1]);throw new Error("not implemented")}function ib(t,e,n){return n(Pp(t,e)).toOperationNode()}function sb(t,e,n,i){return jn.createWithOn(t,Ua(e),zt(n,"=",i))}const ob=p({is(t){return t.kind==="OffsetNode"},create(t){return p({kind:"OffsetNode",offset:Ar.create(t)})}}),ab=p({is(t){return t.kind==="GroupByItemNode"},create(t){return p({kind:"GroupByItemNode",groupBy:t})}});function ub(t){return t=Vn(t)?t(Qr()):t,Ma(t).map(ab.create)}const Fp=p({is(t){return t.kind==="SetOperationNode"},create(t,e,n){return p({kind:"SetOperationNode",operator:t,expression:e,all:n})}});function js(t,e,n){return Fp.create(t,e.toOperationNode(),n)}var $;const he=class{constructor(e){k(this,$,void 0);P(this,$,p(e))}get expressionType(){}where(...e){return new he({...r(this,$),queryNode:ye.cloneWithWhere(r(this,$).queryNode,Rn(e))})}whereRef(e,n,i){return new he({...r(this,$),queryNode:ye.cloneWithWhere(r(this,$).queryNode,zt(e,n,i))})}orWhere(...e){return new he({...r(this,$),queryNode:ye.cloneWithOrWhere(r(this,$).queryNode,Rn(e))})}orWhereRef(e,n,i){return new he({...r(this,$),queryNode:ye.cloneWithOrWhere(r(this,$).queryNode,zt(e,n,i))})}whereExists(e){return new he({...r(this,$),queryNode:ye.cloneWithWhere(r(this,$).queryNode,sn(e))})}whereNotExists(e){return new he({...r(this,$),queryNode:ye.cloneWithWhere(r(this,$).queryNode,Vt(e))})}orWhereExists(e){return new he({...r(this,$),queryNode:ye.cloneWithOrWhere(r(this,$).queryNode,sn(e))})}orWhereNotExists(e){return new he({...r(this,$),queryNode:ye.cloneWithOrWhere(r(this,$).queryNode,Vt(e))})}having(...e){return new he({...r(this,$),queryNode:We.cloneWithHaving(r(this,$).queryNode,Qh(e))})}havingRef(e,n,i){return new he({...r(this,$),queryNode:We.cloneWithHaving(r(this,$).queryNode,zt(e,n,i))})}orHaving(...e){return new he({...r(this,$),queryNode:We.cloneWithOrHaving(r(this,$).queryNode,Qh(e))})}orHavingRef(e,n,i){return new he({...r(this,$),queryNode:We.cloneWithOrHaving(r(this,$).queryNode,zt(e,n,i))})}havingExists(e){return new he({...r(this,$),queryNode:We.cloneWithHaving(r(this,$).queryNode,sn(e))})}havingNotExist(e){return new he({...r(this,$),queryNode:We.cloneWithHaving(r(this,$).queryNode,Vt(e))})}havingNotExists(e){return new he({...r(this,$),queryNode:We.cloneWithHaving(r(this,$).queryNode,Vt(e))})}orHavingExists(e){return new he({...r(this,$),queryNode:We.cloneWithOrHaving(r(this,$).queryNode,sn(e))})}orHavingNotExists(e){return new he({...r(this,$),queryNode:We.cloneWithOrHaving(r(this,$).queryNode,Vt(e))})}select(e){return new he({...r(this,$),queryNode:We.cloneWithSelections(r(this,$).queryNode,gu(e))})}distinctOn(e){return new he({...r(this,$),queryNode:We.cloneWithDistinctOn(r(this,$).queryNode,Ma(e))})}modifyFront(e){return new he({...r(this,$),queryNode:We.cloneWithFrontModifier(r(this,$).queryNode,Sr.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new he({...r(this,$),queryNode:We.cloneWithEndModifier(r(this,$).queryNode,Sr.createWithExpression(e.toOperationNode()))})}distinct(){return new he({...r(this,$),queryNode:We.cloneWithFrontModifier(r(this,$).queryNode,Sr.create("Distinct"))})}forUpdate(){return new he({...r(this,$),queryNode:We.cloneWithEndModifier(r(this,$).queryNode,Sr.create("ForUpdate"))})}forShare(){return new he({...r(this,$),queryNode:We.cloneWithEndModifier(r(this,$).queryNode,Sr.create("ForShare"))})}forKeyShare(){return new he({...r(this,$),queryNode:We.cloneWithEndModifier(r(this,$).queryNode,Sr.create("ForKeyShare"))})}forNoKeyUpdate(){return new he({...r(this,$),queryNode:We.cloneWithEndModifier(r(this,$).queryNode,Sr.create("ForNoKeyUpdate"))})}skipLocked(){return new he({...r(this,$),queryNode:We.cloneWithEndModifier(r(this,$).queryNode,Sr.create("SkipLocked"))})}noWait(){return new he({...r(this,$),queryNode:We.cloneWithEndModifier(r(this,$).queryNode,Sr.create("NoWait"))})}selectAll(e){return new he({...r(this,$),queryNode:We.cloneWithSelections(r(this,$).queryNode,bu(e))})}innerJoin(...e){return new he({...r(this,$),queryNode:ye.cloneWithJoin(r(this,$).queryNode,vn("InnerJoin",e))})}leftJoin(...e){return new he({...r(this,$),queryNode:ye.cloneWithJoin(r(this,$).queryNode,vn("LeftJoin",e))})}rightJoin(...e){return new he({...r(this,$),queryNode:ye.cloneWithJoin(r(this,$).queryNode,vn("RightJoin",e))})}fullJoin(...e){return new he({...r(this,$),queryNode:ye.cloneWithJoin(r(this,$).queryNode,vn("FullJoin",e))})}innerJoinLateral(...e){return new he({...r(this,$),queryNode:ye.cloneWithJoin(r(this,$).queryNode,vn("LateralInnerJoin",e))})}leftJoinLateral(...e){return new he({...r(this,$),queryNode:ye.cloneWithJoin(r(this,$).queryNode,vn("LateralLeftJoin",e))})}orderBy(e,n){return new he({...r(this,$),queryNode:We.cloneWithOrderByItem(r(this,$).queryNode,wl(e,n))})}groupBy(e){return new he({...r(this,$),queryNode:We.cloneWithGroupByItems(r(this,$).queryNode,ub(e))})}limit(e){return new he({...r(this,$),queryNode:We.cloneWithLimit(r(this,$).queryNode,Tp.create(e))})}offset(e){return new he({...r(this,$),queryNode:We.cloneWithOffset(r(this,$).queryNode,ob.create(e))})}union(e){return new he({...r(this,$),queryNode:We.cloneWithSetOperation(r(this,$).queryNode,js("union",e,!1))})}unionAll(e){return new he({...r(this,$),queryNode:We.cloneWithSetOperation(r(this,$).queryNode,js("union",e,!0))})}intersect(e){return new he({...r(this,$),queryNode:We.cloneWithSetOperation(r(this,$).queryNode,js("intersect",e,!1))})}intersectAll(e){return new he({...r(this,$),queryNode:We.cloneWithSetOperation(r(this,$).queryNode,js("intersect",e,!0))})}except(e){return new he({...r(this,$),queryNode:We.cloneWithSetOperation(r(this,$).queryNode,js("except",e,!1))})}exceptAll(e){return new he({...r(this,$),queryNode:We.cloneWithSetOperation(r(this,$).queryNode,js("except",e,!0))})}as(e){return new cb(this,e)}clearSelect(){return new he({...r(this,$),queryNode:We.cloneWithoutSelections(r(this,$).queryNode)})}clearWhere(){return new he({...r(this,$),queryNode:ye.cloneWithoutWhere(r(this,$).queryNode)})}clearLimit(){return new he({...r(this,$),queryNode:We.cloneWithoutLimit(r(this,$).queryNode)})}clearOffset(){return new he({...r(this,$),queryNode:We.cloneWithoutOffset(r(this,$).queryNode)})}clearOrderBy(){return new he({...r(this,$),queryNode:We.cloneWithoutOrderBy(r(this,$).queryNode)})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,n){return e?n(this):new he({...r(this,$)})}if(e,n){return this.$if(e,n)}$castTo(){return new he(r(this,$))}castTo(){return this.$castTo()}$narrowType(){return new he(r(this,$))}$assertType(){return new he(r(this,$))}assertType(){return new he(r(this,$))}withPlugin(e){return new he({...r(this,$),executor:r(this,$).executor.withPlugin(e)})}toOperationNode(){return r(this,$).executor.transformQuery(r(this,$).queryNode,r(this,$).queryId)}compile(){return r(this,$).executor.compileQuery(this.toOperationNode(),r(this,$).queryId)}async execute(){const e=this.compile();return(await r(this,$).executor.executeQuery(e,r(this,$).queryId)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=gl){const n=await this.executeTakeFirst();if(n===void 0)throw bl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),i=r(this,$).executor.stream(n,e,r(this,$).queryId);for await(const a of i)yield*a.rows}async explain(e,n){return await new he({...r(this,$),queryNode:ye.cloneWithExplain(r(this,$).queryNode,e,n)}).execute()}};let Fo=he;$=new WeakMap;$e(Fo,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");var co,lo;class cb{constructor(e,n){k(this,co,void 0);k(this,lo,void 0);P(this,co,e),P(this,lo,n)}get expression(){return r(this,co)}get alias(){return r(this,lo)}toOperationNode(){return Es.create(r(this,co).toOperationNode(),mt.create(r(this,lo)))}}co=new WeakMap,lo=new WeakMap;var fo;const Yf=class{constructor(e){k(this,fo,void 0);P(this,fo,e)}get expressionType(){}as(e){return new lb(this,e)}$castTo(){return new Yf(r(this,fo))}toOperationNode(){return r(this,fo)}};let Dt=Yf;fo=new WeakMap;var ho,li;class lb{constructor(e,n){k(this,ho,void 0);k(this,li,void 0);P(this,ho,e),P(this,li,n)}get expression(){return r(this,ho)}get alias(){return r(this,li)}toOperationNode(){return Es.create(r(this,ho).toOperationNode(),hn(r(this,li))?r(this,li).toOperationNode():mt.create(r(this,li)))}}ho=new WeakMap,li=new WeakMap;const Un=p({is(t){return t.kind==="AggregateFunctionNode"},create(t,e=[]){return p({kind:"AggregateFunctionNode",func:t,aggregated:e})},cloneWithDistinct(t){return p({...t,distinct:!0})},cloneWithFilter(t,e){return p({...t,filter:t.filter?tn.cloneWithOperation(t.filter,"And",e):tn.create(e)})},cloneWithOrFilter(t,e){return p({...t,filter:t.filter?tn.cloneWithOperation(t.filter,"Or",e):tn.create(e)})},cloneWithOver(t,e){return p({...t,over:e})}}),fb=p({is(t){return t.kind==="FunctionNode"},create(t,e){return p({kind:"FunctionNode",func:t,arguments:e})}});var st;const $n=class{constructor(e){k(this,st,void 0);P(this,st,p(e))}get expressionType(){}as(e){return new hb(this,e)}distinct(){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithDistinct(r(this,st).aggregateFunctionNode)})}filterWhere(...e){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithFilter(r(this,st).aggregateFunctionNode,Rn(e))})}filterWhereExists(e){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithFilter(r(this,st).aggregateFunctionNode,sn(e))})}filterWhereNotExists(e){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithFilter(r(this,st).aggregateFunctionNode,Vt(e))})}filterWhereRef(e,n,i){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithFilter(r(this,st).aggregateFunctionNode,zt(e,n,i))})}orFilterWhere(...e){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithOrFilter(r(this,st).aggregateFunctionNode,Rn(e))})}orFilterWhereExists(e){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithOrFilter(r(this,st).aggregateFunctionNode,sn(e))})}orFilterWhereNotExists(e){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithOrFilter(r(this,st).aggregateFunctionNode,Vt(e))})}orFilterWhereRef(e,n,i){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithOrFilter(r(this,st).aggregateFunctionNode,zt(e,n,i))})}over(e){const n=Xg();return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithOver(r(this,st).aggregateFunctionNode,(e?e(n):n).toOperationNode())})}$call(e){return e(this)}toOperationNode(){return r(this,st).aggregateFunctionNode}};let Fa=$n;st=new WeakMap;$e(Fa,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");var po,mo;class hb{constructor(e,n){k(this,po,void 0);k(this,mo,void 0);P(this,po,e),P(this,mo,n)}get expression(){return r(this,po)}get alias(){return r(this,mo)}toOperationNode(){return Es.create(r(this,po).toOperationNode(),mt.create(r(this,mo)))}}po=new WeakMap,mo=new WeakMap;function Up(){const t=(n,i)=>new Dt(fb.create(n,Ma(i))),e=(n,i)=>new Fa({aggregateFunctionNode:Un.create(n,i?Ma(i):void 0)});return Object.assign(t,{agg:e,avg(n){return e("avg",[n])},coalesce(n,...i){return t("coalesce",[n,...i])},count(n){return e("count",[n])},countAll(n){return new Fa({aggregateFunctionNode:Un.create("count",bu(n))})},max(n){return e("max",[n])},min(n){return e("min",[n])},sum(n){return e("sum",[n])}})}var yo;class $p{constructor(e){k(this,yo,void 0);P(this,yo,p(e))}when(...e){return new Qp({...r(this,yo),node:pr.cloneWithWhen(r(this,yo).node,zf.create(Mp(e)))})}}yo=new WeakMap;var wo;class Qp{constructor(e){k(this,wo,void 0);P(this,wo,p(e))}then(e){return new db({...r(this,wo),node:pr.cloneWithThen(r(this,wo).node,$r(e))})}}wo=new WeakMap;var xr;class db{constructor(e){k(this,xr,void 0);P(this,xr,p(e))}when(...e){return new Qp({...r(this,xr),node:pr.cloneWithWhen(r(this,xr).node,zf.create(Mp(e)))})}else(e){return new pb({...r(this,xr),node:pr.cloneWith(r(this,xr).node,{else:$r(e)})})}end(){return new Dt(pr.cloneWith(r(this,xr).node,{isStatement:!1}))}endCase(){return new Dt(pr.cloneWith(r(this,xr).node,{isStatement:!0}))}}xr=new WeakMap;var go;class pb{constructor(e){k(this,go,void 0);P(this,go,p(e))}end(){return new Dt(pr.cloneWith(r(this,go).node,{isStatement:!1}))}endCase(){return new Dt(pr.cloneWith(r(this,go).node,{isStatement:!0}))}}go=new WeakMap;function jp(t=Nl){function e(n,i){return new Dt(jf(n,i))}return{get fn(){return Up()},selectFrom(n){return new Fo({queryId:et(),executor:t,queryNode:We.create(Uo(n))})},case(n){return new $p({node:pr.create(_a(n)?void 0:Vr(n))})},ref(n){return new Dt(Mo(n))},val(n){return new Dt(qp(n))},cmpr(n,i,a){return new Dt(cf(n,i,a))},bxp(n,i,a){return new Dt(cf(n,i,a))},unary:e,not(n){return e("not",n)},exists(n){return e("exists",n)},neg(n){return e("-",n)},and(n){if(n.length===0)return new Dt(Ar.createImmediate(!0));if(n.length===1)return new Dt(n[0].toOperationNode());let i=La.create(n[0].toOperationNode(),n[1].toOperationNode());for(let a=2;aUa(e)):[Ua(t)]}function Ua(t){return yr(t)?mb(t):Hp(t)}function mb(t){const e=" as ";if(t.includes(e)){const[n,i]=t.split(e).map(Vp);return Es.create(_n(n),mt.create(i))}else return _n(t)}function _n(t){const e=".";if(t.includes(e)){const[n,i]=t.split(e).map(Vp);return vi.createWithSchema(n,i)}else return vi.create(t)}function Vp(t){return t.trim()}const zp=p({is(t){return t.kind==="AddColumnNode"},create(t){return p({kind:"AddColumnNode",column:t})}}),Yi=p({is(t){return t.kind==="AlterColumnNode"},create(t){return p({kind:"AlterColumnNode",column:Nt.create(t)})},cloneWith(t,e){return p({...t,...e})}}),bt=p({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return p({kind:"ColumnDefinitionNode",column:Nt.create(t),dataType:e})},cloneWithFrontModifier(t,e){return p({...t,frontModifiers:t.frontModifiers?p([...t.frontModifiers,e]):[e]})},cloneWithEndModifier(t,e){return p({...t,endModifiers:t.endModifiers?p([...t.endModifiers,e]):[e]})},cloneWith(t,e){return p({...t,...e})}}),Kp=p({is(t){return t.kind==="DropColumnNode"},create(t){return p({kind:"DropColumnNode",column:Nt.create(t)})}}),Jp=p({is(t){return t.kind==="RenameColumnNode"},create(t,e){return p({kind:"RenameColumnNode",column:Nt.create(t),renameTo:Nt.create(e)})}}),Jf=p({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return p({kind:"CheckConstraintNode",expression:t,name:e?mt.create(e):void 0})}}),yb=["no action","restrict","cascade","set null","set default"],ec=p({is(t){return t.kind==="ReferencesNode"},create(t,e){return p({kind:"ReferencesNode",table:t,columns:p([...e])})},cloneWithOnDelete(t,e){return p({...t,onDelete:e})},cloneWithOnUpdate(t,e){return p({...t,onUpdate:e})}});function Gp(t){return hn(t)?t.toOperationNode():Ar.createImmediate(t)}const zu=p({is(t){return t.kind==="GeneratedNode"},create(t){return p({kind:"GeneratedNode",...t})},createWithExpression(t){return p({kind:"GeneratedNode",always:!0,expression:t})},cloneWith(t,e){return p({...t,...e})}}),wb=p({is(t){return t.kind==="DefaultValueNode"},create(t){return p({kind:"DefaultValueNode",defaultValue:t})}});function bc(t){if(yb.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}var Ye;const kt=class{constructor(e){k(this,Ye,void 0);P(this,Ye,e)}autoIncrement(){return new kt(bt.cloneWith(r(this,Ye),{autoIncrement:!0}))}primaryKey(){return new kt(bt.cloneWith(r(this,Ye),{primaryKey:!0}))}references(e){const n=Mo(e);if(!yl.is(n)||Uf.is(n.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new kt(bt.cloneWith(r(this,Ye),{references:ec.create(n.table,[n.column])}))}onDelete(e){if(!r(this,Ye).references)throw new Error("on delete constraint can only be added for foreign keys");return new kt(bt.cloneWith(r(this,Ye),{references:ec.cloneWithOnDelete(r(this,Ye).references,bc(e))}))}onUpdate(e){if(!r(this,Ye).references)throw new Error("on update constraint can only be added for foreign keys");return new kt(bt.cloneWith(r(this,Ye),{references:ec.cloneWithOnUpdate(r(this,Ye).references,bc(e))}))}unique(){return new kt(bt.cloneWith(r(this,Ye),{unique:!0}))}notNull(){return new kt(bt.cloneWith(r(this,Ye),{notNull:!0}))}unsigned(){return new kt(bt.cloneWith(r(this,Ye),{unsigned:!0}))}defaultTo(e){return new kt(bt.cloneWith(r(this,Ye),{defaultTo:wb.create(Gp(e))}))}check(e){return new kt(bt.cloneWith(r(this,Ye),{check:Jf.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new kt(bt.cloneWith(r(this,Ye),{generated:zu.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new kt(bt.cloneWith(r(this,Ye),{generated:zu.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new kt(bt.cloneWith(r(this,Ye),{generated:zu.create({identity:!0,byDefault:!0})}))}stored(){if(!r(this,Ye).generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new kt(bt.cloneWith(r(this,Ye),{generated:zu.cloneWith(r(this,Ye).generated,{stored:!0})}))}modifyFront(e){return new kt(bt.cloneWithFrontModifier(r(this,Ye),e.toOperationNode()))}modifyEnd(e){return new kt(bt.cloneWithEndModifier(r(this,Ye),e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return r(this,Ye)}};let Ci=kt;Ye=new WeakMap;$e(Ci,"don't await ColumnDefinitionBuilder instances directly.");const Xp=p({is(t){return t.kind==="ModifyColumnNode"},create(t){return p({kind:"ModifyColumnNode",column:t})}}),gb=p({is(t){return t.kind==="DataTypeNode"},create(t){return p({kind:"DataTypeNode",dataType:t})}});function $o(t){return hn(t)?t.toOperationNode():gb.create(t)}const Nc=p({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,n,i){return p({kind:"ForeignKeyConstraintNode",columns:t,references:ec.create(e,n),name:i?mt.create(i):void 0})},cloneWith(t,e){return p({...t,...e})}});var as;const Bc=class{constructor(e){k(this,as,void 0);P(this,as,e)}onDelete(e){return new Bc(Nc.cloneWith(r(this,as),{onDelete:bc(e)}))}onUpdate(e){return new Bc(Nc.cloneWith(r(this,as),{onUpdate:bc(e)}))}$call(e){return e(this)}toOperationNode(){return r(this,as)}};let $a=Bc;as=new WeakMap;$e($a,"don't await ForeignKeyConstraintBuilder instances directly.");const lf=p({is(t){return t.kind==="AddConstraintNode"},create(t){return p({kind:"AddConstraintNode",constraint:t})}}),Yp=p({is(t){return t.kind==="UniqueConstraintNode"},create(t,e){return p({kind:"UniqueConstraintNode",columns:p(t.map(Nt.create)),name:e?mt.create(e):void 0})}}),tc=p({is(t){return t.kind==="DropConstraintNode"},create(t){return p({kind:"DropConstraintNode",constraintName:mt.create(t)})},cloneWith(t,e){return p({...t,...e})}});class El{constructor(e){Yt(this,"alterColumnNode");this.alterColumnNode=e}setDataType(e){return new ya(Yi.cloneWith(this.alterColumnNode,{dataType:$o(e)}))}setDefault(e){return new ya(Yi.cloneWith(this.alterColumnNode,{setDefault:Gp(e)}))}dropDefault(){return new ya(Yi.cloneWith(this.alterColumnNode,{dropDefault:!0}))}setNotNull(){return new ya(Yi.cloneWith(this.alterColumnNode,{setNotNull:!0}))}dropNotNull(){return new ya(Yi.cloneWith(this.alterColumnNode,{dropNotNull:!0}))}$call(e){return e(this)}}class ya extends El{toOperationNode(){return this.alterColumnNode}}var ir;class ba{constructor(e){k(this,ir,void 0);P(this,ir,p(e))}toOperationNode(){return r(this,ir).executor.transformQuery(r(this,ir).node,r(this,ir).queryId)}compile(){return r(this,ir).executor.compileQuery(this.toOperationNode(),r(this,ir).queryId)}async execute(){await r(this,ir).executor.executeQuery(this.compile(),r(this,ir).queryId)}}ir=new WeakMap;$e(ba,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");var Zt;const Fc=class{constructor(e){k(this,Zt,void 0);P(this,Zt,p(e))}onDelete(e){return new Fc({...r(this,Zt),constraintBuilder:r(this,Zt).constraintBuilder.onDelete(e)})}onUpdate(e){return new Fc({...r(this,Zt),constraintBuilder:r(this,Zt).constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return r(this,Zt).executor.transformQuery(Et.cloneWithTableProps(r(this,Zt).node,{addConstraint:lf.create(r(this,Zt).constraintBuilder.toOperationNode())}),r(this,Zt).queryId)}compile(){return r(this,Zt).executor.compileQuery(this.toOperationNode(),r(this,Zt).queryId)}async execute(){await r(this,Zt).executor.executeQuery(this.compile(),r(this,Zt).queryId)}};let vc=Fc;Zt=new WeakMap;$e(vc,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");var _t;const Ca=class{constructor(e){k(this,_t,void 0);P(this,_t,p(e))}ifExists(){return new Ca({...r(this,_t),node:Et.cloneWithTableProps(r(this,_t).node,{dropConstraint:tc.cloneWith(r(this,_t).node.dropConstraint,{ifExists:!0})})})}cascade(){return new Ca({...r(this,_t),node:Et.cloneWithTableProps(r(this,_t).node,{dropConstraint:tc.cloneWith(r(this,_t).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new Ca({...r(this,_t),node:Et.cloneWithTableProps(r(this,_t).node,{dropConstraint:tc.cloneWith(r(this,_t).node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return r(this,_t).executor.transformQuery(r(this,_t).node,r(this,_t).queryId)}compile(){return r(this,_t).executor.compileQuery(this.toOperationNode(),r(this,_t).queryId)}async execute(){await r(this,_t).executor.executeQuery(this.compile(),r(this,_t).queryId)}};let _c=Ca;_t=new WeakMap;$e(_c,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");var ot;class Zp{constructor(e){k(this,ot,void 0);P(this,ot,p(e))}renameTo(e){return new ba({...r(this,ot),node:Et.cloneWithTableProps(r(this,ot).node,{renameTo:_n(e)})})}setSchema(e){return new ba({...r(this,ot),node:Et.cloneWithTableProps(r(this,ot).node,{setSchema:mt.create(e)})})}alterColumn(e,n){const i=n(new El(Yi.create(e)));return new ci({...r(this,ot),node:Et.cloneWithColumnAlteration(r(this,ot).node,i.toOperationNode())})}dropColumn(e){return new ci({...r(this,ot),node:Et.cloneWithColumnAlteration(r(this,ot).node,Kp.create(e))})}renameColumn(e,n){return new ci({...r(this,ot),node:Et.cloneWithColumnAlteration(r(this,ot).node,Jp.create(e,n))})}addColumn(e,n,i=Po){const a=i(new Ci(bt.create(e,$o(n))));return new ci({...r(this,ot),node:Et.cloneWithColumnAlteration(r(this,ot).node,zp.create(a.toOperationNode()))})}modifyColumn(e,n,i=Po){const a=i(new Ci(bt.create(e,$o(n))));return new ci({...r(this,ot),node:Et.cloneWithColumnAlteration(r(this,ot).node,Xp.create(a.toOperationNode()))})}addUniqueConstraint(e,n){return new ba({...r(this,ot),node:Et.cloneWithTableProps(r(this,ot).node,{addConstraint:lf.create(Yp.create(n,e))})})}addCheckConstraint(e,n){return new ba({...r(this,ot),node:Et.cloneWithTableProps(r(this,ot).node,{addConstraint:lf.create(Jf.create(n.toOperationNode(),e))})})}addForeignKeyConstraint(e,n,i,a){return new vc({...r(this,ot),constraintBuilder:new $a(Nc.create(n.map(Nt.create),_n(i),a.map(Nt.create),e))})}dropConstraint(e){return new _c({...r(this,ot),node:Et.cloneWithTableProps(r(this,ot).node,{dropConstraint:tc.create(e)})})}$call(e){return e(this)}call(e){return this.$call(e)}}ot=new WeakMap;var gt;const ts=class{constructor(e){k(this,gt,void 0);P(this,gt,p(e))}alterColumn(e,n){const i=n(new El(Yi.create(e)));return new ts({...r(this,gt),node:Et.cloneWithColumnAlteration(r(this,gt).node,i.toOperationNode())})}dropColumn(e){return new ts({...r(this,gt),node:Et.cloneWithColumnAlteration(r(this,gt).node,Kp.create(e))})}renameColumn(e,n){return new ts({...r(this,gt),node:Et.cloneWithColumnAlteration(r(this,gt).node,Jp.create(e,n))})}addColumn(e,n,i=Po){const a=i(new Ci(bt.create(e,$o(n))));return new ts({...r(this,gt),node:Et.cloneWithColumnAlteration(r(this,gt).node,zp.create(a.toOperationNode()))})}modifyColumn(e,n,i=Po){const a=i(new Ci(bt.create(e,$o(n))));return new ts({...r(this,gt),node:Et.cloneWithColumnAlteration(r(this,gt).node,Xp.create(a.toOperationNode()))})}toOperationNode(){return r(this,gt).executor.transformQuery(r(this,gt).node,r(this,gt).queryId)}compile(){return r(this,gt).executor.compileQuery(this.toOperationNode(),r(this,gt).queryId)}async execute(){await r(this,gt).executor.executeQuery(this.compile(),r(this,gt).queryId)}};let ci=ts;gt=new WeakMap;$e(Zp,"don't await AlterTableBuilder instances");$e(El,"don't await AlterColumnBuilder instances");$e(ci,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class em extends Vf{transformValue(e){return{...super.transformValue(e),immediate:!0}}}var Ze;const vr=class{constructor(e){k(this,Ze,void 0);P(this,Ze,p(e))}ifNotExists(){return new vr({...r(this,Ze),node:ii.cloneWith(r(this,Ze).node,{ifNotExists:!0})})}unique(){return new vr({...r(this,Ze),node:ii.cloneWith(r(this,Ze).node,{unique:!0})})}on(e){return new vr({...r(this,Ze),node:ii.cloneWith(r(this,Ze).node,{table:_n(e)})})}column(e){return new vr({...r(this,Ze),node:ii.cloneWithColumns(r(this,Ze).node,[Ah(e)])})}columns(e){return new vr({...r(this,Ze),node:ii.cloneWithColumns(r(this,Ze).node,e.map(Ah))})}expression(e){return new vr({...r(this,Ze),node:ii.cloneWithColumns(r(this,Ze).node,[e.toOperationNode()])})}using(e){return new vr({...r(this,Ze),node:ii.cloneWith(r(this,Ze).node,{using:en.createWithSql(e)})})}where(...e){const n=new em;return new vr({...r(this,Ze),node:ye.cloneWithWhere(r(this,Ze).node,n.transformNode(Rn(e)))})}$call(e){return e(this)}toOperationNode(){return r(this,Ze).executor.transformQuery(r(this,Ze).node,r(this,Ze).queryId)}compile(){return r(this,Ze).executor.compileQuery(this.toOperationNode(),r(this,Ze).queryId)}async execute(){await r(this,Ze).executor.executeQuery(this.compile(),r(this,Ze).queryId)}};let xc=vr;Ze=new WeakMap;$e(xc,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");var Wn;const Zf=class{constructor(e){k(this,Wn,void 0);P(this,Wn,p(e))}ifNotExists(){return new Zf({...r(this,Wn),node:gp.cloneWith(r(this,Wn).node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return r(this,Wn).executor.transformQuery(r(this,Wn).node,r(this,Wn).queryId)}compile(){return r(this,Wn).executor.compileQuery(this.toOperationNode(),r(this,Wn).queryId)}async execute(){await r(this,Wn).executor.executeQuery(this.compile(),r(this,Wn).queryId)}};let Ec=Zf;Wn=new WeakMap;$e(Ec,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");const bb=p({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return p({kind:"PrimaryKeyConstraintNode",columns:p(t.map(Nt.create)),name:e?mt.create(e):void 0})}});function Nb(t){if(hg.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}var Ue;const Qn=class{constructor(e){k(this,Ue,void 0);P(this,Ue,p(e))}temporary(){return new Qn({...r(this,Ue),node:Zn.cloneWith(r(this,Ue).node,{temporary:!0})})}onCommit(e){return new Qn({...r(this,Ue),node:Zn.cloneWith(r(this,Ue).node,{onCommit:Nb(e)})})}ifNotExists(){return new Qn({...r(this,Ue),node:Zn.cloneWith(r(this,Ue).node,{ifNotExists:!0})})}addColumn(e,n,i=Po){const a=i(new Ci(bt.create(e,$o(n))));return new Qn({...r(this,Ue),node:Zn.cloneWithColumn(r(this,Ue).node,a.toOperationNode())})}addPrimaryKeyConstraint(e,n){return new Qn({...r(this,Ue),node:Zn.cloneWithConstraint(r(this,Ue).node,bb.create(n,e))})}addUniqueConstraint(e,n){return new Qn({...r(this,Ue),node:Zn.cloneWithConstraint(r(this,Ue).node,Yp.create(n,e))})}addCheckConstraint(e,n){return new Qn({...r(this,Ue),node:Zn.cloneWithConstraint(r(this,Ue).node,Jf.create(n.toOperationNode(),e))})}addForeignKeyConstraint(e,n,i,a,l=Po){const m=l(new $a(Nc.create(n.map(Nt.create),_n(i),a.map(Nt.create),e)));return new Qn({...r(this,Ue),node:Zn.cloneWithConstraint(r(this,Ue).node,m.toOperationNode())})}modifyFront(e){return new Qn({...r(this,Ue),node:Zn.cloneWithFrontModifier(r(this,Ue).node,e.toOperationNode())})}modifyEnd(e){return new Qn({...r(this,Ue),node:Zn.cloneWithEndModifier(r(this,Ue).node,e.toOperationNode())})}$call(e){return e(this)}call(e){return this.$call(e)}toOperationNode(){return r(this,Ue).executor.transformQuery(r(this,Ue).node,r(this,Ue).queryId)}compile(){return r(this,Ue).executor.compileQuery(this.toOperationNode(),r(this,Ue).queryId)}async execute(){await r(this,Ue).executor.executeQuery(this.compile(),r(this,Ue).queryId)}};let Cc=Qn;Ue=new WeakMap;$e(Cc,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");var Ut;const qa=class{constructor(e){k(this,Ut,void 0);P(this,Ut,p(e))}on(e){return new qa({...r(this,Ut),node:Zu.cloneWith(r(this,Ut).node,{table:_n(e)})})}ifExists(){return new qa({...r(this,Ut),node:Zu.cloneWith(r(this,Ut).node,{ifExists:!0})})}cascade(){return new qa({...r(this,Ut),node:Zu.cloneWith(r(this,Ut).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return r(this,Ut).executor.transformQuery(r(this,Ut).node,r(this,Ut).queryId)}compile(){return r(this,Ut).executor.compileQuery(this.toOperationNode(),r(this,Ut).queryId)}async execute(){await r(this,Ut).executor.executeQuery(this.compile(),r(this,Ut).queryId)}};let qc=qa;Ut=new WeakMap;$e(qc,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");var ln;const Uc=class{constructor(e){k(this,ln,void 0);P(this,ln,p(e))}ifExists(){return new Uc({...r(this,ln),node:rf.cloneWith(r(this,ln).node,{ifExists:!0})})}cascade(){return new Uc({...r(this,ln),node:rf.cloneWith(r(this,ln).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return r(this,ln).executor.transformQuery(r(this,ln).node,r(this,ln).queryId)}compile(){return r(this,ln).executor.compileQuery(this.toOperationNode(),r(this,ln).queryId)}async execute(){await r(this,ln).executor.executeQuery(this.compile(),r(this,ln).queryId)}};let Oc=Uc;ln=new WeakMap;$e(Oc,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");var fn;const $c=class{constructor(e){k(this,fn,void 0);P(this,fn,p(e))}ifExists(){return new $c({...r(this,fn),node:sf.cloneWith(r(this,fn).node,{ifExists:!0})})}cascade(){return new $c({...r(this,fn),node:sf.cloneWith(r(this,fn).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return r(this,fn).executor.transformQuery(r(this,fn).node,r(this,fn).queryId)}compile(){return r(this,fn).executor.compileQuery(this.toOperationNode(),r(this,fn).queryId)}async execute(){await r(this,fn).executor.executeQuery(this.compile(),r(this,fn).queryId)}};let Wc=$c;fn=new WeakMap;$e(Wc,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");const ai=p({is(t){return t.kind==="CreateViewNode"},create(t){return p({kind:"CreateViewNode",name:Ei.create(t)})},cloneWith(t,e){return p({...t,...e})}});var Qc;class vb{constructor(){k(this,Qc,new em)}transformQuery(e){return r(this,Qc).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}Qc=new WeakMap;var dt;const ui=class{constructor(e){k(this,dt,void 0);P(this,dt,p(e))}temporary(){return new ui({...r(this,dt),node:ai.cloneWith(r(this,dt).node,{temporary:!0})})}materialized(){return new ui({...r(this,dt),node:ai.cloneWith(r(this,dt).node,{materialized:!0})})}ifNotExists(){return new ui({...r(this,dt),node:ai.cloneWith(r(this,dt).node,{ifNotExists:!0})})}orReplace(){return new ui({...r(this,dt),node:ai.cloneWith(r(this,dt).node,{orReplace:!0})})}columns(e){return new ui({...r(this,dt),node:ai.cloneWith(r(this,dt).node,{columns:e.map(Ep)})})}as(e){const n=e.withPlugin(new vb).toOperationNode();return new ui({...r(this,dt),node:ai.cloneWith(r(this,dt).node,{as:n})})}$call(e){return e(this)}toOperationNode(){return r(this,dt).executor.transformQuery(r(this,dt).node,r(this,dt).queryId)}compile(){return r(this,dt).executor.compileQuery(this.toOperationNode(),r(this,dt).queryId)}async execute(){await r(this,dt).executor.executeQuery(this.compile(),r(this,dt).queryId)}};let Ic=ui;dt=new WeakMap;$e(Ic,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const nc=p({is(t){return t.kind==="DropViewNode"},create(t){return p({kind:"DropViewNode",name:Ei.create(t)})},cloneWith(t,e){return p({...t,...e})}});var $t;const Oa=class{constructor(e){k(this,$t,void 0);P(this,$t,p(e))}materialized(){return new Oa({...r(this,$t),node:nc.cloneWith(r(this,$t).node,{materialized:!0})})}ifExists(){return new Oa({...r(this,$t),node:nc.cloneWith(r(this,$t).node,{ifExists:!0})})}cascade(){return new Oa({...r(this,$t),node:nc.cloneWith(r(this,$t).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return r(this,$t).executor.transformQuery(r(this,$t).node,r(this,$t).queryId)}compile(){return r(this,$t).executor.compileQuery(this.toOperationNode(),r(this,$t).queryId)}async execute(){await r(this,$t).executor.executeQuery(this.compile(),r(this,$t).queryId)}};let Ac=Oa;$t=new WeakMap;$e(Ac,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const tm=p({is(t){return t.kind==="CreateTypeNode"},create(t){return p({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return p({...t,enum:Qf.create(e.map(n=>Ar.createImmediate(n)))})}});var In;const eh=class{constructor(e){k(this,In,void 0);P(this,In,p(e))}toOperationNode(){return r(this,In).executor.transformQuery(r(this,In).node,r(this,In).queryId)}asEnum(e){return new eh({...r(this,In),node:tm.cloneWithEnum(r(this,In).node,e)})}$call(e){return e(this)}compile(){return r(this,In).executor.compileQuery(this.toOperationNode(),r(this,In).queryId)}async execute(){await r(this,In).executor.executeQuery(this.compile(),r(this,In).queryId)}};let Tc=eh;In=new WeakMap;$e(Tc,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const nm=p({is(t){return t.kind==="DropTypeNode"},create(t){return p({kind:"DropTypeNode",name:t})},cloneWith(t,e){return p({...t,...e})}});var An;const th=class{constructor(e){k(this,An,void 0);P(this,An,p(e))}ifExists(){return new th({...r(this,An),node:nm.cloneWith(r(this,An).node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return r(this,An).executor.transformQuery(r(this,An).node,r(this,An).queryId)}compile(){return r(this,An).executor.compileQuery(this.toOperationNode(),r(this,An).queryId)}async execute(){await r(this,An).executor.executeQuery(this.compile(),r(this,An).queryId)}};let kc=th;An=new WeakMap;$e(kc,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function Hh(t){const e=".";if(t.includes(e)){const n=t.split(e).map(_b);if(n.length===2)return Ei.createWithSchema(n[0],n[1]);throw new Error(`invalid schemable identifier ${t}`)}else return Ei.create(t)}function _b(t){return t.trim()}var St;const Wa=class{constructor(e){k(this,St,void 0);P(this,St,e)}createTable(e){return new Cc({queryId:et(),executor:r(this,St),node:Zn.create(_n(e))})}dropTable(e){return new Wc({queryId:et(),executor:r(this,St),node:sf.create(_n(e))})}createIndex(e){return new xc({queryId:et(),executor:r(this,St),node:ii.create(e)})}dropIndex(e){return new qc({queryId:et(),executor:r(this,St),node:Zu.create(e)})}createSchema(e){return new Ec({queryId:et(),executor:r(this,St),node:gp.create(e)})}dropSchema(e){return new Oc({queryId:et(),executor:r(this,St),node:rf.create(e)})}alterTable(e){return new Zp({queryId:et(),executor:r(this,St),node:Et.create(_n(e))})}createView(e){return new Ic({queryId:et(),executor:r(this,St),node:ai.create(e)})}dropView(e){return new Ac({queryId:et(),executor:r(this,St),node:nc.create(e)})}createType(e){return new Tc({queryId:et(),executor:r(this,St),node:tm.create(Hh(e))})}dropType(e){return new kc({queryId:et(),executor:r(this,St),node:nm.create(Hh(e))})}withPlugin(e){return new Wa(r(this,St).withPlugin(e))}withoutPlugins(){return new Wa(r(this,St).withoutPlugins())}withSchema(e){return new Wa(r(this,St).withPluginAtFront(new Nu(e)))}};let ff=Wa;St=new WeakMap;class xb{ref(e){return new Ig(e)}}var bo;class Eb{constructor(e){k(this,bo,void 0);P(this,bo,e)}async provideConnection(e){const n=await r(this,bo).acquireConnection();try{return await e(n)}finally{await r(this,bo).releaseConnection(n)}}}bo=new WeakMap;var Er,Cr,Lr;const ns=class extends Lp{constructor(n,i,a,l=[]){super(l);k(this,Er,void 0);k(this,Cr,void 0);k(this,Lr,void 0);P(this,Er,n),P(this,Cr,i),P(this,Lr,a)}get adapter(){return r(this,Cr)}compileQuery(n){return r(this,Er).compileQuery(n)}provideConnection(n){return r(this,Lr).provideConnection(n)}withPlugins(n){return new ns(r(this,Er),r(this,Cr),r(this,Lr),[...this.plugins,...n])}withPlugin(n){return new ns(r(this,Er),r(this,Cr),r(this,Lr),[...this.plugins,n])}withPluginAtFront(n){return new ns(r(this,Er),r(this,Cr),r(this,Lr),[n,...this.plugins])}withConnectionProvider(n){return new ns(r(this,Er),r(this,Cr),n,[...this.plugins])}withoutPlugins(){return new ns(r(this,Er),r(this,Cr),r(this,Lr),[])}};let hf=ns;Er=new WeakMap,Cr=new WeakMap,Lr=new WeakMap;function Vh(){return typeof performance<"u"&&Vn(performance.now)?performance.now():Date.now()}var sr,fi,Pr,us,Za,jc,rm,Hc,im,Vc,sm,zc,om,eu,df;class Cb{constructor(e,n){k(this,jc);k(this,Hc);k(this,Vc);k(this,zc);k(this,eu);k(this,sr,void 0);k(this,fi,void 0);k(this,Pr,void 0);k(this,us,void 0);k(this,Za,new WeakSet);P(this,sr,e),P(this,fi,n)}async init(){r(this,Pr)||P(this,Pr,r(this,sr).init().catch(e=>(P(this,Pr,void 0),Promise.reject(e)))),await r(this,Pr)}async acquireConnection(){await this.init();const e=await r(this,sr).acquireConnection();return r(this,Za).has(e)||(Oe(this,jc,rm).call(this)&&Oe(this,Hc,im).call(this,e),r(this,Za).add(e)),e}async releaseConnection(e){await r(this,sr).releaseConnection(e)}beginTransaction(e,n){return r(this,sr).beginTransaction(e,n)}commitTransaction(e){return r(this,sr).commitTransaction(e)}rollbackTransaction(e){return r(this,sr).rollbackTransaction(e)}async destroy(){r(this,Pr)&&(await r(this,Pr),r(this,us)||P(this,us,r(this,sr).destroy().catch(e=>(P(this,us,void 0),Promise.reject(e)))),await r(this,us))}}sr=new WeakMap,fi=new WeakMap,Pr=new WeakMap,us=new WeakMap,Za=new WeakMap,jc=new WeakSet,rm=function(){return r(this,fi).isLevelEnabled("query")||r(this,fi).isLevelEnabled("error")},Hc=new WeakSet,im=function(e){const n=e.executeQuery;e.executeQuery=async i=>{const a=Vh();try{return await n.call(e,i)}catch(l){throw await Oe(this,Vc,sm).call(this,l,i,a),l}finally{await Oe(this,zc,om).call(this,i,a)}}},Vc=new WeakSet,sm=async function(e,n,i){await r(this,fi).error(()=>({level:"error",error:e,query:n,queryDurationMillis:Oe(this,eu,df).call(this,i)}))},zc=new WeakSet,om=async function(e,n){await r(this,fi).query(()=>({level:"query",query:e,queryDurationMillis:Oe(this,eu,df).call(this,n)}))},eu=new WeakSet,df=function(e){return Vh()-e};var tu,hi,Kc,um;class am{constructor(e){k(this,Kc);k(this,tu,void 0);k(this,hi,void 0);P(this,tu,e)}async provideConnection(e){for(;r(this,hi);)await r(this,hi);const n=Oe(this,Kc,um).call(this,e);return P(this,hi,n.then(()=>{P(this,hi,void 0)}).catch(()=>{P(this,hi,void 0)})),n}}tu=new WeakMap,hi=new WeakMap,Kc=new WeakSet,um=async function(e){return await e(r(this,tu))};const qb=["read uncommitted","read committed","repeatable read","serializable"];p(["query","error"]);var di,cs;class Ob{constructor(e){k(this,di,void 0);k(this,cs,void 0);Vn(e)?(P(this,cs,e),P(this,di,p({query:!0,error:!0}))):(P(this,cs,Wb),P(this,di,p({query:e.includes("query"),error:e.includes("error")})))}isLevelEnabled(e){return r(this,di)[e]}async query(e){r(this,di).query&&await r(this,cs).call(this,e())}async error(e){r(this,di).error&&await r(this,cs).call(this,e())}}di=new WeakMap,cs=new WeakMap;function Wb(t){t.level==="query"?(console.log(`kysely:query: ${t.query.sql}`),console.log(`kysely:query: duration: ${t.queryDurationMillis.toFixed(1)}ms`)):t.level==="error"&&(t.error instanceof Error?console.error(`kysely:error: ${t.error.stack??t.error.message}`):console.error(`kysely:error: ${t}`))}function Ib(t){return Ir(t)&&Vn(t.compile)}var Qt;const Xs=class extends gc{constructor(n){let i,a;if(Ab(n))i={executor:n.executor},a={...n};else{const l=n.dialect,m=l.createDriver(),g=l.createQueryCompiler(),v=l.createAdapter(),d=new Ob(n.log??[]),I=new Cb(m,d),B=new Eb(I),D=new hf(g,v,B,n.plugins??[]);i={executor:D},a={config:n,executor:D,dialect:l,driver:I}}super(i);k(this,Qt,void 0);P(this,Qt,p(a))}get schema(){return new ff(r(this,Qt).executor)}get dynamic(){return new xb}get introspection(){return r(this,Qt).dialect.createIntrospector(this.withoutPlugins())}case(n){return new $p({node:pr.create(_a(n)?void 0:_l(n))})}get fn(){return Up()}transaction(){return new Sc({...r(this,Qt)})}connection(){return new cm({...r(this,Qt)})}withPlugin(n){return new Xs({...r(this,Qt),executor:r(this,Qt).executor.withPlugin(n)})}withoutPlugins(){return new Xs({...r(this,Qt),executor:r(this,Qt).executor.withoutPlugins()})}withSchema(n){return new Xs({...r(this,Qt),executor:r(this,Qt).executor.withPluginAtFront(new Nu(n))})}withTables(){return new Xs({...r(this,Qt)})}async destroy(){await r(this,Qt).driver.destroy()}get isTransaction(){return!1}getExecutor(){return r(this,Qt).executor}executeQuery(n,i=et()){const a=Ib(n)?n.compile():n;return this.getExecutor().executeQuery(a,i)}};let Qa=Xs;Qt=new WeakMap;var or;const Ys=class extends Qa{constructor(n){super(n);k(this,or,void 0);P(this,or,n)}get isTransaction(){return!0}transaction(){throw new Error("calling the transaction method for a Transaction is not supported")}connection(){throw new Error("calling the connection method for a Transaction is not supported")}async destroy(){throw new Error("calling the destroy method for a Transaction is not supported")}withPlugin(n){return new Ys({...r(this,or),executor:r(this,or).executor.withPlugin(n)})}withoutPlugins(){return new Ys({...r(this,or),executor:r(this,or).executor.withoutPlugins()})}withSchema(n){return new Ys({...r(this,or),executor:r(this,or).executor.withPluginAtFront(new Nu(n))})}withTables(){return new Ys({...r(this,or)})}};let pf=Ys;or=new WeakMap;function Ab(t){return Ir(t)&&Ir(t.config)&&Ir(t.driver)&&Ir(t.executor)&&Ir(t.dialect)}var ls;class cm{constructor(e){k(this,ls,void 0);P(this,ls,p(e))}async execute(e){return r(this,ls).executor.provideConnection(async n=>{const i=r(this,ls).executor.withConnectionProvider(new am(n)),a=new Qa({...r(this,ls),executor:i});return await e(a)})}}ls=new WeakMap;$e(cm,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");var ar;const nh=class{constructor(e){k(this,ar,void 0);P(this,ar,p(e))}setIsolationLevel(e){return new nh({...r(this,ar),isolationLevel:e})}async execute(e){const{isolationLevel:n,...i}=r(this,ar),a={isolationLevel:n};return Tb(a),r(this,ar).executor.provideConnection(async l=>{const m=r(this,ar).executor.withConnectionProvider(new am(l)),g=new pf({...i,executor:m});try{await r(this,ar).driver.beginTransaction(l,a);const v=await e(g);return await r(this,ar).driver.commitTransaction(l),v}catch(v){throw await r(this,ar).driver.rollbackTransaction(l),v}})}};let Sc=nh;ar=new WeakMap;$e(Sc,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function Tb(t){if(t.isolationLevel&&!qb.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}var Nn,No,rc,nu,mf,ru,yf;const Jc=class{constructor(e){k(this,No);k(this,nu);k(this,ru);k(this,Nn,void 0);P(this,Nn,p(e))}get expressionType(){}as(e){return new kb(this,e)}$castTo(){return new Jc({...r(this,Nn)})}castTo(){return this.$castTo()}withPlugin(e){return new Jc({...r(this,Nn),plugins:r(this,Nn).plugins!==void 0?p([...r(this,Nn).plugins,e]):p([e])})}toOperationNode(){return Oe(this,nu,mf).call(this,Oe(this,No,rc).call(this))}compile(e){return Oe(this,ru,yf).call(this,Oe(this,No,rc).call(this,e))}async execute(e){const n=Oe(this,No,rc).call(this,e);return n.executeQuery(Oe(this,ru,yf).call(this,n),r(this,Nn).queryId)}};let rr=Jc;Nn=new WeakMap,No=new WeakSet,rc=function(e){const n=e!==void 0?e.getExecutor():Nl;return r(this,Nn).plugins!==void 0?n.withPlugins(r(this,Nn).plugins):n},nu=new WeakSet,mf=function(e){return e.transformQuery(r(this,Nn).rawNode,r(this,Nn).queryId)},ru=new WeakSet,yf=function(e){return e.compileQuery(Oe(this,nu,mf).call(this,e),r(this,Nn).queryId)};$e(rr,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");var vo,pi;class kb{constructor(e,n){k(this,vo,void 0);k(this,pi,void 0);P(this,vo,e),P(this,pi,n)}get expression(){return r(this,vo)}get alias(){return r(this,pi)}toOperationNode(){return Es.create(r(this,vo).toOperationNode(),hn(r(this,pi))?r(this,pi).toOperationNode():mt.create(r(this,pi)))}}vo=new WeakMap,pi=new WeakMap;const Sn=Object.assign((t,...e)=>new rr({queryId:et(),rawNode:en.create(t,(e==null?void 0:e.map($r))??[])}),{ref(t){return new rr({queryId:et(),rawNode:en.createWithChild(Mo(t))})},val(t){return new rr({queryId:et(),rawNode:en.createWithChild($r(t))})},value(t){return this.val(t)},table(t){return new rr({queryId:et(),rawNode:en.createWithChild(_n(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",new rr({queryId:et(),rawNode:en.create(e,t.map(mt.create))})},lit(t){return new rr({queryId:et(),rawNode:en.createWithChild(Ar.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return new rr({queryId:et(),rawNode:en.createWithSql(t)})},join(t,e=Sn`, `){const n=new Array(2*t.length-1),i=e.toOperationNode();for(let a=0;a{this.nodeStack.push(e),r(this,Gc)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}Gc=new WeakMap;var _o,fs;class Rb extends Sb{constructor(){super(...arguments);k(this,_o,"");k(this,fs,[])}get numParameters(){return r(this,fs).length}compileQuery(n){return P(this,_o,""),P(this,fs,[]),this.visitNode(n),p({query:n,sql:this.getSql(),parameters:[...r(this,fs)]})}getSql(){return r(this,_o)}visitSelectQuery(n){const i=this.parentNode!==void 0&&!Or.is(this.parentNode)&&!ai.is(this.parentNode)&&!Fp.is(this.parentNode);this.parentNode===void 0&&n.explain&&(this.visitNode(n.explain),this.append(" ")),i&&this.append("("),n.with&&(this.visitNode(n.with),this.append(" ")),this.append("select "),n.distinctOn&&(this.compileDistinctOn(n.distinctOn),this.append(" ")),n.frontModifiers&&n.frontModifiers.length>0&&(this.compileList(n.frontModifiers," "),this.append(" ")),n.selections&&(this.compileList(n.selections),this.append(" ")),this.visitNode(n.from),n.joins&&(this.append(" "),this.compileList(n.joins," ")),n.where&&(this.append(" "),this.visitNode(n.where)),n.groupBy&&(this.append(" "),this.visitNode(n.groupBy)),n.having&&(this.append(" "),this.visitNode(n.having)),n.setOperations&&(this.append(" "),this.compileList(n.setOperations," ")),n.orderBy&&(this.append(" "),this.visitNode(n.orderBy)),n.limit&&(this.append(" "),this.visitNode(n.limit)),n.offset&&(this.append(" "),this.visitNode(n.offset)),n.endModifiers&&n.endModifiers.length>0&&(this.append(" "),this.compileList(n.endModifiers," ")),i&&this.append(")")}visitFrom(n){this.append("from "),this.compileList(n.froms)}visitSelection(n){this.visitNode(n.selection)}visitColumn(n){this.visitNode(n.column)}compileDistinctOn(n){this.append("distinct on ("),this.compileList(n),this.append(")")}compileList(n,i=", "){const a=n.length-1;for(let l=0;l<=a;l++)this.visitNode(n[l]),ll&&this.visitNode(a[l])}visitOperator(n){this.append(n.operator)}visitTable(n){this.visitNode(n.table)}visitSchemableIdentifier(n){n.schema&&(this.visitNode(n.schema),this.append(".")),this.visitNode(n.identifier)}visitCreateTable(n){this.append("create "),n.frontModifiers&&n.frontModifiers.length>0&&(this.compileList(n.frontModifiers," "),this.append(" ")),n.temporary&&this.append("temporary "),this.append("table "),n.ifNotExists&&this.append("if not exists "),this.visitNode(n.table),this.append(" ("),this.compileList([...n.columns,...n.constraints??[]]),this.append(")"),n.onCommit&&(this.append(" on commit "),this.append(n.onCommit)),n.endModifiers&&n.endModifiers.length>0&&(this.append(" "),this.compileList(n.endModifiers," "))}visitColumnDefinition(n){this.visitNode(n.column),this.append(" "),this.visitNode(n.dataType),n.unsigned&&this.append(" unsigned"),n.frontModifiers&&n.frontModifiers.length>0&&(this.append(" "),this.compileList(n.frontModifiers," ")),n.generated&&(this.append(" "),this.visitNode(n.generated)),n.defaultTo&&(this.append(" "),this.visitNode(n.defaultTo)),n.notNull&&this.append(" not null"),n.unique&&this.append(" unique"),n.primaryKey&&this.append(" primary key"),n.autoIncrement&&(this.append(" "),this.append(this.getAutoIncrement())),n.references&&(this.append(" "),this.visitNode(n.references)),n.check&&(this.append(" "),this.visitNode(n.check)),n.endModifiers&&n.endModifiers.length>0&&(this.append(" "),this.compileList(n.endModifiers," "))}getAutoIncrement(){return"auto_increment"}visitReferences(n){this.append("references "),this.visitNode(n.table),this.append(" ("),this.compileList(n.columns),this.append(")"),n.onDelete&&(this.append(" on delete "),this.append(n.onDelete)),n.onUpdate&&(this.append(" on update "),this.append(n.onUpdate))}visitDropTable(n){this.append("drop table "),n.ifExists&&this.append("if exists "),this.visitNode(n.table),n.cascade&&this.append(" cascade")}visitDataType(n){this.append(n.dataType)}visitOrderBy(n){this.append("order by "),this.compileList(n.items)}visitOrderByItem(n){this.visitNode(n.orderBy),n.direction&&(this.append(" "),this.visitNode(n.direction))}visitGroupBy(n){this.append("group by "),this.compileList(n.items)}visitGroupByItem(n){this.visitNode(n.groupBy)}visitUpdateQuery(n){const i=this.nodeStack.find(ye.is)!==n;!i&&n.explain&&(this.visitNode(n.explain),this.append(" ")),i&&this.append("("),n.with&&(this.visitNode(n.with),this.append(" ")),this.append("update "),this.visitNode(n.table),this.append(" set "),n.updates&&this.compileList(n.updates),n.from&&(this.append(" "),this.visitNode(n.from)),n.joins&&(this.append(" "),this.compileList(n.joins," ")),n.where&&(this.append(" "),this.visitNode(n.where)),n.returning&&(this.append(" "),this.visitNode(n.returning)),i&&this.append(")")}visitColumnUpdate(n){this.visitNode(n.column),this.append(" = "),this.visitNode(n.value)}visitLimit(n){this.append("limit "),this.visitNode(n.limit)}visitOffset(n){this.append("offset "),this.visitNode(n.offset)}visitOnConflict(n){this.append("on conflict"),n.columns?(this.append(" ("),this.compileList(n.columns),this.append(")")):n.constraint?(this.append(" on constraint "),this.visitNode(n.constraint)):n.indexExpression&&(this.append(" ("),this.visitNode(n.indexExpression),this.append(")")),n.indexWhere&&(this.append(" "),this.visitNode(n.indexWhere)),n.doNothing===!0?this.append(" do nothing"):n.updates&&(this.append(" do update set "),this.compileList(n.updates),n.updateWhere&&(this.append(" "),this.visitNode(n.updateWhere)))}visitOnDuplicateKey(n){this.append("on duplicate key update "),this.compileList(n.updates)}visitCreateIndex(n){this.append("create "),n.unique&&this.append("unique "),this.append("index "),n.ifNotExists&&this.append("if not exists "),this.visitNode(n.name),n.table&&(this.append(" on "),this.visitNode(n.table)),n.using&&(this.append(" using "),this.visitNode(n.using)),n.columns&&(this.append(" ("),this.compileList(n.columns),this.append(")")),n.where&&(this.append(" "),this.visitNode(n.where))}visitDropIndex(n){this.append("drop index "),n.ifExists&&this.append("if exists "),this.visitNode(n.name),n.table&&(this.append(" on "),this.visitNode(n.table)),n.cascade&&this.append(" cascade")}visitCreateSchema(n){this.append("create schema "),n.ifNotExists&&this.append("if not exists "),this.visitNode(n.schema)}visitDropSchema(n){this.append("drop schema "),n.ifExists&&this.append("if exists "),this.visitNode(n.schema),n.cascade&&this.append(" cascade")}visitPrimaryKeyConstraint(n){n.name&&(this.append("constraint "),this.visitNode(n.name),this.append(" ")),this.append("primary key ("),this.compileList(n.columns),this.append(")")}visitUniqueConstraint(n){n.name&&(this.append("constraint "),this.visitNode(n.name),this.append(" ")),this.append("unique ("),this.compileList(n.columns),this.append(")")}visitCheckConstraint(n){n.name&&(this.append("constraint "),this.visitNode(n.name),this.append(" ")),this.append("check ("),this.visitNode(n.expression),this.append(")")}visitForeignKeyConstraint(n){n.name&&(this.append("constraint "),this.visitNode(n.name),this.append(" ")),this.append("foreign key ("),this.compileList(n.columns),this.append(") "),this.visitNode(n.references),n.onDelete&&(this.append(" on delete "),this.append(n.onDelete)),n.onUpdate&&(this.append(" on update "),this.append(n.onUpdate))}visitList(n){this.compileList(n.items)}visitWith(n){this.append("with "),n.recursive&&this.append("recursive "),this.compileList(n.expressions)}visitCommonTableExpression(n){this.visitNode(n.name),this.append(" as "),this.visitNode(n.expression)}visitCommonTableExpressionName(n){this.visitNode(n.table),n.columns&&(this.append("("),this.compileList(n.columns),this.append(")"))}visitAlterTable(n){this.append("alter table "),this.visitNode(n.table),this.append(" "),n.renameTo&&(this.append("rename to "),this.visitNode(n.renameTo)),n.setSchema&&(this.append("set schema "),this.visitNode(n.setSchema)),n.addConstraint&&this.visitNode(n.addConstraint),n.dropConstraint&&this.visitNode(n.dropConstraint),n.columnAlterations&&this.compileList(n.columnAlterations)}visitAddColumn(n){this.append("add column "),this.visitNode(n.column)}visitRenameColumn(n){this.append("rename column "),this.visitNode(n.column),this.append(" to "),this.visitNode(n.renameTo)}visitDropColumn(n){this.append("drop column "),this.visitNode(n.column)}visitAlterColumn(n){this.append("alter column "),this.visitNode(n.column),this.append(" "),n.dataType&&(this.append("type "),this.visitNode(n.dataType),n.dataTypeExpression&&(this.append("using "),this.visitNode(n.dataTypeExpression))),n.setDefault&&(this.append("set default "),this.visitNode(n.setDefault)),n.dropDefault&&this.append("drop default"),n.setNotNull&&this.append("set not null"),n.dropNotNull&&this.append("drop not null")}visitModifyColumn(n){this.append("modify column "),this.visitNode(n.column)}visitAddConstraint(n){this.append("add "),this.visitNode(n.constraint)}visitDropConstraint(n){this.append("drop constraint "),n.ifExists&&this.append("if exists "),this.visitNode(n.constraintName),n.modifier==="cascade"?this.append(" cascade"):n.modifier==="restrict"&&this.append(" restrict")}visitSetOperation(n){this.append(n.operator),this.append(" "),n.all&&this.append("all "),this.visitNode(n.expression)}visitCreateView(n){this.append("create "),n.orReplace&&this.append("or replace "),n.materialized&&this.append("materialized "),n.temporary&&this.append("temporary "),this.append("view "),n.ifNotExists&&this.append("if not exists "),this.visitNode(n.name),this.append(" "),n.columns&&(this.append("("),this.compileList(n.columns),this.append(") ")),n.as&&(this.append("as "),this.visitNode(n.as))}visitDropView(n){this.append("drop "),n.materialized&&this.append("materialized "),this.append("view "),n.ifExists&&this.append("if exists "),this.visitNode(n.name),n.cascade&&this.append(" cascade")}visitGenerated(n){this.append("generated "),n.always&&this.append("always "),n.byDefault&&this.append("by default "),this.append("as "),n.identity&&this.append("identity"),n.expression&&(this.append("("),this.visitNode(n.expression),this.append(")")),n.stored&&this.append(" stored")}visitDefaultValue(n){this.append("default "),this.visitNode(n.defaultValue)}visitSelectModifier(n){n.rawModifier?this.visitNode(n.rawModifier):this.append(Db[n.modifier])}visitCreateType(n){this.append("create type "),this.visitNode(n.name),n.enum&&(this.append(" as enum "),this.visitNode(n.enum))}visitDropType(n){this.append("drop type "),n.ifExists&&this.append("if exists "),this.visitNode(n.name)}visitExplain(n){this.append("explain"),(n.options||n.format)&&(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),n.options&&(this.visitNode(n.options),n.format&&this.append(this.getExplainOptionsDelimiter())),n.format&&(this.append("format"),this.append(this.getExplainOptionAssignment()),this.append(n.format)),this.append(this.getRightExplainOptionsWrapper()))}visitDefaultInsertValue(n){this.append("default")}visitAggregateFunction(n){this.append(n.func),this.append("("),n.distinct&&this.append("distinct "),this.compileList(n.aggregated),this.append(")"),n.filter&&(this.append(" filter("),this.visitNode(n.filter),this.append(")")),n.over&&(this.append(" "),this.visitNode(n.over))}visitOver(n){this.append("over("),n.partitionBy&&(this.visitNode(n.partitionBy),n.orderBy&&this.append(" ")),n.orderBy&&this.visitNode(n.orderBy),this.append(")")}visitPartitionBy(n){this.append("partition by "),this.compileList(n.items)}visitPartitionByItem(n){this.visitNode(n.partitionBy)}visitBinaryOperation(n){this.visitNode(n.leftOperand),this.append(" "),this.visitNode(n.operator),this.append(" "),this.visitNode(n.rightOperand)}visitUnaryOperation(n){this.visitNode(n.operator),this.isMinusOperator(n.operator)||this.append(" "),this.visitNode(n.operand)}isMinusOperator(n){return Ff.is(n)&&n.operator==="-"}visitUsing(n){this.append("using "),this.compileList(n.tables)}visitFunction(n){this.append(n.func),this.append("("),this.compileList(n.arguments),this.append(")")}visitCase(n){this.append("case"),n.value&&(this.append(" "),this.visitNode(n.value)),n.when&&(this.append(" "),this.compileList(n.when," ")),n.else&&(this.append(" else "),this.visitNode(n.else)),this.append(" end"),n.isStatement&&this.append(" case")}visitWhen(n){this.append("when "),this.visitNode(n.condition),n.result&&(this.append(" then "),this.visitNode(n.result))}append(n){P(this,_o,r(this,_o)+n)}appendValue(n){this.addParameter(n),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier(n){const i=this.getLeftIdentifierWrapper(),a=this.getRightIdentifierWrapper();let l="";for(const m of n)l+=m,m===i?l+=i:m===a&&(l+=a);return l}addParameter(n){r(this,fs).push(n)}appendImmediateValue(n){if(yr(n))this.append(`'${n}'`);else if(cg(n)||yp(n))this.append(n.toString());else if(wp(n))this.append("null");else if(lg(n))this.appendImmediateValue(n.toISOString());else if(fg(n))this.appendImmediateValue(n.toString());else throw new Error(`invalid immediate value ${n}`)}}_o=new WeakMap,fs=new WeakMap;const Db=p({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),Lb=p({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral"}),jr=p({raw(t){return p({sql:t,query:en.createWithSql(t),parameters:p([])})}}),Pb=/"/g;class lm extends Rb{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(e){return e.replace(Pb,'""')}visitDefaultInsertValue(e){this.append("null")}}const Mb="kysely_migration",Bb="kysely_migration_lock";p({__noMigrations__:!0});var xo,Xc,hm;class fm{constructor(e){k(this,Xc);k(this,xo,void 0);P(this,xo,e)}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let n=r(this,xo).selectFrom("sqlite_schema").where("type","in",["table","view"]).where("name","not like","sqlite_%").select("name").orderBy("name").$castTo();e.withInternalKyselyTables||(n=n.where("name","!=",Mb).where("name","!=",Bb));const i=await n.execute();return Promise.all(i.map(({name:a})=>Oe(this,Xc,hm).call(this,a)))}async getMetadata(e){return{tables:await this.getTables(e)}}}xo=new WeakMap,Xc=new WeakSet,hm=async function(e){var m,g,v,d,I,B;const n=r(this,xo),i=await n.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),a=(B=(I=(d=(v=(g=(m=i.sql)==null?void 0:m.split(/[\(\),]/))==null?void 0:g.find(D=>D.toLowerCase().includes("autoincrement")))==null?void 0:v.trimStart())==null?void 0:d.split(/\s+/))==null?void 0:I[0])==null?void 0:B.replace(/["`]/g,""),l=await n.selectFrom(Sn`pragma_table_info(${e})`.as("table_info")).select(["name","type","notnull","dflt_value"]).orderBy("cid").execute();return{name:e,isView:i.type==="view",columns:l.map(D=>({name:D.name,dataType:D.type,isNullable:!D.notnull,isAutoIncrementing:D.name===a,hasDefaultValue:D.dflt_value!=null}))}};class dm{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var pm=class{createQueryCompiler(){return new lm}createAdapter(){return new dm}createIntrospector(t){return new fm(t)}},iu,Yc,sd,mm=(sd=class{constructor(){k(this,iu,new Fb);Yt(this,"connection");k(this,Yc,void 0)}async acquireConnection(){return await r(this,iu).lock(),this.connection}async beginTransaction(t){await t.executeQuery(jr.raw("begin"))}async commitTransaction(t){await t.executeQuery(jr.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(jr.raw("rollback"))}async releaseConnection(){r(this,iu).unlock()}async destroy(){var t;(t=r(this,Yc))==null||t.close()}},iu=new WeakMap,Yc=new WeakMap,sd),hs,Eo,od,Fb=(od=class{constructor(){k(this,hs,void 0);k(this,Eo,void 0)}async lock(){for(;r(this,hs);)await r(this,hs);P(this,hs,new Promise(e=>{P(this,Eo,e)}))}unlock(){const e=r(this,Eo);P(this,hs,void 0),P(this,Eo,void 0),e==null||e()}},hs=new WeakMap,Eo=new WeakMap,od),ym=class{streamQuery(){throw new Error("Sqlite driver doesn't support streaming")}async executeQuery(t){const{parameters:e,sql:n,query:i}=t;return Promise.resolve(i.kind==="SelectQueryNode"||i.kind==="RawNode"?{rows:await this.query(n,e)}:{rows:[],...await this.exec(n,e)})}};function Ub({func:t,delay:e,maxCalls:n}){let i,a=0,l=null;function m(){i&&clearTimeout(i),a=0,l=null}function g(){a>=n?(t(l),m()):(i&&clearTimeout(i),i=setTimeout(()=>{t(l),m(),i=void 0},e))}return v=>{a++,l=v,i===void 0&&a===0?(t(v),a++):g()}}var Tn,Co,ad,$b=(ad=class extends mm{constructor(e){super();k(this,Tn,void 0);k(this,Co,void 0);P(this,Tn,e)}async init(){var e,n,i,a;if(P(this,Co,typeof r(this,Tn).database=="function"?await r(this,Tn).database():r(this,Tn).database),!r(this,Co))throw new Error("no database");this.connection=new Qb(r(this,Co),(e=r(this,Tn).onWrite)==null?void 0:e.func,(n=r(this,Tn).onWrite)==null?void 0:n.isThrottle,(i=r(this,Tn).onWrite)==null?void 0:i.maxCalls,(a=r(this,Tn).onWrite)==null?void 0:a.delay),r(this,Tn).onCreateConnection&&await r(this,Tn).onCreateConnection(this.connection)}async beginTransaction(e){await e.executeQuery(jr.raw("begin")),this.connection&&this.connection.transactionNum++}async commitTransaction(e){await e.executeQuery(jr.raw("commit")),this.connection&&this.connection.transactionNum--}async rollbackTransaction(e){await e.executeQuery(jr.raw("rollback")),this.connection&&this.connection.transactionNum--}},Tn=new WeakMap,Co=new WeakMap,ad),mi,qo,ud,Qb=(ud=class extends ym{constructor(e,n,i=!1,a=1e3,l=2e3){super();k(this,mi,void 0);k(this,qo,void 0);Yt(this,"transactionNum",0);P(this,mi,e),P(this,qo,n?i?Ub({func:n,maxCalls:a,delay:l}):n:void 0)}query(e,n){const i=r(this,mi).prepare(e);i.bind(n);const a=[];for(;i.step();)a.push(i.getAsObject());return i.free(),a}exec(e,n){r(this,mi).run(e,n);const i=BigInt(this.query("SELECT last_insert_rowid() as id")[0].id),a=BigInt(r(this,mi).getRowsModified());return this.transactionNum===0&&r(this,qo)&&r(this,qo).call(this,r(this,mi).export()),{numAffectedRows:a,insertId:i}}},mi=new WeakMap,qo=new WeakMap,ud),su,cd,jb=(cd=class extends pm{constructor(e){super();k(this,su,void 0);P(this,su,e)}createDriver(){return new $b(r(this,su))}},su=new WeakMap,cd),Mr,ds,ld,Hb=(ld=class extends mm{constructor(e){super();k(this,Mr,void 0);k(this,ds,void 0);P(this,Mr,e)}async init(){P(this,ds,typeof r(this,Mr).database=="function"?await r(this,Mr).database():r(this,Mr).database),this.connection=new Vb(r(this,ds)),r(this,Mr).onCreateConnection&&await r(this,Mr).onCreateConnection(this.connection)}async close(){var e;await((e=r(this,ds))==null?void 0:e.sqlite.close(r(this,ds).db))}},Mr=new WeakMap,ds=new WeakMap,ld),kn,ps,fd,Vb=(fd=class extends ym{constructor(e){super();k(this,kn,void 0);k(this,ps,void 0);P(this,ps,e.db),P(this,kn,e.sqlite)}async run(e){const n=r(this,kn).str_new(r(this,ps),e.sql),i=await r(this,kn).prepare_v2(r(this,ps),r(this,kn).str_value(n));if(i===null)return[];const a=i.stmt;try{typeof e.param<"u"&&r(this,kn).bind_collection(a,e.param);const l=[];let m=[];for(;await r(this,kn).step(a)===100;){m=m.length===0?r(this,kn).column_names(a):m;const g=r(this,kn).row(a);l.push(m.reduce((v,d,I)=>(v[d]=g[I],v),{}))}return l}finally{await r(this,kn).finalize(a)}}async query(e,n){return await this.run({sql:e,param:n})}async exec(e,n){await this.run({sql:e,param:n});const i=await this.run({sql:"SELECT last_insert_rowid() as id"});return{insertId:BigInt(i[0].id),numAffectedRows:BigInt(r(this,kn).changes(r(this,ps)))}}},kn=new WeakMap,ps=new WeakMap,fd),ou,hd,zb=(hd=class extends pm{constructor(e){super();k(this,ou,void 0);P(this,ou,e)}createDriver(){return new Hb(r(this,ou))}},ou=new WeakMap,hd);function Kb(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Jb(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function i(){if(this instanceof i){var a=[null];a.push.apply(a,arguments);var l=Function.bind.apply(e,a);return new l}return e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var a=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(n,i,a.get?a:{enumerable:!0,get:function(){return t[i]}})}),n}var wm={exports:{}};const Gb={},Xb=Object.freeze(Object.defineProperty({__proto__:null,default:Gb},Symbol.toStringTag,{value:"Module"})),Ku=Jb(Xb);(function(t,e){var n=void 0,i=function(a){return n||(n=new Promise(function(l,m){var g=typeof a<"u"?a:{},v=g.onAbort;g.onAbort=function(o){m(new Error(o)),v&&v(o)},g.postRun=g.postRun||[],g.postRun.push(function(){l(g)}),t=void 0;var d;d||(d=typeof g<"u"?g:{}),d.onRuntimeInitialized=function(){function o(W,G){switch(typeof G){case"boolean":Mu(W,G?1:0);break;case"number":Lu(W,G);break;case"string":da(W,G,-1,-1);break;case"object":if(G===null)ha(W);else if(G.length!=null){var s=Fs(G);Pu(W,s,G.length,-1),Ui(s)}else ji(W,"Wrong API use : tried to return a value of an unknown type ("+G+").",-1);break;default:ha(W)}}function c(W,G){for(var s=[],u=0;u>>0),W!=null){var G=this.filename,s="/",u=G;if(s&&(s=typeof s=="string"?s:Oi(s),u=G?ue(s+"/"+G):s),G=mn(!0,!0),u=Ii(u,(G!==void 0?G:438)&4095|32768,0),W){if(typeof W=="string"){s=Array(W.length);for(var f=0,y=W.length;f{ee||(T=Ku,ee=Ku)},C=function(o,c){return Ne(),o=ee.normalize(o),T.readFileSync(o,c?void 0:"utf8")},O=o=>(o=C(o,!0),o.buffer||(o=new Uint8Array(o)),o),N=(o,c,h)=>{Ne(),o=ee.normalize(o),T.readFile(o,function(w,E){w?h(w):c(E.buffer)})},1{var c=new XMLHttpRequest;return c.open("GET",o,!1),c.send(null),c.responseText},ne&&(O=o=>{var c=new XMLHttpRequest;return c.open("GET",o,!1),c.responseType="arraybuffer",c.send(null),new Uint8Array(c.response)}),N=(o,c,h)=>{var w=new XMLHttpRequest;w.open("GET",o,!0),w.responseType="arraybuffer",w.onload=()=>{w.status==200||w.status==0&&w.response?c(w.response):h()},w.onerror=h,w.send(null)});var ae=d.print||console.log.bind(console),_e=d.printErr||console.warn.bind(console);Object.assign(d,I),I=null,d.thisProgram&&(B=d.thisProgram);var xe;d.wasmBinary&&(xe=d.wasmBinary),d.noExitRuntime,typeof WebAssembly!="object"&&x("no native wasm support detected");var tt,ze=!1,Ot=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Wt(o,c,h){var w=c+h;for(h=c;o[h]&&!(h>=w);)++h;if(16E?w+=String.fromCharCode(E):(E-=65536,w+=String.fromCharCode(55296|E>>10,56320|E&1023))}}else w+=String.fromCharCode(E)}return w}function Qe(o,c){return o?Wt(qe,o,c):""}function Kt(o,c,h,w){if(!(0=Q){var ve=o.charCodeAt(++L);Q=65536+((Q&1023)<<10)|ve&1023}if(127>=Q){if(h>=w)break;c[h++]=Q}else{if(2047>=Q){if(h+1>=w)break;c[h++]=192|Q>>6}else{if(65535>=Q){if(h+2>=w)break;c[h++]=224|Q>>12}else{if(h+3>=w)break;c[h++]=240|Q>>18,c[h++]=128|Q>>12&63}c[h++]=128|Q>>6&63}c[h++]=128|Q&63}}return c[h]=0,h-E}function dn(o){for(var c=0,h=0;h=w?c++:2047>=w?c+=2:55296<=w&&57343>=w?(c+=4,++h):c+=3}return c}var wt,ge,qe,ut,we,Re,Pt,Tr;function Cs(){var o=tt.buffer;wt=o,d.HEAP8=ge=new Int8Array(o),d.HEAP16=ut=new Int16Array(o),d.HEAP32=we=new Int32Array(o),d.HEAPU8=qe=new Uint8Array(o),d.HEAPU16=new Uint16Array(o),d.HEAPU32=Re=new Uint32Array(o),d.HEAPF32=Pt=new Float32Array(o),d.HEAPF64=Tr=new Float64Array(o)}var En,pn=[],fe=[],Me=[];function zn(){var o=d.preRun.shift();pn.unshift(o)}var Jt=0,Ke=null;function x(o){throw d.onAbort&&d.onAbort(o),o="Aborted("+o+")",_e(o),ze=!0,new WebAssembly.RuntimeError(o+". Build with -sASSERTIONS for more info.")}function q(){return R.startsWith("data:application/octet-stream;base64,")}var R;if(R="sql-wasm.wasm",!q()){var F=R;R=d.locateFile?d.locateFile(F,b):b+F}function K(){var o=R;try{if(o==R&&xe)return new Uint8Array(xe);if(O)return O(o);throw"both async and sync fetching of the wasm failed"}catch(c){x(c)}}function Y(){if(!xe&&(D||ne)){if(typeof fetch=="function"&&!R.startsWith("file://"))return fetch(R,{credentials:"same-origin"}).then(function(o){if(!o.ok)throw"failed to load wasm binary file at '"+R+"'";return o.arrayBuffer()}).catch(function(){return K()});if(N)return new Promise(function(o,c){N(R,function(h){o(new Uint8Array(h))},c)})}return Promise.resolve().then(function(){return K()})}var j,z;function re(o){for(;0>0];case"i8":return ge[o>>0];case"i16":return ut[o>>1];case"i32":return we[o>>2];case"i64":return we[o>>2];case"float":return Pt[o>>2];case"double":return Tr[o>>3];case"*":return Re[o>>2];default:x("invalid type for getValue: "+c)}return null}function ce(o){var c="i32";switch(c.endsWith("*")&&(c="*"),c){case"i1":ge[o>>0]=0;break;case"i8":ge[o>>0]=0;break;case"i16":ut[o>>1]=0;break;case"i32":we[o>>2]=0;break;case"i64":z=[0,(j=0,1<=+Math.abs(j)?0>>0:~~+Math.ceil((j-+(~~j>>>0))/4294967296)>>>0:0)],we[o>>2]=z[0],we[o+4>>2]=z[1];break;case"float":Pt[o>>2]=0;break;case"double":Tr[o>>3]=0;break;case"*":Re[o>>2]=0;break;default:x("invalid type for setValue: "+c)}}var oe=(o,c)=>{for(var h=0,w=o.length-1;0<=w;w--){var E=o[w];E==="."?o.splice(w,1):E===".."?(o.splice(w,1),h++):h&&(o.splice(w,1),h--)}if(c)for(;h;h--)o.unshift("..");return o},ue=o=>{var c=o.charAt(0)==="/",h=o.substr(-1)==="/";return(o=oe(o.split("/").filter(w=>!!w),!c).join("/"))||c||(o="."),o&&h&&(o+="/"),(c?"/":"")+o},be=o=>{var c=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(o).slice(1);return o=c[0],c=c[1],!o&&!c?".":(c&&(c=c.substr(0,c.length-1)),o+c)},Ee=o=>{if(o==="/")return"/";o=ue(o),o=o.replace(/\/$/,"");var c=o.lastIndexOf("/");return c===-1?o:o.substr(c+1)};function je(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var o=new Uint8Array(1);return()=>(crypto.getRandomValues(o),o[0])}if(te)try{var c=Ku;return()=>c.randomBytes(1)[0]}catch{}return()=>x("randomDevice")}function Le(){for(var o="",c=!1,h=arguments.length-1;-1<=h&&!c;h--){if(c=0<=h?arguments[h]:"/",typeof c!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!c)return"";o=c+"/"+o,c=c.charAt(0)==="/"}return o=oe(o.split("/").filter(w=>!!w),!c).join("/"),(c?"/":"")+o||"."}function it(o,c){var h=Array(dn(o)+1);return o=Kt(o,h,0,h.length),c&&(h.length=o),h}var me=[];function Cn(o,c){me[o]={input:[],output:[],Xa:c},Wi(o,qi)}var qi={open:function(o){var c=me[o.node.rdev];if(!c)throw new H(43);o.tty=c,o.seekable=!1},close:function(o){o.tty.Xa.fsync(o.tty)},fsync:function(o){o.tty.Xa.fsync(o.tty)},read:function(o,c,h,w){if(!o.tty||!o.tty.Xa.tb)throw new H(60);for(var E=0,L=0;Le in t?qm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Yt=(t,e,n)=>(Wm(t,typeof e!="symbol"?e+"":e,n),n),Tl=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var r=(t,e,n)=>(Tl(t,e,"read from private field"),n?n.call(t):e.get(t)),S=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},P=(t,e,n,i)=>(Tl(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n);var qe=(t,e,n)=>(Tl(t,e,"access private method"),n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const m of l.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&i(m)}).observe(document,{childList:!0,subtree:!0});function n(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function i(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();function bf(t,e){const n=Object.create(null),i=t.split(",");for(let a=0;a!!n[a.toLowerCase()]:a=>!!n[a]}function Nf(t){if(Ie(t)){const e={};for(let n=0;n{if(n){const i=n.split(Am);i.length>1&&(e[i[0].trim()]=i[1].trim())}}),e}function vf(t){let e="";if(Lt(t))e=t;else if(Ie(t))for(let n=0;nLt(t)?t:t==null?"":Ie(t)||yt(t)&&(t.toString===Ed||!Se(t.toString))?JSON.stringify(t,vd,2):String(t),vd=(t,e)=>e&&e.__v_isRef?vd(t,e.value):eo(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((n,[i,a])=>(n[`${i} =>`]=a,n),{})}:_d(e)?{[`Set(${e.size})`]:[...e.values()]}:yt(e)&&!Ie(e)&&!Cd(e)?String(e):e,lt={},Zs=[],pr=()=>{},Lm=()=>!1,Pm=/^on[^a-z]/,sl=t=>Pm.test(t),_f=t=>t.startsWith("onUpdate:"),on=Object.assign,xf=(t,e)=>{const n=t.indexOf(e);n>-1&&t.splice(n,1)},Mm=Object.prototype.hasOwnProperty,Be=(t,e)=>Mm.call(t,e),Ie=Array.isArray,eo=t=>ol(t)==="[object Map]",_d=t=>ol(t)==="[object Set]",Se=t=>typeof t=="function",Lt=t=>typeof t=="string",Ef=t=>typeof t=="symbol",yt=t=>t!==null&&typeof t=="object",xd=t=>yt(t)&&Se(t.then)&&Se(t.catch),Ed=Object.prototype.toString,ol=t=>Ed.call(t),Bm=t=>ol(t).slice(8,-1),Cd=t=>ol(t)==="[object Object]",Cf=t=>Lt(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,Ju=bf(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),al=t=>{const e=Object.create(null);return n=>e[n]||(e[n]=t(n))},Fm=/-(\w)/g,ko=al(t=>t.replace(Fm,(e,n)=>n?n.toUpperCase():"")),Um=/\B([A-Z])/g,$o=al(t=>t.replace(Um,"-$1").toLowerCase()),Od=al(t=>t.charAt(0).toUpperCase()+t.slice(1)),Sl=al(t=>t?`on${Od(t)}`:""),Wa=(t,e)=>!Object.is(t,e),kl=(t,e)=>{for(let n=0;n{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})},$m=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let rh;const Qm=()=>rh||(rh=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});let er;class jm{constructor(e=!1){this.detached=e,this._active=!0,this.effects=[],this.cleanups=[],this.parent=er,!e&&er&&(this.index=(er.scopes||(er.scopes=[])).push(this)-1)}get active(){return this._active}run(e){if(this._active){const n=er;try{return er=this,e()}finally{er=n}}}on(){er=this}off(){er=this.parent}stop(e){if(this._active){let n,i;for(n=0,i=this.effects.length;n{const e=new Set(t);return e.w=0,e.n=0,e},qd=t=>(t.w&vi)>0,Wd=t=>(t.n&vi)>0,zm=({deps:t})=>{if(t.length)for(let e=0;e{const{deps:e}=t;if(e.length){let n=0;for(let i=0;i{(W==="length"||W>=v)&&w.push(d)})}else switch(n!==void 0&&w.push(m.get(n)),e){case"add":Ie(t)?Cf(n)&&w.push(m.get("length")):(w.push(m.get(vs)),eo(t)&&w.push(m.get(Vl)));break;case"delete":Ie(t)||(w.push(m.get(vs)),eo(t)&&w.push(m.get(Vl)));break;case"set":eo(t)&&w.push(m.get(vs));break}if(w.length===1)w[0]&&zl(w[0]);else{const v=[];for(const d of w)d&&v.push(...d);zl(Of(v))}}function zl(t,e){const n=Ie(t)?t:[...t];for(const i of n)i.computed&&sh(i);for(const i of n)i.computed||sh(i)}function sh(t,e){(t!==lr||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const Jm=bf("__proto__,__v_isRef,__isVue"),Td=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(Ef)),Gm=Wf(),Xm=Wf(!1,!0),Ym=Wf(!0),oh=Zm();function Zm(){const t={};return["includes","indexOf","lastIndexOf"].forEach(e=>{t[e]=function(...n){const i=Fe(this);for(let l=0,m=this.length;l{t[e]=function(...n){Qo();const i=Fe(this)[e].apply(this,n);return jo(),i}}),t}function ey(t){const e=Fe(this);return xn(e,"has",t),e.hasOwnProperty(t)}function Wf(t=!1,e=!1){return function(i,a,l){if(a==="__v_isReactive")return!t;if(a==="__v_isReadonly")return t;if(a==="__v_isShallow")return e;if(a==="__v_raw"&&l===(t?e?yy:Ld:e?Dd:Rd).get(i))return i;const m=Ie(i);if(!t){if(m&&Be(oh,a))return Reflect.get(oh,a,l);if(a==="hasOwnProperty")return ey}const w=Reflect.get(i,a,l);return(Ef(a)?Td.has(a):Jm(a))||(t||xn(i,"get",a),e)?w:rn(w)?m&&Cf(a)?w:w.value:yt(w)?t?Pd(w):Tf(w):w}}const ty=Sd(),ny=Sd(!0);function Sd(t=!1){return function(n,i,a,l){let m=n[i];if(Ro(m)&&rn(m)&&!rn(a))return!1;if(!t&&(!ac(a)&&!Ro(a)&&(m=Fe(m),a=Fe(a)),!Ie(n)&&rn(m)&&!rn(a)))return m.value=a,!0;const w=Ie(n)&&Cf(i)?Number(i)t,ul=t=>Reflect.getPrototypeOf(t);function Bu(t,e,n=!1,i=!1){t=t.__v_raw;const a=Fe(t),l=Fe(e);n||(e!==l&&xn(a,"get",e),xn(a,"get",l));const{has:m}=ul(a),w=i?If:n?kf:Ia;if(m.call(a,e))return w(t.get(e));if(m.call(a,l))return w(t.get(l));t!==a&&t.get(e)}function Fu(t,e=!1){const n=this.__v_raw,i=Fe(n),a=Fe(t);return e||(t!==a&&xn(i,"has",t),xn(i,"has",a)),t===a?n.has(t):n.has(t)||n.has(a)}function Uu(t,e=!1){return t=t.__v_raw,!e&&xn(Fe(t),"iterate",vs),Reflect.get(t,"size",t)}function ah(t){t=Fe(t);const e=Fe(this);return ul(e).has.call(e,t)||(e.add(t),jr(e,"add",t,t)),this}function uh(t,e){e=Fe(e);const n=Fe(this),{has:i,get:a}=ul(n);let l=i.call(n,t);l||(t=Fe(t),l=i.call(n,t));const m=a.call(n,t);return n.set(t,e),l?Wa(e,m)&&jr(n,"set",t,e):jr(n,"add",t,e),this}function ch(t){const e=Fe(this),{has:n,get:i}=ul(e);let a=n.call(e,t);a||(t=Fe(t),a=n.call(e,t)),i&&i.call(e,t);const l=e.delete(t);return a&&jr(e,"delete",t,void 0),l}function lh(){const t=Fe(this),e=t.size!==0,n=t.clear();return e&&jr(t,"clear",void 0,void 0),n}function $u(t,e){return function(i,a){const l=this,m=l.__v_raw,w=Fe(m),v=e?If:t?kf:Ia;return!t&&xn(w,"iterate",vs),m.forEach((d,W)=>i.call(a,v(d),v(W),l))}}function Qu(t,e,n){return function(...i){const a=this.__v_raw,l=Fe(a),m=eo(l),w=t==="entries"||t===Symbol.iterator&&m,v=t==="keys"&&m,d=a[t](...i),W=n?If:e?kf:Ia;return!e&&xn(l,"iterate",v?Vl:vs),{next(){const{value:B,done:D}=d.next();return D?{value:B,done:D}:{value:w?[W(B[0]),W(B[1])]:W(B),done:D}},[Symbol.iterator](){return this}}}}function ni(t){return function(...e){return t==="delete"?!1:this}}function uy(){const t={get(l){return Bu(this,l)},get size(){return Uu(this)},has:Fu,add:ah,set:uh,delete:ch,clear:lh,forEach:$u(!1,!1)},e={get(l){return Bu(this,l,!1,!0)},get size(){return Uu(this)},has:Fu,add:ah,set:uh,delete:ch,clear:lh,forEach:$u(!1,!0)},n={get(l){return Bu(this,l,!0)},get size(){return Uu(this,!0)},has(l){return Fu.call(this,l,!0)},add:ni("add"),set:ni("set"),delete:ni("delete"),clear:ni("clear"),forEach:$u(!0,!1)},i={get(l){return Bu(this,l,!0,!0)},get size(){return Uu(this,!0)},has(l){return Fu.call(this,l,!0)},add:ni("add"),set:ni("set"),delete:ni("delete"),clear:ni("clear"),forEach:$u(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(l=>{t[l]=Qu(l,!1,!1),n[l]=Qu(l,!0,!1),e[l]=Qu(l,!1,!0),i[l]=Qu(l,!0,!0)}),[t,n,e,i]}const[cy,ly,fy,hy]=uy();function Af(t,e){const n=e?t?hy:fy:t?ly:cy;return(i,a,l)=>a==="__v_isReactive"?!t:a==="__v_isReadonly"?t:a==="__v_raw"?i:Reflect.get(Be(n,a)&&a in i?n:i,a,l)}const dy={get:Af(!1,!1)},py={get:Af(!1,!0)},my={get:Af(!0,!1)},Rd=new WeakMap,Dd=new WeakMap,Ld=new WeakMap,yy=new WeakMap;function wy(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function gy(t){return t.__v_skip||!Object.isExtensible(t)?0:wy(Bm(t))}function Tf(t){return Ro(t)?t:Sf(t,!1,kd,dy,Rd)}function by(t){return Sf(t,!1,ay,py,Dd)}function Pd(t){return Sf(t,!0,oy,my,Ld)}function Sf(t,e,n,i,a){if(!yt(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const l=a.get(t);if(l)return l;const m=gy(t);if(m===0)return t;const w=new Proxy(t,m===2?i:n);return a.set(t,w),w}function to(t){return Ro(t)?to(t.__v_raw):!!(t&&t.__v_isReactive)}function Ro(t){return!!(t&&t.__v_isReadonly)}function ac(t){return!!(t&&t.__v_isShallow)}function Md(t){return to(t)||Ro(t)}function Fe(t){const e=t&&t.__v_raw;return e?Fe(e):t}function Bd(t){return oc(t,"__v_skip",!0),t}const Ia=t=>yt(t)?Tf(t):t,kf=t=>yt(t)?Pd(t):t;function Fd(t){gi&&lr&&(t=Fe(t),Ad(t.dep||(t.dep=Of())))}function Ud(t,e){t=Fe(t);const n=t.dep;n&&zl(n)}function rn(t){return!!(t&&t.__v_isRef===!0)}function Ny(t){return vy(t,!1)}function vy(t,e){return rn(t)?t:new _y(t,e)}class _y{constructor(e,n){this.__v_isShallow=n,this.dep=void 0,this.__v_isRef=!0,this._rawValue=n?e:Fe(e),this._value=n?e:Ia(e)}get value(){return Fd(this),this._value}set value(e){const n=this.__v_isShallow||ac(e)||Ro(e);e=n?e:Fe(e),Wa(e,this._rawValue)&&(this._rawValue=e,this._value=n?e:Ia(e),Ud(this))}}function $d(t){return rn(t)?t.value:t}const xy={get:(t,e,n)=>$d(Reflect.get(t,e,n)),set:(t,e,n,i)=>{const a=t[e];return rn(a)&&!rn(n)?(a.value=n,!0):Reflect.set(t,e,n,i)}};function Qd(t){return to(t)?t:new Proxy(t,xy)}var jd;class Ey{constructor(e,n,i,a){this._setter=n,this.dep=void 0,this.__v_isRef=!0,this[jd]=!1,this._dirty=!0,this.effect=new qf(e,()=>{this._dirty||(this._dirty=!0,Ud(this))}),this.effect.computed=this,this.effect.active=this._cacheable=!a,this.__v_isReadonly=i}get value(){const e=Fe(this);return Fd(e),(e._dirty||!e._cacheable)&&(e._dirty=!1,e._value=e.effect.run()),e._value}set value(e){this._setter(e)}}jd="__v_isReadonly";function Cy(t,e,n=!1){let i,a;const l=Se(t);return l?(i=t,a=pr):(i=t.get,a=t.set),new Ey(i,a,l||!a,n)}function bi(t,e,n,i){let a;try{a=i?t(...i):t()}catch(l){cl(l,e,n)}return a}function Hn(t,e,n,i){if(Se(t)){const l=bi(t,e,n,i);return l&&xd(l)&&l.catch(m=>{cl(m,e,n)}),l}const a=[];for(let l=0;l>>1;Ta(nn[i])qr&&nn.splice(e,1)}function Ay(t){Ie(t)?no.push(...t):(!Rr||!Rr.includes(t,t.allowRecurse?Ki+1:Ki))&&no.push(t),Vd()}function fh(t,e=Aa?qr+1:0){for(;eTa(n)-Ta(i)),Ki=0;Kit.id==null?1/0:t.id,Ty=(t,e)=>{const n=Ta(t)-Ta(e);if(n===0){if(t.pre&&!e.pre)return-1;if(e.pre&&!t.pre)return 1}return n};function Kd(t){Kl=!1,Aa=!0,nn.sort(Ty);const e=pr;try{for(qr=0;qrLt(ne)?ne.trim():ne)),B&&(a=n.map($m))}let w,v=i[w=Sl(e)]||i[w=Sl(ko(e))];!v&&l&&(v=i[w=Sl($o(e))]),v&&Hn(v,t,6,a);const d=i[w+"Once"];if(d){if(!t.emitted)t.emitted={};else if(t.emitted[w])return;t.emitted[w]=!0,Hn(d,t,6,a)}}function Jd(t,e,n=!1){const i=e.emitsCache,a=i.get(t);if(a!==void 0)return a;const l=t.emits;let m={},w=!1;if(!Se(t)){const v=d=>{const W=Jd(d,e,!0);W&&(w=!0,on(m,W))};!n&&e.mixins.length&&e.mixins.forEach(v),t.extends&&v(t.extends),t.mixins&&t.mixins.forEach(v)}return!l&&!w?(yt(t)&&i.set(t,null),null):(Ie(l)?l.forEach(v=>m[v]=null):on(m,l),yt(t)&&i.set(t,m),m)}function ll(t,e){return!t||!sl(e)?!1:(e=e.slice(2).replace(/Once$/,""),Be(t,e[0].toLowerCase()+e.slice(1))||Be(t,$o(e))||Be(t,e))}let fr=null,Gd=null;function uc(t){const e=fr;return fr=t,Gd=t&&t.type.__scopeId||null,e}function ky(t,e=fr,n){if(!e||t._n)return t;const i=(...a)=>{i._d&&Nh(-1);const l=uc(e);let m;try{m=t(...a)}finally{uc(l),i._d&&Nh(1)}return m};return i._n=!0,i._c=!0,i._d=!0,i}function Rl(t){const{type:e,vnode:n,proxy:i,withProxy:a,props:l,propsOptions:[m],slots:w,attrs:v,emit:d,render:W,renderCache:B,data:D,setupState:ne,ctx:te,inheritAttrs:b}=t;let C,N;const q=uc(t);try{if(n.shapeFlag&4){const ee=a||i;C=Cr(W.call(ee,ee,B,l,ne,D,te)),N=v}else{const ee=e;C=Cr(ee.length>1?ee(l,{attrs:v,slots:w,emit:d}):ee(l,null)),N=e.props?v:Ry(v)}}catch(ee){Na.length=0,cl(ee,t,1),C=_s(Fr)}let T=C;if(N&&b!==!1){const ee=Object.keys(N),{shapeFlag:Ne}=T;ee.length&&Ne&7&&(m&&ee.some(_f)&&(N=Dy(N,m)),T=_i(T,N))}return n.dirs&&(T=_i(T),T.dirs=T.dirs?T.dirs.concat(n.dirs):n.dirs),n.transition&&(T.transition=n.transition),C=T,uc(q),C}const Ry=t=>{let e;for(const n in t)(n==="class"||n==="style"||sl(n))&&((e||(e={}))[n]=t[n]);return e},Dy=(t,e)=>{const n={};for(const i in t)(!_f(i)||!(i.slice(9)in e))&&(n[i]=t[i]);return n};function Ly(t,e,n){const{props:i,children:a,component:l}=t,{props:m,children:w,patchFlag:v}=e,d=l.emitsOptions;if(e.dirs||e.transition)return!0;if(n&&v>=0){if(v&1024)return!0;if(v&16)return i?hh(i,m,d):!!m;if(v&8){const W=e.dynamicProps;for(let B=0;Bt.__isSuspense;function By(t,e){e&&e.pendingBranch?Ie(t)?e.effects.push(...t):e.effects.push(t):Ay(t)}function Fy(t,e){if(Ot){let n=Ot.provides;const i=Ot.parent&&Ot.parent.provides;i===n&&(n=Ot.provides=Object.create(i)),n[t]=e}}function Gu(t,e,n=!1){const i=Ot||fr;if(i){const a=i.parent==null?i.vnode.appContext&&i.vnode.appContext.provides:i.parent.provides;if(a&&t in a)return a[t];if(arguments.length>1)return n&&Se(e)?e.call(i.proxy):e}}const ju={};function Dl(t,e,n){return Xd(t,e,n)}function Xd(t,e,{immediate:n,deep:i,flush:a,onTrack:l,onTrigger:m}=lt){const w=Vm()===(Ot==null?void 0:Ot.scope)?Ot:null;let v,d=!1,W=!1;if(rn(t)?(v=()=>t.value,d=ac(t)):to(t)?(v=()=>t,i=!0):Ie(t)?(W=!0,d=t.some(T=>to(T)||ac(T)),v=()=>t.map(T=>{if(rn(T))return T.value;if(to(T))return Ks(T);if(Se(T))return bi(T,w,2)})):Se(t)?e?v=()=>bi(t,w,2):v=()=>{if(!(w&&w.isUnmounted))return B&&B(),Hn(t,w,3,[D])}:v=pr,e&&i){const T=v;v=()=>Ks(T())}let B,D=T=>{B=N.onStop=()=>{bi(T,w,4)}},ne;if(Ra)if(D=pr,e?n&&Hn(e,w,3,[v(),W?[]:void 0,D]):v(),a==="sync"){const T=Bw();ne=T.__watcherHandles||(T.__watcherHandles=[])}else return pr;let te=W?new Array(t.length).fill(ju):ju;const b=()=>{if(N.active)if(e){const T=N.run();(i||d||(W?T.some((ee,Ne)=>Wa(ee,te[Ne])):Wa(T,te)))&&(B&&B(),Hn(e,w,3,[T,te===ju?void 0:W&&te[0]===ju?[]:te,D]),te=T)}else N.run()};b.allowRecurse=!!e;let C;a==="sync"?C=b:a==="post"?C=()=>bn(b,w&&w.suspense):(b.pre=!0,w&&(b.id=w.uid),C=()=>Df(b));const N=new qf(v,C);e?n?b():te=N.run():a==="post"?bn(N.run.bind(N),w&&w.suspense):N.run();const q=()=>{N.stop(),w&&w.scope&&xf(w.scope.effects,N)};return ne&&ne.push(q),q}function Uy(t,e,n){const i=this.proxy,a=Lt(t)?t.includes(".")?Yd(i,t):()=>i[t]:t.bind(i,i);let l;Se(e)?l=e:(l=e.handler,n=e);const m=Ot;Do(this);const w=Xd(a,l.bind(i),n);return m?Do(m):xs(),w}function Yd(t,e){const n=e.split(".");return()=>{let i=t;for(let a=0;a{Ks(n,e)});else if(Cd(t))for(const n in t)Ks(t[n],e);return t}function $y(){const t={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return np(()=>{t.isMounted=!0}),rp(()=>{t.isUnmounting=!0}),t}const Fn=[Function,Array],Qy={name:"BaseTransition",props:{mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:Fn,onEnter:Fn,onAfterEnter:Fn,onEnterCancelled:Fn,onBeforeLeave:Fn,onLeave:Fn,onAfterLeave:Fn,onLeaveCancelled:Fn,onBeforeAppear:Fn,onAppear:Fn,onAfterAppear:Fn,onAppearCancelled:Fn},setup(t,{slots:e}){const n=Tw(),i=$y();let a;return()=>{const l=e.default&&ep(e.default(),!0);if(!l||!l.length)return;let m=l[0];if(l.length>1){for(const b of l)if(b.type!==Fr){m=b;break}}const w=Fe(t),{mode:v}=w;if(i.isLeaving)return Ll(m);const d=dh(m);if(!d)return Ll(m);const W=Jl(d,w,i,n);Gl(d,W);const B=n.subTree,D=B&&dh(B);let ne=!1;const{getTransitionKey:te}=d.type;if(te){const b=te();a===void 0?a=b:b!==a&&(a=b,ne=!0)}if(D&&D.type!==Fr&&(!Ji(d,D)||ne)){const b=Jl(D,w,i,n);if(Gl(D,b),v==="out-in")return i.isLeaving=!0,b.afterLeave=()=>{i.isLeaving=!1,n.update.active!==!1&&n.update()},Ll(m);v==="in-out"&&d.type!==Fr&&(b.delayLeave=(C,N,q)=>{const T=Zd(i,D);T[String(D.key)]=D,C._leaveCb=()=>{N(),C._leaveCb=void 0,delete W.delayedLeave},W.delayedLeave=q})}return m}}},jy=Qy;function Zd(t,e){const{leavingVNodes:n}=t;let i=n.get(e.type);return i||(i=Object.create(null),n.set(e.type,i)),i}function Jl(t,e,n,i){const{appear:a,mode:l,persisted:m=!1,onBeforeEnter:w,onEnter:v,onAfterEnter:d,onEnterCancelled:W,onBeforeLeave:B,onLeave:D,onAfterLeave:ne,onLeaveCancelled:te,onBeforeAppear:b,onAppear:C,onAfterAppear:N,onAppearCancelled:q}=e,T=String(t.key),ee=Zd(n,t),Ne=(xe,tt)=>{xe&&Hn(xe,i,9,tt)},ae=(xe,tt)=>{const ze=tt[1];Ne(xe,tt),Ie(xe)?xe.every(qt=>qt.length<=1)&&ze():xe.length<=1&&ze()},_e={mode:l,persisted:m,beforeEnter(xe){let tt=w;if(!n.isMounted)if(a)tt=b||w;else return;xe._leaveCb&&xe._leaveCb(!0);const ze=ee[T];ze&&Ji(t,ze)&&ze.el._leaveCb&&ze.el._leaveCb(),Ne(tt,[xe])},enter(xe){let tt=v,ze=d,qt=W;if(!n.isMounted)if(a)tt=C||v,ze=N||d,qt=q||W;else return;let Wt=!1;const Qe=xe._enterCb=Kt=>{Wt||(Wt=!0,Kt?Ne(qt,[xe]):Ne(ze,[xe]),_e.delayedLeave&&_e.delayedLeave(),xe._enterCb=void 0)};tt?ae(tt,[xe,Qe]):Qe()},leave(xe,tt){const ze=String(t.key);if(xe._enterCb&&xe._enterCb(!0),n.isUnmounting)return tt();Ne(B,[xe]);let qt=!1;const Wt=xe._leaveCb=Qe=>{qt||(qt=!0,tt(),Qe?Ne(te,[xe]):Ne(ne,[xe]),xe._leaveCb=void 0,ee[ze]===t&&delete ee[ze])};ee[ze]=t,D?ae(D,[xe,Wt]):Wt()},clone(xe){return Jl(xe,e,n,i)}};return _e}function Ll(t){if(fl(t))return t=_i(t),t.children=null,t}function dh(t){return fl(t)?t.children?t.children[0]:void 0:t}function Gl(t,e){t.shapeFlag&6&&t.component?Gl(t.component.subTree,e):t.shapeFlag&128?(t.ssContent.transition=e.clone(t.ssContent),t.ssFallback.transition=e.clone(t.ssFallback)):t.transition=e}function ep(t,e=!1,n){let i=[],a=0;for(let l=0;l1)for(let l=0;l!!t.type.__asyncLoader,fl=t=>t.type.__isKeepAlive;function Vy(t,e){tp(t,"a",e)}function zy(t,e){tp(t,"da",e)}function tp(t,e,n=Ot){const i=t.__wdc||(t.__wdc=()=>{let a=n;for(;a;){if(a.isDeactivated)return;a=a.parent}return t()});if(hl(e,i,n),n){let a=n.parent;for(;a&&a.parent;)fl(a.parent.vnode)&&Ky(i,e,n,a),a=a.parent}}function Ky(t,e,n,i){const a=hl(e,t,i,!0);ip(()=>{xf(i[e],a)},n)}function hl(t,e,n=Ot,i=!1){if(n){const a=n[t]||(n[t]=[]),l=e.__weh||(e.__weh=(...m)=>{if(n.isUnmounted)return;Qo(),Do(n);const w=Hn(e,n,t,m);return xs(),jo(),w});return i?a.unshift(l):a.push(l),l}}const Vr=t=>(e,n=Ot)=>(!Ra||t==="sp")&&hl(t,(...i)=>e(...i),n),Jy=Vr("bm"),np=Vr("m"),Gy=Vr("bu"),Xy=Vr("u"),rp=Vr("bum"),ip=Vr("um"),Yy=Vr("sp"),Zy=Vr("rtg"),ew=Vr("rtc");function tw(t,e=Ot){hl("ec",t,e)}function ji(t,e,n,i){const a=t.dirs,l=e&&e.dirs;for(let m=0;mt?pp(t)?Bf(t)||t.proxy:Xl(t.parent):null,ba=on(Object.create(null),{$:t=>t,$el:t=>t.vnode.el,$data:t=>t.data,$props:t=>t.props,$attrs:t=>t.attrs,$slots:t=>t.slots,$refs:t=>t.refs,$parent:t=>Xl(t.parent),$root:t=>Xl(t.root),$emit:t=>t.emit,$options:t=>Lf(t),$forceUpdate:t=>t.f||(t.f=()=>Df(t.update)),$nextTick:t=>t.n||(t.n=qy.bind(t.proxy)),$watch:t=>Uy.bind(t)}),Pl=(t,e)=>t!==lt&&!t.__isScriptSetup&&Be(t,e),rw={get({_:t},e){const{ctx:n,setupState:i,data:a,props:l,accessCache:m,type:w,appContext:v}=t;let d;if(e[0]!=="$"){const ne=m[e];if(ne!==void 0)switch(ne){case 1:return i[e];case 2:return a[e];case 4:return n[e];case 3:return l[e]}else{if(Pl(i,e))return m[e]=1,i[e];if(a!==lt&&Be(a,e))return m[e]=2,a[e];if((d=t.propsOptions[0])&&Be(d,e))return m[e]=3,l[e];if(n!==lt&&Be(n,e))return m[e]=4,n[e];Yl&&(m[e]=0)}}const W=ba[e];let B,D;if(W)return e==="$attrs"&&xn(t,"get",e),W(t);if((B=w.__cssModules)&&(B=B[e]))return B;if(n!==lt&&Be(n,e))return m[e]=4,n[e];if(D=v.config.globalProperties,Be(D,e))return D[e]},set({_:t},e,n){const{data:i,setupState:a,ctx:l}=t;return Pl(a,e)?(a[e]=n,!0):i!==lt&&Be(i,e)?(i[e]=n,!0):Be(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(l[e]=n,!0)},has({_:{data:t,setupState:e,accessCache:n,ctx:i,appContext:a,propsOptions:l}},m){let w;return!!n[m]||t!==lt&&Be(t,m)||Pl(e,m)||(w=l[0])&&Be(w,m)||Be(i,m)||Be(ba,m)||Be(a.config.globalProperties,m)},defineProperty(t,e,n){return n.get!=null?t._.accessCache[e]=0:Be(n,"value")&&this.set(t,e,n.value,null),Reflect.defineProperty(t,e,n)}};let Yl=!0;function iw(t){const e=Lf(t),n=t.proxy,i=t.ctx;Yl=!1,e.beforeCreate&&ph(e.beforeCreate,t,"bc");const{data:a,computed:l,methods:m,watch:w,provide:v,inject:d,created:W,beforeMount:B,mounted:D,beforeUpdate:ne,updated:te,activated:b,deactivated:C,beforeDestroy:N,beforeUnmount:q,destroyed:T,unmounted:ee,render:Ne,renderTracked:ae,renderTriggered:_e,errorCaptured:xe,serverPrefetch:tt,expose:ze,inheritAttrs:qt,components:Wt,directives:Qe,filters:Kt}=e;if(d&&sw(d,i,null,t.appContext.config.unwrapInjectedRef),m)for(const ge in m){const Oe=m[ge];Se(Oe)&&(i[ge]=Oe.bind(n))}if(a){const ge=a.call(n,n);yt(ge)&&(t.data=Tf(ge))}if(Yl=!0,l)for(const ge in l){const Oe=l[ge],ut=Se(Oe)?Oe.bind(n,n):Se(Oe.get)?Oe.get.bind(n,n):pr,we=!Se(Oe)&&Se(Oe.set)?Oe.set.bind(n):pr,Re=Pw({get:ut,set:we});Object.defineProperty(i,ge,{enumerable:!0,configurable:!0,get:()=>Re.value,set:Pt=>Re.value=Pt})}if(w)for(const ge in w)sp(w[ge],i,n,ge);if(v){const ge=Se(v)?v.call(n):v;Reflect.ownKeys(ge).forEach(Oe=>{Fy(Oe,ge[Oe])})}W&&ph(W,t,"c");function wt(ge,Oe){Ie(Oe)?Oe.forEach(ut=>ge(ut.bind(n))):Oe&&ge(Oe.bind(n))}if(wt(Jy,B),wt(np,D),wt(Gy,ne),wt(Xy,te),wt(Vy,b),wt(zy,C),wt(tw,xe),wt(ew,ae),wt(Zy,_e),wt(rp,q),wt(ip,ee),wt(Yy,tt),Ie(ze))if(ze.length){const ge=t.exposed||(t.exposed={});ze.forEach(Oe=>{Object.defineProperty(ge,Oe,{get:()=>n[Oe],set:ut=>n[Oe]=ut})})}else t.exposed||(t.exposed={});Ne&&t.render===pr&&(t.render=Ne),qt!=null&&(t.inheritAttrs=qt),Wt&&(t.components=Wt),Qe&&(t.directives=Qe)}function sw(t,e,n=pr,i=!1){Ie(t)&&(t=Zl(t));for(const a in t){const l=t[a];let m;yt(l)?"default"in l?m=Gu(l.from||a,l.default,!0):m=Gu(l.from||a):m=Gu(l),rn(m)&&i?Object.defineProperty(e,a,{enumerable:!0,configurable:!0,get:()=>m.value,set:w=>m.value=w}):e[a]=m}}function ph(t,e,n){Hn(Ie(t)?t.map(i=>i.bind(e.proxy)):t.bind(e.proxy),e,n)}function sp(t,e,n,i){const a=i.includes(".")?Yd(n,i):()=>n[i];if(Lt(t)){const l=e[t];Se(l)&&Dl(a,l)}else if(Se(t))Dl(a,t.bind(n));else if(yt(t))if(Ie(t))t.forEach(l=>sp(l,e,n,i));else{const l=Se(t.handler)?t.handler.bind(n):e[t.handler];Se(l)&&Dl(a,l,t)}}function Lf(t){const e=t.type,{mixins:n,extends:i}=e,{mixins:a,optionsCache:l,config:{optionMergeStrategies:m}}=t.appContext,w=l.get(e);let v;return w?v=w:!a.length&&!n&&!i?v=e:(v={},a.length&&a.forEach(d=>cc(v,d,m,!0)),cc(v,e,m)),yt(e)&&l.set(e,v),v}function cc(t,e,n,i=!1){const{mixins:a,extends:l}=e;l&&cc(t,l,n,!0),a&&a.forEach(m=>cc(t,m,n,!0));for(const m in e)if(!(i&&m==="expose")){const w=ow[m]||n&&n[m];t[m]=w?w(t[m],e[m]):e[m]}return t}const ow={data:mh,props:zi,emits:zi,methods:zi,computed:zi,beforeCreate:un,created:un,beforeMount:un,mounted:un,beforeUpdate:un,updated:un,beforeDestroy:un,beforeUnmount:un,destroyed:un,unmounted:un,activated:un,deactivated:un,errorCaptured:un,serverPrefetch:un,components:zi,directives:zi,watch:uw,provide:mh,inject:aw};function mh(t,e){return e?t?function(){return on(Se(t)?t.call(this,this):t,Se(e)?e.call(this,this):e)}:e:t}function aw(t,e){return zi(Zl(t),Zl(e))}function Zl(t){if(Ie(t)){const e={};for(let n=0;n0)&&!(m&16)){if(m&8){const W=t.vnode.dynamicProps;for(let B=0;B{v=!0;const[D,ne]=ap(B,e,!0);on(m,D),ne&&w.push(...ne)};!n&&e.mixins.length&&e.mixins.forEach(W),t.extends&&W(t.extends),t.mixins&&t.mixins.forEach(W)}if(!l&&!v)return yt(t)&&i.set(t,Zs),Zs;if(Ie(l))for(let W=0;W-1,ne[1]=b<0||te-1||Be(ne,"default"))&&w.push(B)}}}const d=[m,w];return yt(t)&&i.set(t,d),d}function yh(t){return t[0]!=="$"}function wh(t){const e=t&&t.toString().match(/^\s*(function|class) (\w+)/);return e?e[2]:t===null?"null":""}function gh(t,e){return wh(t)===wh(e)}function bh(t,e){return Ie(e)?e.findIndex(n=>gh(n,t)):Se(e)&&gh(e,t)?0:-1}const up=t=>t[0]==="_"||t==="$stable",Pf=t=>Ie(t)?t.map(Cr):[Cr(t)],fw=(t,e,n)=>{if(e._n)return e;const i=ky((...a)=>Pf(e(...a)),n);return i._c=!1,i},cp=(t,e,n)=>{const i=t._ctx;for(const a in t){if(up(a))continue;const l=t[a];if(Se(l))e[a]=fw(a,l,i);else if(l!=null){const m=Pf(l);e[a]=()=>m}}},lp=(t,e)=>{const n=Pf(e);t.slots.default=()=>n},hw=(t,e)=>{if(t.vnode.shapeFlag&32){const n=e._;n?(t.slots=Fe(e),oc(e,"_",n)):cp(e,t.slots={})}else t.slots={},e&&lp(t,e);oc(t.slots,pl,1)},dw=(t,e,n)=>{const{vnode:i,slots:a}=t;let l=!0,m=lt;if(i.shapeFlag&32){const w=e._;w?n&&w===1?l=!1:(on(a,e),!n&&w===1&&delete a._):(l=!e.$stable,cp(e,a)),m=e}else e&&(lp(t,e),m={default:1});if(l)for(const w in a)!up(w)&&!(w in m)&&delete a[w]};function fp(){return{app:null,config:{isNativeTag:Lm,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}let pw=0;function mw(t,e){return function(i,a=null){Se(i)||(i=Object.assign({},i)),a!=null&&!yt(a)&&(a=null);const l=fp(),m=new Set;let w=!1;const v=l.app={_uid:pw++,_component:i,_props:a,_container:null,_context:l,_instance:null,version:Fw,get config(){return l.config},set config(d){},use(d,...W){return m.has(d)||(d&&Se(d.install)?(m.add(d),d.install(v,...W)):Se(d)&&(m.add(d),d(v,...W))),v},mixin(d){return l.mixins.includes(d)||l.mixins.push(d),v},component(d,W){return W?(l.components[d]=W,v):l.components[d]},directive(d,W){return W?(l.directives[d]=W,v):l.directives[d]},mount(d,W,B){if(!w){const D=_s(i,a);return D.appContext=l,W&&e?e(D,d):t(D,d,B),w=!0,v._container=d,d.__vue_app__=v,Bf(D.component)||D.component.proxy}},unmount(){w&&(t(null,v._container),delete v._container.__vue_app__)},provide(d,W){return l.provides[d]=W,v}};return v}}function tf(t,e,n,i,a=!1){if(Ie(t)){t.forEach((D,ne)=>tf(D,e&&(Ie(e)?e[ne]:e),n,i,a));return}if(Xu(i)&&!a)return;const l=i.shapeFlag&4?Bf(i.component)||i.component.proxy:i.el,m=a?null:l,{i:w,r:v}=t,d=e&&e.r,W=w.refs===lt?w.refs={}:w.refs,B=w.setupState;if(d!=null&&d!==v&&(Lt(d)?(W[d]=null,Be(B,d)&&(B[d]=null)):rn(d)&&(d.value=null)),Se(v))bi(v,w,12,[m,W]);else{const D=Lt(v),ne=rn(v);if(D||ne){const te=()=>{if(t.f){const b=D?Be(B,v)?B[v]:W[v]:v.value;a?Ie(b)&&xf(b,l):Ie(b)?b.includes(l)||b.push(l):D?(W[v]=[l],Be(B,v)&&(B[v]=W[v])):(v.value=[l],t.k&&(W[t.k]=v.value))}else D?(W[v]=m,Be(B,v)&&(B[v]=m)):ne&&(v.value=m,t.k&&(W[t.k]=m))};m?(te.id=-1,bn(te,n)):te()}}}const bn=By;function yw(t){return ww(t)}function ww(t,e){const n=Qm();n.__VUE__=!0;const{insert:i,remove:a,patchProp:l,createElement:m,createText:w,createComment:v,setText:d,setElementText:W,parentNode:B,nextSibling:D,setScopeId:ne=pr,insertStaticContent:te}=t,b=(x,O,R,F=null,K=null,Y=null,j=!1,z=null,re=!!O.dynamicChildren)=>{if(x===O)return;x&&!Ji(x,O)&&(F=fe(x),Pt(x,K,Y,!0),x=null),O.patchFlag===-2&&(re=!1,O.dynamicChildren=null);const{type:J,ref:ce,shapeFlag:oe}=O;switch(J){case dl:C(x,O,R,F);break;case Fr:N(x,O,R,F);break;case Ml:x==null&&q(O,R,F,j);break;case cr:Wt(x,O,R,F,K,Y,j,z,re);break;default:oe&1?Ne(x,O,R,F,K,Y,j,z,re):oe&6?Qe(x,O,R,F,K,Y,j,z,re):(oe&64||oe&128)&&J.process(x,O,R,F,K,Y,j,z,re,zn)}ce!=null&&K&&tf(ce,x&&x.ref,Y,O||x,!O)},C=(x,O,R,F)=>{if(x==null)i(O.el=w(O.children),R,F);else{const K=O.el=x.el;O.children!==x.children&&d(K,O.children)}},N=(x,O,R,F)=>{x==null?i(O.el=v(O.children||""),R,F):O.el=x.el},q=(x,O,R,F)=>{[x.el,x.anchor]=te(x.children,O,R,F,x.el,x.anchor)},T=({el:x,anchor:O},R,F)=>{let K;for(;x&&x!==O;)K=D(x),i(x,R,F),x=K;i(O,R,F)},ee=({el:x,anchor:O})=>{let R;for(;x&&x!==O;)R=D(x),a(x),x=R;a(O)},Ne=(x,O,R,F,K,Y,j,z,re)=>{j=j||O.type==="svg",x==null?ae(O,R,F,K,Y,j,z,re):tt(x,O,K,Y,j,z,re)},ae=(x,O,R,F,K,Y,j,z)=>{let re,J;const{type:ce,props:oe,shapeFlag:ue,transition:be,dirs:Ee}=x;if(re=x.el=m(x.type,Y,oe&&oe.is,oe),ue&8?W(re,x.children):ue&16&&xe(x.children,re,null,F,K,Y&&ce!=="foreignObject",j,z),Ee&&ji(x,null,F,"created"),_e(re,x,x.scopeId,j,F),oe){for(const Le in oe)Le!=="value"&&!Ju(Le)&&l(re,Le,null,oe[Le],Y,x.children,F,K,pn);"value"in oe&&l(re,"value",null,oe.value),(J=oe.onVnodeBeforeMount)&&br(J,F,x)}Ee&&ji(x,null,F,"beforeMount");const je=(!K||K&&!K.pendingBranch)&&be&&!be.persisted;je&&be.beforeEnter(re),i(re,O,R),((J=oe&&oe.onVnodeMounted)||je||Ee)&&bn(()=>{J&&br(J,F,x),je&&be.enter(re),Ee&&ji(x,null,F,"mounted")},K)},_e=(x,O,R,F,K)=>{if(R&&ne(x,R),F)for(let Y=0;Y{for(let J=re;J{const z=O.el=x.el;let{patchFlag:re,dynamicChildren:J,dirs:ce}=O;re|=x.patchFlag&16;const oe=x.props||lt,ue=O.props||lt;let be;R&&Hi(R,!1),(be=ue.onVnodeBeforeUpdate)&&br(be,R,O,x),ce&&ji(O,x,R,"beforeUpdate"),R&&Hi(R,!0);const Ee=K&&O.type!=="foreignObject";if(J?ze(x.dynamicChildren,J,z,R,F,Ee,Y):j||Oe(x,O,z,null,R,F,Ee,Y,!1),re>0){if(re&16)qt(z,O,oe,ue,R,F,K);else if(re&2&&oe.class!==ue.class&&l(z,"class",null,ue.class,K),re&4&&l(z,"style",oe.style,ue.style,K),re&8){const je=O.dynamicProps;for(let Le=0;Le{be&&br(be,R,O,x),ce&&ji(O,x,R,"updated")},F)},ze=(x,O,R,F,K,Y,j)=>{for(let z=0;z{if(R!==F){if(R!==lt)for(const z in R)!Ju(z)&&!(z in F)&&l(x,z,R[z],null,j,O.children,K,Y,pn);for(const z in F){if(Ju(z))continue;const re=F[z],J=R[z];re!==J&&z!=="value"&&l(x,z,J,re,j,O.children,K,Y,pn)}"value"in F&&l(x,"value",R.value,F.value)}},Wt=(x,O,R,F,K,Y,j,z,re)=>{const J=O.el=x?x.el:w(""),ce=O.anchor=x?x.anchor:w("");let{patchFlag:oe,dynamicChildren:ue,slotScopeIds:be}=O;be&&(z=z?z.concat(be):be),x==null?(i(J,R,F),i(ce,R,F),xe(O.children,R,ce,K,Y,j,z,re)):oe>0&&oe&64&&ue&&x.dynamicChildren?(ze(x.dynamicChildren,ue,R,K,Y,j,z),(O.key!=null||K&&O===K.subTree)&&hp(x,O,!0)):Oe(x,O,R,ce,K,Y,j,z,re)},Qe=(x,O,R,F,K,Y,j,z,re)=>{O.slotScopeIds=z,x==null?O.shapeFlag&512?K.ctx.activate(O,R,F,j,re):Kt(O,R,F,K,Y,j,re):dn(x,O,re)},Kt=(x,O,R,F,K,Y,j)=>{const z=x.component=Aw(x,F,K);if(fl(x)&&(z.ctx.renderer=zn),Sw(z),z.asyncDep){if(K&&K.registerDep(z,wt),!x.el){const re=z.subTree=_s(Fr);N(null,re,O,R)}return}wt(z,x,O,R,K,Y,j)},dn=(x,O,R)=>{const F=O.component=x.component;if(Ly(x,O,R))if(F.asyncDep&&!F.asyncResolved){ge(F,O,R);return}else F.next=O,Iy(F.update),F.update();else O.el=x.el,F.vnode=O},wt=(x,O,R,F,K,Y,j)=>{const z=()=>{if(x.isMounted){let{next:ce,bu:oe,u:ue,parent:be,vnode:Ee}=x,je=ce,Le;Hi(x,!1),ce?(ce.el=Ee.el,ge(x,ce,j)):ce=Ee,oe&&kl(oe),(Le=ce.props&&ce.props.onVnodeBeforeUpdate)&&br(Le,be,ce,Ee),Hi(x,!0);const it=Rl(x),me=x.subTree;x.subTree=it,b(me,it,B(me.el),fe(me),x,K,Y),ce.el=it.el,je===null&&Py(x,it.el),ue&&bn(ue,K),(Le=ce.props&&ce.props.onVnodeUpdated)&&bn(()=>br(Le,be,ce,Ee),K)}else{let ce;const{el:oe,props:ue}=O,{bm:be,m:Ee,parent:je}=x,Le=Xu(O);if(Hi(x,!1),be&&kl(be),!Le&&(ce=ue&&ue.onVnodeBeforeMount)&&br(ce,je,O),Hi(x,!0),oe&&Ke){const it=()=>{x.subTree=Rl(x),Ke(oe,x.subTree,x,K,null)};Le?O.type.__asyncLoader().then(()=>!x.isUnmounted&&it()):it()}else{const it=x.subTree=Rl(x);b(null,it,R,F,x,K,Y),O.el=it.el}if(Ee&&bn(Ee,K),!Le&&(ce=ue&&ue.onVnodeMounted)){const it=O;bn(()=>br(ce,je,it),K)}(O.shapeFlag&256||je&&Xu(je.vnode)&&je.vnode.shapeFlag&256)&&x.a&&bn(x.a,K),x.isMounted=!0,O=R=F=null}},re=x.effect=new qf(z,()=>Df(J),x.scope),J=x.update=()=>re.run();J.id=x.uid,Hi(x,!0),J()},ge=(x,O,R)=>{O.component=x;const F=x.vnode.props;x.vnode=O,x.next=null,lw(x,O.props,F,R),dw(x,O.children,R),Qo(),fh(),jo()},Oe=(x,O,R,F,K,Y,j,z,re=!1)=>{const J=x&&x.children,ce=x?x.shapeFlag:0,oe=O.children,{patchFlag:ue,shapeFlag:be}=O;if(ue>0){if(ue&128){we(J,oe,R,F,K,Y,j,z,re);return}else if(ue&256){ut(J,oe,R,F,K,Y,j,z,re);return}}be&8?(ce&16&&pn(J,K,Y),oe!==J&&W(R,oe)):ce&16?be&16?we(J,oe,R,F,K,Y,j,z,re):pn(J,K,Y,!0):(ce&8&&W(R,""),be&16&&xe(oe,R,F,K,Y,j,z,re))},ut=(x,O,R,F,K,Y,j,z,re)=>{x=x||Zs,O=O||Zs;const J=x.length,ce=O.length,oe=Math.min(J,ce);let ue;for(ue=0;uece?pn(x,K,Y,!0,!1,oe):xe(O,R,F,K,Y,j,z,re,oe)},we=(x,O,R,F,K,Y,j,z,re)=>{let J=0;const ce=O.length;let oe=x.length-1,ue=ce-1;for(;J<=oe&&J<=ue;){const be=x[J],Ee=O[J]=re?si(O[J]):Cr(O[J]);if(Ji(be,Ee))b(be,Ee,R,null,K,Y,j,z,re);else break;J++}for(;J<=oe&&J<=ue;){const be=x[oe],Ee=O[ue]=re?si(O[ue]):Cr(O[ue]);if(Ji(be,Ee))b(be,Ee,R,null,K,Y,j,z,re);else break;oe--,ue--}if(J>oe){if(J<=ue){const be=ue+1,Ee=beue)for(;J<=oe;)Pt(x[J],K,Y,!0),J++;else{const be=J,Ee=J,je=new Map;for(J=Ee;J<=ue;J++){const le=O[J]=re?si(O[J]):Cr(O[J]);le.key!=null&&je.set(le.key,J)}let Le,it=0;const me=ue-Ee+1;let Cn=!1,Ci=0;const Gt=new Array(me);for(J=0;J=me){Pt(le,K,Y,!0);continue}let Mt;if(le.key!=null)Mt=je.get(le.key);else for(Le=Ee;Le<=ue;Le++)if(Gt[Le-Ee]===0&&Ji(le,O[Le])){Mt=Le;break}Mt===void 0?Pt(le,K,Y,!0):(Gt[Mt-Ee]=J+1,Mt>=Ci?Ci=Mt:Cn=!0,b(le,O[Mt],R,null,K,Y,j,z,re),it++)}const Os=Cn?gw(Gt):Zs;for(Le=Os.length-1,J=me-1;J>=0;J--){const le=Ee+J,Mt=O[le],Z=le+1{const{el:Y,type:j,transition:z,children:re,shapeFlag:J}=x;if(J&6){Re(x.component.subTree,O,R,F);return}if(J&128){x.suspense.move(O,R,F);return}if(J&64){j.move(x,O,R,zn);return}if(j===cr){i(Y,O,R);for(let oe=0;oez.enter(Y),K);else{const{leave:oe,delayLeave:ue,afterLeave:be}=z,Ee=()=>i(Y,O,R),je=()=>{oe(Y,()=>{Ee(),be&&be()})};ue?ue(Y,Ee,je):je()}else i(Y,O,R)},Pt=(x,O,R,F=!1,K=!1)=>{const{type:Y,props:j,ref:z,children:re,dynamicChildren:J,shapeFlag:ce,patchFlag:oe,dirs:ue}=x;if(z!=null&&tf(z,null,R,x,!0),ce&256){O.ctx.deactivate(x);return}const be=ce&1&&ue,Ee=!Xu(x);let je;if(Ee&&(je=j&&j.onVnodeBeforeUnmount)&&br(je,O,x),ce&6)En(x.component,R,F);else{if(ce&128){x.suspense.unmount(R,F);return}be&&ji(x,null,O,"beforeUnmount"),ce&64?x.type.remove(x,O,R,K,zn,F):J&&(Y!==cr||oe>0&&oe&64)?pn(J,O,R,!1,!0):(Y===cr&&oe&384||!K&&ce&16)&&pn(re,O,R),F&&Ar(x)}(Ee&&(je=j&&j.onVnodeUnmounted)||be)&&bn(()=>{je&&br(je,O,x),be&&ji(x,null,O,"unmounted")},R)},Ar=x=>{const{type:O,el:R,anchor:F,transition:K}=x;if(O===cr){Cs(R,F);return}if(O===Ml){ee(x);return}const Y=()=>{a(R),K&&!K.persisted&&K.afterLeave&&K.afterLeave()};if(x.shapeFlag&1&&K&&!K.persisted){const{leave:j,delayLeave:z}=K,re=()=>j(R,Y);z?z(x.el,Y,re):re()}else Y()},Cs=(x,O)=>{let R;for(;x!==O;)R=D(x),a(x),x=R;a(O)},En=(x,O,R)=>{const{bum:F,scope:K,update:Y,subTree:j,um:z}=x;F&&kl(F),K.stop(),Y&&(Y.active=!1,Pt(j,x,O,R)),z&&bn(z,O),bn(()=>{x.isUnmounted=!0},O),O&&O.pendingBranch&&!O.isUnmounted&&x.asyncDep&&!x.asyncResolved&&x.suspenseId===O.pendingId&&(O.deps--,O.deps===0&&O.resolve())},pn=(x,O,R,F=!1,K=!1,Y=0)=>{for(let j=Y;jx.shapeFlag&6?fe(x.component.subTree):x.shapeFlag&128?x.suspense.next():D(x.anchor||x.el),Me=(x,O,R)=>{x==null?O._vnode&&Pt(O._vnode,null,null,!0):b(O._vnode||null,x,O,null,null,null,R),fh(),zd(),O._vnode=x},zn={p:b,um:Pt,m:Re,r:Ar,mt:Kt,mc:xe,pc:Oe,pbc:ze,n:fe,o:t};let Jt,Ke;return e&&([Jt,Ke]=e(zn)),{render:Me,hydrate:Jt,createApp:mw(Me,Jt)}}function Hi({effect:t,update:e},n){t.allowRecurse=e.allowRecurse=n}function hp(t,e,n=!1){const i=t.children,a=e.children;if(Ie(i)&&Ie(a))for(let l=0;l>1,t[n[w]]0&&(e[i]=n[l-1]),n[l]=i)}}for(l=n.length,m=n[l-1];l-- >0;)n[l]=m,m=e[m];return n}const bw=t=>t.__isTeleport,cr=Symbol(void 0),dl=Symbol(void 0),Fr=Symbol(void 0),Ml=Symbol(void 0),Na=[];let hr=null;function Nw(t=!1){Na.push(hr=t?null:[])}function vw(){Na.pop(),hr=Na[Na.length-1]||null}let Sa=1;function Nh(t){Sa+=t}function _w(t){return t.dynamicChildren=Sa>0?hr||Zs:null,vw(),Sa>0&&hr&&hr.push(t),t}function xw(t,e,n,i,a,l){return _w(Ct(t,e,n,i,a,l,!0))}function Ew(t){return t?t.__v_isVNode===!0:!1}function Ji(t,e){return t.type===e.type&&t.key===e.key}const pl="__vInternal",dp=({key:t})=>t??null,Yu=({ref:t,ref_key:e,ref_for:n})=>t!=null?Lt(t)||rn(t)||Se(t)?{i:fr,r:t,k:e,f:!!n}:t:null;function Ct(t,e=null,n=null,i=0,a=null,l=t===cr?0:1,m=!1,w=!1){const v={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&dp(e),ref:e&&Yu(e),scopeId:Gd,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetAnchor:null,staticCount:0,shapeFlag:l,patchFlag:i,dynamicProps:a,dynamicChildren:null,appContext:null,ctx:fr};return w?(Mf(v,n),l&128&&t.normalize(v)):n&&(v.shapeFlag|=Lt(n)?8:16),Sa>0&&!m&&hr&&(v.patchFlag>0||l&6)&&v.patchFlag!==32&&hr.push(v),v}const _s=Cw;function Cw(t,e=null,n=null,i=0,a=null,l=!1){if((!t||t===nw)&&(t=Fr),Ew(t)){const w=_i(t,e,!0);return n&&Mf(w,n),Sa>0&&!l&&hr&&(w.shapeFlag&6?hr[hr.indexOf(t)]=w:hr.push(w)),w.patchFlag|=-2,w}if(Lw(t)&&(t=t.__vccOpts),e){e=Ow(e);let{class:w,style:v}=e;w&&!Lt(w)&&(e.class=vf(w)),yt(v)&&(Md(v)&&!Ie(v)&&(v=on({},v)),e.style=Nf(v))}const m=Lt(t)?1:My(t)?128:bw(t)?64:yt(t)?4:Se(t)?2:0;return Ct(t,e,n,i,a,m,l,!0)}function Ow(t){return t?Md(t)||pl in t?on({},t):t:null}function _i(t,e,n=!1){const{props:i,ref:a,patchFlag:l,children:m}=t,w=e?qw(i||{},e):i;return{__v_isVNode:!0,__v_skip:!0,type:t.type,props:w,key:w&&dp(w),ref:e&&e.ref?n&&a?Ie(a)?a.concat(Yu(e)):[a,Yu(e)]:Yu(e):a,scopeId:t.scopeId,slotScopeIds:t.slotScopeIds,children:m,target:t.target,targetAnchor:t.targetAnchor,staticCount:t.staticCount,shapeFlag:t.shapeFlag,patchFlag:e&&t.type!==cr?l===-1?16:l|16:l,dynamicProps:t.dynamicProps,dynamicChildren:t.dynamicChildren,appContext:t.appContext,dirs:t.dirs,transition:t.transition,component:t.component,suspense:t.suspense,ssContent:t.ssContent&&_i(t.ssContent),ssFallback:t.ssFallback&&_i(t.ssFallback),el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce}}function ka(t=" ",e=0){return _s(dl,null,t,e)}function Cr(t){return t==null||typeof t=="boolean"?_s(Fr):Ie(t)?_s(cr,null,t.slice()):typeof t=="object"?si(t):_s(dl,null,String(t))}function si(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:_i(t)}function Mf(t,e){let n=0;const{shapeFlag:i}=t;if(e==null)e=null;else if(Ie(e))n=16;else if(typeof e=="object")if(i&65){const a=e.default;a&&(a._c&&(a._d=!1),Mf(t,a()),a._c&&(a._d=!0));return}else{n=32;const a=e._;!a&&!(pl in e)?e._ctx=fr:a===3&&fr&&(fr.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else Se(e)?(e={default:e,_ctx:fr},n=32):(e=String(e),i&64?(n=16,e=[ka(e)]):n=8);t.children=e,t.shapeFlag|=n}function qw(...t){const e={};for(let n=0;nOt||fr,Do=t=>{Ot=t,t.scope.on()},xs=()=>{Ot&&Ot.scope.off(),Ot=null};function pp(t){return t.vnode.shapeFlag&4}let Ra=!1;function Sw(t,e=!1){Ra=e;const{props:n,children:i}=t.vnode,a=pp(t);cw(t,n,a,e),hw(t,i);const l=a?kw(t,e):void 0;return Ra=!1,l}function kw(t,e){const n=t.type;t.accessCache=Object.create(null),t.proxy=Bd(new Proxy(t.ctx,rw));const{setup:i}=n;if(i){const a=t.setupContext=i.length>1?Dw(t):null;Do(t),Qo();const l=bi(i,t,0,[t.props,a]);if(jo(),xs(),xd(l)){if(l.then(xs,xs),e)return l.then(m=>{vh(t,m,e)}).catch(m=>{cl(m,t,0)});t.asyncDep=l}else vh(t,l,e)}else mp(t,e)}function vh(t,e,n){Se(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:yt(e)&&(t.setupState=Qd(e)),mp(t,n)}let _h;function mp(t,e,n){const i=t.type;if(!t.render){if(!e&&_h&&!i.render){const a=i.template||Lf(t).template;if(a){const{isCustomElement:l,compilerOptions:m}=t.appContext.config,{delimiters:w,compilerOptions:v}=i,d=on(on({isCustomElement:l,delimiters:w},m),v);i.render=_h(a,d)}}t.render=i.render||pr}Do(t),Qo(),iw(t),jo(),xs()}function Rw(t){return new Proxy(t.attrs,{get(e,n){return xn(t,"get","$attrs"),e[n]}})}function Dw(t){const e=i=>{t.exposed=i||{}};let n;return{get attrs(){return n||(n=Rw(t))},slots:t.slots,emit:t.emit,expose:e}}function Bf(t){if(t.exposed)return t.exposeProxy||(t.exposeProxy=new Proxy(Qd(Bd(t.exposed)),{get(e,n){if(n in e)return e[n];if(n in ba)return ba[n](t)},has(e,n){return n in e||n in ba}}))}function Lw(t){return Se(t)&&"__vccOpts"in t}const Pw=(t,e)=>Cy(t,e,Ra),Mw=Symbol(""),Bw=()=>Gu(Mw),Fw="3.2.47",Uw="http://www.w3.org/2000/svg",Gi=typeof document<"u"?document:null,xh=Gi&&Gi.createElement("template"),$w={insert:(t,e,n)=>{e.insertBefore(t,n||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,n,i)=>{const a=e?Gi.createElementNS(Uw,t):Gi.createElement(t,n?{is:n}:void 0);return t==="select"&&i&&i.multiple!=null&&a.setAttribute("multiple",i.multiple),a},createText:t=>Gi.createTextNode(t),createComment:t=>Gi.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>Gi.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,n,i,a,l){const m=n?n.previousSibling:e.lastChild;if(a&&(a===l||a.nextSibling))for(;e.insertBefore(a.cloneNode(!0),n),!(a===l||!(a=a.nextSibling)););else{xh.innerHTML=i?`${t}`:t;const w=xh.content;if(i){const v=w.firstChild;for(;v.firstChild;)w.appendChild(v.firstChild);w.removeChild(v)}e.insertBefore(w,n)}return[m?m.nextSibling:e.firstChild,n?n.previousSibling:e.lastChild]}};function Qw(t,e,n){const i=t._vtc;i&&(e=(e?[e,...i]:[...i]).join(" ")),e==null?t.removeAttribute("class"):n?t.setAttribute("class",e):t.className=e}function jw(t,e,n){const i=t.style,a=Lt(n);if(n&&!a){if(e&&!Lt(e))for(const l in e)n[l]==null&&nf(i,l,"");for(const l in n)nf(i,l,n[l])}else{const l=i.display;a?e!==n&&(i.cssText=n):e&&t.removeAttribute("style"),"_vod"in t&&(i.display=l)}}const Eh=/\s*!important$/;function nf(t,e,n){if(Ie(n))n.forEach(i=>nf(t,e,i));else if(n==null&&(n=""),e.startsWith("--"))t.setProperty(e,n);else{const i=Hw(t,e);Eh.test(n)?t.setProperty($o(i),n.replace(Eh,""),"important"):t[i]=n}}const Ch=["Webkit","Moz","ms"],Bl={};function Hw(t,e){const n=Bl[e];if(n)return n;let i=ko(e);if(i!=="filter"&&i in t)return Bl[e]=i;i=Od(i);for(let a=0;aFl||(Yw.then(()=>Fl=0),Fl=Date.now());function eg(t,e){const n=i=>{if(!i._vts)i._vts=Date.now();else if(i._vts<=n.attached)return;Hn(tg(i,n.value),e,5,[i])};return n.value=t,n.attached=Zw(),n}function tg(t,e){if(Ie(e)){const n=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{n.call(t),t._stopped=!0},e.map(i=>a=>!a._stopped&&i&&i(a))}else return e}const Wh=/^on[a-z]/,ng=(t,e,n,i,a=!1,l,m,w,v)=>{e==="class"?Qw(t,i,a):e==="style"?jw(t,n,i):sl(e)?_f(e)||Gw(t,e,n,i,m):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):rg(t,e,i,a))?zw(t,e,i,l,m,w,v):(e==="true-value"?t._trueValue=i:e==="false-value"&&(t._falseValue=i),Vw(t,e,i,a))};function rg(t,e,n,i){return i?!!(e==="innerHTML"||e==="textContent"||e in t&&Wh.test(e)&&Se(n)):e==="spellcheck"||e==="draggable"||e==="translate"||e==="form"||e==="list"&&t.tagName==="INPUT"||e==="type"&&t.tagName==="TEXTAREA"||Wh.test(e)&&Lt(n)?!1:e in t}const ig={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String};jy.props;const sg=on({patchProp:ng},$w);let Ih;function og(){return Ih||(Ih=yw(sg))}const ag=(...t)=>{const e=og().createApp(...t),{mount:n}=e;return e.mount=i=>{const a=ug(i);if(!a)return;const l=e._component;!Se(l)&&!l.render&&!l.template&&(l.template=a.innerHTML),a.innerHTML="";const m=n(a,!1,a instanceof SVGElement);return a instanceof Element&&(a.removeAttribute("v-cloak"),a.setAttribute("data-v-app","")),m},e};function ug(t){return Lt(t)?document.querySelector(t):t}function va(t){return typeof t>"u"||t===void 0}function mr(t){return typeof t=="string"}function cg(t){return typeof t=="number"}function yp(t){return typeof t=="boolean"}function wp(t){return t===null}function lg(t){return t instanceof Date}function fg(t){return typeof t=="bigint"}function Vn(t){return typeof t=="function"}function Wr(t){return typeof t=="object"&&t!==null}function p(t){return Object.freeze(t)}function wu(t){return Array.isArray(t)}function Lo(t){return t}const Et=p({is(t){return t.kind==="AlterTableNode"},create(t){return p({kind:"AlterTableNode",table:t})},cloneWithTableProps(t,e){return p({...t,...e})},cloneWithColumnAlteration(t,e){return p({...t,columnAlterations:t.columnAlterations?[...t.columnAlterations,e]:[e]})}}),mt=p({is(t){return t.kind==="IdentifierNode"},create(t){return p({kind:"IdentifierNode",name:t})}}),ri=p({is(t){return t.kind==="CreateIndexNode"},create(t){return p({kind:"CreateIndexNode",name:mt.create(t)})},cloneWith(t,e){return p({...t,...e})},cloneWithColumns(t,e){return p({...t,columns:[...t.columns||[],...e]})}}),gp=p({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return p({kind:"CreateSchemaNode",schema:mt.create(t),...e})},cloneWith(t,e){return p({...t,...e})}}),hg=["preserve rows","delete rows","drop"],Zn=p({is(t){return t.kind==="CreateTableNode"},create(t){return p({kind:"CreateTableNode",table:t,columns:p([])})},cloneWithColumn(t,e){return p({...t,columns:p([...t.columns,e])})},cloneWithConstraint(t,e){return p({...t,constraints:t.constraints?p([...t.constraints,e]):p([e])})},cloneWithFrontModifier(t,e){return p({...t,frontModifiers:t.frontModifiers?p([...t.frontModifiers,e]):p([e])})},cloneWithEndModifier(t,e){return p({...t,endModifiers:t.endModifiers?p([...t.endModifiers,e]):p([e])})},cloneWith(t,e){return p({...t,...e})}}),xi=p({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return p({kind:"SchemableIdentifierNode",identifier:mt.create(t)})},createWithSchema(t,e){return p({kind:"SchemableIdentifierNode",schema:mt.create(t),identifier:mt.create(e)})}}),Zu=p({is(t){return t.kind==="DropIndexNode"},create(t,e){return p({kind:"DropIndexNode",name:xi.create(t),...e})},cloneWith(t,e){return p({...t,...e})}}),rf=p({is(t){return t.kind==="DropSchemaNode"},create(t,e){return p({kind:"DropSchemaNode",schema:mt.create(t),...e})},cloneWith(t,e){return p({...t,...e})}}),sf=p({is(t){return t.kind==="DropTableNode"},create(t,e){return p({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return p({...t,...e})}}),Es=p({is(t){return t.kind==="AliasNode"},create(t,e){return p({kind:"AliasNode",node:t,alias:e})}}),Ni=p({is(t){return t.kind==="TableNode"},create(t){return p({kind:"TableNode",table:xi.create(t)})},createWithSchema(t,e){return p({kind:"TableNode",table:xi.createWithSchema(t,e)})}});function hn(t){return Wr(t)&&Vn(t.toOperationNode)}function dg(t){return Wr(t)&&"expressionType"in t&&hn(t)}function pg(t){return Wr(t)&&"expression"in t&&mr(t.alias)&&hn(t)}const Sr=p({is(t){return t.kind==="SelectModifierNode"},create(t){return p({kind:"SelectModifierNode",modifier:t})},createWithExpression(t){return p({kind:"SelectModifierNode",rawModifier:t})}}),Da=p({is(t){return t.kind==="AndNode"},create(t,e){return p({kind:"AndNode",left:t,right:e})}}),La=p({is(t){return t.kind==="OrNode"},create(t,e){return p({kind:"OrNode",left:t,right:e})}}),pa=p({is(t){return t.kind==="OnNode"},create(t){return p({kind:"OnNode",on:t})},cloneWithOperation(t,e,n){return p({...t,on:e==="And"?Da.create(t.on,n):La.create(t.on,n)})}}),jn=p({is(t){return t.kind==="JoinNode"},create(t,e){return p({kind:"JoinNode",joinType:t,table:e,on:void 0})},createWithOn(t,e,n){return p({kind:"JoinNode",joinType:t,table:e,on:pa.create(n)})},cloneWithOn(t,e){return p({...t,on:t.on?pa.cloneWithOperation(t.on,"And",e):pa.create(e)})},cloneWithOrOn(t,e){return p({...t,on:t.on?pa.cloneWithOperation(t.on,"Or",e):pa.create(e)})}}),ml=p({is(t){return t.kind==="BinaryOperationNode"},create(t,e,n){return p({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:n})}}),en=p({is(t){return t.kind==="RawNode"},create(t,e){return p({kind:"RawNode",sqlFragments:p(t),parameters:p(e)})},createWithSql(t){return en.create([t],[])},createWithChild(t){return en.create(["",""],[t])},createWithChildren(t){return en.create(new Array(t.length+1).fill(""),t)}}),bp=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->"],mg=["+","-","*","/","%","^","&","|","#","<<",">>"],Np=[...bp,...mg,"&&","||"],yg=["exists","not exists"],wg=["not","-",...yg],gg=[...Np,...wg],Ff=p({is(t){return t.kind==="OperatorNode"},create(t){return p({kind:"OperatorNode",operator:t})}});function vp(t){return mr(t)&&Np.includes(t)}function _p(t){return mr(t)&&bp.includes(t)}const ro=p({is(t){return t.kind==="ParensNode"},create(t){return p({kind:"ParensNode",node:t})}}),Nt=p({is(t){return t.kind==="ColumnNode"},create(t){return p({kind:"ColumnNode",column:mt.create(t)})}}),Uf=p({is(t){return t.kind==="SelectAllNode"},create(){return p({kind:"SelectAllNode"})}}),yl=p({is(t){return t.kind==="ReferenceNode"},create(t,e){return p({kind:"ReferenceNode",table:t,column:e})},createSelectAll(t){return p({kind:"ReferenceNode",table:t,column:Uf.create()})}}),bg=p({is(t){return t.kind==="OrderByItemNode"},create(t,e){return p({kind:"OrderByItemNode",orderBy:t,direction:e})}});function Ng(t){return t==="asc"||t==="desc"}function wl(t,e){return bg.create(vg(t),_g(e))}function vg(t){return Hr(t)}function _g(t){if(t)return t==="asc"||t==="desc"?en.createWithSql(t):t.toOperationNode()}function xp(t){return mr(t)?Po(t):t.toOperationNode()}function Pa(t){return wu(t)?t.map(e=>Hr(e)):[Hr(t)]}function Hr(t){return xl(t)?_l(t):xp(t)}function Po(t){const e=".";if(t.includes(e)){const n=t.split(e).map($f);if(n.length===3)return Eg(n);if(n.length===2)return Cg(n);throw new Error(`invalid column reference ${t}`)}else return Nt.create(t)}function xg(t){const e=" as ";if(t.includes(e)){const[n,i]=t.split(e).map($f);return Es.create(Po(n),mt.create(i))}else return Po(t)}function Ep(t){return Nt.create(t)}function Ah(t){const e=" ";if(t.includes(e)){const[n,i]=t.split(e).map($f);if(!Ng(i))throw new Error(`invalid order direction "${i}" next to "${n}"`);return wl(n,i)}else return Ep(t)}function Eg(t){const[e,n,i]=t;return yl.create(Ni.createWithSchema(e,n),Nt.create(i))}function Cg(t){const[e,n]=t;return yl.create(Ni.create(e),Nt.create(n))}function $f(t){return t.trim()}const Cp=p({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return p({kind:"PrimitiveValueListNode",values:p([...t])})}}),Qf=p({is(t){return t.kind==="ValueListNode"},create(t){return p({kind:"ValueListNode",values:p(t)})}}),Ir=p({is(t){return t.kind==="ValueNode"},create(t){return p({kind:"ValueNode",value:t})},createImmediate(t){return p({kind:"ValueNode",value:t,immediate:!0})}});function Op(t){return wu(t)?Og(t):Ur(t)}function Ur(t){return xl(t)?_l(t):Ir.create(t)}function Og(t){return t.some(xl)?Qf.create(t.map(e=>Ur(e))):Cp.create(t)}const Mo=p({is(t){return t.kind==="OrderByNode"},create(t){return p({kind:"OrderByNode",items:p([t])})},cloneWithItem(t,e){return p({...t,items:p([...t.items,e])})}}),Th=p({is(t){return t.kind==="PartitionByNode"},create(t){return p({kind:"PartitionByNode",items:p(t)})},cloneWithItems(t,e){return p({...t,items:p([...t.items,...e])})}}),of=p({is(t){return t.kind==="OverNode"},create(){return p({kind:"OverNode"})},cloneWithOrderByItem(t,e){return p({...t,orderBy:t.orderBy?Mo.cloneWithItem(t.orderBy,e):Mo.create(e)})},cloneWithPartitionByItems(t,e){return p({...t,partitionBy:t.partitionBy?Th.cloneWithItems(t.partitionBy,e):Th.create(e)})}}),lc=p({is(t){return t.kind==="FromNode"},create(t){return p({kind:"FromNode",froms:p(t)})},cloneWithFroms(t,e){return p({...t,froms:p([...t.froms,...e])})}}),Sh=p({is(t){return t.kind==="GroupByNode"},create(t){return p({kind:"GroupByNode",items:p(t)})},cloneWithItems(t,e){return p({...t,items:p([...t.items,...e])})}}),Hu=p({is(t){return t.kind==="HavingNode"},create(t){return p({kind:"HavingNode",having:t})},cloneWithOperation(t,e,n){return p({...t,having:e==="And"?Da.create(t.having,n):La.create(t.having,n)})}}),We=p({is(t){return t.kind==="SelectQueryNode"},create(t,e){return p({kind:"SelectQueryNode",from:lc.create(t),...e&&{with:e}})},cloneWithSelections(t,e){return p({...t,selections:t.selections?p([...t.selections,...e]):p(e)})},cloneWithDistinctOn(t,e){return p({...t,distinctOn:t.distinctOn?p([...t.distinctOn,...e]):p(e)})},cloneWithFrontModifier(t,e){return p({...t,frontModifiers:t.frontModifiers?p([...t.frontModifiers,e]):p([e])})},cloneWithEndModifier(t,e){return p({...t,endModifiers:t.endModifiers?p([...t.endModifiers,e]):p([e])})},cloneWithOrderByItem(t,e){return p({...t,orderBy:t.orderBy?Mo.cloneWithItem(t.orderBy,e):Mo.create(e)})},cloneWithGroupByItems(t,e){return p({...t,groupBy:t.groupBy?Sh.cloneWithItems(t.groupBy,e):Sh.create(e)})},cloneWithLimit(t,e){return p({...t,limit:e})},cloneWithOffset(t,e){return p({...t,offset:e})},cloneWithHaving(t,e){return p({...t,having:t.having?Hu.cloneWithOperation(t.having,"And",e):Hu.create(e)})},cloneWithOrHaving(t,e){return p({...t,having:t.having?Hu.cloneWithOperation(t.having,"Or",e):Hu.create(e)})},cloneWithSetOperation(t,e){return p({...t,setOperations:t.setOperations?p([...t.setOperations,e]):p([e])})},cloneWithoutSelections(t){return p({...t,selections:[]})},cloneWithoutLimit(t){return p({...t,limit:void 0})},cloneWithoutOffset(t){return p({...t,offset:void 0})},cloneWithoutOrderBy(t){return p({...t,orderBy:void 0})}}),qp=p({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return p({kind:"UnaryOperationNode",operator:t,operand:e})}});function sn(t){return jf("exists",t)}function Vt(t){return jf("not exists",t)}function jf(t,e){return qp.create(Ff.create(t),Hr(e))}function $e(t,e){Object.defineProperties(t.prototype,{then:{enumerable:!1,value:()=>{throw new Error(e)}}})}var ft;const tr=class{constructor(e){S(this,ft,void 0);P(this,ft,p(e))}on(...e){return new tr({...r(this,ft),joinNode:jn.cloneWithOn(r(this,ft).joinNode,jh(e))})}orOn(...e){return new tr({...r(this,ft),joinNode:jn.cloneWithOrOn(r(this,ft).joinNode,jh(e))})}onRef(e,n,i){return new tr({...r(this,ft),joinNode:jn.cloneWithOn(r(this,ft).joinNode,zt(e,n,i))})}orOnRef(e,n,i){return new tr({...r(this,ft),joinNode:jn.cloneWithOrOn(r(this,ft).joinNode,zt(e,n,i))})}onExists(e){return new tr({...r(this,ft),joinNode:jn.cloneWithOn(r(this,ft).joinNode,sn(e))})}onNotExists(e){return new tr({...r(this,ft),joinNode:jn.cloneWithOn(r(this,ft).joinNode,Vt(e))})}orOnExists(e){return new tr({...r(this,ft),joinNode:jn.cloneWithOrOn(r(this,ft).joinNode,sn(e))})}orOnNotExists(e){return new tr({...r(this,ft),joinNode:jn.cloneWithOrOn(r(this,ft).joinNode,Vt(e))})}onTrue(){return new tr({...r(this,ft),joinNode:jn.cloneWithOn(r(this,ft).joinNode,en.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return r(this,ft).joinNode}};let fc=tr;ft=new WeakMap;$e(fc,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const qg=p({is(t){return t.kind==="PartitionByItemNode"},create(t){return p({kind:"PartitionByItemNode",partitionBy:t})}});function Wg(t){return Pa(t).map(qg.create)}var rs;const Rc=class{constructor(e){S(this,rs,void 0);P(this,rs,p(e))}orderBy(e,n){return new Rc({overNode:of.cloneWithOrderByItem(r(this,rs).overNode,wl(e,n))})}partitionBy(e){return new Rc({overNode:of.cloneWithPartitionByItems(r(this,rs).overNode,Wg(e))})}$call(e){return e(this)}toOperationNode(){return r(this,rs).overNode}};let hc=Rc;rs=new WeakMap;$e(hc,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");const _a=p({is(t){return t.kind==="SelectionNode"},create(t){return p({kind:"SelectionNode",selection:t})},createSelectAll(){return p({kind:"SelectionNode",selection:Uf.create()})},createSelectAllFromTable(t){return p({kind:"SelectionNode",selection:yl.createSelectAll(t)})}});var io;class Ig{constructor(e){S(this,io,void 0);P(this,io,e)}get dynamicReference(){return r(this,io)}get refType(){}toOperationNode(){return xp(r(this,io))}}io=new WeakMap;function Ag(t){return Wr(t)&&hn(t)&&mr(t.dynamicReference)}function gu(t){return Vn(t)?gu(t($r())):wu(t)?t.map(e=>kh(e)):[kh(t)]}function kh(t){return mr(t)?_a.create(xg(t)):Ag(t)?_a.create(t.toOperationNode()):_a.create(Hp(t))}function bu(t){return t?Array.isArray(t)?t.map(Rh):[Rh(t)]:[_a.createSelectAll()]}function Rh(t){if(mr(t))return _a.createSelectAllFromTable(_n(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const Tg=p({is(t){return t.kind==="ValuesNode"},create(t){return p({kind:"ValuesNode",values:p(t)})}}),Sg=p({is(t){return t.kind==="DefaultInsertValueNode"},create(){return p({kind:"DefaultInsertValueNode"})}});function kg(t){const e=Vn(t)?t($r()):t,n=wu(e)?e:p([e]);return Rg(n)}function Rg(t){const e=Dg(t);return[p([...e.keys()].map(Nt.create)),Tg.create(t.map(n=>Lg(n,e)))]}function Dg(t){const e=new Map;for(const n of t){const i=Object.keys(n);for(const a of i)!e.has(a)&&n[a]!==void 0&&e.set(a,e.size)}return e}function Lg(t,e){const n=Object.keys(t),i=Array.from({length:e.size});let a=!1;for(const m of n){const w=e.get(m);if(va(w))continue;const v=t[m];(va(v)||xl(v))&&(a=!0),i[w]=v}if(n.lengthva(w)?m:Ur(w)))}return Cp.create(i)}const Or=p({is(t){return t.kind==="InsertQueryNode"},create(t,e,n){return p({kind:"InsertQueryNode",into:t,...e&&{with:e},replace:n})},cloneWith(t,e){return p({...t,...e})}}),dc=p({is(t){return t.kind==="UpdateQueryNode"},create(t,e){return p({kind:"UpdateQueryNode",table:t,...e&&{with:e}})},cloneWithFromItems(t,e){return p({...t,from:t.from?lc.cloneWithFroms(t.from,e):lc.create(e)})},cloneWithUpdates(t,e){return p({...t,updates:t.updates?p([...t.updates,...e]):e})}}),Dh=p({is(t){return t.kind==="UsingNode"},create(t){return p({kind:"UsingNode",tables:p(t)})},cloneWithTables(t,e){return p({...t,tables:p([...t.tables,...e])})}}),xa=p({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return p({kind:"DeleteQueryNode",from:lc.create(t),...e&&{with:e}})},cloneWithOrderByItem(t,e){return p({...t,orderBy:t.orderBy?Mo.cloneWithItem(t.orderBy,e):Mo.create(e)})},cloneWithLimit(t,e){return p({...t,limit:e})},cloneWithUsing(t,e){return p({...t,using:t.using!==void 0?Dh.cloneWithTables(t.using,e):Dh.create(e)})}}),tn=p({is(t){return t.kind==="WhereNode"},create(t){return p({kind:"WhereNode",where:t})},cloneWithOperation(t,e,n){return p({...t,where:e==="And"?Da.create(t.where,n):La.create(t.where,n)})}}),Lh=p({is(t){return t.kind==="ReturningNode"},create(t){return p({kind:"ReturningNode",selections:p(t)})},cloneWithSelections(t,e){return p({...t,selections:t.selections?p([...t.selections,...e]):p(e)})}}),Pg=p({is(t){return t.kind==="ExplainNode"},create(t,e){return p({kind:"ExplainNode",format:t,options:e})}}),ye=p({is(t){return We.is(t)||Or.is(t)||dc.is(t)||xa.is(t)},cloneWithWhere(t,e){return p({...t,where:t.where?tn.cloneWithOperation(t.where,"And",e):tn.create(e)})},cloneWithOrWhere(t,e){return p({...t,where:t.where?tn.cloneWithOperation(t.where,"Or",e):tn.create(e)})},cloneWithJoin(t,e){return p({...t,joins:t.joins?p([...t.joins,e]):p([e])})},cloneWithReturning(t,e){return p({...t,returning:t.returning?Lh.cloneWithSelections(t.returning,e):Lh.create(e)})},cloneWithoutWhere(t){return p({...t,where:void 0})},cloneWithExplain(t,e,n){return p({...t,explain:Pg.create(e,n==null?void 0:n.toOperationNode())})}}),Mg=p({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return p({kind:"ColumnUpdateNode",column:t,value:e})}});function Hf(t){const e=Vn(t)?t($r()):t;return Object.entries(e).filter(([n,i])=>i!==void 0).map(([n,i])=>Mg.create(Nt.create(n),Ur(i)))}const Bg=p({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return p({kind:"OnDuplicateKeyNode",updates:t})}});var Qa,ja;class Wp{constructor(e,n){S(this,Qa,void 0);S(this,ja,void 0);P(this,Qa,e),P(this,ja,n)}get insertId(){return r(this,Qa)}get numInsertedOrUpdatedRows(){return r(this,ja)}}Qa=new WeakMap,ja=new WeakMap;for(const t of["insertId","numInsertedOrUpdatedRows"])Object.defineProperty(Wp.prototype,t,{enumerable:!0});class gl extends Error{constructor(n){super("no result");Yt(this,"node");this.node=n}}function bl(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const at=p({is(t){return t.kind==="OnConflictNode"},create(){return p({kind:"OnConflictNode"})},cloneWith(t,e){return p({...t,...e})},cloneWithIndexWhere(t,e){return p({...t,indexWhere:t.indexWhere?tn.cloneWithOperation(t.indexWhere,"And",e):tn.create(e)})},cloneWithIndexOrWhere(t,e){return p({...t,indexWhere:t.indexWhere?tn.cloneWithOperation(t.indexWhere,"Or",e):tn.create(e)})},cloneWithUpdateWhere(t,e){return p({...t,updateWhere:t.updateWhere?tn.cloneWithOperation(t.updateWhere,"And",e):tn.create(e)})},cloneWithUpdateOrWhere(t,e){return p({...t,updateWhere:t.updateWhere?tn.cloneWithOperation(t.updateWhere,"Or",e):tn.create(e)})},cloneWithoutIndexWhere(t){return p({...t,indexWhere:void 0})},cloneWithoutUpdateWhere(t){return p({...t,updateWhere:void 0})}});var ke;const cn=class{constructor(e){S(this,ke,void 0);P(this,ke,p(e))}column(e){const n=Nt.create(e);return new cn({...r(this,ke),onConflictNode:at.cloneWith(r(this,ke).onConflictNode,{columns:r(this,ke).onConflictNode.columns?p([...r(this,ke).onConflictNode.columns,n]):p([n])})})}columns(e){const n=e.map(Nt.create);return new cn({...r(this,ke),onConflictNode:at.cloneWith(r(this,ke).onConflictNode,{columns:r(this,ke).onConflictNode.columns?p([...r(this,ke).onConflictNode.columns,...n]):p(n)})})}constraint(e){return new cn({...r(this,ke),onConflictNode:at.cloneWith(r(this,ke).onConflictNode,{constraint:mt.create(e)})})}expression(e){return new cn({...r(this,ke),onConflictNode:at.cloneWith(r(this,ke).onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new cn({...r(this,ke),onConflictNode:at.cloneWithIndexWhere(r(this,ke).onConflictNode,Rn(e))})}whereRef(e,n,i){return new cn({...r(this,ke),onConflictNode:at.cloneWithIndexWhere(r(this,ke).onConflictNode,zt(e,n,i))})}orWhere(...e){return new cn({...r(this,ke),onConflictNode:at.cloneWithIndexOrWhere(r(this,ke).onConflictNode,Rn(e))})}orWhereRef(e,n,i){return new cn({...r(this,ke),onConflictNode:at.cloneWithIndexOrWhere(r(this,ke).onConflictNode,zt(e,n,i))})}whereExists(e){return new cn({...r(this,ke),onConflictNode:at.cloneWithIndexWhere(r(this,ke).onConflictNode,sn(e))})}whereNotExists(e){return new cn({...r(this,ke),onConflictNode:at.cloneWithIndexWhere(r(this,ke).onConflictNode,Vt(e))})}orWhereExists(e){return new cn({...r(this,ke),onConflictNode:at.cloneWithIndexOrWhere(r(this,ke).onConflictNode,sn(e))})}orWhereNotExists(e){return new cn({...r(this,ke),onConflictNode:at.cloneWithIndexOrWhere(r(this,ke).onConflictNode,Vt(e))})}clearWhere(){return new cn({...r(this,ke),onConflictNode:at.cloneWithoutIndexWhere(r(this,ke).onConflictNode)})}doNothing(){return new Ip({...r(this,ke),onConflictNode:at.cloneWith(r(this,ke).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new mc({...r(this,ke),onConflictNode:at.cloneWith(r(this,ke).onConflictNode,{updates:Hf(e)})})}$call(e){return e(this)}};let pc=cn;ke=new WeakMap;$e(pc,"don't await OnConflictBuilder instances.");var Ha;class Ip{constructor(e){S(this,Ha,void 0);P(this,Ha,p(e))}toOperationNode(){return r(this,Ha).onConflictNode}}Ha=new WeakMap;$e(Ip,"don't await OnConflictDoNothingBuilder instances.");var ht;const nr=class{constructor(e){S(this,ht,void 0);P(this,ht,p(e))}where(...e){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateWhere(r(this,ht).onConflictNode,Rn(e))})}whereRef(e,n,i){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateWhere(r(this,ht).onConflictNode,zt(e,n,i))})}orWhere(...e){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateOrWhere(r(this,ht).onConflictNode,Rn(e))})}orWhereRef(e,n,i){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateOrWhere(r(this,ht).onConflictNode,zt(e,n,i))})}whereExists(e){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateWhere(r(this,ht).onConflictNode,sn(e))})}whereNotExists(e){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateWhere(r(this,ht).onConflictNode,Vt(e))})}orWhereExists(e){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateOrWhere(r(this,ht).onConflictNode,sn(e))})}orWhereNotExists(e){return new nr({...r(this,ht),onConflictNode:at.cloneWithUpdateOrWhere(r(this,ht).onConflictNode,Vt(e))})}clearWhere(){return new nr({...r(this,ht),onConflictNode:at.cloneWithoutUpdateWhere(r(this,ht).onConflictNode)})}$call(e){return e(this)}toOperationNode(){return r(this,ht).onConflictNode}};let mc=nr;ht=new WeakMap;$e(mc,"don't await OnConflictUpdateBuilder instances.");var Te;const Tt=class{constructor(e){S(this,Te,void 0);P(this,Te,p(e))}values(e){const[n,i]=kg(e);return new Tt({...r(this,Te),queryNode:Or.cloneWith(r(this,Te).queryNode,{columns:n,values:i})})}columns(e){return new Tt({...r(this,Te),queryNode:Or.cloneWith(r(this,Te).queryNode,{columns:p(e.map(Nt.create))})})}expression(e){return new Tt({...r(this,Te),queryNode:Or.cloneWith(r(this,Te).queryNode,{values:_l(e)})})}ignore(){return new Tt({...r(this,Te),queryNode:Or.cloneWith(r(this,Te).queryNode,{ignore:!0})})}onConflict(e){return new Tt({...r(this,Te),queryNode:Or.cloneWith(r(this,Te).queryNode,{onConflict:e(new pc({onConflictNode:at.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new Tt({...r(this,Te),queryNode:Or.cloneWith(r(this,Te).queryNode,{onDuplicateKey:Bg.create(Hf(e))})})}returning(e){return new Tt({...r(this,Te),queryNode:ye.cloneWithReturning(r(this,Te).queryNode,gu(e))})}returningAll(){return new Tt({...r(this,Te),queryNode:ye.cloneWithReturning(r(this,Te).queryNode,bu())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,n){return e?n(this):new Tt({...r(this,Te)})}if(e,n){return e?n(this):new Tt({...r(this,Te)})}$castTo(){return new Tt(r(this,Te))}castTo(){return this.$castTo()}$narrowType(){return new Tt(r(this,Te))}$assertType(){return new Tt(r(this,Te))}assertType(){return new Tt(r(this,Te))}withPlugin(e){return new Tt({...r(this,Te),executor:r(this,Te).executor.withPlugin(e)})}toOperationNode(){return r(this,Te).executor.transformQuery(r(this,Te).queryNode,r(this,Te).queryId)}compile(){return r(this,Te).executor.compileQuery(this.toOperationNode(),r(this,Te).queryId)}async execute(){const e=this.compile(),n=e.query,i=await r(this,Te).executor.executeQuery(e,r(this,Te).queryId);return r(this,Te).executor.adapter.supportsReturning&&n.returning?i.rows:[new Wp(i.insertId,i.numAffectedRows??i.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=gl){const n=await this.executeTakeFirst();if(n===void 0)throw bl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),i=r(this,Te).executor.stream(n,e,r(this,Te).queryId);for await(const a of i)yield*a.rows}async explain(e,n){return await new Tt({...r(this,Te),queryNode:ye.cloneWithExplain(r(this,Te).queryNode,e,n)}).execute()}};let Ma=Tt;Te=new WeakMap;$e(Ma,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");var Va;class Ap{constructor(e){S(this,Va,void 0);P(this,Va,e)}get numDeletedRows(){return r(this,Va)}}Va=new WeakMap;Object.defineProperty(Ap.prototype,"numDeletedRows",{enumerable:!0});const Tp=p({is(t){return t.kind==="LimitNode"},create(t){return p({kind:"LimitNode",limit:Ir.create(t)})}});var de;const Xe=class{constructor(e){S(this,de,void 0);P(this,de,p(e))}where(...e){return new Xe({...r(this,de),queryNode:ye.cloneWithWhere(r(this,de).queryNode,Rn(e))})}whereRef(e,n,i){return new Xe({...r(this,de),queryNode:ye.cloneWithWhere(r(this,de).queryNode,zt(e,n,i))})}orWhere(...e){return new Xe({...r(this,de),queryNode:ye.cloneWithOrWhere(r(this,de).queryNode,Rn(e))})}orWhereRef(e,n,i){return new Xe({...r(this,de),queryNode:ye.cloneWithOrWhere(r(this,de).queryNode,zt(e,n,i))})}whereExists(e){return new Xe({...r(this,de),queryNode:ye.cloneWithWhere(r(this,de).queryNode,sn(e))})}whereNotExists(e){return new Xe({...r(this,de),queryNode:ye.cloneWithWhere(r(this,de).queryNode,Vt(e))})}orWhereExists(e){return new Xe({...r(this,de),queryNode:ye.cloneWithOrWhere(r(this,de).queryNode,sn(e))})}orWhereNotExists(e){return new Xe({...r(this,de),queryNode:ye.cloneWithOrWhere(r(this,de).queryNode,Vt(e))})}clearWhere(){return new Xe({...r(this,de),queryNode:ye.cloneWithoutWhere(r(this,de).queryNode)})}using(e){return new Xe({...r(this,de),queryNode:xa.cloneWithUsing(r(this,de).queryNode,Fo(e))})}innerJoin(...e){return new Xe({...r(this,de),queryNode:ye.cloneWithJoin(r(this,de).queryNode,vn("InnerJoin",e))})}leftJoin(...e){return new Xe({...r(this,de),queryNode:ye.cloneWithJoin(r(this,de).queryNode,vn("LeftJoin",e))})}rightJoin(...e){return new Xe({...r(this,de),queryNode:ye.cloneWithJoin(r(this,de).queryNode,vn("RightJoin",e))})}fullJoin(...e){return new Xe({...r(this,de),queryNode:ye.cloneWithJoin(r(this,de).queryNode,vn("FullJoin",e))})}returning(e){return new Xe({...r(this,de),queryNode:ye.cloneWithReturning(r(this,de).queryNode,gu(e))})}returningAll(e){return new Xe({...r(this,de),queryNode:ye.cloneWithReturning(r(this,de).queryNode,bu(e))})}orderBy(e,n){return new Xe({...r(this,de),queryNode:xa.cloneWithOrderByItem(r(this,de).queryNode,wl(e,n))})}limit(e){return new Xe({...r(this,de),queryNode:xa.cloneWithLimit(r(this,de).queryNode,Tp.create(e))})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,n){return e?n(this):new Xe({...r(this,de)})}if(e,n){return this.$if(e,n)}$castTo(){return new Xe(r(this,de))}castTo(){return this.$castTo()}$narrowType(){return new Xe(r(this,de))}$assertType(){return new Xe(r(this,de))}assertType(){return new Xe(r(this,de))}withPlugin(e){return new Xe({...r(this,de),executor:r(this,de).executor.withPlugin(e)})}toOperationNode(){return r(this,de).executor.transformQuery(r(this,de).queryNode,r(this,de).queryId)}compile(){return r(this,de).executor.compileQuery(this.toOperationNode(),r(this,de).queryId)}async execute(){const e=this.compile(),n=e.query,i=await r(this,de).executor.executeQuery(e,r(this,de).queryId);return r(this,de).executor.adapter.supportsReturning&&n.returning?i.rows:[new Ap(i.numAffectedRows??i.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=gl){const n=await this.executeTakeFirst();if(n===void 0)throw bl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),i=r(this,de).executor.stream(n,e,r(this,de).queryId);for await(const a of i)yield*a.rows}async explain(e,n){return await new Xe({...r(this,de),queryNode:ye.cloneWithExplain(r(this,de).queryNode,e,n)}).execute()}};let yc=Xe;de=new WeakMap;$e(yc,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");var za;class Sp{constructor(e){S(this,za,void 0);P(this,za,e)}get numUpdatedRows(){return r(this,za)}}za=new WeakMap;Object.defineProperty(Sp.prototype,"numUpdatedRows",{enumerable:!0});var pe;const nt=class{constructor(e){S(this,pe,void 0);P(this,pe,p(e))}where(...e){return new nt({...r(this,pe),queryNode:ye.cloneWithWhere(r(this,pe).queryNode,Rn(e))})}whereRef(e,n,i){return new nt({...r(this,pe),queryNode:ye.cloneWithWhere(r(this,pe).queryNode,zt(e,n,i))})}orWhere(...e){return new nt({...r(this,pe),queryNode:ye.cloneWithOrWhere(r(this,pe).queryNode,Rn(e))})}orWhereRef(e,n,i){return new nt({...r(this,pe),queryNode:ye.cloneWithOrWhere(r(this,pe).queryNode,zt(e,n,i))})}whereExists(e){return new nt({...r(this,pe),queryNode:ye.cloneWithWhere(r(this,pe).queryNode,sn(e))})}whereNotExists(e){return new nt({...r(this,pe),queryNode:ye.cloneWithWhere(r(this,pe).queryNode,Vt(e))})}orWhereExists(e){return new nt({...r(this,pe),queryNode:ye.cloneWithOrWhere(r(this,pe).queryNode,sn(e))})}orWhereNotExists(e){return new nt({...r(this,pe),queryNode:ye.cloneWithOrWhere(r(this,pe).queryNode,Vt(e))})}clearWhere(){return new nt({...r(this,pe),queryNode:ye.cloneWithoutWhere(r(this,pe).queryNode)})}from(e){return new nt({...r(this,pe),queryNode:dc.cloneWithFromItems(r(this,pe).queryNode,Fo(e))})}innerJoin(...e){return new nt({...r(this,pe),queryNode:ye.cloneWithJoin(r(this,pe).queryNode,vn("InnerJoin",e))})}leftJoin(...e){return new nt({...r(this,pe),queryNode:ye.cloneWithJoin(r(this,pe).queryNode,vn("LeftJoin",e))})}rightJoin(...e){return new nt({...r(this,pe),queryNode:ye.cloneWithJoin(r(this,pe).queryNode,vn("RightJoin",e))})}fullJoin(...e){return new nt({...r(this,pe),queryNode:ye.cloneWithJoin(r(this,pe).queryNode,vn("FullJoin",e))})}set(e){return new nt({...r(this,pe),queryNode:dc.cloneWithUpdates(r(this,pe).queryNode,Hf(e))})}returning(e){return new nt({...r(this,pe),queryNode:ye.cloneWithReturning(r(this,pe).queryNode,gu(e))})}returningAll(){return new nt({...r(this,pe),queryNode:ye.cloneWithReturning(r(this,pe).queryNode,bu())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,n){return e?n(this):new nt({...r(this,pe)})}if(e,n){return this.$if(e,n)}$castTo(){return new nt(r(this,pe))}castTo(){return this.$castTo()}$narrowType(){return new nt(r(this,pe))}$assertType(){return new nt(r(this,pe))}assertType(){return new nt(r(this,pe))}withPlugin(e){return new nt({...r(this,pe),executor:r(this,pe).executor.withPlugin(e)})}toOperationNode(){return r(this,pe).executor.transformQuery(r(this,pe).queryNode,r(this,pe).queryId)}compile(){return r(this,pe).executor.compileQuery(this.toOperationNode(),r(this,pe).queryId)}async execute(){const e=this.compile(),n=e.query,i=await r(this,pe).executor.executeQuery(e,r(this,pe).queryId);return r(this,pe).executor.adapter.supportsReturning&&n.returning?i.rows:[new Sp(i.numAffectedRows??i.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=gl){const n=await this.executeTakeFirst();if(n===void 0)throw bl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),i=r(this,pe).executor.stream(n,e,r(this,pe).queryId);for await(const a of i)yield*a.rows}async explain(e,n){return await new nt({...r(this,pe),queryNode:ye.cloneWithExplain(r(this,pe).queryNode,e,n)}).execute()}};let wc=nt;pe=new WeakMap;$e(wc,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");const Fg=p({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return p({kind:"CommonTableExpressionNode",name:t,expression:e})}}),Ph=p({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return p({kind:"CommonTableExpressionNameNode",table:Ni.create(t),columns:e?p(e.map(Nt.create)):void 0})}});function Mh(t,e){const n=e(Gg());return Fg.create(Ug(t),n.toOperationNode())}function Ug(t){if(t.includes("(")){const e=t.split(/[\(\)]/),n=e[0],i=e[1].split(",").map(a=>a.trim());return Ph.create(n,i)}else return Ph.create(t)}const Vu=p({is(t){return t.kind==="WithNode"},create(t,e){return p({kind:"WithNode",expressions:p([t]),...e})},cloneWithExpression(t,e){return p({...t,expressions:p([...t.expressions,e])})}}),Bh=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function $g(t){let e="";for(let n=0;nthis.transformNode(n)))}transformSelectQuery(e){return{kind:"SelectQueryNode",from:this.transformNode(e.from),selections:this.transformNodeList(e.selections),distinctOn:this.transformNodeList(e.distinctOn),joins:this.transformNodeList(e.joins),groupBy:this.transformNode(e.groupBy),orderBy:this.transformNode(e.orderBy),where:this.transformNode(e.where),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),limit:this.transformNode(e.limit),offset:this.transformNode(e.offset),with:this.transformNode(e.with),having:this.transformNode(e.having),explain:this.transformNode(e.explain),setOperations:this.transformNodeList(e.setOperations)}}transformSelection(e){return{kind:"SelectionNode",selection:this.transformNode(e.selection)}}transformColumn(e){return{kind:"ColumnNode",column:this.transformNode(e.column)}}transformAlias(e){return{kind:"AliasNode",node:this.transformNode(e.node),alias:this.transformNode(e.alias)}}transformTable(e){return{kind:"TableNode",table:this.transformNode(e.table)}}transformFrom(e){return{kind:"FromNode",froms:this.transformNodeList(e.froms)}}transformReference(e){return{kind:"ReferenceNode",table:this.transformNode(e.table),column:this.transformNode(e.column)}}transformAnd(e){return{kind:"AndNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformOr(e){return{kind:"OrNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformValueList(e){return{kind:"ValueListNode",values:this.transformNodeList(e.values)}}transformParens(e){return{kind:"ParensNode",node:this.transformNode(e.node)}}transformJoin(e){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table),on:this.transformNode(e.on)}}transformRaw(e){return{kind:"RawNode",sqlFragments:p([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters)}}transformWhere(e){return{kind:"WhereNode",where:this.transformNode(e.where)}}transformInsertQuery(e){return{kind:"InsertQueryNode",into:this.transformNode(e.into),columns:this.transformNodeList(e.columns),values:this.transformNode(e.values),returning:this.transformNode(e.returning),onConflict:this.transformNode(e.onConflict),onDuplicateKey:this.transformNode(e.onDuplicateKey),with:this.transformNode(e.with),ignore:e.ignore,replace:e.replace,explain:this.transformNode(e.explain)}}transformValues(e){return{kind:"ValuesNode",values:this.transformNodeList(e.values)}}transformDeleteQuery(e){return{kind:"DeleteQueryNode",from:this.transformNode(e.from),using:this.transformNode(e.using),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),returning:this.transformNode(e.returning),with:this.transformNode(e.with),orderBy:this.transformNode(e.orderBy),limit:this.transformNode(e.limit),explain:this.transformNode(e.explain)}}transformReturning(e){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections)}}transformCreateTable(e){return{kind:"CreateTableNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),constraints:this.transformNodeList(e.constraints),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers)}}transformColumnDefinition(e){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),references:this.transformNode(e.references),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo),check:this.transformNode(e.check),generated:this.transformNode(e.generated),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers)}}transformAddColumn(e){return{kind:"AddColumnNode",column:this.transformNode(e.column)}}transformDropTable(e){return{kind:"DropTableNode",table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e){return{kind:"OrderByNode",items:this.transformNodeList(e.items)}}transformOrderByItem(e){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy),direction:this.transformNode(e.direction)}}transformGroupBy(e){return{kind:"GroupByNode",items:this.transformNodeList(e.items)}}transformGroupByItem(e){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy)}}transformUpdateQuery(e){return{kind:"UpdateQueryNode",table:this.transformNode(e.table),from:this.transformNode(e.from),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),updates:this.transformNodeList(e.updates),returning:this.transformNode(e.returning),with:this.transformNode(e.with),explain:this.transformNode(e.explain)}}transformColumnUpdate(e){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column),value:this.transformNode(e.value)}}transformLimit(e){return{kind:"LimitNode",limit:this.transformNode(e.limit)}}transformOffset(e){return{kind:"OffsetNode",offset:this.transformNode(e.offset)}}transformOnConflict(e){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns),constraint:this.transformNode(e.constraint),indexExpression:this.transformNode(e.indexExpression),indexWhere:this.transformNode(e.indexWhere),updates:this.transformNodeList(e.updates),updateWhere:this.transformNode(e.updateWhere),doNothing:e.doNothing}}transformOnDuplicateKey(e){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates)}}transformCreateIndex(e){return{kind:"CreateIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists,where:this.transformNode(e.where)}}transformList(e){return{kind:"ListNode",items:this.transformNodeList(e.items)}}transformDropIndex(e){return{kind:"DropIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformUniqueConstraint(e){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformForeignKeyConstraint(e){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns),references:this.transformNode(e.references),name:this.transformNode(e.name),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformSetOperation(e){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression),all:e.all}}transformReferences(e){return{kind:"ReferencesNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression),name:this.transformNode(e.name)}}transformWith(e){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions),recursive:e.recursive}}transformCommonTableExpression(e){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name),expression:this.transformNode(e.expression)}}transformCommonTableExpressionName(e){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns)}}transformHaving(e){return{kind:"HavingNode",having:this.transformNode(e.having)}}transformCreateSchema(e){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema),ifNotExists:e.ifNotExists}}transformDropSchema(e){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e){return{kind:"AlterTableNode",table:this.transformNode(e.table),renameTo:this.transformNode(e.renameTo),setSchema:this.transformNode(e.setSchema),columnAlterations:this.transformNodeList(e.columnAlterations),addConstraint:this.transformNode(e.addConstraint),dropConstraint:this.transformNode(e.dropConstraint)}}transformDropColumn(e){return{kind:"DropColumnNode",column:this.transformNode(e.column)}}transformRenameColumn(e){return{kind:"RenameColumnNode",column:this.transformNode(e.column),renameTo:this.transformNode(e.renameTo)}}transformAlterColumn(e){return{kind:"AlterColumnNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),dataTypeExpression:this.transformNode(e.dataTypeExpression),setDefault:this.transformNode(e.setDefault),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e){return{kind:"ModifyColumnNode",column:this.transformNode(e.column)}}transformAddConstraint(e){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint)}}transformDropConstraint(e){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName),ifExists:e.ifExists,modifier:e.modifier}}transformCreateView(e){return{kind:"CreateViewNode",name:this.transformNode(e.name),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns),as:this.transformNode(e.as)}}transformDropView(e){return{kind:"DropViewNode",name:this.transformNode(e.name),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression)}}transformDefaultValue(e){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue)}}transformOn(e){return{kind:"OnNode",on:this.transformNode(e.on)}}transformSelectModifier(e){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier)}}transformCreateType(e){return{kind:"CreateTypeNode",name:this.transformNode(e.name),enum:this.transformNode(e.enum)}}transformDropType(e){return{kind:"DropTypeNode",name:this.transformNode(e.name),ifExists:e.ifExists}}transformExplain(e){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options)}}transformSchemableIdentifier(e){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema),identifier:this.transformNode(e.identifier)}}transformAggregateFunction(e){return{kind:"AggregateFunctionNode",aggregated:this.transformNodeList(e.aggregated),distinct:e.distinct,filter:this.transformNode(e.filter),func:e.func,over:this.transformNode(e.over)}}transformOver(e){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy),partitionBy:this.transformNode(e.partitionBy)}}transformPartitionBy(e){return{kind:"PartitionByNode",items:this.transformNodeList(e.items)}}transformPartitionByItem(e){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy)}}transformBinaryOperation(e){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand),operator:this.transformNode(e.operator),rightOperand:this.transformNode(e.rightOperand)}}transformUnaryOperation(e){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator),operand:this.transformNode(e.operand)}}transformUsing(e){return{kind:"UsingNode",tables:this.transformNodeList(e.tables)}}transformFunction(e){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments)}}transformCase(e){return{kind:"CaseNode",value:this.transformNode(e.value),when:this.transformNodeList(e.when),else:this.transformNode(e.else),isStatement:e.isStatement}}transformWhen(e){return{kind:"WhenNode",condition:this.transformNode(e.condition),result:this.transformNode(e.result)}}transformDataType(e){return e}transformSelectAll(e){return e}transformIdentifier(e){return e}transformValue(e){return e}transformPrimitiveValueList(e){return e}transformOperator(e){return e}transformDefaultInsertValue(e){return e}}Dc=new WeakMap;const Hg=p({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0});var oo,is,Lc,kp,Pc,Rp,ss,wa,Ka,af,Mc,Dp;class Vg extends Vf{constructor(n){super();S(this,Lc);S(this,Pc);S(this,ss);S(this,Ka);S(this,Mc);S(this,oo,void 0);S(this,is,new Set);P(this,oo,n)}transformNodeImpl(n){if(!qe(this,Lc,kp).call(this,n))return super.transformNodeImpl(n);const i=qe(this,Pc,Rp).call(this,n);for(const l of i)r(this,is).add(l);const a=super.transformNodeImpl(n);for(const l of i)r(this,is).delete(l);return a}transformSchemableIdentifier(n){const i=super.transformSchemableIdentifier(n);return i.schema||!r(this,is).has(n.identifier.name)?i:{...i,schema:mt.create(r(this,oo))}}transformReferences(n){const i=super.transformReferences(n);return i.table.table.schema?i:{...i,table:Ni.createWithSchema(r(this,oo),i.table.table.identifier.name)}}}oo=new WeakMap,is=new WeakMap,Lc=new WeakSet,kp=function(n){return n.kind in Hg},Pc=new WeakSet,Rp=function(n){const i=new Set;if("name"in n&&n.name&&xi.is(n.name)&&qe(this,Ka,af).call(this,n.name,i),"from"in n&&n.from)for(const a of n.from.froms)qe(this,ss,wa).call(this,a,i);if("into"in n&&n.into&&qe(this,ss,wa).call(this,n.into,i),"table"in n&&n.table&&qe(this,ss,wa).call(this,n.table,i),"joins"in n&&n.joins)for(const a of n.joins)qe(this,ss,wa).call(this,a.table,i);return"with"in n&&n.with&&qe(this,Mc,Dp).call(this,n.with,i),i},ss=new WeakSet,wa=function(n,i){const a=Ni.is(n)?n:Es.is(n)&&Ni.is(n.node)?n.node:null;a&&qe(this,Ka,af).call(this,a.table,i)},Ka=new WeakSet,af=function(n,i){r(this,is).has(n.identifier.name)||i.add(n.identifier.name)},Mc=new WeakSet,Dp=function(n,i){for(const a of n.expressions)i.delete(a.name.table.table.identifier.name)};var Ja;class Nu{constructor(e){S(this,Ja,void 0);P(this,Ja,new Vg(e))}transformQuery(e){return r(this,Ja).transformNode(e.node)}async transformResult(e){return e.result}}Ja=new WeakMap;var rt;const es=class{constructor(e){S(this,rt,void 0);P(this,rt,p(e))}selectFrom(e){return new Bo({queryId:et(),executor:r(this,rt).executor,queryNode:We.create(Fo(e),r(this,rt).withNode)})}insertInto(e){return new Ma({queryId:et(),executor:r(this,rt).executor,queryNode:Or.create(_n(e),r(this,rt).withNode)})}replaceInto(e){return new Ma({queryId:et(),executor:r(this,rt).executor,queryNode:Or.create(_n(e),r(this,rt).withNode,!0)})}deleteFrom(e){return new yc({queryId:et(),executor:r(this,rt).executor,queryNode:xa.create(Fo(e),r(this,rt).withNode)})}updateTable(e){return new wc({queryId:et(),executor:r(this,rt).executor,queryNode:dc.create(Fa(e),r(this,rt).withNode)})}with(e,n){const i=Mh(e,n);return new es({...r(this,rt),withNode:r(this,rt).withNode?Vu.cloneWithExpression(r(this,rt).withNode,i):Vu.create(i)})}withRecursive(e,n){const i=Mh(e,n);return new es({...r(this,rt),withNode:r(this,rt).withNode?Vu.cloneWithExpression(r(this,rt).withNode,i):Vu.create(i,{recursive:!0})})}withPlugin(e){return new es({...r(this,rt),executor:r(this,rt).executor.withPlugin(e)})}withoutPlugins(){return new es({...r(this,rt),executor:r(this,rt).executor.withoutPlugins()})}withSchema(e){return new es({...r(this,rt),executor:r(this,rt).executor.withPluginAtFront(new Nu(e))})}};let gc=es;rt=new WeakMap;var Ga,ao,uo;class Fh{constructor(){S(this,Ga,void 0);S(this,ao,void 0);S(this,uo,void 0);Yt(this,"resolve",e=>{r(this,ao)&&r(this,ao).call(this,e)});Yt(this,"reject",e=>{r(this,uo)&&r(this,uo).call(this,e)});P(this,Ga,new Promise((e,n)=>{P(this,uo,n),P(this,ao,e)}))}get promise(){return r(this,Ga)}}Ga=new WeakMap,ao=new WeakMap,uo=new WeakMap;const Uh=new Set;function zg(t){Uh.has(t)||(Uh.add(t),console.log(t))}const Kg=p([]);var os,Xa,uf;class Lp{constructor(e=Kg){S(this,Xa);S(this,os,void 0);P(this,os,e)}get plugins(){return r(this,os)}transformQuery(e,n){for(const i of r(this,os)){const a=i.transformQuery({node:e,queryId:n});if(a.kind===e.kind)e=a;else throw new Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${e.kind}`,`but it returned a ${a.kind}`].join(" "))}return e}async executeQuery(e,n){return await this.provideConnection(async i=>{const a=await i.executeQuery(e),l=await qe(this,Xa,uf).call(this,a,n);return Jg(a,l),l})}async*stream(e,n,i){const a=new Fh,l=new Fh;this.provideConnection(async w=>(a.resolve(w),await l.promise)).catch(w=>a.reject(w));const m=await a.promise;try{for await(const w of m.streamQuery(e,n))yield await qe(this,Xa,uf).call(this,w,i)}finally{l.resolve()}}}os=new WeakMap,Xa=new WeakSet,uf=async function(e,n){for(const i of r(this,os))e=await i.transformResult({result:e,queryId:n});return e};function Jg(t,e){const{numAffectedRows:n}=t;n===void 0&&t.numUpdatedOrDeletedRows===void 0||n!==void 0&&e.numAffectedRows!==void 0||zg("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class Js extends Lp{get adapter(){throw new Error("this query cannot be compiled to SQL")}compileQuery(){throw new Error("this query cannot be compiled to SQL")}provideConnection(){throw new Error("this query cannot be executed")}withConnectionProvider(){throw new Error("this query cannot have a connection provider")}withPlugin(e){return new Js([...this.plugins,e])}withPlugins(e){return new Js([...this.plugins,...e])}withPluginAtFront(e){return new Js([e,...this.plugins])}withoutPlugins(){return new Js([])}}const Nl=new Js;function $h(){return new Bo({queryId:et(),executor:Nl,queryNode:We.create(Fo([]))})}function Gg(){return new gc({executor:Nl})}function Pp(t,e){return new fc({joinNode:jn.create(t,Fa(e))})}function Xg(){return new hc({overNode:of.create()})}const zf=p({is(t){return t.kind==="WhenNode"},create(t){return p({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return p({...t,result:e})}}),dr=p({is(t){return t.kind==="CaseNode"},create(t){return p({kind:"CaseNode",value:t})},cloneWithWhen(t,e){return p({...t,when:p(t.when?[...t.when,e]:[e])})},cloneWithThen(t,e){return p({...t,when:t.when?p([...t.when.slice(0,-1),zf.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return p({...t,...e})}});function cf(t,e,n){if(!vp(e)&&!hn(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return eb(e,n)?tb(t,e,n):ml.create(Hr(t),Kf(e),Op(n))}function Yg(t,e,n){if(!vp(e)&&!hn(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return ml.create(Hr(t),Kf(e),Hr(n))}function Zg(t,e,n){if(!_p(e)&&!hn(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return cf(t,e,n)}function zt(t,e,n){if(!_p(e)&&!hn(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return Yg(t,e,n)}function Rn(t){return vl("where",t)}function Qh(t){return vl("having",t)}function jh(t){return vl("on",t)}function Mp(t){return vl("when",t)}function vl(t,e){if(e.length===3)return Zg(e[0],e[1],e[2]);if(e.length===1)return nb(t,e[0]);throw Bp(t,e)}function eb(t,e){return(t==="is"||t==="is not")&&(wp(e)||yp(e))}function tb(t,e,n){return ml.create(Hr(t),Kf(e),Ir.createImmediate(n))}function Kf(t){if(mr(t)&&gg.includes(t))return Ff.create(t);if(hn(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function nb(t,e){if(Vn(e)){if(t==="when")throw new Error("when method doesn't accept a callback as an argument");return rb[t](e)}else if(hn(e)){const n=e.toOperationNode();if(en.is(n)||ml.is(n)||qp.is(n)||ro.is(n)||dr.is(n))return n}else if(t==="when")return Ir.create(e);throw Bp(t,e)}function Bp(t,e){return new Error(`invalid arguments passed to a '${t}' method: ${JSON.stringify(e)}`)}const rb=p({where(t){const e=$h(),n=$r(),a=t(Object.assign(e,n)).toOperationNode();if(We.is(a)){if(!a.where)throw new Error("no `where` methods called inside a group callback");return ro.create(a.where.where)}else return a},having(t){const e=$h(),n=$r(),a=t(Object.assign(e,n)).toOperationNode();if(We.is(a)){if(!a.having)throw new Error("no `having` methods called inside a group callback");return ro.create(a.having.having)}else return a},on(t){const e=Pp("InnerJoin","table"),n=$r(),a=t(Object.assign(e,n)).toOperationNode();if(jn.is(a)){if(!a.on)throw new Error("no `on` methods called inside a group callback");return ro.create(a.on.on)}else return a}});function vn(t,e){if(e.length===3)return sb(t,e[0],e[1],e[2]);if(e.length===2)return ib(t,e[0],e[1]);throw new Error("not implemented")}function ib(t,e,n){return n(Pp(t,e)).toOperationNode()}function sb(t,e,n,i){return jn.createWithOn(t,Fa(e),zt(n,"=",i))}const ob=p({is(t){return t.kind==="OffsetNode"},create(t){return p({kind:"OffsetNode",offset:Ir.create(t)})}}),ab=p({is(t){return t.kind==="GroupByItemNode"},create(t){return p({kind:"GroupByItemNode",groupBy:t})}});function ub(t){return t=Vn(t)?t($r()):t,Pa(t).map(ab.create)}const Fp=p({is(t){return t.kind==="SetOperationNode"},create(t,e,n){return p({kind:"SetOperationNode",operator:t,expression:e,all:n})}});function js(t,e,n){return Fp.create(t,e.toOperationNode(),n)}var $;const he=class{constructor(e){S(this,$,void 0);P(this,$,p(e))}get expressionType(){}where(...e){return new he({...r(this,$),queryNode:ye.cloneWithWhere(r(this,$).queryNode,Rn(e))})}whereRef(e,n,i){return new he({...r(this,$),queryNode:ye.cloneWithWhere(r(this,$).queryNode,zt(e,n,i))})}orWhere(...e){return new he({...r(this,$),queryNode:ye.cloneWithOrWhere(r(this,$).queryNode,Rn(e))})}orWhereRef(e,n,i){return new he({...r(this,$),queryNode:ye.cloneWithOrWhere(r(this,$).queryNode,zt(e,n,i))})}whereExists(e){return new he({...r(this,$),queryNode:ye.cloneWithWhere(r(this,$).queryNode,sn(e))})}whereNotExists(e){return new he({...r(this,$),queryNode:ye.cloneWithWhere(r(this,$).queryNode,Vt(e))})}orWhereExists(e){return new he({...r(this,$),queryNode:ye.cloneWithOrWhere(r(this,$).queryNode,sn(e))})}orWhereNotExists(e){return new he({...r(this,$),queryNode:ye.cloneWithOrWhere(r(this,$).queryNode,Vt(e))})}having(...e){return new he({...r(this,$),queryNode:We.cloneWithHaving(r(this,$).queryNode,Qh(e))})}havingRef(e,n,i){return new he({...r(this,$),queryNode:We.cloneWithHaving(r(this,$).queryNode,zt(e,n,i))})}orHaving(...e){return new he({...r(this,$),queryNode:We.cloneWithOrHaving(r(this,$).queryNode,Qh(e))})}orHavingRef(e,n,i){return new he({...r(this,$),queryNode:We.cloneWithOrHaving(r(this,$).queryNode,zt(e,n,i))})}havingExists(e){return new he({...r(this,$),queryNode:We.cloneWithHaving(r(this,$).queryNode,sn(e))})}havingNotExist(e){return new he({...r(this,$),queryNode:We.cloneWithHaving(r(this,$).queryNode,Vt(e))})}havingNotExists(e){return new he({...r(this,$),queryNode:We.cloneWithHaving(r(this,$).queryNode,Vt(e))})}orHavingExists(e){return new he({...r(this,$),queryNode:We.cloneWithOrHaving(r(this,$).queryNode,sn(e))})}orHavingNotExists(e){return new he({...r(this,$),queryNode:We.cloneWithOrHaving(r(this,$).queryNode,Vt(e))})}select(e){return new he({...r(this,$),queryNode:We.cloneWithSelections(r(this,$).queryNode,gu(e))})}distinctOn(e){return new he({...r(this,$),queryNode:We.cloneWithDistinctOn(r(this,$).queryNode,Pa(e))})}modifyFront(e){return new he({...r(this,$),queryNode:We.cloneWithFrontModifier(r(this,$).queryNode,Sr.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new he({...r(this,$),queryNode:We.cloneWithEndModifier(r(this,$).queryNode,Sr.createWithExpression(e.toOperationNode()))})}distinct(){return new he({...r(this,$),queryNode:We.cloneWithFrontModifier(r(this,$).queryNode,Sr.create("Distinct"))})}forUpdate(){return new he({...r(this,$),queryNode:We.cloneWithEndModifier(r(this,$).queryNode,Sr.create("ForUpdate"))})}forShare(){return new he({...r(this,$),queryNode:We.cloneWithEndModifier(r(this,$).queryNode,Sr.create("ForShare"))})}forKeyShare(){return new he({...r(this,$),queryNode:We.cloneWithEndModifier(r(this,$).queryNode,Sr.create("ForKeyShare"))})}forNoKeyUpdate(){return new he({...r(this,$),queryNode:We.cloneWithEndModifier(r(this,$).queryNode,Sr.create("ForNoKeyUpdate"))})}skipLocked(){return new he({...r(this,$),queryNode:We.cloneWithEndModifier(r(this,$).queryNode,Sr.create("SkipLocked"))})}noWait(){return new he({...r(this,$),queryNode:We.cloneWithEndModifier(r(this,$).queryNode,Sr.create("NoWait"))})}selectAll(e){return new he({...r(this,$),queryNode:We.cloneWithSelections(r(this,$).queryNode,bu(e))})}innerJoin(...e){return new he({...r(this,$),queryNode:ye.cloneWithJoin(r(this,$).queryNode,vn("InnerJoin",e))})}leftJoin(...e){return new he({...r(this,$),queryNode:ye.cloneWithJoin(r(this,$).queryNode,vn("LeftJoin",e))})}rightJoin(...e){return new he({...r(this,$),queryNode:ye.cloneWithJoin(r(this,$).queryNode,vn("RightJoin",e))})}fullJoin(...e){return new he({...r(this,$),queryNode:ye.cloneWithJoin(r(this,$).queryNode,vn("FullJoin",e))})}innerJoinLateral(...e){return new he({...r(this,$),queryNode:ye.cloneWithJoin(r(this,$).queryNode,vn("LateralInnerJoin",e))})}leftJoinLateral(...e){return new he({...r(this,$),queryNode:ye.cloneWithJoin(r(this,$).queryNode,vn("LateralLeftJoin",e))})}orderBy(e,n){return new he({...r(this,$),queryNode:We.cloneWithOrderByItem(r(this,$).queryNode,wl(e,n))})}groupBy(e){return new he({...r(this,$),queryNode:We.cloneWithGroupByItems(r(this,$).queryNode,ub(e))})}limit(e){return new he({...r(this,$),queryNode:We.cloneWithLimit(r(this,$).queryNode,Tp.create(e))})}offset(e){return new he({...r(this,$),queryNode:We.cloneWithOffset(r(this,$).queryNode,ob.create(e))})}union(e){return new he({...r(this,$),queryNode:We.cloneWithSetOperation(r(this,$).queryNode,js("union",e,!1))})}unionAll(e){return new he({...r(this,$),queryNode:We.cloneWithSetOperation(r(this,$).queryNode,js("union",e,!0))})}intersect(e){return new he({...r(this,$),queryNode:We.cloneWithSetOperation(r(this,$).queryNode,js("intersect",e,!1))})}intersectAll(e){return new he({...r(this,$),queryNode:We.cloneWithSetOperation(r(this,$).queryNode,js("intersect",e,!0))})}except(e){return new he({...r(this,$),queryNode:We.cloneWithSetOperation(r(this,$).queryNode,js("except",e,!1))})}exceptAll(e){return new he({...r(this,$),queryNode:We.cloneWithSetOperation(r(this,$).queryNode,js("except",e,!0))})}as(e){return new cb(this,e)}clearSelect(){return new he({...r(this,$),queryNode:We.cloneWithoutSelections(r(this,$).queryNode)})}clearWhere(){return new he({...r(this,$),queryNode:ye.cloneWithoutWhere(r(this,$).queryNode)})}clearLimit(){return new he({...r(this,$),queryNode:We.cloneWithoutLimit(r(this,$).queryNode)})}clearOffset(){return new he({...r(this,$),queryNode:We.cloneWithoutOffset(r(this,$).queryNode)})}clearOrderBy(){return new he({...r(this,$),queryNode:We.cloneWithoutOrderBy(r(this,$).queryNode)})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,n){return e?n(this):new he({...r(this,$)})}if(e,n){return this.$if(e,n)}$castTo(){return new he(r(this,$))}castTo(){return this.$castTo()}$narrowType(){return new he(r(this,$))}$assertType(){return new he(r(this,$))}assertType(){return new he(r(this,$))}withPlugin(e){return new he({...r(this,$),executor:r(this,$).executor.withPlugin(e)})}toOperationNode(){return r(this,$).executor.transformQuery(r(this,$).queryNode,r(this,$).queryId)}compile(){return r(this,$).executor.compileQuery(this.toOperationNode(),r(this,$).queryId)}async execute(){const e=this.compile();return(await r(this,$).executor.executeQuery(e,r(this,$).queryId)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=gl){const n=await this.executeTakeFirst();if(n===void 0)throw bl(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),i=r(this,$).executor.stream(n,e,r(this,$).queryId);for await(const a of i)yield*a.rows}async explain(e,n){return await new he({...r(this,$),queryNode:ye.cloneWithExplain(r(this,$).queryNode,e,n)}).execute()}};let Bo=he;$=new WeakMap;$e(Bo,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");var co,lo;class cb{constructor(e,n){S(this,co,void 0);S(this,lo,void 0);P(this,co,e),P(this,lo,n)}get expression(){return r(this,co)}get alias(){return r(this,lo)}toOperationNode(){return Es.create(r(this,co).toOperationNode(),mt.create(r(this,lo)))}}co=new WeakMap,lo=new WeakMap;var fo;const Yf=class{constructor(e){S(this,fo,void 0);P(this,fo,e)}get expressionType(){}as(e){return new lb(this,e)}$castTo(){return new Yf(r(this,fo))}toOperationNode(){return r(this,fo)}};let Dt=Yf;fo=new WeakMap;var ho,ci;class lb{constructor(e,n){S(this,ho,void 0);S(this,ci,void 0);P(this,ho,e),P(this,ci,n)}get expression(){return r(this,ho)}get alias(){return r(this,ci)}toOperationNode(){return Es.create(r(this,ho).toOperationNode(),hn(r(this,ci))?r(this,ci).toOperationNode():mt.create(r(this,ci)))}}ho=new WeakMap,ci=new WeakMap;const Un=p({is(t){return t.kind==="AggregateFunctionNode"},create(t,e=[]){return p({kind:"AggregateFunctionNode",func:t,aggregated:e})},cloneWithDistinct(t){return p({...t,distinct:!0})},cloneWithFilter(t,e){return p({...t,filter:t.filter?tn.cloneWithOperation(t.filter,"And",e):tn.create(e)})},cloneWithOrFilter(t,e){return p({...t,filter:t.filter?tn.cloneWithOperation(t.filter,"Or",e):tn.create(e)})},cloneWithOver(t,e){return p({...t,over:e})}}),fb=p({is(t){return t.kind==="FunctionNode"},create(t,e){return p({kind:"FunctionNode",func:t,arguments:e})}});var st;const $n=class{constructor(e){S(this,st,void 0);P(this,st,p(e))}get expressionType(){}as(e){return new hb(this,e)}distinct(){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithDistinct(r(this,st).aggregateFunctionNode)})}filterWhere(...e){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithFilter(r(this,st).aggregateFunctionNode,Rn(e))})}filterWhereExists(e){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithFilter(r(this,st).aggregateFunctionNode,sn(e))})}filterWhereNotExists(e){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithFilter(r(this,st).aggregateFunctionNode,Vt(e))})}filterWhereRef(e,n,i){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithFilter(r(this,st).aggregateFunctionNode,zt(e,n,i))})}orFilterWhere(...e){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithOrFilter(r(this,st).aggregateFunctionNode,Rn(e))})}orFilterWhereExists(e){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithOrFilter(r(this,st).aggregateFunctionNode,sn(e))})}orFilterWhereNotExists(e){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithOrFilter(r(this,st).aggregateFunctionNode,Vt(e))})}orFilterWhereRef(e,n,i){return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithOrFilter(r(this,st).aggregateFunctionNode,zt(e,n,i))})}over(e){const n=Xg();return new $n({...r(this,st),aggregateFunctionNode:Un.cloneWithOver(r(this,st).aggregateFunctionNode,(e?e(n):n).toOperationNode())})}$call(e){return e(this)}toOperationNode(){return r(this,st).aggregateFunctionNode}};let Ba=$n;st=new WeakMap;$e(Ba,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");var po,mo;class hb{constructor(e,n){S(this,po,void 0);S(this,mo,void 0);P(this,po,e),P(this,mo,n)}get expression(){return r(this,po)}get alias(){return r(this,mo)}toOperationNode(){return Es.create(r(this,po).toOperationNode(),mt.create(r(this,mo)))}}po=new WeakMap,mo=new WeakMap;function Up(){const t=(n,i)=>new Dt(fb.create(n,Pa(i))),e=(n,i)=>new Ba({aggregateFunctionNode:Un.create(n,i?Pa(i):void 0)});return Object.assign(t,{agg:e,avg(n){return e("avg",[n])},coalesce(n,...i){return t("coalesce",[n,...i])},count(n){return e("count",[n])},countAll(n){return new Ba({aggregateFunctionNode:Un.create("count",bu(n))})},max(n){return e("max",[n])},min(n){return e("min",[n])},sum(n){return e("sum",[n])}})}var yo;class $p{constructor(e){S(this,yo,void 0);P(this,yo,p(e))}when(...e){return new Qp({...r(this,yo),node:dr.cloneWithWhen(r(this,yo).node,zf.create(Mp(e)))})}}yo=new WeakMap;var wo;class Qp{constructor(e){S(this,wo,void 0);P(this,wo,p(e))}then(e){return new db({...r(this,wo),node:dr.cloneWithThen(r(this,wo).node,Ur(e))})}}wo=new WeakMap;var _r;class db{constructor(e){S(this,_r,void 0);P(this,_r,p(e))}when(...e){return new Qp({...r(this,_r),node:dr.cloneWithWhen(r(this,_r).node,zf.create(Mp(e)))})}else(e){return new pb({...r(this,_r),node:dr.cloneWith(r(this,_r).node,{else:Ur(e)})})}end(){return new Dt(dr.cloneWith(r(this,_r).node,{isStatement:!1}))}endCase(){return new Dt(dr.cloneWith(r(this,_r).node,{isStatement:!0}))}}_r=new WeakMap;var go;class pb{constructor(e){S(this,go,void 0);P(this,go,p(e))}end(){return new Dt(dr.cloneWith(r(this,go).node,{isStatement:!1}))}endCase(){return new Dt(dr.cloneWith(r(this,go).node,{isStatement:!0}))}}go=new WeakMap;function jp(t=Nl){function e(n,i){return new Dt(jf(n,i))}return{get fn(){return Up()},selectFrom(n){return new Bo({queryId:et(),executor:t,queryNode:We.create(Fo(n))})},case(n){return new $p({node:dr.create(va(n)?void 0:Hr(n))})},ref(n){return new Dt(Po(n))},val(n){return new Dt(Op(n))},cmpr(n,i,a){return new Dt(cf(n,i,a))},bxp(n,i,a){return new Dt(cf(n,i,a))},unary:e,not(n){return e("not",n)},exists(n){return e("exists",n)},neg(n){return e("-",n)},and(n){if(n.length===0)return new Dt(Ir.createImmediate(!0));if(n.length===1)return new Dt(n[0].toOperationNode());let i=Da.create(n[0].toOperationNode(),n[1].toOperationNode());for(let a=2;aFa(e)):[Fa(t)]}function Fa(t){return mr(t)?mb(t):Hp(t)}function mb(t){const e=" as ";if(t.includes(e)){const[n,i]=t.split(e).map(Vp);return Es.create(_n(n),mt.create(i))}else return _n(t)}function _n(t){const e=".";if(t.includes(e)){const[n,i]=t.split(e).map(Vp);return Ni.createWithSchema(n,i)}else return Ni.create(t)}function Vp(t){return t.trim()}const zp=p({is(t){return t.kind==="AddColumnNode"},create(t){return p({kind:"AddColumnNode",column:t})}}),Xi=p({is(t){return t.kind==="AlterColumnNode"},create(t){return p({kind:"AlterColumnNode",column:Nt.create(t)})},cloneWith(t,e){return p({...t,...e})}}),bt=p({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return p({kind:"ColumnDefinitionNode",column:Nt.create(t),dataType:e})},cloneWithFrontModifier(t,e){return p({...t,frontModifiers:t.frontModifiers?p([...t.frontModifiers,e]):[e]})},cloneWithEndModifier(t,e){return p({...t,endModifiers:t.endModifiers?p([...t.endModifiers,e]):[e]})},cloneWith(t,e){return p({...t,...e})}}),Kp=p({is(t){return t.kind==="DropColumnNode"},create(t){return p({kind:"DropColumnNode",column:Nt.create(t)})}}),Jp=p({is(t){return t.kind==="RenameColumnNode"},create(t,e){return p({kind:"RenameColumnNode",column:Nt.create(t),renameTo:Nt.create(e)})}}),Jf=p({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return p({kind:"CheckConstraintNode",expression:t,name:e?mt.create(e):void 0})}}),yb=["no action","restrict","cascade","set null","set default"],ec=p({is(t){return t.kind==="ReferencesNode"},create(t,e){return p({kind:"ReferencesNode",table:t,columns:p([...e])})},cloneWithOnDelete(t,e){return p({...t,onDelete:e})},cloneWithOnUpdate(t,e){return p({...t,onUpdate:e})}});function Gp(t){return hn(t)?t.toOperationNode():Ir.createImmediate(t)}const zu=p({is(t){return t.kind==="GeneratedNode"},create(t){return p({kind:"GeneratedNode",...t})},createWithExpression(t){return p({kind:"GeneratedNode",always:!0,expression:t})},cloneWith(t,e){return p({...t,...e})}}),wb=p({is(t){return t.kind==="DefaultValueNode"},create(t){return p({kind:"DefaultValueNode",defaultValue:t})}});function bc(t){if(yb.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}var Ye;const St=class{constructor(e){S(this,Ye,void 0);P(this,Ye,e)}autoIncrement(){return new St(bt.cloneWith(r(this,Ye),{autoIncrement:!0}))}primaryKey(){return new St(bt.cloneWith(r(this,Ye),{primaryKey:!0}))}references(e){const n=Po(e);if(!yl.is(n)||Uf.is(n.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new St(bt.cloneWith(r(this,Ye),{references:ec.create(n.table,[n.column])}))}onDelete(e){if(!r(this,Ye).references)throw new Error("on delete constraint can only be added for foreign keys");return new St(bt.cloneWith(r(this,Ye),{references:ec.cloneWithOnDelete(r(this,Ye).references,bc(e))}))}onUpdate(e){if(!r(this,Ye).references)throw new Error("on update constraint can only be added for foreign keys");return new St(bt.cloneWith(r(this,Ye),{references:ec.cloneWithOnUpdate(r(this,Ye).references,bc(e))}))}unique(){return new St(bt.cloneWith(r(this,Ye),{unique:!0}))}notNull(){return new St(bt.cloneWith(r(this,Ye),{notNull:!0}))}unsigned(){return new St(bt.cloneWith(r(this,Ye),{unsigned:!0}))}defaultTo(e){return new St(bt.cloneWith(r(this,Ye),{defaultTo:wb.create(Gp(e))}))}check(e){return new St(bt.cloneWith(r(this,Ye),{check:Jf.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new St(bt.cloneWith(r(this,Ye),{generated:zu.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new St(bt.cloneWith(r(this,Ye),{generated:zu.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new St(bt.cloneWith(r(this,Ye),{generated:zu.create({identity:!0,byDefault:!0})}))}stored(){if(!r(this,Ye).generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new St(bt.cloneWith(r(this,Ye),{generated:zu.cloneWith(r(this,Ye).generated,{stored:!0})}))}modifyFront(e){return new St(bt.cloneWithFrontModifier(r(this,Ye),e.toOperationNode()))}modifyEnd(e){return new St(bt.cloneWithEndModifier(r(this,Ye),e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return r(this,Ye)}};let Ei=St;Ye=new WeakMap;$e(Ei,"don't await ColumnDefinitionBuilder instances directly.");const Xp=p({is(t){return t.kind==="ModifyColumnNode"},create(t){return p({kind:"ModifyColumnNode",column:t})}}),gb=p({is(t){return t.kind==="DataTypeNode"},create(t){return p({kind:"DataTypeNode",dataType:t})}});function Uo(t){return hn(t)?t.toOperationNode():gb.create(t)}const Nc=p({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,n,i){return p({kind:"ForeignKeyConstraintNode",columns:t,references:ec.create(e,n),name:i?mt.create(i):void 0})},cloneWith(t,e){return p({...t,...e})}});var as;const Bc=class{constructor(e){S(this,as,void 0);P(this,as,e)}onDelete(e){return new Bc(Nc.cloneWith(r(this,as),{onDelete:bc(e)}))}onUpdate(e){return new Bc(Nc.cloneWith(r(this,as),{onUpdate:bc(e)}))}$call(e){return e(this)}toOperationNode(){return r(this,as)}};let Ua=Bc;as=new WeakMap;$e(Ua,"don't await ForeignKeyConstraintBuilder instances directly.");const lf=p({is(t){return t.kind==="AddConstraintNode"},create(t){return p({kind:"AddConstraintNode",constraint:t})}}),Yp=p({is(t){return t.kind==="UniqueConstraintNode"},create(t,e){return p({kind:"UniqueConstraintNode",columns:p(t.map(Nt.create)),name:e?mt.create(e):void 0})}}),tc=p({is(t){return t.kind==="DropConstraintNode"},create(t){return p({kind:"DropConstraintNode",constraintName:mt.create(t)})},cloneWith(t,e){return p({...t,...e})}});class El{constructor(e){Yt(this,"alterColumnNode");this.alterColumnNode=e}setDataType(e){return new ma(Xi.cloneWith(this.alterColumnNode,{dataType:Uo(e)}))}setDefault(e){return new ma(Xi.cloneWith(this.alterColumnNode,{setDefault:Gp(e)}))}dropDefault(){return new ma(Xi.cloneWith(this.alterColumnNode,{dropDefault:!0}))}setNotNull(){return new ma(Xi.cloneWith(this.alterColumnNode,{setNotNull:!0}))}dropNotNull(){return new ma(Xi.cloneWith(this.alterColumnNode,{dropNotNull:!0}))}$call(e){return e(this)}}class ma extends El{toOperationNode(){return this.alterColumnNode}}var ir;class ga{constructor(e){S(this,ir,void 0);P(this,ir,p(e))}toOperationNode(){return r(this,ir).executor.transformQuery(r(this,ir).node,r(this,ir).queryId)}compile(){return r(this,ir).executor.compileQuery(this.toOperationNode(),r(this,ir).queryId)}async execute(){await r(this,ir).executor.executeQuery(this.compile(),r(this,ir).queryId)}}ir=new WeakMap;$e(ga,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");var Zt;const Fc=class{constructor(e){S(this,Zt,void 0);P(this,Zt,p(e))}onDelete(e){return new Fc({...r(this,Zt),constraintBuilder:r(this,Zt).constraintBuilder.onDelete(e)})}onUpdate(e){return new Fc({...r(this,Zt),constraintBuilder:r(this,Zt).constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return r(this,Zt).executor.transformQuery(Et.cloneWithTableProps(r(this,Zt).node,{addConstraint:lf.create(r(this,Zt).constraintBuilder.toOperationNode())}),r(this,Zt).queryId)}compile(){return r(this,Zt).executor.compileQuery(this.toOperationNode(),r(this,Zt).queryId)}async execute(){await r(this,Zt).executor.executeQuery(this.compile(),r(this,Zt).queryId)}};let vc=Fc;Zt=new WeakMap;$e(vc,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");var _t;const Ea=class{constructor(e){S(this,_t,void 0);P(this,_t,p(e))}ifExists(){return new Ea({...r(this,_t),node:Et.cloneWithTableProps(r(this,_t).node,{dropConstraint:tc.cloneWith(r(this,_t).node.dropConstraint,{ifExists:!0})})})}cascade(){return new Ea({...r(this,_t),node:Et.cloneWithTableProps(r(this,_t).node,{dropConstraint:tc.cloneWith(r(this,_t).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new Ea({...r(this,_t),node:Et.cloneWithTableProps(r(this,_t).node,{dropConstraint:tc.cloneWith(r(this,_t).node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return r(this,_t).executor.transformQuery(r(this,_t).node,r(this,_t).queryId)}compile(){return r(this,_t).executor.compileQuery(this.toOperationNode(),r(this,_t).queryId)}async execute(){await r(this,_t).executor.executeQuery(this.compile(),r(this,_t).queryId)}};let _c=Ea;_t=new WeakMap;$e(_c,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");var ot;class Zp{constructor(e){S(this,ot,void 0);P(this,ot,p(e))}renameTo(e){return new ga({...r(this,ot),node:Et.cloneWithTableProps(r(this,ot).node,{renameTo:_n(e)})})}setSchema(e){return new ga({...r(this,ot),node:Et.cloneWithTableProps(r(this,ot).node,{setSchema:mt.create(e)})})}alterColumn(e,n){const i=n(new El(Xi.create(e)));return new ui({...r(this,ot),node:Et.cloneWithColumnAlteration(r(this,ot).node,i.toOperationNode())})}dropColumn(e){return new ui({...r(this,ot),node:Et.cloneWithColumnAlteration(r(this,ot).node,Kp.create(e))})}renameColumn(e,n){return new ui({...r(this,ot),node:Et.cloneWithColumnAlteration(r(this,ot).node,Jp.create(e,n))})}addColumn(e,n,i=Lo){const a=i(new Ei(bt.create(e,Uo(n))));return new ui({...r(this,ot),node:Et.cloneWithColumnAlteration(r(this,ot).node,zp.create(a.toOperationNode()))})}modifyColumn(e,n,i=Lo){const a=i(new Ei(bt.create(e,Uo(n))));return new ui({...r(this,ot),node:Et.cloneWithColumnAlteration(r(this,ot).node,Xp.create(a.toOperationNode()))})}addUniqueConstraint(e,n){return new ga({...r(this,ot),node:Et.cloneWithTableProps(r(this,ot).node,{addConstraint:lf.create(Yp.create(n,e))})})}addCheckConstraint(e,n){return new ga({...r(this,ot),node:Et.cloneWithTableProps(r(this,ot).node,{addConstraint:lf.create(Jf.create(n.toOperationNode(),e))})})}addForeignKeyConstraint(e,n,i,a){return new vc({...r(this,ot),constraintBuilder:new Ua(Nc.create(n.map(Nt.create),_n(i),a.map(Nt.create),e))})}dropConstraint(e){return new _c({...r(this,ot),node:Et.cloneWithTableProps(r(this,ot).node,{dropConstraint:tc.create(e)})})}$call(e){return e(this)}call(e){return this.$call(e)}}ot=new WeakMap;var gt;const ts=class{constructor(e){S(this,gt,void 0);P(this,gt,p(e))}alterColumn(e,n){const i=n(new El(Xi.create(e)));return new ts({...r(this,gt),node:Et.cloneWithColumnAlteration(r(this,gt).node,i.toOperationNode())})}dropColumn(e){return new ts({...r(this,gt),node:Et.cloneWithColumnAlteration(r(this,gt).node,Kp.create(e))})}renameColumn(e,n){return new ts({...r(this,gt),node:Et.cloneWithColumnAlteration(r(this,gt).node,Jp.create(e,n))})}addColumn(e,n,i=Lo){const a=i(new Ei(bt.create(e,Uo(n))));return new ts({...r(this,gt),node:Et.cloneWithColumnAlteration(r(this,gt).node,zp.create(a.toOperationNode()))})}modifyColumn(e,n,i=Lo){const a=i(new Ei(bt.create(e,Uo(n))));return new ts({...r(this,gt),node:Et.cloneWithColumnAlteration(r(this,gt).node,Xp.create(a.toOperationNode()))})}toOperationNode(){return r(this,gt).executor.transformQuery(r(this,gt).node,r(this,gt).queryId)}compile(){return r(this,gt).executor.compileQuery(this.toOperationNode(),r(this,gt).queryId)}async execute(){await r(this,gt).executor.executeQuery(this.compile(),r(this,gt).queryId)}};let ui=ts;gt=new WeakMap;$e(Zp,"don't await AlterTableBuilder instances");$e(El,"don't await AlterColumnBuilder instances");$e(ui,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class em extends Vf{transformValue(e){return{...super.transformValue(e),immediate:!0}}}var Ze;const Nr=class{constructor(e){S(this,Ze,void 0);P(this,Ze,p(e))}ifNotExists(){return new Nr({...r(this,Ze),node:ri.cloneWith(r(this,Ze).node,{ifNotExists:!0})})}unique(){return new Nr({...r(this,Ze),node:ri.cloneWith(r(this,Ze).node,{unique:!0})})}on(e){return new Nr({...r(this,Ze),node:ri.cloneWith(r(this,Ze).node,{table:_n(e)})})}column(e){return new Nr({...r(this,Ze),node:ri.cloneWithColumns(r(this,Ze).node,[Ah(e)])})}columns(e){return new Nr({...r(this,Ze),node:ri.cloneWithColumns(r(this,Ze).node,e.map(Ah))})}expression(e){return new Nr({...r(this,Ze),node:ri.cloneWithColumns(r(this,Ze).node,[e.toOperationNode()])})}using(e){return new Nr({...r(this,Ze),node:ri.cloneWith(r(this,Ze).node,{using:en.createWithSql(e)})})}where(...e){const n=new em;return new Nr({...r(this,Ze),node:ye.cloneWithWhere(r(this,Ze).node,n.transformNode(Rn(e)))})}$call(e){return e(this)}toOperationNode(){return r(this,Ze).executor.transformQuery(r(this,Ze).node,r(this,Ze).queryId)}compile(){return r(this,Ze).executor.compileQuery(this.toOperationNode(),r(this,Ze).queryId)}async execute(){await r(this,Ze).executor.executeQuery(this.compile(),r(this,Ze).queryId)}};let xc=Nr;Ze=new WeakMap;$e(xc,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");var Wn;const Zf=class{constructor(e){S(this,Wn,void 0);P(this,Wn,p(e))}ifNotExists(){return new Zf({...r(this,Wn),node:gp.cloneWith(r(this,Wn).node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return r(this,Wn).executor.transformQuery(r(this,Wn).node,r(this,Wn).queryId)}compile(){return r(this,Wn).executor.compileQuery(this.toOperationNode(),r(this,Wn).queryId)}async execute(){await r(this,Wn).executor.executeQuery(this.compile(),r(this,Wn).queryId)}};let Ec=Zf;Wn=new WeakMap;$e(Ec,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");const bb=p({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return p({kind:"PrimaryKeyConstraintNode",columns:p(t.map(Nt.create)),name:e?mt.create(e):void 0})}});function Nb(t){if(hg.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}var Ue;const Qn=class{constructor(e){S(this,Ue,void 0);P(this,Ue,p(e))}temporary(){return new Qn({...r(this,Ue),node:Zn.cloneWith(r(this,Ue).node,{temporary:!0})})}onCommit(e){return new Qn({...r(this,Ue),node:Zn.cloneWith(r(this,Ue).node,{onCommit:Nb(e)})})}ifNotExists(){return new Qn({...r(this,Ue),node:Zn.cloneWith(r(this,Ue).node,{ifNotExists:!0})})}addColumn(e,n,i=Lo){const a=i(new Ei(bt.create(e,Uo(n))));return new Qn({...r(this,Ue),node:Zn.cloneWithColumn(r(this,Ue).node,a.toOperationNode())})}addPrimaryKeyConstraint(e,n){return new Qn({...r(this,Ue),node:Zn.cloneWithConstraint(r(this,Ue).node,bb.create(n,e))})}addUniqueConstraint(e,n){return new Qn({...r(this,Ue),node:Zn.cloneWithConstraint(r(this,Ue).node,Yp.create(n,e))})}addCheckConstraint(e,n){return new Qn({...r(this,Ue),node:Zn.cloneWithConstraint(r(this,Ue).node,Jf.create(n.toOperationNode(),e))})}addForeignKeyConstraint(e,n,i,a,l=Lo){const m=l(new Ua(Nc.create(n.map(Nt.create),_n(i),a.map(Nt.create),e)));return new Qn({...r(this,Ue),node:Zn.cloneWithConstraint(r(this,Ue).node,m.toOperationNode())})}modifyFront(e){return new Qn({...r(this,Ue),node:Zn.cloneWithFrontModifier(r(this,Ue).node,e.toOperationNode())})}modifyEnd(e){return new Qn({...r(this,Ue),node:Zn.cloneWithEndModifier(r(this,Ue).node,e.toOperationNode())})}$call(e){return e(this)}call(e){return this.$call(e)}toOperationNode(){return r(this,Ue).executor.transformQuery(r(this,Ue).node,r(this,Ue).queryId)}compile(){return r(this,Ue).executor.compileQuery(this.toOperationNode(),r(this,Ue).queryId)}async execute(){await r(this,Ue).executor.executeQuery(this.compile(),r(this,Ue).queryId)}};let Cc=Qn;Ue=new WeakMap;$e(Cc,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");var Ut;const Ca=class{constructor(e){S(this,Ut,void 0);P(this,Ut,p(e))}on(e){return new Ca({...r(this,Ut),node:Zu.cloneWith(r(this,Ut).node,{table:_n(e)})})}ifExists(){return new Ca({...r(this,Ut),node:Zu.cloneWith(r(this,Ut).node,{ifExists:!0})})}cascade(){return new Ca({...r(this,Ut),node:Zu.cloneWith(r(this,Ut).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return r(this,Ut).executor.transformQuery(r(this,Ut).node,r(this,Ut).queryId)}compile(){return r(this,Ut).executor.compileQuery(this.toOperationNode(),r(this,Ut).queryId)}async execute(){await r(this,Ut).executor.executeQuery(this.compile(),r(this,Ut).queryId)}};let Oc=Ca;Ut=new WeakMap;$e(Oc,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");var ln;const Uc=class{constructor(e){S(this,ln,void 0);P(this,ln,p(e))}ifExists(){return new Uc({...r(this,ln),node:rf.cloneWith(r(this,ln).node,{ifExists:!0})})}cascade(){return new Uc({...r(this,ln),node:rf.cloneWith(r(this,ln).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return r(this,ln).executor.transformQuery(r(this,ln).node,r(this,ln).queryId)}compile(){return r(this,ln).executor.compileQuery(this.toOperationNode(),r(this,ln).queryId)}async execute(){await r(this,ln).executor.executeQuery(this.compile(),r(this,ln).queryId)}};let qc=Uc;ln=new WeakMap;$e(qc,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");var fn;const $c=class{constructor(e){S(this,fn,void 0);P(this,fn,p(e))}ifExists(){return new $c({...r(this,fn),node:sf.cloneWith(r(this,fn).node,{ifExists:!0})})}cascade(){return new $c({...r(this,fn),node:sf.cloneWith(r(this,fn).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return r(this,fn).executor.transformQuery(r(this,fn).node,r(this,fn).queryId)}compile(){return r(this,fn).executor.compileQuery(this.toOperationNode(),r(this,fn).queryId)}async execute(){await r(this,fn).executor.executeQuery(this.compile(),r(this,fn).queryId)}};let Wc=$c;fn=new WeakMap;$e(Wc,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");const oi=p({is(t){return t.kind==="CreateViewNode"},create(t){return p({kind:"CreateViewNode",name:xi.create(t)})},cloneWith(t,e){return p({...t,...e})}});var Qc;class vb{constructor(){S(this,Qc,new em)}transformQuery(e){return r(this,Qc).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}Qc=new WeakMap;var dt;const ai=class{constructor(e){S(this,dt,void 0);P(this,dt,p(e))}temporary(){return new ai({...r(this,dt),node:oi.cloneWith(r(this,dt).node,{temporary:!0})})}materialized(){return new ai({...r(this,dt),node:oi.cloneWith(r(this,dt).node,{materialized:!0})})}ifNotExists(){return new ai({...r(this,dt),node:oi.cloneWith(r(this,dt).node,{ifNotExists:!0})})}orReplace(){return new ai({...r(this,dt),node:oi.cloneWith(r(this,dt).node,{orReplace:!0})})}columns(e){return new ai({...r(this,dt),node:oi.cloneWith(r(this,dt).node,{columns:e.map(Ep)})})}as(e){const n=e.withPlugin(new vb).toOperationNode();return new ai({...r(this,dt),node:oi.cloneWith(r(this,dt).node,{as:n})})}$call(e){return e(this)}toOperationNode(){return r(this,dt).executor.transformQuery(r(this,dt).node,r(this,dt).queryId)}compile(){return r(this,dt).executor.compileQuery(this.toOperationNode(),r(this,dt).queryId)}async execute(){await r(this,dt).executor.executeQuery(this.compile(),r(this,dt).queryId)}};let Ic=ai;dt=new WeakMap;$e(Ic,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const nc=p({is(t){return t.kind==="DropViewNode"},create(t){return p({kind:"DropViewNode",name:xi.create(t)})},cloneWith(t,e){return p({...t,...e})}});var $t;const Oa=class{constructor(e){S(this,$t,void 0);P(this,$t,p(e))}materialized(){return new Oa({...r(this,$t),node:nc.cloneWith(r(this,$t).node,{materialized:!0})})}ifExists(){return new Oa({...r(this,$t),node:nc.cloneWith(r(this,$t).node,{ifExists:!0})})}cascade(){return new Oa({...r(this,$t),node:nc.cloneWith(r(this,$t).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return r(this,$t).executor.transformQuery(r(this,$t).node,r(this,$t).queryId)}compile(){return r(this,$t).executor.compileQuery(this.toOperationNode(),r(this,$t).queryId)}async execute(){await r(this,$t).executor.executeQuery(this.compile(),r(this,$t).queryId)}};let Ac=Oa;$t=new WeakMap;$e(Ac,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const tm=p({is(t){return t.kind==="CreateTypeNode"},create(t){return p({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return p({...t,enum:Qf.create(e.map(n=>Ir.createImmediate(n)))})}});var In;const eh=class{constructor(e){S(this,In,void 0);P(this,In,p(e))}toOperationNode(){return r(this,In).executor.transformQuery(r(this,In).node,r(this,In).queryId)}asEnum(e){return new eh({...r(this,In),node:tm.cloneWithEnum(r(this,In).node,e)})}$call(e){return e(this)}compile(){return r(this,In).executor.compileQuery(this.toOperationNode(),r(this,In).queryId)}async execute(){await r(this,In).executor.executeQuery(this.compile(),r(this,In).queryId)}};let Tc=eh;In=new WeakMap;$e(Tc,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const nm=p({is(t){return t.kind==="DropTypeNode"},create(t){return p({kind:"DropTypeNode",name:t})},cloneWith(t,e){return p({...t,...e})}});var An;const th=class{constructor(e){S(this,An,void 0);P(this,An,p(e))}ifExists(){return new th({...r(this,An),node:nm.cloneWith(r(this,An).node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return r(this,An).executor.transformQuery(r(this,An).node,r(this,An).queryId)}compile(){return r(this,An).executor.compileQuery(this.toOperationNode(),r(this,An).queryId)}async execute(){await r(this,An).executor.executeQuery(this.compile(),r(this,An).queryId)}};let Sc=th;An=new WeakMap;$e(Sc,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function Hh(t){const e=".";if(t.includes(e)){const n=t.split(e).map(_b);if(n.length===2)return xi.createWithSchema(n[0],n[1]);throw new Error(`invalid schemable identifier ${t}`)}else return xi.create(t)}function _b(t){return t.trim()}var kt;const qa=class{constructor(e){S(this,kt,void 0);P(this,kt,e)}createTable(e){return new Cc({queryId:et(),executor:r(this,kt),node:Zn.create(_n(e))})}dropTable(e){return new Wc({queryId:et(),executor:r(this,kt),node:sf.create(_n(e))})}createIndex(e){return new xc({queryId:et(),executor:r(this,kt),node:ri.create(e)})}dropIndex(e){return new Oc({queryId:et(),executor:r(this,kt),node:Zu.create(e)})}createSchema(e){return new Ec({queryId:et(),executor:r(this,kt),node:gp.create(e)})}dropSchema(e){return new qc({queryId:et(),executor:r(this,kt),node:rf.create(e)})}alterTable(e){return new Zp({queryId:et(),executor:r(this,kt),node:Et.create(_n(e))})}createView(e){return new Ic({queryId:et(),executor:r(this,kt),node:oi.create(e)})}dropView(e){return new Ac({queryId:et(),executor:r(this,kt),node:nc.create(e)})}createType(e){return new Tc({queryId:et(),executor:r(this,kt),node:tm.create(Hh(e))})}dropType(e){return new Sc({queryId:et(),executor:r(this,kt),node:nm.create(Hh(e))})}withPlugin(e){return new qa(r(this,kt).withPlugin(e))}withoutPlugins(){return new qa(r(this,kt).withoutPlugins())}withSchema(e){return new qa(r(this,kt).withPluginAtFront(new Nu(e)))}};let ff=qa;kt=new WeakMap;class xb{ref(e){return new Ig(e)}}var bo;class Eb{constructor(e){S(this,bo,void 0);P(this,bo,e)}async provideConnection(e){const n=await r(this,bo).acquireConnection();try{return await e(n)}finally{await r(this,bo).releaseConnection(n)}}}bo=new WeakMap;var xr,Er,Dr;const ns=class extends Lp{constructor(n,i,a,l=[]){super(l);S(this,xr,void 0);S(this,Er,void 0);S(this,Dr,void 0);P(this,xr,n),P(this,Er,i),P(this,Dr,a)}get adapter(){return r(this,Er)}compileQuery(n){return r(this,xr).compileQuery(n)}provideConnection(n){return r(this,Dr).provideConnection(n)}withPlugins(n){return new ns(r(this,xr),r(this,Er),r(this,Dr),[...this.plugins,...n])}withPlugin(n){return new ns(r(this,xr),r(this,Er),r(this,Dr),[...this.plugins,n])}withPluginAtFront(n){return new ns(r(this,xr),r(this,Er),r(this,Dr),[n,...this.plugins])}withConnectionProvider(n){return new ns(r(this,xr),r(this,Er),n,[...this.plugins])}withoutPlugins(){return new ns(r(this,xr),r(this,Er),r(this,Dr),[])}};let hf=ns;xr=new WeakMap,Er=new WeakMap,Dr=new WeakMap;function Vh(){return typeof performance<"u"&&Vn(performance.now)?performance.now():Date.now()}var sr,li,Lr,us,Ya,jc,rm,Hc,im,Vc,sm,zc,om,Za,df;class Cb{constructor(e,n){S(this,jc);S(this,Hc);S(this,Vc);S(this,zc);S(this,Za);S(this,sr,void 0);S(this,li,void 0);S(this,Lr,void 0);S(this,us,void 0);S(this,Ya,new WeakSet);P(this,sr,e),P(this,li,n)}async init(){r(this,Lr)||P(this,Lr,r(this,sr).init().catch(e=>(P(this,Lr,void 0),Promise.reject(e)))),await r(this,Lr)}async acquireConnection(){await this.init();const e=await r(this,sr).acquireConnection();return r(this,Ya).has(e)||(qe(this,jc,rm).call(this)&&qe(this,Hc,im).call(this,e),r(this,Ya).add(e)),e}async releaseConnection(e){await r(this,sr).releaseConnection(e)}beginTransaction(e,n){return r(this,sr).beginTransaction(e,n)}commitTransaction(e){return r(this,sr).commitTransaction(e)}rollbackTransaction(e){return r(this,sr).rollbackTransaction(e)}async destroy(){r(this,Lr)&&(await r(this,Lr),r(this,us)||P(this,us,r(this,sr).destroy().catch(e=>(P(this,us,void 0),Promise.reject(e)))),await r(this,us))}}sr=new WeakMap,li=new WeakMap,Lr=new WeakMap,us=new WeakMap,Ya=new WeakMap,jc=new WeakSet,rm=function(){return r(this,li).isLevelEnabled("query")||r(this,li).isLevelEnabled("error")},Hc=new WeakSet,im=function(e){const n=e.executeQuery;e.executeQuery=async i=>{const a=Vh();try{return await n.call(e,i)}catch(l){throw await qe(this,Vc,sm).call(this,l,i,a),l}finally{await qe(this,zc,om).call(this,i,a)}}},Vc=new WeakSet,sm=async function(e,n,i){await r(this,li).error(()=>({level:"error",error:e,query:n,queryDurationMillis:qe(this,Za,df).call(this,i)}))},zc=new WeakSet,om=async function(e,n){await r(this,li).query(()=>({level:"query",query:e,queryDurationMillis:qe(this,Za,df).call(this,n)}))},Za=new WeakSet,df=function(e){return Vh()-e};var eu,fi,Kc,um;class am{constructor(e){S(this,Kc);S(this,eu,void 0);S(this,fi,void 0);P(this,eu,e)}async provideConnection(e){for(;r(this,fi);)await r(this,fi);const n=qe(this,Kc,um).call(this,e);return P(this,fi,n.then(()=>{P(this,fi,void 0)}).catch(()=>{P(this,fi,void 0)})),n}}eu=new WeakMap,fi=new WeakMap,Kc=new WeakSet,um=async function(e){return await e(r(this,eu))};const Ob=["read uncommitted","read committed","repeatable read","serializable"];p(["query","error"]);var hi,cs;class qb{constructor(e){S(this,hi,void 0);S(this,cs,void 0);Vn(e)?(P(this,cs,e),P(this,hi,p({query:!0,error:!0}))):(P(this,cs,Wb),P(this,hi,p({query:e.includes("query"),error:e.includes("error")})))}isLevelEnabled(e){return r(this,hi)[e]}async query(e){r(this,hi).query&&await r(this,cs).call(this,e())}async error(e){r(this,hi).error&&await r(this,cs).call(this,e())}}hi=new WeakMap,cs=new WeakMap;function Wb(t){t.level==="query"?(console.log(`kysely:query: ${t.query.sql}`),console.log(`kysely:query: duration: ${t.queryDurationMillis.toFixed(1)}ms`)):t.level==="error"&&(t.error instanceof Error?console.error(`kysely:error: ${t.error.stack??t.error.message}`):console.error(`kysely:error: ${t}`))}function Ib(t){return Wr(t)&&Vn(t.compile)}var Qt;const Xs=class extends gc{constructor(n){let i,a;if(Ab(n))i={executor:n.executor},a={...n};else{const l=n.dialect,m=l.createDriver(),w=l.createQueryCompiler(),v=l.createAdapter(),d=new qb(n.log??[]),W=new Cb(m,d),B=new Eb(W),D=new hf(w,v,B,n.plugins??[]);i={executor:D},a={config:n,executor:D,dialect:l,driver:W}}super(i);S(this,Qt,void 0);P(this,Qt,p(a))}get schema(){return new ff(r(this,Qt).executor)}get dynamic(){return new xb}get introspection(){return r(this,Qt).dialect.createIntrospector(this.withoutPlugins())}case(n){return new $p({node:dr.create(va(n)?void 0:_l(n))})}get fn(){return Up()}transaction(){return new kc({...r(this,Qt)})}connection(){return new cm({...r(this,Qt)})}withPlugin(n){return new Xs({...r(this,Qt),executor:r(this,Qt).executor.withPlugin(n)})}withoutPlugins(){return new Xs({...r(this,Qt),executor:r(this,Qt).executor.withoutPlugins()})}withSchema(n){return new Xs({...r(this,Qt),executor:r(this,Qt).executor.withPluginAtFront(new Nu(n))})}withTables(){return new Xs({...r(this,Qt)})}async destroy(){await r(this,Qt).driver.destroy()}get isTransaction(){return!1}getExecutor(){return r(this,Qt).executor}executeQuery(n,i=et()){const a=Ib(n)?n.compile():n;return this.getExecutor().executeQuery(a,i)}};let $a=Xs;Qt=new WeakMap;var or;const Ys=class extends $a{constructor(n){super(n);S(this,or,void 0);P(this,or,n)}get isTransaction(){return!0}transaction(){throw new Error("calling the transaction method for a Transaction is not supported")}connection(){throw new Error("calling the connection method for a Transaction is not supported")}async destroy(){throw new Error("calling the destroy method for a Transaction is not supported")}withPlugin(n){return new Ys({...r(this,or),executor:r(this,or).executor.withPlugin(n)})}withoutPlugins(){return new Ys({...r(this,or),executor:r(this,or).executor.withoutPlugins()})}withSchema(n){return new Ys({...r(this,or),executor:r(this,or).executor.withPluginAtFront(new Nu(n))})}withTables(){return new Ys({...r(this,or)})}};let pf=Ys;or=new WeakMap;function Ab(t){return Wr(t)&&Wr(t.config)&&Wr(t.driver)&&Wr(t.executor)&&Wr(t.dialect)}var ls;class cm{constructor(e){S(this,ls,void 0);P(this,ls,p(e))}async execute(e){return r(this,ls).executor.provideConnection(async n=>{const i=r(this,ls).executor.withConnectionProvider(new am(n)),a=new $a({...r(this,ls),executor:i});return await e(a)})}}ls=new WeakMap;$e(cm,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");var ar;const nh=class{constructor(e){S(this,ar,void 0);P(this,ar,p(e))}setIsolationLevel(e){return new nh({...r(this,ar),isolationLevel:e})}async execute(e){const{isolationLevel:n,...i}=r(this,ar),a={isolationLevel:n};return Tb(a),r(this,ar).executor.provideConnection(async l=>{const m=r(this,ar).executor.withConnectionProvider(new am(l)),w=new pf({...i,executor:m});try{await r(this,ar).driver.beginTransaction(l,a);const v=await e(w);return await r(this,ar).driver.commitTransaction(l),v}catch(v){throw await r(this,ar).driver.rollbackTransaction(l),v}})}};let kc=nh;ar=new WeakMap;$e(kc,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function Tb(t){if(t.isolationLevel&&!Ob.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}var Nn,No,rc,tu,mf,nu,yf;const Jc=class{constructor(e){S(this,No);S(this,tu);S(this,nu);S(this,Nn,void 0);P(this,Nn,p(e))}get expressionType(){}as(e){return new Sb(this,e)}$castTo(){return new Jc({...r(this,Nn)})}castTo(){return this.$castTo()}withPlugin(e){return new Jc({...r(this,Nn),plugins:r(this,Nn).plugins!==void 0?p([...r(this,Nn).plugins,e]):p([e])})}toOperationNode(){return qe(this,tu,mf).call(this,qe(this,No,rc).call(this))}compile(e){return qe(this,nu,yf).call(this,qe(this,No,rc).call(this,e))}async execute(e){const n=qe(this,No,rc).call(this,e);return n.executeQuery(qe(this,nu,yf).call(this,n),r(this,Nn).queryId)}};let rr=Jc;Nn=new WeakMap,No=new WeakSet,rc=function(e){const n=e!==void 0?e.getExecutor():Nl;return r(this,Nn).plugins!==void 0?n.withPlugins(r(this,Nn).plugins):n},tu=new WeakSet,mf=function(e){return e.transformQuery(r(this,Nn).rawNode,r(this,Nn).queryId)},nu=new WeakSet,yf=function(e){return e.compileQuery(qe(this,tu,mf).call(this,e),r(this,Nn).queryId)};$e(rr,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");var vo,di;class Sb{constructor(e,n){S(this,vo,void 0);S(this,di,void 0);P(this,vo,e),P(this,di,n)}get expression(){return r(this,vo)}get alias(){return r(this,di)}toOperationNode(){return Es.create(r(this,vo).toOperationNode(),hn(r(this,di))?r(this,di).toOperationNode():mt.create(r(this,di)))}}vo=new WeakMap,di=new WeakMap;const kn=Object.assign((t,...e)=>new rr({queryId:et(),rawNode:en.create(t,(e==null?void 0:e.map(Ur))??[])}),{ref(t){return new rr({queryId:et(),rawNode:en.createWithChild(Po(t))})},val(t){return new rr({queryId:et(),rawNode:en.createWithChild(Ur(t))})},value(t){return this.val(t)},table(t){return new rr({queryId:et(),rawNode:en.createWithChild(_n(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",new rr({queryId:et(),rawNode:en.create(e,t.map(mt.create))})},lit(t){return new rr({queryId:et(),rawNode:en.createWithChild(Ir.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return new rr({queryId:et(),rawNode:en.createWithSql(t)})},join(t,e=kn`, `){const n=new Array(2*t.length-1),i=e.toOperationNode();for(let a=0;a{this.nodeStack.push(e),r(this,Gc)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}Gc=new WeakMap;var _o,fs;class Rb extends kb{constructor(){super(...arguments);S(this,_o,"");S(this,fs,[])}get numParameters(){return r(this,fs).length}compileQuery(n){return P(this,_o,""),P(this,fs,[]),this.visitNode(n),p({query:n,sql:this.getSql(),parameters:[...r(this,fs)]})}getSql(){return r(this,_o)}visitSelectQuery(n){const i=this.parentNode!==void 0&&!Or.is(this.parentNode)&&!oi.is(this.parentNode)&&!Fp.is(this.parentNode);this.parentNode===void 0&&n.explain&&(this.visitNode(n.explain),this.append(" ")),i&&this.append("("),n.with&&(this.visitNode(n.with),this.append(" ")),this.append("select "),n.distinctOn&&(this.compileDistinctOn(n.distinctOn),this.append(" ")),n.frontModifiers&&n.frontModifiers.length>0&&(this.compileList(n.frontModifiers," "),this.append(" ")),n.selections&&(this.compileList(n.selections),this.append(" ")),this.visitNode(n.from),n.joins&&(this.append(" "),this.compileList(n.joins," ")),n.where&&(this.append(" "),this.visitNode(n.where)),n.groupBy&&(this.append(" "),this.visitNode(n.groupBy)),n.having&&(this.append(" "),this.visitNode(n.having)),n.setOperations&&(this.append(" "),this.compileList(n.setOperations," ")),n.orderBy&&(this.append(" "),this.visitNode(n.orderBy)),n.limit&&(this.append(" "),this.visitNode(n.limit)),n.offset&&(this.append(" "),this.visitNode(n.offset)),n.endModifiers&&n.endModifiers.length>0&&(this.append(" "),this.compileList(n.endModifiers," ")),i&&this.append(")")}visitFrom(n){this.append("from "),this.compileList(n.froms)}visitSelection(n){this.visitNode(n.selection)}visitColumn(n){this.visitNode(n.column)}compileDistinctOn(n){this.append("distinct on ("),this.compileList(n),this.append(")")}compileList(n,i=", "){const a=n.length-1;for(let l=0;l<=a;l++)this.visitNode(n[l]),ll&&this.visitNode(a[l])}visitOperator(n){this.append(n.operator)}visitTable(n){this.visitNode(n.table)}visitSchemableIdentifier(n){n.schema&&(this.visitNode(n.schema),this.append(".")),this.visitNode(n.identifier)}visitCreateTable(n){this.append("create "),n.frontModifiers&&n.frontModifiers.length>0&&(this.compileList(n.frontModifiers," "),this.append(" ")),n.temporary&&this.append("temporary "),this.append("table "),n.ifNotExists&&this.append("if not exists "),this.visitNode(n.table),this.append(" ("),this.compileList([...n.columns,...n.constraints??[]]),this.append(")"),n.onCommit&&(this.append(" on commit "),this.append(n.onCommit)),n.endModifiers&&n.endModifiers.length>0&&(this.append(" "),this.compileList(n.endModifiers," "))}visitColumnDefinition(n){this.visitNode(n.column),this.append(" "),this.visitNode(n.dataType),n.unsigned&&this.append(" unsigned"),n.frontModifiers&&n.frontModifiers.length>0&&(this.append(" "),this.compileList(n.frontModifiers," ")),n.generated&&(this.append(" "),this.visitNode(n.generated)),n.defaultTo&&(this.append(" "),this.visitNode(n.defaultTo)),n.notNull&&this.append(" not null"),n.unique&&this.append(" unique"),n.primaryKey&&this.append(" primary key"),n.autoIncrement&&(this.append(" "),this.append(this.getAutoIncrement())),n.references&&(this.append(" "),this.visitNode(n.references)),n.check&&(this.append(" "),this.visitNode(n.check)),n.endModifiers&&n.endModifiers.length>0&&(this.append(" "),this.compileList(n.endModifiers," "))}getAutoIncrement(){return"auto_increment"}visitReferences(n){this.append("references "),this.visitNode(n.table),this.append(" ("),this.compileList(n.columns),this.append(")"),n.onDelete&&(this.append(" on delete "),this.append(n.onDelete)),n.onUpdate&&(this.append(" on update "),this.append(n.onUpdate))}visitDropTable(n){this.append("drop table "),n.ifExists&&this.append("if exists "),this.visitNode(n.table),n.cascade&&this.append(" cascade")}visitDataType(n){this.append(n.dataType)}visitOrderBy(n){this.append("order by "),this.compileList(n.items)}visitOrderByItem(n){this.visitNode(n.orderBy),n.direction&&(this.append(" "),this.visitNode(n.direction))}visitGroupBy(n){this.append("group by "),this.compileList(n.items)}visitGroupByItem(n){this.visitNode(n.groupBy)}visitUpdateQuery(n){const i=this.nodeStack.find(ye.is)!==n;!i&&n.explain&&(this.visitNode(n.explain),this.append(" ")),i&&this.append("("),n.with&&(this.visitNode(n.with),this.append(" ")),this.append("update "),this.visitNode(n.table),this.append(" set "),n.updates&&this.compileList(n.updates),n.from&&(this.append(" "),this.visitNode(n.from)),n.joins&&(this.append(" "),this.compileList(n.joins," ")),n.where&&(this.append(" "),this.visitNode(n.where)),n.returning&&(this.append(" "),this.visitNode(n.returning)),i&&this.append(")")}visitColumnUpdate(n){this.visitNode(n.column),this.append(" = "),this.visitNode(n.value)}visitLimit(n){this.append("limit "),this.visitNode(n.limit)}visitOffset(n){this.append("offset "),this.visitNode(n.offset)}visitOnConflict(n){this.append("on conflict"),n.columns?(this.append(" ("),this.compileList(n.columns),this.append(")")):n.constraint?(this.append(" on constraint "),this.visitNode(n.constraint)):n.indexExpression&&(this.append(" ("),this.visitNode(n.indexExpression),this.append(")")),n.indexWhere&&(this.append(" "),this.visitNode(n.indexWhere)),n.doNothing===!0?this.append(" do nothing"):n.updates&&(this.append(" do update set "),this.compileList(n.updates),n.updateWhere&&(this.append(" "),this.visitNode(n.updateWhere)))}visitOnDuplicateKey(n){this.append("on duplicate key update "),this.compileList(n.updates)}visitCreateIndex(n){this.append("create "),n.unique&&this.append("unique "),this.append("index "),n.ifNotExists&&this.append("if not exists "),this.visitNode(n.name),n.table&&(this.append(" on "),this.visitNode(n.table)),n.using&&(this.append(" using "),this.visitNode(n.using)),n.columns&&(this.append(" ("),this.compileList(n.columns),this.append(")")),n.where&&(this.append(" "),this.visitNode(n.where))}visitDropIndex(n){this.append("drop index "),n.ifExists&&this.append("if exists "),this.visitNode(n.name),n.table&&(this.append(" on "),this.visitNode(n.table)),n.cascade&&this.append(" cascade")}visitCreateSchema(n){this.append("create schema "),n.ifNotExists&&this.append("if not exists "),this.visitNode(n.schema)}visitDropSchema(n){this.append("drop schema "),n.ifExists&&this.append("if exists "),this.visitNode(n.schema),n.cascade&&this.append(" cascade")}visitPrimaryKeyConstraint(n){n.name&&(this.append("constraint "),this.visitNode(n.name),this.append(" ")),this.append("primary key ("),this.compileList(n.columns),this.append(")")}visitUniqueConstraint(n){n.name&&(this.append("constraint "),this.visitNode(n.name),this.append(" ")),this.append("unique ("),this.compileList(n.columns),this.append(")")}visitCheckConstraint(n){n.name&&(this.append("constraint "),this.visitNode(n.name),this.append(" ")),this.append("check ("),this.visitNode(n.expression),this.append(")")}visitForeignKeyConstraint(n){n.name&&(this.append("constraint "),this.visitNode(n.name),this.append(" ")),this.append("foreign key ("),this.compileList(n.columns),this.append(") "),this.visitNode(n.references),n.onDelete&&(this.append(" on delete "),this.append(n.onDelete)),n.onUpdate&&(this.append(" on update "),this.append(n.onUpdate))}visitList(n){this.compileList(n.items)}visitWith(n){this.append("with "),n.recursive&&this.append("recursive "),this.compileList(n.expressions)}visitCommonTableExpression(n){this.visitNode(n.name),this.append(" as "),this.visitNode(n.expression)}visitCommonTableExpressionName(n){this.visitNode(n.table),n.columns&&(this.append("("),this.compileList(n.columns),this.append(")"))}visitAlterTable(n){this.append("alter table "),this.visitNode(n.table),this.append(" "),n.renameTo&&(this.append("rename to "),this.visitNode(n.renameTo)),n.setSchema&&(this.append("set schema "),this.visitNode(n.setSchema)),n.addConstraint&&this.visitNode(n.addConstraint),n.dropConstraint&&this.visitNode(n.dropConstraint),n.columnAlterations&&this.compileList(n.columnAlterations)}visitAddColumn(n){this.append("add column "),this.visitNode(n.column)}visitRenameColumn(n){this.append("rename column "),this.visitNode(n.column),this.append(" to "),this.visitNode(n.renameTo)}visitDropColumn(n){this.append("drop column "),this.visitNode(n.column)}visitAlterColumn(n){this.append("alter column "),this.visitNode(n.column),this.append(" "),n.dataType&&(this.append("type "),this.visitNode(n.dataType),n.dataTypeExpression&&(this.append("using "),this.visitNode(n.dataTypeExpression))),n.setDefault&&(this.append("set default "),this.visitNode(n.setDefault)),n.dropDefault&&this.append("drop default"),n.setNotNull&&this.append("set not null"),n.dropNotNull&&this.append("drop not null")}visitModifyColumn(n){this.append("modify column "),this.visitNode(n.column)}visitAddConstraint(n){this.append("add "),this.visitNode(n.constraint)}visitDropConstraint(n){this.append("drop constraint "),n.ifExists&&this.append("if exists "),this.visitNode(n.constraintName),n.modifier==="cascade"?this.append(" cascade"):n.modifier==="restrict"&&this.append(" restrict")}visitSetOperation(n){this.append(n.operator),this.append(" "),n.all&&this.append("all "),this.visitNode(n.expression)}visitCreateView(n){this.append("create "),n.orReplace&&this.append("or replace "),n.materialized&&this.append("materialized "),n.temporary&&this.append("temporary "),this.append("view "),n.ifNotExists&&this.append("if not exists "),this.visitNode(n.name),this.append(" "),n.columns&&(this.append("("),this.compileList(n.columns),this.append(") ")),n.as&&(this.append("as "),this.visitNode(n.as))}visitDropView(n){this.append("drop "),n.materialized&&this.append("materialized "),this.append("view "),n.ifExists&&this.append("if exists "),this.visitNode(n.name),n.cascade&&this.append(" cascade")}visitGenerated(n){this.append("generated "),n.always&&this.append("always "),n.byDefault&&this.append("by default "),this.append("as "),n.identity&&this.append("identity"),n.expression&&(this.append("("),this.visitNode(n.expression),this.append(")")),n.stored&&this.append(" stored")}visitDefaultValue(n){this.append("default "),this.visitNode(n.defaultValue)}visitSelectModifier(n){n.rawModifier?this.visitNode(n.rawModifier):this.append(Db[n.modifier])}visitCreateType(n){this.append("create type "),this.visitNode(n.name),n.enum&&(this.append(" as enum "),this.visitNode(n.enum))}visitDropType(n){this.append("drop type "),n.ifExists&&this.append("if exists "),this.visitNode(n.name)}visitExplain(n){this.append("explain"),(n.options||n.format)&&(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),n.options&&(this.visitNode(n.options),n.format&&this.append(this.getExplainOptionsDelimiter())),n.format&&(this.append("format"),this.append(this.getExplainOptionAssignment()),this.append(n.format)),this.append(this.getRightExplainOptionsWrapper()))}visitDefaultInsertValue(n){this.append("default")}visitAggregateFunction(n){this.append(n.func),this.append("("),n.distinct&&this.append("distinct "),this.compileList(n.aggregated),this.append(")"),n.filter&&(this.append(" filter("),this.visitNode(n.filter),this.append(")")),n.over&&(this.append(" "),this.visitNode(n.over))}visitOver(n){this.append("over("),n.partitionBy&&(this.visitNode(n.partitionBy),n.orderBy&&this.append(" ")),n.orderBy&&this.visitNode(n.orderBy),this.append(")")}visitPartitionBy(n){this.append("partition by "),this.compileList(n.items)}visitPartitionByItem(n){this.visitNode(n.partitionBy)}visitBinaryOperation(n){this.visitNode(n.leftOperand),this.append(" "),this.visitNode(n.operator),this.append(" "),this.visitNode(n.rightOperand)}visitUnaryOperation(n){this.visitNode(n.operator),this.isMinusOperator(n.operator)||this.append(" "),this.visitNode(n.operand)}isMinusOperator(n){return Ff.is(n)&&n.operator==="-"}visitUsing(n){this.append("using "),this.compileList(n.tables)}visitFunction(n){this.append(n.func),this.append("("),this.compileList(n.arguments),this.append(")")}visitCase(n){this.append("case"),n.value&&(this.append(" "),this.visitNode(n.value)),n.when&&(this.append(" "),this.compileList(n.when," ")),n.else&&(this.append(" else "),this.visitNode(n.else)),this.append(" end"),n.isStatement&&this.append(" case")}visitWhen(n){this.append("when "),this.visitNode(n.condition),n.result&&(this.append(" then "),this.visitNode(n.result))}append(n){P(this,_o,r(this,_o)+n)}appendValue(n){this.addParameter(n),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier(n){const i=this.getLeftIdentifierWrapper(),a=this.getRightIdentifierWrapper();let l="";for(const m of n)l+=m,m===i?l+=i:m===a&&(l+=a);return l}addParameter(n){r(this,fs).push(n)}appendImmediateValue(n){if(mr(n))this.append(`'${n}'`);else if(cg(n)||yp(n))this.append(n.toString());else if(wp(n))this.append("null");else if(lg(n))this.appendImmediateValue(n.toISOString());else if(fg(n))this.appendImmediateValue(n.toString());else throw new Error(`invalid immediate value ${n}`)}}_o=new WeakMap,fs=new WeakMap;const Db=p({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),Lb=p({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral"}),Qr=p({raw(t){return p({sql:t,query:en.createWithSql(t),parameters:p([])})}}),Pb=/"/g;class lm extends Rb{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(e){return e.replace(Pb,'""')}visitDefaultInsertValue(e){this.append("null")}}const Mb="kysely_migration",Bb="kysely_migration_lock";p({__noMigrations__:!0});var xo,Xc,hm;class fm{constructor(e){S(this,Xc);S(this,xo,void 0);P(this,xo,e)}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let n=r(this,xo).selectFrom("sqlite_schema").where("type","in",["table","view"]).where("name","not like","sqlite_%").select("name").orderBy("name").$castTo();e.withInternalKyselyTables||(n=n.where("name","!=",Mb).where("name","!=",Bb));const i=await n.execute();return Promise.all(i.map(({name:a})=>qe(this,Xc,hm).call(this,a)))}async getMetadata(e){return{tables:await this.getTables(e)}}}xo=new WeakMap,Xc=new WeakSet,hm=async function(e){var m,w,v,d,W,B;const n=r(this,xo),i=await n.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),a=(B=(W=(d=(v=(w=(m=i.sql)==null?void 0:m.split(/[\(\),]/))==null?void 0:w.find(D=>D.toLowerCase().includes("autoincrement")))==null?void 0:v.trimStart())==null?void 0:d.split(/\s+/))==null?void 0:W[0])==null?void 0:B.replace(/["`]/g,""),l=await n.selectFrom(kn`pragma_table_info(${e})`.as("table_info")).select(["name","type","notnull","dflt_value"]).orderBy("cid").execute();return{name:e,isView:i.type==="view",columns:l.map(D=>({name:D.name,dataType:D.type,isNullable:!D.notnull,isAutoIncrementing:D.name===a,hasDefaultValue:D.dflt_value!=null}))}};class dm{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var pm=class{createQueryCompiler(){return new lm}createAdapter(){return new dm}createIntrospector(t){return new fm(t)}},ru,Yc,sd,mm=(sd=class{constructor(){S(this,ru,new Fb);Yt(this,"connection");S(this,Yc,void 0)}async acquireConnection(){return await r(this,ru).lock(),this.connection}async beginTransaction(t){await t.executeQuery(Qr.raw("begin"))}async commitTransaction(t){await t.executeQuery(Qr.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(Qr.raw("rollback"))}async releaseConnection(){r(this,ru).unlock()}async destroy(){var t;(t=r(this,Yc))==null||t.close()}},ru=new WeakMap,Yc=new WeakMap,sd),hs,Eo,od,Fb=(od=class{constructor(){S(this,hs,void 0);S(this,Eo,void 0)}async lock(){for(;r(this,hs);)await r(this,hs);P(this,hs,new Promise(e=>{P(this,Eo,e)}))}unlock(){const e=r(this,Eo);P(this,hs,void 0),P(this,Eo,void 0),e==null||e()}},hs=new WeakMap,Eo=new WeakMap,od),ym=class{streamQuery(){throw new Error("Sqlite driver doesn't support streaming")}async executeQuery(t){const{parameters:e,sql:n,query:i}=t;return["SelectQueryNode","RawNode"].includes(i.kind)?{rows:await this.query(n,e)}:{rows:[],...await this.exec(n,e)}}};function Ub({func:t,delay:e,maxCalls:n}){let i,a=0,l=null;function m(){i&&clearTimeout(i),a=0,l=null}function w(){a>=n?(t(l),m()):(i&&clearTimeout(i),i=setTimeout(()=>{t(l),m(),i=void 0},e))}return v=>{a++,l=v,i===void 0&&a===0?(t(v),a++):w()}}var Tn,Co,ad,$b=(ad=class extends mm{constructor(e){super();S(this,Tn,void 0);S(this,Co,void 0);P(this,Tn,e)}async init(){var e,n,i,a;if(P(this,Co,typeof r(this,Tn).database=="function"?await r(this,Tn).database():r(this,Tn).database),!r(this,Co))throw new Error("no database");this.connection=new Qb(r(this,Co),(e=r(this,Tn).onWrite)==null?void 0:e.func,(n=r(this,Tn).onWrite)==null?void 0:n.isThrottle,(i=r(this,Tn).onWrite)==null?void 0:i.maxCalls,(a=r(this,Tn).onWrite)==null?void 0:a.delay),r(this,Tn).onCreateConnection&&await r(this,Tn).onCreateConnection(this.connection)}async beginTransaction(e){await e.executeQuery(Qr.raw("begin")),this.connection&&this.connection.transactionNum++}async commitTransaction(e){await e.executeQuery(Qr.raw("commit")),this.connection&&this.connection.transactionNum--}async rollbackTransaction(e){await e.executeQuery(Qr.raw("rollback")),this.connection&&this.connection.transactionNum--}},Tn=new WeakMap,Co=new WeakMap,ad),pi,Oo,ud,Qb=(ud=class extends ym{constructor(e,n,i=!1,a=1e3,l=2e3){super();S(this,pi,void 0);S(this,Oo,void 0);Yt(this,"transactionNum",0);P(this,pi,e),P(this,Oo,n?i?Ub({func:n,maxCalls:a,delay:l}):n:void 0)}query(e,n){const i=r(this,pi).prepare(e);i.bind(n);const a=[];for(;i.step();)a.push(i.getAsObject());return i.free(),a}exec(e,n){r(this,pi).run(e,n);const i=BigInt(this.query("SELECT last_insert_rowid() as id")[0].id),a=BigInt(r(this,pi).getRowsModified());return this.transactionNum===0&&r(this,Oo)&&r(this,Oo).call(this,r(this,pi).export()),{numAffectedRows:a,insertId:i}}},pi=new WeakMap,Oo=new WeakMap,ud),iu,cd,jb=(cd=class extends pm{constructor(e){super();S(this,iu,void 0);P(this,iu,e)}createDriver(){return new $b(r(this,iu))}},iu=new WeakMap,cd),Pr,ds,ld,Hb=(ld=class extends mm{constructor(e){super();S(this,Pr,void 0);S(this,ds,void 0);P(this,Pr,e)}async init(){P(this,ds,typeof r(this,Pr).database=="function"?await r(this,Pr).database():r(this,Pr).database),this.connection=new Vb(r(this,ds)),r(this,Pr).onCreateConnection&&await r(this,Pr).onCreateConnection(this.connection)}async close(){var e;await((e=r(this,ds))==null?void 0:e.sqlite.close(r(this,ds).db))}},Pr=new WeakMap,ds=new WeakMap,ld),Sn,ps,fd,Vb=(fd=class extends ym{constructor(e){super();S(this,Sn,void 0);S(this,ps,void 0);P(this,ps,e.db),P(this,Sn,e.sqlite)}async run(e){const n=r(this,Sn).str_new(r(this,ps),e.sql),i=await r(this,Sn).prepare_v2(r(this,ps),r(this,Sn).str_value(n));if(i===null)return[];const a=i.stmt;try{typeof e.param<"u"&&r(this,Sn).bind_collection(a,e.param);const l=[];let m=[];for(;await r(this,Sn).step(a)===100;){m=m.length===0?r(this,Sn).column_names(a):m;const w=r(this,Sn).row(a);l.push(m.reduce((v,d,W)=>(v[d]=w[W],v),{}))}return l}finally{await r(this,Sn).finalize(a)}}async query(e,n){return await this.run({sql:e,param:n})}async exec(e,n){await this.run({sql:e,param:n});const i=await this.run({sql:"SELECT last_insert_rowid() as id"});return{insertId:BigInt(i[0].id),numAffectedRows:BigInt(r(this,Sn).changes(r(this,ps)))}}},Sn=new WeakMap,ps=new WeakMap,fd),su,hd,zb=(hd=class extends pm{constructor(e){super();S(this,su,void 0);P(this,su,e)}createDriver(){return new Hb(r(this,su))}},su=new WeakMap,hd);function Kb(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Jb(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function i(){if(this instanceof i){var a=[null];a.push.apply(a,arguments);var l=Function.bind.apply(e,a);return new l}return e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var a=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(n,i,a.get?a:{enumerable:!0,get:function(){return t[i]}})}),n}var wm={exports:{}};const Gb={},Xb=Object.freeze(Object.defineProperty({__proto__:null,default:Gb},Symbol.toStringTag,{value:"Module"})),Ku=Jb(Xb);(function(t,e){var n=void 0,i=function(a){return n||(n=new Promise(function(l,m){var w=typeof a<"u"?a:{},v=w.onAbort;w.onAbort=function(o){m(new Error(o)),v&&v(o)},w.postRun=w.postRun||[],w.postRun.push(function(){l(w)}),t=void 0;var d;d||(d=typeof w<"u"?w:{}),d.onRuntimeInitialized=function(){function o(I,G){switch(typeof G){case"boolean":Mu(I,G?1:0);break;case"number":Lu(I,G);break;case"string":ha(I,G,-1,-1);break;case"object":if(G===null)fa(I);else if(G.length!=null){var s=Fs(G);Pu(I,s,G.length,-1),Fi(s)}else Qi(I,"Wrong API use : tried to return a value of an unknown type ("+G+").",-1);break;default:fa(I)}}function c(I,G){for(var s=[],u=0;u>>0),I!=null){var G=this.filename,s="/",u=G;if(s&&(s=typeof s=="string"?s:Oi(s),u=G?ue(s+"/"+G):s),G=mn(!0,!0),u=Wi(u,(G!==void 0?G:438)&4095|32768,0),I){if(typeof I=="string"){s=Array(I.length);for(var f=0,y=I.length;f{ee||(T=Ku,ee=Ku)},C=function(o,c){return Ne(),o=ee.normalize(o),T.readFileSync(o,c?void 0:"utf8")},q=o=>(o=C(o,!0),o.buffer||(o=new Uint8Array(o)),o),N=(o,c,h)=>{Ne(),o=ee.normalize(o),T.readFile(o,function(g,E){g?h(g):c(E.buffer)})},1{var c=new XMLHttpRequest;return c.open("GET",o,!1),c.send(null),c.responseText},ne&&(q=o=>{var c=new XMLHttpRequest;return c.open("GET",o,!1),c.responseType="arraybuffer",c.send(null),new Uint8Array(c.response)}),N=(o,c,h)=>{var g=new XMLHttpRequest;g.open("GET",o,!0),g.responseType="arraybuffer",g.onload=()=>{g.status==200||g.status==0&&g.response?c(g.response):h()},g.onerror=h,g.send(null)});var ae=d.print||console.log.bind(console),_e=d.printErr||console.warn.bind(console);Object.assign(d,W),W=null,d.thisProgram&&(B=d.thisProgram);var xe;d.wasmBinary&&(xe=d.wasmBinary),d.noExitRuntime,typeof WebAssembly!="object"&&x("no native wasm support detected");var tt,ze=!1,qt=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Wt(o,c,h){var g=c+h;for(h=c;o[h]&&!(h>=g);)++h;if(16E?g+=String.fromCharCode(E):(E-=65536,g+=String.fromCharCode(55296|E>>10,56320|E&1023))}}else g+=String.fromCharCode(E)}return g}function Qe(o,c){return o?Wt(Oe,o,c):""}function Kt(o,c,h,g){if(!(0=Q){var ve=o.charCodeAt(++L);Q=65536+((Q&1023)<<10)|ve&1023}if(127>=Q){if(h>=g)break;c[h++]=Q}else{if(2047>=Q){if(h+1>=g)break;c[h++]=192|Q>>6}else{if(65535>=Q){if(h+2>=g)break;c[h++]=224|Q>>12}else{if(h+3>=g)break;c[h++]=240|Q>>18,c[h++]=128|Q>>12&63}c[h++]=128|Q>>6&63}c[h++]=128|Q&63}}return c[h]=0,h-E}function dn(o){for(var c=0,h=0;h=g?c++:2047>=g?c+=2:55296<=g&&57343>=g?(c+=4,++h):c+=3}return c}var wt,ge,Oe,ut,we,Re,Pt,Ar;function Cs(){var o=tt.buffer;wt=o,d.HEAP8=ge=new Int8Array(o),d.HEAP16=ut=new Int16Array(o),d.HEAP32=we=new Int32Array(o),d.HEAPU8=Oe=new Uint8Array(o),d.HEAPU16=new Uint16Array(o),d.HEAPU32=Re=new Uint32Array(o),d.HEAPF32=Pt=new Float32Array(o),d.HEAPF64=Ar=new Float64Array(o)}var En,pn=[],fe=[],Me=[];function zn(){var o=d.preRun.shift();pn.unshift(o)}var Jt=0,Ke=null;function x(o){throw d.onAbort&&d.onAbort(o),o="Aborted("+o+")",_e(o),ze=!0,new WebAssembly.RuntimeError(o+". Build with -sASSERTIONS for more info.")}function O(){return R.startsWith("data:application/octet-stream;base64,")}var R;if(R="sql-wasm.wasm",!O()){var F=R;R=d.locateFile?d.locateFile(F,b):b+F}function K(){var o=R;try{if(o==R&&xe)return new Uint8Array(xe);if(q)return q(o);throw"both async and sync fetching of the wasm failed"}catch(c){x(c)}}function Y(){if(!xe&&(D||ne)){if(typeof fetch=="function"&&!R.startsWith("file://"))return fetch(R,{credentials:"same-origin"}).then(function(o){if(!o.ok)throw"failed to load wasm binary file at '"+R+"'";return o.arrayBuffer()}).catch(function(){return K()});if(N)return new Promise(function(o,c){N(R,function(h){o(new Uint8Array(h))},c)})}return Promise.resolve().then(function(){return K()})}var j,z;function re(o){for(;0>0];case"i8":return ge[o>>0];case"i16":return ut[o>>1];case"i32":return we[o>>2];case"i64":return we[o>>2];case"float":return Pt[o>>2];case"double":return Ar[o>>3];case"*":return Re[o>>2];default:x("invalid type for getValue: "+c)}return null}function ce(o){var c="i32";switch(c.endsWith("*")&&(c="*"),c){case"i1":ge[o>>0]=0;break;case"i8":ge[o>>0]=0;break;case"i16":ut[o>>1]=0;break;case"i32":we[o>>2]=0;break;case"i64":z=[0,(j=0,1<=+Math.abs(j)?0>>0:~~+Math.ceil((j-+(~~j>>>0))/4294967296)>>>0:0)],we[o>>2]=z[0],we[o+4>>2]=z[1];break;case"float":Pt[o>>2]=0;break;case"double":Ar[o>>3]=0;break;case"*":Re[o>>2]=0;break;default:x("invalid type for setValue: "+c)}}var oe=(o,c)=>{for(var h=0,g=o.length-1;0<=g;g--){var E=o[g];E==="."?o.splice(g,1):E===".."?(o.splice(g,1),h++):h&&(o.splice(g,1),h--)}if(c)for(;h;h--)o.unshift("..");return o},ue=o=>{var c=o.charAt(0)==="/",h=o.substr(-1)==="/";return(o=oe(o.split("/").filter(g=>!!g),!c).join("/"))||c||(o="."),o&&h&&(o+="/"),(c?"/":"")+o},be=o=>{var c=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(o).slice(1);return o=c[0],c=c[1],!o&&!c?".":(c&&(c=c.substr(0,c.length-1)),o+c)},Ee=o=>{if(o==="/")return"/";o=ue(o),o=o.replace(/\/$/,"");var c=o.lastIndexOf("/");return c===-1?o:o.substr(c+1)};function je(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var o=new Uint8Array(1);return()=>(crypto.getRandomValues(o),o[0])}if(te)try{var c=Ku;return()=>c.randomBytes(1)[0]}catch{}return()=>x("randomDevice")}function Le(){for(var o="",c=!1,h=arguments.length-1;-1<=h&&!c;h--){if(c=0<=h?arguments[h]:"/",typeof c!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!c)return"";o=c+"/"+o,c=c.charAt(0)==="/"}return o=oe(o.split("/").filter(g=>!!g),!c).join("/"),(c?"/":"")+o||"."}function it(o,c){var h=Array(dn(o)+1);return o=Kt(o,h,0,h.length),c&&(h.length=o),h}var me=[];function Cn(o,c){me[o]={input:[],output:[],Xa:c},qi(o,Ci)}var Ci={open:function(o){var c=me[o.node.rdev];if(!c)throw new H(43);o.tty=c,o.seekable=!1},close:function(o){o.tty.Xa.fsync(o.tty)},fsync:function(o){o.tty.Xa.fsync(o.tty)},read:function(o,c,h,g){if(!o.tty||!o.tty.Xa.tb)throw new H(60);for(var E=0,L=0;L=c||(c=Math.max(c,h*(1048576>h?2:1.125)>>>0),h!=0&&(c=Math.max(c,256)),h=o.Ia,o.Ia=new Uint8Array(c),0=o.node.Ma)return 0;if(o=Math.min(o.node.Ma-E,w),8c)throw new H(28);return c},lb:function(o,c,h){le.qb(o.node,c+h),o.node.Ma=Math.max(o.node.Ma,c+h)},bb:function(o,c,h,w,E){if((o.node.mode&61440)!==32768)throw new H(43);if(o=o.node.Ia,E&2||o.buffer!==wt){if((0{if(o=Le("/",o),!o)return{path:"",node:null};if(c=Object.assign({rb:!0,kb:0},c),8!!Q),!1);for(var h=Mt,w="/",E=0;E{for(var c;;){if(o===o.parent)return o=o.Ra.ub,c?o[o.length-1]!=="/"?o+"/"+c:o+c:o;c=c?o.name+"/"+c:o.name,o=o.parent}},Ws=(o,c)=>{for(var h=0,w=0;w>>0)%qn.length},kr=o=>{var c=Ws(o.parent.id,o.name);if(qn[c]===o)qn[c]=o.Wa;else for(c=qn[c];c;){if(c.Wa===o){c.Wa=o.Wa;break}c=c.Wa}},wr=(o,c)=>{var h;if(h=(h=Kr(o,"x"))?h:o.Ga.lookup?0:2)throw new H(h,o);for(h=qn[Ws(o.id,c)];h;h=h.Wa){var w=h.name;if(h.parent.id===o.id&&w===c)return h}return o.Ga.lookup(o,c)},Vo=(o,c,h,w)=>(o=new ra(o,c,h,w),c=Ws(o.parent.id,o.name),o.Wa=qn[c],qn[c]=o),Cl={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},zo=o=>{var c=["r","w","rw"][o&3];return o&512&&(c+="w"),c},Kr=(o,c)=>{if(Os)return 0;if(!c.includes("r")||o.mode&292){if(c.includes("w")&&!(o.mode&146)||c.includes("x")&&!(o.mode&73))return 2}else return 2;return 0},Is=(o,c)=>{try{return wr(o,c),20}catch{}return Kr(o,"wx")},Ko=(o,c,h)=>{try{var w=wr(o,c)}catch(E){return E.Ka}if(o=Kr(o,"wx"))return o;if(h){if((w.mode&61440)!==16384)return 54;if(w===w.parent||Oi(w)==="/")return 10}else if((w.mode&61440)===16384)return 31;return 0},Jo=(o=0)=>{for(;4096>=o;o++)if(!Dn[o])return o;throw new H(33)},On=(o,c)=>(Li||(Li=function(){this.$a={}},Li.prototype={},Object.defineProperties(Li.prototype,{object:{get:function(){return this.node},set:function(h){this.node=h}},flags:{get:function(){return this.$a.flags},set:function(h){this.$a.flags=h}},position:{get:function(){return this.$a.position},set:function(h){this.$a.position=h}}})),o=Object.assign(new Li,o),c=Jo(c),o.fd=c,Dn[c]=o),As={open:o=>{o.Ha=Z[o.node.rdev].Ha,o.Ha.open&&o.Ha.open(o)},Ta:()=>{throw new H(70)}},Wi=(o,c)=>{Z[o]={Ha:c}},Go=(o,c)=>{var h=c==="/",w=!c;if(h&&Mt)throw new H(10);if(!h&&!w){var E=Bt(c,{rb:!1});if(c=E.path,E=E.node,E.Va)throw new H(10);if((E.mode&61440)!==16384)throw new H(54)}c={type:o,Kb:{},ub:c,Eb:[]},o=o.Ra(c),o.Ra=c,c.root=o,h?Mt=o:E&&(E.Va=c,E.Ra&&E.Ra.Eb.push(c))},Ii=(o,c,h)=>{var w=Bt(o,{parent:!0}).node;if(o=Ee(o),!o||o==="."||o==="..")throw new H(28);var E=Is(w,o);if(E)throw new H(E);if(!w.Ga.ab)throw new H(63);return w.Ga.ab(w,o,c,h)},an=(o,c)=>Ii(o,(c!==void 0?c:511)&1023|16384,0),Ai=(o,c,h)=>{typeof h>"u"&&(h=c,c=438),Ii(o,c|8192,h)},Ts=(o,c)=>{if(!Le(o))throw new H(44);var h=Bt(c,{parent:!0}).node;if(!h)throw new H(44);c=Ee(c);var w=Is(h,c);if(w)throw new H(w);if(!h.Ga.symlink)throw new H(63);h.Ga.symlink(h,c,o)},Xo=o=>{var c=Bt(o,{parent:!0}).node;o=Ee(o);var h=wr(c,o),w=Ko(c,o,!0);if(w)throw new H(w);if(!c.Ga.rmdir)throw new H(63);if(h.Va)throw new H(10);c.Ga.rmdir(c,o),kr(h)},Ti=o=>{var c=Bt(o,{parent:!0}).node;if(!c)throw new H(44);o=Ee(o);var h=wr(c,o),w=Ko(c,o,!1);if(w)throw new H(w);if(!c.Ga.unlink)throw new H(63);if(h.Va)throw new H(10);c.Ga.unlink(c,o),kr(h)},Yo=o=>{if(o=Bt(o).node,!o)throw new H(44);if(!o.Ga.readlink)throw new H(28);return Le(Oi(o.parent),o.Ga.readlink(o))},Jr=(o,c)=>{if(o=Bt(o,{Sa:!c}).node,!o)throw new H(44);if(!o.Ga.Pa)throw new H(63);return o.Ga.Pa(o)},Zo=o=>Jr(o,!0),ks=(o,c)=>{if(o=typeof o=="string"?Bt(o,{Sa:!0}).node:o,!o.Ga.Oa)throw new H(63);o.Ga.Oa(o,{mode:c&4095|o.mode&-4096,timestamp:Date.now()})},Gr=(o,c)=>{if(0>c)throw new H(28);if(o=typeof o=="string"?Bt(o,{Sa:!0}).node:o,!o.Ga.Oa)throw new H(63);if((o.mode&61440)===16384)throw new H(31);if((o.mode&61440)!==32768)throw new H(28);var h=Kr(o,"w");if(h)throw new H(h);o.Ga.Oa(o,{size:c,timestamp:Date.now()})},gr=(o,c,h)=>{if(o==="")throw new H(44);if(typeof c=="string"){var w=Cl[c];if(typeof w>"u")throw Error("Unknown file open mode: "+c);c=w}if(h=c&64?(typeof h>"u"?438:h)&4095|32768:0,typeof o=="object")var E=o;else{o=ue(o);try{E=Bt(o,{Sa:!(c&131072)}).node}catch{}}if(w=!1,c&64)if(E){if(c&128)throw new H(20)}else E=Ii(o,h,0),w=!0;if(!E)throw new H(44);if((E.mode&61440)===8192&&(c&=-513),c&65536&&(E.mode&61440)!==16384)throw new H(54);if(!w&&(h=E?(E.mode&61440)===40960?32:(E.mode&61440)===16384&&(zo(c)!=="r"||c&512)?31:Kr(E,zo(c)):44))throw new H(h);return c&512&&!w&&Gr(E,0),c&=-131713,E=On({node:E,path:Oi(E),flags:c,seekable:!0,position:0,Ha:E.Ha,Ib:[],error:!1}),E.Ha.open&&E.Ha.open(E),!d.logReadFiles||c&1||(Pi||(Pi={}),o in Pi||(Pi[o]=1)),E},He=o=>{if(o.fd===null)throw new H(8);o.hb&&(o.hb=null);try{o.Ha.close&&o.Ha.close(o)}catch(c){throw c}finally{Dn[o.fd]=null}o.fd=null},Xr=(o,c,h)=>{if(o.fd===null)throw new H(8);if(!o.seekable||!o.Ha.Ta)throw new H(70);if(h!=0&&h!=1&&h!=2)throw new H(28);o.position=o.Ha.Ta(o,c,h),o.Ib=[]},ki=(o,c,h,w,E)=>{if(0>w||0>E)throw new H(28);if(o.fd===null)throw new H(8);if((o.flags&2097155)===1)throw new H(8);if((o.node.mode&61440)===16384)throw new H(31);if(!o.Ha.read)throw new H(28);var L=typeof E<"u";if(!L)E=o.position;else if(!o.seekable)throw new H(70);return c=o.Ha.read(o,c,h,w,E),L||(o.position+=c),c},br=(o,c,h,w,E)=>{if(0>w||0>E)throw new H(28);if(o.fd===null)throw new H(8);if(!(o.flags&2097155))throw new H(8);if((o.node.mode&61440)===16384)throw new H(31);if(!o.Ha.write)throw new H(28);o.seekable&&o.flags&1024&&Xr(o,0,2);var L=typeof E<"u";if(!L)E=o.position;else if(!o.seekable)throw new H(70);return c=o.Ha.write(o,c,h,w,E,void 0),L||(o.position+=c),c},Ss=o=>{var c,h=gr(o,h||0);o=Jr(o).size;var w=new Uint8Array(o);return ki(h,w,0,o,0),c=w,He(h),c},Si=()=>{H||(H=function(o,c){this.node=c,this.Hb=function(h){this.Ka=h},this.Hb(o),this.message="FS error"},H.prototype=Error(),H.prototype.constructor=H,[44].forEach(o=>{Kn[o]=new H(o),Kn[o].stack=""}))},Ri,mn=(o,c)=>{var h=0;return o&&(h|=365),c&&(h|=146),h},Ln=(o,c,h)=>{o=ue("/dev/"+o);var w=mn(!!c,!!h);Di||(Di=64);var E=Di++<<8|0;Wi(E,{open:L=>{L.seekable=!1},close:()=>{h&&h.buffer&&h.buffer.length&&h(10)},read:(L,Q,ve,Pe)=>{for(var De=0,ct=0;ct{for(var De=0;De>2]=w.dev,we[h+8>>2]=w.ino,we[h+12>>2]=w.mode,Re[h+16>>2]=w.nlink,we[h+20>>2]=w.uid,we[h+24>>2]=w.gid,we[h+28>>2]=w.rdev,z=[w.size>>>0,(j=w.size,1<=+Math.abs(j)?0>>0:~~+Math.ceil((j-+(~~j>>>0))/4294967296)>>>0:0)],we[h+40>>2]=z[0],we[h+44>>2]=z[1],we[h+48>>2]=4096,we[h+52>>2]=w.blocks,z=[Math.floor(w.atime.getTime()/1e3)>>>0,(j=Math.floor(w.atime.getTime()/1e3),1<=+Math.abs(j)?0>>0:~~+Math.ceil((j-+(~~j>>>0))/4294967296)>>>0:0)],we[h+56>>2]=z[0],we[h+60>>2]=z[1],Re[h+64>>2]=0,z=[Math.floor(w.mtime.getTime()/1e3)>>>0,(j=Math.floor(w.mtime.getTime()/1e3),1<=+Math.abs(j)?0>>0:~~+Math.ceil((j-+(~~j>>>0))/4294967296)>>>0:0)],we[h+72>>2]=z[0],we[h+76>>2]=z[1],Re[h+80>>2]=0,z=[Math.floor(w.ctime.getTime()/1e3)>>>0,(j=Math.floor(w.ctime.getTime()/1e3),1<=+Math.abs(j)?0>>0:~~+Math.ceil((j-+(~~j>>>0))/4294967296)>>>0:0)],we[h+88>>2]=z[0],we[h+92>>2]=z[1],Re[h+96>>2]=0,z=[w.ino>>>0,(j=w.ino,1<=+Math.abs(j)?0>>0:~~+Math.ceil((j-+(~~j>>>0))/4294967296)>>>0:0)],we[h+104>>2]=z[0],we[h+108>>2]=z[1],0}var Yr=void 0;function Bi(){return Yr+=4,we[Yr-4>>2]}function yn(o){if(o=Dn[o],!o)throw new H(8);return o}function Rs(o){return Re[o>>2]+4294967296*we[o+4>>2]}function ea(o){var c=dn(o)+1,h=Fi(c);return h&&Kt(o,ge,h,c),h}function vu(o,c,h){function w(Pe){return(Pe=Pe.toTimeString().match(/\(([A-Za-z ]+)\)$/))?Pe[1]:"GMT"}var E=new Date().getFullYear(),L=new Date(E,0,1),Q=new Date(E,6,1);E=L.getTimezoneOffset();var ve=Q.getTimezoneOffset();we[o>>2]=60*Math.max(E,ve),we[c>>2]=+(E!=ve),o=w(L),c=w(Q),o=ea(o),c=ea(c),ve>2]=o,Re[h+4>>2]=c):(Re[h>>2]=c,Re[h+4>>2]=o)}function Ds(o,c,h){Ds.Bb||(Ds.Bb=!0,vu(o,c,h))}var ta;ta=te?()=>{var o=process.hrtime();return 1e3*o[0]+o[1]/1e6}:()=>performance.now();var Ls={};function na(){if(!Ps){var o={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:B||"./this.program"},c;for(c in Ls)Ls[c]===void 0?delete o[c]:o[c]=Ls[c];var h=[];for(c in o)h.push(c+"="+o[c]);Ps=h}return Ps}var Ps,Gn=void 0,Ms=[];function Bs(o,c){if(!Gn){Gn=new WeakMap;var h=En.length;if(Gn)for(var w=0;w<0+h;w++){var E=En.get(w);E&&Gn.set(E,w)}}if(Gn.has(o))return Gn.get(o);if(Ms.length)h=Ms.pop();else{try{En.grow(1)}catch(ve){throw ve instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":ve}h=En.length-1}try{En.set(h,o)}catch(ve){if(!(ve instanceof TypeError))throw ve;if(typeof WebAssembly.Function=="function"){w=WebAssembly.Function,E={i:"i32",j:"i64",f:"f32",d:"f64",p:"i32"};for(var L={parameters:[],results:c[0]=="v"?[]:[E[c[0]]]},Q=1;QQ?w.push(Q):w.push(Q%128|128,Q>>7),Q=0;QE?c.push(E):c.push(E%128|128,E>>7),c.push.apply(c,w),c.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),c=new WebAssembly.Module(new Uint8Array(c)),c=new WebAssembly.Instance(c,{e:{f:o}}).exports.f}En.set(h,c)}return Gn.set(o,h),h}function Zr(o){Gn.delete(En.get(o)),Ms.push(o)}function Fs(o){var c=Fi(o.length);return o.subarray||o.slice||(o=new Uint8Array(o)),qe.set(o,c),c}function _u(o,c,h,w){var E={string:De=>{var ct=0;if(De!=null&&De!==0){var Pn=(De.length<<2)+1;ct=Xn(Pn),Kt(De,qe,ct,Pn)}return ct},array:De=>{var ct=Xn(De.length);return ge.set(De,ct),ct}};o=d["_"+o];var L=[],Q=0;if(w)for(var ve=0;ve{an("/dev"),Wi(259,{read:()=>0,write:(c,h,w,E)=>E}),Ai("/dev/null",259),Cn(1280,Gt),Cn(1536,qs),Ai("/dev/tty",1280),Ai("/dev/tty1",1536);var o=je();Ln("random",o),Ln("urandom",o),an("/dev/shm"),an("/dev/shm/tmp")})(),(()=>{an("/proc");var o=an("/proc/self");an("/proc/self/fd"),Go({Ra:()=>{var c=Vo(o,"fd",16895,73);return c.Ga={lookup:(h,w)=>{var E=Dn[+w];if(!E)throw new H(8);return h={parent:null,Ra:{ub:"fake"},Ga:{readlink:()=>E.path}},h.parent=h}},c}},"/proc/self/fd")})();var xu={a:function(o,c,h,w){x("Assertion failed: "+Qe(o)+", at: "+[c?Qe(c):"unknown filename",h,w?Qe(w):"unknown function"])},h:function(o,c){try{return o=Qe(o),ks(o,c),0}catch(h){if(typeof Je>"u"||!(h instanceof H))throw h;return-h.Ka}},H:function(o,c,h){try{if(c=Qe(c),c=Jn(o,c),h&-8)return-28;var w=Bt(c,{Sa:!0}).node;return w?(o="",h&4&&(o+="r"),h&2&&(o+="w"),h&1&&(o+="x"),o&&Kr(w,o)?-2:0):-44}catch(E){if(typeof Je>"u"||!(E instanceof H))throw E;return-E.Ka}},i:function(o,c){try{var h=Dn[o];if(!h)throw new H(8);return ks(h.node,c),0}catch(w){if(typeof Je>"u"||!(w instanceof H))throw w;return-w.Ka}},g:function(o){try{var c=Dn[o];if(!c)throw new H(8);var h=c.node,w=typeof h=="string"?Bt(h,{Sa:!0}).node:h;if(!w.Ga.Oa)throw new H(63);return w.Ga.Oa(w,{timestamp:Date.now()}),0}catch(E){if(typeof Je>"u"||!(E instanceof H))throw E;return-E.Ka}},b:function(o,c,h){Yr=h;try{var w=yn(o);switch(c){case 0:var E=Bi();return 0>E?-28:On(w,E).fd;case 1:case 2:return 0;case 3:return w.flags;case 4:return E=Bi(),w.flags|=E,0;case 5:return E=Bi(),ut[E+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return we[ia()>>2]=28,-1;default:return-28}}catch(L){if(typeof Je>"u"||!(L instanceof H))throw L;return-L.Ka}},G:function(o,c){try{var h=yn(o);return Mi(Jr,h.path,c)}catch(w){if(typeof Je>"u"||!(w instanceof H))throw w;return-w.Ka}},l:function(o,c,h){try{if(c=h+2097152>>>0<4194305-!!c?(c>>>0)+4294967296*h:NaN,isNaN(c))return-61;var w=Dn[o];if(!w)throw new H(8);if(!(w.flags&2097155))throw new H(28);return Gr(w.node,c),0}catch(E){if(typeof Je>"u"||!(E instanceof H))throw E;return-E.Ka}},B:function(o,c){try{if(c===0)return-28;var h=dn("/")+1;return c"u"||!(w instanceof H))throw w;return-w.Ka}},E:function(o,c){try{return o=Qe(o),Mi(Zo,o,c)}catch(h){if(typeof Je>"u"||!(h instanceof H))throw h;return-h.Ka}},y:function(o,c,h){try{return c=Qe(c),c=Jn(o,c),c=ue(c),c[c.length-1]==="/"&&(c=c.substr(0,c.length-1)),an(c,h),0}catch(w){if(typeof Je>"u"||!(w instanceof H))throw w;return-w.Ka}},D:function(o,c,h,w){try{c=Qe(c);var E=w&256;return c=Jn(o,c,w&4096),Mi(E?Zo:Jr,c,h)}catch(L){if(typeof Je>"u"||!(L instanceof H))throw L;return-L.Ka}},v:function(o,c,h,w){Yr=w;try{c=Qe(c),c=Jn(o,c);var E=w?Bi():0;return gr(c,h,E).fd}catch(L){if(typeof Je>"u"||!(L instanceof H))throw L;return-L.Ka}},t:function(o,c,h,w){try{if(c=Qe(c),c=Jn(o,c),0>=w)return-28;var E=Yo(c),L=Math.min(w,dn(E)),Q=ge[h+L];return Kt(E,qe,h,w+1),ge[h+L]=Q,L}catch(ve){if(typeof Je>"u"||!(ve instanceof H))throw ve;return-ve.Ka}},s:function(o){try{return o=Qe(o),Xo(o),0}catch(c){if(typeof Je>"u"||!(c instanceof H))throw c;return-c.Ka}},F:function(o,c){try{return o=Qe(o),Mi(Jr,o,c)}catch(h){if(typeof Je>"u"||!(h instanceof H))throw h;return-h.Ka}},p:function(o,c,h){try{return c=Qe(c),c=Jn(o,c),h===0?Ti(c):h===512?Xo(c):x("Invalid flags passed to unlinkat"),0}catch(w){if(typeof Je>"u"||!(w instanceof H))throw w;return-w.Ka}},o:function(o,c,h){try{if(c=Qe(c),c=Jn(o,c,!0),h){var w=Rs(h),E=we[h+8>>2];L=1e3*w+E/1e6,h+=16,w=Rs(h),E=we[h+8>>2],Q=1e3*w+E/1e6}else var L=Date.now(),Q=L;o=L;var ve=Bt(c,{Sa:!0}).node;return ve.Ga.Oa(ve,{timestamp:Math.max(o,Q)}),0}catch(Pe){if(typeof Je>"u"||!(Pe instanceof H))throw Pe;return-Pe.Ka}},e:function(){return Date.now()},j:function(o,c){o=new Date(1e3*Rs(o)),we[c>>2]=o.getSeconds(),we[c+4>>2]=o.getMinutes(),we[c+8>>2]=o.getHours(),we[c+12>>2]=o.getDate(),we[c+16>>2]=o.getMonth(),we[c+20>>2]=o.getFullYear()-1900,we[c+24>>2]=o.getDay();var h=new Date(o.getFullYear(),0,1);we[c+28>>2]=(o.getTime()-h.getTime())/864e5|0,we[c+36>>2]=-(60*o.getTimezoneOffset());var w=new Date(o.getFullYear(),6,1).getTimezoneOffset();h=h.getTimezoneOffset(),we[c+32>>2]=(w!=h&&o.getTimezoneOffset()==Math.min(h,w))|0},w:function(o,c,h,w,E,L){try{var Q=yn(w);if(c&2&&!(h&2)&&(Q.flags&2097155)!==2)throw new H(2);if((Q.flags&2097155)===1)throw new H(2);if(!Q.Ha.bb)throw new H(43);var ve=Q.Ha.bb(Q,o,E,c,h),Pe=ve.Fb;return we[L>>2]=ve.vb,Pe}catch(De){if(typeof Je>"u"||!(De instanceof H))throw De;return-De.Ka}},x:function(o,c,h,w,E,L){try{var Q=yn(E);if(h&2){var ve=qe.slice(o,o+c);Q&&Q.Ha.cb&&Q.Ha.cb(Q,ve,L,c,w)}}catch(Pe){if(typeof Je>"u"||!(Pe instanceof H))throw Pe;return-Pe.Ka}},n:Ds,q:function(){return 2147483648},d:ta,c:function(o){var c=qe.length;if(o>>>=0,2147483648=h;h*=2){var w=c*(1+.2/h);w=Math.min(w,o+100663296);var E=Math;w=Math.max(o,w),E=E.min.call(E,2147483648,w+(65536-w%65536)%65536);e:{try{tt.grow(E-wt.byteLength+65535>>>16),Cs();var L=1;break e}catch{}L=void 0}if(L)return!0}return!1},z:function(o,c){var h=0;return na().forEach(function(w,E){var L=c+h;for(E=Re[o+4*E>>2]=L,L=0;L>0]=w.charCodeAt(L);ge[E>>0]=0,h+=w.length+1}),0},A:function(o,c){var h=na();Re[o>>2]=h.length;var w=0;return h.forEach(function(E){w+=E.length+1}),Re[c>>2]=w,0},f:function(o){try{var c=yn(o);return He(c),0}catch(h){if(typeof Je>"u"||!(h instanceof H))throw h;return h.Ka}},m:function(o,c){try{var h=yn(o);return ge[c>>0]=h.tty?2:(h.mode&61440)===16384?3:(h.mode&61440)===40960?7:4,0}catch(w){if(typeof Je>"u"||!(w instanceof H))throw w;return w.Ka}},u:function(o,c,h,w){try{e:{var E=yn(o);o=c;for(var L=c=0;L>2],ve=Re[o+4>>2];o+=8;var Pe=ki(E,ge,Q,ve);if(0>Pe){var De=-1;break e}if(c+=Pe,Pe>2]=De,0}catch(ct){if(typeof Je>"u"||!(ct instanceof H))throw ct;return ct.Ka}},k:function(o,c,h,w,E){try{if(c=h+2097152>>>0<4194305-!!c?(c>>>0)+4294967296*h:NaN,isNaN(c))return 61;var L=yn(o);return Xr(L,c,w),z=[L.position>>>0,(j=L.position,1<=+Math.abs(j)?0>>0:~~+Math.ceil((j-+(~~j>>>0))/4294967296)>>>0:0)],we[E>>2]=z[0],we[E+4>>2]=z[1],L.hb&&c===0&&w===0&&(L.hb=null),0}catch(Q){if(typeof Je>"u"||!(Q instanceof H))throw Q;return Q.Ka}},C:function(o){try{var c=yn(o);return c.Ha&&c.Ha.fsync?c.Ha.fsync(c):0}catch(h){if(typeof Je>"u"||!(h instanceof H))throw h;return h.Ka}},r:function(o,c,h,w){try{e:{var E=yn(o);o=c;for(var L=c=0;L>2],ve=Re[o+4>>2];o+=8;var Pe=br(E,ge,Q,ve);if(0>Pe){var De=-1;break e}c+=Pe}De=c}return Re[w>>2]=De,0}catch(ct){if(typeof Je>"u"||!(ct instanceof H))throw ct;return ct.Ka}}};(function(){function o(E){d.asm=E.exports,tt=d.asm.I,Cs(),En=d.asm.Aa,fe.unshift(d.asm.J),Jt--,d.monitorRunDependencies&&d.monitorRunDependencies(Jt),Jt==0&&Ke&&(E=Ke,Ke=null,E())}function c(E){o(E.instance)}function h(E){return Y().then(function(L){return WebAssembly.instantiate(L,w)}).then(function(L){return L}).then(E,function(L){_e("failed to asynchronously prepare wasm: "+L),x(L)})}var w={a:xu};if(Jt++,d.monitorRunDependencies&&d.monitorRunDependencies(Jt),d.instantiateWasm)try{return d.instantiateWasm(w,o)}catch(E){return _e("Module.instantiateWasm callback failed with error: "+E),!1}return function(){return xe||typeof WebAssembly.instantiateStreaming!="function"||q()||R.startsWith("file://")||te||typeof fetch!="function"?h(c):fetch(R,{credentials:"same-origin"}).then(function(E){return WebAssembly.instantiateStreaming(E,w).then(c,function(L){return _e("wasm streaming compile failed: "+L),_e("falling back to ArrayBuffer instantiation"),h(c)})})}(),{}})(),d.___wasm_call_ctors=function(){return(d.___wasm_call_ctors=d.asm.J).apply(null,arguments)},d._sqlite3_free=function(){return(d._sqlite3_free=d.asm.K).apply(null,arguments)},d._sqlite3_value_double=function(){return(d._sqlite3_value_double=d.asm.L).apply(null,arguments)},d._sqlite3_value_text=function(){return(d._sqlite3_value_text=d.asm.M).apply(null,arguments)};var ia=d.___errno_location=function(){return(ia=d.___errno_location=d.asm.N).apply(null,arguments)};d._sqlite3_prepare_v2=function(){return(d._sqlite3_prepare_v2=d.asm.O).apply(null,arguments)},d._sqlite3_step=function(){return(d._sqlite3_step=d.asm.P).apply(null,arguments)},d._sqlite3_finalize=function(){return(d._sqlite3_finalize=d.asm.Q).apply(null,arguments)},d._sqlite3_reset=function(){return(d._sqlite3_reset=d.asm.R).apply(null,arguments)},d._sqlite3_value_int=function(){return(d._sqlite3_value_int=d.asm.S).apply(null,arguments)},d._sqlite3_clear_bindings=function(){return(d._sqlite3_clear_bindings=d.asm.T).apply(null,arguments)},d._sqlite3_value_blob=function(){return(d._sqlite3_value_blob=d.asm.U).apply(null,arguments)},d._sqlite3_value_bytes=function(){return(d._sqlite3_value_bytes=d.asm.V).apply(null,arguments)},d._sqlite3_value_type=function(){return(d._sqlite3_value_type=d.asm.W).apply(null,arguments)},d._sqlite3_result_blob=function(){return(d._sqlite3_result_blob=d.asm.X).apply(null,arguments)},d._sqlite3_result_double=function(){return(d._sqlite3_result_double=d.asm.Y).apply(null,arguments)},d._sqlite3_result_error=function(){return(d._sqlite3_result_error=d.asm.Z).apply(null,arguments)},d._sqlite3_result_int=function(){return(d._sqlite3_result_int=d.asm._).apply(null,arguments)},d._sqlite3_result_int64=function(){return(d._sqlite3_result_int64=d.asm.$).apply(null,arguments)},d._sqlite3_result_null=function(){return(d._sqlite3_result_null=d.asm.aa).apply(null,arguments)},d._sqlite3_result_text=function(){return(d._sqlite3_result_text=d.asm.ba).apply(null,arguments)},d._sqlite3_sql=function(){return(d._sqlite3_sql=d.asm.ca).apply(null,arguments)},d._sqlite3_aggregate_context=function(){return(d._sqlite3_aggregate_context=d.asm.da).apply(null,arguments)},d._sqlite3_column_count=function(){return(d._sqlite3_column_count=d.asm.ea).apply(null,arguments)},d._sqlite3_data_count=function(){return(d._sqlite3_data_count=d.asm.fa).apply(null,arguments)},d._sqlite3_column_blob=function(){return(d._sqlite3_column_blob=d.asm.ga).apply(null,arguments)},d._sqlite3_column_bytes=function(){return(d._sqlite3_column_bytes=d.asm.ha).apply(null,arguments)},d._sqlite3_column_double=function(){return(d._sqlite3_column_double=d.asm.ia).apply(null,arguments)},d._sqlite3_column_text=function(){return(d._sqlite3_column_text=d.asm.ja).apply(null,arguments)},d._sqlite3_column_type=function(){return(d._sqlite3_column_type=d.asm.ka).apply(null,arguments)},d._sqlite3_column_name=function(){return(d._sqlite3_column_name=d.asm.la).apply(null,arguments)},d._sqlite3_bind_blob=function(){return(d._sqlite3_bind_blob=d.asm.ma).apply(null,arguments)},d._sqlite3_bind_double=function(){return(d._sqlite3_bind_double=d.asm.na).apply(null,arguments)},d._sqlite3_bind_int=function(){return(d._sqlite3_bind_int=d.asm.oa).apply(null,arguments)},d._sqlite3_bind_text=function(){return(d._sqlite3_bind_text=d.asm.pa).apply(null,arguments)},d._sqlite3_bind_parameter_index=function(){return(d._sqlite3_bind_parameter_index=d.asm.qa).apply(null,arguments)},d._sqlite3_normalized_sql=function(){return(d._sqlite3_normalized_sql=d.asm.ra).apply(null,arguments)},d._sqlite3_errmsg=function(){return(d._sqlite3_errmsg=d.asm.sa).apply(null,arguments)},d._sqlite3_exec=function(){return(d._sqlite3_exec=d.asm.ta).apply(null,arguments)},d._sqlite3_changes=function(){return(d._sqlite3_changes=d.asm.ua).apply(null,arguments)},d._sqlite3_close_v2=function(){return(d._sqlite3_close_v2=d.asm.va).apply(null,arguments)},d._sqlite3_create_function_v2=function(){return(d._sqlite3_create_function_v2=d.asm.wa).apply(null,arguments)},d._sqlite3_open=function(){return(d._sqlite3_open=d.asm.xa).apply(null,arguments)};var Fi=d._malloc=function(){return(Fi=d._malloc=d.asm.ya).apply(null,arguments)},Ui=d._free=function(){return(Ui=d._free=d.asm.za).apply(null,arguments)};d._RegisterExtensionFunctions=function(){return(d._RegisterExtensionFunctions=d.asm.Ba).apply(null,arguments)};var sa=d._emscripten_builtin_memalign=function(){return(sa=d._emscripten_builtin_memalign=d.asm.Ca).apply(null,arguments)},ei=d.stackSave=function(){return(ei=d.stackSave=d.asm.Da).apply(null,arguments)},ti=d.stackRestore=function(){return(ti=d.stackRestore=d.asm.Ea).apply(null,arguments)},Xn=d.stackAlloc=function(){return(Xn=d.stackAlloc=d.asm.Fa).apply(null,arguments)};d.UTF8ToString=Qe,d.stackAlloc=Xn,d.stackSave=ei,d.stackRestore=ti,d.cwrap=function(o,c,h,w){h=h||[];var E=h.every(L=>L==="number"||L==="boolean");return c!=="string"&&E&&!w?d["_"+o]:function(){return _u(o,c,h,arguments)}};var $i;Ke=function o(){$i||oa(),$i||(Ke=o)};function oa(){function o(){if(!$i&&($i=!0,d.calledRun=!0,!ze)){if(d.noFSInit||Ri||(Ri=!0,Si(),d.stdin=d.stdin,d.stdout=d.stdout,d.stderr=d.stderr,d.stdin?Ln("stdin",d.stdin):Ts("/dev/tty","/dev/stdin"),d.stdout?Ln("stdout",null,d.stdout):Ts("/dev/tty","/dev/stdout"),d.stderr?Ln("stderr",null,d.stderr):Ts("/dev/tty1","/dev/stderr"),gr("/dev/stdin",0),gr("/dev/stdout",1),gr("/dev/stderr",1)),Os=!1,re(fe),d.onRuntimeInitialized&&d.onRuntimeInitialized(),d.postRun)for(typeof d.postRun=="function"&&(d.postRun=[d.postRun]);d.postRun.length;){var c=d.postRun.shift();Me.unshift(c)}re(Me)}}if(!(0=this._size)return 0;const i=this._data.subarray(e,Math.min(this._size,e+n.length));return n.set(i),i.length}reserve(e){if(this._data.length>=e)return;const n=e-this._data.length,i=Math.min(rN,Math.max(nN,this._data.length)),a=new Uint8Array(this._data.length+Math.max(i,n));a.set(this._data),this._data=a}write(e,n){return this.reserve(e+n.length),this._data.set(n,e),this._size=Math.max(this._size,e+n.length),n.length}truncate(e){this._size=e}toUint8Array(){return this._data.subarray(0,this._size)}}const sN=self.indexedDB||window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB||window.shimIndexedDB,Gf=new Promise((t,e)=>{const n=sN.open(tN,1);n.onupgradeneeded=()=>n.result.createObjectStore("files",{keyPath:"name"}),n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error)});async function oN(t){const e=await Gf,n=await new Promise((i,a)=>{const m=e.transaction("files","readonly").objectStore("files").get(t);m.onsuccess=()=>i(m.result),m.onerror=()=>a(m.error)});if(n&&!Gs.has(t)){const i=new iN(n.data);return Gs.set(t,i),i}else return Gs.has(t)?Gs.get(t):null}async function aN(t,e){const n=await Gf;await new Promise((i,a)=>{const m=n.transaction("files","readwrite").objectStore("files").put({name:t,data:e});m.onsuccess=()=>i(!0),m.onerror=()=>a(m.error)})}async function zh(t){const e=await Gf;await new Promise((n,i)=>{const l=e.transaction("files","readwrite").objectStore("files").delete(t);l.onsuccess=()=>n(!0),l.onerror=()=>i(l.error)})}async function uN(t,e){if(await aN(t,e),Gs.has(t)){const n=Gs.get(t);n.truncate(0),n.write(0,e)}}var cN=t=>t==null||typeof t=="bigint"||typeof t=="number"||typeof t=="object"&&"buffer"in t?t:typeof t=="boolean"?`${t}`:t instanceof Date?t.toISOString():JSON.stringify(t),lN=t=>{if(t==null||typeof t=="bigint"||typeof t=="number"||typeof t=="object"&&"buffer"in t)return t;if(typeof t=="string"){const e=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?$/;if(/^(true|false)$/.test(t))return t==="true";if(e.test(t))return new Date(t);try{return JSON.parse(t,(n,i)=>typeof i=="string"&&e.exec(i)?new Date(i):i)}catch{}}return t},ms,dd,fN=(dd=class extends Vf{constructor(e){super();k(this,ms,void 0);P(this,ms,e||cN)}transformPrimitiveValueList(e){return{...e,values:e.values.map(r(this,ms))}}transformColumnUpdate(e){const{value:n}=e;if(n.kind!=="ValueNode")return super.transformColumnUpdate(e);const{value:i,...a}=n,l=r(this,ms).call(this,i);return i===l?super.transformColumnUpdate(e):super.transformColumnUpdate({...e,value:{...a,value:l}})}transformValue(e){return{...e,value:r(this,ms).call(this,e.value)}}},ms=new WeakMap,dd),au,uu,Oo,pd,hN=(pd=class{constructor(t={}){k(this,au,void 0);k(this,uu,void 0);k(this,Oo,void 0);P(this,au,new fN(t.serializer)),P(this,uu,t.deserializer||lN),P(this,Oo,new WeakMap)}transformQuery(t){const{node:e,queryId:n}=t;return e.kind==="SelectQueryNode"&&r(this,Oo).set(n,e.kind),r(this,au).transformNode(t.node)}async parseResult(t){return await Promise.all(t.map(async e=>{const n={...e};for(const i in n)n[i]=await r(this,uu).call(this,n[i]);return n}))}async transformResult(t){const{result:e,queryId:n}=t,{rows:i}=e,a=r(this,Oo).get(n);return i&&a==="SelectQueryNode"?{...t.result,rows:await this.parseResult(i)}:t.result}},au=new WeakMap,uu=new WeakMap,Oo=new WeakMap,pd);function Ul(t){return typeof t=="string"}function dN(t){return typeof t=="boolean"}async function Kh(t,e,n,i,a="rowid"){await Sn` - create trigger if not exists ${Sn.raw(e)}_${Sn.raw(i)} - after ${Sn.raw(n)} - on ${Sn.table(e)} +`));if(!c)return null;o.input=it(c,!0)}return o.input.shift()},jb:function(o,c){c===null||c===10?(ae(Wt(o.output,0)),o.output=[]):c!=0&&o.output.push(c)},fsync:function(o){o.output&&0=c||(c=Math.max(c,h*(1048576>h?2:1.125)>>>0),h!=0&&(c=Math.max(c,256)),h=o.Ia,o.Ia=new Uint8Array(c),0=o.node.Ma)return 0;if(o=Math.min(o.node.Ma-E,g),8c)throw new H(28);return c},lb:function(o,c,h){le.qb(o.node,c+h),o.node.Ma=Math.max(o.node.Ma,c+h)},bb:function(o,c,h,g,E){if((o.node.mode&61440)!==32768)throw new H(43);if(o=o.node.Ia,E&2||o.buffer!==wt){if((0{if(o=Le("/",o),!o)return{path:"",node:null};if(c=Object.assign({rb:!0,kb:0},c),8!!Q),!1);for(var h=Mt,g="/",E=0;E{for(var c;;){if(o===o.parent)return o=o.Ra.ub,c?o[o.length-1]!=="/"?o+"/"+c:o+c:o;c=c?o.name+"/"+c:o.name,o=o.parent}},Ws=(o,c)=>{for(var h=0,g=0;g>>0)%On.length},Tr=o=>{var c=Ws(o.parent.id,o.name);if(On[c]===o)On[c]=o.Wa;else for(c=On[c];c;){if(c.Wa===o){c.Wa=o.Wa;break}c=c.Wa}},yr=(o,c)=>{var h;if(h=(h=zr(o,"x"))?h:o.Ga.lookup?0:2)throw new H(h,o);for(h=On[Ws(o.id,c)];h;h=h.Wa){var g=h.name;if(h.parent.id===o.id&&g===c)return h}return o.Ga.lookup(o,c)},Ho=(o,c,h,g)=>(o=new na(o,c,h,g),c=Ws(o.parent.id,o.name),o.Wa=On[c],On[c]=o),Cl={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Vo=o=>{var c=["r","w","rw"][o&3];return o&512&&(c+="w"),c},zr=(o,c)=>{if(qs)return 0;if(!c.includes("r")||o.mode&292){if(c.includes("w")&&!(o.mode&146)||c.includes("x")&&!(o.mode&73))return 2}else return 2;return 0},Is=(o,c)=>{try{return yr(o,c),20}catch{}return zr(o,"wx")},zo=(o,c,h)=>{try{var g=yr(o,c)}catch(E){return E.Ka}if(o=zr(o,"wx"))return o;if(h){if((g.mode&61440)!==16384)return 54;if(g===g.parent||Oi(g)==="/")return 10}else if((g.mode&61440)===16384)return 31;return 0},Ko=(o=0)=>{for(;4096>=o;o++)if(!Dn[o])return o;throw new H(33)},qn=(o,c)=>(Di||(Di=function(){this.$a={}},Di.prototype={},Object.defineProperties(Di.prototype,{object:{get:function(){return this.node},set:function(h){this.node=h}},flags:{get:function(){return this.$a.flags},set:function(h){this.$a.flags=h}},position:{get:function(){return this.$a.position},set:function(h){this.$a.position=h}}})),o=Object.assign(new Di,o),c=Ko(c),o.fd=c,Dn[c]=o),As={open:o=>{o.Ha=Z[o.node.rdev].Ha,o.Ha.open&&o.Ha.open(o)},Ta:()=>{throw new H(70)}},qi=(o,c)=>{Z[o]={Ha:c}},Jo=(o,c)=>{var h=c==="/",g=!c;if(h&&Mt)throw new H(10);if(!h&&!g){var E=Bt(c,{rb:!1});if(c=E.path,E=E.node,E.Va)throw new H(10);if((E.mode&61440)!==16384)throw new H(54)}c={type:o,Kb:{},ub:c,Eb:[]},o=o.Ra(c),o.Ra=c,c.root=o,h?Mt=o:E&&(E.Va=c,E.Ra&&E.Ra.Eb.push(c))},Wi=(o,c,h)=>{var g=Bt(o,{parent:!0}).node;if(o=Ee(o),!o||o==="."||o==="..")throw new H(28);var E=Is(g,o);if(E)throw new H(E);if(!g.Ga.ab)throw new H(63);return g.Ga.ab(g,o,c,h)},an=(o,c)=>Wi(o,(c!==void 0?c:511)&1023|16384,0),Ii=(o,c,h)=>{typeof h>"u"&&(h=c,c=438),Wi(o,c|8192,h)},Ts=(o,c)=>{if(!Le(o))throw new H(44);var h=Bt(c,{parent:!0}).node;if(!h)throw new H(44);c=Ee(c);var g=Is(h,c);if(g)throw new H(g);if(!h.Ga.symlink)throw new H(63);h.Ga.symlink(h,c,o)},Go=o=>{var c=Bt(o,{parent:!0}).node;o=Ee(o);var h=yr(c,o),g=zo(c,o,!0);if(g)throw new H(g);if(!c.Ga.rmdir)throw new H(63);if(h.Va)throw new H(10);c.Ga.rmdir(c,o),Tr(h)},Ai=o=>{var c=Bt(o,{parent:!0}).node;if(!c)throw new H(44);o=Ee(o);var h=yr(c,o),g=zo(c,o,!1);if(g)throw new H(g);if(!c.Ga.unlink)throw new H(63);if(h.Va)throw new H(10);c.Ga.unlink(c,o),Tr(h)},Xo=o=>{if(o=Bt(o).node,!o)throw new H(44);if(!o.Ga.readlink)throw new H(28);return Le(Oi(o.parent),o.Ga.readlink(o))},Kr=(o,c)=>{if(o=Bt(o,{Sa:!c}).node,!o)throw new H(44);if(!o.Ga.Pa)throw new H(63);return o.Ga.Pa(o)},Yo=o=>Kr(o,!0),Ss=(o,c)=>{if(o=typeof o=="string"?Bt(o,{Sa:!0}).node:o,!o.Ga.Oa)throw new H(63);o.Ga.Oa(o,{mode:c&4095|o.mode&-4096,timestamp:Date.now()})},Jr=(o,c)=>{if(0>c)throw new H(28);if(o=typeof o=="string"?Bt(o,{Sa:!0}).node:o,!o.Ga.Oa)throw new H(63);if((o.mode&61440)===16384)throw new H(31);if((o.mode&61440)!==32768)throw new H(28);var h=zr(o,"w");if(h)throw new H(h);o.Ga.Oa(o,{size:c,timestamp:Date.now()})},wr=(o,c,h)=>{if(o==="")throw new H(44);if(typeof c=="string"){var g=Cl[c];if(typeof g>"u")throw Error("Unknown file open mode: "+c);c=g}if(h=c&64?(typeof h>"u"?438:h)&4095|32768:0,typeof o=="object")var E=o;else{o=ue(o);try{E=Bt(o,{Sa:!(c&131072)}).node}catch{}}if(g=!1,c&64)if(E){if(c&128)throw new H(20)}else E=Wi(o,h,0),g=!0;if(!E)throw new H(44);if((E.mode&61440)===8192&&(c&=-513),c&65536&&(E.mode&61440)!==16384)throw new H(54);if(!g&&(h=E?(E.mode&61440)===40960?32:(E.mode&61440)===16384&&(Vo(c)!=="r"||c&512)?31:zr(E,Vo(c)):44))throw new H(h);return c&512&&!g&&Jr(E,0),c&=-131713,E=qn({node:E,path:Oi(E),flags:c,seekable:!0,position:0,Ha:E.Ha,Ib:[],error:!1}),E.Ha.open&&E.Ha.open(E),!d.logReadFiles||c&1||(Li||(Li={}),o in Li||(Li[o]=1)),E},He=o=>{if(o.fd===null)throw new H(8);o.hb&&(o.hb=null);try{o.Ha.close&&o.Ha.close(o)}catch(c){throw c}finally{Dn[o.fd]=null}o.fd=null},Gr=(o,c,h)=>{if(o.fd===null)throw new H(8);if(!o.seekable||!o.Ha.Ta)throw new H(70);if(h!=0&&h!=1&&h!=2)throw new H(28);o.position=o.Ha.Ta(o,c,h),o.Ib=[]},Ti=(o,c,h,g,E)=>{if(0>g||0>E)throw new H(28);if(o.fd===null)throw new H(8);if((o.flags&2097155)===1)throw new H(8);if((o.node.mode&61440)===16384)throw new H(31);if(!o.Ha.read)throw new H(28);var L=typeof E<"u";if(!L)E=o.position;else if(!o.seekable)throw new H(70);return c=o.Ha.read(o,c,h,g,E),L||(o.position+=c),c},gr=(o,c,h,g,E)=>{if(0>g||0>E)throw new H(28);if(o.fd===null)throw new H(8);if(!(o.flags&2097155))throw new H(8);if((o.node.mode&61440)===16384)throw new H(31);if(!o.Ha.write)throw new H(28);o.seekable&&o.flags&1024&&Gr(o,0,2);var L=typeof E<"u";if(!L)E=o.position;else if(!o.seekable)throw new H(70);return c=o.Ha.write(o,c,h,g,E,void 0),L||(o.position+=c),c},ks=o=>{var c,h=wr(o,h||0);o=Kr(o).size;var g=new Uint8Array(o);return Ti(h,g,0,o,0),c=g,He(h),c},Si=()=>{H||(H=function(o,c){this.node=c,this.Hb=function(h){this.Ka=h},this.Hb(o),this.message="FS error"},H.prototype=Error(),H.prototype.constructor=H,[44].forEach(o=>{Kn[o]=new H(o),Kn[o].stack=""}))},ki,mn=(o,c)=>{var h=0;return o&&(h|=365),c&&(h|=146),h},Ln=(o,c,h)=>{o=ue("/dev/"+o);var g=mn(!!c,!!h);Ri||(Ri=64);var E=Ri++<<8|0;qi(E,{open:L=>{L.seekable=!1},close:()=>{h&&h.buffer&&h.buffer.length&&h(10)},read:(L,Q,ve,Pe)=>{for(var De=0,ct=0;ct{for(var De=0;De>2]=g.dev,we[h+8>>2]=g.ino,we[h+12>>2]=g.mode,Re[h+16>>2]=g.nlink,we[h+20>>2]=g.uid,we[h+24>>2]=g.gid,we[h+28>>2]=g.rdev,z=[g.size>>>0,(j=g.size,1<=+Math.abs(j)?0>>0:~~+Math.ceil((j-+(~~j>>>0))/4294967296)>>>0:0)],we[h+40>>2]=z[0],we[h+44>>2]=z[1],we[h+48>>2]=4096,we[h+52>>2]=g.blocks,z=[Math.floor(g.atime.getTime()/1e3)>>>0,(j=Math.floor(g.atime.getTime()/1e3),1<=+Math.abs(j)?0>>0:~~+Math.ceil((j-+(~~j>>>0))/4294967296)>>>0:0)],we[h+56>>2]=z[0],we[h+60>>2]=z[1],Re[h+64>>2]=0,z=[Math.floor(g.mtime.getTime()/1e3)>>>0,(j=Math.floor(g.mtime.getTime()/1e3),1<=+Math.abs(j)?0>>0:~~+Math.ceil((j-+(~~j>>>0))/4294967296)>>>0:0)],we[h+72>>2]=z[0],we[h+76>>2]=z[1],Re[h+80>>2]=0,z=[Math.floor(g.ctime.getTime()/1e3)>>>0,(j=Math.floor(g.ctime.getTime()/1e3),1<=+Math.abs(j)?0>>0:~~+Math.ceil((j-+(~~j>>>0))/4294967296)>>>0:0)],we[h+88>>2]=z[0],we[h+92>>2]=z[1],Re[h+96>>2]=0,z=[g.ino>>>0,(j=g.ino,1<=+Math.abs(j)?0>>0:~~+Math.ceil((j-+(~~j>>>0))/4294967296)>>>0:0)],we[h+104>>2]=z[0],we[h+108>>2]=z[1],0}var Xr=void 0;function Mi(){return Xr+=4,we[Xr-4>>2]}function yn(o){if(o=Dn[o],!o)throw new H(8);return o}function Rs(o){return Re[o>>2]+4294967296*we[o+4>>2]}function Zo(o){var c=dn(o)+1,h=Bi(c);return h&&Kt(o,ge,h,c),h}function vu(o,c,h){function g(Pe){return(Pe=Pe.toTimeString().match(/\(([A-Za-z ]+)\)$/))?Pe[1]:"GMT"}var E=new Date().getFullYear(),L=new Date(E,0,1),Q=new Date(E,6,1);E=L.getTimezoneOffset();var ve=Q.getTimezoneOffset();we[o>>2]=60*Math.max(E,ve),we[c>>2]=+(E!=ve),o=g(L),c=g(Q),o=Zo(o),c=Zo(c),ve>2]=o,Re[h+4>>2]=c):(Re[h>>2]=c,Re[h+4>>2]=o)}function Ds(o,c,h){Ds.Bb||(Ds.Bb=!0,vu(o,c,h))}var ea;ea=te?()=>{var o=process.hrtime();return 1e3*o[0]+o[1]/1e6}:()=>performance.now();var Ls={};function ta(){if(!Ps){var o={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:B||"./this.program"},c;for(c in Ls)Ls[c]===void 0?delete o[c]:o[c]=Ls[c];var h=[];for(c in o)h.push(c+"="+o[c]);Ps=h}return Ps}var Ps,Gn=void 0,Ms=[];function Bs(o,c){if(!Gn){Gn=new WeakMap;var h=En.length;if(Gn)for(var g=0;g<0+h;g++){var E=En.get(g);E&&Gn.set(E,g)}}if(Gn.has(o))return Gn.get(o);if(Ms.length)h=Ms.pop();else{try{En.grow(1)}catch(ve){throw ve instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":ve}h=En.length-1}try{En.set(h,o)}catch(ve){if(!(ve instanceof TypeError))throw ve;if(typeof WebAssembly.Function=="function"){g=WebAssembly.Function,E={i:"i32",j:"i64",f:"f32",d:"f64",p:"i32"};for(var L={parameters:[],results:c[0]=="v"?[]:[E[c[0]]]},Q=1;QQ?g.push(Q):g.push(Q%128|128,Q>>7),Q=0;QE?c.push(E):c.push(E%128|128,E>>7),c.push.apply(c,g),c.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),c=new WebAssembly.Module(new Uint8Array(c)),c=new WebAssembly.Instance(c,{e:{f:o}}).exports.f}En.set(h,c)}return Gn.set(o,h),h}function Yr(o){Gn.delete(En.get(o)),Ms.push(o)}function Fs(o){var c=Bi(o.length);return o.subarray||o.slice||(o=new Uint8Array(o)),Oe.set(o,c),c}function _u(o,c,h,g){var E={string:De=>{var ct=0;if(De!=null&&De!==0){var Pn=(De.length<<2)+1;ct=Xn(Pn),Kt(De,Oe,ct,Pn)}return ct},array:De=>{var ct=Xn(De.length);return ge.set(De,ct),ct}};o=d["_"+o];var L=[],Q=0;if(g)for(var ve=0;ve{an("/dev"),qi(259,{read:()=>0,write:(c,h,g,E)=>E}),Ii("/dev/null",259),Cn(1280,Gt),Cn(1536,Os),Ii("/dev/tty",1280),Ii("/dev/tty1",1536);var o=je();Ln("random",o),Ln("urandom",o),an("/dev/shm"),an("/dev/shm/tmp")})(),(()=>{an("/proc");var o=an("/proc/self");an("/proc/self/fd"),Jo({Ra:()=>{var c=Ho(o,"fd",16895,73);return c.Ga={lookup:(h,g)=>{var E=Dn[+g];if(!E)throw new H(8);return h={parent:null,Ra:{ub:"fake"},Ga:{readlink:()=>E.path}},h.parent=h}},c}},"/proc/self/fd")})();var xu={a:function(o,c,h,g){x("Assertion failed: "+Qe(o)+", at: "+[c?Qe(c):"unknown filename",h,g?Qe(g):"unknown function"])},h:function(o,c){try{return o=Qe(o),Ss(o,c),0}catch(h){if(typeof Je>"u"||!(h instanceof H))throw h;return-h.Ka}},H:function(o,c,h){try{if(c=Qe(c),c=Jn(o,c),h&-8)return-28;var g=Bt(c,{Sa:!0}).node;return g?(o="",h&4&&(o+="r"),h&2&&(o+="w"),h&1&&(o+="x"),o&&zr(g,o)?-2:0):-44}catch(E){if(typeof Je>"u"||!(E instanceof H))throw E;return-E.Ka}},i:function(o,c){try{var h=Dn[o];if(!h)throw new H(8);return Ss(h.node,c),0}catch(g){if(typeof Je>"u"||!(g instanceof H))throw g;return-g.Ka}},g:function(o){try{var c=Dn[o];if(!c)throw new H(8);var h=c.node,g=typeof h=="string"?Bt(h,{Sa:!0}).node:h;if(!g.Ga.Oa)throw new H(63);return g.Ga.Oa(g,{timestamp:Date.now()}),0}catch(E){if(typeof Je>"u"||!(E instanceof H))throw E;return-E.Ka}},b:function(o,c,h){Xr=h;try{var g=yn(o);switch(c){case 0:var E=Mi();return 0>E?-28:qn(g,E).fd;case 1:case 2:return 0;case 3:return g.flags;case 4:return E=Mi(),g.flags|=E,0;case 5:return E=Mi(),ut[E+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return we[ra()>>2]=28,-1;default:return-28}}catch(L){if(typeof Je>"u"||!(L instanceof H))throw L;return-L.Ka}},G:function(o,c){try{var h=yn(o);return Pi(Kr,h.path,c)}catch(g){if(typeof Je>"u"||!(g instanceof H))throw g;return-g.Ka}},l:function(o,c,h){try{if(c=h+2097152>>>0<4194305-!!c?(c>>>0)+4294967296*h:NaN,isNaN(c))return-61;var g=Dn[o];if(!g)throw new H(8);if(!(g.flags&2097155))throw new H(28);return Jr(g.node,c),0}catch(E){if(typeof Je>"u"||!(E instanceof H))throw E;return-E.Ka}},B:function(o,c){try{if(c===0)return-28;var h=dn("/")+1;return c"u"||!(g instanceof H))throw g;return-g.Ka}},E:function(o,c){try{return o=Qe(o),Pi(Yo,o,c)}catch(h){if(typeof Je>"u"||!(h instanceof H))throw h;return-h.Ka}},y:function(o,c,h){try{return c=Qe(c),c=Jn(o,c),c=ue(c),c[c.length-1]==="/"&&(c=c.substr(0,c.length-1)),an(c,h),0}catch(g){if(typeof Je>"u"||!(g instanceof H))throw g;return-g.Ka}},D:function(o,c,h,g){try{c=Qe(c);var E=g&256;return c=Jn(o,c,g&4096),Pi(E?Yo:Kr,c,h)}catch(L){if(typeof Je>"u"||!(L instanceof H))throw L;return-L.Ka}},v:function(o,c,h,g){Xr=g;try{c=Qe(c),c=Jn(o,c);var E=g?Mi():0;return wr(c,h,E).fd}catch(L){if(typeof Je>"u"||!(L instanceof H))throw L;return-L.Ka}},t:function(o,c,h,g){try{if(c=Qe(c),c=Jn(o,c),0>=g)return-28;var E=Xo(c),L=Math.min(g,dn(E)),Q=ge[h+L];return Kt(E,Oe,h,g+1),ge[h+L]=Q,L}catch(ve){if(typeof Je>"u"||!(ve instanceof H))throw ve;return-ve.Ka}},s:function(o){try{return o=Qe(o),Go(o),0}catch(c){if(typeof Je>"u"||!(c instanceof H))throw c;return-c.Ka}},F:function(o,c){try{return o=Qe(o),Pi(Kr,o,c)}catch(h){if(typeof Je>"u"||!(h instanceof H))throw h;return-h.Ka}},p:function(o,c,h){try{return c=Qe(c),c=Jn(o,c),h===0?Ai(c):h===512?Go(c):x("Invalid flags passed to unlinkat"),0}catch(g){if(typeof Je>"u"||!(g instanceof H))throw g;return-g.Ka}},o:function(o,c,h){try{if(c=Qe(c),c=Jn(o,c,!0),h){var g=Rs(h),E=we[h+8>>2];L=1e3*g+E/1e6,h+=16,g=Rs(h),E=we[h+8>>2],Q=1e3*g+E/1e6}else var L=Date.now(),Q=L;o=L;var ve=Bt(c,{Sa:!0}).node;return ve.Ga.Oa(ve,{timestamp:Math.max(o,Q)}),0}catch(Pe){if(typeof Je>"u"||!(Pe instanceof H))throw Pe;return-Pe.Ka}},e:function(){return Date.now()},j:function(o,c){o=new Date(1e3*Rs(o)),we[c>>2]=o.getSeconds(),we[c+4>>2]=o.getMinutes(),we[c+8>>2]=o.getHours(),we[c+12>>2]=o.getDate(),we[c+16>>2]=o.getMonth(),we[c+20>>2]=o.getFullYear()-1900,we[c+24>>2]=o.getDay();var h=new Date(o.getFullYear(),0,1);we[c+28>>2]=(o.getTime()-h.getTime())/864e5|0,we[c+36>>2]=-(60*o.getTimezoneOffset());var g=new Date(o.getFullYear(),6,1).getTimezoneOffset();h=h.getTimezoneOffset(),we[c+32>>2]=(g!=h&&o.getTimezoneOffset()==Math.min(h,g))|0},w:function(o,c,h,g,E,L){try{var Q=yn(g);if(c&2&&!(h&2)&&(Q.flags&2097155)!==2)throw new H(2);if((Q.flags&2097155)===1)throw new H(2);if(!Q.Ha.bb)throw new H(43);var ve=Q.Ha.bb(Q,o,E,c,h),Pe=ve.Fb;return we[L>>2]=ve.vb,Pe}catch(De){if(typeof Je>"u"||!(De instanceof H))throw De;return-De.Ka}},x:function(o,c,h,g,E,L){try{var Q=yn(E);if(h&2){var ve=Oe.slice(o,o+c);Q&&Q.Ha.cb&&Q.Ha.cb(Q,ve,L,c,g)}}catch(Pe){if(typeof Je>"u"||!(Pe instanceof H))throw Pe;return-Pe.Ka}},n:Ds,q:function(){return 2147483648},d:ea,c:function(o){var c=Oe.length;if(o>>>=0,2147483648=h;h*=2){var g=c*(1+.2/h);g=Math.min(g,o+100663296);var E=Math;g=Math.max(o,g),E=E.min.call(E,2147483648,g+(65536-g%65536)%65536);e:{try{tt.grow(E-wt.byteLength+65535>>>16),Cs();var L=1;break e}catch{}L=void 0}if(L)return!0}return!1},z:function(o,c){var h=0;return ta().forEach(function(g,E){var L=c+h;for(E=Re[o+4*E>>2]=L,L=0;L>0]=g.charCodeAt(L);ge[E>>0]=0,h+=g.length+1}),0},A:function(o,c){var h=ta();Re[o>>2]=h.length;var g=0;return h.forEach(function(E){g+=E.length+1}),Re[c>>2]=g,0},f:function(o){try{var c=yn(o);return He(c),0}catch(h){if(typeof Je>"u"||!(h instanceof H))throw h;return h.Ka}},m:function(o,c){try{var h=yn(o);return ge[c>>0]=h.tty?2:(h.mode&61440)===16384?3:(h.mode&61440)===40960?7:4,0}catch(g){if(typeof Je>"u"||!(g instanceof H))throw g;return g.Ka}},u:function(o,c,h,g){try{e:{var E=yn(o);o=c;for(var L=c=0;L>2],ve=Re[o+4>>2];o+=8;var Pe=Ti(E,ge,Q,ve);if(0>Pe){var De=-1;break e}if(c+=Pe,Pe>2]=De,0}catch(ct){if(typeof Je>"u"||!(ct instanceof H))throw ct;return ct.Ka}},k:function(o,c,h,g,E){try{if(c=h+2097152>>>0<4194305-!!c?(c>>>0)+4294967296*h:NaN,isNaN(c))return 61;var L=yn(o);return Gr(L,c,g),z=[L.position>>>0,(j=L.position,1<=+Math.abs(j)?0>>0:~~+Math.ceil((j-+(~~j>>>0))/4294967296)>>>0:0)],we[E>>2]=z[0],we[E+4>>2]=z[1],L.hb&&c===0&&g===0&&(L.hb=null),0}catch(Q){if(typeof Je>"u"||!(Q instanceof H))throw Q;return Q.Ka}},C:function(o){try{var c=yn(o);return c.Ha&&c.Ha.fsync?c.Ha.fsync(c):0}catch(h){if(typeof Je>"u"||!(h instanceof H))throw h;return h.Ka}},r:function(o,c,h,g){try{e:{var E=yn(o);o=c;for(var L=c=0;L>2],ve=Re[o+4>>2];o+=8;var Pe=gr(E,ge,Q,ve);if(0>Pe){var De=-1;break e}c+=Pe}De=c}return Re[g>>2]=De,0}catch(ct){if(typeof Je>"u"||!(ct instanceof H))throw ct;return ct.Ka}}};(function(){function o(E){d.asm=E.exports,tt=d.asm.I,Cs(),En=d.asm.Aa,fe.unshift(d.asm.J),Jt--,d.monitorRunDependencies&&d.monitorRunDependencies(Jt),Jt==0&&Ke&&(E=Ke,Ke=null,E())}function c(E){o(E.instance)}function h(E){return Y().then(function(L){return WebAssembly.instantiate(L,g)}).then(function(L){return L}).then(E,function(L){_e("failed to asynchronously prepare wasm: "+L),x(L)})}var g={a:xu};if(Jt++,d.monitorRunDependencies&&d.monitorRunDependencies(Jt),d.instantiateWasm)try{return d.instantiateWasm(g,o)}catch(E){return _e("Module.instantiateWasm callback failed with error: "+E),!1}return function(){return xe||typeof WebAssembly.instantiateStreaming!="function"||O()||R.startsWith("file://")||te||typeof fetch!="function"?h(c):fetch(R,{credentials:"same-origin"}).then(function(E){return WebAssembly.instantiateStreaming(E,g).then(c,function(L){return _e("wasm streaming compile failed: "+L),_e("falling back to ArrayBuffer instantiation"),h(c)})})}(),{}})(),d.___wasm_call_ctors=function(){return(d.___wasm_call_ctors=d.asm.J).apply(null,arguments)},d._sqlite3_free=function(){return(d._sqlite3_free=d.asm.K).apply(null,arguments)},d._sqlite3_value_double=function(){return(d._sqlite3_value_double=d.asm.L).apply(null,arguments)},d._sqlite3_value_text=function(){return(d._sqlite3_value_text=d.asm.M).apply(null,arguments)};var ra=d.___errno_location=function(){return(ra=d.___errno_location=d.asm.N).apply(null,arguments)};d._sqlite3_prepare_v2=function(){return(d._sqlite3_prepare_v2=d.asm.O).apply(null,arguments)},d._sqlite3_step=function(){return(d._sqlite3_step=d.asm.P).apply(null,arguments)},d._sqlite3_finalize=function(){return(d._sqlite3_finalize=d.asm.Q).apply(null,arguments)},d._sqlite3_reset=function(){return(d._sqlite3_reset=d.asm.R).apply(null,arguments)},d._sqlite3_value_int=function(){return(d._sqlite3_value_int=d.asm.S).apply(null,arguments)},d._sqlite3_clear_bindings=function(){return(d._sqlite3_clear_bindings=d.asm.T).apply(null,arguments)},d._sqlite3_value_blob=function(){return(d._sqlite3_value_blob=d.asm.U).apply(null,arguments)},d._sqlite3_value_bytes=function(){return(d._sqlite3_value_bytes=d.asm.V).apply(null,arguments)},d._sqlite3_value_type=function(){return(d._sqlite3_value_type=d.asm.W).apply(null,arguments)},d._sqlite3_result_blob=function(){return(d._sqlite3_result_blob=d.asm.X).apply(null,arguments)},d._sqlite3_result_double=function(){return(d._sqlite3_result_double=d.asm.Y).apply(null,arguments)},d._sqlite3_result_error=function(){return(d._sqlite3_result_error=d.asm.Z).apply(null,arguments)},d._sqlite3_result_int=function(){return(d._sqlite3_result_int=d.asm._).apply(null,arguments)},d._sqlite3_result_int64=function(){return(d._sqlite3_result_int64=d.asm.$).apply(null,arguments)},d._sqlite3_result_null=function(){return(d._sqlite3_result_null=d.asm.aa).apply(null,arguments)},d._sqlite3_result_text=function(){return(d._sqlite3_result_text=d.asm.ba).apply(null,arguments)},d._sqlite3_sql=function(){return(d._sqlite3_sql=d.asm.ca).apply(null,arguments)},d._sqlite3_aggregate_context=function(){return(d._sqlite3_aggregate_context=d.asm.da).apply(null,arguments)},d._sqlite3_column_count=function(){return(d._sqlite3_column_count=d.asm.ea).apply(null,arguments)},d._sqlite3_data_count=function(){return(d._sqlite3_data_count=d.asm.fa).apply(null,arguments)},d._sqlite3_column_blob=function(){return(d._sqlite3_column_blob=d.asm.ga).apply(null,arguments)},d._sqlite3_column_bytes=function(){return(d._sqlite3_column_bytes=d.asm.ha).apply(null,arguments)},d._sqlite3_column_double=function(){return(d._sqlite3_column_double=d.asm.ia).apply(null,arguments)},d._sqlite3_column_text=function(){return(d._sqlite3_column_text=d.asm.ja).apply(null,arguments)},d._sqlite3_column_type=function(){return(d._sqlite3_column_type=d.asm.ka).apply(null,arguments)},d._sqlite3_column_name=function(){return(d._sqlite3_column_name=d.asm.la).apply(null,arguments)},d._sqlite3_bind_blob=function(){return(d._sqlite3_bind_blob=d.asm.ma).apply(null,arguments)},d._sqlite3_bind_double=function(){return(d._sqlite3_bind_double=d.asm.na).apply(null,arguments)},d._sqlite3_bind_int=function(){return(d._sqlite3_bind_int=d.asm.oa).apply(null,arguments)},d._sqlite3_bind_text=function(){return(d._sqlite3_bind_text=d.asm.pa).apply(null,arguments)},d._sqlite3_bind_parameter_index=function(){return(d._sqlite3_bind_parameter_index=d.asm.qa).apply(null,arguments)},d._sqlite3_normalized_sql=function(){return(d._sqlite3_normalized_sql=d.asm.ra).apply(null,arguments)},d._sqlite3_errmsg=function(){return(d._sqlite3_errmsg=d.asm.sa).apply(null,arguments)},d._sqlite3_exec=function(){return(d._sqlite3_exec=d.asm.ta).apply(null,arguments)},d._sqlite3_changes=function(){return(d._sqlite3_changes=d.asm.ua).apply(null,arguments)},d._sqlite3_close_v2=function(){return(d._sqlite3_close_v2=d.asm.va).apply(null,arguments)},d._sqlite3_create_function_v2=function(){return(d._sqlite3_create_function_v2=d.asm.wa).apply(null,arguments)},d._sqlite3_open=function(){return(d._sqlite3_open=d.asm.xa).apply(null,arguments)};var Bi=d._malloc=function(){return(Bi=d._malloc=d.asm.ya).apply(null,arguments)},Fi=d._free=function(){return(Fi=d._free=d.asm.za).apply(null,arguments)};d._RegisterExtensionFunctions=function(){return(d._RegisterExtensionFunctions=d.asm.Ba).apply(null,arguments)};var ia=d._emscripten_builtin_memalign=function(){return(ia=d._emscripten_builtin_memalign=d.asm.Ca).apply(null,arguments)},Zr=d.stackSave=function(){return(Zr=d.stackSave=d.asm.Da).apply(null,arguments)},ei=d.stackRestore=function(){return(ei=d.stackRestore=d.asm.Ea).apply(null,arguments)},Xn=d.stackAlloc=function(){return(Xn=d.stackAlloc=d.asm.Fa).apply(null,arguments)};d.UTF8ToString=Qe,d.stackAlloc=Xn,d.stackSave=Zr,d.stackRestore=ei,d.cwrap=function(o,c,h,g){h=h||[];var E=h.every(L=>L==="number"||L==="boolean");return c!=="string"&&E&&!g?d["_"+o]:function(){return _u(o,c,h,arguments)}};var Ui;Ke=function o(){Ui||sa(),Ui||(Ke=o)};function sa(){function o(){if(!Ui&&(Ui=!0,d.calledRun=!0,!ze)){if(d.noFSInit||ki||(ki=!0,Si(),d.stdin=d.stdin,d.stdout=d.stdout,d.stderr=d.stderr,d.stdin?Ln("stdin",d.stdin):Ts("/dev/tty","/dev/stdin"),d.stdout?Ln("stdout",null,d.stdout):Ts("/dev/tty","/dev/stdout"),d.stderr?Ln("stderr",null,d.stderr):Ts("/dev/tty1","/dev/stderr"),wr("/dev/stdin",0),wr("/dev/stdout",1),wr("/dev/stderr",1)),qs=!1,re(fe),d.onRuntimeInitialized&&d.onRuntimeInitialized(),d.postRun)for(typeof d.postRun=="function"&&(d.postRun=[d.postRun]);d.postRun.length;){var c=d.postRun.shift();Me.unshift(c)}re(Me)}}if(!(0=this._size)return 0;const i=this._data.subarray(e,Math.min(this._size,e+n.length));return n.set(i),i.length}reserve(e){if(this._data.length>=e)return;const n=e-this._data.length,i=Math.min(rN,Math.max(nN,this._data.length)),a=new Uint8Array(this._data.length+Math.max(i,n));a.set(this._data),this._data=a}write(e,n){return this.reserve(e+n.length),this._data.set(n,e),this._size=Math.max(this._size,e+n.length),n.length}truncate(e){this._size=e}toUint8Array(){return this._data.subarray(0,this._size)}}const sN=self.indexedDB||window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB||window.shimIndexedDB,Gf=new Promise((t,e)=>{const n=sN.open(tN,1);n.onupgradeneeded=()=>n.result.createObjectStore("files",{keyPath:"name"}),n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error)});async function oN(t){const e=await Gf,n=await new Promise((i,a)=>{const m=e.transaction("files","readonly").objectStore("files").get(t);m.onsuccess=()=>i(m.result),m.onerror=()=>a(m.error)});if(n&&!Gs.has(t)){const i=new iN(n.data);return Gs.set(t,i),i}else return Gs.has(t)?Gs.get(t):null}async function aN(t,e){const n=await Gf;await new Promise((i,a)=>{const m=n.transaction("files","readwrite").objectStore("files").put({name:t,data:e});m.onsuccess=()=>i(!0),m.onerror=()=>a(m.error)})}async function zh(t){const e=await Gf;await new Promise((n,i)=>{const l=e.transaction("files","readwrite").objectStore("files").delete(t);l.onsuccess=()=>n(!0),l.onerror=()=>i(l.error)})}async function uN(t,e){if(await aN(t,e),Gs.has(t)){const n=Gs.get(t);n.truncate(0),n.write(0,e)}}var cN=t=>t==null||typeof t=="bigint"||typeof t=="number"||typeof t=="object"&&"buffer"in t?t:typeof t=="boolean"?`${t}`:t instanceof Date?t.toISOString():JSON.stringify(t),lN=t=>{if(t==null||typeof t=="bigint"||typeof t=="number"||typeof t=="object"&&"buffer"in t)return t;if(typeof t=="string"){const e=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?$/;if(/^(true|false)$/.test(t))return t==="true";if(e.test(t))return new Date(t);try{return JSON.parse(t,(n,i)=>typeof i=="string"&&e.exec(i)?new Date(i):i)}catch{}}return t},ms,dd,fN=(dd=class extends Vf{constructor(e){super();S(this,ms,void 0);P(this,ms,e||cN)}transformPrimitiveValueList(e){return{...e,values:e.values.map(r(this,ms))}}transformColumnUpdate(e){const{value:n}=e;if(n.kind!=="ValueNode")return super.transformColumnUpdate(e);const{value:i,...a}=n,l=r(this,ms).call(this,i);return i===l?super.transformColumnUpdate(e):super.transformColumnUpdate({...e,value:{...a,value:l}})}transformValue(e){return{...e,value:r(this,ms).call(this,e.value)}}},ms=new WeakMap,dd),ou,au,qo,pd,hN=(pd=class{constructor(t={}){S(this,ou,void 0);S(this,au,void 0);S(this,qo,void 0);P(this,ou,new fN(t.serializer)),P(this,au,t.deserializer||lN),P(this,qo,new WeakMap)}transformQuery(t){const{node:e,queryId:n}=t;return e.kind==="SelectQueryNode"&&r(this,qo).set(n,e.kind),r(this,ou).transformNode(t.node)}async parseResult(t){return await Promise.all(t.map(async e=>{const n={...e};for(const i in n)n[i]=await r(this,au).call(this,n[i]);return n}))}async transformResult(t){const{result:e,queryId:n}=t,{rows:i}=e,a=r(this,qo).get(n);return i&&a==="SelectQueryNode"?{...t.result,rows:await this.parseResult(i)}:t.result}},ou=new WeakMap,au=new WeakMap,qo=new WeakMap,pd);function Ul(t){return typeof t=="string"}function dN(t){return typeof t=="boolean"}async function Kh(t,e,n,i,a="rowid"){await kn` + create trigger if not exists ${kn.raw(e)}_${kn.raw(i)} + after ${kn.raw(n)} + on ${kn.table(e)} begin - update ${Sn.table(e)} - set ${Sn.ref(i)} = datetime('now','localtime') - where ${Sn.ref(a)} = NEW.${Sn.ref(a)}; + update ${kn.table(e)} + set ${kn.ref(i)} = datetime('now','localtime') + where ${kn.ref(a)} = NEW.${kn.ref(a)}; end - `.execute(t).catch(l=>{console.error(l)})}function pN(t){const e=new Map;for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const i=t[n];e.set(n,i)}return e}async function mN(t,e,n=!1){for(const[i,a]of e){const{columns:l,property:m}=a;n&&await t.schema.dropTable(i).ifExists().execute().catch();let g=t.schema.createTable(i),v="rowid",d=!1,I="createAt",B="updateAt";if(m!=null&&m.timestamp&&!dN(m.timestamp)){const{create:D,update:ne}=m.timestamp;I=D??"createAt",B=ne??"updateAt"}for(const D in l){if(!Object.prototype.hasOwnProperty.call(l,D))continue;const ne=l[D];let te="text";const{type:b,notNull:C,defaultTo:N}=ne;switch(b){case"boolean":case"date":case"object":case"string":te="text";break;case"increments":v=D;case"number":te="integer";break;case"blob":te="blob"}[I,B].includes(D)||(g=g.addColumn(D,te,O=>b==="increments"?(d=!0,O.autoIncrement().primaryKey()):(C&&(O=O.notNull()),N!==void 0&&(O=O.defaultTo(N instanceof Function?N(Sn):N)),O)))}if(m){const D=m.primary,ne=m.unique;if(m.timestamp&&(I&&(g=g.addColumn(I,"text")),B&&(g=g.addColumn(B,"text"))),!d&&D){const te=Ul(D);v=te?D:D[0],g=g.addPrimaryKeyConstraint(`pk_${te?D:D.join("_")}`,te?[D]:D)}ne==null||ne.forEach(te=>{const b=Ul(te);v=!D&&!d?b?te:te[0]:v,g=g.addUniqueConstraint(`un_${b?te:te.join("_")}`,b?[te]:te)})}if(await g.ifNotExists().execute(),m!=null&&m.index)for(const D of m.index){const ne=Ul(D);let te=t.schema.createIndex(`idx_${ne?D:D.join("_")}`).on(i);te=ne?te.column(D):te.columns(D),await te.ifNotExists().execute()}m!=null&&m.timestamp&&(I&&await Kh(t,i,"insert",I,v),B&&await Kh(t,i,"update",B,v))}}var yi,cu,md,yN=(md=class{constructor(t){Yt(this,"kysely");k(this,yi,void 0);k(this,cu,void 0);const{dialect:e,tables:n,dropTableBeforeInit:i,onError:a,onQuery:l,plugins:m}=t,g=[new hN];m&&g.push(...m),this.kysely=new Qa({dialect:e,log:v=>{v.level==="error"?a&&a(v.error):l&&l(v.query,v.queryDurationMillis)},plugins:g}),P(this,yi,i?0:1),P(this,cu,pN(n))}async init(t=!1){const e=t||r(this,yi)===0;return await mN(this.kysely,r(this,cu),e),P(this,yi,2),this}async checkInit(){if(r(this,yi)!==2&&await this.init(),r(this,yi)!==2)throw new Error("fail to init table")}async transaction(t,e=!1){return await this.checkInit(),await this.kysely.transaction().execute(t).catch(n=>{e&&console.error(n)})}async exec(t,e=!1){return await this.checkInit(),t(this.kysely).catch(n=>{e&&console.error(n)})}async toSQL(t){return await this.checkInit(),t(this.kysely).compile()}async raw(t){return await this.checkInit(),t(Sn).execute(this.kysely)}},yi=new WeakMap,cu=new WeakMap,md);async function Xf(t){const e=await new yN({dialect:t,tables:{test:{columns:{id:{type:"increments"},name:{type:"string"},blobtest:{type:"blob"},createAt:{type:"date"},updateAt:{type:"date"}},property:{timestamp:!0}}}}).init();console.log("test"),console.log(await e.raw(n=>n`PRAGMA table_info(${n.table("test")});`)),console.log(await e.raw(n=>n`select last_insert_rowid()`));for(let n=0;n<100;n++)await e.transaction(i=>i.insertInto("test").values({name:`test at ${Date.now()}`,blobtest:Uint8Array.from([2,3,4,5,6,7,8])}).execute());return e.exec(n=>n.selectFrom("test").selectAll().execute())}const wN=new jb({async database(){const t=await Zb({locateFile:()=>eN});return new t.Database(await oN("sqljs"))},onWrite:{func(t){console.log(`[sqljs] write to indexeddb, length: ${t.length}`),uN("sqljs",t)},isThrottle:!0}});function gN(){const t=Ny();function e(){Xf(wN).then(n=>{t.value=n})}return{result:t,run:e}}function bN(){return new Worker(""+new URL("sqljsWorker-eaa67eb7.js",import.meta.url).href)}function NN(){return new Worker(""+new URL("officialWasmWorker-94e472c1.js",import.meta.url).href)}const Ve=0,vN=5,xt=10,gm=12,bm=14,zi=21,$l=25,_N=27,Jh=100,xN=101,EN=3850,CN=522,qN=1,ON=2,Nm=4,WN=8,Vs=0,Zi=1,ic=2,IN=3,sc=4,AN=512,TN=1024,kN=2048,SN=16384,Gh=1,Xh=2,Yh=3,Zh=4,ed=5,td=0x7fffffffffffffffn,nd=-0x8000000000000000n;class Rr extends Error{constructor(e,n){super(e),this.code=n}}const Hs=!0;function RN(t){const e={},n=t._getSqliteFree(),i=t._malloc(8),a=[i,i+4];function l(b){if(typeof b!="string")return 0;const C=t.lengthBytesUTF8(b),N=t._sqlite3_malloc(C+1);return t.stringToUTF8(b,N,C+1),N}function m(b,C){return BigInt(C)<<32n|BigInt(b)&0xffffffffn}const g=function(){const b=BigInt(Number.MAX_SAFE_INTEGER)>>32n,C=BigInt(Number.MIN_SAFE_INTEGER)>>32n;return function(N,O){return O>b||O2147483647||T<-2147483648)return $l;const ee=C(N,O,T);return te(b,ee,I.get(N))}}(),e.bind_int64=function(){const b="sqlite3_bind_int64",C=t.cwrap(b,...Ce("nnnn:n"));return function(N,O,T){if(B(N),T>td||T>32n,ae=C(N,O,Number(ee),Number(Ne));return te(b,ae,I.get(N))}}(),e.bind_null=function(){const b="sqlite3_bind_null",C=t.cwrap(b,...Ce("nn:n"));return function(N,O){B(N);const T=C(N,O);return te(b,T,I.get(N))}}(),e.bind_parameter_name=function(){const b="sqlite3_bind_parameter_name",C=t.cwrap(b,...Ce("n:s"));return function(N,O){return B(N),C(N,O)}}(),e.bind_text=function(){const b="sqlite3_bind_text",C=t.cwrap(b,...Ce("nnnnn:n"));return function(N,O,T){B(N);const ee=l(T),Ne=C(N,O,ee,-1,n);return te(b,Ne,I.get(N))}}(),e.changes=function(){const b="sqlite3_changes",C=t.cwrap(b,...Ce("n:n"));return function(N){return d(N),C(N)}}(),e.close=function(){const b="sqlite3_close",C=t.cwrap(b,...Ce("n:n"),{async:Hs});return async function(N){d(N);const O=await C(N);return v.delete(N),te(b,O,N)}}(),e.column=function(b,C){B(b);const N=e.column_type(b,C);switch(N){case Zh:return e.column_blob(b,C);case Xh:return e.column_double(b,C);case Gh:const O=e.column_int(b,C),T=t.getTempRet0();return g(O,T);case ed:return null;case Yh:return e.column_text(b,C);default:throw new Rr("unknown type",N)}},e.column_blob=function(){const b="sqlite3_column_blob",C=t.cwrap(b,...Ce("nn:n"));return function(N,O){B(N);const T=e.column_bytes(N,O),ee=C(N,O);return t.HEAPU8.subarray(ee,ee+T)}}(),e.column_bytes=function(){const b="sqlite3_column_bytes",C=t.cwrap(b,...Ce("nn:n"));return function(N,O){return B(N),C(N,O)}}(),e.column_count=function(){const b="sqlite3_column_count",C=t.cwrap(b,...Ce("n:n"));return function(N){return B(N),C(N)}}(),e.column_double=function(){const b="sqlite3_column_double",C=t.cwrap(b,...Ce("nn:n"));return function(N,O){return B(N),C(N,O)}}(),e.column_int=function(){const b="sqlite3_column_int64",C=t.cwrap(b,...Ce("nn:n"));return function(N,O){return B(N),C(N,O)}}(),e.column_int64=function(){const b="sqlite3_column_int64",C=t.cwrap(b,...Ce("nn:n"));return function(N,O){B(N);const T=C(N,O),ee=t.getTempRet0();return m(T,ee)}}(),e.column_name=function(){const b="sqlite3_column_name",C=t.cwrap(b,...Ce("nn:s"));return function(N,O){return B(N),C(N,O)}}(),e.column_names=function(b){const C=[],N=e.column_count(b);for(let O=0;Otd||O>32n;C(N,Number(T),Number(ee))}}(),e.result_null=function(){const b="sqlite3_result_null",C=t.cwrap(b,...Ce("n:n"));return function(N){C(N)}}(),e.result_text=function(){const b="sqlite3_result_text",C=t.cwrap(b,...Ce("nnnn:n"));return function(N,O){const T=l(O);C(N,T,-1,n)}}(),e.row=function(b){const C=[],N=e.data_count(b);for(let O=0;O{var t=import.meta.url;return function(e={}){var n;n||(n=typeof e<"u"?e:{});var i,a;n.ready=new Promise((s,u)=>{i=s,a=u});var l=Object.assign({},n),m="./this.program",g=(s,u)=>{throw u},v=typeof window=="object",d=typeof importScripts=="function",I="",B;(v||d)&&(d?I=self.location.href:typeof document<"u"&&document.currentScript&&(I=document.currentScript.src),t&&(I=t),I.indexOf("blob:")!==0?I=I.substr(0,I.replace(/[?#].*/,"").lastIndexOf("/")+1):I="",d&&(B=s=>{var u=new XMLHttpRequest;return u.open("GET",s,!1),u.responseType="arraybuffer",u.send(null),new Uint8Array(u.response)}));var D=n.print||console.log.bind(console),ne=n.printErr||console.warn.bind(console);Object.assign(n,l),l=null,n.thisProgram&&(m=n.thisProgram),n.quit&&(g=n.quit);var te;n.wasmBinary&&(te=n.wasmBinary);var b=n.noExitRuntime||!0;typeof WebAssembly!="object"&&ut("no native wasm support detected");var C,N=!1,O,T,ee,Ne,ae,_e,xe,tt;function ze(){var s=C.buffer;n.HEAP8=T=new Int8Array(s),n.HEAP16=Ne=new Int16Array(s),n.HEAP32=ae=new Int32Array(s),n.HEAPU8=ee=new Uint8Array(s),n.HEAPU16=new Uint16Array(s),n.HEAPU32=_e=new Uint32Array(s),n.HEAPF32=xe=new Float32Array(s),n.HEAPF64=tt=new Float64Array(s)}var Ot=[],Wt=[],Qe=[],Kt=[],dn=0;function wt(){var s=n.preRun.shift();Ot.unshift(s)}var ge=0,qe=null;function ut(s){throw n.onAbort&&n.onAbort(s),s="Aborted("+s+")",ne(s),N=!0,O=1,s=new WebAssembly.RuntimeError(s+". Build with -sASSERTIONS for more info."),a(s),s}function we(s){return s.startsWith("data:application/octet-stream;base64,")}var Re;if(n.locateFile){if(Re="wa-sqlite-async.wasm",!we(Re)){var Pt=Re;Re=n.locateFile?n.locateFile(Pt,I):I+Pt}}else Re=new URL(""+new URL("wa-sqlite-async-24800831.wasm",import.meta.url).href,self.location).href;function Tr(s){try{if(s==Re&&te)return new Uint8Array(te);if(B)return B(s);throw"both async and sync fetching of the wasm failed"}catch(u){ut(u)}}function Cs(s){return te||!v&&!d||typeof fetch!="function"?Promise.resolve().then(()=>Tr(s)):fetch(s,{credentials:"same-origin"}).then(u=>{if(!u.ok)throw"failed to load wasm binary file at '"+s+"'";return u.arrayBuffer()}).catch(()=>Tr(s))}function En(s,u,f){return Cs(s).then(y=>WebAssembly.instantiate(y,u)).then(y=>y).then(f,y=>{ne("failed to asynchronously prepare wasm: "+y),ut(y)})}function pn(s,u){var f=Re;return te||typeof WebAssembly.instantiateStreaming!="function"||we(f)||typeof fetch!="function"?En(f,s,u):fetch(f,{credentials:"same-origin"}).then(y=>WebAssembly.instantiateStreaming(y,s).then(u,function(_){return ne("wasm streaming compile failed: "+_),ne("falling back to ArrayBuffer instantiation"),En(f,s,u)}))}var fe,Me;function zn(s){this.name="ExitStatus",this.message="Program terminated with exit("+s+")",this.status=s}function Jt(s){for(;0>0];case"i8":return T[s>>0];case"i16":return Ne[s>>1];case"i32":return ae[s>>2];case"i64":return ae[s>>2];case"float":return xe[s>>2];case"double":return tt[s>>3];case"*":return _e[s>>2];default:ut("invalid type for getValue: "+u)}}function x(s,u,f="i8"){switch(f.endsWith("*")&&(f="*"),f){case"i1":T[s>>0]=u;break;case"i8":T[s>>0]=u;break;case"i16":Ne[s>>1]=u;break;case"i32":ae[s>>2]=u;break;case"i64":Me=[u>>>0,(fe=u,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[s>>2]=Me[0],ae[s+4>>2]=Me[1];break;case"float":xe[s>>2]=u;break;case"double":tt[s>>3]=u;break;case"*":_e[s>>2]=u;break;default:ut("invalid type for setValue: "+f)}}var q=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function R(s,u,f){var y=u+f;for(f=u;s[f]&&!(f>=y);)++f;if(16_?y+=String.fromCharCode(_):(_-=65536,y+=String.fromCharCode(55296|_>>10,56320|_&1023))}}else y+=String.fromCharCode(_)}return y}function F(s,u){return s?R(ee,s,u):""}var K=(s,u)=>{for(var f=0,y=s.length-1;0<=y;y--){var _=s[y];_==="."?s.splice(y,1):_===".."?(s.splice(y,1),f++):f&&(s.splice(y,1),f--)}if(u)for(;f;f--)s.unshift("..");return s},Y=s=>{var u=s.charAt(0)==="/",f=s.substr(-1)==="/";return(s=K(s.split("/").filter(y=>!!y),!u).join("/"))||u||(s="."),s&&f&&(s+="/"),(u?"/":"")+s},j=s=>{var u=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(s).slice(1);return s=u[0],u=u[1],!s&&!u?".":(u&&(u=u.substr(0,u.length-1)),s+u)},z=s=>{if(s==="/")return"/";s=Y(s),s=s.replace(/\/$/,"");var u=s.lastIndexOf("/");return u===-1?s:s.substr(u+1)};function re(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return s=>crypto.getRandomValues(s);ut("initRandomDevice")}function J(s){return(J=re())(s)}function ce(){for(var s="",u=!1,f=arguments.length-1;-1<=f&&!u;f--){if(u=0<=f?arguments[f]:"/",typeof u!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!u)return"";s=u+"/"+s,u=u.charAt(0)==="/"}return s=K(s.split("/").filter(y=>!!y),!u).join("/"),(u?"/":"")+s||"."}function oe(s){for(var u=0,f=0;f=y?u++:2047>=y?u+=2:55296<=y&&57343>=y?(u+=4,++f):u+=3}return u}function ue(s,u,f,y){if(!(0=A){var V=s.charCodeAt(++S);A=65536+((A&1023)<<10)|V&1023}if(127>=A){if(f>=y)break;u[f++]=A}else{if(2047>=A){if(f+1>=y)break;u[f++]=192|A>>6}else{if(65535>=A){if(f+2>=y)break;u[f++]=224|A>>12}else{if(f+3>=y)break;u[f++]=240|A>>18,u[f++]=128|A>>12&63}u[f++]=128|A>>6&63}u[f++]=128|A&63}}return u[f]=0,f-_}var be=[];function Ee(s,u){be[s]={input:[],Rb:[],bc:u},Is(s,je)}var je={open:function(s){var u=be[s.node.ec];if(!u)throw new Z(43);s.Sb=u,s.seekable=!1},close:function(s){s.Sb.bc.ic(s.Sb)},ic:function(s){s.Sb.bc.ic(s.Sb)},read:function(s,u,f,y){if(!s.Sb||!s.Sb.bc.zc)throw new Z(60);for(var _=0,S=0;S{console.error(l)})}function pN(t){const e=new Map;for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const i=t[n];e.set(n,i)}return e}async function mN(t,e,n=!1){for(const[i,a]of e){const{columns:l,property:m}=a;n&&await t.schema.dropTable(i).ifExists().execute().catch();let w=t.schema.createTable(i),v="rowid",d=!1,W="createAt",B="updateAt";if(m!=null&&m.timestamp&&!dN(m.timestamp)){const{create:D,update:ne}=m.timestamp;W=D??"createAt",B=ne??"updateAt"}for(const D in l){if(!Object.prototype.hasOwnProperty.call(l,D))continue;const ne=l[D];let te="text";const{type:b,notNull:C,defaultTo:N}=ne;switch(b){case"boolean":case"date":case"object":case"string":te="text";break;case"increments":v=D;case"number":te="integer";break;case"blob":te="blob"}[W,B].includes(D)||(w=w.addColumn(D,te,q=>b==="increments"?(d=!0,q.autoIncrement().primaryKey()):(C&&(q=q.notNull()),N!==void 0&&(q=q.defaultTo(N instanceof Function?N(kn):N)),q)))}if(m){const D=m.primary,ne=m.unique;if(m.timestamp&&(W&&(w=w.addColumn(W,"text")),B&&(w=w.addColumn(B,"text"))),!d&&D){const te=Ul(D);v=te?D:D[0],w=w.addPrimaryKeyConstraint(`pk_${te?D:D.join("_")}`,te?[D]:D)}ne==null||ne.forEach(te=>{const b=Ul(te);v=!D&&!d?b?te:te[0]:v,w=w.addUniqueConstraint(`un_${b?te:te.join("_")}`,b?[te]:te)})}if(await w.ifNotExists().execute(),m!=null&&m.index)for(const D of m.index){const ne=Ul(D);let te=t.schema.createIndex(`idx_${ne?D:D.join("_")}`).on(i);te=ne?te.column(D):te.columns(D),await te.ifNotExists().execute()}m!=null&&m.timestamp&&(W&&await Kh(t,i,"insert",W,v),B&&await Kh(t,i,"update",B,v))}}var mi,uu,md,yN=(md=class{constructor(t){Yt(this,"kysely");S(this,mi,void 0);S(this,uu,void 0);const{dialect:e,tables:n,dropTableBeforeInit:i,onError:a,onQuery:l,plugins:m}=t,w=[new hN];m&&w.push(...m),this.kysely=new $a({dialect:e,log:v=>{v.level==="error"?a&&a(v.error):l&&l(v.query,v.queryDurationMillis)},plugins:w}),P(this,mi,i?0:1),P(this,uu,pN(n))}async init(t=!1){const e=t||r(this,mi)===0;return await mN(this.kysely,r(this,uu),e),P(this,mi,2),this}async checkInit(){if(r(this,mi)!==2&&await this.init(),r(this,mi)!==2)throw new Error("fail to init table")}async transaction(t,e=!1){return await this.checkInit(),await this.kysely.transaction().execute(t).catch(n=>{e&&console.error(n)})}async exec(t,e=!1){return await this.checkInit(),t(this.kysely).catch(n=>{e&&console.error(n)})}async toSQL(t){return await this.checkInit(),t(this.kysely).compile()}async raw(t){return await this.checkInit(),t(kn).execute(this.kysely)}},mi=new WeakMap,uu=new WeakMap,md);async function Xf(t){const e=await new yN({dialect:t,tables:{test:{columns:{id:{type:"increments"},name:{type:"string"},blobtest:{type:"blob"},createAt:{type:"date"},updateAt:{type:"date"}},property:{timestamp:!0}}}}).init();console.log("test"),console.log(await e.raw(n=>n`PRAGMA table_info(${n.table("test")});`)),console.log(await e.raw(n=>n`select last_insert_rowid()`));for(let n=0;n<100;n++)await e.transaction(i=>i.insertInto("test").values({name:`test at ${Date.now()}`,blobtest:Uint8Array.from([2,3,4,5,6,7,8])}).execute());return e.exec(n=>n.selectFrom("test").selectAll().execute())}const wN=new jb({async database(){const t=await Zb({locateFile:()=>eN});return new t.Database(await oN("sqljs"))},onWrite:{func(t){console.log(`[sqljs] write to indexeddb, length: ${t.length}`),uN("sqljs",t)},isThrottle:!0}});function gN(){const t=Ny();function e(){Xf(wN).then(n=>{t.value=n})}return{result:t,run:e}}function bN(){return new Worker(""+new URL("sqljsWorker-342e964b.js",import.meta.url).href)}function NN(){return new Worker(""+new URL("officialWasmWorker-b264d8ca.js",import.meta.url).href)}const Ve=0,vN=5,xt=10,gm=12,bm=14,Vi=21,$l=25,_N=27,Jh=100,xN=101,EN=3850,CN=522,ON=1,qN=2,Nm=4,WN=8,Vs=0,Yi=1,ic=2,IN=3,sc=4,AN=512,TN=1024,SN=2048,kN=16384,Gh=1,Xh=2,Yh=3,Zh=4,ed=5,td=0x7fffffffffffffffn,nd=-0x8000000000000000n;class kr extends Error{constructor(e,n){super(e),this.code=n}}const Hs=!0;function RN(t){const e={},n=t._getSqliteFree(),i=t._malloc(8),a=[i,i+4];function l(b){if(typeof b!="string")return 0;const C=t.lengthBytesUTF8(b),N=t._sqlite3_malloc(C+1);return t.stringToUTF8(b,N,C+1),N}function m(b,C){return BigInt(C)<<32n|BigInt(b)&0xffffffffn}const w=function(){const b=BigInt(Number.MAX_SAFE_INTEGER)>>32n,C=BigInt(Number.MIN_SAFE_INTEGER)>>32n;return function(N,q){return q>b||q2147483647||T<-2147483648)return $l;const ee=C(N,q,T);return te(b,ee,W.get(N))}}(),e.bind_int64=function(){const b="sqlite3_bind_int64",C=t.cwrap(b,...Ce("nnnn:n"));return function(N,q,T){if(B(N),T>td||T>32n,ae=C(N,q,Number(ee),Number(Ne));return te(b,ae,W.get(N))}}(),e.bind_null=function(){const b="sqlite3_bind_null",C=t.cwrap(b,...Ce("nn:n"));return function(N,q){B(N);const T=C(N,q);return te(b,T,W.get(N))}}(),e.bind_parameter_name=function(){const b="sqlite3_bind_parameter_name",C=t.cwrap(b,...Ce("n:s"));return function(N,q){return B(N),C(N,q)}}(),e.bind_text=function(){const b="sqlite3_bind_text",C=t.cwrap(b,...Ce("nnnnn:n"));return function(N,q,T){B(N);const ee=l(T),Ne=C(N,q,ee,-1,n);return te(b,Ne,W.get(N))}}(),e.changes=function(){const b="sqlite3_changes",C=t.cwrap(b,...Ce("n:n"));return function(N){return d(N),C(N)}}(),e.close=function(){const b="sqlite3_close",C=t.cwrap(b,...Ce("n:n"),{async:Hs});return async function(N){d(N);const q=await C(N);return v.delete(N),te(b,q,N)}}(),e.column=function(b,C){B(b);const N=e.column_type(b,C);switch(N){case Zh:return e.column_blob(b,C);case Xh:return e.column_double(b,C);case Gh:const q=e.column_int(b,C),T=t.getTempRet0();return w(q,T);case ed:return null;case Yh:return e.column_text(b,C);default:throw new kr("unknown type",N)}},e.column_blob=function(){const b="sqlite3_column_blob",C=t.cwrap(b,...Ce("nn:n"));return function(N,q){B(N);const T=e.column_bytes(N,q),ee=C(N,q);return t.HEAPU8.subarray(ee,ee+T)}}(),e.column_bytes=function(){const b="sqlite3_column_bytes",C=t.cwrap(b,...Ce("nn:n"));return function(N,q){return B(N),C(N,q)}}(),e.column_count=function(){const b="sqlite3_column_count",C=t.cwrap(b,...Ce("n:n"));return function(N){return B(N),C(N)}}(),e.column_double=function(){const b="sqlite3_column_double",C=t.cwrap(b,...Ce("nn:n"));return function(N,q){return B(N),C(N,q)}}(),e.column_int=function(){const b="sqlite3_column_int64",C=t.cwrap(b,...Ce("nn:n"));return function(N,q){return B(N),C(N,q)}}(),e.column_int64=function(){const b="sqlite3_column_int64",C=t.cwrap(b,...Ce("nn:n"));return function(N,q){B(N);const T=C(N,q),ee=t.getTempRet0();return m(T,ee)}}(),e.column_name=function(){const b="sqlite3_column_name",C=t.cwrap(b,...Ce("nn:s"));return function(N,q){return B(N),C(N,q)}}(),e.column_names=function(b){const C=[],N=e.column_count(b);for(let q=0;qtd||q>32n;C(N,Number(T),Number(ee))}}(),e.result_null=function(){const b="sqlite3_result_null",C=t.cwrap(b,...Ce("n:n"));return function(N){C(N)}}(),e.result_text=function(){const b="sqlite3_result_text",C=t.cwrap(b,...Ce("nnnn:n"));return function(N,q){const T=l(q);C(N,T,-1,n)}}(),e.row=function(b){const C=[],N=e.data_count(b);for(let q=0;q{var t=import.meta.url;return function(e={}){var n;n||(n=typeof e<"u"?e:{});var i,a;n.ready=new Promise((s,u)=>{i=s,a=u});var l=Object.assign({},n),m="./this.program",w=(s,u)=>{throw u},v=typeof window=="object",d=typeof importScripts=="function",W="",B;(v||d)&&(d?W=self.location.href:typeof document<"u"&&document.currentScript&&(W=document.currentScript.src),t&&(W=t),W.indexOf("blob:")!==0?W=W.substr(0,W.replace(/[?#].*/,"").lastIndexOf("/")+1):W="",d&&(B=s=>{var u=new XMLHttpRequest;return u.open("GET",s,!1),u.responseType="arraybuffer",u.send(null),new Uint8Array(u.response)}));var D=n.print||console.log.bind(console),ne=n.printErr||console.warn.bind(console);Object.assign(n,l),l=null,n.thisProgram&&(m=n.thisProgram),n.quit&&(w=n.quit);var te;n.wasmBinary&&(te=n.wasmBinary);var b=n.noExitRuntime||!0;typeof WebAssembly!="object"&&ut("no native wasm support detected");var C,N=!1,q,T,ee,Ne,ae,_e,xe,tt;function ze(){var s=C.buffer;n.HEAP8=T=new Int8Array(s),n.HEAP16=Ne=new Int16Array(s),n.HEAP32=ae=new Int32Array(s),n.HEAPU8=ee=new Uint8Array(s),n.HEAPU16=new Uint16Array(s),n.HEAPU32=_e=new Uint32Array(s),n.HEAPF32=xe=new Float32Array(s),n.HEAPF64=tt=new Float64Array(s)}var qt=[],Wt=[],Qe=[],Kt=[],dn=0;function wt(){var s=n.preRun.shift();qt.unshift(s)}var ge=0,Oe=null;function ut(s){throw n.onAbort&&n.onAbort(s),s="Aborted("+s+")",ne(s),N=!0,q=1,s=new WebAssembly.RuntimeError(s+". Build with -sASSERTIONS for more info."),a(s),s}function we(s){return s.startsWith("data:application/octet-stream;base64,")}var Re;if(n.locateFile){if(Re="wa-sqlite-async.wasm",!we(Re)){var Pt=Re;Re=n.locateFile?n.locateFile(Pt,W):W+Pt}}else Re=new URL(""+new URL("wa-sqlite-async-24800831.wasm",import.meta.url).href,self.location).href;function Ar(s){try{if(s==Re&&te)return new Uint8Array(te);if(B)return B(s);throw"both async and sync fetching of the wasm failed"}catch(u){ut(u)}}function Cs(s){return te||!v&&!d||typeof fetch!="function"?Promise.resolve().then(()=>Ar(s)):fetch(s,{credentials:"same-origin"}).then(u=>{if(!u.ok)throw"failed to load wasm binary file at '"+s+"'";return u.arrayBuffer()}).catch(()=>Ar(s))}function En(s,u,f){return Cs(s).then(y=>WebAssembly.instantiate(y,u)).then(y=>y).then(f,y=>{ne("failed to asynchronously prepare wasm: "+y),ut(y)})}function pn(s,u){var f=Re;return te||typeof WebAssembly.instantiateStreaming!="function"||we(f)||typeof fetch!="function"?En(f,s,u):fetch(f,{credentials:"same-origin"}).then(y=>WebAssembly.instantiateStreaming(y,s).then(u,function(_){return ne("wasm streaming compile failed: "+_),ne("falling back to ArrayBuffer instantiation"),En(f,s,u)}))}var fe,Me;function zn(s){this.name="ExitStatus",this.message="Program terminated with exit("+s+")",this.status=s}function Jt(s){for(;0>0];case"i8":return T[s>>0];case"i16":return Ne[s>>1];case"i32":return ae[s>>2];case"i64":return ae[s>>2];case"float":return xe[s>>2];case"double":return tt[s>>3];case"*":return _e[s>>2];default:ut("invalid type for getValue: "+u)}}function x(s,u,f="i8"){switch(f.endsWith("*")&&(f="*"),f){case"i1":T[s>>0]=u;break;case"i8":T[s>>0]=u;break;case"i16":Ne[s>>1]=u;break;case"i32":ae[s>>2]=u;break;case"i64":Me=[u>>>0,(fe=u,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[s>>2]=Me[0],ae[s+4>>2]=Me[1];break;case"float":xe[s>>2]=u;break;case"double":tt[s>>3]=u;break;case"*":_e[s>>2]=u;break;default:ut("invalid type for setValue: "+f)}}var O=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function R(s,u,f){var y=u+f;for(f=u;s[f]&&!(f>=y);)++f;if(16_?y+=String.fromCharCode(_):(_-=65536,y+=String.fromCharCode(55296|_>>10,56320|_&1023))}}else y+=String.fromCharCode(_)}return y}function F(s,u){return s?R(ee,s,u):""}var K=(s,u)=>{for(var f=0,y=s.length-1;0<=y;y--){var _=s[y];_==="."?s.splice(y,1):_===".."?(s.splice(y,1),f++):f&&(s.splice(y,1),f--)}if(u)for(;f;f--)s.unshift("..");return s},Y=s=>{var u=s.charAt(0)==="/",f=s.substr(-1)==="/";return(s=K(s.split("/").filter(y=>!!y),!u).join("/"))||u||(s="."),s&&f&&(s+="/"),(u?"/":"")+s},j=s=>{var u=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(s).slice(1);return s=u[0],u=u[1],!s&&!u?".":(u&&(u=u.substr(0,u.length-1)),s+u)},z=s=>{if(s==="/")return"/";s=Y(s),s=s.replace(/\/$/,"");var u=s.lastIndexOf("/");return u===-1?s:s.substr(u+1)};function re(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return s=>crypto.getRandomValues(s);ut("initRandomDevice")}function J(s){return(J=re())(s)}function ce(){for(var s="",u=!1,f=arguments.length-1;-1<=f&&!u;f--){if(u=0<=f?arguments[f]:"/",typeof u!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!u)return"";s=u+"/"+s,u=u.charAt(0)==="/"}return s=K(s.split("/").filter(y=>!!y),!u).join("/"),(u?"/":"")+s||"."}function oe(s){for(var u=0,f=0;f=y?u++:2047>=y?u+=2:55296<=y&&57343>=y?(u+=4,++f):u+=3}return u}function ue(s,u,f,y){if(!(0=A){var V=s.charCodeAt(++k);A=65536+((A&1023)<<10)|V&1023}if(127>=A){if(f>=y)break;u[f++]=A}else{if(2047>=A){if(f+1>=y)break;u[f++]=192|A>>6}else{if(65535>=A){if(f+2>=y)break;u[f++]=224|A>>12}else{if(f+3>=y)break;u[f++]=240|A>>18,u[f++]=128|A>>12&63}u[f++]=128|A>>6&63}u[f++]=128|A&63}}return u[f]=0,f-_}var be=[];function Ee(s,u){be[s]={input:[],Rb:[],bc:u},Is(s,je)}var je={open:function(s){var u=be[s.node.ec];if(!u)throw new Z(43);s.Sb=u,s.seekable=!1},close:function(s){s.Sb.bc.ic(s.Sb)},ic:function(s){s.Sb.bc.ic(s.Sb)},read:function(s,u,f,y){if(!s.Sb||!s.Sb.bc.zc)throw new Z(60);for(var _=0,k=0;k=u||(u=Math.max(u,f*(1048576>f?2:1.125)>>>0),f!=0&&(u=Math.max(u,256)),f=s.Nb,s.Nb=new Uint8Array(u),0=s.node.Pb)return 0;if(s=Math.min(s.node.Pb-_,y),8u)throw new Z(28);return u},vc:function(s,u,f){me.xc(s.node,u+f),s.node.Pb=Math.max(s.node.Pb,u+f)},kc:function(s,u,f,y,_){if((s.node.mode&61440)!==32768)throw new Z(43);if(s=s.node.Nb,_&2||s.buffer!==T.buffer){if((0{if(s=ce(s),!s)return{path:"",node:null};if(u=Object.assign({yc:!0,tc:0},u),8!!A);for(var f=Cn,y="/",_=0;_{for(var u;;){if(s===s.parent)return s=s.Ub.Ac,u?s[s.length-1]!=="/"?s+"/"+u:s+u:s;u=u?s.name+"/"+u:s.name,s=s.parent}},Os=(s,u)=>{for(var f=0,y=0;y>>0)%le.length},H=s=>{var u=Os(s.parent.id,s.name);if(le[u]===s)le[u]=s.ac;else for(u=le[u];u;){if(u.ac===s){u.ac=s.ac;break}u=u.ac}},Kn=(s,u)=>{var f;if(f=(f=kr(s,"x"))?f:s.Cb.cc?0:2)throw new Z(f,s);for(f=le[Os(s.id,u)];f;f=f.ac){var y=f.name;if(f.parent.id===s.id&&y===u)return f}return s.Cb.cc(s,u)},Bt=(s,u,f,y)=>(s=new Tu(s,u,f,y),u=Os(s.parent.id,s.name),s.ac=le[u],le[u]=s),Oi={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Ws=s=>{var u=["r","w","rw"][s&3];return s&512&&(u+="w"),u},kr=(s,u)=>{if(Mt)return 0;if(!u.includes("r")||s.mode&292){if(u.includes("w")&&!(s.mode&146)||u.includes("x")&&!(s.mode&73))return 2}else return 2;return 0},wr=(s,u)=>{try{return Kn(s,u),20}catch{}return kr(s,"wx")},Vo=(s,u,f)=>{try{var y=Kn(s,u)}catch(_){return _.Ob}if(s=kr(s,"wx"))return s;if(f){if((y.mode&61440)!==16384)return 54;if(y===y.parent||qn(y)==="/")return 10}else if((y.mode&61440)===16384)return 31;return 0},Cl=(s=0)=>{for(;4096>=s;s++)if(!Gt[s])return s;throw new Z(33)},zo=(s,u)=>(Xr||(Xr=function(){this.hc={}},Xr.prototype={},Object.defineProperties(Xr.prototype,{object:{get:function(){return this.node},set:function(f){this.node=f}},flags:{get:function(){return this.hc.flags},set:function(f){this.hc.flags=f}},position:{get:function(){return this.hc.position},set:function(f){this.hc.position=f}}})),s=Object.assign(new Xr,s),u=Cl(u),s.Wb=u,Gt[u]=s),Kr={open:s=>{s.Mb=qi[s.node.ec].Mb,s.Mb.open&&s.Mb.open(s)},Zb:()=>{throw new Z(70)}},Is=(s,u)=>{qi[s]={Mb:u}},Ko=(s,u)=>{var f=u==="/",y=!u;if(f&&Cn)throw new Z(10);if(!f&&!y){var _=Xt(u,{yc:!1});if(u=_.path,_=_.node,_.$b)throw new Z(10);if((_.mode&61440)!==16384)throw new Z(54)}u={type:s,Wc:{},Ac:u,Mc:[]},s=s.Ub(u),s.Ub=u,u.root=s,f?Cn=s:_&&(_.$b=u,_.Ub&&_.Ub.Mc.push(u))},Jo=(s,u,f)=>{var y=Xt(s,{parent:!0}).node;if(s=z(s),!s||s==="."||s==="..")throw new Z(28);var _=wr(y,s);if(_)throw new Z(_);if(!y.Cb.jc)throw new Z(63);return y.Cb.jc(y,s,u,f)},On=(s,u)=>Jo(s,(u!==void 0?u:511)&1023|16384,0),As=(s,u,f)=>{typeof f>"u"&&(f=u,u=438),Jo(s,u|8192,f)},Wi=(s,u)=>{if(!ce(s))throw new Z(44);var f=Xt(u,{parent:!0}).node;if(!f)throw new Z(44);u=z(u);var y=wr(f,u);if(y)throw new Z(y);if(!f.Cb.nc)throw new Z(63);f.Cb.nc(f,u,s)},Go=s=>{var u=Xt(s,{parent:!0}).node;s=z(s);var f=Kn(u,s),y=Vo(u,s,!0);if(y)throw new Z(y);if(!u.Cb.mc)throw new Z(63);if(f.$b)throw new Z(10);u.Cb.mc(u,s),H(f)},Ii=s=>{if(s=Xt(s).node,!s)throw new Z(44);if(!s.Cb.fc)throw new Z(28);return ce(qn(s.parent),s.Cb.fc(s))},an=(s,u)=>{if(s=Xt(s,{Yb:!u}).node,!s)throw new Z(44);if(!s.Cb.Tb)throw new Z(63);return s.Cb.Tb(s)},Ai=s=>an(s,!0),Ts=(s,u)=>{if(s=typeof s=="string"?Xt(s,{Yb:!0}).node:s,!s.Cb.Qb)throw new Z(63);s.Cb.Qb(s,{mode:u&4095|s.mode&-4096,timestamp:Date.now()})},Xo=(s,u)=>{if(0>u)throw new Z(28);if(s=typeof s=="string"?Xt(s,{Yb:!0}).node:s,!s.Cb.Qb)throw new Z(63);if((s.mode&61440)===16384)throw new Z(31);if((s.mode&61440)!==32768)throw new Z(28);var f=kr(s,"w");if(f)throw new Z(f);s.Cb.Qb(s,{size:u,timestamp:Date.now()})},Ti=(s,u,f)=>{if(s==="")throw new Z(44);if(typeof u=="string"){var y=Oi[u];if(typeof y>"u")throw Error("Unknown file open mode: "+u);u=y}if(f=u&64?(typeof f>"u"?438:f)&4095|32768:0,typeof s=="object")var _=s;else{s=Y(s);try{_=Xt(s,{Yb:!(u&131072)}).node}catch{}}if(y=!1,u&64)if(_){if(u&128)throw new Z(20)}else _=Jo(s,f,0),y=!0;if(!_)throw new Z(44);if((_.mode&61440)===8192&&(u&=-513),u&65536&&(_.mode&61440)!==16384)throw new Z(54);if(!y&&(f=_?(_.mode&61440)===40960?32:(_.mode&61440)===16384&&(Ws(u)!=="r"||u&512)?31:kr(_,Ws(u)):44))throw new Z(f);return u&512&&!y&&Xo(_,0),u&=-131713,_=zo({node:_,path:qn(_),flags:u,seekable:!0,position:0,Mb:_.Mb,Tc:[],error:!1}),_.Mb.open&&_.Mb.open(_),!n.logReadFiles||u&1||(ki||(ki={}),s in ki||(ki[s]=1)),_},Yo=(s,u,f)=>{if(s.Wb===null)throw new Z(8);if(!s.seekable||!s.Mb.Zb)throw new Z(70);if(f!=0&&f!=1&&f!=2)throw new Z(28);s.position=s.Mb.Zb(s,u,f),s.Tc=[]},Jr=()=>{Z||(Z=function(s,u){this.name="ErrnoError",this.node=u,this.Rc=function(f){this.Ob=f},this.Rc(s),this.message="FS error"},Z.prototype=Error(),Z.prototype.constructor=Z,[44].forEach(s=>{Dn[s]=new Z(s),Dn[s].stack=""}))},Zo,ks=(s,u)=>{var f=0;return s&&(f|=365),u&&(f|=146),f},Gr=(s,u,f)=>{s=Y("/dev/"+s);var y=ks(!!u,!!f);gr||(gr=64);var _=gr++<<8|0;Is(_,{open:S=>{S.seekable=!1},close:()=>{f&&f.buffer&&f.buffer.length&&f(10)},read:(S,A,V,M)=>{for(var U=0,ie=0;ie{for(var U=0;U>2]=y.Ic,ae[f+8>>2]=y.qc,ae[f+12>>2]=y.mode,_e[f+16>>2]=y.Oc,ae[f+20>>2]=y.uid,ae[f+24>>2]=y.Lc,ae[f+28>>2]=y.ec,Me=[y.size>>>0,(fe=y.size,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[f+40>>2]=Me[0],ae[f+44>>2]=Me[1],ae[f+48>>2]=4096,ae[f+52>>2]=y.Gc,s=y.Ec.getTime(),u=y.Nc.getTime();var _=y.Hc.getTime();return Me=[Math.floor(s/1e3)>>>0,(fe=Math.floor(s/1e3),1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[f+56>>2]=Me[0],ae[f+60>>2]=Me[1],_e[f+64>>2]=s%1e3*1e3,Me=[Math.floor(u/1e3)>>>0,(fe=Math.floor(u/1e3),1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[f+72>>2]=Me[0],ae[f+76>>2]=Me[1],_e[f+80>>2]=u%1e3*1e3,Me=[Math.floor(_/1e3)>>>0,(fe=Math.floor(_/1e3),1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[f+88>>2]=Me[0],ae[f+92>>2]=Me[1],_e[f+96>>2]=_%1e3*1e3,Me=[y.qc>>>0,(fe=y.qc,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[f+104>>2]=Me[0],ae[f+108>>2]=Me[1],0}var Si=void 0;function Ri(){return Si+=4,ae[Si-4>>2]}function mn(s){if(s=Gt[s],!s)throw new Z(8);return s}function Ln(s,u,f){return ue(s,ee,u,f)}function Di(s){return _e[s>>2]+4294967296*ae[s+4>>2]}var Je=[0,31,60,91,121,152,182,213,244,274,305,335],Li=[0,31,59,90,120,151,181,212,243,273,304,334];function Pi(s){var u=oe(s)+1,f=fa(u);return f&&Ln(s,f,u),f}var Jn={};function Mi(){if(!Yr){var s={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:m||"./this.program"},u;for(u in Jn)Jn[u]===void 0?delete s[u]:s[u]=Jn[u];var f=[];for(u in s)f.push(u+"="+s[u]);Yr=f}return Yr}var Yr;function Bi(){}function yn(){}function Rs(){}function ea(){}function vu(){}function Ds(){}function ta(){}function Ls(){}function na(){}function Ps(){}function Gn(){}function Ms(){}function Bs(){}function Zr(){}function Fs(){}function _u(){}function ra(){}function xu(){}function ia(){}function Fi(){}function Ui(){}function sa(){}function ei(){}function ti(){}function Xn(){}function $i(){}function oa(){}function o(){}function c(){}function h(){}function w(){}function E(){}function L(){}function Q(){}function ve(){}function Pe(){}function De(){}function ct(){}function Pn(){}function aa(s){O=s,b||0{ca={resolve:s,reject:u}})}function Il(){var s=fa(12300),u=s+12;ae[s>>2]=u,ae[s+4>>2]=u+12288,u=Us[0];var f=Cu[u];return f===void 0&&(f=Ol++,Cu[u]=f,qu[f]=u),ae[s+8>>2]=f,s}function Wu(s){if(!N){if(Yn===0){var u=!1,f=!1;s((y=0)=>{if(!N&&(Eu=y,u=!0,f)){Yn=2,Qi(()=>ji(Mn)),y=!1;try{var _=(0,n.asm[qu[ae[Mn+8>>2]]])()}catch(V){_=V,y=!0}var S=!1;if(!Mn){var A=ca;A&&(ca=null,(y?A.reject:A.resolve)(_),S=!0)}if(y&&!S)throw _}}),f=!0,u||(Yn=1,Mn=Il(),Qi(()=>Pu(Mn)))}else Yn===2?(Yn=0,Qi(pa),ku(Mn),Mn=null,Wl.forEach(y=>{if(!N)try{if(y(),!(b||0{s().then(u)})}var Au={};function Bn(s,u,f,y,_){function S(X){return--dn,M!==0&&ha(M),u==="string"?F(X):u==="boolean"?!!X:X}var A={string:X=>{var se=0;if(X!=null&&X!==0){se=oe(X)+1;var Ae=da(se);Ln(X,Ae,se),se=Ae}return se},array:X=>{var se=da(X.length);return T.set(X,se),se}};s=n["_"+s];var V=[],M=0;if(y)for(var U=0;U{On("/dev"),Is(259,{read:()=>0,write:(y,_,S,A)=>A}),As("/dev/null",259),Ee(1280,Le),Ee(1536,it),As("/dev/tty",1280),As("/dev/tty1",1536);var s=new Uint8Array(1024),u=0,f=()=>(u===0&&(u=J(s).byteLength),s[--u]);Gr("random",f),Gr("urandom",f),On("/dev/shm"),On("/dev/shm/tmp")})(),(()=>{On("/proc");var s=On("/proc/self");On("/proc/self/fd"),Ko({Ub:()=>{var u=Bt(s,"fd",16895,73);return u.Cb={cc:(f,y)=>{var _=Gt[+y];if(!_)throw new Z(8);return f={parent:null,Ub:{Ac:"fake"},Cb:{fc:()=>_.path}},f.parent=f}},u}},"/proc/self/fd")})(),function(){const s=new Map;n.setAuthorizer=function(u,f,y){return f?s.set(u,{f,uc:y}):s.delete(u),Bn("set_authorizer","number",["number"],[u])},Bi=function(u,f,y,_,S,A){if(s.has(u)){const{f:V,uc:M}=s.get(u);return V(M,f,y?F(y):null,_?F(_):null,S?F(S):null,A?F(A):null)}return 0}}(),function(){const s=new Map,u=new Map;n.createFunction=function(f,y,_,S,A,V){const M=s.size;return s.set(M,{f:V,Xb:A}),Bn("create_function","number","number string number number number number".split(" "),[f,y,_,S,M,0])},n.createAggregate=function(f,y,_,S,A,V,M){const U=s.size;return s.set(U,{step:V,Jc:M,Xb:A}),Bn("create_function","number","number string number number number number".split(" "),[f,y,_,S,U,1])},n.getFunctionUserData=function(f){return u.get(f)},Rs=function(f,y,_,S){f=s.get(f),u.set(y,f.Xb),f.f(y,new Uint32Array(ee.buffer,S,_)),u.delete(y)},vu=function(f,y,_,S){f=s.get(f),u.set(y,f.Xb),f.step(y,new Uint32Array(ee.buffer,S,_)),u.delete(y)},yn=function(f,y){f=s.get(f),u.set(y,f.Xb),f.Jc(y),u.delete(y)}}(),function(){const s=new Map;n.progressHandler=function(u,f,y,_){return y?s.set(u,{f:y,uc:_}):s.delete(u),Bn("progress_handler",null,["number","number"],[u,f])},ea=function(u){if(s.has(u)){const{f,uc:y}=s.get(u);return f(y)}return 0}}(),function(){function s(M,U){const ie=`get${M}`,X=`set${M}`;return new Proxy(new DataView(ee.buffer,U,M==="Int32"?4:8),{get(se,Ae){if(Ae===ie)return function(Ge,At){if(!At)throw Error("must be little endian");return se[Ae](Ge,At)};if(Ae===X)return function(Ge,At,vt){if(!vt)throw Error("must be little endian");return se[Ae](Ge,At,vt)};if(typeof Ae=="string"&&Ae.match(/^(get)|(set)/))throw Error("invalid type");return se[Ae]}})}const u=typeof Au=="object",f=new Map,y=new Map,_=new Map,S=u?new Set:null,A=u?new Set:null,V=new Map;sa=function(M,U,ie,X){V.set(F(M),{size:U,dc:Array.from(new Uint32Array(ee.buffer,X,ie))})},n.createModule=function(M,U,ie,X){u&&(ie.handleAsync=Iu);const se=f.size;return f.set(se,{module:ie,Xb:X}),X=0,ie.xCreate&&(X|=1),ie.xConnect&&(X|=2),ie.xBestIndex&&(X|=4),ie.xDisconnect&&(X|=8),ie.xDestroy&&(X|=16),ie.xOpen&&(X|=32),ie.xClose&&(X|=64),ie.xFilter&&(X|=128),ie.xNext&&(X|=256),ie.xEof&&(X|=512),ie.xColumn&&(X|=1024),ie.xRowid&&(X|=2048),ie.xUpdate&&(X|=4096),ie.xBegin&&(X|=8192),ie.xSync&&(X|=16384),ie.xCommit&&(X|=32768),ie.xRollback&&(X|=65536),ie.xFindFunction&&(X|=131072),ie.xRename&&(X|=262144),Bn("create_module","number",["number","string","number","number"],[M,U,se,X])},Ms=function(M,U,ie,X,se,Ae){if(U=f.get(U),y.set(se,U),u){S.delete(se);for(const Ge of S)y.delete(Ge)}return X=Array.from(new Uint32Array(ee.buffer,X,ie)).map(Ge=>F(Ge)),U.module.xCreate(M,U.Xb,X,se,s("Int32",Ae))},Gn=function(M,U,ie,X,se,Ae){if(U=f.get(U),y.set(se,U),u){S.delete(se);for(const Ge of S)y.delete(Ge)}return X=Array.from(new Uint32Array(ee.buffer,X,ie)).map(Ge=>F(Ge)),U.module.xConnect(M,U.Xb,X,se,s("Int32",Ae))},ta=function(M,U){var ie=y.get(M),X=V.get("sqlite3_index_info").dc;const se={};se.nConstraint=Ke(U+X[0],"i32"),se.aConstraint=[];for(var Ae=Ke(U+X[1],"*"),Ge=V.get("sqlite3_index_constraint").size,At=0;At>=2,_e[A]+_e[A+1]*2**32}const f=typeof Au=="object",y=new Map,_=new Map;n.registerVFS=function(A,V){if(Bn("sqlite3_vfs_find","number",["string"],[A.name]))throw Error(`VFS '${A.name}' already registered`);f&&(A.handleAsync=Iu);var M=A.Vc??64;const U=n._malloc(4);return V=Bn("register_vfs","number",["string","number","number","number"],[A.name,M,V?1:0,U]),V||(M=Ke(U,"*"),y.set(M,A)),n._free(U),V};const S=f?new Set:null;oa=function(A){const V=_.get(A);return f?S.add(A):_.delete(A),V.xClose(A)},Q=function(A,V,M,U){return _.get(A).xRead(A,ee.subarray(V,V+M),u(U))},Pn=function(A,V,M,U){return _.get(A).xWrite(A,ee.subarray(V,V+M),u(U))},De=function(A,V){return _.get(A).xTruncate(A,u(V))},Pe=function(A,V){return _.get(A).xSync(A,V)},w=function(A,V){const M=_.get(A);return V=s("BigInt64",V),M.xFileSize(A,V)},E=function(A,V){return _.get(A).xLock(A,V)},ct=function(A,V){return _.get(A).xUnlock(A,V)},$i=function(A,V){const M=_.get(A);return V=s("Int32",V),M.xCheckReservedLock(A,V)},h=function(A,V,M){const U=_.get(A);return M=new DataView(ee.buffer,M),U.xFileControl(A,V,M)},ve=function(A){return _.get(A).xSectorSize(A)},c=function(A){return _.get(A).xDeviceCharacteristics(A)},L=function(A,V,M,U,ie){if(A=y.get(A),_.set(M,A),f){S.delete(M);for(var X of S)_.delete(X)}if(X=null,U&64){X=1;const se=[];for(;X;){const Ae=ee[V++];if(Ae)se.push(Ae);else switch(ee[V]||(X=null),X){case 1:se.push(63),X=2;break;case 2:se.push(61),X=3;break;case 3:se.push(38),X=2}}X=new TextDecoder().decode(new Uint8Array(se))}else V&&(X=F(V));return ie=s("Int32",ie),A.xOpen(X,M,U,ie)},o=function(A,V,M){return y.get(A).xDelete(F(V),M)},Xn=function(A,V,M,U){return A=y.get(A),U=s("Int32",U),A.xAccess(F(V),M,U)}}();var Al={a:function(s,u,f,y){ut("Assertion failed: "+F(s)+", at: "+[u?F(u):"unknown filename",f,y?F(y):"unknown function"])},K:function(s,u){try{return s=F(s),Ts(s,u),0}catch(f){if(typeof He>"u"||f.name!=="ErrnoError")throw f;return-f.Ob}},M:function(s,u,f){try{if(u=F(u),u=br(s,u),f&-8)return-28;var y=Xt(u,{Yb:!0}).node;return y?(s="",f&4&&(s+="r"),f&2&&(s+="w"),f&1&&(s+="x"),s&&kr(y,s)?-2:0):-44}catch(_){if(typeof He>"u"||_.name!=="ErrnoError")throw _;return-_.Ob}},L:function(s,u){try{var f=Gt[s];if(!f)throw new Z(8);return Ts(f.node,u),0}catch(y){if(typeof He>"u"||y.name!=="ErrnoError")throw y;return-y.Ob}},J:function(s){try{var u=Gt[s];if(!u)throw new Z(8);var f=u.node,y=typeof f=="string"?Xt(f,{Yb:!0}).node:f;if(!y.Cb.Qb)throw new Z(63);return y.Cb.Qb(y,{timestamp:Date.now()}),0}catch(_){if(typeof He>"u"||_.name!=="ErrnoError")throw _;return-_.Ob}},b:function(s,u,f){Si=f;try{var y=mn(s);switch(u){case 0:var _=Ri();return 0>_?-28:zo(y,_).Wb;case 1:case 2:return 0;case 3:return y.flags;case 4:return _=Ri(),y.flags|=_,0;case 5:return _=Ri(),Ne[_+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return ae[la()>>2]=28,-1;default:return-28}}catch(S){if(typeof He>"u"||S.name!=="ErrnoError")throw S;return-S.Ob}},I:function(s,u){try{var f=mn(s);return Ss(an,f.path,u)}catch(y){if(typeof He>"u"||y.name!=="ErrnoError")throw y;return-y.Ob}},j:function(s,u,f){try{if(u=f+2097152>>>0<4194305-!!u?(u>>>0)+4294967296*f:NaN,isNaN(u))return-61;var y=Gt[s];if(!y)throw new Z(8);if(!(y.flags&2097155))throw new Z(28);return Xo(y.node,u),0}catch(_){if(typeof He>"u"||_.name!=="ErrnoError")throw _;return-_.Ob}},C:function(s,u){try{if(u===0)return-28;var f=oe("/")+1;return u"u"||y.name!=="ErrnoError")throw y;return-y.Ob}},F:function(s,u){try{return s=F(s),Ss(Ai,s,u)}catch(f){if(typeof He>"u"||f.name!=="ErrnoError")throw f;return-f.Ob}},z:function(s,u,f){try{return u=F(u),u=br(s,u),u=Y(u),u[u.length-1]==="/"&&(u=u.substr(0,u.length-1)),On(u,f),0}catch(y){if(typeof He>"u"||y.name!=="ErrnoError")throw y;return-y.Ob}},E:function(s,u,f,y){try{u=F(u);var _=y&256;return u=br(s,u,y&4096),Ss(_?Ai:an,u,f)}catch(S){if(typeof He>"u"||S.name!=="ErrnoError")throw S;return-S.Ob}},u:function(s,u,f,y){Si=y;try{u=F(u),u=br(s,u);var _=y?Ri():0;return Ti(u,f,_).Wb}catch(S){if(typeof He>"u"||S.name!=="ErrnoError")throw S;return-S.Ob}},s:function(s,u,f,y){try{if(u=F(u),u=br(s,u),0>=y)return-28;var _=Ii(u),S=Math.min(y,oe(_)),A=T[f+S];return Ln(_,f,y+1),T[f+S]=A,S}catch(V){if(typeof He>"u"||V.name!=="ErrnoError")throw V;return-V.Ob}},r:function(s){try{return s=F(s),Go(s),0}catch(u){if(typeof He>"u"||u.name!=="ErrnoError")throw u;return-u.Ob}},H:function(s,u){try{return s=F(s),Ss(an,s,u)}catch(f){if(typeof He>"u"||f.name!=="ErrnoError")throw f;return-f.Ob}},o:function(s,u,f){try{if(u=F(u),u=br(s,u),f===0){s=u;var y=Xt(s,{parent:!0}).node;if(!y)throw new Z(44);var _=z(s),S=Kn(y,_),A=Vo(y,_,!1);if(A)throw new Z(A);if(!y.Cb.oc)throw new Z(63);if(S.$b)throw new Z(10);y.Cb.oc(y,_),H(S)}else f===512?Go(u):ut("Invalid flags passed to unlinkat");return 0}catch(V){if(typeof He>"u"||V.name!=="ErrnoError")throw V;return-V.Ob}},n:function(s,u,f){try{if(u=F(u),u=br(s,u,!0),f){var y=Di(f),_=ae[f+8>>2];S=1e3*y+_/1e6,f+=16,y=Di(f),_=ae[f+8>>2],A=1e3*y+_/1e6}else var S=Date.now(),A=S;s=S;var V=Xt(u,{Yb:!0}).node;return V.Cb.Qb(V,{timestamp:Math.max(s,A)}),0}catch(M){if(typeof He>"u"||M.name!=="ErrnoError")throw M;return-M.Ob}},y:function(s,u){s=new Date(1e3*Di(s)),ae[u>>2]=s.getSeconds(),ae[u+4>>2]=s.getMinutes(),ae[u+8>>2]=s.getHours(),ae[u+12>>2]=s.getDate(),ae[u+16>>2]=s.getMonth(),ae[u+20>>2]=s.getFullYear()-1900,ae[u+24>>2]=s.getDay();var f=s.getFullYear();ae[u+28>>2]=(f%4!==0||f%100===0&&f%400!==0?Li:Je)[s.getMonth()]+s.getDate()-1|0,ae[u+36>>2]=-(60*s.getTimezoneOffset()),f=new Date(s.getFullYear(),6,1).getTimezoneOffset();var y=new Date(s.getFullYear(),0,1).getTimezoneOffset();ae[u+32>>2]=(f!=y&&s.getTimezoneOffset()==Math.min(y,f))|0},w:function(s,u,f,y,_,S,A){try{var V=mn(y);if(u&2&&!(f&2)&&(V.flags&2097155)!==2)throw new Z(2);if((V.flags&2097155)===1)throw new Z(2);if(!V.Mb.kc)throw new Z(43);var M=V.Mb.kc(V,s,_,u,f),U=M.Pc;return ae[S>>2]=M.Dc,_e[A>>2]=U,0}catch(ie){if(typeof He>"u"||ie.name!=="ErrnoError")throw ie;return-ie.Ob}},x:function(s,u,f,y,_,S){try{var A=mn(_);if(f&2){if((A.node.mode&61440)!==32768)throw new Z(43);y&2||A.Mb.lc&&A.Mb.lc(A,ee.slice(s,s+u),S,u,y)}}catch(V){if(typeof He>"u"||V.name!=="ErrnoError")throw V;return-V.Ob}},p:function(s,u,f){function y(M){return(M=M.toTimeString().match(/\(([A-Za-z ]+)\)$/))?M[1]:"GMT"}var _=new Date().getFullYear(),S=new Date(_,0,1),A=new Date(_,6,1);_=S.getTimezoneOffset();var V=A.getTimezoneOffset();_e[s>>2]=60*Math.max(_,V),ae[u>>2]=+(_!=V),s=y(S),u=y(A),s=Pi(s),u=Pi(u),V<_?(_e[f>>2]=s,_e[f+4>>2]=u):(_e[f>>2]=u,_e[f+4>>2]=s)},e:function(){return Date.now()},d:()=>performance.now(),l:function(s){var u=ee.length;if(s>>>=0,2147483648=f;f*=2){var y=u*(1+.2/f);y=Math.min(y,s+100663296);var _=Math,S=_.min;y=Math.max(s,y),y+=(65536-y%65536)%65536;e:{var A=C.buffer;try{C.grow(S.call(_,2147483648,y)-A.byteLength+65535>>>16),ze();var V=1;break e}catch{}V=void 0}if(V)return!0}return!1},A:function(s,u){var f=0;return Mi().forEach(function(y,_){var S=u+f;for(_=_e[s+4*_>>2]=S,S=0;S>0]=y.charCodeAt(S);T[_>>0]=0,f+=y.length+1}),0},B:function(s,u){var f=Mi();_e[s>>2]=f.length;var y=0;return f.forEach(function(_){y+=_.length+1}),_e[u>>2]=y,0},f:function(s){try{var u=mn(s);if(u.Wb===null)throw new Z(8);u.pc&&(u.pc=null);try{u.Mb.close&&u.Mb.close(u)}catch(f){throw f}finally{Gt[u.Wb]=null}return u.Wb=null,0}catch(f){if(typeof He>"u"||f.name!=="ErrnoError")throw f;return f.Ob}},m:function(s,u){try{var f=mn(s);return T[u>>0]=f.Sb?2:(f.mode&61440)===16384?3:(f.mode&61440)===40960?7:4,Ne[u+2>>1]=0,Me=[0,(fe=0,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[u+8>>2]=Me[0],ae[u+12>>2]=Me[1],Me=[0,(fe=0,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[u+16>>2]=Me[0],ae[u+20>>2]=Me[1],0}catch(y){if(typeof He>"u"||y.name!=="ErrnoError")throw y;return y.Ob}},t:function(s,u,f,y){try{e:{var _=mn(s);s=u;for(var S,A=u=0;A>2],M=_e[s+4>>2];s+=8;var U=_,ie=V,X=M,se=S,Ae=T;if(0>X||0>se)throw new Z(28);if(U.Wb===null)throw new Z(8);if((U.flags&2097155)===1)throw new Z(8);if((U.node.mode&61440)===16384)throw new Z(31);if(!U.Mb.read)throw new Z(28);var Ge=typeof se<"u";if(!Ge)se=U.position;else if(!U.seekable)throw new Z(70);var At=U.Mb.read(U,Ae,ie,X,se);Ge||(U.position+=At);var vt=At;if(0>vt){var wn=-1;break e}if(u+=vt,vt>2]=wn,0}catch(Ft){if(typeof He>"u"||Ft.name!=="ErrnoError")throw Ft;return Ft.Ob}},i:function(s,u,f,y,_){try{if(u=f+2097152>>>0<4194305-!!u?(u>>>0)+4294967296*f:NaN,isNaN(u))return 61;var S=mn(s);return Yo(S,u,y),Me=[S.position>>>0,(fe=S.position,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[_>>2]=Me[0],ae[_+4>>2]=Me[1],S.pc&&u===0&&y===0&&(S.pc=null),0}catch(A){if(typeof He>"u"||A.name!=="ErrnoError")throw A;return A.Ob}},D:function(s){try{var u=mn(s);return Wu(function(f){var y=u.node.Ub;y.type.Sc?y.type.Sc(y,!1,function(_){f(_?function(){return 29}:0)}):f(0)})}catch(f){if(typeof He>"u"||f.name!=="ErrnoError")throw f;return f.Ob}},q:function(s,u,f,y){try{e:{var _=mn(s);s=u;for(var S,A=u=0;A>2],M=_e[s+4>>2];s+=8;var U=_,ie=V,X=M,se=S,Ae=T;if(0>X||0>se)throw new Z(28);if(U.Wb===null)throw new Z(8);if(!(U.flags&2097155))throw new Z(8);if((U.node.mode&61440)===16384)throw new Z(31);if(!U.Mb.write)throw new Z(28);U.seekable&&U.flags&1024&&Yo(U,0,2);var Ge=typeof se<"u";if(!Ge)se=U.position;else if(!U.seekable)throw new Z(70);var At=U.Mb.write(U,Ae,ie,X,se,void 0);Ge||(U.position+=At);var vt=At;if(0>vt){var wn=-1;break e}u+=vt,typeof S<"u"&&(S+=vt)}wn=u}return _e[y>>2]=wn,0}catch(Ft){if(typeof He>"u"||Ft.name!=="ErrnoError")throw Ft;return Ft.Ob}},ra:Bi,N:yn,ga:Rs,ca:ea,Y:vu,la:Ds,G:ta,h:Ls,oa:na,ja:Ps,ea:Gn,fa:Ms,k:Bs,v:Zr,pa:Fs,g:_u,qa:ra,da:xu,ha:ia,ia:Fi,na:Ui,c:sa,ka:ei,ma:ti,aa:Xn,V:$i,$:oa,ba:o,S:c,U:h,Z:w,X:E,R:L,Q,T:ve,_:Pe,O:De,W:ct,P:Pn};(function(){function s(f){if(f=f.exports,f=ql(f),n.asm=f,C=n.asm.sa,ze(),Wt.unshift(n.asm.ta),ge--,n.monitorRunDependencies&&n.monitorRunDependencies(ge),ge==0&&qe){var y=qe;qe=null,y()}return f}var u={a:Al};if(ge++,n.monitorRunDependencies&&n.monitorRunDependencies(ge),n.instantiateWasm)try{return n.instantiateWasm(u,s)}catch(f){ne("Module.instantiateWasm callback failed with error: "+f),a(f)}return pn(u,function(f){s(f.instance)}).catch(a),{}})(),n._sqlite3_vfs_find=function(){return(n._sqlite3_vfs_find=n.asm.ua).apply(null,arguments)},n._sqlite3_malloc=function(){return(n._sqlite3_malloc=n.asm.va).apply(null,arguments)},n._sqlite3_free=function(){return(n._sqlite3_free=n.asm.wa).apply(null,arguments)},n._sqlite3_prepare_v2=function(){return(n._sqlite3_prepare_v2=n.asm.xa).apply(null,arguments)},n._sqlite3_step=function(){return(n._sqlite3_step=n.asm.ya).apply(null,arguments)},n._sqlite3_column_int64=function(){return(n._sqlite3_column_int64=n.asm.za).apply(null,arguments)},n._sqlite3_column_int=function(){return(n._sqlite3_column_int=n.asm.Aa).apply(null,arguments)},n._sqlite3_finalize=function(){return(n._sqlite3_finalize=n.asm.Ba).apply(null,arguments)},n._sqlite3_reset=function(){return(n._sqlite3_reset=n.asm.Ca).apply(null,arguments)},n._sqlite3_clear_bindings=function(){return(n._sqlite3_clear_bindings=n.asm.Da).apply(null,arguments)},n._sqlite3_value_blob=function(){return(n._sqlite3_value_blob=n.asm.Ea).apply(null,arguments)},n._sqlite3_value_text=function(){return(n._sqlite3_value_text=n.asm.Fa).apply(null,arguments)},n._sqlite3_value_bytes=function(){return(n._sqlite3_value_bytes=n.asm.Ga).apply(null,arguments)},n._sqlite3_value_double=function(){return(n._sqlite3_value_double=n.asm.Ha).apply(null,arguments)},n._sqlite3_value_int=function(){return(n._sqlite3_value_int=n.asm.Ia).apply(null,arguments)},n._sqlite3_value_int64=function(){return(n._sqlite3_value_int64=n.asm.Ja).apply(null,arguments)},n._sqlite3_value_type=function(){return(n._sqlite3_value_type=n.asm.Ka).apply(null,arguments)},n._sqlite3_result_blob=function(){return(n._sqlite3_result_blob=n.asm.La).apply(null,arguments)},n._sqlite3_result_double=function(){return(n._sqlite3_result_double=n.asm.Ma).apply(null,arguments)},n._sqlite3_result_error=function(){return(n._sqlite3_result_error=n.asm.Na).apply(null,arguments)},n._sqlite3_result_int=function(){return(n._sqlite3_result_int=n.asm.Oa).apply(null,arguments)},n._sqlite3_result_int64=function(){return(n._sqlite3_result_int64=n.asm.Pa).apply(null,arguments)},n._sqlite3_result_null=function(){return(n._sqlite3_result_null=n.asm.Qa).apply(null,arguments)},n._sqlite3_result_text=function(){return(n._sqlite3_result_text=n.asm.Ra).apply(null,arguments)},n._sqlite3_column_count=function(){return(n._sqlite3_column_count=n.asm.Sa).apply(null,arguments)},n._sqlite3_data_count=function(){return(n._sqlite3_data_count=n.asm.Ta).apply(null,arguments)},n._sqlite3_column_blob=function(){return(n._sqlite3_column_blob=n.asm.Ua).apply(null,arguments)},n._sqlite3_column_bytes=function(){return(n._sqlite3_column_bytes=n.asm.Va).apply(null,arguments)},n._sqlite3_column_double=function(){return(n._sqlite3_column_double=n.asm.Wa).apply(null,arguments)},n._sqlite3_column_text=function(){return(n._sqlite3_column_text=n.asm.Xa).apply(null,arguments)},n._sqlite3_column_type=function(){return(n._sqlite3_column_type=n.asm.Ya).apply(null,arguments)},n._sqlite3_column_name=function(){return(n._sqlite3_column_name=n.asm.Za).apply(null,arguments)},n._sqlite3_bind_blob=function(){return(n._sqlite3_bind_blob=n.asm._a).apply(null,arguments)},n._sqlite3_bind_double=function(){return(n._sqlite3_bind_double=n.asm.$a).apply(null,arguments)},n._sqlite3_bind_int=function(){return(n._sqlite3_bind_int=n.asm.ab).apply(null,arguments)},n._sqlite3_bind_int64=function(){return(n._sqlite3_bind_int64=n.asm.bb).apply(null,arguments)},n._sqlite3_bind_null=function(){return(n._sqlite3_bind_null=n.asm.cb).apply(null,arguments)},n._sqlite3_bind_text=function(){return(n._sqlite3_bind_text=n.asm.db).apply(null,arguments)},n._sqlite3_bind_parameter_count=function(){return(n._sqlite3_bind_parameter_count=n.asm.eb).apply(null,arguments)},n._sqlite3_bind_parameter_name=function(){return(n._sqlite3_bind_parameter_name=n.asm.fb).apply(null,arguments)},n._sqlite3_sql=function(){return(n._sqlite3_sql=n.asm.gb).apply(null,arguments)},n._sqlite3_exec=function(){return(n._sqlite3_exec=n.asm.hb).apply(null,arguments)},n._sqlite3_errmsg=function(){return(n._sqlite3_errmsg=n.asm.ib).apply(null,arguments)},n._sqlite3_declare_vtab=function(){return(n._sqlite3_declare_vtab=n.asm.jb).apply(null,arguments)},n._sqlite3_libversion=function(){return(n._sqlite3_libversion=n.asm.kb).apply(null,arguments)},n._sqlite3_libversion_number=function(){return(n._sqlite3_libversion_number=n.asm.lb).apply(null,arguments)},n._sqlite3_changes=function(){return(n._sqlite3_changes=n.asm.mb).apply(null,arguments)},n._sqlite3_close=function(){return(n._sqlite3_close=n.asm.nb).apply(null,arguments)},n._sqlite3_limit=function(){return(n._sqlite3_limit=n.asm.ob).apply(null,arguments)},n._sqlite3_open_v2=function(){return(n._sqlite3_open_v2=n.asm.pb).apply(null,arguments)},n._sqlite3_get_autocommit=function(){return(n._sqlite3_get_autocommit=n.asm.qb).apply(null,arguments)};function la(){return(la=n.asm.rb).apply(null,arguments)}var fa=n._malloc=function(){return(fa=n._malloc=n.asm.sb).apply(null,arguments)},ku=n._free=function(){return(ku=n._free=n.asm.tb).apply(null,arguments)};n._RegisterExtensionFunctions=function(){return(n._RegisterExtensionFunctions=n.asm.ub).apply(null,arguments)},n._set_authorizer=function(){return(n._set_authorizer=n.asm.vb).apply(null,arguments)},n._create_function=function(){return(n._create_function=n.asm.wb).apply(null,arguments)},n._create_module=function(){return(n._create_module=n.asm.xb).apply(null,arguments)},n._progress_handler=function(){return(n._progress_handler=n.asm.yb).apply(null,arguments)},n._register_vfs=function(){return(n._register_vfs=n.asm.zb).apply(null,arguments)},n._getSqliteFree=function(){return(n._getSqliteFree=n.asm.Ab).apply(null,arguments)};var Su=n._main=function(){return(Su=n._main=n.asm.Bb).apply(null,arguments)};function Ru(){return(Ru=n.asm.Db).apply(null,arguments)}function Du(){return(Du=n.asm.Eb).apply(null,arguments)}function Lu(){return(Lu=n.asm.Fb).apply(null,arguments)}function ha(){return(ha=n.asm.Gb).apply(null,arguments)}function da(){return(da=n.asm.Hb).apply(null,arguments)}function Pu(){return(Pu=n.asm.Ib).apply(null,arguments)}function Mu(){return(Mu=n.asm.Jb).apply(null,arguments)}function ji(){return(ji=n.asm.Kb).apply(null,arguments)}function pa(){return(pa=n.asm.Lb).apply(null,arguments)}n.getTempRet0=Du,n.ccall=Bn,n.cwrap=function(s,u,f,y){var _=!f||f.every(S=>S==="number"||S==="boolean");return u!=="string"&&_&&!y?n["_"+s]:function(){return Bn(s,u,f,arguments,y)}},n.setValue=x,n.getValue=Ke,n.UTF8ToString=F,n.stringToUTF8=Ln,n.lengthBytesUTF8=oe;var $s;qe=function s(){$s||W(),$s||(qe=s)};function W(){function s(){if(!$s&&($s=!0,n.calledRun=!0,!N)){if(n.noFSInit||Zo||(Zo=!0,Jr(),n.stdin=n.stdin,n.stdout=n.stdout,n.stderr=n.stderr,n.stdin?Gr("stdin",n.stdin):Wi("/dev/tty","/dev/stdin"),n.stdout?Gr("stdout",null,n.stdout):Wi("/dev/tty","/dev/stdout"),n.stderr?Gr("stderr",null,n.stderr):Wi("/dev/tty1","/dev/stderr"),Ti("/dev/stdin",0),Ti("/dev/stdout",1),Ti("/dev/stderr",1)),Mt=!1,Jt(Wt),Jt(Qe),i(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),G){var u=Su;try{var f=u(0,0);O=f,aa(f)}catch(y){ua(y)}}if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)u=n.postRun.shift(),Kt.unshift(u);Jt(Kt)}}if(!(0{try{await navigator.locks.request(e,n,l=>{if(i(l),l)return new Promise(m=>r(this,Wo).set(e,m))})}catch(l){a(l)}})}_releaseWebLock(e){var n;(n=r(this,Wo).get(e))==null||n(),r(this,Wo).delete(e)}async _pollWebLock(e){var i;return(i=(await navigator.locks.query()).held.find(({name:a})=>a===e))==null?void 0:i.mode}_getTimeoutSignal(){if(this.timeoutMillis){const e=new AbortController;return setTimeout(()=>e.abort(),this.timeoutMillis),e.signal}}}jt=new WeakMap,Wo=new WeakMap,lu=new WeakMap,fu=new WeakSet,wf=async function(e,n){const i=n&PN;try{const a=()=>e.call(this,i);return await P(this,lu,r(this,lu).then(a,a)),P(this,jt,i),Ve}catch(a){return a.name==="AbortError"?vN:(console.error(a),EN)}},Zc=new WeakSet,vm=async function(e){if(e===r(this,jt))return Ve;switch(r(this,jt)){case Vs:switch(e){case Zi:return this._NONEtoSHARED();default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}case Zi:switch(e){case ic:return this._SHAREDtoRESERVED();case sc:return this._SHAREDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}case ic:switch(e){case sc:return this._RESERVEDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}},el=new WeakSet,_m=async function(e){if(e===r(this,jt))return Ve;switch(r(this,jt)){case sc:switch(e){case Zi:return this._EXCLUSIVEtoSHARED();case Vs:return this._EXCLUSIVEtoNONE();default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}case ic:switch(e){case Zi:return this._RESERVEDtoSHARED();case Vs:return this._RESERVEDtoNONE();default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}case Zi:switch(e){case Vs:return this._SHAREDtoNONE();default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}};class BN extends MN{constructor(e){super(),this._lockName=e+"-outer",this._reservedName=e+"-reserved"}async isSomewhereReserved(){return await this._pollWebLock(this._reservedName)==="exclusive"}async _NONEtoSHARED(){await this._acquireWebLock(this._lockName,{mode:"exclusive",signal:this._getTimeoutSignal()})}async _SHAREDtoRESERVED(){await this._acquireWebLock(this._reservedName,{mode:"exclusive",signal:this._getTimeoutSignal()})}async _RESERVEDtoSHARED(){this._releaseWebLock(this._reservedName)}async _SHAREDtoNONE(){this._releaseWebLock(this._lockName)}}const FN=5e3;let UN=0;const Ql=new WeakMap;function _r(...t){}var Io,Ao,hu,Rt,du,To,ys,tl,xm;class $N{constructor(e,n={durability:"default"}){k(this,tl);k(this,Io,void 0);k(this,Ao,void 0);k(this,hu,void 0);k(this,Rt,null);k(this,du,0);k(this,To,Promise.resolve());k(this,ys,Promise.resolve());P(this,Ao,Promise.resolve(e).then(i=>P(this,Io,i))),P(this,hu,n)}async close(){const e=r(this,Io)??await r(this,Ao);await r(this,To),await this.sync(),e.close()}async run(e,n){const i=r(this,To).then(()=>Oe(this,tl,xm).call(this,e,n));return P(this,To,i.catch(()=>{})),i}async sync(){await r(this,ys),P(this,ys,Promise.resolve())}}Io=new WeakMap,Ao=new WeakMap,hu=new WeakMap,Rt=new WeakMap,du=new WeakMap,To=new WeakMap,ys=new WeakMap,tl=new WeakSet,xm=async function(e,n){var a,l;const i=r(this,Io)??await r(this,Ao);if(e==="readwrite"&&((a=r(this,Rt))==null?void 0:a.mode)==="readonly")P(this,Rt,null);else if(performance.now()-r(this,du)>FN){try{(l=r(this,Rt))==null||l.commit()}catch(m){if(m.name!=="InvalidStateError")throw m}await new Promise(m=>setTimeout(m)),P(this,Rt,null)}for(let m=0;m<2;++m){if(!r(this,Rt)){P(this,Rt,i.transaction(i.objectStoreNames,e,r(this,hu)));const g=P(this,du,performance.now());P(this,ys,r(this,ys).then(()=>new Promise((v,d)=>{r(this,Rt).addEventListener("complete",I=>{v(),r(this,Rt)===I.target&&P(this,Rt,null),_r(`transaction ${Ql.get(I.target)} complete`)}),r(this,Rt).addEventListener("abort",I=>{console.warn("tx abort",(performance.now()-g)/1e3);const B=I.target.error;d(B),r(this,Rt)===I.target&&P(this,Rt,null),_r(`transaction ${Ql.get(I.target)} aborted`,B)})}))),Ql.set(r(this,Rt),UN++)}try{const g=Object.fromEntries(Array.from(i.objectStoreNames,v=>[v,new QN(r(this,Rt).objectStore(v))]));return await n(g)}catch(g){if(P(this,Rt,null),m)throw g}}};function si(t){return new Promise((e,n)=>{t.addEventListener("success",()=>e(t.result)),t.addEventListener("error",()=>n(t.error))})}var It;class QN{constructor(e){k(this,It,void 0);P(this,It,e)}get(e){_r(`get ${r(this,It).name}`,e);const n=r(this,It).get(e);return si(n)}getAll(e,n){_r(`getAll ${r(this,It).name}`,e,n);const i=r(this,It).getAll(e,n);return si(i)}getKey(e){_r(`getKey ${r(this,It).name}`,e);const n=r(this,It).getKey(e);return si(n)}getAllKeys(e,n){_r(`getAllKeys ${r(this,It).name}`,e,n);const i=r(this,It).getAllKeys(e,n);return si(i)}put(e,n){_r(`put ${r(this,It).name}`,e,n);const i=r(this,It).put(e,n);return si(i)}delete(e){_r(`delete ${r(this,It).name}`,e);const n=r(this,It).delete(e);return si(n)}clear(){_r(`clear ${r(this,It).name}`);const e=r(this,It).clear();return si(e)}index(e){return new jN(r(this,It).index(e))}}It=new WeakMap;var ws;class jN{constructor(e){k(this,ws,void 0);P(this,ws,e)}getAllKeys(e,n){_r(`IDBIndex.getAllKeys ${r(this,ws).objectStore.name}<${r(this,ws).name}>`,e,n);const i=r(this,ws).getAllKeys(e,n);return si(i)}}ws=new WeakMap;const HN=512,rd=3e3,id={durability:"default",purge:"deferred",purgeAtLeast:16};function gn(...t){}var wi,Ht,pt,gs,bs,Br,pu,gf,nl,Em,rl,Cm,gi,zs,il,qm;class VN extends LN{constructor(n="wa-sqlite",i=id){super();k(this,pu);k(this,nl);k(this,rl);k(this,gi);k(this,il);k(this,wi,void 0);k(this,Ht,new Map);k(this,pt,void 0);k(this,gs,new Set);k(this,bs,performance.now());k(this,Br,new Set);this.name=n,P(this,wi,Object.assign({},id,i)),P(this,pt,new $N(zN(n),{durability:r(this,wi).durability}))}async close(){var n;for(const i of r(this,Ht).keys())await this.xClose(i);await((n=r(this,pt))==null?void 0:n.close()),P(this,pt,null)}xOpen(n,i,a,l){return this.handleAsync(async()=>{n===null&&(n=`null_${i}`),gn(`xOpen ${n} 0x${i.toString(16)} 0x${a.toString(16)}`);try{const m=new URL(n,"http://localhost/"),g={path:m.pathname,flags:a,block0:null,locks:new BN(m.pathname)};return r(this,Ht).set(i,g),await r(this,pt).run("readwrite",async({blocks:v})=>{if(g.block0=await v.get(Oe(this,gi,zs).call(this,g,0)),!g.block0)if(a&Nm)g.block0={path:g.path,offset:0,version:0,data:new Uint8Array(0),fileSize:0},v.put(g.block0);else throw new Error(`file not found: ${g.path}`)}),l.setInt32(0,a&qN,!0),Ve}catch(m){return console.error(m),bm}})}xClose(n){return this.handleAsync(async()=>{try{const i=r(this,Ht).get(n);return i&&(gn(`xClose ${i.path}`),r(this,Ht).delete(n),i.flags&WN&&r(this,pt).run("readwrite",({blocks:a})=>{a.delete(IDBKeyRange.bound([i.path],[i.path,[]]))})),Ve}catch(i){return console.error(i),xt}})}xRead(n,i,a){return this.handleAsync(async()=>{const l=r(this,Ht).get(n);gn(`xRead ${l.path} ${i.byteLength} ${a}`);try{return await r(this,pt).run("readonly",async({blocks:g})=>{let v=0;for(;vrd){const m=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&r(this,Br).add(n),await new Promise(v=>setTimeout(v));const g=Oe(this,pu,gf).call(this,n,i,a);return P(this,bs,performance.now()),g});return l&&r(this,Br).delete(n),m}return Oe(this,pu,gf).call(this,n,i,a)}xTruncate(n,i){const a=r(this,Ht).get(n);gn(`xTruncate ${a.path} ${i}`);try{Object.assign(a.block0,{fileSize:i,data:a.block0.data.slice(0,i)});const l=Object.assign({},a.block0);return r(this,pt).run("readwrite",({blocks:m})=>{m.delete(Oe(this,gi,zs).call(this,a,-1/0,-i)),m.put(l)}),Ve}catch(l){return console.error(l),xt}}xSync(n,i){const a=r(this,Br).has(n);if(a||r(this,wi).durability!=="relaxed"||performance.now()-r(this,bs)>rd){const m=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&r(this,Br).add(n);const g=await Oe(this,nl,Em).call(this,n,i);return P(this,bs,performance.now()),g});return a&&r(this,Br).delete(n),m}const l=r(this,Ht).get(n);return gn(`xSync ${l.path} ${i}`),Ve}xFileSize(n,i){const a=r(this,Ht).get(n);return gn(`xFileSize ${a.path}`),i.setBigInt64(0,BigInt(a.block0.fileSize),!0),Ve}xLock(n,i){return this.handleAsync(async()=>{const a=r(this,Ht).get(n);gn(`xLock ${a.path} ${i}`);try{const l=await a.locks.lock(i);return l===Ve&&a.locks.state===Zi&&(a.block0=await r(this,pt).run("readonly",({blocks:m})=>m.get(Oe(this,gi,zs).call(this,a,0)))),l}catch(l){return console.error(l),xt}})}xUnlock(n,i){return this.handleAsync(async()=>{const a=r(this,Ht).get(n);gn(`xUnlock ${a.path} ${i}`);try{return a.locks.unlock(i)}catch(l){return console.error(l),xt}})}xCheckReservedLock(n,i){return this.handleAsync(async()=>{const a=r(this,Ht).get(n);gn(`xCheckReservedLock ${a.path}`);const l=await a.locks.isSomewhereReserved();return i.setInt32(0,l?1:0,!0),Ve})}xSectorSize(n){return HN}xDeviceCharacteristics(n){return SN|AN|TN|kN}xFileControl(n,i,a){const l=r(this,Ht).get(n);switch(gn(`xFileControl ${l.path} ${i}`),i){case 11:return l.overwrite=!0,Ve;case 21:if(l.overwrite)try{return this.handleAsync(async()=>(await Oe(this,il,qm).call(this,l),Ve))}catch(m){return console.error(m),xt}return Ve;case 22:return l.overwrite=!1,Ve;case 31:return this.handleAsync(async()=>{try{return l.block0.version--,l.changedPages=new Set,r(this,pt).run("readwrite",async({blocks:m})=>{const g=await m.index("version").getAllKeys(IDBKeyRange.bound([l.path],[l.path,l.block0.version]));for(const v of g)m.delete(v)}),Ve}catch(m){return console.error(m),xt}});case 32:try{const m=Object.assign({},l.block0);m.data=m.data.slice();const g=l.changedPages;return l.changedPages=null,r(this,pt).run("readwrite",async({blocks:v})=>{v.put(m);const d=await v.get([l.path,"purge",0])??{path:l.path,offset:"purge",version:0,data:new Map,count:0};d.count+=g.size;for(const I of g)d.data.set(I,m.version);v.put(d),Oe(this,rl,Cm).call(this,l.path,d.count)}),Ve}catch(m){return console.error(m),xt}case 33:return this.handleAsync(async()=>{try{return l.changedPages=null,l.block0=await r(this,pt).run("readonly",({blocks:m})=>m.get([l.path,0,l.block0.version+1])),Ve}catch(m){return console.error(m),xt}});default:return gm}}xAccess(n,i,a){return this.handleAsync(async()=>{try{const l=new URL(n,"file://localhost/").pathname;gn(`xAccess ${l} ${i}`);const m=await r(this,pt).run("readonly",({blocks:g})=>g.getKey(Oe(this,gi,zs).call(this,{path:l},0)));return a.setInt32(0,m?1:0,!0),Ve}catch(l){return console.error(l),xt}})}xDelete(n,i){return this.handleAsync(async()=>{const a=new URL(n,"file://localhost/").pathname;try{return r(this,pt).run("readwrite",({blocks:l})=>l.delete(IDBKeyRange.bound([a],[a,[]]))),i&&await r(this,pt).sync(),Ve}catch(l){return console.error(l),xt}})}async purge(n){const i=Date.now();await r(this,pt).run("readwrite",async({blocks:a})=>{const l=await a.get([n,"purge",0]);if(l){for(const[m,g]of l.data)a.delete(IDBKeyRange.bound([n,m,g],[n,m,1/0],!0,!1));await a.delete([n,"purge",0])}gn(`purge ${n} ${(l==null?void 0:l.data.size)??0} pages in ${Date.now()-i} ms`)})}}wi=new WeakMap,Ht=new WeakMap,pt=new WeakMap,gs=new WeakMap,bs=new WeakMap,Br=new WeakMap,pu=new WeakSet,gf=function(n,i,a){const l=r(this,Ht).get(n);gn(`xWrite ${l.path} ${i.byteLength} ${a}`);try{const m=l.block0.fileSize;l.block0.fileSize=Math.max(l.block0.fileSize,a+i.byteLength);const g=a===0?l.block0:{path:l.path,offset:-a,version:l.block0.version,data:null};return g.data=i.slice(),l.changedPages?(m===l.block0.fileSize&&l.changedPages.add(-a),a!==0&&r(this,pt).run("readwrite",({blocks:v})=>v.put(g))):r(this,pt).run("readwrite",({blocks:v})=>v.put(g)),Ve}catch(m){return console.error(m),xt}},nl=new WeakSet,Em=async function(n,i){const a=r(this,Ht).get(n);gn(`xSync ${a.path} ${i}`);try{await r(this,pt).sync()}catch(l){return console.error(l),xt}return Ve},rl=new WeakSet,Cm=function(n,i){r(this,wi).purge==="manual"||r(this,gs).has(n)||i{this.purge(n),r(this,gs).delete(n)}):setTimeout(()=>{this.purge(n),r(this,gs).delete(n)}),r(this,gs).add(n))},gi=new WeakSet,zs=function(n,i,a=0){const l=!i||-i{const ne=await D.index("version").getAllKeys(IDBKeyRange.bound([n.path,B+1],[n.path,1/0]));for(const te of ne)D.delete(te);D.delete([n.path,"purge",0]);for(let te=0;te=I)break;const T={path:C.path,offset:O,version:B,data:C.data.subarray(N*l,(N+1)*l)};T.offset===0&&(T.fileSize=I,n.block0=T),D.put(T)}}}})};function zN(t){return new Promise((e,n)=>{const i=globalThis.indexedDB.open(t,5);i.addEventListener("upgradeneeded",function(){i.result.createObjectStore("blocks",{keyPath:["path","offset","version"]}).createIndex("version",["path","version"])}),i.addEventListener("success",()=>{e(i.result)}),i.addEventListener("error",()=>{n(i.error)})})}const KN=""+new URL("wa-sqlite-async-24800831.wasm",import.meta.url).href,JN=new zb({async database(){const t=await DN({locateFile:()=>KN}),e=RN(t),n="wa-sqlite-test";e.vfs_register(new VN(n));const i=await e.open_v2(n,void 0,n);return{sqlite:e,db:i}}});function GN(){console.log("start wa-sqlite test"),Xf(JN).then(t=>{t==null||t.forEach(e=>console.log("[wa-sqlite]",e))})}function XN(t){return{all:t=t||new Map,on:function(e,n){var i=t.get(e);i?i.push(n):t.set(e,[n])},off:function(e,n){var i=t.get(e);i&&(n?i.splice(i.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var i=t.get(e);i&&i.slice().map(function(a){a(n)}),(i=t.get("*"))&&i.slice().map(function(a){a(e,n)})}}}var cr=XN(),Fr,ur,mu,yd,YN=(yd=class{constructor(t){k(this,Fr,void 0);k(this,ur,void 0);Yt(this,"connection");k(this,mu,new ZN);P(this,Fr,t),P(this,ur,r(this,Fr).worker??new Worker(new URL(""+new URL("worker-cda8cefb.js",import.meta.url).href,self.location),{type:"module"})),r(this,ur).onmessage=n=>{const{type:i,data:a}=n.data;switch(i){case"close":cr.emit("close",a);break;case"query":cr.emit("query",a);break;case"exec":cr.emit("exec",a);break;case"init":cr.emit("init",a);break;case"error":throw a}};const e={type:"init",dbName:r(this,Fr).dbName,url:r(this,Fr).url};r(this,ur).postMessage(e)}async init(){await new Promise(t=>{cr.on("init",()=>{cr.off("init"),t()})}),this.connection=new e0(r(this,ur)),r(this,Fr).onCreateConnection&&await r(this,Fr).onCreateConnection(this.connection)}async acquireConnection(){return await r(this,mu).lock(),this.connection}async beginTransaction(t){await t.executeQuery(jr.raw("begin"))}async commitTransaction(t){await t.executeQuery(jr.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(jr.raw("rollback"))}async releaseConnection(){r(this,mu).unlock()}async destroy(){if(r(this,ur))return r(this,ur).postMessage({type:"close"}),new Promise(t=>{cr.on("close",()=>{r(this,ur).terminate(),P(this,ur,null),t()})})}},Fr=new WeakMap,ur=new WeakMap,mu=new WeakMap,yd),Ns,ko,wd,ZN=(wd=class{constructor(){k(this,Ns,void 0);k(this,ko,void 0)}async lock(){for(;r(this,Ns);)await r(this,Ns);P(this,Ns,new Promise(t=>{P(this,ko,t)}))}unlock(){const t=r(this,ko);P(this,Ns,void 0),P(this,ko,void 0),t==null||t()}},Ns=new WeakMap,ko=new WeakMap,wd),So,gd,e0=(gd=class{constructor(t){k(this,So,void 0);P(this,So,t)}query(t,e){const n={type:"query",sql:t,param:e};return r(this,So).postMessage(n),new Promise(i=>{cr.on("query",a=>{cr.off("query"),i(a)})})}exec(t,e){const n={type:"exec",sql:t,param:e};return r(this,So).postMessage(n),new Promise(i=>{cr.on("exec",a=>{cr.off("exec"),i(a)})})}streamQuery(){throw new Error("Sqlite driver doesn't support streaming")}async executeQuery(t){const{parameters:e,sql:n,query:i}=t;return Promise.resolve(i.kind==="SelectQueryNode"||i.kind==="RawNode"?{rows:await this.query(n,e)}:{rows:[],...await this.exec(n,e)})}},So=new WeakMap,gd),yu,bd,t0=(bd=class{constructor(t){k(this,yu,void 0);P(this,yu,t)}createDriver(){return new YN(r(this,yu))}createQueryCompiler(){return new lm}createAdapter(){return new dm}createIntrospector(t){return new fm(t)}},yu=new WeakMap,bd);const n0=""+new URL("wa-sqlite-async-24800831.wasm",import.meta.url).href,r0=new t0({dbName:"wa-sqlite-worker-test",url:n0});function i0(){console.log("start wa-sqlite-worker test"),Xf(r0).then(t=>{t==null||t.forEach(e=>console.log("[wa-sqlite-worker]",e))})}const s0=Ct("h1",null,[Ra(" test "),Ct("a",{href:"https://github.com/kysely-org/kysely",target:"_blank"},"Kysely"),Ra(" WASM dialect ")],-1),o0=Ct("br",null,null,-1),a0=Ct("h3",null,"see worker result in console",-1),u0=Ct("h3",null,[Ra(" you can explore "),Ct("a",{href:"https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API#origin_private_file_system",target:"_blank"}," OPFS "),Ra(" file using "),Ct("a",{href:"https://chrome.google.com/webstore/detail/opfs-explorer/acndjpgkpaclldomagafnognkcgjignd",target:"_blank"}," opfs-explorer ")],-1),c0=Ct("br",null,null,-1),l0={class:"buttons"},f0=Ct("br",null,null,-1),h0=Ct("div",null," result run in main thread: ",-1),d0=Hy({__name:"App",setup(t){const e=new bN,{result:n,run:i}=gN(),a=new NN;function l(){i()}function m(){e.postMessage("")}function g(){a.postMessage("")}function v(){GN()}function d(){i0()}async function I(){console.clear();const B=await navigator.storage.getDirectory();await zh("sqljs"),await zh("sqlijsWorker"),indexedDB.deleteDatabase("idb-batch-atomic");try{await B.removeEntry("test.db")}catch{}try{await B.removeEntry("test.db-journal")}catch{}console.log("clear all")}return(B,D)=>(Nw(),xw(lr,null,[s0,o0,a0,u0,c0,Ct("div",l0,[Ct("button",{onClick:D[0]||(D[0]=ne=>l())}," test sqljs in main thread "),Ct("button",{onClick:D[1]||(D[1]=ne=>m())}," test sqljs in Worker "),Ct("button",{onClick:D[2]||(D[2]=ne=>g())}," test officialWasm in Worker "),Ct("button",{onClick:D[3]||(D[3]=ne=>v())}," test wa-sqlite in main thread "),Ct("button",{onClick:D[4]||(D[4]=ne=>d())}," test wa-sqlite in Worker "),Ct("button",{onClick:D[5]||(D[5]=ne=>I())}," clear ")]),f0,h0,Ct("pre",null,""+Dm($d(n))+` +`)),!u)return null;var f=Array(oe(u)+1);u=ue(u,f,0,f.length),f.length=u,s.input=f}return s.input.shift()},sc:function(s,u){u===null||u===10?(D(R(s.Rb,0)),s.Rb=[]):u!=0&&s.Rb.push(u)},ic:function(s){s.Rb&&0=u||(u=Math.max(u,f*(1048576>f?2:1.125)>>>0),f!=0&&(u=Math.max(u,256)),f=s.Nb,s.Nb=new Uint8Array(u),0=s.node.Pb)return 0;if(s=Math.min(s.node.Pb-_,y),8u)throw new Z(28);return u},vc:function(s,u,f){me.xc(s.node,u+f),s.node.Pb=Math.max(s.node.Pb,u+f)},kc:function(s,u,f,y,_){if((s.node.mode&61440)!==32768)throw new Z(43);if(s=s.node.Nb,_&2||s.buffer!==T.buffer){if((0{if(s=ce(s),!s)return{path:"",node:null};if(u=Object.assign({yc:!0,tc:0},u),8!!A);for(var f=Cn,y="/",_=0;_{for(var u;;){if(s===s.parent)return s=s.Ub.Ac,u?s[s.length-1]!=="/"?s+"/"+u:s+u:s;u=u?s.name+"/"+u:s.name,s=s.parent}},qs=(s,u)=>{for(var f=0,y=0;y>>0)%le.length},H=s=>{var u=qs(s.parent.id,s.name);if(le[u]===s)le[u]=s.ac;else for(u=le[u];u;){if(u.ac===s){u.ac=s.ac;break}u=u.ac}},Kn=(s,u)=>{var f;if(f=(f=Tr(s,"x"))?f:s.Cb.cc?0:2)throw new Z(f,s);for(f=le[qs(s.id,u)];f;f=f.ac){var y=f.name;if(f.parent.id===s.id&&y===u)return f}return s.Cb.cc(s,u)},Bt=(s,u,f,y)=>(s=new Tu(s,u,f,y),u=qs(s.parent.id,s.name),s.ac=le[u],le[u]=s),Oi={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Ws=s=>{var u=["r","w","rw"][s&3];return s&512&&(u+="w"),u},Tr=(s,u)=>{if(Mt)return 0;if(!u.includes("r")||s.mode&292){if(u.includes("w")&&!(s.mode&146)||u.includes("x")&&!(s.mode&73))return 2}else return 2;return 0},yr=(s,u)=>{try{return Kn(s,u),20}catch{}return Tr(s,"wx")},Ho=(s,u,f)=>{try{var y=Kn(s,u)}catch(_){return _.Ob}if(s=Tr(s,"wx"))return s;if(f){if((y.mode&61440)!==16384)return 54;if(y===y.parent||On(y)==="/")return 10}else if((y.mode&61440)===16384)return 31;return 0},Cl=(s=0)=>{for(;4096>=s;s++)if(!Gt[s])return s;throw new Z(33)},Vo=(s,u)=>(Gr||(Gr=function(){this.hc={}},Gr.prototype={},Object.defineProperties(Gr.prototype,{object:{get:function(){return this.node},set:function(f){this.node=f}},flags:{get:function(){return this.hc.flags},set:function(f){this.hc.flags=f}},position:{get:function(){return this.hc.position},set:function(f){this.hc.position=f}}})),s=Object.assign(new Gr,s),u=Cl(u),s.Wb=u,Gt[u]=s),zr={open:s=>{s.Mb=Ci[s.node.ec].Mb,s.Mb.open&&s.Mb.open(s)},Zb:()=>{throw new Z(70)}},Is=(s,u)=>{Ci[s]={Mb:u}},zo=(s,u)=>{var f=u==="/",y=!u;if(f&&Cn)throw new Z(10);if(!f&&!y){var _=Xt(u,{yc:!1});if(u=_.path,_=_.node,_.$b)throw new Z(10);if((_.mode&61440)!==16384)throw new Z(54)}u={type:s,Wc:{},Ac:u,Mc:[]},s=s.Ub(u),s.Ub=u,u.root=s,f?Cn=s:_&&(_.$b=u,_.Ub&&_.Ub.Mc.push(u))},Ko=(s,u,f)=>{var y=Xt(s,{parent:!0}).node;if(s=z(s),!s||s==="."||s==="..")throw new Z(28);var _=yr(y,s);if(_)throw new Z(_);if(!y.Cb.jc)throw new Z(63);return y.Cb.jc(y,s,u,f)},qn=(s,u)=>Ko(s,(u!==void 0?u:511)&1023|16384,0),As=(s,u,f)=>{typeof f>"u"&&(f=u,u=438),Ko(s,u|8192,f)},qi=(s,u)=>{if(!ce(s))throw new Z(44);var f=Xt(u,{parent:!0}).node;if(!f)throw new Z(44);u=z(u);var y=yr(f,u);if(y)throw new Z(y);if(!f.Cb.nc)throw new Z(63);f.Cb.nc(f,u,s)},Jo=s=>{var u=Xt(s,{parent:!0}).node;s=z(s);var f=Kn(u,s),y=Ho(u,s,!0);if(y)throw new Z(y);if(!u.Cb.mc)throw new Z(63);if(f.$b)throw new Z(10);u.Cb.mc(u,s),H(f)},Wi=s=>{if(s=Xt(s).node,!s)throw new Z(44);if(!s.Cb.fc)throw new Z(28);return ce(On(s.parent),s.Cb.fc(s))},an=(s,u)=>{if(s=Xt(s,{Yb:!u}).node,!s)throw new Z(44);if(!s.Cb.Tb)throw new Z(63);return s.Cb.Tb(s)},Ii=s=>an(s,!0),Ts=(s,u)=>{if(s=typeof s=="string"?Xt(s,{Yb:!0}).node:s,!s.Cb.Qb)throw new Z(63);s.Cb.Qb(s,{mode:u&4095|s.mode&-4096,timestamp:Date.now()})},Go=(s,u)=>{if(0>u)throw new Z(28);if(s=typeof s=="string"?Xt(s,{Yb:!0}).node:s,!s.Cb.Qb)throw new Z(63);if((s.mode&61440)===16384)throw new Z(31);if((s.mode&61440)!==32768)throw new Z(28);var f=Tr(s,"w");if(f)throw new Z(f);s.Cb.Qb(s,{size:u,timestamp:Date.now()})},Ai=(s,u,f)=>{if(s==="")throw new Z(44);if(typeof u=="string"){var y=Oi[u];if(typeof y>"u")throw Error("Unknown file open mode: "+u);u=y}if(f=u&64?(typeof f>"u"?438:f)&4095|32768:0,typeof s=="object")var _=s;else{s=Y(s);try{_=Xt(s,{Yb:!(u&131072)}).node}catch{}}if(y=!1,u&64)if(_){if(u&128)throw new Z(20)}else _=Ko(s,f,0),y=!0;if(!_)throw new Z(44);if((_.mode&61440)===8192&&(u&=-513),u&65536&&(_.mode&61440)!==16384)throw new Z(54);if(!y&&(f=_?(_.mode&61440)===40960?32:(_.mode&61440)===16384&&(Ws(u)!=="r"||u&512)?31:Tr(_,Ws(u)):44))throw new Z(f);return u&512&&!y&&Go(_,0),u&=-131713,_=Vo({node:_,path:On(_),flags:u,seekable:!0,position:0,Mb:_.Mb,Tc:[],error:!1}),_.Mb.open&&_.Mb.open(_),!n.logReadFiles||u&1||(Ti||(Ti={}),s in Ti||(Ti[s]=1)),_},Xo=(s,u,f)=>{if(s.Wb===null)throw new Z(8);if(!s.seekable||!s.Mb.Zb)throw new Z(70);if(f!=0&&f!=1&&f!=2)throw new Z(28);s.position=s.Mb.Zb(s,u,f),s.Tc=[]},Kr=()=>{Z||(Z=function(s,u){this.name="ErrnoError",this.node=u,this.Rc=function(f){this.Ob=f},this.Rc(s),this.message="FS error"},Z.prototype=Error(),Z.prototype.constructor=Z,[44].forEach(s=>{Dn[s]=new Z(s),Dn[s].stack=""}))},Yo,Ss=(s,u)=>{var f=0;return s&&(f|=365),u&&(f|=146),f},Jr=(s,u,f)=>{s=Y("/dev/"+s);var y=Ss(!!u,!!f);wr||(wr=64);var _=wr++<<8|0;Is(_,{open:k=>{k.seekable=!1},close:()=>{f&&f.buffer&&f.buffer.length&&f(10)},read:(k,A,V,M)=>{for(var U=0,ie=0;ie{for(var U=0;U>2]=y.Ic,ae[f+8>>2]=y.qc,ae[f+12>>2]=y.mode,_e[f+16>>2]=y.Oc,ae[f+20>>2]=y.uid,ae[f+24>>2]=y.Lc,ae[f+28>>2]=y.ec,Me=[y.size>>>0,(fe=y.size,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[f+40>>2]=Me[0],ae[f+44>>2]=Me[1],ae[f+48>>2]=4096,ae[f+52>>2]=y.Gc,s=y.Ec.getTime(),u=y.Nc.getTime();var _=y.Hc.getTime();return Me=[Math.floor(s/1e3)>>>0,(fe=Math.floor(s/1e3),1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[f+56>>2]=Me[0],ae[f+60>>2]=Me[1],_e[f+64>>2]=s%1e3*1e3,Me=[Math.floor(u/1e3)>>>0,(fe=Math.floor(u/1e3),1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[f+72>>2]=Me[0],ae[f+76>>2]=Me[1],_e[f+80>>2]=u%1e3*1e3,Me=[Math.floor(_/1e3)>>>0,(fe=Math.floor(_/1e3),1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[f+88>>2]=Me[0],ae[f+92>>2]=Me[1],_e[f+96>>2]=_%1e3*1e3,Me=[y.qc>>>0,(fe=y.qc,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[f+104>>2]=Me[0],ae[f+108>>2]=Me[1],0}var Si=void 0;function ki(){return Si+=4,ae[Si-4>>2]}function mn(s){if(s=Gt[s],!s)throw new Z(8);return s}function Ln(s,u,f){return ue(s,ee,u,f)}function Ri(s){return _e[s>>2]+4294967296*ae[s+4>>2]}var Je=[0,31,60,91,121,152,182,213,244,274,305,335],Di=[0,31,59,90,120,151,181,212,243,273,304,334];function Li(s){var u=oe(s)+1,f=la(u);return f&&Ln(s,f,u),f}var Jn={};function Pi(){if(!Xr){var s={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:m||"./this.program"},u;for(u in Jn)Jn[u]===void 0?delete s[u]:s[u]=Jn[u];var f=[];for(u in s)f.push(u+"="+s[u]);Xr=f}return Xr}var Xr;function Mi(){}function yn(){}function Rs(){}function Zo(){}function vu(){}function Ds(){}function ea(){}function Ls(){}function ta(){}function Ps(){}function Gn(){}function Ms(){}function Bs(){}function Yr(){}function Fs(){}function _u(){}function na(){}function xu(){}function ra(){}function Bi(){}function Fi(){}function ia(){}function Zr(){}function ei(){}function Xn(){}function Ui(){}function sa(){}function o(){}function c(){}function h(){}function g(){}function E(){}function L(){}function Q(){}function ve(){}function Pe(){}function De(){}function ct(){}function Pn(){}function oa(s){q=s,b||0{ua={resolve:s,reject:u}})}function Il(){var s=la(12300),u=s+12;ae[s>>2]=u,ae[s+4>>2]=u+12288,u=Us[0];var f=Cu[u];return f===void 0&&(f=ql++,Cu[u]=f,Ou[f]=u),ae[s+8>>2]=f,s}function Wu(s){if(!N){if(Yn===0){var u=!1,f=!1;s((y=0)=>{if(!N&&(Eu=y,u=!0,f)){Yn=2,$i(()=>Qi(Mn)),y=!1;try{var _=(0,n.asm[Ou[ae[Mn+8>>2]]])()}catch(V){_=V,y=!0}var k=!1;if(!Mn){var A=ua;A&&(ua=null,(y?A.reject:A.resolve)(_),k=!0)}if(y&&!k)throw _}}),f=!0,u||(Yn=1,Mn=Il(),$i(()=>Pu(Mn)))}else Yn===2?(Yn=0,$i(da),Su(Mn),Mn=null,Wl.forEach(y=>{if(!N)try{if(y(),!(b||0{s().then(u)})}var Au={};function Bn(s,u,f,y,_){function k(X){return--dn,M!==0&&fa(M),u==="string"?F(X):u==="boolean"?!!X:X}var A={string:X=>{var se=0;if(X!=null&&X!==0){se=oe(X)+1;var Ae=ha(se);Ln(X,Ae,se),se=Ae}return se},array:X=>{var se=ha(X.length);return T.set(X,se),se}};s=n["_"+s];var V=[],M=0;if(y)for(var U=0;U{qn("/dev"),Is(259,{read:()=>0,write:(y,_,k,A)=>A}),As("/dev/null",259),Ee(1280,Le),Ee(1536,it),As("/dev/tty",1280),As("/dev/tty1",1536);var s=new Uint8Array(1024),u=0,f=()=>(u===0&&(u=J(s).byteLength),s[--u]);Jr("random",f),Jr("urandom",f),qn("/dev/shm"),qn("/dev/shm/tmp")})(),(()=>{qn("/proc");var s=qn("/proc/self");qn("/proc/self/fd"),zo({Ub:()=>{var u=Bt(s,"fd",16895,73);return u.Cb={cc:(f,y)=>{var _=Gt[+y];if(!_)throw new Z(8);return f={parent:null,Ub:{Ac:"fake"},Cb:{fc:()=>_.path}},f.parent=f}},u}},"/proc/self/fd")})(),function(){const s=new Map;n.setAuthorizer=function(u,f,y){return f?s.set(u,{f,uc:y}):s.delete(u),Bn("set_authorizer","number",["number"],[u])},Mi=function(u,f,y,_,k,A){if(s.has(u)){const{f:V,uc:M}=s.get(u);return V(M,f,y?F(y):null,_?F(_):null,k?F(k):null,A?F(A):null)}return 0}}(),function(){const s=new Map,u=new Map;n.createFunction=function(f,y,_,k,A,V){const M=s.size;return s.set(M,{f:V,Xb:A}),Bn("create_function","number","number string number number number number".split(" "),[f,y,_,k,M,0])},n.createAggregate=function(f,y,_,k,A,V,M){const U=s.size;return s.set(U,{step:V,Jc:M,Xb:A}),Bn("create_function","number","number string number number number number".split(" "),[f,y,_,k,U,1])},n.getFunctionUserData=function(f){return u.get(f)},Rs=function(f,y,_,k){f=s.get(f),u.set(y,f.Xb),f.f(y,new Uint32Array(ee.buffer,k,_)),u.delete(y)},vu=function(f,y,_,k){f=s.get(f),u.set(y,f.Xb),f.step(y,new Uint32Array(ee.buffer,k,_)),u.delete(y)},yn=function(f,y){f=s.get(f),u.set(y,f.Xb),f.Jc(y),u.delete(y)}}(),function(){const s=new Map;n.progressHandler=function(u,f,y,_){return y?s.set(u,{f:y,uc:_}):s.delete(u),Bn("progress_handler",null,["number","number"],[u,f])},Zo=function(u){if(s.has(u)){const{f,uc:y}=s.get(u);return f(y)}return 0}}(),function(){function s(M,U){const ie=`get${M}`,X=`set${M}`;return new Proxy(new DataView(ee.buffer,U,M==="Int32"?4:8),{get(se,Ae){if(Ae===ie)return function(Ge,At){if(!At)throw Error("must be little endian");return se[Ae](Ge,At)};if(Ae===X)return function(Ge,At,vt){if(!vt)throw Error("must be little endian");return se[Ae](Ge,At,vt)};if(typeof Ae=="string"&&Ae.match(/^(get)|(set)/))throw Error("invalid type");return se[Ae]}})}const u=typeof Au=="object",f=new Map,y=new Map,_=new Map,k=u?new Set:null,A=u?new Set:null,V=new Map;ia=function(M,U,ie,X){V.set(F(M),{size:U,dc:Array.from(new Uint32Array(ee.buffer,X,ie))})},n.createModule=function(M,U,ie,X){u&&(ie.handleAsync=Iu);const se=f.size;return f.set(se,{module:ie,Xb:X}),X=0,ie.xCreate&&(X|=1),ie.xConnect&&(X|=2),ie.xBestIndex&&(X|=4),ie.xDisconnect&&(X|=8),ie.xDestroy&&(X|=16),ie.xOpen&&(X|=32),ie.xClose&&(X|=64),ie.xFilter&&(X|=128),ie.xNext&&(X|=256),ie.xEof&&(X|=512),ie.xColumn&&(X|=1024),ie.xRowid&&(X|=2048),ie.xUpdate&&(X|=4096),ie.xBegin&&(X|=8192),ie.xSync&&(X|=16384),ie.xCommit&&(X|=32768),ie.xRollback&&(X|=65536),ie.xFindFunction&&(X|=131072),ie.xRename&&(X|=262144),Bn("create_module","number",["number","string","number","number"],[M,U,se,X])},Ms=function(M,U,ie,X,se,Ae){if(U=f.get(U),y.set(se,U),u){k.delete(se);for(const Ge of k)y.delete(Ge)}return X=Array.from(new Uint32Array(ee.buffer,X,ie)).map(Ge=>F(Ge)),U.module.xCreate(M,U.Xb,X,se,s("Int32",Ae))},Gn=function(M,U,ie,X,se,Ae){if(U=f.get(U),y.set(se,U),u){k.delete(se);for(const Ge of k)y.delete(Ge)}return X=Array.from(new Uint32Array(ee.buffer,X,ie)).map(Ge=>F(Ge)),U.module.xConnect(M,U.Xb,X,se,s("Int32",Ae))},ea=function(M,U){var ie=y.get(M),X=V.get("sqlite3_index_info").dc;const se={};se.nConstraint=Ke(U+X[0],"i32"),se.aConstraint=[];for(var Ae=Ke(U+X[1],"*"),Ge=V.get("sqlite3_index_constraint").size,At=0;At>=2,_e[A]+_e[A+1]*2**32}const f=typeof Au=="object",y=new Map,_=new Map;n.registerVFS=function(A,V){if(Bn("sqlite3_vfs_find","number",["string"],[A.name]))throw Error(`VFS '${A.name}' already registered`);f&&(A.handleAsync=Iu);var M=A.Vc??64;const U=n._malloc(4);return V=Bn("register_vfs","number",["string","number","number","number"],[A.name,M,V?1:0,U]),V||(M=Ke(U,"*"),y.set(M,A)),n._free(U),V};const k=f?new Set:null;sa=function(A){const V=_.get(A);return f?k.add(A):_.delete(A),V.xClose(A)},Q=function(A,V,M,U){return _.get(A).xRead(A,ee.subarray(V,V+M),u(U))},Pn=function(A,V,M,U){return _.get(A).xWrite(A,ee.subarray(V,V+M),u(U))},De=function(A,V){return _.get(A).xTruncate(A,u(V))},Pe=function(A,V){return _.get(A).xSync(A,V)},g=function(A,V){const M=_.get(A);return V=s("BigInt64",V),M.xFileSize(A,V)},E=function(A,V){return _.get(A).xLock(A,V)},ct=function(A,V){return _.get(A).xUnlock(A,V)},Ui=function(A,V){const M=_.get(A);return V=s("Int32",V),M.xCheckReservedLock(A,V)},h=function(A,V,M){const U=_.get(A);return M=new DataView(ee.buffer,M),U.xFileControl(A,V,M)},ve=function(A){return _.get(A).xSectorSize(A)},c=function(A){return _.get(A).xDeviceCharacteristics(A)},L=function(A,V,M,U,ie){if(A=y.get(A),_.set(M,A),f){k.delete(M);for(var X of k)_.delete(X)}if(X=null,U&64){X=1;const se=[];for(;X;){const Ae=ee[V++];if(Ae)se.push(Ae);else switch(ee[V]||(X=null),X){case 1:se.push(63),X=2;break;case 2:se.push(61),X=3;break;case 3:se.push(38),X=2}}X=new TextDecoder().decode(new Uint8Array(se))}else V&&(X=F(V));return ie=s("Int32",ie),A.xOpen(X,M,U,ie)},o=function(A,V,M){return y.get(A).xDelete(F(V),M)},Xn=function(A,V,M,U){return A=y.get(A),U=s("Int32",U),A.xAccess(F(V),M,U)}}();var Al={a:function(s,u,f,y){ut("Assertion failed: "+F(s)+", at: "+[u?F(u):"unknown filename",f,y?F(y):"unknown function"])},K:function(s,u){try{return s=F(s),Ts(s,u),0}catch(f){if(typeof He>"u"||f.name!=="ErrnoError")throw f;return-f.Ob}},M:function(s,u,f){try{if(u=F(u),u=gr(s,u),f&-8)return-28;var y=Xt(u,{Yb:!0}).node;return y?(s="",f&4&&(s+="r"),f&2&&(s+="w"),f&1&&(s+="x"),s&&Tr(y,s)?-2:0):-44}catch(_){if(typeof He>"u"||_.name!=="ErrnoError")throw _;return-_.Ob}},L:function(s,u){try{var f=Gt[s];if(!f)throw new Z(8);return Ts(f.node,u),0}catch(y){if(typeof He>"u"||y.name!=="ErrnoError")throw y;return-y.Ob}},J:function(s){try{var u=Gt[s];if(!u)throw new Z(8);var f=u.node,y=typeof f=="string"?Xt(f,{Yb:!0}).node:f;if(!y.Cb.Qb)throw new Z(63);return y.Cb.Qb(y,{timestamp:Date.now()}),0}catch(_){if(typeof He>"u"||_.name!=="ErrnoError")throw _;return-_.Ob}},b:function(s,u,f){Si=f;try{var y=mn(s);switch(u){case 0:var _=ki();return 0>_?-28:Vo(y,_).Wb;case 1:case 2:return 0;case 3:return y.flags;case 4:return _=ki(),y.flags|=_,0;case 5:return _=ki(),Ne[_+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return ae[ca()>>2]=28,-1;default:return-28}}catch(k){if(typeof He>"u"||k.name!=="ErrnoError")throw k;return-k.Ob}},I:function(s,u){try{var f=mn(s);return ks(an,f.path,u)}catch(y){if(typeof He>"u"||y.name!=="ErrnoError")throw y;return-y.Ob}},j:function(s,u,f){try{if(u=f+2097152>>>0<4194305-!!u?(u>>>0)+4294967296*f:NaN,isNaN(u))return-61;var y=Gt[s];if(!y)throw new Z(8);if(!(y.flags&2097155))throw new Z(28);return Go(y.node,u),0}catch(_){if(typeof He>"u"||_.name!=="ErrnoError")throw _;return-_.Ob}},C:function(s,u){try{if(u===0)return-28;var f=oe("/")+1;return u"u"||y.name!=="ErrnoError")throw y;return-y.Ob}},F:function(s,u){try{return s=F(s),ks(Ii,s,u)}catch(f){if(typeof He>"u"||f.name!=="ErrnoError")throw f;return-f.Ob}},z:function(s,u,f){try{return u=F(u),u=gr(s,u),u=Y(u),u[u.length-1]==="/"&&(u=u.substr(0,u.length-1)),qn(u,f),0}catch(y){if(typeof He>"u"||y.name!=="ErrnoError")throw y;return-y.Ob}},E:function(s,u,f,y){try{u=F(u);var _=y&256;return u=gr(s,u,y&4096),ks(_?Ii:an,u,f)}catch(k){if(typeof He>"u"||k.name!=="ErrnoError")throw k;return-k.Ob}},u:function(s,u,f,y){Si=y;try{u=F(u),u=gr(s,u);var _=y?ki():0;return Ai(u,f,_).Wb}catch(k){if(typeof He>"u"||k.name!=="ErrnoError")throw k;return-k.Ob}},s:function(s,u,f,y){try{if(u=F(u),u=gr(s,u),0>=y)return-28;var _=Wi(u),k=Math.min(y,oe(_)),A=T[f+k];return Ln(_,f,y+1),T[f+k]=A,k}catch(V){if(typeof He>"u"||V.name!=="ErrnoError")throw V;return-V.Ob}},r:function(s){try{return s=F(s),Jo(s),0}catch(u){if(typeof He>"u"||u.name!=="ErrnoError")throw u;return-u.Ob}},H:function(s,u){try{return s=F(s),ks(an,s,u)}catch(f){if(typeof He>"u"||f.name!=="ErrnoError")throw f;return-f.Ob}},o:function(s,u,f){try{if(u=F(u),u=gr(s,u),f===0){s=u;var y=Xt(s,{parent:!0}).node;if(!y)throw new Z(44);var _=z(s),k=Kn(y,_),A=Ho(y,_,!1);if(A)throw new Z(A);if(!y.Cb.oc)throw new Z(63);if(k.$b)throw new Z(10);y.Cb.oc(y,_),H(k)}else f===512?Jo(u):ut("Invalid flags passed to unlinkat");return 0}catch(V){if(typeof He>"u"||V.name!=="ErrnoError")throw V;return-V.Ob}},n:function(s,u,f){try{if(u=F(u),u=gr(s,u,!0),f){var y=Ri(f),_=ae[f+8>>2];k=1e3*y+_/1e6,f+=16,y=Ri(f),_=ae[f+8>>2],A=1e3*y+_/1e6}else var k=Date.now(),A=k;s=k;var V=Xt(u,{Yb:!0}).node;return V.Cb.Qb(V,{timestamp:Math.max(s,A)}),0}catch(M){if(typeof He>"u"||M.name!=="ErrnoError")throw M;return-M.Ob}},y:function(s,u){s=new Date(1e3*Ri(s)),ae[u>>2]=s.getSeconds(),ae[u+4>>2]=s.getMinutes(),ae[u+8>>2]=s.getHours(),ae[u+12>>2]=s.getDate(),ae[u+16>>2]=s.getMonth(),ae[u+20>>2]=s.getFullYear()-1900,ae[u+24>>2]=s.getDay();var f=s.getFullYear();ae[u+28>>2]=(f%4!==0||f%100===0&&f%400!==0?Di:Je)[s.getMonth()]+s.getDate()-1|0,ae[u+36>>2]=-(60*s.getTimezoneOffset()),f=new Date(s.getFullYear(),6,1).getTimezoneOffset();var y=new Date(s.getFullYear(),0,1).getTimezoneOffset();ae[u+32>>2]=(f!=y&&s.getTimezoneOffset()==Math.min(y,f))|0},w:function(s,u,f,y,_,k,A){try{var V=mn(y);if(u&2&&!(f&2)&&(V.flags&2097155)!==2)throw new Z(2);if((V.flags&2097155)===1)throw new Z(2);if(!V.Mb.kc)throw new Z(43);var M=V.Mb.kc(V,s,_,u,f),U=M.Pc;return ae[k>>2]=M.Dc,_e[A>>2]=U,0}catch(ie){if(typeof He>"u"||ie.name!=="ErrnoError")throw ie;return-ie.Ob}},x:function(s,u,f,y,_,k){try{var A=mn(_);if(f&2){if((A.node.mode&61440)!==32768)throw new Z(43);y&2||A.Mb.lc&&A.Mb.lc(A,ee.slice(s,s+u),k,u,y)}}catch(V){if(typeof He>"u"||V.name!=="ErrnoError")throw V;return-V.Ob}},p:function(s,u,f){function y(M){return(M=M.toTimeString().match(/\(([A-Za-z ]+)\)$/))?M[1]:"GMT"}var _=new Date().getFullYear(),k=new Date(_,0,1),A=new Date(_,6,1);_=k.getTimezoneOffset();var V=A.getTimezoneOffset();_e[s>>2]=60*Math.max(_,V),ae[u>>2]=+(_!=V),s=y(k),u=y(A),s=Li(s),u=Li(u),V<_?(_e[f>>2]=s,_e[f+4>>2]=u):(_e[f>>2]=u,_e[f+4>>2]=s)},e:function(){return Date.now()},d:()=>performance.now(),l:function(s){var u=ee.length;if(s>>>=0,2147483648=f;f*=2){var y=u*(1+.2/f);y=Math.min(y,s+100663296);var _=Math,k=_.min;y=Math.max(s,y),y+=(65536-y%65536)%65536;e:{var A=C.buffer;try{C.grow(k.call(_,2147483648,y)-A.byteLength+65535>>>16),ze();var V=1;break e}catch{}V=void 0}if(V)return!0}return!1},A:function(s,u){var f=0;return Pi().forEach(function(y,_){var k=u+f;for(_=_e[s+4*_>>2]=k,k=0;k>0]=y.charCodeAt(k);T[_>>0]=0,f+=y.length+1}),0},B:function(s,u){var f=Pi();_e[s>>2]=f.length;var y=0;return f.forEach(function(_){y+=_.length+1}),_e[u>>2]=y,0},f:function(s){try{var u=mn(s);if(u.Wb===null)throw new Z(8);u.pc&&(u.pc=null);try{u.Mb.close&&u.Mb.close(u)}catch(f){throw f}finally{Gt[u.Wb]=null}return u.Wb=null,0}catch(f){if(typeof He>"u"||f.name!=="ErrnoError")throw f;return f.Ob}},m:function(s,u){try{var f=mn(s);return T[u>>0]=f.Sb?2:(f.mode&61440)===16384?3:(f.mode&61440)===40960?7:4,Ne[u+2>>1]=0,Me=[0,(fe=0,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[u+8>>2]=Me[0],ae[u+12>>2]=Me[1],Me=[0,(fe=0,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[u+16>>2]=Me[0],ae[u+20>>2]=Me[1],0}catch(y){if(typeof He>"u"||y.name!=="ErrnoError")throw y;return y.Ob}},t:function(s,u,f,y){try{e:{var _=mn(s);s=u;for(var k,A=u=0;A>2],M=_e[s+4>>2];s+=8;var U=_,ie=V,X=M,se=k,Ae=T;if(0>X||0>se)throw new Z(28);if(U.Wb===null)throw new Z(8);if((U.flags&2097155)===1)throw new Z(8);if((U.node.mode&61440)===16384)throw new Z(31);if(!U.Mb.read)throw new Z(28);var Ge=typeof se<"u";if(!Ge)se=U.position;else if(!U.seekable)throw new Z(70);var At=U.Mb.read(U,Ae,ie,X,se);Ge||(U.position+=At);var vt=At;if(0>vt){var wn=-1;break e}if(u+=vt,vt>2]=wn,0}catch(Ft){if(typeof He>"u"||Ft.name!=="ErrnoError")throw Ft;return Ft.Ob}},i:function(s,u,f,y,_){try{if(u=f+2097152>>>0<4194305-!!u?(u>>>0)+4294967296*f:NaN,isNaN(u))return 61;var k=mn(s);return Xo(k,u,y),Me=[k.position>>>0,(fe=k.position,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[_>>2]=Me[0],ae[_+4>>2]=Me[1],k.pc&&u===0&&y===0&&(k.pc=null),0}catch(A){if(typeof He>"u"||A.name!=="ErrnoError")throw A;return A.Ob}},D:function(s){try{var u=mn(s);return Wu(function(f){var y=u.node.Ub;y.type.Sc?y.type.Sc(y,!1,function(_){f(_?function(){return 29}:0)}):f(0)})}catch(f){if(typeof He>"u"||f.name!=="ErrnoError")throw f;return f.Ob}},q:function(s,u,f,y){try{e:{var _=mn(s);s=u;for(var k,A=u=0;A>2],M=_e[s+4>>2];s+=8;var U=_,ie=V,X=M,se=k,Ae=T;if(0>X||0>se)throw new Z(28);if(U.Wb===null)throw new Z(8);if(!(U.flags&2097155))throw new Z(8);if((U.node.mode&61440)===16384)throw new Z(31);if(!U.Mb.write)throw new Z(28);U.seekable&&U.flags&1024&&Xo(U,0,2);var Ge=typeof se<"u";if(!Ge)se=U.position;else if(!U.seekable)throw new Z(70);var At=U.Mb.write(U,Ae,ie,X,se,void 0);Ge||(U.position+=At);var vt=At;if(0>vt){var wn=-1;break e}u+=vt,typeof k<"u"&&(k+=vt)}wn=u}return _e[y>>2]=wn,0}catch(Ft){if(typeof He>"u"||Ft.name!=="ErrnoError")throw Ft;return Ft.Ob}},ra:Mi,N:yn,ga:Rs,ca:Zo,Y:vu,la:Ds,G:ea,h:Ls,oa:ta,ja:Ps,ea:Gn,fa:Ms,k:Bs,v:Yr,pa:Fs,g:_u,qa:na,da:xu,ha:ra,ia:Bi,na:Fi,c:ia,ka:Zr,ma:ei,aa:Xn,V:Ui,$:sa,ba:o,S:c,U:h,Z:g,X:E,R:L,Q,T:ve,_:Pe,O:De,W:ct,P:Pn};(function(){function s(f){if(f=f.exports,f=Ol(f),n.asm=f,C=n.asm.sa,ze(),Wt.unshift(n.asm.ta),ge--,n.monitorRunDependencies&&n.monitorRunDependencies(ge),ge==0&&Oe){var y=Oe;Oe=null,y()}return f}var u={a:Al};if(ge++,n.monitorRunDependencies&&n.monitorRunDependencies(ge),n.instantiateWasm)try{return n.instantiateWasm(u,s)}catch(f){ne("Module.instantiateWasm callback failed with error: "+f),a(f)}return pn(u,function(f){s(f.instance)}).catch(a),{}})(),n._sqlite3_vfs_find=function(){return(n._sqlite3_vfs_find=n.asm.ua).apply(null,arguments)},n._sqlite3_malloc=function(){return(n._sqlite3_malloc=n.asm.va).apply(null,arguments)},n._sqlite3_free=function(){return(n._sqlite3_free=n.asm.wa).apply(null,arguments)},n._sqlite3_prepare_v2=function(){return(n._sqlite3_prepare_v2=n.asm.xa).apply(null,arguments)},n._sqlite3_step=function(){return(n._sqlite3_step=n.asm.ya).apply(null,arguments)},n._sqlite3_column_int64=function(){return(n._sqlite3_column_int64=n.asm.za).apply(null,arguments)},n._sqlite3_column_int=function(){return(n._sqlite3_column_int=n.asm.Aa).apply(null,arguments)},n._sqlite3_finalize=function(){return(n._sqlite3_finalize=n.asm.Ba).apply(null,arguments)},n._sqlite3_reset=function(){return(n._sqlite3_reset=n.asm.Ca).apply(null,arguments)},n._sqlite3_clear_bindings=function(){return(n._sqlite3_clear_bindings=n.asm.Da).apply(null,arguments)},n._sqlite3_value_blob=function(){return(n._sqlite3_value_blob=n.asm.Ea).apply(null,arguments)},n._sqlite3_value_text=function(){return(n._sqlite3_value_text=n.asm.Fa).apply(null,arguments)},n._sqlite3_value_bytes=function(){return(n._sqlite3_value_bytes=n.asm.Ga).apply(null,arguments)},n._sqlite3_value_double=function(){return(n._sqlite3_value_double=n.asm.Ha).apply(null,arguments)},n._sqlite3_value_int=function(){return(n._sqlite3_value_int=n.asm.Ia).apply(null,arguments)},n._sqlite3_value_int64=function(){return(n._sqlite3_value_int64=n.asm.Ja).apply(null,arguments)},n._sqlite3_value_type=function(){return(n._sqlite3_value_type=n.asm.Ka).apply(null,arguments)},n._sqlite3_result_blob=function(){return(n._sqlite3_result_blob=n.asm.La).apply(null,arguments)},n._sqlite3_result_double=function(){return(n._sqlite3_result_double=n.asm.Ma).apply(null,arguments)},n._sqlite3_result_error=function(){return(n._sqlite3_result_error=n.asm.Na).apply(null,arguments)},n._sqlite3_result_int=function(){return(n._sqlite3_result_int=n.asm.Oa).apply(null,arguments)},n._sqlite3_result_int64=function(){return(n._sqlite3_result_int64=n.asm.Pa).apply(null,arguments)},n._sqlite3_result_null=function(){return(n._sqlite3_result_null=n.asm.Qa).apply(null,arguments)},n._sqlite3_result_text=function(){return(n._sqlite3_result_text=n.asm.Ra).apply(null,arguments)},n._sqlite3_column_count=function(){return(n._sqlite3_column_count=n.asm.Sa).apply(null,arguments)},n._sqlite3_data_count=function(){return(n._sqlite3_data_count=n.asm.Ta).apply(null,arguments)},n._sqlite3_column_blob=function(){return(n._sqlite3_column_blob=n.asm.Ua).apply(null,arguments)},n._sqlite3_column_bytes=function(){return(n._sqlite3_column_bytes=n.asm.Va).apply(null,arguments)},n._sqlite3_column_double=function(){return(n._sqlite3_column_double=n.asm.Wa).apply(null,arguments)},n._sqlite3_column_text=function(){return(n._sqlite3_column_text=n.asm.Xa).apply(null,arguments)},n._sqlite3_column_type=function(){return(n._sqlite3_column_type=n.asm.Ya).apply(null,arguments)},n._sqlite3_column_name=function(){return(n._sqlite3_column_name=n.asm.Za).apply(null,arguments)},n._sqlite3_bind_blob=function(){return(n._sqlite3_bind_blob=n.asm._a).apply(null,arguments)},n._sqlite3_bind_double=function(){return(n._sqlite3_bind_double=n.asm.$a).apply(null,arguments)},n._sqlite3_bind_int=function(){return(n._sqlite3_bind_int=n.asm.ab).apply(null,arguments)},n._sqlite3_bind_int64=function(){return(n._sqlite3_bind_int64=n.asm.bb).apply(null,arguments)},n._sqlite3_bind_null=function(){return(n._sqlite3_bind_null=n.asm.cb).apply(null,arguments)},n._sqlite3_bind_text=function(){return(n._sqlite3_bind_text=n.asm.db).apply(null,arguments)},n._sqlite3_bind_parameter_count=function(){return(n._sqlite3_bind_parameter_count=n.asm.eb).apply(null,arguments)},n._sqlite3_bind_parameter_name=function(){return(n._sqlite3_bind_parameter_name=n.asm.fb).apply(null,arguments)},n._sqlite3_sql=function(){return(n._sqlite3_sql=n.asm.gb).apply(null,arguments)},n._sqlite3_exec=function(){return(n._sqlite3_exec=n.asm.hb).apply(null,arguments)},n._sqlite3_errmsg=function(){return(n._sqlite3_errmsg=n.asm.ib).apply(null,arguments)},n._sqlite3_declare_vtab=function(){return(n._sqlite3_declare_vtab=n.asm.jb).apply(null,arguments)},n._sqlite3_libversion=function(){return(n._sqlite3_libversion=n.asm.kb).apply(null,arguments)},n._sqlite3_libversion_number=function(){return(n._sqlite3_libversion_number=n.asm.lb).apply(null,arguments)},n._sqlite3_changes=function(){return(n._sqlite3_changes=n.asm.mb).apply(null,arguments)},n._sqlite3_close=function(){return(n._sqlite3_close=n.asm.nb).apply(null,arguments)},n._sqlite3_limit=function(){return(n._sqlite3_limit=n.asm.ob).apply(null,arguments)},n._sqlite3_open_v2=function(){return(n._sqlite3_open_v2=n.asm.pb).apply(null,arguments)},n._sqlite3_get_autocommit=function(){return(n._sqlite3_get_autocommit=n.asm.qb).apply(null,arguments)};function ca(){return(ca=n.asm.rb).apply(null,arguments)}var la=n._malloc=function(){return(la=n._malloc=n.asm.sb).apply(null,arguments)},Su=n._free=function(){return(Su=n._free=n.asm.tb).apply(null,arguments)};n._RegisterExtensionFunctions=function(){return(n._RegisterExtensionFunctions=n.asm.ub).apply(null,arguments)},n._set_authorizer=function(){return(n._set_authorizer=n.asm.vb).apply(null,arguments)},n._create_function=function(){return(n._create_function=n.asm.wb).apply(null,arguments)},n._create_module=function(){return(n._create_module=n.asm.xb).apply(null,arguments)},n._progress_handler=function(){return(n._progress_handler=n.asm.yb).apply(null,arguments)},n._register_vfs=function(){return(n._register_vfs=n.asm.zb).apply(null,arguments)},n._getSqliteFree=function(){return(n._getSqliteFree=n.asm.Ab).apply(null,arguments)};var ku=n._main=function(){return(ku=n._main=n.asm.Bb).apply(null,arguments)};function Ru(){return(Ru=n.asm.Db).apply(null,arguments)}function Du(){return(Du=n.asm.Eb).apply(null,arguments)}function Lu(){return(Lu=n.asm.Fb).apply(null,arguments)}function fa(){return(fa=n.asm.Gb).apply(null,arguments)}function ha(){return(ha=n.asm.Hb).apply(null,arguments)}function Pu(){return(Pu=n.asm.Ib).apply(null,arguments)}function Mu(){return(Mu=n.asm.Jb).apply(null,arguments)}function Qi(){return(Qi=n.asm.Kb).apply(null,arguments)}function da(){return(da=n.asm.Lb).apply(null,arguments)}n.getTempRet0=Du,n.ccall=Bn,n.cwrap=function(s,u,f,y){var _=!f||f.every(k=>k==="number"||k==="boolean");return u!=="string"&&_&&!y?n["_"+s]:function(){return Bn(s,u,f,arguments,y)}},n.setValue=x,n.getValue=Ke,n.UTF8ToString=F,n.stringToUTF8=Ln,n.lengthBytesUTF8=oe;var $s;Oe=function s(){$s||I(),$s||(Oe=s)};function I(){function s(){if(!$s&&($s=!0,n.calledRun=!0,!N)){if(n.noFSInit||Yo||(Yo=!0,Kr(),n.stdin=n.stdin,n.stdout=n.stdout,n.stderr=n.stderr,n.stdin?Jr("stdin",n.stdin):qi("/dev/tty","/dev/stdin"),n.stdout?Jr("stdout",null,n.stdout):qi("/dev/tty","/dev/stdout"),n.stderr?Jr("stderr",null,n.stderr):qi("/dev/tty1","/dev/stderr"),Ai("/dev/stdin",0),Ai("/dev/stdout",1),Ai("/dev/stderr",1)),Mt=!1,Jt(Wt),Jt(Qe),i(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),G){var u=ku;try{var f=u(0,0);q=f,oa(f)}catch(y){aa(y)}}if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)u=n.postRun.shift(),Kt.unshift(u);Jt(Kt)}}if(!(0{try{await navigator.locks.request(e,n,l=>{if(i(l),l)return new Promise(m=>r(this,Wo).set(e,m))})}catch(l){a(l)}})}_releaseWebLock(e){var n;(n=r(this,Wo).get(e))==null||n(),r(this,Wo).delete(e)}async _pollWebLock(e){var i;return(i=(await navigator.locks.query()).held.find(({name:a})=>a===e))==null?void 0:i.mode}_getTimeoutSignal(){if(this.timeoutMillis){const e=new AbortController;return setTimeout(()=>e.abort(),this.timeoutMillis),e.signal}}}jt=new WeakMap,Wo=new WeakMap,cu=new WeakMap,lu=new WeakSet,wf=async function(e,n){const i=n&PN;try{const a=()=>e.call(this,i);return await P(this,cu,r(this,cu).then(a,a)),P(this,jt,i),Ve}catch(a){return a.name==="AbortError"?vN:(console.error(a),EN)}},Zc=new WeakSet,vm=async function(e){if(e===r(this,jt))return Ve;switch(r(this,jt)){case Vs:switch(e){case Yi:return this._NONEtoSHARED();default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}case Yi:switch(e){case ic:return this._SHAREDtoRESERVED();case sc:return this._SHAREDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}case ic:switch(e){case sc:return this._RESERVEDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}},el=new WeakSet,_m=async function(e){if(e===r(this,jt))return Ve;switch(r(this,jt)){case sc:switch(e){case Yi:return this._EXCLUSIVEtoSHARED();case Vs:return this._EXCLUSIVEtoNONE();default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}case ic:switch(e){case Yi:return this._RESERVEDtoSHARED();case Vs:return this._RESERVEDtoNONE();default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}case Yi:switch(e){case Vs:return this._SHAREDtoNONE();default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}};class BN extends MN{constructor(e){super(),this._lockName=e+"-outer",this._reservedName=e+"-reserved"}async isSomewhereReserved(){return await this._pollWebLock(this._reservedName)==="exclusive"}async _NONEtoSHARED(){await this._acquireWebLock(this._lockName,{mode:"exclusive",signal:this._getTimeoutSignal()})}async _SHAREDtoRESERVED(){await this._acquireWebLock(this._reservedName,{mode:"exclusive",signal:this._getTimeoutSignal()})}async _RESERVEDtoSHARED(){this._releaseWebLock(this._reservedName)}async _SHAREDtoNONE(){this._releaseWebLock(this._lockName)}}const FN=5e3;let UN=0;const Ql=new WeakMap;function vr(...t){}var Io,Ao,fu,Rt,hu,To,ys,tl,xm;class $N{constructor(e,n={durability:"default"}){S(this,tl);S(this,Io,void 0);S(this,Ao,void 0);S(this,fu,void 0);S(this,Rt,null);S(this,hu,0);S(this,To,Promise.resolve());S(this,ys,Promise.resolve());P(this,Ao,Promise.resolve(e).then(i=>P(this,Io,i))),P(this,fu,n)}async close(){const e=r(this,Io)??await r(this,Ao);await r(this,To),await this.sync(),e.close()}async run(e,n){const i=r(this,To).then(()=>qe(this,tl,xm).call(this,e,n));return P(this,To,i.catch(()=>{})),i}async sync(){await r(this,ys),P(this,ys,Promise.resolve())}}Io=new WeakMap,Ao=new WeakMap,fu=new WeakMap,Rt=new WeakMap,hu=new WeakMap,To=new WeakMap,ys=new WeakMap,tl=new WeakSet,xm=async function(e,n){var a,l;const i=r(this,Io)??await r(this,Ao);if(e==="readwrite"&&((a=r(this,Rt))==null?void 0:a.mode)==="readonly")P(this,Rt,null);else if(performance.now()-r(this,hu)>FN){try{(l=r(this,Rt))==null||l.commit()}catch(m){if(m.name!=="InvalidStateError")throw m}await new Promise(m=>setTimeout(m)),P(this,Rt,null)}for(let m=0;m<2;++m){if(!r(this,Rt)){P(this,Rt,i.transaction(i.objectStoreNames,e,r(this,fu)));const w=P(this,hu,performance.now());P(this,ys,r(this,ys).then(()=>new Promise((v,d)=>{r(this,Rt).addEventListener("complete",W=>{v(),r(this,Rt)===W.target&&P(this,Rt,null),vr(`transaction ${Ql.get(W.target)} complete`)}),r(this,Rt).addEventListener("abort",W=>{console.warn("tx abort",(performance.now()-w)/1e3);const B=W.target.error;d(B),r(this,Rt)===W.target&&P(this,Rt,null),vr(`transaction ${Ql.get(W.target)} aborted`,B)})}))),Ql.set(r(this,Rt),UN++)}try{const w=Object.fromEntries(Array.from(i.objectStoreNames,v=>[v,new QN(r(this,Rt).objectStore(v))]));return await n(w)}catch(w){if(P(this,Rt,null),m)throw w}}};function ii(t){return new Promise((e,n)=>{t.addEventListener("success",()=>e(t.result)),t.addEventListener("error",()=>n(t.error))})}var It;class QN{constructor(e){S(this,It,void 0);P(this,It,e)}get(e){vr(`get ${r(this,It).name}`,e);const n=r(this,It).get(e);return ii(n)}getAll(e,n){vr(`getAll ${r(this,It).name}`,e,n);const i=r(this,It).getAll(e,n);return ii(i)}getKey(e){vr(`getKey ${r(this,It).name}`,e);const n=r(this,It).getKey(e);return ii(n)}getAllKeys(e,n){vr(`getAllKeys ${r(this,It).name}`,e,n);const i=r(this,It).getAllKeys(e,n);return ii(i)}put(e,n){vr(`put ${r(this,It).name}`,e,n);const i=r(this,It).put(e,n);return ii(i)}delete(e){vr(`delete ${r(this,It).name}`,e);const n=r(this,It).delete(e);return ii(n)}clear(){vr(`clear ${r(this,It).name}`);const e=r(this,It).clear();return ii(e)}index(e){return new jN(r(this,It).index(e))}}It=new WeakMap;var ws;class jN{constructor(e){S(this,ws,void 0);P(this,ws,e)}getAllKeys(e,n){vr(`IDBIndex.getAllKeys ${r(this,ws).objectStore.name}<${r(this,ws).name}>`,e,n);const i=r(this,ws).getAllKeys(e,n);return ii(i)}}ws=new WeakMap;const HN=512,rd=3e3,id={durability:"default",purge:"deferred",purgeAtLeast:16};function gn(...t){}var yi,Ht,pt,gs,bs,Mr,du,gf,nl,Em,rl,Cm,wi,zs,il,Om;class VN extends LN{constructor(n="wa-sqlite",i=id){super();S(this,du);S(this,nl);S(this,rl);S(this,wi);S(this,il);S(this,yi,void 0);S(this,Ht,new Map);S(this,pt,void 0);S(this,gs,new Set);S(this,bs,performance.now());S(this,Mr,new Set);this.name=n,P(this,yi,Object.assign({},id,i)),P(this,pt,new $N(zN(n),{durability:r(this,yi).durability}))}async close(){var n;for(const i of r(this,Ht).keys())await this.xClose(i);await((n=r(this,pt))==null?void 0:n.close()),P(this,pt,null)}xOpen(n,i,a,l){return this.handleAsync(async()=>{n===null&&(n=`null_${i}`),gn(`xOpen ${n} 0x${i.toString(16)} 0x${a.toString(16)}`);try{const m=new URL(n,"http://localhost/"),w={path:m.pathname,flags:a,block0:null,locks:new BN(m.pathname)};return r(this,Ht).set(i,w),await r(this,pt).run("readwrite",async({blocks:v})=>{if(w.block0=await v.get(qe(this,wi,zs).call(this,w,0)),!w.block0)if(a&Nm)w.block0={path:w.path,offset:0,version:0,data:new Uint8Array(0),fileSize:0},v.put(w.block0);else throw new Error(`file not found: ${w.path}`)}),l.setInt32(0,a&ON,!0),Ve}catch(m){return console.error(m),bm}})}xClose(n){return this.handleAsync(async()=>{try{const i=r(this,Ht).get(n);return i&&(gn(`xClose ${i.path}`),r(this,Ht).delete(n),i.flags&WN&&r(this,pt).run("readwrite",({blocks:a})=>{a.delete(IDBKeyRange.bound([i.path],[i.path,[]]))})),Ve}catch(i){return console.error(i),xt}})}xRead(n,i,a){return this.handleAsync(async()=>{const l=r(this,Ht).get(n);gn(`xRead ${l.path} ${i.byteLength} ${a}`);try{return await r(this,pt).run("readonly",async({blocks:w})=>{let v=0;for(;vrd){const m=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&r(this,Mr).add(n),await new Promise(v=>setTimeout(v));const w=qe(this,du,gf).call(this,n,i,a);return P(this,bs,performance.now()),w});return l&&r(this,Mr).delete(n),m}return qe(this,du,gf).call(this,n,i,a)}xTruncate(n,i){const a=r(this,Ht).get(n);gn(`xTruncate ${a.path} ${i}`);try{Object.assign(a.block0,{fileSize:i,data:a.block0.data.slice(0,i)});const l=Object.assign({},a.block0);return r(this,pt).run("readwrite",({blocks:m})=>{m.delete(qe(this,wi,zs).call(this,a,-1/0,-i)),m.put(l)}),Ve}catch(l){return console.error(l),xt}}xSync(n,i){const a=r(this,Mr).has(n);if(a||r(this,yi).durability!=="relaxed"||performance.now()-r(this,bs)>rd){const m=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&r(this,Mr).add(n);const w=await qe(this,nl,Em).call(this,n,i);return P(this,bs,performance.now()),w});return a&&r(this,Mr).delete(n),m}const l=r(this,Ht).get(n);return gn(`xSync ${l.path} ${i}`),Ve}xFileSize(n,i){const a=r(this,Ht).get(n);return gn(`xFileSize ${a.path}`),i.setBigInt64(0,BigInt(a.block0.fileSize),!0),Ve}xLock(n,i){return this.handleAsync(async()=>{const a=r(this,Ht).get(n);gn(`xLock ${a.path} ${i}`);try{const l=await a.locks.lock(i);return l===Ve&&a.locks.state===Yi&&(a.block0=await r(this,pt).run("readonly",({blocks:m})=>m.get(qe(this,wi,zs).call(this,a,0)))),l}catch(l){return console.error(l),xt}})}xUnlock(n,i){return this.handleAsync(async()=>{const a=r(this,Ht).get(n);gn(`xUnlock ${a.path} ${i}`);try{return a.locks.unlock(i)}catch(l){return console.error(l),xt}})}xCheckReservedLock(n,i){return this.handleAsync(async()=>{const a=r(this,Ht).get(n);gn(`xCheckReservedLock ${a.path}`);const l=await a.locks.isSomewhereReserved();return i.setInt32(0,l?1:0,!0),Ve})}xSectorSize(n){return HN}xDeviceCharacteristics(n){return kN|AN|TN|SN}xFileControl(n,i,a){const l=r(this,Ht).get(n);switch(gn(`xFileControl ${l.path} ${i}`),i){case 11:return l.overwrite=!0,Ve;case 21:if(l.overwrite)try{return this.handleAsync(async()=>(await qe(this,il,Om).call(this,l),Ve))}catch(m){return console.error(m),xt}return Ve;case 22:return l.overwrite=!1,Ve;case 31:return this.handleAsync(async()=>{try{return l.block0.version--,l.changedPages=new Set,r(this,pt).run("readwrite",async({blocks:m})=>{const w=await m.index("version").getAllKeys(IDBKeyRange.bound([l.path],[l.path,l.block0.version]));for(const v of w)m.delete(v)}),Ve}catch(m){return console.error(m),xt}});case 32:try{const m=Object.assign({},l.block0);m.data=m.data.slice();const w=l.changedPages;return l.changedPages=null,r(this,pt).run("readwrite",async({blocks:v})=>{v.put(m);const d=await v.get([l.path,"purge",0])??{path:l.path,offset:"purge",version:0,data:new Map,count:0};d.count+=w.size;for(const W of w)d.data.set(W,m.version);v.put(d),qe(this,rl,Cm).call(this,l.path,d.count)}),Ve}catch(m){return console.error(m),xt}case 33:return this.handleAsync(async()=>{try{return l.changedPages=null,l.block0=await r(this,pt).run("readonly",({blocks:m})=>m.get([l.path,0,l.block0.version+1])),Ve}catch(m){return console.error(m),xt}});default:return gm}}xAccess(n,i,a){return this.handleAsync(async()=>{try{const l=new URL(n,"file://localhost/").pathname;gn(`xAccess ${l} ${i}`);const m=await r(this,pt).run("readonly",({blocks:w})=>w.getKey(qe(this,wi,zs).call(this,{path:l},0)));return a.setInt32(0,m?1:0,!0),Ve}catch(l){return console.error(l),xt}})}xDelete(n,i){return this.handleAsync(async()=>{const a=new URL(n,"file://localhost/").pathname;try{return r(this,pt).run("readwrite",({blocks:l})=>l.delete(IDBKeyRange.bound([a],[a,[]]))),i&&await r(this,pt).sync(),Ve}catch(l){return console.error(l),xt}})}async purge(n){const i=Date.now();await r(this,pt).run("readwrite",async({blocks:a})=>{const l=await a.get([n,"purge",0]);if(l){for(const[m,w]of l.data)a.delete(IDBKeyRange.bound([n,m,w],[n,m,1/0],!0,!1));await a.delete([n,"purge",0])}gn(`purge ${n} ${(l==null?void 0:l.data.size)??0} pages in ${Date.now()-i} ms`)})}}yi=new WeakMap,Ht=new WeakMap,pt=new WeakMap,gs=new WeakMap,bs=new WeakMap,Mr=new WeakMap,du=new WeakSet,gf=function(n,i,a){const l=r(this,Ht).get(n);gn(`xWrite ${l.path} ${i.byteLength} ${a}`);try{const m=l.block0.fileSize;l.block0.fileSize=Math.max(l.block0.fileSize,a+i.byteLength);const w=a===0?l.block0:{path:l.path,offset:-a,version:l.block0.version,data:null};return w.data=i.slice(),l.changedPages?(m===l.block0.fileSize&&l.changedPages.add(-a),a!==0&&r(this,pt).run("readwrite",({blocks:v})=>v.put(w))):r(this,pt).run("readwrite",({blocks:v})=>v.put(w)),Ve}catch(m){return console.error(m),xt}},nl=new WeakSet,Em=async function(n,i){const a=r(this,Ht).get(n);gn(`xSync ${a.path} ${i}`);try{await r(this,pt).sync()}catch(l){return console.error(l),xt}return Ve},rl=new WeakSet,Cm=function(n,i){r(this,yi).purge==="manual"||r(this,gs).has(n)||i{this.purge(n),r(this,gs).delete(n)}):setTimeout(()=>{this.purge(n),r(this,gs).delete(n)}),r(this,gs).add(n))},wi=new WeakSet,zs=function(n,i,a=0){const l=!i||-i{const ne=await D.index("version").getAllKeys(IDBKeyRange.bound([n.path,B+1],[n.path,1/0]));for(const te of ne)D.delete(te);D.delete([n.path,"purge",0]);for(let te=0;te=W)break;const T={path:C.path,offset:q,version:B,data:C.data.subarray(N*l,(N+1)*l)};T.offset===0&&(T.fileSize=W,n.block0=T),D.put(T)}}}})};function zN(t){return new Promise((e,n)=>{const i=globalThis.indexedDB.open(t,5);i.addEventListener("upgradeneeded",function(){i.result.createObjectStore("blocks",{keyPath:["path","offset","version"]}).createIndex("version",["path","version"])}),i.addEventListener("success",()=>{e(i.result)}),i.addEventListener("error",()=>{n(i.error)})})}const KN=""+new URL("wa-sqlite-async-24800831.wasm",import.meta.url).href,JN=new zb({async database(){const t=await DN({locateFile:()=>KN}),e=RN(t),n="wa-sqlite-test";e.vfs_register(new VN(n));const i=await e.open_v2(n,void 0,n);return{sqlite:e,db:i}}});function GN(){console.log("start wa-sqlite test"),Xf(JN).then(t=>{t==null||t.forEach(e=>console.log("[wa-sqlite]",e))})}function XN(t){return{all:t=t||new Map,on:function(e,n){var i=t.get(e);i?i.push(n):t.set(e,[n])},off:function(e,n){var i=t.get(e);i&&(n?i.splice(i.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var i=t.get(e);i&&i.slice().map(function(a){a(n)}),(i=t.get("*"))&&i.slice().map(function(a){a(e,n)})}}}var Zi=XN(),Br,ur,pu,yd,YN=(yd=class{constructor(t){S(this,Br,void 0);S(this,ur,void 0);Yt(this,"connection");S(this,pu,new ZN);P(this,Br,t),P(this,ur,r(this,Br).worker??new Worker(new URL(""+new URL("worker-72ad2512.js",import.meta.url).href,self.location),{type:"module"})),r(this,ur).onmessage=n=>{const{type:i,msg:a}=n.data;Zi.emit(i,a)};const e={type:"init",dbName:r(this,Br).dbName,url:r(this,Br).url};r(this,ur).postMessage(e)}async init(){await new Promise((t,e)=>{Zi.on("init",n=>{Zi.off("init");const{err:i}=n;i?e(i):t()})}),this.connection=new e0(r(this,ur)),r(this,Br).onCreateConnection&&await r(this,Br).onCreateConnection(this.connection)}async acquireConnection(){return await r(this,pu).lock(),this.connection}async beginTransaction(t){await t.executeQuery(Qr.raw("begin"))}async commitTransaction(t){await t.executeQuery(Qr.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(Qr.raw("rollback"))}async releaseConnection(){r(this,pu).unlock()}async destroy(){if(r(this,ur))return r(this,ur).postMessage({type:"close"}),new Promise((t,e)=>{Zi.on("close",n=>{Zi.off("close");const{err:i}=n;i?e(i):(r(this,ur).terminate(),P(this,ur,null),t())})})}},Br=new WeakMap,ur=new WeakMap,pu=new WeakMap,yd),Ns,So,wd,ZN=(wd=class{constructor(){S(this,Ns,void 0);S(this,So,void 0)}async lock(){for(;r(this,Ns);)await r(this,Ns);P(this,Ns,new Promise(t=>{P(this,So,t)}))}unlock(){const t=r(this,So);P(this,Ns,void 0),P(this,So,void 0),t==null||t()}},Ns=new WeakMap,So=new WeakMap,wd),mu,gd,e0=(gd=class{constructor(t){S(this,mu,void 0);P(this,mu,t)}streamQuery(){throw new Error("Sqlite driver doesn't support streaming")}async executeQuery(t){const{parameters:e,sql:n,query:i}=t,l={type:"run",isQuery:["SelectQueryNode","RawNode"].includes(i.kind),sql:n,parameters:e};return r(this,mu).postMessage(l),new Promise((m,w)=>{Zi.on("run",v=>{Zi.off("run");const{data:d,err:W}=v;!W&&d?m(d):w(W)})})}},mu=new WeakMap,gd),yu,bd,t0=(bd=class{constructor(t){S(this,yu,void 0);P(this,yu,t)}createDriver(){return new YN(r(this,yu))}createQueryCompiler(){return new lm}createAdapter(){return new dm}createIntrospector(t){return new fm(t)}},yu=new WeakMap,bd);const n0=""+new URL("wa-sqlite-async-24800831.wasm",import.meta.url).href,r0=new t0({dbName:"wa-sqlite-worker-test",url:n0});function i0(){console.log("start wa-sqlite-worker test"),Xf(r0).then(t=>{t==null||t.forEach(e=>console.log("[wa-sqlite-worker]",e))})}const s0=Ct("h1",null,[ka(" test "),Ct("a",{href:"https://github.com/kysely-org/kysely",target:"_blank"},"Kysely"),ka(" WASM dialect ")],-1),o0=Ct("br",null,null,-1),a0=Ct("h3",null,"see worker result in console",-1),u0=Ct("h3",null,[ka(" you can explore "),Ct("a",{href:"https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API#origin_private_file_system",target:"_blank"}," OPFS "),ka(" file using "),Ct("a",{href:"https://chrome.google.com/webstore/detail/opfs-explorer/acndjpgkpaclldomagafnognkcgjignd",target:"_blank"}," opfs-explorer ")],-1),c0=Ct("br",null,null,-1),l0={class:"buttons"},f0=Ct("br",null,null,-1),h0=Ct("div",null," result run in main thread: ",-1),d0=Hy({__name:"App",setup(t){const e=new bN,{result:n,run:i}=gN(),a=new NN;function l(){i()}function m(){e.postMessage("")}function w(){a.postMessage("")}function v(){GN()}function d(){i0()}async function W(){console.clear();const B=await navigator.storage.getDirectory();await zh("sqljs"),await zh("sqlijsWorker"),indexedDB.deleteDatabase("idb-batch-atomic");try{await B.removeEntry("test.db")}catch{}try{await B.removeEntry("test.db-journal")}catch{}console.log("clear all")}return(B,D)=>(Nw(),xw(cr,null,[s0,o0,a0,u0,c0,Ct("div",l0,[Ct("button",{onClick:D[0]||(D[0]=ne=>l())}," test sqljs in main thread "),Ct("button",{onClick:D[1]||(D[1]=ne=>m())}," test sqljs in Worker "),Ct("button",{onClick:D[2]||(D[2]=ne=>w())}," test officialWasm in Worker "),Ct("button",{onClick:D[3]||(D[3]=ne=>v())}," test wa-sqlite in main thread "),Ct("button",{onClick:D[4]||(D[4]=ne=>d())}," test wa-sqlite in Worker "),Ct("button",{onClick:D[5]||(D[5]=ne=>W())}," clear ")]),f0,h0,Ct("pre",null,""+Dm($d(n))+` `,1)],64))}});ag(d0).mount("#root"); diff --git a/assets/officialWasmWorker-94e472c1.js b/assets/officialWasmWorker-b264d8ca.js similarity index 96% rename from assets/officialWasmWorker-94e472c1.js rename to assets/officialWasmWorker-b264d8ca.js index c4af9e0..b4ae12e 100644 --- a/assets/officialWasmWorker-94e472c1.js +++ b/assets/officialWasmWorker-b264d8ca.js @@ -1,4 +1,4 @@ -var yd=Object.defineProperty;var gd=(Te,Ne,Ze)=>Ne in Te?yd(Te,Ne,{enumerable:!0,configurable:!0,writable:!0,value:Ze}):Te[Ne]=Ze;var Tt=(Te,Ne,Ze)=>(gd(Te,typeof Ne!="symbol"?Ne+"":Ne,Ze),Ze),qo=(Te,Ne,Ze)=>{if(!Ne.has(Te))throw TypeError("Cannot "+Ze)};var s=(Te,Ne,Ze)=>(qo(Te,Ne,"read from private field"),Ze?Ze.call(Te):Ne.get(Te)),R=(Te,Ne,Ze)=>{if(Ne.has(Te))throw TypeError("Cannot add the same private member more than once");Ne instanceof WeakSet?Ne.add(Te):Ne.set(Te,Ze)},U=(Te,Ne,Ze,Pr)=>(qo(Te,Ne,"write to private field"),Pr?Pr.call(Te,Ze):Ne.set(Te,Ze),Ze);var Le=(Te,Ne,Ze)=>(qo(Te,Ne,"access private method"),Ze);(function(){var ze,Dn,cr,Zr,ei,ge,ti,Ve,ye,ni,Z,ri,te,dr,gs,fr,Rn,ws,il,qs,sl,Bn,Oi,ii,bo,bs,ol,si,Re,oi,hr,pr,Un,ai,No,F,_r,mr,yr,gr,kn,Ue,wr,qr,br,Nr,sn,vr,Fe,jn,Xt,qt,tt,je,Ye,Pe,Ft,ke,ht,vt,xt,Ss,He,pt,Pt,Lt,lt,xr,an,ln,_n,Yt,On,mn,Vn,fi,ks,al,Is,ll,Os,ul,As,cl,hi,vo,pi,An,Ts,dl,Tn,Hn,_t,Zt,$n,en,Ot,kr,Us,_i,xo,mi,Eo,Ir,Cn,Ws,Or,Gn,Ar,Fs,fl,yi,Ps,Oa,Jn,Tr,Aa,yn,gi,Ta,Kn,Ca,wi,Wa,Xn,Fa,qi,bi,Cr,Pa,Wn,Ni,La;"use strict";function Te(t){return typeof t>"u"||t===void 0}function Ne(t){return typeof t=="string"}function Ze(t){return typeof t=="number"}function Pr(t){return typeof t=="boolean"}function So(t){return t===null}function hl(t){return t instanceof Date}function pl(t){return typeof t=="bigint"}function Rt(t){return typeof t=="function"}function tn(t){return typeof t=="object"&&t!==null}function h(t){return Object.freeze(t)}function Lr(t){return Array.isArray(t)}function tr(t){return t}const et=h({is(t){return t.kind==="AlterTableNode"},create(t){return h({kind:"AlterTableNode",table:t})},cloneWithTableProps(t,e){return h({...t,...e})},cloneWithColumnAlteration(t,e){return h({...t,columnAlterations:t.columnAlterations?[...t.columnAlterations,e]:[e]})}}),Ge=h({is(t){return t.kind==="IdentifierNode"},create(t){return h({kind:"IdentifierNode",name:t})}}),bn=h({is(t){return t.kind==="CreateIndexNode"},create(t){return h({kind:"CreateIndexNode",name:Ge.create(t)})},cloneWith(t,e){return h({...t,...e})},cloneWithColumns(t,e){return h({...t,columns:[...t.columns||[],...e]})}}),ko=h({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return h({kind:"CreateSchemaNode",schema:Ge.create(t),...e})},cloneWith(t,e){return h({...t,...e})}}),_l=["preserve rows","delete rows","drop"],Ht=h({is(t){return t.kind==="CreateTableNode"},create(t){return h({kind:"CreateTableNode",table:t,columns:h([])})},cloneWithColumn(t,e){return h({...t,columns:h([...t.columns,e])})},cloneWithConstraint(t,e){return h({...t,constraints:t.constraints?h([...t.constraints,e]):h([e])})},cloneWithFrontModifier(t,e){return h({...t,frontModifiers:t.frontModifiers?h([...t.frontModifiers,e]):h([e])})},cloneWithEndModifier(t,e){return h({...t,endModifiers:t.endModifiers?h([...t.endModifiers,e]):h([e])})},cloneWith(t,e){return h({...t,...e})}}),Nn=h({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return h({kind:"SchemableIdentifierNode",identifier:Ge.create(t)})},createWithSchema(t,e){return h({kind:"SchemableIdentifierNode",schema:Ge.create(t),identifier:Ge.create(e)})}}),Ai=h({is(t){return t.kind==="DropIndexNode"},create(t,e){return h({kind:"DropIndexNode",name:Nn.create(t),...e})},cloneWith(t,e){return h({...t,...e})}}),js=h({is(t){return t.kind==="DropSchemaNode"},create(t,e){return h({kind:"DropSchemaNode",schema:Ge.create(t),...e})},cloneWith(t,e){return h({...t,...e})}}),Qs=h({is(t){return t.kind==="DropTableNode"},create(t,e){return h({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return h({...t,...e})}}),Pn=h({is(t){return t.kind==="AliasNode"},create(t,e){return h({kind:"AliasNode",node:t,alias:e})}}),vn=h({is(t){return t.kind==="TableNode"},create(t){return h({kind:"TableNode",table:Nn.create(t)})},createWithSchema(t,e){return h({kind:"TableNode",table:Nn.createWithSchema(t,e)})}});function bt(t){return tn(t)&&Rt(t.toOperationNode)}function ml(t){return tn(t)&&"expressionType"in t&&bt(t)}function yl(t){return tn(t)&&"expression"in t&&Ne(t.alias)&&bt(t)}const dn=h({is(t){return t.kind==="SelectModifierNode"},create(t){return h({kind:"SelectModifierNode",modifier:t})},createWithExpression(t){return h({kind:"SelectModifierNode",rawModifier:t})}}),Dr=h({is(t){return t.kind==="AndNode"},create(t,e){return h({kind:"AndNode",left:t,right:e})}}),Rr=h({is(t){return t.kind==="OrNode"},create(t,e){return h({kind:"OrNode",left:t,right:e})}}),Br=h({is(t){return t.kind==="OnNode"},create(t){return h({kind:"OnNode",on:t})},cloneWithOperation(t,e,r){return h({...t,on:e==="And"?Dr.create(t.on,r):Rr.create(t.on,r)})}}),Bt=h({is(t){return t.kind==="JoinNode"},create(t,e){return h({kind:"JoinNode",joinType:t,table:e,on:void 0})},createWithOn(t,e,r){return h({kind:"JoinNode",joinType:t,table:e,on:Br.create(r)})},cloneWithOn(t,e){return h({...t,on:t.on?Br.cloneWithOperation(t.on,"And",e):Br.create(e)})},cloneWithOrOn(t,e){return h({...t,on:t.on?Br.cloneWithOperation(t.on,"Or",e):Br.create(e)})}}),Ti=h({is(t){return t.kind==="BinaryOperationNode"},create(t,e,r){return h({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:r})}}),yt=h({is(t){return t.kind==="RawNode"},create(t,e){return h({kind:"RawNode",sqlFragments:h(t),parameters:h(e)})},createWithSql(t){return yt.create([t],[])},createWithChild(t){return yt.create(["",""],[t])},createWithChildren(t){return yt.create(new Array(t.length+1).fill(""),t)}}),Io=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->"],gl=["+","-","*","/","%","^","&","|","#","<<",">>"],Oo=[...Io,...gl,"&&","||"],wl=["not","-",...["exists","not exists"]],ql=[...Oo,...wl],zs=h({is(t){return t.kind==="OperatorNode"},create(t){return h({kind:"OperatorNode",operator:t})}});function Ao(t){return Ne(t)&&Oo.includes(t)}function To(t){return Ne(t)&&Io.includes(t)}const nr=h({is(t){return t.kind==="ParensNode"},create(t){return h({kind:"ParensNode",node:t})}}),Ke=h({is(t){return t.kind==="ColumnNode"},create(t){return h({kind:"ColumnNode",column:Ge.create(t)})}}),Vs=h({is(t){return t.kind==="SelectAllNode"},create(){return h({kind:"SelectAllNode"})}}),Ci=h({is(t){return t.kind==="ReferenceNode"},create(t,e){return h({kind:"ReferenceNode",table:t,column:e})},createSelectAll(t){return h({kind:"ReferenceNode",table:t,column:Vs.create()})}}),bl=h({is(t){return t.kind==="OrderByItemNode"},create(t,e){return h({kind:"OrderByItemNode",orderBy:t,direction:e})}});function Nl(t){return t==="asc"||t==="desc"}function Wi(t,e){return bl.create(vl(t),xl(e))}function vl(t){return fn(t)}function xl(t){if(t)return t==="asc"||t==="desc"?yt.createWithSql(t):t.toOperationNode()}function Co(t){return Ne(t)?rr(t):t.toOperationNode()}function Mr(t){return Lr(t)?t.map(e=>fn(e)):[fn(t)]}function fn(t){return Ki(t)?Ji(t):Co(t)}function rr(t){const e=".";if(t.includes(e)){const r=t.split(e).map(Hs);if(r.length===3)return Sl(r);if(r.length===2)return kl(r);throw new Error(`invalid column reference ${t}`)}else return Ke.create(t)}function El(t){const e=" as ";if(t.includes(e)){const[r,n]=t.split(e).map(Hs);return Pn.create(rr(r),Ge.create(n))}else return rr(t)}function Wo(t){return Ke.create(t)}function Fo(t){const e=" ";if(t.includes(e)){const[r,n]=t.split(e).map(Hs);if(!Nl(n))throw new Error(`invalid order direction "${n}" next to "${r}"`);return Wi(r,n)}else return Wo(t)}function Sl(t){const[e,r,n]=t;return Ci.create(vn.createWithSchema(e,r),Ke.create(n))}function kl(t){const[e,r]=t;return Ci.create(vn.create(e),Ke.create(r))}function Hs(t){return t.trim()}const Po=h({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return h({kind:"PrimitiveValueListNode",values:h([...t])})}}),$s=h({is(t){return t.kind==="ValueListNode"},create(t){return h({kind:"ValueListNode",values:h(t)})}}),nn=h({is(t){return t.kind==="ValueNode"},create(t){return h({kind:"ValueNode",value:t})},createImmediate(t){return h({kind:"ValueNode",value:t,immediate:!0})}});function Lo(t){return Lr(t)?Il(t):hn(t)}function hn(t){return Ki(t)?Ji(t):nn.create(t)}function Il(t){return t.some(Ki)?$s.create(t.map(e=>hn(e))):Po.create(t)}const ir=h({is(t){return t.kind==="OrderByNode"},create(t){return h({kind:"OrderByNode",items:h([t])})},cloneWithItem(t,e){return h({...t,items:h([...t.items,e])})}}),Do=h({is(t){return t.kind==="PartitionByNode"},create(t){return h({kind:"PartitionByNode",items:h(t)})},cloneWithItems(t,e){return h({...t,items:h([...t.items,...e])})}}),Gs=h({is(t){return t.kind==="OverNode"},create(){return h({kind:"OverNode"})},cloneWithOrderByItem(t,e){return h({...t,orderBy:t.orderBy?ir.cloneWithItem(t.orderBy,e):ir.create(e)})},cloneWithPartitionByItems(t,e){return h({...t,partitionBy:t.partitionBy?Do.cloneWithItems(t.partitionBy,e):Do.create(e)})}}),Fi=h({is(t){return t.kind==="FromNode"},create(t){return h({kind:"FromNode",froms:h(t)})},cloneWithFroms(t,e){return h({...t,froms:h([...t.froms,...e])})}}),Ro=h({is(t){return t.kind==="GroupByNode"},create(t){return h({kind:"GroupByNode",items:h(t)})},cloneWithItems(t,e){return h({...t,items:h([...t.items,...e])})}}),Pi=h({is(t){return t.kind==="HavingNode"},create(t){return h({kind:"HavingNode",having:t})},cloneWithOperation(t,e,r){return h({...t,having:e==="And"?Dr.create(t.having,r):Rr.create(t.having,r)})}}),_e=h({is(t){return t.kind==="SelectQueryNode"},create(t,e){return h({kind:"SelectQueryNode",from:Fi.create(t),...e&&{with:e}})},cloneWithSelections(t,e){return h({...t,selections:t.selections?h([...t.selections,...e]):h(e)})},cloneWithDistinctOn(t,e){return h({...t,distinctOn:t.distinctOn?h([...t.distinctOn,...e]):h(e)})},cloneWithFrontModifier(t,e){return h({...t,frontModifiers:t.frontModifiers?h([...t.frontModifiers,e]):h([e])})},cloneWithEndModifier(t,e){return h({...t,endModifiers:t.endModifiers?h([...t.endModifiers,e]):h([e])})},cloneWithOrderByItem(t,e){return h({...t,orderBy:t.orderBy?ir.cloneWithItem(t.orderBy,e):ir.create(e)})},cloneWithGroupByItems(t,e){return h({...t,groupBy:t.groupBy?Ro.cloneWithItems(t.groupBy,e):Ro.create(e)})},cloneWithLimit(t,e){return h({...t,limit:e})},cloneWithOffset(t,e){return h({...t,offset:e})},cloneWithHaving(t,e){return h({...t,having:t.having?Pi.cloneWithOperation(t.having,"And",e):Pi.create(e)})},cloneWithOrHaving(t,e){return h({...t,having:t.having?Pi.cloneWithOperation(t.having,"Or",e):Pi.create(e)})},cloneWithSetOperation(t,e){return h({...t,setOperations:t.setOperations?h([...t.setOperations,e]):h([e])})},cloneWithoutSelections(t){return h({...t,selections:[]})},cloneWithoutLimit(t){return h({...t,limit:void 0})},cloneWithoutOffset(t){return h({...t,offset:void 0})},cloneWithoutOrderBy(t){return h({...t,orderBy:void 0})}}),Bo=h({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return h({kind:"UnaryOperationNode",operator:t,operand:e})}});function gt(t){return Js("exists",t)}function dt(t){return Js("not exists",t)}function Js(t,e){return Bo.create(zs.create(t),fn(e))}function Se(t,e){Object.defineProperties(t.prototype,{then:{enumerable:!1,value:()=>{throw new Error(e)}}})}const Jt=class{constructor(e){R(this,ze,void 0);U(this,ze,h(e))}on(...e){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOn(s(this,ze).joinNode,ia(e))})}orOn(...e){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOrOn(s(this,ze).joinNode,ia(e))})}onRef(e,r,n){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOn(s(this,ze).joinNode,ft(e,r,n))})}orOnRef(e,r,n){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOrOn(s(this,ze).joinNode,ft(e,r,n))})}onExists(e){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOn(s(this,ze).joinNode,gt(e))})}onNotExists(e){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOn(s(this,ze).joinNode,dt(e))})}orOnExists(e){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOrOn(s(this,ze).joinNode,gt(e))})}orOnNotExists(e){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOrOn(s(this,ze).joinNode,dt(e))})}onTrue(){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOn(s(this,ze).joinNode,yt.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return s(this,ze).joinNode}};let Li=Jt;ze=new WeakMap,Se(Li,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const Ol=h({is(t){return t.kind==="PartitionByItemNode"},create(t){return h({kind:"PartitionByItemNode",partitionBy:t})}});function Al(t){return Mr(t).map(Ol.create)}const ys=class{constructor(e){R(this,Dn,void 0);U(this,Dn,h(e))}orderBy(e,r){return new ys({overNode:Gs.cloneWithOrderByItem(s(this,Dn).overNode,Wi(e,r))})}partitionBy(e){return new ys({overNode:Gs.cloneWithPartitionByItems(s(this,Dn).overNode,Al(e))})}$call(e){return e(this)}toOperationNode(){return s(this,Dn).overNode}};let Di=ys;Dn=new WeakMap,Se(Di,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");const Ur=h({is(t){return t.kind==="SelectionNode"},create(t){return h({kind:"SelectionNode",selection:t})},createSelectAll(){return h({kind:"SelectionNode",selection:Vs.create()})},createSelectAllFromTable(t){return h({kind:"SelectionNode",selection:Ci.createSelectAll(t)})}});class Tl{constructor(e){R(this,cr,void 0);U(this,cr,e)}get dynamicReference(){return s(this,cr)}get refType(){}toOperationNode(){return Co(s(this,cr))}}cr=new WeakMap;function Cl(t){return tn(t)&&bt(t)&&Ne(t.dynamicReference)}function jr(t){return Rt(t)?jr(t(pn())):Lr(t)?t.map(e=>Mo(e)):[Mo(t)]}function Mo(t){return Ne(t)?Ur.create(El(t)):Cl(t)?Ur.create(t.toOperationNode()):Ur.create(fa(t))}function Qr(t){return t?Array.isArray(t)?t.map(Uo):[Uo(t)]:[Ur.createSelectAll()]}function Uo(t){if(Ne(t))return Ur.createSelectAllFromTable(It(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const Wl=h({is(t){return t.kind==="ValuesNode"},create(t){return h({kind:"ValuesNode",values:h(t)})}}),Fl=h({is(t){return t.kind==="DefaultInsertValueNode"},create(){return h({kind:"DefaultInsertValueNode"})}});function Pl(t){const e=Rt(t)?t(pn()):t,r=Lr(e)?e:h([e]);return Ll(r)}function Ll(t){const e=Dl(t);return[h([...e.keys()].map(Ke.create)),Wl.create(t.map(r=>Rl(r,e)))]}function Dl(t){const e=new Map;for(const r of t){const n=Object.keys(r);for(const A of n)!e.has(A)&&r[A]!==void 0&&e.set(A,e.size)}return e}function Rl(t,e){const r=Object.keys(t),n=Array.from({length:e.size});let A=!1;for(const ae of r){const me=e.get(ae);if(Te(me))continue;const Oe=t[ae];(Te(Oe)||Ki(Oe))&&(A=!0),n[me]=Oe}if(r.lengthTe(me)?ae:hn(me)))}return Po.create(n)}const rn=h({is(t){return t.kind==="InsertQueryNode"},create(t,e,r){return h({kind:"InsertQueryNode",into:t,...e&&{with:e},replace:r})},cloneWith(t,e){return h({...t,...e})}}),Ri=h({is(t){return t.kind==="UpdateQueryNode"},create(t,e){return h({kind:"UpdateQueryNode",table:t,...e&&{with:e}})},cloneWithFromItems(t,e){return h({...t,from:t.from?Fi.cloneWithFroms(t.from,e):Fi.create(e)})},cloneWithUpdates(t,e){return h({...t,updates:t.updates?h([...t.updates,...e]):e})}}),jo=h({is(t){return t.kind==="UsingNode"},create(t){return h({kind:"UsingNode",tables:h(t)})},cloneWithTables(t,e){return h({...t,tables:h([...t.tables,...e])})}}),zr=h({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return h({kind:"DeleteQueryNode",from:Fi.create(t),...e&&{with:e}})},cloneWithOrderByItem(t,e){return h({...t,orderBy:t.orderBy?ir.cloneWithItem(t.orderBy,e):ir.create(e)})},cloneWithLimit(t,e){return h({...t,limit:e})},cloneWithUsing(t,e){return h({...t,using:t.using!==void 0?jo.cloneWithTables(t.using,e):jo.create(e)})}}),wt=h({is(t){return t.kind==="WhereNode"},create(t){return h({kind:"WhereNode",where:t})},cloneWithOperation(t,e,r){return h({...t,where:e==="And"?Dr.create(t.where,r):Rr.create(t.where,r)})}}),Qo=h({is(t){return t.kind==="ReturningNode"},create(t){return h({kind:"ReturningNode",selections:h(t)})},cloneWithSelections(t,e){return h({...t,selections:t.selections?h([...t.selections,...e]):h(e)})}}),Bl=h({is(t){return t.kind==="ExplainNode"},create(t,e){return h({kind:"ExplainNode",format:t,options:e})}}),re=h({is(t){return _e.is(t)||rn.is(t)||Ri.is(t)||zr.is(t)},cloneWithWhere(t,e){return h({...t,where:t.where?wt.cloneWithOperation(t.where,"And",e):wt.create(e)})},cloneWithOrWhere(t,e){return h({...t,where:t.where?wt.cloneWithOperation(t.where,"Or",e):wt.create(e)})},cloneWithJoin(t,e){return h({...t,joins:t.joins?h([...t.joins,e]):h([e])})},cloneWithReturning(t,e){return h({...t,returning:t.returning?Qo.cloneWithSelections(t.returning,e):Qo.create(e)})},cloneWithoutWhere(t){return h({...t,where:void 0})},cloneWithExplain(t,e,r){return h({...t,explain:Bl.create(e,r==null?void 0:r.toOperationNode())})}}),Ml=h({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return h({kind:"ColumnUpdateNode",column:t,value:e})}});function Ks(t){const e=Rt(t)?t(pn()):t;return Object.entries(e).filter(([r,n])=>n!==void 0).map(([r,n])=>Ml.create(Ke.create(r),hn(n)))}const Ul=h({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return h({kind:"OnDuplicateKeyNode",updates:t})}});class zo{constructor(e,r){R(this,Zr,void 0);R(this,ei,void 0);U(this,Zr,e),U(this,ei,r)}get insertId(){return s(this,Zr)}get numInsertedOrUpdatedRows(){return s(this,ei)}}Zr=new WeakMap,ei=new WeakMap;for(const t of["insertId","numInsertedOrUpdatedRows"])Object.defineProperty(zo.prototype,t,{enumerable:!0});class Bi extends Error{constructor(r){super("no result");Tt(this,"node");this.node=r}}function Mi(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const Me=h({is(t){return t.kind==="OnConflictNode"},create(){return h({kind:"OnConflictNode"})},cloneWith(t,e){return h({...t,...e})},cloneWithIndexWhere(t,e){return h({...t,indexWhere:t.indexWhere?wt.cloneWithOperation(t.indexWhere,"And",e):wt.create(e)})},cloneWithIndexOrWhere(t,e){return h({...t,indexWhere:t.indexWhere?wt.cloneWithOperation(t.indexWhere,"Or",e):wt.create(e)})},cloneWithUpdateWhere(t,e){return h({...t,updateWhere:t.updateWhere?wt.cloneWithOperation(t.updateWhere,"And",e):wt.create(e)})},cloneWithUpdateOrWhere(t,e){return h({...t,updateWhere:t.updateWhere?wt.cloneWithOperation(t.updateWhere,"Or",e):wt.create(e)})},cloneWithoutIndexWhere(t){return h({...t,indexWhere:void 0})},cloneWithoutUpdateWhere(t){return h({...t,updateWhere:void 0})}}),Nt=class{constructor(e){R(this,ge,void 0);U(this,ge,h(e))}column(e){const r=Ke.create(e);return new Nt({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{columns:s(this,ge).onConflictNode.columns?h([...s(this,ge).onConflictNode.columns,r]):h([r])})})}columns(e){const r=e.map(Ke.create);return new Nt({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{columns:s(this,ge).onConflictNode.columns?h([...s(this,ge).onConflictNode.columns,...r]):h(r)})})}constraint(e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{constraint:Ge.create(e)})})}expression(e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexWhere(s(this,ge).onConflictNode,Ct(e))})}whereRef(e,r,n){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexWhere(s(this,ge).onConflictNode,ft(e,r,n))})}orWhere(...e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexOrWhere(s(this,ge).onConflictNode,Ct(e))})}orWhereRef(e,r,n){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexOrWhere(s(this,ge).onConflictNode,ft(e,r,n))})}whereExists(e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexWhere(s(this,ge).onConflictNode,gt(e))})}whereNotExists(e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexWhere(s(this,ge).onConflictNode,dt(e))})}orWhereExists(e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexOrWhere(s(this,ge).onConflictNode,gt(e))})}orWhereNotExists(e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexOrWhere(s(this,ge).onConflictNode,dt(e))})}clearWhere(){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithoutIndexWhere(s(this,ge).onConflictNode)})}doNothing(){return new Vo({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new ji({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{updates:Ks(e)})})}$call(e){return e(this)}};let Ui=Nt;ge=new WeakMap,Se(Ui,"don't await OnConflictBuilder instances.");class Vo{constructor(e){R(this,ti,void 0);U(this,ti,h(e))}toOperationNode(){return s(this,ti).onConflictNode}}ti=new WeakMap,Se(Vo,"don't await OnConflictDoNothingBuilder instances.");const Kt=class{constructor(e){R(this,Ve,void 0);U(this,Ve,h(e))}where(...e){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateWhere(s(this,Ve).onConflictNode,Ct(e))})}whereRef(e,r,n){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateWhere(s(this,Ve).onConflictNode,ft(e,r,n))})}orWhere(...e){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateOrWhere(s(this,Ve).onConflictNode,Ct(e))})}orWhereRef(e,r,n){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateOrWhere(s(this,Ve).onConflictNode,ft(e,r,n))})}whereExists(e){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateWhere(s(this,Ve).onConflictNode,gt(e))})}whereNotExists(e){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateWhere(s(this,Ve).onConflictNode,dt(e))})}orWhereExists(e){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateOrWhere(s(this,Ve).onConflictNode,gt(e))})}orWhereNotExists(e){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateOrWhere(s(this,Ve).onConflictNode,dt(e))})}clearWhere(){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithoutUpdateWhere(s(this,Ve).onConflictNode)})}$call(e){return e(this)}toOperationNode(){return s(this,Ve).onConflictNode}};let ji=Kt;Ve=new WeakMap,Se(ji,"don't await OnConflictUpdateBuilder instances.");const ot=class{constructor(e){R(this,ye,void 0);U(this,ye,h(e))}values(e){const[r,n]=Pl(e);return new ot({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{columns:r,values:n})})}columns(e){return new ot({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{columns:h(e.map(Ke.create))})})}expression(e){return new ot({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{values:Ji(e)})})}ignore(){return new ot({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{ignore:!0})})}onConflict(e){return new ot({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{onConflict:e(new Ui({onConflictNode:Me.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new ot({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{onDuplicateKey:Ul.create(Ks(e))})})}returning(e){return new ot({...s(this,ye),queryNode:re.cloneWithReturning(s(this,ye).queryNode,jr(e))})}returningAll(){return new ot({...s(this,ye),queryNode:re.cloneWithReturning(s(this,ye).queryNode,Qr())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new ot({...s(this,ye)})}if(e,r){return e?r(this):new ot({...s(this,ye)})}$castTo(){return new ot(s(this,ye))}castTo(){return this.$castTo()}$narrowType(){return new ot(s(this,ye))}$assertType(){return new ot(s(this,ye))}assertType(){return new ot(s(this,ye))}withPlugin(e){return new ot({...s(this,ye),executor:s(this,ye).executor.withPlugin(e)})}toOperationNode(){return s(this,ye).executor.transformQuery(s(this,ye).queryNode,s(this,ye).queryId)}compile(){return s(this,ye).executor.compileQuery(this.toOperationNode(),s(this,ye).queryId)}async execute(){const e=this.compile(),r=e.query,n=await s(this,ye).executor.executeQuery(e,s(this,ye).queryId);return s(this,ye).executor.adapter.supportsReturning&&r.returning?n.rows:[new zo(n.insertId,n.numAffectedRows??n.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Bi){const r=await this.executeTakeFirst();if(r===void 0)throw Mi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=s(this,ye).executor.stream(r,e,s(this,ye).queryId);for await(const A of n)yield*A.rows}async explain(e,r){return await new ot({...s(this,ye),queryNode:re.cloneWithExplain(s(this,ye).queryNode,e,r)}).execute()}};let Vr=ot;ye=new WeakMap,Se(Vr,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Ho{constructor(e){R(this,ni,void 0);U(this,ni,e)}get numDeletedRows(){return s(this,ni)}}ni=new WeakMap,Object.defineProperty(Ho.prototype,"numDeletedRows",{enumerable:!0});const $o=h({is(t){return t.kind==="LimitNode"},create(t){return h({kind:"LimitNode",limit:nn.create(t)})}}),We=class{constructor(e){R(this,Z,void 0);U(this,Z,h(e))}where(...e){return new We({...s(this,Z),queryNode:re.cloneWithWhere(s(this,Z).queryNode,Ct(e))})}whereRef(e,r,n){return new We({...s(this,Z),queryNode:re.cloneWithWhere(s(this,Z).queryNode,ft(e,r,n))})}orWhere(...e){return new We({...s(this,Z),queryNode:re.cloneWithOrWhere(s(this,Z).queryNode,Ct(e))})}orWhereRef(e,r,n){return new We({...s(this,Z),queryNode:re.cloneWithOrWhere(s(this,Z).queryNode,ft(e,r,n))})}whereExists(e){return new We({...s(this,Z),queryNode:re.cloneWithWhere(s(this,Z).queryNode,gt(e))})}whereNotExists(e){return new We({...s(this,Z),queryNode:re.cloneWithWhere(s(this,Z).queryNode,dt(e))})}orWhereExists(e){return new We({...s(this,Z),queryNode:re.cloneWithOrWhere(s(this,Z).queryNode,gt(e))})}orWhereNotExists(e){return new We({...s(this,Z),queryNode:re.cloneWithOrWhere(s(this,Z).queryNode,dt(e))})}clearWhere(){return new We({...s(this,Z),queryNode:re.cloneWithoutWhere(s(this,Z).queryNode)})}using(e){return new We({...s(this,Z),queryNode:zr.cloneWithUsing(s(this,Z).queryNode,lr(e))})}innerJoin(...e){return new We({...s(this,Z),queryNode:re.cloneWithJoin(s(this,Z).queryNode,kt("InnerJoin",e))})}leftJoin(...e){return new We({...s(this,Z),queryNode:re.cloneWithJoin(s(this,Z).queryNode,kt("LeftJoin",e))})}rightJoin(...e){return new We({...s(this,Z),queryNode:re.cloneWithJoin(s(this,Z).queryNode,kt("RightJoin",e))})}fullJoin(...e){return new We({...s(this,Z),queryNode:re.cloneWithJoin(s(this,Z).queryNode,kt("FullJoin",e))})}returning(e){return new We({...s(this,Z),queryNode:re.cloneWithReturning(s(this,Z).queryNode,jr(e))})}returningAll(e){return new We({...s(this,Z),queryNode:re.cloneWithReturning(s(this,Z).queryNode,Qr(e))})}orderBy(e,r){return new We({...s(this,Z),queryNode:zr.cloneWithOrderByItem(s(this,Z).queryNode,Wi(e,r))})}limit(e){return new We({...s(this,Z),queryNode:zr.cloneWithLimit(s(this,Z).queryNode,$o.create(e))})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new We({...s(this,Z)})}if(e,r){return this.$if(e,r)}$castTo(){return new We(s(this,Z))}castTo(){return this.$castTo()}$narrowType(){return new We(s(this,Z))}$assertType(){return new We(s(this,Z))}assertType(){return new We(s(this,Z))}withPlugin(e){return new We({...s(this,Z),executor:s(this,Z).executor.withPlugin(e)})}toOperationNode(){return s(this,Z).executor.transformQuery(s(this,Z).queryNode,s(this,Z).queryId)}compile(){return s(this,Z).executor.compileQuery(this.toOperationNode(),s(this,Z).queryId)}async execute(){const e=this.compile(),r=e.query,n=await s(this,Z).executor.executeQuery(e,s(this,Z).queryId);return s(this,Z).executor.adapter.supportsReturning&&r.returning?n.rows:[new Ho(n.numAffectedRows??n.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Bi){const r=await this.executeTakeFirst();if(r===void 0)throw Mi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=s(this,Z).executor.stream(r,e,s(this,Z).queryId);for await(const A of n)yield*A.rows}async explain(e,r){return await new We({...s(this,Z),queryNode:re.cloneWithExplain(s(this,Z).queryNode,e,r)}).execute()}};let Qi=We;Z=new WeakMap,Se(Qi,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Go{constructor(e){R(this,ri,void 0);U(this,ri,e)}get numUpdatedRows(){return s(this,ri)}}ri=new WeakMap,Object.defineProperty(Go.prototype,"numUpdatedRows",{enumerable:!0});const De=class{constructor(e){R(this,te,void 0);U(this,te,h(e))}where(...e){return new De({...s(this,te),queryNode:re.cloneWithWhere(s(this,te).queryNode,Ct(e))})}whereRef(e,r,n){return new De({...s(this,te),queryNode:re.cloneWithWhere(s(this,te).queryNode,ft(e,r,n))})}orWhere(...e){return new De({...s(this,te),queryNode:re.cloneWithOrWhere(s(this,te).queryNode,Ct(e))})}orWhereRef(e,r,n){return new De({...s(this,te),queryNode:re.cloneWithOrWhere(s(this,te).queryNode,ft(e,r,n))})}whereExists(e){return new De({...s(this,te),queryNode:re.cloneWithWhere(s(this,te).queryNode,gt(e))})}whereNotExists(e){return new De({...s(this,te),queryNode:re.cloneWithWhere(s(this,te).queryNode,dt(e))})}orWhereExists(e){return new De({...s(this,te),queryNode:re.cloneWithOrWhere(s(this,te).queryNode,gt(e))})}orWhereNotExists(e){return new De({...s(this,te),queryNode:re.cloneWithOrWhere(s(this,te).queryNode,dt(e))})}clearWhere(){return new De({...s(this,te),queryNode:re.cloneWithoutWhere(s(this,te).queryNode)})}from(e){return new De({...s(this,te),queryNode:Ri.cloneWithFromItems(s(this,te).queryNode,lr(e))})}innerJoin(...e){return new De({...s(this,te),queryNode:re.cloneWithJoin(s(this,te).queryNode,kt("InnerJoin",e))})}leftJoin(...e){return new De({...s(this,te),queryNode:re.cloneWithJoin(s(this,te).queryNode,kt("LeftJoin",e))})}rightJoin(...e){return new De({...s(this,te),queryNode:re.cloneWithJoin(s(this,te).queryNode,kt("RightJoin",e))})}fullJoin(...e){return new De({...s(this,te),queryNode:re.cloneWithJoin(s(this,te).queryNode,kt("FullJoin",e))})}set(e){return new De({...s(this,te),queryNode:Ri.cloneWithUpdates(s(this,te).queryNode,Ks(e))})}returning(e){return new De({...s(this,te),queryNode:re.cloneWithReturning(s(this,te).queryNode,jr(e))})}returningAll(){return new De({...s(this,te),queryNode:re.cloneWithReturning(s(this,te).queryNode,Qr())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new De({...s(this,te)})}if(e,r){return this.$if(e,r)}$castTo(){return new De(s(this,te))}castTo(){return this.$castTo()}$narrowType(){return new De(s(this,te))}$assertType(){return new De(s(this,te))}assertType(){return new De(s(this,te))}withPlugin(e){return new De({...s(this,te),executor:s(this,te).executor.withPlugin(e)})}toOperationNode(){return s(this,te).executor.transformQuery(s(this,te).queryNode,s(this,te).queryId)}compile(){return s(this,te).executor.compileQuery(this.toOperationNode(),s(this,te).queryId)}async execute(){const e=this.compile(),r=e.query,n=await s(this,te).executor.executeQuery(e,s(this,te).queryId);return s(this,te).executor.adapter.supportsReturning&&r.returning?n.rows:[new Go(n.numAffectedRows??n.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Bi){const r=await this.executeTakeFirst();if(r===void 0)throw Mi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=s(this,te).executor.stream(r,e,s(this,te).queryId);for await(const A of n)yield*A.rows}async explain(e,r){return await new De({...s(this,te),queryNode:re.cloneWithExplain(s(this,te).queryNode,e,r)}).execute()}};let zi=De;te=new WeakMap,Se(zi,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");const jl=h({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return h({kind:"CommonTableExpressionNode",name:t,expression:e})}}),Jo=h({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return h({kind:"CommonTableExpressionNameNode",table:vn.create(t),columns:e?h(e.map(Ke.create)):void 0})}});function Ko(t,e){const r=e(Yl());return jl.create(Ql(t),r.toOperationNode())}function Ql(t){if(t.includes("(")){const e=t.split(/[\(\)]/),r=e[0],n=e[1].split(",").map(A=>A.trim());return Jo.create(r,n)}else return Jo.create(t)}const Vi=h({is(t){return t.kind==="WithNode"},create(t,e){return h({kind:"WithNode",expressions:h([t]),...e})},cloneWithExpression(t,e){return h({...t,expressions:h([...t.expressions,e])})}}),Xo=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function zl(t){let e="";for(let r=0;rthis.transformNode(r)))}transformSelectQuery(e){return{kind:"SelectQueryNode",from:this.transformNode(e.from),selections:this.transformNodeList(e.selections),distinctOn:this.transformNodeList(e.distinctOn),joins:this.transformNodeList(e.joins),groupBy:this.transformNode(e.groupBy),orderBy:this.transformNode(e.orderBy),where:this.transformNode(e.where),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),limit:this.transformNode(e.limit),offset:this.transformNode(e.offset),with:this.transformNode(e.with),having:this.transformNode(e.having),explain:this.transformNode(e.explain),setOperations:this.transformNodeList(e.setOperations)}}transformSelection(e){return{kind:"SelectionNode",selection:this.transformNode(e.selection)}}transformColumn(e){return{kind:"ColumnNode",column:this.transformNode(e.column)}}transformAlias(e){return{kind:"AliasNode",node:this.transformNode(e.node),alias:this.transformNode(e.alias)}}transformTable(e){return{kind:"TableNode",table:this.transformNode(e.table)}}transformFrom(e){return{kind:"FromNode",froms:this.transformNodeList(e.froms)}}transformReference(e){return{kind:"ReferenceNode",table:this.transformNode(e.table),column:this.transformNode(e.column)}}transformAnd(e){return{kind:"AndNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformOr(e){return{kind:"OrNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformValueList(e){return{kind:"ValueListNode",values:this.transformNodeList(e.values)}}transformParens(e){return{kind:"ParensNode",node:this.transformNode(e.node)}}transformJoin(e){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table),on:this.transformNode(e.on)}}transformRaw(e){return{kind:"RawNode",sqlFragments:h([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters)}}transformWhere(e){return{kind:"WhereNode",where:this.transformNode(e.where)}}transformInsertQuery(e){return{kind:"InsertQueryNode",into:this.transformNode(e.into),columns:this.transformNodeList(e.columns),values:this.transformNode(e.values),returning:this.transformNode(e.returning),onConflict:this.transformNode(e.onConflict),onDuplicateKey:this.transformNode(e.onDuplicateKey),with:this.transformNode(e.with),ignore:e.ignore,replace:e.replace,explain:this.transformNode(e.explain)}}transformValues(e){return{kind:"ValuesNode",values:this.transformNodeList(e.values)}}transformDeleteQuery(e){return{kind:"DeleteQueryNode",from:this.transformNode(e.from),using:this.transformNode(e.using),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),returning:this.transformNode(e.returning),with:this.transformNode(e.with),orderBy:this.transformNode(e.orderBy),limit:this.transformNode(e.limit),explain:this.transformNode(e.explain)}}transformReturning(e){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections)}}transformCreateTable(e){return{kind:"CreateTableNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),constraints:this.transformNodeList(e.constraints),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers)}}transformColumnDefinition(e){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),references:this.transformNode(e.references),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo),check:this.transformNode(e.check),generated:this.transformNode(e.generated),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers)}}transformAddColumn(e){return{kind:"AddColumnNode",column:this.transformNode(e.column)}}transformDropTable(e){return{kind:"DropTableNode",table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e){return{kind:"OrderByNode",items:this.transformNodeList(e.items)}}transformOrderByItem(e){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy),direction:this.transformNode(e.direction)}}transformGroupBy(e){return{kind:"GroupByNode",items:this.transformNodeList(e.items)}}transformGroupByItem(e){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy)}}transformUpdateQuery(e){return{kind:"UpdateQueryNode",table:this.transformNode(e.table),from:this.transformNode(e.from),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),updates:this.transformNodeList(e.updates),returning:this.transformNode(e.returning),with:this.transformNode(e.with),explain:this.transformNode(e.explain)}}transformColumnUpdate(e){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column),value:this.transformNode(e.value)}}transformLimit(e){return{kind:"LimitNode",limit:this.transformNode(e.limit)}}transformOffset(e){return{kind:"OffsetNode",offset:this.transformNode(e.offset)}}transformOnConflict(e){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns),constraint:this.transformNode(e.constraint),indexExpression:this.transformNode(e.indexExpression),indexWhere:this.transformNode(e.indexWhere),updates:this.transformNodeList(e.updates),updateWhere:this.transformNode(e.updateWhere),doNothing:e.doNothing}}transformOnDuplicateKey(e){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates)}}transformCreateIndex(e){return{kind:"CreateIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists,where:this.transformNode(e.where)}}transformList(e){return{kind:"ListNode",items:this.transformNodeList(e.items)}}transformDropIndex(e){return{kind:"DropIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformUniqueConstraint(e){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformForeignKeyConstraint(e){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns),references:this.transformNode(e.references),name:this.transformNode(e.name),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformSetOperation(e){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression),all:e.all}}transformReferences(e){return{kind:"ReferencesNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression),name:this.transformNode(e.name)}}transformWith(e){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions),recursive:e.recursive}}transformCommonTableExpression(e){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name),expression:this.transformNode(e.expression)}}transformCommonTableExpressionName(e){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns)}}transformHaving(e){return{kind:"HavingNode",having:this.transformNode(e.having)}}transformCreateSchema(e){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema),ifNotExists:e.ifNotExists}}transformDropSchema(e){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e){return{kind:"AlterTableNode",table:this.transformNode(e.table),renameTo:this.transformNode(e.renameTo),setSchema:this.transformNode(e.setSchema),columnAlterations:this.transformNodeList(e.columnAlterations),addConstraint:this.transformNode(e.addConstraint),dropConstraint:this.transformNode(e.dropConstraint)}}transformDropColumn(e){return{kind:"DropColumnNode",column:this.transformNode(e.column)}}transformRenameColumn(e){return{kind:"RenameColumnNode",column:this.transformNode(e.column),renameTo:this.transformNode(e.renameTo)}}transformAlterColumn(e){return{kind:"AlterColumnNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),dataTypeExpression:this.transformNode(e.dataTypeExpression),setDefault:this.transformNode(e.setDefault),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e){return{kind:"ModifyColumnNode",column:this.transformNode(e.column)}}transformAddConstraint(e){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint)}}transformDropConstraint(e){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName),ifExists:e.ifExists,modifier:e.modifier}}transformCreateView(e){return{kind:"CreateViewNode",name:this.transformNode(e.name),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns),as:this.transformNode(e.as)}}transformDropView(e){return{kind:"DropViewNode",name:this.transformNode(e.name),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression)}}transformDefaultValue(e){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue)}}transformOn(e){return{kind:"OnNode",on:this.transformNode(e.on)}}transformSelectModifier(e){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier)}}transformCreateType(e){return{kind:"CreateTypeNode",name:this.transformNode(e.name),enum:this.transformNode(e.enum)}}transformDropType(e){return{kind:"DropTypeNode",name:this.transformNode(e.name),ifExists:e.ifExists}}transformExplain(e){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options)}}transformSchemableIdentifier(e){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema),identifier:this.transformNode(e.identifier)}}transformAggregateFunction(e){return{kind:"AggregateFunctionNode",aggregated:this.transformNodeList(e.aggregated),distinct:e.distinct,filter:this.transformNode(e.filter),func:e.func,over:this.transformNode(e.over)}}transformOver(e){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy),partitionBy:this.transformNode(e.partitionBy)}}transformPartitionBy(e){return{kind:"PartitionByNode",items:this.transformNodeList(e.items)}}transformPartitionByItem(e){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy)}}transformBinaryOperation(e){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand),operator:this.transformNode(e.operator),rightOperand:this.transformNode(e.rightOperand)}}transformUnaryOperation(e){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator),operand:this.transformNode(e.operand)}}transformUsing(e){return{kind:"UsingNode",tables:this.transformNodeList(e.tables)}}transformFunction(e){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments)}}transformCase(e){return{kind:"CaseNode",value:this.transformNode(e.value),when:this.transformNodeList(e.when),else:this.transformNode(e.else),isStatement:e.isStatement}}transformWhen(e){return{kind:"WhenNode",condition:this.transformNode(e.condition),result:this.transformNode(e.result)}}transformDataType(e){return e}transformSelectAll(e){return e}transformIdentifier(e){return e}transformValue(e){return e}transformPrimitiveValueList(e){return e}transformOperator(e){return e}transformDefaultInsertValue(e){return e}}gs=new WeakMap;const $l=h({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0});class Gl extends Xs{constructor(r){super();R(this,ws);R(this,qs);R(this,Bn);R(this,ii);R(this,bs);R(this,fr,void 0);R(this,Rn,new Set);U(this,fr,r)}transformNodeImpl(r){if(!Le(this,ws,il).call(this,r))return super.transformNodeImpl(r);const n=Le(this,qs,sl).call(this,r);for(const X of n)s(this,Rn).add(X);const A=super.transformNodeImpl(r);for(const X of n)s(this,Rn).delete(X);return A}transformSchemableIdentifier(r){const n=super.transformSchemableIdentifier(r);return n.schema||!s(this,Rn).has(r.identifier.name)?n:{...n,schema:Ge.create(s(this,fr))}}transformReferences(r){const n=super.transformReferences(r);return n.table.table.schema?n:{...n,table:vn.createWithSchema(s(this,fr),n.table.table.identifier.name)}}}fr=new WeakMap,Rn=new WeakMap,ws=new WeakSet,il=function(r){return r.kind in $l},qs=new WeakSet,sl=function(r){const n=new Set;if("name"in r&&r.name&&Nn.is(r.name)&&Le(this,ii,bo).call(this,r.name,n),"from"in r&&r.from)for(const A of r.from.froms)Le(this,Bn,Oi).call(this,A,n);if("into"in r&&r.into&&Le(this,Bn,Oi).call(this,r.into,n),"table"in r&&r.table&&Le(this,Bn,Oi).call(this,r.table,n),"joins"in r&&r.joins)for(const A of r.joins)Le(this,Bn,Oi).call(this,A.table,n);return"with"in r&&r.with&&Le(this,bs,ol).call(this,r.with,n),n},Bn=new WeakSet,Oi=function(r,n){const A=vn.is(r)?r:Pn.is(r)&&vn.is(r.node)?r.node:null;A&&Le(this,ii,bo).call(this,A.table,n)},ii=new WeakSet,bo=function(r,n){s(this,Rn).has(r.identifier.name)||n.add(r.identifier.name)},bs=new WeakSet,ol=function(r,n){for(const A of r.expressions)n.delete(A.name.table.table.identifier.name)};class Hr{constructor(e){R(this,si,void 0);U(this,si,new Gl(e))}transformQuery(e){return s(this,si).transformNode(e.node)}async transformResult(e){return e.result}}si=new WeakMap;const Mn=class{constructor(e){R(this,Re,void 0);U(this,Re,h(e))}selectFrom(e){return new ar({queryId:Ce(),executor:s(this,Re).executor,queryNode:_e.create(lr(e),s(this,Re).withNode)})}insertInto(e){return new Vr({queryId:Ce(),executor:s(this,Re).executor,queryNode:rn.create(It(e),s(this,Re).withNode)})}replaceInto(e){return new Vr({queryId:Ce(),executor:s(this,Re).executor,queryNode:rn.create(It(e),s(this,Re).withNode,!0)})}deleteFrom(e){return new Qi({queryId:Ce(),executor:s(this,Re).executor,queryNode:zr.create(lr(e),s(this,Re).withNode)})}updateTable(e){return new zi({queryId:Ce(),executor:s(this,Re).executor,queryNode:Ri.create(Gr(e),s(this,Re).withNode)})}with(e,r){const n=Ko(e,r);return new Mn({...s(this,Re),withNode:s(this,Re).withNode?Vi.cloneWithExpression(s(this,Re).withNode,n):Vi.create(n)})}withRecursive(e,r){const n=Ko(e,r);return new Mn({...s(this,Re),withNode:s(this,Re).withNode?Vi.cloneWithExpression(s(this,Re).withNode,n):Vi.create(n,{recursive:!0})})}withPlugin(e){return new Mn({...s(this,Re),executor:s(this,Re).executor.withPlugin(e)})}withoutPlugins(){return new Mn({...s(this,Re),executor:s(this,Re).executor.withoutPlugins()})}withSchema(e){return new Mn({...s(this,Re),executor:s(this,Re).executor.withPluginAtFront(new Hr(e))})}};let Hi=Mn;Re=new WeakMap;class Yo{constructor(){R(this,oi,void 0);R(this,hr,void 0);R(this,pr,void 0);Tt(this,"resolve",e=>{s(this,hr)&&s(this,hr).call(this,e)});Tt(this,"reject",e=>{s(this,pr)&&s(this,pr).call(this,e)});U(this,oi,new Promise((e,r)=>{U(this,pr,r),U(this,hr,e)}))}get promise(){return s(this,oi)}}oi=new WeakMap,hr=new WeakMap,pr=new WeakMap;const Zo=new Set;function Jl(t){Zo.has(t)||(Zo.add(t),console.log(t))}const Kl=h([]);class ea{constructor(e=Kl){R(this,ai);R(this,Un,void 0);U(this,Un,e)}get plugins(){return s(this,Un)}transformQuery(e,r){for(const n of s(this,Un)){const A=n.transformQuery({node:e,queryId:r});if(A.kind===e.kind)e=A;else throw new Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${e.kind}`,`but it returned a ${A.kind}`].join(" "))}return e}async executeQuery(e,r){return await this.provideConnection(async n=>{const A=await n.executeQuery(e),X=await Le(this,ai,No).call(this,A,r);return Xl(A,X),X})}async*stream(e,r,n){const A=new Yo,X=new Yo;this.provideConnection(async me=>(A.resolve(me),await X.promise)).catch(me=>A.reject(me));const ae=await A.promise;try{for await(const me of ae.streamQuery(e,r))yield await Le(this,ai,No).call(this,me,n)}finally{X.resolve()}}}Un=new WeakMap,ai=new WeakSet,No=async function(e,r){for(const n of s(this,Un))e=await n.transformResult({result:e,queryId:r});return e};function Xl(t,e){const{numAffectedRows:r}=t;r===void 0&&t.numUpdatedOrDeletedRows===void 0||r!==void 0&&e.numAffectedRows!==void 0||Jl("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class sr extends ea{get adapter(){throw new Error("this query cannot be compiled to SQL")}compileQuery(){throw new Error("this query cannot be compiled to SQL")}provideConnection(){throw new Error("this query cannot be executed")}withConnectionProvider(){throw new Error("this query cannot have a connection provider")}withPlugin(e){return new sr([...this.plugins,e])}withPlugins(e){return new sr([...this.plugins,...e])}withPluginAtFront(e){return new sr([e,...this.plugins])}withoutPlugins(){return new sr([])}}const $i=new sr;function ta(){return new ar({queryId:Ce(),executor:$i,queryNode:_e.create(lr([]))})}function Yl(){return new Hi({executor:$i})}function na(t,e){return new Li({joinNode:Bt.create(t,Gr(e))})}function Zl(){return new Di({overNode:Gs.create()})}const Ys=h({is(t){return t.kind==="WhenNode"},create(t){return h({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return h({...t,result:e})}}),$t=h({is(t){return t.kind==="CaseNode"},create(t){return h({kind:"CaseNode",value:t})},cloneWithWhen(t,e){return h({...t,when:h(t.when?[...t.when,e]:[e])})},cloneWithThen(t,e){return h({...t,when:t.when?h([...t.when.slice(0,-1),Ys.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return h({...t,...e})}});function Zs(t,e,r){if(!Ao(e)&&!bt(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return nu(e,r)?ru(t,e,r):Ti.create(fn(t),eo(e),Lo(r))}function eu(t,e,r){if(!Ao(e)&&!bt(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return Ti.create(fn(t),eo(e),fn(r))}function tu(t,e,r){if(!To(e)&&!bt(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return Zs(t,e,r)}function ft(t,e,r){if(!To(e)&&!bt(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return eu(t,e,r)}function Ct(t){return Gi("where",t)}function ra(t){return Gi("having",t)}function ia(t){return Gi("on",t)}function sa(t){return Gi("when",t)}function Gi(t,e){if(e.length===3)return tu(e[0],e[1],e[2]);if(e.length===1)return iu(t,e[0]);throw oa(t,e)}function nu(t,e){return(t==="is"||t==="is not")&&(So(e)||Pr(e))}function ru(t,e,r){return Ti.create(fn(t),eo(e),nn.createImmediate(r))}function eo(t){if(Ne(t)&&ql.includes(t))return zs.create(t);if(bt(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function iu(t,e){if(Rt(e)){if(t==="when")throw new Error("when method doesn't accept a callback as an argument");return su[t](e)}else if(bt(e)){const r=e.toOperationNode();if(yt.is(r)||Ti.is(r)||Bo.is(r)||nr.is(r)||$t.is(r))return r}else if(t==="when")return nn.create(e);throw oa(t,e)}function oa(t,e){return new Error(`invalid arguments passed to a '${t}' method: ${JSON.stringify(e)}`)}const su=h({where(t){const e=ta(),r=pn(),A=t(Object.assign(e,r)).toOperationNode();if(_e.is(A)){if(!A.where)throw new Error("no `where` methods called inside a group callback");return nr.create(A.where.where)}else return A},having(t){const e=ta(),r=pn(),A=t(Object.assign(e,r)).toOperationNode();if(_e.is(A)){if(!A.having)throw new Error("no `having` methods called inside a group callback");return nr.create(A.having.having)}else return A},on(t){const e=na("InnerJoin","table"),r=pn(),A=t(Object.assign(e,r)).toOperationNode();if(Bt.is(A)){if(!A.on)throw new Error("no `on` methods called inside a group callback");return nr.create(A.on.on)}else return A}});function kt(t,e){if(e.length===3)return au(t,e[0],e[1],e[2]);if(e.length===2)return ou(t,e[0],e[1]);throw new Error("not implemented")}function ou(t,e,r){return r(na(t,e)).toOperationNode()}function au(t,e,r,n){return Bt.createWithOn(t,Gr(e),ft(r,"=",n))}const lu=h({is(t){return t.kind==="OffsetNode"},create(t){return h({kind:"OffsetNode",offset:nn.create(t)})}}),uu=h({is(t){return t.kind==="GroupByItemNode"},create(t){return h({kind:"GroupByItemNode",groupBy:t})}});function cu(t){return t=Rt(t)?t(pn()):t,Mr(t).map(uu.create)}const aa=h({is(t){return t.kind==="SetOperationNode"},create(t,e,r){return h({kind:"SetOperationNode",operator:t,expression:e,all:r})}});function or(t,e,r){return aa.create(t,e.toOperationNode(),r)}const ee=class{constructor(e){R(this,F,void 0);U(this,F,h(e))}get expressionType(){}where(...e){return new ee({...s(this,F),queryNode:re.cloneWithWhere(s(this,F).queryNode,Ct(e))})}whereRef(e,r,n){return new ee({...s(this,F),queryNode:re.cloneWithWhere(s(this,F).queryNode,ft(e,r,n))})}orWhere(...e){return new ee({...s(this,F),queryNode:re.cloneWithOrWhere(s(this,F).queryNode,Ct(e))})}orWhereRef(e,r,n){return new ee({...s(this,F),queryNode:re.cloneWithOrWhere(s(this,F).queryNode,ft(e,r,n))})}whereExists(e){return new ee({...s(this,F),queryNode:re.cloneWithWhere(s(this,F).queryNode,gt(e))})}whereNotExists(e){return new ee({...s(this,F),queryNode:re.cloneWithWhere(s(this,F).queryNode,dt(e))})}orWhereExists(e){return new ee({...s(this,F),queryNode:re.cloneWithOrWhere(s(this,F).queryNode,gt(e))})}orWhereNotExists(e){return new ee({...s(this,F),queryNode:re.cloneWithOrWhere(s(this,F).queryNode,dt(e))})}having(...e){return new ee({...s(this,F),queryNode:_e.cloneWithHaving(s(this,F).queryNode,ra(e))})}havingRef(e,r,n){return new ee({...s(this,F),queryNode:_e.cloneWithHaving(s(this,F).queryNode,ft(e,r,n))})}orHaving(...e){return new ee({...s(this,F),queryNode:_e.cloneWithOrHaving(s(this,F).queryNode,ra(e))})}orHavingRef(e,r,n){return new ee({...s(this,F),queryNode:_e.cloneWithOrHaving(s(this,F).queryNode,ft(e,r,n))})}havingExists(e){return new ee({...s(this,F),queryNode:_e.cloneWithHaving(s(this,F).queryNode,gt(e))})}havingNotExist(e){return new ee({...s(this,F),queryNode:_e.cloneWithHaving(s(this,F).queryNode,dt(e))})}havingNotExists(e){return new ee({...s(this,F),queryNode:_e.cloneWithHaving(s(this,F).queryNode,dt(e))})}orHavingExists(e){return new ee({...s(this,F),queryNode:_e.cloneWithOrHaving(s(this,F).queryNode,gt(e))})}orHavingNotExists(e){return new ee({...s(this,F),queryNode:_e.cloneWithOrHaving(s(this,F).queryNode,dt(e))})}select(e){return new ee({...s(this,F),queryNode:_e.cloneWithSelections(s(this,F).queryNode,jr(e))})}distinctOn(e){return new ee({...s(this,F),queryNode:_e.cloneWithDistinctOn(s(this,F).queryNode,Mr(e))})}modifyFront(e){return new ee({...s(this,F),queryNode:_e.cloneWithFrontModifier(s(this,F).queryNode,dn.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new ee({...s(this,F),queryNode:_e.cloneWithEndModifier(s(this,F).queryNode,dn.createWithExpression(e.toOperationNode()))})}distinct(){return new ee({...s(this,F),queryNode:_e.cloneWithFrontModifier(s(this,F).queryNode,dn.create("Distinct"))})}forUpdate(){return new ee({...s(this,F),queryNode:_e.cloneWithEndModifier(s(this,F).queryNode,dn.create("ForUpdate"))})}forShare(){return new ee({...s(this,F),queryNode:_e.cloneWithEndModifier(s(this,F).queryNode,dn.create("ForShare"))})}forKeyShare(){return new ee({...s(this,F),queryNode:_e.cloneWithEndModifier(s(this,F).queryNode,dn.create("ForKeyShare"))})}forNoKeyUpdate(){return new ee({...s(this,F),queryNode:_e.cloneWithEndModifier(s(this,F).queryNode,dn.create("ForNoKeyUpdate"))})}skipLocked(){return new ee({...s(this,F),queryNode:_e.cloneWithEndModifier(s(this,F).queryNode,dn.create("SkipLocked"))})}noWait(){return new ee({...s(this,F),queryNode:_e.cloneWithEndModifier(s(this,F).queryNode,dn.create("NoWait"))})}selectAll(e){return new ee({...s(this,F),queryNode:_e.cloneWithSelections(s(this,F).queryNode,Qr(e))})}innerJoin(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,kt("InnerJoin",e))})}leftJoin(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,kt("LeftJoin",e))})}rightJoin(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,kt("RightJoin",e))})}fullJoin(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,kt("FullJoin",e))})}innerJoinLateral(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,kt("LateralInnerJoin",e))})}leftJoinLateral(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,kt("LateralLeftJoin",e))})}orderBy(e,r){return new ee({...s(this,F),queryNode:_e.cloneWithOrderByItem(s(this,F).queryNode,Wi(e,r))})}groupBy(e){return new ee({...s(this,F),queryNode:_e.cloneWithGroupByItems(s(this,F).queryNode,cu(e))})}limit(e){return new ee({...s(this,F),queryNode:_e.cloneWithLimit(s(this,F).queryNode,$o.create(e))})}offset(e){return new ee({...s(this,F),queryNode:_e.cloneWithOffset(s(this,F).queryNode,lu.create(e))})}union(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,or("union",e,!1))})}unionAll(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,or("union",e,!0))})}intersect(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,or("intersect",e,!1))})}intersectAll(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,or("intersect",e,!0))})}except(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,or("except",e,!1))})}exceptAll(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,or("except",e,!0))})}as(e){return new du(this,e)}clearSelect(){return new ee({...s(this,F),queryNode:_e.cloneWithoutSelections(s(this,F).queryNode)})}clearWhere(){return new ee({...s(this,F),queryNode:re.cloneWithoutWhere(s(this,F).queryNode)})}clearLimit(){return new ee({...s(this,F),queryNode:_e.cloneWithoutLimit(s(this,F).queryNode)})}clearOffset(){return new ee({...s(this,F),queryNode:_e.cloneWithoutOffset(s(this,F).queryNode)})}clearOrderBy(){return new ee({...s(this,F),queryNode:_e.cloneWithoutOrderBy(s(this,F).queryNode)})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new ee({...s(this,F)})}if(e,r){return this.$if(e,r)}$castTo(){return new ee(s(this,F))}castTo(){return this.$castTo()}$narrowType(){return new ee(s(this,F))}$assertType(){return new ee(s(this,F))}assertType(){return new ee(s(this,F))}withPlugin(e){return new ee({...s(this,F),executor:s(this,F).executor.withPlugin(e)})}toOperationNode(){return s(this,F).executor.transformQuery(s(this,F).queryNode,s(this,F).queryId)}compile(){return s(this,F).executor.compileQuery(this.toOperationNode(),s(this,F).queryId)}async execute(){const e=this.compile();return(await s(this,F).executor.executeQuery(e,s(this,F).queryId)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Bi){const r=await this.executeTakeFirst();if(r===void 0)throw Mi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=s(this,F).executor.stream(r,e,s(this,F).queryId);for await(const A of n)yield*A.rows}async explain(e,r){return await new ee({...s(this,F),queryNode:re.cloneWithExplain(s(this,F).queryNode,e,r)}).execute()}};let ar=ee;F=new WeakMap,Se(ar,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class du{constructor(e,r){R(this,_r,void 0);R(this,mr,void 0);U(this,_r,e),U(this,mr,r)}get expression(){return s(this,_r)}get alias(){return s(this,mr)}toOperationNode(){return Pn.create(s(this,_r).toOperationNode(),Ge.create(s(this,mr)))}}_r=new WeakMap,mr=new WeakMap;const lo=class{constructor(e){R(this,yr,void 0);U(this,yr,e)}get expressionType(){}as(e){return new fu(this,e)}$castTo(){return new lo(s(this,yr))}toOperationNode(){return s(this,yr)}};let st=lo;yr=new WeakMap;class fu{constructor(e,r){R(this,gr,void 0);R(this,kn,void 0);U(this,gr,e),U(this,kn,r)}get expression(){return s(this,gr)}get alias(){return s(this,kn)}toOperationNode(){return Pn.create(s(this,gr).toOperationNode(),bt(s(this,kn))?s(this,kn).toOperationNode():Ge.create(s(this,kn)))}}gr=new WeakMap,kn=new WeakMap;const Mt=h({is(t){return t.kind==="AggregateFunctionNode"},create(t,e=[]){return h({kind:"AggregateFunctionNode",func:t,aggregated:e})},cloneWithDistinct(t){return h({...t,distinct:!0})},cloneWithFilter(t,e){return h({...t,filter:t.filter?wt.cloneWithOperation(t.filter,"And",e):wt.create(e)})},cloneWithOrFilter(t,e){return h({...t,filter:t.filter?wt.cloneWithOperation(t.filter,"Or",e):wt.create(e)})},cloneWithOver(t,e){return h({...t,over:e})}}),hu=h({is(t){return t.kind==="FunctionNode"},create(t,e){return h({kind:"FunctionNode",func:t,arguments:e})}}),Ut=class{constructor(e){R(this,Ue,void 0);U(this,Ue,h(e))}get expressionType(){}as(e){return new pu(this,e)}distinct(){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithDistinct(s(this,Ue).aggregateFunctionNode)})}filterWhere(...e){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithFilter(s(this,Ue).aggregateFunctionNode,Ct(e))})}filterWhereExists(e){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithFilter(s(this,Ue).aggregateFunctionNode,gt(e))})}filterWhereNotExists(e){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithFilter(s(this,Ue).aggregateFunctionNode,dt(e))})}filterWhereRef(e,r,n){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithFilter(s(this,Ue).aggregateFunctionNode,ft(e,r,n))})}orFilterWhere(...e){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithOrFilter(s(this,Ue).aggregateFunctionNode,Ct(e))})}orFilterWhereExists(e){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithOrFilter(s(this,Ue).aggregateFunctionNode,gt(e))})}orFilterWhereNotExists(e){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithOrFilter(s(this,Ue).aggregateFunctionNode,dt(e))})}orFilterWhereRef(e,r,n){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithOrFilter(s(this,Ue).aggregateFunctionNode,ft(e,r,n))})}over(e){const r=Zl();return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithOver(s(this,Ue).aggregateFunctionNode,(e?e(r):r).toOperationNode())})}$call(e){return e(this)}toOperationNode(){return s(this,Ue).aggregateFunctionNode}};let $r=Ut;Ue=new WeakMap,Se($r,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");class pu{constructor(e,r){R(this,wr,void 0);R(this,qr,void 0);U(this,wr,e),U(this,qr,r)}get expression(){return s(this,wr)}get alias(){return s(this,qr)}toOperationNode(){return Pn.create(s(this,wr).toOperationNode(),Ge.create(s(this,qr)))}}wr=new WeakMap,qr=new WeakMap;function la(){const t=(r,n)=>new st(hu.create(r,Mr(n))),e=(r,n)=>new $r({aggregateFunctionNode:Mt.create(r,n?Mr(n):void 0)});return Object.assign(t,{agg:e,avg(r){return e("avg",[r])},coalesce(r,...n){return t("coalesce",[r,...n])},count(r){return e("count",[r])},countAll(r){return new $r({aggregateFunctionNode:Mt.create("count",Qr(r))})},max(r){return e("max",[r])},min(r){return e("min",[r])},sum(r){return e("sum",[r])}})}class ua{constructor(e){R(this,br,void 0);U(this,br,h(e))}when(...e){return new ca({...s(this,br),node:$t.cloneWithWhen(s(this,br).node,Ys.create(sa(e)))})}}br=new WeakMap;class ca{constructor(e){R(this,Nr,void 0);U(this,Nr,h(e))}then(e){return new _u({...s(this,Nr),node:$t.cloneWithThen(s(this,Nr).node,hn(e))})}}Nr=new WeakMap;class _u{constructor(e){R(this,sn,void 0);U(this,sn,h(e))}when(...e){return new ca({...s(this,sn),node:$t.cloneWithWhen(s(this,sn).node,Ys.create(sa(e)))})}else(e){return new mu({...s(this,sn),node:$t.cloneWith(s(this,sn).node,{else:hn(e)})})}end(){return new st($t.cloneWith(s(this,sn).node,{isStatement:!1}))}endCase(){return new st($t.cloneWith(s(this,sn).node,{isStatement:!0}))}}sn=new WeakMap;class mu{constructor(e){R(this,vr,void 0);U(this,vr,h(e))}end(){return new st($t.cloneWith(s(this,vr).node,{isStatement:!1}))}endCase(){return new st($t.cloneWith(s(this,vr).node,{isStatement:!0}))}}vr=new WeakMap;function da(t=$i){function e(r,n){return new st(Js(r,n))}return{get fn(){return la()},selectFrom(r){return new ar({queryId:Ce(),executor:t,queryNode:_e.create(lr(r))})},case(r){return new ua({node:$t.create(Te(r)?void 0:fn(r))})},ref(r){return new st(rr(r))},val(r){return new st(Lo(r))},cmpr(r,n,A){return new st(Zs(r,n,A))},bxp(r,n,A){return new st(Zs(r,n,A))},unary:e,not(r){return e("not",r)},exists(r){return e("exists",r)},neg(r){return e("-",r)},and(r){if(r.length===0)return new st(nn.createImmediate(!0));if(r.length===1)return new st(r[0].toOperationNode());let n=Dr.create(r[0].toOperationNode(),r[1].toOperationNode());for(let A=2;AGr(e)):[Gr(t)]}function Gr(t){return Ne(t)?yu(t):fa(t)}function yu(t){const e=" as ";if(t.includes(e)){const[r,n]=t.split(e).map(ha);return Pn.create(It(r),Ge.create(n))}else return It(t)}function It(t){const e=".";if(t.includes(e)){const[r,n]=t.split(e).map(ha);return vn.createWithSchema(r,n)}else return vn.create(t)}function ha(t){return t.trim()}const pa=h({is(t){return t.kind==="AddColumnNode"},create(t){return h({kind:"AddColumnNode",column:t})}}),Ln=h({is(t){return t.kind==="AlterColumnNode"},create(t){return h({kind:"AlterColumnNode",column:Ke.create(t)})},cloneWith(t,e){return h({...t,...e})}}),Xe=h({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return h({kind:"ColumnDefinitionNode",column:Ke.create(t),dataType:e})},cloneWithFrontModifier(t,e){return h({...t,frontModifiers:t.frontModifiers?h([...t.frontModifiers,e]):[e]})},cloneWithEndModifier(t,e){return h({...t,endModifiers:t.endModifiers?h([...t.endModifiers,e]):[e]})},cloneWith(t,e){return h({...t,...e})}}),_a=h({is(t){return t.kind==="DropColumnNode"},create(t){return h({kind:"DropColumnNode",column:Ke.create(t)})}}),ma=h({is(t){return t.kind==="RenameColumnNode"},create(t,e){return h({kind:"RenameColumnNode",column:Ke.create(t),renameTo:Ke.create(e)})}}),to=h({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return h({kind:"CheckConstraintNode",expression:t,name:e?Ge.create(e):void 0})}}),gu=["no action","restrict","cascade","set null","set default"],Xi=h({is(t){return t.kind==="ReferencesNode"},create(t,e){return h({kind:"ReferencesNode",table:t,columns:h([...e])})},cloneWithOnDelete(t,e){return h({...t,onDelete:e})},cloneWithOnUpdate(t,e){return h({...t,onUpdate:e})}});function ya(t){return bt(t)?t.toOperationNode():nn.createImmediate(t)}const Yi=h({is(t){return t.kind==="GeneratedNode"},create(t){return h({kind:"GeneratedNode",...t})},createWithExpression(t){return h({kind:"GeneratedNode",always:!0,expression:t})},cloneWith(t,e){return h({...t,...e})}}),wu=h({is(t){return t.kind==="DefaultValueNode"},create(t){return h({kind:"DefaultValueNode",defaultValue:t})}});function Zi(t){if(gu.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}const at=class{constructor(e){R(this,Fe,void 0);U(this,Fe,e)}autoIncrement(){return new at(Xe.cloneWith(s(this,Fe),{autoIncrement:!0}))}primaryKey(){return new at(Xe.cloneWith(s(this,Fe),{primaryKey:!0}))}references(e){const r=rr(e);if(!Ci.is(r)||Vs.is(r.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new at(Xe.cloneWith(s(this,Fe),{references:Xi.create(r.table,[r.column])}))}onDelete(e){if(!s(this,Fe).references)throw new Error("on delete constraint can only be added for foreign keys");return new at(Xe.cloneWith(s(this,Fe),{references:Xi.cloneWithOnDelete(s(this,Fe).references,Zi(e))}))}onUpdate(e){if(!s(this,Fe).references)throw new Error("on update constraint can only be added for foreign keys");return new at(Xe.cloneWith(s(this,Fe),{references:Xi.cloneWithOnUpdate(s(this,Fe).references,Zi(e))}))}unique(){return new at(Xe.cloneWith(s(this,Fe),{unique:!0}))}notNull(){return new at(Xe.cloneWith(s(this,Fe),{notNull:!0}))}unsigned(){return new at(Xe.cloneWith(s(this,Fe),{unsigned:!0}))}defaultTo(e){return new at(Xe.cloneWith(s(this,Fe),{defaultTo:wu.create(ya(e))}))}check(e){return new at(Xe.cloneWith(s(this,Fe),{check:to.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new at(Xe.cloneWith(s(this,Fe),{generated:Yi.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new at(Xe.cloneWith(s(this,Fe),{generated:Yi.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new at(Xe.cloneWith(s(this,Fe),{generated:Yi.create({identity:!0,byDefault:!0})}))}stored(){if(!s(this,Fe).generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new at(Xe.cloneWith(s(this,Fe),{generated:Yi.cloneWith(s(this,Fe).generated,{stored:!0})}))}modifyFront(e){return new at(Xe.cloneWithFrontModifier(s(this,Fe),e.toOperationNode()))}modifyEnd(e){return new at(Xe.cloneWithEndModifier(s(this,Fe),e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return s(this,Fe)}};let xn=at;Fe=new WeakMap,Se(xn,"don't await ColumnDefinitionBuilder instances directly.");const ga=h({is(t){return t.kind==="ModifyColumnNode"},create(t){return h({kind:"ModifyColumnNode",column:t})}}),qu=h({is(t){return t.kind==="DataTypeNode"},create(t){return h({kind:"DataTypeNode",dataType:t})}});function ur(t){return bt(t)?t.toOperationNode():qu.create(t)}const es=h({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,r,n){return h({kind:"ForeignKeyConstraintNode",columns:t,references:Xi.create(e,r),name:n?Ge.create(n):void 0})},cloneWith(t,e){return h({...t,...e})}}),Ns=class{constructor(e){R(this,jn,void 0);U(this,jn,e)}onDelete(e){return new Ns(es.cloneWith(s(this,jn),{onDelete:Zi(e)}))}onUpdate(e){return new Ns(es.cloneWith(s(this,jn),{onUpdate:Zi(e)}))}$call(e){return e(this)}toOperationNode(){return s(this,jn)}};let Jr=Ns;jn=new WeakMap,Se(Jr,"don't await ForeignKeyConstraintBuilder instances directly.");const no=h({is(t){return t.kind==="AddConstraintNode"},create(t){return h({kind:"AddConstraintNode",constraint:t})}}),wa=h({is(t){return t.kind==="UniqueConstraintNode"},create(t,e){return h({kind:"UniqueConstraintNode",columns:h(t.map(Ke.create)),name:e?Ge.create(e):void 0})}}),ts=h({is(t){return t.kind==="DropConstraintNode"},create(t){return h({kind:"DropConstraintNode",constraintName:Ge.create(t)})},cloneWith(t,e){return h({...t,...e})}});class ns{constructor(e){Tt(this,"alterColumnNode");this.alterColumnNode=e}setDataType(e){return new Kr(Ln.cloneWith(this.alterColumnNode,{dataType:ur(e)}))}setDefault(e){return new Kr(Ln.cloneWith(this.alterColumnNode,{setDefault:ya(e)}))}dropDefault(){return new Kr(Ln.cloneWith(this.alterColumnNode,{dropDefault:!0}))}setNotNull(){return new Kr(Ln.cloneWith(this.alterColumnNode,{setNotNull:!0}))}dropNotNull(){return new Kr(Ln.cloneWith(this.alterColumnNode,{dropNotNull:!0}))}$call(e){return e(this)}}class Kr extends ns{toOperationNode(){return this.alterColumnNode}}class Xr{constructor(e){R(this,Xt,void 0);U(this,Xt,h(e))}toOperationNode(){return s(this,Xt).executor.transformQuery(s(this,Xt).node,s(this,Xt).queryId)}compile(){return s(this,Xt).executor.compileQuery(this.toOperationNode(),s(this,Xt).queryId)}async execute(){await s(this,Xt).executor.executeQuery(this.compile(),s(this,Xt).queryId)}}Xt=new WeakMap,Se(Xr,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");const vs=class{constructor(e){R(this,qt,void 0);U(this,qt,h(e))}onDelete(e){return new vs({...s(this,qt),constraintBuilder:s(this,qt).constraintBuilder.onDelete(e)})}onUpdate(e){return new vs({...s(this,qt),constraintBuilder:s(this,qt).constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return s(this,qt).executor.transformQuery(et.cloneWithTableProps(s(this,qt).node,{addConstraint:no.create(s(this,qt).constraintBuilder.toOperationNode())}),s(this,qt).queryId)}compile(){return s(this,qt).executor.compileQuery(this.toOperationNode(),s(this,qt).queryId)}async execute(){await s(this,qt).executor.executeQuery(this.compile(),s(this,qt).queryId)}};let rs=vs;qt=new WeakMap,Se(rs,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");const li=class{constructor(e){R(this,tt,void 0);U(this,tt,h(e))}ifExists(){return new li({...s(this,tt),node:et.cloneWithTableProps(s(this,tt).node,{dropConstraint:ts.cloneWith(s(this,tt).node.dropConstraint,{ifExists:!0})})})}cascade(){return new li({...s(this,tt),node:et.cloneWithTableProps(s(this,tt).node,{dropConstraint:ts.cloneWith(s(this,tt).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new li({...s(this,tt),node:et.cloneWithTableProps(s(this,tt).node,{dropConstraint:ts.cloneWith(s(this,tt).node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return s(this,tt).executor.transformQuery(s(this,tt).node,s(this,tt).queryId)}compile(){return s(this,tt).executor.compileQuery(this.toOperationNode(),s(this,tt).queryId)}async execute(){await s(this,tt).executor.executeQuery(this.compile(),s(this,tt).queryId)}};let is=li;tt=new WeakMap,Se(is,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");class qa{constructor(e){R(this,je,void 0);U(this,je,h(e))}renameTo(e){return new Xr({...s(this,je),node:et.cloneWithTableProps(s(this,je).node,{renameTo:It(e)})})}setSchema(e){return new Xr({...s(this,je),node:et.cloneWithTableProps(s(this,je).node,{setSchema:Ge.create(e)})})}alterColumn(e,r){const n=r(new ns(Ln.create(e)));return new En({...s(this,je),node:et.cloneWithColumnAlteration(s(this,je).node,n.toOperationNode())})}dropColumn(e){return new En({...s(this,je),node:et.cloneWithColumnAlteration(s(this,je).node,_a.create(e))})}renameColumn(e,r){return new En({...s(this,je),node:et.cloneWithColumnAlteration(s(this,je).node,ma.create(e,r))})}addColumn(e,r,n=tr){const A=n(new xn(Xe.create(e,ur(r))));return new En({...s(this,je),node:et.cloneWithColumnAlteration(s(this,je).node,pa.create(A.toOperationNode()))})}modifyColumn(e,r,n=tr){const A=n(new xn(Xe.create(e,ur(r))));return new En({...s(this,je),node:et.cloneWithColumnAlteration(s(this,je).node,ga.create(A.toOperationNode()))})}addUniqueConstraint(e,r){return new Xr({...s(this,je),node:et.cloneWithTableProps(s(this,je).node,{addConstraint:no.create(wa.create(r,e))})})}addCheckConstraint(e,r){return new Xr({...s(this,je),node:et.cloneWithTableProps(s(this,je).node,{addConstraint:no.create(to.create(r.toOperationNode(),e))})})}addForeignKeyConstraint(e,r,n,A){return new rs({...s(this,je),constraintBuilder:new Jr(es.create(r.map(Ke.create),It(n),A.map(Ke.create),e))})}dropConstraint(e){return new is({...s(this,je),node:et.cloneWithTableProps(s(this,je).node,{dropConstraint:ts.create(e)})})}$call(e){return e(this)}call(e){return this.$call(e)}}je=new WeakMap;const Qn=class{constructor(e){R(this,Ye,void 0);U(this,Ye,h(e))}alterColumn(e,r){const n=r(new ns(Ln.create(e)));return new Qn({...s(this,Ye),node:et.cloneWithColumnAlteration(s(this,Ye).node,n.toOperationNode())})}dropColumn(e){return new Qn({...s(this,Ye),node:et.cloneWithColumnAlteration(s(this,Ye).node,_a.create(e))})}renameColumn(e,r){return new Qn({...s(this,Ye),node:et.cloneWithColumnAlteration(s(this,Ye).node,ma.create(e,r))})}addColumn(e,r,n=tr){const A=n(new xn(Xe.create(e,ur(r))));return new Qn({...s(this,Ye),node:et.cloneWithColumnAlteration(s(this,Ye).node,pa.create(A.toOperationNode()))})}modifyColumn(e,r,n=tr){const A=n(new xn(Xe.create(e,ur(r))));return new Qn({...s(this,Ye),node:et.cloneWithColumnAlteration(s(this,Ye).node,ga.create(A.toOperationNode()))})}toOperationNode(){return s(this,Ye).executor.transformQuery(s(this,Ye).node,s(this,Ye).queryId)}compile(){return s(this,Ye).executor.compileQuery(this.toOperationNode(),s(this,Ye).queryId)}async execute(){await s(this,Ye).executor.executeQuery(this.compile(),s(this,Ye).queryId)}};let En=Qn;Ye=new WeakMap,Se(qa,"don't await AlterTableBuilder instances"),Se(ns,"don't await AlterColumnBuilder instances"),Se(En,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class ba extends Xs{transformValue(e){return{...super.transformValue(e),immediate:!0}}}const on=class{constructor(e){R(this,Pe,void 0);U(this,Pe,h(e))}ifNotExists(){return new on({...s(this,Pe),node:bn.cloneWith(s(this,Pe).node,{ifNotExists:!0})})}unique(){return new on({...s(this,Pe),node:bn.cloneWith(s(this,Pe).node,{unique:!0})})}on(e){return new on({...s(this,Pe),node:bn.cloneWith(s(this,Pe).node,{table:It(e)})})}column(e){return new on({...s(this,Pe),node:bn.cloneWithColumns(s(this,Pe).node,[Fo(e)])})}columns(e){return new on({...s(this,Pe),node:bn.cloneWithColumns(s(this,Pe).node,e.map(Fo))})}expression(e){return new on({...s(this,Pe),node:bn.cloneWithColumns(s(this,Pe).node,[e.toOperationNode()])})}using(e){return new on({...s(this,Pe),node:bn.cloneWith(s(this,Pe).node,{using:yt.createWithSql(e)})})}where(...e){const r=new ba;return new on({...s(this,Pe),node:re.cloneWithWhere(s(this,Pe).node,r.transformNode(Ct(e)))})}$call(e){return e(this)}toOperationNode(){return s(this,Pe).executor.transformQuery(s(this,Pe).node,s(this,Pe).queryId)}compile(){return s(this,Pe).executor.compileQuery(this.toOperationNode(),s(this,Pe).queryId)}async execute(){await s(this,Pe).executor.executeQuery(this.compile(),s(this,Pe).queryId)}};let ss=on;Pe=new WeakMap,Se(ss,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");const uo=class{constructor(e){R(this,Ft,void 0);U(this,Ft,h(e))}ifNotExists(){return new uo({...s(this,Ft),node:ko.cloneWith(s(this,Ft).node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return s(this,Ft).executor.transformQuery(s(this,Ft).node,s(this,Ft).queryId)}compile(){return s(this,Ft).executor.compileQuery(this.toOperationNode(),s(this,Ft).queryId)}async execute(){await s(this,Ft).executor.executeQuery(this.compile(),s(this,Ft).queryId)}};let os=uo;Ft=new WeakMap,Se(os,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");const bu=h({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return h({kind:"PrimaryKeyConstraintNode",columns:h(t.map(Ke.create)),name:e?Ge.create(e):void 0})}});function Nu(t){if(_l.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}const jt=class{constructor(e){R(this,ke,void 0);U(this,ke,h(e))}temporary(){return new jt({...s(this,ke),node:Ht.cloneWith(s(this,ke).node,{temporary:!0})})}onCommit(e){return new jt({...s(this,ke),node:Ht.cloneWith(s(this,ke).node,{onCommit:Nu(e)})})}ifNotExists(){return new jt({...s(this,ke),node:Ht.cloneWith(s(this,ke).node,{ifNotExists:!0})})}addColumn(e,r,n=tr){const A=n(new xn(Xe.create(e,ur(r))));return new jt({...s(this,ke),node:Ht.cloneWithColumn(s(this,ke).node,A.toOperationNode())})}addPrimaryKeyConstraint(e,r){return new jt({...s(this,ke),node:Ht.cloneWithConstraint(s(this,ke).node,bu.create(r,e))})}addUniqueConstraint(e,r){return new jt({...s(this,ke),node:Ht.cloneWithConstraint(s(this,ke).node,wa.create(r,e))})}addCheckConstraint(e,r){return new jt({...s(this,ke),node:Ht.cloneWithConstraint(s(this,ke).node,to.create(r.toOperationNode(),e))})}addForeignKeyConstraint(e,r,n,A,X=tr){const ae=X(new Jr(es.create(r.map(Ke.create),It(n),A.map(Ke.create),e)));return new jt({...s(this,ke),node:Ht.cloneWithConstraint(s(this,ke).node,ae.toOperationNode())})}modifyFront(e){return new jt({...s(this,ke),node:Ht.cloneWithFrontModifier(s(this,ke).node,e.toOperationNode())})}modifyEnd(e){return new jt({...s(this,ke),node:Ht.cloneWithEndModifier(s(this,ke).node,e.toOperationNode())})}$call(e){return e(this)}call(e){return this.$call(e)}toOperationNode(){return s(this,ke).executor.transformQuery(s(this,ke).node,s(this,ke).queryId)}compile(){return s(this,ke).executor.compileQuery(this.toOperationNode(),s(this,ke).queryId)}async execute(){await s(this,ke).executor.executeQuery(this.compile(),s(this,ke).queryId)}};let as=jt;ke=new WeakMap,Se(as,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");const ui=class{constructor(e){R(this,ht,void 0);U(this,ht,h(e))}on(e){return new ui({...s(this,ht),node:Ai.cloneWith(s(this,ht).node,{table:It(e)})})}ifExists(){return new ui({...s(this,ht),node:Ai.cloneWith(s(this,ht).node,{ifExists:!0})})}cascade(){return new ui({...s(this,ht),node:Ai.cloneWith(s(this,ht).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return s(this,ht).executor.transformQuery(s(this,ht).node,s(this,ht).queryId)}compile(){return s(this,ht).executor.compileQuery(this.toOperationNode(),s(this,ht).queryId)}async execute(){await s(this,ht).executor.executeQuery(this.compile(),s(this,ht).queryId)}};let ls=ui;ht=new WeakMap,Se(ls,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");const xs=class{constructor(e){R(this,vt,void 0);U(this,vt,h(e))}ifExists(){return new xs({...s(this,vt),node:js.cloneWith(s(this,vt).node,{ifExists:!0})})}cascade(){return new xs({...s(this,vt),node:js.cloneWith(s(this,vt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return s(this,vt).executor.transformQuery(s(this,vt).node,s(this,vt).queryId)}compile(){return s(this,vt).executor.compileQuery(this.toOperationNode(),s(this,vt).queryId)}async execute(){await s(this,vt).executor.executeQuery(this.compile(),s(this,vt).queryId)}};let us=xs;vt=new WeakMap,Se(us,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");const Es=class{constructor(e){R(this,xt,void 0);U(this,xt,h(e))}ifExists(){return new Es({...s(this,xt),node:Qs.cloneWith(s(this,xt).node,{ifExists:!0})})}cascade(){return new Es({...s(this,xt),node:Qs.cloneWith(s(this,xt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return s(this,xt).executor.transformQuery(s(this,xt).node,s(this,xt).queryId)}compile(){return s(this,xt).executor.compileQuery(this.toOperationNode(),s(this,xt).queryId)}async execute(){await s(this,xt).executor.executeQuery(this.compile(),s(this,xt).queryId)}};let cs=Es;xt=new WeakMap,Se(cs,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");const Sn=h({is(t){return t.kind==="CreateViewNode"},create(t){return h({kind:"CreateViewNode",name:Nn.create(t)})},cloneWith(t,e){return h({...t,...e})}});class vu{constructor(){R(this,Ss,new ba)}transformQuery(e){return s(this,Ss).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}Ss=new WeakMap;const In=class{constructor(e){R(this,He,void 0);U(this,He,h(e))}temporary(){return new In({...s(this,He),node:Sn.cloneWith(s(this,He).node,{temporary:!0})})}materialized(){return new In({...s(this,He),node:Sn.cloneWith(s(this,He).node,{materialized:!0})})}ifNotExists(){return new In({...s(this,He),node:Sn.cloneWith(s(this,He).node,{ifNotExists:!0})})}orReplace(){return new In({...s(this,He),node:Sn.cloneWith(s(this,He).node,{orReplace:!0})})}columns(e){return new In({...s(this,He),node:Sn.cloneWith(s(this,He).node,{columns:e.map(Wo)})})}as(e){const r=e.withPlugin(new vu).toOperationNode();return new In({...s(this,He),node:Sn.cloneWith(s(this,He).node,{as:r})})}$call(e){return e(this)}toOperationNode(){return s(this,He).executor.transformQuery(s(this,He).node,s(this,He).queryId)}compile(){return s(this,He).executor.compileQuery(this.toOperationNode(),s(this,He).queryId)}async execute(){await s(this,He).executor.executeQuery(this.compile(),s(this,He).queryId)}};let ds=In;He=new WeakMap,Se(ds,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const fs=h({is(t){return t.kind==="DropViewNode"},create(t){return h({kind:"DropViewNode",name:Nn.create(t)})},cloneWith(t,e){return h({...t,...e})}}),ci=class{constructor(e){R(this,pt,void 0);U(this,pt,h(e))}materialized(){return new ci({...s(this,pt),node:fs.cloneWith(s(this,pt).node,{materialized:!0})})}ifExists(){return new ci({...s(this,pt),node:fs.cloneWith(s(this,pt).node,{ifExists:!0})})}cascade(){return new ci({...s(this,pt),node:fs.cloneWith(s(this,pt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return s(this,pt).executor.transformQuery(s(this,pt).node,s(this,pt).queryId)}compile(){return s(this,pt).executor.compileQuery(this.toOperationNode(),s(this,pt).queryId)}async execute(){await s(this,pt).executor.executeQuery(this.compile(),s(this,pt).queryId)}};let hs=ci;pt=new WeakMap,Se(hs,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const Na=h({is(t){return t.kind==="CreateTypeNode"},create(t){return h({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return h({...t,enum:$s.create(e.map(r=>nn.createImmediate(r)))})}}),co=class{constructor(e){R(this,Pt,void 0);U(this,Pt,h(e))}toOperationNode(){return s(this,Pt).executor.transformQuery(s(this,Pt).node,s(this,Pt).queryId)}asEnum(e){return new co({...s(this,Pt),node:Na.cloneWithEnum(s(this,Pt).node,e)})}$call(e){return e(this)}compile(){return s(this,Pt).executor.compileQuery(this.toOperationNode(),s(this,Pt).queryId)}async execute(){await s(this,Pt).executor.executeQuery(this.compile(),s(this,Pt).queryId)}};let ps=co;Pt=new WeakMap,Se(ps,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const va=h({is(t){return t.kind==="DropTypeNode"},create(t){return h({kind:"DropTypeNode",name:t})},cloneWith(t,e){return h({...t,...e})}}),fo=class{constructor(e){R(this,Lt,void 0);U(this,Lt,h(e))}ifExists(){return new fo({...s(this,Lt),node:va.cloneWith(s(this,Lt).node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return s(this,Lt).executor.transformQuery(s(this,Lt).node,s(this,Lt).queryId)}compile(){return s(this,Lt).executor.compileQuery(this.toOperationNode(),s(this,Lt).queryId)}async execute(){await s(this,Lt).executor.executeQuery(this.compile(),s(this,Lt).queryId)}};let _s=fo;Lt=new WeakMap,Se(_s,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function xa(t){const e=".";if(t.includes(e)){const r=t.split(e).map(xu);if(r.length===2)return Nn.createWithSchema(r[0],r[1]);throw new Error(`invalid schemable identifier ${t}`)}else return Nn.create(t)}function xu(t){return t.trim()}const di=class{constructor(e){R(this,lt,void 0);U(this,lt,e)}createTable(e){return new as({queryId:Ce(),executor:s(this,lt),node:Ht.create(It(e))})}dropTable(e){return new cs({queryId:Ce(),executor:s(this,lt),node:Qs.create(It(e))})}createIndex(e){return new ss({queryId:Ce(),executor:s(this,lt),node:bn.create(e)})}dropIndex(e){return new ls({queryId:Ce(),executor:s(this,lt),node:Ai.create(e)})}createSchema(e){return new os({queryId:Ce(),executor:s(this,lt),node:ko.create(e)})}dropSchema(e){return new us({queryId:Ce(),executor:s(this,lt),node:js.create(e)})}alterTable(e){return new qa({queryId:Ce(),executor:s(this,lt),node:et.create(It(e))})}createView(e){return new ds({queryId:Ce(),executor:s(this,lt),node:Sn.create(e)})}dropView(e){return new hs({queryId:Ce(),executor:s(this,lt),node:fs.create(e)})}createType(e){return new ps({queryId:Ce(),executor:s(this,lt),node:Na.create(xa(e))})}dropType(e){return new _s({queryId:Ce(),executor:s(this,lt),node:va.create(xa(e))})}withPlugin(e){return new di(s(this,lt).withPlugin(e))}withoutPlugins(){return new di(s(this,lt).withoutPlugins())}withSchema(e){return new di(s(this,lt).withPluginAtFront(new Hr(e)))}};let ro=di;lt=new WeakMap;class Eu{ref(e){return new Tl(e)}}class Su{constructor(e){R(this,xr,void 0);U(this,xr,e)}async provideConnection(e){const r=await s(this,xr).acquireConnection();try{return await e(r)}finally{await s(this,xr).releaseConnection(r)}}}xr=new WeakMap;const zn=class extends ea{constructor(r,n,A,X=[]){super(X);R(this,an,void 0);R(this,ln,void 0);R(this,_n,void 0);U(this,an,r),U(this,ln,n),U(this,_n,A)}get adapter(){return s(this,ln)}compileQuery(r){return s(this,an).compileQuery(r)}provideConnection(r){return s(this,_n).provideConnection(r)}withPlugins(r){return new zn(s(this,an),s(this,ln),s(this,_n),[...this.plugins,...r])}withPlugin(r){return new zn(s(this,an),s(this,ln),s(this,_n),[...this.plugins,r])}withPluginAtFront(r){return new zn(s(this,an),s(this,ln),s(this,_n),[r,...this.plugins])}withConnectionProvider(r){return new zn(s(this,an),s(this,ln),r,[...this.plugins])}withoutPlugins(){return new zn(s(this,an),s(this,ln),s(this,_n),[])}};let io=zn;an=new WeakMap,ln=new WeakMap,_n=new WeakMap;function Ea(){return typeof performance<"u"&&Rt(performance.now)?performance.now():Date.now()}class ku{constructor(e,r){R(this,ks);R(this,Is);R(this,Os);R(this,As);R(this,hi);R(this,Yt,void 0);R(this,On,void 0);R(this,mn,void 0);R(this,Vn,void 0);R(this,fi,new WeakSet);U(this,Yt,e),U(this,On,r)}async init(){s(this,mn)||U(this,mn,s(this,Yt).init().catch(e=>(U(this,mn,void 0),Promise.reject(e)))),await s(this,mn)}async acquireConnection(){await this.init();const e=await s(this,Yt).acquireConnection();return s(this,fi).has(e)||(Le(this,ks,al).call(this)&&Le(this,Is,ll).call(this,e),s(this,fi).add(e)),e}async releaseConnection(e){await s(this,Yt).releaseConnection(e)}beginTransaction(e,r){return s(this,Yt).beginTransaction(e,r)}commitTransaction(e){return s(this,Yt).commitTransaction(e)}rollbackTransaction(e){return s(this,Yt).rollbackTransaction(e)}async destroy(){s(this,mn)&&(await s(this,mn),s(this,Vn)||U(this,Vn,s(this,Yt).destroy().catch(e=>(U(this,Vn,void 0),Promise.reject(e)))),await s(this,Vn))}}Yt=new WeakMap,On=new WeakMap,mn=new WeakMap,Vn=new WeakMap,fi=new WeakMap,ks=new WeakSet,al=function(){return s(this,On).isLevelEnabled("query")||s(this,On).isLevelEnabled("error")},Is=new WeakSet,ll=function(e){const r=e.executeQuery;e.executeQuery=async n=>{const A=Ea();try{return await r.call(e,n)}catch(X){throw await Le(this,Os,ul).call(this,X,n,A),X}finally{await Le(this,As,cl).call(this,n,A)}}},Os=new WeakSet,ul=async function(e,r,n){await s(this,On).error(()=>({level:"error",error:e,query:r,queryDurationMillis:Le(this,hi,vo).call(this,n)}))},As=new WeakSet,cl=async function(e,r){await s(this,On).query(()=>({level:"query",query:e,queryDurationMillis:Le(this,hi,vo).call(this,r)}))},hi=new WeakSet,vo=function(e){return Ea()-e};class Sa{constructor(e){R(this,Ts);R(this,pi,void 0);R(this,An,void 0);U(this,pi,e)}async provideConnection(e){for(;s(this,An);)await s(this,An);const r=Le(this,Ts,dl).call(this,e);return U(this,An,r.then(()=>{U(this,An,void 0)}).catch(()=>{U(this,An,void 0)})),r}}pi=new WeakMap,An=new WeakMap,Ts=new WeakSet,dl=async function(e){return await e(s(this,pi))};const Iu=["read uncommitted","read committed","repeatable read","serializable"];h(["query","error"]);class Ou{constructor(e){R(this,Tn,void 0);R(this,Hn,void 0);Rt(e)?(U(this,Hn,e),U(this,Tn,h({query:!0,error:!0}))):(U(this,Hn,Au),U(this,Tn,h({query:e.includes("query"),error:e.includes("error")})))}isLevelEnabled(e){return s(this,Tn)[e]}async query(e){s(this,Tn).query&&await s(this,Hn).call(this,e())}async error(e){s(this,Tn).error&&await s(this,Hn).call(this,e())}}Tn=new WeakMap,Hn=new WeakMap;function Au(t){t.level==="query"?(console.log(`kysely:query: ${t.query.sql}`),console.log(`kysely:query: duration: ${t.queryDurationMillis.toFixed(1)}ms`)):t.level==="error"&&(t.error instanceof Error?console.error(`kysely:error: ${t.error.stack??t.error.message}`):console.error(`kysely:error: ${t}`))}function Tu(t){return tn(t)&&Rt(t.compile)}const Er=class extends Hi{constructor(r){let n,A;if(Cu(r))n={executor:r.executor},A={...r};else{const X=r.dialect,ae=X.createDriver(),me=X.createQueryCompiler(),Oe=X.createAdapter(),At=new Ou(r.log??[]),nt=new ku(ae,At),rt=new Su(nt),ue=new io(me,Oe,rt,r.plugins??[]);n={executor:ue},A={config:r,executor:ue,dialect:X,driver:nt}}super(n);R(this,_t,void 0);U(this,_t,h(A))}get schema(){return new ro(s(this,_t).executor)}get dynamic(){return new Eu}get introspection(){return s(this,_t).dialect.createIntrospector(this.withoutPlugins())}case(r){return new ua({node:$t.create(Te(r)?void 0:Ji(r))})}get fn(){return la()}transaction(){return new ms({...s(this,_t)})}connection(){return new ka({...s(this,_t)})}withPlugin(r){return new Er({...s(this,_t),executor:s(this,_t).executor.withPlugin(r)})}withoutPlugins(){return new Er({...s(this,_t),executor:s(this,_t).executor.withoutPlugins()})}withSchema(r){return new Er({...s(this,_t),executor:s(this,_t).executor.withPluginAtFront(new Hr(r))})}withTables(){return new Er({...s(this,_t)})}async destroy(){await s(this,_t).driver.destroy()}get isTransaction(){return!1}getExecutor(){return s(this,_t).executor}executeQuery(r,n=Ce()){const A=Tu(r)?r.compile():r;return this.getExecutor().executeQuery(A,n)}};let Yr=Er;_t=new WeakMap;const Sr=class extends Yr{constructor(r){super(r);R(this,Zt,void 0);U(this,Zt,r)}get isTransaction(){return!0}transaction(){throw new Error("calling the transaction method for a Transaction is not supported")}connection(){throw new Error("calling the connection method for a Transaction is not supported")}async destroy(){throw new Error("calling the destroy method for a Transaction is not supported")}withPlugin(r){return new Sr({...s(this,Zt),executor:s(this,Zt).executor.withPlugin(r)})}withoutPlugins(){return new Sr({...s(this,Zt),executor:s(this,Zt).executor.withoutPlugins()})}withSchema(r){return new Sr({...s(this,Zt),executor:s(this,Zt).executor.withPluginAtFront(new Hr(r))})}withTables(){return new Sr({...s(this,Zt)})}};let so=Sr;Zt=new WeakMap;function Cu(t){return tn(t)&&tn(t.config)&&tn(t.driver)&&tn(t.executor)&&tn(t.dialect)}class ka{constructor(e){R(this,$n,void 0);U(this,$n,h(e))}async execute(e){return s(this,$n).executor.provideConnection(async r=>{const n=s(this,$n).executor.withConnectionProvider(new Sa(r)),A=new Yr({...s(this,$n),executor:n});return await e(A)})}}$n=new WeakMap,Se(ka,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");const ho=class{constructor(e){R(this,en,void 0);U(this,en,h(e))}setIsolationLevel(e){return new ho({...s(this,en),isolationLevel:e})}async execute(e){const{isolationLevel:r,...n}=s(this,en),A={isolationLevel:r};return Wu(A),s(this,en).executor.provideConnection(async X=>{const ae=s(this,en).executor.withConnectionProvider(new Sa(X)),me=new so({...n,executor:ae});try{await s(this,en).driver.beginTransaction(X,A);const Oe=await e(me);return await s(this,en).driver.commitTransaction(X),Oe}catch(Oe){throw await s(this,en).driver.rollbackTransaction(X),Oe}})}};let ms=ho;en=new WeakMap,Se(ms,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function Wu(t){if(t.isolationLevel&&!Iu.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}const Cs=class{constructor(e){R(this,kr);R(this,_i);R(this,mi);R(this,Ot,void 0);U(this,Ot,h(e))}get expressionType(){}as(e){return new Fu(this,e)}$castTo(){return new Cs({...s(this,Ot)})}castTo(){return this.$castTo()}withPlugin(e){return new Cs({...s(this,Ot),plugins:s(this,Ot).plugins!==void 0?h([...s(this,Ot).plugins,e]):h([e])})}toOperationNode(){return Le(this,_i,xo).call(this,Le(this,kr,Us).call(this))}compile(e){return Le(this,mi,Eo).call(this,Le(this,kr,Us).call(this,e))}async execute(e){const r=Le(this,kr,Us).call(this,e);return r.executeQuery(Le(this,mi,Eo).call(this,r),s(this,Ot).queryId)}};let Gt=Cs;Ot=new WeakMap,kr=new WeakSet,Us=function(e){const r=e!==void 0?e.getExecutor():$i;return s(this,Ot).plugins!==void 0?r.withPlugins(s(this,Ot).plugins):r},_i=new WeakSet,xo=function(e){return e.transformQuery(s(this,Ot).rawNode,s(this,Ot).queryId)},mi=new WeakSet,Eo=function(e){return e.compileQuery(Le(this,_i,xo).call(this,e),s(this,Ot).queryId)},Se(Gt,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");class Fu{constructor(e,r){R(this,Ir,void 0);R(this,Cn,void 0);U(this,Ir,e),U(this,Cn,r)}get expression(){return s(this,Ir)}get alias(){return s(this,Cn)}toOperationNode(){return Pn.create(s(this,Ir).toOperationNode(),bt(s(this,Cn))?s(this,Cn).toOperationNode():Ge.create(s(this,Cn)))}}Ir=new WeakMap,Cn=new WeakMap;const Wt=Object.assign((t,...e)=>new Gt({queryId:Ce(),rawNode:yt.create(t,(e==null?void 0:e.map(hn))??[])}),{ref(t){return new Gt({queryId:Ce(),rawNode:yt.createWithChild(rr(t))})},val(t){return new Gt({queryId:Ce(),rawNode:yt.createWithChild(hn(t))})},value(t){return this.val(t)},table(t){return new Gt({queryId:Ce(),rawNode:yt.createWithChild(It(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",new Gt({queryId:Ce(),rawNode:yt.create(e,t.map(Ge.create))})},lit(t){return new Gt({queryId:Ce(),rawNode:yt.createWithChild(nn.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return new Gt({queryId:Ce(),rawNode:yt.createWithSql(t)})},join(t,e=Wt`, `){const r=new Array(2*t.length-1),n=e.toOperationNode();for(let A=0;A{this.nodeStack.push(e),s(this,Ws)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}Ws=new WeakMap;class Lu extends Pu{constructor(){super(...arguments);R(this,Or,"");R(this,Gn,[])}get numParameters(){return s(this,Gn).length}compileQuery(r){return U(this,Or,""),U(this,Gn,[]),this.visitNode(r),h({query:r,sql:this.getSql(),parameters:[...s(this,Gn)]})}getSql(){return s(this,Or)}visitSelectQuery(r){const n=this.parentNode!==void 0&&!rn.is(this.parentNode)&&!Sn.is(this.parentNode)&&!aa.is(this.parentNode);this.parentNode===void 0&&r.explain&&(this.visitNode(r.explain),this.append(" ")),n&&this.append("("),r.with&&(this.visitNode(r.with),this.append(" ")),this.append("select "),r.distinctOn&&(this.compileDistinctOn(r.distinctOn),this.append(" ")),r.frontModifiers&&r.frontModifiers.length>0&&(this.compileList(r.frontModifiers," "),this.append(" ")),r.selections&&(this.compileList(r.selections),this.append(" ")),this.visitNode(r.from),r.joins&&(this.append(" "),this.compileList(r.joins," ")),r.where&&(this.append(" "),this.visitNode(r.where)),r.groupBy&&(this.append(" "),this.visitNode(r.groupBy)),r.having&&(this.append(" "),this.visitNode(r.having)),r.setOperations&&(this.append(" "),this.compileList(r.setOperations," ")),r.orderBy&&(this.append(" "),this.visitNode(r.orderBy)),r.limit&&(this.append(" "),this.visitNode(r.limit)),r.offset&&(this.append(" "),this.visitNode(r.offset)),r.endModifiers&&r.endModifiers.length>0&&(this.append(" "),this.compileList(r.endModifiers," ")),n&&this.append(")")}visitFrom(r){this.append("from "),this.compileList(r.froms)}visitSelection(r){this.visitNode(r.selection)}visitColumn(r){this.visitNode(r.column)}compileDistinctOn(r){this.append("distinct on ("),this.compileList(r),this.append(")")}compileList(r,n=", "){const A=r.length-1;for(let X=0;X<=A;X++)this.visitNode(r[X]),XX&&this.visitNode(A[X])}visitOperator(r){this.append(r.operator)}visitTable(r){this.visitNode(r.table)}visitSchemableIdentifier(r){r.schema&&(this.visitNode(r.schema),this.append(".")),this.visitNode(r.identifier)}visitCreateTable(r){this.append("create "),r.frontModifiers&&r.frontModifiers.length>0&&(this.compileList(r.frontModifiers," "),this.append(" ")),r.temporary&&this.append("temporary "),this.append("table "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.table),this.append(" ("),this.compileList([...r.columns,...r.constraints??[]]),this.append(")"),r.onCommit&&(this.append(" on commit "),this.append(r.onCommit)),r.endModifiers&&r.endModifiers.length>0&&(this.append(" "),this.compileList(r.endModifiers," "))}visitColumnDefinition(r){this.visitNode(r.column),this.append(" "),this.visitNode(r.dataType),r.unsigned&&this.append(" unsigned"),r.frontModifiers&&r.frontModifiers.length>0&&(this.append(" "),this.compileList(r.frontModifiers," ")),r.generated&&(this.append(" "),this.visitNode(r.generated)),r.defaultTo&&(this.append(" "),this.visitNode(r.defaultTo)),r.notNull&&this.append(" not null"),r.unique&&this.append(" unique"),r.primaryKey&&this.append(" primary key"),r.autoIncrement&&(this.append(" "),this.append(this.getAutoIncrement())),r.references&&(this.append(" "),this.visitNode(r.references)),r.check&&(this.append(" "),this.visitNode(r.check)),r.endModifiers&&r.endModifiers.length>0&&(this.append(" "),this.compileList(r.endModifiers," "))}getAutoIncrement(){return"auto_increment"}visitReferences(r){this.append("references "),this.visitNode(r.table),this.append(" ("),this.compileList(r.columns),this.append(")"),r.onDelete&&(this.append(" on delete "),this.append(r.onDelete)),r.onUpdate&&(this.append(" on update "),this.append(r.onUpdate))}visitDropTable(r){this.append("drop table "),r.ifExists&&this.append("if exists "),this.visitNode(r.table),r.cascade&&this.append(" cascade")}visitDataType(r){this.append(r.dataType)}visitOrderBy(r){this.append("order by "),this.compileList(r.items)}visitOrderByItem(r){this.visitNode(r.orderBy),r.direction&&(this.append(" "),this.visitNode(r.direction))}visitGroupBy(r){this.append("group by "),this.compileList(r.items)}visitGroupByItem(r){this.visitNode(r.groupBy)}visitUpdateQuery(r){const n=this.nodeStack.find(re.is)!==r;!n&&r.explain&&(this.visitNode(r.explain),this.append(" ")),n&&this.append("("),r.with&&(this.visitNode(r.with),this.append(" ")),this.append("update "),this.visitNode(r.table),this.append(" set "),r.updates&&this.compileList(r.updates),r.from&&(this.append(" "),this.visitNode(r.from)),r.joins&&(this.append(" "),this.compileList(r.joins," ")),r.where&&(this.append(" "),this.visitNode(r.where)),r.returning&&(this.append(" "),this.visitNode(r.returning)),n&&this.append(")")}visitColumnUpdate(r){this.visitNode(r.column),this.append(" = "),this.visitNode(r.value)}visitLimit(r){this.append("limit "),this.visitNode(r.limit)}visitOffset(r){this.append("offset "),this.visitNode(r.offset)}visitOnConflict(r){this.append("on conflict"),r.columns?(this.append(" ("),this.compileList(r.columns),this.append(")")):r.constraint?(this.append(" on constraint "),this.visitNode(r.constraint)):r.indexExpression&&(this.append(" ("),this.visitNode(r.indexExpression),this.append(")")),r.indexWhere&&(this.append(" "),this.visitNode(r.indexWhere)),r.doNothing===!0?this.append(" do nothing"):r.updates&&(this.append(" do update set "),this.compileList(r.updates),r.updateWhere&&(this.append(" "),this.visitNode(r.updateWhere)))}visitOnDuplicateKey(r){this.append("on duplicate key update "),this.compileList(r.updates)}visitCreateIndex(r){this.append("create "),r.unique&&this.append("unique "),this.append("index "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.name),r.table&&(this.append(" on "),this.visitNode(r.table)),r.using&&(this.append(" using "),this.visitNode(r.using)),r.columns&&(this.append(" ("),this.compileList(r.columns),this.append(")")),r.where&&(this.append(" "),this.visitNode(r.where))}visitDropIndex(r){this.append("drop index "),r.ifExists&&this.append("if exists "),this.visitNode(r.name),r.table&&(this.append(" on "),this.visitNode(r.table)),r.cascade&&this.append(" cascade")}visitCreateSchema(r){this.append("create schema "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.schema)}visitDropSchema(r){this.append("drop schema "),r.ifExists&&this.append("if exists "),this.visitNode(r.schema),r.cascade&&this.append(" cascade")}visitPrimaryKeyConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("primary key ("),this.compileList(r.columns),this.append(")")}visitUniqueConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("unique ("),this.compileList(r.columns),this.append(")")}visitCheckConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("check ("),this.visitNode(r.expression),this.append(")")}visitForeignKeyConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("foreign key ("),this.compileList(r.columns),this.append(") "),this.visitNode(r.references),r.onDelete&&(this.append(" on delete "),this.append(r.onDelete)),r.onUpdate&&(this.append(" on update "),this.append(r.onUpdate))}visitList(r){this.compileList(r.items)}visitWith(r){this.append("with "),r.recursive&&this.append("recursive "),this.compileList(r.expressions)}visitCommonTableExpression(r){this.visitNode(r.name),this.append(" as "),this.visitNode(r.expression)}visitCommonTableExpressionName(r){this.visitNode(r.table),r.columns&&(this.append("("),this.compileList(r.columns),this.append(")"))}visitAlterTable(r){this.append("alter table "),this.visitNode(r.table),this.append(" "),r.renameTo&&(this.append("rename to "),this.visitNode(r.renameTo)),r.setSchema&&(this.append("set schema "),this.visitNode(r.setSchema)),r.addConstraint&&this.visitNode(r.addConstraint),r.dropConstraint&&this.visitNode(r.dropConstraint),r.columnAlterations&&this.compileList(r.columnAlterations)}visitAddColumn(r){this.append("add column "),this.visitNode(r.column)}visitRenameColumn(r){this.append("rename column "),this.visitNode(r.column),this.append(" to "),this.visitNode(r.renameTo)}visitDropColumn(r){this.append("drop column "),this.visitNode(r.column)}visitAlterColumn(r){this.append("alter column "),this.visitNode(r.column),this.append(" "),r.dataType&&(this.append("type "),this.visitNode(r.dataType),r.dataTypeExpression&&(this.append("using "),this.visitNode(r.dataTypeExpression))),r.setDefault&&(this.append("set default "),this.visitNode(r.setDefault)),r.dropDefault&&this.append("drop default"),r.setNotNull&&this.append("set not null"),r.dropNotNull&&this.append("drop not null")}visitModifyColumn(r){this.append("modify column "),this.visitNode(r.column)}visitAddConstraint(r){this.append("add "),this.visitNode(r.constraint)}visitDropConstraint(r){this.append("drop constraint "),r.ifExists&&this.append("if exists "),this.visitNode(r.constraintName),r.modifier==="cascade"?this.append(" cascade"):r.modifier==="restrict"&&this.append(" restrict")}visitSetOperation(r){this.append(r.operator),this.append(" "),r.all&&this.append("all "),this.visitNode(r.expression)}visitCreateView(r){this.append("create "),r.orReplace&&this.append("or replace "),r.materialized&&this.append("materialized "),r.temporary&&this.append("temporary "),this.append("view "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.name),this.append(" "),r.columns&&(this.append("("),this.compileList(r.columns),this.append(") ")),r.as&&(this.append("as "),this.visitNode(r.as))}visitDropView(r){this.append("drop "),r.materialized&&this.append("materialized "),this.append("view "),r.ifExists&&this.append("if exists "),this.visitNode(r.name),r.cascade&&this.append(" cascade")}visitGenerated(r){this.append("generated "),r.always&&this.append("always "),r.byDefault&&this.append("by default "),this.append("as "),r.identity&&this.append("identity"),r.expression&&(this.append("("),this.visitNode(r.expression),this.append(")")),r.stored&&this.append(" stored")}visitDefaultValue(r){this.append("default "),this.visitNode(r.defaultValue)}visitSelectModifier(r){r.rawModifier?this.visitNode(r.rawModifier):this.append(Du[r.modifier])}visitCreateType(r){this.append("create type "),this.visitNode(r.name),r.enum&&(this.append(" as enum "),this.visitNode(r.enum))}visitDropType(r){this.append("drop type "),r.ifExists&&this.append("if exists "),this.visitNode(r.name)}visitExplain(r){this.append("explain"),(r.options||r.format)&&(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),r.options&&(this.visitNode(r.options),r.format&&this.append(this.getExplainOptionsDelimiter())),r.format&&(this.append("format"),this.append(this.getExplainOptionAssignment()),this.append(r.format)),this.append(this.getRightExplainOptionsWrapper()))}visitDefaultInsertValue(r){this.append("default")}visitAggregateFunction(r){this.append(r.func),this.append("("),r.distinct&&this.append("distinct "),this.compileList(r.aggregated),this.append(")"),r.filter&&(this.append(" filter("),this.visitNode(r.filter),this.append(")")),r.over&&(this.append(" "),this.visitNode(r.over))}visitOver(r){this.append("over("),r.partitionBy&&(this.visitNode(r.partitionBy),r.orderBy&&this.append(" ")),r.orderBy&&this.visitNode(r.orderBy),this.append(")")}visitPartitionBy(r){this.append("partition by "),this.compileList(r.items)}visitPartitionByItem(r){this.visitNode(r.partitionBy)}visitBinaryOperation(r){this.visitNode(r.leftOperand),this.append(" "),this.visitNode(r.operator),this.append(" "),this.visitNode(r.rightOperand)}visitUnaryOperation(r){this.visitNode(r.operator),this.isMinusOperator(r.operator)||this.append(" "),this.visitNode(r.operand)}isMinusOperator(r){return zs.is(r)&&r.operator==="-"}visitUsing(r){this.append("using "),this.compileList(r.tables)}visitFunction(r){this.append(r.func),this.append("("),this.compileList(r.arguments),this.append(")")}visitCase(r){this.append("case"),r.value&&(this.append(" "),this.visitNode(r.value)),r.when&&(this.append(" "),this.compileList(r.when," ")),r.else&&(this.append(" else "),this.visitNode(r.else)),this.append(" end"),r.isStatement&&this.append(" case")}visitWhen(r){this.append("when "),this.visitNode(r.condition),r.result&&(this.append(" then "),this.visitNode(r.result))}append(r){U(this,Or,s(this,Or)+r)}appendValue(r){this.addParameter(r),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier(r){const n=this.getLeftIdentifierWrapper(),A=this.getRightIdentifierWrapper();let X="";for(const ae of r)X+=ae,ae===n?X+=n:ae===A&&(X+=A);return X}addParameter(r){s(this,Gn).push(r)}appendImmediateValue(r){if(Ne(r))this.append(`'${r}'`);else if(Ze(r)||Pr(r))this.append(r.toString());else if(So(r))this.append("null");else if(hl(r))this.appendImmediateValue(r.toISOString());else if(pl(r))this.appendImmediateValue(r.toString());else throw new Error(`invalid immediate value ${r}`)}}Or=new WeakMap,Gn=new WeakMap;const Du=h({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),Ru=h({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral"}),oo=h({raw(t){return h({sql:t,query:yt.createWithSql(t),parameters:h([])})}}),Bu=/"/g;class Mu extends Lu{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(e){return e.replace(Bu,'""')}visitDefaultInsertValue(e){this.append("null")}}const Uu="kysely_migration",ju="kysely_migration_lock";h({__noMigrations__:!0});class Qu{constructor(e){R(this,Fs);R(this,Ar,void 0);U(this,Ar,e)}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let r=s(this,Ar).selectFrom("sqlite_schema").where("type","in",["table","view"]).where("name","not like","sqlite_%").select("name").orderBy("name").$castTo();e.withInternalKyselyTables||(r=r.where("name","!=",Uu).where("name","!=",ju));const n=await r.execute();return Promise.all(n.map(({name:A})=>Le(this,Fs,fl).call(this,A)))}async getMetadata(e){return{tables:await this.getTables(e)}}}Ar=new WeakMap,Fs=new WeakSet,fl=async function(e){var ae,me,Oe,At,nt,rt;const r=s(this,Ar),n=await r.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),A=(rt=(nt=(At=(Oe=(me=(ae=n.sql)==null?void 0:ae.split(/[\(\),]/))==null?void 0:me.find(ue=>ue.toLowerCase().includes("autoincrement")))==null?void 0:Oe.trimStart())==null?void 0:At.split(/\s+/))==null?void 0:nt[0])==null?void 0:rt.replace(/["`]/g,""),X=await r.selectFrom(Wt`pragma_table_info(${e})`.as("table_info")).select(["name","type","notnull","dflt_value"]).orderBy("cid").execute();return{name:e,isView:n.type==="view",columns:X.map(ue=>({name:ue.name,dataType:ue.type,isNullable:!ue.notnull,isAutoIncrementing:ue.name===A,hasDefaultValue:ue.dflt_value!=null}))}};class zu{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var Vu=class{createQueryCompiler(){return new Mu}createAdapter(){return new zu}createIntrospector(t){return new Qu(t)}},Hu=(Oa=class{constructor(){R(this,yi,new $u);Tt(this,"connection");R(this,Ps,void 0)}async acquireConnection(){return await s(this,yi).lock(),this.connection}async beginTransaction(t){await t.executeQuery(oo.raw("begin"))}async commitTransaction(t){await t.executeQuery(oo.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(oo.raw("rollback"))}async releaseConnection(){s(this,yi).unlock()}async destroy(){var t;(t=s(this,Ps))==null||t.close()}},yi=new WeakMap,Ps=new WeakMap,Oa),$u=(Aa=class{constructor(){R(this,Jn,void 0);R(this,Tr,void 0)}async lock(){for(;s(this,Jn);)await s(this,Jn);U(this,Jn,new Promise(t=>{U(this,Tr,t)}))}unlock(){const t=s(this,Tr);U(this,Jn,void 0),U(this,Tr,void 0),t==null||t()}},Jn=new WeakMap,Tr=new WeakMap,Aa),Gu=class{streamQuery(){throw new Error("Sqlite driver doesn't support streaming")}async executeQuery(t){const{parameters:e,sql:r,query:n}=t;return Promise.resolve(n.kind==="SelectQueryNode"||n.kind==="RawNode"?{rows:await this.query(r,e)}:{rows:[],...await this.exec(r,e)})}},Ju=(Ta=class extends Hu{constructor(e){super();R(this,yn,void 0);R(this,gi,void 0);U(this,yn,e)}async init(){U(this,gi,typeof s(this,yn).database=="function"?await s(this,yn).database():s(this,yn).database),this.connection=new Ku(s(this,gi)),s(this,yn).onCreateConnection&&await s(this,yn).onCreateConnection(this.connection)}},yn=new WeakMap,gi=new WeakMap,Ta),Ku=(Ca=class extends Gu{constructor(e){super();R(this,Kn,void 0);U(this,Kn,e)}query(e,r){const n=[];return s(this,Kn).exec({sql:e,bind:r??[],rowMode:"object",resultRows:n}),n}exec(e,r){return s(this,Kn).exec({sql:e,bind:r??[]}),{numAffectedRows:BigInt(s(this,Kn).changes(!1,!0)),insertId:BigInt(this.query("SELECT last_insert_rowid() as id")[0].id)}}},Kn=new WeakMap,Ca),Xu=(Wa=class extends Vu{constructor(e){super();R(this,wi,void 0);U(this,wi,e)}createDriver(){return new Ju(s(this,wi))}},wi=new WeakMap,Wa),Yu=(()=>{var t=self.location.href;return function(e){var r=e||{},n=typeof r<"u"?r:{},A,X;n.ready=new Promise(function(o,i){A=o,X=i});const ae=globalThis.sqlite3InitModuleState||Object.assign(Object.create(null),{debugModule:()=>{}});delete globalThis.sqlite3InitModuleState,ae.debugModule("globalThis.location =",globalThis.location);const me="emscripten-bug-17951";n[me]=function o(i,l){i.env.foo=function(){};const a=n.locateFile(o.uri,typeof ue>"u"?"":ue);ae.debugModule("instantiateWasm() uri =",a);const u=()=>fetch(a,{credentials:"same-origin"});return(WebAssembly.instantiateStreaming?async()=>WebAssembly.instantiateStreaming(u(),i).then(N=>l(N.instance,N.module)):async()=>u().then(N=>N.arrayBuffer()).then(N=>WebAssembly.instantiate(N,i)).then(N=>l(N.instance,N.module)))(),{}},n[me].uri="sqlite3.wasm";var Oe=Object.assign({},n),At="./this.program",nt=typeof window=="object",rt=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&process.versions.node;var ue="";function Qt(o){return n.locateFile?n.locateFile(o,ue):ue+o}var Qe,gn,vi;(nt||rt)&&(rt?ue=self.location.href:typeof document<"u"&&document.currentScript&&(ue=document.currentScript.src),t&&(ue=t),ue.indexOf("blob:")!==0?ue=ue.substr(0,ue.replace(/[?#].*/,"").lastIndexOf("/")+1):ue="",Qe=o=>{var i=new XMLHttpRequest;return i.open("GET",o,!1),i.send(null),i.responseText},rt&&(vi=o=>{var i=new XMLHttpRequest;return i.open("GET",o,!1),i.responseType="arraybuffer",i.send(null),new Uint8Array(i.response)}),gn=(o,i,l)=>{var a=new XMLHttpRequest;a.open("GET",o,!0),a.responseType="arraybuffer",a.onload=()=>{if(a.status==200||a.status==0&&a.response){i(a.response);return}l()},a.onerror=l,a.send(null)});var wn=n.print||console.log.bind(console),Et=n.printErr||console.warn.bind(console);Object.assign(n,Oe),Oe=null,n.arguments&&n.arguments,n.thisProgram&&(At=n.thisProgram),n.quit&&n.quit;var xi;n.wasmBinary&&(xi=n.wasmBinary),n.noExitRuntime,typeof WebAssembly!="object"&&Zn("no native wasm support detected");var Fn,Da=!1;function cc(o,i){o||Zn(i)}var Ra=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Wr(o,i,l){for(var a=i+l,u=i;o[u]&&!(u>=a);)++u;if(u-i>16&&o.buffer&&Ra)return Ra.decode(o.subarray(i,u));for(var d="";i>10,56320|V&1023)}}return d}function dc(o,i){return o?Wr(Si,o,i):""}function Ls(o,i,l,a){if(!(a>0))return 0;for(var u=l,d=l+a-1,N=0;N=55296&&S<=57343){var C=o.charCodeAt(++N);S=65536+((S&1023)<<10)|C&1023}if(S<=127){if(l>=d)break;i[l++]=S}else if(S<=2047){if(l+1>=d)break;i[l++]=192|S>>6,i[l++]=128|S&63}else if(S<=65535){if(l+2>=d)break;i[l++]=224|S>>12,i[l++]=128|S>>6&63,i[l++]=128|S&63}else{if(l+3>=d)break;i[l++]=240|S>>18,i[l++]=128|S>>12&63,i[l++]=128|S>>6&63,i[l++]=128|S&63}}return i[l]=0,l-u}function Ba(o,i,l){return Ls(o,Si,i,l)}function Ei(o){for(var i=0,l=0;l=55296&&a<=57343?(i+=4,++l):i+=3}return i}var Dt,Si,Ma,we,it;function Ua(){var o=Fn.buffer;n.HEAP8=Dt=new Int8Array(o),n.HEAP16=Ma=new Int16Array(o),n.HEAP32=we=new Int32Array(o),n.HEAPU8=Si=new Uint8Array(o),n.HEAPU16=new Uint16Array(o),n.HEAPU32=it=new Uint32Array(o),n.HEAPF32=new Float32Array(o),n.HEAPF64=new Float64Array(o),n.HEAP64=new BigInt64Array(o),n.HEAPU64=new BigUint64Array(o)}var ja=n.INITIAL_MEMORY||16777216;n.wasmMemory?Fn=n.wasmMemory:Fn=new WebAssembly.Memory({initial:ja/65536,maximum:2147483648/65536}),Ua(),ja=Fn.buffer.byteLength;var Qa=[],za=[],Va=[];function fc(){if(n.preRun)for(typeof n.preRun=="function"&&(n.preRun=[n.preRun]);n.preRun.length;)_c(n.preRun.shift());_o(Qa)}function hc(){!n.noFSInit&&!c.init.initialized&&c.init(),c.ignorePermissions=!1,_o(za)}function pc(){if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)yc(n.postRun.shift());_o(Va)}function _c(o){Qa.unshift(o)}function mc(o){za.unshift(o)}function yc(o){Va.unshift(o)}var Yn=0,ki=null;function bd(o){return o}function po(o){Yn++,n.monitorRunDependencies&&n.monitorRunDependencies(Yn)}function Ds(o){if(Yn--,n.monitorRunDependencies&&n.monitorRunDependencies(Yn),Yn==0&&ki){var i=ki;ki=null,i()}}function Zn(o){n.onAbort&&n.onAbort(o),o="Aborted("+o+")",Et(o),Da=!0,o+=". Build with -sASSERTIONS for more info.";var i=new WebAssembly.RuntimeError(o);throw X(i),i}var gc="data:application/octet-stream;base64,";function Ha(o){return o.startsWith(gc)}var zt;n.locateFile?(zt="sqlite3.wasm",Ha(zt)||(zt=Qt(zt))):zt=new URL(""+new URL("sqlite3-14470338.wasm",self.location.href).href,self.location).href;function $a(o){try{if(o==zt&&xi)return new Uint8Array(xi);if(vi)return vi(o);throw"both async and sync fetching of the wasm failed"}catch(i){Zn(i)}}function wc(){return!xi&&(nt||rt)&&typeof fetch=="function"?fetch(zt,{credentials:"same-origin"}).then(function(o){if(!o.ok)throw"failed to load wasm binary file at '"+zt+"'";return o.arrayBuffer()}).catch(function(){return $a(zt)}):Promise.resolve().then(function(){return $a(zt)})}function qc(){var o={env:Za,wasi_snapshot_preview1:Za};function i(N,S){var C=N.exports;n.asm=C,n.asm.__indirect_function_table,mc(n.asm.__wasm_call_ctors),Ds()}po();function l(N){i(N.instance)}function a(N){return wc().then(function(S){return WebAssembly.instantiate(S,o)}).then(function(S){return S}).then(N,function(S){Et("failed to asynchronously prepare wasm: "+S),Zn(S)})}function u(){return!xi&&typeof WebAssembly.instantiateStreaming=="function"&&!Ha(zt)&&typeof fetch=="function"?fetch(zt,{credentials:"same-origin"}).then(function(N){var S=WebAssembly.instantiateStreaming(N,o);return S.then(l,function(C){return Et("wasm streaming compile failed: "+C),Et("falling back to ArrayBuffer instantiation"),a(l)})}):a(l)}if(n.instantiateWasm)try{var d=n.instantiateWasm(o,i);return d}catch(N){Et("Module.instantiateWasm callback failed with error: "+N),X(N)}return u().catch(X),{}}var qe,ut;function _o(o){for(;o.length>0;)o.shift()(n)}var Ee={isAbs:o=>o.charAt(0)==="/",splitPath:o=>{var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return i.exec(o).slice(1)},normalizeArray:(o,i)=>{for(var l=0,a=o.length-1;a>=0;a--){var u=o[a];u==="."?o.splice(a,1):u===".."?(o.splice(a,1),l++):l&&(o.splice(a,1),l--)}if(i)for(;l;l--)o.unshift("..");return o},normalize:o=>{var i=Ee.isAbs(o),l=o.substr(-1)==="/";return o=Ee.normalizeArray(o.split("/").filter(a=>!!a),!i).join("/"),!o&&!i&&(o="."),o&&l&&(o+="/"),(i?"/":"")+o},dirname:o=>{var i=Ee.splitPath(o),l=i[0],a=i[1];return!l&&!a?".":(a&&(a=a.substr(0,a.length-1)),l+a)},basename:o=>{if(o==="/")return"/";o=Ee.normalize(o),o=o.replace(/\/$/,"");var i=o.lastIndexOf("/");return i===-1?o:o.substr(i+1)},join:function(){var o=Array.prototype.slice.call(arguments);return Ee.normalize(o.join("/"))},join2:(o,i)=>Ee.normalize(o+"/"+i)};function bc(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var o=new Uint8Array(1);return()=>(crypto.getRandomValues(o),o[0])}else return()=>Zn("randomDevice")}var qn={resolve:function(){for(var o="",i=!1,l=arguments.length-1;l>=-1&&!i;l--){var a=l>=0?arguments[l]:c.cwd();if(typeof a!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!a)return"";o=a+"/"+o,i=Ee.isAbs(a)}return o=Ee.normalizeArray(o.split("/").filter(u=>!!u),!i).join("/"),(i?"/":"")+o||"."},relative:(o,i)=>{o=qn.resolve(o).substr(1),i=qn.resolve(i).substr(1);function l(V){for(var J=0;J=0&&V[ie]==="";ie--);return J>ie?[]:V.slice(J,ie-J+1)}for(var a=l(o.split("/")),u=l(i.split("/")),d=Math.min(a.length,u.length),N=d,S=0;S0?l:Ei(o)+1,u=new Array(a),d=Ls(o,u,0,u.length);return i&&(u.length=d),u}var er={ttys:[],init:function(){},shutdown:function(){},register:function(o,i){er.ttys[o]={input:[],output:[],ops:i},c.registerDevice(o,er.stream_ops)},stream_ops:{open:function(o){var i=er.ttys[o.node.rdev];if(!i)throw new c.ErrnoError(43);o.tty=i,o.seekable=!1},close:function(o){o.tty.ops.fsync(o.tty)},fsync:function(o){o.tty.ops.fsync(o.tty)},read:function(o,i,l,a,u){if(!o.tty||!o.tty.ops.get_char)throw new c.ErrnoError(60);for(var d=0,N=0;NNe in Te?yd(Te,Ne,{enumerable:!0,configurable:!0,writable:!0,value:Ze}):Te[Ne]=Ze;var Tt=(Te,Ne,Ze)=>(gd(Te,typeof Ne!="symbol"?Ne+"":Ne,Ze),Ze),qo=(Te,Ne,Ze)=>{if(!Ne.has(Te))throw TypeError("Cannot "+Ze)};var s=(Te,Ne,Ze)=>(qo(Te,Ne,"read from private field"),Ze?Ze.call(Te):Ne.get(Te)),R=(Te,Ne,Ze)=>{if(Ne.has(Te))throw TypeError("Cannot add the same private member more than once");Ne instanceof WeakSet?Ne.add(Te):Ne.set(Te,Ze)},U=(Te,Ne,Ze,Pr)=>(qo(Te,Ne,"write to private field"),Pr?Pr.call(Te,Ze):Ne.set(Te,Ze),Ze);var Le=(Te,Ne,Ze)=>(qo(Te,Ne,"access private method"),Ze);(function(){var ze,Dn,cr,Zr,ei,ge,ti,Ve,ye,ni,Z,ri,te,dr,gs,fr,Rn,ws,il,qs,sl,Bn,Oi,ii,bo,bs,ol,si,Re,oi,hr,pr,Un,ai,No,F,_r,mr,yr,gr,kn,Ue,wr,qr,br,Nr,sn,vr,Fe,jn,Xt,qt,tt,je,Ye,Pe,Ft,ke,ht,vt,xt,Ss,He,pt,Pt,Lt,lt,xr,an,ln,_n,Yt,On,mn,Vn,fi,ks,al,Is,ll,Os,ul,As,cl,hi,vo,pi,An,Ts,dl,Tn,Hn,_t,Zt,$n,en,Ot,kr,Us,_i,xo,mi,Eo,Ir,Cn,Ws,Or,Gn,Ar,Fs,fl,yi,Ps,Oa,Jn,Tr,Aa,yn,gi,Ta,Kn,Ca,wi,Wa,Xn,Fa,qi,bi,Cr,Pa,Wn,Ni,La;"use strict";function Te(t){return typeof t>"u"||t===void 0}function Ne(t){return typeof t=="string"}function Ze(t){return typeof t=="number"}function Pr(t){return typeof t=="boolean"}function So(t){return t===null}function hl(t){return t instanceof Date}function pl(t){return typeof t=="bigint"}function Rt(t){return typeof t=="function"}function tn(t){return typeof t=="object"&&t!==null}function h(t){return Object.freeze(t)}function Lr(t){return Array.isArray(t)}function tr(t){return t}const et=h({is(t){return t.kind==="AlterTableNode"},create(t){return h({kind:"AlterTableNode",table:t})},cloneWithTableProps(t,e){return h({...t,...e})},cloneWithColumnAlteration(t,e){return h({...t,columnAlterations:t.columnAlterations?[...t.columnAlterations,e]:[e]})}}),Ge=h({is(t){return t.kind==="IdentifierNode"},create(t){return h({kind:"IdentifierNode",name:t})}}),bn=h({is(t){return t.kind==="CreateIndexNode"},create(t){return h({kind:"CreateIndexNode",name:Ge.create(t)})},cloneWith(t,e){return h({...t,...e})},cloneWithColumns(t,e){return h({...t,columns:[...t.columns||[],...e]})}}),ko=h({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return h({kind:"CreateSchemaNode",schema:Ge.create(t),...e})},cloneWith(t,e){return h({...t,...e})}}),_l=["preserve rows","delete rows","drop"],Ht=h({is(t){return t.kind==="CreateTableNode"},create(t){return h({kind:"CreateTableNode",table:t,columns:h([])})},cloneWithColumn(t,e){return h({...t,columns:h([...t.columns,e])})},cloneWithConstraint(t,e){return h({...t,constraints:t.constraints?h([...t.constraints,e]):h([e])})},cloneWithFrontModifier(t,e){return h({...t,frontModifiers:t.frontModifiers?h([...t.frontModifiers,e]):h([e])})},cloneWithEndModifier(t,e){return h({...t,endModifiers:t.endModifiers?h([...t.endModifiers,e]):h([e])})},cloneWith(t,e){return h({...t,...e})}}),Nn=h({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return h({kind:"SchemableIdentifierNode",identifier:Ge.create(t)})},createWithSchema(t,e){return h({kind:"SchemableIdentifierNode",schema:Ge.create(t),identifier:Ge.create(e)})}}),Ai=h({is(t){return t.kind==="DropIndexNode"},create(t,e){return h({kind:"DropIndexNode",name:Nn.create(t),...e})},cloneWith(t,e){return h({...t,...e})}}),js=h({is(t){return t.kind==="DropSchemaNode"},create(t,e){return h({kind:"DropSchemaNode",schema:Ge.create(t),...e})},cloneWith(t,e){return h({...t,...e})}}),Qs=h({is(t){return t.kind==="DropTableNode"},create(t,e){return h({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return h({...t,...e})}}),Pn=h({is(t){return t.kind==="AliasNode"},create(t,e){return h({kind:"AliasNode",node:t,alias:e})}}),vn=h({is(t){return t.kind==="TableNode"},create(t){return h({kind:"TableNode",table:Nn.create(t)})},createWithSchema(t,e){return h({kind:"TableNode",table:Nn.createWithSchema(t,e)})}});function bt(t){return tn(t)&&Rt(t.toOperationNode)}function ml(t){return tn(t)&&"expressionType"in t&&bt(t)}function yl(t){return tn(t)&&"expression"in t&&Ne(t.alias)&&bt(t)}const dn=h({is(t){return t.kind==="SelectModifierNode"},create(t){return h({kind:"SelectModifierNode",modifier:t})},createWithExpression(t){return h({kind:"SelectModifierNode",rawModifier:t})}}),Dr=h({is(t){return t.kind==="AndNode"},create(t,e){return h({kind:"AndNode",left:t,right:e})}}),Rr=h({is(t){return t.kind==="OrNode"},create(t,e){return h({kind:"OrNode",left:t,right:e})}}),Br=h({is(t){return t.kind==="OnNode"},create(t){return h({kind:"OnNode",on:t})},cloneWithOperation(t,e,r){return h({...t,on:e==="And"?Dr.create(t.on,r):Rr.create(t.on,r)})}}),Bt=h({is(t){return t.kind==="JoinNode"},create(t,e){return h({kind:"JoinNode",joinType:t,table:e,on:void 0})},createWithOn(t,e,r){return h({kind:"JoinNode",joinType:t,table:e,on:Br.create(r)})},cloneWithOn(t,e){return h({...t,on:t.on?Br.cloneWithOperation(t.on,"And",e):Br.create(e)})},cloneWithOrOn(t,e){return h({...t,on:t.on?Br.cloneWithOperation(t.on,"Or",e):Br.create(e)})}}),Ti=h({is(t){return t.kind==="BinaryOperationNode"},create(t,e,r){return h({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:r})}}),yt=h({is(t){return t.kind==="RawNode"},create(t,e){return h({kind:"RawNode",sqlFragments:h(t),parameters:h(e)})},createWithSql(t){return yt.create([t],[])},createWithChild(t){return yt.create(["",""],[t])},createWithChildren(t){return yt.create(new Array(t.length+1).fill(""),t)}}),Io=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->"],gl=["+","-","*","/","%","^","&","|","#","<<",">>"],Oo=[...Io,...gl,"&&","||"],wl=["not","-",...["exists","not exists"]],ql=[...Oo,...wl],zs=h({is(t){return t.kind==="OperatorNode"},create(t){return h({kind:"OperatorNode",operator:t})}});function Ao(t){return Ne(t)&&Oo.includes(t)}function To(t){return Ne(t)&&Io.includes(t)}const nr=h({is(t){return t.kind==="ParensNode"},create(t){return h({kind:"ParensNode",node:t})}}),Ke=h({is(t){return t.kind==="ColumnNode"},create(t){return h({kind:"ColumnNode",column:Ge.create(t)})}}),Vs=h({is(t){return t.kind==="SelectAllNode"},create(){return h({kind:"SelectAllNode"})}}),Ci=h({is(t){return t.kind==="ReferenceNode"},create(t,e){return h({kind:"ReferenceNode",table:t,column:e})},createSelectAll(t){return h({kind:"ReferenceNode",table:t,column:Vs.create()})}}),bl=h({is(t){return t.kind==="OrderByItemNode"},create(t,e){return h({kind:"OrderByItemNode",orderBy:t,direction:e})}});function Nl(t){return t==="asc"||t==="desc"}function Wi(t,e){return bl.create(vl(t),xl(e))}function vl(t){return fn(t)}function xl(t){if(t)return t==="asc"||t==="desc"?yt.createWithSql(t):t.toOperationNode()}function Co(t){return Ne(t)?rr(t):t.toOperationNode()}function Mr(t){return Lr(t)?t.map(e=>fn(e)):[fn(t)]}function fn(t){return Ki(t)?Ji(t):Co(t)}function rr(t){const e=".";if(t.includes(e)){const r=t.split(e).map(Hs);if(r.length===3)return Sl(r);if(r.length===2)return kl(r);throw new Error(`invalid column reference ${t}`)}else return Ke.create(t)}function El(t){const e=" as ";if(t.includes(e)){const[r,n]=t.split(e).map(Hs);return Pn.create(rr(r),Ge.create(n))}else return rr(t)}function Wo(t){return Ke.create(t)}function Fo(t){const e=" ";if(t.includes(e)){const[r,n]=t.split(e).map(Hs);if(!Nl(n))throw new Error(`invalid order direction "${n}" next to "${r}"`);return Wi(r,n)}else return Wo(t)}function Sl(t){const[e,r,n]=t;return Ci.create(vn.createWithSchema(e,r),Ke.create(n))}function kl(t){const[e,r]=t;return Ci.create(vn.create(e),Ke.create(r))}function Hs(t){return t.trim()}const Po=h({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return h({kind:"PrimitiveValueListNode",values:h([...t])})}}),$s=h({is(t){return t.kind==="ValueListNode"},create(t){return h({kind:"ValueListNode",values:h(t)})}}),nn=h({is(t){return t.kind==="ValueNode"},create(t){return h({kind:"ValueNode",value:t})},createImmediate(t){return h({kind:"ValueNode",value:t,immediate:!0})}});function Lo(t){return Lr(t)?Il(t):hn(t)}function hn(t){return Ki(t)?Ji(t):nn.create(t)}function Il(t){return t.some(Ki)?$s.create(t.map(e=>hn(e))):Po.create(t)}const ir=h({is(t){return t.kind==="OrderByNode"},create(t){return h({kind:"OrderByNode",items:h([t])})},cloneWithItem(t,e){return h({...t,items:h([...t.items,e])})}}),Do=h({is(t){return t.kind==="PartitionByNode"},create(t){return h({kind:"PartitionByNode",items:h(t)})},cloneWithItems(t,e){return h({...t,items:h([...t.items,...e])})}}),Gs=h({is(t){return t.kind==="OverNode"},create(){return h({kind:"OverNode"})},cloneWithOrderByItem(t,e){return h({...t,orderBy:t.orderBy?ir.cloneWithItem(t.orderBy,e):ir.create(e)})},cloneWithPartitionByItems(t,e){return h({...t,partitionBy:t.partitionBy?Do.cloneWithItems(t.partitionBy,e):Do.create(e)})}}),Fi=h({is(t){return t.kind==="FromNode"},create(t){return h({kind:"FromNode",froms:h(t)})},cloneWithFroms(t,e){return h({...t,froms:h([...t.froms,...e])})}}),Ro=h({is(t){return t.kind==="GroupByNode"},create(t){return h({kind:"GroupByNode",items:h(t)})},cloneWithItems(t,e){return h({...t,items:h([...t.items,...e])})}}),Pi=h({is(t){return t.kind==="HavingNode"},create(t){return h({kind:"HavingNode",having:t})},cloneWithOperation(t,e,r){return h({...t,having:e==="And"?Dr.create(t.having,r):Rr.create(t.having,r)})}}),_e=h({is(t){return t.kind==="SelectQueryNode"},create(t,e){return h({kind:"SelectQueryNode",from:Fi.create(t),...e&&{with:e}})},cloneWithSelections(t,e){return h({...t,selections:t.selections?h([...t.selections,...e]):h(e)})},cloneWithDistinctOn(t,e){return h({...t,distinctOn:t.distinctOn?h([...t.distinctOn,...e]):h(e)})},cloneWithFrontModifier(t,e){return h({...t,frontModifiers:t.frontModifiers?h([...t.frontModifiers,e]):h([e])})},cloneWithEndModifier(t,e){return h({...t,endModifiers:t.endModifiers?h([...t.endModifiers,e]):h([e])})},cloneWithOrderByItem(t,e){return h({...t,orderBy:t.orderBy?ir.cloneWithItem(t.orderBy,e):ir.create(e)})},cloneWithGroupByItems(t,e){return h({...t,groupBy:t.groupBy?Ro.cloneWithItems(t.groupBy,e):Ro.create(e)})},cloneWithLimit(t,e){return h({...t,limit:e})},cloneWithOffset(t,e){return h({...t,offset:e})},cloneWithHaving(t,e){return h({...t,having:t.having?Pi.cloneWithOperation(t.having,"And",e):Pi.create(e)})},cloneWithOrHaving(t,e){return h({...t,having:t.having?Pi.cloneWithOperation(t.having,"Or",e):Pi.create(e)})},cloneWithSetOperation(t,e){return h({...t,setOperations:t.setOperations?h([...t.setOperations,e]):h([e])})},cloneWithoutSelections(t){return h({...t,selections:[]})},cloneWithoutLimit(t){return h({...t,limit:void 0})},cloneWithoutOffset(t){return h({...t,offset:void 0})},cloneWithoutOrderBy(t){return h({...t,orderBy:void 0})}}),Bo=h({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return h({kind:"UnaryOperationNode",operator:t,operand:e})}});function gt(t){return Js("exists",t)}function dt(t){return Js("not exists",t)}function Js(t,e){return Bo.create(zs.create(t),fn(e))}function Se(t,e){Object.defineProperties(t.prototype,{then:{enumerable:!1,value:()=>{throw new Error(e)}}})}const Jt=class{constructor(e){R(this,ze,void 0);U(this,ze,h(e))}on(...e){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOn(s(this,ze).joinNode,ia(e))})}orOn(...e){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOrOn(s(this,ze).joinNode,ia(e))})}onRef(e,r,n){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOn(s(this,ze).joinNode,ft(e,r,n))})}orOnRef(e,r,n){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOrOn(s(this,ze).joinNode,ft(e,r,n))})}onExists(e){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOn(s(this,ze).joinNode,gt(e))})}onNotExists(e){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOn(s(this,ze).joinNode,dt(e))})}orOnExists(e){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOrOn(s(this,ze).joinNode,gt(e))})}orOnNotExists(e){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOrOn(s(this,ze).joinNode,dt(e))})}onTrue(){return new Jt({...s(this,ze),joinNode:Bt.cloneWithOn(s(this,ze).joinNode,yt.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return s(this,ze).joinNode}};let Li=Jt;ze=new WeakMap,Se(Li,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const Ol=h({is(t){return t.kind==="PartitionByItemNode"},create(t){return h({kind:"PartitionByItemNode",partitionBy:t})}});function Al(t){return Mr(t).map(Ol.create)}const ys=class{constructor(e){R(this,Dn,void 0);U(this,Dn,h(e))}orderBy(e,r){return new ys({overNode:Gs.cloneWithOrderByItem(s(this,Dn).overNode,Wi(e,r))})}partitionBy(e){return new ys({overNode:Gs.cloneWithPartitionByItems(s(this,Dn).overNode,Al(e))})}$call(e){return e(this)}toOperationNode(){return s(this,Dn).overNode}};let Di=ys;Dn=new WeakMap,Se(Di,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");const Ur=h({is(t){return t.kind==="SelectionNode"},create(t){return h({kind:"SelectionNode",selection:t})},createSelectAll(){return h({kind:"SelectionNode",selection:Vs.create()})},createSelectAllFromTable(t){return h({kind:"SelectionNode",selection:Ci.createSelectAll(t)})}});class Tl{constructor(e){R(this,cr,void 0);U(this,cr,e)}get dynamicReference(){return s(this,cr)}get refType(){}toOperationNode(){return Co(s(this,cr))}}cr=new WeakMap;function Cl(t){return tn(t)&&bt(t)&&Ne(t.dynamicReference)}function jr(t){return Rt(t)?jr(t(pn())):Lr(t)?t.map(e=>Mo(e)):[Mo(t)]}function Mo(t){return Ne(t)?Ur.create(El(t)):Cl(t)?Ur.create(t.toOperationNode()):Ur.create(fa(t))}function Qr(t){return t?Array.isArray(t)?t.map(Uo):[Uo(t)]:[Ur.createSelectAll()]}function Uo(t){if(Ne(t))return Ur.createSelectAllFromTable(It(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const Wl=h({is(t){return t.kind==="ValuesNode"},create(t){return h({kind:"ValuesNode",values:h(t)})}}),Fl=h({is(t){return t.kind==="DefaultInsertValueNode"},create(){return h({kind:"DefaultInsertValueNode"})}});function Pl(t){const e=Rt(t)?t(pn()):t,r=Lr(e)?e:h([e]);return Ll(r)}function Ll(t){const e=Dl(t);return[h([...e.keys()].map(Ke.create)),Wl.create(t.map(r=>Rl(r,e)))]}function Dl(t){const e=new Map;for(const r of t){const n=Object.keys(r);for(const A of n)!e.has(A)&&r[A]!==void 0&&e.set(A,e.size)}return e}function Rl(t,e){const r=Object.keys(t),n=Array.from({length:e.size});let A=!1;for(const ae of r){const me=e.get(ae);if(Te(me))continue;const Oe=t[ae];(Te(Oe)||Ki(Oe))&&(A=!0),n[me]=Oe}if(r.lengthTe(me)?ae:hn(me)))}return Po.create(n)}const rn=h({is(t){return t.kind==="InsertQueryNode"},create(t,e,r){return h({kind:"InsertQueryNode",into:t,...e&&{with:e},replace:r})},cloneWith(t,e){return h({...t,...e})}}),Ri=h({is(t){return t.kind==="UpdateQueryNode"},create(t,e){return h({kind:"UpdateQueryNode",table:t,...e&&{with:e}})},cloneWithFromItems(t,e){return h({...t,from:t.from?Fi.cloneWithFroms(t.from,e):Fi.create(e)})},cloneWithUpdates(t,e){return h({...t,updates:t.updates?h([...t.updates,...e]):e})}}),jo=h({is(t){return t.kind==="UsingNode"},create(t){return h({kind:"UsingNode",tables:h(t)})},cloneWithTables(t,e){return h({...t,tables:h([...t.tables,...e])})}}),zr=h({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return h({kind:"DeleteQueryNode",from:Fi.create(t),...e&&{with:e}})},cloneWithOrderByItem(t,e){return h({...t,orderBy:t.orderBy?ir.cloneWithItem(t.orderBy,e):ir.create(e)})},cloneWithLimit(t,e){return h({...t,limit:e})},cloneWithUsing(t,e){return h({...t,using:t.using!==void 0?jo.cloneWithTables(t.using,e):jo.create(e)})}}),wt=h({is(t){return t.kind==="WhereNode"},create(t){return h({kind:"WhereNode",where:t})},cloneWithOperation(t,e,r){return h({...t,where:e==="And"?Dr.create(t.where,r):Rr.create(t.where,r)})}}),Qo=h({is(t){return t.kind==="ReturningNode"},create(t){return h({kind:"ReturningNode",selections:h(t)})},cloneWithSelections(t,e){return h({...t,selections:t.selections?h([...t.selections,...e]):h(e)})}}),Bl=h({is(t){return t.kind==="ExplainNode"},create(t,e){return h({kind:"ExplainNode",format:t,options:e})}}),re=h({is(t){return _e.is(t)||rn.is(t)||Ri.is(t)||zr.is(t)},cloneWithWhere(t,e){return h({...t,where:t.where?wt.cloneWithOperation(t.where,"And",e):wt.create(e)})},cloneWithOrWhere(t,e){return h({...t,where:t.where?wt.cloneWithOperation(t.where,"Or",e):wt.create(e)})},cloneWithJoin(t,e){return h({...t,joins:t.joins?h([...t.joins,e]):h([e])})},cloneWithReturning(t,e){return h({...t,returning:t.returning?Qo.cloneWithSelections(t.returning,e):Qo.create(e)})},cloneWithoutWhere(t){return h({...t,where:void 0})},cloneWithExplain(t,e,r){return h({...t,explain:Bl.create(e,r==null?void 0:r.toOperationNode())})}}),Ml=h({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return h({kind:"ColumnUpdateNode",column:t,value:e})}});function Ks(t){const e=Rt(t)?t(pn()):t;return Object.entries(e).filter(([r,n])=>n!==void 0).map(([r,n])=>Ml.create(Ke.create(r),hn(n)))}const Ul=h({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return h({kind:"OnDuplicateKeyNode",updates:t})}});class zo{constructor(e,r){R(this,Zr,void 0);R(this,ei,void 0);U(this,Zr,e),U(this,ei,r)}get insertId(){return s(this,Zr)}get numInsertedOrUpdatedRows(){return s(this,ei)}}Zr=new WeakMap,ei=new WeakMap;for(const t of["insertId","numInsertedOrUpdatedRows"])Object.defineProperty(zo.prototype,t,{enumerable:!0});class Bi extends Error{constructor(r){super("no result");Tt(this,"node");this.node=r}}function Mi(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const Me=h({is(t){return t.kind==="OnConflictNode"},create(){return h({kind:"OnConflictNode"})},cloneWith(t,e){return h({...t,...e})},cloneWithIndexWhere(t,e){return h({...t,indexWhere:t.indexWhere?wt.cloneWithOperation(t.indexWhere,"And",e):wt.create(e)})},cloneWithIndexOrWhere(t,e){return h({...t,indexWhere:t.indexWhere?wt.cloneWithOperation(t.indexWhere,"Or",e):wt.create(e)})},cloneWithUpdateWhere(t,e){return h({...t,updateWhere:t.updateWhere?wt.cloneWithOperation(t.updateWhere,"And",e):wt.create(e)})},cloneWithUpdateOrWhere(t,e){return h({...t,updateWhere:t.updateWhere?wt.cloneWithOperation(t.updateWhere,"Or",e):wt.create(e)})},cloneWithoutIndexWhere(t){return h({...t,indexWhere:void 0})},cloneWithoutUpdateWhere(t){return h({...t,updateWhere:void 0})}}),Nt=class{constructor(e){R(this,ge,void 0);U(this,ge,h(e))}column(e){const r=Ke.create(e);return new Nt({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{columns:s(this,ge).onConflictNode.columns?h([...s(this,ge).onConflictNode.columns,r]):h([r])})})}columns(e){const r=e.map(Ke.create);return new Nt({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{columns:s(this,ge).onConflictNode.columns?h([...s(this,ge).onConflictNode.columns,...r]):h(r)})})}constraint(e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{constraint:Ge.create(e)})})}expression(e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexWhere(s(this,ge).onConflictNode,Ct(e))})}whereRef(e,r,n){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexWhere(s(this,ge).onConflictNode,ft(e,r,n))})}orWhere(...e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexOrWhere(s(this,ge).onConflictNode,Ct(e))})}orWhereRef(e,r,n){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexOrWhere(s(this,ge).onConflictNode,ft(e,r,n))})}whereExists(e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexWhere(s(this,ge).onConflictNode,gt(e))})}whereNotExists(e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexWhere(s(this,ge).onConflictNode,dt(e))})}orWhereExists(e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexOrWhere(s(this,ge).onConflictNode,gt(e))})}orWhereNotExists(e){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithIndexOrWhere(s(this,ge).onConflictNode,dt(e))})}clearWhere(){return new Nt({...s(this,ge),onConflictNode:Me.cloneWithoutIndexWhere(s(this,ge).onConflictNode)})}doNothing(){return new Vo({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new ji({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{updates:Ks(e)})})}$call(e){return e(this)}};let Ui=Nt;ge=new WeakMap,Se(Ui,"don't await OnConflictBuilder instances.");class Vo{constructor(e){R(this,ti,void 0);U(this,ti,h(e))}toOperationNode(){return s(this,ti).onConflictNode}}ti=new WeakMap,Se(Vo,"don't await OnConflictDoNothingBuilder instances.");const Kt=class{constructor(e){R(this,Ve,void 0);U(this,Ve,h(e))}where(...e){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateWhere(s(this,Ve).onConflictNode,Ct(e))})}whereRef(e,r,n){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateWhere(s(this,Ve).onConflictNode,ft(e,r,n))})}orWhere(...e){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateOrWhere(s(this,Ve).onConflictNode,Ct(e))})}orWhereRef(e,r,n){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateOrWhere(s(this,Ve).onConflictNode,ft(e,r,n))})}whereExists(e){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateWhere(s(this,Ve).onConflictNode,gt(e))})}whereNotExists(e){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateWhere(s(this,Ve).onConflictNode,dt(e))})}orWhereExists(e){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateOrWhere(s(this,Ve).onConflictNode,gt(e))})}orWhereNotExists(e){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithUpdateOrWhere(s(this,Ve).onConflictNode,dt(e))})}clearWhere(){return new Kt({...s(this,Ve),onConflictNode:Me.cloneWithoutUpdateWhere(s(this,Ve).onConflictNode)})}$call(e){return e(this)}toOperationNode(){return s(this,Ve).onConflictNode}};let ji=Kt;Ve=new WeakMap,Se(ji,"don't await OnConflictUpdateBuilder instances.");const ot=class{constructor(e){R(this,ye,void 0);U(this,ye,h(e))}values(e){const[r,n]=Pl(e);return new ot({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{columns:r,values:n})})}columns(e){return new ot({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{columns:h(e.map(Ke.create))})})}expression(e){return new ot({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{values:Ji(e)})})}ignore(){return new ot({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{ignore:!0})})}onConflict(e){return new ot({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{onConflict:e(new Ui({onConflictNode:Me.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new ot({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{onDuplicateKey:Ul.create(Ks(e))})})}returning(e){return new ot({...s(this,ye),queryNode:re.cloneWithReturning(s(this,ye).queryNode,jr(e))})}returningAll(){return new ot({...s(this,ye),queryNode:re.cloneWithReturning(s(this,ye).queryNode,Qr())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new ot({...s(this,ye)})}if(e,r){return e?r(this):new ot({...s(this,ye)})}$castTo(){return new ot(s(this,ye))}castTo(){return this.$castTo()}$narrowType(){return new ot(s(this,ye))}$assertType(){return new ot(s(this,ye))}assertType(){return new ot(s(this,ye))}withPlugin(e){return new ot({...s(this,ye),executor:s(this,ye).executor.withPlugin(e)})}toOperationNode(){return s(this,ye).executor.transformQuery(s(this,ye).queryNode,s(this,ye).queryId)}compile(){return s(this,ye).executor.compileQuery(this.toOperationNode(),s(this,ye).queryId)}async execute(){const e=this.compile(),r=e.query,n=await s(this,ye).executor.executeQuery(e,s(this,ye).queryId);return s(this,ye).executor.adapter.supportsReturning&&r.returning?n.rows:[new zo(n.insertId,n.numAffectedRows??n.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Bi){const r=await this.executeTakeFirst();if(r===void 0)throw Mi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=s(this,ye).executor.stream(r,e,s(this,ye).queryId);for await(const A of n)yield*A.rows}async explain(e,r){return await new ot({...s(this,ye),queryNode:re.cloneWithExplain(s(this,ye).queryNode,e,r)}).execute()}};let Vr=ot;ye=new WeakMap,Se(Vr,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Ho{constructor(e){R(this,ni,void 0);U(this,ni,e)}get numDeletedRows(){return s(this,ni)}}ni=new WeakMap,Object.defineProperty(Ho.prototype,"numDeletedRows",{enumerable:!0});const $o=h({is(t){return t.kind==="LimitNode"},create(t){return h({kind:"LimitNode",limit:nn.create(t)})}}),We=class{constructor(e){R(this,Z,void 0);U(this,Z,h(e))}where(...e){return new We({...s(this,Z),queryNode:re.cloneWithWhere(s(this,Z).queryNode,Ct(e))})}whereRef(e,r,n){return new We({...s(this,Z),queryNode:re.cloneWithWhere(s(this,Z).queryNode,ft(e,r,n))})}orWhere(...e){return new We({...s(this,Z),queryNode:re.cloneWithOrWhere(s(this,Z).queryNode,Ct(e))})}orWhereRef(e,r,n){return new We({...s(this,Z),queryNode:re.cloneWithOrWhere(s(this,Z).queryNode,ft(e,r,n))})}whereExists(e){return new We({...s(this,Z),queryNode:re.cloneWithWhere(s(this,Z).queryNode,gt(e))})}whereNotExists(e){return new We({...s(this,Z),queryNode:re.cloneWithWhere(s(this,Z).queryNode,dt(e))})}orWhereExists(e){return new We({...s(this,Z),queryNode:re.cloneWithOrWhere(s(this,Z).queryNode,gt(e))})}orWhereNotExists(e){return new We({...s(this,Z),queryNode:re.cloneWithOrWhere(s(this,Z).queryNode,dt(e))})}clearWhere(){return new We({...s(this,Z),queryNode:re.cloneWithoutWhere(s(this,Z).queryNode)})}using(e){return new We({...s(this,Z),queryNode:zr.cloneWithUsing(s(this,Z).queryNode,lr(e))})}innerJoin(...e){return new We({...s(this,Z),queryNode:re.cloneWithJoin(s(this,Z).queryNode,kt("InnerJoin",e))})}leftJoin(...e){return new We({...s(this,Z),queryNode:re.cloneWithJoin(s(this,Z).queryNode,kt("LeftJoin",e))})}rightJoin(...e){return new We({...s(this,Z),queryNode:re.cloneWithJoin(s(this,Z).queryNode,kt("RightJoin",e))})}fullJoin(...e){return new We({...s(this,Z),queryNode:re.cloneWithJoin(s(this,Z).queryNode,kt("FullJoin",e))})}returning(e){return new We({...s(this,Z),queryNode:re.cloneWithReturning(s(this,Z).queryNode,jr(e))})}returningAll(e){return new We({...s(this,Z),queryNode:re.cloneWithReturning(s(this,Z).queryNode,Qr(e))})}orderBy(e,r){return new We({...s(this,Z),queryNode:zr.cloneWithOrderByItem(s(this,Z).queryNode,Wi(e,r))})}limit(e){return new We({...s(this,Z),queryNode:zr.cloneWithLimit(s(this,Z).queryNode,$o.create(e))})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new We({...s(this,Z)})}if(e,r){return this.$if(e,r)}$castTo(){return new We(s(this,Z))}castTo(){return this.$castTo()}$narrowType(){return new We(s(this,Z))}$assertType(){return new We(s(this,Z))}assertType(){return new We(s(this,Z))}withPlugin(e){return new We({...s(this,Z),executor:s(this,Z).executor.withPlugin(e)})}toOperationNode(){return s(this,Z).executor.transformQuery(s(this,Z).queryNode,s(this,Z).queryId)}compile(){return s(this,Z).executor.compileQuery(this.toOperationNode(),s(this,Z).queryId)}async execute(){const e=this.compile(),r=e.query,n=await s(this,Z).executor.executeQuery(e,s(this,Z).queryId);return s(this,Z).executor.adapter.supportsReturning&&r.returning?n.rows:[new Ho(n.numAffectedRows??n.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Bi){const r=await this.executeTakeFirst();if(r===void 0)throw Mi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=s(this,Z).executor.stream(r,e,s(this,Z).queryId);for await(const A of n)yield*A.rows}async explain(e,r){return await new We({...s(this,Z),queryNode:re.cloneWithExplain(s(this,Z).queryNode,e,r)}).execute()}};let Qi=We;Z=new WeakMap,Se(Qi,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Go{constructor(e){R(this,ri,void 0);U(this,ri,e)}get numUpdatedRows(){return s(this,ri)}}ri=new WeakMap,Object.defineProperty(Go.prototype,"numUpdatedRows",{enumerable:!0});const De=class{constructor(e){R(this,te,void 0);U(this,te,h(e))}where(...e){return new De({...s(this,te),queryNode:re.cloneWithWhere(s(this,te).queryNode,Ct(e))})}whereRef(e,r,n){return new De({...s(this,te),queryNode:re.cloneWithWhere(s(this,te).queryNode,ft(e,r,n))})}orWhere(...e){return new De({...s(this,te),queryNode:re.cloneWithOrWhere(s(this,te).queryNode,Ct(e))})}orWhereRef(e,r,n){return new De({...s(this,te),queryNode:re.cloneWithOrWhere(s(this,te).queryNode,ft(e,r,n))})}whereExists(e){return new De({...s(this,te),queryNode:re.cloneWithWhere(s(this,te).queryNode,gt(e))})}whereNotExists(e){return new De({...s(this,te),queryNode:re.cloneWithWhere(s(this,te).queryNode,dt(e))})}orWhereExists(e){return new De({...s(this,te),queryNode:re.cloneWithOrWhere(s(this,te).queryNode,gt(e))})}orWhereNotExists(e){return new De({...s(this,te),queryNode:re.cloneWithOrWhere(s(this,te).queryNode,dt(e))})}clearWhere(){return new De({...s(this,te),queryNode:re.cloneWithoutWhere(s(this,te).queryNode)})}from(e){return new De({...s(this,te),queryNode:Ri.cloneWithFromItems(s(this,te).queryNode,lr(e))})}innerJoin(...e){return new De({...s(this,te),queryNode:re.cloneWithJoin(s(this,te).queryNode,kt("InnerJoin",e))})}leftJoin(...e){return new De({...s(this,te),queryNode:re.cloneWithJoin(s(this,te).queryNode,kt("LeftJoin",e))})}rightJoin(...e){return new De({...s(this,te),queryNode:re.cloneWithJoin(s(this,te).queryNode,kt("RightJoin",e))})}fullJoin(...e){return new De({...s(this,te),queryNode:re.cloneWithJoin(s(this,te).queryNode,kt("FullJoin",e))})}set(e){return new De({...s(this,te),queryNode:Ri.cloneWithUpdates(s(this,te).queryNode,Ks(e))})}returning(e){return new De({...s(this,te),queryNode:re.cloneWithReturning(s(this,te).queryNode,jr(e))})}returningAll(){return new De({...s(this,te),queryNode:re.cloneWithReturning(s(this,te).queryNode,Qr())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new De({...s(this,te)})}if(e,r){return this.$if(e,r)}$castTo(){return new De(s(this,te))}castTo(){return this.$castTo()}$narrowType(){return new De(s(this,te))}$assertType(){return new De(s(this,te))}assertType(){return new De(s(this,te))}withPlugin(e){return new De({...s(this,te),executor:s(this,te).executor.withPlugin(e)})}toOperationNode(){return s(this,te).executor.transformQuery(s(this,te).queryNode,s(this,te).queryId)}compile(){return s(this,te).executor.compileQuery(this.toOperationNode(),s(this,te).queryId)}async execute(){const e=this.compile(),r=e.query,n=await s(this,te).executor.executeQuery(e,s(this,te).queryId);return s(this,te).executor.adapter.supportsReturning&&r.returning?n.rows:[new Go(n.numAffectedRows??n.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Bi){const r=await this.executeTakeFirst();if(r===void 0)throw Mi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=s(this,te).executor.stream(r,e,s(this,te).queryId);for await(const A of n)yield*A.rows}async explain(e,r){return await new De({...s(this,te),queryNode:re.cloneWithExplain(s(this,te).queryNode,e,r)}).execute()}};let zi=De;te=new WeakMap,Se(zi,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");const jl=h({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return h({kind:"CommonTableExpressionNode",name:t,expression:e})}}),Jo=h({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return h({kind:"CommonTableExpressionNameNode",table:vn.create(t),columns:e?h(e.map(Ke.create)):void 0})}});function Ko(t,e){const r=e(Yl());return jl.create(Ql(t),r.toOperationNode())}function Ql(t){if(t.includes("(")){const e=t.split(/[\(\)]/),r=e[0],n=e[1].split(",").map(A=>A.trim());return Jo.create(r,n)}else return Jo.create(t)}const Vi=h({is(t){return t.kind==="WithNode"},create(t,e){return h({kind:"WithNode",expressions:h([t]),...e})},cloneWithExpression(t,e){return h({...t,expressions:h([...t.expressions,e])})}}),Xo=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function zl(t){let e="";for(let r=0;rthis.transformNode(r)))}transformSelectQuery(e){return{kind:"SelectQueryNode",from:this.transformNode(e.from),selections:this.transformNodeList(e.selections),distinctOn:this.transformNodeList(e.distinctOn),joins:this.transformNodeList(e.joins),groupBy:this.transformNode(e.groupBy),orderBy:this.transformNode(e.orderBy),where:this.transformNode(e.where),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),limit:this.transformNode(e.limit),offset:this.transformNode(e.offset),with:this.transformNode(e.with),having:this.transformNode(e.having),explain:this.transformNode(e.explain),setOperations:this.transformNodeList(e.setOperations)}}transformSelection(e){return{kind:"SelectionNode",selection:this.transformNode(e.selection)}}transformColumn(e){return{kind:"ColumnNode",column:this.transformNode(e.column)}}transformAlias(e){return{kind:"AliasNode",node:this.transformNode(e.node),alias:this.transformNode(e.alias)}}transformTable(e){return{kind:"TableNode",table:this.transformNode(e.table)}}transformFrom(e){return{kind:"FromNode",froms:this.transformNodeList(e.froms)}}transformReference(e){return{kind:"ReferenceNode",table:this.transformNode(e.table),column:this.transformNode(e.column)}}transformAnd(e){return{kind:"AndNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformOr(e){return{kind:"OrNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformValueList(e){return{kind:"ValueListNode",values:this.transformNodeList(e.values)}}transformParens(e){return{kind:"ParensNode",node:this.transformNode(e.node)}}transformJoin(e){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table),on:this.transformNode(e.on)}}transformRaw(e){return{kind:"RawNode",sqlFragments:h([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters)}}transformWhere(e){return{kind:"WhereNode",where:this.transformNode(e.where)}}transformInsertQuery(e){return{kind:"InsertQueryNode",into:this.transformNode(e.into),columns:this.transformNodeList(e.columns),values:this.transformNode(e.values),returning:this.transformNode(e.returning),onConflict:this.transformNode(e.onConflict),onDuplicateKey:this.transformNode(e.onDuplicateKey),with:this.transformNode(e.with),ignore:e.ignore,replace:e.replace,explain:this.transformNode(e.explain)}}transformValues(e){return{kind:"ValuesNode",values:this.transformNodeList(e.values)}}transformDeleteQuery(e){return{kind:"DeleteQueryNode",from:this.transformNode(e.from),using:this.transformNode(e.using),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),returning:this.transformNode(e.returning),with:this.transformNode(e.with),orderBy:this.transformNode(e.orderBy),limit:this.transformNode(e.limit),explain:this.transformNode(e.explain)}}transformReturning(e){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections)}}transformCreateTable(e){return{kind:"CreateTableNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),constraints:this.transformNodeList(e.constraints),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers)}}transformColumnDefinition(e){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),references:this.transformNode(e.references),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo),check:this.transformNode(e.check),generated:this.transformNode(e.generated),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers)}}transformAddColumn(e){return{kind:"AddColumnNode",column:this.transformNode(e.column)}}transformDropTable(e){return{kind:"DropTableNode",table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e){return{kind:"OrderByNode",items:this.transformNodeList(e.items)}}transformOrderByItem(e){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy),direction:this.transformNode(e.direction)}}transformGroupBy(e){return{kind:"GroupByNode",items:this.transformNodeList(e.items)}}transformGroupByItem(e){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy)}}transformUpdateQuery(e){return{kind:"UpdateQueryNode",table:this.transformNode(e.table),from:this.transformNode(e.from),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),updates:this.transformNodeList(e.updates),returning:this.transformNode(e.returning),with:this.transformNode(e.with),explain:this.transformNode(e.explain)}}transformColumnUpdate(e){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column),value:this.transformNode(e.value)}}transformLimit(e){return{kind:"LimitNode",limit:this.transformNode(e.limit)}}transformOffset(e){return{kind:"OffsetNode",offset:this.transformNode(e.offset)}}transformOnConflict(e){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns),constraint:this.transformNode(e.constraint),indexExpression:this.transformNode(e.indexExpression),indexWhere:this.transformNode(e.indexWhere),updates:this.transformNodeList(e.updates),updateWhere:this.transformNode(e.updateWhere),doNothing:e.doNothing}}transformOnDuplicateKey(e){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates)}}transformCreateIndex(e){return{kind:"CreateIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists,where:this.transformNode(e.where)}}transformList(e){return{kind:"ListNode",items:this.transformNodeList(e.items)}}transformDropIndex(e){return{kind:"DropIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformUniqueConstraint(e){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformForeignKeyConstraint(e){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns),references:this.transformNode(e.references),name:this.transformNode(e.name),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformSetOperation(e){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression),all:e.all}}transformReferences(e){return{kind:"ReferencesNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression),name:this.transformNode(e.name)}}transformWith(e){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions),recursive:e.recursive}}transformCommonTableExpression(e){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name),expression:this.transformNode(e.expression)}}transformCommonTableExpressionName(e){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns)}}transformHaving(e){return{kind:"HavingNode",having:this.transformNode(e.having)}}transformCreateSchema(e){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema),ifNotExists:e.ifNotExists}}transformDropSchema(e){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e){return{kind:"AlterTableNode",table:this.transformNode(e.table),renameTo:this.transformNode(e.renameTo),setSchema:this.transformNode(e.setSchema),columnAlterations:this.transformNodeList(e.columnAlterations),addConstraint:this.transformNode(e.addConstraint),dropConstraint:this.transformNode(e.dropConstraint)}}transformDropColumn(e){return{kind:"DropColumnNode",column:this.transformNode(e.column)}}transformRenameColumn(e){return{kind:"RenameColumnNode",column:this.transformNode(e.column),renameTo:this.transformNode(e.renameTo)}}transformAlterColumn(e){return{kind:"AlterColumnNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),dataTypeExpression:this.transformNode(e.dataTypeExpression),setDefault:this.transformNode(e.setDefault),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e){return{kind:"ModifyColumnNode",column:this.transformNode(e.column)}}transformAddConstraint(e){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint)}}transformDropConstraint(e){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName),ifExists:e.ifExists,modifier:e.modifier}}transformCreateView(e){return{kind:"CreateViewNode",name:this.transformNode(e.name),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns),as:this.transformNode(e.as)}}transformDropView(e){return{kind:"DropViewNode",name:this.transformNode(e.name),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression)}}transformDefaultValue(e){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue)}}transformOn(e){return{kind:"OnNode",on:this.transformNode(e.on)}}transformSelectModifier(e){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier)}}transformCreateType(e){return{kind:"CreateTypeNode",name:this.transformNode(e.name),enum:this.transformNode(e.enum)}}transformDropType(e){return{kind:"DropTypeNode",name:this.transformNode(e.name),ifExists:e.ifExists}}transformExplain(e){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options)}}transformSchemableIdentifier(e){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema),identifier:this.transformNode(e.identifier)}}transformAggregateFunction(e){return{kind:"AggregateFunctionNode",aggregated:this.transformNodeList(e.aggregated),distinct:e.distinct,filter:this.transformNode(e.filter),func:e.func,over:this.transformNode(e.over)}}transformOver(e){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy),partitionBy:this.transformNode(e.partitionBy)}}transformPartitionBy(e){return{kind:"PartitionByNode",items:this.transformNodeList(e.items)}}transformPartitionByItem(e){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy)}}transformBinaryOperation(e){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand),operator:this.transformNode(e.operator),rightOperand:this.transformNode(e.rightOperand)}}transformUnaryOperation(e){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator),operand:this.transformNode(e.operand)}}transformUsing(e){return{kind:"UsingNode",tables:this.transformNodeList(e.tables)}}transformFunction(e){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments)}}transformCase(e){return{kind:"CaseNode",value:this.transformNode(e.value),when:this.transformNodeList(e.when),else:this.transformNode(e.else),isStatement:e.isStatement}}transformWhen(e){return{kind:"WhenNode",condition:this.transformNode(e.condition),result:this.transformNode(e.result)}}transformDataType(e){return e}transformSelectAll(e){return e}transformIdentifier(e){return e}transformValue(e){return e}transformPrimitiveValueList(e){return e}transformOperator(e){return e}transformDefaultInsertValue(e){return e}}gs=new WeakMap;const $l=h({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0});class Gl extends Xs{constructor(r){super();R(this,ws);R(this,qs);R(this,Bn);R(this,ii);R(this,bs);R(this,fr,void 0);R(this,Rn,new Set);U(this,fr,r)}transformNodeImpl(r){if(!Le(this,ws,il).call(this,r))return super.transformNodeImpl(r);const n=Le(this,qs,sl).call(this,r);for(const X of n)s(this,Rn).add(X);const A=super.transformNodeImpl(r);for(const X of n)s(this,Rn).delete(X);return A}transformSchemableIdentifier(r){const n=super.transformSchemableIdentifier(r);return n.schema||!s(this,Rn).has(r.identifier.name)?n:{...n,schema:Ge.create(s(this,fr))}}transformReferences(r){const n=super.transformReferences(r);return n.table.table.schema?n:{...n,table:vn.createWithSchema(s(this,fr),n.table.table.identifier.name)}}}fr=new WeakMap,Rn=new WeakMap,ws=new WeakSet,il=function(r){return r.kind in $l},qs=new WeakSet,sl=function(r){const n=new Set;if("name"in r&&r.name&&Nn.is(r.name)&&Le(this,ii,bo).call(this,r.name,n),"from"in r&&r.from)for(const A of r.from.froms)Le(this,Bn,Oi).call(this,A,n);if("into"in r&&r.into&&Le(this,Bn,Oi).call(this,r.into,n),"table"in r&&r.table&&Le(this,Bn,Oi).call(this,r.table,n),"joins"in r&&r.joins)for(const A of r.joins)Le(this,Bn,Oi).call(this,A.table,n);return"with"in r&&r.with&&Le(this,bs,ol).call(this,r.with,n),n},Bn=new WeakSet,Oi=function(r,n){const A=vn.is(r)?r:Pn.is(r)&&vn.is(r.node)?r.node:null;A&&Le(this,ii,bo).call(this,A.table,n)},ii=new WeakSet,bo=function(r,n){s(this,Rn).has(r.identifier.name)||n.add(r.identifier.name)},bs=new WeakSet,ol=function(r,n){for(const A of r.expressions)n.delete(A.name.table.table.identifier.name)};class Hr{constructor(e){R(this,si,void 0);U(this,si,new Gl(e))}transformQuery(e){return s(this,si).transformNode(e.node)}async transformResult(e){return e.result}}si=new WeakMap;const Mn=class{constructor(e){R(this,Re,void 0);U(this,Re,h(e))}selectFrom(e){return new ar({queryId:Ce(),executor:s(this,Re).executor,queryNode:_e.create(lr(e),s(this,Re).withNode)})}insertInto(e){return new Vr({queryId:Ce(),executor:s(this,Re).executor,queryNode:rn.create(It(e),s(this,Re).withNode)})}replaceInto(e){return new Vr({queryId:Ce(),executor:s(this,Re).executor,queryNode:rn.create(It(e),s(this,Re).withNode,!0)})}deleteFrom(e){return new Qi({queryId:Ce(),executor:s(this,Re).executor,queryNode:zr.create(lr(e),s(this,Re).withNode)})}updateTable(e){return new zi({queryId:Ce(),executor:s(this,Re).executor,queryNode:Ri.create(Gr(e),s(this,Re).withNode)})}with(e,r){const n=Ko(e,r);return new Mn({...s(this,Re),withNode:s(this,Re).withNode?Vi.cloneWithExpression(s(this,Re).withNode,n):Vi.create(n)})}withRecursive(e,r){const n=Ko(e,r);return new Mn({...s(this,Re),withNode:s(this,Re).withNode?Vi.cloneWithExpression(s(this,Re).withNode,n):Vi.create(n,{recursive:!0})})}withPlugin(e){return new Mn({...s(this,Re),executor:s(this,Re).executor.withPlugin(e)})}withoutPlugins(){return new Mn({...s(this,Re),executor:s(this,Re).executor.withoutPlugins()})}withSchema(e){return new Mn({...s(this,Re),executor:s(this,Re).executor.withPluginAtFront(new Hr(e))})}};let Hi=Mn;Re=new WeakMap;class Yo{constructor(){R(this,oi,void 0);R(this,hr,void 0);R(this,pr,void 0);Tt(this,"resolve",e=>{s(this,hr)&&s(this,hr).call(this,e)});Tt(this,"reject",e=>{s(this,pr)&&s(this,pr).call(this,e)});U(this,oi,new Promise((e,r)=>{U(this,pr,r),U(this,hr,e)}))}get promise(){return s(this,oi)}}oi=new WeakMap,hr=new WeakMap,pr=new WeakMap;const Zo=new Set;function Jl(t){Zo.has(t)||(Zo.add(t),console.log(t))}const Kl=h([]);class ea{constructor(e=Kl){R(this,ai);R(this,Un,void 0);U(this,Un,e)}get plugins(){return s(this,Un)}transformQuery(e,r){for(const n of s(this,Un)){const A=n.transformQuery({node:e,queryId:r});if(A.kind===e.kind)e=A;else throw new Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${e.kind}`,`but it returned a ${A.kind}`].join(" "))}return e}async executeQuery(e,r){return await this.provideConnection(async n=>{const A=await n.executeQuery(e),X=await Le(this,ai,No).call(this,A,r);return Xl(A,X),X})}async*stream(e,r,n){const A=new Yo,X=new Yo;this.provideConnection(async me=>(A.resolve(me),await X.promise)).catch(me=>A.reject(me));const ae=await A.promise;try{for await(const me of ae.streamQuery(e,r))yield await Le(this,ai,No).call(this,me,n)}finally{X.resolve()}}}Un=new WeakMap,ai=new WeakSet,No=async function(e,r){for(const n of s(this,Un))e=await n.transformResult({result:e,queryId:r});return e};function Xl(t,e){const{numAffectedRows:r}=t;r===void 0&&t.numUpdatedOrDeletedRows===void 0||r!==void 0&&e.numAffectedRows!==void 0||Jl("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class sr extends ea{get adapter(){throw new Error("this query cannot be compiled to SQL")}compileQuery(){throw new Error("this query cannot be compiled to SQL")}provideConnection(){throw new Error("this query cannot be executed")}withConnectionProvider(){throw new Error("this query cannot have a connection provider")}withPlugin(e){return new sr([...this.plugins,e])}withPlugins(e){return new sr([...this.plugins,...e])}withPluginAtFront(e){return new sr([e,...this.plugins])}withoutPlugins(){return new sr([])}}const $i=new sr;function ta(){return new ar({queryId:Ce(),executor:$i,queryNode:_e.create(lr([]))})}function Yl(){return new Hi({executor:$i})}function na(t,e){return new Li({joinNode:Bt.create(t,Gr(e))})}function Zl(){return new Di({overNode:Gs.create()})}const Ys=h({is(t){return t.kind==="WhenNode"},create(t){return h({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return h({...t,result:e})}}),$t=h({is(t){return t.kind==="CaseNode"},create(t){return h({kind:"CaseNode",value:t})},cloneWithWhen(t,e){return h({...t,when:h(t.when?[...t.when,e]:[e])})},cloneWithThen(t,e){return h({...t,when:t.when?h([...t.when.slice(0,-1),Ys.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return h({...t,...e})}});function Zs(t,e,r){if(!Ao(e)&&!bt(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return nu(e,r)?ru(t,e,r):Ti.create(fn(t),eo(e),Lo(r))}function eu(t,e,r){if(!Ao(e)&&!bt(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return Ti.create(fn(t),eo(e),fn(r))}function tu(t,e,r){if(!To(e)&&!bt(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return Zs(t,e,r)}function ft(t,e,r){if(!To(e)&&!bt(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return eu(t,e,r)}function Ct(t){return Gi("where",t)}function ra(t){return Gi("having",t)}function ia(t){return Gi("on",t)}function sa(t){return Gi("when",t)}function Gi(t,e){if(e.length===3)return tu(e[0],e[1],e[2]);if(e.length===1)return iu(t,e[0]);throw oa(t,e)}function nu(t,e){return(t==="is"||t==="is not")&&(So(e)||Pr(e))}function ru(t,e,r){return Ti.create(fn(t),eo(e),nn.createImmediate(r))}function eo(t){if(Ne(t)&&ql.includes(t))return zs.create(t);if(bt(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function iu(t,e){if(Rt(e)){if(t==="when")throw new Error("when method doesn't accept a callback as an argument");return su[t](e)}else if(bt(e)){const r=e.toOperationNode();if(yt.is(r)||Ti.is(r)||Bo.is(r)||nr.is(r)||$t.is(r))return r}else if(t==="when")return nn.create(e);throw oa(t,e)}function oa(t,e){return new Error(`invalid arguments passed to a '${t}' method: ${JSON.stringify(e)}`)}const su=h({where(t){const e=ta(),r=pn(),A=t(Object.assign(e,r)).toOperationNode();if(_e.is(A)){if(!A.where)throw new Error("no `where` methods called inside a group callback");return nr.create(A.where.where)}else return A},having(t){const e=ta(),r=pn(),A=t(Object.assign(e,r)).toOperationNode();if(_e.is(A)){if(!A.having)throw new Error("no `having` methods called inside a group callback");return nr.create(A.having.having)}else return A},on(t){const e=na("InnerJoin","table"),r=pn(),A=t(Object.assign(e,r)).toOperationNode();if(Bt.is(A)){if(!A.on)throw new Error("no `on` methods called inside a group callback");return nr.create(A.on.on)}else return A}});function kt(t,e){if(e.length===3)return au(t,e[0],e[1],e[2]);if(e.length===2)return ou(t,e[0],e[1]);throw new Error("not implemented")}function ou(t,e,r){return r(na(t,e)).toOperationNode()}function au(t,e,r,n){return Bt.createWithOn(t,Gr(e),ft(r,"=",n))}const lu=h({is(t){return t.kind==="OffsetNode"},create(t){return h({kind:"OffsetNode",offset:nn.create(t)})}}),uu=h({is(t){return t.kind==="GroupByItemNode"},create(t){return h({kind:"GroupByItemNode",groupBy:t})}});function cu(t){return t=Rt(t)?t(pn()):t,Mr(t).map(uu.create)}const aa=h({is(t){return t.kind==="SetOperationNode"},create(t,e,r){return h({kind:"SetOperationNode",operator:t,expression:e,all:r})}});function or(t,e,r){return aa.create(t,e.toOperationNode(),r)}const ee=class{constructor(e){R(this,F,void 0);U(this,F,h(e))}get expressionType(){}where(...e){return new ee({...s(this,F),queryNode:re.cloneWithWhere(s(this,F).queryNode,Ct(e))})}whereRef(e,r,n){return new ee({...s(this,F),queryNode:re.cloneWithWhere(s(this,F).queryNode,ft(e,r,n))})}orWhere(...e){return new ee({...s(this,F),queryNode:re.cloneWithOrWhere(s(this,F).queryNode,Ct(e))})}orWhereRef(e,r,n){return new ee({...s(this,F),queryNode:re.cloneWithOrWhere(s(this,F).queryNode,ft(e,r,n))})}whereExists(e){return new ee({...s(this,F),queryNode:re.cloneWithWhere(s(this,F).queryNode,gt(e))})}whereNotExists(e){return new ee({...s(this,F),queryNode:re.cloneWithWhere(s(this,F).queryNode,dt(e))})}orWhereExists(e){return new ee({...s(this,F),queryNode:re.cloneWithOrWhere(s(this,F).queryNode,gt(e))})}orWhereNotExists(e){return new ee({...s(this,F),queryNode:re.cloneWithOrWhere(s(this,F).queryNode,dt(e))})}having(...e){return new ee({...s(this,F),queryNode:_e.cloneWithHaving(s(this,F).queryNode,ra(e))})}havingRef(e,r,n){return new ee({...s(this,F),queryNode:_e.cloneWithHaving(s(this,F).queryNode,ft(e,r,n))})}orHaving(...e){return new ee({...s(this,F),queryNode:_e.cloneWithOrHaving(s(this,F).queryNode,ra(e))})}orHavingRef(e,r,n){return new ee({...s(this,F),queryNode:_e.cloneWithOrHaving(s(this,F).queryNode,ft(e,r,n))})}havingExists(e){return new ee({...s(this,F),queryNode:_e.cloneWithHaving(s(this,F).queryNode,gt(e))})}havingNotExist(e){return new ee({...s(this,F),queryNode:_e.cloneWithHaving(s(this,F).queryNode,dt(e))})}havingNotExists(e){return new ee({...s(this,F),queryNode:_e.cloneWithHaving(s(this,F).queryNode,dt(e))})}orHavingExists(e){return new ee({...s(this,F),queryNode:_e.cloneWithOrHaving(s(this,F).queryNode,gt(e))})}orHavingNotExists(e){return new ee({...s(this,F),queryNode:_e.cloneWithOrHaving(s(this,F).queryNode,dt(e))})}select(e){return new ee({...s(this,F),queryNode:_e.cloneWithSelections(s(this,F).queryNode,jr(e))})}distinctOn(e){return new ee({...s(this,F),queryNode:_e.cloneWithDistinctOn(s(this,F).queryNode,Mr(e))})}modifyFront(e){return new ee({...s(this,F),queryNode:_e.cloneWithFrontModifier(s(this,F).queryNode,dn.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new ee({...s(this,F),queryNode:_e.cloneWithEndModifier(s(this,F).queryNode,dn.createWithExpression(e.toOperationNode()))})}distinct(){return new ee({...s(this,F),queryNode:_e.cloneWithFrontModifier(s(this,F).queryNode,dn.create("Distinct"))})}forUpdate(){return new ee({...s(this,F),queryNode:_e.cloneWithEndModifier(s(this,F).queryNode,dn.create("ForUpdate"))})}forShare(){return new ee({...s(this,F),queryNode:_e.cloneWithEndModifier(s(this,F).queryNode,dn.create("ForShare"))})}forKeyShare(){return new ee({...s(this,F),queryNode:_e.cloneWithEndModifier(s(this,F).queryNode,dn.create("ForKeyShare"))})}forNoKeyUpdate(){return new ee({...s(this,F),queryNode:_e.cloneWithEndModifier(s(this,F).queryNode,dn.create("ForNoKeyUpdate"))})}skipLocked(){return new ee({...s(this,F),queryNode:_e.cloneWithEndModifier(s(this,F).queryNode,dn.create("SkipLocked"))})}noWait(){return new ee({...s(this,F),queryNode:_e.cloneWithEndModifier(s(this,F).queryNode,dn.create("NoWait"))})}selectAll(e){return new ee({...s(this,F),queryNode:_e.cloneWithSelections(s(this,F).queryNode,Qr(e))})}innerJoin(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,kt("InnerJoin",e))})}leftJoin(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,kt("LeftJoin",e))})}rightJoin(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,kt("RightJoin",e))})}fullJoin(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,kt("FullJoin",e))})}innerJoinLateral(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,kt("LateralInnerJoin",e))})}leftJoinLateral(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,kt("LateralLeftJoin",e))})}orderBy(e,r){return new ee({...s(this,F),queryNode:_e.cloneWithOrderByItem(s(this,F).queryNode,Wi(e,r))})}groupBy(e){return new ee({...s(this,F),queryNode:_e.cloneWithGroupByItems(s(this,F).queryNode,cu(e))})}limit(e){return new ee({...s(this,F),queryNode:_e.cloneWithLimit(s(this,F).queryNode,$o.create(e))})}offset(e){return new ee({...s(this,F),queryNode:_e.cloneWithOffset(s(this,F).queryNode,lu.create(e))})}union(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,or("union",e,!1))})}unionAll(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,or("union",e,!0))})}intersect(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,or("intersect",e,!1))})}intersectAll(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,or("intersect",e,!0))})}except(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,or("except",e,!1))})}exceptAll(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,or("except",e,!0))})}as(e){return new du(this,e)}clearSelect(){return new ee({...s(this,F),queryNode:_e.cloneWithoutSelections(s(this,F).queryNode)})}clearWhere(){return new ee({...s(this,F),queryNode:re.cloneWithoutWhere(s(this,F).queryNode)})}clearLimit(){return new ee({...s(this,F),queryNode:_e.cloneWithoutLimit(s(this,F).queryNode)})}clearOffset(){return new ee({...s(this,F),queryNode:_e.cloneWithoutOffset(s(this,F).queryNode)})}clearOrderBy(){return new ee({...s(this,F),queryNode:_e.cloneWithoutOrderBy(s(this,F).queryNode)})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new ee({...s(this,F)})}if(e,r){return this.$if(e,r)}$castTo(){return new ee(s(this,F))}castTo(){return this.$castTo()}$narrowType(){return new ee(s(this,F))}$assertType(){return new ee(s(this,F))}assertType(){return new ee(s(this,F))}withPlugin(e){return new ee({...s(this,F),executor:s(this,F).executor.withPlugin(e)})}toOperationNode(){return s(this,F).executor.transformQuery(s(this,F).queryNode,s(this,F).queryId)}compile(){return s(this,F).executor.compileQuery(this.toOperationNode(),s(this,F).queryId)}async execute(){const e=this.compile();return(await s(this,F).executor.executeQuery(e,s(this,F).queryId)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Bi){const r=await this.executeTakeFirst();if(r===void 0)throw Mi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),n=s(this,F).executor.stream(r,e,s(this,F).queryId);for await(const A of n)yield*A.rows}async explain(e,r){return await new ee({...s(this,F),queryNode:re.cloneWithExplain(s(this,F).queryNode,e,r)}).execute()}};let ar=ee;F=new WeakMap,Se(ar,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class du{constructor(e,r){R(this,_r,void 0);R(this,mr,void 0);U(this,_r,e),U(this,mr,r)}get expression(){return s(this,_r)}get alias(){return s(this,mr)}toOperationNode(){return Pn.create(s(this,_r).toOperationNode(),Ge.create(s(this,mr)))}}_r=new WeakMap,mr=new WeakMap;const lo=class{constructor(e){R(this,yr,void 0);U(this,yr,e)}get expressionType(){}as(e){return new fu(this,e)}$castTo(){return new lo(s(this,yr))}toOperationNode(){return s(this,yr)}};let st=lo;yr=new WeakMap;class fu{constructor(e,r){R(this,gr,void 0);R(this,kn,void 0);U(this,gr,e),U(this,kn,r)}get expression(){return s(this,gr)}get alias(){return s(this,kn)}toOperationNode(){return Pn.create(s(this,gr).toOperationNode(),bt(s(this,kn))?s(this,kn).toOperationNode():Ge.create(s(this,kn)))}}gr=new WeakMap,kn=new WeakMap;const Mt=h({is(t){return t.kind==="AggregateFunctionNode"},create(t,e=[]){return h({kind:"AggregateFunctionNode",func:t,aggregated:e})},cloneWithDistinct(t){return h({...t,distinct:!0})},cloneWithFilter(t,e){return h({...t,filter:t.filter?wt.cloneWithOperation(t.filter,"And",e):wt.create(e)})},cloneWithOrFilter(t,e){return h({...t,filter:t.filter?wt.cloneWithOperation(t.filter,"Or",e):wt.create(e)})},cloneWithOver(t,e){return h({...t,over:e})}}),hu=h({is(t){return t.kind==="FunctionNode"},create(t,e){return h({kind:"FunctionNode",func:t,arguments:e})}}),Ut=class{constructor(e){R(this,Ue,void 0);U(this,Ue,h(e))}get expressionType(){}as(e){return new pu(this,e)}distinct(){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithDistinct(s(this,Ue).aggregateFunctionNode)})}filterWhere(...e){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithFilter(s(this,Ue).aggregateFunctionNode,Ct(e))})}filterWhereExists(e){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithFilter(s(this,Ue).aggregateFunctionNode,gt(e))})}filterWhereNotExists(e){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithFilter(s(this,Ue).aggregateFunctionNode,dt(e))})}filterWhereRef(e,r,n){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithFilter(s(this,Ue).aggregateFunctionNode,ft(e,r,n))})}orFilterWhere(...e){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithOrFilter(s(this,Ue).aggregateFunctionNode,Ct(e))})}orFilterWhereExists(e){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithOrFilter(s(this,Ue).aggregateFunctionNode,gt(e))})}orFilterWhereNotExists(e){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithOrFilter(s(this,Ue).aggregateFunctionNode,dt(e))})}orFilterWhereRef(e,r,n){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithOrFilter(s(this,Ue).aggregateFunctionNode,ft(e,r,n))})}over(e){const r=Zl();return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithOver(s(this,Ue).aggregateFunctionNode,(e?e(r):r).toOperationNode())})}$call(e){return e(this)}toOperationNode(){return s(this,Ue).aggregateFunctionNode}};let $r=Ut;Ue=new WeakMap,Se($r,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");class pu{constructor(e,r){R(this,wr,void 0);R(this,qr,void 0);U(this,wr,e),U(this,qr,r)}get expression(){return s(this,wr)}get alias(){return s(this,qr)}toOperationNode(){return Pn.create(s(this,wr).toOperationNode(),Ge.create(s(this,qr)))}}wr=new WeakMap,qr=new WeakMap;function la(){const t=(r,n)=>new st(hu.create(r,Mr(n))),e=(r,n)=>new $r({aggregateFunctionNode:Mt.create(r,n?Mr(n):void 0)});return Object.assign(t,{agg:e,avg(r){return e("avg",[r])},coalesce(r,...n){return t("coalesce",[r,...n])},count(r){return e("count",[r])},countAll(r){return new $r({aggregateFunctionNode:Mt.create("count",Qr(r))})},max(r){return e("max",[r])},min(r){return e("min",[r])},sum(r){return e("sum",[r])}})}class ua{constructor(e){R(this,br,void 0);U(this,br,h(e))}when(...e){return new ca({...s(this,br),node:$t.cloneWithWhen(s(this,br).node,Ys.create(sa(e)))})}}br=new WeakMap;class ca{constructor(e){R(this,Nr,void 0);U(this,Nr,h(e))}then(e){return new _u({...s(this,Nr),node:$t.cloneWithThen(s(this,Nr).node,hn(e))})}}Nr=new WeakMap;class _u{constructor(e){R(this,sn,void 0);U(this,sn,h(e))}when(...e){return new ca({...s(this,sn),node:$t.cloneWithWhen(s(this,sn).node,Ys.create(sa(e)))})}else(e){return new mu({...s(this,sn),node:$t.cloneWith(s(this,sn).node,{else:hn(e)})})}end(){return new st($t.cloneWith(s(this,sn).node,{isStatement:!1}))}endCase(){return new st($t.cloneWith(s(this,sn).node,{isStatement:!0}))}}sn=new WeakMap;class mu{constructor(e){R(this,vr,void 0);U(this,vr,h(e))}end(){return new st($t.cloneWith(s(this,vr).node,{isStatement:!1}))}endCase(){return new st($t.cloneWith(s(this,vr).node,{isStatement:!0}))}}vr=new WeakMap;function da(t=$i){function e(r,n){return new st(Js(r,n))}return{get fn(){return la()},selectFrom(r){return new ar({queryId:Ce(),executor:t,queryNode:_e.create(lr(r))})},case(r){return new ua({node:$t.create(Te(r)?void 0:fn(r))})},ref(r){return new st(rr(r))},val(r){return new st(Lo(r))},cmpr(r,n,A){return new st(Zs(r,n,A))},bxp(r,n,A){return new st(Zs(r,n,A))},unary:e,not(r){return e("not",r)},exists(r){return e("exists",r)},neg(r){return e("-",r)},and(r){if(r.length===0)return new st(nn.createImmediate(!0));if(r.length===1)return new st(r[0].toOperationNode());let n=Dr.create(r[0].toOperationNode(),r[1].toOperationNode());for(let A=2;AGr(e)):[Gr(t)]}function Gr(t){return Ne(t)?yu(t):fa(t)}function yu(t){const e=" as ";if(t.includes(e)){const[r,n]=t.split(e).map(ha);return Pn.create(It(r),Ge.create(n))}else return It(t)}function It(t){const e=".";if(t.includes(e)){const[r,n]=t.split(e).map(ha);return vn.createWithSchema(r,n)}else return vn.create(t)}function ha(t){return t.trim()}const pa=h({is(t){return t.kind==="AddColumnNode"},create(t){return h({kind:"AddColumnNode",column:t})}}),Ln=h({is(t){return t.kind==="AlterColumnNode"},create(t){return h({kind:"AlterColumnNode",column:Ke.create(t)})},cloneWith(t,e){return h({...t,...e})}}),Xe=h({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return h({kind:"ColumnDefinitionNode",column:Ke.create(t),dataType:e})},cloneWithFrontModifier(t,e){return h({...t,frontModifiers:t.frontModifiers?h([...t.frontModifiers,e]):[e]})},cloneWithEndModifier(t,e){return h({...t,endModifiers:t.endModifiers?h([...t.endModifiers,e]):[e]})},cloneWith(t,e){return h({...t,...e})}}),_a=h({is(t){return t.kind==="DropColumnNode"},create(t){return h({kind:"DropColumnNode",column:Ke.create(t)})}}),ma=h({is(t){return t.kind==="RenameColumnNode"},create(t,e){return h({kind:"RenameColumnNode",column:Ke.create(t),renameTo:Ke.create(e)})}}),to=h({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return h({kind:"CheckConstraintNode",expression:t,name:e?Ge.create(e):void 0})}}),gu=["no action","restrict","cascade","set null","set default"],Xi=h({is(t){return t.kind==="ReferencesNode"},create(t,e){return h({kind:"ReferencesNode",table:t,columns:h([...e])})},cloneWithOnDelete(t,e){return h({...t,onDelete:e})},cloneWithOnUpdate(t,e){return h({...t,onUpdate:e})}});function ya(t){return bt(t)?t.toOperationNode():nn.createImmediate(t)}const Yi=h({is(t){return t.kind==="GeneratedNode"},create(t){return h({kind:"GeneratedNode",...t})},createWithExpression(t){return h({kind:"GeneratedNode",always:!0,expression:t})},cloneWith(t,e){return h({...t,...e})}}),wu=h({is(t){return t.kind==="DefaultValueNode"},create(t){return h({kind:"DefaultValueNode",defaultValue:t})}});function Zi(t){if(gu.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}const at=class{constructor(e){R(this,Fe,void 0);U(this,Fe,e)}autoIncrement(){return new at(Xe.cloneWith(s(this,Fe),{autoIncrement:!0}))}primaryKey(){return new at(Xe.cloneWith(s(this,Fe),{primaryKey:!0}))}references(e){const r=rr(e);if(!Ci.is(r)||Vs.is(r.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new at(Xe.cloneWith(s(this,Fe),{references:Xi.create(r.table,[r.column])}))}onDelete(e){if(!s(this,Fe).references)throw new Error("on delete constraint can only be added for foreign keys");return new at(Xe.cloneWith(s(this,Fe),{references:Xi.cloneWithOnDelete(s(this,Fe).references,Zi(e))}))}onUpdate(e){if(!s(this,Fe).references)throw new Error("on update constraint can only be added for foreign keys");return new at(Xe.cloneWith(s(this,Fe),{references:Xi.cloneWithOnUpdate(s(this,Fe).references,Zi(e))}))}unique(){return new at(Xe.cloneWith(s(this,Fe),{unique:!0}))}notNull(){return new at(Xe.cloneWith(s(this,Fe),{notNull:!0}))}unsigned(){return new at(Xe.cloneWith(s(this,Fe),{unsigned:!0}))}defaultTo(e){return new at(Xe.cloneWith(s(this,Fe),{defaultTo:wu.create(ya(e))}))}check(e){return new at(Xe.cloneWith(s(this,Fe),{check:to.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new at(Xe.cloneWith(s(this,Fe),{generated:Yi.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new at(Xe.cloneWith(s(this,Fe),{generated:Yi.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new at(Xe.cloneWith(s(this,Fe),{generated:Yi.create({identity:!0,byDefault:!0})}))}stored(){if(!s(this,Fe).generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new at(Xe.cloneWith(s(this,Fe),{generated:Yi.cloneWith(s(this,Fe).generated,{stored:!0})}))}modifyFront(e){return new at(Xe.cloneWithFrontModifier(s(this,Fe),e.toOperationNode()))}modifyEnd(e){return new at(Xe.cloneWithEndModifier(s(this,Fe),e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return s(this,Fe)}};let xn=at;Fe=new WeakMap,Se(xn,"don't await ColumnDefinitionBuilder instances directly.");const ga=h({is(t){return t.kind==="ModifyColumnNode"},create(t){return h({kind:"ModifyColumnNode",column:t})}}),qu=h({is(t){return t.kind==="DataTypeNode"},create(t){return h({kind:"DataTypeNode",dataType:t})}});function ur(t){return bt(t)?t.toOperationNode():qu.create(t)}const es=h({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,r,n){return h({kind:"ForeignKeyConstraintNode",columns:t,references:Xi.create(e,r),name:n?Ge.create(n):void 0})},cloneWith(t,e){return h({...t,...e})}}),Ns=class{constructor(e){R(this,jn,void 0);U(this,jn,e)}onDelete(e){return new Ns(es.cloneWith(s(this,jn),{onDelete:Zi(e)}))}onUpdate(e){return new Ns(es.cloneWith(s(this,jn),{onUpdate:Zi(e)}))}$call(e){return e(this)}toOperationNode(){return s(this,jn)}};let Jr=Ns;jn=new WeakMap,Se(Jr,"don't await ForeignKeyConstraintBuilder instances directly.");const no=h({is(t){return t.kind==="AddConstraintNode"},create(t){return h({kind:"AddConstraintNode",constraint:t})}}),wa=h({is(t){return t.kind==="UniqueConstraintNode"},create(t,e){return h({kind:"UniqueConstraintNode",columns:h(t.map(Ke.create)),name:e?Ge.create(e):void 0})}}),ts=h({is(t){return t.kind==="DropConstraintNode"},create(t){return h({kind:"DropConstraintNode",constraintName:Ge.create(t)})},cloneWith(t,e){return h({...t,...e})}});class ns{constructor(e){Tt(this,"alterColumnNode");this.alterColumnNode=e}setDataType(e){return new Kr(Ln.cloneWith(this.alterColumnNode,{dataType:ur(e)}))}setDefault(e){return new Kr(Ln.cloneWith(this.alterColumnNode,{setDefault:ya(e)}))}dropDefault(){return new Kr(Ln.cloneWith(this.alterColumnNode,{dropDefault:!0}))}setNotNull(){return new Kr(Ln.cloneWith(this.alterColumnNode,{setNotNull:!0}))}dropNotNull(){return new Kr(Ln.cloneWith(this.alterColumnNode,{dropNotNull:!0}))}$call(e){return e(this)}}class Kr extends ns{toOperationNode(){return this.alterColumnNode}}class Xr{constructor(e){R(this,Xt,void 0);U(this,Xt,h(e))}toOperationNode(){return s(this,Xt).executor.transformQuery(s(this,Xt).node,s(this,Xt).queryId)}compile(){return s(this,Xt).executor.compileQuery(this.toOperationNode(),s(this,Xt).queryId)}async execute(){await s(this,Xt).executor.executeQuery(this.compile(),s(this,Xt).queryId)}}Xt=new WeakMap,Se(Xr,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");const vs=class{constructor(e){R(this,qt,void 0);U(this,qt,h(e))}onDelete(e){return new vs({...s(this,qt),constraintBuilder:s(this,qt).constraintBuilder.onDelete(e)})}onUpdate(e){return new vs({...s(this,qt),constraintBuilder:s(this,qt).constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return s(this,qt).executor.transformQuery(et.cloneWithTableProps(s(this,qt).node,{addConstraint:no.create(s(this,qt).constraintBuilder.toOperationNode())}),s(this,qt).queryId)}compile(){return s(this,qt).executor.compileQuery(this.toOperationNode(),s(this,qt).queryId)}async execute(){await s(this,qt).executor.executeQuery(this.compile(),s(this,qt).queryId)}};let rs=vs;qt=new WeakMap,Se(rs,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");const li=class{constructor(e){R(this,tt,void 0);U(this,tt,h(e))}ifExists(){return new li({...s(this,tt),node:et.cloneWithTableProps(s(this,tt).node,{dropConstraint:ts.cloneWith(s(this,tt).node.dropConstraint,{ifExists:!0})})})}cascade(){return new li({...s(this,tt),node:et.cloneWithTableProps(s(this,tt).node,{dropConstraint:ts.cloneWith(s(this,tt).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new li({...s(this,tt),node:et.cloneWithTableProps(s(this,tt).node,{dropConstraint:ts.cloneWith(s(this,tt).node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return s(this,tt).executor.transformQuery(s(this,tt).node,s(this,tt).queryId)}compile(){return s(this,tt).executor.compileQuery(this.toOperationNode(),s(this,tt).queryId)}async execute(){await s(this,tt).executor.executeQuery(this.compile(),s(this,tt).queryId)}};let is=li;tt=new WeakMap,Se(is,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");class qa{constructor(e){R(this,je,void 0);U(this,je,h(e))}renameTo(e){return new Xr({...s(this,je),node:et.cloneWithTableProps(s(this,je).node,{renameTo:It(e)})})}setSchema(e){return new Xr({...s(this,je),node:et.cloneWithTableProps(s(this,je).node,{setSchema:Ge.create(e)})})}alterColumn(e,r){const n=r(new ns(Ln.create(e)));return new En({...s(this,je),node:et.cloneWithColumnAlteration(s(this,je).node,n.toOperationNode())})}dropColumn(e){return new En({...s(this,je),node:et.cloneWithColumnAlteration(s(this,je).node,_a.create(e))})}renameColumn(e,r){return new En({...s(this,je),node:et.cloneWithColumnAlteration(s(this,je).node,ma.create(e,r))})}addColumn(e,r,n=tr){const A=n(new xn(Xe.create(e,ur(r))));return new En({...s(this,je),node:et.cloneWithColumnAlteration(s(this,je).node,pa.create(A.toOperationNode()))})}modifyColumn(e,r,n=tr){const A=n(new xn(Xe.create(e,ur(r))));return new En({...s(this,je),node:et.cloneWithColumnAlteration(s(this,je).node,ga.create(A.toOperationNode()))})}addUniqueConstraint(e,r){return new Xr({...s(this,je),node:et.cloneWithTableProps(s(this,je).node,{addConstraint:no.create(wa.create(r,e))})})}addCheckConstraint(e,r){return new Xr({...s(this,je),node:et.cloneWithTableProps(s(this,je).node,{addConstraint:no.create(to.create(r.toOperationNode(),e))})})}addForeignKeyConstraint(e,r,n,A){return new rs({...s(this,je),constraintBuilder:new Jr(es.create(r.map(Ke.create),It(n),A.map(Ke.create),e))})}dropConstraint(e){return new is({...s(this,je),node:et.cloneWithTableProps(s(this,je).node,{dropConstraint:ts.create(e)})})}$call(e){return e(this)}call(e){return this.$call(e)}}je=new WeakMap;const Qn=class{constructor(e){R(this,Ye,void 0);U(this,Ye,h(e))}alterColumn(e,r){const n=r(new ns(Ln.create(e)));return new Qn({...s(this,Ye),node:et.cloneWithColumnAlteration(s(this,Ye).node,n.toOperationNode())})}dropColumn(e){return new Qn({...s(this,Ye),node:et.cloneWithColumnAlteration(s(this,Ye).node,_a.create(e))})}renameColumn(e,r){return new Qn({...s(this,Ye),node:et.cloneWithColumnAlteration(s(this,Ye).node,ma.create(e,r))})}addColumn(e,r,n=tr){const A=n(new xn(Xe.create(e,ur(r))));return new Qn({...s(this,Ye),node:et.cloneWithColumnAlteration(s(this,Ye).node,pa.create(A.toOperationNode()))})}modifyColumn(e,r,n=tr){const A=n(new xn(Xe.create(e,ur(r))));return new Qn({...s(this,Ye),node:et.cloneWithColumnAlteration(s(this,Ye).node,ga.create(A.toOperationNode()))})}toOperationNode(){return s(this,Ye).executor.transformQuery(s(this,Ye).node,s(this,Ye).queryId)}compile(){return s(this,Ye).executor.compileQuery(this.toOperationNode(),s(this,Ye).queryId)}async execute(){await s(this,Ye).executor.executeQuery(this.compile(),s(this,Ye).queryId)}};let En=Qn;Ye=new WeakMap,Se(qa,"don't await AlterTableBuilder instances"),Se(ns,"don't await AlterColumnBuilder instances"),Se(En,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class ba extends Xs{transformValue(e){return{...super.transformValue(e),immediate:!0}}}const on=class{constructor(e){R(this,Pe,void 0);U(this,Pe,h(e))}ifNotExists(){return new on({...s(this,Pe),node:bn.cloneWith(s(this,Pe).node,{ifNotExists:!0})})}unique(){return new on({...s(this,Pe),node:bn.cloneWith(s(this,Pe).node,{unique:!0})})}on(e){return new on({...s(this,Pe),node:bn.cloneWith(s(this,Pe).node,{table:It(e)})})}column(e){return new on({...s(this,Pe),node:bn.cloneWithColumns(s(this,Pe).node,[Fo(e)])})}columns(e){return new on({...s(this,Pe),node:bn.cloneWithColumns(s(this,Pe).node,e.map(Fo))})}expression(e){return new on({...s(this,Pe),node:bn.cloneWithColumns(s(this,Pe).node,[e.toOperationNode()])})}using(e){return new on({...s(this,Pe),node:bn.cloneWith(s(this,Pe).node,{using:yt.createWithSql(e)})})}where(...e){const r=new ba;return new on({...s(this,Pe),node:re.cloneWithWhere(s(this,Pe).node,r.transformNode(Ct(e)))})}$call(e){return e(this)}toOperationNode(){return s(this,Pe).executor.transformQuery(s(this,Pe).node,s(this,Pe).queryId)}compile(){return s(this,Pe).executor.compileQuery(this.toOperationNode(),s(this,Pe).queryId)}async execute(){await s(this,Pe).executor.executeQuery(this.compile(),s(this,Pe).queryId)}};let ss=on;Pe=new WeakMap,Se(ss,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");const uo=class{constructor(e){R(this,Ft,void 0);U(this,Ft,h(e))}ifNotExists(){return new uo({...s(this,Ft),node:ko.cloneWith(s(this,Ft).node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return s(this,Ft).executor.transformQuery(s(this,Ft).node,s(this,Ft).queryId)}compile(){return s(this,Ft).executor.compileQuery(this.toOperationNode(),s(this,Ft).queryId)}async execute(){await s(this,Ft).executor.executeQuery(this.compile(),s(this,Ft).queryId)}};let os=uo;Ft=new WeakMap,Se(os,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");const bu=h({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return h({kind:"PrimaryKeyConstraintNode",columns:h(t.map(Ke.create)),name:e?Ge.create(e):void 0})}});function Nu(t){if(_l.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}const jt=class{constructor(e){R(this,ke,void 0);U(this,ke,h(e))}temporary(){return new jt({...s(this,ke),node:Ht.cloneWith(s(this,ke).node,{temporary:!0})})}onCommit(e){return new jt({...s(this,ke),node:Ht.cloneWith(s(this,ke).node,{onCommit:Nu(e)})})}ifNotExists(){return new jt({...s(this,ke),node:Ht.cloneWith(s(this,ke).node,{ifNotExists:!0})})}addColumn(e,r,n=tr){const A=n(new xn(Xe.create(e,ur(r))));return new jt({...s(this,ke),node:Ht.cloneWithColumn(s(this,ke).node,A.toOperationNode())})}addPrimaryKeyConstraint(e,r){return new jt({...s(this,ke),node:Ht.cloneWithConstraint(s(this,ke).node,bu.create(r,e))})}addUniqueConstraint(e,r){return new jt({...s(this,ke),node:Ht.cloneWithConstraint(s(this,ke).node,wa.create(r,e))})}addCheckConstraint(e,r){return new jt({...s(this,ke),node:Ht.cloneWithConstraint(s(this,ke).node,to.create(r.toOperationNode(),e))})}addForeignKeyConstraint(e,r,n,A,X=tr){const ae=X(new Jr(es.create(r.map(Ke.create),It(n),A.map(Ke.create),e)));return new jt({...s(this,ke),node:Ht.cloneWithConstraint(s(this,ke).node,ae.toOperationNode())})}modifyFront(e){return new jt({...s(this,ke),node:Ht.cloneWithFrontModifier(s(this,ke).node,e.toOperationNode())})}modifyEnd(e){return new jt({...s(this,ke),node:Ht.cloneWithEndModifier(s(this,ke).node,e.toOperationNode())})}$call(e){return e(this)}call(e){return this.$call(e)}toOperationNode(){return s(this,ke).executor.transformQuery(s(this,ke).node,s(this,ke).queryId)}compile(){return s(this,ke).executor.compileQuery(this.toOperationNode(),s(this,ke).queryId)}async execute(){await s(this,ke).executor.executeQuery(this.compile(),s(this,ke).queryId)}};let as=jt;ke=new WeakMap,Se(as,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");const ui=class{constructor(e){R(this,ht,void 0);U(this,ht,h(e))}on(e){return new ui({...s(this,ht),node:Ai.cloneWith(s(this,ht).node,{table:It(e)})})}ifExists(){return new ui({...s(this,ht),node:Ai.cloneWith(s(this,ht).node,{ifExists:!0})})}cascade(){return new ui({...s(this,ht),node:Ai.cloneWith(s(this,ht).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return s(this,ht).executor.transformQuery(s(this,ht).node,s(this,ht).queryId)}compile(){return s(this,ht).executor.compileQuery(this.toOperationNode(),s(this,ht).queryId)}async execute(){await s(this,ht).executor.executeQuery(this.compile(),s(this,ht).queryId)}};let ls=ui;ht=new WeakMap,Se(ls,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");const xs=class{constructor(e){R(this,vt,void 0);U(this,vt,h(e))}ifExists(){return new xs({...s(this,vt),node:js.cloneWith(s(this,vt).node,{ifExists:!0})})}cascade(){return new xs({...s(this,vt),node:js.cloneWith(s(this,vt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return s(this,vt).executor.transformQuery(s(this,vt).node,s(this,vt).queryId)}compile(){return s(this,vt).executor.compileQuery(this.toOperationNode(),s(this,vt).queryId)}async execute(){await s(this,vt).executor.executeQuery(this.compile(),s(this,vt).queryId)}};let us=xs;vt=new WeakMap,Se(us,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");const Es=class{constructor(e){R(this,xt,void 0);U(this,xt,h(e))}ifExists(){return new Es({...s(this,xt),node:Qs.cloneWith(s(this,xt).node,{ifExists:!0})})}cascade(){return new Es({...s(this,xt),node:Qs.cloneWith(s(this,xt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return s(this,xt).executor.transformQuery(s(this,xt).node,s(this,xt).queryId)}compile(){return s(this,xt).executor.compileQuery(this.toOperationNode(),s(this,xt).queryId)}async execute(){await s(this,xt).executor.executeQuery(this.compile(),s(this,xt).queryId)}};let cs=Es;xt=new WeakMap,Se(cs,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");const Sn=h({is(t){return t.kind==="CreateViewNode"},create(t){return h({kind:"CreateViewNode",name:Nn.create(t)})},cloneWith(t,e){return h({...t,...e})}});class vu{constructor(){R(this,Ss,new ba)}transformQuery(e){return s(this,Ss).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}Ss=new WeakMap;const In=class{constructor(e){R(this,He,void 0);U(this,He,h(e))}temporary(){return new In({...s(this,He),node:Sn.cloneWith(s(this,He).node,{temporary:!0})})}materialized(){return new In({...s(this,He),node:Sn.cloneWith(s(this,He).node,{materialized:!0})})}ifNotExists(){return new In({...s(this,He),node:Sn.cloneWith(s(this,He).node,{ifNotExists:!0})})}orReplace(){return new In({...s(this,He),node:Sn.cloneWith(s(this,He).node,{orReplace:!0})})}columns(e){return new In({...s(this,He),node:Sn.cloneWith(s(this,He).node,{columns:e.map(Wo)})})}as(e){const r=e.withPlugin(new vu).toOperationNode();return new In({...s(this,He),node:Sn.cloneWith(s(this,He).node,{as:r})})}$call(e){return e(this)}toOperationNode(){return s(this,He).executor.transformQuery(s(this,He).node,s(this,He).queryId)}compile(){return s(this,He).executor.compileQuery(this.toOperationNode(),s(this,He).queryId)}async execute(){await s(this,He).executor.executeQuery(this.compile(),s(this,He).queryId)}};let ds=In;He=new WeakMap,Se(ds,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const fs=h({is(t){return t.kind==="DropViewNode"},create(t){return h({kind:"DropViewNode",name:Nn.create(t)})},cloneWith(t,e){return h({...t,...e})}}),ci=class{constructor(e){R(this,pt,void 0);U(this,pt,h(e))}materialized(){return new ci({...s(this,pt),node:fs.cloneWith(s(this,pt).node,{materialized:!0})})}ifExists(){return new ci({...s(this,pt),node:fs.cloneWith(s(this,pt).node,{ifExists:!0})})}cascade(){return new ci({...s(this,pt),node:fs.cloneWith(s(this,pt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return s(this,pt).executor.transformQuery(s(this,pt).node,s(this,pt).queryId)}compile(){return s(this,pt).executor.compileQuery(this.toOperationNode(),s(this,pt).queryId)}async execute(){await s(this,pt).executor.executeQuery(this.compile(),s(this,pt).queryId)}};let hs=ci;pt=new WeakMap,Se(hs,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const Na=h({is(t){return t.kind==="CreateTypeNode"},create(t){return h({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return h({...t,enum:$s.create(e.map(r=>nn.createImmediate(r)))})}}),co=class{constructor(e){R(this,Pt,void 0);U(this,Pt,h(e))}toOperationNode(){return s(this,Pt).executor.transformQuery(s(this,Pt).node,s(this,Pt).queryId)}asEnum(e){return new co({...s(this,Pt),node:Na.cloneWithEnum(s(this,Pt).node,e)})}$call(e){return e(this)}compile(){return s(this,Pt).executor.compileQuery(this.toOperationNode(),s(this,Pt).queryId)}async execute(){await s(this,Pt).executor.executeQuery(this.compile(),s(this,Pt).queryId)}};let ps=co;Pt=new WeakMap,Se(ps,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const va=h({is(t){return t.kind==="DropTypeNode"},create(t){return h({kind:"DropTypeNode",name:t})},cloneWith(t,e){return h({...t,...e})}}),fo=class{constructor(e){R(this,Lt,void 0);U(this,Lt,h(e))}ifExists(){return new fo({...s(this,Lt),node:va.cloneWith(s(this,Lt).node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return s(this,Lt).executor.transformQuery(s(this,Lt).node,s(this,Lt).queryId)}compile(){return s(this,Lt).executor.compileQuery(this.toOperationNode(),s(this,Lt).queryId)}async execute(){await s(this,Lt).executor.executeQuery(this.compile(),s(this,Lt).queryId)}};let _s=fo;Lt=new WeakMap,Se(_s,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function xa(t){const e=".";if(t.includes(e)){const r=t.split(e).map(xu);if(r.length===2)return Nn.createWithSchema(r[0],r[1]);throw new Error(`invalid schemable identifier ${t}`)}else return Nn.create(t)}function xu(t){return t.trim()}const di=class{constructor(e){R(this,lt,void 0);U(this,lt,e)}createTable(e){return new as({queryId:Ce(),executor:s(this,lt),node:Ht.create(It(e))})}dropTable(e){return new cs({queryId:Ce(),executor:s(this,lt),node:Qs.create(It(e))})}createIndex(e){return new ss({queryId:Ce(),executor:s(this,lt),node:bn.create(e)})}dropIndex(e){return new ls({queryId:Ce(),executor:s(this,lt),node:Ai.create(e)})}createSchema(e){return new os({queryId:Ce(),executor:s(this,lt),node:ko.create(e)})}dropSchema(e){return new us({queryId:Ce(),executor:s(this,lt),node:js.create(e)})}alterTable(e){return new qa({queryId:Ce(),executor:s(this,lt),node:et.create(It(e))})}createView(e){return new ds({queryId:Ce(),executor:s(this,lt),node:Sn.create(e)})}dropView(e){return new hs({queryId:Ce(),executor:s(this,lt),node:fs.create(e)})}createType(e){return new ps({queryId:Ce(),executor:s(this,lt),node:Na.create(xa(e))})}dropType(e){return new _s({queryId:Ce(),executor:s(this,lt),node:va.create(xa(e))})}withPlugin(e){return new di(s(this,lt).withPlugin(e))}withoutPlugins(){return new di(s(this,lt).withoutPlugins())}withSchema(e){return new di(s(this,lt).withPluginAtFront(new Hr(e)))}};let ro=di;lt=new WeakMap;class Eu{ref(e){return new Tl(e)}}class Su{constructor(e){R(this,xr,void 0);U(this,xr,e)}async provideConnection(e){const r=await s(this,xr).acquireConnection();try{return await e(r)}finally{await s(this,xr).releaseConnection(r)}}}xr=new WeakMap;const zn=class extends ea{constructor(r,n,A,X=[]){super(X);R(this,an,void 0);R(this,ln,void 0);R(this,_n,void 0);U(this,an,r),U(this,ln,n),U(this,_n,A)}get adapter(){return s(this,ln)}compileQuery(r){return s(this,an).compileQuery(r)}provideConnection(r){return s(this,_n).provideConnection(r)}withPlugins(r){return new zn(s(this,an),s(this,ln),s(this,_n),[...this.plugins,...r])}withPlugin(r){return new zn(s(this,an),s(this,ln),s(this,_n),[...this.plugins,r])}withPluginAtFront(r){return new zn(s(this,an),s(this,ln),s(this,_n),[r,...this.plugins])}withConnectionProvider(r){return new zn(s(this,an),s(this,ln),r,[...this.plugins])}withoutPlugins(){return new zn(s(this,an),s(this,ln),s(this,_n),[])}};let io=zn;an=new WeakMap,ln=new WeakMap,_n=new WeakMap;function Ea(){return typeof performance<"u"&&Rt(performance.now)?performance.now():Date.now()}class ku{constructor(e,r){R(this,ks);R(this,Is);R(this,Os);R(this,As);R(this,hi);R(this,Yt,void 0);R(this,On,void 0);R(this,mn,void 0);R(this,Vn,void 0);R(this,fi,new WeakSet);U(this,Yt,e),U(this,On,r)}async init(){s(this,mn)||U(this,mn,s(this,Yt).init().catch(e=>(U(this,mn,void 0),Promise.reject(e)))),await s(this,mn)}async acquireConnection(){await this.init();const e=await s(this,Yt).acquireConnection();return s(this,fi).has(e)||(Le(this,ks,al).call(this)&&Le(this,Is,ll).call(this,e),s(this,fi).add(e)),e}async releaseConnection(e){await s(this,Yt).releaseConnection(e)}beginTransaction(e,r){return s(this,Yt).beginTransaction(e,r)}commitTransaction(e){return s(this,Yt).commitTransaction(e)}rollbackTransaction(e){return s(this,Yt).rollbackTransaction(e)}async destroy(){s(this,mn)&&(await s(this,mn),s(this,Vn)||U(this,Vn,s(this,Yt).destroy().catch(e=>(U(this,Vn,void 0),Promise.reject(e)))),await s(this,Vn))}}Yt=new WeakMap,On=new WeakMap,mn=new WeakMap,Vn=new WeakMap,fi=new WeakMap,ks=new WeakSet,al=function(){return s(this,On).isLevelEnabled("query")||s(this,On).isLevelEnabled("error")},Is=new WeakSet,ll=function(e){const r=e.executeQuery;e.executeQuery=async n=>{const A=Ea();try{return await r.call(e,n)}catch(X){throw await Le(this,Os,ul).call(this,X,n,A),X}finally{await Le(this,As,cl).call(this,n,A)}}},Os=new WeakSet,ul=async function(e,r,n){await s(this,On).error(()=>({level:"error",error:e,query:r,queryDurationMillis:Le(this,hi,vo).call(this,n)}))},As=new WeakSet,cl=async function(e,r){await s(this,On).query(()=>({level:"query",query:e,queryDurationMillis:Le(this,hi,vo).call(this,r)}))},hi=new WeakSet,vo=function(e){return Ea()-e};class Sa{constructor(e){R(this,Ts);R(this,pi,void 0);R(this,An,void 0);U(this,pi,e)}async provideConnection(e){for(;s(this,An);)await s(this,An);const r=Le(this,Ts,dl).call(this,e);return U(this,An,r.then(()=>{U(this,An,void 0)}).catch(()=>{U(this,An,void 0)})),r}}pi=new WeakMap,An=new WeakMap,Ts=new WeakSet,dl=async function(e){return await e(s(this,pi))};const Iu=["read uncommitted","read committed","repeatable read","serializable"];h(["query","error"]);class Ou{constructor(e){R(this,Tn,void 0);R(this,Hn,void 0);Rt(e)?(U(this,Hn,e),U(this,Tn,h({query:!0,error:!0}))):(U(this,Hn,Au),U(this,Tn,h({query:e.includes("query"),error:e.includes("error")})))}isLevelEnabled(e){return s(this,Tn)[e]}async query(e){s(this,Tn).query&&await s(this,Hn).call(this,e())}async error(e){s(this,Tn).error&&await s(this,Hn).call(this,e())}}Tn=new WeakMap,Hn=new WeakMap;function Au(t){t.level==="query"?(console.log(`kysely:query: ${t.query.sql}`),console.log(`kysely:query: duration: ${t.queryDurationMillis.toFixed(1)}ms`)):t.level==="error"&&(t.error instanceof Error?console.error(`kysely:error: ${t.error.stack??t.error.message}`):console.error(`kysely:error: ${t}`))}function Tu(t){return tn(t)&&Rt(t.compile)}const Er=class extends Hi{constructor(r){let n,A;if(Cu(r))n={executor:r.executor},A={...r};else{const X=r.dialect,ae=X.createDriver(),me=X.createQueryCompiler(),Oe=X.createAdapter(),At=new Ou(r.log??[]),nt=new ku(ae,At),rt=new Su(nt),ue=new io(me,Oe,rt,r.plugins??[]);n={executor:ue},A={config:r,executor:ue,dialect:X,driver:nt}}super(n);R(this,_t,void 0);U(this,_t,h(A))}get schema(){return new ro(s(this,_t).executor)}get dynamic(){return new Eu}get introspection(){return s(this,_t).dialect.createIntrospector(this.withoutPlugins())}case(r){return new ua({node:$t.create(Te(r)?void 0:Ji(r))})}get fn(){return la()}transaction(){return new ms({...s(this,_t)})}connection(){return new ka({...s(this,_t)})}withPlugin(r){return new Er({...s(this,_t),executor:s(this,_t).executor.withPlugin(r)})}withoutPlugins(){return new Er({...s(this,_t),executor:s(this,_t).executor.withoutPlugins()})}withSchema(r){return new Er({...s(this,_t),executor:s(this,_t).executor.withPluginAtFront(new Hr(r))})}withTables(){return new Er({...s(this,_t)})}async destroy(){await s(this,_t).driver.destroy()}get isTransaction(){return!1}getExecutor(){return s(this,_t).executor}executeQuery(r,n=Ce()){const A=Tu(r)?r.compile():r;return this.getExecutor().executeQuery(A,n)}};let Yr=Er;_t=new WeakMap;const Sr=class extends Yr{constructor(r){super(r);R(this,Zt,void 0);U(this,Zt,r)}get isTransaction(){return!0}transaction(){throw new Error("calling the transaction method for a Transaction is not supported")}connection(){throw new Error("calling the connection method for a Transaction is not supported")}async destroy(){throw new Error("calling the destroy method for a Transaction is not supported")}withPlugin(r){return new Sr({...s(this,Zt),executor:s(this,Zt).executor.withPlugin(r)})}withoutPlugins(){return new Sr({...s(this,Zt),executor:s(this,Zt).executor.withoutPlugins()})}withSchema(r){return new Sr({...s(this,Zt),executor:s(this,Zt).executor.withPluginAtFront(new Hr(r))})}withTables(){return new Sr({...s(this,Zt)})}};let so=Sr;Zt=new WeakMap;function Cu(t){return tn(t)&&tn(t.config)&&tn(t.driver)&&tn(t.executor)&&tn(t.dialect)}class ka{constructor(e){R(this,$n,void 0);U(this,$n,h(e))}async execute(e){return s(this,$n).executor.provideConnection(async r=>{const n=s(this,$n).executor.withConnectionProvider(new Sa(r)),A=new Yr({...s(this,$n),executor:n});return await e(A)})}}$n=new WeakMap,Se(ka,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");const ho=class{constructor(e){R(this,en,void 0);U(this,en,h(e))}setIsolationLevel(e){return new ho({...s(this,en),isolationLevel:e})}async execute(e){const{isolationLevel:r,...n}=s(this,en),A={isolationLevel:r};return Wu(A),s(this,en).executor.provideConnection(async X=>{const ae=s(this,en).executor.withConnectionProvider(new Sa(X)),me=new so({...n,executor:ae});try{await s(this,en).driver.beginTransaction(X,A);const Oe=await e(me);return await s(this,en).driver.commitTransaction(X),Oe}catch(Oe){throw await s(this,en).driver.rollbackTransaction(X),Oe}})}};let ms=ho;en=new WeakMap,Se(ms,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function Wu(t){if(t.isolationLevel&&!Iu.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}const Cs=class{constructor(e){R(this,kr);R(this,_i);R(this,mi);R(this,Ot,void 0);U(this,Ot,h(e))}get expressionType(){}as(e){return new Fu(this,e)}$castTo(){return new Cs({...s(this,Ot)})}castTo(){return this.$castTo()}withPlugin(e){return new Cs({...s(this,Ot),plugins:s(this,Ot).plugins!==void 0?h([...s(this,Ot).plugins,e]):h([e])})}toOperationNode(){return Le(this,_i,xo).call(this,Le(this,kr,Us).call(this))}compile(e){return Le(this,mi,Eo).call(this,Le(this,kr,Us).call(this,e))}async execute(e){const r=Le(this,kr,Us).call(this,e);return r.executeQuery(Le(this,mi,Eo).call(this,r),s(this,Ot).queryId)}};let Gt=Cs;Ot=new WeakMap,kr=new WeakSet,Us=function(e){const r=e!==void 0?e.getExecutor():$i;return s(this,Ot).plugins!==void 0?r.withPlugins(s(this,Ot).plugins):r},_i=new WeakSet,xo=function(e){return e.transformQuery(s(this,Ot).rawNode,s(this,Ot).queryId)},mi=new WeakSet,Eo=function(e){return e.compileQuery(Le(this,_i,xo).call(this,e),s(this,Ot).queryId)},Se(Gt,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");class Fu{constructor(e,r){R(this,Ir,void 0);R(this,Cn,void 0);U(this,Ir,e),U(this,Cn,r)}get expression(){return s(this,Ir)}get alias(){return s(this,Cn)}toOperationNode(){return Pn.create(s(this,Ir).toOperationNode(),bt(s(this,Cn))?s(this,Cn).toOperationNode():Ge.create(s(this,Cn)))}}Ir=new WeakMap,Cn=new WeakMap;const Wt=Object.assign((t,...e)=>new Gt({queryId:Ce(),rawNode:yt.create(t,(e==null?void 0:e.map(hn))??[])}),{ref(t){return new Gt({queryId:Ce(),rawNode:yt.createWithChild(rr(t))})},val(t){return new Gt({queryId:Ce(),rawNode:yt.createWithChild(hn(t))})},value(t){return this.val(t)},table(t){return new Gt({queryId:Ce(),rawNode:yt.createWithChild(It(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",new Gt({queryId:Ce(),rawNode:yt.create(e,t.map(Ge.create))})},lit(t){return new Gt({queryId:Ce(),rawNode:yt.createWithChild(nn.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return new Gt({queryId:Ce(),rawNode:yt.createWithSql(t)})},join(t,e=Wt`, `){const r=new Array(2*t.length-1),n=e.toOperationNode();for(let A=0;A{this.nodeStack.push(e),s(this,Ws)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}Ws=new WeakMap;class Lu extends Pu{constructor(){super(...arguments);R(this,Or,"");R(this,Gn,[])}get numParameters(){return s(this,Gn).length}compileQuery(r){return U(this,Or,""),U(this,Gn,[]),this.visitNode(r),h({query:r,sql:this.getSql(),parameters:[...s(this,Gn)]})}getSql(){return s(this,Or)}visitSelectQuery(r){const n=this.parentNode!==void 0&&!rn.is(this.parentNode)&&!Sn.is(this.parentNode)&&!aa.is(this.parentNode);this.parentNode===void 0&&r.explain&&(this.visitNode(r.explain),this.append(" ")),n&&this.append("("),r.with&&(this.visitNode(r.with),this.append(" ")),this.append("select "),r.distinctOn&&(this.compileDistinctOn(r.distinctOn),this.append(" ")),r.frontModifiers&&r.frontModifiers.length>0&&(this.compileList(r.frontModifiers," "),this.append(" ")),r.selections&&(this.compileList(r.selections),this.append(" ")),this.visitNode(r.from),r.joins&&(this.append(" "),this.compileList(r.joins," ")),r.where&&(this.append(" "),this.visitNode(r.where)),r.groupBy&&(this.append(" "),this.visitNode(r.groupBy)),r.having&&(this.append(" "),this.visitNode(r.having)),r.setOperations&&(this.append(" "),this.compileList(r.setOperations," ")),r.orderBy&&(this.append(" "),this.visitNode(r.orderBy)),r.limit&&(this.append(" "),this.visitNode(r.limit)),r.offset&&(this.append(" "),this.visitNode(r.offset)),r.endModifiers&&r.endModifiers.length>0&&(this.append(" "),this.compileList(r.endModifiers," ")),n&&this.append(")")}visitFrom(r){this.append("from "),this.compileList(r.froms)}visitSelection(r){this.visitNode(r.selection)}visitColumn(r){this.visitNode(r.column)}compileDistinctOn(r){this.append("distinct on ("),this.compileList(r),this.append(")")}compileList(r,n=", "){const A=r.length-1;for(let X=0;X<=A;X++)this.visitNode(r[X]),XX&&this.visitNode(A[X])}visitOperator(r){this.append(r.operator)}visitTable(r){this.visitNode(r.table)}visitSchemableIdentifier(r){r.schema&&(this.visitNode(r.schema),this.append(".")),this.visitNode(r.identifier)}visitCreateTable(r){this.append("create "),r.frontModifiers&&r.frontModifiers.length>0&&(this.compileList(r.frontModifiers," "),this.append(" ")),r.temporary&&this.append("temporary "),this.append("table "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.table),this.append(" ("),this.compileList([...r.columns,...r.constraints??[]]),this.append(")"),r.onCommit&&(this.append(" on commit "),this.append(r.onCommit)),r.endModifiers&&r.endModifiers.length>0&&(this.append(" "),this.compileList(r.endModifiers," "))}visitColumnDefinition(r){this.visitNode(r.column),this.append(" "),this.visitNode(r.dataType),r.unsigned&&this.append(" unsigned"),r.frontModifiers&&r.frontModifiers.length>0&&(this.append(" "),this.compileList(r.frontModifiers," ")),r.generated&&(this.append(" "),this.visitNode(r.generated)),r.defaultTo&&(this.append(" "),this.visitNode(r.defaultTo)),r.notNull&&this.append(" not null"),r.unique&&this.append(" unique"),r.primaryKey&&this.append(" primary key"),r.autoIncrement&&(this.append(" "),this.append(this.getAutoIncrement())),r.references&&(this.append(" "),this.visitNode(r.references)),r.check&&(this.append(" "),this.visitNode(r.check)),r.endModifiers&&r.endModifiers.length>0&&(this.append(" "),this.compileList(r.endModifiers," "))}getAutoIncrement(){return"auto_increment"}visitReferences(r){this.append("references "),this.visitNode(r.table),this.append(" ("),this.compileList(r.columns),this.append(")"),r.onDelete&&(this.append(" on delete "),this.append(r.onDelete)),r.onUpdate&&(this.append(" on update "),this.append(r.onUpdate))}visitDropTable(r){this.append("drop table "),r.ifExists&&this.append("if exists "),this.visitNode(r.table),r.cascade&&this.append(" cascade")}visitDataType(r){this.append(r.dataType)}visitOrderBy(r){this.append("order by "),this.compileList(r.items)}visitOrderByItem(r){this.visitNode(r.orderBy),r.direction&&(this.append(" "),this.visitNode(r.direction))}visitGroupBy(r){this.append("group by "),this.compileList(r.items)}visitGroupByItem(r){this.visitNode(r.groupBy)}visitUpdateQuery(r){const n=this.nodeStack.find(re.is)!==r;!n&&r.explain&&(this.visitNode(r.explain),this.append(" ")),n&&this.append("("),r.with&&(this.visitNode(r.with),this.append(" ")),this.append("update "),this.visitNode(r.table),this.append(" set "),r.updates&&this.compileList(r.updates),r.from&&(this.append(" "),this.visitNode(r.from)),r.joins&&(this.append(" "),this.compileList(r.joins," ")),r.where&&(this.append(" "),this.visitNode(r.where)),r.returning&&(this.append(" "),this.visitNode(r.returning)),n&&this.append(")")}visitColumnUpdate(r){this.visitNode(r.column),this.append(" = "),this.visitNode(r.value)}visitLimit(r){this.append("limit "),this.visitNode(r.limit)}visitOffset(r){this.append("offset "),this.visitNode(r.offset)}visitOnConflict(r){this.append("on conflict"),r.columns?(this.append(" ("),this.compileList(r.columns),this.append(")")):r.constraint?(this.append(" on constraint "),this.visitNode(r.constraint)):r.indexExpression&&(this.append(" ("),this.visitNode(r.indexExpression),this.append(")")),r.indexWhere&&(this.append(" "),this.visitNode(r.indexWhere)),r.doNothing===!0?this.append(" do nothing"):r.updates&&(this.append(" do update set "),this.compileList(r.updates),r.updateWhere&&(this.append(" "),this.visitNode(r.updateWhere)))}visitOnDuplicateKey(r){this.append("on duplicate key update "),this.compileList(r.updates)}visitCreateIndex(r){this.append("create "),r.unique&&this.append("unique "),this.append("index "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.name),r.table&&(this.append(" on "),this.visitNode(r.table)),r.using&&(this.append(" using "),this.visitNode(r.using)),r.columns&&(this.append(" ("),this.compileList(r.columns),this.append(")")),r.where&&(this.append(" "),this.visitNode(r.where))}visitDropIndex(r){this.append("drop index "),r.ifExists&&this.append("if exists "),this.visitNode(r.name),r.table&&(this.append(" on "),this.visitNode(r.table)),r.cascade&&this.append(" cascade")}visitCreateSchema(r){this.append("create schema "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.schema)}visitDropSchema(r){this.append("drop schema "),r.ifExists&&this.append("if exists "),this.visitNode(r.schema),r.cascade&&this.append(" cascade")}visitPrimaryKeyConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("primary key ("),this.compileList(r.columns),this.append(")")}visitUniqueConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("unique ("),this.compileList(r.columns),this.append(")")}visitCheckConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("check ("),this.visitNode(r.expression),this.append(")")}visitForeignKeyConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("foreign key ("),this.compileList(r.columns),this.append(") "),this.visitNode(r.references),r.onDelete&&(this.append(" on delete "),this.append(r.onDelete)),r.onUpdate&&(this.append(" on update "),this.append(r.onUpdate))}visitList(r){this.compileList(r.items)}visitWith(r){this.append("with "),r.recursive&&this.append("recursive "),this.compileList(r.expressions)}visitCommonTableExpression(r){this.visitNode(r.name),this.append(" as "),this.visitNode(r.expression)}visitCommonTableExpressionName(r){this.visitNode(r.table),r.columns&&(this.append("("),this.compileList(r.columns),this.append(")"))}visitAlterTable(r){this.append("alter table "),this.visitNode(r.table),this.append(" "),r.renameTo&&(this.append("rename to "),this.visitNode(r.renameTo)),r.setSchema&&(this.append("set schema "),this.visitNode(r.setSchema)),r.addConstraint&&this.visitNode(r.addConstraint),r.dropConstraint&&this.visitNode(r.dropConstraint),r.columnAlterations&&this.compileList(r.columnAlterations)}visitAddColumn(r){this.append("add column "),this.visitNode(r.column)}visitRenameColumn(r){this.append("rename column "),this.visitNode(r.column),this.append(" to "),this.visitNode(r.renameTo)}visitDropColumn(r){this.append("drop column "),this.visitNode(r.column)}visitAlterColumn(r){this.append("alter column "),this.visitNode(r.column),this.append(" "),r.dataType&&(this.append("type "),this.visitNode(r.dataType),r.dataTypeExpression&&(this.append("using "),this.visitNode(r.dataTypeExpression))),r.setDefault&&(this.append("set default "),this.visitNode(r.setDefault)),r.dropDefault&&this.append("drop default"),r.setNotNull&&this.append("set not null"),r.dropNotNull&&this.append("drop not null")}visitModifyColumn(r){this.append("modify column "),this.visitNode(r.column)}visitAddConstraint(r){this.append("add "),this.visitNode(r.constraint)}visitDropConstraint(r){this.append("drop constraint "),r.ifExists&&this.append("if exists "),this.visitNode(r.constraintName),r.modifier==="cascade"?this.append(" cascade"):r.modifier==="restrict"&&this.append(" restrict")}visitSetOperation(r){this.append(r.operator),this.append(" "),r.all&&this.append("all "),this.visitNode(r.expression)}visitCreateView(r){this.append("create "),r.orReplace&&this.append("or replace "),r.materialized&&this.append("materialized "),r.temporary&&this.append("temporary "),this.append("view "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.name),this.append(" "),r.columns&&(this.append("("),this.compileList(r.columns),this.append(") ")),r.as&&(this.append("as "),this.visitNode(r.as))}visitDropView(r){this.append("drop "),r.materialized&&this.append("materialized "),this.append("view "),r.ifExists&&this.append("if exists "),this.visitNode(r.name),r.cascade&&this.append(" cascade")}visitGenerated(r){this.append("generated "),r.always&&this.append("always "),r.byDefault&&this.append("by default "),this.append("as "),r.identity&&this.append("identity"),r.expression&&(this.append("("),this.visitNode(r.expression),this.append(")")),r.stored&&this.append(" stored")}visitDefaultValue(r){this.append("default "),this.visitNode(r.defaultValue)}visitSelectModifier(r){r.rawModifier?this.visitNode(r.rawModifier):this.append(Du[r.modifier])}visitCreateType(r){this.append("create type "),this.visitNode(r.name),r.enum&&(this.append(" as enum "),this.visitNode(r.enum))}visitDropType(r){this.append("drop type "),r.ifExists&&this.append("if exists "),this.visitNode(r.name)}visitExplain(r){this.append("explain"),(r.options||r.format)&&(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),r.options&&(this.visitNode(r.options),r.format&&this.append(this.getExplainOptionsDelimiter())),r.format&&(this.append("format"),this.append(this.getExplainOptionAssignment()),this.append(r.format)),this.append(this.getRightExplainOptionsWrapper()))}visitDefaultInsertValue(r){this.append("default")}visitAggregateFunction(r){this.append(r.func),this.append("("),r.distinct&&this.append("distinct "),this.compileList(r.aggregated),this.append(")"),r.filter&&(this.append(" filter("),this.visitNode(r.filter),this.append(")")),r.over&&(this.append(" "),this.visitNode(r.over))}visitOver(r){this.append("over("),r.partitionBy&&(this.visitNode(r.partitionBy),r.orderBy&&this.append(" ")),r.orderBy&&this.visitNode(r.orderBy),this.append(")")}visitPartitionBy(r){this.append("partition by "),this.compileList(r.items)}visitPartitionByItem(r){this.visitNode(r.partitionBy)}visitBinaryOperation(r){this.visitNode(r.leftOperand),this.append(" "),this.visitNode(r.operator),this.append(" "),this.visitNode(r.rightOperand)}visitUnaryOperation(r){this.visitNode(r.operator),this.isMinusOperator(r.operator)||this.append(" "),this.visitNode(r.operand)}isMinusOperator(r){return zs.is(r)&&r.operator==="-"}visitUsing(r){this.append("using "),this.compileList(r.tables)}visitFunction(r){this.append(r.func),this.append("("),this.compileList(r.arguments),this.append(")")}visitCase(r){this.append("case"),r.value&&(this.append(" "),this.visitNode(r.value)),r.when&&(this.append(" "),this.compileList(r.when," ")),r.else&&(this.append(" else "),this.visitNode(r.else)),this.append(" end"),r.isStatement&&this.append(" case")}visitWhen(r){this.append("when "),this.visitNode(r.condition),r.result&&(this.append(" then "),this.visitNode(r.result))}append(r){U(this,Or,s(this,Or)+r)}appendValue(r){this.addParameter(r),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier(r){const n=this.getLeftIdentifierWrapper(),A=this.getRightIdentifierWrapper();let X="";for(const ae of r)X+=ae,ae===n?X+=n:ae===A&&(X+=A);return X}addParameter(r){s(this,Gn).push(r)}appendImmediateValue(r){if(Ne(r))this.append(`'${r}'`);else if(Ze(r)||Pr(r))this.append(r.toString());else if(So(r))this.append("null");else if(hl(r))this.appendImmediateValue(r.toISOString());else if(pl(r))this.appendImmediateValue(r.toString());else throw new Error(`invalid immediate value ${r}`)}}Or=new WeakMap,Gn=new WeakMap;const Du=h({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),Ru=h({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral"}),oo=h({raw(t){return h({sql:t,query:yt.createWithSql(t),parameters:h([])})}}),Bu=/"/g;class Mu extends Lu{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(e){return e.replace(Bu,'""')}visitDefaultInsertValue(e){this.append("null")}}const Uu="kysely_migration",ju="kysely_migration_lock";h({__noMigrations__:!0});class Qu{constructor(e){R(this,Fs);R(this,Ar,void 0);U(this,Ar,e)}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let r=s(this,Ar).selectFrom("sqlite_schema").where("type","in",["table","view"]).where("name","not like","sqlite_%").select("name").orderBy("name").$castTo();e.withInternalKyselyTables||(r=r.where("name","!=",Uu).where("name","!=",ju));const n=await r.execute();return Promise.all(n.map(({name:A})=>Le(this,Fs,fl).call(this,A)))}async getMetadata(e){return{tables:await this.getTables(e)}}}Ar=new WeakMap,Fs=new WeakSet,fl=async function(e){var ae,me,Oe,At,nt,rt;const r=s(this,Ar),n=await r.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),A=(rt=(nt=(At=(Oe=(me=(ae=n.sql)==null?void 0:ae.split(/[\(\),]/))==null?void 0:me.find(ue=>ue.toLowerCase().includes("autoincrement")))==null?void 0:Oe.trimStart())==null?void 0:At.split(/\s+/))==null?void 0:nt[0])==null?void 0:rt.replace(/["`]/g,""),X=await r.selectFrom(Wt`pragma_table_info(${e})`.as("table_info")).select(["name","type","notnull","dflt_value"]).orderBy("cid").execute();return{name:e,isView:n.type==="view",columns:X.map(ue=>({name:ue.name,dataType:ue.type,isNullable:!ue.notnull,isAutoIncrementing:ue.name===A,hasDefaultValue:ue.dflt_value!=null}))}};class zu{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var Vu=class{createQueryCompiler(){return new Mu}createAdapter(){return new zu}createIntrospector(t){return new Qu(t)}},Hu=(Oa=class{constructor(){R(this,yi,new $u);Tt(this,"connection");R(this,Ps,void 0)}async acquireConnection(){return await s(this,yi).lock(),this.connection}async beginTransaction(t){await t.executeQuery(oo.raw("begin"))}async commitTransaction(t){await t.executeQuery(oo.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(oo.raw("rollback"))}async releaseConnection(){s(this,yi).unlock()}async destroy(){var t;(t=s(this,Ps))==null||t.close()}},yi=new WeakMap,Ps=new WeakMap,Oa),$u=(Aa=class{constructor(){R(this,Jn,void 0);R(this,Tr,void 0)}async lock(){for(;s(this,Jn);)await s(this,Jn);U(this,Jn,new Promise(t=>{U(this,Tr,t)}))}unlock(){const t=s(this,Tr);U(this,Jn,void 0),U(this,Tr,void 0),t==null||t()}},Jn=new WeakMap,Tr=new WeakMap,Aa),Gu=class{streamQuery(){throw new Error("Sqlite driver doesn't support streaming")}async executeQuery(t){const{parameters:e,sql:r,query:n}=t;return["SelectQueryNode","RawNode"].includes(n.kind)?{rows:await this.query(r,e)}:{rows:[],...await this.exec(r,e)}}},Ju=(Ta=class extends Hu{constructor(e){super();R(this,yn,void 0);R(this,gi,void 0);U(this,yn,e)}async init(){U(this,gi,typeof s(this,yn).database=="function"?await s(this,yn).database():s(this,yn).database),this.connection=new Ku(s(this,gi)),s(this,yn).onCreateConnection&&await s(this,yn).onCreateConnection(this.connection)}},yn=new WeakMap,gi=new WeakMap,Ta),Ku=(Ca=class extends Gu{constructor(e){super();R(this,Kn,void 0);U(this,Kn,e)}query(e,r){const n=[];return s(this,Kn).exec({sql:e,bind:r??[],rowMode:"object",resultRows:n}),n}exec(e,r){return s(this,Kn).exec({sql:e,bind:r??[]}),{numAffectedRows:BigInt(s(this,Kn).changes(!1,!0)),insertId:BigInt(this.query("SELECT last_insert_rowid() as id")[0].id)}}},Kn=new WeakMap,Ca),Xu=(Wa=class extends Vu{constructor(e){super();R(this,wi,void 0);U(this,wi,e)}createDriver(){return new Ju(s(this,wi))}},wi=new WeakMap,Wa),Yu=(()=>{var t=self.location.href;return function(e){var r=e||{},n=typeof r<"u"?r:{},A,X;n.ready=new Promise(function(o,i){A=o,X=i});const ae=globalThis.sqlite3InitModuleState||Object.assign(Object.create(null),{debugModule:()=>{}});delete globalThis.sqlite3InitModuleState,ae.debugModule("globalThis.location =",globalThis.location);const me="emscripten-bug-17951";n[me]=function o(i,l){i.env.foo=function(){};const a=n.locateFile(o.uri,typeof ue>"u"?"":ue);ae.debugModule("instantiateWasm() uri =",a);const u=()=>fetch(a,{credentials:"same-origin"});return(WebAssembly.instantiateStreaming?async()=>WebAssembly.instantiateStreaming(u(),i).then(N=>l(N.instance,N.module)):async()=>u().then(N=>N.arrayBuffer()).then(N=>WebAssembly.instantiate(N,i)).then(N=>l(N.instance,N.module)))(),{}},n[me].uri="sqlite3.wasm";var Oe=Object.assign({},n),At="./this.program",nt=typeof window=="object",rt=typeof importScripts=="function";typeof process=="object"&&typeof process.versions=="object"&&process.versions.node;var ue="";function Qt(o){return n.locateFile?n.locateFile(o,ue):ue+o}var Qe,gn,vi;(nt||rt)&&(rt?ue=self.location.href:typeof document<"u"&&document.currentScript&&(ue=document.currentScript.src),t&&(ue=t),ue.indexOf("blob:")!==0?ue=ue.substr(0,ue.replace(/[?#].*/,"").lastIndexOf("/")+1):ue="",Qe=o=>{var i=new XMLHttpRequest;return i.open("GET",o,!1),i.send(null),i.responseText},rt&&(vi=o=>{var i=new XMLHttpRequest;return i.open("GET",o,!1),i.responseType="arraybuffer",i.send(null),new Uint8Array(i.response)}),gn=(o,i,l)=>{var a=new XMLHttpRequest;a.open("GET",o,!0),a.responseType="arraybuffer",a.onload=()=>{if(a.status==200||a.status==0&&a.response){i(a.response);return}l()},a.onerror=l,a.send(null)});var wn=n.print||console.log.bind(console),Et=n.printErr||console.warn.bind(console);Object.assign(n,Oe),Oe=null,n.arguments&&n.arguments,n.thisProgram&&(At=n.thisProgram),n.quit&&n.quit;var xi;n.wasmBinary&&(xi=n.wasmBinary),n.noExitRuntime,typeof WebAssembly!="object"&&Zn("no native wasm support detected");var Fn,Da=!1;function cc(o,i){o||Zn(i)}var Ra=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Wr(o,i,l){for(var a=i+l,u=i;o[u]&&!(u>=a);)++u;if(u-i>16&&o.buffer&&Ra)return Ra.decode(o.subarray(i,u));for(var d="";i>10,56320|V&1023)}}return d}function dc(o,i){return o?Wr(Si,o,i):""}function Ls(o,i,l,a){if(!(a>0))return 0;for(var u=l,d=l+a-1,N=0;N=55296&&S<=57343){var C=o.charCodeAt(++N);S=65536+((S&1023)<<10)|C&1023}if(S<=127){if(l>=d)break;i[l++]=S}else if(S<=2047){if(l+1>=d)break;i[l++]=192|S>>6,i[l++]=128|S&63}else if(S<=65535){if(l+2>=d)break;i[l++]=224|S>>12,i[l++]=128|S>>6&63,i[l++]=128|S&63}else{if(l+3>=d)break;i[l++]=240|S>>18,i[l++]=128|S>>12&63,i[l++]=128|S>>6&63,i[l++]=128|S&63}}return i[l]=0,l-u}function Ba(o,i,l){return Ls(o,Si,i,l)}function Ei(o){for(var i=0,l=0;l=55296&&a<=57343?(i+=4,++l):i+=3}return i}var Dt,Si,Ma,we,it;function Ua(){var o=Fn.buffer;n.HEAP8=Dt=new Int8Array(o),n.HEAP16=Ma=new Int16Array(o),n.HEAP32=we=new Int32Array(o),n.HEAPU8=Si=new Uint8Array(o),n.HEAPU16=new Uint16Array(o),n.HEAPU32=it=new Uint32Array(o),n.HEAPF32=new Float32Array(o),n.HEAPF64=new Float64Array(o),n.HEAP64=new BigInt64Array(o),n.HEAPU64=new BigUint64Array(o)}var ja=n.INITIAL_MEMORY||16777216;n.wasmMemory?Fn=n.wasmMemory:Fn=new WebAssembly.Memory({initial:ja/65536,maximum:2147483648/65536}),Ua(),ja=Fn.buffer.byteLength;var Qa=[],za=[],Va=[];function fc(){if(n.preRun)for(typeof n.preRun=="function"&&(n.preRun=[n.preRun]);n.preRun.length;)_c(n.preRun.shift());_o(Qa)}function hc(){!n.noFSInit&&!c.init.initialized&&c.init(),c.ignorePermissions=!1,_o(za)}function pc(){if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)yc(n.postRun.shift());_o(Va)}function _c(o){Qa.unshift(o)}function mc(o){za.unshift(o)}function yc(o){Va.unshift(o)}var Yn=0,ki=null;function bd(o){return o}function po(o){Yn++,n.monitorRunDependencies&&n.monitorRunDependencies(Yn)}function Ds(o){if(Yn--,n.monitorRunDependencies&&n.monitorRunDependencies(Yn),Yn==0&&ki){var i=ki;ki=null,i()}}function Zn(o){n.onAbort&&n.onAbort(o),o="Aborted("+o+")",Et(o),Da=!0,o+=". Build with -sASSERTIONS for more info.";var i=new WebAssembly.RuntimeError(o);throw X(i),i}var gc="data:application/octet-stream;base64,";function Ha(o){return o.startsWith(gc)}var zt;n.locateFile?(zt="sqlite3.wasm",Ha(zt)||(zt=Qt(zt))):zt=new URL(""+new URL("sqlite3-14470338.wasm",self.location.href).href,self.location).href;function $a(o){try{if(o==zt&&xi)return new Uint8Array(xi);if(vi)return vi(o);throw"both async and sync fetching of the wasm failed"}catch(i){Zn(i)}}function wc(){return!xi&&(nt||rt)&&typeof fetch=="function"?fetch(zt,{credentials:"same-origin"}).then(function(o){if(!o.ok)throw"failed to load wasm binary file at '"+zt+"'";return o.arrayBuffer()}).catch(function(){return $a(zt)}):Promise.resolve().then(function(){return $a(zt)})}function qc(){var o={env:Za,wasi_snapshot_preview1:Za};function i(N,S){var C=N.exports;n.asm=C,n.asm.__indirect_function_table,mc(n.asm.__wasm_call_ctors),Ds()}po();function l(N){i(N.instance)}function a(N){return wc().then(function(S){return WebAssembly.instantiate(S,o)}).then(function(S){return S}).then(N,function(S){Et("failed to asynchronously prepare wasm: "+S),Zn(S)})}function u(){return!xi&&typeof WebAssembly.instantiateStreaming=="function"&&!Ha(zt)&&typeof fetch=="function"?fetch(zt,{credentials:"same-origin"}).then(function(N){var S=WebAssembly.instantiateStreaming(N,o);return S.then(l,function(C){return Et("wasm streaming compile failed: "+C),Et("falling back to ArrayBuffer instantiation"),a(l)})}):a(l)}if(n.instantiateWasm)try{var d=n.instantiateWasm(o,i);return d}catch(N){Et("Module.instantiateWasm callback failed with error: "+N),X(N)}return u().catch(X),{}}var qe,ut;function _o(o){for(;o.length>0;)o.shift()(n)}var Ee={isAbs:o=>o.charAt(0)==="/",splitPath:o=>{var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return i.exec(o).slice(1)},normalizeArray:(o,i)=>{for(var l=0,a=o.length-1;a>=0;a--){var u=o[a];u==="."?o.splice(a,1):u===".."?(o.splice(a,1),l++):l&&(o.splice(a,1),l--)}if(i)for(;l;l--)o.unshift("..");return o},normalize:o=>{var i=Ee.isAbs(o),l=o.substr(-1)==="/";return o=Ee.normalizeArray(o.split("/").filter(a=>!!a),!i).join("/"),!o&&!i&&(o="."),o&&l&&(o+="/"),(i?"/":"")+o},dirname:o=>{var i=Ee.splitPath(o),l=i[0],a=i[1];return!l&&!a?".":(a&&(a=a.substr(0,a.length-1)),l+a)},basename:o=>{if(o==="/")return"/";o=Ee.normalize(o),o=o.replace(/\/$/,"");var i=o.lastIndexOf("/");return i===-1?o:o.substr(i+1)},join:function(){var o=Array.prototype.slice.call(arguments);return Ee.normalize(o.join("/"))},join2:(o,i)=>Ee.normalize(o+"/"+i)};function bc(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var o=new Uint8Array(1);return()=>(crypto.getRandomValues(o),o[0])}else return()=>Zn("randomDevice")}var qn={resolve:function(){for(var o="",i=!1,l=arguments.length-1;l>=-1&&!i;l--){var a=l>=0?arguments[l]:c.cwd();if(typeof a!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!a)return"";o=a+"/"+o,i=Ee.isAbs(a)}return o=Ee.normalizeArray(o.split("/").filter(u=>!!u),!i).join("/"),(i?"/":"")+o||"."},relative:(o,i)=>{o=qn.resolve(o).substr(1),i=qn.resolve(i).substr(1);function l(V){for(var J=0;J=0&&V[ie]==="";ie--);return J>ie?[]:V.slice(J,ie-J+1)}for(var a=l(o.split("/")),u=l(i.split("/")),d=Math.min(a.length,u.length),N=d,S=0;S0?l:Ei(o)+1,u=new Array(a),d=Ls(o,u,0,u.length);return i&&(u.length=d),u}var er={ttys:[],init:function(){},shutdown:function(){},register:function(o,i){er.ttys[o]={input:[],output:[],ops:i},c.registerDevice(o,er.stream_ops)},stream_ops:{open:function(o){var i=er.ttys[o.node.rdev];if(!i)throw new c.ErrnoError(43);o.tty=i,o.seekable=!1},close:function(o){o.tty.ops.fsync(o.tty)},fsync:function(o){o.tty.ops.fsync(o.tty)},read:function(o,i,l,a,u){if(!o.tty||!o.tty.ops.get_char)throw new c.ErrnoError(60);for(var d=0,N=0;N0&&(wn(Wr(o.output,0)),o.output=[])}},default_tty1_ops:{put_char:function(o,i){i===null||i===10?(Et(Wr(o.output,0)),o.output=[]):i!=0&&o.output.push(i)},fsync:function(o){o.output&&o.output.length>0&&(Et(Wr(o.output,0)),o.output=[])}}};function Ga(o){Zn()}var he={ops_table:null,mount:function(o){return he.createNode(null,"/",16895,0)},createNode:function(o,i,l,a){if(c.isBlkdev(l)||c.isFIFO(l))throw new c.ErrnoError(63);he.ops_table||(he.ops_table={dir:{node:{getattr:he.node_ops.getattr,setattr:he.node_ops.setattr,lookup:he.node_ops.lookup,mknod:he.node_ops.mknod,rename:he.node_ops.rename,unlink:he.node_ops.unlink,rmdir:he.node_ops.rmdir,readdir:he.node_ops.readdir,symlink:he.node_ops.symlink},stream:{llseek:he.stream_ops.llseek}},file:{node:{getattr:he.node_ops.getattr,setattr:he.node_ops.setattr},stream:{llseek:he.stream_ops.llseek,read:he.stream_ops.read,write:he.stream_ops.write,allocate:he.stream_ops.allocate,mmap:he.stream_ops.mmap,msync:he.stream_ops.msync}},link:{node:{getattr:he.node_ops.getattr,setattr:he.node_ops.setattr,readlink:he.node_ops.readlink},stream:{}},chrdev:{node:{getattr:he.node_ops.getattr,setattr:he.node_ops.setattr},stream:c.chrdev_stream_ops}});var u=c.createNode(o,i,l,a);return c.isDir(u.mode)?(u.node_ops=he.ops_table.dir.node,u.stream_ops=he.ops_table.dir.stream,u.contents={}):c.isFile(u.mode)?(u.node_ops=he.ops_table.file.node,u.stream_ops=he.ops_table.file.stream,u.usedBytes=0,u.contents=null):c.isLink(u.mode)?(u.node_ops=he.ops_table.link.node,u.stream_ops=he.ops_table.link.stream):c.isChrdev(u.mode)&&(u.node_ops=he.ops_table.chrdev.node,u.stream_ops=he.ops_table.chrdev.stream),u.timestamp=Date.now(),o&&(o.contents[i]=u,o.timestamp=u.timestamp),u},getFileDataAsTypedArray:function(o){return o.contents?o.contents.subarray?o.contents.subarray(0,o.usedBytes):new Uint8Array(o.contents):new Uint8Array(0)},expandFileStorage:function(o,i){var l=o.contents?o.contents.length:0;if(!(l>=i)){var a=1024*1024;i=Math.max(i,l*(l>>0),l!=0&&(i=Math.max(i,256));var u=o.contents;o.contents=new Uint8Array(i),o.usedBytes>0&&o.contents.set(u.subarray(0,o.usedBytes),0)}},resizeFileStorage:function(o,i){if(o.usedBytes!=i)if(i==0)o.contents=null,o.usedBytes=0;else{var l=o.contents;o.contents=new Uint8Array(i),l&&o.contents.set(l.subarray(0,Math.min(i,o.usedBytes))),o.usedBytes=i}},node_ops:{getattr:function(o){var i={};return i.dev=c.isChrdev(o.mode)?o.id:1,i.ino=o.id,i.mode=o.mode,i.nlink=1,i.uid=0,i.gid=0,i.rdev=o.rdev,c.isDir(o.mode)?i.size=4096:c.isFile(o.mode)?i.size=o.usedBytes:c.isLink(o.mode)?i.size=o.link.length:i.size=0,i.atime=new Date(o.timestamp),i.mtime=new Date(o.timestamp),i.ctime=new Date(o.timestamp),i.blksize=4096,i.blocks=Math.ceil(i.size/i.blksize),i},setattr:function(o,i){i.mode!==void 0&&(o.mode=i.mode),i.timestamp!==void 0&&(o.timestamp=i.timestamp),i.size!==void 0&&he.resizeFileStorage(o,i.size)},lookup:function(o,i){throw c.genericErrors[44]},mknod:function(o,i,l,a){return he.createNode(o,i,l,a)},rename:function(o,i,l){if(c.isDir(o.mode)){var a;try{a=c.lookupNode(i,l)}catch{}if(a)for(var u in a.contents)throw new c.ErrnoError(55)}delete o.parent.contents[o.name],o.parent.timestamp=Date.now(),o.name=l,i.contents[l]=o,i.timestamp=o.parent.timestamp,o.parent=i},unlink:function(o,i){delete o.contents[i],o.timestamp=Date.now()},rmdir:function(o,i){var l=c.lookupNode(o,i);for(var a in l.contents)throw new c.ErrnoError(55);delete o.contents[i],o.timestamp=Date.now()},readdir:function(o){var i=[".",".."];for(var l in o.contents)o.contents.hasOwnProperty(l)&&i.push(l);return i},symlink:function(o,i,l){var a=he.createNode(o,i,41471,0);return a.link=l,a},readlink:function(o){if(!c.isLink(o.mode))throw new c.ErrnoError(28);return o.link}},stream_ops:{read:function(o,i,l,a,u){var d=o.node.contents;if(u>=o.node.usedBytes)return 0;var N=Math.min(o.node.usedBytes-u,a);if(N>8&&d.subarray)i.set(d.subarray(u,u+N),l);else for(var S=0;S0||l+i{cc(d,'Loading data file "'+o+'" failed (no arrayBuffer).'),i(new Uint8Array(d)),u&&Ds()},d=>{if(l)l();else throw'Loading data file "'+o+'" failed.'}),u&&po()}var c={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(o,i={})=>{if(o=qn.resolve(o),!o)return{path:"",node:null};var l={follow_mount:!0,recurse_count:0};if(i=Object.assign(l,i),i.recurse_count>8)throw new c.ErrnoError(32);for(var a=o.split("/").filter(ie=>!!ie),u=c.root,d="/",N=0;N40)throw new c.ErrnoError(32)}}return{path:d,node:u}},getPath:o=>{for(var i;;){if(c.isRoot(o)){var l=o.mount.mountpoint;return i?l[l.length-1]!=="/"?l+"/"+i:l+i:l}i=i?o.name+"/"+i:o.name,o=o.parent}},hashName:(o,i)=>{for(var l=0,a=0;a>>0)%c.nameTable.length},hashAddNode:o=>{var i=c.hashName(o.parent.id,o.name);o.name_next=c.nameTable[i],c.nameTable[i]=o},hashRemoveNode:o=>{var i=c.hashName(o.parent.id,o.name);if(c.nameTable[i]===o)c.nameTable[i]=o.name_next;else for(var l=c.nameTable[i];l;){if(l.name_next===o){l.name_next=o.name_next;break}l=l.name_next}},lookupNode:(o,i)=>{var l=c.mayLookup(o);if(l)throw new c.ErrnoError(l,o);for(var a=c.hashName(o.id,i),u=c.nameTable[a];u;u=u.name_next){var d=u.name;if(u.parent.id===o.id&&d===i)return u}return c.lookup(o,i)},createNode:(o,i,l,a)=>{var u=new c.FSNode(o,i,l,a);return c.hashAddNode(u),u},destroyNode:o=>{c.hashRemoveNode(o)},isRoot:o=>o===o.parent,isMountpoint:o=>!!o.mounted,isFile:o=>(o&61440)===32768,isDir:o=>(o&61440)===16384,isLink:o=>(o&61440)===40960,isChrdev:o=>(o&61440)===8192,isBlkdev:o=>(o&61440)===24576,isFIFO:o=>(o&61440)===4096,isSocket:o=>(o&49152)===49152,flagModes:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},modeStringToFlags:o=>{var i=c.flagModes[o];if(typeof i>"u")throw new Error("Unknown file open mode: "+o);return i},flagsToPermissionString:o=>{var i=["r","w","rw"][o&3];return o&512&&(i+="w"),i},nodePermissions:(o,i)=>c.ignorePermissions?0:i.includes("r")&&!(o.mode&292)||i.includes("w")&&!(o.mode&146)||i.includes("x")&&!(o.mode&73)?2:0,mayLookup:o=>{var i=c.nodePermissions(o,"x");return i||(o.node_ops.lookup?0:2)},mayCreate:(o,i)=>{try{var l=c.lookupNode(o,i);return 20}catch{}return c.nodePermissions(o,"wx")},mayDelete:(o,i,l)=>{var a;try{a=c.lookupNode(o,i)}catch(d){return d.errno}var u=c.nodePermissions(o,"wx");if(u)return u;if(l){if(!c.isDir(a.mode))return 54;if(c.isRoot(a)||c.getPath(a)===c.cwd())return 10}else if(c.isDir(a.mode))return 31;return 0},mayOpen:(o,i)=>o?c.isLink(o.mode)?32:c.isDir(o.mode)&&(c.flagsToPermissionString(i)!=="r"||i&512)?31:c.nodePermissions(o,c.flagsToPermissionString(i)):44,MAX_OPEN_FDS:4096,nextfd:(o=0,i=c.MAX_OPEN_FDS)=>{for(var l=o;l<=i;l++)if(!c.streams[l])return l;throw new c.ErrnoError(33)},getStream:o=>c.streams[o],createStream:(o,i,l)=>{c.FSStream||(c.FSStream=function(){this.shared={}},c.FSStream.prototype={},Object.defineProperties(c.FSStream.prototype,{object:{get:function(){return this.node},set:function(u){this.node=u}},isRead:{get:function(){return(this.flags&2097155)!==1}},isWrite:{get:function(){return(this.flags&2097155)!==0}},isAppend:{get:function(){return this.flags&1024}},flags:{get:function(){return this.shared.flags},set:function(u){this.shared.flags=u}},position:{get:function(){return this.shared.position},set:function(u){this.shared.position=u}}})),o=Object.assign(new c.FSStream,o);var a=c.nextfd(i,l);return o.fd=a,c.streams[a]=o,o},closeStream:o=>{c.streams[o]=null},chrdev_stream_ops:{open:o=>{var i=c.getDevice(o.node.rdev);o.stream_ops=i.stream_ops,o.stream_ops.open&&o.stream_ops.open(o)},llseek:()=>{throw new c.ErrnoError(70)}},major:o=>o>>8,minor:o=>o&255,makedev:(o,i)=>o<<8|i,registerDevice:(o,i)=>{c.devices[o]={stream_ops:i}},getDevice:o=>c.devices[o],getMounts:o=>{for(var i=[],l=[o];l.length;){var a=l.pop();i.push(a),l.push.apply(l,a.mounts)}return i},syncfs:(o,i)=>{typeof o=="function"&&(i=o,o=!1),c.syncFSRequests++,c.syncFSRequests>1&&Et("warning: "+c.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work");var l=c.getMounts(c.root.mount),a=0;function u(N){return c.syncFSRequests--,i(N)}function d(N){if(N)return d.errored?void 0:(d.errored=!0,u(N));++a>=l.length&&u(null)}l.forEach(N=>{if(!N.type.syncfs)return d(null);N.type.syncfs(N,o,d)})},mount:(o,i,l)=>{var a=l==="/",u=!l,d;if(a&&c.root)throw new c.ErrnoError(10);if(!a&&!u){var N=c.lookupPath(l,{follow_mount:!1});if(l=N.path,d=N.node,c.isMountpoint(d))throw new c.ErrnoError(10);if(!c.isDir(d.mode))throw new c.ErrnoError(54)}var S={type:o,opts:i,mountpoint:l,mounts:[]},C=o.mount(S);return C.mount=S,S.root=C,a?c.root=C:d&&(d.mounted=S,d.mount&&d.mount.mounts.push(S)),C},unmount:o=>{var i=c.lookupPath(o,{follow_mount:!1});if(!c.isMountpoint(i.node))throw new c.ErrnoError(28);var l=i.node,a=l.mounted,u=c.getMounts(a);Object.keys(c.nameTable).forEach(N=>{for(var S=c.nameTable[N];S;){var C=S.name_next;u.includes(S.mount)&&c.destroyNode(S),S=C}}),l.mounted=null;var d=l.mount.mounts.indexOf(a);l.mount.mounts.splice(d,1)},lookup:(o,i)=>o.node_ops.lookup(o,i),mknod:(o,i,l)=>{var a=c.lookupPath(o,{parent:!0}),u=a.node,d=Ee.basename(o);if(!d||d==="."||d==="..")throw new c.ErrnoError(28);var N=c.mayCreate(u,d);if(N)throw new c.ErrnoError(N);if(!u.node_ops.mknod)throw new c.ErrnoError(63);return u.node_ops.mknod(u,d,i,l)},create:(o,i)=>(i=i!==void 0?i:438,i&=4095,i|=32768,c.mknod(o,i,0)),mkdir:(o,i)=>(i=i!==void 0?i:511,i&=1023,i|=16384,c.mknod(o,i,0)),mkdirTree:(o,i)=>{for(var l=o.split("/"),a="",u=0;u(typeof l>"u"&&(l=i,i=438),i|=8192,c.mknod(o,i,l)),symlink:(o,i)=>{if(!qn.resolve(o))throw new c.ErrnoError(44);var l=c.lookupPath(i,{parent:!0}),a=l.node;if(!a)throw new c.ErrnoError(44);var u=Ee.basename(i),d=c.mayCreate(a,u);if(d)throw new c.ErrnoError(d);if(!a.node_ops.symlink)throw new c.ErrnoError(63);return a.node_ops.symlink(a,u,o)},rename:(o,i)=>{var l=Ee.dirname(o),a=Ee.dirname(i),u=Ee.basename(o),d=Ee.basename(i),N,S,C;if(N=c.lookupPath(o,{parent:!0}),S=N.node,N=c.lookupPath(i,{parent:!0}),C=N.node,!S||!C)throw new c.ErrnoError(44);if(S.mount!==C.mount)throw new c.ErrnoError(75);var V=c.lookupNode(S,u),J=qn.relative(o,a);if(J.charAt(0)!==".")throw new c.ErrnoError(28);if(J=qn.relative(i,l),J.charAt(0)!==".")throw new c.ErrnoError(55);var ie;try{ie=c.lookupNode(C,d)}catch{}if(V!==ie){var k=c.isDir(V.mode),m=c.mayDelete(S,u,k);if(m)throw new c.ErrnoError(m);if(m=ie?c.mayDelete(C,d,k):c.mayCreate(C,d),m)throw new c.ErrnoError(m);if(!S.node_ops.rename)throw new c.ErrnoError(63);if(c.isMountpoint(V)||ie&&c.isMountpoint(ie))throw new c.ErrnoError(10);if(C!==S&&(m=c.nodePermissions(S,"w"),m))throw new c.ErrnoError(m);c.hashRemoveNode(V);try{S.node_ops.rename(V,C,d)}catch(y){throw y}finally{c.hashAddNode(V)}}},rmdir:o=>{var i=c.lookupPath(o,{parent:!0}),l=i.node,a=Ee.basename(o),u=c.lookupNode(l,a),d=c.mayDelete(l,a,!0);if(d)throw new c.ErrnoError(d);if(!l.node_ops.rmdir)throw new c.ErrnoError(63);if(c.isMountpoint(u))throw new c.ErrnoError(10);l.node_ops.rmdir(l,a),c.destroyNode(u)},readdir:o=>{var i=c.lookupPath(o,{follow:!0}),l=i.node;if(!l.node_ops.readdir)throw new c.ErrnoError(54);return l.node_ops.readdir(l)},unlink:o=>{var i=c.lookupPath(o,{parent:!0}),l=i.node;if(!l)throw new c.ErrnoError(44);var a=Ee.basename(o),u=c.lookupNode(l,a),d=c.mayDelete(l,a,!1);if(d)throw new c.ErrnoError(d);if(!l.node_ops.unlink)throw new c.ErrnoError(63);if(c.isMountpoint(u))throw new c.ErrnoError(10);l.node_ops.unlink(l,a),c.destroyNode(u)},readlink:o=>{var i=c.lookupPath(o),l=i.node;if(!l)throw new c.ErrnoError(44);if(!l.node_ops.readlink)throw new c.ErrnoError(28);return qn.resolve(c.getPath(l.parent),l.node_ops.readlink(l))},stat:(o,i)=>{var l=c.lookupPath(o,{follow:!i}),a=l.node;if(!a)throw new c.ErrnoError(44);if(!a.node_ops.getattr)throw new c.ErrnoError(63);return a.node_ops.getattr(a)},lstat:o=>c.stat(o,!0),chmod:(o,i,l)=>{var a;if(typeof o=="string"){var u=c.lookupPath(o,{follow:!l});a=u.node}else a=o;if(!a.node_ops.setattr)throw new c.ErrnoError(63);a.node_ops.setattr(a,{mode:i&4095|a.mode&-4096,timestamp:Date.now()})},lchmod:(o,i)=>{c.chmod(o,i,!0)},fchmod:(o,i)=>{var l=c.getStream(o);if(!l)throw new c.ErrnoError(8);c.chmod(l.node,i)},chown:(o,i,l,a)=>{var u;if(typeof o=="string"){var d=c.lookupPath(o,{follow:!a});u=d.node}else u=o;if(!u.node_ops.setattr)throw new c.ErrnoError(63);u.node_ops.setattr(u,{timestamp:Date.now()})},lchown:(o,i,l)=>{c.chown(o,i,l,!0)},fchown:(o,i,l)=>{var a=c.getStream(o);if(!a)throw new c.ErrnoError(8);c.chown(a.node,i,l)},truncate:(o,i)=>{if(i<0)throw new c.ErrnoError(28);var l;if(typeof o=="string"){var a=c.lookupPath(o,{follow:!0});l=a.node}else l=o;if(!l.node_ops.setattr)throw new c.ErrnoError(63);if(c.isDir(l.mode))throw new c.ErrnoError(31);if(!c.isFile(l.mode))throw new c.ErrnoError(28);var u=c.nodePermissions(l,"w");if(u)throw new c.ErrnoError(u);l.node_ops.setattr(l,{size:i,timestamp:Date.now()})},ftruncate:(o,i)=>{var l=c.getStream(o);if(!l)throw new c.ErrnoError(8);if(!(l.flags&2097155))throw new c.ErrnoError(28);c.truncate(l.node,i)},utime:(o,i,l)=>{var a=c.lookupPath(o,{follow:!0}),u=a.node;u.node_ops.setattr(u,{timestamp:Math.max(i,l)})},open:(o,i,l)=>{if(o==="")throw new c.ErrnoError(44);i=typeof i=="string"?c.modeStringToFlags(i):i,l=typeof l>"u"?438:l,i&64?l=l&4095|32768:l=0;var a;if(typeof o=="object")a=o;else{o=Ee.normalize(o);try{var u=c.lookupPath(o,{follow:!(i&131072)});a=u.node}catch{}}var d=!1;if(i&64)if(a){if(i&128)throw new c.ErrnoError(20)}else a=c.mknod(o,l,0),d=!0;if(!a)throw new c.ErrnoError(44);if(c.isChrdev(a.mode)&&(i&=-513),i&65536&&!c.isDir(a.mode))throw new c.ErrnoError(54);if(!d){var N=c.mayOpen(a,i);if(N)throw new c.ErrnoError(N)}i&512&&!d&&c.truncate(a,0),i&=-131713;var S=c.createStream({node:a,path:c.getPath(a),flags:i,seekable:!0,position:0,stream_ops:a.stream_ops,ungotten:[],error:!1});return S.stream_ops.open&&S.stream_ops.open(S),n.logReadFiles&&!(i&1)&&(c.readFiles||(c.readFiles={}),o in c.readFiles||(c.readFiles[o]=1)),S},close:o=>{if(c.isClosed(o))throw new c.ErrnoError(8);o.getdents&&(o.getdents=null);try{o.stream_ops.close&&o.stream_ops.close(o)}catch(i){throw i}finally{c.closeStream(o.fd)}o.fd=null},isClosed:o=>o.fd===null,llseek:(o,i,l)=>{if(c.isClosed(o))throw new c.ErrnoError(8);if(!o.seekable||!o.stream_ops.llseek)throw new c.ErrnoError(70);if(l!=0&&l!=1&&l!=2)throw new c.ErrnoError(28);return o.position=o.stream_ops.llseek(o,i,l),o.ungotten=[],o.position},read:(o,i,l,a,u)=>{if(a<0||u<0)throw new c.ErrnoError(28);if(c.isClosed(o))throw new c.ErrnoError(8);if((o.flags&2097155)===1)throw new c.ErrnoError(8);if(c.isDir(o.node.mode))throw new c.ErrnoError(31);if(!o.stream_ops.read)throw new c.ErrnoError(28);var d=typeof u<"u";if(!d)u=o.position;else if(!o.seekable)throw new c.ErrnoError(70);var N=o.stream_ops.read(o,i,l,a,u);return d||(o.position+=N),N},write:(o,i,l,a,u,d)=>{if(a<0||u<0)throw new c.ErrnoError(28);if(c.isClosed(o))throw new c.ErrnoError(8);if(!(o.flags&2097155))throw new c.ErrnoError(8);if(c.isDir(o.node.mode))throw new c.ErrnoError(31);if(!o.stream_ops.write)throw new c.ErrnoError(28);o.seekable&&o.flags&1024&&c.llseek(o,0,2);var N=typeof u<"u";if(!N)u=o.position;else if(!o.seekable)throw new c.ErrnoError(70);var S=o.stream_ops.write(o,i,l,a,u,d);return N||(o.position+=S),S},allocate:(o,i,l)=>{if(c.isClosed(o))throw new c.ErrnoError(8);if(i<0||l<=0)throw new c.ErrnoError(28);if(!(o.flags&2097155))throw new c.ErrnoError(8);if(!c.isFile(o.node.mode)&&!c.isDir(o.node.mode))throw new c.ErrnoError(43);if(!o.stream_ops.allocate)throw new c.ErrnoError(138);o.stream_ops.allocate(o,i,l)},mmap:(o,i,l,a,u)=>{if(a&2&&!(u&2)&&(o.flags&2097155)!==2)throw new c.ErrnoError(2);if((o.flags&2097155)===1)throw new c.ErrnoError(2);if(!o.stream_ops.mmap)throw new c.ErrnoError(43);return o.stream_ops.mmap(o,i,l,a,u)},msync:(o,i,l,a,u)=>o.stream_ops.msync?o.stream_ops.msync(o,i,l,a,u):0,munmap:o=>0,ioctl:(o,i,l)=>{if(!o.stream_ops.ioctl)throw new c.ErrnoError(59);return o.stream_ops.ioctl(o,i,l)},readFile:(o,i={})=>{if(i.flags=i.flags||0,i.encoding=i.encoding||"binary",i.encoding!=="utf8"&&i.encoding!=="binary")throw new Error('Invalid encoding type "'+i.encoding+'"');var l,a=c.open(o,i.flags),u=c.stat(o),d=u.size,N=new Uint8Array(d);return c.read(a,N,0,d,0),i.encoding==="utf8"?l=Wr(N,0):i.encoding==="binary"&&(l=N),c.close(a),l},writeFile:(o,i,l={})=>{l.flags=l.flags||577;var a=c.open(o,l.flags,l.mode);if(typeof i=="string"){var u=new Uint8Array(Ei(i)+1),d=Ls(i,u,0,u.length);c.write(a,u,0,d,void 0,l.canOwn)}else if(ArrayBuffer.isView(i))c.write(a,i,0,i.byteLength,void 0,l.canOwn);else throw new Error("Unsupported data type");c.close(a)},cwd:()=>c.currentPath,chdir:o=>{var i=c.lookupPath(o,{follow:!0});if(i.node===null)throw new c.ErrnoError(44);if(!c.isDir(i.node.mode))throw new c.ErrnoError(54);var l=c.nodePermissions(i.node,"x");if(l)throw new c.ErrnoError(l);c.currentPath=i.path},createDefaultDirectories:()=>{c.mkdir("/tmp"),c.mkdir("/home"),c.mkdir("/home/web_user")},createDefaultDevices:()=>{c.mkdir("/dev"),c.registerDevice(c.makedev(1,3),{read:()=>0,write:(i,l,a,u,d)=>u}),c.mkdev("/dev/null",c.makedev(1,3)),er.register(c.makedev(5,0),er.default_tty_ops),er.register(c.makedev(6,0),er.default_tty1_ops),c.mkdev("/dev/tty",c.makedev(5,0)),c.mkdev("/dev/tty1",c.makedev(6,0));var o=bc();c.createDevice("/dev","random",o),c.createDevice("/dev","urandom",o),c.mkdir("/dev/shm"),c.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{c.mkdir("/proc");var o=c.mkdir("/proc/self");c.mkdir("/proc/self/fd"),c.mount({mount:()=>{var i=c.createNode(o,"fd",16895,73);return i.node_ops={lookup:(l,a)=>{var u=+a,d=c.getStream(u);if(!d)throw new c.ErrnoError(8);var N={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>d.path}};return N.parent=N,N}},i}},{},"/proc/self/fd")},createStandardStreams:()=>{n.stdin?c.createDevice("/dev","stdin",n.stdin):c.symlink("/dev/tty","/dev/stdin"),n.stdout?c.createDevice("/dev","stdout",null,n.stdout):c.symlink("/dev/tty","/dev/stdout"),n.stderr?c.createDevice("/dev","stderr",null,n.stderr):c.symlink("/dev/tty1","/dev/stderr"),c.open("/dev/stdin",0),c.open("/dev/stdout",1),c.open("/dev/stderr",1)},ensureErrnoError:()=>{c.ErrnoError||(c.ErrnoError=function(i,l){this.node=l,this.setErrno=function(a){this.errno=a},this.setErrno(i),this.message="FS error"},c.ErrnoError.prototype=new Error,c.ErrnoError.prototype.constructor=c.ErrnoError,[44].forEach(o=>{c.genericErrors[o]=new c.ErrnoError(o),c.genericErrors[o].stack=""}))},staticInit:()=>{c.ensureErrnoError(),c.nameTable=new Array(4096),c.mount(he,{},"/"),c.createDefaultDirectories(),c.createDefaultDevices(),c.createSpecialDirectories(),c.filesystems={MEMFS:he}},init:(o,i,l)=>{c.init.initialized=!0,c.ensureErrnoError(),n.stdin=o||n.stdin,n.stdout=i||n.stdout,n.stderr=l||n.stderr,c.createStandardStreams()},quit:()=>{c.init.initialized=!1;for(var o=0;o{var l=0;return o&&(l|=365),i&&(l|=146),l},findObject:(o,i)=>{var l=c.analyzePath(o,i);return l.exists?l.object:null},analyzePath:(o,i)=>{try{var l=c.lookupPath(o,{follow:!i});o=l.path}catch{}var a={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var l=c.lookupPath(o,{parent:!0});a.parentExists=!0,a.parentPath=l.path,a.parentObject=l.node,a.name=Ee.basename(o),l=c.lookupPath(o,{follow:!i}),a.exists=!0,a.path=l.path,a.object=l.node,a.name=l.node.name,a.isRoot=l.path==="/"}catch(u){a.error=u.errno}return a},createPath:(o,i,l,a)=>{o=typeof o=="string"?o:c.getPath(o);for(var u=i.split("/").reverse();u.length;){var d=u.pop();if(d){var N=Ee.join2(o,d);try{c.mkdir(N)}catch{}o=N}}return N},createFile:(o,i,l,a,u)=>{var d=Ee.join2(typeof o=="string"?o:c.getPath(o),i),N=c.getMode(a,u);return c.create(d,N)},createDataFile:(o,i,l,a,u,d)=>{var N=i;o&&(o=typeof o=="string"?o:c.getPath(o),N=i?Ee.join2(o,i):o);var S=c.getMode(a,u),C=c.create(N,S);if(l){if(typeof l=="string"){for(var V=new Array(l.length),J=0,ie=l.length;J{var u=Ee.join2(typeof o=="string"?o:c.getPath(o),i),d=c.getMode(!!l,!!a);c.createDevice.major||(c.createDevice.major=64);var N=c.makedev(c.createDevice.major++,0);return c.registerDevice(N,{open:S=>{S.seekable=!1},close:S=>{a&&a.buffer&&a.buffer.length&&a(10)},read:(S,C,V,J,ie)=>{for(var k=0,m=0;m{for(var k=0;k{if(o.isDevice||o.isFolder||o.link||o.contents)return!0;if(typeof XMLHttpRequest<"u")throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(Qe)try{o.contents=mo(Qe(o.url),!0),o.usedBytes=o.contents.length}catch{throw new c.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile:(o,i,l,a,u)=>{function d(){this.lengthKnown=!1,this.chunks=[]}if(d.prototype.get=function(m){if(!(m>this.length-1||m<0)){var y=m%this.chunkSize,x=m/this.chunkSize|0;return this.getter(x)[y]}},d.prototype.setDataGetter=function(m){this.getter=m},d.prototype.cacheLength=function(){var m=new XMLHttpRequest;if(m.open("HEAD",l,!1),m.send(null),!(m.status>=200&&m.status<300||m.status===304))throw new Error("Couldn't load "+l+". Status: "+m.status);var y=Number(m.getResponseHeader("Content-length")),x,E=(x=m.getResponseHeader("Accept-Ranges"))&&x==="bytes",b=(x=m.getResponseHeader("Content-Encoding"))&&x==="gzip",P=1024*1024;E||(P=y);var M=(D,le)=>{if(D>le)throw new Error("invalid range ("+D+", "+le+") or no bytes requested!");if(le>y-1)throw new Error("only "+y+" bytes available! programmer error!");var z=new XMLHttpRequest;if(z.open("GET",l,!1),y!==P&&z.setRequestHeader("Range","bytes="+D+"-"+le),z.responseType="arraybuffer",z.overrideMimeType&&z.overrideMimeType("text/plain; charset=x-user-defined"),z.send(null),!(z.status>=200&&z.status<300||z.status===304))throw new Error("Couldn't load "+l+". Status: "+z.status);return z.response!==void 0?new Uint8Array(z.response||[]):mo(z.responseText||"",!0)},B=this;B.setDataGetter(D=>{var le=D*P,z=(D+1)*P-1;if(z=Math.min(z,y-1),typeof B.chunks[D]>"u"&&(B.chunks[D]=M(le,z)),typeof B.chunks[D]>"u")throw new Error("doXHR failed!");return B.chunks[D]}),(b||!y)&&(P=y=1,y=this.getter(0).length,P=y,wn("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=y,this._chunkSize=P,this.lengthKnown=!0},typeof XMLHttpRequest<"u"){if(!rt)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var N=new d;Object.defineProperties(N,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var S={isDevice:!1,contents:N}}else var S={isDevice:!1,url:l};var C=c.createFile(o,i,S,a,u);S.contents?C.contents=S.contents:S.url&&(C.contents=null,C.url=S.url),Object.defineProperties(C,{usedBytes:{get:function(){return this.contents.length}}});var V={},J=Object.keys(C.stream_ops);J.forEach(k=>{var m=C.stream_ops[k];V[k]=function(){return c.forceLoadFile(C),m.apply(null,arguments)}});function ie(k,m,y,x,E){var b=k.node.contents;if(E>=b.length)return 0;var P=Math.min(b.length-E,x);if(b.slice)for(var M=0;M(c.forceLoadFile(C),ie(k,m,y,x,E)),V.mmap=(k,m,y,x,E)=>{c.forceLoadFile(C);var b=Ga();if(!b)throw new c.ErrnoError(48);return ie(k,Dt,b,m,y),{ptr:b,allocated:!0}},C.stream_ops=V,C},createPreloadedFile:(o,i,l,a,u,d,N,S,C,V)=>{var J=i?qn.resolve(Ee.join2(o,i)):o;function ie(k){function m(y){V&&V(),S||c.createDataFile(o,i,y,a,u,C),d&&d(),Ds()}Browser.handledByPreloadPlugin(k,J,m,()=>{N&&N(),Ds()})||m(k)}po(),typeof l=="string"?Nc(l,k=>ie(k),N):ie(l)},indexedDB:()=>window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,DB_NAME:()=>"EM_FS_"+window.location.pathname,DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:(o,i,l)=>{i=i||(()=>{}),l=l||(()=>{});var a=c.indexedDB();try{var u=a.open(c.DB_NAME(),c.DB_VERSION)}catch(d){return l(d)}u.onupgradeneeded=()=>{wn("creating db");var d=u.result;d.createObjectStore(c.DB_STORE_NAME)},u.onsuccess=()=>{var d=u.result,N=d.transaction([c.DB_STORE_NAME],"readwrite"),S=N.objectStore(c.DB_STORE_NAME),C=0,V=0,J=o.length;function ie(){V==0?i():l()}o.forEach(k=>{var m=S.put(c.analyzePath(k).object.contents,k);m.onsuccess=()=>{C++,C+V==J&&ie()},m.onerror=()=>{V++,C+V==J&&ie()}}),N.onerror=l},u.onerror=l},loadFilesFromDB:(o,i,l)=>{i=i||(()=>{}),l=l||(()=>{});var a=c.indexedDB();try{var u=a.open(c.DB_NAME(),c.DB_VERSION)}catch(d){return l(d)}u.onupgradeneeded=l,u.onsuccess=()=>{var d=u.result;try{var N=d.transaction([c.DB_STORE_NAME],"readonly")}catch(k){l(k);return}var S=N.objectStore(c.DB_STORE_NAME),C=0,V=0,J=o.length;function ie(){V==0?i():l()}o.forEach(k=>{var m=S.get(k);m.onsuccess=()=>{c.analyzePath(k).exists&&c.unlink(k),c.createDataFile(Ee.dirname(k),Ee.basename(k),m.result,!0,!0,!0),C++,C+V==J&&ie()},m.onerror=()=>{V++,C+V==J&&ie()}}),N.onerror=l},u.onerror=l}},fe={DEFAULT_POLLMASK:5,calculateAt:function(o,i,l){if(Ee.isAbs(i))return i;var a;if(o===-100)a=c.cwd();else{var u=fe.getStreamFromFD(o);a=u.path}if(i.length==0){if(!l)throw new c.ErrnoError(44);return a}return Ee.join2(a,i)},doStat:function(o,i,l){try{var a=o(i)}catch(S){if(S&&S.node&&Ee.normalize(i)!==Ee.normalize(c.getPath(S.node)))return-54;throw S}we[l>>2]=a.dev,we[l+8>>2]=a.ino,we[l+12>>2]=a.mode,it[l+16>>2]=a.nlink,we[l+20>>2]=a.uid,we[l+24>>2]=a.gid,we[l+28>>2]=a.rdev,ut=[a.size>>>0,(qe=a.size,+Math.abs(qe)>=1?qe>0?(Math.min(+Math.floor(qe/4294967296),4294967295)|0)>>>0:~~+Math.ceil((qe-+(~~qe>>>0))/4294967296)>>>0:0)],we[l+40>>2]=ut[0],we[l+44>>2]=ut[1],we[l+48>>2]=4096,we[l+52>>2]=a.blocks;var u=a.atime.getTime(),d=a.mtime.getTime(),N=a.ctime.getTime();return ut=[Math.floor(u/1e3)>>>0,(qe=Math.floor(u/1e3),+Math.abs(qe)>=1?qe>0?(Math.min(+Math.floor(qe/4294967296),4294967295)|0)>>>0:~~+Math.ceil((qe-+(~~qe>>>0))/4294967296)>>>0:0)],we[l+56>>2]=ut[0],we[l+60>>2]=ut[1],it[l+64>>2]=u%1e3*1e3,ut=[Math.floor(d/1e3)>>>0,(qe=Math.floor(d/1e3),+Math.abs(qe)>=1?qe>0?(Math.min(+Math.floor(qe/4294967296),4294967295)|0)>>>0:~~+Math.ceil((qe-+(~~qe>>>0))/4294967296)>>>0:0)],we[l+72>>2]=ut[0],we[l+76>>2]=ut[1],it[l+80>>2]=d%1e3*1e3,ut=[Math.floor(N/1e3)>>>0,(qe=Math.floor(N/1e3),+Math.abs(qe)>=1?qe>0?(Math.min(+Math.floor(qe/4294967296),4294967295)|0)>>>0:~~+Math.ceil((qe-+(~~qe>>>0))/4294967296)>>>0:0)],we[l+88>>2]=ut[0],we[l+92>>2]=ut[1],it[l+96>>2]=N%1e3*1e3,ut=[a.ino>>>0,(qe=a.ino,+Math.abs(qe)>=1?qe>0?(Math.min(+Math.floor(qe/4294967296),4294967295)|0)>>>0:~~+Math.ceil((qe-+(~~qe>>>0))/4294967296)>>>0:0)],we[l+104>>2]=ut[0],we[l+108>>2]=ut[1],0},doMsync:function(o,i,l,a,u){if(!c.isFile(i.node.mode))throw new c.ErrnoError(43);if(a&2)return 0;var d=Si.slice(o,o+l);c.msync(i,d,u,l,a)},varargs:void 0,get:function(){fe.varargs+=4;var o=we[fe.varargs-4>>2];return o},getStr:function(o){var i=dc(o);return i},getStreamFromFD:function(o){var i=c.getStream(o);if(!i)throw new c.ErrnoError(8);return i}};function vc(o,i){try{return o=fe.getStr(o),c.chmod(o,i),0}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return-l.errno}}function xc(o,i,l,a){try{if(i=fe.getStr(i),i=fe.calculateAt(o,i),l&-8)return-28;var u=c.lookupPath(i,{follow:!0}),d=u.node;if(!d)return-44;var N="";return l&4&&(N+="r"),l&2&&(N+="w"),l&1&&(N+="x"),N&&c.nodePermissions(d,N)?-2:0}catch(S){if(typeof c>"u"||!(S instanceof c.ErrnoError))throw S;return-S.errno}}function Ec(o,i){try{return c.fchmod(o,i),0}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return-l.errno}}function Sc(o,i,l){try{return c.fchown(o,i,l),0}catch(a){if(typeof c>"u"||!(a instanceof c.ErrnoError))throw a;return-a.errno}}function kc(o){return we[el()>>2]=o,o}function Ic(o,i,l){fe.varargs=l;try{var a=fe.getStreamFromFD(o);switch(i){case 0:{var u=fe.get();if(u<0)return-28;var d;return d=c.createStream(a,u),d.fd}case 1:case 2:return 0;case 3:return a.flags;case 4:{var u=fe.get();return a.flags|=u,0}case 5:{var u=fe.get(),N=0;return Ma[u+N>>1]=2,0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:return kc(28),-1;default:return-28}}catch(S){if(typeof c>"u"||!(S instanceof c.ErrnoError))throw S;return-S.errno}}function Oc(o,i){try{var l=fe.getStreamFromFD(o);return fe.doStat(c.stat,l.path,i)}catch(a){if(typeof c>"u"||!(a instanceof c.ErrnoError))throw a;return-a.errno}}var Ac=9007199254740992,Tc=-9007199254740992;function Ja(o){return oAc?NaN:Number(o)}function Cc(o,i){try{return i=Ja(i),isNaN(i)?-61:(c.ftruncate(o,i),0)}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return-l.errno}}function Wc(o,i){try{if(i===0)return-28;var l=c.cwd(),a=Ei(l)+1;return i"u"||!(u instanceof c.ErrnoError))throw u;return-u.errno}}function Fc(o,i,l){fe.varargs=l;try{var a=fe.getStreamFromFD(o);switch(i){case 21509:case 21505:return a.tty?0:-59;case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:return a.tty?0:-59;case 21519:{if(!a.tty)return-59;var u=fe.get();return we[u>>2]=0,0}case 21520:return a.tty?-28:-59;case 21531:{var u=fe.get();return c.ioctl(a,i,u)}case 21523:return a.tty?0:-59;case 21524:return a.tty?0:-59;default:return-28}}catch(d){if(typeof c>"u"||!(d instanceof c.ErrnoError))throw d;return-d.errno}}function Pc(o,i){try{return o=fe.getStr(o),fe.doStat(c.lstat,o,i)}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return-l.errno}}function Lc(o,i,l){try{return i=fe.getStr(i),i=fe.calculateAt(o,i),i=Ee.normalize(i),i[i.length-1]==="/"&&(i=i.substr(0,i.length-1)),c.mkdir(i,l,0),0}catch(a){if(typeof c>"u"||!(a instanceof c.ErrnoError))throw a;return-a.errno}}function Dc(o,i,l,a){try{i=fe.getStr(i);var u=a&256,d=a&4096;return a=a&-6401,i=fe.calculateAt(o,i,d),fe.doStat(u?c.lstat:c.stat,i,l)}catch(N){if(typeof c>"u"||!(N instanceof c.ErrnoError))throw N;return-N.errno}}function Rc(o,i,l,a){fe.varargs=a;try{i=fe.getStr(i),i=fe.calculateAt(o,i);var u=a?fe.get():0;return c.open(i,l,u).fd}catch(d){if(typeof c>"u"||!(d instanceof c.ErrnoError))throw d;return-d.errno}}function Bc(o,i,l,a){try{if(i=fe.getStr(i),i=fe.calculateAt(o,i),a<=0)return-28;var u=c.readlink(i),d=Math.min(a,Ei(u)),N=Dt[l+d];return Ba(u,l,a+1),Dt[l+d]=N,d}catch(S){if(typeof c>"u"||!(S instanceof c.ErrnoError))throw S;return-S.errno}}function Mc(o){try{return o=fe.getStr(o),c.rmdir(o),0}catch(i){if(typeof c>"u"||!(i instanceof c.ErrnoError))throw i;return-i.errno}}function Uc(o,i){try{return o=fe.getStr(o),fe.doStat(c.stat,o,i)}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return-l.errno}}function jc(o,i,l){try{return i=fe.getStr(i),i=fe.calculateAt(o,i),l===0?c.unlink(i):l===512?c.rmdir(i):Zn("Invalid flags passed to unlinkat"),0}catch(a){if(typeof c>"u"||!(a instanceof c.ErrnoError))throw a;return-a.errno}}function yo(o){return it[o>>2]+we[o+4>>2]*4294967296}function Qc(o,i,l,a){try{if(i=fe.getStr(i),i=fe.calculateAt(o,i,!0),l){var N=yo(l),S=we[l+8>>2];u=N*1e3+S/(1e3*1e3),l+=16,N=yo(l),S=we[l+8>>2],d=N*1e3+S/(1e3*1e3)}else var u=Date.now(),d=u;return c.utime(i,u,d),0}catch(C){if(typeof c>"u"||!(C instanceof c.ErrnoError))throw C;return-C.errno}}var zc=!0;function Vc(){return zc}function Hc(o){return o%4===0&&(o%100!==0||o%400===0)}var $c=[0,31,60,91,121,152,182,213,244,274,305,335],Gc=[0,31,59,90,120,151,181,212,243,273,304,334];function Jc(o){var i=Hc(o.getFullYear()),l=i?$c:Gc,a=l[o.getMonth()]+o.getDate()-1;return a}function Kc(o,i){var l=new Date(yo(o)*1e3);we[i>>2]=l.getSeconds(),we[i+4>>2]=l.getMinutes(),we[i+8>>2]=l.getHours(),we[i+12>>2]=l.getDate(),we[i+16>>2]=l.getMonth(),we[i+20>>2]=l.getFullYear()-1900,we[i+24>>2]=l.getDay();var a=Jc(l)|0;we[i+28>>2]=a,we[i+36>>2]=-(l.getTimezoneOffset()*60);var u=new Date(l.getFullYear(),0,1),d=new Date(l.getFullYear(),6,1).getTimezoneOffset(),N=u.getTimezoneOffset(),S=(d!=N&&l.getTimezoneOffset()==Math.min(N,d))|0;we[i+32>>2]=S}function Ka(o){var i=Ei(o)+1,l=tl(i);return l&&Ls(o,Dt,l,i),l}function Xc(o,i,l){var a=new Date().getFullYear(),u=new Date(a,0,1),d=new Date(a,6,1),N=u.getTimezoneOffset(),S=d.getTimezoneOffset(),C=Math.max(N,S);it[o>>2]=C*60,we[i>>2]=+(N!=S);function V(y){var x=y.toTimeString().match(/\(([A-Za-z ]+)\)$/);return x?x[1]:"GMT"}var J=V(u),ie=V(d),k=Ka(J),m=Ka(ie);S>2]=k,it[l+4>>2]=m):(it[l>>2]=m,it[l+4>>2]=k)}function Yc(){return Date.now()}var Xa;Xa=()=>performance.now();function Zc(){return 2147483648}function ed(o){var i=Fn.buffer;try{return Fn.grow(o-i.byteLength+65535>>>16),Ua(),1}catch{}}function td(o){var i=Si.length;o=o>>>0;var l=Zc();if(o>l)return!1;let a=(C,V)=>C+(V-C%V)%V;for(var u=1;u<=4;u*=2){var d=i*(1+.2/u);d=Math.min(d,o+100663296);var N=Math.min(l,a(Math.max(o,d),65536)),S=ed(N);if(S)return!0}return!1}var go={};function nd(){return At||"./this.program"}function Ii(){if(!Ii.strings){var o=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",i={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:o,_:nd()};for(var l in go)go[l]===void 0?delete i[l]:i[l]=go[l];var a=[];for(var l in i)a.push(l+"="+i[l]);Ii.strings=a}return Ii.strings}function rd(o,i,l){for(var a=0;a>0]=o.charCodeAt(a);l||(Dt[i>>0]=0)}function id(o,i){var l=0;return Ii().forEach(function(a,u){var d=i+l;it[o+u*4>>2]=d,rd(a,d),l+=a.length+1}),0}function sd(o,i){var l=Ii();it[o>>2]=l.length;var a=0;return l.forEach(function(u){a+=u.length+1}),it[i>>2]=a,0}function od(o){try{var i=fe.getStreamFromFD(o);return c.close(i),0}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return l.errno}}function ad(o,i){try{var l=fe.getStreamFromFD(o),a=l.tty?2:c.isDir(l.mode)?3:c.isLink(l.mode)?7:4;return Dt[i>>0]=a,0}catch(u){if(typeof c>"u"||!(u instanceof c.ErrnoError))throw u;return u.errno}}function ld(o,i,l,a){for(var u=0,d=0;d>2],S=it[i+4>>2];i+=8;var C=c.read(o,Dt,N,S,a);if(C<0)return-1;if(u+=C,C>2]=d,0}catch(N){if(typeof c>"u"||!(N instanceof c.ErrnoError))throw N;return N.errno}}function cd(o,i,l,a){try{if(i=Ja(i),isNaN(i))return 61;var u=fe.getStreamFromFD(o);return c.llseek(u,i,l),ut=[u.position>>>0,(qe=u.position,+Math.abs(qe)>=1?qe>0?(Math.min(+Math.floor(qe/4294967296),4294967295)|0)>>>0:~~+Math.ceil((qe-+(~~qe>>>0))/4294967296)>>>0:0)],we[a>>2]=ut[0],we[a+4>>2]=ut[1],u.getdents&&i===0&&l===0&&(u.getdents=null),0}catch(d){if(typeof c>"u"||!(d instanceof c.ErrnoError))throw d;return d.errno}}function dd(o){try{var i=fe.getStreamFromFD(o);return i.stream_ops&&i.stream_ops.fsync?i.stream_ops.fsync(i):0}catch(l){if(typeof c>"u"||!(l instanceof c.ErrnoError))throw l;return l.errno}}function fd(o,i,l,a){for(var u=0,d=0;d>2],S=it[i+4>>2];i+=8;var C=c.write(o,Dt,N,S,a);if(C<0)return-1;u+=C,typeof a<"u"&&(a+=C)}return u}function hd(o,i,l,a){try{var u=fe.getStreamFromFD(o),d=fd(u,i,l);return it[a>>2]=d,0}catch(N){if(typeof c>"u"||!(N instanceof c.ErrnoError))throw N;return N.errno}}var Ya=function(o,i,l,a){o||(o=this),this.parent=o,this.mount=o.mount,this.mounted=null,this.id=c.nextInode++,this.name=i,this.mode=l,this.node_ops={},this.stream_ops={},this.rdev=a},Rs=365,Bs=146;Object.defineProperties(Ya.prototype,{read:{get:function(){return(this.mode&Rs)===Rs},set:function(o){o?this.mode|=Rs:this.mode&=~Rs}},write:{get:function(){return(this.mode&Bs)===Bs},set:function(o){o?this.mode|=Bs:this.mode&=~Bs}},isFolder:{get:function(){return c.isDir(this.mode)}},isDevice:{get:function(){return c.isChrdev(this.mode)}}}),c.FSNode=Ya,c.staticInit();var Za={__syscall_chmod:vc,__syscall_faccessat:xc,__syscall_fchmod:Ec,__syscall_fchown32:Sc,__syscall_fcntl64:Ic,__syscall_fstat64:Oc,__syscall_ftruncate64:Cc,__syscall_getcwd:Wc,__syscall_ioctl:Fc,__syscall_lstat64:Pc,__syscall_mkdirat:Lc,__syscall_newfstatat:Dc,__syscall_openat:Rc,__syscall_readlinkat:Bc,__syscall_rmdir:Mc,__syscall_stat64:Uc,__syscall_unlinkat:jc,__syscall_utimensat:Qc,_emscripten_get_now_is_monotonic:Vc,_localtime_js:Kc,_tzset_js:Xc,emscripten_date_now:Yc,emscripten_get_now:Xa,emscripten_resize_heap:td,environ_get:id,environ_sizes_get:sd,fd_close:od,fd_fdstat_get:ad,fd_read:ud,fd_seek:cd,fd_sync:dd,fd_write:hd,memory:Fn};qc(),n.___wasm_call_ctors=function(){return(n.___wasm_call_ctors=n.asm.__wasm_call_ctors).apply(null,arguments)},n._sqlite3_status64=function(){return(n._sqlite3_status64=n.asm.sqlite3_status64).apply(null,arguments)},n._sqlite3_status=function(){return(n._sqlite3_status=n.asm.sqlite3_status).apply(null,arguments)},n._sqlite3_db_status=function(){return(n._sqlite3_db_status=n.asm.sqlite3_db_status).apply(null,arguments)},n._sqlite3_msize=function(){return(n._sqlite3_msize=n.asm.sqlite3_msize).apply(null,arguments)},n._sqlite3_vfs_find=function(){return(n._sqlite3_vfs_find=n.asm.sqlite3_vfs_find).apply(null,arguments)},n._sqlite3_initialize=function(){return(n._sqlite3_initialize=n.asm.sqlite3_initialize).apply(null,arguments)},n._sqlite3_malloc=function(){return(n._sqlite3_malloc=n.asm.sqlite3_malloc).apply(null,arguments)},n._sqlite3_free=function(){return(n._sqlite3_free=n.asm.sqlite3_free).apply(null,arguments)},n._sqlite3_vfs_register=function(){return(n._sqlite3_vfs_register=n.asm.sqlite3_vfs_register).apply(null,arguments)},n._sqlite3_vfs_unregister=function(){return(n._sqlite3_vfs_unregister=n.asm.sqlite3_vfs_unregister).apply(null,arguments)},n._sqlite3_malloc64=function(){return(n._sqlite3_malloc64=n.asm.sqlite3_malloc64).apply(null,arguments)},n._sqlite3_realloc=function(){return(n._sqlite3_realloc=n.asm.sqlite3_realloc).apply(null,arguments)},n._sqlite3_realloc64=function(){return(n._sqlite3_realloc64=n.asm.sqlite3_realloc64).apply(null,arguments)},n._sqlite3_value_text=function(){return(n._sqlite3_value_text=n.asm.sqlite3_value_text).apply(null,arguments)},n._sqlite3_randomness=function(){return(n._sqlite3_randomness=n.asm.sqlite3_randomness).apply(null,arguments)},n._sqlite3_stricmp=function(){return(n._sqlite3_stricmp=n.asm.sqlite3_stricmp).apply(null,arguments)},n._sqlite3_strnicmp=function(){return(n._sqlite3_strnicmp=n.asm.sqlite3_strnicmp).apply(null,arguments)},n._sqlite3_uri_parameter=function(){return(n._sqlite3_uri_parameter=n.asm.sqlite3_uri_parameter).apply(null,arguments)};var el=n.___errno_location=function(){return(el=n.___errno_location=n.asm.__errno_location).apply(null,arguments)};n._sqlite3_uri_boolean=function(){return(n._sqlite3_uri_boolean=n.asm.sqlite3_uri_boolean).apply(null,arguments)},n._sqlite3_serialize=function(){return(n._sqlite3_serialize=n.asm.sqlite3_serialize).apply(null,arguments)},n._sqlite3_prepare_v2=function(){return(n._sqlite3_prepare_v2=n.asm.sqlite3_prepare_v2).apply(null,arguments)},n._sqlite3_step=function(){return(n._sqlite3_step=n.asm.sqlite3_step).apply(null,arguments)},n._sqlite3_column_int64=function(){return(n._sqlite3_column_int64=n.asm.sqlite3_column_int64).apply(null,arguments)},n._sqlite3_column_int=function(){return(n._sqlite3_column_int=n.asm.sqlite3_column_int).apply(null,arguments)},n._sqlite3_finalize=function(){return(n._sqlite3_finalize=n.asm.sqlite3_finalize).apply(null,arguments)},n._sqlite3_file_control=function(){return(n._sqlite3_file_control=n.asm.sqlite3_file_control).apply(null,arguments)},n._sqlite3_reset=function(){return(n._sqlite3_reset=n.asm.sqlite3_reset).apply(null,arguments)},n._sqlite3_deserialize=function(){return(n._sqlite3_deserialize=n.asm.sqlite3_deserialize).apply(null,arguments)},n._sqlite3_clear_bindings=function(){return(n._sqlite3_clear_bindings=n.asm.sqlite3_clear_bindings).apply(null,arguments)},n._sqlite3_value_blob=function(){return(n._sqlite3_value_blob=n.asm.sqlite3_value_blob).apply(null,arguments)},n._sqlite3_value_bytes=function(){return(n._sqlite3_value_bytes=n.asm.sqlite3_value_bytes).apply(null,arguments)},n._sqlite3_value_double=function(){return(n._sqlite3_value_double=n.asm.sqlite3_value_double).apply(null,arguments)},n._sqlite3_value_int=function(){return(n._sqlite3_value_int=n.asm.sqlite3_value_int).apply(null,arguments)},n._sqlite3_value_int64=function(){return(n._sqlite3_value_int64=n.asm.sqlite3_value_int64).apply(null,arguments)},n._sqlite3_value_subtype=function(){return(n._sqlite3_value_subtype=n.asm.sqlite3_value_subtype).apply(null,arguments)},n._sqlite3_value_pointer=function(){return(n._sqlite3_value_pointer=n.asm.sqlite3_value_pointer).apply(null,arguments)},n._sqlite3_value_type=function(){return(n._sqlite3_value_type=n.asm.sqlite3_value_type).apply(null,arguments)},n._sqlite3_value_nochange=function(){return(n._sqlite3_value_nochange=n.asm.sqlite3_value_nochange).apply(null,arguments)},n._sqlite3_value_frombind=function(){return(n._sqlite3_value_frombind=n.asm.sqlite3_value_frombind).apply(null,arguments)},n._sqlite3_value_dup=function(){return(n._sqlite3_value_dup=n.asm.sqlite3_value_dup).apply(null,arguments)},n._sqlite3_value_free=function(){return(n._sqlite3_value_free=n.asm.sqlite3_value_free).apply(null,arguments)},n._sqlite3_result_blob=function(){return(n._sqlite3_result_blob=n.asm.sqlite3_result_blob).apply(null,arguments)},n._sqlite3_result_error_nomem=function(){return(n._sqlite3_result_error_nomem=n.asm.sqlite3_result_error_nomem).apply(null,arguments)},n._sqlite3_result_error_toobig=function(){return(n._sqlite3_result_error_toobig=n.asm.sqlite3_result_error_toobig).apply(null,arguments)},n._sqlite3_result_double=function(){return(n._sqlite3_result_double=n.asm.sqlite3_result_double).apply(null,arguments)},n._sqlite3_result_error=function(){return(n._sqlite3_result_error=n.asm.sqlite3_result_error).apply(null,arguments)},n._sqlite3_result_int=function(){return(n._sqlite3_result_int=n.asm.sqlite3_result_int).apply(null,arguments)},n._sqlite3_result_int64=function(){return(n._sqlite3_result_int64=n.asm.sqlite3_result_int64).apply(null,arguments)},n._sqlite3_result_null=function(){return(n._sqlite3_result_null=n.asm.sqlite3_result_null).apply(null,arguments)},n._sqlite3_result_pointer=function(){return(n._sqlite3_result_pointer=n.asm.sqlite3_result_pointer).apply(null,arguments)},n._sqlite3_result_subtype=function(){return(n._sqlite3_result_subtype=n.asm.sqlite3_result_subtype).apply(null,arguments)},n._sqlite3_result_text=function(){return(n._sqlite3_result_text=n.asm.sqlite3_result_text).apply(null,arguments)},n._sqlite3_result_zeroblob=function(){return(n._sqlite3_result_zeroblob=n.asm.sqlite3_result_zeroblob).apply(null,arguments)},n._sqlite3_result_zeroblob64=function(){return(n._sqlite3_result_zeroblob64=n.asm.sqlite3_result_zeroblob64).apply(null,arguments)},n._sqlite3_result_error_code=function(){return(n._sqlite3_result_error_code=n.asm.sqlite3_result_error_code).apply(null,arguments)},n._sqlite3_user_data=function(){return(n._sqlite3_user_data=n.asm.sqlite3_user_data).apply(null,arguments)},n._sqlite3_context_db_handle=function(){return(n._sqlite3_context_db_handle=n.asm.sqlite3_context_db_handle).apply(null,arguments)},n._sqlite3_vtab_nochange=function(){return(n._sqlite3_vtab_nochange=n.asm.sqlite3_vtab_nochange).apply(null,arguments)},n._sqlite3_vtab_in_first=function(){return(n._sqlite3_vtab_in_first=n.asm.sqlite3_vtab_in_first).apply(null,arguments)},n._sqlite3_vtab_in_next=function(){return(n._sqlite3_vtab_in_next=n.asm.sqlite3_vtab_in_next).apply(null,arguments)},n._sqlite3_aggregate_context=function(){return(n._sqlite3_aggregate_context=n.asm.sqlite3_aggregate_context).apply(null,arguments)},n._sqlite3_get_auxdata=function(){return(n._sqlite3_get_auxdata=n.asm.sqlite3_get_auxdata).apply(null,arguments)},n._sqlite3_set_auxdata=function(){return(n._sqlite3_set_auxdata=n.asm.sqlite3_set_auxdata).apply(null,arguments)},n._sqlite3_column_count=function(){return(n._sqlite3_column_count=n.asm.sqlite3_column_count).apply(null,arguments)},n._sqlite3_data_count=function(){return(n._sqlite3_data_count=n.asm.sqlite3_data_count).apply(null,arguments)},n._sqlite3_column_blob=function(){return(n._sqlite3_column_blob=n.asm.sqlite3_column_blob).apply(null,arguments)},n._sqlite3_column_bytes=function(){return(n._sqlite3_column_bytes=n.asm.sqlite3_column_bytes).apply(null,arguments)},n._sqlite3_column_double=function(){return(n._sqlite3_column_double=n.asm.sqlite3_column_double).apply(null,arguments)},n._sqlite3_column_text=function(){return(n._sqlite3_column_text=n.asm.sqlite3_column_text).apply(null,arguments)},n._sqlite3_column_value=function(){return(n._sqlite3_column_value=n.asm.sqlite3_column_value).apply(null,arguments)},n._sqlite3_column_type=function(){return(n._sqlite3_column_type=n.asm.sqlite3_column_type).apply(null,arguments)},n._sqlite3_column_name=function(){return(n._sqlite3_column_name=n.asm.sqlite3_column_name).apply(null,arguments)},n._sqlite3_bind_blob=function(){return(n._sqlite3_bind_blob=n.asm.sqlite3_bind_blob).apply(null,arguments)},n._sqlite3_bind_double=function(){return(n._sqlite3_bind_double=n.asm.sqlite3_bind_double).apply(null,arguments)},n._sqlite3_bind_int=function(){return(n._sqlite3_bind_int=n.asm.sqlite3_bind_int).apply(null,arguments)},n._sqlite3_bind_int64=function(){return(n._sqlite3_bind_int64=n.asm.sqlite3_bind_int64).apply(null,arguments)},n._sqlite3_bind_null=function(){return(n._sqlite3_bind_null=n.asm.sqlite3_bind_null).apply(null,arguments)},n._sqlite3_bind_pointer=function(){return(n._sqlite3_bind_pointer=n.asm.sqlite3_bind_pointer).apply(null,arguments)},n._sqlite3_bind_text=function(){return(n._sqlite3_bind_text=n.asm.sqlite3_bind_text).apply(null,arguments)},n._sqlite3_bind_parameter_count=function(){return(n._sqlite3_bind_parameter_count=n.asm.sqlite3_bind_parameter_count).apply(null,arguments)},n._sqlite3_bind_parameter_index=function(){return(n._sqlite3_bind_parameter_index=n.asm.sqlite3_bind_parameter_index).apply(null,arguments)},n._sqlite3_db_handle=function(){return(n._sqlite3_db_handle=n.asm.sqlite3_db_handle).apply(null,arguments)},n._sqlite3_stmt_readonly=function(){return(n._sqlite3_stmt_readonly=n.asm.sqlite3_stmt_readonly).apply(null,arguments)},n._sqlite3_stmt_isexplain=function(){return(n._sqlite3_stmt_isexplain=n.asm.sqlite3_stmt_isexplain).apply(null,arguments)},n._sqlite3_stmt_status=function(){return(n._sqlite3_stmt_status=n.asm.sqlite3_stmt_status).apply(null,arguments)},n._sqlite3_sql=function(){return(n._sqlite3_sql=n.asm.sqlite3_sql).apply(null,arguments)},n._sqlite3_expanded_sql=function(){return(n._sqlite3_expanded_sql=n.asm.sqlite3_expanded_sql).apply(null,arguments)},n._sqlite3_preupdate_old=function(){return(n._sqlite3_preupdate_old=n.asm.sqlite3_preupdate_old).apply(null,arguments)},n._sqlite3_preupdate_count=function(){return(n._sqlite3_preupdate_count=n.asm.sqlite3_preupdate_count).apply(null,arguments)},n._sqlite3_preupdate_depth=function(){return(n._sqlite3_preupdate_depth=n.asm.sqlite3_preupdate_depth).apply(null,arguments)},n._sqlite3_preupdate_blobwrite=function(){return(n._sqlite3_preupdate_blobwrite=n.asm.sqlite3_preupdate_blobwrite).apply(null,arguments)},n._sqlite3_preupdate_new=function(){return(n._sqlite3_preupdate_new=n.asm.sqlite3_preupdate_new).apply(null,arguments)},n._sqlite3_value_numeric_type=function(){return(n._sqlite3_value_numeric_type=n.asm.sqlite3_value_numeric_type).apply(null,arguments)},n._sqlite3_errmsg=function(){return(n._sqlite3_errmsg=n.asm.sqlite3_errmsg).apply(null,arguments)},n._sqlite3_set_authorizer=function(){return(n._sqlite3_set_authorizer=n.asm.sqlite3_set_authorizer).apply(null,arguments)},n._sqlite3_strglob=function(){return(n._sqlite3_strglob=n.asm.sqlite3_strglob).apply(null,arguments)},n._sqlite3_strlike=function(){return(n._sqlite3_strlike=n.asm.sqlite3_strlike).apply(null,arguments)},n._sqlite3_exec=function(){return(n._sqlite3_exec=n.asm.sqlite3_exec).apply(null,arguments)},n._sqlite3_auto_extension=function(){return(n._sqlite3_auto_extension=n.asm.sqlite3_auto_extension).apply(null,arguments)},n._sqlite3_cancel_auto_extension=function(){return(n._sqlite3_cancel_auto_extension=n.asm.sqlite3_cancel_auto_extension).apply(null,arguments)},n._sqlite3_reset_auto_extension=function(){return(n._sqlite3_reset_auto_extension=n.asm.sqlite3_reset_auto_extension).apply(null,arguments)},n._sqlite3_prepare_v3=function(){return(n._sqlite3_prepare_v3=n.asm.sqlite3_prepare_v3).apply(null,arguments)},n._sqlite3_create_module=function(){return(n._sqlite3_create_module=n.asm.sqlite3_create_module).apply(null,arguments)},n._sqlite3_create_module_v2=function(){return(n._sqlite3_create_module_v2=n.asm.sqlite3_create_module_v2).apply(null,arguments)},n._sqlite3_drop_modules=function(){return(n._sqlite3_drop_modules=n.asm.sqlite3_drop_modules).apply(null,arguments)},n._sqlite3_declare_vtab=function(){return(n._sqlite3_declare_vtab=n.asm.sqlite3_declare_vtab).apply(null,arguments)},n._sqlite3_vtab_on_conflict=function(){return(n._sqlite3_vtab_on_conflict=n.asm.sqlite3_vtab_on_conflict).apply(null,arguments)},n._sqlite3_vtab_collation=function(){return(n._sqlite3_vtab_collation=n.asm.sqlite3_vtab_collation).apply(null,arguments)},n._sqlite3_vtab_in=function(){return(n._sqlite3_vtab_in=n.asm.sqlite3_vtab_in).apply(null,arguments)},n._sqlite3_vtab_rhs_value=function(){return(n._sqlite3_vtab_rhs_value=n.asm.sqlite3_vtab_rhs_value).apply(null,arguments)},n._sqlite3_vtab_distinct=function(){return(n._sqlite3_vtab_distinct=n.asm.sqlite3_vtab_distinct).apply(null,arguments)},n._sqlite3_keyword_name=function(){return(n._sqlite3_keyword_name=n.asm.sqlite3_keyword_name).apply(null,arguments)},n._sqlite3_keyword_count=function(){return(n._sqlite3_keyword_count=n.asm.sqlite3_keyword_count).apply(null,arguments)},n._sqlite3_keyword_check=function(){return(n._sqlite3_keyword_check=n.asm.sqlite3_keyword_check).apply(null,arguments)},n._sqlite3_complete=function(){return(n._sqlite3_complete=n.asm.sqlite3_complete).apply(null,arguments)},n._sqlite3_libversion=function(){return(n._sqlite3_libversion=n.asm.sqlite3_libversion).apply(null,arguments)},n._sqlite3_libversion_number=function(){return(n._sqlite3_libversion_number=n.asm.sqlite3_libversion_number).apply(null,arguments)},n._sqlite3_shutdown=function(){return(n._sqlite3_shutdown=n.asm.sqlite3_shutdown).apply(null,arguments)},n._sqlite3_last_insert_rowid=function(){return(n._sqlite3_last_insert_rowid=n.asm.sqlite3_last_insert_rowid).apply(null,arguments)},n._sqlite3_set_last_insert_rowid=function(){return(n._sqlite3_set_last_insert_rowid=n.asm.sqlite3_set_last_insert_rowid).apply(null,arguments)},n._sqlite3_changes64=function(){return(n._sqlite3_changes64=n.asm.sqlite3_changes64).apply(null,arguments)},n._sqlite3_changes=function(){return(n._sqlite3_changes=n.asm.sqlite3_changes).apply(null,arguments)},n._sqlite3_total_changes64=function(){return(n._sqlite3_total_changes64=n.asm.sqlite3_total_changes64).apply(null,arguments)},n._sqlite3_total_changes=function(){return(n._sqlite3_total_changes=n.asm.sqlite3_total_changes).apply(null,arguments)},n._sqlite3_txn_state=function(){return(n._sqlite3_txn_state=n.asm.sqlite3_txn_state).apply(null,arguments)},n._sqlite3_close_v2=function(){return(n._sqlite3_close_v2=n.asm.sqlite3_close_v2).apply(null,arguments)},n._sqlite3_busy_handler=function(){return(n._sqlite3_busy_handler=n.asm.sqlite3_busy_handler).apply(null,arguments)},n._sqlite3_progress_handler=function(){return(n._sqlite3_progress_handler=n.asm.sqlite3_progress_handler).apply(null,arguments)},n._sqlite3_busy_timeout=function(){return(n._sqlite3_busy_timeout=n.asm.sqlite3_busy_timeout).apply(null,arguments)},n._sqlite3_create_function=function(){return(n._sqlite3_create_function=n.asm.sqlite3_create_function).apply(null,arguments)},n._sqlite3_create_function_v2=function(){return(n._sqlite3_create_function_v2=n.asm.sqlite3_create_function_v2).apply(null,arguments)},n._sqlite3_create_window_function=function(){return(n._sqlite3_create_window_function=n.asm.sqlite3_create_window_function).apply(null,arguments)},n._sqlite3_overload_function=function(){return(n._sqlite3_overload_function=n.asm.sqlite3_overload_function).apply(null,arguments)},n._sqlite3_trace_v2=function(){return(n._sqlite3_trace_v2=n.asm.sqlite3_trace_v2).apply(null,arguments)},n._sqlite3_commit_hook=function(){return(n._sqlite3_commit_hook=n.asm.sqlite3_commit_hook).apply(null,arguments)},n._sqlite3_update_hook=function(){return(n._sqlite3_update_hook=n.asm.sqlite3_update_hook).apply(null,arguments)},n._sqlite3_rollback_hook=function(){return(n._sqlite3_rollback_hook=n.asm.sqlite3_rollback_hook).apply(null,arguments)},n._sqlite3_preupdate_hook=function(){return(n._sqlite3_preupdate_hook=n.asm.sqlite3_preupdate_hook).apply(null,arguments)},n._sqlite3_error_offset=function(){return(n._sqlite3_error_offset=n.asm.sqlite3_error_offset).apply(null,arguments)},n._sqlite3_errcode=function(){return(n._sqlite3_errcode=n.asm.sqlite3_errcode).apply(null,arguments)},n._sqlite3_extended_errcode=function(){return(n._sqlite3_extended_errcode=n.asm.sqlite3_extended_errcode).apply(null,arguments)},n._sqlite3_errstr=function(){return(n._sqlite3_errstr=n.asm.sqlite3_errstr).apply(null,arguments)},n._sqlite3_limit=function(){return(n._sqlite3_limit=n.asm.sqlite3_limit).apply(null,arguments)},n._sqlite3_open=function(){return(n._sqlite3_open=n.asm.sqlite3_open).apply(null,arguments)},n._sqlite3_open_v2=function(){return(n._sqlite3_open_v2=n.asm.sqlite3_open_v2).apply(null,arguments)},n._sqlite3_create_collation=function(){return(n._sqlite3_create_collation=n.asm.sqlite3_create_collation).apply(null,arguments)},n._sqlite3_create_collation_v2=function(){return(n._sqlite3_create_collation_v2=n.asm.sqlite3_create_collation_v2).apply(null,arguments)},n._sqlite3_collation_needed=function(){return(n._sqlite3_collation_needed=n.asm.sqlite3_collation_needed).apply(null,arguments)},n._sqlite3_table_column_metadata=function(){return(n._sqlite3_table_column_metadata=n.asm.sqlite3_table_column_metadata).apply(null,arguments)},n._sqlite3_extended_result_codes=function(){return(n._sqlite3_extended_result_codes=n.asm.sqlite3_extended_result_codes).apply(null,arguments)},n._sqlite3_uri_key=function(){return(n._sqlite3_uri_key=n.asm.sqlite3_uri_key).apply(null,arguments)},n._sqlite3_uri_int64=function(){return(n._sqlite3_uri_int64=n.asm.sqlite3_uri_int64).apply(null,arguments)},n._sqlite3_db_name=function(){return(n._sqlite3_db_name=n.asm.sqlite3_db_name).apply(null,arguments)},n._sqlite3_db_filename=function(){return(n._sqlite3_db_filename=n.asm.sqlite3_db_filename).apply(null,arguments)},n._sqlite3_compileoption_used=function(){return(n._sqlite3_compileoption_used=n.asm.sqlite3_compileoption_used).apply(null,arguments)},n._sqlite3_compileoption_get=function(){return(n._sqlite3_compileoption_get=n.asm.sqlite3_compileoption_get).apply(null,arguments)},n._sqlite3session_diff=function(){return(n._sqlite3session_diff=n.asm.sqlite3session_diff).apply(null,arguments)},n._sqlite3session_attach=function(){return(n._sqlite3session_attach=n.asm.sqlite3session_attach).apply(null,arguments)},n._sqlite3session_create=function(){return(n._sqlite3session_create=n.asm.sqlite3session_create).apply(null,arguments)},n._sqlite3session_delete=function(){return(n._sqlite3session_delete=n.asm.sqlite3session_delete).apply(null,arguments)},n._sqlite3session_table_filter=function(){return(n._sqlite3session_table_filter=n.asm.sqlite3session_table_filter).apply(null,arguments)},n._sqlite3session_changeset=function(){return(n._sqlite3session_changeset=n.asm.sqlite3session_changeset).apply(null,arguments)},n._sqlite3session_changeset_strm=function(){return(n._sqlite3session_changeset_strm=n.asm.sqlite3session_changeset_strm).apply(null,arguments)},n._sqlite3session_patchset_strm=function(){return(n._sqlite3session_patchset_strm=n.asm.sqlite3session_patchset_strm).apply(null,arguments)},n._sqlite3session_patchset=function(){return(n._sqlite3session_patchset=n.asm.sqlite3session_patchset).apply(null,arguments)},n._sqlite3session_enable=function(){return(n._sqlite3session_enable=n.asm.sqlite3session_enable).apply(null,arguments)},n._sqlite3session_indirect=function(){return(n._sqlite3session_indirect=n.asm.sqlite3session_indirect).apply(null,arguments)},n._sqlite3session_isempty=function(){return(n._sqlite3session_isempty=n.asm.sqlite3session_isempty).apply(null,arguments)},n._sqlite3session_memory_used=function(){return(n._sqlite3session_memory_used=n.asm.sqlite3session_memory_used).apply(null,arguments)},n._sqlite3session_object_config=function(){return(n._sqlite3session_object_config=n.asm.sqlite3session_object_config).apply(null,arguments)},n._sqlite3session_changeset_size=function(){return(n._sqlite3session_changeset_size=n.asm.sqlite3session_changeset_size).apply(null,arguments)},n._sqlite3changeset_start=function(){return(n._sqlite3changeset_start=n.asm.sqlite3changeset_start).apply(null,arguments)},n._sqlite3changeset_start_v2=function(){return(n._sqlite3changeset_start_v2=n.asm.sqlite3changeset_start_v2).apply(null,arguments)},n._sqlite3changeset_start_strm=function(){return(n._sqlite3changeset_start_strm=n.asm.sqlite3changeset_start_strm).apply(null,arguments)},n._sqlite3changeset_start_v2_strm=function(){return(n._sqlite3changeset_start_v2_strm=n.asm.sqlite3changeset_start_v2_strm).apply(null,arguments)},n._sqlite3changeset_next=function(){return(n._sqlite3changeset_next=n.asm.sqlite3changeset_next).apply(null,arguments)},n._sqlite3changeset_op=function(){return(n._sqlite3changeset_op=n.asm.sqlite3changeset_op).apply(null,arguments)},n._sqlite3changeset_pk=function(){return(n._sqlite3changeset_pk=n.asm.sqlite3changeset_pk).apply(null,arguments)},n._sqlite3changeset_old=function(){return(n._sqlite3changeset_old=n.asm.sqlite3changeset_old).apply(null,arguments)},n._sqlite3changeset_new=function(){return(n._sqlite3changeset_new=n.asm.sqlite3changeset_new).apply(null,arguments)},n._sqlite3changeset_conflict=function(){return(n._sqlite3changeset_conflict=n.asm.sqlite3changeset_conflict).apply(null,arguments)},n._sqlite3changeset_fk_conflicts=function(){return(n._sqlite3changeset_fk_conflicts=n.asm.sqlite3changeset_fk_conflicts).apply(null,arguments)},n._sqlite3changeset_finalize=function(){return(n._sqlite3changeset_finalize=n.asm.sqlite3changeset_finalize).apply(null,arguments)},n._sqlite3changeset_invert=function(){return(n._sqlite3changeset_invert=n.asm.sqlite3changeset_invert).apply(null,arguments)},n._sqlite3changeset_invert_strm=function(){return(n._sqlite3changeset_invert_strm=n.asm.sqlite3changeset_invert_strm).apply(null,arguments)},n._sqlite3changeset_apply_v2=function(){return(n._sqlite3changeset_apply_v2=n.asm.sqlite3changeset_apply_v2).apply(null,arguments)},n._sqlite3changeset_apply=function(){return(n._sqlite3changeset_apply=n.asm.sqlite3changeset_apply).apply(null,arguments)},n._sqlite3changeset_apply_v2_strm=function(){return(n._sqlite3changeset_apply_v2_strm=n.asm.sqlite3changeset_apply_v2_strm).apply(null,arguments)},n._sqlite3changeset_apply_strm=function(){return(n._sqlite3changeset_apply_strm=n.asm.sqlite3changeset_apply_strm).apply(null,arguments)},n._sqlite3changegroup_new=function(){return(n._sqlite3changegroup_new=n.asm.sqlite3changegroup_new).apply(null,arguments)},n._sqlite3changegroup_add=function(){return(n._sqlite3changegroup_add=n.asm.sqlite3changegroup_add).apply(null,arguments)},n._sqlite3changegroup_output=function(){return(n._sqlite3changegroup_output=n.asm.sqlite3changegroup_output).apply(null,arguments)},n._sqlite3changegroup_add_strm=function(){return(n._sqlite3changegroup_add_strm=n.asm.sqlite3changegroup_add_strm).apply(null,arguments)},n._sqlite3changegroup_output_strm=function(){return(n._sqlite3changegroup_output_strm=n.asm.sqlite3changegroup_output_strm).apply(null,arguments)},n._sqlite3changegroup_delete=function(){return(n._sqlite3changegroup_delete=n.asm.sqlite3changegroup_delete).apply(null,arguments)},n._sqlite3changeset_concat=function(){return(n._sqlite3changeset_concat=n.asm.sqlite3changeset_concat).apply(null,arguments)},n._sqlite3changeset_concat_strm=function(){return(n._sqlite3changeset_concat_strm=n.asm.sqlite3changeset_concat_strm).apply(null,arguments)},n._sqlite3session_config=function(){return(n._sqlite3session_config=n.asm.sqlite3session_config).apply(null,arguments)},n._sqlite3_sourceid=function(){return(n._sqlite3_sourceid=n.asm.sqlite3_sourceid).apply(null,arguments)},n._sqlite3_wasm_pstack_ptr=function(){return(n._sqlite3_wasm_pstack_ptr=n.asm.sqlite3_wasm_pstack_ptr).apply(null,arguments)},n._sqlite3_wasm_pstack_restore=function(){return(n._sqlite3_wasm_pstack_restore=n.asm.sqlite3_wasm_pstack_restore).apply(null,arguments)},n._sqlite3_wasm_pstack_alloc=function(){return(n._sqlite3_wasm_pstack_alloc=n.asm.sqlite3_wasm_pstack_alloc).apply(null,arguments)},n._sqlite3_wasm_pstack_remaining=function(){return(n._sqlite3_wasm_pstack_remaining=n.asm.sqlite3_wasm_pstack_remaining).apply(null,arguments)},n._sqlite3_wasm_pstack_quota=function(){return(n._sqlite3_wasm_pstack_quota=n.asm.sqlite3_wasm_pstack_quota).apply(null,arguments)},n._sqlite3_wasm_db_error=function(){return(n._sqlite3_wasm_db_error=n.asm.sqlite3_wasm_db_error).apply(null,arguments)},n._sqlite3_wasm_test_struct=function(){return(n._sqlite3_wasm_test_struct=n.asm.sqlite3_wasm_test_struct).apply(null,arguments)},n._sqlite3_wasm_enum_json=function(){return(n._sqlite3_wasm_enum_json=n.asm.sqlite3_wasm_enum_json).apply(null,arguments)},n._sqlite3_wasm_vfs_unlink=function(){return(n._sqlite3_wasm_vfs_unlink=n.asm.sqlite3_wasm_vfs_unlink).apply(null,arguments)},n._sqlite3_wasm_db_vfs=function(){return(n._sqlite3_wasm_db_vfs=n.asm.sqlite3_wasm_db_vfs).apply(null,arguments)},n._sqlite3_wasm_db_reset=function(){return(n._sqlite3_wasm_db_reset=n.asm.sqlite3_wasm_db_reset).apply(null,arguments)},n._sqlite3_wasm_db_export_chunked=function(){return(n._sqlite3_wasm_db_export_chunked=n.asm.sqlite3_wasm_db_export_chunked).apply(null,arguments)},n._sqlite3_wasm_db_serialize=function(){return(n._sqlite3_wasm_db_serialize=n.asm.sqlite3_wasm_db_serialize).apply(null,arguments)},n._sqlite3_wasm_vfs_create_file=function(){return(n._sqlite3_wasm_vfs_create_file=n.asm.sqlite3_wasm_vfs_create_file).apply(null,arguments)},n._sqlite3_wasm_kvvfsMakeKeyOnPstack=function(){return(n._sqlite3_wasm_kvvfsMakeKeyOnPstack=n.asm.sqlite3_wasm_kvvfsMakeKeyOnPstack).apply(null,arguments)},n._sqlite3_wasm_kvvfs_methods=function(){return(n._sqlite3_wasm_kvvfs_methods=n.asm.sqlite3_wasm_kvvfs_methods).apply(null,arguments)},n._sqlite3_wasm_vtab_config=function(){return(n._sqlite3_wasm_vtab_config=n.asm.sqlite3_wasm_vtab_config).apply(null,arguments)},n._sqlite3_wasm_db_config_ip=function(){return(n._sqlite3_wasm_db_config_ip=n.asm.sqlite3_wasm_db_config_ip).apply(null,arguments)},n._sqlite3_wasm_db_config_pii=function(){return(n._sqlite3_wasm_db_config_pii=n.asm.sqlite3_wasm_db_config_pii).apply(null,arguments)},n._sqlite3_wasm_db_config_s=function(){return(n._sqlite3_wasm_db_config_s=n.asm.sqlite3_wasm_db_config_s).apply(null,arguments)},n._sqlite3_wasm_config_i=function(){return(n._sqlite3_wasm_config_i=n.asm.sqlite3_wasm_config_i).apply(null,arguments)},n._sqlite3_wasm_config_ii=function(){return(n._sqlite3_wasm_config_ii=n.asm.sqlite3_wasm_config_ii).apply(null,arguments)},n._sqlite3_wasm_config_j=function(){return(n._sqlite3_wasm_config_j=n.asm.sqlite3_wasm_config_j).apply(null,arguments)},n._sqlite3_wasm_init_wasmfs=function(){return(n._sqlite3_wasm_init_wasmfs=n.asm.sqlite3_wasm_init_wasmfs).apply(null,arguments)},n._sqlite3_wasm_test_intptr=function(){return(n._sqlite3_wasm_test_intptr=n.asm.sqlite3_wasm_test_intptr).apply(null,arguments)},n._sqlite3_wasm_test_voidptr=function(){return(n._sqlite3_wasm_test_voidptr=n.asm.sqlite3_wasm_test_voidptr).apply(null,arguments)},n._sqlite3_wasm_test_int64_max=function(){return(n._sqlite3_wasm_test_int64_max=n.asm.sqlite3_wasm_test_int64_max).apply(null,arguments)},n._sqlite3_wasm_test_int64_min=function(){return(n._sqlite3_wasm_test_int64_min=n.asm.sqlite3_wasm_test_int64_min).apply(null,arguments)},n._sqlite3_wasm_test_int64_times2=function(){return(n._sqlite3_wasm_test_int64_times2=n.asm.sqlite3_wasm_test_int64_times2).apply(null,arguments)},n._sqlite3_wasm_test_int64_minmax=function(){return(n._sqlite3_wasm_test_int64_minmax=n.asm.sqlite3_wasm_test_int64_minmax).apply(null,arguments)},n._sqlite3_wasm_test_int64ptr=function(){return(n._sqlite3_wasm_test_int64ptr=n.asm.sqlite3_wasm_test_int64ptr).apply(null,arguments)},n._sqlite3_wasm_test_stack_overflow=function(){return(n._sqlite3_wasm_test_stack_overflow=n.asm.sqlite3_wasm_test_stack_overflow).apply(null,arguments)},n._sqlite3_wasm_test_str_hello=function(){return(n._sqlite3_wasm_test_str_hello=n.asm.sqlite3_wasm_test_str_hello).apply(null,arguments)};var tl=n._malloc=function(){return(tl=n._malloc=n.asm.malloc).apply(null,arguments)};n._free=function(){return(n._free=n.asm.free).apply(null,arguments)},n._realloc=function(){return(n._realloc=n.asm.realloc).apply(null,arguments)},n.stackSave=function(){return(n.stackSave=n.asm.stackSave).apply(null,arguments)},n.stackRestore=function(){return(n.stackRestore=n.asm.stackRestore).apply(null,arguments)},n.stackAlloc=function(){return(n.stackAlloc=n.asm.stackAlloc).apply(null,arguments)},n.wasmMemory=Fn;var Ms;ki=function o(){Ms||nl(),Ms||(ki=o)};function nl(o){if(Yn>0||(fc(),Yn>0))return;function i(){Ms||(Ms=!0,n.calledRun=!0,!Da&&(hc(),A(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),pc()))}n.setStatus?(n.setStatus("Running..."),setTimeout(function(){setTimeout(function(){n.setStatus("")},1),i()},1)):i()}if(n.preInit)for(typeof n.preInit=="function"&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();return nl(),n.postRun||(n.postRun=[]),n.postRun.push(function(o){if(globalThis.sqlite3ApiBootstrap=function i(l=globalThis.sqlite3ApiConfig||i.defaultConfig){if(i.sqlite3)return console.warn("sqlite3ApiBootstrap() called multiple times.","Config and external initializers are ignored on calls after the first."),i.sqlite3;const a=Object.assign(Object.create(null),{exports:void 0,memory:void 0,bigIntEnabled:(()=>typeof o<"u"?!!o.HEAPU64:!!globalThis.BigInt64Array)(),debug:console.debug.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),log:console.log.bind(console),wasmfsOpfsDir:"/opfs",useStdAlloc:!1},l||{});Object.assign(a,{allocExportName:a.useStdAlloc?"malloc":"sqlite3_malloc",deallocExportName:a.useStdAlloc?"free":"sqlite3_free",reallocExportName:a.useStdAlloc?"realloc":"sqlite3_realloc"},a),["exports","memory","wasmfsOpfsDir"].forEach(f=>{typeof a[f]=="function"&&(a[f]=a[f]())}),a.wasmOpfsDir=!1;const u=Object.create(null),d=Object.create(null),N=f=>u.sqlite3_js_rc_str&&u.sqlite3_js_rc_str(f)||"Unknown result code #"+f,S=f=>typeof f=="number"&&f===(f|0);class C extends Error{constructor(...p){let _;if(p.length)if(S(p[0]))if(_=p[0],p.length===1)super(N(p[0]));else{const W=N(_);typeof p[1]=="object"?super(W,p[1]):(p[0]=W+":",super(p.join(" ")))}else p.length===2&&typeof p[1]=="object"?super(...p):super(p.join(" "));this.resultCode=_||u.SQLITE_ERROR,this.name="SQLite3Error"}}C.toss=(...f)=>{throw new C(...f)};const V=C.toss;a.wasmfsOpfsDir&&!/^\/[^/]+$/.test(a.wasmfsOpfsDir)&&V("config.wasmfsOpfsDir must be falsy or in the form '/dir-name'.");const J=f=>typeof f!="bigint"&&f===(f|0)&&f<=2147483647&&f>=-2147483648,ie=function f(p){return f._max||(f._max=BigInt("0x7fffffffffffffff"),f._min=~f._max),p>=f._min&&p<=f._max},k=f=>f>=-0x7fffffffn-1n&&f<=0x7fffffffn,m=function f(p){return f._min||(f._min=Number.MIN_SAFE_INTEGER,f._max=Number.MAX_SAFE_INTEGER),p>=f._min&&p<=f._max},y=f=>f&&f.constructor&&J(f.constructor.BYTES_PER_ELEMENT)?f:!1,x=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,E=f=>f.buffer instanceof x,b=(f,p,_)=>E(f)?f.slice(p,_):f.subarray(p,_),P=f=>f&&(f instanceof Uint8Array||f instanceof Int8Array||f instanceof ArrayBuffer),M=f=>f&&(f instanceof Uint8Array||f instanceof Int8Array||f instanceof ArrayBuffer),B=f=>P(f)||V("Value is not of a supported TypedArray type."),D=new TextDecoder("utf-8"),le=function(f,p,_){return D.decode(b(f,p,_))},z=function(f){return M(f)?le(f instanceof ArrayBuffer?new Uint8Array(f):f):Array.isArray(f)?f.join(""):(d.isPtr(f)&&(f=d.cstrToJs(f)),f)};class g extends Error{constructor(...p){p.length===2&&typeof p[1]=="object"?super(...p):p.length?super(p.join(" ")):super("Allocation failed."),this.resultCode=u.SQLITE_NOMEM,this.name="WasmAllocError"}}g.toss=(...f)=>{throw new g(...f)},Object.assign(u,{sqlite3_bind_blob:void 0,sqlite3_bind_text:void 0,sqlite3_create_function_v2:(f,p,_,W,L,se,oe,ce,pe)=>{},sqlite3_create_function:(f,p,_,W,L,se,oe,ce)=>{},sqlite3_create_window_function:(f,p,_,W,L,se,oe,ce,pe,de)=>{},sqlite3_prepare_v3:(f,p,_,W,L,se)=>{},sqlite3_prepare_v2:(f,p,_,W,L)=>{},sqlite3_exec:(f,p,_,W,L)=>{},sqlite3_randomness:(f,p)=>{}});const v={affirmBindableTypedArray:B,flexibleString:z,bigIntFits32:k,bigIntFits64:ie,bigIntFitsDouble:m,isBindableTypedArray:P,isInt32:J,isSQLableTypedArray:M,isTypedArray:y,typedArrayToString:le,isUIThread:()=>globalThis.window===globalThis&&!!globalThis.document,isSharedTypedArray:E,toss:function(...f){throw new Error(f.join(" "))},toss3:V,typedArrayPart:b};Object.assign(d,{ptrSizeof:a.wasmPtrSizeof||4,ptrIR:a.wasmPtrIR||"i32",bigIntEnabled:!!a.bigIntEnabled,exports:a.exports||V("Missing API config.exports (WASM module exports)."),memory:a.memory||a.exports.memory||V("API config object requires a WebAssembly.Memory object","in either config.exports.memory (exported)","or config.memory (imported)."),alloc:void 0,realloc:void 0,dealloc:void 0}),d.allocFromTypedArray=function(f){f instanceof ArrayBuffer&&(f=new Uint8Array(f)),B(f);const p=d.alloc(f.byteLength||1);return d.heapForSize(f.constructor).set(f.byteLength?f:[0],p),p};{const f=a.allocExportName,p=a.deallocExportName,_=a.reallocExportName;for(const W of[f,p,_])d.exports[W]instanceof Function||V("Missing required exports[",W,"] function.");d.alloc=function W(L){return W.impl(L)||g.toss("Failed to allocate",L," bytes.")},d.alloc.impl=d.exports[f],d.realloc=function W(L,se){const oe=W.impl(L,se);return se?oe||g.toss("Failed to reallocate",se," bytes."):0},d.realloc.impl=d.exports[_],d.dealloc=d.exports[p]}d.compileOptionUsed=function f(p){if(arguments.length){if(Array.isArray(p)){const _={};return p.forEach(W=>{_[W]=u.sqlite3_compileoption_used(W)}),_}else if(typeof p=="object")return Object.keys(p).forEach(_=>{p[_]=u.sqlite3_compileoption_used(_)}),p}else{if(f._result)return f._result;f._opt||(f._rx=/^([^=]+)=(.+)/,f._rxInt=/^-?\d+$/,f._opt=function(oe,ce){const pe=f._rx.exec(oe);ce[0]=pe?pe[1]:oe,ce[1]=pe?f._rxInt.test(pe[2])?+pe[2]:pe[2]:!0});const _={},W=[0,0];let L=0,se;for(;se=u.sqlite3_compileoption_get(L++);)f._opt(se,W),_[W[0]]=W[1];return f._result=_}return typeof p=="string"?!!u.sqlite3_compileoption_used(p):!1},d.pstack=Object.assign(Object.create(null),{restore:d.exports.sqlite3_wasm_pstack_restore,alloc:function(f){return typeof f=="string"&&!(f=d.sizeofIR(f))&&g.toss("Invalid value for pstack.alloc(",arguments[0],")"),d.exports.sqlite3_wasm_pstack_alloc(f)||g.toss("Could not allocate",f,"bytes from the pstack.")},allocChunks:function(f,p){typeof p=="string"&&!(p=d.sizeofIR(p))&&g.toss("Invalid size value for allocChunks(",arguments[1],")");const _=d.pstack.alloc(f*p),W=[];let L=0,se=0;for(;Lf===1?d.pstack.alloc(p?8:d.ptrSizeof):d.pstack.allocChunks(f,p?8:d.ptrSizeof)}),Object.defineProperties(d.pstack,{pointer:{configurable:!1,iterable:!0,writeable:!1,get:d.exports.sqlite3_wasm_pstack_ptr},quota:{configurable:!1,iterable:!0,writeable:!1,get:d.exports.sqlite3_wasm_pstack_quota},remaining:{configurable:!1,iterable:!0,writeable:!1,get:d.exports.sqlite3_wasm_pstack_remaining}}),u.sqlite3_randomness=(...f)=>{if(f.length===1&&v.isTypedArray(f[0])&&f[0].BYTES_PER_ELEMENT===1){const p=f[0];if(p.byteLength===0)return d.exports.sqlite3_randomness(0,0),p;const _=d.pstack.pointer;try{let W=p.byteLength,L=0;const se=d.exports.sqlite3_randomness,oe=d.heap8u(),ce=W<512?W:512,pe=d.pstack.alloc(ce);do{const de=W>ce?ce:W;se(de,pe),p.set(b(oe,pe,pe+de),L),W-=de,L+=de}while(W>0)}catch(W){console.error("Highly unexpected (and ignored!) exception in sqlite3_randomness():",W)}finally{d.pstack.restore(_)}return p}d.exports.sqlite3_randomness(...f)};let I;if(u.sqlite3_wasmfs_opfs_dir=function(){if(I!==void 0)return I;const f=a.wasmfsOpfsDir;if(console.error("sqlite3_wasmfs_opfs_dir() can no longer work due to incompatible WASMFS changes. It will be removed."),!f||!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle)return I="";try{return f&&d.xCallWrapped("sqlite3_wasm_init_wasmfs","i32",["string"],f)===0?I=f:I=""}catch{return I=""}},u.sqlite3_wasmfs_filename_is_persistent=function(f){const p=u.sqlite3_wasmfs_opfs_dir();return p&&f?f.startsWith(p+"/"):!1},u.sqlite3_js_db_uses_vfs=function(f,p,_=0){try{const W=u.sqlite3_vfs_find(p);return W?f?W===u.sqlite3_js_db_vfs(f,_)?W:!1:W===u.sqlite3_vfs_find(0)?W:!1:!1}catch{return!1}},u.sqlite3_js_vfs_list=function(){const f=[];let p=u.sqlite3_vfs_find(0);for(;p;){const _=new u.sqlite3_vfs(p);f.push(d.cstrToJs(_.$zName)),p=_.$pNext,_.dispose()}return f},u.sqlite3_js_db_export=function(f,p=0){f=d.xWrap.testConvertArg("sqlite3*",f),f||V("Invalid sqlite3* argument."),d.bigIntEnabled||V("BigInt64 support is not enabled.");const _=d.scopedAllocPush();let W;try{const L=d.scopedAlloc(8+d.ptrSizeof),se=L+8,oe=p?d.isPtr(p)?p:d.scopedAllocCString(""+p):0;let ce=d.exports.sqlite3_wasm_db_serialize(f,oe,se,L,0);ce&&V("Database serialization failed with code",w.capi.sqlite3_js_rc_str(ce)),W=d.peekPtr(se);const pe=d.peek(L,"i64");return ce=pe?d.heap8u().slice(W,W+Number(pe)):new Uint8Array,ce}finally{W&&d.exports.sqlite3_free(W),d.scopedAllocPop(_)}},u.sqlite3_js_db_vfs=(f,p=0)=>d.sqlite3_wasm_db_vfs(f,p),u.sqlite3_js_aggregate_context=(f,p)=>u.sqlite3_aggregate_context(f,p)||(p?g.toss("Cannot allocate",p,"bytes for sqlite3_aggregate_context()"):0),u.sqlite3_js_vfs_create_file=function(f,p,_,W){let L;_?(d.isPtr(_)?L=_:_ instanceof ArrayBuffer&&(_=new Uint8Array(_)),_ instanceof Uint8Array?(L=d.allocFromTypedArray(_),(arguments.length<4||!v.isInt32(W)||W<0)&&(W=_.byteLength)):C.toss("Invalid 3rd argument type for sqlite3_js_vfs_create_file().")):L=0,(!v.isInt32(W)||W<0)&&(d.dealloc(L),C.toss("Invalid 4th argument for sqlite3_js_vfs_create_file()."));try{const se=d.sqlite3_wasm_vfs_create_file(f,p,L,W);se&&C.toss("Creation of file failed with sqlite3 result code",u.sqlite3_js_rc_str(se))}finally{d.dealloc(L)}},v.isUIThread()){const f=function(p){const _=Object.create(null);return _.prefix="kvvfs-"+p,_.stores=[],(p==="session"||p==="")&&_.stores.push(globalThis.sessionStorage),(p==="local"||p==="")&&_.stores.push(globalThis.localStorage),_};u.sqlite3_js_kvvfs_clear=function(p=""){let _=0;const W=f(p);return W.stores.forEach(L=>{const se=[];let oe;for(oe=0;oeL.removeItem(ce)),_+=se.length}),_},u.sqlite3_js_kvvfs_size=function(p=""){let _=0;const W=f(p);return W.stores.forEach(L=>{let se;for(se=0;seq(f,p,"sqlite3_preupdate_new"),u.sqlite3_preupdate_old_js=(f,p)=>q(f,p,"sqlite3_preupdate_old"),u.sqlite3changeset_new_js=(f,p)=>q(f,p,"sqlite3changeset_new"),u.sqlite3changeset_old_js=(f,p)=>q(f,p,"sqlite3changeset_old");const w={WasmAllocError:g,SQLite3Error:C,capi:u,util:v,wasm:d,config:a,version:Object.create(null),client:void 0,asyncPostInit:async function(){let f=i.initializersAsync;if(delete i.initializersAsync,!f||!f.length)return Promise.resolve(w);f=f.map(_=>(_ instanceof Promise?_:_(w)).catch(L=>{throw console.error("an async sqlite3 initializer failed:",L),L}));const p=()=>(w.__isUnderTest||(delete w.util,delete w.StructBinder),w);{let _=f.shift();for(;f.length;)_=_.then(f.shift());return _.then(p)}},scriptInfo:void 0};try{i.initializers.forEach(f=>{f(w)})}catch(f){throw console.error("sqlite3 bootstrap initializer threw:",f),f}return delete i.initializers,i.sqlite3=w,w},globalThis.sqlite3ApiBootstrap.initializers=[],globalThis.sqlite3ApiBootstrap.initializersAsync=[],globalThis.sqlite3ApiBootstrap.defaultConfig=Object.create(null),globalThis.sqlite3ApiBootstrap.sqlite3=void 0,globalThis.WhWasmUtilInstaller=function(i){var z;i.bigIntEnabled===void 0&&(i.bigIntEnabled=!!self.BigInt64Array);const l=(...g)=>{throw new Error(g.join(" "))};i.exports||Object.defineProperty(i,"exports",{enumerable:!0,configurable:!0,get:()=>i.instance&&i.instance.exports});const a=i.pointerIR||"i32",u=i.ptrSizeof=a==="i32"?4:a==="i64"?8:l("Unhandled ptrSizeof:",a),d=Object.create(null);d.heapSize=0,d.memory=null,d.freeFuncIndexes=[],d.scopedAlloc=[],d.utf8Decoder=new TextDecoder,d.utf8Encoder=new TextEncoder("utf-8"),i.sizeofIR=g=>{switch(g){case"i8":return 1;case"i16":return 2;case"i32":case"f32":case"float":return 4;case"i64":case"f64":case"double":return 8;case"*":return u;default:return(""+g).endsWith("*")?u:void 0}};const N=function(){if(!d.memory)d.memory=i.memory instanceof WebAssembly.Memory?i.memory:i.exports.memory;else if(d.heapSize===d.memory.buffer.byteLength)return d;const g=d.memory.buffer;return d.HEAP8=new Int8Array(g),d.HEAP8U=new Uint8Array(g),d.HEAP16=new Int16Array(g),d.HEAP16U=new Uint16Array(g),d.HEAP32=new Int32Array(g),d.HEAP32U=new Uint32Array(g),i.bigIntEnabled&&(d.HEAP64=new BigInt64Array(g),d.HEAP64U=new BigUint64Array(g)),d.HEAP32F=new Float32Array(g),d.HEAP64F=new Float64Array(g),d.heapSize=g.byteLength,d};i.heap8=()=>N().HEAP8,i.heap8u=()=>N().HEAP8U,i.heap16=()=>N().HEAP16,i.heap16u=()=>N().HEAP16U,i.heap32=()=>N().HEAP32,i.heap32u=()=>N().HEAP32U,i.heapForSize=function(g,v=!0){const I=d.memory&&d.heapSize===d.memory.buffer.byteLength?d:N();switch(g){case Int8Array:return I.HEAP8;case Uint8Array:return I.HEAP8U;case Int16Array:return I.HEAP16;case Uint16Array:return I.HEAP16U;case Int32Array:return I.HEAP32;case Uint32Array:return I.HEAP32U;case 8:return v?I.HEAP8U:I.HEAP8;case 16:return v?I.HEAP16U:I.HEAP16;case 32:return v?I.HEAP32U:I.HEAP32;case 64:if(I.HEAP64)return v?I.HEAP64U:I.HEAP64;break;default:if(i.bigIntEnabled){if(g===self.BigUint64Array)return I.HEAP64U;if(g===self.BigInt64Array)return I.HEAP64;break}}l("Invalid heapForSize() size: expecting 8, 16, 32,","or (if BigInt is enabled) 64.")},i.functionTable=function(){return i.exports.__indirect_function_table},i.functionEntry=function(g){const v=i.functionTable();return g>7)},rxJSig:/^(\w)\((\w*)\)$/,sigParams:function(f){const p=g._.rxJSig.exec(f);return p?p[2]:f.substr(1)},letterType:f=>g._.sigTypes[f]||l("Invalid signature letter:",f),pushSigType:(f,p)=>f.push(g._.typeCodes[g._.letterType(p)])}),typeof v=="string"){const f=I;I=v,v=f}const q=g._.sigParams(I),w=[1,96];g._.uleb128Encode(w,"push",q.length);for(const f of q)g._.pushSigType(w,f);return I[0]==="v"?w.push(0):(w.push(1),g._.pushSigType(w,I[0])),g._.uleb128Encode(w,"unshift",w.length),w.unshift(0,97,115,109,1,0,0,0,1),w.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array(w)),{e:{f:v}}).exports.f};const S=function(v,I,q){if(q&&!d.scopedAlloc.length&&l("No scopedAllocPush() scope is active."),typeof v=="string"){const _=I;I=v,v=_}(typeof I!="string"||!(v instanceof Function))&&l("Invalid arguments: expecting (function,signature) or (signature,function).");const w=i.functionTable(),f=w.length;let p;for(;d.freeFuncIndexes.length&&(p=d.freeFuncIndexes.pop(),w.get(p));){p=null;continue}p||(p=f,w.grow(1));try{return w.set(p,v),q&&d.scopedAlloc[d.scopedAlloc.length-1].push(p),p}catch(_){if(!(_ instanceof TypeError))throw p===f&&d.freeFuncIndexes.push(f),_}try{const _=i.jsFuncToWasm(v,I);w.set(p,_),q&&d.scopedAlloc[d.scopedAlloc.length-1].push(p)}catch(_){throw p===f&&d.freeFuncIndexes.push(f),_}return p};i.installFunction=(g,v)=>S(g,v,!1),i.scopedInstallFunction=(g,v)=>S(g,v,!0),i.uninstallFunction=function(g){if(!g&&g!==0)return;const v=d.freeFuncIndexes,I=i.functionTable();v.push(g);const q=I.get(g);return I.set(g,null),q},i.peek=function(v,I="i8"){I.endsWith("*")&&(I=a);const q=d.memory&&d.heapSize===d.memory.buffer.byteLength?d:N(),w=Array.isArray(v)?[]:void 0;let f;do{switch(w&&(v=arguments[0].shift()),I){case"i1":case"i8":f=q.HEAP8[v>>0];break;case"i16":f=q.HEAP16[v>>1];break;case"i32":f=q.HEAP32[v>>2];break;case"float":case"f32":f=q.HEAP32F[v>>2];break;case"double":case"f64":f=Number(q.HEAP64F[v>>3]);break;case"i64":if(i.bigIntEnabled){f=BigInt(q.HEAP64[v>>3]);break}default:l("Invalid type for peek():",I)}w&&w.push(f)}while(w&&arguments[0].length);return w||f},i.poke=function(g,v,I="i8"){I.endsWith("*")&&(I=a);const q=d.memory&&d.heapSize===d.memory.buffer.byteLength?d:N();for(const w of Array.isArray(g)?g:[g])switch(I){case"i1":case"i8":q.HEAP8[w>>0]=v;continue;case"i16":q.HEAP16[w>>1]=v;continue;case"i32":q.HEAP32[w>>2]=v;continue;case"float":case"f32":q.HEAP32F[w>>2]=v;continue;case"double":case"f64":q.HEAP64F[w>>3]=v;continue;case"i64":if(q.HEAP64){q.HEAP64[w>>3]=BigInt(v);continue}default:l("Invalid type for poke(): "+I)}return this},i.peekPtr=(...g)=>i.peek(g.length===1?g[0]:g,a),i.pokePtr=(g,v=0)=>i.poke(g,v,a),i.peek8=(...g)=>i.peek(g.length===1?g[0]:g,"i8"),i.poke8=(g,v)=>i.poke(g,v,"i8"),i.peek16=(...g)=>i.peek(g.length===1?g[0]:g,"i16"),i.poke16=(g,v)=>i.poke(g,v,"i16"),i.peek32=(...g)=>i.peek(g.length===1?g[0]:g,"i32"),i.poke32=(g,v)=>i.poke(g,v,"i32"),i.peek64=(...g)=>i.peek(g.length===1?g[0]:g,"i64"),i.poke64=(g,v)=>i.poke(g,v,"i64"),i.peek32f=(...g)=>i.peek(g.length===1?g[0]:g,"f32"),i.poke32f=(g,v)=>i.poke(g,v,"f32"),i.peek64f=(...g)=>i.peek(g.length===1?g[0]:g,"f64"),i.poke64f=(g,v)=>i.poke(g,v,"f64"),i.getMemValue=i.peek,i.getPtrValue=i.peekPtr,i.setMemValue=i.poke,i.setPtrValue=i.pokePtr,i.isPtr32=g=>typeof g=="number"&&g===(g|0)&&g>=0,i.isPtr=i.isPtr32,i.cstrlen=function(g){if(!g||!i.isPtr(g))return null;const v=N().HEAP8U;let I=g;for(;v[I]!==0;++I);return I-g};const C=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,V=function(g,v,I){return d.utf8Decoder.decode(g.buffer instanceof C?g.slice(v,I):g.subarray(v,I))};i.cstrToJs=function(g){const v=i.cstrlen(g);return v?V(N().HEAP8U,g,g+v):v===null?v:""},i.jstrlen=function(g){if(typeof g!="string")return null;const v=g.length;let I=0;for(let q=0;q=55296&&w<=57343&&(w=65536+((w&1023)<<10)|g.charCodeAt(++q)&1023),w<=127?++I:w<=2047?I+=2:w<=65535?I+=3:I+=4}return I},i.jstrcpy=function(g,v,I=0,q=-1,w=!0){if((!v||!(v instanceof Int8Array)&&!(v instanceof Uint8Array))&&l("jstrcpy() target must be an Int8Array or Uint8Array."),q<0&&(q=v.length-I),!(q>0)||!(I>=0))return 0;let f=0,p=g.length;const _=I,W=I+q-(w?1:0);for(;f=55296&&L<=57343&&(L=65536+((L&1023)<<10)|g.charCodeAt(++f)&1023),L<=127){if(I>=W)break;v[I++]=L}else if(L<=2047){if(I+1>=W)break;v[I++]=192|L>>6,v[I++]=128|L&63}else if(L<=65535){if(I+2>=W)break;v[I++]=224|L>>12,v[I++]=128|L>>6&63,v[I++]=128|L&63}else{if(I+3>=W)break;v[I++]=240|L>>18,v[I++]=128|L>>12&63,v[I++]=128|L>>6&63,v[I++]=128|L&63}}return w&&(v[I++]=0),I-_},i.cstrncpy=function(g,v,I){if((!g||!v)&&l("cstrncpy() does not accept NULL strings."),I<0)I=i.cstrlen(strPtr)+1;else if(!(I>0))return 0;const q=i.heap8u();let w=0,f;for(;wd.utf8Encoder.encode(v?g+"\0":g);const J=(g,v)=>{(!(g.alloc instanceof Function)||!(g.dealloc instanceof Function))&&l("Object is missing alloc() and/or dealloc() function(s)","required by",v+"().")},ie=function(g,v,I,q){if(J(i,q),typeof g!="string")return null;{const w=d.utf8Encoder.encode(g),f=I(w.length+1),p=N().HEAP8U;return p.set(w,f),p[f+w.length]=0,v?[f,w.length]:f}};i.allocCString=(g,v=!1)=>ie(g,v,i.alloc,"allocCString()"),i.scopedAllocPush=function(){J(i,"scopedAllocPush");const g=[];return d.scopedAlloc.push(g),g},i.scopedAllocPop=function(g){J(i,"scopedAllocPop");const v=arguments.length?d.scopedAlloc.indexOf(g):d.scopedAlloc.length-1;v<0&&l("Invalid state object for scopedAllocPop()."),arguments.length===0&&(g=d.scopedAlloc[v]),d.scopedAlloc.splice(v,1);for(let I;I=g.pop();)i.functionEntry(I)?i.uninstallFunction(I):i.dealloc(I)},i.scopedAlloc=function(g){d.scopedAlloc.length||l("No scopedAllocPush() scope is active.");const v=i.alloc(g);return d.scopedAlloc[d.scopedAlloc.length-1].push(v),v},Object.defineProperty(i.scopedAlloc,"level",{configurable:!1,enumerable:!1,get:()=>d.scopedAlloc.length,set:()=>l("The 'active' property is read-only.")}),i.scopedAllocCString=(g,v=!1)=>ie(g,v,i.scopedAlloc,"scopedAllocCString()");const k=function(g,v){const I=i[g?"scopedAlloc":"alloc"]((v.length+1)*i.ptrSizeof);let q=0;return v.forEach(w=>{i.pokePtr(I+i.ptrSizeof*q++,i[g?"scopedAllocCString":"allocCString"](""+w))}),i.pokePtr(I+i.ptrSizeof*q,0),I};i.scopedAllocMainArgv=g=>k(!0,g),i.allocMainArgv=g=>k(!1,g),i.cArgvToJs=(g,v)=>{const I=[];for(let q=0;qm(g,v,"alloc"),i.scopedAllocPtr=(g=1,v=!0)=>m(g,v,"scopedAlloc"),i.xGet=function(g){return i.exports[g]||l("Cannot find exported symbol:",g)};const y=(g,v)=>l(g+"() requires",v,"argument(s).");i.xCall=function(g,...v){const I=i.xGet(g);return I instanceof Function||l("Exported symbol",g,"is not a function."),I.length!==v.length&&y(g,I.length),arguments.length===2&&Array.isArray(arguments[1])?I.apply(null,arguments[1]):I.apply(null,v)},d.xWrap=Object.create(null),d.xWrap.convert=Object.create(null),d.xWrap.convert.arg=new Map,d.xWrap.convert.result=new Map;const x=d.xWrap.convert.arg,E=d.xWrap.convert.result;i.bigIntEnabled&&x.set("i64",g=>BigInt(g));const b=a==="i32"?g=>g|0:g=>BigInt(g)|BigInt(0);x.set("i32",b).set("i16",g=>(g|0)&65535).set("i8",g=>(g|0)&255).set("f32",g=>Number(g).valueOf()).set("float",x.get("f32")).set("f64",x.get("f32")).set("double",x.get("f64")).set("int",x.get("i32")).set("null",g=>g).set(null,x.get("null")).set("**",b).set("*",b),E.set("*",b).set("pointer",b).set("number",g=>Number(g)).set("void",g=>{}).set("null",g=>g).set(null,E.get("null"));{const g=["i8","i16","i32","int","f32","float","f64","double"];i.bigIntEnabled&&g.push("i64");const v=x.get(a);for(const I of g)x.set(I+"*",v),E.set(I+"*",v),E.set(I,x.get(I)||l("Missing arg converter:",I))}const P=function(g){return typeof g=="string"?i.scopedAllocCString(g):g?b(g):null};x.set("string",P).set("utf8",P).set("pointer",P),E.set("string",g=>i.cstrToJs(g)).set("utf8",E.get("string")).set("string:dealloc",g=>{try{return g?i.cstrToJs(g):null}finally{i.dealloc(g)}}).set("utf8:dealloc",E.get("string:dealloc")).set("json",g=>JSON.parse(i.cstrToJs(g))).set("json:dealloc",g=>{try{return g?JSON.parse(i.cstrToJs(g)):null}finally{i.dealloc(g)}});const M=class{constructor(g){this.name=g.name||"unnamed adapter"}convertArg(g,v,I){l("AbstractArgAdapter must be subclassed.")}};x.FuncPtrAdapter=(z=class extends M{constructor(v){super(v),x.FuncPtrAdapter.warnOnUse&&console.warn("xArg.FuncPtrAdapter is an internal-only API","and is not intended to be invoked from","client-level code. Invoked with:",v),this.signature=v.signature,v.contextKey instanceof Function&&(this.contextKey=v.contextKey,v.bindScope||(v.bindScope="context")),this.bindScope=v.bindScope||l("FuncPtrAdapter options requires a bindScope (explicit or implied)."),z.bindScopes.indexOf(v.bindScope)<0&&l("Invalid options.bindScope ("+v.bindMod+") for FuncPtrAdapter. Expecting one of: ("+z.bindScopes.join(", ")+")"),this.isTransient=this.bindScope==="transient",this.isContext=this.bindScope==="context",this.isPermanent=this.bindScope==="permanent",this.singleton=this.bindScope==="singleton"?[]:void 0,this.callProxy=v.callProxy instanceof Function?v.callProxy:void 0}contextKey(v,I){return this}contextMap(v){const I=this.__cmap||(this.__cmap=new Map);let q=I.get(v);return q===void 0&&I.set(v,q=[]),q}convertArg(v,I,q){let w=this.singleton;if(!w&&this.isContext&&(w=this.contextMap(this.contextKey(I,q))),w&&w[0]===v)return w[1];if(v instanceof Function){this.callProxy&&(v=this.callProxy(v));const f=S(v,this.signature,this.isTransient);if(z.debugFuncInstall&&z.debugOut("FuncPtrAdapter installed",this,this.contextKey(I,q),"@"+f,v),w){if(w[1]){z.debugFuncInstall&&z.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(I,q),"@"+w[1],v);try{i.uninstallFunction(w[1])}catch{}}w[0]=v,w[1]=f}return f}else if(i.isPtr(v)||v===null||v===void 0){if(w&&w[1]&&w[1]!==v){z.debugFuncInstall&&z.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(I,q),"@"+w[1],v);try{i.uninstallFunction(w[1])}catch{}w[0]=w[1]=v|0}return v||0}else throw new TypeError("Invalid FuncPtrAdapter argument type. Expecting a function pointer or a "+(this.name?this.name+" ":"")+"function matching signature "+this.signature+".")}},Tt(z,"warnOnUse",!1),Tt(z,"debugFuncInstall",!1),Tt(z,"debugOut",console.debug.bind(console)),Tt(z,"bindScopes",["transient","context","singleton","permanent"]),z);const B=g=>x.get(g)||l("Argument adapter not found:",g),D=g=>E.get(g)||l("Result adapter not found:",g);d.xWrap.convertArg=(g,...v)=>B(g)(...v),d.xWrap.convertArgNoCheck=(g,...v)=>x.get(g)(...v),d.xWrap.convertResult=(g,v)=>g===null?v:g?D(g)(v):void 0,d.xWrap.convertResultNoCheck=(g,v)=>g===null?v:g?E.get(g)(v):void 0,i.xWrap=function(g,v,...I){arguments.length===3&&Array.isArray(arguments[2])&&(I=arguments[2]),i.isPtr(g)&&(g=i.functionEntry(g)||l("Function pointer not found in WASM function table."));const q=g instanceof Function,w=q?g:i.xGet(g);if(q&&(g=w.name||"unnamed function"),I.length!==w.length&&y(g,w.length),v===null&&w.length===0)return w;v!=null&&D(v);for(const p of I)p instanceof M?x.set(p,(..._)=>p.convertArg(..._)):B(p);const f=d.xWrap;return w.length===0?(...p)=>p.length?y(g,w.length):f.convertResult(v,w.call(null)):function(...p){p.length!==w.length&&y(g,w.length);const _=i.scopedAllocPush();try{for(const W in p)p[W]=f.convertArgNoCheck(I[W],p[W],p,W);return f.convertResultNoCheck(v,w.apply(null,p))}finally{i.scopedAllocPop(_)}}};const le=function(g,v,I,q,w,f){if(typeof I=="string"){if(v===1)return f.get(I);if(v===2){if(q)q instanceof Function||l(w,"requires a function argument.");else return delete f.get(I),g;return f.set(I,q),g}}l("Invalid arguments to",w)};return i.xWrap.resultAdapter=function g(v,I){return le(g,arguments.length,v,I,"resultAdapter()",E)},i.xWrap.argAdapter=function g(v,I){return le(g,arguments.length,v,I,"argAdapter()",x)},i.xWrap.FuncPtrAdapter=x.FuncPtrAdapter,i.xCallWrapped=function(g,v,I,...q){return Array.isArray(arguments[3])&&(q=arguments[3]),i.xWrap(g,v,I||[]).apply(null,q||[])},i.xWrap.testConvertArg=d.xWrap.convertArg,i.xWrap.testConvertResult=d.xWrap.convertResult,i},globalThis.WhWasmUtilInstaller.yawl=function(i){const l=()=>fetch(i.uri,{credentials:"same-origin"}),a=this,u=function(N){if(i.wasmUtilTarget){const S=(...V)=>{throw new Error(V.join(" "))},C=i.wasmUtilTarget;if(C.module=N.module,C.instance=N.instance,C.instance.exports.memory||(C.memory=i.imports&&i.imports.env&&i.imports.env.memory||S("Missing 'memory' object!")),!C.alloc&&N.instance.exports.malloc){const V=N.instance.exports;C.alloc=function(J){return V.malloc(J)||S("Allocation of",J,"bytes failed.")},C.dealloc=function(J){V.free(J)}}a(C)}return i.onload&&i.onload(N,i),N};return WebAssembly.instantiateStreaming?function(){return WebAssembly.instantiateStreaming(l(),i.imports||{}).then(u)}:function(){return l().then(S=>S.arrayBuffer()).then(S=>WebAssembly.instantiate(S,i.imports||{})).then(u)}}.bind(globalThis.WhWasmUtilInstaller),globalThis.Jaccwabyt=function i(l){const a=(...T)=>{throw new Error(T.join(" "))};!(l.heap instanceof WebAssembly.Memory)&&!(l.heap instanceof Function)&&a("config.heap must be WebAssembly.Memory instance or a function."),["alloc","dealloc"].forEach(function(T){l[T]instanceof Function||a("Config option '"+T+"' must be a function.")});const u=i,d=l.heap instanceof Function?l.heap:()=>new Uint8Array(l.heap.buffer),N=l.alloc,S=l.dealloc,C=l.log||console.log.bind(console),V=l.memberPrefix||"",J=l.memberSuffix||"",ie=l.bigIntEnabled===void 0?!!self.BigInt64Array:!!l.bigIntEnabled,k=self.BigInt,m=self.BigInt64Array,y=l.ptrSizeof||4,x=l.ptrIR||"i32";u.debugFlags||(u.__makeDebugFlags=function(T=null){T&&T.__flags&&(T=T.__flags);const H=function $(K){return arguments.length===0?$.__flags:(K<0?(delete $.__flags.getter,delete $.__flags.setter,delete $.__flags.alloc,delete $.__flags.dealloc):($.__flags.getter=(1&K)!==0,$.__flags.setter=(2&K)!==0,$.__flags.alloc=(4&K)!==0,$.__flags.dealloc=(8&K)!==0),$._flags)};return Object.defineProperty(H,"__flags",{iterable:!1,writable:!1,value:Object.create(T)}),T||H(0),H},u.debugFlags=u.__makeDebugFlags());const E=function(){const T=new ArrayBuffer(2);return new DataView(T).setInt16(0,256,!0),new Int16Array(T)[0]===256}(),b=T=>T[1]==="(",P=T=>T==="P",M=T=>b(T)?"p":T[0],B=function(T){switch(M(T)){case"c":case"C":return"i8";case"i":return"i32";case"p":case"P":case"s":return x;case"j":return"i64";case"f":return"float";case"d":return"double"}a("Unhandled signature IR:",T)},D=m?()=>!0:()=>a("BigInt64Array is not available."),le=function(T){switch(M(T)){case"p":case"P":case"s":{switch(y){case 4:return"getInt32";case 8:return D()&&"getBigInt64"}break}case"i":return"getInt32";case"c":return"getInt8";case"C":return"getUint8";case"j":return D()&&"getBigInt64";case"f":return"getFloat32";case"d":return"getFloat64"}a("Unhandled DataView getter for signature:",T)},z=function(T){switch(M(T)){case"p":case"P":case"s":{switch(y){case 4:return"setInt32";case 8:return D()&&"setBigInt64"}break}case"i":return"setInt32";case"c":return"setInt8";case"C":return"setUint8";case"j":return D()&&"setBigInt64";case"f":return"setFloat32";case"d":return"setFloat64"}a("Unhandled DataView setter for signature:",T)},g=function(T){switch(M(T)){case"i":case"f":case"c":case"C":case"d":return Number;case"j":return D()&&k;case"p":case"P":case"s":switch(y){case 4:return Number;case 8:return D()&&k}break}a("Unhandled DataView set wrapper for signature:",T)},v=(T,H)=>T+"::"+H,I=function(T,H){return()=>a(v(T,H),"is read-only.")},q=new WeakMap,w="(pointer-is-external)",f=function(T,H,$){if($||($=q.get(H)),$){if(q.delete(H),Array.isArray(H.ondispose)){let K;for(;K=H.ondispose.shift();)try{K instanceof Function?K.call(H):K instanceof be?K.dispose():typeof K=="number"&&S(K)}catch(Ie){console.warn("ondispose() for",T.structName,"@",$,"threw. NOT propagating it.",Ie)}}else if(H.ondispose instanceof Function)try{H.ondispose()}catch(K){console.warn("ondispose() for",T.structName,"@",$,"threw. NOT propagating it.",K)}delete H.ondispose,T.debugFlags.__flags.dealloc&&C("debug.dealloc:",H[w]?"EXTERNAL":"",T.structName,"instance:",T.structInfo.sizeof,"bytes @"+$),H[w]||S($)}},p=T=>({configurable:!1,writable:!1,iterable:!1,value:T}),_=function(T,H,$){let K=!$;$?Object.defineProperty(H,w,p($)):($=N(T.structInfo.sizeof),$||a("Allocation of",T.structName,"structure failed."));try{T.debugFlags.__flags.alloc&&C("debug.alloc:",K?"":"EXTERNAL",T.structName,"instance:",T.structInfo.sizeof,"bytes @"+$),K&&d().fill(0,$,$+T.structInfo.sizeof),q.set(H,$)}catch(Ie){throw f(T,H,$),Ie}},W=function(){const T=this.pointer;return T?new Uint8Array(d().slice(T,T+this.structInfo.sizeof)):null},se=p(T=>V+T+J),oe=function(T,H,$=!0){let K=T.members[H];if(!K&&(V||J)){for(const Ie of Object.values(T.members))if(Ie.key===H){K=Ie;break}!K&&$&&a(v(T.name,H),"is not a mapped struct member.")}return K},ce=function T(H,$,K=!1){T._||(T._=Be=>Be.replace(/[^vipPsjrdcC]/g,"").replace(/[pPscC]/g,"i"));const Ie=oe(H.structInfo,$,!0);return K?T._(Ie.signature):Ie.signature},pe={configurable:!1,enumerable:!1,get:function(){return q.get(this)},set:()=>a("Cannot assign the 'pointer' property of a struct.")},de=p(function(){const T=[];for(const H of Object.keys(this.structInfo.members))T.push(this.memberKey(H));return T}),ve=new TextDecoder("utf-8"),Je=new TextEncoder,mt=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,un=function(T,H,$){return ve.decode(T.buffer instanceof mt?T.slice(H,$):T.subarray(H,$))},O=function(T,H,$=!1){const K=oe(T.structInfo,H,$);return K&&K.signature.length===1&&K.signature[0]==="s"?K:!1},j=function(T){T.signature!=="s"&&a("Invalid member type signature for C-string value:",JSON.stringify(T))},Q=function(H,$){const K=oe(H.structInfo,$,!0);j(K);const Ie=H[K.key];if(!Ie)return null;let Be=Ie;const Ae=d();for(;Ae[Be]!==0;++Be);return Ie===Be?"":un(Ae,Ie,Be)},Y=function(T,...H){T.ondispose?Array.isArray(T.ondispose)||(T.ondispose=[T.ondispose]):T.ondispose=[],T.ondispose.push(...H)},G=function(T){const H=Je.encode(T),$=N(H.length+1);$||a("Allocation error while duplicating string:",T);const K=d();return K.set(H,$),K[$+H.length]=0,$},xe=function(T,H,$){const K=oe(T.structInfo,H,!0);j(K);const Ie=G($);return T[K.key]=Ie,Y(T,Ie),T},be=function(H,$){arguments[2]!==p&&a("Do not call the StructType constructor","from client-level code."),Object.defineProperties(this,{structName:p(H),structInfo:p($)})};be.prototype=Object.create(null,{dispose:p(function(){f(this.constructor,this)}),lookupMember:p(function(T,H=!0){return oe(this.structInfo,T,H)}),memberToJsString:p(function(T){return Q(this,T)}),memberIsString:p(function(T,H=!0){return O(this,T,H)}),memberKey:se,memberKeys:de,memberSignature:p(function(T,H=!1){return ce(this,T,H)}),memoryDump:p(W),pointer:pe,setMemberCString:p(function(T,H){return xe(this,T,H)})}),Object.assign(be.prototype,{addOnDispose:function(...T){return Y(this,...T),this}}),Object.defineProperties(be,{allocCString:p(G),isA:p(T=>T instanceof be),hasExternalPointer:p(T=>T instanceof be&&!!T[w]),memberKey:se});const ne=T=>Number.isFinite(T)||T instanceof(k||Number),Vt=function T(H,$,K){if(!T._){T._={getters:{},setters:{},sw:{}};const St=["i","c","C","p","P","s","f","d","v()"];ie&&St.push("j"),St.forEach(function(cn){T._.getters[cn]=le(cn),T._.setters[cn]=z(cn),T._.sw[cn]=g(cn)});const pd=/^[ipPsjfdcC]$/,_d=/^[vipPsjfdcC]\([ipPsjfdcC]*\)$/;T.sigCheck=function(cn,md,rl,wo){Object.prototype.hasOwnProperty.call(cn,rl)&&a(cn.structName,"already has a property named",rl+"."),pd.test(wo)||_d.test(wo)||a("Malformed signature for",v(cn.structName,md)+":",wo)}}const Ie=H.memberKey($);T.sigCheck(H.prototype,$,Ie,K.signature),K.key=Ie,K.name=$;const Be=M(K.signature),Ae=v(H.prototype.structName,Ie),$e=H.prototype.debugFlags.__flags,Fr=Object.create(null);Fr.configurable=!1,Fr.enumerable=!1,Fr.get=function(){$e.getter&&C("debug.getter:",T._.getters[Be],"for",B(Be),Ae,"@",this.pointer,"+",K.offset,"sz",K.sizeof);let St=new DataView(d().buffer,this.pointer+K.offset,K.sizeof)[T._.getters[Be]](0,E);return $e.getter&&C("debug.getter:",Ae,"result =",St),St},K.readOnly?Fr.set=I(H.prototype.structName,Ie):Fr.set=function(St){if($e.setter&&C("debug.setter:",T._.setters[Be],"for",B(Be),Ae,"@",this.pointer,"+",K.offset,"sz",K.sizeof,St),this.pointer||a("Cannot set struct property on disposed instance."),St===null)St=0;else for(;!ne(St);){if(P(K.signature)&&St instanceof be){St=St.pointer||0,$e.setter&&C("debug.setter:",Ae,"resolved to",St);break}a("Invalid value for pointer-type",Ae+".")}new DataView(d().buffer,this.pointer+K.offset,K.sizeof)[T._.setters[Be]](0,T._.sw[Be](St),E)},Object.defineProperty(H.prototype,Ie,Fr)},ct=function T(H,$){arguments.length===1?($=H,H=$.name):$.name||($.name=H),H||a("Struct name is required.");let K=!1;Object.keys($.members).forEach(Ae=>{const $e=$.members[Ae];$e.sizeof?$e.sizeof===1?$e.signature==="c"||$e.signature==="C"||a("Unexpected sizeof==1 member",v($.name,Ae),"with signature",$e.signature):($e.sizeof%4!==0&&(console.warn("Invalid struct member description =",$e,"from",$),a(H,"member",Ae,"sizeof is not aligned. sizeof="+$e.sizeof)),$e.offset%4!==0&&(console.warn("Invalid struct member description =",$e,"from",$),a(H,"member",Ae,"offset is not aligned. offset="+$e.offset))):a(H,"member",Ae,"is missing sizeof."),(!K||K.offset<$e.offset)&&(K=$e)}),K?$.sizeofAe instanceof Be),memberKey:se,memberKeys:de,methodInfoForKey:p(function(Ae){}),structInfo:p($),structName:p(H)}),Be.prototype=new be(H,$,p),Object.defineProperties(Be.prototype,{debugFlags:Ie,constructor:p(Be)}),Object.keys($.members).forEach(Ae=>Vt(Be,Ae,$.members[Ae])),Be};return ct.StructType=be,ct.config=l,ct.allocCString=G,ct.debugFlags||(ct.debugFlags=u.__makeDebugFlags(u.debugFlags)),ct},globalThis.sqlite3ApiBootstrap.initializers.push(function(i){const l=(...k)=>{throw new Error(k.join(" "))};i.SQLite3Error.toss;const a=i.capi,u=i.wasm,d=i.util;if(globalThis.WhWasmUtilInstaller(u),delete globalThis.WhWasmUtilInstaller,u.bindingSignatures=[["sqlite3_aggregate_context","void*","sqlite3_context*","int"],["sqlite3_bind_double","int","sqlite3_stmt*","int","f64"],["sqlite3_bind_int","int","sqlite3_stmt*","int","int"],["sqlite3_bind_null",void 0,"sqlite3_stmt*","int"],["sqlite3_bind_parameter_count","int","sqlite3_stmt*"],["sqlite3_bind_parameter_index","int","sqlite3_stmt*","string"],["sqlite3_bind_pointer","int","sqlite3_stmt*","int","*","string:static","*"],["sqlite3_busy_handler","int",["sqlite3*",new u.xWrap.FuncPtrAdapter({signature:"i(pi)",contextKey:(k,m)=>k[0]}),"*"]],["sqlite3_busy_timeout","int","sqlite3*","int"],["sqlite3_changes","int","sqlite3*"],["sqlite3_clear_bindings","int","sqlite3_stmt*"],["sqlite3_collation_needed","int","sqlite3*","*","*"],["sqlite3_column_blob","*","sqlite3_stmt*","int"],["sqlite3_column_bytes","int","sqlite3_stmt*","int"],["sqlite3_column_count","int","sqlite3_stmt*"],["sqlite3_column_double","f64","sqlite3_stmt*","int"],["sqlite3_column_int","int","sqlite3_stmt*","int"],["sqlite3_column_name","string","sqlite3_stmt*","int"],["sqlite3_column_text","string","sqlite3_stmt*","int"],["sqlite3_column_type","int","sqlite3_stmt*","int"],["sqlite3_column_value","sqlite3_value*","sqlite3_stmt*","int"],["sqlite3_commit_hook","void*",["sqlite3*",new u.xWrap.FuncPtrAdapter({name:"sqlite3_commit_hook",signature:"i(p)",contextKey:k=>k[0]}),"*"]],["sqlite3_compileoption_get","string","int"],["sqlite3_compileoption_used","int","string"],["sqlite3_complete","int","string:flexible"],["sqlite3_context_db_handle","sqlite3*","sqlite3_context*"],["sqlite3_data_count","int","sqlite3_stmt*"],["sqlite3_db_filename","string","sqlite3*","string"],["sqlite3_db_handle","sqlite3*","sqlite3_stmt*"],["sqlite3_db_name","string","sqlite3*","int"],["sqlite3_db_status","int","sqlite3*","int","*","*","int"],["sqlite3_errcode","int","sqlite3*"],["sqlite3_errmsg","string","sqlite3*"],["sqlite3_error_offset","int","sqlite3*"],["sqlite3_errstr","string","int"],["sqlite3_exec","int",["sqlite3*","string:flexible",new u.xWrap.FuncPtrAdapter({signature:"i(pipp)",bindScope:"transient",callProxy:k=>{let m;return(y,x,E,b)=>{try{const P=u.cArgvToJs(x,E);return m||(m=u.cArgvToJs(x,b)),k(P,m)|0}catch(P){return P.resultCode||a.SQLITE_ERROR}}}}),"*","**"]],["sqlite3_expanded_sql","string","sqlite3_stmt*"],["sqlite3_extended_errcode","int","sqlite3*"],["sqlite3_extended_result_codes","int","sqlite3*","int"],["sqlite3_file_control","int","sqlite3*","string","int","*"],["sqlite3_finalize","int","sqlite3_stmt*"],["sqlite3_free",void 0,"*"],["sqlite3_get_auxdata","*","sqlite3_context*","int"],["sqlite3_initialize",void 0],["sqlite3_keyword_count","int"],["sqlite3_keyword_name","int",["int","**","*"]],["sqlite3_keyword_check","int",["string","int"]],["sqlite3_libversion","string"],["sqlite3_libversion_number","int"],["sqlite3_limit","int",["sqlite3*","int","int"]],["sqlite3_malloc","*","int"],["sqlite3_open","int","string","*"],["sqlite3_open_v2","int","string","*","int","string"],["sqlite3_progress_handler",void 0,["sqlite3*","int",new u.xWrap.FuncPtrAdapter({name:"xProgressHandler",signature:"i(p)",bindScope:"context",contextKey:(k,m)=>k[0]}),"*"]],["sqlite3_realloc","*","*","int"],["sqlite3_reset","int","sqlite3_stmt*"],["sqlite3_result_blob",void 0,"sqlite3_context*","*","int","*"],["sqlite3_result_double",void 0,"sqlite3_context*","f64"],["sqlite3_result_error",void 0,"sqlite3_context*","string","int"],["sqlite3_result_error_code",void 0,"sqlite3_context*","int"],["sqlite3_result_error_nomem",void 0,"sqlite3_context*"],["sqlite3_result_error_toobig",void 0,"sqlite3_context*"],["sqlite3_result_int",void 0,"sqlite3_context*","int"],["sqlite3_result_null",void 0,"sqlite3_context*"],["sqlite3_result_pointer",void 0,"sqlite3_context*","*","string:static","*"],["sqlite3_result_subtype",void 0,"sqlite3_value*","int"],["sqlite3_result_text",void 0,"sqlite3_context*","string","int","*"],["sqlite3_result_zeroblob",void 0,"sqlite3_context*","int"],["sqlite3_rollback_hook","void*",["sqlite3*",new u.xWrap.FuncPtrAdapter({name:"sqlite3_rollback_hook",signature:"v(p)",contextKey:k=>k[0]}),"*"]],["sqlite3_set_authorizer","int",["sqlite3*",new u.xWrap.FuncPtrAdapter({name:"sqlite3_set_authorizer::xAuth",signature:"i(pissss)",contextKey:(k,m)=>k[0],callProxy:k=>(m,y,x,E,b,P)=>{try{return x=x&&u.cstrToJs(x),E=E&&u.cstrToJs(E),b=b&&u.cstrToJs(b),P=P&&u.cstrToJs(P),k(m,y,x,E,b,P)||0}catch(M){return M.resultCode||a.SQLITE_ERROR}}}),"*"]],["sqlite3_set_auxdata",void 0,["sqlite3_context*","int","*",new u.xWrap.FuncPtrAdapter({name:"xDestroyAuxData",signature:"v(*)",contextKey:(k,m)=>k[0]})]],["sqlite3_shutdown",void 0],["sqlite3_sourceid","string"],["sqlite3_sql","string","sqlite3_stmt*"],["sqlite3_status","int","int","*","*","int"],["sqlite3_step","int","sqlite3_stmt*"],["sqlite3_stmt_isexplain","int",["sqlite3_stmt*"]],["sqlite3_stmt_readonly","int",["sqlite3_stmt*"]],["sqlite3_stmt_status","int","sqlite3_stmt*","int","int"],["sqlite3_strglob","int","string","string"],["sqlite3_stricmp","int","string","string"],["sqlite3_strlike","int","string","string","int"],["sqlite3_strnicmp","int","string","string","int"],["sqlite3_table_column_metadata","int","sqlite3*","string","string","string","**","**","*","*","*"],["sqlite3_total_changes","int","sqlite3*"],["sqlite3_trace_v2","int",["sqlite3*","int",new u.xWrap.FuncPtrAdapter({name:"sqlite3_trace_v2::callback",signature:"i(ippp)",contextKey:(k,m)=>k[0]}),"*"]],["sqlite3_txn_state","int",["sqlite3*","string"]],["sqlite3_uri_boolean","int","sqlite3_filename","string","int"],["sqlite3_uri_key","string","sqlite3_filename","int"],["sqlite3_uri_parameter","string","sqlite3_filename","string"],["sqlite3_user_data","void*","sqlite3_context*"],["sqlite3_value_blob","*","sqlite3_value*"],["sqlite3_value_bytes","int","sqlite3_value*"],["sqlite3_value_double","f64","sqlite3_value*"],["sqlite3_value_dup","sqlite3_value*","sqlite3_value*"],["sqlite3_value_free",void 0,"sqlite3_value*"],["sqlite3_value_frombind","int","sqlite3_value*"],["sqlite3_value_int","int","sqlite3_value*"],["sqlite3_value_nochange","int","sqlite3_value*"],["sqlite3_value_numeric_type","int","sqlite3_value*"],["sqlite3_value_pointer","*","sqlite3_value*","string:static"],["sqlite3_value_subtype","int","sqlite3_value*"],["sqlite3_value_text","string","sqlite3_value*"],["sqlite3_value_type","int","sqlite3_value*"],["sqlite3_vfs_find","*","string"],["sqlite3_vfs_register","int","sqlite3_vfs*","int"],["sqlite3_vfs_unregister","int","sqlite3_vfs*"]],u.exports.sqlite3_activate_see instanceof Function&&u.bindingSignatures.push(["sqlite3_key","int","sqlite3*","string","int"],["sqlite3_key_v2","int","sqlite3*","string","*","int"],["sqlite3_rekey","int","sqlite3*","string","int"],["sqlite3_rekey_v2","int","sqlite3*","string","*","int"],["sqlite3_activate_see",void 0,"string"]),u.bindingSignatures.int64=[["sqlite3_bind_int64","int",["sqlite3_stmt*","int","i64"]],["sqlite3_changes64","i64",["sqlite3*"]],["sqlite3_column_int64","i64",["sqlite3_stmt*","int"]],["sqlite3_create_module","int",["sqlite3*","string","sqlite3_module*","*"]],["sqlite3_create_module_v2","int",["sqlite3*","string","sqlite3_module*","*","*"]],["sqlite3_declare_vtab","int",["sqlite3*","string:flexible"]],["sqlite3_deserialize","int","sqlite3*","string","*","i64","i64","int"],["sqlite3_drop_modules","int",["sqlite3*","**"]],["sqlite3_last_insert_rowid","i64",["sqlite3*"]],["sqlite3_malloc64","*","i64"],["sqlite3_msize","i64","*"],["sqlite3_overload_function","int",["sqlite3*","string","int"]],["sqlite3_preupdate_blobwrite","int","sqlite3*"],["sqlite3_preupdate_count","int","sqlite3*"],["sqlite3_preupdate_depth","int","sqlite3*"],["sqlite3_preupdate_hook","*",["sqlite3*",new u.xWrap.FuncPtrAdapter({name:"sqlite3_preupdate_hook",signature:"v(ppippjj)",contextKey:k=>k[0],callProxy:k=>(m,y,x,E,b,P,M)=>{k(m,y,x,u.cstrToJs(E),u.cstrToJs(b),P,M)}}),"*"]],["sqlite3_preupdate_new","int",["sqlite3*","int","**"]],["sqlite3_preupdate_old","int",["sqlite3*","int","**"]],["sqlite3_realloc64","*","*","i64"],["sqlite3_result_int64",void 0,"*","i64"],["sqlite3_result_zeroblob64","int","*","i64"],["sqlite3_serialize","*","sqlite3*","string","*","int"],["sqlite3_set_last_insert_rowid",void 0,["sqlite3*","i64"]],["sqlite3_status64","int","int","*","*","int"],["sqlite3_total_changes64","i64",["sqlite3*"]],["sqlite3_update_hook","*",["sqlite3*",new u.xWrap.FuncPtrAdapter({name:"sqlite3_update_hook",signature:"v(iippj)",contextKey:k=>k[0],callProxy:k=>(m,y,x,E,b)=>{k(m,y,u.cstrToJs(x),u.cstrToJs(E),b)}}),"*"]],["sqlite3_uri_int64","i64",["sqlite3_filename","string","i64"]],["sqlite3_value_int64","i64","sqlite3_value*"],["sqlite3_vtab_collation","string","sqlite3_index_info*","int"],["sqlite3_vtab_distinct","int","sqlite3_index_info*"],["sqlite3_vtab_in","int","sqlite3_index_info*","int","int"],["sqlite3_vtab_in_first","int","sqlite3_value*","**"],["sqlite3_vtab_in_next","int","sqlite3_value*","**"],["sqlite3_vtab_nochange","int","sqlite3_context*"],["sqlite3_vtab_on_conflict","int","sqlite3*"],["sqlite3_vtab_rhs_value","int","sqlite3_index_info*","int","**"]],u.bigIntEnabled&&u.exports.sqlite3changegroup_add){const k={signature:"i(ps)",callProxy:m=>(y,x)=>{try{return m(y,u.cstrToJs(x))|0}catch(E){return E.resultCode||a.SQLITE_ERROR}}};u.bindingSignatures.int64.push(["sqlite3changegroup_add","int",["sqlite3_changegroup*","int","void*"]],["sqlite3changegroup_add_strm","int",["sqlite3_changegroup*",new u.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3changegroup_delete",void 0,["sqlite3_changegroup*"]],["sqlite3changegroup_new","int",["**"]],["sqlite3changegroup_output","int",["sqlite3_changegroup*","int*","**"]],["sqlite3changegroup_output_strm","int",["sqlite3_changegroup*",new u.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppi)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply","int",["sqlite3*","int","void*",new u.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...k}),new u.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_strm","int",["sqlite3*",new u.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new u.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...k}),new u.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_v2","int",["sqlite3*","int","void*",new u.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...k}),new u.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v2_strm","int",["sqlite3*",new u.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new u.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...k}),new u.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_concat","int",["int","void*","int","void*","int*","**"]],["sqlite3changeset_concat_strm","int",[new u.xWrap.FuncPtrAdapter({name:"xInputA",signature:"i(ppp)",bindScope:"transient"}),"void*",new u.xWrap.FuncPtrAdapter({name:"xInputB",signature:"i(ppp)",bindScope:"transient"}),"void*",new u.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppi)",bindScope:"transient"}),"void*"]],["sqlite3changeset_conflict","int",["sqlite3_changeset_iter*","int","**"]],["sqlite3changeset_finalize","int",["sqlite3_changeset_iter*"]],["sqlite3changeset_fk_conflicts","int",["sqlite3_changeset_iter*","int*"]],["sqlite3changeset_invert","int",["int","void*","int*","**"]],["sqlite3changeset_invert_strm","int",[new u.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new u.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppi)",bindScope:"transient"}),"void*"]],["sqlite3changeset_new","int",["sqlite3_changeset_iter*","int","**"]],["sqlite3changeset_next","int",["sqlite3_changeset_iter*"]],["sqlite3changeset_old","int",["sqlite3_changeset_iter*","int","**"]],["sqlite3changeset_op","int",["sqlite3_changeset_iter*","**","int*","int*","int*"]],["sqlite3changeset_pk","int",["sqlite3_changeset_iter*","**","int*"]],["sqlite3changeset_start","int",["**","int","*"]],["sqlite3changeset_start_strm","int",["**",new u.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3changeset_start_v2","int",["**","int","*","int"]],["sqlite3changeset_start_v2_strm","int",["**",new u.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*","int"]],["sqlite3session_attach","int",["sqlite3_session*","string"]],["sqlite3session_changeset","int",["sqlite3_session*","int*","**"]],["sqlite3session_changeset_size","i64",["sqlite3_session*"]],["sqlite3session_changeset_strm","int",["sqlite3_session*",new u.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3session_config","int",["int","void*"]],["sqlite3session_create","int",["sqlite3*","string","**"]],["sqlite3session_diff","int",["sqlite3_session*","string","string","**"]],["sqlite3session_enable","int",["sqlite3_session*","int"]],["sqlite3session_indirect","int",["sqlite3_session*","int"]],["sqlite3session_isempty","int",["sqlite3_session*"]],["sqlite3session_memory_used","i64",["sqlite3_session*"]],["sqlite3session_object_config","int",["sqlite3_session*","int","void*"]],["sqlite3session_patchset","int",["sqlite3_session*","*","**"]],["sqlite3session_patchset_strm","int",["sqlite3_session*",new u.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3session_table_filter",void 0,["sqlite3_session*",new u.xWrap.FuncPtrAdapter({name:"xFilter",...k,contextKey:(m,y)=>m[0]}),"*"]])}u.bindingSignatures.wasm=[["sqlite3_wasm_db_reset","int","sqlite3*"],["sqlite3_wasm_db_vfs","sqlite3_vfs*","sqlite3*","string"],["sqlite3_wasm_vfs_create_file","int","sqlite3_vfs*","string","*","int"],["sqlite3_wasm_vfs_unlink","int","sqlite3_vfs*","string"]],i.StructBinder=globalThis.Jaccwabyt({heap:u.heap8u,alloc:u.alloc,dealloc:u.dealloc,bigIntEnabled:u.bigIntEnabled,memberPrefix:"$"}),delete globalThis.Jaccwabyt;{const k=u.xWrap.argAdapter("string");u.xWrap.argAdapter("string:flexible",b=>k(d.flexibleString(b))),u.xWrap.argAdapter("string:static",function(b){return u.isPtr(b)?b:(b=""+b,this[b]||(this[b]=u.allocCString(b)))}.bind(Object.create(null)));const m=u.xWrap.argAdapter("*"),y=function(){};u.xWrap.argAdapter("sqlite3_filename",m)("sqlite3_context*",m)("sqlite3_value*",m)("void*",m)("sqlite3_changegroup*",m)("sqlite3_changeset_iter*",m)("sqlite3_session*",m)("sqlite3_stmt*",b=>{var P;return m(b instanceof(((P=i==null?void 0:i.oo1)==null?void 0:P.Stmt)||y)?b.pointer:b)})("sqlite3*",b=>{var P;return m(b instanceof(((P=i==null?void 0:i.oo1)==null?void 0:P.DB)||y)?b.pointer:b)})("sqlite3_index_info*",b=>m(b instanceof(a.sqlite3_index_info||y)?b.pointer:b))("sqlite3_module*",b=>m(b instanceof(a.sqlite3_module||y)?b.pointer:b))("sqlite3_vfs*",b=>typeof b=="string"?a.sqlite3_vfs_find(b)||i.SQLite3Error.toss(a.SQLITE_NOTFOUND,"Unknown sqlite3_vfs name:",b):m(b instanceof(a.sqlite3_vfs||y)?b.pointer:b));const x=u.xWrap.resultAdapter("*");u.xWrap.resultAdapter("sqlite3*",x)("sqlite3_context*",x)("sqlite3_stmt*",x)("sqlite3_value*",x)("sqlite3_vfs*",x)("void*",x);for(const b of u.bindingSignatures)a[b[0]]=u.xWrap.apply(null,b);for(const b of u.bindingSignatures.wasm)u[b[0]]=u.xWrap.apply(null,b);const E=function(b){return()=>l(b+"() is unavailable due to lack","of BigInt support in this build.")};for(const b of u.bindingSignatures.int64)a[b[0]]=u.bigIntEnabled?u.xWrap.apply(null,b):E(b[0]);if(delete u.bindingSignatures,u.exports.sqlite3_wasm_db_error){const b=u.xWrap("sqlite3_wasm_db_error","int","sqlite3*","int","string");d.sqlite3_wasm_db_error=function(P,M,B){return M instanceof i.WasmAllocError?(M=a.SQLITE_NOMEM,B=0):M instanceof Error&&(B=B||""+M,M=M.resultCode||a.SQLITE_ERROR),P?b(P,M,B):M}}else d.sqlite3_wasm_db_error=function(b,P,M){return console.warn("sqlite3_wasm_db_error() is not exported.",arguments),P}}{const k=u.xCall("sqlite3_wasm_enum_json");k||l("Maintenance required: increase sqlite3_wasm_enum_json()'s","static buffer size!"),u.ctype=JSON.parse(u.cstrToJs(k));const m=["access","authorizer","blobFinalizers","changeset","config","dataTypes","dbConfig","dbStatus","encodings","fcntl","flock","ioCap","limits","openFlags","prepareFlags","resultCodes","sqlite3Status","stmtStatus","syncFlags","trace","txnState","udfFlags","version"];u.bigIntEnabled&&m.push("serialize","session","vtab");for(const E of m)for(const b of Object.entries(u.ctype[E]))a[b[0]]=b[1];u.functionEntry(a.SQLITE_WASM_DEALLOC)||l("Internal error: cannot resolve exported function","entry SQLITE_WASM_DEALLOC (=="+a.SQLITE_WASM_DEALLOC+").");const y=Object.create(null);for(const E of["resultCodes"])for(const b of Object.entries(u.ctype[E]))y[b[1]]=b[0];a.sqlite3_js_rc_str=E=>y[E];const x=Object.assign(Object.create(null),{WasmTestStruct:!0,sqlite3_kvvfs_methods:!d.isUIThread(),sqlite3_index_info:!u.bigIntEnabled,sqlite3_index_constraint:!u.bigIntEnabled,sqlite3_index_orderby:!u.bigIntEnabled,sqlite3_index_constraint_usage:!u.bigIntEnabled});for(const E of u.ctype.structs)x[E.name]||(a[E.name]=i.StructBinder(E));if(a.sqlite3_index_info){for(const E of["sqlite3_index_constraint","sqlite3_index_orderby","sqlite3_index_constraint_usage"])a.sqlite3_index_info[E]=a[E],delete a[E];a.sqlite3_vtab_config=u.xWrap("sqlite3_wasm_vtab_config","int",["sqlite3*","int","int"])}}const N=(k,m,y)=>i.util.sqlite3_wasm_db_error(k,a.SQLITE_MISUSE,m+"() requires "+y+" argument"+(y===1?"":"s")+"."),S=k=>d.sqlite3_wasm_db_error(k,a.SQLITE_FORMAT,"SQLITE_UTF8 is the only supported encoding."),C=k=>u.xWrap.argAdapter("sqlite3*")(k),V=k=>u.isPtr(k)?u.cstrToJs(k):k,J=function(k,m){k=C(k);let y=this.dbMap.get(k);if(m)!y&&m>0&&this.dbMap.set(k,y=Object.create(null));else return this.dbMap.delete(k),y;return y}.bind(Object.assign(Object.create(null),{dbMap:new Map}));J.addCollation=function(k,m){const y=J(k,1);y.collation||(y.collation=new Set),y.collation.add(V(m).toLowerCase())},J._addUDF=function(k,m,y,x){m=V(m).toLowerCase();let E=x.get(m);E||x.set(m,E=new Set),E.add(y<0?-1:y)},J.addFunction=function(k,m,y){const x=J(k,1);x.udf||(x.udf=new Map),this._addUDF(k,m,y,x.udf)},J.addWindowFunc=function(k,m,y){const x=J(k,1);x.wudf||(x.wudf=new Map),this._addUDF(k,m,y,x.wudf)},J.cleanup=function(k){k=C(k);const m=[k];for(const E of["sqlite3_busy_handler","sqlite3_commit_hook","sqlite3_preupdate_hook","sqlite3_progress_handler","sqlite3_rollback_hook","sqlite3_set_authorizer","sqlite3_trace_v2","sqlite3_update_hook"]){const b=u.exports[E];m.length=b.length;try{a[E](...m)}catch(P){console.warn("close-time call of",E+"(",m,") threw:",P)}}const y=J(k,0);if(!y)return;if(y.collation){for(const E of y.collation)try{a.sqlite3_create_collation_v2(k,E,a.SQLITE_UTF8,0,0,0)}catch{}delete y.collation}let x;for(x=0;x<2;++x){const E=x?y.wudf:y.udf;if(!E)continue;const b=x?a.sqlite3_create_window_function:a.sqlite3_create_function_v2;for(const P of E){const M=P[0],B=P[1],D=[k,M,0,a.SQLITE_UTF8,0,0,0,0,0];x&&D.push(0);for(const le of B)try{D[2]=le,b.apply(null,D)}catch{}B.clear()}E.clear()}delete y.udf,delete y.wudf};{const k=u.xWrap("sqlite3_close_v2","int","sqlite3*");a.sqlite3_close_v2=function(m){if(arguments.length!==1)return N(m,"sqlite3_close_v2",1);if(m)try{J.cleanup(m)}catch{}return k(m)}}if(a.sqlite3session_table_filter){const k=u.xWrap("sqlite3session_delete",void 0,["sqlite3_session*"]);a.sqlite3session_delete=function(m){if(arguments.length!==1)return N(pDb,"sqlite3session_delete",1);m&&a.sqlite3session_table_filter(m,0,0),k(m)}}{const k=(y,x)=>"argv["+x+"]:"+y[0]+":"+u.cstrToJs(y[1]).toLowerCase(),m=u.xWrap("sqlite3_create_collation_v2","int",["sqlite3*","string","int","*",new u.xWrap.FuncPtrAdapter({name:"xCompare",signature:"i(pipip)",contextKey:k}),new u.xWrap.FuncPtrAdapter({name:"xDestroy",signature:"v(p)",contextKey:k})]);a.sqlite3_create_collation_v2=function(y,x,E,b,P,M){if(arguments.length!==6)return N(y,"sqlite3_create_collation_v2",6);if(!(E&15))E|=a.SQLITE_UTF8;else if(a.SQLITE_UTF8!==(E&15))return S(y);try{const B=m(y,x,E,b,P,M);return B===0&&P instanceof Function&&J.addCollation(y,x),B}catch(B){return d.sqlite3_wasm_db_error(y,B)}},a.sqlite3_create_collation=(y,x,E,b,P)=>arguments.length===5?a.sqlite3_create_collation_v2(y,x,E,b,P,0):N(y,"sqlite3_create_collation",5)}{const k=function(E,b){return E[0]+":"+(E[2]<0?-1:E[2])+":"+b+":"+u.cstrToJs(E[1]).toLowerCase()},m=Object.assign(Object.create(null),{xInverseAndStep:{signature:"v(pip)",contextKey:k,callProxy:E=>(b,P,M)=>{try{E(b,...a.sqlite3_values_to_js(P,M))}catch(B){a.sqlite3_result_error_js(b,B)}}},xFinalAndValue:{signature:"v(p)",contextKey:k,callProxy:E=>b=>{try{a.sqlite3_result_js(b,E(b))}catch(P){a.sqlite3_result_error_js(b,P)}}},xFunc:{signature:"v(pip)",contextKey:k,callProxy:E=>(b,P,M)=>{try{a.sqlite3_result_js(b,E(b,...a.sqlite3_values_to_js(P,M)))}catch(B){a.sqlite3_result_error_js(b,B)}}},xDestroy:{signature:"v(p)",contextKey:k,callProxy:E=>b=>{try{E(b)}catch(P){console.error("UDF xDestroy method threw:",P)}}}}),y=u.xWrap("sqlite3_create_function_v2","int",["sqlite3*","string","int","int","*",new u.xWrap.FuncPtrAdapter({name:"xFunc",...m.xFunc}),new u.xWrap.FuncPtrAdapter({name:"xStep",...m.xInverseAndStep}),new u.xWrap.FuncPtrAdapter({name:"xFinal",...m.xFinalAndValue}),new u.xWrap.FuncPtrAdapter({name:"xDestroy",...m.xDestroy})]),x=u.xWrap("sqlite3_create_window_function","int",["sqlite3*","string","int","int","*",new u.xWrap.FuncPtrAdapter({name:"xStep",...m.xInverseAndStep}),new u.xWrap.FuncPtrAdapter({name:"xFinal",...m.xFinalAndValue}),new u.xWrap.FuncPtrAdapter({name:"xValue",...m.xFinalAndValue}),new u.xWrap.FuncPtrAdapter({name:"xInverse",...m.xInverseAndStep}),new u.xWrap.FuncPtrAdapter({name:"xDestroy",...m.xDestroy})]);a.sqlite3_create_function_v2=function E(b,P,M,B,D,le,z,g,v){if(E.length!==arguments.length)return N(b,"sqlite3_create_function_v2",E.length);if(!(B&15))B|=a.SQLITE_UTF8;else if(a.SQLITE_UTF8!==(B&15))return S(b);try{const I=y(b,P,M,B,D,le,z,g,v);return I===0&&(le instanceof Function||z instanceof Function||g instanceof Function||v instanceof Function)&&J.addFunction(b,P,M),I}catch(I){return console.error("sqlite3_create_function_v2() setup threw:",I),d.sqlite3_wasm_db_error(b,I,"Creation of UDF threw: "+I)}},a.sqlite3_create_function=function E(b,P,M,B,D,le,z,g){return E.length===arguments.length?a.sqlite3_create_function_v2(b,P,M,B,D,le,z,g,0):N(b,"sqlite3_create_function",E.length)},a.sqlite3_create_window_function=function E(b,P,M,B,D,le,z,g,v,I){if(E.length!==arguments.length)return N(b,"sqlite3_create_window_function",E.length);if(!(B&15))B|=a.SQLITE_UTF8;else if(a.SQLITE_UTF8!==(B&15))return S(b);try{const q=x(b,P,M,B,D,le,z,g,v,I);return q===0&&(le instanceof Function||z instanceof Function||g instanceof Function||v instanceof Function||I instanceof Function)&&J.addWindowFunc(b,P,M),q}catch(q){return console.error("sqlite3_create_window_function() setup threw:",q),d.sqlite3_wasm_db_error(b,q,"Creation of UDF threw: "+q)}},a.sqlite3_create_function_v2.udfSetResult=a.sqlite3_create_function.udfSetResult=a.sqlite3_create_window_function.udfSetResult=a.sqlite3_result_js,a.sqlite3_create_function_v2.udfConvertArgs=a.sqlite3_create_function.udfConvertArgs=a.sqlite3_create_window_function.udfConvertArgs=a.sqlite3_values_to_js,a.sqlite3_create_function_v2.udfSetError=a.sqlite3_create_function.udfSetError=a.sqlite3_create_window_function.udfSetError=a.sqlite3_result_error_js}{const k=(y,x)=>(typeof y=="string"?x=-1:d.isSQLableTypedArray(y)?(x=y.byteLength,y=d.typedArrayToString(y instanceof ArrayBuffer?new Uint8Array(y):y)):Array.isArray(y)&&(y=y.join(""),x=-1),[y,x]),m={basic:u.xWrap("sqlite3_prepare_v3","int",["sqlite3*","string","int","int","**","**"]),full:u.xWrap("sqlite3_prepare_v3","int",["sqlite3*","*","int","int","**","**"])};a.sqlite3_prepare_v3=function y(x,E,b,P,M,B){if(y.length!==arguments.length)return N(x,"sqlite3_prepare_v3",y.length);const[D,le]=k(E,b);switch(typeof D){case"string":return m.basic(x,D,le,P,M,null);case"number":return m.full(x,D,le,P,M,B);default:return d.sqlite3_wasm_db_error(x,a.SQLITE_MISUSE,"Invalid SQL argument type for sqlite3_prepare_v2/v3().")}},a.sqlite3_prepare_v2=function y(x,E,b,P,M){return y.length===arguments.length?a.sqlite3_prepare_v3(x,E,b,0,P,M):N(x,"sqlite3_prepare_v2",y.length)}}{const k=u.xWrap("sqlite3_bind_text","int",["sqlite3_stmt*","int","string","int","*"]),m=u.xWrap("sqlite3_bind_blob","int",["sqlite3_stmt*","int","*","int","*"]);a.sqlite3_bind_text=function y(x,E,b,P,M){if(y.length!==arguments.length)return N(a.sqlite3_db_handle(x),"sqlite3_bind_text",y.length);if(u.isPtr(b)||b===null)return k(x,E,b,P,M);b instanceof ArrayBuffer?b=new Uint8Array(b):Array.isArray(pMem)&&(b=pMem.join(""));let B,D;try{if(d.isSQLableTypedArray(b))B=u.allocFromTypedArray(b),D=b.byteLength;else if(typeof b=="string")[B,D]=u.allocCString(b);else return d.sqlite3_wasm_db_error(a.sqlite3_db_handle(x),a.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_text().");return k(x,E,B,D,a.SQLITE_WASM_DEALLOC)}catch(le){return u.dealloc(B),d.sqlite3_wasm_db_error(a.sqlite3_db_handle(x),le)}},a.sqlite3_bind_blob=function y(x,E,b,P,M){if(y.length!==arguments.length)return N(a.sqlite3_db_handle(x),"sqlite3_bind_blob",y.length);if(u.isPtr(b)||b===null)return m(x,E,b,P,M);b instanceof ArrayBuffer?b=new Uint8Array(b):Array.isArray(b)&&(b=b.join(""));let B,D;try{if(d.isBindableTypedArray(b))B=u.allocFromTypedArray(b),D=P>=0?P:b.byteLength;else if(typeof b=="string")[B,D]=u.allocCString(b);else return d.sqlite3_wasm_db_error(a.sqlite3_db_handle(x),a.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_blob().");return m(x,E,B,D,a.SQLITE_WASM_DEALLOC)}catch(le){return u.dealloc(B),d.sqlite3_wasm_db_error(a.sqlite3_db_handle(x),le)}}}a.sqlite3_config=function(k,...m){if(arguments.length<2)return a.SQLITE_MISUSE;switch(k){case a.SQLITE_CONFIG_COVERING_INDEX_SCAN:case a.SQLITE_CONFIG_MEMSTATUS:case a.SQLITE_CONFIG_SMALL_MALLOC:case a.SQLITE_CONFIG_SORTERREF_SIZE:case a.SQLITE_CONFIG_STMTJRNL_SPILL:case a.SQLITE_CONFIG_URI:return u.exports.sqlite3_wasm_config_i(k,m[0]);case a.SQLITE_CONFIG_LOOKASIDE:return u.exports.sqlite3_wasm_config_ii(k,m[0],m[1]);case a.SQLITE_CONFIG_MEMDB_MAXSIZE:return u.exports.sqlite3_wasm_config_j(k,m[0]);case a.SQLITE_CONFIG_GETMALLOC:case a.SQLITE_CONFIG_GETMUTEX:case a.SQLITE_CONFIG_GETPCACHE2:case a.SQLITE_CONFIG_GETPCACHE:case a.SQLITE_CONFIG_HEAP:case a.SQLITE_CONFIG_LOG:case a.SQLITE_CONFIG_MALLOC:case a.SQLITE_CONFIG_MMAP_SIZE:case a.SQLITE_CONFIG_MULTITHREAD:case a.SQLITE_CONFIG_MUTEX:case a.SQLITE_CONFIG_PAGECACHE:case a.SQLITE_CONFIG_PCACHE2:case a.SQLITE_CONFIG_PCACHE:case a.SQLITE_CONFIG_PCACHE_HDRSZ:case a.SQLITE_CONFIG_PMASZ:case a.SQLITE_CONFIG_SERIALIZED:case a.SQLITE_CONFIG_SINGLETHREAD:case a.SQLITE_CONFIG_SQLLOG:case a.SQLITE_CONFIG_WIN32_HEAPSIZE:default:return a.SQLITE_NOTFOUND}};{const k=new Set;a.sqlite3_auto_extension=function(m){if(m instanceof Function)m=u.installFunction("i(ppp)",m);else if(arguments.length!==1||!u.isPtr(m))return a.SQLITE_MISUSE;const y=u.exports.sqlite3_auto_extension(m);return m!==arguments[0]&&(y===0?k.add(m):u.uninstallFunction(m)),y},a.sqlite3_cancel_auto_extension=function(m){return!m||arguments.length!==1||!u.isPtr(m)?0:u.exports.sqlite3_cancel_auto_extension(m)},a.sqlite3_reset_auto_extension=function(){u.exports.sqlite3_reset_auto_extension();for(const m of k)u.uninstallFunction(m);k.clear()}}const ie=a.sqlite3_vfs_find("kvvfs");if(ie)if(d.isUIThread()){const k=new a.sqlite3_kvvfs_methods(u.exports.sqlite3_wasm_kvvfs_methods());delete a.sqlite3_kvvfs_methods;const m=u.exports.sqlite3_wasm_kvvfsMakeKeyOnPstack,y=u.pstack,x=b=>u.peek(b)===115?sessionStorage:localStorage,E={xRead:(b,P,M,B)=>{const D=y.pointer,le=u.scopedAllocPush();try{const z=m(b,P);if(!z)return-3;const g=u.cstrToJs(z),v=x(b).getItem(g);if(!v)return-1;const I=v.length;if(B<=0)return I;if(B===1)return u.poke(M,0),I;const q=u.scopedAllocCString(v);return B>I+1&&(B=I+1),u.heap8u().copyWithin(M,q,q+B-1),u.poke(M+B-1,0),B-1}catch(z){return console.error("kvstorageRead()",z),-2}finally{y.restore(D),u.scopedAllocPop(le)}},xWrite:(b,P,M)=>{const B=y.pointer;try{const D=m(b,P);if(!D)return 1;const le=u.cstrToJs(D);return x(b).setItem(le,u.cstrToJs(M)),0}catch(D){return console.error("kvstorageWrite()",D),a.SQLITE_IOERR}finally{y.restore(B)}},xDelete:(b,P)=>{const M=y.pointer;try{const B=m(b,P);return B?(x(b).removeItem(u.cstrToJs(B)),0):1}catch(B){return console.error("kvstorageDelete()",B),a.SQLITE_IOERR}finally{y.restore(M)}}};for(const b of Object.keys(E))k[k.memberKey(b)]=u.installFunction(k.memberSignature(b),E[b])}else a.sqlite3_vfs_unregister(ie);u.xWrap.FuncPtrAdapter.warnOnUse=!0}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){i.version={libVersion:"3.42.0",libVersionNumber:3042e3,sourceId:"2023-05-16 12:36:15 831d0fb2836b71c9bc51067c49fee4b8f18047814f2ff22d817d25195cf350b0",downloadVersion:342e4}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){const l=(...q)=>{throw new i.SQLite3Error(...q)},a=i.capi,u=i.wasm,d=i.util,N=new WeakMap,S=new WeakMap,C=(q,w,f)=>{const p=Object.getOwnPropertyDescriptor(q,w);return p?p.value:f},V=function(q,w){return w&&(q instanceof m&&(q=q.pointer),l("sqlite3 result code",w+":",q?a.sqlite3_errmsg(q):a.sqlite3_errstr(w))),arguments[0]},J=u.installFunction("i(ippp)",function(q,w,f,p){a.SQLITE_TRACE_STMT===q&&console.log("SQL TRACE #"+ ++this.counter+" via sqlite3@"+w+":",u.cstrToJs(p))}.bind({counter:0})),ie=Object.create(null),k=function q(...w){if(!q._name2vfs){q._name2vfs=Object.create(null);const de=typeof importScripts=="function"?ve=>l("The VFS for",ve,"is only available in the main window thread."):!1;q._name2vfs[":localStorage:"]={vfs:"kvvfs",filename:de||(()=>"local")},q._name2vfs[":sessionStorage:"]={vfs:"kvvfs",filename:de||(()=>"session")}}const f=q.normalizeArgs(...w);let p=f.filename,_=f.vfs,W=f.flags;(typeof p!="string"&&typeof p!="number"||typeof W!="string"||_&&typeof _!="string"&&typeof _!="number")&&(i.config.error("Invalid DB ctor args",f,arguments),l("Invalid arguments for DB constructor."));let L=typeof p=="number"?u.cstrToJs(p):p;const se=q._name2vfs[L];se&&(_=se.vfs,p=L=se.filename(L));let oe,ce=0;W.indexOf("c")>=0&&(ce|=a.SQLITE_OPEN_CREATE|a.SQLITE_OPEN_READWRITE),W.indexOf("w")>=0&&(ce|=a.SQLITE_OPEN_READWRITE),ce===0&&(ce|=a.SQLITE_OPEN_READONLY),ce|=a.SQLITE_OPEN_EXRESCODE;const pe=u.pstack.pointer;try{const de=u.pstack.allocPtr();let ve=a.sqlite3_open_v2(p,de,ce,_||0);oe=u.peekPtr(de),V(oe,ve),a.sqlite3_extended_result_codes(oe,1),W.indexOf("t")>=0&&a.sqlite3_trace_v2(oe,a.SQLITE_TRACE_STMT,J,oe)}catch(de){throw oe&&a.sqlite3_close_v2(oe),de}finally{u.pstack.restore(pe)}this.filename=L,N.set(this,oe),S.set(this,Object.create(null));try{const de=a.sqlite3_js_db_vfs(oe);de||l("Internal error: cannot get VFS for new db handle.");const ve=ie[de];ve instanceof Function?ve(this,i):ve&&V(oe,a.sqlite3_exec(oe,ve,0,0,0))}catch(de){throw this.close(),de}};k.setVfsPostOpenSql=function(q,w){ie[q]=w},k.normalizeArgs=function(q=":memory:",w="c",f=null){const p={};return arguments.length===1&&arguments[0]&&typeof arguments[0]=="object"?(Object.assign(p,arguments[0]),p.flags===void 0&&(p.flags="c"),p.vfs===void 0&&(p.vfs=null),p.filename===void 0&&(p.filename=":memory:")):(p.filename=q,p.flags=w,p.vfs=f),p};const m=function(...q){k.apply(this,q)};m.dbCtorHelper=k;const y={null:1,number:2,string:3,boolean:4,blob:5};y.undefined==y.null,u.bigIntEnabled&&(y.bigint=y.number);const x=function(){y!==arguments[2]&&l(a.SQLITE_MISUSE,"Do not call the Stmt constructor directly. Use DB.prepare()."),this.db=arguments[0],N.set(this,arguments[1]),this.columnCount=a.sqlite3_column_count(this.pointer),this.parameterCount=a.sqlite3_bind_parameter_count(this.pointer)},E=function(q){return q.pointer||l("DB has been closed."),q},b=function(q,w){return(w!==(w|0)||w<0||w>=q.columnCount)&&l("Column index",w,"is out of range."),q},P=function(q,w){const f=Object.create(null);switch(f.opt=Object.create(null),w.length){case 1:typeof w[0]=="string"||d.isSQLableTypedArray(w[0])||Array.isArray(w[0])?f.sql=w[0]:w[0]&&typeof w[0]=="object"&&(f.opt=w[0],f.sql=f.opt.sql);break;case 2:f.sql=w[0],f.opt=w[1];break;default:l("Invalid argument count for exec().")}f.sql=d.flexibleString(f.sql),typeof f.sql!="string"&&l("Missing SQL argument or unsupported SQL value type.");const p=f.opt;switch(p.returnValue){case"resultRows":p.resultRows||(p.resultRows=[]),f.returnVal=()=>p.resultRows;break;case"saveSql":p.saveSql||(p.saveSql=[]),f.returnVal=()=>p.saveSql;break;case void 0:case"this":f.returnVal=()=>q;break;default:l("Invalid returnValue value:",p.returnValue)}if(!p.callback&&!p.returnValue&&p.rowMode!==void 0&&(p.resultRows||(p.resultRows=[]),f.returnVal=()=>p.resultRows),p.callback||p.resultRows)switch(p.rowMode===void 0?"array":p.rowMode){case"object":f.cbArg=_=>_.get(Object.create(null));break;case"array":f.cbArg=_=>_.get([]);break;case"stmt":Array.isArray(p.resultRows)&&l("exec(): invalid rowMode for a resultRows array: must","be one of 'array', 'object',","a result column number, or column name reference."),f.cbArg=_=>_;break;default:if(d.isInt32(p.rowMode)){f.cbArg=_=>_.get(p.rowMode);break}else if(typeof p.rowMode=="string"&&p.rowMode.length>1&&p.rowMode[0]==="$"){const _=p.rowMode.substr(1);f.cbArg=W=>{const L=W.get(Object.create(null))[_];return L===void 0?l(a.SQLITE_NOTFOUND,"exec(): unknown result column:",_):L};break}l("Invalid rowMode:",p.rowMode)}return f},M=(q,w,f,...p)=>{const _=q.prepare(w);try{return _.bind(f).step()?_.get(...p):void 0}finally{_.finalize()}},B=(q,w,f,p)=>q.exec({sql:w,bind:f,rowMode:p,returnValue:"resultRows"});m.checkRc=(q,w)=>V(q,w),m.prototype={isOpen:function(){return!!this.pointer},affirmOpen:function(){return E(this)},close:function(){if(this.pointer){if(this.onclose&&this.onclose.before instanceof Function)try{this.onclose.before(this)}catch{}const q=this.pointer;if(Object.keys(S.get(this)).forEach((w,f)=>{f&&f.pointer&&f.finalize()}),N.delete(this),S.delete(this),a.sqlite3_close_v2(q),this.onclose&&this.onclose.after instanceof Function)try{this.onclose.after(this)}catch{}delete this.filename}},changes:function(q=!1,w=!1){const f=E(this).pointer;return q?w?a.sqlite3_total_changes64(f):a.sqlite3_total_changes(f):w?a.sqlite3_changes64(f):a.sqlite3_changes(f)},dbFilename:function(q="main"){return a.sqlite3_db_filename(E(this).pointer,q)},dbName:function(q=0){return a.sqlite3_db_name(E(this).pointer,q)},dbVfsName:function(q=0){let w;const f=a.sqlite3_js_db_vfs(E(this).pointer,q);if(f){const p=new a.sqlite3_vfs(f);try{w=u.cstrToJs(p.$zName)}finally{p.dispose()}}return w},prepare:function(q){E(this);const w=u.pstack.pointer;let f,p;try{f=u.pstack.alloc(8),m.checkRc(this,a.sqlite3_prepare_v2(this.pointer,q,-1,f,null)),p=u.peekPtr(f)}finally{u.pstack.restore(w)}p||l("Cannot prepare empty SQL.");const _=new x(this,p,y);return S.get(this)[p]=_,_},exec:function(){E(this);const q=P(this,arguments);if(!q.sql)return l("exec() requires an SQL string.");const w=q.opt,f=w.callback,p=Array.isArray(w.resultRows)?w.resultRows:void 0;let _,W=w.bind,L=!!(q.cbArg||w.columnNames||p);const se=u.scopedAllocPush(),oe=Array.isArray(w.saveSql)?w.saveSql:void 0;try{const ce=d.isSQLableTypedArray(q.sql);let pe=ce?q.sql.byteLength:u.jstrlen(q.sql);const de=u.scopedAlloc(2*u.ptrSizeof+(pe+1)),ve=de+u.ptrSizeof;let Je=ve+u.ptrSizeof;const mt=Je+pe;for(ce?u.heap8().set(q.sql,Je):u.jstrcpy(q.sql,u.heap8(),Je,pe,!1),u.poke(Je+pe,0);Je&&u.peek(Je,"i8");){u.pokePtr([de,ve],0),m.checkRc(this,a.sqlite3_prepare_v3(this.pointer,Je,pe,0,de,ve));const un=u.peekPtr(de);if(Je=u.peekPtr(ve),pe=mt-Je,!!un){if(oe&&oe.push(a.sqlite3_sql(un).trim()),_=new x(this,un,y),W&&_.parameterCount&&(_.bind(W),W=null),L&&_.columnCount){if(L=!1,Array.isArray(w.columnNames)&&_.getColumnNames(w.columnNames),q.cbArg||p){for(;_.step();_._isLocked=!1){_._isLocked=!0;const O=q.cbArg(_);if(p&&p.push(O),f&&f.call(w,O,_)===!1)break}_._isLocked=!1}}else _.step();_.finalize(),_=null}}}finally{_&&(delete _._isLocked,_.finalize()),u.scopedAllocPop(se)}return q.returnVal()},createFunction:function(w,f,p){const _=j=>j instanceof Function;switch(arguments.length){case 1:p=w,w=p.name,f=p.xFunc||0;break;case 2:_(f)||(p=f,f=p.xFunc||0);break}p||(p={}),typeof w!="string"&&l("Invalid arguments: missing function name.");let W=p.xStep||0,L=p.xFinal||0;const se=p.xValue||0,oe=p.xInverse||0;let ce;_(f)?(ce=!1,(_(W)||_(L))&&l("Ambiguous arguments: scalar or aggregate?"),W=L=null):_(W)?(_(L)||l("Missing xFinal() callback for aggregate or window UDF."),f=null):_(L)?l("Missing xStep() callback for aggregate or window UDF."):l("Missing function-type properties."),ce===!1?(_(se)||_(oe))&&l("xValue and xInverse are not permitted for non-window UDFs."):_(se)?(_(oe)||l("xInverse must be provided if xValue is."),ce=!0):_(oe)&&l("xValue must be provided if xInverse is.");const pe=p.pApp;pe!=null&&(typeof pe!="number"||!d.isInt32(pe))&&l("Invalid value for pApp property. Must be a legal WASM pointer value.");const de=p.xDestroy||0;de&&!_(de)&&l("xDestroy property must be a function.");let ve=0;C(p,"deterministic")&&(ve|=a.SQLITE_DETERMINISTIC),C(p,"directOnly")&&(ve|=a.SQLITE_DIRECTONLY),C(p,"innocuous")&&(ve|=a.SQLITE_INNOCUOUS),w=w.toLowerCase();const Je=f||W,mt=C(p,"arity"),un=typeof mt=="number"?mt:Je.length?Je.length-1:0;let O;return ce?O=a.sqlite3_create_window_function(this.pointer,w,un,a.SQLITE_UTF8|ve,pe||0,W,L,se,oe,de):O=a.sqlite3_create_function_v2(this.pointer,w,un,a.SQLITE_UTF8|ve,pe||0,f,W,L,de),m.checkRc(this,O),this},selectValue:function(q,w,f){return M(this,q,w,0,f)},selectValues:function(q,w,f){const p=this.prepare(q),_=[];try{for(p.bind(w);p.step();)_.push(p.get(0,f))}finally{p.finalize()}return _},selectArray:function(q,w){return M(this,q,w,[])},selectObject:function(q,w){return M(this,q,w,{})},selectArrays:function(q,w){return B(this,q,w,"array")},selectObjects:function(q,w){return B(this,q,w,"object")},openStatementCount:function(){return this.pointer?Object.keys(S.get(this)).length:0},transaction:function(q){let w="BEGIN";arguments.length>1&&(/[^a-zA-Z]/.test(arguments[0])&&l(a.SQLITE_MISUSE,"Invalid argument for BEGIN qualifier."),w+=" "+arguments[0],q=arguments[1]),E(this).exec(w);try{const f=q(this);return this.exec("COMMIT"),f}catch(f){throw this.exec("ROLLBACK"),f}},savepoint:function(q){E(this).exec("SAVEPOINT oo1");try{const w=q(this);return this.exec("RELEASE oo1"),w}catch(w){throw this.exec("ROLLBACK to SAVEPOINT oo1; RELEASE SAVEPOINT oo1"),w}},checkRc:function(q){return m.checkRc(this,q)}};const D=function(q){return q.pointer||l("Stmt has been closed."),q},le=function(q){let w=y[q==null?"null":typeof q];switch(w){case y.boolean:case y.null:case y.number:case y.string:return w;case y.bigint:if(u.bigIntEnabled)return w;default:return d.isBindableTypedArray(q)?y.blob:void 0}},z=function(q){return le(q)||l("Unsupported bind() argument type:",typeof q)},g=function(q,w){const f=typeof w=="number"?w:a.sqlite3_bind_parameter_index(q.pointer,w);return f===0||!d.isInt32(f)?l("Invalid bind() parameter name: "+w):(f<1||f>q.parameterCount)&&l("Bind index",w,"is out of range."),f},v=function(q,w){return q._isLocked&&l("Operation is illegal when statement is locked:",w),q},I=function q(w,f,p,_){v(D(w),"bind()"),q._||(q._tooBigInt=L=>l("BigInt value is too big to store without precision loss:",L),q._={string:function(L,se,oe,ce){const[pe,de]=u.allocCString(oe,!0);return(ce?a.sqlite3_bind_blob:a.sqlite3_bind_text)(L.pointer,se,pe,de,a.SQLITE_WASM_DEALLOC)}}),z(_),f=g(w,f);let W=0;switch(_==null?y.null:p){case y.null:W=a.sqlite3_bind_null(w.pointer,f);break;case y.string:W=q._.string(w,f,_,!1);break;case y.number:{let L;d.isInt32(_)?L=a.sqlite3_bind_int:typeof _=="bigint"?d.bigIntFits64(_)?u.bigIntEnabled?L=a.sqlite3_bind_int64:d.bigIntFitsDouble(_)?(_=Number(_),L=a.sqlite3_bind_double):q._tooBigInt(_):q._tooBigInt(_):(_=Number(_),u.bigIntEnabled&&Number.isInteger(_)?L=a.sqlite3_bind_int64:L=a.sqlite3_bind_double),W=L(w.pointer,f,_);break}case y.boolean:W=a.sqlite3_bind_int(w.pointer,f,_?1:0);break;case y.blob:{if(typeof _=="string"){W=q._.string(w,f,_,!0);break}else _ instanceof ArrayBuffer?_=new Uint8Array(_):d.isBindableTypedArray(_)||l("Binding a value as a blob requires","that it be a string, Uint8Array, Int8Array, or ArrayBuffer.");const L=u.alloc(_.byteLength||1);u.heap8().set(_.byteLength?_:[0],L),W=a.sqlite3_bind_blob(w.pointer,f,L,_.byteLength,a.SQLITE_WASM_DEALLOC);break}default:i.config.warn("Unsupported bind() argument type:",_),l("Unsupported bind() argument type: "+typeof _)}return W&&m.checkRc(w.db.pointer,W),w._mayGet=!1,w};x.prototype={finalize:function(){this.pointer&&(v(this,"finalize()"),delete S.get(this.db)[this.pointer],a.sqlite3_finalize(this.pointer),N.delete(this),delete this._mayGet,delete this.columnCount,delete this.parameterCount,delete this.db,delete this._isLocked)},clearBindings:function(){return v(D(this),"clearBindings()"),a.sqlite3_clear_bindings(this.pointer),this._mayGet=!1,this},reset:function(q){return v(this,"reset()"),q&&this.clearBindings(),a.sqlite3_reset(D(this).pointer),this._mayGet=!1,this},bind:function(){D(this);let q,w;switch(arguments.length){case 1:q=1,w=arguments[0];break;case 2:q=arguments[0],w=arguments[1];break;default:l("Invalid bind() arguments.")}return w===void 0?this:(this.parameterCount||l("This statement has no bindable parameters."),this._mayGet=!1,w===null?I(this,q,y.null,w):Array.isArray(w)?(arguments.length!==1&&l("When binding an array, an index argument is not permitted."),w.forEach((f,p)=>I(this,p+1,z(f),f)),this):(w instanceof ArrayBuffer&&(w=new Uint8Array(w)),typeof w=="object"&&!d.isBindableTypedArray(w)?(arguments.length!==1&&l("When binding an object, an index argument is not permitted."),Object.keys(w).forEach(f=>I(this,f,z(w[f]),w[f])),this):I(this,q,z(w),w)))},bindAsBlob:function(q,w){D(this),arguments.length===1&&(w=q,q=1);const f=z(w);return y.string!==f&&y.blob!==f&&y.null!==f&&l("Invalid value type for bindAsBlob()"),I(this,q,y.blob,w)},step:function(){v(this,"step()");const q=a.sqlite3_step(D(this).pointer);switch(q){case a.SQLITE_DONE:return this._mayGet=!1;case a.SQLITE_ROW:return this._mayGet=!0;default:this._mayGet=!1,i.config.warn("sqlite3_step() rc=",q,a.sqlite3_js_rc_str(q),"SQL =",a.sqlite3_sql(this.pointer)),m.checkRc(this.db.pointer,q)}},stepReset:function(){return this.step(),this.reset()},stepFinalize:function(){const q=this.step();return this.finalize(),q},get:function(q,w){if(D(this)._mayGet||l("Stmt.step() has not (recently) returned true."),Array.isArray(q)){let f=0;for(;f=Number.MIN_SAFE_INTEGER&&f<=Number.MAX_SAFE_INTEGER?Number(f).valueOf():f}else{const f=a.sqlite3_column_double(this.pointer,q);return(f>Number.MAX_SAFE_INTEGER||fl("The pointer property is read-only.")};Object.defineProperty(x.prototype,"pointer",q),Object.defineProperty(m.prototype,"pointer",q)}if(i.oo1={DB:m,Stmt:x},d.isUIThread()){i.oo1.JsStorageDb=function(w="session"){w!=="session"&&w!=="local"&&l("JsStorageDb db name must be one of 'session' or 'local'."),k.call(this,{filename:w,flags:"c",vfs:"kvvfs"})};const q=i.oo1.JsStorageDb;q.prototype=Object.create(m.prototype),q.clearStorage=a.sqlite3_js_kvvfs_clear,q.prototype.clearStorage=function(){return q.clearStorage(E(this).filename)},q.storageSize=a.sqlite3_js_kvvfs_size,q.prototype.storageSize=function(){return q.storageSize(E(this).filename)}}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){i.initWorker1API=function(){const l=(...m)=>{throw new Error(m.join(" "))};globalThis.WorkerGlobalScope instanceof Function||l("initWorker1API() must be run from a Worker thread."),this.self;const a=this.sqlite3||l("Missing this.sqlite3 object."),u=a.oo1.DB,d=function(m){let y=N.idMap.get(m);return y||(y="db#"+ ++N.idSeq+"@"+m.pointer,N.idMap.set(m,y),y)},N={dbList:[],idSeq:0,idMap:new WeakMap,xfer:[],open:function(m){const y=new u(m);return this.dbs[d(y)]=y,this.dbList.indexOf(y)<0&&this.dbList.push(y),y},close:function(m,y){if(m){delete this.dbs[d(m)];const x=m.filename,E=a.wasm.sqlite3_wasm_db_vfs(m.pointer,0);m.close();const b=this.dbList.indexOf(m);b>=0&&this.dbList.splice(b,1),y&&x&&E&&a.wasm.sqlite3_wasm_vfs_unlink(E,x)}},post:function(m,y){y&&y.length?(globalThis.postMessage(m,Array.from(y)),y.length=0):globalThis.postMessage(m)},dbs:Object.create(null),getDb:function(m,y=!0){return this.dbs[m]||(y?l("Unknown (or closed) DB ID:",m):void 0)}},S=function(m=N.dbList[0]){return m&&m.pointer?m:l("DB is not opened.")},C=function(m,y=!0){const x=N.getDb(m.dbId,!1)||N.dbList[0];return y?S(x):x},V=function(){return N.dbList[0]&&d(N.dbList[0])},J=function(m){const y=/^file:.+(vfs=(\w+))/.exec(m);return a.capi.sqlite3_vfs_find(y?y[2]:0)},ie=m=>m===""||m[0]===":",k={open:function(m){const y=Object.create(null),x=m.args||Object.create(null);x.simulateError&&l("Throwing because of simulateError flag.");const E=Object.create(null);let b,P;if(y.vfs=x.vfs,ie(x.filename)?y.filename=x.filename||"":(y.filename=x.filename,b=x.byteArray,b&&(P=J(x.filename))),P){let B;try{B=a.wasm.allocFromTypedArray(b);const D=a.wasm.sqlite3_wasm_vfs_create_file(P,y.filename,B,b.byteLength);D&&a.SQLite3Error.toss(D)}catch(D){throw new a.SQLite3Error(D.name+" creating "+x.filename+": "+D.message,{cause:D})}finally{B&&a.wasm.dealloc(B)}}const M=N.open(y);return E.filename=M.filename,E.persistent=!!a.capi.sqlite3_js_db_uses_vfs(M.pointer,"opfs"),E.dbId=d(M),E.vfs=M.dbVfsName(),E},close:function(m){const y=C(m,!1),x={filename:y&&y.filename};if(y){const E=m.args&&typeof m.args=="object"?!!m.args.unlink:!1;N.close(y,E)}return x},exec:function(m){const y=typeof m.args=="string"?{sql:m.args}:m.args||Object.create(null);y.rowMode==="stmt"?l("Invalid rowMode for 'exec': stmt mode","does not work in the Worker API."):y.sql||l("'exec' requires input SQL.");const x=C(m);(y.callback||Array.isArray(y.resultRows))&&(x._blobXfer=N.xfer);const E=y.callback;let b=0;const P=!!y.columnNames;typeof E=="string"&&(P||(y.columnNames=[]),y.callback=function(M,B){N.post({type:E,columnNames:y.columnNames,rowNumber:++b,row:M},N.xfer)});try{x.exec(y),y.callback instanceof Function&&(y.callback=E,N.post({type:E,columnNames:y.columnNames,rowNumber:null,row:void 0}))}finally{delete x._blobXfer,y.callback&&(y.callback=E)}return y},"config-get":function(){const m=Object.create(null),y=a.config;return["bigIntEnabled"].forEach(function(x){Object.getOwnPropertyDescriptor(y,x)&&(m[x]=y[x])}),m.version=a.version,m.vfsList=a.capi.sqlite3_js_vfs_list(),m.opfsEnabled=!!a.opfs,m},export:function(m){const y=C(m),x={byteArray:a.capi.sqlite3_js_db_export(y.pointer),filename:y.filename,mimetype:"application/x-sqlite3"};return N.xfer.push(x.byteArray.buffer),x},toss:function(m){l("Testing worker exception")},"opfs-tree":async function(m){return a.opfs||l("OPFS support is unavailable."),await a.opfs.treeList()}};globalThis.onmessage=async function(m){m=m.data;let y,x=m.dbId,E=m.type;const b=performance.now();try{k.hasOwnProperty(E)&&k[E]instanceof Function?y=await k[E](m):l("Unknown db worker message type:",m.type)}catch(P){E="error",y={operation:m.type,message:P.message,errorClass:P.name,input:m},P.stack&&(y.stack=typeof P.stack=="string"?P.stack.split(/\n\s*/):P.stack)}x||(x=y.dbId||V()),N.post({type:E,dbId:x,messageId:m.messageId,workerReceivedTime:b,workerRespondTime:performance.now(),departureTime:m.departureTime,result:y},N.xfer)},globalThis.postMessage({type:"sqlite3-api",result:"worker1-ready"})}.bind({self,sqlite3:i})}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){const l=i.wasm,a=i.capi,u=i.util.toss3,d=Object.create(null),N=Object.create(null),S=i.StructBinder;i.vfs=d,i.vtab=N;const C=a.sqlite3_index_info;C.prototype.nthConstraint=function(m,y=!1){if(m<0||m>=this.$nConstraint)return!1;const x=this.$aConstraint+C.sqlite3_index_constraint.structInfo.sizeof*m;return y?x:new C.sqlite3_index_constraint(x)},C.prototype.nthConstraintUsage=function(m,y=!1){if(m<0||m>=this.$nConstraint)return!1;const x=this.$aConstraintUsage+C.sqlite3_index_constraint_usage.structInfo.sizeof*m;return y?x:new C.sqlite3_index_constraint_usage(x)},C.prototype.nthOrderBy=function(m,y=!1){if(m<0||m>=this.$nOrderBy)return!1;const x=this.$aOrderBy+C.sqlite3_index_orderby.structInfo.sizeof*m;return y?x:new C.sqlite3_index_orderby(x)};const V=function m(y,x,E,b=m.installMethodArgcCheck){if(y instanceof S.StructType?!(E instanceof Function)&&!l.isPtr(E)&&u("Usage errror: expecting a Function or WASM pointer to one."):u("Usage error: target object is-not-a StructType."),arguments.length===1)return(D,le)=>m(y,D,le,b);m.argcProxy||(m.argcProxy=function(D,le,z,g){return function(...v){return z.length!==arguments.length&&u("Argument mismatch for",D.structInfo.name+"::"+le+": Native signature is:",g),z.apply(this,v)}},m.removeFuncList=function(){this.ondispose.__removeFuncList&&(this.ondispose.__removeFuncList.forEach((D,le)=>{if(typeof D=="number")try{l.uninstallFunction(D)}catch{}}),delete this.ondispose.__removeFuncList)});const P=y.memberSignature(x);P.length<2&&u("Member",x,"does not have a function pointer signature:",P);const M=y.memberKey(x),B=b&&!l.isPtr(E)?m.argcProxy(y,M,E,P):E;if(l.isPtr(B))B&&!l.functionEntry(B)&&u("Pointer",B,"is not a WASM function table entry."),y[M]=B;else{const D=l.installFunction(B,y.memberSignature(x,!0));y[M]=D,(!y.ondispose||!y.ondispose.__removeFuncList)&&(y.addOnDispose("ondispose.__removeFuncList handler",m.removeFuncList),y.ondispose.__removeFuncList=[]),y.ondispose.__removeFuncList.push(M,D)}return(D,le)=>m(y,D,le,b)};V.installMethodArgcCheck=!1;const J=function(m,y,x=V.installMethodArgcCheck){const E=new Map;for(const b of Object.keys(y)){const P=y[b],M=E.get(P);if(M){const B=m.memberKey(b);m[B]=m[m.memberKey(M)]}else V(m,b,P,x),E.set(P,b)}return m};S.StructType.prototype.installMethod=function(y,x,E=V.installMethodArgcCheck){return arguments.length<3&&y&&typeof y=="object"?J(this,...arguments):V(this,...arguments)},S.StructType.prototype.installMethods=function(m,y=V.installMethodArgcCheck){return J(this,m,y)},a.sqlite3_vfs.prototype.registerVfs=function(m=!1){this instanceof i.capi.sqlite3_vfs||u("Expecting a sqlite3_vfs-type argument.");const y=a.sqlite3_vfs_register(this,m?1:0);return y&&u("sqlite3_vfs_register(",this,") failed with rc",y),this.pointer!==a.sqlite3_vfs_find(this.$zName)&&u("BUG: sqlite3_vfs_find(vfs.$zName) failed for just-installed VFS",this),this},d.installVfs=function(m){let y=0;const x=["io","vfs"];for(const E of x){const b=m[E];b&&(++y,J(b.struct,b.methods,!!b.applyArgcCheck),E==="vfs"&&(!b.struct.$zName&&typeof b.name=="string"&&b.struct.addOnDispose(b.struct.$zName=l.allocCString(b.name)),b.struct.registerVfs(!!b.asDefault)))}return y||u("Misuse: installVfs() options object requires at least","one of:",x),this};const ie=function(m,y){return function(x,E=!1){if(arguments.length===0&&(x=new y),x instanceof y)return this.set(x.pointer,x),x;l.isPtr(x)||i.SQLite3Error.toss("Invalid argument to",m+"()");let b=this.get(x);return E&&this.delete(x),b}.bind(new Map)},k=function(m,y){const x=ie(m,y);return Object.assign(Object.create(null),{StructType:y,create:E=>{const b=x();return l.pokePtr(E,b.pointer),b},get:E=>x(E),unget:E=>x(E,!0),dispose:E=>{const b=x(E,!0);b&&b.dispose()}})};N.xVtab=k("xVtab",a.sqlite3_vtab),N.xCursor=k("xCursor",a.sqlite3_vtab_cursor),N.xIndexInfo=m=>new a.sqlite3_index_info(m),N.xError=function m(y,x,E){if(m.errorReporter instanceof Function)try{m.errorReporter("sqlite3_module::"+y+"(): "+x.message)}catch{}let b;return x instanceof i.WasmAllocError?b=a.SQLITE_NOMEM:arguments.length>2?b=E:x instanceof i.SQLite3Error&&(b=x.resultCode),b||a.SQLITE_ERROR},N.xError.errorReporter=console.error.bind(console),N.xRowid=(m,y)=>l.poke(m,y,"i64"),N.setupModule=function(m){let y=!1;const x=this instanceof a.sqlite3_module?this:m.struct||(y=new a.sqlite3_module);try{const E=m.methods||u("Missing 'methods' object.");for(const b of Object.entries({xConnect:"xCreate",xDisconnect:"xDestroy"})){const P=b[0],M=b[1];E[P]===!0?E[P]=E[M]:E[M]===!0&&(E[M]=E[P])}if(m.catchExceptions){const b=function(B,D){return["xConnect","xCreate"].indexOf(B)>=0?function(le,z,g,v,I,q){try{return D(...arguments)||0}catch(w){return w instanceof i.WasmAllocError||(l.dealloc(l.peekPtr(q)),l.pokePtr(q,l.allocCString(w.message))),N.xError(B,w)}}:function(...le){try{return D(...le)||0}catch(z){return N.xError(B,z)}}},P=["xCreate","xConnect","xBestIndex","xDisconnect","xDestroy","xOpen","xClose","xFilter","xNext","xEof","xColumn","xRowid","xUpdate","xBegin","xSync","xCommit","xRollback","xFindFunction","xRename","xSavepoint","xRelease","xRollbackTo","xShadowName"],M=Object.create(null);for(const B of P){const D=E[B];if(D instanceof Function)B==="xConnect"&&E.xCreate===D?M[B]=E.xCreate:B==="xCreate"&&E.xConnect===D?M[B]=E.xConnect:M[B]=b(B,D);else continue}J(x,M,!1)}else J(x,E,!!m.applyArgcCheck);if(x.$iVersion===0){let b;typeof m.iVersion=="number"?b=m.iVersion:x.$xShadowName?b=3:x.$xSavePoint||x.$xRelease||x.$xRollbackTo?b=2:b=1,x.$iVersion=b}}catch(E){throw y&&y.dispose(),E}return x},a.sqlite3_module.prototype.setupModule=function(m){return N.setupModule.call(this,m)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){const l=function a(u){var S;if(!globalThis.SharedArrayBuffer||!globalThis.Atomics)return Promise.reject(new Error("Cannot install OPFS: Missing SharedArrayBuffer and/or Atomics. The server must emit the COOP/COEP response headers to enable those. See https://sqlite.org/wasm/doc/trunk/persistence.md#coop-coep"));if(typeof WorkerGlobalScope>"u")return Promise.reject(new Error("The OPFS sqlite3_vfs cannot run in the main thread because it requires Atomics.wait()."));if(!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle||!((S=navigator==null?void 0:navigator.storage)!=null&&S.getDirectory))return Promise.reject(new Error("Missing required OPFS APIs."));(!u||typeof u!="object")&&(u=Object.create(null));const d=new URL(globalThis.location.href).searchParams;return u.verbose===void 0&&(u.verbose=d.has("opfs-verbose")?+d.get("opfs-verbose")||2:1),u.sanityChecks===void 0&&(u.sanityChecks=d.has("opfs-sanity-check")),u.proxyUri===void 0&&(u.proxyUri=a.defaultProxyUri),typeof u.proxyUri=="function"&&(u.proxyUri=u.proxyUri()),new Promise(function(C,V){const J={0:i.config.error,1:i.config.warn,2:i.config.log},ie=(O,...j)=>{u.verbose>O&&J[O]("OPFS syncer:",...j)},k=(...O)=>ie(2,...O),m=(...O)=>ie(1,...O),y=(...O)=>ie(0,...O),x=i.util.toss,E=i.capi,b=i.wasm,P=E.sqlite3_vfs,M=E.sqlite3_file,B=E.sqlite3_io_methods,D=Object.create(null),le=()=>{var O;return globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle&&globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle&&((O=navigator==null?void 0:navigator.storage)==null?void 0:O.getDirectory)};D.metrics={dump:function(){let O,j=0,Q=0,Y=0;for(O in _.opIds){const G=W[O];j+=G.count,Q+=G.time,Y+=G.wait,G.avgTime=G.count&&G.time?G.time/G.count:0,G.avgWait=G.count&&G.wait?G.wait/G.count:0}i.config.log(globalThis.location.href,"metrics for",globalThis.location.href,":",W,` Total of`,j,"op(s) for",Q,"ms (incl. "+Y+" ms of waiting on the async side)"),i.config.log("Serialization metrics:",W.s11n),w.postMessage({type:"opfs-async-metrics"})},reset:function(){let O;const j=Y=>Y.count=Y.time=Y.wait=0;for(O in _.opIds)j(W[O]=Object.create(null));let Q=W.s11n=Object.create(null);Q=Q.serialize=Object.create(null),Q.count=Q.time=0,Q=W.s11n.deserialize=Object.create(null),Q.count=Q.time=0}};const z=new P,g=new B;let v;const I=O=>(v=!0,z.dispose(),V(O)),q=O=>(v=!1,C(O)),w=new Worker(new URL(""+new URL("sqlite3-opfs-async-proxy-9f074d6f.js",self.location.href).href,self.location));setTimeout(()=>{v===void 0&&I(new Error("Timeout while waiting for OPFS async proxy worker."))},4e3),w._originalOnError=w.onerror,w.onerror=function(O){y("Error initializing OPFS asyncer:",O),I(new Error("Loading OPFS async Worker failed for unknown reasons."))};const f=E.sqlite3_vfs_find(null),p=f?new P(f):null;z.$iVersion=2,z.$szOsFile=E.sqlite3_file.structInfo.sizeof,z.$mxPathname=1024,z.$zName=b.allocCString("opfs"),z.$xDlOpen=z.$xDlError=z.$xDlSym=z.$xDlClose=null,z.ondispose=["$zName",z.$zName,"cleanup default VFS wrapper",()=>p?p.dispose():null,"cleanup opfsIoMethods",()=>g.dispose()];const _=Object.create(null);_.verbose=u.verbose,_.littleEndian=(()=>{const O=new ArrayBuffer(2);return new DataView(O).setInt16(0,256,!0),new Int16Array(O)[0]===256})(),_.asyncIdleWaitTime=150,_.asyncS11nExceptions=1,_.fileBufferSize=1024*64,_.sabS11nOffset=_.fileBufferSize,_.sabS11nSize=z.$mxPathname*2,_.sabIO=new SharedArrayBuffer(_.fileBufferSize+_.sabS11nSize),_.opIds=Object.create(null);const W=Object.create(null);{let O=0;_.opIds.whichOp=O++,_.opIds.rc=O++,_.opIds.xAccess=O++,_.opIds.xClose=O++,_.opIds.xDelete=O++,_.opIds.xDeleteNoWait=O++,_.opIds.xFileSize=O++,_.opIds.xLock=O++,_.opIds.xOpen=O++,_.opIds.xRead=O++,_.opIds.xSleep=O++,_.opIds.xSync=O++,_.opIds.xTruncate=O++,_.opIds.xUnlock=O++,_.opIds.xWrite=O++,_.opIds.mkdir=O++,_.opIds["opfs-async-metrics"]=O++,_.opIds["opfs-async-shutdown"]=O++,_.opIds.retry=O++,_.sabOP=new SharedArrayBuffer(O*4),D.metrics.reset()}_.sq3Codes=Object.create(null),["SQLITE_ACCESS_EXISTS","SQLITE_ACCESS_READWRITE","SQLITE_BUSY","SQLITE_ERROR","SQLITE_IOERR","SQLITE_IOERR_ACCESS","SQLITE_IOERR_CLOSE","SQLITE_IOERR_DELETE","SQLITE_IOERR_FSYNC","SQLITE_IOERR_LOCK","SQLITE_IOERR_READ","SQLITE_IOERR_SHORT_READ","SQLITE_IOERR_TRUNCATE","SQLITE_IOERR_UNLOCK","SQLITE_IOERR_WRITE","SQLITE_LOCK_EXCLUSIVE","SQLITE_LOCK_NONE","SQLITE_LOCK_PENDING","SQLITE_LOCK_RESERVED","SQLITE_LOCK_SHARED","SQLITE_LOCKED","SQLITE_MISUSE","SQLITE_NOTFOUND","SQLITE_OPEN_CREATE","SQLITE_OPEN_DELETEONCLOSE","SQLITE_OPEN_MAIN_DB","SQLITE_OPEN_READONLY"].forEach(O=>{(_.sq3Codes[O]=E[O])===void 0&&x("Maintenance required: not found:",O)}),_.opfsFlags=Object.assign(Object.create(null),{OPFS_UNLOCK_ASAP:1,defaultUnlockAsap:!1});const L=(O,...j)=>{const Q=_.opIds[O]||x("Invalid op ID:",O);_.s11n.serialize(...j),Atomics.store(_.sabOPView,_.opIds.rc,-1),Atomics.store(_.sabOPView,_.opIds.whichOp,Q),Atomics.notify(_.sabOPView,_.opIds.whichOp);const Y=performance.now();Atomics.wait(_.sabOPView,_.opIds.rc,-1);const G=Atomics.load(_.sabOPView,_.opIds.rc);if(W[O].wait+=performance.now()-Y,G&&_.asyncS11nExceptions){const xe=_.s11n.deserialize();xe&&y(O+"() async error:",...xe)}return G};D.debug={asyncShutdown:()=>{m("Shutting down OPFS async listener. The OPFS VFS will no longer work."),L("opfs-async-shutdown")},asyncRestart:()=>{m("Attempting to restart OPFS VFS async listener. Might work, might not."),w.postMessage({type:"opfs-async-restart"})}};const se=()=>{if(_.s11n)return _.s11n;const O=new TextDecoder,j=new TextEncoder("utf-8"),Q=new Uint8Array(_.sabIO,_.sabS11nOffset,_.sabS11nSize),Y=new DataView(_.sabIO,_.sabS11nOffset,_.sabS11nSize);_.s11n=Object.create(null);const G=Object.create(null);G.number={id:1,size:8,getter:"getFloat64",setter:"setFloat64"},G.bigint={id:2,size:8,getter:"getBigInt64",setter:"setBigInt64"},G.boolean={id:3,size:4,getter:"getInt32",setter:"setInt32"},G.string={id:4};const xe=ne=>G[typeof ne]||x("Maintenance required: this value type cannot be serialized.",ne),be=ne=>{switch(ne){case G.number.id:return G.number;case G.bigint.id:return G.bigint;case G.boolean.id:return G.boolean;case G.string.id:return G.string;default:x("Invalid type ID:",ne)}};return _.s11n.deserialize=function(ne=!1){++W.s11n.deserialize.count;const Vt=performance.now(),ct=Q[0],T=ct?[]:null;if(ct){const H=[];let $=1,K,Ie,Be;for(K=0;K{pe.start=performance.now(),pe.op=O,++W[O].count},ve=()=>W[pe.op].time+=performance.now()-pe.start,Je={xCheckReservedLock:function(O,j){const Q=ce[O];return b.poke(j,Q.lockType?1:0,"i32"),0},xClose:function(O){de("xClose");let j=0;const Q=ce[O];return Q&&(delete ce[O],j=L("xClose",O),Q.sq3File&&Q.sq3File.dispose()),ve(),j},xDeviceCharacteristics:function(O){return E.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(O,j,Q){return E.SQLITE_NOTFOUND},xFileSize:function(O,j){de("xFileSize");let Q=L("xFileSize",O);if(Q==0)try{const Y=_.s11n.deserialize()[0];b.poke(j,Y,"i64")}catch(Y){y("Unexpected error reading xFileSize() result:",Y),Q=_.sq3Codes.SQLITE_IOERR}return ve(),Q},xLock:function(O,j){de("xLock");const Q=ce[O];let Y=0;return Q.lockType?Q.lockType=j:(Y=L("xLock",O,j),Y===0&&(Q.lockType=j)),ve(),Y},xRead:function(O,j,Q,Y){de("xRead");const G=ce[O];let xe;try{xe=L("xRead",O,Q,Number(Y)),(xe===0||E.SQLITE_IOERR_SHORT_READ===xe)&&b.heap8u().set(G.sabView.subarray(0,Q),j)}catch(be){y("xRead(",arguments,") failed:",be,G),xe=E.SQLITE_IOERR_READ}return ve(),xe},xSync:function(O,j){de("xSync"),++W.xSync.count;const Q=L("xSync",O,j);return ve(),Q},xTruncate:function(O,j){de("xTruncate");const Q=L("xTruncate",O,Number(j));return ve(),Q},xUnlock:function(O,j){de("xUnlock");const Q=ce[O];let Y=0;return E.SQLITE_LOCK_NONE===j&&Q.lockType&&(Y=L("xUnlock",O,j)),Y===0&&(Q.lockType=j),ve(),Y},xWrite:function(O,j,Q,Y){de("xWrite");const G=ce[O];let xe;try{G.sabView.set(b.heap8u().subarray(j,j+Q)),xe=L("xWrite",O,Q,Number(Y))}catch(be){y("xWrite(",arguments,") failed:",be,G),xe=E.SQLITE_IOERR_WRITE}return ve(),xe}},mt={xAccess:function(O,j,Q,Y){de("xAccess");const G=L("xAccess",b.cstrToJs(j));return b.poke(Y,G?0:1,"i32"),ve(),0},xCurrentTime:function(O,j){return b.poke(j,24405875e-1+new Date().getTime()/864e5,"double"),0},xCurrentTimeInt64:function(O,j){return b.poke(j,24405875e-1*864e5+new Date().getTime(),"i64"),0},xDelete:function(O,j,Q){return de("xDelete"),L("xDelete",b.cstrToJs(j),Q,!1),ve(),0},xFullPathname:function(O,j,Q,Y){return b.cstrncpy(Y,j,Q)!!Y):Q},D.getDirForFilename=async function(j,Q=!1){const Y=D.getResolvedPath(j,!0),G=Y.pop();let xe=D.rootDirectory;for(const be of Y)be&&(xe=await xe.getDirectoryHandle(be,{create:!!Q}));return[xe,G]},D.mkdir=async function(O){try{return await D.getDirForFilename(O+"/filepart",!0),!0}catch{return!1}},D.entryExists=async function(O){try{const[j,Q]=await D.getDirForFilename(O);return await j.getFileHandle(Q),!0}catch{return!1}},D.randomFilename=oe,D.registerVfs=(O=!1)=>b.exports.sqlite3_vfs_register(z.pointer,O?1:0),D.treeList=async function(){const O=async function Q(Y,G){G.name=Y.name,G.dirs=[],G.files=[];for await(const xe of Y.values())if(xe.kind==="directory"){const be=Object.create(null);G.dirs.push(be),await Q(xe,be)}else G.files.push(xe.name)},j=Object.create(null);return await O(D.rootDirectory,j),j},D.rmfr=async function(){const O=D.rootDirectory,j={recurse:!0};for await(const Q of O.values())O.removeEntry(Q.name,j)},D.unlink=async function(O,j=!1,Q=!1){try{const[Y,G]=await D.getDirForFilename(O,!1);return await Y.removeEntry(G,{recursive:j}),!0}catch(Y){if(Q)throw new Error("unlink(",arguments[0],") failed: "+Y.message,{cause:Y});return!1}},D.traverse=async function(O){const j={recursive:!0,directory:D.rootDirectory};typeof O=="function"&&(O={callback:O}),O=Object.assign(j,O||{}),async function Y(G,xe){for await(const be of G.values()){if(O.callback(be,G,xe)===!1)return!1;if(O.recursive&&be.kind==="directory"&&await Y(be,xe+1)===!1)break}}(O.directory,0)},i.oo1){const O=function(...j){const Q=i.oo1.DB.dbCtorHelper.normalizeArgs(...j);Q.vfs=z.$zName,i.oo1.DB.dbCtorHelper.call(this,Q)};O.prototype=Object.create(i.oo1.DB.prototype),i.oo1.OpfsDb=O,i.oo1.DB.dbCtorHelper.setVfsPostOpenSql(z.pointer,function(j,Q){Q.capi.sqlite3_busy_timeout(j,1e4),Q.capi.sqlite3_exec(j,["pragma journal_mode=persist;","pragma cache_size=-16384;"],0,0,0)})}const un=function(){const O=b.scopedAllocPush(),j=new M;try{const Q=j.pointer,Y=E.SQLITE_OPEN_CREATE|E.SQLITE_OPEN_READWRITE|E.SQLITE_OPEN_MAIN_DB,G=b.scopedAlloc(8),xe="/sanity/check/file"+oe(8),be=b.scopedAllocCString(xe);let ne;if(_.s11n.serialize("This is ä string."),ne=_.s11n.deserialize(),k("deserialize() says:",ne),ne[0]!=="This is ä string."&&x("String d13n error."),mt.xAccess(z.pointer,be,0,G),ne=b.peek(G,"i32"),k("xAccess(",xe,") exists ?=",ne),ne=mt.xOpen(z.pointer,be,Q,Y,G),k("open rc =",ne,"state.sabOPView[xOpen] =",_.sabOPView[_.opIds.xOpen]),ne!==0){y("open failed with code",ne);return}mt.xAccess(z.pointer,be,0,G),ne=b.peek(G,"i32"),ne||x("xAccess() failed to detect file."),ne=Je.xSync(j.pointer,0),ne&&x("sync failed w/ rc",ne),ne=Je.xTruncate(j.pointer,1024),ne&&x("truncate failed w/ rc",ne),b.poke(G,0,"i64"),ne=Je.xFileSize(j.pointer,G),ne&&x("xFileSize failed w/ rc",ne),k("xFileSize says:",b.peek(G,"i64")),ne=Je.xWrite(j.pointer,be,10,1),ne&&x("xWrite() failed!");const Vt=b.scopedAlloc(16);ne=Je.xRead(j.pointer,Vt,6,2),b.poke(Vt+6,0);let ct=b.cstrToJs(Vt);k("xRead() got:",ct),ct!=="sanity"&&x("Unexpected xRead() value."),mt.xSleep&&(k("xSleep()ing before close()ing..."),mt.xSleep(z.pointer,2e3),k("waking up from xSleep()")),ne=Je.xClose(Q),k("xClose rc =",ne,"sabOPView =",_.sabOPView),k("Deleting file:",xe),mt.xDelete(z.pointer,be,4660),mt.xAccess(z.pointer,be,0,G),ne=b.peek(G,"i32"),ne&&x("Expecting 0 from xAccess(",xe,") after xDelete()."),m("End of OPFS sanity checks.")}finally{j.dispose(),b.scopedAllocPop(O)}};w.onmessage=function({data:O}){switch(O.type){case"opfs-unavailable":I(new Error(O.payload.join(" ")));break;case"opfs-async-loaded":w.postMessage({type:"opfs-async-init",args:_});break;case"opfs-async-inited":{if(v===!0)break;try{i.vfs.installVfs({io:{struct:g,methods:Je},vfs:{struct:z,methods:mt}}),_.sabOPView=new Int32Array(_.sabOP),_.sabFileBufView=new Uint8Array(_.sabIO,0,_.fileBufferSize),_.sabS11nView=new Uint8Array(_.sabIO,_.sabS11nOffset,_.sabS11nSize),se(),u.sanityChecks&&(m("Running sanity checks because of opfs-sanity-check URL arg..."),un()),le()?navigator.storage.getDirectory().then(j=>{w.onerror=w._originalOnError,delete w._originalOnError,i.opfs=D,D.rootDirectory=j,k("End of OPFS sqlite3_vfs setup.",z),q(i)}).catch(I):q(i)}catch(j){y(j),I(j)}break}default:{const j="Unexpected message from the OPFS async worker: "+JSON.stringify(O);y(j),I(new Error(j));break}}}})};l.defaultProxyUri="sqlite3-opfs-async-proxy.js",globalThis.sqlite3ApiBootstrap.initializersAsync.push(async a=>{try{let u=l.defaultProxyUri;return a.scriptInfo.sqlite3Dir&&(l.defaultProxyUri=a.scriptInfo.sqlite3Dir+u),l().catch(d=>{a.config.warn("Ignoring inability to install OPFS sqlite3_vfs:",d.message)})}catch(u){throw a.config.error("installOpfsVfs() exception:",u),u}})}),typeof o<"u"){const i=Object.assign(Object.create(null),{exports:o.asm,memory:o.wasmMemory},globalThis.sqlite3ApiConfig||{});globalThis.sqlite3ApiConfig=i;let l;try{l=globalThis.sqlite3ApiBootstrap()}catch(a){throw console.error("sqlite3ApiBootstrap() error:",a),a}finally{delete globalThis.sqlite3ApiBootstrap,delete globalThis.sqlite3ApiConfig}o.sqlite3=l}else console.warn("This is not running in an Emscripten module context, so","globalThis.sqlite3ApiBootstrap() is _not_ being called due to lack","of config info for the WASM environment.","It must be called manually.")}),r.ready}})();const Zu=function(){var r,n;const t=Yu;if(!t)throw new Error("Expecting globalThis.sqlite3InitModule to be defined by the Emscripten build.");const e=globalThis.sqlite3InitModuleState=Object.assign(Object.create(null),{moduleScript:(r=globalThis==null?void 0:globalThis.document)==null?void 0:r.currentScript,isWorker:typeof WorkerGlobalScope<"u",location:globalThis.location,urlParams:(n=globalThis==null?void 0:globalThis.location)!=null&&n.href?new URL(globalThis.location.href).searchParams:new URLSearchParams});if(e.debugModule=e.urlParams.has("sqlite3.debugModule")?(...A)=>console.warn("sqlite3.debugModule:",...A):()=>{},e.urlParams.has("sqlite3.dir"))e.sqlite3Dir=e.urlParams.get("sqlite3.dir")+"/";else if(e.moduleScript){const A=e.moduleScript.src.split("/");A.pop(),e.sqlite3Dir=A.join("/")+"/"}if(globalThis.sqlite3InitModule=function A(...X){return t(...X).then(ae=>{var At,nt,rt;if(typeof WorkerGlobalScope<"u"&&(ae.ENVIRONMENT_IS_PTHREAD||ae._pthread_self||typeof threadAlert=="function"||(rt=(nt=(At=globalThis==null?void 0:globalThis.location)==null?void 0:At.pathname)==null?void 0:nt.endsWith)!=null&&rt.call(nt,".worker.js")))return ae;const me=ae.sqlite3;me.scriptInfo=e,A.__isUnderTest&&(me.__isUnderTest=!0);const Oe=me.asyncPostInit;return delete me.asyncPostInit,Oe()}).catch(ae=>{throw console.error("Exception loading sqlite3 module:",ae),ae})},globalThis.sqlite3InitModule.ready=t.ready,globalThis.sqlite3InitModuleState.moduleScript){const A=globalThis.sqlite3InitModuleState;let X=A.moduleScript.src.split("/");X.pop(),A.scriptDir=X.join("/")+"/"}return e.debugModule("sqlite3InitModuleState =",e),globalThis.sqlite3InitModule}();var ec=t=>t==null||typeof t=="bigint"||typeof t=="number"||typeof t=="object"&&"buffer"in t?t:typeof t=="boolean"?`${t}`:t instanceof Date?t.toISOString():JSON.stringify(t),tc=t=>{if(t==null||typeof t=="bigint"||typeof t=="number"||typeof t=="object"&&"buffer"in t)return t;if(typeof t=="string"){const e=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?$/;if(/^(true|false)$/.test(t))return t==="true";if(e.test(t))return new Date(t);try{return JSON.parse(t,(r,n)=>typeof n=="string"&&e.exec(n)?new Date(n):n)}catch{}}return t},nc=(Fa=class extends Xs{constructor(e){super();R(this,Xn,void 0);U(this,Xn,e||ec)}transformPrimitiveValueList(e){return{...e,values:e.values.map(s(this,Xn))}}transformColumnUpdate(e){const{value:r}=e;if(r.kind!=="ValueNode")return super.transformColumnUpdate(e);const{value:n,...A}=r,X=s(this,Xn).call(this,n);return n===X?super.transformColumnUpdate(e):super.transformColumnUpdate({...e,value:{...A,value:X}})}transformValue(e){return{...e,value:s(this,Xn).call(this,e.value)}}},Xn=new WeakMap,Fa),rc=(Pa=class{constructor(t={}){R(this,qi,void 0);R(this,bi,void 0);R(this,Cr,void 0);U(this,qi,new nc(t.serializer)),U(this,bi,t.deserializer||tc),U(this,Cr,new WeakMap)}transformQuery(t){const{node:e,queryId:r}=t;return e.kind==="SelectQueryNode"&&s(this,Cr).set(r,e.kind),s(this,qi).transformNode(t.node)}async parseResult(t){return await Promise.all(t.map(async e=>{const r={...e};for(const n in r)r[n]=await s(this,bi).call(this,r[n]);return r}))}async transformResult(t){const{result:e,queryId:r}=t,{rows:n}=e,A=s(this,Cr).get(r);return n&&A==="SelectQueryNode"?{...t.result,rows:await this.parseResult(n)}:t.result}},qi=new WeakMap,bi=new WeakMap,Cr=new WeakMap,Pa);function ao(t){return typeof t=="string"}function ic(t){return typeof t=="boolean"}async function Ia(t,e,r,n,A="rowid"){await Wt` diff --git a/assets/sqljsWorker-eaa67eb7.js b/assets/sqljsWorker-342e964b.js similarity index 89% rename from assets/sqljsWorker-eaa67eb7.js rename to assets/sqljsWorker-342e964b.js index 267f018..b6cdfea 100644 --- a/assets/sqljsWorker-eaa67eb7.js +++ b/assets/sqljsWorker-342e964b.js @@ -1,4 +1,4 @@ -var Hl=Object.defineProperty;var Yl=(J,_,me)=>_ in J?Hl(J,_,{enumerable:!0,configurable:!0,writable:!0,value:me}):J[_]=me;var Xe=(J,_,me)=>(Yl(J,typeof _!="symbol"?_+"":_,me),me),Eo=(J,_,me)=>{if(!_.has(J))throw TypeError("Cannot "+me)};var n=(J,_,me)=>(Eo(J,_,"read from private field"),me?me.call(J):_.get(J)),w=(J,_,me)=>{if(_.has(J))throw TypeError("Cannot add the same private member more than once");_ instanceof WeakSet?_.add(J):_.set(J,me)},g=(J,_,me,dn)=>(Eo(J,_,"write to private field"),dn?dn.call(J,me):_.set(J,me),me);var X=(J,_,me)=>(Eo(J,_,"access private method"),me);(function(){var se,or,Mr,Tn,An,B,Sn,oe,L,Dn,x,Rn,q,Pr,rs,_r,ar,ns,Qu,is,Uu,ur,di,Ln,To,ss,Vu,Bn,ee,Mn,Fr,Qr,cr,Pn,Ao,m,Ur,Vr,jr,$r,jt,re,Jr,Gr,Kr,zr,bt,Hr,z,lr,dt,De,Ne,ne,le,H,Ge,U,Ce,Me,Pe,cs,ae,ke,Ke,ze,xe,Yr,Wt,Ot,St,ft,Jt,Dt,pr,Vn,ls,ju,ds,$u,fs,Ju,ps,Gu,jn,So,$n,Gt,ms,Ku,Kt,mr,Ie,pt,yr,mt,Ve,en,Bs,Jn,Do,Gn,Ro,tn,zt,Ns,rn,Nr,nn,ws,zu,Kn,vs,Fa,wr,sn,Qa,He,on,Ua,Ht,an,Va,zn,ja,vr,$a,Hn,Yn,un,Ja,Yt,Xn,Ga;"use strict";function J(t){return typeof t>"u"||t===void 0}function _(t){return typeof t=="string"}function me(t){return typeof t=="number"}function dn(t){return typeof t=="boolean"}function Lo(t){return t===null}function Hu(t){return t instanceof Date}function Yu(t){return typeof t=="bigint"}function Ze(t){return typeof t=="function"}function wt(t){return typeof t=="object"&&t!==null}function a(t){return Object.freeze(t)}function fn(t){return Array.isArray(t)}function Cr(t){return t}const ye=a({is(t){return t.kind==="AlterTableNode"},create(t){return a({kind:"AlterTableNode",table:t})},cloneWithTableProps(t,e){return a({...t,...e})},cloneWithColumnAlteration(t,e){return a({...t,columnAlterations:t.columnAlterations?[...t.columnAlterations,e]:[e]})}}),ue=a({is(t){return t.kind==="IdentifierNode"},create(t){return a({kind:"IdentifierNode",name:t})}}),Pt=a({is(t){return t.kind==="CreateIndexNode"},create(t){return a({kind:"CreateIndexNode",name:ue.create(t)})},cloneWith(t,e){return a({...t,...e})},cloneWithColumns(t,e){return a({...t,columns:[...t.columns||[],...e]})}}),Bo=a({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return a({kind:"CreateSchemaNode",schema:ue.create(t),...e})},cloneWith(t,e){return a({...t,...e})}}),Xu=["preserve rows","delete rows","drop"],at=a({is(t){return t.kind==="CreateTableNode"},create(t){return a({kind:"CreateTableNode",table:t,columns:a([])})},cloneWithColumn(t,e){return a({...t,columns:a([...t.columns,e])})},cloneWithConstraint(t,e){return a({...t,constraints:t.constraints?a([...t.constraints,e]):a([e])})},cloneWithFrontModifier(t,e){return a({...t,frontModifiers:t.frontModifiers?a([...t.frontModifiers,e]):a([e])})},cloneWithEndModifier(t,e){return a({...t,endModifiers:t.endModifiers?a([...t.endModifiers,e]):a([e])})},cloneWith(t,e){return a({...t,...e})}}),_t=a({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return a({kind:"SchemableIdentifierNode",identifier:ue.create(t)})},createWithSchema(t,e){return a({kind:"SchemableIdentifierNode",schema:ue.create(t),identifier:ue.create(e)})}}),fi=a({is(t){return t.kind==="DropIndexNode"},create(t,e){return a({kind:"DropIndexNode",name:_t.create(t),...e})},cloneWith(t,e){return a({...t,...e})}}),Ms=a({is(t){return t.kind==="DropSchemaNode"},create(t,e){return a({kind:"DropSchemaNode",schema:ue.create(t),...e})},cloneWith(t,e){return a({...t,...e})}}),Ps=a({is(t){return t.kind==="DropTableNode"},create(t,e){return a({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return a({...t,...e})}}),ir=a({is(t){return t.kind==="AliasNode"},create(t,e){return a({kind:"AliasNode",node:t,alias:e})}}),Ft=a({is(t){return t.kind==="TableNode"},create(t){return a({kind:"TableNode",table:_t.create(t)})},createWithSchema(t,e){return a({kind:"TableNode",table:_t.createWithSchema(t,e)})}});function Le(t){return wt(t)&&Ze(t.toOperationNode)}function Zu(t){return wt(t)&&"expressionType"in t&&Le(t)}function eh(t){return wt(t)&&"expression"in t&&_(t.alias)&&Le(t)}const It=a({is(t){return t.kind==="SelectModifierNode"},create(t){return a({kind:"SelectModifierNode",modifier:t})},createWithExpression(t){return a({kind:"SelectModifierNode",rawModifier:t})}}),pn=a({is(t){return t.kind==="AndNode"},create(t,e){return a({kind:"AndNode",left:t,right:e})}}),mn=a({is(t){return t.kind==="OrNode"},create(t,e){return a({kind:"OrNode",left:t,right:e})}}),yn=a({is(t){return t.kind==="OnNode"},create(t){return a({kind:"OnNode",on:t})},cloneWithOperation(t,e,r){return a({...t,on:e==="And"?pn.create(t.on,r):mn.create(t.on,r)})}}),et=a({is(t){return t.kind==="JoinNode"},create(t,e){return a({kind:"JoinNode",joinType:t,table:e,on:void 0})},createWithOn(t,e,r){return a({kind:"JoinNode",joinType:t,table:e,on:yn.create(r)})},cloneWithOn(t,e){return a({...t,on:t.on?yn.cloneWithOperation(t.on,"And",e):yn.create(e)})},cloneWithOrOn(t,e){return a({...t,on:t.on?yn.cloneWithOperation(t.on,"Or",e):yn.create(e)})}}),pi=a({is(t){return t.kind==="BinaryOperationNode"},create(t,e,r){return a({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:r})}}),Te=a({is(t){return t.kind==="RawNode"},create(t,e){return a({kind:"RawNode",sqlFragments:a(t),parameters:a(e)})},createWithSql(t){return Te.create([t],[])},createWithChild(t){return Te.create(["",""],[t])},createWithChildren(t){return Te.create(new Array(t.length+1).fill(""),t)}}),Mo=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->"],th=["+","-","*","/","%","^","&","|","#","<<",">>"],Po=[...Mo,...th,"&&","||"],rh=["not","-",...["exists","not exists"]],nh=[...Po,...rh],_s=a({is(t){return t.kind==="OperatorNode"},create(t){return a({kind:"OperatorNode",operator:t})}});function _o(t){return _(t)&&Po.includes(t)}function Fo(t){return _(t)&&Mo.includes(t)}const kr=a({is(t){return t.kind==="ParensNode"},create(t){return a({kind:"ParensNode",node:t})}}),he=a({is(t){return t.kind==="ColumnNode"},create(t){return a({kind:"ColumnNode",column:ue.create(t)})}}),Fs=a({is(t){return t.kind==="SelectAllNode"},create(){return a({kind:"SelectAllNode"})}}),mi=a({is(t){return t.kind==="ReferenceNode"},create(t,e){return a({kind:"ReferenceNode",table:t,column:e})},createSelectAll(t){return a({kind:"ReferenceNode",table:t,column:Fs.create()})}}),ih=a({is(t){return t.kind==="OrderByItemNode"},create(t,e){return a({kind:"OrderByItemNode",orderBy:t,direction:e})}});function sh(t){return t==="asc"||t==="desc"}function yi(t,e){return ih.create(oh(t),ah(e))}function oh(t){return Et(t)}function ah(t){if(t)return t==="asc"||t==="desc"?Te.createWithSql(t):t.toOperationNode()}function Qo(t){return _(t)?Ir(t):t.toOperationNode()}function Nn(t){return fn(t)?t.map(e=>Et(e)):[Et(t)]}function Et(t){return Di(t)?Si(t):Qo(t)}function Ir(t){const e=".";if(t.includes(e)){const r=t.split(e).map(Qs);if(r.length===3)return hh(r);if(r.length===2)return ch(r);throw new Error(`invalid column reference ${t}`)}else return he.create(t)}function uh(t){const e=" as ";if(t.includes(e)){const[r,u]=t.split(e).map(Qs);return ir.create(Ir(r),ue.create(u))}else return Ir(t)}function Uo(t){return he.create(t)}function Vo(t){const e=" ";if(t.includes(e)){const[r,u]=t.split(e).map(Qs);if(!sh(u))throw new Error(`invalid order direction "${u}" next to "${r}"`);return yi(r,u)}else return Uo(t)}function hh(t){const[e,r,u]=t;return mi.create(Ft.createWithSchema(e,r),he.create(u))}function ch(t){const[e,r]=t;return mi.create(Ft.create(e),he.create(r))}function Qs(t){return t.trim()}const jo=a({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return a({kind:"PrimitiveValueListNode",values:a([...t])})}}),Us=a({is(t){return t.kind==="ValueListNode"},create(t){return a({kind:"ValueListNode",values:a(t)})}}),vt=a({is(t){return t.kind==="ValueNode"},create(t){return a({kind:"ValueNode",value:t})},createImmediate(t){return a({kind:"ValueNode",value:t,immediate:!0})}});function $o(t){return fn(t)?lh(t):Tt(t)}function Tt(t){return Di(t)?Si(t):vt.create(t)}function lh(t){return t.some(Di)?Us.create(t.map(e=>Tt(e))):jo.create(t)}const Er=a({is(t){return t.kind==="OrderByNode"},create(t){return a({kind:"OrderByNode",items:a([t])})},cloneWithItem(t,e){return a({...t,items:a([...t.items,e])})}}),Jo=a({is(t){return t.kind==="PartitionByNode"},create(t){return a({kind:"PartitionByNode",items:a(t)})},cloneWithItems(t,e){return a({...t,items:a([...t.items,...e])})}}),Vs=a({is(t){return t.kind==="OverNode"},create(){return a({kind:"OverNode"})},cloneWithOrderByItem(t,e){return a({...t,orderBy:t.orderBy?Er.cloneWithItem(t.orderBy,e):Er.create(e)})},cloneWithPartitionByItems(t,e){return a({...t,partitionBy:t.partitionBy?Jo.cloneWithItems(t.partitionBy,e):Jo.create(e)})}}),Ni=a({is(t){return t.kind==="FromNode"},create(t){return a({kind:"FromNode",froms:a(t)})},cloneWithFroms(t,e){return a({...t,froms:a([...t.froms,...e])})}}),Go=a({is(t){return t.kind==="GroupByNode"},create(t){return a({kind:"GroupByNode",items:a(t)})},cloneWithItems(t,e){return a({...t,items:a([...t.items,...e])})}}),wi=a({is(t){return t.kind==="HavingNode"},create(t){return a({kind:"HavingNode",having:t})},cloneWithOperation(t,e,r){return a({...t,having:e==="And"?pn.create(t.having,r):mn.create(t.having,r)})}}),D=a({is(t){return t.kind==="SelectQueryNode"},create(t,e){return a({kind:"SelectQueryNode",from:Ni.create(t),...e&&{with:e}})},cloneWithSelections(t,e){return a({...t,selections:t.selections?a([...t.selections,...e]):a(e)})},cloneWithDistinctOn(t,e){return a({...t,distinctOn:t.distinctOn?a([...t.distinctOn,...e]):a(e)})},cloneWithFrontModifier(t,e){return a({...t,frontModifiers:t.frontModifiers?a([...t.frontModifiers,e]):a([e])})},cloneWithEndModifier(t,e){return a({...t,endModifiers:t.endModifiers?a([...t.endModifiers,e]):a([e])})},cloneWithOrderByItem(t,e){return a({...t,orderBy:t.orderBy?Er.cloneWithItem(t.orderBy,e):Er.create(e)})},cloneWithGroupByItems(t,e){return a({...t,groupBy:t.groupBy?Go.cloneWithItems(t.groupBy,e):Go.create(e)})},cloneWithLimit(t,e){return a({...t,limit:e})},cloneWithOffset(t,e){return a({...t,offset:e})},cloneWithHaving(t,e){return a({...t,having:t.having?wi.cloneWithOperation(t.having,"And",e):wi.create(e)})},cloneWithOrHaving(t,e){return a({...t,having:t.having?wi.cloneWithOperation(t.having,"Or",e):wi.create(e)})},cloneWithSetOperation(t,e){return a({...t,setOperations:t.setOperations?a([...t.setOperations,e]):a([e])})},cloneWithoutSelections(t){return a({...t,selections:[]})},cloneWithoutLimit(t){return a({...t,limit:void 0})},cloneWithoutOffset(t){return a({...t,offset:void 0})},cloneWithoutOrderBy(t){return a({...t,orderBy:void 0})}}),Ko=a({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return a({kind:"UnaryOperationNode",operator:t,operand:e})}});function Ae(t){return js("exists",t)}function Oe(t){return js("not exists",t)}function js(t,e){return Ko.create(_s.create(t),Et(e))}function Q(t,e){Object.defineProperties(t.prototype,{then:{enumerable:!1,value:()=>{throw new Error(e)}}})}const ct=class{constructor(e){w(this,se,void 0);g(this,se,a(e))}on(...e){return new ct({...n(this,se),joinNode:et.cloneWithOn(n(this,se).joinNode,fa(e))})}orOn(...e){return new ct({...n(this,se),joinNode:et.cloneWithOrOn(n(this,se).joinNode,fa(e))})}onRef(e,r,u){return new ct({...n(this,se),joinNode:et.cloneWithOn(n(this,se).joinNode,qe(e,r,u))})}orOnRef(e,r,u){return new ct({...n(this,se),joinNode:et.cloneWithOrOn(n(this,se).joinNode,qe(e,r,u))})}onExists(e){return new ct({...n(this,se),joinNode:et.cloneWithOn(n(this,se).joinNode,Ae(e))})}onNotExists(e){return new ct({...n(this,se),joinNode:et.cloneWithOn(n(this,se).joinNode,Oe(e))})}orOnExists(e){return new ct({...n(this,se),joinNode:et.cloneWithOrOn(n(this,se).joinNode,Ae(e))})}orOnNotExists(e){return new ct({...n(this,se),joinNode:et.cloneWithOrOn(n(this,se).joinNode,Oe(e))})}onTrue(){return new ct({...n(this,se),joinNode:et.cloneWithOn(n(this,se).joinNode,Te.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return n(this,se).joinNode}};let vi=ct;se=new WeakMap,Q(vi,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const dh=a({is(t){return t.kind==="PartitionByItemNode"},create(t){return a({kind:"PartitionByItemNode",partitionBy:t})}});function fh(t){return Nn(t).map(dh.create)}const ts=class{constructor(e){w(this,or,void 0);g(this,or,a(e))}orderBy(e,r){return new ts({overNode:Vs.cloneWithOrderByItem(n(this,or).overNode,yi(e,r))})}partitionBy(e){return new ts({overNode:Vs.cloneWithPartitionByItems(n(this,or).overNode,fh(e))})}$call(e){return e(this)}toOperationNode(){return n(this,or).overNode}};let gi=ts;or=new WeakMap,Q(gi,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");const wn=a({is(t){return t.kind==="SelectionNode"},create(t){return a({kind:"SelectionNode",selection:t})},createSelectAll(){return a({kind:"SelectionNode",selection:Fs.create()})},createSelectAllFromTable(t){return a({kind:"SelectionNode",selection:mi.createSelectAll(t)})}});class ph{constructor(e){w(this,Mr,void 0);g(this,Mr,e)}get dynamicReference(){return n(this,Mr)}get refType(){}toOperationNode(){return Qo(n(this,Mr))}}Mr=new WeakMap;function mh(t){return wt(t)&&Le(t)&&_(t.dynamicReference)}function vn(t){return Ze(t)?vn(t(At())):fn(t)?t.map(e=>zo(e)):[zo(t)]}function zo(t){return _(t)?wn.create(uh(t)):mh(t)?wn.create(t.toOperationNode()):wn.create(ba(t))}function gn(t){return t?Array.isArray(t)?t.map(Ho):[Ho(t)]:[wn.createSelectAll()]}function Ho(t){if(_(t))return wn.createSelectAllFromTable(Ue(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const yh=a({is(t){return t.kind==="ValuesNode"},create(t){return a({kind:"ValuesNode",values:a(t)})}}),Nh=a({is(t){return t.kind==="DefaultInsertValueNode"},create(){return a({kind:"DefaultInsertValueNode"})}});function wh(t){const e=Ze(t)?t(At()):t,r=fn(e)?e:a([e]);return vh(r)}function vh(t){const e=gh(t);return[a([...e.keys()].map(he.create)),yh.create(t.map(r=>bh(r,e)))]}function gh(t){const e=new Map;for(const r of t){const u=Object.keys(r);for(const d of u)!e.has(d)&&r[d]!==void 0&&e.set(d,e.size)}return e}function bh(t,e){const r=Object.keys(t),u=Array.from({length:e.size});let d=!1;for(const k of r){const I=e.get(k);if(J(I))continue;const j=t[k];(J(j)||Di(j))&&(d=!0),u[I]=j}if(r.lengthJ(I)?k:Tt(I)))}return jo.create(u)}const gt=a({is(t){return t.kind==="InsertQueryNode"},create(t,e,r){return a({kind:"InsertQueryNode",into:t,...e&&{with:e},replace:r})},cloneWith(t,e){return a({...t,...e})}}),bi=a({is(t){return t.kind==="UpdateQueryNode"},create(t,e){return a({kind:"UpdateQueryNode",table:t,...e&&{with:e}})},cloneWithFromItems(t,e){return a({...t,from:t.from?Ni.cloneWithFroms(t.from,e):Ni.create(e)})},cloneWithUpdates(t,e){return a({...t,updates:t.updates?a([...t.updates,...e]):e})}}),Yo=a({is(t){return t.kind==="UsingNode"},create(t){return a({kind:"UsingNode",tables:a(t)})},cloneWithTables(t,e){return a({...t,tables:a([...t.tables,...e])})}}),bn=a({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return a({kind:"DeleteQueryNode",from:Ni.create(t),...e&&{with:e}})},cloneWithOrderByItem(t,e){return a({...t,orderBy:t.orderBy?Er.cloneWithItem(t.orderBy,e):Er.create(e)})},cloneWithLimit(t,e){return a({...t,limit:e})},cloneWithUsing(t,e){return a({...t,using:t.using!==void 0?Yo.cloneWithTables(t.using,e):Yo.create(e)})}}),Se=a({is(t){return t.kind==="WhereNode"},create(t){return a({kind:"WhereNode",where:t})},cloneWithOperation(t,e,r){return a({...t,where:e==="And"?pn.create(t.where,r):mn.create(t.where,r)})}}),Xo=a({is(t){return t.kind==="ReturningNode"},create(t){return a({kind:"ReturningNode",selections:a(t)})},cloneWithSelections(t,e){return a({...t,selections:t.selections?a([...t.selections,...e]):a(e)})}}),xh=a({is(t){return t.kind==="ExplainNode"},create(t,e){return a({kind:"ExplainNode",format:t,options:e})}}),C=a({is(t){return D.is(t)||gt.is(t)||bi.is(t)||bn.is(t)},cloneWithWhere(t,e){return a({...t,where:t.where?Se.cloneWithOperation(t.where,"And",e):Se.create(e)})},cloneWithOrWhere(t,e){return a({...t,where:t.where?Se.cloneWithOperation(t.where,"Or",e):Se.create(e)})},cloneWithJoin(t,e){return a({...t,joins:t.joins?a([...t.joins,e]):a([e])})},cloneWithReturning(t,e){return a({...t,returning:t.returning?Xo.cloneWithSelections(t.returning,e):Xo.create(e)})},cloneWithoutWhere(t){return a({...t,where:void 0})},cloneWithExplain(t,e,r){return a({...t,explain:xh.create(e,r==null?void 0:r.toOperationNode())})}}),Wh=a({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return a({kind:"ColumnUpdateNode",column:t,value:e})}});function $s(t){const e=Ze(t)?t(At()):t;return Object.entries(e).filter(([r,u])=>u!==void 0).map(([r,u])=>Wh.create(he.create(r),Tt(u)))}const Oh=a({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return a({kind:"OnDuplicateKeyNode",updates:t})}});class Zo{constructor(e,r){w(this,Tn,void 0);w(this,An,void 0);g(this,Tn,e),g(this,An,r)}get insertId(){return n(this,Tn)}get numInsertedOrUpdatedRows(){return n(this,An)}}Tn=new WeakMap,An=new WeakMap;for(const t of["insertId","numInsertedOrUpdatedRows"])Object.defineProperty(Zo.prototype,t,{enumerable:!0});class xi extends Error{constructor(r){super("no result");Xe(this,"node");this.node=r}}function Wi(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const te=a({is(t){return t.kind==="OnConflictNode"},create(){return a({kind:"OnConflictNode"})},cloneWith(t,e){return a({...t,...e})},cloneWithIndexWhere(t,e){return a({...t,indexWhere:t.indexWhere?Se.cloneWithOperation(t.indexWhere,"And",e):Se.create(e)})},cloneWithIndexOrWhere(t,e){return a({...t,indexWhere:t.indexWhere?Se.cloneWithOperation(t.indexWhere,"Or",e):Se.create(e)})},cloneWithUpdateWhere(t,e){return a({...t,updateWhere:t.updateWhere?Se.cloneWithOperation(t.updateWhere,"And",e):Se.create(e)})},cloneWithUpdateOrWhere(t,e){return a({...t,updateWhere:t.updateWhere?Se.cloneWithOperation(t.updateWhere,"Or",e):Se.create(e)})},cloneWithoutIndexWhere(t){return a({...t,indexWhere:void 0})},cloneWithoutUpdateWhere(t){return a({...t,updateWhere:void 0})}}),Be=class{constructor(e){w(this,B,void 0);g(this,B,a(e))}column(e){const r=he.create(e);return new Be({...n(this,B),onConflictNode:te.cloneWith(n(this,B).onConflictNode,{columns:n(this,B).onConflictNode.columns?a([...n(this,B).onConflictNode.columns,r]):a([r])})})}columns(e){const r=e.map(he.create);return new Be({...n(this,B),onConflictNode:te.cloneWith(n(this,B).onConflictNode,{columns:n(this,B).onConflictNode.columns?a([...n(this,B).onConflictNode.columns,...r]):a(r)})})}constraint(e){return new Be({...n(this,B),onConflictNode:te.cloneWith(n(this,B).onConflictNode,{constraint:ue.create(e)})})}expression(e){return new Be({...n(this,B),onConflictNode:te.cloneWith(n(this,B).onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexWhere(n(this,B).onConflictNode,$e(e))})}whereRef(e,r,u){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexWhere(n(this,B).onConflictNode,qe(e,r,u))})}orWhere(...e){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexOrWhere(n(this,B).onConflictNode,$e(e))})}orWhereRef(e,r,u){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexOrWhere(n(this,B).onConflictNode,qe(e,r,u))})}whereExists(e){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexWhere(n(this,B).onConflictNode,Ae(e))})}whereNotExists(e){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexWhere(n(this,B).onConflictNode,Oe(e))})}orWhereExists(e){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexOrWhere(n(this,B).onConflictNode,Ae(e))})}orWhereNotExists(e){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexOrWhere(n(this,B).onConflictNode,Oe(e))})}clearWhere(){return new Be({...n(this,B),onConflictNode:te.cloneWithoutIndexWhere(n(this,B).onConflictNode)})}doNothing(){return new ea({...n(this,B),onConflictNode:te.cloneWith(n(this,B).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new qi({...n(this,B),onConflictNode:te.cloneWith(n(this,B).onConflictNode,{updates:$s(e)})})}$call(e){return e(this)}};let Oi=Be;B=new WeakMap,Q(Oi,"don't await OnConflictBuilder instances.");class ea{constructor(e){w(this,Sn,void 0);g(this,Sn,a(e))}toOperationNode(){return n(this,Sn).onConflictNode}}Sn=new WeakMap,Q(ea,"don't await OnConflictDoNothingBuilder instances.");const lt=class{constructor(e){w(this,oe,void 0);g(this,oe,a(e))}where(...e){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateWhere(n(this,oe).onConflictNode,$e(e))})}whereRef(e,r,u){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateWhere(n(this,oe).onConflictNode,qe(e,r,u))})}orWhere(...e){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateOrWhere(n(this,oe).onConflictNode,$e(e))})}orWhereRef(e,r,u){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateOrWhere(n(this,oe).onConflictNode,qe(e,r,u))})}whereExists(e){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateWhere(n(this,oe).onConflictNode,Ae(e))})}whereNotExists(e){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateWhere(n(this,oe).onConflictNode,Oe(e))})}orWhereExists(e){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateOrWhere(n(this,oe).onConflictNode,Ae(e))})}orWhereNotExists(e){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateOrWhere(n(this,oe).onConflictNode,Oe(e))})}clearWhere(){return new lt({...n(this,oe),onConflictNode:te.cloneWithoutUpdateWhere(n(this,oe).onConflictNode)})}$call(e){return e(this)}toOperationNode(){return n(this,oe).onConflictNode}};let qi=lt;oe=new WeakMap,Q(qi,"don't await OnConflictUpdateBuilder instances.");const ge=class{constructor(e){w(this,L,void 0);g(this,L,a(e))}values(e){const[r,u]=wh(e);return new ge({...n(this,L),queryNode:gt.cloneWith(n(this,L).queryNode,{columns:r,values:u})})}columns(e){return new ge({...n(this,L),queryNode:gt.cloneWith(n(this,L).queryNode,{columns:a(e.map(he.create))})})}expression(e){return new ge({...n(this,L),queryNode:gt.cloneWith(n(this,L).queryNode,{values:Si(e)})})}ignore(){return new ge({...n(this,L),queryNode:gt.cloneWith(n(this,L).queryNode,{ignore:!0})})}onConflict(e){return new ge({...n(this,L),queryNode:gt.cloneWith(n(this,L).queryNode,{onConflict:e(new Oi({onConflictNode:te.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new ge({...n(this,L),queryNode:gt.cloneWith(n(this,L).queryNode,{onDuplicateKey:Oh.create($s(e))})})}returning(e){return new ge({...n(this,L),queryNode:C.cloneWithReturning(n(this,L).queryNode,vn(e))})}returningAll(){return new ge({...n(this,L),queryNode:C.cloneWithReturning(n(this,L).queryNode,gn())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new ge({...n(this,L)})}if(e,r){return e?r(this):new ge({...n(this,L)})}$castTo(){return new ge(n(this,L))}castTo(){return this.$castTo()}$narrowType(){return new ge(n(this,L))}$assertType(){return new ge(n(this,L))}assertType(){return new ge(n(this,L))}withPlugin(e){return new ge({...n(this,L),executor:n(this,L).executor.withPlugin(e)})}toOperationNode(){return n(this,L).executor.transformQuery(n(this,L).queryNode,n(this,L).queryId)}compile(){return n(this,L).executor.compileQuery(this.toOperationNode(),n(this,L).queryId)}async execute(){const e=this.compile(),r=e.query,u=await n(this,L).executor.executeQuery(e,n(this,L).queryId);return n(this,L).executor.adapter.supportsReturning&&r.returning?u.rows:[new Zo(u.insertId,u.numAffectedRows??u.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=xi){const r=await this.executeTakeFirst();if(r===void 0)throw Wi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=n(this,L).executor.stream(r,e,n(this,L).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new ge({...n(this,L),queryNode:C.cloneWithExplain(n(this,L).queryNode,e,r)}).execute()}};let xn=ge;L=new WeakMap,Q(xn,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class ta{constructor(e){w(this,Dn,void 0);g(this,Dn,e)}get numDeletedRows(){return n(this,Dn)}}Dn=new WeakMap,Object.defineProperty(ta.prototype,"numDeletedRows",{enumerable:!0});const ra=a({is(t){return t.kind==="LimitNode"},create(t){return a({kind:"LimitNode",limit:vt.create(t)})}}),K=class{constructor(e){w(this,x,void 0);g(this,x,a(e))}where(...e){return new K({...n(this,x),queryNode:C.cloneWithWhere(n(this,x).queryNode,$e(e))})}whereRef(e,r,u){return new K({...n(this,x),queryNode:C.cloneWithWhere(n(this,x).queryNode,qe(e,r,u))})}orWhere(...e){return new K({...n(this,x),queryNode:C.cloneWithOrWhere(n(this,x).queryNode,$e(e))})}orWhereRef(e,r,u){return new K({...n(this,x),queryNode:C.cloneWithOrWhere(n(this,x).queryNode,qe(e,r,u))})}whereExists(e){return new K({...n(this,x),queryNode:C.cloneWithWhere(n(this,x).queryNode,Ae(e))})}whereNotExists(e){return new K({...n(this,x),queryNode:C.cloneWithWhere(n(this,x).queryNode,Oe(e))})}orWhereExists(e){return new K({...n(this,x),queryNode:C.cloneWithOrWhere(n(this,x).queryNode,Ae(e))})}orWhereNotExists(e){return new K({...n(this,x),queryNode:C.cloneWithOrWhere(n(this,x).queryNode,Oe(e))})}clearWhere(){return new K({...n(this,x),queryNode:C.cloneWithoutWhere(n(this,x).queryNode)})}using(e){return new K({...n(this,x),queryNode:bn.cloneWithUsing(n(this,x).queryNode,Dr(e))})}innerJoin(...e){return new K({...n(this,x),queryNode:C.cloneWithJoin(n(this,x).queryNode,Qe("InnerJoin",e))})}leftJoin(...e){return new K({...n(this,x),queryNode:C.cloneWithJoin(n(this,x).queryNode,Qe("LeftJoin",e))})}rightJoin(...e){return new K({...n(this,x),queryNode:C.cloneWithJoin(n(this,x).queryNode,Qe("RightJoin",e))})}fullJoin(...e){return new K({...n(this,x),queryNode:C.cloneWithJoin(n(this,x).queryNode,Qe("FullJoin",e))})}returning(e){return new K({...n(this,x),queryNode:C.cloneWithReturning(n(this,x).queryNode,vn(e))})}returningAll(e){return new K({...n(this,x),queryNode:C.cloneWithReturning(n(this,x).queryNode,gn(e))})}orderBy(e,r){return new K({...n(this,x),queryNode:bn.cloneWithOrderByItem(n(this,x).queryNode,yi(e,r))})}limit(e){return new K({...n(this,x),queryNode:bn.cloneWithLimit(n(this,x).queryNode,ra.create(e))})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new K({...n(this,x)})}if(e,r){return this.$if(e,r)}$castTo(){return new K(n(this,x))}castTo(){return this.$castTo()}$narrowType(){return new K(n(this,x))}$assertType(){return new K(n(this,x))}assertType(){return new K(n(this,x))}withPlugin(e){return new K({...n(this,x),executor:n(this,x).executor.withPlugin(e)})}toOperationNode(){return n(this,x).executor.transformQuery(n(this,x).queryNode,n(this,x).queryId)}compile(){return n(this,x).executor.compileQuery(this.toOperationNode(),n(this,x).queryId)}async execute(){const e=this.compile(),r=e.query,u=await n(this,x).executor.executeQuery(e,n(this,x).queryId);return n(this,x).executor.adapter.supportsReturning&&r.returning?u.rows:[new ta(u.numAffectedRows??u.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=xi){const r=await this.executeTakeFirst();if(r===void 0)throw Wi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=n(this,x).executor.stream(r,e,n(this,x).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new K({...n(this,x),queryNode:C.cloneWithExplain(n(this,x).queryNode,e,r)}).execute()}};let Ci=K;x=new WeakMap,Q(Ci,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class na{constructor(e){w(this,Rn,void 0);g(this,Rn,e)}get numUpdatedRows(){return n(this,Rn)}}Rn=new WeakMap,Object.defineProperty(na.prototype,"numUpdatedRows",{enumerable:!0});const Z=class{constructor(e){w(this,q,void 0);g(this,q,a(e))}where(...e){return new Z({...n(this,q),queryNode:C.cloneWithWhere(n(this,q).queryNode,$e(e))})}whereRef(e,r,u){return new Z({...n(this,q),queryNode:C.cloneWithWhere(n(this,q).queryNode,qe(e,r,u))})}orWhere(...e){return new Z({...n(this,q),queryNode:C.cloneWithOrWhere(n(this,q).queryNode,$e(e))})}orWhereRef(e,r,u){return new Z({...n(this,q),queryNode:C.cloneWithOrWhere(n(this,q).queryNode,qe(e,r,u))})}whereExists(e){return new Z({...n(this,q),queryNode:C.cloneWithWhere(n(this,q).queryNode,Ae(e))})}whereNotExists(e){return new Z({...n(this,q),queryNode:C.cloneWithWhere(n(this,q).queryNode,Oe(e))})}orWhereExists(e){return new Z({...n(this,q),queryNode:C.cloneWithOrWhere(n(this,q).queryNode,Ae(e))})}orWhereNotExists(e){return new Z({...n(this,q),queryNode:C.cloneWithOrWhere(n(this,q).queryNode,Oe(e))})}clearWhere(){return new Z({...n(this,q),queryNode:C.cloneWithoutWhere(n(this,q).queryNode)})}from(e){return new Z({...n(this,q),queryNode:bi.cloneWithFromItems(n(this,q).queryNode,Dr(e))})}innerJoin(...e){return new Z({...n(this,q),queryNode:C.cloneWithJoin(n(this,q).queryNode,Qe("InnerJoin",e))})}leftJoin(...e){return new Z({...n(this,q),queryNode:C.cloneWithJoin(n(this,q).queryNode,Qe("LeftJoin",e))})}rightJoin(...e){return new Z({...n(this,q),queryNode:C.cloneWithJoin(n(this,q).queryNode,Qe("RightJoin",e))})}fullJoin(...e){return new Z({...n(this,q),queryNode:C.cloneWithJoin(n(this,q).queryNode,Qe("FullJoin",e))})}set(e){return new Z({...n(this,q),queryNode:bi.cloneWithUpdates(n(this,q).queryNode,$s(e))})}returning(e){return new Z({...n(this,q),queryNode:C.cloneWithReturning(n(this,q).queryNode,vn(e))})}returningAll(){return new Z({...n(this,q),queryNode:C.cloneWithReturning(n(this,q).queryNode,gn())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new Z({...n(this,q)})}if(e,r){return this.$if(e,r)}$castTo(){return new Z(n(this,q))}castTo(){return this.$castTo()}$narrowType(){return new Z(n(this,q))}$assertType(){return new Z(n(this,q))}assertType(){return new Z(n(this,q))}withPlugin(e){return new Z({...n(this,q),executor:n(this,q).executor.withPlugin(e)})}toOperationNode(){return n(this,q).executor.transformQuery(n(this,q).queryNode,n(this,q).queryId)}compile(){return n(this,q).executor.compileQuery(this.toOperationNode(),n(this,q).queryId)}async execute(){const e=this.compile(),r=e.query,u=await n(this,q).executor.executeQuery(e,n(this,q).queryId);return n(this,q).executor.adapter.supportsReturning&&r.returning?u.rows:[new na(u.numAffectedRows??u.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=xi){const r=await this.executeTakeFirst();if(r===void 0)throw Wi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=n(this,q).executor.stream(r,e,n(this,q).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new Z({...n(this,q),queryNode:C.cloneWithExplain(n(this,q).queryNode,e,r)}).execute()}};let ki=Z;q=new WeakMap,Q(ki,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");const qh=a({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return a({kind:"CommonTableExpressionNode",name:t,expression:e})}}),ia=a({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return a({kind:"CommonTableExpressionNameNode",table:Ft.create(t),columns:e?a(e.map(he.create)):void 0})}});function sa(t,e){const r=e(Lh());return qh.create(Ch(t),r.toOperationNode())}function Ch(t){if(t.includes("(")){const e=t.split(/[\(\)]/),r=e[0],u=e[1].split(",").map(d=>d.trim());return ia.create(r,u)}else return ia.create(t)}const Ii=a({is(t){return t.kind==="WithNode"},create(t,e){return a({kind:"WithNode",expressions:a([t]),...e})},cloneWithExpression(t,e){return a({...t,expressions:a([...t.expressions,e])})}}),oa=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function kh(t){let e="";for(let r=0;rthis.transformNode(r)))}transformSelectQuery(e){return{kind:"SelectQueryNode",from:this.transformNode(e.from),selections:this.transformNodeList(e.selections),distinctOn:this.transformNodeList(e.distinctOn),joins:this.transformNodeList(e.joins),groupBy:this.transformNode(e.groupBy),orderBy:this.transformNode(e.orderBy),where:this.transformNode(e.where),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),limit:this.transformNode(e.limit),offset:this.transformNode(e.offset),with:this.transformNode(e.with),having:this.transformNode(e.having),explain:this.transformNode(e.explain),setOperations:this.transformNodeList(e.setOperations)}}transformSelection(e){return{kind:"SelectionNode",selection:this.transformNode(e.selection)}}transformColumn(e){return{kind:"ColumnNode",column:this.transformNode(e.column)}}transformAlias(e){return{kind:"AliasNode",node:this.transformNode(e.node),alias:this.transformNode(e.alias)}}transformTable(e){return{kind:"TableNode",table:this.transformNode(e.table)}}transformFrom(e){return{kind:"FromNode",froms:this.transformNodeList(e.froms)}}transformReference(e){return{kind:"ReferenceNode",table:this.transformNode(e.table),column:this.transformNode(e.column)}}transformAnd(e){return{kind:"AndNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformOr(e){return{kind:"OrNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformValueList(e){return{kind:"ValueListNode",values:this.transformNodeList(e.values)}}transformParens(e){return{kind:"ParensNode",node:this.transformNode(e.node)}}transformJoin(e){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table),on:this.transformNode(e.on)}}transformRaw(e){return{kind:"RawNode",sqlFragments:a([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters)}}transformWhere(e){return{kind:"WhereNode",where:this.transformNode(e.where)}}transformInsertQuery(e){return{kind:"InsertQueryNode",into:this.transformNode(e.into),columns:this.transformNodeList(e.columns),values:this.transformNode(e.values),returning:this.transformNode(e.returning),onConflict:this.transformNode(e.onConflict),onDuplicateKey:this.transformNode(e.onDuplicateKey),with:this.transformNode(e.with),ignore:e.ignore,replace:e.replace,explain:this.transformNode(e.explain)}}transformValues(e){return{kind:"ValuesNode",values:this.transformNodeList(e.values)}}transformDeleteQuery(e){return{kind:"DeleteQueryNode",from:this.transformNode(e.from),using:this.transformNode(e.using),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),returning:this.transformNode(e.returning),with:this.transformNode(e.with),orderBy:this.transformNode(e.orderBy),limit:this.transformNode(e.limit),explain:this.transformNode(e.explain)}}transformReturning(e){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections)}}transformCreateTable(e){return{kind:"CreateTableNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),constraints:this.transformNodeList(e.constraints),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers)}}transformColumnDefinition(e){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),references:this.transformNode(e.references),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo),check:this.transformNode(e.check),generated:this.transformNode(e.generated),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers)}}transformAddColumn(e){return{kind:"AddColumnNode",column:this.transformNode(e.column)}}transformDropTable(e){return{kind:"DropTableNode",table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e){return{kind:"OrderByNode",items:this.transformNodeList(e.items)}}transformOrderByItem(e){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy),direction:this.transformNode(e.direction)}}transformGroupBy(e){return{kind:"GroupByNode",items:this.transformNodeList(e.items)}}transformGroupByItem(e){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy)}}transformUpdateQuery(e){return{kind:"UpdateQueryNode",table:this.transformNode(e.table),from:this.transformNode(e.from),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),updates:this.transformNodeList(e.updates),returning:this.transformNode(e.returning),with:this.transformNode(e.with),explain:this.transformNode(e.explain)}}transformColumnUpdate(e){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column),value:this.transformNode(e.value)}}transformLimit(e){return{kind:"LimitNode",limit:this.transformNode(e.limit)}}transformOffset(e){return{kind:"OffsetNode",offset:this.transformNode(e.offset)}}transformOnConflict(e){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns),constraint:this.transformNode(e.constraint),indexExpression:this.transformNode(e.indexExpression),indexWhere:this.transformNode(e.indexWhere),updates:this.transformNodeList(e.updates),updateWhere:this.transformNode(e.updateWhere),doNothing:e.doNothing}}transformOnDuplicateKey(e){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates)}}transformCreateIndex(e){return{kind:"CreateIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists,where:this.transformNode(e.where)}}transformList(e){return{kind:"ListNode",items:this.transformNodeList(e.items)}}transformDropIndex(e){return{kind:"DropIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformUniqueConstraint(e){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformForeignKeyConstraint(e){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns),references:this.transformNode(e.references),name:this.transformNode(e.name),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformSetOperation(e){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression),all:e.all}}transformReferences(e){return{kind:"ReferencesNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression),name:this.transformNode(e.name)}}transformWith(e){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions),recursive:e.recursive}}transformCommonTableExpression(e){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name),expression:this.transformNode(e.expression)}}transformCommonTableExpressionName(e){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns)}}transformHaving(e){return{kind:"HavingNode",having:this.transformNode(e.having)}}transformCreateSchema(e){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema),ifNotExists:e.ifNotExists}}transformDropSchema(e){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e){return{kind:"AlterTableNode",table:this.transformNode(e.table),renameTo:this.transformNode(e.renameTo),setSchema:this.transformNode(e.setSchema),columnAlterations:this.transformNodeList(e.columnAlterations),addConstraint:this.transformNode(e.addConstraint),dropConstraint:this.transformNode(e.dropConstraint)}}transformDropColumn(e){return{kind:"DropColumnNode",column:this.transformNode(e.column)}}transformRenameColumn(e){return{kind:"RenameColumnNode",column:this.transformNode(e.column),renameTo:this.transformNode(e.renameTo)}}transformAlterColumn(e){return{kind:"AlterColumnNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),dataTypeExpression:this.transformNode(e.dataTypeExpression),setDefault:this.transformNode(e.setDefault),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e){return{kind:"ModifyColumnNode",column:this.transformNode(e.column)}}transformAddConstraint(e){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint)}}transformDropConstraint(e){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName),ifExists:e.ifExists,modifier:e.modifier}}transformCreateView(e){return{kind:"CreateViewNode",name:this.transformNode(e.name),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns),as:this.transformNode(e.as)}}transformDropView(e){return{kind:"DropViewNode",name:this.transformNode(e.name),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression)}}transformDefaultValue(e){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue)}}transformOn(e){return{kind:"OnNode",on:this.transformNode(e.on)}}transformSelectModifier(e){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier)}}transformCreateType(e){return{kind:"CreateTypeNode",name:this.transformNode(e.name),enum:this.transformNode(e.enum)}}transformDropType(e){return{kind:"DropTypeNode",name:this.transformNode(e.name),ifExists:e.ifExists}}transformExplain(e){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options)}}transformSchemableIdentifier(e){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema),identifier:this.transformNode(e.identifier)}}transformAggregateFunction(e){return{kind:"AggregateFunctionNode",aggregated:this.transformNodeList(e.aggregated),distinct:e.distinct,filter:this.transformNode(e.filter),func:e.func,over:this.transformNode(e.over)}}transformOver(e){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy),partitionBy:this.transformNode(e.partitionBy)}}transformPartitionBy(e){return{kind:"PartitionByNode",items:this.transformNodeList(e.items)}}transformPartitionByItem(e){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy)}}transformBinaryOperation(e){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand),operator:this.transformNode(e.operator),rightOperand:this.transformNode(e.rightOperand)}}transformUnaryOperation(e){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator),operand:this.transformNode(e.operand)}}transformUsing(e){return{kind:"UsingNode",tables:this.transformNodeList(e.tables)}}transformFunction(e){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments)}}transformCase(e){return{kind:"CaseNode",value:this.transformNode(e.value),when:this.transformNodeList(e.when),else:this.transformNode(e.else),isStatement:e.isStatement}}transformWhen(e){return{kind:"WhenNode",condition:this.transformNode(e.condition),result:this.transformNode(e.result)}}transformDataType(e){return e}transformSelectAll(e){return e}transformIdentifier(e){return e}transformValue(e){return e}transformPrimitiveValueList(e){return e}transformOperator(e){return e}transformDefaultInsertValue(e){return e}}rs=new WeakMap;const Th=a({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0});class Ah extends Js{constructor(r){super();w(this,ns);w(this,is);w(this,ur);w(this,Ln);w(this,ss);w(this,_r,void 0);w(this,ar,new Set);g(this,_r,r)}transformNodeImpl(r){if(!X(this,ns,Qu).call(this,r))return super.transformNodeImpl(r);const u=X(this,is,Uu).call(this,r);for(const b of u)n(this,ar).add(b);const d=super.transformNodeImpl(r);for(const b of u)n(this,ar).delete(b);return d}transformSchemableIdentifier(r){const u=super.transformSchemableIdentifier(r);return u.schema||!n(this,ar).has(r.identifier.name)?u:{...u,schema:ue.create(n(this,_r))}}transformReferences(r){const u=super.transformReferences(r);return u.table.table.schema?u:{...u,table:Ft.createWithSchema(n(this,_r),u.table.table.identifier.name)}}}_r=new WeakMap,ar=new WeakMap,ns=new WeakSet,Qu=function(r){return r.kind in Th},is=new WeakSet,Uu=function(r){const u=new Set;if("name"in r&&r.name&&_t.is(r.name)&&X(this,Ln,To).call(this,r.name,u),"from"in r&&r.from)for(const d of r.from.froms)X(this,ur,di).call(this,d,u);if("into"in r&&r.into&&X(this,ur,di).call(this,r.into,u),"table"in r&&r.table&&X(this,ur,di).call(this,r.table,u),"joins"in r&&r.joins)for(const d of r.joins)X(this,ur,di).call(this,d.table,u);return"with"in r&&r.with&&X(this,ss,Vu).call(this,r.with,u),u},ur=new WeakSet,di=function(r,u){const d=Ft.is(r)?r:ir.is(r)&&Ft.is(r.node)?r.node:null;d&&X(this,Ln,To).call(this,d.table,u)},Ln=new WeakSet,To=function(r,u){n(this,ar).has(r.identifier.name)||u.add(r.identifier.name)},ss=new WeakSet,Vu=function(r,u){for(const d of r.expressions)u.delete(d.name.table.table.identifier.name)};class Wn{constructor(e){w(this,Bn,void 0);g(this,Bn,new Ah(e))}transformQuery(e){return n(this,Bn).transformNode(e.node)}async transformResult(e){return e.result}}Bn=new WeakMap;const hr=class{constructor(e){w(this,ee,void 0);g(this,ee,a(e))}selectFrom(e){return new Sr({queryId:G(),executor:n(this,ee).executor,queryNode:D.create(Dr(e),n(this,ee).withNode)})}insertInto(e){return new xn({queryId:G(),executor:n(this,ee).executor,queryNode:gt.create(Ue(e),n(this,ee).withNode)})}replaceInto(e){return new xn({queryId:G(),executor:n(this,ee).executor,queryNode:gt.create(Ue(e),n(this,ee).withNode,!0)})}deleteFrom(e){return new Ci({queryId:G(),executor:n(this,ee).executor,queryNode:bn.create(Dr(e),n(this,ee).withNode)})}updateTable(e){return new ki({queryId:G(),executor:n(this,ee).executor,queryNode:bi.create(qn(e),n(this,ee).withNode)})}with(e,r){const u=sa(e,r);return new hr({...n(this,ee),withNode:n(this,ee).withNode?Ii.cloneWithExpression(n(this,ee).withNode,u):Ii.create(u)})}withRecursive(e,r){const u=sa(e,r);return new hr({...n(this,ee),withNode:n(this,ee).withNode?Ii.cloneWithExpression(n(this,ee).withNode,u):Ii.create(u,{recursive:!0})})}withPlugin(e){return new hr({...n(this,ee),executor:n(this,ee).executor.withPlugin(e)})}withoutPlugins(){return new hr({...n(this,ee),executor:n(this,ee).executor.withoutPlugins()})}withSchema(e){return new hr({...n(this,ee),executor:n(this,ee).executor.withPluginAtFront(new Wn(e))})}};let Ei=hr;ee=new WeakMap;class aa{constructor(){w(this,Mn,void 0);w(this,Fr,void 0);w(this,Qr,void 0);Xe(this,"resolve",e=>{n(this,Fr)&&n(this,Fr).call(this,e)});Xe(this,"reject",e=>{n(this,Qr)&&n(this,Qr).call(this,e)});g(this,Mn,new Promise((e,r)=>{g(this,Qr,r),g(this,Fr,e)}))}get promise(){return n(this,Mn)}}Mn=new WeakMap,Fr=new WeakMap,Qr=new WeakMap;const ua=new Set;function Sh(t){ua.has(t)||(ua.add(t),console.log(t))}const Dh=a([]);class ha{constructor(e=Dh){w(this,Pn);w(this,cr,void 0);g(this,cr,e)}get plugins(){return n(this,cr)}transformQuery(e,r){for(const u of n(this,cr)){const d=u.transformQuery({node:e,queryId:r});if(d.kind===e.kind)e=d;else throw new Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${e.kind}`,`but it returned a ${d.kind}`].join(" "))}return e}async executeQuery(e,r){return await this.provideConnection(async u=>{const d=await u.executeQuery(e),b=await X(this,Pn,Ao).call(this,d,r);return Rh(d,b),b})}async*stream(e,r,u){const d=new aa,b=new aa;this.provideConnection(async I=>(d.resolve(I),await b.promise)).catch(I=>d.reject(I));const k=await d.promise;try{for await(const I of k.streamQuery(e,r))yield await X(this,Pn,Ao).call(this,I,u)}finally{b.resolve()}}}cr=new WeakMap,Pn=new WeakSet,Ao=async function(e,r){for(const u of n(this,cr))e=await u.transformResult({result:e,queryId:r});return e};function Rh(t,e){const{numAffectedRows:r}=t;r===void 0&&t.numUpdatedOrDeletedRows===void 0||r!==void 0&&e.numAffectedRows!==void 0||Sh("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class Tr extends ha{get adapter(){throw new Error("this query cannot be compiled to SQL")}compileQuery(){throw new Error("this query cannot be compiled to SQL")}provideConnection(){throw new Error("this query cannot be executed")}withConnectionProvider(){throw new Error("this query cannot have a connection provider")}withPlugin(e){return new Tr([...this.plugins,e])}withPlugins(e){return new Tr([...this.plugins,...e])}withPluginAtFront(e){return new Tr([e,...this.plugins])}withoutPlugins(){return new Tr([])}}const Ti=new Tr;function ca(){return new Sr({queryId:G(),executor:Ti,queryNode:D.create(Dr([]))})}function Lh(){return new Ei({executor:Ti})}function la(t,e){return new vi({joinNode:et.create(t,qn(e))})}function Bh(){return new gi({overNode:Vs.create()})}const Gs=a({is(t){return t.kind==="WhenNode"},create(t){return a({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return a({...t,result:e})}}),ut=a({is(t){return t.kind==="CaseNode"},create(t){return a({kind:"CaseNode",value:t})},cloneWithWhen(t,e){return a({...t,when:a(t.when?[...t.when,e]:[e])})},cloneWithThen(t,e){return a({...t,when:t.when?a([...t.when.slice(0,-1),Gs.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return a({...t,...e})}});function Ks(t,e,r){if(!_o(e)&&!Le(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return _h(e,r)?Fh(t,e,r):pi.create(Et(t),zs(e),$o(r))}function Mh(t,e,r){if(!_o(e)&&!Le(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return pi.create(Et(t),zs(e),Et(r))}function Ph(t,e,r){if(!Fo(e)&&!Le(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return Ks(t,e,r)}function qe(t,e,r){if(!Fo(e)&&!Le(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return Mh(t,e,r)}function $e(t){return Ai("where",t)}function da(t){return Ai("having",t)}function fa(t){return Ai("on",t)}function pa(t){return Ai("when",t)}function Ai(t,e){if(e.length===3)return Ph(e[0],e[1],e[2]);if(e.length===1)return Qh(t,e[0]);throw ma(t,e)}function _h(t,e){return(t==="is"||t==="is not")&&(Lo(e)||dn(e))}function Fh(t,e,r){return pi.create(Et(t),zs(e),vt.createImmediate(r))}function zs(t){if(_(t)&&nh.includes(t))return _s.create(t);if(Le(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function Qh(t,e){if(Ze(e)){if(t==="when")throw new Error("when method doesn't accept a callback as an argument");return Uh[t](e)}else if(Le(e)){const r=e.toOperationNode();if(Te.is(r)||pi.is(r)||Ko.is(r)||kr.is(r)||ut.is(r))return r}else if(t==="when")return vt.create(e);throw ma(t,e)}function ma(t,e){return new Error(`invalid arguments passed to a '${t}' method: ${JSON.stringify(e)}`)}const Uh=a({where(t){const e=ca(),r=At(),d=t(Object.assign(e,r)).toOperationNode();if(D.is(d)){if(!d.where)throw new Error("no `where` methods called inside a group callback");return kr.create(d.where.where)}else return d},having(t){const e=ca(),r=At(),d=t(Object.assign(e,r)).toOperationNode();if(D.is(d)){if(!d.having)throw new Error("no `having` methods called inside a group callback");return kr.create(d.having.having)}else return d},on(t){const e=la("InnerJoin","table"),r=At(),d=t(Object.assign(e,r)).toOperationNode();if(et.is(d)){if(!d.on)throw new Error("no `on` methods called inside a group callback");return kr.create(d.on.on)}else return d}});function Qe(t,e){if(e.length===3)return jh(t,e[0],e[1],e[2]);if(e.length===2)return Vh(t,e[0],e[1]);throw new Error("not implemented")}function Vh(t,e,r){return r(la(t,e)).toOperationNode()}function jh(t,e,r,u){return et.createWithOn(t,qn(e),qe(r,"=",u))}const $h=a({is(t){return t.kind==="OffsetNode"},create(t){return a({kind:"OffsetNode",offset:vt.create(t)})}}),Jh=a({is(t){return t.kind==="GroupByItemNode"},create(t){return a({kind:"GroupByItemNode",groupBy:t})}});function Gh(t){return t=Ze(t)?t(At()):t,Nn(t).map(Jh.create)}const ya=a({is(t){return t.kind==="SetOperationNode"},create(t,e,r){return a({kind:"SetOperationNode",operator:t,expression:e,all:r})}});function Ar(t,e,r){return ya.create(t,e.toOperationNode(),r)}const W=class{constructor(e){w(this,m,void 0);g(this,m,a(e))}get expressionType(){}where(...e){return new W({...n(this,m),queryNode:C.cloneWithWhere(n(this,m).queryNode,$e(e))})}whereRef(e,r,u){return new W({...n(this,m),queryNode:C.cloneWithWhere(n(this,m).queryNode,qe(e,r,u))})}orWhere(...e){return new W({...n(this,m),queryNode:C.cloneWithOrWhere(n(this,m).queryNode,$e(e))})}orWhereRef(e,r,u){return new W({...n(this,m),queryNode:C.cloneWithOrWhere(n(this,m).queryNode,qe(e,r,u))})}whereExists(e){return new W({...n(this,m),queryNode:C.cloneWithWhere(n(this,m).queryNode,Ae(e))})}whereNotExists(e){return new W({...n(this,m),queryNode:C.cloneWithWhere(n(this,m).queryNode,Oe(e))})}orWhereExists(e){return new W({...n(this,m),queryNode:C.cloneWithOrWhere(n(this,m).queryNode,Ae(e))})}orWhereNotExists(e){return new W({...n(this,m),queryNode:C.cloneWithOrWhere(n(this,m).queryNode,Oe(e))})}having(...e){return new W({...n(this,m),queryNode:D.cloneWithHaving(n(this,m).queryNode,da(e))})}havingRef(e,r,u){return new W({...n(this,m),queryNode:D.cloneWithHaving(n(this,m).queryNode,qe(e,r,u))})}orHaving(...e){return new W({...n(this,m),queryNode:D.cloneWithOrHaving(n(this,m).queryNode,da(e))})}orHavingRef(e,r,u){return new W({...n(this,m),queryNode:D.cloneWithOrHaving(n(this,m).queryNode,qe(e,r,u))})}havingExists(e){return new W({...n(this,m),queryNode:D.cloneWithHaving(n(this,m).queryNode,Ae(e))})}havingNotExist(e){return new W({...n(this,m),queryNode:D.cloneWithHaving(n(this,m).queryNode,Oe(e))})}havingNotExists(e){return new W({...n(this,m),queryNode:D.cloneWithHaving(n(this,m).queryNode,Oe(e))})}orHavingExists(e){return new W({...n(this,m),queryNode:D.cloneWithOrHaving(n(this,m).queryNode,Ae(e))})}orHavingNotExists(e){return new W({...n(this,m),queryNode:D.cloneWithOrHaving(n(this,m).queryNode,Oe(e))})}select(e){return new W({...n(this,m),queryNode:D.cloneWithSelections(n(this,m).queryNode,vn(e))})}distinctOn(e){return new W({...n(this,m),queryNode:D.cloneWithDistinctOn(n(this,m).queryNode,Nn(e))})}modifyFront(e){return new W({...n(this,m),queryNode:D.cloneWithFrontModifier(n(this,m).queryNode,It.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new W({...n(this,m),queryNode:D.cloneWithEndModifier(n(this,m).queryNode,It.createWithExpression(e.toOperationNode()))})}distinct(){return new W({...n(this,m),queryNode:D.cloneWithFrontModifier(n(this,m).queryNode,It.create("Distinct"))})}forUpdate(){return new W({...n(this,m),queryNode:D.cloneWithEndModifier(n(this,m).queryNode,It.create("ForUpdate"))})}forShare(){return new W({...n(this,m),queryNode:D.cloneWithEndModifier(n(this,m).queryNode,It.create("ForShare"))})}forKeyShare(){return new W({...n(this,m),queryNode:D.cloneWithEndModifier(n(this,m).queryNode,It.create("ForKeyShare"))})}forNoKeyUpdate(){return new W({...n(this,m),queryNode:D.cloneWithEndModifier(n(this,m).queryNode,It.create("ForNoKeyUpdate"))})}skipLocked(){return new W({...n(this,m),queryNode:D.cloneWithEndModifier(n(this,m).queryNode,It.create("SkipLocked"))})}noWait(){return new W({...n(this,m),queryNode:D.cloneWithEndModifier(n(this,m).queryNode,It.create("NoWait"))})}selectAll(e){return new W({...n(this,m),queryNode:D.cloneWithSelections(n(this,m).queryNode,gn(e))})}innerJoin(...e){return new W({...n(this,m),queryNode:C.cloneWithJoin(n(this,m).queryNode,Qe("InnerJoin",e))})}leftJoin(...e){return new W({...n(this,m),queryNode:C.cloneWithJoin(n(this,m).queryNode,Qe("LeftJoin",e))})}rightJoin(...e){return new W({...n(this,m),queryNode:C.cloneWithJoin(n(this,m).queryNode,Qe("RightJoin",e))})}fullJoin(...e){return new W({...n(this,m),queryNode:C.cloneWithJoin(n(this,m).queryNode,Qe("FullJoin",e))})}innerJoinLateral(...e){return new W({...n(this,m),queryNode:C.cloneWithJoin(n(this,m).queryNode,Qe("LateralInnerJoin",e))})}leftJoinLateral(...e){return new W({...n(this,m),queryNode:C.cloneWithJoin(n(this,m).queryNode,Qe("LateralLeftJoin",e))})}orderBy(e,r){return new W({...n(this,m),queryNode:D.cloneWithOrderByItem(n(this,m).queryNode,yi(e,r))})}groupBy(e){return new W({...n(this,m),queryNode:D.cloneWithGroupByItems(n(this,m).queryNode,Gh(e))})}limit(e){return new W({...n(this,m),queryNode:D.cloneWithLimit(n(this,m).queryNode,ra.create(e))})}offset(e){return new W({...n(this,m),queryNode:D.cloneWithOffset(n(this,m).queryNode,$h.create(e))})}union(e){return new W({...n(this,m),queryNode:D.cloneWithSetOperation(n(this,m).queryNode,Ar("union",e,!1))})}unionAll(e){return new W({...n(this,m),queryNode:D.cloneWithSetOperation(n(this,m).queryNode,Ar("union",e,!0))})}intersect(e){return new W({...n(this,m),queryNode:D.cloneWithSetOperation(n(this,m).queryNode,Ar("intersect",e,!1))})}intersectAll(e){return new W({...n(this,m),queryNode:D.cloneWithSetOperation(n(this,m).queryNode,Ar("intersect",e,!0))})}except(e){return new W({...n(this,m),queryNode:D.cloneWithSetOperation(n(this,m).queryNode,Ar("except",e,!1))})}exceptAll(e){return new W({...n(this,m),queryNode:D.cloneWithSetOperation(n(this,m).queryNode,Ar("except",e,!0))})}as(e){return new Kh(this,e)}clearSelect(){return new W({...n(this,m),queryNode:D.cloneWithoutSelections(n(this,m).queryNode)})}clearWhere(){return new W({...n(this,m),queryNode:C.cloneWithoutWhere(n(this,m).queryNode)})}clearLimit(){return new W({...n(this,m),queryNode:D.cloneWithoutLimit(n(this,m).queryNode)})}clearOffset(){return new W({...n(this,m),queryNode:D.cloneWithoutOffset(n(this,m).queryNode)})}clearOrderBy(){return new W({...n(this,m),queryNode:D.cloneWithoutOrderBy(n(this,m).queryNode)})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new W({...n(this,m)})}if(e,r){return this.$if(e,r)}$castTo(){return new W(n(this,m))}castTo(){return this.$castTo()}$narrowType(){return new W(n(this,m))}$assertType(){return new W(n(this,m))}assertType(){return new W(n(this,m))}withPlugin(e){return new W({...n(this,m),executor:n(this,m).executor.withPlugin(e)})}toOperationNode(){return n(this,m).executor.transformQuery(n(this,m).queryNode,n(this,m).queryId)}compile(){return n(this,m).executor.compileQuery(this.toOperationNode(),n(this,m).queryId)}async execute(){const e=this.compile();return(await n(this,m).executor.executeQuery(e,n(this,m).queryId)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=xi){const r=await this.executeTakeFirst();if(r===void 0)throw Wi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=n(this,m).executor.stream(r,e,n(this,m).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new W({...n(this,m),queryNode:C.cloneWithExplain(n(this,m).queryNode,e,r)}).execute()}};let Sr=W;m=new WeakMap,Q(Sr,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Kh{constructor(e,r){w(this,Ur,void 0);w(this,Vr,void 0);g(this,Ur,e),g(this,Vr,r)}get expression(){return n(this,Ur)}get alias(){return n(this,Vr)}toOperationNode(){return ir.create(n(this,Ur).toOperationNode(),ue.create(n(this,Vr)))}}Ur=new WeakMap,Vr=new WeakMap;const ro=class{constructor(e){w(this,jr,void 0);g(this,jr,e)}get expressionType(){}as(e){return new zh(this,e)}$castTo(){return new ro(n(this,jr))}toOperationNode(){return n(this,jr)}};let ve=ro;jr=new WeakMap;class zh{constructor(e,r){w(this,$r,void 0);w(this,jt,void 0);g(this,$r,e),g(this,jt,r)}get expression(){return n(this,$r)}get alias(){return n(this,jt)}toOperationNode(){return ir.create(n(this,$r).toOperationNode(),Le(n(this,jt))?n(this,jt).toOperationNode():ue.create(n(this,jt)))}}$r=new WeakMap,jt=new WeakMap;const tt=a({is(t){return t.kind==="AggregateFunctionNode"},create(t,e=[]){return a({kind:"AggregateFunctionNode",func:t,aggregated:e})},cloneWithDistinct(t){return a({...t,distinct:!0})},cloneWithFilter(t,e){return a({...t,filter:t.filter?Se.cloneWithOperation(t.filter,"And",e):Se.create(e)})},cloneWithOrFilter(t,e){return a({...t,filter:t.filter?Se.cloneWithOperation(t.filter,"Or",e):Se.create(e)})},cloneWithOver(t,e){return a({...t,over:e})}}),Hh=a({is(t){return t.kind==="FunctionNode"},create(t,e){return a({kind:"FunctionNode",func:t,arguments:e})}}),rt=class{constructor(e){w(this,re,void 0);g(this,re,a(e))}get expressionType(){}as(e){return new Yh(this,e)}distinct(){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithDistinct(n(this,re).aggregateFunctionNode)})}filterWhere(...e){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithFilter(n(this,re).aggregateFunctionNode,$e(e))})}filterWhereExists(e){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithFilter(n(this,re).aggregateFunctionNode,Ae(e))})}filterWhereNotExists(e){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithFilter(n(this,re).aggregateFunctionNode,Oe(e))})}filterWhereRef(e,r,u){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithFilter(n(this,re).aggregateFunctionNode,qe(e,r,u))})}orFilterWhere(...e){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithOrFilter(n(this,re).aggregateFunctionNode,$e(e))})}orFilterWhereExists(e){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithOrFilter(n(this,re).aggregateFunctionNode,Ae(e))})}orFilterWhereNotExists(e){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithOrFilter(n(this,re).aggregateFunctionNode,Oe(e))})}orFilterWhereRef(e,r,u){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithOrFilter(n(this,re).aggregateFunctionNode,qe(e,r,u))})}over(e){const r=Bh();return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithOver(n(this,re).aggregateFunctionNode,(e?e(r):r).toOperationNode())})}$call(e){return e(this)}toOperationNode(){return n(this,re).aggregateFunctionNode}};let On=rt;re=new WeakMap,Q(On,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");class Yh{constructor(e,r){w(this,Jr,void 0);w(this,Gr,void 0);g(this,Jr,e),g(this,Gr,r)}get expression(){return n(this,Jr)}get alias(){return n(this,Gr)}toOperationNode(){return ir.create(n(this,Jr).toOperationNode(),ue.create(n(this,Gr)))}}Jr=new WeakMap,Gr=new WeakMap;function Na(){const t=(r,u)=>new ve(Hh.create(r,Nn(u))),e=(r,u)=>new On({aggregateFunctionNode:tt.create(r,u?Nn(u):void 0)});return Object.assign(t,{agg:e,avg(r){return e("avg",[r])},coalesce(r,...u){return t("coalesce",[r,...u])},count(r){return e("count",[r])},countAll(r){return new On({aggregateFunctionNode:tt.create("count",gn(r))})},max(r){return e("max",[r])},min(r){return e("min",[r])},sum(r){return e("sum",[r])}})}class wa{constructor(e){w(this,Kr,void 0);g(this,Kr,a(e))}when(...e){return new va({...n(this,Kr),node:ut.cloneWithWhen(n(this,Kr).node,Gs.create(pa(e)))})}}Kr=new WeakMap;class va{constructor(e){w(this,zr,void 0);g(this,zr,a(e))}then(e){return new Xh({...n(this,zr),node:ut.cloneWithThen(n(this,zr).node,Tt(e))})}}zr=new WeakMap;class Xh{constructor(e){w(this,bt,void 0);g(this,bt,a(e))}when(...e){return new va({...n(this,bt),node:ut.cloneWithWhen(n(this,bt).node,Gs.create(pa(e)))})}else(e){return new Zh({...n(this,bt),node:ut.cloneWith(n(this,bt).node,{else:Tt(e)})})}end(){return new ve(ut.cloneWith(n(this,bt).node,{isStatement:!1}))}endCase(){return new ve(ut.cloneWith(n(this,bt).node,{isStatement:!0}))}}bt=new WeakMap;class Zh{constructor(e){w(this,Hr,void 0);g(this,Hr,a(e))}end(){return new ve(ut.cloneWith(n(this,Hr).node,{isStatement:!1}))}endCase(){return new ve(ut.cloneWith(n(this,Hr).node,{isStatement:!0}))}}Hr=new WeakMap;function ga(t=Ti){function e(r,u){return new ve(js(r,u))}return{get fn(){return Na()},selectFrom(r){return new Sr({queryId:G(),executor:t,queryNode:D.create(Dr(r))})},case(r){return new wa({node:ut.create(J(r)?void 0:Et(r))})},ref(r){return new ve(Ir(r))},val(r){return new ve($o(r))},cmpr(r,u,d){return new ve(Ks(r,u,d))},bxp(r,u,d){return new ve(Ks(r,u,d))},unary:e,not(r){return e("not",r)},exists(r){return e("exists",r)},neg(r){return e("-",r)},and(r){if(r.length===0)return new ve(vt.createImmediate(!0));if(r.length===1)return new ve(r[0].toOperationNode());let u=pn.create(r[0].toOperationNode(),r[1].toOperationNode());for(let d=2;dqn(e)):[qn(t)]}function qn(t){return _(t)?ec(t):ba(t)}function ec(t){const e=" as ";if(t.includes(e)){const[r,u]=t.split(e).map(xa);return ir.create(Ue(r),ue.create(u))}else return Ue(t)}function Ue(t){const e=".";if(t.includes(e)){const[r,u]=t.split(e).map(xa);return Ft.createWithSchema(r,u)}else return Ft.create(t)}function xa(t){return t.trim()}const Wa=a({is(t){return t.kind==="AddColumnNode"},create(t){return a({kind:"AddColumnNode",column:t})}}),sr=a({is(t){return t.kind==="AlterColumnNode"},create(t){return a({kind:"AlterColumnNode",column:he.create(t)})},cloneWith(t,e){return a({...t,...e})}}),ce=a({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return a({kind:"ColumnDefinitionNode",column:he.create(t),dataType:e})},cloneWithFrontModifier(t,e){return a({...t,frontModifiers:t.frontModifiers?a([...t.frontModifiers,e]):[e]})},cloneWithEndModifier(t,e){return a({...t,endModifiers:t.endModifiers?a([...t.endModifiers,e]):[e]})},cloneWith(t,e){return a({...t,...e})}}),Oa=a({is(t){return t.kind==="DropColumnNode"},create(t){return a({kind:"DropColumnNode",column:he.create(t)})}}),qa=a({is(t){return t.kind==="RenameColumnNode"},create(t,e){return a({kind:"RenameColumnNode",column:he.create(t),renameTo:he.create(e)})}}),Hs=a({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return a({kind:"CheckConstraintNode",expression:t,name:e?ue.create(e):void 0})}}),tc=["no action","restrict","cascade","set null","set default"],Ri=a({is(t){return t.kind==="ReferencesNode"},create(t,e){return a({kind:"ReferencesNode",table:t,columns:a([...e])})},cloneWithOnDelete(t,e){return a({...t,onDelete:e})},cloneWithOnUpdate(t,e){return a({...t,onUpdate:e})}});function Ca(t){return Le(t)?t.toOperationNode():vt.createImmediate(t)}const Li=a({is(t){return t.kind==="GeneratedNode"},create(t){return a({kind:"GeneratedNode",...t})},createWithExpression(t){return a({kind:"GeneratedNode",always:!0,expression:t})},cloneWith(t,e){return a({...t,...e})}}),rc=a({is(t){return t.kind==="DefaultValueNode"},create(t){return a({kind:"DefaultValueNode",defaultValue:t})}});function Bi(t){if(tc.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}const be=class{constructor(e){w(this,z,void 0);g(this,z,e)}autoIncrement(){return new be(ce.cloneWith(n(this,z),{autoIncrement:!0}))}primaryKey(){return new be(ce.cloneWith(n(this,z),{primaryKey:!0}))}references(e){const r=Ir(e);if(!mi.is(r)||Fs.is(r.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new be(ce.cloneWith(n(this,z),{references:Ri.create(r.table,[r.column])}))}onDelete(e){if(!n(this,z).references)throw new Error("on delete constraint can only be added for foreign keys");return new be(ce.cloneWith(n(this,z),{references:Ri.cloneWithOnDelete(n(this,z).references,Bi(e))}))}onUpdate(e){if(!n(this,z).references)throw new Error("on update constraint can only be added for foreign keys");return new be(ce.cloneWith(n(this,z),{references:Ri.cloneWithOnUpdate(n(this,z).references,Bi(e))}))}unique(){return new be(ce.cloneWith(n(this,z),{unique:!0}))}notNull(){return new be(ce.cloneWith(n(this,z),{notNull:!0}))}unsigned(){return new be(ce.cloneWith(n(this,z),{unsigned:!0}))}defaultTo(e){return new be(ce.cloneWith(n(this,z),{defaultTo:rc.create(Ca(e))}))}check(e){return new be(ce.cloneWith(n(this,z),{check:Hs.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new be(ce.cloneWith(n(this,z),{generated:Li.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new be(ce.cloneWith(n(this,z),{generated:Li.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new be(ce.cloneWith(n(this,z),{generated:Li.create({identity:!0,byDefault:!0})}))}stored(){if(!n(this,z).generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new be(ce.cloneWith(n(this,z),{generated:Li.cloneWith(n(this,z).generated,{stored:!0})}))}modifyFront(e){return new be(ce.cloneWithFrontModifier(n(this,z),e.toOperationNode()))}modifyEnd(e){return new be(ce.cloneWithEndModifier(n(this,z),e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return n(this,z)}};let Qt=be;z=new WeakMap,Q(Qt,"don't await ColumnDefinitionBuilder instances directly.");const ka=a({is(t){return t.kind==="ModifyColumnNode"},create(t){return a({kind:"ModifyColumnNode",column:t})}}),nc=a({is(t){return t.kind==="DataTypeNode"},create(t){return a({kind:"DataTypeNode",dataType:t})}});function Rr(t){return Le(t)?t.toOperationNode():nc.create(t)}const Mi=a({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,r,u){return a({kind:"ForeignKeyConstraintNode",columns:t,references:Ri.create(e,r),name:u?ue.create(u):void 0})},cloneWith(t,e){return a({...t,...e})}}),os=class{constructor(e){w(this,lr,void 0);g(this,lr,e)}onDelete(e){return new os(Mi.cloneWith(n(this,lr),{onDelete:Bi(e)}))}onUpdate(e){return new os(Mi.cloneWith(n(this,lr),{onUpdate:Bi(e)}))}$call(e){return e(this)}toOperationNode(){return n(this,lr)}};let Cn=os;lr=new WeakMap,Q(Cn,"don't await ForeignKeyConstraintBuilder instances directly.");const Ys=a({is(t){return t.kind==="AddConstraintNode"},create(t){return a({kind:"AddConstraintNode",constraint:t})}}),Ia=a({is(t){return t.kind==="UniqueConstraintNode"},create(t,e){return a({kind:"UniqueConstraintNode",columns:a(t.map(he.create)),name:e?ue.create(e):void 0})}}),Pi=a({is(t){return t.kind==="DropConstraintNode"},create(t){return a({kind:"DropConstraintNode",constraintName:ue.create(t)})},cloneWith(t,e){return a({...t,...e})}});class _i{constructor(e){Xe(this,"alterColumnNode");this.alterColumnNode=e}setDataType(e){return new kn(sr.cloneWith(this.alterColumnNode,{dataType:Rr(e)}))}setDefault(e){return new kn(sr.cloneWith(this.alterColumnNode,{setDefault:Ca(e)}))}dropDefault(){return new kn(sr.cloneWith(this.alterColumnNode,{dropDefault:!0}))}setNotNull(){return new kn(sr.cloneWith(this.alterColumnNode,{setNotNull:!0}))}dropNotNull(){return new kn(sr.cloneWith(this.alterColumnNode,{dropNotNull:!0}))}$call(e){return e(this)}}class kn extends _i{toOperationNode(){return this.alterColumnNode}}class In{constructor(e){w(this,dt,void 0);g(this,dt,a(e))}toOperationNode(){return n(this,dt).executor.transformQuery(n(this,dt).node,n(this,dt).queryId)}compile(){return n(this,dt).executor.compileQuery(this.toOperationNode(),n(this,dt).queryId)}async execute(){await n(this,dt).executor.executeQuery(this.compile(),n(this,dt).queryId)}}dt=new WeakMap,Q(In,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");const as=class{constructor(e){w(this,De,void 0);g(this,De,a(e))}onDelete(e){return new as({...n(this,De),constraintBuilder:n(this,De).constraintBuilder.onDelete(e)})}onUpdate(e){return new as({...n(this,De),constraintBuilder:n(this,De).constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return n(this,De).executor.transformQuery(ye.cloneWithTableProps(n(this,De).node,{addConstraint:Ys.create(n(this,De).constraintBuilder.toOperationNode())}),n(this,De).queryId)}compile(){return n(this,De).executor.compileQuery(this.toOperationNode(),n(this,De).queryId)}async execute(){await n(this,De).executor.executeQuery(this.compile(),n(this,De).queryId)}};let Fi=as;De=new WeakMap,Q(Fi,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");const _n=class{constructor(e){w(this,Ne,void 0);g(this,Ne,a(e))}ifExists(){return new _n({...n(this,Ne),node:ye.cloneWithTableProps(n(this,Ne).node,{dropConstraint:Pi.cloneWith(n(this,Ne).node.dropConstraint,{ifExists:!0})})})}cascade(){return new _n({...n(this,Ne),node:ye.cloneWithTableProps(n(this,Ne).node,{dropConstraint:Pi.cloneWith(n(this,Ne).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new _n({...n(this,Ne),node:ye.cloneWithTableProps(n(this,Ne).node,{dropConstraint:Pi.cloneWith(n(this,Ne).node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return n(this,Ne).executor.transformQuery(n(this,Ne).node,n(this,Ne).queryId)}compile(){return n(this,Ne).executor.compileQuery(this.toOperationNode(),n(this,Ne).queryId)}async execute(){await n(this,Ne).executor.executeQuery(this.compile(),n(this,Ne).queryId)}};let Qi=_n;Ne=new WeakMap,Q(Qi,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");class Ea{constructor(e){w(this,ne,void 0);g(this,ne,a(e))}renameTo(e){return new In({...n(this,ne),node:ye.cloneWithTableProps(n(this,ne).node,{renameTo:Ue(e)})})}setSchema(e){return new In({...n(this,ne),node:ye.cloneWithTableProps(n(this,ne).node,{setSchema:ue.create(e)})})}alterColumn(e,r){const u=r(new _i(sr.create(e)));return new Ut({...n(this,ne),node:ye.cloneWithColumnAlteration(n(this,ne).node,u.toOperationNode())})}dropColumn(e){return new Ut({...n(this,ne),node:ye.cloneWithColumnAlteration(n(this,ne).node,Oa.create(e))})}renameColumn(e,r){return new Ut({...n(this,ne),node:ye.cloneWithColumnAlteration(n(this,ne).node,qa.create(e,r))})}addColumn(e,r,u=Cr){const d=u(new Qt(ce.create(e,Rr(r))));return new Ut({...n(this,ne),node:ye.cloneWithColumnAlteration(n(this,ne).node,Wa.create(d.toOperationNode()))})}modifyColumn(e,r,u=Cr){const d=u(new Qt(ce.create(e,Rr(r))));return new Ut({...n(this,ne),node:ye.cloneWithColumnAlteration(n(this,ne).node,ka.create(d.toOperationNode()))})}addUniqueConstraint(e,r){return new In({...n(this,ne),node:ye.cloneWithTableProps(n(this,ne).node,{addConstraint:Ys.create(Ia.create(r,e))})})}addCheckConstraint(e,r){return new In({...n(this,ne),node:ye.cloneWithTableProps(n(this,ne).node,{addConstraint:Ys.create(Hs.create(r.toOperationNode(),e))})})}addForeignKeyConstraint(e,r,u,d){return new Fi({...n(this,ne),constraintBuilder:new Cn(Mi.create(r.map(he.create),Ue(u),d.map(he.create),e))})}dropConstraint(e){return new Qi({...n(this,ne),node:ye.cloneWithTableProps(n(this,ne).node,{dropConstraint:Pi.create(e)})})}$call(e){return e(this)}call(e){return this.$call(e)}}ne=new WeakMap;const dr=class{constructor(e){w(this,le,void 0);g(this,le,a(e))}alterColumn(e,r){const u=r(new _i(sr.create(e)));return new dr({...n(this,le),node:ye.cloneWithColumnAlteration(n(this,le).node,u.toOperationNode())})}dropColumn(e){return new dr({...n(this,le),node:ye.cloneWithColumnAlteration(n(this,le).node,Oa.create(e))})}renameColumn(e,r){return new dr({...n(this,le),node:ye.cloneWithColumnAlteration(n(this,le).node,qa.create(e,r))})}addColumn(e,r,u=Cr){const d=u(new Qt(ce.create(e,Rr(r))));return new dr({...n(this,le),node:ye.cloneWithColumnAlteration(n(this,le).node,Wa.create(d.toOperationNode()))})}modifyColumn(e,r,u=Cr){const d=u(new Qt(ce.create(e,Rr(r))));return new dr({...n(this,le),node:ye.cloneWithColumnAlteration(n(this,le).node,ka.create(d.toOperationNode()))})}toOperationNode(){return n(this,le).executor.transformQuery(n(this,le).node,n(this,le).queryId)}compile(){return n(this,le).executor.compileQuery(this.toOperationNode(),n(this,le).queryId)}async execute(){await n(this,le).executor.executeQuery(this.compile(),n(this,le).queryId)}};let Ut=dr;le=new WeakMap,Q(Ea,"don't await AlterTableBuilder instances"),Q(_i,"don't await AlterColumnBuilder instances"),Q(Ut,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class Ta extends Js{transformValue(e){return{...super.transformValue(e),immediate:!0}}}const xt=class{constructor(e){w(this,H,void 0);g(this,H,a(e))}ifNotExists(){return new xt({...n(this,H),node:Pt.cloneWith(n(this,H).node,{ifNotExists:!0})})}unique(){return new xt({...n(this,H),node:Pt.cloneWith(n(this,H).node,{unique:!0})})}on(e){return new xt({...n(this,H),node:Pt.cloneWith(n(this,H).node,{table:Ue(e)})})}column(e){return new xt({...n(this,H),node:Pt.cloneWithColumns(n(this,H).node,[Vo(e)])})}columns(e){return new xt({...n(this,H),node:Pt.cloneWithColumns(n(this,H).node,e.map(Vo))})}expression(e){return new xt({...n(this,H),node:Pt.cloneWithColumns(n(this,H).node,[e.toOperationNode()])})}using(e){return new xt({...n(this,H),node:Pt.cloneWith(n(this,H).node,{using:Te.createWithSql(e)})})}where(...e){const r=new Ta;return new xt({...n(this,H),node:C.cloneWithWhere(n(this,H).node,r.transformNode($e(e)))})}$call(e){return e(this)}toOperationNode(){return n(this,H).executor.transformQuery(n(this,H).node,n(this,H).queryId)}compile(){return n(this,H).executor.compileQuery(this.toOperationNode(),n(this,H).queryId)}async execute(){await n(this,H).executor.executeQuery(this.compile(),n(this,H).queryId)}};let Ui=xt;H=new WeakMap,Q(Ui,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");const no=class{constructor(e){w(this,Ge,void 0);g(this,Ge,a(e))}ifNotExists(){return new no({...n(this,Ge),node:Bo.cloneWith(n(this,Ge).node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return n(this,Ge).executor.transformQuery(n(this,Ge).node,n(this,Ge).queryId)}compile(){return n(this,Ge).executor.compileQuery(this.toOperationNode(),n(this,Ge).queryId)}async execute(){await n(this,Ge).executor.executeQuery(this.compile(),n(this,Ge).queryId)}};let Vi=no;Ge=new WeakMap,Q(Vi,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");const ic=a({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return a({kind:"PrimaryKeyConstraintNode",columns:a(t.map(he.create)),name:e?ue.create(e):void 0})}});function sc(t){if(Xu.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}const nt=class{constructor(e){w(this,U,void 0);g(this,U,a(e))}temporary(){return new nt({...n(this,U),node:at.cloneWith(n(this,U).node,{temporary:!0})})}onCommit(e){return new nt({...n(this,U),node:at.cloneWith(n(this,U).node,{onCommit:sc(e)})})}ifNotExists(){return new nt({...n(this,U),node:at.cloneWith(n(this,U).node,{ifNotExists:!0})})}addColumn(e,r,u=Cr){const d=u(new Qt(ce.create(e,Rr(r))));return new nt({...n(this,U),node:at.cloneWithColumn(n(this,U).node,d.toOperationNode())})}addPrimaryKeyConstraint(e,r){return new nt({...n(this,U),node:at.cloneWithConstraint(n(this,U).node,ic.create(r,e))})}addUniqueConstraint(e,r){return new nt({...n(this,U),node:at.cloneWithConstraint(n(this,U).node,Ia.create(r,e))})}addCheckConstraint(e,r){return new nt({...n(this,U),node:at.cloneWithConstraint(n(this,U).node,Hs.create(r.toOperationNode(),e))})}addForeignKeyConstraint(e,r,u,d,b=Cr){const k=b(new Cn(Mi.create(r.map(he.create),Ue(u),d.map(he.create),e)));return new nt({...n(this,U),node:at.cloneWithConstraint(n(this,U).node,k.toOperationNode())})}modifyFront(e){return new nt({...n(this,U),node:at.cloneWithFrontModifier(n(this,U).node,e.toOperationNode())})}modifyEnd(e){return new nt({...n(this,U),node:at.cloneWithEndModifier(n(this,U).node,e.toOperationNode())})}$call(e){return e(this)}call(e){return this.$call(e)}toOperationNode(){return n(this,U).executor.transformQuery(n(this,U).node,n(this,U).queryId)}compile(){return n(this,U).executor.compileQuery(this.toOperationNode(),n(this,U).queryId)}async execute(){await n(this,U).executor.executeQuery(this.compile(),n(this,U).queryId)}};let ji=nt;U=new WeakMap,Q(ji,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");const Fn=class{constructor(e){w(this,Ce,void 0);g(this,Ce,a(e))}on(e){return new Fn({...n(this,Ce),node:fi.cloneWith(n(this,Ce).node,{table:Ue(e)})})}ifExists(){return new Fn({...n(this,Ce),node:fi.cloneWith(n(this,Ce).node,{ifExists:!0})})}cascade(){return new Fn({...n(this,Ce),node:fi.cloneWith(n(this,Ce).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return n(this,Ce).executor.transformQuery(n(this,Ce).node,n(this,Ce).queryId)}compile(){return n(this,Ce).executor.compileQuery(this.toOperationNode(),n(this,Ce).queryId)}async execute(){await n(this,Ce).executor.executeQuery(this.compile(),n(this,Ce).queryId)}};let $i=Fn;Ce=new WeakMap,Q($i,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");const us=class{constructor(e){w(this,Me,void 0);g(this,Me,a(e))}ifExists(){return new us({...n(this,Me),node:Ms.cloneWith(n(this,Me).node,{ifExists:!0})})}cascade(){return new us({...n(this,Me),node:Ms.cloneWith(n(this,Me).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return n(this,Me).executor.transformQuery(n(this,Me).node,n(this,Me).queryId)}compile(){return n(this,Me).executor.compileQuery(this.toOperationNode(),n(this,Me).queryId)}async execute(){await n(this,Me).executor.executeQuery(this.compile(),n(this,Me).queryId)}};let Ji=us;Me=new WeakMap,Q(Ji,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");const hs=class{constructor(e){w(this,Pe,void 0);g(this,Pe,a(e))}ifExists(){return new hs({...n(this,Pe),node:Ps.cloneWith(n(this,Pe).node,{ifExists:!0})})}cascade(){return new hs({...n(this,Pe),node:Ps.cloneWith(n(this,Pe).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return n(this,Pe).executor.transformQuery(n(this,Pe).node,n(this,Pe).queryId)}compile(){return n(this,Pe).executor.compileQuery(this.toOperationNode(),n(this,Pe).queryId)}async execute(){await n(this,Pe).executor.executeQuery(this.compile(),n(this,Pe).queryId)}};let Gi=hs;Pe=new WeakMap,Q(Gi,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");const Vt=a({is(t){return t.kind==="CreateViewNode"},create(t){return a({kind:"CreateViewNode",name:_t.create(t)})},cloneWith(t,e){return a({...t,...e})}});class oc{constructor(){w(this,cs,new Ta)}transformQuery(e){return n(this,cs).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}cs=new WeakMap;const $t=class{constructor(e){w(this,ae,void 0);g(this,ae,a(e))}temporary(){return new $t({...n(this,ae),node:Vt.cloneWith(n(this,ae).node,{temporary:!0})})}materialized(){return new $t({...n(this,ae),node:Vt.cloneWith(n(this,ae).node,{materialized:!0})})}ifNotExists(){return new $t({...n(this,ae),node:Vt.cloneWith(n(this,ae).node,{ifNotExists:!0})})}orReplace(){return new $t({...n(this,ae),node:Vt.cloneWith(n(this,ae).node,{orReplace:!0})})}columns(e){return new $t({...n(this,ae),node:Vt.cloneWith(n(this,ae).node,{columns:e.map(Uo)})})}as(e){const r=e.withPlugin(new oc).toOperationNode();return new $t({...n(this,ae),node:Vt.cloneWith(n(this,ae).node,{as:r})})}$call(e){return e(this)}toOperationNode(){return n(this,ae).executor.transformQuery(n(this,ae).node,n(this,ae).queryId)}compile(){return n(this,ae).executor.compileQuery(this.toOperationNode(),n(this,ae).queryId)}async execute(){await n(this,ae).executor.executeQuery(this.compile(),n(this,ae).queryId)}};let Ki=$t;ae=new WeakMap,Q(Ki,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const zi=a({is(t){return t.kind==="DropViewNode"},create(t){return a({kind:"DropViewNode",name:_t.create(t)})},cloneWith(t,e){return a({...t,...e})}}),Qn=class{constructor(e){w(this,ke,void 0);g(this,ke,a(e))}materialized(){return new Qn({...n(this,ke),node:zi.cloneWith(n(this,ke).node,{materialized:!0})})}ifExists(){return new Qn({...n(this,ke),node:zi.cloneWith(n(this,ke).node,{ifExists:!0})})}cascade(){return new Qn({...n(this,ke),node:zi.cloneWith(n(this,ke).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return n(this,ke).executor.transformQuery(n(this,ke).node,n(this,ke).queryId)}compile(){return n(this,ke).executor.compileQuery(this.toOperationNode(),n(this,ke).queryId)}async execute(){await n(this,ke).executor.executeQuery(this.compile(),n(this,ke).queryId)}};let Hi=Qn;ke=new WeakMap,Q(Hi,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const Aa=a({is(t){return t.kind==="CreateTypeNode"},create(t){return a({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return a({...t,enum:Us.create(e.map(r=>vt.createImmediate(r)))})}}),io=class{constructor(e){w(this,Ke,void 0);g(this,Ke,a(e))}toOperationNode(){return n(this,Ke).executor.transformQuery(n(this,Ke).node,n(this,Ke).queryId)}asEnum(e){return new io({...n(this,Ke),node:Aa.cloneWithEnum(n(this,Ke).node,e)})}$call(e){return e(this)}compile(){return n(this,Ke).executor.compileQuery(this.toOperationNode(),n(this,Ke).queryId)}async execute(){await n(this,Ke).executor.executeQuery(this.compile(),n(this,Ke).queryId)}};let Yi=io;Ke=new WeakMap,Q(Yi,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const Sa=a({is(t){return t.kind==="DropTypeNode"},create(t){return a({kind:"DropTypeNode",name:t})},cloneWith(t,e){return a({...t,...e})}}),so=class{constructor(e){w(this,ze,void 0);g(this,ze,a(e))}ifExists(){return new so({...n(this,ze),node:Sa.cloneWith(n(this,ze).node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return n(this,ze).executor.transformQuery(n(this,ze).node,n(this,ze).queryId)}compile(){return n(this,ze).executor.compileQuery(this.toOperationNode(),n(this,ze).queryId)}async execute(){await n(this,ze).executor.executeQuery(this.compile(),n(this,ze).queryId)}};let Xi=so;ze=new WeakMap,Q(Xi,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function Da(t){const e=".";if(t.includes(e)){const r=t.split(e).map(ac);if(r.length===2)return _t.createWithSchema(r[0],r[1]);throw new Error(`invalid schemable identifier ${t}`)}else return _t.create(t)}function ac(t){return t.trim()}const Un=class{constructor(e){w(this,xe,void 0);g(this,xe,e)}createTable(e){return new ji({queryId:G(),executor:n(this,xe),node:at.create(Ue(e))})}dropTable(e){return new Gi({queryId:G(),executor:n(this,xe),node:Ps.create(Ue(e))})}createIndex(e){return new Ui({queryId:G(),executor:n(this,xe),node:Pt.create(e)})}dropIndex(e){return new $i({queryId:G(),executor:n(this,xe),node:fi.create(e)})}createSchema(e){return new Vi({queryId:G(),executor:n(this,xe),node:Bo.create(e)})}dropSchema(e){return new Ji({queryId:G(),executor:n(this,xe),node:Ms.create(e)})}alterTable(e){return new Ea({queryId:G(),executor:n(this,xe),node:ye.create(Ue(e))})}createView(e){return new Ki({queryId:G(),executor:n(this,xe),node:Vt.create(e)})}dropView(e){return new Hi({queryId:G(),executor:n(this,xe),node:zi.create(e)})}createType(e){return new Yi({queryId:G(),executor:n(this,xe),node:Aa.create(Da(e))})}dropType(e){return new Xi({queryId:G(),executor:n(this,xe),node:Sa.create(Da(e))})}withPlugin(e){return new Un(n(this,xe).withPlugin(e))}withoutPlugins(){return new Un(n(this,xe).withoutPlugins())}withSchema(e){return new Un(n(this,xe).withPluginAtFront(new Wn(e)))}};let Xs=Un;xe=new WeakMap;class uc{ref(e){return new ph(e)}}class hc{constructor(e){w(this,Yr,void 0);g(this,Yr,e)}async provideConnection(e){const r=await n(this,Yr).acquireConnection();try{return await e(r)}finally{await n(this,Yr).releaseConnection(r)}}}Yr=new WeakMap;const fr=class extends ha{constructor(r,u,d,b=[]){super(b);w(this,Wt,void 0);w(this,Ot,void 0);w(this,St,void 0);g(this,Wt,r),g(this,Ot,u),g(this,St,d)}get adapter(){return n(this,Ot)}compileQuery(r){return n(this,Wt).compileQuery(r)}provideConnection(r){return n(this,St).provideConnection(r)}withPlugins(r){return new fr(n(this,Wt),n(this,Ot),n(this,St),[...this.plugins,...r])}withPlugin(r){return new fr(n(this,Wt),n(this,Ot),n(this,St),[...this.plugins,r])}withPluginAtFront(r){return new fr(n(this,Wt),n(this,Ot),n(this,St),[r,...this.plugins])}withConnectionProvider(r){return new fr(n(this,Wt),n(this,Ot),r,[...this.plugins])}withoutPlugins(){return new fr(n(this,Wt),n(this,Ot),n(this,St),[])}};let Zs=fr;Wt=new WeakMap,Ot=new WeakMap,St=new WeakMap;function Ra(){return typeof performance<"u"&&Ze(performance.now)?performance.now():Date.now()}class cc{constructor(e,r){w(this,ls);w(this,ds);w(this,fs);w(this,ps);w(this,jn);w(this,ft,void 0);w(this,Jt,void 0);w(this,Dt,void 0);w(this,pr,void 0);w(this,Vn,new WeakSet);g(this,ft,e),g(this,Jt,r)}async init(){n(this,Dt)||g(this,Dt,n(this,ft).init().catch(e=>(g(this,Dt,void 0),Promise.reject(e)))),await n(this,Dt)}async acquireConnection(){await this.init();const e=await n(this,ft).acquireConnection();return n(this,Vn).has(e)||(X(this,ls,ju).call(this)&&X(this,ds,$u).call(this,e),n(this,Vn).add(e)),e}async releaseConnection(e){await n(this,ft).releaseConnection(e)}beginTransaction(e,r){return n(this,ft).beginTransaction(e,r)}commitTransaction(e){return n(this,ft).commitTransaction(e)}rollbackTransaction(e){return n(this,ft).rollbackTransaction(e)}async destroy(){n(this,Dt)&&(await n(this,Dt),n(this,pr)||g(this,pr,n(this,ft).destroy().catch(e=>(g(this,pr,void 0),Promise.reject(e)))),await n(this,pr))}}ft=new WeakMap,Jt=new WeakMap,Dt=new WeakMap,pr=new WeakMap,Vn=new WeakMap,ls=new WeakSet,ju=function(){return n(this,Jt).isLevelEnabled("query")||n(this,Jt).isLevelEnabled("error")},ds=new WeakSet,$u=function(e){const r=e.executeQuery;e.executeQuery=async u=>{const d=Ra();try{return await r.call(e,u)}catch(b){throw await X(this,fs,Ju).call(this,b,u,d),b}finally{await X(this,ps,Gu).call(this,u,d)}}},fs=new WeakSet,Ju=async function(e,r,u){await n(this,Jt).error(()=>({level:"error",error:e,query:r,queryDurationMillis:X(this,jn,So).call(this,u)}))},ps=new WeakSet,Gu=async function(e,r){await n(this,Jt).query(()=>({level:"query",query:e,queryDurationMillis:X(this,jn,So).call(this,r)}))},jn=new WeakSet,So=function(e){return Ra()-e};class La{constructor(e){w(this,ms);w(this,$n,void 0);w(this,Gt,void 0);g(this,$n,e)}async provideConnection(e){for(;n(this,Gt);)await n(this,Gt);const r=X(this,ms,Ku).call(this,e);return g(this,Gt,r.then(()=>{g(this,Gt,void 0)}).catch(()=>{g(this,Gt,void 0)})),r}}$n=new WeakMap,Gt=new WeakMap,ms=new WeakSet,Ku=async function(e){return await e(n(this,$n))};const lc=["read uncommitted","read committed","repeatable read","serializable"];a(["query","error"]);class dc{constructor(e){w(this,Kt,void 0);w(this,mr,void 0);Ze(e)?(g(this,mr,e),g(this,Kt,a({query:!0,error:!0}))):(g(this,mr,fc),g(this,Kt,a({query:e.includes("query"),error:e.includes("error")})))}isLevelEnabled(e){return n(this,Kt)[e]}async query(e){n(this,Kt).query&&await n(this,mr).call(this,e())}async error(e){n(this,Kt).error&&await n(this,mr).call(this,e())}}Kt=new WeakMap,mr=new WeakMap;function fc(t){t.level==="query"?(console.log(`kysely:query: ${t.query.sql}`),console.log(`kysely:query: duration: ${t.queryDurationMillis.toFixed(1)}ms`)):t.level==="error"&&(t.error instanceof Error?console.error(`kysely:error: ${t.error.stack??t.error.message}`):console.error(`kysely:error: ${t}`))}function pc(t){return wt(t)&&Ze(t.compile)}const Xr=class extends Ei{constructor(r){let u,d;if(mc(r))u={executor:r.executor},d={...r};else{const b=r.dialect,k=b.createDriver(),I=b.createQueryCompiler(),j=b.createAdapter(),c=new dc(r.log??[]),_e=new cc(k,c),Fe=new hc(_e),P=new Zs(I,j,Fe,r.plugins??[]);u={executor:P},d={config:r,executor:P,dialect:b,driver:_e}}super(u);w(this,Ie,void 0);g(this,Ie,a(d))}get schema(){return new Xs(n(this,Ie).executor)}get dynamic(){return new uc}get introspection(){return n(this,Ie).dialect.createIntrospector(this.withoutPlugins())}case(r){return new wa({node:ut.create(J(r)?void 0:Si(r))})}get fn(){return Na()}transaction(){return new Zi({...n(this,Ie)})}connection(){return new Ba({...n(this,Ie)})}withPlugin(r){return new Xr({...n(this,Ie),executor:n(this,Ie).executor.withPlugin(r)})}withoutPlugins(){return new Xr({...n(this,Ie),executor:n(this,Ie).executor.withoutPlugins()})}withSchema(r){return new Xr({...n(this,Ie),executor:n(this,Ie).executor.withPluginAtFront(new Wn(r))})}withTables(){return new Xr({...n(this,Ie)})}async destroy(){await n(this,Ie).driver.destroy()}get isTransaction(){return!1}getExecutor(){return n(this,Ie).executor}executeQuery(r,u=G()){const d=pc(r)?r.compile():r;return this.getExecutor().executeQuery(d,u)}};let En=Xr;Ie=new WeakMap;const Zr=class extends En{constructor(r){super(r);w(this,pt,void 0);g(this,pt,r)}get isTransaction(){return!0}transaction(){throw new Error("calling the transaction method for a Transaction is not supported")}connection(){throw new Error("calling the connection method for a Transaction is not supported")}async destroy(){throw new Error("calling the destroy method for a Transaction is not supported")}withPlugin(r){return new Zr({...n(this,pt),executor:n(this,pt).executor.withPlugin(r)})}withoutPlugins(){return new Zr({...n(this,pt),executor:n(this,pt).executor.withoutPlugins()})}withSchema(r){return new Zr({...n(this,pt),executor:n(this,pt).executor.withPluginAtFront(new Wn(r))})}withTables(){return new Zr({...n(this,pt)})}};let eo=Zr;pt=new WeakMap;function mc(t){return wt(t)&&wt(t.config)&&wt(t.driver)&&wt(t.executor)&&wt(t.dialect)}class Ba{constructor(e){w(this,yr,void 0);g(this,yr,a(e))}async execute(e){return n(this,yr).executor.provideConnection(async r=>{const u=n(this,yr).executor.withConnectionProvider(new La(r)),d=new En({...n(this,yr),executor:u});return await e(d)})}}yr=new WeakMap,Q(Ba,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");const oo=class{constructor(e){w(this,mt,void 0);g(this,mt,a(e))}setIsolationLevel(e){return new oo({...n(this,mt),isolationLevel:e})}async execute(e){const{isolationLevel:r,...u}=n(this,mt),d={isolationLevel:r};return yc(d),n(this,mt).executor.provideConnection(async b=>{const k=n(this,mt).executor.withConnectionProvider(new La(b)),I=new eo({...u,executor:k});try{await n(this,mt).driver.beginTransaction(b,d);const j=await e(I);return await n(this,mt).driver.commitTransaction(b),j}catch(j){throw await n(this,mt).driver.rollbackTransaction(b),j}})}};let Zi=oo;mt=new WeakMap,Q(Zi,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function yc(t){if(t.isolationLevel&&!lc.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}const ys=class{constructor(e){w(this,en);w(this,Jn);w(this,Gn);w(this,Ve,void 0);g(this,Ve,a(e))}get expressionType(){}as(e){return new Nc(this,e)}$castTo(){return new ys({...n(this,Ve)})}castTo(){return this.$castTo()}withPlugin(e){return new ys({...n(this,Ve),plugins:n(this,Ve).plugins!==void 0?a([...n(this,Ve).plugins,e]):a([e])})}toOperationNode(){return X(this,Jn,Do).call(this,X(this,en,Bs).call(this))}compile(e){return X(this,Gn,Ro).call(this,X(this,en,Bs).call(this,e))}async execute(e){const r=X(this,en,Bs).call(this,e);return r.executeQuery(X(this,Gn,Ro).call(this,r),n(this,Ve).queryId)}};let ht=ys;Ve=new WeakMap,en=new WeakSet,Bs=function(e){const r=e!==void 0?e.getExecutor():Ti;return n(this,Ve).plugins!==void 0?r.withPlugins(n(this,Ve).plugins):r},Jn=new WeakSet,Do=function(e){return e.transformQuery(n(this,Ve).rawNode,n(this,Ve).queryId)},Gn=new WeakSet,Ro=function(e){return e.compileQuery(X(this,Jn,Do).call(this,e),n(this,Ve).queryId)},Q(ht,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");class Nc{constructor(e,r){w(this,tn,void 0);w(this,zt,void 0);g(this,tn,e),g(this,zt,r)}get expression(){return n(this,tn)}get alias(){return n(this,zt)}toOperationNode(){return ir.create(n(this,tn).toOperationNode(),Le(n(this,zt))?n(this,zt).toOperationNode():ue.create(n(this,zt)))}}tn=new WeakMap,zt=new WeakMap;const Je=Object.assign((t,...e)=>new ht({queryId:G(),rawNode:Te.create(t,(e==null?void 0:e.map(Tt))??[])}),{ref(t){return new ht({queryId:G(),rawNode:Te.createWithChild(Ir(t))})},val(t){return new ht({queryId:G(),rawNode:Te.createWithChild(Tt(t))})},value(t){return this.val(t)},table(t){return new ht({queryId:G(),rawNode:Te.createWithChild(Ue(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",new ht({queryId:G(),rawNode:Te.create(e,t.map(ue.create))})},lit(t){return new ht({queryId:G(),rawNode:Te.createWithChild(vt.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return new ht({queryId:G(),rawNode:Te.createWithSql(t)})},join(t,e=Je`, `){const r=new Array(2*t.length-1),u=e.toOperationNode();for(let d=0;d{this.nodeStack.push(e),n(this,Ns)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}Ns=new WeakMap;class vc extends wc{constructor(){super(...arguments);w(this,rn,"");w(this,Nr,[])}get numParameters(){return n(this,Nr).length}compileQuery(r){return g(this,rn,""),g(this,Nr,[]),this.visitNode(r),a({query:r,sql:this.getSql(),parameters:[...n(this,Nr)]})}getSql(){return n(this,rn)}visitSelectQuery(r){const u=this.parentNode!==void 0&&!gt.is(this.parentNode)&&!Vt.is(this.parentNode)&&!ya.is(this.parentNode);this.parentNode===void 0&&r.explain&&(this.visitNode(r.explain),this.append(" ")),u&&this.append("("),r.with&&(this.visitNode(r.with),this.append(" ")),this.append("select "),r.distinctOn&&(this.compileDistinctOn(r.distinctOn),this.append(" ")),r.frontModifiers&&r.frontModifiers.length>0&&(this.compileList(r.frontModifiers," "),this.append(" ")),r.selections&&(this.compileList(r.selections),this.append(" ")),this.visitNode(r.from),r.joins&&(this.append(" "),this.compileList(r.joins," ")),r.where&&(this.append(" "),this.visitNode(r.where)),r.groupBy&&(this.append(" "),this.visitNode(r.groupBy)),r.having&&(this.append(" "),this.visitNode(r.having)),r.setOperations&&(this.append(" "),this.compileList(r.setOperations," ")),r.orderBy&&(this.append(" "),this.visitNode(r.orderBy)),r.limit&&(this.append(" "),this.visitNode(r.limit)),r.offset&&(this.append(" "),this.visitNode(r.offset)),r.endModifiers&&r.endModifiers.length>0&&(this.append(" "),this.compileList(r.endModifiers," ")),u&&this.append(")")}visitFrom(r){this.append("from "),this.compileList(r.froms)}visitSelection(r){this.visitNode(r.selection)}visitColumn(r){this.visitNode(r.column)}compileDistinctOn(r){this.append("distinct on ("),this.compileList(r),this.append(")")}compileList(r,u=", "){const d=r.length-1;for(let b=0;b<=d;b++)this.visitNode(r[b]),bb&&this.visitNode(d[b])}visitOperator(r){this.append(r.operator)}visitTable(r){this.visitNode(r.table)}visitSchemableIdentifier(r){r.schema&&(this.visitNode(r.schema),this.append(".")),this.visitNode(r.identifier)}visitCreateTable(r){this.append("create "),r.frontModifiers&&r.frontModifiers.length>0&&(this.compileList(r.frontModifiers," "),this.append(" ")),r.temporary&&this.append("temporary "),this.append("table "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.table),this.append(" ("),this.compileList([...r.columns,...r.constraints??[]]),this.append(")"),r.onCommit&&(this.append(" on commit "),this.append(r.onCommit)),r.endModifiers&&r.endModifiers.length>0&&(this.append(" "),this.compileList(r.endModifiers," "))}visitColumnDefinition(r){this.visitNode(r.column),this.append(" "),this.visitNode(r.dataType),r.unsigned&&this.append(" unsigned"),r.frontModifiers&&r.frontModifiers.length>0&&(this.append(" "),this.compileList(r.frontModifiers," ")),r.generated&&(this.append(" "),this.visitNode(r.generated)),r.defaultTo&&(this.append(" "),this.visitNode(r.defaultTo)),r.notNull&&this.append(" not null"),r.unique&&this.append(" unique"),r.primaryKey&&this.append(" primary key"),r.autoIncrement&&(this.append(" "),this.append(this.getAutoIncrement())),r.references&&(this.append(" "),this.visitNode(r.references)),r.check&&(this.append(" "),this.visitNode(r.check)),r.endModifiers&&r.endModifiers.length>0&&(this.append(" "),this.compileList(r.endModifiers," "))}getAutoIncrement(){return"auto_increment"}visitReferences(r){this.append("references "),this.visitNode(r.table),this.append(" ("),this.compileList(r.columns),this.append(")"),r.onDelete&&(this.append(" on delete "),this.append(r.onDelete)),r.onUpdate&&(this.append(" on update "),this.append(r.onUpdate))}visitDropTable(r){this.append("drop table "),r.ifExists&&this.append("if exists "),this.visitNode(r.table),r.cascade&&this.append(" cascade")}visitDataType(r){this.append(r.dataType)}visitOrderBy(r){this.append("order by "),this.compileList(r.items)}visitOrderByItem(r){this.visitNode(r.orderBy),r.direction&&(this.append(" "),this.visitNode(r.direction))}visitGroupBy(r){this.append("group by "),this.compileList(r.items)}visitGroupByItem(r){this.visitNode(r.groupBy)}visitUpdateQuery(r){const u=this.nodeStack.find(C.is)!==r;!u&&r.explain&&(this.visitNode(r.explain),this.append(" ")),u&&this.append("("),r.with&&(this.visitNode(r.with),this.append(" ")),this.append("update "),this.visitNode(r.table),this.append(" set "),r.updates&&this.compileList(r.updates),r.from&&(this.append(" "),this.visitNode(r.from)),r.joins&&(this.append(" "),this.compileList(r.joins," ")),r.where&&(this.append(" "),this.visitNode(r.where)),r.returning&&(this.append(" "),this.visitNode(r.returning)),u&&this.append(")")}visitColumnUpdate(r){this.visitNode(r.column),this.append(" = "),this.visitNode(r.value)}visitLimit(r){this.append("limit "),this.visitNode(r.limit)}visitOffset(r){this.append("offset "),this.visitNode(r.offset)}visitOnConflict(r){this.append("on conflict"),r.columns?(this.append(" ("),this.compileList(r.columns),this.append(")")):r.constraint?(this.append(" on constraint "),this.visitNode(r.constraint)):r.indexExpression&&(this.append(" ("),this.visitNode(r.indexExpression),this.append(")")),r.indexWhere&&(this.append(" "),this.visitNode(r.indexWhere)),r.doNothing===!0?this.append(" do nothing"):r.updates&&(this.append(" do update set "),this.compileList(r.updates),r.updateWhere&&(this.append(" "),this.visitNode(r.updateWhere)))}visitOnDuplicateKey(r){this.append("on duplicate key update "),this.compileList(r.updates)}visitCreateIndex(r){this.append("create "),r.unique&&this.append("unique "),this.append("index "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.name),r.table&&(this.append(" on "),this.visitNode(r.table)),r.using&&(this.append(" using "),this.visitNode(r.using)),r.columns&&(this.append(" ("),this.compileList(r.columns),this.append(")")),r.where&&(this.append(" "),this.visitNode(r.where))}visitDropIndex(r){this.append("drop index "),r.ifExists&&this.append("if exists "),this.visitNode(r.name),r.table&&(this.append(" on "),this.visitNode(r.table)),r.cascade&&this.append(" cascade")}visitCreateSchema(r){this.append("create schema "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.schema)}visitDropSchema(r){this.append("drop schema "),r.ifExists&&this.append("if exists "),this.visitNode(r.schema),r.cascade&&this.append(" cascade")}visitPrimaryKeyConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("primary key ("),this.compileList(r.columns),this.append(")")}visitUniqueConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("unique ("),this.compileList(r.columns),this.append(")")}visitCheckConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("check ("),this.visitNode(r.expression),this.append(")")}visitForeignKeyConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("foreign key ("),this.compileList(r.columns),this.append(") "),this.visitNode(r.references),r.onDelete&&(this.append(" on delete "),this.append(r.onDelete)),r.onUpdate&&(this.append(" on update "),this.append(r.onUpdate))}visitList(r){this.compileList(r.items)}visitWith(r){this.append("with "),r.recursive&&this.append("recursive "),this.compileList(r.expressions)}visitCommonTableExpression(r){this.visitNode(r.name),this.append(" as "),this.visitNode(r.expression)}visitCommonTableExpressionName(r){this.visitNode(r.table),r.columns&&(this.append("("),this.compileList(r.columns),this.append(")"))}visitAlterTable(r){this.append("alter table "),this.visitNode(r.table),this.append(" "),r.renameTo&&(this.append("rename to "),this.visitNode(r.renameTo)),r.setSchema&&(this.append("set schema "),this.visitNode(r.setSchema)),r.addConstraint&&this.visitNode(r.addConstraint),r.dropConstraint&&this.visitNode(r.dropConstraint),r.columnAlterations&&this.compileList(r.columnAlterations)}visitAddColumn(r){this.append("add column "),this.visitNode(r.column)}visitRenameColumn(r){this.append("rename column "),this.visitNode(r.column),this.append(" to "),this.visitNode(r.renameTo)}visitDropColumn(r){this.append("drop column "),this.visitNode(r.column)}visitAlterColumn(r){this.append("alter column "),this.visitNode(r.column),this.append(" "),r.dataType&&(this.append("type "),this.visitNode(r.dataType),r.dataTypeExpression&&(this.append("using "),this.visitNode(r.dataTypeExpression))),r.setDefault&&(this.append("set default "),this.visitNode(r.setDefault)),r.dropDefault&&this.append("drop default"),r.setNotNull&&this.append("set not null"),r.dropNotNull&&this.append("drop not null")}visitModifyColumn(r){this.append("modify column "),this.visitNode(r.column)}visitAddConstraint(r){this.append("add "),this.visitNode(r.constraint)}visitDropConstraint(r){this.append("drop constraint "),r.ifExists&&this.append("if exists "),this.visitNode(r.constraintName),r.modifier==="cascade"?this.append(" cascade"):r.modifier==="restrict"&&this.append(" restrict")}visitSetOperation(r){this.append(r.operator),this.append(" "),r.all&&this.append("all "),this.visitNode(r.expression)}visitCreateView(r){this.append("create "),r.orReplace&&this.append("or replace "),r.materialized&&this.append("materialized "),r.temporary&&this.append("temporary "),this.append("view "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.name),this.append(" "),r.columns&&(this.append("("),this.compileList(r.columns),this.append(") ")),r.as&&(this.append("as "),this.visitNode(r.as))}visitDropView(r){this.append("drop "),r.materialized&&this.append("materialized "),this.append("view "),r.ifExists&&this.append("if exists "),this.visitNode(r.name),r.cascade&&this.append(" cascade")}visitGenerated(r){this.append("generated "),r.always&&this.append("always "),r.byDefault&&this.append("by default "),this.append("as "),r.identity&&this.append("identity"),r.expression&&(this.append("("),this.visitNode(r.expression),this.append(")")),r.stored&&this.append(" stored")}visitDefaultValue(r){this.append("default "),this.visitNode(r.defaultValue)}visitSelectModifier(r){r.rawModifier?this.visitNode(r.rawModifier):this.append(gc[r.modifier])}visitCreateType(r){this.append("create type "),this.visitNode(r.name),r.enum&&(this.append(" as enum "),this.visitNode(r.enum))}visitDropType(r){this.append("drop type "),r.ifExists&&this.append("if exists "),this.visitNode(r.name)}visitExplain(r){this.append("explain"),(r.options||r.format)&&(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),r.options&&(this.visitNode(r.options),r.format&&this.append(this.getExplainOptionsDelimiter())),r.format&&(this.append("format"),this.append(this.getExplainOptionAssignment()),this.append(r.format)),this.append(this.getRightExplainOptionsWrapper()))}visitDefaultInsertValue(r){this.append("default")}visitAggregateFunction(r){this.append(r.func),this.append("("),r.distinct&&this.append("distinct "),this.compileList(r.aggregated),this.append(")"),r.filter&&(this.append(" filter("),this.visitNode(r.filter),this.append(")")),r.over&&(this.append(" "),this.visitNode(r.over))}visitOver(r){this.append("over("),r.partitionBy&&(this.visitNode(r.partitionBy),r.orderBy&&this.append(" ")),r.orderBy&&this.visitNode(r.orderBy),this.append(")")}visitPartitionBy(r){this.append("partition by "),this.compileList(r.items)}visitPartitionByItem(r){this.visitNode(r.partitionBy)}visitBinaryOperation(r){this.visitNode(r.leftOperand),this.append(" "),this.visitNode(r.operator),this.append(" "),this.visitNode(r.rightOperand)}visitUnaryOperation(r){this.visitNode(r.operator),this.isMinusOperator(r.operator)||this.append(" "),this.visitNode(r.operand)}isMinusOperator(r){return _s.is(r)&&r.operator==="-"}visitUsing(r){this.append("using "),this.compileList(r.tables)}visitFunction(r){this.append(r.func),this.append("("),this.compileList(r.arguments),this.append(")")}visitCase(r){this.append("case"),r.value&&(this.append(" "),this.visitNode(r.value)),r.when&&(this.append(" "),this.compileList(r.when," ")),r.else&&(this.append(" else "),this.visitNode(r.else)),this.append(" end"),r.isStatement&&this.append(" case")}visitWhen(r){this.append("when "),this.visitNode(r.condition),r.result&&(this.append(" then "),this.visitNode(r.result))}append(r){g(this,rn,n(this,rn)+r)}appendValue(r){this.addParameter(r),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier(r){const u=this.getLeftIdentifierWrapper(),d=this.getRightIdentifierWrapper();let b="";for(const k of r)b+=k,k===u?b+=u:k===d&&(b+=d);return b}addParameter(r){n(this,Nr).push(r)}appendImmediateValue(r){if(_(r))this.append(`'${r}'`);else if(me(r)||dn(r))this.append(r.toString());else if(Lo(r))this.append("null");else if(Hu(r))this.appendImmediateValue(r.toISOString());else if(Yu(r))this.appendImmediateValue(r.toString());else throw new Error(`invalid immediate value ${r}`)}}rn=new WeakMap,Nr=new WeakMap;const gc=a({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),bc=a({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral"}),Lr=a({raw(t){return a({sql:t,query:Te.createWithSql(t),parameters:a([])})}}),xc=/"/g;class Wc extends vc{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(e){return e.replace(xc,'""')}visitDefaultInsertValue(e){this.append("null")}}const Oc="kysely_migration",qc="kysely_migration_lock";a({__noMigrations__:!0});class Cc{constructor(e){w(this,ws);w(this,nn,void 0);g(this,nn,e)}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let r=n(this,nn).selectFrom("sqlite_schema").where("type","in",["table","view"]).where("name","not like","sqlite_%").select("name").orderBy("name").$castTo();e.withInternalKyselyTables||(r=r.where("name","!=",Oc).where("name","!=",qc));const u=await r.execute();return Promise.all(u.map(({name:d})=>X(this,ws,zu).call(this,d)))}async getMetadata(e){return{tables:await this.getTables(e)}}}nn=new WeakMap,ws=new WeakSet,zu=async function(e){var k,I,j,c,_e,Fe;const r=n(this,nn),u=await r.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),d=(Fe=(_e=(c=(j=(I=(k=u.sql)==null?void 0:k.split(/[\(\),]/))==null?void 0:I.find(P=>P.toLowerCase().includes("autoincrement")))==null?void 0:j.trimStart())==null?void 0:c.split(/\s+/))==null?void 0:_e[0])==null?void 0:Fe.replace(/["`]/g,""),b=await r.selectFrom(Je`pragma_table_info(${e})`.as("table_info")).select(["name","type","notnull","dflt_value"]).orderBy("cid").execute();return{name:e,isView:u.type==="view",columns:b.map(P=>({name:P.name,dataType:P.type,isNullable:!P.notnull,isAutoIncrementing:P.name===d,hasDefaultValue:P.dflt_value!=null}))}};class kc{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var Ic=class{createQueryCompiler(){return new Wc}createAdapter(){return new kc}createIntrospector(t){return new Cc(t)}},Ec=(Fa=class{constructor(){w(this,Kn,new Tc);Xe(this,"connection");w(this,vs,void 0)}async acquireConnection(){return await n(this,Kn).lock(),this.connection}async beginTransaction(t){await t.executeQuery(Lr.raw("begin"))}async commitTransaction(t){await t.executeQuery(Lr.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(Lr.raw("rollback"))}async releaseConnection(){n(this,Kn).unlock()}async destroy(){var t;(t=n(this,vs))==null||t.close()}},Kn=new WeakMap,vs=new WeakMap,Fa),Tc=(Qa=class{constructor(){w(this,wr,void 0);w(this,sn,void 0)}async lock(){for(;n(this,wr);)await n(this,wr);g(this,wr,new Promise(t=>{g(this,sn,t)}))}unlock(){const t=n(this,sn);g(this,wr,void 0),g(this,sn,void 0),t==null||t()}},wr=new WeakMap,sn=new WeakMap,Qa),Ac=class{streamQuery(){throw new Error("Sqlite driver doesn't support streaming")}async executeQuery(t){const{parameters:e,sql:r,query:u}=t;return Promise.resolve(u.kind==="SelectQueryNode"||u.kind==="RawNode"?{rows:await this.query(r,e)}:{rows:[],...await this.exec(r,e)})}};function Sc({func:t,delay:e,maxCalls:r}){let u,d=0,b=null;function k(){u&&clearTimeout(u),d=0,b=null}function I(){d>=r?(t(b),k()):(u&&clearTimeout(u),u=setTimeout(()=>{t(b),k(),u=void 0},e))}return j=>{d++,b=j,u===void 0&&d===0?(t(j),d++):I()}}var Dc=(Ua=class extends Ec{constructor(e){super();w(this,He,void 0);w(this,on,void 0);g(this,He,e)}async init(){var e,r,u,d;if(g(this,on,typeof n(this,He).database=="function"?await n(this,He).database():n(this,He).database),!n(this,on))throw new Error("no database");this.connection=new Rc(n(this,on),(e=n(this,He).onWrite)==null?void 0:e.func,(r=n(this,He).onWrite)==null?void 0:r.isThrottle,(u=n(this,He).onWrite)==null?void 0:u.maxCalls,(d=n(this,He).onWrite)==null?void 0:d.delay),n(this,He).onCreateConnection&&await n(this,He).onCreateConnection(this.connection)}async beginTransaction(e){await e.executeQuery(Lr.raw("begin")),this.connection&&this.connection.transactionNum++}async commitTransaction(e){await e.executeQuery(Lr.raw("commit")),this.connection&&this.connection.transactionNum--}async rollbackTransaction(e){await e.executeQuery(Lr.raw("rollback")),this.connection&&this.connection.transactionNum--}},He=new WeakMap,on=new WeakMap,Ua),Rc=(Va=class extends Ac{constructor(e,r,u=!1,d=1e3,b=2e3){super();w(this,Ht,void 0);w(this,an,void 0);Xe(this,"transactionNum",0);g(this,Ht,e),g(this,an,r?u?Sc({func:r,maxCalls:d,delay:b}):r:void 0)}query(e,r){const u=n(this,Ht).prepare(e);u.bind(r);const d=[];for(;u.step();)d.push(u.getAsObject());return u.free(),d}exec(e,r){n(this,Ht).run(e,r);const u=BigInt(this.query("SELECT last_insert_rowid() as id")[0].id),d=BigInt(n(this,Ht).getRowsModified());return this.transactionNum===0&&n(this,an)&&n(this,an).call(this,n(this,Ht).export()),{numAffectedRows:d,insertId:u}}},Ht=new WeakMap,an=new WeakMap,Va),Lc=(ja=class extends Ic{constructor(e){super();w(this,zn,void 0);g(this,zn,e)}createDriver(){return new Dc(n(this,zn))}},zn=new WeakMap,ja);function Bc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Mc(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function u(){if(this instanceof u){var d=[null];d.push.apply(d,arguments);var b=Function.bind.apply(e,d);return new b}return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(u){var d=Object.getOwnPropertyDescriptor(t,u);Object.defineProperty(r,u,d.get?d:{enumerable:!0,get:function(){return t[u]}})}),r}var Ma={exports:{}},Pc={},_c=Object.freeze({__proto__:null,default:Pc}),es=Mc(_c);(function(t,e){var r=void 0,u=function(d){return r||(r=new Promise(function(b,k){var I=typeof d<"u"?d:{},j=I.onAbort;I.onAbort=function(i){k(new Error(i)),j&&j(i)},I.postRun=I.postRun||[],I.postRun.push(function(){b(I)}),t=void 0;var c;c||(c=typeof I<"u"?I:{}),c.onRuntimeInitialized=function(){function i(f,v){switch(typeof v){case"boolean":Gl(f,v?1:0);break;case"number":jl(f,v);break;case"string":$l(f,v,-1,-1);break;case"object":if(v===null)_u(f);else if(v.length!=null){var O=Io(v);Jl(f,O,v.length,-1),Ds(O)}else Ls(f,"Wrong API use : tried to return a value of an unknown type ("+v+").",-1);break;default:_u(f)}}function s(f,v){for(var O=[],E=0;E>>0),f!=null){var v=this.filename,O="/",E=v;if(O&&(O=typeof O=="string"?O:ii(O),E=v?Bt(O+"/"+v):O),v=Cu(!0,!0),E=qs(E,(v!==void 0?v:438)&4095|32768,0),f){if(typeof f=="string"){O=Array(f.length);for(var M=0,$=f.length;M<$;++M)O[M]=f.charCodeAt(M);f=O}ks(E,v|146),O=ln(E,577),Wu(O,f,0,f.length,0),go(O),ks(E,v)}}this.handleError(A(this.filename,p)),this.db=Lt(p,"i32"),Kl(this.db),this.Za={},this.Na={}}var p=nr(4),y=c.cwrap,A=y("sqlite3_open","number",["string","number"]),V=y("sqlite3_close_v2","number",["number"]),F=y("sqlite3_exec","number",["number","string","number","number","number"]),pe=y("sqlite3_changes","number",["number"]),Mt=y("sqlite3_prepare_v2","number",["number","string","number","number","number"]),Ru=y("sqlite3_sql","string",["number"]),xl=y("sqlite3_normalized_sql","string",["number"]),Lu=y("sqlite3_prepare_v2","number",["number","number","number","number","number"]),Wl=y("sqlite3_bind_text","number",["number","number","number","number","number"]),Bu=y("sqlite3_bind_blob","number",["number","number","number","number","number"]),Ol=y("sqlite3_bind_double","number",["number","number","number"]),ql=y("sqlite3_bind_int","number",["number","number","number"]),Cl=y("sqlite3_bind_parameter_index","number",["number","string"]),kl=y("sqlite3_step","number",["number"]),Il=y("sqlite3_errmsg","string",["number"]),El=y("sqlite3_column_count","number",["number"]),Tl=y("sqlite3_data_count","number",["number"]),Al=y("sqlite3_column_double","number",["number","number"]),Mu=y("sqlite3_column_text","string",["number","number"]),Sl=y("sqlite3_column_blob","number",["number","number"]),Dl=y("sqlite3_column_bytes","number",["number","number"]),Rl=y("sqlite3_column_type","number",["number","number"]),Ll=y("sqlite3_column_name","string",["number","number"]),Bl=y("sqlite3_reset","number",["number"]),Ml=y("sqlite3_clear_bindings","number",["number"]),Pl=y("sqlite3_finalize","number",["number"]),Pu=y("sqlite3_create_function_v2","number","number string number number number number number number number".split(" ")),_l=y("sqlite3_value_type","number",["number"]),Fl=y("sqlite3_value_bytes","number",["number"]),Ql=y("sqlite3_value_text","string",["number"]),Ul=y("sqlite3_value_blob","number",["number"]),Vl=y("sqlite3_value_double","number",["number"]),jl=y("sqlite3_result_double","",["number","number"]),_u=y("sqlite3_result_null","",["number"]),$l=y("sqlite3_result_text","",["number","string","number","number"]),Jl=y("sqlite3_result_blob","",["number","number","number","number"]),Gl=y("sqlite3_result_int","",["number","number"]),Ls=y("sqlite3_result_error","",["number","string","number"]),Fu=y("sqlite3_aggregate_context","number",["number","number"]),Kl=y("RegisterExtensionFunctions","number",["number"]);o.prototype.bind=function(f){if(!this.La)throw"Statement closed";return this.reset(),Array.isArray(f)?this.xb(f):f!=null&&typeof f=="object"?this.yb(f):!0},o.prototype.step=function(){if(!this.La)throw"Statement closed";this.Ja=1;var f=kl(this.La);switch(f){case 100:return!0;case 101:return!1;default:throw this.db.handleError(f)}},o.prototype.sb=function(f){return f==null&&(f=this.Ja,this.Ja+=1),Al(this.La,f)},o.prototype.Cb=function(f){if(f==null&&(f=this.Ja,this.Ja+=1),f=Mu(this.La,f),typeof BigInt!="function")throw Error("BigInt is not supported");return BigInt(f)},o.prototype.Db=function(f){return f==null&&(f=this.Ja,this.Ja+=1),Mu(this.La,f)},o.prototype.getBlob=function(f){f==null&&(f=this.Ja,this.Ja+=1);var v=Dl(this.La,f);f=Sl(this.La,f);for(var O=new Uint8Array(v),E=0;E{bs||(gs=es,bs=es)},Zn=function(i,s){return ao(),i=bs.normalize(i),gs.readFileSync(i,s?void 0:"utf8")},yt=i=>(i=Zn(i,!0),i.buffer||(i=new Uint8Array(i)),i),Rt=(i,s,o)=>{ao(),i=bs.normalize(i),gs.readFile(i,function(h,l){h?o(h):s(l.buffer)})},1{var s=new XMLHttpRequest;return s.open("GET",i,!1),s.send(null),s.responseText},Re&&(yt=i=>{var s=new XMLHttpRequest;return s.open("GET",i,!1),s.responseType="arraybuffer",s.send(null),new Uint8Array(s.response)}),Rt=(i,s,o)=>{var h=new XMLHttpRequest;h.open("GET",i,!0),h.responseType="arraybuffer",h.onload=()=>{h.status==200||h.status==0&&h.response?s(h.response):o()},h.onerror=o,h.send(null)});var Ka=c.print||console.log.bind(console),gr=c.printErr||console.warn.bind(console);Object.assign(c,_e),_e=null,c.thisProgram&&(Fe=c.thisProgram);var ei;c.wasmBinary&&(ei=c.wasmBinary),c.noExitRuntime,typeof WebAssembly!="object"&&Zt("no native wasm support detected");var uo,za=!1,Ha=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function ti(i,s,o){var h=s+o;for(o=s;i[o]&&!(o>=h);)++o;if(16l?h+=String.fromCharCode(l):(l-=65536,h+=String.fromCharCode(55296|l>>10,56320|l&1023))}}else h+=String.fromCharCode(l)}return h}function We(i,s){return i?ti(qt,i,s):""}function br(i,s,o,h){if(!(0=y){var A=i.charCodeAt(++p);y=65536+((y&1023)<<10)|A&1023}if(127>=y){if(o>=h)break;s[o++]=y}else{if(2047>=y){if(o+1>=h)break;s[o++]=192|y>>6}else{if(65535>=y){if(o+2>=h)break;s[o++]=224|y>>12}else{if(o+3>=h)break;s[o++]=240|y>>18,s[o++]=128|y>>12&63}s[o++]=128|y>>6&63}s[o++]=128|y&63}}return s[o]=0,o-l}function hn(i){for(var s=0,o=0;o=h?s++:2047>=h?s+=2:55296<=h&&57343>=h?(s+=4,++o):s+=3}return s}var ho,we,qt,xs,T,de,co,lo;function Ya(){var i=uo.buffer;ho=i,c.HEAP8=we=new Int8Array(i),c.HEAP16=xs=new Int16Array(i),c.HEAP32=T=new Int32Array(i),c.HEAPU8=qt=new Uint8Array(i),c.HEAPU16=new Uint16Array(i),c.HEAPU32=de=new Uint32Array(i),c.HEAPF32=co=new Float32Array(i),c.HEAPF64=lo=new Float64Array(i)}var Xt,Xa=[],Za=[],eu=[];function al(){var i=c.preRun.shift();Xa.unshift(i)}var xr=0,ri=null;function Zt(i){throw c.onAbort&&c.onAbort(i),i="Aborted("+i+")",gr(i),za=!0,new WebAssembly.RuntimeError(i+". Build with -sASSERTIONS for more info.")}function tu(){return it.startsWith("data:application/octet-stream;base64,")}var it;if(it="sql-wasm.wasm",!tu()){var ru=it;it=c.locateFile?c.locateFile(ru,Ee):Ee+ru}function nu(){var i=it;try{if(i==it&&ei)return new Uint8Array(ei);if(yt)return yt(i);throw"both async and sync fetching of the wasm failed"}catch(s){Zt(s)}}function ul(){if(!ei&&(P||Re)){if(typeof fetch=="function"&&!it.startsWith("file://"))return fetch(it,{credentials:"same-origin"}).then(function(i){if(!i.ok)throw"failed to load wasm binary file at '"+it+"'";return i.arrayBuffer()}).catch(function(){return nu()});if(Rt)return new Promise(function(i,s){Rt(it,function(o){i(new Uint8Array(o))},s)})}return Promise.resolve().then(function(){return nu()})}var S,fe;function fo(i){for(;0>0];case"i8":return we[i>>0];case"i16":return xs[i>>1];case"i32":return T[i>>2];case"i64":return T[i>>2];case"float":return co[i>>2];case"double":return lo[i>>3];case"*":return de[i>>2];default:Zt("invalid type for getValue: "+s)}return null}function ni(i){var s="i32";switch(s.endsWith("*")&&(s="*"),s){case"i1":we[i>>0]=0;break;case"i8":we[i>>0]=0;break;case"i16":xs[i>>1]=0;break;case"i32":T[i>>2]=0;break;case"i64":fe=[0,(S=0,1<=+Math.abs(S)?0>>0:~~+Math.ceil((S-+(~~S>>>0))/4294967296)>>>0:0)],T[i>>2]=fe[0],T[i+4>>2]=fe[1];break;case"float":co[i>>2]=0;break;case"double":lo[i>>3]=0;break;case"*":de[i>>2]=0;break;default:Zt("invalid type for setValue: "+s)}}var po=(i,s)=>{for(var o=0,h=i.length-1;0<=h;h--){var l=i[h];l==="."?i.splice(h,1):l===".."?(i.splice(h,1),o++):o&&(i.splice(h,1),o--)}if(s)for(;o;o--)i.unshift("..");return i},Bt=i=>{var s=i.charAt(0)==="/",o=i.substr(-1)==="/";return(i=po(i.split("/").filter(h=>!!h),!s).join("/"))||s||(i="."),i&&o&&(i+="/"),(s?"/":"")+i},hl=i=>{var s=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(i).slice(1);return i=s[0],s=s[1],!i&&!s?".":(s&&(s=s.substr(0,s.length-1)),i+s)},Ws=i=>{if(i==="/")return"/";i=Bt(i),i=i.replace(/\/$/,"");var s=i.lastIndexOf("/");return s===-1?i:i.substr(s+1)};function cl(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var i=new Uint8Array(1);return()=>(crypto.getRandomValues(i),i[0])}if(Y)try{var s=es;return()=>s.randomBytes(1)[0]}catch{}return()=>Zt("randomDevice")}function Os(){for(var i="",s=!1,o=arguments.length-1;-1<=o&&!s;o--){if(s=0<=o?arguments[o]:"/",typeof s!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!s)return"";i=s+"/"+i,s=s.charAt(0)==="/"}return i=po(i.split("/").filter(h=>!!h),!s).join("/"),(s?"/":"")+i||"."}function iu(i,s){var o=Array(hn(i)+1);return i=br(i,o,0,o.length),s&&(o.length=i),o}var su=[];function ou(i,s){su[i]={input:[],output:[],Xa:s},wo(i,ll)}var ll={open:function(i){var s=su[i.node.rdev];if(!s)throw new N(43);i.tty=s,i.seekable=!1},close:function(i){i.tty.Xa.fsync(i.tty)},fsync:function(i){i.tty.Xa.fsync(i.tty)},read:function(i,s,o,h){if(!i.tty||!i.tty.Xa.tb)throw new N(60);for(var l=0,p=0;p_ in J?Hl(J,_,{enumerable:!0,configurable:!0,writable:!0,value:me}):J[_]=me;var Xe=(J,_,me)=>(Yl(J,typeof _!="symbol"?_+"":_,me),me),Eo=(J,_,me)=>{if(!_.has(J))throw TypeError("Cannot "+me)};var n=(J,_,me)=>(Eo(J,_,"read from private field"),me?me.call(J):_.get(J)),w=(J,_,me)=>{if(_.has(J))throw TypeError("Cannot add the same private member more than once");_ instanceof WeakSet?_.add(J):_.set(J,me)},g=(J,_,me,dn)=>(Eo(J,_,"write to private field"),dn?dn.call(J,me):_.set(J,me),me);var X=(J,_,me)=>(Eo(J,_,"access private method"),me);(function(){var se,or,Mr,Tn,An,B,Sn,oe,L,Dn,x,Rn,q,Pr,rs,_r,ar,ns,Qu,is,Uu,ur,di,Ln,To,ss,Vu,Bn,ee,Mn,Fr,Qr,cr,Pn,Ao,m,Ur,Vr,jr,$r,jt,re,Jr,Gr,Kr,zr,bt,Hr,z,lr,dt,De,Ne,ne,le,H,Ge,U,Ce,Me,Pe,cs,ae,ke,Ke,ze,xe,Yr,Wt,Ot,St,ft,Jt,Dt,pr,Vn,ls,ju,ds,$u,fs,Ju,ps,Gu,jn,So,$n,Gt,ms,Ku,Kt,mr,Ie,pt,yr,mt,Ve,en,Bs,Jn,Do,Gn,Ro,tn,zt,Ns,rn,Nr,nn,ws,zu,Kn,vs,Fa,wr,sn,Qa,He,on,Ua,Ht,an,Va,zn,ja,vr,$a,Hn,Yn,un,Ja,Yt,Xn,Ga;"use strict";function J(t){return typeof t>"u"||t===void 0}function _(t){return typeof t=="string"}function me(t){return typeof t=="number"}function dn(t){return typeof t=="boolean"}function Lo(t){return t===null}function Hu(t){return t instanceof Date}function Yu(t){return typeof t=="bigint"}function Ze(t){return typeof t=="function"}function wt(t){return typeof t=="object"&&t!==null}function a(t){return Object.freeze(t)}function fn(t){return Array.isArray(t)}function Cr(t){return t}const ye=a({is(t){return t.kind==="AlterTableNode"},create(t){return a({kind:"AlterTableNode",table:t})},cloneWithTableProps(t,e){return a({...t,...e})},cloneWithColumnAlteration(t,e){return a({...t,columnAlterations:t.columnAlterations?[...t.columnAlterations,e]:[e]})}}),ue=a({is(t){return t.kind==="IdentifierNode"},create(t){return a({kind:"IdentifierNode",name:t})}}),Pt=a({is(t){return t.kind==="CreateIndexNode"},create(t){return a({kind:"CreateIndexNode",name:ue.create(t)})},cloneWith(t,e){return a({...t,...e})},cloneWithColumns(t,e){return a({...t,columns:[...t.columns||[],...e]})}}),Bo=a({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return a({kind:"CreateSchemaNode",schema:ue.create(t),...e})},cloneWith(t,e){return a({...t,...e})}}),Xu=["preserve rows","delete rows","drop"],at=a({is(t){return t.kind==="CreateTableNode"},create(t){return a({kind:"CreateTableNode",table:t,columns:a([])})},cloneWithColumn(t,e){return a({...t,columns:a([...t.columns,e])})},cloneWithConstraint(t,e){return a({...t,constraints:t.constraints?a([...t.constraints,e]):a([e])})},cloneWithFrontModifier(t,e){return a({...t,frontModifiers:t.frontModifiers?a([...t.frontModifiers,e]):a([e])})},cloneWithEndModifier(t,e){return a({...t,endModifiers:t.endModifiers?a([...t.endModifiers,e]):a([e])})},cloneWith(t,e){return a({...t,...e})}}),_t=a({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return a({kind:"SchemableIdentifierNode",identifier:ue.create(t)})},createWithSchema(t,e){return a({kind:"SchemableIdentifierNode",schema:ue.create(t),identifier:ue.create(e)})}}),fi=a({is(t){return t.kind==="DropIndexNode"},create(t,e){return a({kind:"DropIndexNode",name:_t.create(t),...e})},cloneWith(t,e){return a({...t,...e})}}),Ms=a({is(t){return t.kind==="DropSchemaNode"},create(t,e){return a({kind:"DropSchemaNode",schema:ue.create(t),...e})},cloneWith(t,e){return a({...t,...e})}}),Ps=a({is(t){return t.kind==="DropTableNode"},create(t,e){return a({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return a({...t,...e})}}),ir=a({is(t){return t.kind==="AliasNode"},create(t,e){return a({kind:"AliasNode",node:t,alias:e})}}),Ft=a({is(t){return t.kind==="TableNode"},create(t){return a({kind:"TableNode",table:_t.create(t)})},createWithSchema(t,e){return a({kind:"TableNode",table:_t.createWithSchema(t,e)})}});function Le(t){return wt(t)&&Ze(t.toOperationNode)}function Zu(t){return wt(t)&&"expressionType"in t&&Le(t)}function eh(t){return wt(t)&&"expression"in t&&_(t.alias)&&Le(t)}const It=a({is(t){return t.kind==="SelectModifierNode"},create(t){return a({kind:"SelectModifierNode",modifier:t})},createWithExpression(t){return a({kind:"SelectModifierNode",rawModifier:t})}}),pn=a({is(t){return t.kind==="AndNode"},create(t,e){return a({kind:"AndNode",left:t,right:e})}}),mn=a({is(t){return t.kind==="OrNode"},create(t,e){return a({kind:"OrNode",left:t,right:e})}}),yn=a({is(t){return t.kind==="OnNode"},create(t){return a({kind:"OnNode",on:t})},cloneWithOperation(t,e,r){return a({...t,on:e==="And"?pn.create(t.on,r):mn.create(t.on,r)})}}),et=a({is(t){return t.kind==="JoinNode"},create(t,e){return a({kind:"JoinNode",joinType:t,table:e,on:void 0})},createWithOn(t,e,r){return a({kind:"JoinNode",joinType:t,table:e,on:yn.create(r)})},cloneWithOn(t,e){return a({...t,on:t.on?yn.cloneWithOperation(t.on,"And",e):yn.create(e)})},cloneWithOrOn(t,e){return a({...t,on:t.on?yn.cloneWithOperation(t.on,"Or",e):yn.create(e)})}}),pi=a({is(t){return t.kind==="BinaryOperationNode"},create(t,e,r){return a({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:r})}}),Te=a({is(t){return t.kind==="RawNode"},create(t,e){return a({kind:"RawNode",sqlFragments:a(t),parameters:a(e)})},createWithSql(t){return Te.create([t],[])},createWithChild(t){return Te.create(["",""],[t])},createWithChildren(t){return Te.create(new Array(t.length+1).fill(""),t)}}),Mo=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->"],th=["+","-","*","/","%","^","&","|","#","<<",">>"],Po=[...Mo,...th,"&&","||"],rh=["not","-",...["exists","not exists"]],nh=[...Po,...rh],_s=a({is(t){return t.kind==="OperatorNode"},create(t){return a({kind:"OperatorNode",operator:t})}});function _o(t){return _(t)&&Po.includes(t)}function Fo(t){return _(t)&&Mo.includes(t)}const kr=a({is(t){return t.kind==="ParensNode"},create(t){return a({kind:"ParensNode",node:t})}}),he=a({is(t){return t.kind==="ColumnNode"},create(t){return a({kind:"ColumnNode",column:ue.create(t)})}}),Fs=a({is(t){return t.kind==="SelectAllNode"},create(){return a({kind:"SelectAllNode"})}}),mi=a({is(t){return t.kind==="ReferenceNode"},create(t,e){return a({kind:"ReferenceNode",table:t,column:e})},createSelectAll(t){return a({kind:"ReferenceNode",table:t,column:Fs.create()})}}),ih=a({is(t){return t.kind==="OrderByItemNode"},create(t,e){return a({kind:"OrderByItemNode",orderBy:t,direction:e})}});function sh(t){return t==="asc"||t==="desc"}function yi(t,e){return ih.create(oh(t),ah(e))}function oh(t){return Et(t)}function ah(t){if(t)return t==="asc"||t==="desc"?Te.createWithSql(t):t.toOperationNode()}function Qo(t){return _(t)?Ir(t):t.toOperationNode()}function Nn(t){return fn(t)?t.map(e=>Et(e)):[Et(t)]}function Et(t){return Di(t)?Si(t):Qo(t)}function Ir(t){const e=".";if(t.includes(e)){const r=t.split(e).map(Qs);if(r.length===3)return hh(r);if(r.length===2)return ch(r);throw new Error(`invalid column reference ${t}`)}else return he.create(t)}function uh(t){const e=" as ";if(t.includes(e)){const[r,u]=t.split(e).map(Qs);return ir.create(Ir(r),ue.create(u))}else return Ir(t)}function Uo(t){return he.create(t)}function Vo(t){const e=" ";if(t.includes(e)){const[r,u]=t.split(e).map(Qs);if(!sh(u))throw new Error(`invalid order direction "${u}" next to "${r}"`);return yi(r,u)}else return Uo(t)}function hh(t){const[e,r,u]=t;return mi.create(Ft.createWithSchema(e,r),he.create(u))}function ch(t){const[e,r]=t;return mi.create(Ft.create(e),he.create(r))}function Qs(t){return t.trim()}const jo=a({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return a({kind:"PrimitiveValueListNode",values:a([...t])})}}),Us=a({is(t){return t.kind==="ValueListNode"},create(t){return a({kind:"ValueListNode",values:a(t)})}}),vt=a({is(t){return t.kind==="ValueNode"},create(t){return a({kind:"ValueNode",value:t})},createImmediate(t){return a({kind:"ValueNode",value:t,immediate:!0})}});function $o(t){return fn(t)?lh(t):Tt(t)}function Tt(t){return Di(t)?Si(t):vt.create(t)}function lh(t){return t.some(Di)?Us.create(t.map(e=>Tt(e))):jo.create(t)}const Er=a({is(t){return t.kind==="OrderByNode"},create(t){return a({kind:"OrderByNode",items:a([t])})},cloneWithItem(t,e){return a({...t,items:a([...t.items,e])})}}),Jo=a({is(t){return t.kind==="PartitionByNode"},create(t){return a({kind:"PartitionByNode",items:a(t)})},cloneWithItems(t,e){return a({...t,items:a([...t.items,...e])})}}),Vs=a({is(t){return t.kind==="OverNode"},create(){return a({kind:"OverNode"})},cloneWithOrderByItem(t,e){return a({...t,orderBy:t.orderBy?Er.cloneWithItem(t.orderBy,e):Er.create(e)})},cloneWithPartitionByItems(t,e){return a({...t,partitionBy:t.partitionBy?Jo.cloneWithItems(t.partitionBy,e):Jo.create(e)})}}),Ni=a({is(t){return t.kind==="FromNode"},create(t){return a({kind:"FromNode",froms:a(t)})},cloneWithFroms(t,e){return a({...t,froms:a([...t.froms,...e])})}}),Go=a({is(t){return t.kind==="GroupByNode"},create(t){return a({kind:"GroupByNode",items:a(t)})},cloneWithItems(t,e){return a({...t,items:a([...t.items,...e])})}}),wi=a({is(t){return t.kind==="HavingNode"},create(t){return a({kind:"HavingNode",having:t})},cloneWithOperation(t,e,r){return a({...t,having:e==="And"?pn.create(t.having,r):mn.create(t.having,r)})}}),D=a({is(t){return t.kind==="SelectQueryNode"},create(t,e){return a({kind:"SelectQueryNode",from:Ni.create(t),...e&&{with:e}})},cloneWithSelections(t,e){return a({...t,selections:t.selections?a([...t.selections,...e]):a(e)})},cloneWithDistinctOn(t,e){return a({...t,distinctOn:t.distinctOn?a([...t.distinctOn,...e]):a(e)})},cloneWithFrontModifier(t,e){return a({...t,frontModifiers:t.frontModifiers?a([...t.frontModifiers,e]):a([e])})},cloneWithEndModifier(t,e){return a({...t,endModifiers:t.endModifiers?a([...t.endModifiers,e]):a([e])})},cloneWithOrderByItem(t,e){return a({...t,orderBy:t.orderBy?Er.cloneWithItem(t.orderBy,e):Er.create(e)})},cloneWithGroupByItems(t,e){return a({...t,groupBy:t.groupBy?Go.cloneWithItems(t.groupBy,e):Go.create(e)})},cloneWithLimit(t,e){return a({...t,limit:e})},cloneWithOffset(t,e){return a({...t,offset:e})},cloneWithHaving(t,e){return a({...t,having:t.having?wi.cloneWithOperation(t.having,"And",e):wi.create(e)})},cloneWithOrHaving(t,e){return a({...t,having:t.having?wi.cloneWithOperation(t.having,"Or",e):wi.create(e)})},cloneWithSetOperation(t,e){return a({...t,setOperations:t.setOperations?a([...t.setOperations,e]):a([e])})},cloneWithoutSelections(t){return a({...t,selections:[]})},cloneWithoutLimit(t){return a({...t,limit:void 0})},cloneWithoutOffset(t){return a({...t,offset:void 0})},cloneWithoutOrderBy(t){return a({...t,orderBy:void 0})}}),Ko=a({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return a({kind:"UnaryOperationNode",operator:t,operand:e})}});function Ae(t){return js("exists",t)}function Oe(t){return js("not exists",t)}function js(t,e){return Ko.create(_s.create(t),Et(e))}function Q(t,e){Object.defineProperties(t.prototype,{then:{enumerable:!1,value:()=>{throw new Error(e)}}})}const ct=class{constructor(e){w(this,se,void 0);g(this,se,a(e))}on(...e){return new ct({...n(this,se),joinNode:et.cloneWithOn(n(this,se).joinNode,fa(e))})}orOn(...e){return new ct({...n(this,se),joinNode:et.cloneWithOrOn(n(this,se).joinNode,fa(e))})}onRef(e,r,u){return new ct({...n(this,se),joinNode:et.cloneWithOn(n(this,se).joinNode,qe(e,r,u))})}orOnRef(e,r,u){return new ct({...n(this,se),joinNode:et.cloneWithOrOn(n(this,se).joinNode,qe(e,r,u))})}onExists(e){return new ct({...n(this,se),joinNode:et.cloneWithOn(n(this,se).joinNode,Ae(e))})}onNotExists(e){return new ct({...n(this,se),joinNode:et.cloneWithOn(n(this,se).joinNode,Oe(e))})}orOnExists(e){return new ct({...n(this,se),joinNode:et.cloneWithOrOn(n(this,se).joinNode,Ae(e))})}orOnNotExists(e){return new ct({...n(this,se),joinNode:et.cloneWithOrOn(n(this,se).joinNode,Oe(e))})}onTrue(){return new ct({...n(this,se),joinNode:et.cloneWithOn(n(this,se).joinNode,Te.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return n(this,se).joinNode}};let vi=ct;se=new WeakMap,Q(vi,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const dh=a({is(t){return t.kind==="PartitionByItemNode"},create(t){return a({kind:"PartitionByItemNode",partitionBy:t})}});function fh(t){return Nn(t).map(dh.create)}const ts=class{constructor(e){w(this,or,void 0);g(this,or,a(e))}orderBy(e,r){return new ts({overNode:Vs.cloneWithOrderByItem(n(this,or).overNode,yi(e,r))})}partitionBy(e){return new ts({overNode:Vs.cloneWithPartitionByItems(n(this,or).overNode,fh(e))})}$call(e){return e(this)}toOperationNode(){return n(this,or).overNode}};let gi=ts;or=new WeakMap,Q(gi,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");const wn=a({is(t){return t.kind==="SelectionNode"},create(t){return a({kind:"SelectionNode",selection:t})},createSelectAll(){return a({kind:"SelectionNode",selection:Fs.create()})},createSelectAllFromTable(t){return a({kind:"SelectionNode",selection:mi.createSelectAll(t)})}});class ph{constructor(e){w(this,Mr,void 0);g(this,Mr,e)}get dynamicReference(){return n(this,Mr)}get refType(){}toOperationNode(){return Qo(n(this,Mr))}}Mr=new WeakMap;function mh(t){return wt(t)&&Le(t)&&_(t.dynamicReference)}function vn(t){return Ze(t)?vn(t(At())):fn(t)?t.map(e=>zo(e)):[zo(t)]}function zo(t){return _(t)?wn.create(uh(t)):mh(t)?wn.create(t.toOperationNode()):wn.create(ba(t))}function gn(t){return t?Array.isArray(t)?t.map(Ho):[Ho(t)]:[wn.createSelectAll()]}function Ho(t){if(_(t))return wn.createSelectAllFromTable(Ue(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const yh=a({is(t){return t.kind==="ValuesNode"},create(t){return a({kind:"ValuesNode",values:a(t)})}}),Nh=a({is(t){return t.kind==="DefaultInsertValueNode"},create(){return a({kind:"DefaultInsertValueNode"})}});function wh(t){const e=Ze(t)?t(At()):t,r=fn(e)?e:a([e]);return vh(r)}function vh(t){const e=gh(t);return[a([...e.keys()].map(he.create)),yh.create(t.map(r=>bh(r,e)))]}function gh(t){const e=new Map;for(const r of t){const u=Object.keys(r);for(const d of u)!e.has(d)&&r[d]!==void 0&&e.set(d,e.size)}return e}function bh(t,e){const r=Object.keys(t),u=Array.from({length:e.size});let d=!1;for(const k of r){const I=e.get(k);if(J(I))continue;const j=t[k];(J(j)||Di(j))&&(d=!0),u[I]=j}if(r.lengthJ(I)?k:Tt(I)))}return jo.create(u)}const gt=a({is(t){return t.kind==="InsertQueryNode"},create(t,e,r){return a({kind:"InsertQueryNode",into:t,...e&&{with:e},replace:r})},cloneWith(t,e){return a({...t,...e})}}),bi=a({is(t){return t.kind==="UpdateQueryNode"},create(t,e){return a({kind:"UpdateQueryNode",table:t,...e&&{with:e}})},cloneWithFromItems(t,e){return a({...t,from:t.from?Ni.cloneWithFroms(t.from,e):Ni.create(e)})},cloneWithUpdates(t,e){return a({...t,updates:t.updates?a([...t.updates,...e]):e})}}),Yo=a({is(t){return t.kind==="UsingNode"},create(t){return a({kind:"UsingNode",tables:a(t)})},cloneWithTables(t,e){return a({...t,tables:a([...t.tables,...e])})}}),bn=a({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return a({kind:"DeleteQueryNode",from:Ni.create(t),...e&&{with:e}})},cloneWithOrderByItem(t,e){return a({...t,orderBy:t.orderBy?Er.cloneWithItem(t.orderBy,e):Er.create(e)})},cloneWithLimit(t,e){return a({...t,limit:e})},cloneWithUsing(t,e){return a({...t,using:t.using!==void 0?Yo.cloneWithTables(t.using,e):Yo.create(e)})}}),Se=a({is(t){return t.kind==="WhereNode"},create(t){return a({kind:"WhereNode",where:t})},cloneWithOperation(t,e,r){return a({...t,where:e==="And"?pn.create(t.where,r):mn.create(t.where,r)})}}),Xo=a({is(t){return t.kind==="ReturningNode"},create(t){return a({kind:"ReturningNode",selections:a(t)})},cloneWithSelections(t,e){return a({...t,selections:t.selections?a([...t.selections,...e]):a(e)})}}),xh=a({is(t){return t.kind==="ExplainNode"},create(t,e){return a({kind:"ExplainNode",format:t,options:e})}}),C=a({is(t){return D.is(t)||gt.is(t)||bi.is(t)||bn.is(t)},cloneWithWhere(t,e){return a({...t,where:t.where?Se.cloneWithOperation(t.where,"And",e):Se.create(e)})},cloneWithOrWhere(t,e){return a({...t,where:t.where?Se.cloneWithOperation(t.where,"Or",e):Se.create(e)})},cloneWithJoin(t,e){return a({...t,joins:t.joins?a([...t.joins,e]):a([e])})},cloneWithReturning(t,e){return a({...t,returning:t.returning?Xo.cloneWithSelections(t.returning,e):Xo.create(e)})},cloneWithoutWhere(t){return a({...t,where:void 0})},cloneWithExplain(t,e,r){return a({...t,explain:xh.create(e,r==null?void 0:r.toOperationNode())})}}),Wh=a({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return a({kind:"ColumnUpdateNode",column:t,value:e})}});function $s(t){const e=Ze(t)?t(At()):t;return Object.entries(e).filter(([r,u])=>u!==void 0).map(([r,u])=>Wh.create(he.create(r),Tt(u)))}const Oh=a({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return a({kind:"OnDuplicateKeyNode",updates:t})}});class Zo{constructor(e,r){w(this,Tn,void 0);w(this,An,void 0);g(this,Tn,e),g(this,An,r)}get insertId(){return n(this,Tn)}get numInsertedOrUpdatedRows(){return n(this,An)}}Tn=new WeakMap,An=new WeakMap;for(const t of["insertId","numInsertedOrUpdatedRows"])Object.defineProperty(Zo.prototype,t,{enumerable:!0});class xi extends Error{constructor(r){super("no result");Xe(this,"node");this.node=r}}function Wi(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const te=a({is(t){return t.kind==="OnConflictNode"},create(){return a({kind:"OnConflictNode"})},cloneWith(t,e){return a({...t,...e})},cloneWithIndexWhere(t,e){return a({...t,indexWhere:t.indexWhere?Se.cloneWithOperation(t.indexWhere,"And",e):Se.create(e)})},cloneWithIndexOrWhere(t,e){return a({...t,indexWhere:t.indexWhere?Se.cloneWithOperation(t.indexWhere,"Or",e):Se.create(e)})},cloneWithUpdateWhere(t,e){return a({...t,updateWhere:t.updateWhere?Se.cloneWithOperation(t.updateWhere,"And",e):Se.create(e)})},cloneWithUpdateOrWhere(t,e){return a({...t,updateWhere:t.updateWhere?Se.cloneWithOperation(t.updateWhere,"Or",e):Se.create(e)})},cloneWithoutIndexWhere(t){return a({...t,indexWhere:void 0})},cloneWithoutUpdateWhere(t){return a({...t,updateWhere:void 0})}}),Be=class{constructor(e){w(this,B,void 0);g(this,B,a(e))}column(e){const r=he.create(e);return new Be({...n(this,B),onConflictNode:te.cloneWith(n(this,B).onConflictNode,{columns:n(this,B).onConflictNode.columns?a([...n(this,B).onConflictNode.columns,r]):a([r])})})}columns(e){const r=e.map(he.create);return new Be({...n(this,B),onConflictNode:te.cloneWith(n(this,B).onConflictNode,{columns:n(this,B).onConflictNode.columns?a([...n(this,B).onConflictNode.columns,...r]):a(r)})})}constraint(e){return new Be({...n(this,B),onConflictNode:te.cloneWith(n(this,B).onConflictNode,{constraint:ue.create(e)})})}expression(e){return new Be({...n(this,B),onConflictNode:te.cloneWith(n(this,B).onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexWhere(n(this,B).onConflictNode,$e(e))})}whereRef(e,r,u){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexWhere(n(this,B).onConflictNode,qe(e,r,u))})}orWhere(...e){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexOrWhere(n(this,B).onConflictNode,$e(e))})}orWhereRef(e,r,u){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexOrWhere(n(this,B).onConflictNode,qe(e,r,u))})}whereExists(e){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexWhere(n(this,B).onConflictNode,Ae(e))})}whereNotExists(e){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexWhere(n(this,B).onConflictNode,Oe(e))})}orWhereExists(e){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexOrWhere(n(this,B).onConflictNode,Ae(e))})}orWhereNotExists(e){return new Be({...n(this,B),onConflictNode:te.cloneWithIndexOrWhere(n(this,B).onConflictNode,Oe(e))})}clearWhere(){return new Be({...n(this,B),onConflictNode:te.cloneWithoutIndexWhere(n(this,B).onConflictNode)})}doNothing(){return new ea({...n(this,B),onConflictNode:te.cloneWith(n(this,B).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new qi({...n(this,B),onConflictNode:te.cloneWith(n(this,B).onConflictNode,{updates:$s(e)})})}$call(e){return e(this)}};let Oi=Be;B=new WeakMap,Q(Oi,"don't await OnConflictBuilder instances.");class ea{constructor(e){w(this,Sn,void 0);g(this,Sn,a(e))}toOperationNode(){return n(this,Sn).onConflictNode}}Sn=new WeakMap,Q(ea,"don't await OnConflictDoNothingBuilder instances.");const lt=class{constructor(e){w(this,oe,void 0);g(this,oe,a(e))}where(...e){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateWhere(n(this,oe).onConflictNode,$e(e))})}whereRef(e,r,u){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateWhere(n(this,oe).onConflictNode,qe(e,r,u))})}orWhere(...e){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateOrWhere(n(this,oe).onConflictNode,$e(e))})}orWhereRef(e,r,u){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateOrWhere(n(this,oe).onConflictNode,qe(e,r,u))})}whereExists(e){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateWhere(n(this,oe).onConflictNode,Ae(e))})}whereNotExists(e){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateWhere(n(this,oe).onConflictNode,Oe(e))})}orWhereExists(e){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateOrWhere(n(this,oe).onConflictNode,Ae(e))})}orWhereNotExists(e){return new lt({...n(this,oe),onConflictNode:te.cloneWithUpdateOrWhere(n(this,oe).onConflictNode,Oe(e))})}clearWhere(){return new lt({...n(this,oe),onConflictNode:te.cloneWithoutUpdateWhere(n(this,oe).onConflictNode)})}$call(e){return e(this)}toOperationNode(){return n(this,oe).onConflictNode}};let qi=lt;oe=new WeakMap,Q(qi,"don't await OnConflictUpdateBuilder instances.");const ge=class{constructor(e){w(this,L,void 0);g(this,L,a(e))}values(e){const[r,u]=wh(e);return new ge({...n(this,L),queryNode:gt.cloneWith(n(this,L).queryNode,{columns:r,values:u})})}columns(e){return new ge({...n(this,L),queryNode:gt.cloneWith(n(this,L).queryNode,{columns:a(e.map(he.create))})})}expression(e){return new ge({...n(this,L),queryNode:gt.cloneWith(n(this,L).queryNode,{values:Si(e)})})}ignore(){return new ge({...n(this,L),queryNode:gt.cloneWith(n(this,L).queryNode,{ignore:!0})})}onConflict(e){return new ge({...n(this,L),queryNode:gt.cloneWith(n(this,L).queryNode,{onConflict:e(new Oi({onConflictNode:te.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new ge({...n(this,L),queryNode:gt.cloneWith(n(this,L).queryNode,{onDuplicateKey:Oh.create($s(e))})})}returning(e){return new ge({...n(this,L),queryNode:C.cloneWithReturning(n(this,L).queryNode,vn(e))})}returningAll(){return new ge({...n(this,L),queryNode:C.cloneWithReturning(n(this,L).queryNode,gn())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new ge({...n(this,L)})}if(e,r){return e?r(this):new ge({...n(this,L)})}$castTo(){return new ge(n(this,L))}castTo(){return this.$castTo()}$narrowType(){return new ge(n(this,L))}$assertType(){return new ge(n(this,L))}assertType(){return new ge(n(this,L))}withPlugin(e){return new ge({...n(this,L),executor:n(this,L).executor.withPlugin(e)})}toOperationNode(){return n(this,L).executor.transformQuery(n(this,L).queryNode,n(this,L).queryId)}compile(){return n(this,L).executor.compileQuery(this.toOperationNode(),n(this,L).queryId)}async execute(){const e=this.compile(),r=e.query,u=await n(this,L).executor.executeQuery(e,n(this,L).queryId);return n(this,L).executor.adapter.supportsReturning&&r.returning?u.rows:[new Zo(u.insertId,u.numAffectedRows??u.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=xi){const r=await this.executeTakeFirst();if(r===void 0)throw Wi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=n(this,L).executor.stream(r,e,n(this,L).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new ge({...n(this,L),queryNode:C.cloneWithExplain(n(this,L).queryNode,e,r)}).execute()}};let xn=ge;L=new WeakMap,Q(xn,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class ta{constructor(e){w(this,Dn,void 0);g(this,Dn,e)}get numDeletedRows(){return n(this,Dn)}}Dn=new WeakMap,Object.defineProperty(ta.prototype,"numDeletedRows",{enumerable:!0});const ra=a({is(t){return t.kind==="LimitNode"},create(t){return a({kind:"LimitNode",limit:vt.create(t)})}}),K=class{constructor(e){w(this,x,void 0);g(this,x,a(e))}where(...e){return new K({...n(this,x),queryNode:C.cloneWithWhere(n(this,x).queryNode,$e(e))})}whereRef(e,r,u){return new K({...n(this,x),queryNode:C.cloneWithWhere(n(this,x).queryNode,qe(e,r,u))})}orWhere(...e){return new K({...n(this,x),queryNode:C.cloneWithOrWhere(n(this,x).queryNode,$e(e))})}orWhereRef(e,r,u){return new K({...n(this,x),queryNode:C.cloneWithOrWhere(n(this,x).queryNode,qe(e,r,u))})}whereExists(e){return new K({...n(this,x),queryNode:C.cloneWithWhere(n(this,x).queryNode,Ae(e))})}whereNotExists(e){return new K({...n(this,x),queryNode:C.cloneWithWhere(n(this,x).queryNode,Oe(e))})}orWhereExists(e){return new K({...n(this,x),queryNode:C.cloneWithOrWhere(n(this,x).queryNode,Ae(e))})}orWhereNotExists(e){return new K({...n(this,x),queryNode:C.cloneWithOrWhere(n(this,x).queryNode,Oe(e))})}clearWhere(){return new K({...n(this,x),queryNode:C.cloneWithoutWhere(n(this,x).queryNode)})}using(e){return new K({...n(this,x),queryNode:bn.cloneWithUsing(n(this,x).queryNode,Dr(e))})}innerJoin(...e){return new K({...n(this,x),queryNode:C.cloneWithJoin(n(this,x).queryNode,Qe("InnerJoin",e))})}leftJoin(...e){return new K({...n(this,x),queryNode:C.cloneWithJoin(n(this,x).queryNode,Qe("LeftJoin",e))})}rightJoin(...e){return new K({...n(this,x),queryNode:C.cloneWithJoin(n(this,x).queryNode,Qe("RightJoin",e))})}fullJoin(...e){return new K({...n(this,x),queryNode:C.cloneWithJoin(n(this,x).queryNode,Qe("FullJoin",e))})}returning(e){return new K({...n(this,x),queryNode:C.cloneWithReturning(n(this,x).queryNode,vn(e))})}returningAll(e){return new K({...n(this,x),queryNode:C.cloneWithReturning(n(this,x).queryNode,gn(e))})}orderBy(e,r){return new K({...n(this,x),queryNode:bn.cloneWithOrderByItem(n(this,x).queryNode,yi(e,r))})}limit(e){return new K({...n(this,x),queryNode:bn.cloneWithLimit(n(this,x).queryNode,ra.create(e))})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new K({...n(this,x)})}if(e,r){return this.$if(e,r)}$castTo(){return new K(n(this,x))}castTo(){return this.$castTo()}$narrowType(){return new K(n(this,x))}$assertType(){return new K(n(this,x))}assertType(){return new K(n(this,x))}withPlugin(e){return new K({...n(this,x),executor:n(this,x).executor.withPlugin(e)})}toOperationNode(){return n(this,x).executor.transformQuery(n(this,x).queryNode,n(this,x).queryId)}compile(){return n(this,x).executor.compileQuery(this.toOperationNode(),n(this,x).queryId)}async execute(){const e=this.compile(),r=e.query,u=await n(this,x).executor.executeQuery(e,n(this,x).queryId);return n(this,x).executor.adapter.supportsReturning&&r.returning?u.rows:[new ta(u.numAffectedRows??u.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=xi){const r=await this.executeTakeFirst();if(r===void 0)throw Wi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=n(this,x).executor.stream(r,e,n(this,x).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new K({...n(this,x),queryNode:C.cloneWithExplain(n(this,x).queryNode,e,r)}).execute()}};let Ci=K;x=new WeakMap,Q(Ci,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class na{constructor(e){w(this,Rn,void 0);g(this,Rn,e)}get numUpdatedRows(){return n(this,Rn)}}Rn=new WeakMap,Object.defineProperty(na.prototype,"numUpdatedRows",{enumerable:!0});const Z=class{constructor(e){w(this,q,void 0);g(this,q,a(e))}where(...e){return new Z({...n(this,q),queryNode:C.cloneWithWhere(n(this,q).queryNode,$e(e))})}whereRef(e,r,u){return new Z({...n(this,q),queryNode:C.cloneWithWhere(n(this,q).queryNode,qe(e,r,u))})}orWhere(...e){return new Z({...n(this,q),queryNode:C.cloneWithOrWhere(n(this,q).queryNode,$e(e))})}orWhereRef(e,r,u){return new Z({...n(this,q),queryNode:C.cloneWithOrWhere(n(this,q).queryNode,qe(e,r,u))})}whereExists(e){return new Z({...n(this,q),queryNode:C.cloneWithWhere(n(this,q).queryNode,Ae(e))})}whereNotExists(e){return new Z({...n(this,q),queryNode:C.cloneWithWhere(n(this,q).queryNode,Oe(e))})}orWhereExists(e){return new Z({...n(this,q),queryNode:C.cloneWithOrWhere(n(this,q).queryNode,Ae(e))})}orWhereNotExists(e){return new Z({...n(this,q),queryNode:C.cloneWithOrWhere(n(this,q).queryNode,Oe(e))})}clearWhere(){return new Z({...n(this,q),queryNode:C.cloneWithoutWhere(n(this,q).queryNode)})}from(e){return new Z({...n(this,q),queryNode:bi.cloneWithFromItems(n(this,q).queryNode,Dr(e))})}innerJoin(...e){return new Z({...n(this,q),queryNode:C.cloneWithJoin(n(this,q).queryNode,Qe("InnerJoin",e))})}leftJoin(...e){return new Z({...n(this,q),queryNode:C.cloneWithJoin(n(this,q).queryNode,Qe("LeftJoin",e))})}rightJoin(...e){return new Z({...n(this,q),queryNode:C.cloneWithJoin(n(this,q).queryNode,Qe("RightJoin",e))})}fullJoin(...e){return new Z({...n(this,q),queryNode:C.cloneWithJoin(n(this,q).queryNode,Qe("FullJoin",e))})}set(e){return new Z({...n(this,q),queryNode:bi.cloneWithUpdates(n(this,q).queryNode,$s(e))})}returning(e){return new Z({...n(this,q),queryNode:C.cloneWithReturning(n(this,q).queryNode,vn(e))})}returningAll(){return new Z({...n(this,q),queryNode:C.cloneWithReturning(n(this,q).queryNode,gn())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new Z({...n(this,q)})}if(e,r){return this.$if(e,r)}$castTo(){return new Z(n(this,q))}castTo(){return this.$castTo()}$narrowType(){return new Z(n(this,q))}$assertType(){return new Z(n(this,q))}assertType(){return new Z(n(this,q))}withPlugin(e){return new Z({...n(this,q),executor:n(this,q).executor.withPlugin(e)})}toOperationNode(){return n(this,q).executor.transformQuery(n(this,q).queryNode,n(this,q).queryId)}compile(){return n(this,q).executor.compileQuery(this.toOperationNode(),n(this,q).queryId)}async execute(){const e=this.compile(),r=e.query,u=await n(this,q).executor.executeQuery(e,n(this,q).queryId);return n(this,q).executor.adapter.supportsReturning&&r.returning?u.rows:[new na(u.numAffectedRows??u.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=xi){const r=await this.executeTakeFirst();if(r===void 0)throw Wi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=n(this,q).executor.stream(r,e,n(this,q).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new Z({...n(this,q),queryNode:C.cloneWithExplain(n(this,q).queryNode,e,r)}).execute()}};let ki=Z;q=new WeakMap,Q(ki,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");const qh=a({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return a({kind:"CommonTableExpressionNode",name:t,expression:e})}}),ia=a({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return a({kind:"CommonTableExpressionNameNode",table:Ft.create(t),columns:e?a(e.map(he.create)):void 0})}});function sa(t,e){const r=e(Lh());return qh.create(Ch(t),r.toOperationNode())}function Ch(t){if(t.includes("(")){const e=t.split(/[\(\)]/),r=e[0],u=e[1].split(",").map(d=>d.trim());return ia.create(r,u)}else return ia.create(t)}const Ii=a({is(t){return t.kind==="WithNode"},create(t,e){return a({kind:"WithNode",expressions:a([t]),...e})},cloneWithExpression(t,e){return a({...t,expressions:a([...t.expressions,e])})}}),oa=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function kh(t){let e="";for(let r=0;rthis.transformNode(r)))}transformSelectQuery(e){return{kind:"SelectQueryNode",from:this.transformNode(e.from),selections:this.transformNodeList(e.selections),distinctOn:this.transformNodeList(e.distinctOn),joins:this.transformNodeList(e.joins),groupBy:this.transformNode(e.groupBy),orderBy:this.transformNode(e.orderBy),where:this.transformNode(e.where),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),limit:this.transformNode(e.limit),offset:this.transformNode(e.offset),with:this.transformNode(e.with),having:this.transformNode(e.having),explain:this.transformNode(e.explain),setOperations:this.transformNodeList(e.setOperations)}}transformSelection(e){return{kind:"SelectionNode",selection:this.transformNode(e.selection)}}transformColumn(e){return{kind:"ColumnNode",column:this.transformNode(e.column)}}transformAlias(e){return{kind:"AliasNode",node:this.transformNode(e.node),alias:this.transformNode(e.alias)}}transformTable(e){return{kind:"TableNode",table:this.transformNode(e.table)}}transformFrom(e){return{kind:"FromNode",froms:this.transformNodeList(e.froms)}}transformReference(e){return{kind:"ReferenceNode",table:this.transformNode(e.table),column:this.transformNode(e.column)}}transformAnd(e){return{kind:"AndNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformOr(e){return{kind:"OrNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformValueList(e){return{kind:"ValueListNode",values:this.transformNodeList(e.values)}}transformParens(e){return{kind:"ParensNode",node:this.transformNode(e.node)}}transformJoin(e){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table),on:this.transformNode(e.on)}}transformRaw(e){return{kind:"RawNode",sqlFragments:a([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters)}}transformWhere(e){return{kind:"WhereNode",where:this.transformNode(e.where)}}transformInsertQuery(e){return{kind:"InsertQueryNode",into:this.transformNode(e.into),columns:this.transformNodeList(e.columns),values:this.transformNode(e.values),returning:this.transformNode(e.returning),onConflict:this.transformNode(e.onConflict),onDuplicateKey:this.transformNode(e.onDuplicateKey),with:this.transformNode(e.with),ignore:e.ignore,replace:e.replace,explain:this.transformNode(e.explain)}}transformValues(e){return{kind:"ValuesNode",values:this.transformNodeList(e.values)}}transformDeleteQuery(e){return{kind:"DeleteQueryNode",from:this.transformNode(e.from),using:this.transformNode(e.using),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),returning:this.transformNode(e.returning),with:this.transformNode(e.with),orderBy:this.transformNode(e.orderBy),limit:this.transformNode(e.limit),explain:this.transformNode(e.explain)}}transformReturning(e){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections)}}transformCreateTable(e){return{kind:"CreateTableNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),constraints:this.transformNodeList(e.constraints),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers)}}transformColumnDefinition(e){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),references:this.transformNode(e.references),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo),check:this.transformNode(e.check),generated:this.transformNode(e.generated),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers)}}transformAddColumn(e){return{kind:"AddColumnNode",column:this.transformNode(e.column)}}transformDropTable(e){return{kind:"DropTableNode",table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e){return{kind:"OrderByNode",items:this.transformNodeList(e.items)}}transformOrderByItem(e){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy),direction:this.transformNode(e.direction)}}transformGroupBy(e){return{kind:"GroupByNode",items:this.transformNodeList(e.items)}}transformGroupByItem(e){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy)}}transformUpdateQuery(e){return{kind:"UpdateQueryNode",table:this.transformNode(e.table),from:this.transformNode(e.from),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),updates:this.transformNodeList(e.updates),returning:this.transformNode(e.returning),with:this.transformNode(e.with),explain:this.transformNode(e.explain)}}transformColumnUpdate(e){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column),value:this.transformNode(e.value)}}transformLimit(e){return{kind:"LimitNode",limit:this.transformNode(e.limit)}}transformOffset(e){return{kind:"OffsetNode",offset:this.transformNode(e.offset)}}transformOnConflict(e){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns),constraint:this.transformNode(e.constraint),indexExpression:this.transformNode(e.indexExpression),indexWhere:this.transformNode(e.indexWhere),updates:this.transformNodeList(e.updates),updateWhere:this.transformNode(e.updateWhere),doNothing:e.doNothing}}transformOnDuplicateKey(e){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates)}}transformCreateIndex(e){return{kind:"CreateIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists,where:this.transformNode(e.where)}}transformList(e){return{kind:"ListNode",items:this.transformNodeList(e.items)}}transformDropIndex(e){return{kind:"DropIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformUniqueConstraint(e){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformForeignKeyConstraint(e){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns),references:this.transformNode(e.references),name:this.transformNode(e.name),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformSetOperation(e){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression),all:e.all}}transformReferences(e){return{kind:"ReferencesNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression),name:this.transformNode(e.name)}}transformWith(e){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions),recursive:e.recursive}}transformCommonTableExpression(e){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name),expression:this.transformNode(e.expression)}}transformCommonTableExpressionName(e){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns)}}transformHaving(e){return{kind:"HavingNode",having:this.transformNode(e.having)}}transformCreateSchema(e){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema),ifNotExists:e.ifNotExists}}transformDropSchema(e){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e){return{kind:"AlterTableNode",table:this.transformNode(e.table),renameTo:this.transformNode(e.renameTo),setSchema:this.transformNode(e.setSchema),columnAlterations:this.transformNodeList(e.columnAlterations),addConstraint:this.transformNode(e.addConstraint),dropConstraint:this.transformNode(e.dropConstraint)}}transformDropColumn(e){return{kind:"DropColumnNode",column:this.transformNode(e.column)}}transformRenameColumn(e){return{kind:"RenameColumnNode",column:this.transformNode(e.column),renameTo:this.transformNode(e.renameTo)}}transformAlterColumn(e){return{kind:"AlterColumnNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),dataTypeExpression:this.transformNode(e.dataTypeExpression),setDefault:this.transformNode(e.setDefault),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e){return{kind:"ModifyColumnNode",column:this.transformNode(e.column)}}transformAddConstraint(e){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint)}}transformDropConstraint(e){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName),ifExists:e.ifExists,modifier:e.modifier}}transformCreateView(e){return{kind:"CreateViewNode",name:this.transformNode(e.name),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns),as:this.transformNode(e.as)}}transformDropView(e){return{kind:"DropViewNode",name:this.transformNode(e.name),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression)}}transformDefaultValue(e){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue)}}transformOn(e){return{kind:"OnNode",on:this.transformNode(e.on)}}transformSelectModifier(e){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier)}}transformCreateType(e){return{kind:"CreateTypeNode",name:this.transformNode(e.name),enum:this.transformNode(e.enum)}}transformDropType(e){return{kind:"DropTypeNode",name:this.transformNode(e.name),ifExists:e.ifExists}}transformExplain(e){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options)}}transformSchemableIdentifier(e){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema),identifier:this.transformNode(e.identifier)}}transformAggregateFunction(e){return{kind:"AggregateFunctionNode",aggregated:this.transformNodeList(e.aggregated),distinct:e.distinct,filter:this.transformNode(e.filter),func:e.func,over:this.transformNode(e.over)}}transformOver(e){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy),partitionBy:this.transformNode(e.partitionBy)}}transformPartitionBy(e){return{kind:"PartitionByNode",items:this.transformNodeList(e.items)}}transformPartitionByItem(e){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy)}}transformBinaryOperation(e){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand),operator:this.transformNode(e.operator),rightOperand:this.transformNode(e.rightOperand)}}transformUnaryOperation(e){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator),operand:this.transformNode(e.operand)}}transformUsing(e){return{kind:"UsingNode",tables:this.transformNodeList(e.tables)}}transformFunction(e){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments)}}transformCase(e){return{kind:"CaseNode",value:this.transformNode(e.value),when:this.transformNodeList(e.when),else:this.transformNode(e.else),isStatement:e.isStatement}}transformWhen(e){return{kind:"WhenNode",condition:this.transformNode(e.condition),result:this.transformNode(e.result)}}transformDataType(e){return e}transformSelectAll(e){return e}transformIdentifier(e){return e}transformValue(e){return e}transformPrimitiveValueList(e){return e}transformOperator(e){return e}transformDefaultInsertValue(e){return e}}rs=new WeakMap;const Th=a({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0});class Ah extends Js{constructor(r){super();w(this,ns);w(this,is);w(this,ur);w(this,Ln);w(this,ss);w(this,_r,void 0);w(this,ar,new Set);g(this,_r,r)}transformNodeImpl(r){if(!X(this,ns,Qu).call(this,r))return super.transformNodeImpl(r);const u=X(this,is,Uu).call(this,r);for(const b of u)n(this,ar).add(b);const d=super.transformNodeImpl(r);for(const b of u)n(this,ar).delete(b);return d}transformSchemableIdentifier(r){const u=super.transformSchemableIdentifier(r);return u.schema||!n(this,ar).has(r.identifier.name)?u:{...u,schema:ue.create(n(this,_r))}}transformReferences(r){const u=super.transformReferences(r);return u.table.table.schema?u:{...u,table:Ft.createWithSchema(n(this,_r),u.table.table.identifier.name)}}}_r=new WeakMap,ar=new WeakMap,ns=new WeakSet,Qu=function(r){return r.kind in Th},is=new WeakSet,Uu=function(r){const u=new Set;if("name"in r&&r.name&&_t.is(r.name)&&X(this,Ln,To).call(this,r.name,u),"from"in r&&r.from)for(const d of r.from.froms)X(this,ur,di).call(this,d,u);if("into"in r&&r.into&&X(this,ur,di).call(this,r.into,u),"table"in r&&r.table&&X(this,ur,di).call(this,r.table,u),"joins"in r&&r.joins)for(const d of r.joins)X(this,ur,di).call(this,d.table,u);return"with"in r&&r.with&&X(this,ss,Vu).call(this,r.with,u),u},ur=new WeakSet,di=function(r,u){const d=Ft.is(r)?r:ir.is(r)&&Ft.is(r.node)?r.node:null;d&&X(this,Ln,To).call(this,d.table,u)},Ln=new WeakSet,To=function(r,u){n(this,ar).has(r.identifier.name)||u.add(r.identifier.name)},ss=new WeakSet,Vu=function(r,u){for(const d of r.expressions)u.delete(d.name.table.table.identifier.name)};class Wn{constructor(e){w(this,Bn,void 0);g(this,Bn,new Ah(e))}transformQuery(e){return n(this,Bn).transformNode(e.node)}async transformResult(e){return e.result}}Bn=new WeakMap;const hr=class{constructor(e){w(this,ee,void 0);g(this,ee,a(e))}selectFrom(e){return new Sr({queryId:G(),executor:n(this,ee).executor,queryNode:D.create(Dr(e),n(this,ee).withNode)})}insertInto(e){return new xn({queryId:G(),executor:n(this,ee).executor,queryNode:gt.create(Ue(e),n(this,ee).withNode)})}replaceInto(e){return new xn({queryId:G(),executor:n(this,ee).executor,queryNode:gt.create(Ue(e),n(this,ee).withNode,!0)})}deleteFrom(e){return new Ci({queryId:G(),executor:n(this,ee).executor,queryNode:bn.create(Dr(e),n(this,ee).withNode)})}updateTable(e){return new ki({queryId:G(),executor:n(this,ee).executor,queryNode:bi.create(qn(e),n(this,ee).withNode)})}with(e,r){const u=sa(e,r);return new hr({...n(this,ee),withNode:n(this,ee).withNode?Ii.cloneWithExpression(n(this,ee).withNode,u):Ii.create(u)})}withRecursive(e,r){const u=sa(e,r);return new hr({...n(this,ee),withNode:n(this,ee).withNode?Ii.cloneWithExpression(n(this,ee).withNode,u):Ii.create(u,{recursive:!0})})}withPlugin(e){return new hr({...n(this,ee),executor:n(this,ee).executor.withPlugin(e)})}withoutPlugins(){return new hr({...n(this,ee),executor:n(this,ee).executor.withoutPlugins()})}withSchema(e){return new hr({...n(this,ee),executor:n(this,ee).executor.withPluginAtFront(new Wn(e))})}};let Ei=hr;ee=new WeakMap;class aa{constructor(){w(this,Mn,void 0);w(this,Fr,void 0);w(this,Qr,void 0);Xe(this,"resolve",e=>{n(this,Fr)&&n(this,Fr).call(this,e)});Xe(this,"reject",e=>{n(this,Qr)&&n(this,Qr).call(this,e)});g(this,Mn,new Promise((e,r)=>{g(this,Qr,r),g(this,Fr,e)}))}get promise(){return n(this,Mn)}}Mn=new WeakMap,Fr=new WeakMap,Qr=new WeakMap;const ua=new Set;function Sh(t){ua.has(t)||(ua.add(t),console.log(t))}const Dh=a([]);class ha{constructor(e=Dh){w(this,Pn);w(this,cr,void 0);g(this,cr,e)}get plugins(){return n(this,cr)}transformQuery(e,r){for(const u of n(this,cr)){const d=u.transformQuery({node:e,queryId:r});if(d.kind===e.kind)e=d;else throw new Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${e.kind}`,`but it returned a ${d.kind}`].join(" "))}return e}async executeQuery(e,r){return await this.provideConnection(async u=>{const d=await u.executeQuery(e),b=await X(this,Pn,Ao).call(this,d,r);return Rh(d,b),b})}async*stream(e,r,u){const d=new aa,b=new aa;this.provideConnection(async I=>(d.resolve(I),await b.promise)).catch(I=>d.reject(I));const k=await d.promise;try{for await(const I of k.streamQuery(e,r))yield await X(this,Pn,Ao).call(this,I,u)}finally{b.resolve()}}}cr=new WeakMap,Pn=new WeakSet,Ao=async function(e,r){for(const u of n(this,cr))e=await u.transformResult({result:e,queryId:r});return e};function Rh(t,e){const{numAffectedRows:r}=t;r===void 0&&t.numUpdatedOrDeletedRows===void 0||r!==void 0&&e.numAffectedRows!==void 0||Sh("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class Tr extends ha{get adapter(){throw new Error("this query cannot be compiled to SQL")}compileQuery(){throw new Error("this query cannot be compiled to SQL")}provideConnection(){throw new Error("this query cannot be executed")}withConnectionProvider(){throw new Error("this query cannot have a connection provider")}withPlugin(e){return new Tr([...this.plugins,e])}withPlugins(e){return new Tr([...this.plugins,...e])}withPluginAtFront(e){return new Tr([e,...this.plugins])}withoutPlugins(){return new Tr([])}}const Ti=new Tr;function ca(){return new Sr({queryId:G(),executor:Ti,queryNode:D.create(Dr([]))})}function Lh(){return new Ei({executor:Ti})}function la(t,e){return new vi({joinNode:et.create(t,qn(e))})}function Bh(){return new gi({overNode:Vs.create()})}const Gs=a({is(t){return t.kind==="WhenNode"},create(t){return a({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return a({...t,result:e})}}),ut=a({is(t){return t.kind==="CaseNode"},create(t){return a({kind:"CaseNode",value:t})},cloneWithWhen(t,e){return a({...t,when:a(t.when?[...t.when,e]:[e])})},cloneWithThen(t,e){return a({...t,when:t.when?a([...t.when.slice(0,-1),Gs.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return a({...t,...e})}});function Ks(t,e,r){if(!_o(e)&&!Le(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return _h(e,r)?Fh(t,e,r):pi.create(Et(t),zs(e),$o(r))}function Mh(t,e,r){if(!_o(e)&&!Le(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return pi.create(Et(t),zs(e),Et(r))}function Ph(t,e,r){if(!Fo(e)&&!Le(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return Ks(t,e,r)}function qe(t,e,r){if(!Fo(e)&&!Le(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return Mh(t,e,r)}function $e(t){return Ai("where",t)}function da(t){return Ai("having",t)}function fa(t){return Ai("on",t)}function pa(t){return Ai("when",t)}function Ai(t,e){if(e.length===3)return Ph(e[0],e[1],e[2]);if(e.length===1)return Qh(t,e[0]);throw ma(t,e)}function _h(t,e){return(t==="is"||t==="is not")&&(Lo(e)||dn(e))}function Fh(t,e,r){return pi.create(Et(t),zs(e),vt.createImmediate(r))}function zs(t){if(_(t)&&nh.includes(t))return _s.create(t);if(Le(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function Qh(t,e){if(Ze(e)){if(t==="when")throw new Error("when method doesn't accept a callback as an argument");return Uh[t](e)}else if(Le(e)){const r=e.toOperationNode();if(Te.is(r)||pi.is(r)||Ko.is(r)||kr.is(r)||ut.is(r))return r}else if(t==="when")return vt.create(e);throw ma(t,e)}function ma(t,e){return new Error(`invalid arguments passed to a '${t}' method: ${JSON.stringify(e)}`)}const Uh=a({where(t){const e=ca(),r=At(),d=t(Object.assign(e,r)).toOperationNode();if(D.is(d)){if(!d.where)throw new Error("no `where` methods called inside a group callback");return kr.create(d.where.where)}else return d},having(t){const e=ca(),r=At(),d=t(Object.assign(e,r)).toOperationNode();if(D.is(d)){if(!d.having)throw new Error("no `having` methods called inside a group callback");return kr.create(d.having.having)}else return d},on(t){const e=la("InnerJoin","table"),r=At(),d=t(Object.assign(e,r)).toOperationNode();if(et.is(d)){if(!d.on)throw new Error("no `on` methods called inside a group callback");return kr.create(d.on.on)}else return d}});function Qe(t,e){if(e.length===3)return jh(t,e[0],e[1],e[2]);if(e.length===2)return Vh(t,e[0],e[1]);throw new Error("not implemented")}function Vh(t,e,r){return r(la(t,e)).toOperationNode()}function jh(t,e,r,u){return et.createWithOn(t,qn(e),qe(r,"=",u))}const $h=a({is(t){return t.kind==="OffsetNode"},create(t){return a({kind:"OffsetNode",offset:vt.create(t)})}}),Jh=a({is(t){return t.kind==="GroupByItemNode"},create(t){return a({kind:"GroupByItemNode",groupBy:t})}});function Gh(t){return t=Ze(t)?t(At()):t,Nn(t).map(Jh.create)}const ya=a({is(t){return t.kind==="SetOperationNode"},create(t,e,r){return a({kind:"SetOperationNode",operator:t,expression:e,all:r})}});function Ar(t,e,r){return ya.create(t,e.toOperationNode(),r)}const W=class{constructor(e){w(this,m,void 0);g(this,m,a(e))}get expressionType(){}where(...e){return new W({...n(this,m),queryNode:C.cloneWithWhere(n(this,m).queryNode,$e(e))})}whereRef(e,r,u){return new W({...n(this,m),queryNode:C.cloneWithWhere(n(this,m).queryNode,qe(e,r,u))})}orWhere(...e){return new W({...n(this,m),queryNode:C.cloneWithOrWhere(n(this,m).queryNode,$e(e))})}orWhereRef(e,r,u){return new W({...n(this,m),queryNode:C.cloneWithOrWhere(n(this,m).queryNode,qe(e,r,u))})}whereExists(e){return new W({...n(this,m),queryNode:C.cloneWithWhere(n(this,m).queryNode,Ae(e))})}whereNotExists(e){return new W({...n(this,m),queryNode:C.cloneWithWhere(n(this,m).queryNode,Oe(e))})}orWhereExists(e){return new W({...n(this,m),queryNode:C.cloneWithOrWhere(n(this,m).queryNode,Ae(e))})}orWhereNotExists(e){return new W({...n(this,m),queryNode:C.cloneWithOrWhere(n(this,m).queryNode,Oe(e))})}having(...e){return new W({...n(this,m),queryNode:D.cloneWithHaving(n(this,m).queryNode,da(e))})}havingRef(e,r,u){return new W({...n(this,m),queryNode:D.cloneWithHaving(n(this,m).queryNode,qe(e,r,u))})}orHaving(...e){return new W({...n(this,m),queryNode:D.cloneWithOrHaving(n(this,m).queryNode,da(e))})}orHavingRef(e,r,u){return new W({...n(this,m),queryNode:D.cloneWithOrHaving(n(this,m).queryNode,qe(e,r,u))})}havingExists(e){return new W({...n(this,m),queryNode:D.cloneWithHaving(n(this,m).queryNode,Ae(e))})}havingNotExist(e){return new W({...n(this,m),queryNode:D.cloneWithHaving(n(this,m).queryNode,Oe(e))})}havingNotExists(e){return new W({...n(this,m),queryNode:D.cloneWithHaving(n(this,m).queryNode,Oe(e))})}orHavingExists(e){return new W({...n(this,m),queryNode:D.cloneWithOrHaving(n(this,m).queryNode,Ae(e))})}orHavingNotExists(e){return new W({...n(this,m),queryNode:D.cloneWithOrHaving(n(this,m).queryNode,Oe(e))})}select(e){return new W({...n(this,m),queryNode:D.cloneWithSelections(n(this,m).queryNode,vn(e))})}distinctOn(e){return new W({...n(this,m),queryNode:D.cloneWithDistinctOn(n(this,m).queryNode,Nn(e))})}modifyFront(e){return new W({...n(this,m),queryNode:D.cloneWithFrontModifier(n(this,m).queryNode,It.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new W({...n(this,m),queryNode:D.cloneWithEndModifier(n(this,m).queryNode,It.createWithExpression(e.toOperationNode()))})}distinct(){return new W({...n(this,m),queryNode:D.cloneWithFrontModifier(n(this,m).queryNode,It.create("Distinct"))})}forUpdate(){return new W({...n(this,m),queryNode:D.cloneWithEndModifier(n(this,m).queryNode,It.create("ForUpdate"))})}forShare(){return new W({...n(this,m),queryNode:D.cloneWithEndModifier(n(this,m).queryNode,It.create("ForShare"))})}forKeyShare(){return new W({...n(this,m),queryNode:D.cloneWithEndModifier(n(this,m).queryNode,It.create("ForKeyShare"))})}forNoKeyUpdate(){return new W({...n(this,m),queryNode:D.cloneWithEndModifier(n(this,m).queryNode,It.create("ForNoKeyUpdate"))})}skipLocked(){return new W({...n(this,m),queryNode:D.cloneWithEndModifier(n(this,m).queryNode,It.create("SkipLocked"))})}noWait(){return new W({...n(this,m),queryNode:D.cloneWithEndModifier(n(this,m).queryNode,It.create("NoWait"))})}selectAll(e){return new W({...n(this,m),queryNode:D.cloneWithSelections(n(this,m).queryNode,gn(e))})}innerJoin(...e){return new W({...n(this,m),queryNode:C.cloneWithJoin(n(this,m).queryNode,Qe("InnerJoin",e))})}leftJoin(...e){return new W({...n(this,m),queryNode:C.cloneWithJoin(n(this,m).queryNode,Qe("LeftJoin",e))})}rightJoin(...e){return new W({...n(this,m),queryNode:C.cloneWithJoin(n(this,m).queryNode,Qe("RightJoin",e))})}fullJoin(...e){return new W({...n(this,m),queryNode:C.cloneWithJoin(n(this,m).queryNode,Qe("FullJoin",e))})}innerJoinLateral(...e){return new W({...n(this,m),queryNode:C.cloneWithJoin(n(this,m).queryNode,Qe("LateralInnerJoin",e))})}leftJoinLateral(...e){return new W({...n(this,m),queryNode:C.cloneWithJoin(n(this,m).queryNode,Qe("LateralLeftJoin",e))})}orderBy(e,r){return new W({...n(this,m),queryNode:D.cloneWithOrderByItem(n(this,m).queryNode,yi(e,r))})}groupBy(e){return new W({...n(this,m),queryNode:D.cloneWithGroupByItems(n(this,m).queryNode,Gh(e))})}limit(e){return new W({...n(this,m),queryNode:D.cloneWithLimit(n(this,m).queryNode,ra.create(e))})}offset(e){return new W({...n(this,m),queryNode:D.cloneWithOffset(n(this,m).queryNode,$h.create(e))})}union(e){return new W({...n(this,m),queryNode:D.cloneWithSetOperation(n(this,m).queryNode,Ar("union",e,!1))})}unionAll(e){return new W({...n(this,m),queryNode:D.cloneWithSetOperation(n(this,m).queryNode,Ar("union",e,!0))})}intersect(e){return new W({...n(this,m),queryNode:D.cloneWithSetOperation(n(this,m).queryNode,Ar("intersect",e,!1))})}intersectAll(e){return new W({...n(this,m),queryNode:D.cloneWithSetOperation(n(this,m).queryNode,Ar("intersect",e,!0))})}except(e){return new W({...n(this,m),queryNode:D.cloneWithSetOperation(n(this,m).queryNode,Ar("except",e,!1))})}exceptAll(e){return new W({...n(this,m),queryNode:D.cloneWithSetOperation(n(this,m).queryNode,Ar("except",e,!0))})}as(e){return new Kh(this,e)}clearSelect(){return new W({...n(this,m),queryNode:D.cloneWithoutSelections(n(this,m).queryNode)})}clearWhere(){return new W({...n(this,m),queryNode:C.cloneWithoutWhere(n(this,m).queryNode)})}clearLimit(){return new W({...n(this,m),queryNode:D.cloneWithoutLimit(n(this,m).queryNode)})}clearOffset(){return new W({...n(this,m),queryNode:D.cloneWithoutOffset(n(this,m).queryNode)})}clearOrderBy(){return new W({...n(this,m),queryNode:D.cloneWithoutOrderBy(n(this,m).queryNode)})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new W({...n(this,m)})}if(e,r){return this.$if(e,r)}$castTo(){return new W(n(this,m))}castTo(){return this.$castTo()}$narrowType(){return new W(n(this,m))}$assertType(){return new W(n(this,m))}assertType(){return new W(n(this,m))}withPlugin(e){return new W({...n(this,m),executor:n(this,m).executor.withPlugin(e)})}toOperationNode(){return n(this,m).executor.transformQuery(n(this,m).queryNode,n(this,m).queryId)}compile(){return n(this,m).executor.compileQuery(this.toOperationNode(),n(this,m).queryId)}async execute(){const e=this.compile();return(await n(this,m).executor.executeQuery(e,n(this,m).queryId)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=xi){const r=await this.executeTakeFirst();if(r===void 0)throw Wi(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=n(this,m).executor.stream(r,e,n(this,m).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new W({...n(this,m),queryNode:C.cloneWithExplain(n(this,m).queryNode,e,r)}).execute()}};let Sr=W;m=new WeakMap,Q(Sr,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Kh{constructor(e,r){w(this,Ur,void 0);w(this,Vr,void 0);g(this,Ur,e),g(this,Vr,r)}get expression(){return n(this,Ur)}get alias(){return n(this,Vr)}toOperationNode(){return ir.create(n(this,Ur).toOperationNode(),ue.create(n(this,Vr)))}}Ur=new WeakMap,Vr=new WeakMap;const ro=class{constructor(e){w(this,jr,void 0);g(this,jr,e)}get expressionType(){}as(e){return new zh(this,e)}$castTo(){return new ro(n(this,jr))}toOperationNode(){return n(this,jr)}};let ve=ro;jr=new WeakMap;class zh{constructor(e,r){w(this,$r,void 0);w(this,jt,void 0);g(this,$r,e),g(this,jt,r)}get expression(){return n(this,$r)}get alias(){return n(this,jt)}toOperationNode(){return ir.create(n(this,$r).toOperationNode(),Le(n(this,jt))?n(this,jt).toOperationNode():ue.create(n(this,jt)))}}$r=new WeakMap,jt=new WeakMap;const tt=a({is(t){return t.kind==="AggregateFunctionNode"},create(t,e=[]){return a({kind:"AggregateFunctionNode",func:t,aggregated:e})},cloneWithDistinct(t){return a({...t,distinct:!0})},cloneWithFilter(t,e){return a({...t,filter:t.filter?Se.cloneWithOperation(t.filter,"And",e):Se.create(e)})},cloneWithOrFilter(t,e){return a({...t,filter:t.filter?Se.cloneWithOperation(t.filter,"Or",e):Se.create(e)})},cloneWithOver(t,e){return a({...t,over:e})}}),Hh=a({is(t){return t.kind==="FunctionNode"},create(t,e){return a({kind:"FunctionNode",func:t,arguments:e})}}),rt=class{constructor(e){w(this,re,void 0);g(this,re,a(e))}get expressionType(){}as(e){return new Yh(this,e)}distinct(){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithDistinct(n(this,re).aggregateFunctionNode)})}filterWhere(...e){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithFilter(n(this,re).aggregateFunctionNode,$e(e))})}filterWhereExists(e){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithFilter(n(this,re).aggregateFunctionNode,Ae(e))})}filterWhereNotExists(e){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithFilter(n(this,re).aggregateFunctionNode,Oe(e))})}filterWhereRef(e,r,u){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithFilter(n(this,re).aggregateFunctionNode,qe(e,r,u))})}orFilterWhere(...e){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithOrFilter(n(this,re).aggregateFunctionNode,$e(e))})}orFilterWhereExists(e){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithOrFilter(n(this,re).aggregateFunctionNode,Ae(e))})}orFilterWhereNotExists(e){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithOrFilter(n(this,re).aggregateFunctionNode,Oe(e))})}orFilterWhereRef(e,r,u){return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithOrFilter(n(this,re).aggregateFunctionNode,qe(e,r,u))})}over(e){const r=Bh();return new rt({...n(this,re),aggregateFunctionNode:tt.cloneWithOver(n(this,re).aggregateFunctionNode,(e?e(r):r).toOperationNode())})}$call(e){return e(this)}toOperationNode(){return n(this,re).aggregateFunctionNode}};let On=rt;re=new WeakMap,Q(On,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");class Yh{constructor(e,r){w(this,Jr,void 0);w(this,Gr,void 0);g(this,Jr,e),g(this,Gr,r)}get expression(){return n(this,Jr)}get alias(){return n(this,Gr)}toOperationNode(){return ir.create(n(this,Jr).toOperationNode(),ue.create(n(this,Gr)))}}Jr=new WeakMap,Gr=new WeakMap;function Na(){const t=(r,u)=>new ve(Hh.create(r,Nn(u))),e=(r,u)=>new On({aggregateFunctionNode:tt.create(r,u?Nn(u):void 0)});return Object.assign(t,{agg:e,avg(r){return e("avg",[r])},coalesce(r,...u){return t("coalesce",[r,...u])},count(r){return e("count",[r])},countAll(r){return new On({aggregateFunctionNode:tt.create("count",gn(r))})},max(r){return e("max",[r])},min(r){return e("min",[r])},sum(r){return e("sum",[r])}})}class wa{constructor(e){w(this,Kr,void 0);g(this,Kr,a(e))}when(...e){return new va({...n(this,Kr),node:ut.cloneWithWhen(n(this,Kr).node,Gs.create(pa(e)))})}}Kr=new WeakMap;class va{constructor(e){w(this,zr,void 0);g(this,zr,a(e))}then(e){return new Xh({...n(this,zr),node:ut.cloneWithThen(n(this,zr).node,Tt(e))})}}zr=new WeakMap;class Xh{constructor(e){w(this,bt,void 0);g(this,bt,a(e))}when(...e){return new va({...n(this,bt),node:ut.cloneWithWhen(n(this,bt).node,Gs.create(pa(e)))})}else(e){return new Zh({...n(this,bt),node:ut.cloneWith(n(this,bt).node,{else:Tt(e)})})}end(){return new ve(ut.cloneWith(n(this,bt).node,{isStatement:!1}))}endCase(){return new ve(ut.cloneWith(n(this,bt).node,{isStatement:!0}))}}bt=new WeakMap;class Zh{constructor(e){w(this,Hr,void 0);g(this,Hr,a(e))}end(){return new ve(ut.cloneWith(n(this,Hr).node,{isStatement:!1}))}endCase(){return new ve(ut.cloneWith(n(this,Hr).node,{isStatement:!0}))}}Hr=new WeakMap;function ga(t=Ti){function e(r,u){return new ve(js(r,u))}return{get fn(){return Na()},selectFrom(r){return new Sr({queryId:G(),executor:t,queryNode:D.create(Dr(r))})},case(r){return new wa({node:ut.create(J(r)?void 0:Et(r))})},ref(r){return new ve(Ir(r))},val(r){return new ve($o(r))},cmpr(r,u,d){return new ve(Ks(r,u,d))},bxp(r,u,d){return new ve(Ks(r,u,d))},unary:e,not(r){return e("not",r)},exists(r){return e("exists",r)},neg(r){return e("-",r)},and(r){if(r.length===0)return new ve(vt.createImmediate(!0));if(r.length===1)return new ve(r[0].toOperationNode());let u=pn.create(r[0].toOperationNode(),r[1].toOperationNode());for(let d=2;dqn(e)):[qn(t)]}function qn(t){return _(t)?ec(t):ba(t)}function ec(t){const e=" as ";if(t.includes(e)){const[r,u]=t.split(e).map(xa);return ir.create(Ue(r),ue.create(u))}else return Ue(t)}function Ue(t){const e=".";if(t.includes(e)){const[r,u]=t.split(e).map(xa);return Ft.createWithSchema(r,u)}else return Ft.create(t)}function xa(t){return t.trim()}const Wa=a({is(t){return t.kind==="AddColumnNode"},create(t){return a({kind:"AddColumnNode",column:t})}}),sr=a({is(t){return t.kind==="AlterColumnNode"},create(t){return a({kind:"AlterColumnNode",column:he.create(t)})},cloneWith(t,e){return a({...t,...e})}}),ce=a({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return a({kind:"ColumnDefinitionNode",column:he.create(t),dataType:e})},cloneWithFrontModifier(t,e){return a({...t,frontModifiers:t.frontModifiers?a([...t.frontModifiers,e]):[e]})},cloneWithEndModifier(t,e){return a({...t,endModifiers:t.endModifiers?a([...t.endModifiers,e]):[e]})},cloneWith(t,e){return a({...t,...e})}}),Oa=a({is(t){return t.kind==="DropColumnNode"},create(t){return a({kind:"DropColumnNode",column:he.create(t)})}}),qa=a({is(t){return t.kind==="RenameColumnNode"},create(t,e){return a({kind:"RenameColumnNode",column:he.create(t),renameTo:he.create(e)})}}),Hs=a({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return a({kind:"CheckConstraintNode",expression:t,name:e?ue.create(e):void 0})}}),tc=["no action","restrict","cascade","set null","set default"],Ri=a({is(t){return t.kind==="ReferencesNode"},create(t,e){return a({kind:"ReferencesNode",table:t,columns:a([...e])})},cloneWithOnDelete(t,e){return a({...t,onDelete:e})},cloneWithOnUpdate(t,e){return a({...t,onUpdate:e})}});function Ca(t){return Le(t)?t.toOperationNode():vt.createImmediate(t)}const Li=a({is(t){return t.kind==="GeneratedNode"},create(t){return a({kind:"GeneratedNode",...t})},createWithExpression(t){return a({kind:"GeneratedNode",always:!0,expression:t})},cloneWith(t,e){return a({...t,...e})}}),rc=a({is(t){return t.kind==="DefaultValueNode"},create(t){return a({kind:"DefaultValueNode",defaultValue:t})}});function Bi(t){if(tc.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}const be=class{constructor(e){w(this,z,void 0);g(this,z,e)}autoIncrement(){return new be(ce.cloneWith(n(this,z),{autoIncrement:!0}))}primaryKey(){return new be(ce.cloneWith(n(this,z),{primaryKey:!0}))}references(e){const r=Ir(e);if(!mi.is(r)||Fs.is(r.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new be(ce.cloneWith(n(this,z),{references:Ri.create(r.table,[r.column])}))}onDelete(e){if(!n(this,z).references)throw new Error("on delete constraint can only be added for foreign keys");return new be(ce.cloneWith(n(this,z),{references:Ri.cloneWithOnDelete(n(this,z).references,Bi(e))}))}onUpdate(e){if(!n(this,z).references)throw new Error("on update constraint can only be added for foreign keys");return new be(ce.cloneWith(n(this,z),{references:Ri.cloneWithOnUpdate(n(this,z).references,Bi(e))}))}unique(){return new be(ce.cloneWith(n(this,z),{unique:!0}))}notNull(){return new be(ce.cloneWith(n(this,z),{notNull:!0}))}unsigned(){return new be(ce.cloneWith(n(this,z),{unsigned:!0}))}defaultTo(e){return new be(ce.cloneWith(n(this,z),{defaultTo:rc.create(Ca(e))}))}check(e){return new be(ce.cloneWith(n(this,z),{check:Hs.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new be(ce.cloneWith(n(this,z),{generated:Li.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new be(ce.cloneWith(n(this,z),{generated:Li.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new be(ce.cloneWith(n(this,z),{generated:Li.create({identity:!0,byDefault:!0})}))}stored(){if(!n(this,z).generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new be(ce.cloneWith(n(this,z),{generated:Li.cloneWith(n(this,z).generated,{stored:!0})}))}modifyFront(e){return new be(ce.cloneWithFrontModifier(n(this,z),e.toOperationNode()))}modifyEnd(e){return new be(ce.cloneWithEndModifier(n(this,z),e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return n(this,z)}};let Qt=be;z=new WeakMap,Q(Qt,"don't await ColumnDefinitionBuilder instances directly.");const ka=a({is(t){return t.kind==="ModifyColumnNode"},create(t){return a({kind:"ModifyColumnNode",column:t})}}),nc=a({is(t){return t.kind==="DataTypeNode"},create(t){return a({kind:"DataTypeNode",dataType:t})}});function Rr(t){return Le(t)?t.toOperationNode():nc.create(t)}const Mi=a({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,r,u){return a({kind:"ForeignKeyConstraintNode",columns:t,references:Ri.create(e,r),name:u?ue.create(u):void 0})},cloneWith(t,e){return a({...t,...e})}}),os=class{constructor(e){w(this,lr,void 0);g(this,lr,e)}onDelete(e){return new os(Mi.cloneWith(n(this,lr),{onDelete:Bi(e)}))}onUpdate(e){return new os(Mi.cloneWith(n(this,lr),{onUpdate:Bi(e)}))}$call(e){return e(this)}toOperationNode(){return n(this,lr)}};let Cn=os;lr=new WeakMap,Q(Cn,"don't await ForeignKeyConstraintBuilder instances directly.");const Ys=a({is(t){return t.kind==="AddConstraintNode"},create(t){return a({kind:"AddConstraintNode",constraint:t})}}),Ia=a({is(t){return t.kind==="UniqueConstraintNode"},create(t,e){return a({kind:"UniqueConstraintNode",columns:a(t.map(he.create)),name:e?ue.create(e):void 0})}}),Pi=a({is(t){return t.kind==="DropConstraintNode"},create(t){return a({kind:"DropConstraintNode",constraintName:ue.create(t)})},cloneWith(t,e){return a({...t,...e})}});class _i{constructor(e){Xe(this,"alterColumnNode");this.alterColumnNode=e}setDataType(e){return new kn(sr.cloneWith(this.alterColumnNode,{dataType:Rr(e)}))}setDefault(e){return new kn(sr.cloneWith(this.alterColumnNode,{setDefault:Ca(e)}))}dropDefault(){return new kn(sr.cloneWith(this.alterColumnNode,{dropDefault:!0}))}setNotNull(){return new kn(sr.cloneWith(this.alterColumnNode,{setNotNull:!0}))}dropNotNull(){return new kn(sr.cloneWith(this.alterColumnNode,{dropNotNull:!0}))}$call(e){return e(this)}}class kn extends _i{toOperationNode(){return this.alterColumnNode}}class In{constructor(e){w(this,dt,void 0);g(this,dt,a(e))}toOperationNode(){return n(this,dt).executor.transformQuery(n(this,dt).node,n(this,dt).queryId)}compile(){return n(this,dt).executor.compileQuery(this.toOperationNode(),n(this,dt).queryId)}async execute(){await n(this,dt).executor.executeQuery(this.compile(),n(this,dt).queryId)}}dt=new WeakMap,Q(In,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");const as=class{constructor(e){w(this,De,void 0);g(this,De,a(e))}onDelete(e){return new as({...n(this,De),constraintBuilder:n(this,De).constraintBuilder.onDelete(e)})}onUpdate(e){return new as({...n(this,De),constraintBuilder:n(this,De).constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return n(this,De).executor.transformQuery(ye.cloneWithTableProps(n(this,De).node,{addConstraint:Ys.create(n(this,De).constraintBuilder.toOperationNode())}),n(this,De).queryId)}compile(){return n(this,De).executor.compileQuery(this.toOperationNode(),n(this,De).queryId)}async execute(){await n(this,De).executor.executeQuery(this.compile(),n(this,De).queryId)}};let Fi=as;De=new WeakMap,Q(Fi,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");const _n=class{constructor(e){w(this,Ne,void 0);g(this,Ne,a(e))}ifExists(){return new _n({...n(this,Ne),node:ye.cloneWithTableProps(n(this,Ne).node,{dropConstraint:Pi.cloneWith(n(this,Ne).node.dropConstraint,{ifExists:!0})})})}cascade(){return new _n({...n(this,Ne),node:ye.cloneWithTableProps(n(this,Ne).node,{dropConstraint:Pi.cloneWith(n(this,Ne).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new _n({...n(this,Ne),node:ye.cloneWithTableProps(n(this,Ne).node,{dropConstraint:Pi.cloneWith(n(this,Ne).node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return n(this,Ne).executor.transformQuery(n(this,Ne).node,n(this,Ne).queryId)}compile(){return n(this,Ne).executor.compileQuery(this.toOperationNode(),n(this,Ne).queryId)}async execute(){await n(this,Ne).executor.executeQuery(this.compile(),n(this,Ne).queryId)}};let Qi=_n;Ne=new WeakMap,Q(Qi,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");class Ea{constructor(e){w(this,ne,void 0);g(this,ne,a(e))}renameTo(e){return new In({...n(this,ne),node:ye.cloneWithTableProps(n(this,ne).node,{renameTo:Ue(e)})})}setSchema(e){return new In({...n(this,ne),node:ye.cloneWithTableProps(n(this,ne).node,{setSchema:ue.create(e)})})}alterColumn(e,r){const u=r(new _i(sr.create(e)));return new Ut({...n(this,ne),node:ye.cloneWithColumnAlteration(n(this,ne).node,u.toOperationNode())})}dropColumn(e){return new Ut({...n(this,ne),node:ye.cloneWithColumnAlteration(n(this,ne).node,Oa.create(e))})}renameColumn(e,r){return new Ut({...n(this,ne),node:ye.cloneWithColumnAlteration(n(this,ne).node,qa.create(e,r))})}addColumn(e,r,u=Cr){const d=u(new Qt(ce.create(e,Rr(r))));return new Ut({...n(this,ne),node:ye.cloneWithColumnAlteration(n(this,ne).node,Wa.create(d.toOperationNode()))})}modifyColumn(e,r,u=Cr){const d=u(new Qt(ce.create(e,Rr(r))));return new Ut({...n(this,ne),node:ye.cloneWithColumnAlteration(n(this,ne).node,ka.create(d.toOperationNode()))})}addUniqueConstraint(e,r){return new In({...n(this,ne),node:ye.cloneWithTableProps(n(this,ne).node,{addConstraint:Ys.create(Ia.create(r,e))})})}addCheckConstraint(e,r){return new In({...n(this,ne),node:ye.cloneWithTableProps(n(this,ne).node,{addConstraint:Ys.create(Hs.create(r.toOperationNode(),e))})})}addForeignKeyConstraint(e,r,u,d){return new Fi({...n(this,ne),constraintBuilder:new Cn(Mi.create(r.map(he.create),Ue(u),d.map(he.create),e))})}dropConstraint(e){return new Qi({...n(this,ne),node:ye.cloneWithTableProps(n(this,ne).node,{dropConstraint:Pi.create(e)})})}$call(e){return e(this)}call(e){return this.$call(e)}}ne=new WeakMap;const dr=class{constructor(e){w(this,le,void 0);g(this,le,a(e))}alterColumn(e,r){const u=r(new _i(sr.create(e)));return new dr({...n(this,le),node:ye.cloneWithColumnAlteration(n(this,le).node,u.toOperationNode())})}dropColumn(e){return new dr({...n(this,le),node:ye.cloneWithColumnAlteration(n(this,le).node,Oa.create(e))})}renameColumn(e,r){return new dr({...n(this,le),node:ye.cloneWithColumnAlteration(n(this,le).node,qa.create(e,r))})}addColumn(e,r,u=Cr){const d=u(new Qt(ce.create(e,Rr(r))));return new dr({...n(this,le),node:ye.cloneWithColumnAlteration(n(this,le).node,Wa.create(d.toOperationNode()))})}modifyColumn(e,r,u=Cr){const d=u(new Qt(ce.create(e,Rr(r))));return new dr({...n(this,le),node:ye.cloneWithColumnAlteration(n(this,le).node,ka.create(d.toOperationNode()))})}toOperationNode(){return n(this,le).executor.transformQuery(n(this,le).node,n(this,le).queryId)}compile(){return n(this,le).executor.compileQuery(this.toOperationNode(),n(this,le).queryId)}async execute(){await n(this,le).executor.executeQuery(this.compile(),n(this,le).queryId)}};let Ut=dr;le=new WeakMap,Q(Ea,"don't await AlterTableBuilder instances"),Q(_i,"don't await AlterColumnBuilder instances"),Q(Ut,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class Ta extends Js{transformValue(e){return{...super.transformValue(e),immediate:!0}}}const xt=class{constructor(e){w(this,H,void 0);g(this,H,a(e))}ifNotExists(){return new xt({...n(this,H),node:Pt.cloneWith(n(this,H).node,{ifNotExists:!0})})}unique(){return new xt({...n(this,H),node:Pt.cloneWith(n(this,H).node,{unique:!0})})}on(e){return new xt({...n(this,H),node:Pt.cloneWith(n(this,H).node,{table:Ue(e)})})}column(e){return new xt({...n(this,H),node:Pt.cloneWithColumns(n(this,H).node,[Vo(e)])})}columns(e){return new xt({...n(this,H),node:Pt.cloneWithColumns(n(this,H).node,e.map(Vo))})}expression(e){return new xt({...n(this,H),node:Pt.cloneWithColumns(n(this,H).node,[e.toOperationNode()])})}using(e){return new xt({...n(this,H),node:Pt.cloneWith(n(this,H).node,{using:Te.createWithSql(e)})})}where(...e){const r=new Ta;return new xt({...n(this,H),node:C.cloneWithWhere(n(this,H).node,r.transformNode($e(e)))})}$call(e){return e(this)}toOperationNode(){return n(this,H).executor.transformQuery(n(this,H).node,n(this,H).queryId)}compile(){return n(this,H).executor.compileQuery(this.toOperationNode(),n(this,H).queryId)}async execute(){await n(this,H).executor.executeQuery(this.compile(),n(this,H).queryId)}};let Ui=xt;H=new WeakMap,Q(Ui,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");const no=class{constructor(e){w(this,Ge,void 0);g(this,Ge,a(e))}ifNotExists(){return new no({...n(this,Ge),node:Bo.cloneWith(n(this,Ge).node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return n(this,Ge).executor.transformQuery(n(this,Ge).node,n(this,Ge).queryId)}compile(){return n(this,Ge).executor.compileQuery(this.toOperationNode(),n(this,Ge).queryId)}async execute(){await n(this,Ge).executor.executeQuery(this.compile(),n(this,Ge).queryId)}};let Vi=no;Ge=new WeakMap,Q(Vi,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");const ic=a({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return a({kind:"PrimaryKeyConstraintNode",columns:a(t.map(he.create)),name:e?ue.create(e):void 0})}});function sc(t){if(Xu.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}const nt=class{constructor(e){w(this,U,void 0);g(this,U,a(e))}temporary(){return new nt({...n(this,U),node:at.cloneWith(n(this,U).node,{temporary:!0})})}onCommit(e){return new nt({...n(this,U),node:at.cloneWith(n(this,U).node,{onCommit:sc(e)})})}ifNotExists(){return new nt({...n(this,U),node:at.cloneWith(n(this,U).node,{ifNotExists:!0})})}addColumn(e,r,u=Cr){const d=u(new Qt(ce.create(e,Rr(r))));return new nt({...n(this,U),node:at.cloneWithColumn(n(this,U).node,d.toOperationNode())})}addPrimaryKeyConstraint(e,r){return new nt({...n(this,U),node:at.cloneWithConstraint(n(this,U).node,ic.create(r,e))})}addUniqueConstraint(e,r){return new nt({...n(this,U),node:at.cloneWithConstraint(n(this,U).node,Ia.create(r,e))})}addCheckConstraint(e,r){return new nt({...n(this,U),node:at.cloneWithConstraint(n(this,U).node,Hs.create(r.toOperationNode(),e))})}addForeignKeyConstraint(e,r,u,d,b=Cr){const k=b(new Cn(Mi.create(r.map(he.create),Ue(u),d.map(he.create),e)));return new nt({...n(this,U),node:at.cloneWithConstraint(n(this,U).node,k.toOperationNode())})}modifyFront(e){return new nt({...n(this,U),node:at.cloneWithFrontModifier(n(this,U).node,e.toOperationNode())})}modifyEnd(e){return new nt({...n(this,U),node:at.cloneWithEndModifier(n(this,U).node,e.toOperationNode())})}$call(e){return e(this)}call(e){return this.$call(e)}toOperationNode(){return n(this,U).executor.transformQuery(n(this,U).node,n(this,U).queryId)}compile(){return n(this,U).executor.compileQuery(this.toOperationNode(),n(this,U).queryId)}async execute(){await n(this,U).executor.executeQuery(this.compile(),n(this,U).queryId)}};let ji=nt;U=new WeakMap,Q(ji,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");const Fn=class{constructor(e){w(this,Ce,void 0);g(this,Ce,a(e))}on(e){return new Fn({...n(this,Ce),node:fi.cloneWith(n(this,Ce).node,{table:Ue(e)})})}ifExists(){return new Fn({...n(this,Ce),node:fi.cloneWith(n(this,Ce).node,{ifExists:!0})})}cascade(){return new Fn({...n(this,Ce),node:fi.cloneWith(n(this,Ce).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return n(this,Ce).executor.transformQuery(n(this,Ce).node,n(this,Ce).queryId)}compile(){return n(this,Ce).executor.compileQuery(this.toOperationNode(),n(this,Ce).queryId)}async execute(){await n(this,Ce).executor.executeQuery(this.compile(),n(this,Ce).queryId)}};let $i=Fn;Ce=new WeakMap,Q($i,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");const us=class{constructor(e){w(this,Me,void 0);g(this,Me,a(e))}ifExists(){return new us({...n(this,Me),node:Ms.cloneWith(n(this,Me).node,{ifExists:!0})})}cascade(){return new us({...n(this,Me),node:Ms.cloneWith(n(this,Me).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return n(this,Me).executor.transformQuery(n(this,Me).node,n(this,Me).queryId)}compile(){return n(this,Me).executor.compileQuery(this.toOperationNode(),n(this,Me).queryId)}async execute(){await n(this,Me).executor.executeQuery(this.compile(),n(this,Me).queryId)}};let Ji=us;Me=new WeakMap,Q(Ji,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");const hs=class{constructor(e){w(this,Pe,void 0);g(this,Pe,a(e))}ifExists(){return new hs({...n(this,Pe),node:Ps.cloneWith(n(this,Pe).node,{ifExists:!0})})}cascade(){return new hs({...n(this,Pe),node:Ps.cloneWith(n(this,Pe).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return n(this,Pe).executor.transformQuery(n(this,Pe).node,n(this,Pe).queryId)}compile(){return n(this,Pe).executor.compileQuery(this.toOperationNode(),n(this,Pe).queryId)}async execute(){await n(this,Pe).executor.executeQuery(this.compile(),n(this,Pe).queryId)}};let Gi=hs;Pe=new WeakMap,Q(Gi,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");const Vt=a({is(t){return t.kind==="CreateViewNode"},create(t){return a({kind:"CreateViewNode",name:_t.create(t)})},cloneWith(t,e){return a({...t,...e})}});class oc{constructor(){w(this,cs,new Ta)}transformQuery(e){return n(this,cs).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}cs=new WeakMap;const $t=class{constructor(e){w(this,ae,void 0);g(this,ae,a(e))}temporary(){return new $t({...n(this,ae),node:Vt.cloneWith(n(this,ae).node,{temporary:!0})})}materialized(){return new $t({...n(this,ae),node:Vt.cloneWith(n(this,ae).node,{materialized:!0})})}ifNotExists(){return new $t({...n(this,ae),node:Vt.cloneWith(n(this,ae).node,{ifNotExists:!0})})}orReplace(){return new $t({...n(this,ae),node:Vt.cloneWith(n(this,ae).node,{orReplace:!0})})}columns(e){return new $t({...n(this,ae),node:Vt.cloneWith(n(this,ae).node,{columns:e.map(Uo)})})}as(e){const r=e.withPlugin(new oc).toOperationNode();return new $t({...n(this,ae),node:Vt.cloneWith(n(this,ae).node,{as:r})})}$call(e){return e(this)}toOperationNode(){return n(this,ae).executor.transformQuery(n(this,ae).node,n(this,ae).queryId)}compile(){return n(this,ae).executor.compileQuery(this.toOperationNode(),n(this,ae).queryId)}async execute(){await n(this,ae).executor.executeQuery(this.compile(),n(this,ae).queryId)}};let Ki=$t;ae=new WeakMap,Q(Ki,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const zi=a({is(t){return t.kind==="DropViewNode"},create(t){return a({kind:"DropViewNode",name:_t.create(t)})},cloneWith(t,e){return a({...t,...e})}}),Qn=class{constructor(e){w(this,ke,void 0);g(this,ke,a(e))}materialized(){return new Qn({...n(this,ke),node:zi.cloneWith(n(this,ke).node,{materialized:!0})})}ifExists(){return new Qn({...n(this,ke),node:zi.cloneWith(n(this,ke).node,{ifExists:!0})})}cascade(){return new Qn({...n(this,ke),node:zi.cloneWith(n(this,ke).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return n(this,ke).executor.transformQuery(n(this,ke).node,n(this,ke).queryId)}compile(){return n(this,ke).executor.compileQuery(this.toOperationNode(),n(this,ke).queryId)}async execute(){await n(this,ke).executor.executeQuery(this.compile(),n(this,ke).queryId)}};let Hi=Qn;ke=new WeakMap,Q(Hi,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const Aa=a({is(t){return t.kind==="CreateTypeNode"},create(t){return a({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return a({...t,enum:Us.create(e.map(r=>vt.createImmediate(r)))})}}),io=class{constructor(e){w(this,Ke,void 0);g(this,Ke,a(e))}toOperationNode(){return n(this,Ke).executor.transformQuery(n(this,Ke).node,n(this,Ke).queryId)}asEnum(e){return new io({...n(this,Ke),node:Aa.cloneWithEnum(n(this,Ke).node,e)})}$call(e){return e(this)}compile(){return n(this,Ke).executor.compileQuery(this.toOperationNode(),n(this,Ke).queryId)}async execute(){await n(this,Ke).executor.executeQuery(this.compile(),n(this,Ke).queryId)}};let Yi=io;Ke=new WeakMap,Q(Yi,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const Sa=a({is(t){return t.kind==="DropTypeNode"},create(t){return a({kind:"DropTypeNode",name:t})},cloneWith(t,e){return a({...t,...e})}}),so=class{constructor(e){w(this,ze,void 0);g(this,ze,a(e))}ifExists(){return new so({...n(this,ze),node:Sa.cloneWith(n(this,ze).node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return n(this,ze).executor.transformQuery(n(this,ze).node,n(this,ze).queryId)}compile(){return n(this,ze).executor.compileQuery(this.toOperationNode(),n(this,ze).queryId)}async execute(){await n(this,ze).executor.executeQuery(this.compile(),n(this,ze).queryId)}};let Xi=so;ze=new WeakMap,Q(Xi,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function Da(t){const e=".";if(t.includes(e)){const r=t.split(e).map(ac);if(r.length===2)return _t.createWithSchema(r[0],r[1]);throw new Error(`invalid schemable identifier ${t}`)}else return _t.create(t)}function ac(t){return t.trim()}const Un=class{constructor(e){w(this,xe,void 0);g(this,xe,e)}createTable(e){return new ji({queryId:G(),executor:n(this,xe),node:at.create(Ue(e))})}dropTable(e){return new Gi({queryId:G(),executor:n(this,xe),node:Ps.create(Ue(e))})}createIndex(e){return new Ui({queryId:G(),executor:n(this,xe),node:Pt.create(e)})}dropIndex(e){return new $i({queryId:G(),executor:n(this,xe),node:fi.create(e)})}createSchema(e){return new Vi({queryId:G(),executor:n(this,xe),node:Bo.create(e)})}dropSchema(e){return new Ji({queryId:G(),executor:n(this,xe),node:Ms.create(e)})}alterTable(e){return new Ea({queryId:G(),executor:n(this,xe),node:ye.create(Ue(e))})}createView(e){return new Ki({queryId:G(),executor:n(this,xe),node:Vt.create(e)})}dropView(e){return new Hi({queryId:G(),executor:n(this,xe),node:zi.create(e)})}createType(e){return new Yi({queryId:G(),executor:n(this,xe),node:Aa.create(Da(e))})}dropType(e){return new Xi({queryId:G(),executor:n(this,xe),node:Sa.create(Da(e))})}withPlugin(e){return new Un(n(this,xe).withPlugin(e))}withoutPlugins(){return new Un(n(this,xe).withoutPlugins())}withSchema(e){return new Un(n(this,xe).withPluginAtFront(new Wn(e)))}};let Xs=Un;xe=new WeakMap;class uc{ref(e){return new ph(e)}}class hc{constructor(e){w(this,Yr,void 0);g(this,Yr,e)}async provideConnection(e){const r=await n(this,Yr).acquireConnection();try{return await e(r)}finally{await n(this,Yr).releaseConnection(r)}}}Yr=new WeakMap;const fr=class extends ha{constructor(r,u,d,b=[]){super(b);w(this,Wt,void 0);w(this,Ot,void 0);w(this,St,void 0);g(this,Wt,r),g(this,Ot,u),g(this,St,d)}get adapter(){return n(this,Ot)}compileQuery(r){return n(this,Wt).compileQuery(r)}provideConnection(r){return n(this,St).provideConnection(r)}withPlugins(r){return new fr(n(this,Wt),n(this,Ot),n(this,St),[...this.plugins,...r])}withPlugin(r){return new fr(n(this,Wt),n(this,Ot),n(this,St),[...this.plugins,r])}withPluginAtFront(r){return new fr(n(this,Wt),n(this,Ot),n(this,St),[r,...this.plugins])}withConnectionProvider(r){return new fr(n(this,Wt),n(this,Ot),r,[...this.plugins])}withoutPlugins(){return new fr(n(this,Wt),n(this,Ot),n(this,St),[])}};let Zs=fr;Wt=new WeakMap,Ot=new WeakMap,St=new WeakMap;function Ra(){return typeof performance<"u"&&Ze(performance.now)?performance.now():Date.now()}class cc{constructor(e,r){w(this,ls);w(this,ds);w(this,fs);w(this,ps);w(this,jn);w(this,ft,void 0);w(this,Jt,void 0);w(this,Dt,void 0);w(this,pr,void 0);w(this,Vn,new WeakSet);g(this,ft,e),g(this,Jt,r)}async init(){n(this,Dt)||g(this,Dt,n(this,ft).init().catch(e=>(g(this,Dt,void 0),Promise.reject(e)))),await n(this,Dt)}async acquireConnection(){await this.init();const e=await n(this,ft).acquireConnection();return n(this,Vn).has(e)||(X(this,ls,ju).call(this)&&X(this,ds,$u).call(this,e),n(this,Vn).add(e)),e}async releaseConnection(e){await n(this,ft).releaseConnection(e)}beginTransaction(e,r){return n(this,ft).beginTransaction(e,r)}commitTransaction(e){return n(this,ft).commitTransaction(e)}rollbackTransaction(e){return n(this,ft).rollbackTransaction(e)}async destroy(){n(this,Dt)&&(await n(this,Dt),n(this,pr)||g(this,pr,n(this,ft).destroy().catch(e=>(g(this,pr,void 0),Promise.reject(e)))),await n(this,pr))}}ft=new WeakMap,Jt=new WeakMap,Dt=new WeakMap,pr=new WeakMap,Vn=new WeakMap,ls=new WeakSet,ju=function(){return n(this,Jt).isLevelEnabled("query")||n(this,Jt).isLevelEnabled("error")},ds=new WeakSet,$u=function(e){const r=e.executeQuery;e.executeQuery=async u=>{const d=Ra();try{return await r.call(e,u)}catch(b){throw await X(this,fs,Ju).call(this,b,u,d),b}finally{await X(this,ps,Gu).call(this,u,d)}}},fs=new WeakSet,Ju=async function(e,r,u){await n(this,Jt).error(()=>({level:"error",error:e,query:r,queryDurationMillis:X(this,jn,So).call(this,u)}))},ps=new WeakSet,Gu=async function(e,r){await n(this,Jt).query(()=>({level:"query",query:e,queryDurationMillis:X(this,jn,So).call(this,r)}))},jn=new WeakSet,So=function(e){return Ra()-e};class La{constructor(e){w(this,ms);w(this,$n,void 0);w(this,Gt,void 0);g(this,$n,e)}async provideConnection(e){for(;n(this,Gt);)await n(this,Gt);const r=X(this,ms,Ku).call(this,e);return g(this,Gt,r.then(()=>{g(this,Gt,void 0)}).catch(()=>{g(this,Gt,void 0)})),r}}$n=new WeakMap,Gt=new WeakMap,ms=new WeakSet,Ku=async function(e){return await e(n(this,$n))};const lc=["read uncommitted","read committed","repeatable read","serializable"];a(["query","error"]);class dc{constructor(e){w(this,Kt,void 0);w(this,mr,void 0);Ze(e)?(g(this,mr,e),g(this,Kt,a({query:!0,error:!0}))):(g(this,mr,fc),g(this,Kt,a({query:e.includes("query"),error:e.includes("error")})))}isLevelEnabled(e){return n(this,Kt)[e]}async query(e){n(this,Kt).query&&await n(this,mr).call(this,e())}async error(e){n(this,Kt).error&&await n(this,mr).call(this,e())}}Kt=new WeakMap,mr=new WeakMap;function fc(t){t.level==="query"?(console.log(`kysely:query: ${t.query.sql}`),console.log(`kysely:query: duration: ${t.queryDurationMillis.toFixed(1)}ms`)):t.level==="error"&&(t.error instanceof Error?console.error(`kysely:error: ${t.error.stack??t.error.message}`):console.error(`kysely:error: ${t}`))}function pc(t){return wt(t)&&Ze(t.compile)}const Xr=class extends Ei{constructor(r){let u,d;if(mc(r))u={executor:r.executor},d={...r};else{const b=r.dialect,k=b.createDriver(),I=b.createQueryCompiler(),j=b.createAdapter(),c=new dc(r.log??[]),_e=new cc(k,c),Fe=new hc(_e),P=new Zs(I,j,Fe,r.plugins??[]);u={executor:P},d={config:r,executor:P,dialect:b,driver:_e}}super(u);w(this,Ie,void 0);g(this,Ie,a(d))}get schema(){return new Xs(n(this,Ie).executor)}get dynamic(){return new uc}get introspection(){return n(this,Ie).dialect.createIntrospector(this.withoutPlugins())}case(r){return new wa({node:ut.create(J(r)?void 0:Si(r))})}get fn(){return Na()}transaction(){return new Zi({...n(this,Ie)})}connection(){return new Ba({...n(this,Ie)})}withPlugin(r){return new Xr({...n(this,Ie),executor:n(this,Ie).executor.withPlugin(r)})}withoutPlugins(){return new Xr({...n(this,Ie),executor:n(this,Ie).executor.withoutPlugins()})}withSchema(r){return new Xr({...n(this,Ie),executor:n(this,Ie).executor.withPluginAtFront(new Wn(r))})}withTables(){return new Xr({...n(this,Ie)})}async destroy(){await n(this,Ie).driver.destroy()}get isTransaction(){return!1}getExecutor(){return n(this,Ie).executor}executeQuery(r,u=G()){const d=pc(r)?r.compile():r;return this.getExecutor().executeQuery(d,u)}};let En=Xr;Ie=new WeakMap;const Zr=class extends En{constructor(r){super(r);w(this,pt,void 0);g(this,pt,r)}get isTransaction(){return!0}transaction(){throw new Error("calling the transaction method for a Transaction is not supported")}connection(){throw new Error("calling the connection method for a Transaction is not supported")}async destroy(){throw new Error("calling the destroy method for a Transaction is not supported")}withPlugin(r){return new Zr({...n(this,pt),executor:n(this,pt).executor.withPlugin(r)})}withoutPlugins(){return new Zr({...n(this,pt),executor:n(this,pt).executor.withoutPlugins()})}withSchema(r){return new Zr({...n(this,pt),executor:n(this,pt).executor.withPluginAtFront(new Wn(r))})}withTables(){return new Zr({...n(this,pt)})}};let eo=Zr;pt=new WeakMap;function mc(t){return wt(t)&&wt(t.config)&&wt(t.driver)&&wt(t.executor)&&wt(t.dialect)}class Ba{constructor(e){w(this,yr,void 0);g(this,yr,a(e))}async execute(e){return n(this,yr).executor.provideConnection(async r=>{const u=n(this,yr).executor.withConnectionProvider(new La(r)),d=new En({...n(this,yr),executor:u});return await e(d)})}}yr=new WeakMap,Q(Ba,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");const oo=class{constructor(e){w(this,mt,void 0);g(this,mt,a(e))}setIsolationLevel(e){return new oo({...n(this,mt),isolationLevel:e})}async execute(e){const{isolationLevel:r,...u}=n(this,mt),d={isolationLevel:r};return yc(d),n(this,mt).executor.provideConnection(async b=>{const k=n(this,mt).executor.withConnectionProvider(new La(b)),I=new eo({...u,executor:k});try{await n(this,mt).driver.beginTransaction(b,d);const j=await e(I);return await n(this,mt).driver.commitTransaction(b),j}catch(j){throw await n(this,mt).driver.rollbackTransaction(b),j}})}};let Zi=oo;mt=new WeakMap,Q(Zi,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function yc(t){if(t.isolationLevel&&!lc.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}const ys=class{constructor(e){w(this,en);w(this,Jn);w(this,Gn);w(this,Ve,void 0);g(this,Ve,a(e))}get expressionType(){}as(e){return new Nc(this,e)}$castTo(){return new ys({...n(this,Ve)})}castTo(){return this.$castTo()}withPlugin(e){return new ys({...n(this,Ve),plugins:n(this,Ve).plugins!==void 0?a([...n(this,Ve).plugins,e]):a([e])})}toOperationNode(){return X(this,Jn,Do).call(this,X(this,en,Bs).call(this))}compile(e){return X(this,Gn,Ro).call(this,X(this,en,Bs).call(this,e))}async execute(e){const r=X(this,en,Bs).call(this,e);return r.executeQuery(X(this,Gn,Ro).call(this,r),n(this,Ve).queryId)}};let ht=ys;Ve=new WeakMap,en=new WeakSet,Bs=function(e){const r=e!==void 0?e.getExecutor():Ti;return n(this,Ve).plugins!==void 0?r.withPlugins(n(this,Ve).plugins):r},Jn=new WeakSet,Do=function(e){return e.transformQuery(n(this,Ve).rawNode,n(this,Ve).queryId)},Gn=new WeakSet,Ro=function(e){return e.compileQuery(X(this,Jn,Do).call(this,e),n(this,Ve).queryId)},Q(ht,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");class Nc{constructor(e,r){w(this,tn,void 0);w(this,zt,void 0);g(this,tn,e),g(this,zt,r)}get expression(){return n(this,tn)}get alias(){return n(this,zt)}toOperationNode(){return ir.create(n(this,tn).toOperationNode(),Le(n(this,zt))?n(this,zt).toOperationNode():ue.create(n(this,zt)))}}tn=new WeakMap,zt=new WeakMap;const Je=Object.assign((t,...e)=>new ht({queryId:G(),rawNode:Te.create(t,(e==null?void 0:e.map(Tt))??[])}),{ref(t){return new ht({queryId:G(),rawNode:Te.createWithChild(Ir(t))})},val(t){return new ht({queryId:G(),rawNode:Te.createWithChild(Tt(t))})},value(t){return this.val(t)},table(t){return new ht({queryId:G(),rawNode:Te.createWithChild(Ue(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",new ht({queryId:G(),rawNode:Te.create(e,t.map(ue.create))})},lit(t){return new ht({queryId:G(),rawNode:Te.createWithChild(vt.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return new ht({queryId:G(),rawNode:Te.createWithSql(t)})},join(t,e=Je`, `){const r=new Array(2*t.length-1),u=e.toOperationNode();for(let d=0;d{this.nodeStack.push(e),n(this,Ns)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}Ns=new WeakMap;class vc extends wc{constructor(){super(...arguments);w(this,rn,"");w(this,Nr,[])}get numParameters(){return n(this,Nr).length}compileQuery(r){return g(this,rn,""),g(this,Nr,[]),this.visitNode(r),a({query:r,sql:this.getSql(),parameters:[...n(this,Nr)]})}getSql(){return n(this,rn)}visitSelectQuery(r){const u=this.parentNode!==void 0&&!gt.is(this.parentNode)&&!Vt.is(this.parentNode)&&!ya.is(this.parentNode);this.parentNode===void 0&&r.explain&&(this.visitNode(r.explain),this.append(" ")),u&&this.append("("),r.with&&(this.visitNode(r.with),this.append(" ")),this.append("select "),r.distinctOn&&(this.compileDistinctOn(r.distinctOn),this.append(" ")),r.frontModifiers&&r.frontModifiers.length>0&&(this.compileList(r.frontModifiers," "),this.append(" ")),r.selections&&(this.compileList(r.selections),this.append(" ")),this.visitNode(r.from),r.joins&&(this.append(" "),this.compileList(r.joins," ")),r.where&&(this.append(" "),this.visitNode(r.where)),r.groupBy&&(this.append(" "),this.visitNode(r.groupBy)),r.having&&(this.append(" "),this.visitNode(r.having)),r.setOperations&&(this.append(" "),this.compileList(r.setOperations," ")),r.orderBy&&(this.append(" "),this.visitNode(r.orderBy)),r.limit&&(this.append(" "),this.visitNode(r.limit)),r.offset&&(this.append(" "),this.visitNode(r.offset)),r.endModifiers&&r.endModifiers.length>0&&(this.append(" "),this.compileList(r.endModifiers," ")),u&&this.append(")")}visitFrom(r){this.append("from "),this.compileList(r.froms)}visitSelection(r){this.visitNode(r.selection)}visitColumn(r){this.visitNode(r.column)}compileDistinctOn(r){this.append("distinct on ("),this.compileList(r),this.append(")")}compileList(r,u=", "){const d=r.length-1;for(let b=0;b<=d;b++)this.visitNode(r[b]),bb&&this.visitNode(d[b])}visitOperator(r){this.append(r.operator)}visitTable(r){this.visitNode(r.table)}visitSchemableIdentifier(r){r.schema&&(this.visitNode(r.schema),this.append(".")),this.visitNode(r.identifier)}visitCreateTable(r){this.append("create "),r.frontModifiers&&r.frontModifiers.length>0&&(this.compileList(r.frontModifiers," "),this.append(" ")),r.temporary&&this.append("temporary "),this.append("table "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.table),this.append(" ("),this.compileList([...r.columns,...r.constraints??[]]),this.append(")"),r.onCommit&&(this.append(" on commit "),this.append(r.onCommit)),r.endModifiers&&r.endModifiers.length>0&&(this.append(" "),this.compileList(r.endModifiers," "))}visitColumnDefinition(r){this.visitNode(r.column),this.append(" "),this.visitNode(r.dataType),r.unsigned&&this.append(" unsigned"),r.frontModifiers&&r.frontModifiers.length>0&&(this.append(" "),this.compileList(r.frontModifiers," ")),r.generated&&(this.append(" "),this.visitNode(r.generated)),r.defaultTo&&(this.append(" "),this.visitNode(r.defaultTo)),r.notNull&&this.append(" not null"),r.unique&&this.append(" unique"),r.primaryKey&&this.append(" primary key"),r.autoIncrement&&(this.append(" "),this.append(this.getAutoIncrement())),r.references&&(this.append(" "),this.visitNode(r.references)),r.check&&(this.append(" "),this.visitNode(r.check)),r.endModifiers&&r.endModifiers.length>0&&(this.append(" "),this.compileList(r.endModifiers," "))}getAutoIncrement(){return"auto_increment"}visitReferences(r){this.append("references "),this.visitNode(r.table),this.append(" ("),this.compileList(r.columns),this.append(")"),r.onDelete&&(this.append(" on delete "),this.append(r.onDelete)),r.onUpdate&&(this.append(" on update "),this.append(r.onUpdate))}visitDropTable(r){this.append("drop table "),r.ifExists&&this.append("if exists "),this.visitNode(r.table),r.cascade&&this.append(" cascade")}visitDataType(r){this.append(r.dataType)}visitOrderBy(r){this.append("order by "),this.compileList(r.items)}visitOrderByItem(r){this.visitNode(r.orderBy),r.direction&&(this.append(" "),this.visitNode(r.direction))}visitGroupBy(r){this.append("group by "),this.compileList(r.items)}visitGroupByItem(r){this.visitNode(r.groupBy)}visitUpdateQuery(r){const u=this.nodeStack.find(C.is)!==r;!u&&r.explain&&(this.visitNode(r.explain),this.append(" ")),u&&this.append("("),r.with&&(this.visitNode(r.with),this.append(" ")),this.append("update "),this.visitNode(r.table),this.append(" set "),r.updates&&this.compileList(r.updates),r.from&&(this.append(" "),this.visitNode(r.from)),r.joins&&(this.append(" "),this.compileList(r.joins," ")),r.where&&(this.append(" "),this.visitNode(r.where)),r.returning&&(this.append(" "),this.visitNode(r.returning)),u&&this.append(")")}visitColumnUpdate(r){this.visitNode(r.column),this.append(" = "),this.visitNode(r.value)}visitLimit(r){this.append("limit "),this.visitNode(r.limit)}visitOffset(r){this.append("offset "),this.visitNode(r.offset)}visitOnConflict(r){this.append("on conflict"),r.columns?(this.append(" ("),this.compileList(r.columns),this.append(")")):r.constraint?(this.append(" on constraint "),this.visitNode(r.constraint)):r.indexExpression&&(this.append(" ("),this.visitNode(r.indexExpression),this.append(")")),r.indexWhere&&(this.append(" "),this.visitNode(r.indexWhere)),r.doNothing===!0?this.append(" do nothing"):r.updates&&(this.append(" do update set "),this.compileList(r.updates),r.updateWhere&&(this.append(" "),this.visitNode(r.updateWhere)))}visitOnDuplicateKey(r){this.append("on duplicate key update "),this.compileList(r.updates)}visitCreateIndex(r){this.append("create "),r.unique&&this.append("unique "),this.append("index "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.name),r.table&&(this.append(" on "),this.visitNode(r.table)),r.using&&(this.append(" using "),this.visitNode(r.using)),r.columns&&(this.append(" ("),this.compileList(r.columns),this.append(")")),r.where&&(this.append(" "),this.visitNode(r.where))}visitDropIndex(r){this.append("drop index "),r.ifExists&&this.append("if exists "),this.visitNode(r.name),r.table&&(this.append(" on "),this.visitNode(r.table)),r.cascade&&this.append(" cascade")}visitCreateSchema(r){this.append("create schema "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.schema)}visitDropSchema(r){this.append("drop schema "),r.ifExists&&this.append("if exists "),this.visitNode(r.schema),r.cascade&&this.append(" cascade")}visitPrimaryKeyConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("primary key ("),this.compileList(r.columns),this.append(")")}visitUniqueConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("unique ("),this.compileList(r.columns),this.append(")")}visitCheckConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("check ("),this.visitNode(r.expression),this.append(")")}visitForeignKeyConstraint(r){r.name&&(this.append("constraint "),this.visitNode(r.name),this.append(" ")),this.append("foreign key ("),this.compileList(r.columns),this.append(") "),this.visitNode(r.references),r.onDelete&&(this.append(" on delete "),this.append(r.onDelete)),r.onUpdate&&(this.append(" on update "),this.append(r.onUpdate))}visitList(r){this.compileList(r.items)}visitWith(r){this.append("with "),r.recursive&&this.append("recursive "),this.compileList(r.expressions)}visitCommonTableExpression(r){this.visitNode(r.name),this.append(" as "),this.visitNode(r.expression)}visitCommonTableExpressionName(r){this.visitNode(r.table),r.columns&&(this.append("("),this.compileList(r.columns),this.append(")"))}visitAlterTable(r){this.append("alter table "),this.visitNode(r.table),this.append(" "),r.renameTo&&(this.append("rename to "),this.visitNode(r.renameTo)),r.setSchema&&(this.append("set schema "),this.visitNode(r.setSchema)),r.addConstraint&&this.visitNode(r.addConstraint),r.dropConstraint&&this.visitNode(r.dropConstraint),r.columnAlterations&&this.compileList(r.columnAlterations)}visitAddColumn(r){this.append("add column "),this.visitNode(r.column)}visitRenameColumn(r){this.append("rename column "),this.visitNode(r.column),this.append(" to "),this.visitNode(r.renameTo)}visitDropColumn(r){this.append("drop column "),this.visitNode(r.column)}visitAlterColumn(r){this.append("alter column "),this.visitNode(r.column),this.append(" "),r.dataType&&(this.append("type "),this.visitNode(r.dataType),r.dataTypeExpression&&(this.append("using "),this.visitNode(r.dataTypeExpression))),r.setDefault&&(this.append("set default "),this.visitNode(r.setDefault)),r.dropDefault&&this.append("drop default"),r.setNotNull&&this.append("set not null"),r.dropNotNull&&this.append("drop not null")}visitModifyColumn(r){this.append("modify column "),this.visitNode(r.column)}visitAddConstraint(r){this.append("add "),this.visitNode(r.constraint)}visitDropConstraint(r){this.append("drop constraint "),r.ifExists&&this.append("if exists "),this.visitNode(r.constraintName),r.modifier==="cascade"?this.append(" cascade"):r.modifier==="restrict"&&this.append(" restrict")}visitSetOperation(r){this.append(r.operator),this.append(" "),r.all&&this.append("all "),this.visitNode(r.expression)}visitCreateView(r){this.append("create "),r.orReplace&&this.append("or replace "),r.materialized&&this.append("materialized "),r.temporary&&this.append("temporary "),this.append("view "),r.ifNotExists&&this.append("if not exists "),this.visitNode(r.name),this.append(" "),r.columns&&(this.append("("),this.compileList(r.columns),this.append(") ")),r.as&&(this.append("as "),this.visitNode(r.as))}visitDropView(r){this.append("drop "),r.materialized&&this.append("materialized "),this.append("view "),r.ifExists&&this.append("if exists "),this.visitNode(r.name),r.cascade&&this.append(" cascade")}visitGenerated(r){this.append("generated "),r.always&&this.append("always "),r.byDefault&&this.append("by default "),this.append("as "),r.identity&&this.append("identity"),r.expression&&(this.append("("),this.visitNode(r.expression),this.append(")")),r.stored&&this.append(" stored")}visitDefaultValue(r){this.append("default "),this.visitNode(r.defaultValue)}visitSelectModifier(r){r.rawModifier?this.visitNode(r.rawModifier):this.append(gc[r.modifier])}visitCreateType(r){this.append("create type "),this.visitNode(r.name),r.enum&&(this.append(" as enum "),this.visitNode(r.enum))}visitDropType(r){this.append("drop type "),r.ifExists&&this.append("if exists "),this.visitNode(r.name)}visitExplain(r){this.append("explain"),(r.options||r.format)&&(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),r.options&&(this.visitNode(r.options),r.format&&this.append(this.getExplainOptionsDelimiter())),r.format&&(this.append("format"),this.append(this.getExplainOptionAssignment()),this.append(r.format)),this.append(this.getRightExplainOptionsWrapper()))}visitDefaultInsertValue(r){this.append("default")}visitAggregateFunction(r){this.append(r.func),this.append("("),r.distinct&&this.append("distinct "),this.compileList(r.aggregated),this.append(")"),r.filter&&(this.append(" filter("),this.visitNode(r.filter),this.append(")")),r.over&&(this.append(" "),this.visitNode(r.over))}visitOver(r){this.append("over("),r.partitionBy&&(this.visitNode(r.partitionBy),r.orderBy&&this.append(" ")),r.orderBy&&this.visitNode(r.orderBy),this.append(")")}visitPartitionBy(r){this.append("partition by "),this.compileList(r.items)}visitPartitionByItem(r){this.visitNode(r.partitionBy)}visitBinaryOperation(r){this.visitNode(r.leftOperand),this.append(" "),this.visitNode(r.operator),this.append(" "),this.visitNode(r.rightOperand)}visitUnaryOperation(r){this.visitNode(r.operator),this.isMinusOperator(r.operator)||this.append(" "),this.visitNode(r.operand)}isMinusOperator(r){return _s.is(r)&&r.operator==="-"}visitUsing(r){this.append("using "),this.compileList(r.tables)}visitFunction(r){this.append(r.func),this.append("("),this.compileList(r.arguments),this.append(")")}visitCase(r){this.append("case"),r.value&&(this.append(" "),this.visitNode(r.value)),r.when&&(this.append(" "),this.compileList(r.when," ")),r.else&&(this.append(" else "),this.visitNode(r.else)),this.append(" end"),r.isStatement&&this.append(" case")}visitWhen(r){this.append("when "),this.visitNode(r.condition),r.result&&(this.append(" then "),this.visitNode(r.result))}append(r){g(this,rn,n(this,rn)+r)}appendValue(r){this.addParameter(r),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier(r){const u=this.getLeftIdentifierWrapper(),d=this.getRightIdentifierWrapper();let b="";for(const k of r)b+=k,k===u?b+=u:k===d&&(b+=d);return b}addParameter(r){n(this,Nr).push(r)}appendImmediateValue(r){if(_(r))this.append(`'${r}'`);else if(me(r)||dn(r))this.append(r.toString());else if(Lo(r))this.append("null");else if(Hu(r))this.appendImmediateValue(r.toISOString());else if(Yu(r))this.appendImmediateValue(r.toString());else throw new Error(`invalid immediate value ${r}`)}}rn=new WeakMap,Nr=new WeakMap;const gc=a({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),bc=a({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral"}),Lr=a({raw(t){return a({sql:t,query:Te.createWithSql(t),parameters:a([])})}}),xc=/"/g;class Wc extends vc{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(e){return e.replace(xc,'""')}visitDefaultInsertValue(e){this.append("null")}}const Oc="kysely_migration",qc="kysely_migration_lock";a({__noMigrations__:!0});class Cc{constructor(e){w(this,ws);w(this,nn,void 0);g(this,nn,e)}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let r=n(this,nn).selectFrom("sqlite_schema").where("type","in",["table","view"]).where("name","not like","sqlite_%").select("name").orderBy("name").$castTo();e.withInternalKyselyTables||(r=r.where("name","!=",Oc).where("name","!=",qc));const u=await r.execute();return Promise.all(u.map(({name:d})=>X(this,ws,zu).call(this,d)))}async getMetadata(e){return{tables:await this.getTables(e)}}}nn=new WeakMap,ws=new WeakSet,zu=async function(e){var k,I,j,c,_e,Fe;const r=n(this,nn),u=await r.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),d=(Fe=(_e=(c=(j=(I=(k=u.sql)==null?void 0:k.split(/[\(\),]/))==null?void 0:I.find(P=>P.toLowerCase().includes("autoincrement")))==null?void 0:j.trimStart())==null?void 0:c.split(/\s+/))==null?void 0:_e[0])==null?void 0:Fe.replace(/["`]/g,""),b=await r.selectFrom(Je`pragma_table_info(${e})`.as("table_info")).select(["name","type","notnull","dflt_value"]).orderBy("cid").execute();return{name:e,isView:u.type==="view",columns:b.map(P=>({name:P.name,dataType:P.type,isNullable:!P.notnull,isAutoIncrementing:P.name===d,hasDefaultValue:P.dflt_value!=null}))}};class kc{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var Ic=class{createQueryCompiler(){return new Wc}createAdapter(){return new kc}createIntrospector(t){return new Cc(t)}},Ec=(Fa=class{constructor(){w(this,Kn,new Tc);Xe(this,"connection");w(this,vs,void 0)}async acquireConnection(){return await n(this,Kn).lock(),this.connection}async beginTransaction(t){await t.executeQuery(Lr.raw("begin"))}async commitTransaction(t){await t.executeQuery(Lr.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(Lr.raw("rollback"))}async releaseConnection(){n(this,Kn).unlock()}async destroy(){var t;(t=n(this,vs))==null||t.close()}},Kn=new WeakMap,vs=new WeakMap,Fa),Tc=(Qa=class{constructor(){w(this,wr,void 0);w(this,sn,void 0)}async lock(){for(;n(this,wr);)await n(this,wr);g(this,wr,new Promise(t=>{g(this,sn,t)}))}unlock(){const t=n(this,sn);g(this,wr,void 0),g(this,sn,void 0),t==null||t()}},wr=new WeakMap,sn=new WeakMap,Qa),Ac=class{streamQuery(){throw new Error("Sqlite driver doesn't support streaming")}async executeQuery(t){const{parameters:e,sql:r,query:u}=t;return["SelectQueryNode","RawNode"].includes(u.kind)?{rows:await this.query(r,e)}:{rows:[],...await this.exec(r,e)}}};function Sc({func:t,delay:e,maxCalls:r}){let u,d=0,b=null;function k(){u&&clearTimeout(u),d=0,b=null}function I(){d>=r?(t(b),k()):(u&&clearTimeout(u),u=setTimeout(()=>{t(b),k(),u=void 0},e))}return j=>{d++,b=j,u===void 0&&d===0?(t(j),d++):I()}}var Dc=(Ua=class extends Ec{constructor(e){super();w(this,He,void 0);w(this,on,void 0);g(this,He,e)}async init(){var e,r,u,d;if(g(this,on,typeof n(this,He).database=="function"?await n(this,He).database():n(this,He).database),!n(this,on))throw new Error("no database");this.connection=new Rc(n(this,on),(e=n(this,He).onWrite)==null?void 0:e.func,(r=n(this,He).onWrite)==null?void 0:r.isThrottle,(u=n(this,He).onWrite)==null?void 0:u.maxCalls,(d=n(this,He).onWrite)==null?void 0:d.delay),n(this,He).onCreateConnection&&await n(this,He).onCreateConnection(this.connection)}async beginTransaction(e){await e.executeQuery(Lr.raw("begin")),this.connection&&this.connection.transactionNum++}async commitTransaction(e){await e.executeQuery(Lr.raw("commit")),this.connection&&this.connection.transactionNum--}async rollbackTransaction(e){await e.executeQuery(Lr.raw("rollback")),this.connection&&this.connection.transactionNum--}},He=new WeakMap,on=new WeakMap,Ua),Rc=(Va=class extends Ac{constructor(e,r,u=!1,d=1e3,b=2e3){super();w(this,Ht,void 0);w(this,an,void 0);Xe(this,"transactionNum",0);g(this,Ht,e),g(this,an,r?u?Sc({func:r,maxCalls:d,delay:b}):r:void 0)}query(e,r){const u=n(this,Ht).prepare(e);u.bind(r);const d=[];for(;u.step();)d.push(u.getAsObject());return u.free(),d}exec(e,r){n(this,Ht).run(e,r);const u=BigInt(this.query("SELECT last_insert_rowid() as id")[0].id),d=BigInt(n(this,Ht).getRowsModified());return this.transactionNum===0&&n(this,an)&&n(this,an).call(this,n(this,Ht).export()),{numAffectedRows:d,insertId:u}}},Ht=new WeakMap,an=new WeakMap,Va),Lc=(ja=class extends Ic{constructor(e){super();w(this,zn,void 0);g(this,zn,e)}createDriver(){return new Dc(n(this,zn))}},zn=new WeakMap,ja);function Bc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Mc(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function u(){if(this instanceof u){var d=[null];d.push.apply(d,arguments);var b=Function.bind.apply(e,d);return new b}return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(u){var d=Object.getOwnPropertyDescriptor(t,u);Object.defineProperty(r,u,d.get?d:{enumerable:!0,get:function(){return t[u]}})}),r}var Ma={exports:{}},Pc={},_c=Object.freeze({__proto__:null,default:Pc}),es=Mc(_c);(function(t,e){var r=void 0,u=function(d){return r||(r=new Promise(function(b,k){var I=typeof d<"u"?d:{},j=I.onAbort;I.onAbort=function(i){k(new Error(i)),j&&j(i)},I.postRun=I.postRun||[],I.postRun.push(function(){b(I)}),t=void 0;var c;c||(c=typeof I<"u"?I:{}),c.onRuntimeInitialized=function(){function i(f,v){switch(typeof v){case"boolean":Gl(f,v?1:0);break;case"number":jl(f,v);break;case"string":$l(f,v,-1,-1);break;case"object":if(v===null)_u(f);else if(v.length!=null){var O=Io(v);Jl(f,O,v.length,-1),Ds(O)}else Ls(f,"Wrong API use : tried to return a value of an unknown type ("+v+").",-1);break;default:_u(f)}}function s(f,v){for(var O=[],E=0;E>>0),f!=null){var v=this.filename,O="/",E=v;if(O&&(O=typeof O=="string"?O:ii(O),E=v?Bt(O+"/"+v):O),v=Cu(!0,!0),E=qs(E,(v!==void 0?v:438)&4095|32768,0),f){if(typeof f=="string"){O=Array(f.length);for(var M=0,$=f.length;M<$;++M)O[M]=f.charCodeAt(M);f=O}ks(E,v|146),O=ln(E,577),Wu(O,f,0,f.length,0),go(O),ks(E,v)}}this.handleError(A(this.filename,p)),this.db=Lt(p,"i32"),Kl(this.db),this.Za={},this.Na={}}var p=nr(4),y=c.cwrap,A=y("sqlite3_open","number",["string","number"]),V=y("sqlite3_close_v2","number",["number"]),F=y("sqlite3_exec","number",["number","string","number","number","number"]),pe=y("sqlite3_changes","number",["number"]),Mt=y("sqlite3_prepare_v2","number",["number","string","number","number","number"]),Ru=y("sqlite3_sql","string",["number"]),xl=y("sqlite3_normalized_sql","string",["number"]),Lu=y("sqlite3_prepare_v2","number",["number","number","number","number","number"]),Wl=y("sqlite3_bind_text","number",["number","number","number","number","number"]),Bu=y("sqlite3_bind_blob","number",["number","number","number","number","number"]),Ol=y("sqlite3_bind_double","number",["number","number","number"]),ql=y("sqlite3_bind_int","number",["number","number","number"]),Cl=y("sqlite3_bind_parameter_index","number",["number","string"]),kl=y("sqlite3_step","number",["number"]),Il=y("sqlite3_errmsg","string",["number"]),El=y("sqlite3_column_count","number",["number"]),Tl=y("sqlite3_data_count","number",["number"]),Al=y("sqlite3_column_double","number",["number","number"]),Mu=y("sqlite3_column_text","string",["number","number"]),Sl=y("sqlite3_column_blob","number",["number","number"]),Dl=y("sqlite3_column_bytes","number",["number","number"]),Rl=y("sqlite3_column_type","number",["number","number"]),Ll=y("sqlite3_column_name","string",["number","number"]),Bl=y("sqlite3_reset","number",["number"]),Ml=y("sqlite3_clear_bindings","number",["number"]),Pl=y("sqlite3_finalize","number",["number"]),Pu=y("sqlite3_create_function_v2","number","number string number number number number number number number".split(" ")),_l=y("sqlite3_value_type","number",["number"]),Fl=y("sqlite3_value_bytes","number",["number"]),Ql=y("sqlite3_value_text","string",["number"]),Ul=y("sqlite3_value_blob","number",["number"]),Vl=y("sqlite3_value_double","number",["number"]),jl=y("sqlite3_result_double","",["number","number"]),_u=y("sqlite3_result_null","",["number"]),$l=y("sqlite3_result_text","",["number","string","number","number"]),Jl=y("sqlite3_result_blob","",["number","number","number","number"]),Gl=y("sqlite3_result_int","",["number","number"]),Ls=y("sqlite3_result_error","",["number","string","number"]),Fu=y("sqlite3_aggregate_context","number",["number","number"]),Kl=y("RegisterExtensionFunctions","number",["number"]);o.prototype.bind=function(f){if(!this.La)throw"Statement closed";return this.reset(),Array.isArray(f)?this.xb(f):f!=null&&typeof f=="object"?this.yb(f):!0},o.prototype.step=function(){if(!this.La)throw"Statement closed";this.Ja=1;var f=kl(this.La);switch(f){case 100:return!0;case 101:return!1;default:throw this.db.handleError(f)}},o.prototype.sb=function(f){return f==null&&(f=this.Ja,this.Ja+=1),Al(this.La,f)},o.prototype.Cb=function(f){if(f==null&&(f=this.Ja,this.Ja+=1),f=Mu(this.La,f),typeof BigInt!="function")throw Error("BigInt is not supported");return BigInt(f)},o.prototype.Db=function(f){return f==null&&(f=this.Ja,this.Ja+=1),Mu(this.La,f)},o.prototype.getBlob=function(f){f==null&&(f=this.Ja,this.Ja+=1);var v=Dl(this.La,f);f=Sl(this.La,f);for(var O=new Uint8Array(v),E=0;E{bs||(gs=es,bs=es)},Zn=function(i,s){return ao(),i=bs.normalize(i),gs.readFileSync(i,s?void 0:"utf8")},yt=i=>(i=Zn(i,!0),i.buffer||(i=new Uint8Array(i)),i),Rt=(i,s,o)=>{ao(),i=bs.normalize(i),gs.readFile(i,function(h,l){h?o(h):s(l.buffer)})},1{var s=new XMLHttpRequest;return s.open("GET",i,!1),s.send(null),s.responseText},Re&&(yt=i=>{var s=new XMLHttpRequest;return s.open("GET",i,!1),s.responseType="arraybuffer",s.send(null),new Uint8Array(s.response)}),Rt=(i,s,o)=>{var h=new XMLHttpRequest;h.open("GET",i,!0),h.responseType="arraybuffer",h.onload=()=>{h.status==200||h.status==0&&h.response?s(h.response):o()},h.onerror=o,h.send(null)});var Ka=c.print||console.log.bind(console),gr=c.printErr||console.warn.bind(console);Object.assign(c,_e),_e=null,c.thisProgram&&(Fe=c.thisProgram);var ei;c.wasmBinary&&(ei=c.wasmBinary),c.noExitRuntime,typeof WebAssembly!="object"&&Zt("no native wasm support detected");var uo,za=!1,Ha=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function ti(i,s,o){var h=s+o;for(o=s;i[o]&&!(o>=h);)++o;if(16l?h+=String.fromCharCode(l):(l-=65536,h+=String.fromCharCode(55296|l>>10,56320|l&1023))}}else h+=String.fromCharCode(l)}return h}function We(i,s){return i?ti(qt,i,s):""}function br(i,s,o,h){if(!(0=y){var A=i.charCodeAt(++p);y=65536+((y&1023)<<10)|A&1023}if(127>=y){if(o>=h)break;s[o++]=y}else{if(2047>=y){if(o+1>=h)break;s[o++]=192|y>>6}else{if(65535>=y){if(o+2>=h)break;s[o++]=224|y>>12}else{if(o+3>=h)break;s[o++]=240|y>>18,s[o++]=128|y>>12&63}s[o++]=128|y>>6&63}s[o++]=128|y&63}}return s[o]=0,o-l}function hn(i){for(var s=0,o=0;o=h?s++:2047>=h?s+=2:55296<=h&&57343>=h?(s+=4,++o):s+=3}return s}var ho,we,qt,xs,T,de,co,lo;function Ya(){var i=uo.buffer;ho=i,c.HEAP8=we=new Int8Array(i),c.HEAP16=xs=new Int16Array(i),c.HEAP32=T=new Int32Array(i),c.HEAPU8=qt=new Uint8Array(i),c.HEAPU16=new Uint16Array(i),c.HEAPU32=de=new Uint32Array(i),c.HEAPF32=co=new Float32Array(i),c.HEAPF64=lo=new Float64Array(i)}var Xt,Xa=[],Za=[],eu=[];function al(){var i=c.preRun.shift();Xa.unshift(i)}var xr=0,ri=null;function Zt(i){throw c.onAbort&&c.onAbort(i),i="Aborted("+i+")",gr(i),za=!0,new WebAssembly.RuntimeError(i+". Build with -sASSERTIONS for more info.")}function tu(){return it.startsWith("data:application/octet-stream;base64,")}var it;if(it="sql-wasm.wasm",!tu()){var ru=it;it=c.locateFile?c.locateFile(ru,Ee):Ee+ru}function nu(){var i=it;try{if(i==it&&ei)return new Uint8Array(ei);if(yt)return yt(i);throw"both async and sync fetching of the wasm failed"}catch(s){Zt(s)}}function ul(){if(!ei&&(P||Re)){if(typeof fetch=="function"&&!it.startsWith("file://"))return fetch(it,{credentials:"same-origin"}).then(function(i){if(!i.ok)throw"failed to load wasm binary file at '"+it+"'";return i.arrayBuffer()}).catch(function(){return nu()});if(Rt)return new Promise(function(i,s){Rt(it,function(o){i(new Uint8Array(o))},s)})}return Promise.resolve().then(function(){return nu()})}var S,fe;function fo(i){for(;0>0];case"i8":return we[i>>0];case"i16":return xs[i>>1];case"i32":return T[i>>2];case"i64":return T[i>>2];case"float":return co[i>>2];case"double":return lo[i>>3];case"*":return de[i>>2];default:Zt("invalid type for getValue: "+s)}return null}function ni(i){var s="i32";switch(s.endsWith("*")&&(s="*"),s){case"i1":we[i>>0]=0;break;case"i8":we[i>>0]=0;break;case"i16":xs[i>>1]=0;break;case"i32":T[i>>2]=0;break;case"i64":fe=[0,(S=0,1<=+Math.abs(S)?0>>0:~~+Math.ceil((S-+(~~S>>>0))/4294967296)>>>0:0)],T[i>>2]=fe[0],T[i+4>>2]=fe[1];break;case"float":co[i>>2]=0;break;case"double":lo[i>>3]=0;break;case"*":de[i>>2]=0;break;default:Zt("invalid type for setValue: "+s)}}var po=(i,s)=>{for(var o=0,h=i.length-1;0<=h;h--){var l=i[h];l==="."?i.splice(h,1):l===".."?(i.splice(h,1),o++):o&&(i.splice(h,1),o--)}if(s)for(;o;o--)i.unshift("..");return i},Bt=i=>{var s=i.charAt(0)==="/",o=i.substr(-1)==="/";return(i=po(i.split("/").filter(h=>!!h),!s).join("/"))||s||(i="."),i&&o&&(i+="/"),(s?"/":"")+i},hl=i=>{var s=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(i).slice(1);return i=s[0],s=s[1],!i&&!s?".":(s&&(s=s.substr(0,s.length-1)),i+s)},Ws=i=>{if(i==="/")return"/";i=Bt(i),i=i.replace(/\/$/,"");var s=i.lastIndexOf("/");return s===-1?i:i.substr(s+1)};function cl(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var i=new Uint8Array(1);return()=>(crypto.getRandomValues(i),i[0])}if(Y)try{var s=es;return()=>s.randomBytes(1)[0]}catch{}return()=>Zt("randomDevice")}function Os(){for(var i="",s=!1,o=arguments.length-1;-1<=o&&!s;o--){if(s=0<=o?arguments[o]:"/",typeof s!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!s)return"";i=s+"/"+i,s=s.charAt(0)==="/"}return i=po(i.split("/").filter(h=>!!h),!s).join("/"),(s?"/":"")+i||"."}function iu(i,s){var o=Array(hn(i)+1);return i=br(i,o,0,o.length),s&&(o.length=i),o}var su=[];function ou(i,s){su[i]={input:[],output:[],Xa:s},wo(i,ll)}var ll={open:function(i){var s=su[i.node.rdev];if(!s)throw new N(43);i.tty=s,i.seekable=!1},close:function(i){i.tty.Xa.fsync(i.tty)},fsync:function(i){i.tty.Xa.fsync(i.tty)},read:function(i,s,o,h){if(!i.tty||!i.tty.Xa.tb)throw new N(60);for(var l=0,p=0;p=s||(s=Math.max(s,o*(1048576>o?2:1.125)>>>0),o!=0&&(s=Math.max(s,256)),o=i.Ia,i.Ia=new Uint8Array(s),0=i.node.Ma)return 0;if(i=Math.min(i.node.Ma-l,h),8s)throw new N(28);return s},lb:function(i,s,o){R.qb(i.node,s+o),i.node.Ma=Math.max(i.node.Ma,s+o)},bb:function(i,s,o,h,l){if((i.node.mode&61440)!==32768)throw new N(43);if(i=i.node.Ia,l&2||i.buffer!==ho){if((0{if(i=Os("/",i),!i)return{path:"",node:null};if(s=Object.assign({rb:!0,kb:0},s),8!!y),!1);for(var o=mo,h="/",l=0;l{for(var s;;){if(i===i.parent)return i=i.Ra.ub,s?i[i.length-1]!=="/"?i+"/"+s:i+s:i;s=s?i.name+"/"+s:i.name,i=i.parent}},No=(i,s)=>{for(var o=0,h=0;h>>0)%tr.length},hu=i=>{var s=No(i.parent.id,i.name);if(tr[s]===i)tr[s]=i.Wa;else for(s=tr[s];s;){if(s.Wa===i){s.Wa=i.Wa;break}s=s.Wa}},Wr=(i,s)=>{var o;if(o=(o=cn(i,"x"))?o:i.Ga.lookup?0:2)throw new N(o,i);for(o=tr[No(i.id,s)];o;o=o.Wa){var h=o.name;if(o.parent.id===i.id&&h===s)return o}return i.Ga.lookup(i,s)},cu=(i,s,o,h)=>(i=new Tu(i,s,o,h),s=No(i.parent.id,i.name),i.Wa=tr[s],tr[s]=i),ml={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},lu=i=>{var s=["r","w","rw"][i&3];return i&512&&(s+="w"),s},cn=(i,s)=>{if(uu)return 0;if(!s.includes("r")||i.mode&292){if(s.includes("w")&&!(i.mode&146)||s.includes("x")&&!(i.mode&73))return 2}else return 2;return 0},du=(i,s)=>{try{return Wr(i,s),20}catch{}return cn(i,"wx")},fu=(i,s,o)=>{try{var h=Wr(i,s)}catch(l){return l.Ka}if(i=cn(i,"wx"))return i;if(o){if((h.mode&61440)!==16384)return 54;if(h===h.parent||ii(h)==="/")return 10}else if((h.mode&61440)===16384)return 31;return 0},yl=(i=0)=>{for(;4096>=i;i++)if(!er[i])return i;throw new N(33)},pu=(i,s)=>(ai||(ai=function(){this.$a={}},ai.prototype={},Object.defineProperties(ai.prototype,{object:{get:function(){return this.node},set:function(o){this.node=o}},flags:{get:function(){return this.$a.flags},set:function(o){this.$a.flags=o}},position:{get:function(){return this.$a.position},set:function(o){this.$a.position=o}}})),i=Object.assign(new ai,i),s=yl(s),i.fd=s,er[s]=i),Nl={open:i=>{i.Ha=au[i.node.rdev].Ha,i.Ha.open&&i.Ha.open(i)},Ta:()=>{throw new N(70)}},wo=(i,s)=>{au[i]={Ha:s}},mu=(i,s)=>{var o=s==="/",h=!s;if(o&&mo)throw new N(10);if(!o&&!h){var l=je(s,{rb:!1});if(s=l.path,l=l.node,l.Va)throw new N(10);if((l.mode&61440)!==16384)throw new N(54)}s={type:i,Kb:{},ub:s,Eb:[]},i=i.Ra(s),i.Ra=s,s.root=i,o?mo=i:l&&(l.Va=s,l.Ra&&l.Ra.Eb.push(s))},qs=(i,s,o)=>{var h=je(i,{parent:!0}).node;if(i=Ws(i),!i||i==="."||i==="..")throw new N(28);var l=du(h,i);if(l)throw new N(l);if(!h.Ga.ab)throw new N(63);return h.Ga.ab(h,i,s,o)},Ct=(i,s)=>qs(i,(s!==void 0?s:511)&1023|16384,0),Cs=(i,s,o)=>{typeof o>"u"&&(o=s,s=438),qs(i,s|8192,o)},vo=(i,s)=>{if(!Os(i))throw new N(44);var o=je(s,{parent:!0}).node;if(!o)throw new N(44);s=Ws(s);var h=du(o,s);if(h)throw new N(h);if(!o.Ga.symlink)throw new N(63);o.Ga.symlink(o,s,i)},yu=i=>{var s=je(i,{parent:!0}).node;i=Ws(i);var o=Wr(s,i),h=fu(s,i,!0);if(h)throw new N(h);if(!s.Ga.rmdir)throw new N(63);if(o.Va)throw new N(10);s.Ga.rmdir(s,i),hu(o)},Nu=i=>{var s=je(i,{parent:!0}).node;if(!s)throw new N(44);i=Ws(i);var o=Wr(s,i),h=fu(s,i,!1);if(h)throw new N(h);if(!s.Ga.unlink)throw new N(63);if(o.Va)throw new N(10);s.Ga.unlink(s,i),hu(o)},wu=i=>{if(i=je(i).node,!i)throw new N(44);if(!i.Ga.readlink)throw new N(28);return Os(ii(i.parent),i.Ga.readlink(i))},si=(i,s)=>{if(i=je(i,{Sa:!s}).node,!i)throw new N(44);if(!i.Ga.Pa)throw new N(63);return i.Ga.Pa(i)},vu=i=>si(i,!0),ks=(i,s)=>{if(i=typeof i=="string"?je(i,{Sa:!0}).node:i,!i.Ga.Oa)throw new N(63);i.Ga.Oa(i,{mode:s&4095|i.mode&-4096,timestamp:Date.now()})},gu=(i,s)=>{if(0>s)throw new N(28);if(i=typeof i=="string"?je(i,{Sa:!0}).node:i,!i.Ga.Oa)throw new N(63);if((i.mode&61440)===16384)throw new N(31);if((i.mode&61440)!==32768)throw new N(28);var o=cn(i,"w");if(o)throw new N(o);i.Ga.Oa(i,{size:s,timestamp:Date.now()})},ln=(i,s,o)=>{if(i==="")throw new N(44);if(typeof s=="string"){var h=ml[s];if(typeof h>"u")throw Error("Unknown file open mode: "+s);s=h}if(o=s&64?(typeof o>"u"?438:o)&4095|32768:0,typeof i=="object")var l=i;else{i=Bt(i);try{l=je(i,{Sa:!(s&131072)}).node}catch{}}if(h=!1,s&64)if(l){if(s&128)throw new N(20)}else l=qs(i,o,0),h=!0;if(!l)throw new N(44);if((l.mode&61440)===8192&&(s&=-513),s&65536&&(l.mode&61440)!==16384)throw new N(54);if(!h&&(o=l?(l.mode&61440)===40960?32:(l.mode&61440)===16384&&(lu(s)!=="r"||s&512)?31:cn(l,lu(s)):44))throw new N(o);return s&512&&!h&&gu(l,0),s&=-131713,l=pu({node:l,path:ii(l),flags:s,seekable:!0,position:0,Ha:l.Ha,Ib:[],error:!1}),l.Ha.open&&l.Ha.open(l),!c.logReadFiles||s&1||(Is||(Is={}),i in Is||(Is[i]=1)),l},go=i=>{if(i.fd===null)throw new N(8);i.hb&&(i.hb=null);try{i.Ha.close&&i.Ha.close(i)}catch(s){throw s}finally{er[i.fd]=null}i.fd=null},bu=(i,s,o)=>{if(i.fd===null)throw new N(8);if(!i.seekable||!i.Ha.Ta)throw new N(70);if(o!=0&&o!=1&&o!=2)throw new N(28);i.position=i.Ha.Ta(i,s,o),i.Ib=[]},xu=(i,s,o,h,l)=>{if(0>h||0>l)throw new N(28);if(i.fd===null)throw new N(8);if((i.flags&2097155)===1)throw new N(8);if((i.node.mode&61440)===16384)throw new N(31);if(!i.Ha.read)throw new N(28);var p=typeof l<"u";if(!p)l=i.position;else if(!i.seekable)throw new N(70);return s=i.Ha.read(i,s,o,h,l),p||(i.position+=s),s},Wu=(i,s,o,h,l)=>{if(0>h||0>l)throw new N(28);if(i.fd===null)throw new N(8);if(!(i.flags&2097155))throw new N(8);if((i.node.mode&61440)===16384)throw new N(31);if(!i.Ha.write)throw new N(28);i.seekable&&i.flags&1024&&bu(i,0,2);var p=typeof l<"u";if(!p)l=i.position;else if(!i.seekable)throw new N(70);return s=i.Ha.write(i,s,o,h,l,void 0),p||(i.position+=s),s},wl=i=>{var s,o=ln(i,o||0);i=si(i).size;var h=new Uint8Array(i);return xu(o,h,0,i,0),s=h,go(o),s},Ou=()=>{N||(N=function(i,s){this.node=s,this.Hb=function(o){this.Ka=o},this.Hb(i),this.message="FS error"},N.prototype=Error(),N.prototype.constructor=N,[44].forEach(i=>{yo[i]=new N(i),yo[i].stack=""}))},qu,Cu=(i,s)=>{var o=0;return i&&(o|=365),s&&(o|=146),o},oi=(i,s,o)=>{i=Bt("/dev/"+i);var h=Cu(!!s,!!o);bo||(bo=64);var l=bo++<<8|0;wo(l,{open:p=>{p.seekable=!1},close:()=>{o&&o.buffer&&o.buffer.length&&o(10)},read:(p,y,A,V)=>{for(var F=0,pe=0;pe{for(var F=0;F>2]=h.dev,T[o+8>>2]=h.ino,T[o+12>>2]=h.mode,de[o+16>>2]=h.nlink,T[o+20>>2]=h.uid,T[o+24>>2]=h.gid,T[o+28>>2]=h.rdev,fe=[h.size>>>0,(S=h.size,1<=+Math.abs(S)?0>>0:~~+Math.ceil((S-+(~~S>>>0))/4294967296)>>>0:0)],T[o+40>>2]=fe[0],T[o+44>>2]=fe[1],T[o+48>>2]=4096,T[o+52>>2]=h.blocks,fe=[Math.floor(h.atime.getTime()/1e3)>>>0,(S=Math.floor(h.atime.getTime()/1e3),1<=+Math.abs(S)?0>>0:~~+Math.ceil((S-+(~~S>>>0))/4294967296)>>>0:0)],T[o+56>>2]=fe[0],T[o+60>>2]=fe[1],de[o+64>>2]=0,fe=[Math.floor(h.mtime.getTime()/1e3)>>>0,(S=Math.floor(h.mtime.getTime()/1e3),1<=+Math.abs(S)?0>>0:~~+Math.ceil((S-+(~~S>>>0))/4294967296)>>>0:0)],T[o+72>>2]=fe[0],T[o+76>>2]=fe[1],de[o+80>>2]=0,fe=[Math.floor(h.ctime.getTime()/1e3)>>>0,(S=Math.floor(h.ctime.getTime()/1e3),1<=+Math.abs(S)?0>>0:~~+Math.ceil((S-+(~~S>>>0))/4294967296)>>>0:0)],T[o+88>>2]=fe[0],T[o+92>>2]=fe[1],de[o+96>>2]=0,fe=[h.ino>>>0,(S=h.ino,1<=+Math.abs(S)?0>>0:~~+Math.ceil((S-+(~~S>>>0))/4294967296)>>>0:0)],T[o+104>>2]=fe[0],T[o+108>>2]=fe[1],0}var Ts=void 0;function As(){return Ts+=4,T[Ts-4>>2]}function Nt(i){if(i=er[i],!i)throw new N(8);return i}function xo(i){return de[i>>2]+4294967296*T[i+4>>2]}function ku(i){var s=hn(i)+1,o=Ss(s);return o&&br(i,we,o,s),o}function vl(i,s,o){function h(V){return(V=V.toTimeString().match(/\(([A-Za-z ]+)\)$/))?V[1]:"GMT"}var l=new Date().getFullYear(),p=new Date(l,0,1),y=new Date(l,6,1);l=p.getTimezoneOffset();var A=y.getTimezoneOffset();T[i>>2]=60*Math.max(l,A),T[s>>2]=+(l!=A),i=h(p),s=h(y),i=ku(i),s=ku(s),A>2]=i,de[o+4>>2]=s):(de[o>>2]=s,de[o+4>>2]=i)}function Wo(i,s,o){Wo.Bb||(Wo.Bb=!0,vl(i,s,o))}var Iu;Iu=Y?()=>{var i=process.hrtime();return 1e3*i[0]+i[1]/1e6}:()=>performance.now();var Oo={};function Eu(){if(!qo){var i={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:Fe||"./this.program"},s;for(s in Oo)Oo[s]===void 0?delete i[s]:i[s]=Oo[s];var o=[];for(s in i)o.push(s+"="+i[s]);qo=o}return qo}var qo,rr=void 0,Co=[];function ko(i,s){if(!rr){rr=new WeakMap;var o=Xt.length;if(rr)for(var h=0;h<0+o;h++){var l=Xt.get(h);l&&rr.set(l,h)}}if(rr.has(i))return rr.get(i);if(Co.length)o=Co.pop();else{try{Xt.grow(1)}catch(A){throw A instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":A}o=Xt.length-1}try{Xt.set(o,i)}catch(A){if(!(A instanceof TypeError))throw A;if(typeof WebAssembly.Function=="function"){h=WebAssembly.Function,l={i:"i32",j:"i64",f:"f32",d:"f64",p:"i32"};for(var p={parameters:[],results:s[0]=="v"?[]:[l[s[0]]]},y=1;yy?h.push(y):h.push(y%128|128,y>>7),y=0;yl?s.push(l):s.push(l%128|128,l>>7),s.push.apply(s,h),s.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),s=new WebAssembly.Module(new Uint8Array(s)),s=new WebAssembly.Instance(s,{e:{f:i}}).exports.f}Xt.set(o,s)}return rr.set(i,o),o}function ui(i){rr.delete(Xt.get(i)),Co.push(i)}function Io(i){var s=Ss(i.length);return i.subarray||i.slice||(i=new Uint8Array(i)),qt.set(i,s),s}function gl(i,s,o,h){var l={string:F=>{var pe=0;if(F!=null&&F!==0){var Mt=(F.length<<2)+1;pe=nr(Mt),br(F,qt,pe,Mt)}return pe},array:F=>{var pe=nr(F.length);return we.set(F,pe),pe}};i=c["_"+i];var p=[],y=0;if(h)for(var A=0;A{Ct("/dev"),wo(259,{read:()=>0,write:(s,o,h,l)=>l}),Cs("/dev/null",259),ou(1280,dl),ou(1536,fl),Cs("/dev/tty",1280),Cs("/dev/tty1",1536);var i=cl();oi("random",i),oi("urandom",i),Ct("/dev/shm"),Ct("/dev/shm/tmp")})(),(()=>{Ct("/proc");var i=Ct("/proc/self");Ct("/proc/self/fd"),mu({Ra:()=>{var s=cu(i,"fd",16895,73);return s.Ga={lookup:(o,h)=>{var l=er[+h];if(!l)throw new N(8);return o={parent:null,Ra:{ub:"fake"},Ga:{readlink:()=>l.path}},o.parent=o}},s}},"/proc/self/fd")})();var bl={a:function(i,s,o,h){Zt("Assertion failed: "+We(i)+", at: "+[s?We(s):"unknown filename",o,h?We(h):"unknown function"])},h:function(i,s){try{return i=We(i),ks(i,s),0}catch(o){if(typeof ie>"u"||!(o instanceof N))throw o;return-o.Ka}},H:function(i,s,o){try{if(s=We(s),s=Or(i,s),o&-8)return-28;var h=je(s,{Sa:!0}).node;return h?(i="",o&4&&(i+="r"),o&2&&(i+="w"),o&1&&(i+="x"),i&&cn(h,i)?-2:0):-44}catch(l){if(typeof ie>"u"||!(l instanceof N))throw l;return-l.Ka}},i:function(i,s){try{var o=er[i];if(!o)throw new N(8);return ks(o.node,s),0}catch(h){if(typeof ie>"u"||!(h instanceof N))throw h;return-h.Ka}},g:function(i){try{var s=er[i];if(!s)throw new N(8);var o=s.node,h=typeof o=="string"?je(o,{Sa:!0}).node:o;if(!h.Ga.Oa)throw new N(63);return h.Ga.Oa(h,{timestamp:Date.now()}),0}catch(l){if(typeof ie>"u"||!(l instanceof N))throw l;return-l.Ka}},b:function(i,s,o){Ts=o;try{var h=Nt(i);switch(s){case 0:var l=As();return 0>l?-28:pu(h,l).fd;case 1:case 2:return 0;case 3:return h.flags;case 4:return l=As(),h.flags|=l,0;case 5:return l=As(),xs[l+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return T[Au()>>2]=28,-1;default:return-28}}catch(p){if(typeof ie>"u"||!(p instanceof N))throw p;return-p.Ka}},G:function(i,s){try{var o=Nt(i);return Es(si,o.path,s)}catch(h){if(typeof ie>"u"||!(h instanceof N))throw h;return-h.Ka}},l:function(i,s,o){try{if(s=o+2097152>>>0<4194305-!!s?(s>>>0)+4294967296*o:NaN,isNaN(s))return-61;var h=er[i];if(!h)throw new N(8);if(!(h.flags&2097155))throw new N(28);return gu(h.node,s),0}catch(l){if(typeof ie>"u"||!(l instanceof N))throw l;return-l.Ka}},B:function(i,s){try{if(s===0)return-28;var o=hn("/")+1;return s"u"||!(h instanceof N))throw h;return-h.Ka}},E:function(i,s){try{return i=We(i),Es(vu,i,s)}catch(o){if(typeof ie>"u"||!(o instanceof N))throw o;return-o.Ka}},y:function(i,s,o){try{return s=We(s),s=Or(i,s),s=Bt(s),s[s.length-1]==="/"&&(s=s.substr(0,s.length-1)),Ct(s,o),0}catch(h){if(typeof ie>"u"||!(h instanceof N))throw h;return-h.Ka}},D:function(i,s,o,h){try{s=We(s);var l=h&256;return s=Or(i,s,h&4096),Es(l?vu:si,s,o)}catch(p){if(typeof ie>"u"||!(p instanceof N))throw p;return-p.Ka}},v:function(i,s,o,h){Ts=h;try{s=We(s),s=Or(i,s);var l=h?As():0;return ln(s,o,l).fd}catch(p){if(typeof ie>"u"||!(p instanceof N))throw p;return-p.Ka}},t:function(i,s,o,h){try{if(s=We(s),s=Or(i,s),0>=h)return-28;var l=wu(s),p=Math.min(h,hn(l)),y=we[o+p];return br(l,qt,o,h+1),we[o+p]=y,p}catch(A){if(typeof ie>"u"||!(A instanceof N))throw A;return-A.Ka}},s:function(i){try{return i=We(i),yu(i),0}catch(s){if(typeof ie>"u"||!(s instanceof N))throw s;return-s.Ka}},F:function(i,s){try{return i=We(i),Es(si,i,s)}catch(o){if(typeof ie>"u"||!(o instanceof N))throw o;return-o.Ka}},p:function(i,s,o){try{return s=We(s),s=Or(i,s),o===0?Nu(s):o===512?yu(s):Zt("Invalid flags passed to unlinkat"),0}catch(h){if(typeof ie>"u"||!(h instanceof N))throw h;return-h.Ka}},o:function(i,s,o){try{if(s=We(s),s=Or(i,s,!0),o){var h=xo(o),l=T[o+8>>2];p=1e3*h+l/1e6,o+=16,h=xo(o),l=T[o+8>>2],y=1e3*h+l/1e6}else var p=Date.now(),y=p;i=p;var A=je(s,{Sa:!0}).node;return A.Ga.Oa(A,{timestamp:Math.max(i,y)}),0}catch(V){if(typeof ie>"u"||!(V instanceof N))throw V;return-V.Ka}},e:function(){return Date.now()},j:function(i,s){i=new Date(1e3*xo(i)),T[s>>2]=i.getSeconds(),T[s+4>>2]=i.getMinutes(),T[s+8>>2]=i.getHours(),T[s+12>>2]=i.getDate(),T[s+16>>2]=i.getMonth(),T[s+20>>2]=i.getFullYear()-1900,T[s+24>>2]=i.getDay();var o=new Date(i.getFullYear(),0,1);T[s+28>>2]=(i.getTime()-o.getTime())/864e5|0,T[s+36>>2]=-(60*i.getTimezoneOffset());var h=new Date(i.getFullYear(),6,1).getTimezoneOffset();o=o.getTimezoneOffset(),T[s+32>>2]=(h!=o&&i.getTimezoneOffset()==Math.min(o,h))|0},w:function(i,s,o,h,l,p){try{var y=Nt(h);if(s&2&&!(o&2)&&(y.flags&2097155)!==2)throw new N(2);if((y.flags&2097155)===1)throw new N(2);if(!y.Ha.bb)throw new N(43);var A=y.Ha.bb(y,i,l,s,o),V=A.Fb;return T[p>>2]=A.vb,V}catch(F){if(typeof ie>"u"||!(F instanceof N))throw F;return-F.Ka}},x:function(i,s,o,h,l,p){try{var y=Nt(l);if(o&2){var A=qt.slice(i,i+s);y&&y.Ha.cb&&y.Ha.cb(y,A,p,s,h)}}catch(V){if(typeof ie>"u"||!(V instanceof N))throw V;return-V.Ka}},n:Wo,q:function(){return 2147483648},d:Iu,c:function(i){var s=qt.length;if(i>>>=0,2147483648=o;o*=2){var h=s*(1+.2/o);h=Math.min(h,i+100663296);var l=Math;h=Math.max(i,h),l=l.min.call(l,2147483648,h+(65536-h%65536)%65536);e:{try{uo.grow(l-ho.byteLength+65535>>>16),Ya();var p=1;break e}catch{}p=void 0}if(p)return!0}return!1},z:function(i,s){var o=0;return Eu().forEach(function(h,l){var p=s+o;for(l=de[i+4*l>>2]=p,p=0;p>0]=h.charCodeAt(p);we[l>>0]=0,o+=h.length+1}),0},A:function(i,s){var o=Eu();de[i>>2]=o.length;var h=0;return o.forEach(function(l){h+=l.length+1}),de[s>>2]=h,0},f:function(i){try{var s=Nt(i);return go(s),0}catch(o){if(typeof ie>"u"||!(o instanceof N))throw o;return o.Ka}},m:function(i,s){try{var o=Nt(i);return we[s>>0]=o.tty?2:(o.mode&61440)===16384?3:(o.mode&61440)===40960?7:4,0}catch(h){if(typeof ie>"u"||!(h instanceof N))throw h;return h.Ka}},u:function(i,s,o,h){try{e:{var l=Nt(i);i=s;for(var p=s=0;p>2],A=de[i+4>>2];i+=8;var V=xu(l,we,y,A);if(0>V){var F=-1;break e}if(s+=V,V>2]=F,0}catch(pe){if(typeof ie>"u"||!(pe instanceof N))throw pe;return pe.Ka}},k:function(i,s,o,h,l){try{if(s=o+2097152>>>0<4194305-!!s?(s>>>0)+4294967296*o:NaN,isNaN(s))return 61;var p=Nt(i);return bu(p,s,h),fe=[p.position>>>0,(S=p.position,1<=+Math.abs(S)?0>>0:~~+Math.ceil((S-+(~~S>>>0))/4294967296)>>>0:0)],T[l>>2]=fe[0],T[l+4>>2]=fe[1],p.hb&&s===0&&h===0&&(p.hb=null),0}catch(y){if(typeof ie>"u"||!(y instanceof N))throw y;return y.Ka}},C:function(i){try{var s=Nt(i);return s.Ha&&s.Ha.fsync?s.Ha.fsync(s):0}catch(o){if(typeof ie>"u"||!(o instanceof N))throw o;return o.Ka}},r:function(i,s,o,h){try{e:{var l=Nt(i);i=s;for(var p=s=0;p>2],A=de[i+4>>2];i+=8;var V=Wu(l,we,y,A);if(0>V){var F=-1;break e}s+=V}F=s}return de[h>>2]=F,0}catch(pe){if(typeof ie>"u"||!(pe instanceof N))throw pe;return pe.Ka}}};(function(){function i(l){c.asm=l.exports,uo=c.asm.I,Ya(),Xt=c.asm.Aa,Za.unshift(c.asm.J),xr--,c.monitorRunDependencies&&c.monitorRunDependencies(xr),xr==0&&ri&&(l=ri,ri=null,l())}function s(l){i(l.instance)}function o(l){return ul().then(function(p){return WebAssembly.instantiate(p,h)}).then(function(p){return p}).then(l,function(p){gr("failed to asynchronously prepare wasm: "+p),Zt(p)})}var h={a:bl};if(xr++,c.monitorRunDependencies&&c.monitorRunDependencies(xr),c.instantiateWasm)try{return c.instantiateWasm(h,i)}catch(l){return gr("Module.instantiateWasm callback failed with error: "+l),!1}return function(){return ei||typeof WebAssembly.instantiateStreaming!="function"||tu()||it.startsWith("file://")||Y||typeof fetch!="function"?o(s):fetch(it,{credentials:"same-origin"}).then(function(l){return WebAssembly.instantiateStreaming(l,h).then(s,function(p){return gr("wasm streaming compile failed: "+p),gr("falling back to ArrayBuffer instantiation"),o(s)})})}(),{}})(),c.___wasm_call_ctors=function(){return(c.___wasm_call_ctors=c.asm.J).apply(null,arguments)},c._sqlite3_free=function(){return(c._sqlite3_free=c.asm.K).apply(null,arguments)},c._sqlite3_value_double=function(){return(c._sqlite3_value_double=c.asm.L).apply(null,arguments)},c._sqlite3_value_text=function(){return(c._sqlite3_value_text=c.asm.M).apply(null,arguments)};var Au=c.___errno_location=function(){return(Au=c.___errno_location=c.asm.N).apply(null,arguments)};c._sqlite3_prepare_v2=function(){return(c._sqlite3_prepare_v2=c.asm.O).apply(null,arguments)},c._sqlite3_step=function(){return(c._sqlite3_step=c.asm.P).apply(null,arguments)},c._sqlite3_finalize=function(){return(c._sqlite3_finalize=c.asm.Q).apply(null,arguments)},c._sqlite3_reset=function(){return(c._sqlite3_reset=c.asm.R).apply(null,arguments)},c._sqlite3_value_int=function(){return(c._sqlite3_value_int=c.asm.S).apply(null,arguments)},c._sqlite3_clear_bindings=function(){return(c._sqlite3_clear_bindings=c.asm.T).apply(null,arguments)},c._sqlite3_value_blob=function(){return(c._sqlite3_value_blob=c.asm.U).apply(null,arguments)},c._sqlite3_value_bytes=function(){return(c._sqlite3_value_bytes=c.asm.V).apply(null,arguments)},c._sqlite3_value_type=function(){return(c._sqlite3_value_type=c.asm.W).apply(null,arguments)},c._sqlite3_result_blob=function(){return(c._sqlite3_result_blob=c.asm.X).apply(null,arguments)},c._sqlite3_result_double=function(){return(c._sqlite3_result_double=c.asm.Y).apply(null,arguments)},c._sqlite3_result_error=function(){return(c._sqlite3_result_error=c.asm.Z).apply(null,arguments)},c._sqlite3_result_int=function(){return(c._sqlite3_result_int=c.asm._).apply(null,arguments)},c._sqlite3_result_int64=function(){return(c._sqlite3_result_int64=c.asm.$).apply(null,arguments)},c._sqlite3_result_null=function(){return(c._sqlite3_result_null=c.asm.aa).apply(null,arguments)},c._sqlite3_result_text=function(){return(c._sqlite3_result_text=c.asm.ba).apply(null,arguments)},c._sqlite3_sql=function(){return(c._sqlite3_sql=c.asm.ca).apply(null,arguments)},c._sqlite3_aggregate_context=function(){return(c._sqlite3_aggregate_context=c.asm.da).apply(null,arguments)},c._sqlite3_column_count=function(){return(c._sqlite3_column_count=c.asm.ea).apply(null,arguments)},c._sqlite3_data_count=function(){return(c._sqlite3_data_count=c.asm.fa).apply(null,arguments)},c._sqlite3_column_blob=function(){return(c._sqlite3_column_blob=c.asm.ga).apply(null,arguments)},c._sqlite3_column_bytes=function(){return(c._sqlite3_column_bytes=c.asm.ha).apply(null,arguments)},c._sqlite3_column_double=function(){return(c._sqlite3_column_double=c.asm.ia).apply(null,arguments)},c._sqlite3_column_text=function(){return(c._sqlite3_column_text=c.asm.ja).apply(null,arguments)},c._sqlite3_column_type=function(){return(c._sqlite3_column_type=c.asm.ka).apply(null,arguments)},c._sqlite3_column_name=function(){return(c._sqlite3_column_name=c.asm.la).apply(null,arguments)},c._sqlite3_bind_blob=function(){return(c._sqlite3_bind_blob=c.asm.ma).apply(null,arguments)},c._sqlite3_bind_double=function(){return(c._sqlite3_bind_double=c.asm.na).apply(null,arguments)},c._sqlite3_bind_int=function(){return(c._sqlite3_bind_int=c.asm.oa).apply(null,arguments)},c._sqlite3_bind_text=function(){return(c._sqlite3_bind_text=c.asm.pa).apply(null,arguments)},c._sqlite3_bind_parameter_index=function(){return(c._sqlite3_bind_parameter_index=c.asm.qa).apply(null,arguments)},c._sqlite3_normalized_sql=function(){return(c._sqlite3_normalized_sql=c.asm.ra).apply(null,arguments)},c._sqlite3_errmsg=function(){return(c._sqlite3_errmsg=c.asm.sa).apply(null,arguments)},c._sqlite3_exec=function(){return(c._sqlite3_exec=c.asm.ta).apply(null,arguments)},c._sqlite3_changes=function(){return(c._sqlite3_changes=c.asm.ua).apply(null,arguments)},c._sqlite3_close_v2=function(){return(c._sqlite3_close_v2=c.asm.va).apply(null,arguments)},c._sqlite3_create_function_v2=function(){return(c._sqlite3_create_function_v2=c.asm.wa).apply(null,arguments)},c._sqlite3_open=function(){return(c._sqlite3_open=c.asm.xa).apply(null,arguments)};var Ss=c._malloc=function(){return(Ss=c._malloc=c.asm.ya).apply(null,arguments)},Ds=c._free=function(){return(Ds=c._free=c.asm.za).apply(null,arguments)};c._RegisterExtensionFunctions=function(){return(c._RegisterExtensionFunctions=c.asm.Ba).apply(null,arguments)};var Su=c._emscripten_builtin_memalign=function(){return(Su=c._emscripten_builtin_memalign=c.asm.Ca).apply(null,arguments)},hi=c.stackSave=function(){return(hi=c.stackSave=c.asm.Da).apply(null,arguments)},ci=c.stackRestore=function(){return(ci=c.stackRestore=c.asm.Ea).apply(null,arguments)},nr=c.stackAlloc=function(){return(nr=c.stackAlloc=c.asm.Fa).apply(null,arguments)};c.UTF8ToString=We,c.stackAlloc=nr,c.stackSave=hi,c.stackRestore=ci,c.cwrap=function(i,s,o,h){o=o||[];var l=o.every(p=>p==="number"||p==="boolean");return s!=="string"&&l&&!h?c["_"+i]:function(){return gl(i,s,o,arguments)}};var Rs;ri=function i(){Rs||Du(),Rs||(ri=i)};function Du(){function i(){if(!Rs&&(Rs=!0,c.calledRun=!0,!za)){if(c.noFSInit||qu||(qu=!0,Ou(),c.stdin=c.stdin,c.stdout=c.stdout,c.stderr=c.stderr,c.stdin?oi("stdin",c.stdin):vo("/dev/tty","/dev/stdin"),c.stdout?oi("stdout",null,c.stdout):vo("/dev/tty","/dev/stdout"),c.stderr?oi("stderr",null,c.stderr):vo("/dev/tty1","/dev/stderr"),ln("/dev/stdin",0),ln("/dev/stdout",1),ln("/dev/stderr",1)),uu=!1,fo(Za),c.onRuntimeInitialized&&c.onRuntimeInitialized(),c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;){var s=c.postRun.shift();eu.unshift(s)}fo(eu)}}if(!(0=this._size)return 0;const u=this._data.subarray(e,Math.min(this._size,e+r.length));return r.set(u),u.length}reserve(e){if(this._data.length>=e)return;const r=e-this._data.length,u=Math.min($c,Math.max(jc,this._data.length)),d=new Uint8Array(this._data.length+Math.max(u,r));d.set(this._data),this._data=d}write(e,r){return this.reserve(e+r.length),this._data.set(r,e),this._size=Math.max(this._size,e+r.length),r.length}truncate(e){this._size=e}toUint8Array(){return this._data.subarray(0,this._size)}}const Gc=self.indexedDB||window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB||window.shimIndexedDB,Pa=new Promise((t,e)=>{const r=Gc.open(Vc,1);r.onupgradeneeded=()=>r.result.createObjectStore("files",{keyPath:"name"}),r.onsuccess=()=>t(r.result),r.onerror=()=>e(r.error)});async function Kc(t){const e=await Pa,r=await new Promise((u,d)=>{const k=e.transaction("files","readonly").objectStore("files").get(t);k.onsuccess=()=>u(k.result),k.onerror=()=>d(k.error)});if(r&&!Br.has(t)){const u=new Jc(r.data);return Br.set(t,u),u}else return Br.has(t)?Br.get(t):null}async function zc(t,e){const r=await Pa;await new Promise((u,d)=>{const k=r.transaction("files","readwrite").objectStore("files").put({name:t,data:e});k.onsuccess=()=>u(!0),k.onerror=()=>d(k.error)})}async function Hc(t,e){if(await zc(t,e),Br.has(t)){const r=Br.get(t);r.truncate(0),r.write(0,e)}}var Yc=t=>t==null||typeof t=="bigint"||typeof t=="number"||typeof t=="object"&&"buffer"in t?t:typeof t=="boolean"?`${t}`:t instanceof Date?t.toISOString():JSON.stringify(t),Xc=t=>{if(t==null||typeof t=="bigint"||typeof t=="number"||typeof t=="object"&&"buffer"in t)return t;if(typeof t=="string"){const e=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?$/;if(/^(true|false)$/.test(t))return t==="true";if(e.test(t))return new Date(t);try{return JSON.parse(t,(r,u)=>typeof u=="string"&&e.exec(u)?new Date(u):u)}catch{}}return t},Zc=($a=class extends Js{constructor(e){super();w(this,vr,void 0);g(this,vr,e||Yc)}transformPrimitiveValueList(e){return{...e,values:e.values.map(n(this,vr))}}transformColumnUpdate(e){const{value:r}=e;if(r.kind!=="ValueNode")return super.transformColumnUpdate(e);const{value:u,...d}=r,b=n(this,vr).call(this,u);return u===b?super.transformColumnUpdate(e):super.transformColumnUpdate({...e,value:{...d,value:b}})}transformValue(e){return{...e,value:n(this,vr).call(this,e.value)}}},vr=new WeakMap,$a),el=(Ja=class{constructor(t={}){w(this,Hn,void 0);w(this,Yn,void 0);w(this,un,void 0);g(this,Hn,new Zc(t.serializer)),g(this,Yn,t.deserializer||Xc),g(this,un,new WeakMap)}transformQuery(t){const{node:e,queryId:r}=t;return e.kind==="SelectQueryNode"&&n(this,un).set(r,e.kind),n(this,Hn).transformNode(t.node)}async parseResult(t){return await Promise.all(t.map(async e=>{const r={...e};for(const u in r)r[u]=await n(this,Yn).call(this,r[u]);return r}))}async transformResult(t){const{result:e,queryId:r}=t,{rows:u}=e,d=n(this,un).get(r);return u&&d==="SelectQueryNode"?{...t.result,rows:await this.parseResult(u)}:t.result}},Hn=new WeakMap,Yn=new WeakMap,un=new WeakMap,Ja);function to(t){return typeof t=="string"}function tl(t){return typeof t=="boolean"}async function _a(t,e,r,u,d="rowid"){await Je` create trigger if not exists ${Je.raw(e)}_${Je.raw(u)} diff --git a/assets/worker-cda8cefb.js b/assets/worker-72ad2512.js similarity index 83% rename from assets/worker-cda8cefb.js rename to assets/worker-72ad2512.js index 40bcd9b..b4b0f03 100644 --- a/assets/worker-cda8cefb.js +++ b/assets/worker-72ad2512.js @@ -1,3 +1,3 @@ -var as=Object.defineProperty;var cs=(C,K,D)=>K in C?as(C,K,{enumerable:!0,configurable:!0,writable:!0,value:D}):C[K]=D;var Ye=(C,K,D)=>(cs(C,typeof K!="symbol"?K+"":K,D),D),Ze=(C,K,D)=>{if(!K.has(C))throw TypeError("Cannot "+D)};var y=(C,K,D)=>(Ze(C,K,"read from private field"),D?D.call(C):K.get(C)),F=(C,K,D)=>{if(K.has(C))throw TypeError("Cannot add the same private member more than once");K instanceof WeakSet?K.add(C):K.set(C,D)},X=(C,K,D,Yt)=>(Ze(C,K,"write to private field"),Yt?Yt.call(C,D):K.set(C,D),D);var ot=(C,K,D)=>(Ze(C,K,"access private method"),D);(function(){var rt,Mt,Gt,Jt,Ge,ce,ri,le,ii,hn,Ht,Qt,te,tt,ee,Vt,Nt,fe,si,mn,J,_n,Ot,pn,Et,it,Y,kt,Lt,yt,ne,Je,he,oi,me,ui,xt,Xt,_e,ai,dn;"use strict";var C=0,K=5,D=10,Yt=12,tn=14,Ct=21,Te=25,ci=27,Ne=100,li=101,fi=3850,hi=522,mi=1,_i=2,en=4,pi=8,Bt=0,Tt=1,ue=2,di=3,ae=4,wi=512,bi=1024,yi=2048,gi=16384,nn=1,rn=2,sn=3,on=4,un=5,an=0x7fffffffffffffffn,cn=-0x8000000000000000n,bt=class extends Error{constructor(u,s){super(u),this.code=s}},Ft=!0;function vi(u){const s={},r=u._getSqliteFree(),v=u._malloc(8),d=[v,v+4];function A(c){if(typeof c!="string")return 0;const l=u.lengthBytesUTF8(c),a=u._sqlite3_malloc(l+1);return u.stringToUTF8(c,a,l+1),a}function T(c,l){return BigInt(l)<<32n|BigInt(c)&0xffffffffn}const P=function(){const c=BigInt(Number.MAX_SAFE_INTEGER)>>32n,l=BigInt(Number.MIN_SAFE_INTEGER)>>32n;return function(a,h){return h>c||h2147483647||w<-2147483648)return Te;const q=l(a,h,w);return M(c,q,U.get(a))}}(),s.bind_int64=function(){const c="sqlite3_bind_int64",l=u.cwrap(c,...N("nnnn:n"));return function(a,h,w){if(k(a),w>an||w>32n,R=l(a,h,Number(q),Number(W));return M(c,R,U.get(a))}}(),s.bind_null=function(){const c="sqlite3_bind_null",l=u.cwrap(c,...N("nn:n"));return function(a,h){k(a);const w=l(a,h);return M(c,w,U.get(a))}}(),s.bind_parameter_name=function(){const c="sqlite3_bind_parameter_name",l=u.cwrap(c,...N("n:s"));return function(a,h){return k(a),l(a,h)}}(),s.bind_text=function(){const c="sqlite3_bind_text",l=u.cwrap(c,...N("nnnnn:n"));return function(a,h,w){k(a);const q=A(w),W=l(a,h,q,-1,r);return M(c,W,U.get(a))}}(),s.changes=function(){const c="sqlite3_changes",l=u.cwrap(c,...N("n:n"));return function(a){return $(a),l(a)}}(),s.close=function(){const c="sqlite3_close",l=u.cwrap(c,...N("n:n"),{async:Ft});return async function(a){$(a);const h=await l(a);return Z.delete(a),M(c,h,a)}}(),s.column=function(c,l){k(c);const a=s.column_type(c,l);switch(a){case on:return s.column_blob(c,l);case rn:return s.column_double(c,l);case nn:const h=s.column_int(c,l),w=u.getTempRet0();return P(h,w);case un:return null;case sn:return s.column_text(c,l);default:throw new bt("unknown type",a)}},s.column_blob=function(){const c="sqlite3_column_blob",l=u.cwrap(c,...N("nn:n"));return function(a,h){k(a);const w=s.column_bytes(a,h),q=l(a,h);return u.HEAPU8.subarray(q,q+w)}}(),s.column_bytes=function(){const c="sqlite3_column_bytes",l=u.cwrap(c,...N("nn:n"));return function(a,h){return k(a),l(a,h)}}(),s.column_count=function(){const c="sqlite3_column_count",l=u.cwrap(c,...N("n:n"));return function(a){return k(a),l(a)}}(),s.column_double=function(){const c="sqlite3_column_double",l=u.cwrap(c,...N("nn:n"));return function(a,h){return k(a),l(a,h)}}(),s.column_int=function(){const c="sqlite3_column_int64",l=u.cwrap(c,...N("nn:n"));return function(a,h){return k(a),l(a,h)}}(),s.column_int64=function(){const c="sqlite3_column_int64",l=u.cwrap(c,...N("nn:n"));return function(a,h){k(a);const w=l(a,h),q=u.getTempRet0();return T(w,q)}}(),s.column_name=function(){const c="sqlite3_column_name",l=u.cwrap(c,...N("nn:s"));return function(a,h){return k(a),l(a,h)}}(),s.column_names=function(c){const l=[],a=s.column_count(c);for(let h=0;han||h>32n;l(a,Number(w),Number(q))}}(),s.result_null=function(){const c="sqlite3_result_null",l=u.cwrap(c,...N("n:n"));return function(a){l(a)}}(),s.result_text=function(){const c="sqlite3_result_text",l=u.cwrap(c,...N("nnnn:n"));return function(a,h){const w=A(h);l(a,w,-1,r)}}(),s.row=function(c){const l=[],a=s.data_count(c);for(let h=0;h{var u=self.location.href;return function(s={}){var r;r||(r=typeof s<"u"?s:{});var v,d;r.ready=new Promise((t,e)=>{v=t,d=e});var A=Object.assign({},r),T="./this.program",P=(t,e)=>{throw e},Z=typeof window=="object",$=typeof importScripts=="function",U="",k;(Z||$)&&($?U=self.location.href:typeof document<"u"&&document.currentScript&&(U=document.currentScript.src),u&&(U=u),U.indexOf("blob:")!==0?U=U.substr(0,U.replace(/[?#].*/,"").lastIndexOf("/")+1):U="",$&&(k=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}));var gt=r.print||console.log.bind(console),V=r.printErr||console.warn.bind(console);Object.assign(r,A),A=null,r.thisProgram&&(T=r.thisProgram),r.quit&&(P=r.quit);var M;r.wasmBinary&&(M=r.wasmBinary);var c=r.noExitRuntime||!0;typeof WebAssembly!="object"&&ft("no native wasm support detected");var l,a=!1,h,w,q,W,R,z,Le,De;function wn(){var t=l.buffer;r.HEAP8=w=new Int8Array(t),r.HEAP16=W=new Int16Array(t),r.HEAP32=R=new Int32Array(t),r.HEAPU8=q=new Uint8Array(t),r.HEAPU16=new Uint16Array(t),r.HEAPU32=z=new Uint32Array(t),r.HEAPF32=Le=new Float32Array(t),r.HEAPF64=De=new Float64Array(t)}var bn=[],yn=[],Bi=[],gn=[],pe=0;function Fi(){var t=r.preRun.shift();bn.unshift(t)}var Dt=0,re=null;function ft(t){throw r.onAbort&&r.onAbort(t),t="Aborted("+t+")",V(t),a=!0,h=1,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),d(t),t}function vn(t){return t.startsWith("data:application/octet-stream;base64,")}var Pt;if(r.locateFile){if(Pt="wa-sqlite-async.wasm",!vn(Pt)){var En=Pt;Pt=r.locateFile?r.locateFile(En,U):U+En}}else Pt=new URL(""+new URL("wa-sqlite-async-24800831.wasm",self.location.href).href,self.location).href;function xn(t){try{if(t==Pt&&M)return new Uint8Array(M);if(k)return k(t);throw"both async and sync fetching of the wasm failed"}catch(e){ft(e)}}function Mi(t){return M||!Z&&!$||typeof fetch!="function"?Promise.resolve().then(()=>xn(t)):fetch(t,{credentials:"same-origin"}).then(e=>{if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()}).catch(()=>xn(t))}function Sn(t,e,n){return Mi(t).then(i=>WebAssembly.instantiate(i,e)).then(i=>i).then(n,i=>{V("failed to asynchronously prepare wasm: "+i),ft(i)})}function Hi(t,e){var n=Pt;return M||typeof WebAssembly.instantiateStreaming!="function"||vn(n)||typeof fetch!="function"?Sn(n,t,e):fetch(n,{credentials:"same-origin"}).then(i=>WebAssembly.instantiateStreaming(i,t).then(e,function(o){return V("wasm streaming compile failed: "+o),V("falling back to ArrayBuffer instantiation"),Sn(n,t,e)}))}var I,H;function An(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function de(t){for(;0>0];case"i8":return w[t>>0];case"i16":return W[t>>1];case"i32":return R[t>>2];case"i64":return R[t>>2];case"float":return Le[t>>2];case"double":return De[t>>3];case"*":return z[t>>2];default:ft("invalid type for getValue: "+e)}}function _t(t,e,n="i8"){switch(n.endsWith("*")&&(n="*"),n){case"i1":w[t>>0]=e;break;case"i8":w[t>>0]=e;break;case"i16":W[t>>1]=e;break;case"i32":R[t>>2]=e;break;case"i64":H=[e>>>0,(I=e,1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[t>>2]=H[0],R[t+4>>2]=H[1];break;case"float":Le[t>>2]=e;break;case"double":De[t>>3]=e;break;case"*":z[t>>2]=e;break;default:ft("invalid type for setValue: "+n)}}var qn=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function ie(t,e,n){var i=e+n;for(n=e;t[n]&&!(n>=i);)++n;if(16o?i+=String.fromCharCode(o):(o-=65536,i+=String.fromCharCode(55296|o>>10,56320|o&1023))}}else i+=String.fromCharCode(o)}return i}function B(t,e){return t?ie(q,t,e):""}var Rn=(t,e)=>{for(var n=0,i=t.length-1;0<=i;i--){var o=t[i];o==="."?t.splice(i,1):o===".."?(t.splice(i,1),n++):n&&(t.splice(i,1),n--)}if(e)for(;n;n--)t.unshift("..");return t},St=t=>{var e=t.charAt(0)==="/",n=t.substr(-1)==="/";return(t=Rn(t.split("/").filter(i=>!!i),!e).join("/"))||e||(t="."),t&&n&&(t+="/"),(e?"/":"")+t},Qi=t=>{var e=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(t).slice(1);return t=e[0],e=e[1],!t&&!e?".":(e&&(e=e.substr(0,e.length-1)),t+e)},we=t=>{if(t==="/")return"/";t=St(t),t=t.replace(/\/$/,"");var e=t.lastIndexOf("/");return e===-1?t:t.substr(e+1)};function Vi(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return t=>crypto.getRandomValues(t);ft("initRandomDevice")}function In(t){return(In=Vi())(t)}function be(){for(var t="",e=!1,n=arguments.length-1;-1<=n&&!e;n--){if(e=0<=n?arguments[n]:"/",typeof e!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!e)return"";t=e+"/"+t,e=e.charAt(0)==="/"}return t=Rn(t.split("/").filter(i=>!!i),!e).join("/"),(e?"/":"")+t||"."}function Ut(t){for(var e=0,n=0;n=i?e++:2047>=i?e+=2:55296<=i&&57343>=i?(e+=4,++n):e+=3}return e}function Cn(t,e,n,i){if(!(0=f){var b=t.charCodeAt(++m);f=65536+((f&1023)<<10)|b&1023}if(127>=f){if(n>=i)break;e[n++]=f}else{if(2047>=f){if(n+1>=i)break;e[n++]=192|f>>6}else{if(65535>=f){if(n+2>=i)break;e[n++]=224|f>>12}else{if(n+3>=i)break;e[n++]=240|f>>18,e[n++]=128|f>>12&63}e[n++]=128|f>>6&63}e[n++]=128|f&63}}return e[n]=0,n-o}var Tn=[];function Nn(t,e){Tn[t]={input:[],Rb:[],bc:e},ze(t,Wi)}var Wi={open:function(t){var e=Tn[t.node.ec];if(!e)throw new E(43);t.Sb=e,t.seekable=!1},close:function(t){t.Sb.bc.ic(t.Sb)},ic:function(t){t.Sb.bc.ic(t.Sb)},read:function(t,e,n,i){if(!t.Sb||!t.Sb.bc.zc)throw new E(60);for(var o=0,m=0;mK in C?as(C,K,{enumerable:!0,configurable:!0,writable:!0,value:D}):C[K]=D;var Ye=(C,K,D)=>(cs(C,typeof K!="symbol"?K+"":K,D),D),Ze=(C,K,D)=>{if(!K.has(C))throw TypeError("Cannot "+D)};var y=(C,K,D)=>(Ze(C,K,"read from private field"),D?D.call(C):K.get(C)),F=(C,K,D)=>{if(K.has(C))throw TypeError("Cannot add the same private member more than once");K instanceof WeakSet?K.add(C):K.set(C,D)},X=(C,K,D,Yt)=>(Ze(C,K,"write to private field"),Yt?Yt.call(C,D):K.set(C,D),D);var ot=(C,K,D)=>(Ze(C,K,"access private method"),D);(function(){var rt,Ht,Gt,Jt,Ge,ce,ri,le,ii,hn,Qt,Mt,te,tt,ee,Vt,Nt,fe,si,mn,J,_n,Ot,pn,Et,it,Y,Lt,kt,yt,ne,Je,he,oi,me,ui,xt,Xt,_e,ai,dn;"use strict";var C=0,K=5,D=10,Yt=12,tn=14,Ct=21,Te=25,ci=27,Ne=100,li=101,fi=3850,hi=522,mi=1,_i=2,en=4,pi=8,Bt=0,Tt=1,ue=2,di=3,ae=4,wi=512,bi=1024,yi=2048,gi=16384,nn=1,rn=2,sn=3,on=4,un=5,an=0x7fffffffffffffffn,cn=-0x8000000000000000n,bt=class extends Error{constructor(u,s){super(u),this.code=s}},Ft=!0;function vi(u){const s={},r=u._getSqliteFree(),v=u._malloc(8),d=[v,v+4];function A(c){if(typeof c!="string")return 0;const l=u.lengthBytesUTF8(c),a=u._sqlite3_malloc(l+1);return u.stringToUTF8(c,a,l+1),a}function T(c,l){return BigInt(l)<<32n|BigInt(c)&0xffffffffn}const P=function(){const c=BigInt(Number.MAX_SAFE_INTEGER)>>32n,l=BigInt(Number.MIN_SAFE_INTEGER)>>32n;return function(a,h){return h>c||h2147483647||w<-2147483648)return Te;const q=l(a,h,w);return H(c,q,U.get(a))}}(),s.bind_int64=function(){const c="sqlite3_bind_int64",l=u.cwrap(c,...N("nnnn:n"));return function(a,h,w){if(L(a),w>an||w>32n,R=l(a,h,Number(q),Number(W));return H(c,R,U.get(a))}}(),s.bind_null=function(){const c="sqlite3_bind_null",l=u.cwrap(c,...N("nn:n"));return function(a,h){L(a);const w=l(a,h);return H(c,w,U.get(a))}}(),s.bind_parameter_name=function(){const c="sqlite3_bind_parameter_name",l=u.cwrap(c,...N("n:s"));return function(a,h){return L(a),l(a,h)}}(),s.bind_text=function(){const c="sqlite3_bind_text",l=u.cwrap(c,...N("nnnnn:n"));return function(a,h,w){L(a);const q=A(w),W=l(a,h,q,-1,r);return H(c,W,U.get(a))}}(),s.changes=function(){const c="sqlite3_changes",l=u.cwrap(c,...N("n:n"));return function(a){return $(a),l(a)}}(),s.close=function(){const c="sqlite3_close",l=u.cwrap(c,...N("n:n"),{async:Ft});return async function(a){$(a);const h=await l(a);return Z.delete(a),H(c,h,a)}}(),s.column=function(c,l){L(c);const a=s.column_type(c,l);switch(a){case on:return s.column_blob(c,l);case rn:return s.column_double(c,l);case nn:const h=s.column_int(c,l),w=u.getTempRet0();return P(h,w);case un:return null;case sn:return s.column_text(c,l);default:throw new bt("unknown type",a)}},s.column_blob=function(){const c="sqlite3_column_blob",l=u.cwrap(c,...N("nn:n"));return function(a,h){L(a);const w=s.column_bytes(a,h),q=l(a,h);return u.HEAPU8.subarray(q,q+w)}}(),s.column_bytes=function(){const c="sqlite3_column_bytes",l=u.cwrap(c,...N("nn:n"));return function(a,h){return L(a),l(a,h)}}(),s.column_count=function(){const c="sqlite3_column_count",l=u.cwrap(c,...N("n:n"));return function(a){return L(a),l(a)}}(),s.column_double=function(){const c="sqlite3_column_double",l=u.cwrap(c,...N("nn:n"));return function(a,h){return L(a),l(a,h)}}(),s.column_int=function(){const c="sqlite3_column_int64",l=u.cwrap(c,...N("nn:n"));return function(a,h){return L(a),l(a,h)}}(),s.column_int64=function(){const c="sqlite3_column_int64",l=u.cwrap(c,...N("nn:n"));return function(a,h){L(a);const w=l(a,h),q=u.getTempRet0();return T(w,q)}}(),s.column_name=function(){const c="sqlite3_column_name",l=u.cwrap(c,...N("nn:s"));return function(a,h){return L(a),l(a,h)}}(),s.column_names=function(c){const l=[],a=s.column_count(c);for(let h=0;han||h>32n;l(a,Number(w),Number(q))}}(),s.result_null=function(){const c="sqlite3_result_null",l=u.cwrap(c,...N("n:n"));return function(a){l(a)}}(),s.result_text=function(){const c="sqlite3_result_text",l=u.cwrap(c,...N("nnnn:n"));return function(a,h){const w=A(h);l(a,w,-1,r)}}(),s.row=function(c){const l=[],a=s.data_count(c);for(let h=0;h{var u=self.location.href;return function(s={}){var r;r||(r=typeof s<"u"?s:{});var v,d;r.ready=new Promise((t,e)=>{v=t,d=e});var A=Object.assign({},r),T="./this.program",P=(t,e)=>{throw e},Z=typeof window=="object",$=typeof importScripts=="function",U="",L;(Z||$)&&($?U=self.location.href:typeof document<"u"&&document.currentScript&&(U=document.currentScript.src),u&&(U=u),U.indexOf("blob:")!==0?U=U.substr(0,U.replace(/[?#].*/,"").lastIndexOf("/")+1):U="",$&&(L=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}));var gt=r.print||console.log.bind(console),V=r.printErr||console.warn.bind(console);Object.assign(r,A),A=null,r.thisProgram&&(T=r.thisProgram),r.quit&&(P=r.quit);var H;r.wasmBinary&&(H=r.wasmBinary);var c=r.noExitRuntime||!0;typeof WebAssembly!="object"&&ft("no native wasm support detected");var l,a=!1,h,w,q,W,R,z,ke,De;function wn(){var t=l.buffer;r.HEAP8=w=new Int8Array(t),r.HEAP16=W=new Int16Array(t),r.HEAP32=R=new Int32Array(t),r.HEAPU8=q=new Uint8Array(t),r.HEAPU16=new Uint16Array(t),r.HEAPU32=z=new Uint32Array(t),r.HEAPF32=ke=new Float32Array(t),r.HEAPF64=De=new Float64Array(t)}var bn=[],yn=[],Bi=[],gn=[],pe=0;function Fi(){var t=r.preRun.shift();bn.unshift(t)}var Dt=0,re=null;function ft(t){throw r.onAbort&&r.onAbort(t),t="Aborted("+t+")",V(t),a=!0,h=1,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),d(t),t}function vn(t){return t.startsWith("data:application/octet-stream;base64,")}var Pt;if(r.locateFile){if(Pt="wa-sqlite-async.wasm",!vn(Pt)){var En=Pt;Pt=r.locateFile?r.locateFile(En,U):U+En}}else Pt=new URL(""+new URL("wa-sqlite-async-24800831.wasm",self.location.href).href,self.location).href;function xn(t){try{if(t==Pt&&H)return new Uint8Array(H);if(L)return L(t);throw"both async and sync fetching of the wasm failed"}catch(e){ft(e)}}function Hi(t){return H||!Z&&!$||typeof fetch!="function"?Promise.resolve().then(()=>xn(t)):fetch(t,{credentials:"same-origin"}).then(e=>{if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()}).catch(()=>xn(t))}function Sn(t,e,n){return Hi(t).then(i=>WebAssembly.instantiate(i,e)).then(i=>i).then(n,i=>{V("failed to asynchronously prepare wasm: "+i),ft(i)})}function Qi(t,e){var n=Pt;return H||typeof WebAssembly.instantiateStreaming!="function"||vn(n)||typeof fetch!="function"?Sn(n,t,e):fetch(n,{credentials:"same-origin"}).then(i=>WebAssembly.instantiateStreaming(i,t).then(e,function(o){return V("wasm streaming compile failed: "+o),V("falling back to ArrayBuffer instantiation"),Sn(n,t,e)}))}var I,Q;function An(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function de(t){for(;0>0];case"i8":return w[t>>0];case"i16":return W[t>>1];case"i32":return R[t>>2];case"i64":return R[t>>2];case"float":return ke[t>>2];case"double":return De[t>>3];case"*":return z[t>>2];default:ft("invalid type for getValue: "+e)}}function _t(t,e,n="i8"){switch(n.endsWith("*")&&(n="*"),n){case"i1":w[t>>0]=e;break;case"i8":w[t>>0]=e;break;case"i16":W[t>>1]=e;break;case"i32":R[t>>2]=e;break;case"i64":Q=[e>>>0,(I=e,1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[t>>2]=Q[0],R[t+4>>2]=Q[1];break;case"float":ke[t>>2]=e;break;case"double":De[t>>3]=e;break;case"*":z[t>>2]=e;break;default:ft("invalid type for setValue: "+n)}}var qn=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function ie(t,e,n){var i=e+n;for(n=e;t[n]&&!(n>=i);)++n;if(16o?i+=String.fromCharCode(o):(o-=65536,i+=String.fromCharCode(55296|o>>10,56320|o&1023))}}else i+=String.fromCharCode(o)}return i}function B(t,e){return t?ie(q,t,e):""}var Rn=(t,e)=>{for(var n=0,i=t.length-1;0<=i;i--){var o=t[i];o==="."?t.splice(i,1):o===".."?(t.splice(i,1),n++):n&&(t.splice(i,1),n--)}if(e)for(;n;n--)t.unshift("..");return t},St=t=>{var e=t.charAt(0)==="/",n=t.substr(-1)==="/";return(t=Rn(t.split("/").filter(i=>!!i),!e).join("/"))||e||(t="."),t&&n&&(t+="/"),(e?"/":"")+t},Mi=t=>{var e=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(t).slice(1);return t=e[0],e=e[1],!t&&!e?".":(e&&(e=e.substr(0,e.length-1)),t+e)},we=t=>{if(t==="/")return"/";t=St(t),t=t.replace(/\/$/,"");var e=t.lastIndexOf("/");return e===-1?t:t.substr(e+1)};function Vi(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return t=>crypto.getRandomValues(t);ft("initRandomDevice")}function In(t){return(In=Vi())(t)}function be(){for(var t="",e=!1,n=arguments.length-1;-1<=n&&!e;n--){if(e=0<=n?arguments[n]:"/",typeof e!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!e)return"";t=e+"/"+t,e=e.charAt(0)==="/"}return t=Rn(t.split("/").filter(i=>!!i),!e).join("/"),(e?"/":"")+t||"."}function Ut(t){for(var e=0,n=0;n=i?e++:2047>=i?e+=2:55296<=i&&57343>=i?(e+=4,++n):e+=3}return e}function Cn(t,e,n,i){if(!(0=f){var b=t.charCodeAt(++m);f=65536+((f&1023)<<10)|b&1023}if(127>=f){if(n>=i)break;e[n++]=f}else{if(2047>=f){if(n+1>=i)break;e[n++]=192|f>>6}else{if(65535>=f){if(n+2>=i)break;e[n++]=224|f>>12}else{if(n+3>=i)break;e[n++]=240|f>>18,e[n++]=128|f>>12&63}e[n++]=128|f>>6&63}e[n++]=128|f&63}}return e[n]=0,n-o}var Tn=[];function Nn(t,e){Tn[t]={input:[],Rb:[],bc:e},ze(t,Wi)}var Wi={open:function(t){var e=Tn[t.node.ec];if(!e)throw new E(43);t.Sb=e,t.seekable=!1},close:function(t){t.Sb.bc.ic(t.Sb)},ic:function(t){t.Sb.bc.ic(t.Sb)},read:function(t,e,n,i){if(!t.Sb||!t.Sb.bc.zc)throw new E(60);for(var o=0,m=0;m=e||(e=Math.max(e,n*(1048576>n?2:1.125)>>>0),n!=0&&(e=Math.max(e,256)),n=t.Nb,t.Nb=new Uint8Array(e),0=t.node.Pb)return 0;if(t=Math.min(t.node.Pb-o,i),8e)throw new E(28);return e},vc:function(t,e,n){O.xc(t.node,e+n),t.node.Pb=Math.max(t.node.Pb,e+n)},kc:function(t,e,n,i,o){if((t.node.mode&61440)!==32768)throw new E(43);if(t=t.node.Nb,o&2||t.buffer!==w.buffer){if((0{if(t=be(t),!t)return{path:"",node:null};if(e=Object.assign({yc:!0,tc:0},e),8!!f);for(var n=Pe,i="/",o=0;o{for(var e;;){if(t===t.parent)return t=t.Ub.Ac,e?t[t.length-1]!=="/"?t+"/"+e:t+e:t;e=e?t.name+"/"+e:t.name,t=t.parent}},$e=(t,e)=>{for(var n=0,i=0;i>>0)%qt.length},Ln=t=>{var e=$e(t.parent.id,t.name);if(qt[e]===t)qt[e]=t.ac;else for(e=qt[e];e;){if(e.ac===t){e.ac=t.ac;break}e=e.ac}},$t=(t,e)=>{var n;if(n=(n=Wt(t,"x"))?n:t.Cb.cc?0:2)throw new E(n,t);for(n=qt[$e(t.id,e)];n;n=n.ac){var i=n.name;if(n.parent.id===t.id&&i===e)return n}return t.Cb.cc(t,e)},Dn=(t,e,n,i)=>(t=new Hr(t,e,n,i),e=$e(t.parent.id,t.name),t.ac=qt[e],qt[e]=t),Yi={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Pn=t=>{var e=["r","w","rw"][t&3];return t&512&&(e+="w"),e},Wt=(t,e)=>{if(kn)return 0;if(!e.includes("r")||t.mode&292){if(e.includes("w")&&!(t.mode&146)||e.includes("x")&&!(t.mode&73))return 2}else return 2;return 0},Un=(t,e)=>{try{return $t(t,e),20}catch{}return Wt(t,"wx")},$n=(t,e,n)=>{try{var i=$t(t,e)}catch(o){return o.Ob}if(t=Wt(t,"wx"))return t;if(n){if((i.mode&61440)!==16384)return 54;if(i===i.parent||ye(i)==="/")return 10}else if((i.mode&61440)===16384)return 31;return 0},Zi=(t=0)=>{for(;4096>=t;t++)if(!At[t])return t;throw new E(33)},zn=(t,e)=>(oe||(oe=function(){this.hc={}},oe.prototype={},Object.defineProperties(oe.prototype,{object:{get:function(){return this.node},set:function(n){this.node=n}},flags:{get:function(){return this.hc.flags},set:function(n){this.hc.flags=n}},position:{get:function(){return this.hc.position},set:function(n){this.hc.position=n}}})),t=Object.assign(new oe,t),e=Zi(e),t.Wb=e,At[e]=t),Gi={open:t=>{t.Mb=On[t.node.ec].Mb,t.Mb.open&&t.Mb.open(t)},Zb:()=>{throw new E(70)}},ze=(t,e)=>{On[t]={Mb:e}},Bn=(t,e)=>{var n=e==="/",i=!e;if(n&&Pe)throw new E(10);if(!n&&!i){var o=at(e,{yc:!1});if(e=o.path,o=o.node,o.$b)throw new E(10);if((o.mode&61440)!==16384)throw new E(54)}e={type:t,Wc:{},Ac:e,Mc:[]},t=t.Ub(e),t.Ub=e,e.root=t,n?Pe=t:o&&(o.$b=e,o.Ub&&o.Ub.Mc.push(e))},Be=(t,e,n)=>{var i=at(t,{parent:!0}).node;if(t=we(t),!t||t==="."||t==="..")throw new E(28);var o=Un(i,t);if(o)throw new E(o);if(!i.Cb.jc)throw new E(63);return i.Cb.jc(i,t,e,n)},pt=(t,e)=>Be(t,(e!==void 0?e:511)&1023|16384,0),ge=(t,e,n)=>{typeof n>"u"&&(n=e,e=438),Be(t,e|8192,n)},Fe=(t,e)=>{if(!be(t))throw new E(44);var n=at(e,{parent:!0}).node;if(!n)throw new E(44);e=we(e);var i=Un(n,e);if(i)throw new E(i);if(!n.Cb.nc)throw new E(63);n.Cb.nc(n,e,t)},Fn=t=>{var e=at(t,{parent:!0}).node;t=we(t);var n=$t(e,t),i=$n(e,t,!0);if(i)throw new E(i);if(!e.Cb.mc)throw new E(63);if(n.$b)throw new E(10);e.Cb.mc(e,t),Ln(n)},Mn=t=>{if(t=at(t).node,!t)throw new E(44);if(!t.Cb.fc)throw new E(28);return be(ye(t.parent),t.Cb.fc(t))},ve=(t,e)=>{if(t=at(t,{Yb:!e}).node,!t)throw new E(44);if(!t.Cb.Tb)throw new E(63);return t.Cb.Tb(t)},Hn=t=>ve(t,!0),Qn=(t,e)=>{if(t=typeof t=="string"?at(t,{Yb:!0}).node:t,!t.Cb.Qb)throw new E(63);t.Cb.Qb(t,{mode:e&4095|t.mode&-4096,timestamp:Date.now()})},Vn=(t,e)=>{if(0>e)throw new E(28);if(t=typeof t=="string"?at(t,{Yb:!0}).node:t,!t.Cb.Qb)throw new E(63);if((t.mode&61440)===16384)throw new E(31);if((t.mode&61440)!==32768)throw new E(28);var n=Wt(t,"w");if(n)throw new E(n);t.Cb.Qb(t,{size:e,timestamp:Date.now()})},Ee=(t,e,n)=>{if(t==="")throw new E(44);if(typeof e=="string"){var i=Yi[e];if(typeof i>"u")throw Error("Unknown file open mode: "+e);e=i}if(n=e&64?(typeof n>"u"?438:n)&4095|32768:0,typeof t=="object")var o=t;else{t=St(t);try{o=at(t,{Yb:!(e&131072)}).node}catch{}}if(i=!1,e&64)if(o){if(e&128)throw new E(20)}else o=Be(t,n,0),i=!0;if(!o)throw new E(44);if((o.mode&61440)===8192&&(e&=-513),e&65536&&(o.mode&61440)!==16384)throw new E(54);if(!i&&(n=o?(o.mode&61440)===40960?32:(o.mode&61440)===16384&&(Pn(e)!=="r"||e&512)?31:Wt(o,Pn(e)):44))throw new E(n);return e&512&&!i&&Vn(o,0),e&=-131713,o=zn({node:o,path:ye(o),flags:e,seekable:!0,position:0,Mb:o.Mb,Tc:[],error:!1}),o.Mb.open&&o.Mb.open(o),!r.logReadFiles||e&1||(xe||(xe={}),t in xe||(xe[t]=1)),o},Wn=(t,e,n)=>{if(t.Wb===null)throw new E(8);if(!t.seekable||!t.Mb.Zb)throw new E(70);if(n!=0&&n!=1&&n!=2)throw new E(28);t.position=t.Mb.Zb(t,e,n),t.Tc=[]},jn=()=>{E||(E=function(t,e){this.name="ErrnoError",this.node=e,this.Rc=function(n){this.Ob=n},this.Rc(t),this.message="FS error"},E.prototype=Error(),E.prototype.constructor=E,[44].forEach(t=>{Ue[t]=new E(t),Ue[t].stack=""}))},Kn,Ji=(t,e)=>{var n=0;return t&&(n|=365),e&&(n|=146),n},se=(t,e,n)=>{t=St("/dev/"+t);var i=Ji(!!e,!!n);Me||(Me=64);var o=Me++<<8|0;ze(o,{open:m=>{m.seekable=!1},close:()=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(m,f,b,_)=>{for(var p=0,x=0;x<_;x++){try{var g=e()}catch{throw new E(29)}if(g===void 0&&p===0)throw new E(6);if(g==null)break;p++,f[b+x]=g}return p&&(m.node.timestamp=Date.now()),p},write:(m,f,b,_)=>{for(var p=0;p<_;p++)try{n(f[b+p])}catch{throw new E(29)}return _&&(m.node.timestamp=Date.now()),p}}),ge(t,i,o)},Me,j={},oe,xe;function zt(t,e,n){if(e.charAt(0)==="/")return e;if(t=t===-100?"/":ht(t).path,e.length==0){if(!n)throw new E(44);return t}return St(t+"/"+e)}function Se(t,e,n){try{var i=t(e)}catch(m){if(m&&m.node&&St(e)!==St(ye(m.node)))return-54;throw m}R[n>>2]=i.Ic,R[n+8>>2]=i.qc,R[n+12>>2]=i.mode,z[n+16>>2]=i.Oc,R[n+20>>2]=i.uid,R[n+24>>2]=i.Lc,R[n+28>>2]=i.ec,H=[i.size>>>0,(I=i.size,1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[n+40>>2]=H[0],R[n+44>>2]=H[1],R[n+48>>2]=4096,R[n+52>>2]=i.Gc,t=i.Ec.getTime(),e=i.Nc.getTime();var o=i.Hc.getTime();return H=[Math.floor(t/1e3)>>>0,(I=Math.floor(t/1e3),1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[n+56>>2]=H[0],R[n+60>>2]=H[1],z[n+64>>2]=t%1e3*1e3,H=[Math.floor(e/1e3)>>>0,(I=Math.floor(e/1e3),1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[n+72>>2]=H[0],R[n+76>>2]=H[1],z[n+80>>2]=e%1e3*1e3,H=[Math.floor(o/1e3)>>>0,(I=Math.floor(o/1e3),1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[n+88>>2]=H[0],R[n+92>>2]=H[1],z[n+96>>2]=o%1e3*1e3,H=[i.qc>>>0,(I=i.qc,1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[n+104>>2]=H[0],R[n+108>>2]=H[1],0}var Ae=void 0;function qe(){return Ae+=4,R[Ae-4>>2]}function ht(t){if(t=At[t],!t)throw new E(8);return t}function jt(t,e,n){return Cn(t,q,e,n)}function He(t){return z[t>>2]+4294967296*R[t+4>>2]}var ts=[0,31,60,91,121,152,182,213,244,274,305,335],es=[0,31,59,90,120,151,181,212,243,273,304,334];function Xn(t){var e=Ut(t)+1,n=Ke(e);return n&&jt(t,n,e),n}var Qe={};function Yn(){if(!Ve){var t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:T||"./this.program"},e;for(e in Qe)Qe[e]===void 0?delete t[e]:t[e]=Qe[e];var n=[];for(e in t)n.push(e+"="+t[e]);Ve=n}return Ve}var Ve;function Zn(){}function Gn(){}function Jn(){}function tr(){}function er(){}function nr(){}function rr(){}function ir(){}function sr(){}function or(){}function ur(){}function ar(){}function cr(){}function lr(){}function fr(){}function hr(){}function mr(){}function _r(){}function pr(){}function dr(){}function wr(){}function br(){}function yr(){}function gr(){}function vr(){}function Er(){}function xr(){}function Sr(){}function Ar(){}function qr(){}function Rr(){}function Ir(){}function Cr(){}function Tr(){}function Nr(){}function Or(){}function kr(){}function Lr(){}function Dr(){}function Pr(t){h=t,c||0{je={resolve:t,reject:e}})}function os(){var t=Ke(12300),e=t+12;R[t>>2]=e,R[t+4>>2]=e+12288,e=Ie[0];var n=$r[e];return n===void 0&&(n=rs++,$r[e]=n,zr[n]=e),R[t+8>>2]=n,t}function Br(t){if(!a){if(Rt===0){var e=!1,n=!1;t((i=0)=>{if(!a&&(Ur=i,e=!0,n)){Rt=2,Re(()=>Jr(dt)),i=!1;try{var o=(0,r.asm[zr[R[dt+8>>2]]])()}catch(b){o=b,i=!0}var m=!1;if(!dt){var f=je;f&&(je=null,(i?f.reject:f.resolve)(o),m=!0)}if(i&&!m)throw o}}),n=!0,e||(Rt=1,dt=os(),Re(()=>Zr(dt)))}else Rt===2?(Rt=0,Re(ti),Vr(dt),dt=null,is.forEach(i=>{if(!a)try{if(i(),!(c||0{t().then(e)})}var Mr={};function wt(t,e,n,i,o){function m(g){return--pe,_!==0&&Yr(_),e==="string"?B(g):e==="boolean"?!!g:g}var f={string:g=>{var S=0;if(g!=null&&g!==0){S=Ut(g)+1;var L=Xe(S);jt(g,L,S),S=L}return S},array:g=>{var S=Xe(g.length);return w.set(g,S),S}};t=r["_"+t];var b=[],_=0;if(i)for(var p=0;p{pt("/dev"),ze(259,{read:()=>0,write:(i,o,m,f)=>f}),ge("/dev/null",259),Nn(1280,ji),Nn(1536,Ki),ge("/dev/tty",1280),ge("/dev/tty1",1536);var t=new Uint8Array(1024),e=0,n=()=>(e===0&&(e=In(t).byteLength),t[--e]);se("random",n),se("urandom",n),pt("/dev/shm"),pt("/dev/shm/tmp")})(),(()=>{pt("/proc");var t=pt("/proc/self");pt("/proc/self/fd"),Bn({Ub:()=>{var e=Dn(t,"fd",16895,73);return e.Cb={cc:(n,i)=>{var o=At[+i];if(!o)throw new E(8);return n={parent:null,Ub:{Ac:"fake"},Cb:{fc:()=>o.path}},n.parent=n}},e}},"/proc/self/fd")})(),function(){const t=new Map;r.setAuthorizer=function(e,n,i){return n?t.set(e,{f:n,uc:i}):t.delete(e),wt("set_authorizer","number",["number"],[e])},Zn=function(e,n,i,o,m,f){if(t.has(e)){const{f:b,uc:_}=t.get(e);return b(_,n,i?B(i):null,o?B(o):null,m?B(m):null,f?B(f):null)}return 0}}(),function(){const t=new Map,e=new Map;r.createFunction=function(n,i,o,m,f,b){const _=t.size;return t.set(_,{f:b,Xb:f}),wt("create_function","number","number string number number number number".split(" "),[n,i,o,m,_,0])},r.createAggregate=function(n,i,o,m,f,b,_){const p=t.size;return t.set(p,{step:b,Jc:_,Xb:f}),wt("create_function","number","number string number number number number".split(" "),[n,i,o,m,p,1])},r.getFunctionUserData=function(n){return e.get(n)},Jn=function(n,i,o,m){n=t.get(n),e.set(i,n.Xb),n.f(i,new Uint32Array(q.buffer,m,o)),e.delete(i)},er=function(n,i,o,m){n=t.get(n),e.set(i,n.Xb),n.step(i,new Uint32Array(q.buffer,m,o)),e.delete(i)},Gn=function(n,i){n=t.get(n),e.set(i,n.Xb),n.Jc(i),e.delete(i)}}(),function(){const t=new Map;r.progressHandler=function(e,n,i,o){return i?t.set(e,{f:i,uc:o}):t.delete(e),wt("progress_handler",null,["number","number"],[e,n])},tr=function(e){if(t.has(e)){const{f:n,uc:i}=t.get(e);return n(i)}return 0}}(),function(){function t(_,p){const x=`get${_}`,g=`set${_}`;return new Proxy(new DataView(q.buffer,p,_==="Int32"?4:8),{get(S,L){if(L===x)return function(Q,nt){if(!nt)throw Error("must be little endian");return S[L](Q,nt)};if(L===g)return function(Q,nt,G){if(!G)throw Error("must be little endian");return S[L](Q,nt,G)};if(typeof L=="string"&&L.match(/^(get)|(set)/))throw Error("invalid type");return S[L]}})}const e=typeof Mr=="object",n=new Map,i=new Map,o=new Map,m=e?new Set:null,f=e?new Set:null,b=new Map;br=function(_,p,x,g){b.set(B(_),{size:p,dc:Array.from(new Uint32Array(q.buffer,g,x))})},r.createModule=function(_,p,x,g){e&&(x.handleAsync=Fr);const S=n.size;return n.set(S,{module:x,Xb:g}),g=0,x.xCreate&&(g|=1),x.xConnect&&(g|=2),x.xBestIndex&&(g|=4),x.xDisconnect&&(g|=8),x.xDestroy&&(g|=16),x.xOpen&&(g|=32),x.xClose&&(g|=64),x.xFilter&&(g|=128),x.xNext&&(g|=256),x.xEof&&(g|=512),x.xColumn&&(g|=1024),x.xRowid&&(g|=2048),x.xUpdate&&(g|=4096),x.xBegin&&(g|=8192),x.xSync&&(g|=16384),x.xCommit&&(g|=32768),x.xRollback&&(g|=65536),x.xFindFunction&&(g|=131072),x.xRename&&(g|=262144),wt("create_module","number",["number","string","number","number"],[_,p,S,g])},ar=function(_,p,x,g,S,L){if(p=n.get(p),i.set(S,p),e){m.delete(S);for(const Q of m)i.delete(Q)}return g=Array.from(new Uint32Array(q.buffer,g,x)).map(Q=>B(Q)),p.module.xCreate(_,p.Xb,g,S,t("Int32",L))},ur=function(_,p,x,g,S,L){if(p=n.get(p),i.set(S,p),e){m.delete(S);for(const Q of m)i.delete(Q)}return g=Array.from(new Uint32Array(q.buffer,g,x)).map(Q=>B(Q)),p.module.xConnect(_,p.Xb,g,S,t("Int32",L))},rr=function(_,p){var x=i.get(_),g=b.get("sqlite3_index_info").dc;const S={};S.nConstraint=et(p+g[0],"i32"),S.aConstraint=[];for(var L=et(p+g[1],"*"),Q=b.get("sqlite3_index_constraint").size,nt=0;nt>=2,z[f]+z[f+1]*2**32}const n=typeof Mr=="object",i=new Map,o=new Map;r.registerVFS=function(f,b){if(wt("sqlite3_vfs_find","number",["string"],[f.name]))throw Error(`VFS '${f.name}' already registered`);n&&(f.handleAsync=Fr);var _=f.Vc??64;const p=r._malloc(4);return b=wt("register_vfs","number",["string","number","number","number"],[f.name,_,b?1:0,p]),b||(_=et(p,"*"),i.set(_,f)),r._free(p),b};const m=n?new Set:null;xr=function(f){const b=o.get(f);return n?m.add(f):o.delete(f),b.xClose(f)},Tr=function(f,b,_,p){return o.get(f).xRead(f,q.subarray(b,b+_),e(p))},Dr=function(f,b,_,p){return o.get(f).xWrite(f,q.subarray(b,b+_),e(p))},kr=function(f,b){return o.get(f).xTruncate(f,e(b))},Or=function(f,b){return o.get(f).xSync(f,b)},Rr=function(f,b){const _=o.get(f);return b=t("BigInt64",b),_.xFileSize(f,b)},Ir=function(f,b){return o.get(f).xLock(f,b)},Lr=function(f,b){return o.get(f).xUnlock(f,b)},Er=function(f,b){const _=o.get(f);return b=t("Int32",b),_.xCheckReservedLock(f,b)},qr=function(f,b,_){const p=o.get(f);return _=new DataView(q.buffer,_),p.xFileControl(f,b,_)},Nr=function(f){return o.get(f).xSectorSize(f)},Ar=function(f){return o.get(f).xDeviceCharacteristics(f)},Cr=function(f,b,_,p,x){if(f=i.get(f),o.set(_,f),n){m.delete(_);for(var g of m)o.delete(g)}if(g=null,p&64){g=1;const S=[];for(;g;){const L=q[b++];if(L)S.push(L);else switch(q[b]||(g=null),g){case 1:S.push(63),g=2;break;case 2:S.push(61),g=3;break;case 3:S.push(38),g=2}}g=new TextDecoder().decode(new Uint8Array(S))}else b&&(g=B(b));return x=t("Int32",x),f.xOpen(g,_,p,x)},Sr=function(f,b,_){return i.get(f).xDelete(B(b),_)},vr=function(f,b,_,p){return f=i.get(f),p=t("Int32",p),f.xAccess(B(b),_,p)}}();var us={a:function(t,e,n,i){ft("Assertion failed: "+B(t)+", at: "+[e?B(e):"unknown filename",n,i?B(i):"unknown function"])},K:function(t,e){try{return t=B(t),Qn(t,e),0}catch(n){if(typeof j>"u"||n.name!=="ErrnoError")throw n;return-n.Ob}},M:function(t,e,n){try{if(e=B(e),e=zt(t,e),n&-8)return-28;var i=at(e,{Yb:!0}).node;return i?(t="",n&4&&(t+="r"),n&2&&(t+="w"),n&1&&(t+="x"),t&&Wt(i,t)?-2:0):-44}catch(o){if(typeof j>"u"||o.name!=="ErrnoError")throw o;return-o.Ob}},L:function(t,e){try{var n=At[t];if(!n)throw new E(8);return Qn(n.node,e),0}catch(i){if(typeof j>"u"||i.name!=="ErrnoError")throw i;return-i.Ob}},J:function(t){try{var e=At[t];if(!e)throw new E(8);var n=e.node,i=typeof n=="string"?at(n,{Yb:!0}).node:n;if(!i.Cb.Qb)throw new E(63);return i.Cb.Qb(i,{timestamp:Date.now()}),0}catch(o){if(typeof j>"u"||o.name!=="ErrnoError")throw o;return-o.Ob}},b:function(t,e,n){Ae=n;try{var i=ht(t);switch(e){case 0:var o=qe();return 0>o?-28:zn(i,o).Wb;case 1:case 2:return 0;case 3:return i.flags;case 4:return o=qe(),i.flags|=o,0;case 5:return o=qe(),W[o+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return R[Qr()>>2]=28,-1;default:return-28}}catch(m){if(typeof j>"u"||m.name!=="ErrnoError")throw m;return-m.Ob}},I:function(t,e){try{var n=ht(t);return Se(ve,n.path,e)}catch(i){if(typeof j>"u"||i.name!=="ErrnoError")throw i;return-i.Ob}},j:function(t,e,n){try{if(e=n+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*n:NaN,isNaN(e))return-61;var i=At[t];if(!i)throw new E(8);if(!(i.flags&2097155))throw new E(28);return Vn(i.node,e),0}catch(o){if(typeof j>"u"||o.name!=="ErrnoError")throw o;return-o.Ob}},C:function(t,e){try{if(e===0)return-28;var n=Ut("/")+1;return e"u"||i.name!=="ErrnoError")throw i;return-i.Ob}},F:function(t,e){try{return t=B(t),Se(Hn,t,e)}catch(n){if(typeof j>"u"||n.name!=="ErrnoError")throw n;return-n.Ob}},z:function(t,e,n){try{return e=B(e),e=zt(t,e),e=St(e),e[e.length-1]==="/"&&(e=e.substr(0,e.length-1)),pt(e,n),0}catch(i){if(typeof j>"u"||i.name!=="ErrnoError")throw i;return-i.Ob}},E:function(t,e,n,i){try{e=B(e);var o=i&256;return e=zt(t,e,i&4096),Se(o?Hn:ve,e,n)}catch(m){if(typeof j>"u"||m.name!=="ErrnoError")throw m;return-m.Ob}},u:function(t,e,n,i){Ae=i;try{e=B(e),e=zt(t,e);var o=i?qe():0;return Ee(e,n,o).Wb}catch(m){if(typeof j>"u"||m.name!=="ErrnoError")throw m;return-m.Ob}},s:function(t,e,n,i){try{if(e=B(e),e=zt(t,e),0>=i)return-28;var o=Mn(e),m=Math.min(i,Ut(o)),f=w[n+m];return jt(o,n,i+1),w[n+m]=f,m}catch(b){if(typeof j>"u"||b.name!=="ErrnoError")throw b;return-b.Ob}},r:function(t){try{return t=B(t),Fn(t),0}catch(e){if(typeof j>"u"||e.name!=="ErrnoError")throw e;return-e.Ob}},H:function(t,e){try{return t=B(t),Se(ve,t,e)}catch(n){if(typeof j>"u"||n.name!=="ErrnoError")throw n;return-n.Ob}},o:function(t,e,n){try{if(e=B(e),e=zt(t,e),n===0){t=e;var i=at(t,{parent:!0}).node;if(!i)throw new E(44);var o=we(t),m=$t(i,o),f=$n(i,o,!1);if(f)throw new E(f);if(!i.Cb.oc)throw new E(63);if(m.$b)throw new E(10);i.Cb.oc(i,o),Ln(m)}else n===512?Fn(e):ft("Invalid flags passed to unlinkat");return 0}catch(b){if(typeof j>"u"||b.name!=="ErrnoError")throw b;return-b.Ob}},n:function(t,e,n){try{if(e=B(e),e=zt(t,e,!0),n){var i=He(n),o=R[n+8>>2];m=1e3*i+o/1e6,n+=16,i=He(n),o=R[n+8>>2],f=1e3*i+o/1e6}else var m=Date.now(),f=m;t=m;var b=at(e,{Yb:!0}).node;return b.Cb.Qb(b,{timestamp:Math.max(t,f)}),0}catch(_){if(typeof j>"u"||_.name!=="ErrnoError")throw _;return-_.Ob}},y:function(t,e){t=new Date(1e3*He(t)),R[e>>2]=t.getSeconds(),R[e+4>>2]=t.getMinutes(),R[e+8>>2]=t.getHours(),R[e+12>>2]=t.getDate(),R[e+16>>2]=t.getMonth(),R[e+20>>2]=t.getFullYear()-1900,R[e+24>>2]=t.getDay();var n=t.getFullYear();R[e+28>>2]=(n%4!==0||n%100===0&&n%400!==0?es:ts)[t.getMonth()]+t.getDate()-1|0,R[e+36>>2]=-(60*t.getTimezoneOffset()),n=new Date(t.getFullYear(),6,1).getTimezoneOffset();var i=new Date(t.getFullYear(),0,1).getTimezoneOffset();R[e+32>>2]=(n!=i&&t.getTimezoneOffset()==Math.min(i,n))|0},w:function(t,e,n,i,o,m,f){try{var b=ht(i);if(e&2&&!(n&2)&&(b.flags&2097155)!==2)throw new E(2);if((b.flags&2097155)===1)throw new E(2);if(!b.Mb.kc)throw new E(43);var _=b.Mb.kc(b,t,o,e,n),p=_.Pc;return R[m>>2]=_.Dc,z[f>>2]=p,0}catch(x){if(typeof j>"u"||x.name!=="ErrnoError")throw x;return-x.Ob}},x:function(t,e,n,i,o,m){try{var f=ht(o);if(n&2){if((f.node.mode&61440)!==32768)throw new E(43);i&2||f.Mb.lc&&f.Mb.lc(f,q.slice(t,t+e),m,e,i)}}catch(b){if(typeof j>"u"||b.name!=="ErrnoError")throw b;return-b.Ob}},p:function(t,e,n){function i(_){return(_=_.toTimeString().match(/\(([A-Za-z ]+)\)$/))?_[1]:"GMT"}var o=new Date().getFullYear(),m=new Date(o,0,1),f=new Date(o,6,1);o=m.getTimezoneOffset();var b=f.getTimezoneOffset();z[t>>2]=60*Math.max(o,b),R[e>>2]=+(o!=b),t=i(m),e=i(f),t=Xn(t),e=Xn(e),b>2]=t,z[n+4>>2]=e):(z[n>>2]=e,z[n+4>>2]=t)},e:function(){return Date.now()},d:()=>performance.now(),l:function(t){var e=q.length;if(t>>>=0,2147483648=n;n*=2){var i=e*(1+.2/n);i=Math.min(i,t+100663296);var o=Math,m=o.min;i=Math.max(t,i),i+=(65536-i%65536)%65536;t:{var f=l.buffer;try{l.grow(m.call(o,2147483648,i)-f.byteLength+65535>>>16),wn();var b=1;break t}catch{}b=void 0}if(b)return!0}return!1},A:function(t,e){var n=0;return Yn().forEach(function(i,o){var m=e+n;for(o=z[t+4*o>>2]=m,m=0;m>0]=i.charCodeAt(m);w[o>>0]=0,n+=i.length+1}),0},B:function(t,e){var n=Yn();z[t>>2]=n.length;var i=0;return n.forEach(function(o){i+=o.length+1}),z[e>>2]=i,0},f:function(t){try{var e=ht(t);if(e.Wb===null)throw new E(8);e.pc&&(e.pc=null);try{e.Mb.close&&e.Mb.close(e)}catch(n){throw n}finally{At[e.Wb]=null}return e.Wb=null,0}catch(n){if(typeof j>"u"||n.name!=="ErrnoError")throw n;return n.Ob}},m:function(t,e){try{var n=ht(t);return w[e>>0]=n.Sb?2:(n.mode&61440)===16384?3:(n.mode&61440)===40960?7:4,W[e+2>>1]=0,H=[0,(I=0,1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[e+8>>2]=H[0],R[e+12>>2]=H[1],H=[0,(I=0,1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[e+16>>2]=H[0],R[e+20>>2]=H[1],0}catch(i){if(typeof j>"u"||i.name!=="ErrnoError")throw i;return i.Ob}},t:function(t,e,n,i){try{t:{var o=ht(t);t=e;for(var m,f=e=0;f>2],_=z[t+4>>2];t+=8;var p=o,x=b,g=_,S=m,L=w;if(0>g||0>S)throw new E(28);if(p.Wb===null)throw new E(8);if((p.flags&2097155)===1)throw new E(8);if((p.node.mode&61440)===16384)throw new E(31);if(!p.Mb.read)throw new E(28);var Q=typeof S<"u";if(!Q)S=p.position;else if(!p.seekable)throw new E(70);var nt=p.Mb.read(p,L,x,g,S);Q||(p.position+=nt);var G=nt;if(0>G){var ct=-1;break t}if(e+=G,G<_)break;typeof m<"u"&&(m+=G)}ct=e}return z[i>>2]=ct,0}catch(st){if(typeof j>"u"||st.name!=="ErrnoError")throw st;return st.Ob}},i:function(t,e,n,i,o){try{if(e=n+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*n:NaN,isNaN(e))return 61;var m=ht(t);return Wn(m,e,i),H=[m.position>>>0,(I=m.position,1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[o>>2]=H[0],R[o+4>>2]=H[1],m.pc&&e===0&&i===0&&(m.pc=null),0}catch(f){if(typeof j>"u"||f.name!=="ErrnoError")throw f;return f.Ob}},D:function(t){try{var e=ht(t);return Br(function(n){var i=e.node.Ub;i.type.Sc?i.type.Sc(i,!1,function(o){n(o?function(){return 29}:0)}):n(0)})}catch(n){if(typeof j>"u"||n.name!=="ErrnoError")throw n;return n.Ob}},q:function(t,e,n,i){try{t:{var o=ht(t);t=e;for(var m,f=e=0;f>2],_=z[t+4>>2];t+=8;var p=o,x=b,g=_,S=m,L=w;if(0>g||0>S)throw new E(28);if(p.Wb===null)throw new E(8);if(!(p.flags&2097155))throw new E(8);if((p.node.mode&61440)===16384)throw new E(31);if(!p.Mb.write)throw new E(28);p.seekable&&p.flags&1024&&Wn(p,0,2);var Q=typeof S<"u";if(!Q)S=p.position;else if(!p.seekable)throw new E(70);var nt=p.Mb.write(p,L,x,g,S,void 0);Q||(p.position+=nt);var G=nt;if(0>G){var ct=-1;break t}e+=G,typeof m<"u"&&(m+=G)}ct=e}return z[i>>2]=ct,0}catch(st){if(typeof j>"u"||st.name!=="ErrnoError")throw st;return st.Ob}},ra:Zn,N:Gn,ga:Jn,ca:tr,Y:er,la:nr,G:rr,h:ir,oa:sr,ja:or,ea:ur,fa:ar,k:cr,v:lr,pa:fr,g:hr,qa:mr,da:_r,ha:pr,ia:dr,na:wr,c:br,ka:yr,ma:gr,aa:vr,V:Er,$:xr,ba:Sr,S:Ar,U:qr,Z:Rr,X:Ir,R:Cr,Q:Tr,T:Nr,_:Or,O:kr,W:Lr,P:Dr};(function(){function t(n){if(n=n.exports,n=ns(n),r.asm=n,l=r.asm.sa,wn(),yn.unshift(r.asm.ta),Dt--,r.monitorRunDependencies&&r.monitorRunDependencies(Dt),Dt==0&&re){var i=re;re=null,i()}return n}var e={a:us};if(Dt++,r.monitorRunDependencies&&r.monitorRunDependencies(Dt),r.instantiateWasm)try{return r.instantiateWasm(e,t)}catch(n){V("Module.instantiateWasm callback failed with error: "+n),d(n)}return Hi(e,function(n){t(n.instance)}).catch(d),{}})(),r._sqlite3_vfs_find=function(){return(r._sqlite3_vfs_find=r.asm.ua).apply(null,arguments)},r._sqlite3_malloc=function(){return(r._sqlite3_malloc=r.asm.va).apply(null,arguments)},r._sqlite3_free=function(){return(r._sqlite3_free=r.asm.wa).apply(null,arguments)},r._sqlite3_prepare_v2=function(){return(r._sqlite3_prepare_v2=r.asm.xa).apply(null,arguments)},r._sqlite3_step=function(){return(r._sqlite3_step=r.asm.ya).apply(null,arguments)},r._sqlite3_column_int64=function(){return(r._sqlite3_column_int64=r.asm.za).apply(null,arguments)},r._sqlite3_column_int=function(){return(r._sqlite3_column_int=r.asm.Aa).apply(null,arguments)},r._sqlite3_finalize=function(){return(r._sqlite3_finalize=r.asm.Ba).apply(null,arguments)},r._sqlite3_reset=function(){return(r._sqlite3_reset=r.asm.Ca).apply(null,arguments)},r._sqlite3_clear_bindings=function(){return(r._sqlite3_clear_bindings=r.asm.Da).apply(null,arguments)},r._sqlite3_value_blob=function(){return(r._sqlite3_value_blob=r.asm.Ea).apply(null,arguments)},r._sqlite3_value_text=function(){return(r._sqlite3_value_text=r.asm.Fa).apply(null,arguments)},r._sqlite3_value_bytes=function(){return(r._sqlite3_value_bytes=r.asm.Ga).apply(null,arguments)},r._sqlite3_value_double=function(){return(r._sqlite3_value_double=r.asm.Ha).apply(null,arguments)},r._sqlite3_value_int=function(){return(r._sqlite3_value_int=r.asm.Ia).apply(null,arguments)},r._sqlite3_value_int64=function(){return(r._sqlite3_value_int64=r.asm.Ja).apply(null,arguments)},r._sqlite3_value_type=function(){return(r._sqlite3_value_type=r.asm.Ka).apply(null,arguments)},r._sqlite3_result_blob=function(){return(r._sqlite3_result_blob=r.asm.La).apply(null,arguments)},r._sqlite3_result_double=function(){return(r._sqlite3_result_double=r.asm.Ma).apply(null,arguments)},r._sqlite3_result_error=function(){return(r._sqlite3_result_error=r.asm.Na).apply(null,arguments)},r._sqlite3_result_int=function(){return(r._sqlite3_result_int=r.asm.Oa).apply(null,arguments)},r._sqlite3_result_int64=function(){return(r._sqlite3_result_int64=r.asm.Pa).apply(null,arguments)},r._sqlite3_result_null=function(){return(r._sqlite3_result_null=r.asm.Qa).apply(null,arguments)},r._sqlite3_result_text=function(){return(r._sqlite3_result_text=r.asm.Ra).apply(null,arguments)},r._sqlite3_column_count=function(){return(r._sqlite3_column_count=r.asm.Sa).apply(null,arguments)},r._sqlite3_data_count=function(){return(r._sqlite3_data_count=r.asm.Ta).apply(null,arguments)},r._sqlite3_column_blob=function(){return(r._sqlite3_column_blob=r.asm.Ua).apply(null,arguments)},r._sqlite3_column_bytes=function(){return(r._sqlite3_column_bytes=r.asm.Va).apply(null,arguments)},r._sqlite3_column_double=function(){return(r._sqlite3_column_double=r.asm.Wa).apply(null,arguments)},r._sqlite3_column_text=function(){return(r._sqlite3_column_text=r.asm.Xa).apply(null,arguments)},r._sqlite3_column_type=function(){return(r._sqlite3_column_type=r.asm.Ya).apply(null,arguments)},r._sqlite3_column_name=function(){return(r._sqlite3_column_name=r.asm.Za).apply(null,arguments)},r._sqlite3_bind_blob=function(){return(r._sqlite3_bind_blob=r.asm._a).apply(null,arguments)},r._sqlite3_bind_double=function(){return(r._sqlite3_bind_double=r.asm.$a).apply(null,arguments)},r._sqlite3_bind_int=function(){return(r._sqlite3_bind_int=r.asm.ab).apply(null,arguments)},r._sqlite3_bind_int64=function(){return(r._sqlite3_bind_int64=r.asm.bb).apply(null,arguments)},r._sqlite3_bind_null=function(){return(r._sqlite3_bind_null=r.asm.cb).apply(null,arguments)},r._sqlite3_bind_text=function(){return(r._sqlite3_bind_text=r.asm.db).apply(null,arguments)},r._sqlite3_bind_parameter_count=function(){return(r._sqlite3_bind_parameter_count=r.asm.eb).apply(null,arguments)},r._sqlite3_bind_parameter_name=function(){return(r._sqlite3_bind_parameter_name=r.asm.fb).apply(null,arguments)},r._sqlite3_sql=function(){return(r._sqlite3_sql=r.asm.gb).apply(null,arguments)},r._sqlite3_exec=function(){return(r._sqlite3_exec=r.asm.hb).apply(null,arguments)},r._sqlite3_errmsg=function(){return(r._sqlite3_errmsg=r.asm.ib).apply(null,arguments)},r._sqlite3_declare_vtab=function(){return(r._sqlite3_declare_vtab=r.asm.jb).apply(null,arguments)},r._sqlite3_libversion=function(){return(r._sqlite3_libversion=r.asm.kb).apply(null,arguments)},r._sqlite3_libversion_number=function(){return(r._sqlite3_libversion_number=r.asm.lb).apply(null,arguments)},r._sqlite3_changes=function(){return(r._sqlite3_changes=r.asm.mb).apply(null,arguments)},r._sqlite3_close=function(){return(r._sqlite3_close=r.asm.nb).apply(null,arguments)},r._sqlite3_limit=function(){return(r._sqlite3_limit=r.asm.ob).apply(null,arguments)},r._sqlite3_open_v2=function(){return(r._sqlite3_open_v2=r.asm.pb).apply(null,arguments)},r._sqlite3_get_autocommit=function(){return(r._sqlite3_get_autocommit=r.asm.qb).apply(null,arguments)};function Qr(){return(Qr=r.asm.rb).apply(null,arguments)}var Ke=r._malloc=function(){return(Ke=r._malloc=r.asm.sb).apply(null,arguments)},Vr=r._free=function(){return(Vr=r._free=r.asm.tb).apply(null,arguments)};r._RegisterExtensionFunctions=function(){return(r._RegisterExtensionFunctions=r.asm.ub).apply(null,arguments)},r._set_authorizer=function(){return(r._set_authorizer=r.asm.vb).apply(null,arguments)},r._create_function=function(){return(r._create_function=r.asm.wb).apply(null,arguments)},r._create_module=function(){return(r._create_module=r.asm.xb).apply(null,arguments)},r._progress_handler=function(){return(r._progress_handler=r.asm.yb).apply(null,arguments)},r._register_vfs=function(){return(r._register_vfs=r.asm.zb).apply(null,arguments)},r._getSqliteFree=function(){return(r._getSqliteFree=r.asm.Ab).apply(null,arguments)};var Wr=r._main=function(){return(Wr=r._main=r.asm.Bb).apply(null,arguments)};function jr(){return(jr=r.asm.Db).apply(null,arguments)}function Kr(){return(Kr=r.asm.Eb).apply(null,arguments)}function Xr(){return(Xr=r.asm.Fb).apply(null,arguments)}function Yr(){return(Yr=r.asm.Gb).apply(null,arguments)}function Xe(){return(Xe=r.asm.Hb).apply(null,arguments)}function Zr(){return(Zr=r.asm.Ib).apply(null,arguments)}function Gr(){return(Gr=r.asm.Jb).apply(null,arguments)}function Jr(){return(Jr=r.asm.Kb).apply(null,arguments)}function ti(){return(ti=r.asm.Lb).apply(null,arguments)}r.getTempRet0=Kr,r.ccall=wt,r.cwrap=function(t,e,n,i){var o=!n||n.every(m=>m==="number"||m==="boolean");return e!=="string"&&o&&!i?r["_"+t]:function(){return wt(t,e,n,arguments,i)}},r.setValue=_t,r.getValue=et,r.UTF8ToString=B,r.stringToUTF8=jt,r.lengthBytesUTF8=Ut;var Ce;re=function t(){Ce||ei(),Ce||(re=t)};function ei(){function t(){if(!Ce&&(Ce=!0,r.calledRun=!0,!a)){if(r.noFSInit||Kn||(Kn=!0,jn(),r.stdin=r.stdin,r.stdout=r.stdout,r.stderr=r.stderr,r.stdin?se("stdin",r.stdin):Fe("/dev/tty","/dev/stdin"),r.stdout?se("stdout",null,r.stdout):Fe("/dev/tty","/dev/stdout"),r.stderr?se("stderr",null,r.stderr):Fe("/dev/tty1","/dev/stderr"),Ee("/dev/stdin",0),Ee("/dev/stdout",1),Ee("/dev/stderr",1)),kn=!1,de(yn),de(Bi),v(r),r.onRuntimeInitialized&&r.onRuntimeInitialized(),ni){var e=Wr;try{var n=e(0,0);h=n,Pr(n)}catch(i){We(i)}}if(r.postRun)for(typeof r.postRun=="function"&&(r.postRun=[r.postRun]);r.postRun.length;)e=r.postRun.shift(),gn.unshift(e);de(gn)}}if(!(0{try{await navigator.locks.request(u,s,d=>{if(r(d),d)return new Promise(A=>y(this,Mt).set(u,A))})}catch(d){v(d)}})}_releaseWebLock(u){var s;(s=y(this,Mt).get(u))==null||s(),y(this,Mt).delete(u)}async _pollWebLock(u){var r;return(r=(await navigator.locks.query()).held.find(({name:v})=>v===u))==null?void 0:r.mode}_getTimeoutSignal(){if(this.timeoutMillis){const u=new AbortController;return setTimeout(()=>u.abort(),this.timeoutMillis),u.signal}}},rt=new WeakMap,Mt=new WeakMap,Gt=new WeakMap,Jt=new WeakSet,Ge=async function(u,s){const r=s&Ai;try{const v=()=>u.call(this,r);return await X(this,Gt,y(this,Gt).then(v,v)),X(this,rt,r),C}catch(v){return v.name==="AbortError"?K:(console.error(v),fi)}},ce=new WeakSet,ri=async function(u){if(u===y(this,rt))return C;switch(y(this,rt)){case Bt:switch(u){case Tt:return this._NONEtoSHARED();default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}case Tt:switch(u){case ue:return this._SHAREDtoRESERVED();case ae:return this._SHAREDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}case ue:switch(u){case ae:return this._RESERVEDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}},le=new WeakSet,ii=async function(u){if(u===y(this,rt))return C;switch(y(this,rt)){case ae:switch(u){case Tt:return this._EXCLUSIVEtoSHARED();case Bt:return this._EXCLUSIVEtoNONE();default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}case ue:switch(u){case Tt:return this._RESERVEDtoSHARED();case Bt:return this._RESERVEDtoNONE();default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}case Tt:switch(u){case Bt:return this._SHAREDtoNONE();default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}},hn),Ri=class extends qi{constructor(u){super(),this._lockName=u+"-outer",this._reservedName=u+"-reserved"}async isSomewhereReserved(){return await this._pollWebLock(this._reservedName)==="exclusive"}async _NONEtoSHARED(){await this._acquireWebLock(this._lockName,{mode:"exclusive",signal:this._getTimeoutSignal()})}async _SHAREDtoRESERVED(){await this._acquireWebLock(this._reservedName,{mode:"exclusive",signal:this._getTimeoutSignal()})}async _RESERVEDtoSHARED(){this._releaseWebLock(this._reservedName)}async _SHAREDtoNONE(){this._releaseWebLock(this._lockName)}},Ii=5e3,Ci=0,Oe=new WeakMap;function mt(...u){}var Ti=(mn=class{constructor(u,s={durability:"default"}){F(this,fe);F(this,Ht,void 0);F(this,Qt,void 0);F(this,te,void 0);F(this,tt,null);F(this,ee,0);F(this,Vt,Promise.resolve());F(this,Nt,Promise.resolve());X(this,Qt,Promise.resolve(u).then(r=>X(this,Ht,r))),X(this,te,s)}async close(){const u=y(this,Ht)??await y(this,Qt);await y(this,Vt),await this.sync(),u.close()}async run(u,s){const r=y(this,Vt).then(()=>ot(this,fe,si).call(this,u,s));return X(this,Vt,r.catch(()=>{})),r}async sync(){await y(this,Nt),X(this,Nt,Promise.resolve())}},Ht=new WeakMap,Qt=new WeakMap,te=new WeakMap,tt=new WeakMap,ee=new WeakMap,Vt=new WeakMap,Nt=new WeakMap,fe=new WeakSet,si=async function(u,s){var v,d;const r=y(this,Ht)??await y(this,Qt);if(u==="readwrite"&&((v=y(this,tt))==null?void 0:v.mode)==="readonly")X(this,tt,null);else if(performance.now()-y(this,ee)>Ii){try{(d=y(this,tt))==null||d.commit()}catch(A){if(A.name!=="InvalidStateError")throw A}await new Promise(A=>setTimeout(A)),X(this,tt,null)}for(let A=0;A<2;++A){if(!y(this,tt)){X(this,tt,r.transaction(r.objectStoreNames,u,y(this,te)));const T=X(this,ee,performance.now());X(this,Nt,y(this,Nt).then(()=>new Promise((P,Z)=>{y(this,tt).addEventListener("complete",$=>{P(),y(this,tt)===$.target&&X(this,tt,null),mt(`transaction ${Oe.get($.target)} complete`)}),y(this,tt).addEventListener("abort",$=>{console.warn("tx abort",(performance.now()-T)/1e3);const U=$.target.error;Z(U),y(this,tt)===$.target&&X(this,tt,null),mt(`transaction ${Oe.get($.target)} aborted`,U)})}))),Oe.set(y(this,tt),Ci++)}try{const T=Object.fromEntries(Array.from(r.objectStoreNames,P=>[P,new Ni(y(this,tt).objectStore(P))]));return await s(T)}catch(T){if(X(this,tt,null),A)throw T}}},mn);function vt(u){return new Promise((s,r)=>{u.addEventListener("success",()=>s(u.result)),u.addEventListener("error",()=>r(u.error))})}var Ni=(_n=class{constructor(u){F(this,J,void 0);X(this,J,u)}get(u){mt(`get ${y(this,J).name}`,u);const s=y(this,J).get(u);return vt(s)}getAll(u,s){mt(`getAll ${y(this,J).name}`,u,s);const r=y(this,J).getAll(u,s);return vt(r)}getKey(u){mt(`getKey ${y(this,J).name}`,u);const s=y(this,J).getKey(u);return vt(s)}getAllKeys(u,s){mt(`getAllKeys ${y(this,J).name}`,u,s);const r=y(this,J).getAllKeys(u,s);return vt(r)}put(u,s){mt(`put ${y(this,J).name}`,u,s);const r=y(this,J).put(u,s);return vt(r)}delete(u){mt(`delete ${y(this,J).name}`,u);const s=y(this,J).delete(u);return vt(s)}clear(){mt(`clear ${y(this,J).name}`);const u=y(this,J).clear();return vt(u)}index(u){return new Oi(y(this,J).index(u))}},J=new WeakMap,_n),Oi=(pn=class{constructor(u){F(this,Ot,void 0);X(this,Ot,u)}getAllKeys(u,s){mt(`IDBIndex.getAllKeys ${y(this,Ot).objectStore.name}<${y(this,Ot).name}>`,u,s);const r=y(this,Ot).getAllKeys(u,s);return vt(r)}},Ot=new WeakMap,pn),ki=512,ln=3e3,fn={durability:"default",purge:"deferred",purgeAtLeast:16};function ut(...u){}var Li=(dn=class extends Si{constructor(s="wa-sqlite",r=fn){super();F(this,ne);F(this,he);F(this,me);F(this,xt);F(this,_e);F(this,Et,void 0);F(this,it,new Map);F(this,Y,void 0);F(this,kt,new Set);F(this,Lt,performance.now());F(this,yt,new Set);this.name=s,X(this,Et,Object.assign({},fn,r)),X(this,Y,new Ti(Di(s),{durability:y(this,Et).durability}))}async close(){var s;for(const r of y(this,it).keys())await this.xClose(r);await((s=y(this,Y))==null?void 0:s.close()),X(this,Y,null)}xOpen(s,r,v,d){return this.handleAsync(async()=>{s===null&&(s=`null_${r}`),ut(`xOpen ${s} 0x${r.toString(16)} 0x${v.toString(16)}`);try{const A=new URL(s,"http://localhost/"),T={path:A.pathname,flags:v,block0:null,locks:new Ri(A.pathname)};return y(this,it).set(r,T),await y(this,Y).run("readwrite",async({blocks:P})=>{if(T.block0=await P.get(ot(this,xt,Xt).call(this,T,0)),!T.block0)if(v&en)T.block0={path:T.path,offset:0,version:0,data:new Uint8Array(0),fileSize:0},P.put(T.block0);else throw new Error(`file not found: ${T.path}`)}),d.setInt32(0,v&mi,!0),C}catch(A){return console.error(A),tn}})}xClose(s){return this.handleAsync(async()=>{try{const r=y(this,it).get(s);return r&&(ut(`xClose ${r.path}`),y(this,it).delete(s),r.flags&pi&&y(this,Y).run("readwrite",({blocks:v})=>{v.delete(IDBKeyRange.bound([r.path],[r.path,[]]))})),C}catch(r){return console.error(r),D}})}xRead(s,r,v){return this.handleAsync(async()=>{const d=y(this,it).get(s);ut(`xRead ${d.path} ${r.byteLength} ${v}`);try{return await y(this,Y).run("readonly",async({blocks:T})=>{let P=0;for(;Pln){const A=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&y(this,yt).add(s),await new Promise(P=>setTimeout(P));const T=ot(this,ne,Je).call(this,s,r,v);return X(this,Lt,performance.now()),T});return d&&y(this,yt).delete(s),A}return ot(this,ne,Je).call(this,s,r,v)}xTruncate(s,r){const v=y(this,it).get(s);ut(`xTruncate ${v.path} ${r}`);try{Object.assign(v.block0,{fileSize:r,data:v.block0.data.slice(0,r)});const d=Object.assign({},v.block0);return y(this,Y).run("readwrite",({blocks:A})=>{A.delete(ot(this,xt,Xt).call(this,v,-1/0,-r)),A.put(d)}),C}catch(d){return console.error(d),D}}xSync(s,r){const v=y(this,yt).has(s);if(v||y(this,Et).durability!=="relaxed"||performance.now()-y(this,Lt)>ln){const A=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&y(this,yt).add(s);const T=await ot(this,he,oi).call(this,s,r);return X(this,Lt,performance.now()),T});return v&&y(this,yt).delete(s),A}const d=y(this,it).get(s);return ut(`xSync ${d.path} ${r}`),C}xFileSize(s,r){const v=y(this,it).get(s);return ut(`xFileSize ${v.path}`),r.setBigInt64(0,BigInt(v.block0.fileSize),!0),C}xLock(s,r){return this.handleAsync(async()=>{const v=y(this,it).get(s);ut(`xLock ${v.path} ${r}`);try{const d=await v.locks.lock(r);return d===C&&v.locks.state===Tt&&(v.block0=await y(this,Y).run("readonly",({blocks:A})=>A.get(ot(this,xt,Xt).call(this,v,0)))),d}catch(d){return console.error(d),D}})}xUnlock(s,r){return this.handleAsync(async()=>{const v=y(this,it).get(s);ut(`xUnlock ${v.path} ${r}`);try{return v.locks.unlock(r)}catch(d){return console.error(d),D}})}xCheckReservedLock(s,r){return this.handleAsync(async()=>{const v=y(this,it).get(s);ut(`xCheckReservedLock ${v.path}`);const d=await v.locks.isSomewhereReserved();return r.setInt32(0,d?1:0,!0),C})}xSectorSize(s){return ki}xDeviceCharacteristics(s){return gi|wi|bi|yi}xFileControl(s,r,v){const d=y(this,it).get(s);switch(ut(`xFileControl ${d.path} ${r}`),r){case 11:return d.overwrite=!0,C;case 21:if(d.overwrite)try{return this.handleAsync(async()=>(await ot(this,_e,ai).call(this,d),C))}catch(A){return console.error(A),D}return C;case 22:return d.overwrite=!1,C;case 31:return this.handleAsync(async()=>{try{return d.block0.version--,d.changedPages=new Set,y(this,Y).run("readwrite",async({blocks:A})=>{const T=await A.index("version").getAllKeys(IDBKeyRange.bound([d.path],[d.path,d.block0.version]));for(const P of T)A.delete(P)}),C}catch(A){return console.error(A),D}});case 32:try{const A=Object.assign({},d.block0);A.data=A.data.slice();const T=d.changedPages;return d.changedPages=null,y(this,Y).run("readwrite",async({blocks:P})=>{P.put(A);const Z=await P.get([d.path,"purge",0])??{path:d.path,offset:"purge",version:0,data:new Map,count:0};Z.count+=T.size;for(const $ of T)Z.data.set($,A.version);P.put(Z),ot(this,me,ui).call(this,d.path,Z.count)}),C}catch(A){return console.error(A),D}case 33:return this.handleAsync(async()=>{try{return d.changedPages=null,d.block0=await y(this,Y).run("readonly",({blocks:A})=>A.get([d.path,0,d.block0.version+1])),C}catch(A){return console.error(A),D}});default:return Yt}}xAccess(s,r,v){return this.handleAsync(async()=>{try{const d=new URL(s,"file://localhost/").pathname;ut(`xAccess ${d} ${r}`);const A=await y(this,Y).run("readonly",({blocks:T})=>T.getKey(ot(this,xt,Xt).call(this,{path:d},0)));return v.setInt32(0,A?1:0,!0),C}catch(d){return console.error(d),D}})}xDelete(s,r){return this.handleAsync(async()=>{const v=new URL(s,"file://localhost/").pathname;try{return y(this,Y).run("readwrite",({blocks:d})=>d.delete(IDBKeyRange.bound([v],[v,[]]))),r&&await y(this,Y).sync(),C}catch(d){return console.error(d),D}})}async purge(s){const r=Date.now();await y(this,Y).run("readwrite",async({blocks:v})=>{const d=await v.get([s,"purge",0]);if(d){for(const[A,T]of d.data)v.delete(IDBKeyRange.bound([s,A,T],[s,A,1/0],!0,!1));await v.delete([s,"purge",0])}ut(`purge ${s} ${(d==null?void 0:d.data.size)??0} pages in ${Date.now()-r} ms`)})}},Et=new WeakMap,it=new WeakMap,Y=new WeakMap,kt=new WeakMap,Lt=new WeakMap,yt=new WeakMap,ne=new WeakSet,Je=function(s,r,v){const d=y(this,it).get(s);ut(`xWrite ${d.path} ${r.byteLength} ${v}`);try{const A=d.block0.fileSize;d.block0.fileSize=Math.max(d.block0.fileSize,v+r.byteLength);const T=v===0?d.block0:{path:d.path,offset:-v,version:d.block0.version,data:null};return T.data=r.slice(),d.changedPages?(A===d.block0.fileSize&&d.changedPages.add(-v),v!==0&&y(this,Y).run("readwrite",({blocks:P})=>P.put(T))):y(this,Y).run("readwrite",({blocks:P})=>P.put(T)),C}catch(A){return console.error(A),D}},he=new WeakSet,oi=async function(s,r){const v=y(this,it).get(s);ut(`xSync ${v.path} ${r}`);try{await y(this,Y).sync()}catch(d){return console.error(d),D}return C},me=new WeakSet,ui=function(s,r){y(this,Et).purge==="manual"||y(this,kt).has(s)||r{this.purge(s),y(this,kt).delete(s)}):setTimeout(()=>{this.purge(s),y(this,kt).delete(s)}),y(this,kt).add(s))},xt=new WeakSet,Xt=function(s,r,v=0){const d=!r||-r{const gt=await k.index("version").getAllKeys(IDBKeyRange.bound([s.path,U+1],[s.path,1/0]));for(const V of gt)k.delete(V);k.delete([s.path,"purge",0]);for(let V=0;V<$;V+=A){const M=await k.getAll(IDBKeyRange.lowerBound([s.path,-(V+A),1/0]),T);for(const c of M)k.delete([c.path,c.offset,c.version]);if(P===1){const c=new Uint8Array(d);for(const a of M)c.set(a.data,-(V+a.offset));const l={path:s.path,offset:-V,version:U,data:c};l.offset===0&&(l.fileSize=$,s.block0=l),k.put(l)}else{const c=M[0];for(let l=0;l=$)break;const h={path:c.path,offset:a,version:U,data:c.data.subarray(l*d,(l+1)*d)};h.offset===0&&(h.fileSize=$,s.block0=h),k.put(h)}}}})},dn);function Di(u){return new Promise((s,r)=>{const v=globalThis.indexedDB.open(u,5);v.addEventListener("upgradeneeded",function(){v.result.createObjectStore("blocks",{keyPath:["path","offset","version"]}).createIndex("version",["path","version"])}),v.addEventListener("success",()=>{s(v.result)}),v.addEventListener("error",()=>{r(v.error)})})}var lt,Zt;async function Pi(u,s){const r=await xi({locateFile:()=>s});lt=vi(r),lt.vfs_register(new Li(u)),Zt=await lt.open_v2(u,void 0,u),postMessage({type:"init",data:null})}async function ke(u,s){const r=lt.str_new(Zt,u),v=await lt.prepare_v2(Zt,lt.str_value(r));if(v===null)return[];const d=v.stmt;try{typeof s<"u"&<.bind_collection(d,s);const A=[];let T=[];for(;await lt.step(d)===Ne;){T=T.length===0?lt.column_names(d):T;const P=lt.row(d);A.push(T.reduce((Z,$,U)=>(Z[$]=P[U],Z),{}))}return A}finally{await lt.finalize(d)}}async function Ui(u,s){await ke(u,s);const r=await ke("SELECT last_insert_rowid() as id"),v={type:"exec",data:{insertId:BigInt(r[0].id),numAffectedRows:BigInt(lt.changes(Zt))}};postMessage(v)}async function $i(u,s){const r={type:"query",data:await ke(u,s)};postMessage(r)}async function zi(){await lt.close(Zt),postMessage({type:"close",data:null})}onmessage=async u=>{try{const s=u.data;switch(s.type){case"exec":await Ui(s.sql,s.param);break;case"query":await $i(s.sql,s.param);break;case"close":await zi();break;case"init":await Pi(s.dbName,s.url);break}}catch(s){postMessage({type:"error",data:s})}}})(); +`)),!e)return null;var n=Array(Ut(e)+1);e=Cn(e,n,0,n.length),n.length=e,t.input=n}return t.input.shift()},sc:function(t,e){e===null||e===10?(gt(ie(t.Rb,0)),t.Rb=[]):e!=0&&t.Rb.push(e)},ic:function(t){t.Rb&&0=e||(e=Math.max(e,n*(1048576>n?2:1.125)>>>0),n!=0&&(e=Math.max(e,256)),n=t.Nb,t.Nb=new Uint8Array(e),0=t.node.Pb)return 0;if(t=Math.min(t.node.Pb-o,i),8e)throw new E(28);return e},vc:function(t,e,n){O.xc(t.node,e+n),t.node.Pb=Math.max(t.node.Pb,e+n)},kc:function(t,e,n,i,o){if((t.node.mode&61440)!==32768)throw new E(43);if(t=t.node.Nb,o&2||t.buffer!==w.buffer){if((0{if(t=be(t),!t)return{path:"",node:null};if(e=Object.assign({yc:!0,tc:0},e),8!!f);for(var n=Pe,i="/",o=0;o{for(var e;;){if(t===t.parent)return t=t.Ub.Ac,e?t[t.length-1]!=="/"?t+"/"+e:t+e:t;e=e?t.name+"/"+e:t.name,t=t.parent}},$e=(t,e)=>{for(var n=0,i=0;i>>0)%qt.length},kn=t=>{var e=$e(t.parent.id,t.name);if(qt[e]===t)qt[e]=t.ac;else for(e=qt[e];e;){if(e.ac===t){e.ac=t.ac;break}e=e.ac}},$t=(t,e)=>{var n;if(n=(n=Wt(t,"x"))?n:t.Cb.cc?0:2)throw new E(n,t);for(n=qt[$e(t.id,e)];n;n=n.ac){var i=n.name;if(n.parent.id===t.id&&i===e)return n}return t.Cb.cc(t,e)},Dn=(t,e,n,i)=>(t=new Qr(t,e,n,i),e=$e(t.parent.id,t.name),t.ac=qt[e],qt[e]=t),Yi={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Pn=t=>{var e=["r","w","rw"][t&3];return t&512&&(e+="w"),e},Wt=(t,e)=>{if(Ln)return 0;if(!e.includes("r")||t.mode&292){if(e.includes("w")&&!(t.mode&146)||e.includes("x")&&!(t.mode&73))return 2}else return 2;return 0},Un=(t,e)=>{try{return $t(t,e),20}catch{}return Wt(t,"wx")},$n=(t,e,n)=>{try{var i=$t(t,e)}catch(o){return o.Ob}if(t=Wt(t,"wx"))return t;if(n){if((i.mode&61440)!==16384)return 54;if(i===i.parent||ye(i)==="/")return 10}else if((i.mode&61440)===16384)return 31;return 0},Zi=(t=0)=>{for(;4096>=t;t++)if(!At[t])return t;throw new E(33)},zn=(t,e)=>(oe||(oe=function(){this.hc={}},oe.prototype={},Object.defineProperties(oe.prototype,{object:{get:function(){return this.node},set:function(n){this.node=n}},flags:{get:function(){return this.hc.flags},set:function(n){this.hc.flags=n}},position:{get:function(){return this.hc.position},set:function(n){this.hc.position=n}}})),t=Object.assign(new oe,t),e=Zi(e),t.Wb=e,At[e]=t),Gi={open:t=>{t.Mb=On[t.node.ec].Mb,t.Mb.open&&t.Mb.open(t)},Zb:()=>{throw new E(70)}},ze=(t,e)=>{On[t]={Mb:e}},Bn=(t,e)=>{var n=e==="/",i=!e;if(n&&Pe)throw new E(10);if(!n&&!i){var o=at(e,{yc:!1});if(e=o.path,o=o.node,o.$b)throw new E(10);if((o.mode&61440)!==16384)throw new E(54)}e={type:t,Wc:{},Ac:e,Mc:[]},t=t.Ub(e),t.Ub=e,e.root=t,n?Pe=t:o&&(o.$b=e,o.Ub&&o.Ub.Mc.push(e))},Be=(t,e,n)=>{var i=at(t,{parent:!0}).node;if(t=we(t),!t||t==="."||t==="..")throw new E(28);var o=Un(i,t);if(o)throw new E(o);if(!i.Cb.jc)throw new E(63);return i.Cb.jc(i,t,e,n)},pt=(t,e)=>Be(t,(e!==void 0?e:511)&1023|16384,0),ge=(t,e,n)=>{typeof n>"u"&&(n=e,e=438),Be(t,e|8192,n)},Fe=(t,e)=>{if(!be(t))throw new E(44);var n=at(e,{parent:!0}).node;if(!n)throw new E(44);e=we(e);var i=Un(n,e);if(i)throw new E(i);if(!n.Cb.nc)throw new E(63);n.Cb.nc(n,e,t)},Fn=t=>{var e=at(t,{parent:!0}).node;t=we(t);var n=$t(e,t),i=$n(e,t,!0);if(i)throw new E(i);if(!e.Cb.mc)throw new E(63);if(n.$b)throw new E(10);e.Cb.mc(e,t),kn(n)},Hn=t=>{if(t=at(t).node,!t)throw new E(44);if(!t.Cb.fc)throw new E(28);return be(ye(t.parent),t.Cb.fc(t))},ve=(t,e)=>{if(t=at(t,{Yb:!e}).node,!t)throw new E(44);if(!t.Cb.Tb)throw new E(63);return t.Cb.Tb(t)},Qn=t=>ve(t,!0),Mn=(t,e)=>{if(t=typeof t=="string"?at(t,{Yb:!0}).node:t,!t.Cb.Qb)throw new E(63);t.Cb.Qb(t,{mode:e&4095|t.mode&-4096,timestamp:Date.now()})},Vn=(t,e)=>{if(0>e)throw new E(28);if(t=typeof t=="string"?at(t,{Yb:!0}).node:t,!t.Cb.Qb)throw new E(63);if((t.mode&61440)===16384)throw new E(31);if((t.mode&61440)!==32768)throw new E(28);var n=Wt(t,"w");if(n)throw new E(n);t.Cb.Qb(t,{size:e,timestamp:Date.now()})},Ee=(t,e,n)=>{if(t==="")throw new E(44);if(typeof e=="string"){var i=Yi[e];if(typeof i>"u")throw Error("Unknown file open mode: "+e);e=i}if(n=e&64?(typeof n>"u"?438:n)&4095|32768:0,typeof t=="object")var o=t;else{t=St(t);try{o=at(t,{Yb:!(e&131072)}).node}catch{}}if(i=!1,e&64)if(o){if(e&128)throw new E(20)}else o=Be(t,n,0),i=!0;if(!o)throw new E(44);if((o.mode&61440)===8192&&(e&=-513),e&65536&&(o.mode&61440)!==16384)throw new E(54);if(!i&&(n=o?(o.mode&61440)===40960?32:(o.mode&61440)===16384&&(Pn(e)!=="r"||e&512)?31:Wt(o,Pn(e)):44))throw new E(n);return e&512&&!i&&Vn(o,0),e&=-131713,o=zn({node:o,path:ye(o),flags:e,seekable:!0,position:0,Mb:o.Mb,Tc:[],error:!1}),o.Mb.open&&o.Mb.open(o),!r.logReadFiles||e&1||(xe||(xe={}),t in xe||(xe[t]=1)),o},Wn=(t,e,n)=>{if(t.Wb===null)throw new E(8);if(!t.seekable||!t.Mb.Zb)throw new E(70);if(n!=0&&n!=1&&n!=2)throw new E(28);t.position=t.Mb.Zb(t,e,n),t.Tc=[]},jn=()=>{E||(E=function(t,e){this.name="ErrnoError",this.node=e,this.Rc=function(n){this.Ob=n},this.Rc(t),this.message="FS error"},E.prototype=Error(),E.prototype.constructor=E,[44].forEach(t=>{Ue[t]=new E(t),Ue[t].stack=""}))},Kn,Ji=(t,e)=>{var n=0;return t&&(n|=365),e&&(n|=146),n},se=(t,e,n)=>{t=St("/dev/"+t);var i=Ji(!!e,!!n);He||(He=64);var o=He++<<8|0;ze(o,{open:m=>{m.seekable=!1},close:()=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(m,f,b,_)=>{for(var p=0,x=0;x<_;x++){try{var g=e()}catch{throw new E(29)}if(g===void 0&&p===0)throw new E(6);if(g==null)break;p++,f[b+x]=g}return p&&(m.node.timestamp=Date.now()),p},write:(m,f,b,_)=>{for(var p=0;p<_;p++)try{n(f[b+p])}catch{throw new E(29)}return _&&(m.node.timestamp=Date.now()),p}}),ge(t,i,o)},He,j={},oe,xe;function zt(t,e,n){if(e.charAt(0)==="/")return e;if(t=t===-100?"/":ht(t).path,e.length==0){if(!n)throw new E(44);return t}return St(t+"/"+e)}function Se(t,e,n){try{var i=t(e)}catch(m){if(m&&m.node&&St(e)!==St(ye(m.node)))return-54;throw m}R[n>>2]=i.Ic,R[n+8>>2]=i.qc,R[n+12>>2]=i.mode,z[n+16>>2]=i.Oc,R[n+20>>2]=i.uid,R[n+24>>2]=i.Lc,R[n+28>>2]=i.ec,Q=[i.size>>>0,(I=i.size,1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[n+40>>2]=Q[0],R[n+44>>2]=Q[1],R[n+48>>2]=4096,R[n+52>>2]=i.Gc,t=i.Ec.getTime(),e=i.Nc.getTime();var o=i.Hc.getTime();return Q=[Math.floor(t/1e3)>>>0,(I=Math.floor(t/1e3),1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[n+56>>2]=Q[0],R[n+60>>2]=Q[1],z[n+64>>2]=t%1e3*1e3,Q=[Math.floor(e/1e3)>>>0,(I=Math.floor(e/1e3),1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[n+72>>2]=Q[0],R[n+76>>2]=Q[1],z[n+80>>2]=e%1e3*1e3,Q=[Math.floor(o/1e3)>>>0,(I=Math.floor(o/1e3),1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[n+88>>2]=Q[0],R[n+92>>2]=Q[1],z[n+96>>2]=o%1e3*1e3,Q=[i.qc>>>0,(I=i.qc,1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[n+104>>2]=Q[0],R[n+108>>2]=Q[1],0}var Ae=void 0;function qe(){return Ae+=4,R[Ae-4>>2]}function ht(t){if(t=At[t],!t)throw new E(8);return t}function jt(t,e,n){return Cn(t,q,e,n)}function Qe(t){return z[t>>2]+4294967296*R[t+4>>2]}var ts=[0,31,60,91,121,152,182,213,244,274,305,335],es=[0,31,59,90,120,151,181,212,243,273,304,334];function Xn(t){var e=Ut(t)+1,n=Ke(e);return n&&jt(t,n,e),n}var Me={};function Yn(){if(!Ve){var t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:T||"./this.program"},e;for(e in Me)Me[e]===void 0?delete t[e]:t[e]=Me[e];var n=[];for(e in t)n.push(e+"="+t[e]);Ve=n}return Ve}var Ve;function Zn(){}function Gn(){}function Jn(){}function tr(){}function er(){}function nr(){}function rr(){}function ir(){}function sr(){}function or(){}function ur(){}function ar(){}function cr(){}function lr(){}function fr(){}function hr(){}function mr(){}function _r(){}function pr(){}function dr(){}function wr(){}function br(){}function yr(){}function gr(){}function vr(){}function Er(){}function xr(){}function Sr(){}function Ar(){}function qr(){}function Rr(){}function Ir(){}function Cr(){}function Tr(){}function Nr(){}function Or(){}function Lr(){}function kr(){}function Dr(){}function Pr(t){h=t,c||0{je={resolve:t,reject:e}})}function os(){var t=Ke(12300),e=t+12;R[t>>2]=e,R[t+4>>2]=e+12288,e=Ie[0];var n=$r[e];return n===void 0&&(n=rs++,$r[e]=n,zr[n]=e),R[t+8>>2]=n,t}function Br(t){if(!a){if(Rt===0){var e=!1,n=!1;t((i=0)=>{if(!a&&(Ur=i,e=!0,n)){Rt=2,Re(()=>Jr(dt)),i=!1;try{var o=(0,r.asm[zr[R[dt+8>>2]]])()}catch(b){o=b,i=!0}var m=!1;if(!dt){var f=je;f&&(je=null,(i?f.reject:f.resolve)(o),m=!0)}if(i&&!m)throw o}}),n=!0,e||(Rt=1,dt=os(),Re(()=>Zr(dt)))}else Rt===2?(Rt=0,Re(ti),Vr(dt),dt=null,is.forEach(i=>{if(!a)try{if(i(),!(c||0{t().then(e)})}var Hr={};function wt(t,e,n,i,o){function m(g){return--pe,_!==0&&Yr(_),e==="string"?B(g):e==="boolean"?!!g:g}var f={string:g=>{var S=0;if(g!=null&&g!==0){S=Ut(g)+1;var k=Xe(S);jt(g,k,S),S=k}return S},array:g=>{var S=Xe(g.length);return w.set(g,S),S}};t=r["_"+t];var b=[],_=0;if(i)for(var p=0;p{pt("/dev"),ze(259,{read:()=>0,write:(i,o,m,f)=>f}),ge("/dev/null",259),Nn(1280,ji),Nn(1536,Ki),ge("/dev/tty",1280),ge("/dev/tty1",1536);var t=new Uint8Array(1024),e=0,n=()=>(e===0&&(e=In(t).byteLength),t[--e]);se("random",n),se("urandom",n),pt("/dev/shm"),pt("/dev/shm/tmp")})(),(()=>{pt("/proc");var t=pt("/proc/self");pt("/proc/self/fd"),Bn({Ub:()=>{var e=Dn(t,"fd",16895,73);return e.Cb={cc:(n,i)=>{var o=At[+i];if(!o)throw new E(8);return n={parent:null,Ub:{Ac:"fake"},Cb:{fc:()=>o.path}},n.parent=n}},e}},"/proc/self/fd")})(),function(){const t=new Map;r.setAuthorizer=function(e,n,i){return n?t.set(e,{f:n,uc:i}):t.delete(e),wt("set_authorizer","number",["number"],[e])},Zn=function(e,n,i,o,m,f){if(t.has(e)){const{f:b,uc:_}=t.get(e);return b(_,n,i?B(i):null,o?B(o):null,m?B(m):null,f?B(f):null)}return 0}}(),function(){const t=new Map,e=new Map;r.createFunction=function(n,i,o,m,f,b){const _=t.size;return t.set(_,{f:b,Xb:f}),wt("create_function","number","number string number number number number".split(" "),[n,i,o,m,_,0])},r.createAggregate=function(n,i,o,m,f,b,_){const p=t.size;return t.set(p,{step:b,Jc:_,Xb:f}),wt("create_function","number","number string number number number number".split(" "),[n,i,o,m,p,1])},r.getFunctionUserData=function(n){return e.get(n)},Jn=function(n,i,o,m){n=t.get(n),e.set(i,n.Xb),n.f(i,new Uint32Array(q.buffer,m,o)),e.delete(i)},er=function(n,i,o,m){n=t.get(n),e.set(i,n.Xb),n.step(i,new Uint32Array(q.buffer,m,o)),e.delete(i)},Gn=function(n,i){n=t.get(n),e.set(i,n.Xb),n.Jc(i),e.delete(i)}}(),function(){const t=new Map;r.progressHandler=function(e,n,i,o){return i?t.set(e,{f:i,uc:o}):t.delete(e),wt("progress_handler",null,["number","number"],[e,n])},tr=function(e){if(t.has(e)){const{f:n,uc:i}=t.get(e);return n(i)}return 0}}(),function(){function t(_,p){const x=`get${_}`,g=`set${_}`;return new Proxy(new DataView(q.buffer,p,_==="Int32"?4:8),{get(S,k){if(k===x)return function(M,nt){if(!nt)throw Error("must be little endian");return S[k](M,nt)};if(k===g)return function(M,nt,G){if(!G)throw Error("must be little endian");return S[k](M,nt,G)};if(typeof k=="string"&&k.match(/^(get)|(set)/))throw Error("invalid type");return S[k]}})}const e=typeof Hr=="object",n=new Map,i=new Map,o=new Map,m=e?new Set:null,f=e?new Set:null,b=new Map;br=function(_,p,x,g){b.set(B(_),{size:p,dc:Array.from(new Uint32Array(q.buffer,g,x))})},r.createModule=function(_,p,x,g){e&&(x.handleAsync=Fr);const S=n.size;return n.set(S,{module:x,Xb:g}),g=0,x.xCreate&&(g|=1),x.xConnect&&(g|=2),x.xBestIndex&&(g|=4),x.xDisconnect&&(g|=8),x.xDestroy&&(g|=16),x.xOpen&&(g|=32),x.xClose&&(g|=64),x.xFilter&&(g|=128),x.xNext&&(g|=256),x.xEof&&(g|=512),x.xColumn&&(g|=1024),x.xRowid&&(g|=2048),x.xUpdate&&(g|=4096),x.xBegin&&(g|=8192),x.xSync&&(g|=16384),x.xCommit&&(g|=32768),x.xRollback&&(g|=65536),x.xFindFunction&&(g|=131072),x.xRename&&(g|=262144),wt("create_module","number",["number","string","number","number"],[_,p,S,g])},ar=function(_,p,x,g,S,k){if(p=n.get(p),i.set(S,p),e){m.delete(S);for(const M of m)i.delete(M)}return g=Array.from(new Uint32Array(q.buffer,g,x)).map(M=>B(M)),p.module.xCreate(_,p.Xb,g,S,t("Int32",k))},ur=function(_,p,x,g,S,k){if(p=n.get(p),i.set(S,p),e){m.delete(S);for(const M of m)i.delete(M)}return g=Array.from(new Uint32Array(q.buffer,g,x)).map(M=>B(M)),p.module.xConnect(_,p.Xb,g,S,t("Int32",k))},rr=function(_,p){var x=i.get(_),g=b.get("sqlite3_index_info").dc;const S={};S.nConstraint=et(p+g[0],"i32"),S.aConstraint=[];for(var k=et(p+g[1],"*"),M=b.get("sqlite3_index_constraint").size,nt=0;nt>=2,z[f]+z[f+1]*2**32}const n=typeof Hr=="object",i=new Map,o=new Map;r.registerVFS=function(f,b){if(wt("sqlite3_vfs_find","number",["string"],[f.name]))throw Error(`VFS '${f.name}' already registered`);n&&(f.handleAsync=Fr);var _=f.Vc??64;const p=r._malloc(4);return b=wt("register_vfs","number",["string","number","number","number"],[f.name,_,b?1:0,p]),b||(_=et(p,"*"),i.set(_,f)),r._free(p),b};const m=n?new Set:null;xr=function(f){const b=o.get(f);return n?m.add(f):o.delete(f),b.xClose(f)},Tr=function(f,b,_,p){return o.get(f).xRead(f,q.subarray(b,b+_),e(p))},Dr=function(f,b,_,p){return o.get(f).xWrite(f,q.subarray(b,b+_),e(p))},Lr=function(f,b){return o.get(f).xTruncate(f,e(b))},Or=function(f,b){return o.get(f).xSync(f,b)},Rr=function(f,b){const _=o.get(f);return b=t("BigInt64",b),_.xFileSize(f,b)},Ir=function(f,b){return o.get(f).xLock(f,b)},kr=function(f,b){return o.get(f).xUnlock(f,b)},Er=function(f,b){const _=o.get(f);return b=t("Int32",b),_.xCheckReservedLock(f,b)},qr=function(f,b,_){const p=o.get(f);return _=new DataView(q.buffer,_),p.xFileControl(f,b,_)},Nr=function(f){return o.get(f).xSectorSize(f)},Ar=function(f){return o.get(f).xDeviceCharacteristics(f)},Cr=function(f,b,_,p,x){if(f=i.get(f),o.set(_,f),n){m.delete(_);for(var g of m)o.delete(g)}if(g=null,p&64){g=1;const S=[];for(;g;){const k=q[b++];if(k)S.push(k);else switch(q[b]||(g=null),g){case 1:S.push(63),g=2;break;case 2:S.push(61),g=3;break;case 3:S.push(38),g=2}}g=new TextDecoder().decode(new Uint8Array(S))}else b&&(g=B(b));return x=t("Int32",x),f.xOpen(g,_,p,x)},Sr=function(f,b,_){return i.get(f).xDelete(B(b),_)},vr=function(f,b,_,p){return f=i.get(f),p=t("Int32",p),f.xAccess(B(b),_,p)}}();var us={a:function(t,e,n,i){ft("Assertion failed: "+B(t)+", at: "+[e?B(e):"unknown filename",n,i?B(i):"unknown function"])},K:function(t,e){try{return t=B(t),Mn(t,e),0}catch(n){if(typeof j>"u"||n.name!=="ErrnoError")throw n;return-n.Ob}},M:function(t,e,n){try{if(e=B(e),e=zt(t,e),n&-8)return-28;var i=at(e,{Yb:!0}).node;return i?(t="",n&4&&(t+="r"),n&2&&(t+="w"),n&1&&(t+="x"),t&&Wt(i,t)?-2:0):-44}catch(o){if(typeof j>"u"||o.name!=="ErrnoError")throw o;return-o.Ob}},L:function(t,e){try{var n=At[t];if(!n)throw new E(8);return Mn(n.node,e),0}catch(i){if(typeof j>"u"||i.name!=="ErrnoError")throw i;return-i.Ob}},J:function(t){try{var e=At[t];if(!e)throw new E(8);var n=e.node,i=typeof n=="string"?at(n,{Yb:!0}).node:n;if(!i.Cb.Qb)throw new E(63);return i.Cb.Qb(i,{timestamp:Date.now()}),0}catch(o){if(typeof j>"u"||o.name!=="ErrnoError")throw o;return-o.Ob}},b:function(t,e,n){Ae=n;try{var i=ht(t);switch(e){case 0:var o=qe();return 0>o?-28:zn(i,o).Wb;case 1:case 2:return 0;case 3:return i.flags;case 4:return o=qe(),i.flags|=o,0;case 5:return o=qe(),W[o+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return R[Mr()>>2]=28,-1;default:return-28}}catch(m){if(typeof j>"u"||m.name!=="ErrnoError")throw m;return-m.Ob}},I:function(t,e){try{var n=ht(t);return Se(ve,n.path,e)}catch(i){if(typeof j>"u"||i.name!=="ErrnoError")throw i;return-i.Ob}},j:function(t,e,n){try{if(e=n+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*n:NaN,isNaN(e))return-61;var i=At[t];if(!i)throw new E(8);if(!(i.flags&2097155))throw new E(28);return Vn(i.node,e),0}catch(o){if(typeof j>"u"||o.name!=="ErrnoError")throw o;return-o.Ob}},C:function(t,e){try{if(e===0)return-28;var n=Ut("/")+1;return e"u"||i.name!=="ErrnoError")throw i;return-i.Ob}},F:function(t,e){try{return t=B(t),Se(Qn,t,e)}catch(n){if(typeof j>"u"||n.name!=="ErrnoError")throw n;return-n.Ob}},z:function(t,e,n){try{return e=B(e),e=zt(t,e),e=St(e),e[e.length-1]==="/"&&(e=e.substr(0,e.length-1)),pt(e,n),0}catch(i){if(typeof j>"u"||i.name!=="ErrnoError")throw i;return-i.Ob}},E:function(t,e,n,i){try{e=B(e);var o=i&256;return e=zt(t,e,i&4096),Se(o?Qn:ve,e,n)}catch(m){if(typeof j>"u"||m.name!=="ErrnoError")throw m;return-m.Ob}},u:function(t,e,n,i){Ae=i;try{e=B(e),e=zt(t,e);var o=i?qe():0;return Ee(e,n,o).Wb}catch(m){if(typeof j>"u"||m.name!=="ErrnoError")throw m;return-m.Ob}},s:function(t,e,n,i){try{if(e=B(e),e=zt(t,e),0>=i)return-28;var o=Hn(e),m=Math.min(i,Ut(o)),f=w[n+m];return jt(o,n,i+1),w[n+m]=f,m}catch(b){if(typeof j>"u"||b.name!=="ErrnoError")throw b;return-b.Ob}},r:function(t){try{return t=B(t),Fn(t),0}catch(e){if(typeof j>"u"||e.name!=="ErrnoError")throw e;return-e.Ob}},H:function(t,e){try{return t=B(t),Se(ve,t,e)}catch(n){if(typeof j>"u"||n.name!=="ErrnoError")throw n;return-n.Ob}},o:function(t,e,n){try{if(e=B(e),e=zt(t,e),n===0){t=e;var i=at(t,{parent:!0}).node;if(!i)throw new E(44);var o=we(t),m=$t(i,o),f=$n(i,o,!1);if(f)throw new E(f);if(!i.Cb.oc)throw new E(63);if(m.$b)throw new E(10);i.Cb.oc(i,o),kn(m)}else n===512?Fn(e):ft("Invalid flags passed to unlinkat");return 0}catch(b){if(typeof j>"u"||b.name!=="ErrnoError")throw b;return-b.Ob}},n:function(t,e,n){try{if(e=B(e),e=zt(t,e,!0),n){var i=Qe(n),o=R[n+8>>2];m=1e3*i+o/1e6,n+=16,i=Qe(n),o=R[n+8>>2],f=1e3*i+o/1e6}else var m=Date.now(),f=m;t=m;var b=at(e,{Yb:!0}).node;return b.Cb.Qb(b,{timestamp:Math.max(t,f)}),0}catch(_){if(typeof j>"u"||_.name!=="ErrnoError")throw _;return-_.Ob}},y:function(t,e){t=new Date(1e3*Qe(t)),R[e>>2]=t.getSeconds(),R[e+4>>2]=t.getMinutes(),R[e+8>>2]=t.getHours(),R[e+12>>2]=t.getDate(),R[e+16>>2]=t.getMonth(),R[e+20>>2]=t.getFullYear()-1900,R[e+24>>2]=t.getDay();var n=t.getFullYear();R[e+28>>2]=(n%4!==0||n%100===0&&n%400!==0?es:ts)[t.getMonth()]+t.getDate()-1|0,R[e+36>>2]=-(60*t.getTimezoneOffset()),n=new Date(t.getFullYear(),6,1).getTimezoneOffset();var i=new Date(t.getFullYear(),0,1).getTimezoneOffset();R[e+32>>2]=(n!=i&&t.getTimezoneOffset()==Math.min(i,n))|0},w:function(t,e,n,i,o,m,f){try{var b=ht(i);if(e&2&&!(n&2)&&(b.flags&2097155)!==2)throw new E(2);if((b.flags&2097155)===1)throw new E(2);if(!b.Mb.kc)throw new E(43);var _=b.Mb.kc(b,t,o,e,n),p=_.Pc;return R[m>>2]=_.Dc,z[f>>2]=p,0}catch(x){if(typeof j>"u"||x.name!=="ErrnoError")throw x;return-x.Ob}},x:function(t,e,n,i,o,m){try{var f=ht(o);if(n&2){if((f.node.mode&61440)!==32768)throw new E(43);i&2||f.Mb.lc&&f.Mb.lc(f,q.slice(t,t+e),m,e,i)}}catch(b){if(typeof j>"u"||b.name!=="ErrnoError")throw b;return-b.Ob}},p:function(t,e,n){function i(_){return(_=_.toTimeString().match(/\(([A-Za-z ]+)\)$/))?_[1]:"GMT"}var o=new Date().getFullYear(),m=new Date(o,0,1),f=new Date(o,6,1);o=m.getTimezoneOffset();var b=f.getTimezoneOffset();z[t>>2]=60*Math.max(o,b),R[e>>2]=+(o!=b),t=i(m),e=i(f),t=Xn(t),e=Xn(e),b>2]=t,z[n+4>>2]=e):(z[n>>2]=e,z[n+4>>2]=t)},e:function(){return Date.now()},d:()=>performance.now(),l:function(t){var e=q.length;if(t>>>=0,2147483648=n;n*=2){var i=e*(1+.2/n);i=Math.min(i,t+100663296);var o=Math,m=o.min;i=Math.max(t,i),i+=(65536-i%65536)%65536;t:{var f=l.buffer;try{l.grow(m.call(o,2147483648,i)-f.byteLength+65535>>>16),wn();var b=1;break t}catch{}b=void 0}if(b)return!0}return!1},A:function(t,e){var n=0;return Yn().forEach(function(i,o){var m=e+n;for(o=z[t+4*o>>2]=m,m=0;m>0]=i.charCodeAt(m);w[o>>0]=0,n+=i.length+1}),0},B:function(t,e){var n=Yn();z[t>>2]=n.length;var i=0;return n.forEach(function(o){i+=o.length+1}),z[e>>2]=i,0},f:function(t){try{var e=ht(t);if(e.Wb===null)throw new E(8);e.pc&&(e.pc=null);try{e.Mb.close&&e.Mb.close(e)}catch(n){throw n}finally{At[e.Wb]=null}return e.Wb=null,0}catch(n){if(typeof j>"u"||n.name!=="ErrnoError")throw n;return n.Ob}},m:function(t,e){try{var n=ht(t);return w[e>>0]=n.Sb?2:(n.mode&61440)===16384?3:(n.mode&61440)===40960?7:4,W[e+2>>1]=0,Q=[0,(I=0,1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[e+8>>2]=Q[0],R[e+12>>2]=Q[1],Q=[0,(I=0,1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[e+16>>2]=Q[0],R[e+20>>2]=Q[1],0}catch(i){if(typeof j>"u"||i.name!=="ErrnoError")throw i;return i.Ob}},t:function(t,e,n,i){try{t:{var o=ht(t);t=e;for(var m,f=e=0;f>2],_=z[t+4>>2];t+=8;var p=o,x=b,g=_,S=m,k=w;if(0>g||0>S)throw new E(28);if(p.Wb===null)throw new E(8);if((p.flags&2097155)===1)throw new E(8);if((p.node.mode&61440)===16384)throw new E(31);if(!p.Mb.read)throw new E(28);var M=typeof S<"u";if(!M)S=p.position;else if(!p.seekable)throw new E(70);var nt=p.Mb.read(p,k,x,g,S);M||(p.position+=nt);var G=nt;if(0>G){var ct=-1;break t}if(e+=G,G<_)break;typeof m<"u"&&(m+=G)}ct=e}return z[i>>2]=ct,0}catch(st){if(typeof j>"u"||st.name!=="ErrnoError")throw st;return st.Ob}},i:function(t,e,n,i,o){try{if(e=n+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*n:NaN,isNaN(e))return 61;var m=ht(t);return Wn(m,e,i),Q=[m.position>>>0,(I=m.position,1<=+Math.abs(I)?0>>0:~~+Math.ceil((I-+(~~I>>>0))/4294967296)>>>0:0)],R[o>>2]=Q[0],R[o+4>>2]=Q[1],m.pc&&e===0&&i===0&&(m.pc=null),0}catch(f){if(typeof j>"u"||f.name!=="ErrnoError")throw f;return f.Ob}},D:function(t){try{var e=ht(t);return Br(function(n){var i=e.node.Ub;i.type.Sc?i.type.Sc(i,!1,function(o){n(o?function(){return 29}:0)}):n(0)})}catch(n){if(typeof j>"u"||n.name!=="ErrnoError")throw n;return n.Ob}},q:function(t,e,n,i){try{t:{var o=ht(t);t=e;for(var m,f=e=0;f>2],_=z[t+4>>2];t+=8;var p=o,x=b,g=_,S=m,k=w;if(0>g||0>S)throw new E(28);if(p.Wb===null)throw new E(8);if(!(p.flags&2097155))throw new E(8);if((p.node.mode&61440)===16384)throw new E(31);if(!p.Mb.write)throw new E(28);p.seekable&&p.flags&1024&&Wn(p,0,2);var M=typeof S<"u";if(!M)S=p.position;else if(!p.seekable)throw new E(70);var nt=p.Mb.write(p,k,x,g,S,void 0);M||(p.position+=nt);var G=nt;if(0>G){var ct=-1;break t}e+=G,typeof m<"u"&&(m+=G)}ct=e}return z[i>>2]=ct,0}catch(st){if(typeof j>"u"||st.name!=="ErrnoError")throw st;return st.Ob}},ra:Zn,N:Gn,ga:Jn,ca:tr,Y:er,la:nr,G:rr,h:ir,oa:sr,ja:or,ea:ur,fa:ar,k:cr,v:lr,pa:fr,g:hr,qa:mr,da:_r,ha:pr,ia:dr,na:wr,c:br,ka:yr,ma:gr,aa:vr,V:Er,$:xr,ba:Sr,S:Ar,U:qr,Z:Rr,X:Ir,R:Cr,Q:Tr,T:Nr,_:Or,O:Lr,W:kr,P:Dr};(function(){function t(n){if(n=n.exports,n=ns(n),r.asm=n,l=r.asm.sa,wn(),yn.unshift(r.asm.ta),Dt--,r.monitorRunDependencies&&r.monitorRunDependencies(Dt),Dt==0&&re){var i=re;re=null,i()}return n}var e={a:us};if(Dt++,r.monitorRunDependencies&&r.monitorRunDependencies(Dt),r.instantiateWasm)try{return r.instantiateWasm(e,t)}catch(n){V("Module.instantiateWasm callback failed with error: "+n),d(n)}return Qi(e,function(n){t(n.instance)}).catch(d),{}})(),r._sqlite3_vfs_find=function(){return(r._sqlite3_vfs_find=r.asm.ua).apply(null,arguments)},r._sqlite3_malloc=function(){return(r._sqlite3_malloc=r.asm.va).apply(null,arguments)},r._sqlite3_free=function(){return(r._sqlite3_free=r.asm.wa).apply(null,arguments)},r._sqlite3_prepare_v2=function(){return(r._sqlite3_prepare_v2=r.asm.xa).apply(null,arguments)},r._sqlite3_step=function(){return(r._sqlite3_step=r.asm.ya).apply(null,arguments)},r._sqlite3_column_int64=function(){return(r._sqlite3_column_int64=r.asm.za).apply(null,arguments)},r._sqlite3_column_int=function(){return(r._sqlite3_column_int=r.asm.Aa).apply(null,arguments)},r._sqlite3_finalize=function(){return(r._sqlite3_finalize=r.asm.Ba).apply(null,arguments)},r._sqlite3_reset=function(){return(r._sqlite3_reset=r.asm.Ca).apply(null,arguments)},r._sqlite3_clear_bindings=function(){return(r._sqlite3_clear_bindings=r.asm.Da).apply(null,arguments)},r._sqlite3_value_blob=function(){return(r._sqlite3_value_blob=r.asm.Ea).apply(null,arguments)},r._sqlite3_value_text=function(){return(r._sqlite3_value_text=r.asm.Fa).apply(null,arguments)},r._sqlite3_value_bytes=function(){return(r._sqlite3_value_bytes=r.asm.Ga).apply(null,arguments)},r._sqlite3_value_double=function(){return(r._sqlite3_value_double=r.asm.Ha).apply(null,arguments)},r._sqlite3_value_int=function(){return(r._sqlite3_value_int=r.asm.Ia).apply(null,arguments)},r._sqlite3_value_int64=function(){return(r._sqlite3_value_int64=r.asm.Ja).apply(null,arguments)},r._sqlite3_value_type=function(){return(r._sqlite3_value_type=r.asm.Ka).apply(null,arguments)},r._sqlite3_result_blob=function(){return(r._sqlite3_result_blob=r.asm.La).apply(null,arguments)},r._sqlite3_result_double=function(){return(r._sqlite3_result_double=r.asm.Ma).apply(null,arguments)},r._sqlite3_result_error=function(){return(r._sqlite3_result_error=r.asm.Na).apply(null,arguments)},r._sqlite3_result_int=function(){return(r._sqlite3_result_int=r.asm.Oa).apply(null,arguments)},r._sqlite3_result_int64=function(){return(r._sqlite3_result_int64=r.asm.Pa).apply(null,arguments)},r._sqlite3_result_null=function(){return(r._sqlite3_result_null=r.asm.Qa).apply(null,arguments)},r._sqlite3_result_text=function(){return(r._sqlite3_result_text=r.asm.Ra).apply(null,arguments)},r._sqlite3_column_count=function(){return(r._sqlite3_column_count=r.asm.Sa).apply(null,arguments)},r._sqlite3_data_count=function(){return(r._sqlite3_data_count=r.asm.Ta).apply(null,arguments)},r._sqlite3_column_blob=function(){return(r._sqlite3_column_blob=r.asm.Ua).apply(null,arguments)},r._sqlite3_column_bytes=function(){return(r._sqlite3_column_bytes=r.asm.Va).apply(null,arguments)},r._sqlite3_column_double=function(){return(r._sqlite3_column_double=r.asm.Wa).apply(null,arguments)},r._sqlite3_column_text=function(){return(r._sqlite3_column_text=r.asm.Xa).apply(null,arguments)},r._sqlite3_column_type=function(){return(r._sqlite3_column_type=r.asm.Ya).apply(null,arguments)},r._sqlite3_column_name=function(){return(r._sqlite3_column_name=r.asm.Za).apply(null,arguments)},r._sqlite3_bind_blob=function(){return(r._sqlite3_bind_blob=r.asm._a).apply(null,arguments)},r._sqlite3_bind_double=function(){return(r._sqlite3_bind_double=r.asm.$a).apply(null,arguments)},r._sqlite3_bind_int=function(){return(r._sqlite3_bind_int=r.asm.ab).apply(null,arguments)},r._sqlite3_bind_int64=function(){return(r._sqlite3_bind_int64=r.asm.bb).apply(null,arguments)},r._sqlite3_bind_null=function(){return(r._sqlite3_bind_null=r.asm.cb).apply(null,arguments)},r._sqlite3_bind_text=function(){return(r._sqlite3_bind_text=r.asm.db).apply(null,arguments)},r._sqlite3_bind_parameter_count=function(){return(r._sqlite3_bind_parameter_count=r.asm.eb).apply(null,arguments)},r._sqlite3_bind_parameter_name=function(){return(r._sqlite3_bind_parameter_name=r.asm.fb).apply(null,arguments)},r._sqlite3_sql=function(){return(r._sqlite3_sql=r.asm.gb).apply(null,arguments)},r._sqlite3_exec=function(){return(r._sqlite3_exec=r.asm.hb).apply(null,arguments)},r._sqlite3_errmsg=function(){return(r._sqlite3_errmsg=r.asm.ib).apply(null,arguments)},r._sqlite3_declare_vtab=function(){return(r._sqlite3_declare_vtab=r.asm.jb).apply(null,arguments)},r._sqlite3_libversion=function(){return(r._sqlite3_libversion=r.asm.kb).apply(null,arguments)},r._sqlite3_libversion_number=function(){return(r._sqlite3_libversion_number=r.asm.lb).apply(null,arguments)},r._sqlite3_changes=function(){return(r._sqlite3_changes=r.asm.mb).apply(null,arguments)},r._sqlite3_close=function(){return(r._sqlite3_close=r.asm.nb).apply(null,arguments)},r._sqlite3_limit=function(){return(r._sqlite3_limit=r.asm.ob).apply(null,arguments)},r._sqlite3_open_v2=function(){return(r._sqlite3_open_v2=r.asm.pb).apply(null,arguments)},r._sqlite3_get_autocommit=function(){return(r._sqlite3_get_autocommit=r.asm.qb).apply(null,arguments)};function Mr(){return(Mr=r.asm.rb).apply(null,arguments)}var Ke=r._malloc=function(){return(Ke=r._malloc=r.asm.sb).apply(null,arguments)},Vr=r._free=function(){return(Vr=r._free=r.asm.tb).apply(null,arguments)};r._RegisterExtensionFunctions=function(){return(r._RegisterExtensionFunctions=r.asm.ub).apply(null,arguments)},r._set_authorizer=function(){return(r._set_authorizer=r.asm.vb).apply(null,arguments)},r._create_function=function(){return(r._create_function=r.asm.wb).apply(null,arguments)},r._create_module=function(){return(r._create_module=r.asm.xb).apply(null,arguments)},r._progress_handler=function(){return(r._progress_handler=r.asm.yb).apply(null,arguments)},r._register_vfs=function(){return(r._register_vfs=r.asm.zb).apply(null,arguments)},r._getSqliteFree=function(){return(r._getSqliteFree=r.asm.Ab).apply(null,arguments)};var Wr=r._main=function(){return(Wr=r._main=r.asm.Bb).apply(null,arguments)};function jr(){return(jr=r.asm.Db).apply(null,arguments)}function Kr(){return(Kr=r.asm.Eb).apply(null,arguments)}function Xr(){return(Xr=r.asm.Fb).apply(null,arguments)}function Yr(){return(Yr=r.asm.Gb).apply(null,arguments)}function Xe(){return(Xe=r.asm.Hb).apply(null,arguments)}function Zr(){return(Zr=r.asm.Ib).apply(null,arguments)}function Gr(){return(Gr=r.asm.Jb).apply(null,arguments)}function Jr(){return(Jr=r.asm.Kb).apply(null,arguments)}function ti(){return(ti=r.asm.Lb).apply(null,arguments)}r.getTempRet0=Kr,r.ccall=wt,r.cwrap=function(t,e,n,i){var o=!n||n.every(m=>m==="number"||m==="boolean");return e!=="string"&&o&&!i?r["_"+t]:function(){return wt(t,e,n,arguments,i)}},r.setValue=_t,r.getValue=et,r.UTF8ToString=B,r.stringToUTF8=jt,r.lengthBytesUTF8=Ut;var Ce;re=function t(){Ce||ei(),Ce||(re=t)};function ei(){function t(){if(!Ce&&(Ce=!0,r.calledRun=!0,!a)){if(r.noFSInit||Kn||(Kn=!0,jn(),r.stdin=r.stdin,r.stdout=r.stdout,r.stderr=r.stderr,r.stdin?se("stdin",r.stdin):Fe("/dev/tty","/dev/stdin"),r.stdout?se("stdout",null,r.stdout):Fe("/dev/tty","/dev/stdout"),r.stderr?se("stderr",null,r.stderr):Fe("/dev/tty1","/dev/stderr"),Ee("/dev/stdin",0),Ee("/dev/stdout",1),Ee("/dev/stderr",1)),Ln=!1,de(yn),de(Bi),v(r),r.onRuntimeInitialized&&r.onRuntimeInitialized(),ni){var e=Wr;try{var n=e(0,0);h=n,Pr(n)}catch(i){We(i)}}if(r.postRun)for(typeof r.postRun=="function"&&(r.postRun=[r.postRun]);r.postRun.length;)e=r.postRun.shift(),gn.unshift(e);de(gn)}}if(!(0{try{await navigator.locks.request(u,s,d=>{if(r(d),d)return new Promise(A=>y(this,Ht).set(u,A))})}catch(d){v(d)}})}_releaseWebLock(u){var s;(s=y(this,Ht).get(u))==null||s(),y(this,Ht).delete(u)}async _pollWebLock(u){var r;return(r=(await navigator.locks.query()).held.find(({name:v})=>v===u))==null?void 0:r.mode}_getTimeoutSignal(){if(this.timeoutMillis){const u=new AbortController;return setTimeout(()=>u.abort(),this.timeoutMillis),u.signal}}},rt=new WeakMap,Ht=new WeakMap,Gt=new WeakMap,Jt=new WeakSet,Ge=async function(u,s){const r=s&Ai;try{const v=()=>u.call(this,r);return await X(this,Gt,y(this,Gt).then(v,v)),X(this,rt,r),C}catch(v){return v.name==="AbortError"?K:(console.error(v),fi)}},ce=new WeakSet,ri=async function(u){if(u===y(this,rt))return C;switch(y(this,rt)){case Bt:switch(u){case Tt:return this._NONEtoSHARED();default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}case Tt:switch(u){case ue:return this._SHAREDtoRESERVED();case ae:return this._SHAREDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}case ue:switch(u){case ae:return this._RESERVEDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}},le=new WeakSet,ii=async function(u){if(u===y(this,rt))return C;switch(y(this,rt)){case ae:switch(u){case Tt:return this._EXCLUSIVEtoSHARED();case Bt:return this._EXCLUSIVEtoNONE();default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}case ue:switch(u){case Tt:return this._RESERVEDtoSHARED();case Bt:return this._RESERVEDtoNONE();default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}case Tt:switch(u){case Bt:return this._SHAREDtoNONE();default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}default:throw new Error(`unexpected transition ${y(this,rt)} -> ${u}`)}},hn),Ri=class extends qi{constructor(u){super(),this._lockName=u+"-outer",this._reservedName=u+"-reserved"}async isSomewhereReserved(){return await this._pollWebLock(this._reservedName)==="exclusive"}async _NONEtoSHARED(){await this._acquireWebLock(this._lockName,{mode:"exclusive",signal:this._getTimeoutSignal()})}async _SHAREDtoRESERVED(){await this._acquireWebLock(this._reservedName,{mode:"exclusive",signal:this._getTimeoutSignal()})}async _RESERVEDtoSHARED(){this._releaseWebLock(this._reservedName)}async _SHAREDtoNONE(){this._releaseWebLock(this._lockName)}},Ii=5e3,Ci=0,Oe=new WeakMap;function mt(...u){}var Ti=(mn=class{constructor(u,s={durability:"default"}){F(this,fe);F(this,Qt,void 0);F(this,Mt,void 0);F(this,te,void 0);F(this,tt,null);F(this,ee,0);F(this,Vt,Promise.resolve());F(this,Nt,Promise.resolve());X(this,Mt,Promise.resolve(u).then(r=>X(this,Qt,r))),X(this,te,s)}async close(){const u=y(this,Qt)??await y(this,Mt);await y(this,Vt),await this.sync(),u.close()}async run(u,s){const r=y(this,Vt).then(()=>ot(this,fe,si).call(this,u,s));return X(this,Vt,r.catch(()=>{})),r}async sync(){await y(this,Nt),X(this,Nt,Promise.resolve())}},Qt=new WeakMap,Mt=new WeakMap,te=new WeakMap,tt=new WeakMap,ee=new WeakMap,Vt=new WeakMap,Nt=new WeakMap,fe=new WeakSet,si=async function(u,s){var v,d;const r=y(this,Qt)??await y(this,Mt);if(u==="readwrite"&&((v=y(this,tt))==null?void 0:v.mode)==="readonly")X(this,tt,null);else if(performance.now()-y(this,ee)>Ii){try{(d=y(this,tt))==null||d.commit()}catch(A){if(A.name!=="InvalidStateError")throw A}await new Promise(A=>setTimeout(A)),X(this,tt,null)}for(let A=0;A<2;++A){if(!y(this,tt)){X(this,tt,r.transaction(r.objectStoreNames,u,y(this,te)));const T=X(this,ee,performance.now());X(this,Nt,y(this,Nt).then(()=>new Promise((P,Z)=>{y(this,tt).addEventListener("complete",$=>{P(),y(this,tt)===$.target&&X(this,tt,null),mt(`transaction ${Oe.get($.target)} complete`)}),y(this,tt).addEventListener("abort",$=>{console.warn("tx abort",(performance.now()-T)/1e3);const U=$.target.error;Z(U),y(this,tt)===$.target&&X(this,tt,null),mt(`transaction ${Oe.get($.target)} aborted`,U)})}))),Oe.set(y(this,tt),Ci++)}try{const T=Object.fromEntries(Array.from(r.objectStoreNames,P=>[P,new Ni(y(this,tt).objectStore(P))]));return await s(T)}catch(T){if(X(this,tt,null),A)throw T}}},mn);function vt(u){return new Promise((s,r)=>{u.addEventListener("success",()=>s(u.result)),u.addEventListener("error",()=>r(u.error))})}var Ni=(_n=class{constructor(u){F(this,J,void 0);X(this,J,u)}get(u){mt(`get ${y(this,J).name}`,u);const s=y(this,J).get(u);return vt(s)}getAll(u,s){mt(`getAll ${y(this,J).name}`,u,s);const r=y(this,J).getAll(u,s);return vt(r)}getKey(u){mt(`getKey ${y(this,J).name}`,u);const s=y(this,J).getKey(u);return vt(s)}getAllKeys(u,s){mt(`getAllKeys ${y(this,J).name}`,u,s);const r=y(this,J).getAllKeys(u,s);return vt(r)}put(u,s){mt(`put ${y(this,J).name}`,u,s);const r=y(this,J).put(u,s);return vt(r)}delete(u){mt(`delete ${y(this,J).name}`,u);const s=y(this,J).delete(u);return vt(s)}clear(){mt(`clear ${y(this,J).name}`);const u=y(this,J).clear();return vt(u)}index(u){return new Oi(y(this,J).index(u))}},J=new WeakMap,_n),Oi=(pn=class{constructor(u){F(this,Ot,void 0);X(this,Ot,u)}getAllKeys(u,s){mt(`IDBIndex.getAllKeys ${y(this,Ot).objectStore.name}<${y(this,Ot).name}>`,u,s);const r=y(this,Ot).getAllKeys(u,s);return vt(r)}},Ot=new WeakMap,pn),Li=512,ln=3e3,fn={durability:"default",purge:"deferred",purgeAtLeast:16};function ut(...u){}var ki=(dn=class extends Si{constructor(s="wa-sqlite",r=fn){super();F(this,ne);F(this,he);F(this,me);F(this,xt);F(this,_e);F(this,Et,void 0);F(this,it,new Map);F(this,Y,void 0);F(this,Lt,new Set);F(this,kt,performance.now());F(this,yt,new Set);this.name=s,X(this,Et,Object.assign({},fn,r)),X(this,Y,new Ti(Di(s),{durability:y(this,Et).durability}))}async close(){var s;for(const r of y(this,it).keys())await this.xClose(r);await((s=y(this,Y))==null?void 0:s.close()),X(this,Y,null)}xOpen(s,r,v,d){return this.handleAsync(async()=>{s===null&&(s=`null_${r}`),ut(`xOpen ${s} 0x${r.toString(16)} 0x${v.toString(16)}`);try{const A=new URL(s,"http://localhost/"),T={path:A.pathname,flags:v,block0:null,locks:new Ri(A.pathname)};return y(this,it).set(r,T),await y(this,Y).run("readwrite",async({blocks:P})=>{if(T.block0=await P.get(ot(this,xt,Xt).call(this,T,0)),!T.block0)if(v&en)T.block0={path:T.path,offset:0,version:0,data:new Uint8Array(0),fileSize:0},P.put(T.block0);else throw new Error(`file not found: ${T.path}`)}),d.setInt32(0,v&mi,!0),C}catch(A){return console.error(A),tn}})}xClose(s){return this.handleAsync(async()=>{try{const r=y(this,it).get(s);return r&&(ut(`xClose ${r.path}`),y(this,it).delete(s),r.flags&pi&&y(this,Y).run("readwrite",({blocks:v})=>{v.delete(IDBKeyRange.bound([r.path],[r.path,[]]))})),C}catch(r){return console.error(r),D}})}xRead(s,r,v){return this.handleAsync(async()=>{const d=y(this,it).get(s);ut(`xRead ${d.path} ${r.byteLength} ${v}`);try{return await y(this,Y).run("readonly",async({blocks:T})=>{let P=0;for(;Pln){const A=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&y(this,yt).add(s),await new Promise(P=>setTimeout(P));const T=ot(this,ne,Je).call(this,s,r,v);return X(this,kt,performance.now()),T});return d&&y(this,yt).delete(s),A}return ot(this,ne,Je).call(this,s,r,v)}xTruncate(s,r){const v=y(this,it).get(s);ut(`xTruncate ${v.path} ${r}`);try{Object.assign(v.block0,{fileSize:r,data:v.block0.data.slice(0,r)});const d=Object.assign({},v.block0);return y(this,Y).run("readwrite",({blocks:A})=>{A.delete(ot(this,xt,Xt).call(this,v,-1/0,-r)),A.put(d)}),C}catch(d){return console.error(d),D}}xSync(s,r){const v=y(this,yt).has(s);if(v||y(this,Et).durability!=="relaxed"||performance.now()-y(this,kt)>ln){const A=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&y(this,yt).add(s);const T=await ot(this,he,oi).call(this,s,r);return X(this,kt,performance.now()),T});return v&&y(this,yt).delete(s),A}const d=y(this,it).get(s);return ut(`xSync ${d.path} ${r}`),C}xFileSize(s,r){const v=y(this,it).get(s);return ut(`xFileSize ${v.path}`),r.setBigInt64(0,BigInt(v.block0.fileSize),!0),C}xLock(s,r){return this.handleAsync(async()=>{const v=y(this,it).get(s);ut(`xLock ${v.path} ${r}`);try{const d=await v.locks.lock(r);return d===C&&v.locks.state===Tt&&(v.block0=await y(this,Y).run("readonly",({blocks:A})=>A.get(ot(this,xt,Xt).call(this,v,0)))),d}catch(d){return console.error(d),D}})}xUnlock(s,r){return this.handleAsync(async()=>{const v=y(this,it).get(s);ut(`xUnlock ${v.path} ${r}`);try{return v.locks.unlock(r)}catch(d){return console.error(d),D}})}xCheckReservedLock(s,r){return this.handleAsync(async()=>{const v=y(this,it).get(s);ut(`xCheckReservedLock ${v.path}`);const d=await v.locks.isSomewhereReserved();return r.setInt32(0,d?1:0,!0),C})}xSectorSize(s){return Li}xDeviceCharacteristics(s){return gi|wi|bi|yi}xFileControl(s,r,v){const d=y(this,it).get(s);switch(ut(`xFileControl ${d.path} ${r}`),r){case 11:return d.overwrite=!0,C;case 21:if(d.overwrite)try{return this.handleAsync(async()=>(await ot(this,_e,ai).call(this,d),C))}catch(A){return console.error(A),D}return C;case 22:return d.overwrite=!1,C;case 31:return this.handleAsync(async()=>{try{return d.block0.version--,d.changedPages=new Set,y(this,Y).run("readwrite",async({blocks:A})=>{const T=await A.index("version").getAllKeys(IDBKeyRange.bound([d.path],[d.path,d.block0.version]));for(const P of T)A.delete(P)}),C}catch(A){return console.error(A),D}});case 32:try{const A=Object.assign({},d.block0);A.data=A.data.slice();const T=d.changedPages;return d.changedPages=null,y(this,Y).run("readwrite",async({blocks:P})=>{P.put(A);const Z=await P.get([d.path,"purge",0])??{path:d.path,offset:"purge",version:0,data:new Map,count:0};Z.count+=T.size;for(const $ of T)Z.data.set($,A.version);P.put(Z),ot(this,me,ui).call(this,d.path,Z.count)}),C}catch(A){return console.error(A),D}case 33:return this.handleAsync(async()=>{try{return d.changedPages=null,d.block0=await y(this,Y).run("readonly",({blocks:A})=>A.get([d.path,0,d.block0.version+1])),C}catch(A){return console.error(A),D}});default:return Yt}}xAccess(s,r,v){return this.handleAsync(async()=>{try{const d=new URL(s,"file://localhost/").pathname;ut(`xAccess ${d} ${r}`);const A=await y(this,Y).run("readonly",({blocks:T})=>T.getKey(ot(this,xt,Xt).call(this,{path:d},0)));return v.setInt32(0,A?1:0,!0),C}catch(d){return console.error(d),D}})}xDelete(s,r){return this.handleAsync(async()=>{const v=new URL(s,"file://localhost/").pathname;try{return y(this,Y).run("readwrite",({blocks:d})=>d.delete(IDBKeyRange.bound([v],[v,[]]))),r&&await y(this,Y).sync(),C}catch(d){return console.error(d),D}})}async purge(s){const r=Date.now();await y(this,Y).run("readwrite",async({blocks:v})=>{const d=await v.get([s,"purge",0]);if(d){for(const[A,T]of d.data)v.delete(IDBKeyRange.bound([s,A,T],[s,A,1/0],!0,!1));await v.delete([s,"purge",0])}ut(`purge ${s} ${(d==null?void 0:d.data.size)??0} pages in ${Date.now()-r} ms`)})}},Et=new WeakMap,it=new WeakMap,Y=new WeakMap,Lt=new WeakMap,kt=new WeakMap,yt=new WeakMap,ne=new WeakSet,Je=function(s,r,v){const d=y(this,it).get(s);ut(`xWrite ${d.path} ${r.byteLength} ${v}`);try{const A=d.block0.fileSize;d.block0.fileSize=Math.max(d.block0.fileSize,v+r.byteLength);const T=v===0?d.block0:{path:d.path,offset:-v,version:d.block0.version,data:null};return T.data=r.slice(),d.changedPages?(A===d.block0.fileSize&&d.changedPages.add(-v),v!==0&&y(this,Y).run("readwrite",({blocks:P})=>P.put(T))):y(this,Y).run("readwrite",({blocks:P})=>P.put(T)),C}catch(A){return console.error(A),D}},he=new WeakSet,oi=async function(s,r){const v=y(this,it).get(s);ut(`xSync ${v.path} ${r}`);try{await y(this,Y).sync()}catch(d){return console.error(d),D}return C},me=new WeakSet,ui=function(s,r){y(this,Et).purge==="manual"||y(this,Lt).has(s)||r{this.purge(s),y(this,Lt).delete(s)}):setTimeout(()=>{this.purge(s),y(this,Lt).delete(s)}),y(this,Lt).add(s))},xt=new WeakSet,Xt=function(s,r,v=0){const d=!r||-r{const gt=await L.index("version").getAllKeys(IDBKeyRange.bound([s.path,U+1],[s.path,1/0]));for(const V of gt)L.delete(V);L.delete([s.path,"purge",0]);for(let V=0;V<$;V+=A){const H=await L.getAll(IDBKeyRange.lowerBound([s.path,-(V+A),1/0]),T);for(const c of H)L.delete([c.path,c.offset,c.version]);if(P===1){const c=new Uint8Array(d);for(const a of H)c.set(a.data,-(V+a.offset));const l={path:s.path,offset:-V,version:U,data:c};l.offset===0&&(l.fileSize=$,s.block0=l),L.put(l)}else{const c=H[0];for(let l=0;l=$)break;const h={path:c.path,offset:a,version:U,data:c.data.subarray(l*d,(l+1)*d)};h.offset===0&&(h.fileSize=$,s.block0=h),L.put(h)}}}})},dn);function Di(u){return new Promise((s,r)=>{const v=globalThis.indexedDB.open(u,5);v.addEventListener("upgradeneeded",function(){v.result.createObjectStore("blocks",{keyPath:["path","offset","version"]}).createIndex("version",["path","version"])}),v.addEventListener("success",()=>{s(v.result)}),v.addEventListener("error",()=>{r(v.error)})})}var lt,Zt;async function Pi(u,s){const r=await xi({locateFile:()=>s});lt=vi(r),lt.vfs_register(new ki(u)),Zt=await lt.open_v2(u,void 0,u)}async function Le(u,s){const r=lt.str_new(Zt,u),v=await lt.prepare_v2(Zt,lt.str_value(r));if(v===null)return[];const d=v.stmt;try{typeof s<"u"&<.bind_collection(d,s);const A=[];let T=[];for(;await lt.step(d)===Ne;){T=T.length===0?lt.column_names(d):T;const P=lt.row(d);A.push(T.reduce((Z,$,U)=>(Z[$]=P[U],Z),{}))}return A}finally{await lt.finalize(d)}}async function Ui(u,s){await Le(u,s);const r=await Le("SELECT last_insert_rowid() as id");return{insertId:BigInt(r[0].id),numAffectedRows:BigInt(lt.changes(Zt)),rows:[]}}async function $i(u,s){return{rows:await Le(u,s)}}async function zi(){await lt.close(Zt)}onmessage=async u=>{const s=u.data,r={type:s.type,msg:{data:null,err:null}};try{switch(s.type){case"run":r.msg.data=s.isQuery?await $i(s.sql,s.parameters):await Ui(s.sql,s.parameters);break;case"close":await zi();break;case"init":await Pi(s.dbName,s.url);break}}catch(v){r.msg.err=v}postMessage(r)}})(); diff --git a/index.html b/index.html index d7699a4..f815cbc 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ test - +