diff --git a/assets/index-b9a926db.js b/assets/index-b9a926db.js new file mode 100644 index 0000000..c984d8f --- /dev/null +++ b/assets/index-b9a926db.js @@ -0,0 +1,15 @@ +var Vp=Object.defineProperty;var zp=(t,e,n)=>e in t?Vp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Te=(t,e,n)=>(zp(t,typeof e!="symbol"?e+"":e,n),n),al=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var r=(t,e,n)=>(al(t,e,"read from private field"),n?n.call(t):e.get(t)),F=(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)},J=(t,e,n,i)=>(al(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n);var Oe=(t,e,n)=>(al(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 Kl(t,e){const n=Object.create(null),i=t.split(",");for(let a=0;a!!n[a.toLowerCase()]:a=>!!n[a]}function Jl(t){if(Ie(t)){const e={};for(let n=0;n{if(n){const i=n.split(Jp);i.length>1&&(e[i[0].trim()]=i[1].trim())}}),e}function Gl(t){let e="";if(Pt(t))e=t;else if(Ie(t))for(let n=0;nPt(t)?t:t==null?"":Ie(t)||wt(t)&&(t.toString===Qh||!Se(t.toString))?JSON.stringify(t,Fh,2):String(t),Fh=(t,e)=>e&&e.__v_isRef?Fh(t,e.value):Us(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((n,[i,a])=>(n[`${i} =>`]=a,n),{})}:Uh(e)?{[`Set(${e.size})`]:[...e.values()]}:wt(e)&&!Ie(e)&&!jh(e)?String(e):e,ft={},Fs=[],fr=()=>{},tm=()=>!1,nm=/^on[^a-z]/,Dc=t=>nm.test(t),Xl=t=>t.startsWith("onUpdate:"),on=Object.assign,Yl=(t,e)=>{const n=t.indexOf(e);n>-1&&t.splice(n,1)},rm=Object.prototype.hasOwnProperty,Fe=(t,e)=>rm.call(t,e),Ie=Array.isArray,Us=t=>Lc(t)==="[object Map]",Uh=t=>Lc(t)==="[object Set]",Se=t=>typeof t=="function",Pt=t=>typeof t=="string",Zl=t=>typeof t=="symbol",wt=t=>t!==null&&typeof t=="object",$h=t=>wt(t)&&Se(t.then)&&Se(t.catch),Qh=Object.prototype.toString,Lc=t=>Qh.call(t),im=t=>Lc(t).slice(8,-1),jh=t=>Lc(t)==="[object Object]",ef=t=>Pt(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,qu=Kl(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),Pc=t=>{const e=Object.create(null);return n=>e[n]||(e[n]=t(n))},sm=/-(\w)/g,mo=Pc(t=>t.replace(sm,(e,n)=>n?n.toUpperCase():"")),om=/\B([A-Z])/g,Eo=Pc(t=>t.replace(om,"-$1").toLowerCase()),Hh=Pc(t=>t.charAt(0).toUpperCase()+t.slice(1)),ul=Pc(t=>t?`on${Hh(t)}`:""),la=(t,e)=>!Object.is(t,e),cl=(t,e)=>{for(let n=0;n{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})},am=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let Sf;const um=()=>Sf||(Sf=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});let Yn;class cm{constructor(e=!1){this.detached=e,this._active=!0,this.effects=[],this.cleanups=[],this.parent=Yn,!e&&Yn&&(this.index=(Yn.scopes||(Yn.scopes=[])).push(this)-1)}get active(){return this._active}run(e){if(this._active){const n=Yn;try{return Yn=this,e()}finally{Yn=n}}}on(){Yn=this}off(){Yn=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},Vh=t=>(t.w&pi)>0,zh=t=>(t.n&pi)>0,hm=({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)&&w.push(d)})}else switch(n!==void 0&&w.push(m.get(n)),e){case"add":Ie(t)?ef(n)&&w.push(m.get("length")):(w.push(m.get(us)),Us(t)&&w.push(m.get(_l)));break;case"delete":Ie(t)||(w.push(m.get(us)),Us(t)&&w.push(m.get(_l)));break;case"set":Us(t)&&w.push(m.get(us));break}if(w.length===1)w[0]&&xl(w[0]);else{const v=[];for(const d of w)d&&v.push(...d);xl(tf(v))}}function xl(t,e){const n=Ie(t)?t:[...t];for(const i of n)i.computed&&Df(i);for(const i of n)i.computed||Df(i)}function Df(t,e){(t!==ar||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const pm=Kl("__proto__,__v_isRef,__isVue"),Gh=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(Zl)),mm=rf(),ym=rf(!1,!0),wm=rf(!0),Lf=gm();function gm(){const t={};return["includes","indexOf","lastIndexOf"].forEach(e=>{t[e]=function(...n){const i=Ue(this);for(let l=0,m=this.length;l{t[e]=function(...n){Co();const i=Ue(this)[e].apply(this,n);return qo(),i}}),t}function bm(t){const e=Ue(this);return xn(e,"has",t),e.hasOwnProperty(t)}function rf(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?Dm:td:e?ed:Zh).get(i))return i;const m=Ie(i);if(!t){if(m&&Fe(Lf,a))return Reflect.get(Lf,a,l);if(a==="hasOwnProperty")return bm}const w=Reflect.get(i,a,l);return(Zl(a)?Gh.has(a):pm(a))||(t||xn(i,"get",a),e)?w:rn(w)?m&&ef(a)?w:w.value:wt(w)?t?nd(w):af(w):w}}const Nm=Xh(),vm=Xh(!0);function Xh(t=!1){return function(n,i,a,l){let m=n[i];if(yo(m)&&rn(m)&&!rn(a))return!1;if(!t&&(!Mu(a)&&!yo(a)&&(m=Ue(m),a=Ue(a)),!Ie(n)&&rn(m)&&!rn(a)))return m.value=a,!0;const w=Ie(n)&&ef(i)?Number(i)t,Mc=t=>Reflect.getPrototypeOf(t);function yu(t,e,n=!1,i=!1){t=t.__v_raw;const a=Ue(t),l=Ue(e);n||(e!==l&&xn(a,"get",e),xn(a,"get",l));const{has:m}=Mc(a),w=i?sf:n?cf:fa;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 wu(t,e=!1){const n=this.__v_raw,i=Ue(n),a=Ue(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 gu(t,e=!1){return t=t.__v_raw,!e&&xn(Ue(t),"iterate",us),Reflect.get(t,"size",t)}function Pf(t){t=Ue(t);const e=Ue(this);return Mc(e).has.call(e,t)||(e.add(t),Br(e,"add",t,t)),this}function Mf(t,e){e=Ue(e);const n=Ue(this),{has:i,get:a}=Mc(n);let l=i.call(n,t);l||(t=Ue(t),l=i.call(n,t));const m=a.call(n,t);return n.set(t,e),l?la(e,m)&&Br(n,"set",t,e):Br(n,"add",t,e),this}function Bf(t){const e=Ue(this),{has:n,get:i}=Mc(e);let a=n.call(e,t);a||(t=Ue(t),a=n.call(e,t)),i&&i.call(e,t);const l=e.delete(t);return a&&Br(e,"delete",t,void 0),l}function Ff(){const t=Ue(this),e=t.size!==0,n=t.clear();return e&&Br(t,"clear",void 0,void 0),n}function bu(t,e){return function(i,a){const l=this,m=l.__v_raw,w=Ue(m),v=e?sf:t?cf:fa;return!t&&xn(w,"iterate",us),m.forEach((d,I)=>i.call(a,v(d),v(I),l))}}function Nu(t,e,n){return function(...i){const a=this.__v_raw,l=Ue(a),m=Us(l),w=t==="entries"||t===Symbol.iterator&&m,v=t==="keys"&&m,d=a[t](...i),I=n?sf:e?cf:fa;return!e&&xn(l,"iterate",v?_l:us),{next(){const{value:M,done:B}=d.next();return B?{value:M,done:B}:{value:w?[I(M[0]),I(M[1])]:I(M),done:B}},[Symbol.iterator](){return this}}}}function Xr(t){return function(...e){return t==="delete"?!1:this}}function Om(){const t={get(l){return yu(this,l)},get size(){return gu(this)},has:wu,add:Pf,set:Mf,delete:Bf,clear:Ff,forEach:bu(!1,!1)},e={get(l){return yu(this,l,!1,!0)},get size(){return gu(this)},has:wu,add:Pf,set:Mf,delete:Bf,clear:Ff,forEach:bu(!1,!0)},n={get(l){return yu(this,l,!0)},get size(){return gu(this,!0)},has(l){return wu.call(this,l,!0)},add:Xr("add"),set:Xr("set"),delete:Xr("delete"),clear:Xr("clear"),forEach:bu(!0,!1)},i={get(l){return yu(this,l,!0,!0)},get size(){return gu(this,!0)},has(l){return wu.call(this,l,!0)},add:Xr("add"),set:Xr("set"),delete:Xr("delete"),clear:Xr("clear"),forEach:bu(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(l=>{t[l]=Nu(l,!1,!1),n[l]=Nu(l,!0,!1),e[l]=Nu(l,!1,!0),i[l]=Nu(l,!0,!0)}),[t,n,e,i]}const[Wm,Im,Am,Tm]=Om();function of(t,e){const n=e?t?Tm:Am:t?Im:Wm;return(i,a,l)=>a==="__v_isReactive"?!t:a==="__v_isReadonly"?t:a==="__v_raw"?i:Reflect.get(Fe(n,a)&&a in i?n:i,a,l)}const km={get:of(!1,!1)},Sm={get:of(!1,!0)},Rm={get:of(!0,!1)},Zh=new WeakMap,ed=new WeakMap,td=new WeakMap,Dm=new WeakMap;function Lm(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function Pm(t){return t.__v_skip||!Object.isExtensible(t)?0:Lm(im(t))}function af(t){return yo(t)?t:uf(t,!1,Yh,km,Zh)}function Mm(t){return uf(t,!1,qm,Sm,ed)}function nd(t){return uf(t,!0,Cm,Rm,td)}function uf(t,e,n,i,a){if(!wt(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const l=a.get(t);if(l)return l;const m=Pm(t);if(m===0)return t;const w=new Proxy(t,m===2?i:n);return a.set(t,w),w}function $s(t){return yo(t)?$s(t.__v_raw):!!(t&&t.__v_isReactive)}function yo(t){return!!(t&&t.__v_isReadonly)}function Mu(t){return!!(t&&t.__v_isShallow)}function rd(t){return $s(t)||yo(t)}function Ue(t){const e=t&&t.__v_raw;return e?Ue(e):t}function id(t){return Pu(t,"__v_skip",!0),t}const fa=t=>wt(t)?af(t):t,cf=t=>wt(t)?nd(t):t;function sd(t){fi&&ar&&(t=Ue(t),Jh(t.dep||(t.dep=tf())))}function od(t,e){t=Ue(t);const n=t.dep;n&&xl(n)}function rn(t){return!!(t&&t.__v_isRef===!0)}function Bm(t){return Fm(t,!1)}function Fm(t,e){return rn(t)?t:new Um(t,e)}class Um{constructor(e,n){this.__v_isShallow=n,this.dep=void 0,this.__v_isRef=!0,this._rawValue=n?e:Ue(e),this._value=n?e:fa(e)}get value(){return sd(this),this._value}set value(e){const n=this.__v_isShallow||Mu(e)||yo(e);e=n?e:Ue(e),la(e,this._rawValue)&&(this._rawValue=e,this._value=n?e:fa(e),od(this))}}function ad(t){return rn(t)?t.value:t}const $m={get:(t,e,n)=>ad(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 ud(t){return $s(t)?t:new Proxy(t,$m)}var cd;class Qm{constructor(e,n,i,a){this._setter=n,this.dep=void 0,this.__v_isRef=!0,this[cd]=!1,this._dirty=!0,this.effect=new nf(e,()=>{this._dirty||(this._dirty=!0,od(this))}),this.effect.computed=this,this.effect.active=this._cacheable=!a,this.__v_isReadonly=i}get value(){const e=Ue(this);return sd(e),(e._dirty||!e._cacheable)&&(e._dirty=!1,e._value=e.effect.run()),e._value}set value(e){this._setter(e)}}cd="__v_isReadonly";function jm(t,e,n=!1){let i,a;const l=Se(t);return l?(i=t,a=fr):(i=t.get,a=t.set),new Qm(i,a,l||!a,n)}function hi(t,e,n,i){let a;try{a=i?t(...i):t()}catch(l){Bc(l,e,n)}return a}function Qn(t,e,n,i){if(Se(t)){const l=hi(t,e,n,i);return l&&$h(l)&&l.catch(m=>{Bc(m,e,n)}),l}const a=[];for(let l=0;l>>1;da(nn[i])Er&&nn.splice(e,1)}function Jm(t){Ie(t)?Qs.push(...t):(!Tr||!Tr.includes(t,t.allowRecurse?Ui+1:Ui))&&Qs.push(t),fd()}function Uf(t,e=ha?Er+1:0){for(;eda(n)-da(i)),Ui=0;Uit.id==null?1/0:t.id,Gm=(t,e)=>{const n=da(t)-da(e);if(n===0){if(t.pre&&!e.pre)return-1;if(e.pre&&!t.pre)return 1}return n};function dd(t){El=!1,ha=!0,nn.sort(Gm);const e=fr;try{for(Er=0;ErPt(Y)?Y.trim():Y)),M&&(a=n.map(am))}let w,v=i[w=ul(e)]||i[w=ul(mo(e))];!v&&l&&(v=i[w=ul(Eo(e))]),v&&Qn(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,Qn(d,t,6,a)}}function pd(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 I=pd(d,e,!0);I&&(w=!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&&!w?(wt(t)&&i.set(t,null),null):(Ie(l)?l.forEach(v=>m[v]=null):on(m,l),wt(t)&&i.set(t,m),m)}function Fc(t,e){return!t||!Dc(e)?!1:(e=e.slice(2).replace(/Once$/,""),Fe(t,e[0].toLowerCase()+e.slice(1))||Fe(t,Eo(e))||Fe(t,e))}let ur=null,md=null;function Bu(t){const e=ur;return ur=t,md=t&&t.type.__scopeId||null,e}function Ym(t,e=ur,n){if(!e||t._n)return t;const i=(...a)=>{i._d&&Gf(-1);const l=Bu(e);let m;try{m=t(...a)}finally{Bu(l),i._d&&Gf(1)}return m};return i._n=!0,i._c=!0,i._d=!0,i}function ll(t){const{type:e,vnode:n,proxy:i,withProxy:a,props:l,propsOptions:[m],slots:w,attrs:v,emit:d,render:I,renderCache:M,data:B,setupState:Y,ctx:Z,inheritAttrs:b}=t;let C,N;const O=Bu(t);try{if(n.shapeFlag&4){const ne=a||i;C=_r(I.call(ne,ne,M,l,Y,B,Z)),N=v}else{const ne=e;C=_r(ne.length>1?ne(l,{attrs:v,slots:w,emit:d}):ne(l,null)),N=e.props?v:Zm(v)}}catch(ne){na.length=0,Bc(ne,t,1),C=cs(Dr)}let T=C;if(N&&b!==!1){const ne=Object.keys(N),{shapeFlag:Ne}=T;ne.length&&Ne&7&&(m&&ne.some(Xl)&&(N=ey(N,m)),T=mi(T,N))}return n.dirs&&(T=mi(T),T.dirs=T.dirs?T.dirs.concat(n.dirs):n.dirs),n.transition&&(T.transition=n.transition),C=T,Bu(O),C}const Zm=t=>{let e;for(const n in t)(n==="class"||n==="style"||Dc(n))&&((e||(e={}))[n]=t[n]);return e},ey=(t,e)=>{const n={};for(const i in t)(!Xl(i)||!(i.slice(9)in e))&&(n[i]=t[i]);return n};function ty(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?$f(i,m,d):!!m;if(v&8){const I=e.dynamicProps;for(let M=0;Mt.__isSuspense;function iy(t,e){e&&e.pendingBranch?Ie(t)?e.effects.push(...t):e.effects.push(t):Jm(t)}function sy(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 Ou(t,e,n=!1){const i=Ot||ur;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 vu={};function fl(t,e,n){return yd(t,e,n)}function yd(t,e,{immediate:n,deep:i,flush:a,onTrack:l,onTrigger:m}=ft){const w=fm()===(Ot==null?void 0:Ot.scope)?Ot:null;let v,d=!1,I=!1;if(rn(t)?(v=()=>t.value,d=Mu(t)):$s(t)?(v=()=>t,i=!0):Ie(t)?(I=!0,d=t.some(T=>$s(T)||Mu(T)),v=()=>t.map(T=>{if(rn(T))return T.value;if($s(T))return Ds(T);if(Se(T))return hi(T,w,2)})):Se(t)?e?v=()=>hi(t,w,2):v=()=>{if(!(w&&w.isUnmounted))return M&&M(),Qn(t,w,3,[B])}:v=fr,e&&i){const T=v;v=()=>Ds(T())}let M,B=T=>{M=N.onStop=()=>{hi(T,w,4)}},Y;if(ya)if(B=fr,e?n&&Qn(e,w,3,[v(),I?[]:void 0,B]):v(),a==="sync"){const T=iw();Y=T.__watcherHandles||(T.__watcherHandles=[])}else return fr;let Z=I?new Array(t.length).fill(vu):vu;const b=()=>{if(N.active)if(e){const T=N.run();(i||d||(I?T.some((ne,Ne)=>la(ne,Z[Ne])):la(T,Z)))&&(M&&M(),Qn(e,w,3,[T,Z===vu?void 0:I&&Z[0]===vu?[]:Z,B]),Z=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=()=>ff(b));const N=new nf(v,C);e?n?b():Z=N.run():a==="post"?bn(N.run.bind(N),w&&w.suspense):N.run();const O=()=>{N.stop(),w&&w.scope&&Yl(w.scope.effects,N)};return Y&&Y.push(O),O}function oy(t,e,n){const i=this.proxy,a=Pt(t)?t.includes(".")?wd(i,t):()=>i[t]:t.bind(i,i);let l;Se(e)?l=e:(l=e.handler,n=e);const m=Ot;wo(this);const w=yd(a,l.bind(i),n);return m?wo(m):ls(),w}function wd(t,e){const n=e.split(".");return()=>{let i=t;for(let a=0;a{Ds(n,e)});else if(jh(t))for(const n in t)Ds(t[n],e);return t}function ay(){const t={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return vd(()=>{t.isMounted=!0}),_d(()=>{t.isUnmounting=!0}),t}const Mn=[Function,Array],uy={name:"BaseTransition",props:{mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:Mn,onEnter:Mn,onAfterEnter:Mn,onEnterCancelled:Mn,onBeforeLeave:Mn,onLeave:Mn,onAfterLeave:Mn,onLeaveCancelled:Mn,onBeforeAppear:Mn,onAppear:Mn,onAfterAppear:Mn,onAppearCancelled:Mn},setup(t,{slots:e}){const n=Gy(),i=ay();let a;return()=>{const l=e.default&&bd(e.default(),!0);if(!l||!l.length)return;let m=l[0];if(l.length>1){for(const b of l)if(b.type!==Dr){m=b;break}}const w=Ue(t),{mode:v}=w;if(i.isLeaving)return hl(m);const d=Qf(m);if(!d)return hl(m);const I=Cl(d,w,i,n);ql(d,I);const M=n.subTree,B=M&&Qf(M);let Y=!1;const{getTransitionKey:Z}=d.type;if(Z){const b=Z();a===void 0?a=b:b!==a&&(a=b,Y=!0)}if(B&&B.type!==Dr&&(!$i(d,B)||Y)){const b=Cl(B,w,i,n);if(ql(B,b),v==="out-in")return i.isLeaving=!0,b.afterLeave=()=>{i.isLeaving=!1,n.update.active!==!1&&n.update()},hl(m);v==="in-out"&&d.type!==Dr&&(b.delayLeave=(C,N,O)=>{const T=gd(i,B);T[String(B.key)]=B,C._leaveCb=()=>{N(),C._leaveCb=void 0,delete I.delayedLeave},I.delayedLeave=O})}return m}}},cy=uy;function gd(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 Cl(t,e,n,i){const{appear:a,mode:l,persisted:m=!1,onBeforeEnter:w,onEnter:v,onAfterEnter:d,onEnterCancelled:I,onBeforeLeave:M,onLeave:B,onAfterLeave:Y,onLeaveCancelled:Z,onBeforeAppear:b,onAppear:C,onAfterAppear:N,onAppearCancelled:O}=e,T=String(t.key),ne=gd(n,t),Ne=(xe,nt)=>{xe&&Qn(xe,i,9,nt)},ae=(xe,nt)=>{const Ke=nt[1];Ne(xe,nt),Ie(xe)?xe.every(Wt=>Wt.length<=1)&&Ke():xe.length<=1&&Ke()},_e={mode:l,persisted:m,beforeEnter(xe){let nt=w;if(!n.isMounted)if(a)nt=b||w;else return;xe._leaveCb&&xe._leaveCb(!0);const Ke=ne[T];Ke&&$i(t,Ke)&&Ke.el._leaveCb&&Ke.el._leaveCb(),Ne(nt,[xe])},enter(xe){let nt=v,Ke=d,Wt=I;if(!n.isMounted)if(a)nt=C||v,Ke=N||d,Wt=O||I;else return;let It=!1;const je=xe._enterCb=Jt=>{It||(It=!0,Jt?Ne(Wt,[xe]):Ne(Ke,[xe]),_e.delayedLeave&&_e.delayedLeave(),xe._enterCb=void 0)};nt?ae(nt,[xe,je]):je()},leave(xe,nt){const Ke=String(t.key);if(xe._enterCb&&xe._enterCb(!0),n.isUnmounting)return nt();Ne(M,[xe]);let Wt=!1;const It=xe._leaveCb=je=>{Wt||(Wt=!0,nt(),je?Ne(Z,[xe]):Ne(Y,[xe]),xe._leaveCb=void 0,ne[Ke]===t&&delete ne[Ke])};ne[Ke]=t,B?ae(B,[xe,It]):It()},clone(xe){return Cl(xe,e,n,i)}};return _e}function hl(t){if(Uc(t))return t=mi(t),t.children=null,t}function Qf(t){return Uc(t)?t.children?t.children[0]:void 0:t}function ql(t,e){t.shapeFlag&6&&t.component?ql(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 bd(t,e=!1,n){let i=[],a=0;for(let l=0;l1)for(let l=0;l!!t.type.__asyncLoader,Uc=t=>t.type.__isKeepAlive;function fy(t,e){Nd(t,"a",e)}function hy(t,e){Nd(t,"da",e)}function Nd(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($c(e,i,n),n){let a=n.parent;for(;a&&a.parent;)Uc(a.parent.vnode)&&dy(i,e,n,a),a=a.parent}}function dy(t,e,n,i){const a=$c(e,t,i,!0);xd(()=>{Yl(i[e],a)},n)}function $c(t,e,n=Ot,i=!1){if(n){const a=n[t]||(n[t]=[]),l=e.__weh||(e.__weh=(...m)=>{if(n.isUnmounted)return;Co(),wo(n);const w=Qn(e,n,t,m);return ls(),qo(),w});return i?a.unshift(l):a.push(l),l}}const Ur=t=>(e,n=Ot)=>(!ya||t==="sp")&&$c(t,(...i)=>e(...i),n),py=Ur("bm"),vd=Ur("m"),my=Ur("bu"),yy=Ur("u"),_d=Ur("bum"),xd=Ur("um"),wy=Ur("sp"),gy=Ur("rtg"),by=Ur("rtc");function Ny(t,e=Ot){$c("ec",t,e)}function Pi(t,e,n,i){const a=t.dirs,l=e&&e.dirs;for(let m=0;mt?Sd(t)?mf(t)||t.proxy:Ol(t.parent):null,ta=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=>Ol(t.parent),$root:t=>Ol(t.root),$emit:t=>t.emit,$options:t=>hf(t),$forceUpdate:t=>t.f||(t.f=()=>ff(t.update)),$nextTick:t=>t.n||(t.n=Vm.bind(t.proxy)),$watch:t=>oy.bind(t)}),dl=(t,e)=>t!==ft&&!t.__isScriptSetup&&Fe(t,e),_y={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 Y=m[e];if(Y!==void 0)switch(Y){case 1:return i[e];case 2:return a[e];case 4:return n[e];case 3:return l[e]}else{if(dl(i,e))return m[e]=1,i[e];if(a!==ft&&Fe(a,e))return m[e]=2,a[e];if((d=t.propsOptions[0])&&Fe(d,e))return m[e]=3,l[e];if(n!==ft&&Fe(n,e))return m[e]=4,n[e];Wl&&(m[e]=0)}}const I=ta[e];let M,B;if(I)return e==="$attrs"&&xn(t,"get",e),I(t);if((M=w.__cssModules)&&(M=M[e]))return M;if(n!==ft&&Fe(n,e))return m[e]=4,n[e];if(B=v.config.globalProperties,Fe(B,e))return B[e]},set({_:t},e,n){const{data:i,setupState:a,ctx:l}=t;return dl(a,e)?(a[e]=n,!0):i!==ft&&Fe(i,e)?(i[e]=n,!0):Fe(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!==ft&&Fe(t,m)||dl(e,m)||(w=l[0])&&Fe(w,m)||Fe(i,m)||Fe(ta,m)||Fe(a.config.globalProperties,m)},defineProperty(t,e,n){return n.get!=null?t._.accessCache[e]=0:Fe(n,"value")&&this.set(t,e,n.value,null),Reflect.defineProperty(t,e,n)}};let Wl=!0;function xy(t){const e=hf(t),n=t.proxy,i=t.ctx;Wl=!1,e.beforeCreate&&jf(e.beforeCreate,t,"bc");const{data:a,computed:l,methods:m,watch:w,provide:v,inject:d,created:I,beforeMount:M,mounted:B,beforeUpdate:Y,updated:Z,activated:b,deactivated:C,beforeDestroy:N,beforeUnmount:O,destroyed:T,unmounted:ne,render:Ne,renderTracked:ae,renderTriggered:_e,errorCaptured:xe,serverPrefetch:nt,expose:Ke,inheritAttrs:Wt,components:It,directives:je,filters:Jt}=e;if(d&&Ey(d,i,null,t.appContext.config.unwrapInjectedRef),m)for(const ge in m){const qe=m[ge];Se(qe)&&(i[ge]=qe.bind(n))}if(a){const ge=a.call(n,n);wt(ge)&&(t.data=af(ge))}if(Wl=!0,l)for(const ge in l){const qe=l[ge],ct=Se(qe)?qe.bind(n,n):Se(qe.get)?qe.get.bind(n,n):fr,we=!Se(qe)&&Se(qe.set)?qe.set.bind(n):fr,De=nw({get:ct,set:we});Object.defineProperty(i,ge,{enumerable:!0,configurable:!0,get:()=>De.value,set:Mt=>De.value=Mt})}if(w)for(const ge in w)Ed(w[ge],i,n,ge);if(v){const ge=Se(v)?v.call(n):v;Reflect.ownKeys(ge).forEach(qe=>{sy(qe,ge[qe])})}I&&jf(I,t,"c");function gt(ge,qe){Ie(qe)?qe.forEach(ct=>ge(ct.bind(n))):qe&&ge(qe.bind(n))}if(gt(py,M),gt(vd,B),gt(my,Y),gt(yy,Z),gt(fy,b),gt(hy,C),gt(Ny,xe),gt(by,ae),gt(gy,_e),gt(_d,O),gt(xd,ne),gt(wy,nt),Ie(Ke))if(Ke.length){const ge=t.exposed||(t.exposed={});Ke.forEach(qe=>{Object.defineProperty(ge,qe,{get:()=>n[qe],set:ct=>n[qe]=ct})})}else t.exposed||(t.exposed={});Ne&&t.render===fr&&(t.render=Ne),Wt!=null&&(t.inheritAttrs=Wt),It&&(t.components=It),je&&(t.directives=je)}function Ey(t,e,n=fr,i=!1){Ie(t)&&(t=Il(t));for(const a in t){const l=t[a];let m;wt(l)?"default"in l?m=Ou(l.from||a,l.default,!0):m=Ou(l.from||a):m=Ou(l),rn(m)&&i?Object.defineProperty(e,a,{enumerable:!0,configurable:!0,get:()=>m.value,set:w=>m.value=w}):e[a]=m}}function jf(t,e,n){Qn(Ie(t)?t.map(i=>i.bind(e.proxy)):t.bind(e.proxy),e,n)}function Ed(t,e,n,i){const a=i.includes(".")?wd(n,i):()=>n[i];if(Pt(t)){const l=e[t];Se(l)&&fl(a,l)}else if(Se(t))fl(a,t.bind(n));else if(wt(t))if(Ie(t))t.forEach(l=>Ed(l,e,n,i));else{const l=Se(t.handler)?t.handler.bind(n):e[t.handler];Se(l)&&fl(a,l,t)}}function hf(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=>Fu(v,d,m,!0)),Fu(v,e,m)),wt(e)&&l.set(e,v),v}function Fu(t,e,n,i=!1){const{mixins:a,extends:l}=e;l&&Fu(t,l,n,!0),a&&a.forEach(m=>Fu(t,m,n,!0));for(const m in e)if(!(i&&m==="expose")){const w=Cy[m]||n&&n[m];t[m]=w?w(t[m],e[m]):e[m]}return t}const Cy={data:Hf,props:Fi,emits:Fi,methods:Fi,computed:Fi,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:Fi,directives:Fi,watch:Oy,provide:Hf,inject:qy};function Hf(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 qy(t,e){return Fi(Il(t),Il(e))}function Il(t){if(Ie(t)){const e={};for(let n=0;n0)&&!(m&16)){if(m&8){const I=t.vnode.dynamicProps;for(let M=0;M{v=!0;const[B,Y]=qd(M,e,!0);on(m,B),Y&&w.push(...Y)};!n&&e.mixins.length&&e.mixins.forEach(I),t.extends&&I(t.extends),t.mixins&&t.mixins.forEach(I)}if(!l&&!v)return wt(t)&&i.set(t,Fs),Fs;if(Ie(l))for(let I=0;I-1,Y[1]=b<0||Z-1||Fe(Y,"default"))&&w.push(M)}}}const d=[m,w];return wt(t)&&i.set(t,d),d}function Vf(t){return t[0]!=="$"}function zf(t){const e=t&&t.toString().match(/^\s*(function|class) (\w+)/);return e?e[2]:t===null?"null":""}function Kf(t,e){return zf(t)===zf(e)}function Jf(t,e){return Ie(e)?e.findIndex(n=>Kf(n,t)):Se(e)&&Kf(e,t)?0:-1}const Od=t=>t[0]==="_"||t==="$stable",df=t=>Ie(t)?t.map(_r):[_r(t)],Ay=(t,e,n)=>{if(e._n)return e;const i=Ym((...a)=>df(e(...a)),n);return i._c=!1,i},Wd=(t,e,n)=>{const i=t._ctx;for(const a in t){if(Od(a))continue;const l=t[a];if(Se(l))e[a]=Ay(a,l,i);else if(l!=null){const m=df(l);e[a]=()=>m}}},Id=(t,e)=>{const n=df(e);t.slots.default=()=>n},Ty=(t,e)=>{if(t.vnode.shapeFlag&32){const n=e._;n?(t.slots=Ue(e),Pu(e,"_",n)):Wd(e,t.slots={})}else t.slots={},e&&Id(t,e);Pu(t.slots,jc,1)},ky=(t,e,n)=>{const{vnode:i,slots:a}=t;let l=!0,m=ft;if(i.shapeFlag&32){const w=e._;w?n&&w===1?l=!1:(on(a,e),!n&&w===1&&delete a._):(l=!e.$stable,Wd(e,a)),m=e}else e&&(Id(t,e),m={default:1});if(l)for(const w in a)!Od(w)&&!(w in m)&&delete a[w]};function Ad(){return{app:null,config:{isNativeTag:tm,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 Sy=0;function Ry(t,e){return function(i,a=null){Se(i)||(i=Object.assign({},i)),a!=null&&!wt(a)&&(a=null);const l=Ad(),m=new Set;let w=!1;const v=l.app={_uid:Sy++,_component:i,_props:a,_container:null,_context:l,_instance:null,version:sw,get config(){return l.config},set config(d){},use(d,...I){return m.has(d)||(d&&Se(d.install)?(m.add(d),d.install(v,...I)):Se(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,M){if(!w){const B=cs(i,a);return B.appContext=l,I&&e?e(B,d):t(B,d,M),w=!0,v._container=d,d.__vue_app__=v,mf(B.component)||B.component.proxy}},unmount(){w&&(t(null,v._container),delete v._container.__vue_app__)},provide(d,I){return l.provides[d]=I,v}};return v}}function Tl(t,e,n,i,a=!1){if(Ie(t)){t.forEach((B,Y)=>Tl(B,e&&(Ie(e)?e[Y]:e),n,i,a));return}if(Wu(i)&&!a)return;const l=i.shapeFlag&4?mf(i.component)||i.component.proxy:i.el,m=a?null:l,{i:w,r:v}=t,d=e&&e.r,I=w.refs===ft?w.refs={}:w.refs,M=w.setupState;if(d!=null&&d!==v&&(Pt(d)?(I[d]=null,Fe(M,d)&&(M[d]=null)):rn(d)&&(d.value=null)),Se(v))hi(v,w,12,[m,I]);else{const B=Pt(v),Y=rn(v);if(B||Y){const Z=()=>{if(t.f){const b=B?Fe(M,v)?M[v]:I[v]:v.value;a?Ie(b)&&Yl(b,l):Ie(b)?b.includes(l)||b.push(l):B?(I[v]=[l],Fe(M,v)&&(M[v]=I[v])):(v.value=[l],t.k&&(I[t.k]=v.value))}else B?(I[v]=m,Fe(M,v)&&(M[v]=m)):Y&&(v.value=m,t.k&&(I[t.k]=m))};m?(Z.id=-1,bn(Z,n)):Z()}}}const bn=iy;function Dy(t){return Ly(t)}function Ly(t,e){const n=um();n.__VUE__=!0;const{insert:i,remove:a,patchProp:l,createElement:m,createText:w,createComment:v,setText:d,setElementText:I,parentNode:M,nextSibling:B,setScopeId:Y=fr,insertStaticContent:Z}=t,b=(x,q,S,L=null,z=null,ee=null,Q=!1,V=null,re=!!q.dynamicChildren)=>{if(x===q)return;x&&!$i(x,q)&&(L=fe(x),Mt(x,z,ee,!0),x=null),q.patchFlag===-2&&(re=!1,q.dynamicChildren=null);const{type:K,ref:ce,shapeFlag:oe}=q;switch(K){case Qc:C(x,q,S,L);break;case Dr:N(x,q,S,L);break;case pl:x==null&&O(q,S,L,Q);break;case or:It(x,q,S,L,z,ee,Q,V,re);break;default:oe&1?Ne(x,q,S,L,z,ee,Q,V,re):oe&6?je(x,q,S,L,z,ee,Q,V,re):(oe&64||oe&128)&&K.process(x,q,S,L,z,ee,Q,V,re,Hn)}ce!=null&&z&&Tl(ce,x&&x.ref,ee,q||x,!q)},C=(x,q,S,L)=>{if(x==null)i(q.el=w(q.children),S,L);else{const z=q.el=x.el;q.children!==x.children&&d(z,q.children)}},N=(x,q,S,L)=>{x==null?i(q.el=v(q.children||""),S,L):q.el=x.el},O=(x,q,S,L)=>{[x.el,x.anchor]=Z(x.children,q,S,L,x.el,x.anchor)},T=({el:x,anchor:q},S,L)=>{let z;for(;x&&x!==q;)z=B(x),i(x,S,L),x=z;i(q,S,L)},ne=({el:x,anchor:q})=>{let S;for(;x&&x!==q;)S=B(x),a(x),x=S;a(q)},Ne=(x,q,S,L,z,ee,Q,V,re)=>{Q=Q||q.type==="svg",x==null?ae(q,S,L,z,ee,Q,V,re):nt(x,q,z,ee,Q,V,re)},ae=(x,q,S,L,z,ee,Q,V)=>{let re,K;const{type:ce,props:oe,shapeFlag:ue,transition:be,dirs:Ee}=x;if(re=x.el=m(x.type,ee,oe&&oe.is,oe),ue&8?I(re,x.children):ue&16&&xe(x.children,re,null,L,z,ee&&ce!=="foreignObject",Q,V),Ee&&Pi(x,null,L,"created"),_e(re,x,x.scopeId,Q,L),oe){for(const Pe in oe)Pe!=="value"&&!qu(Pe)&&l(re,Pe,null,oe[Pe],ee,x.children,L,z,pn);"value"in oe&&l(re,"value",null,oe.value),(K=oe.onVnodeBeforeMount)&&yr(K,L,x)}Ee&&Pi(x,null,L,"beforeMount");const He=(!z||z&&!z.pendingBranch)&&be&&!be.persisted;He&&be.beforeEnter(re),i(re,q,S),((K=oe&&oe.onVnodeMounted)||He||Ee)&&bn(()=>{K&&yr(K,L,x),He&&be.enter(re),Ee&&Pi(x,null,L,"mounted")},z)},_e=(x,q,S,L,z)=>{if(S&&Y(x,S),L)for(let ee=0;ee{for(let K=re;K{const V=q.el=x.el;let{patchFlag:re,dynamicChildren:K,dirs:ce}=q;re|=x.patchFlag&16;const oe=x.props||ft,ue=q.props||ft;let be;S&&Mi(S,!1),(be=ue.onVnodeBeforeUpdate)&&yr(be,S,q,x),ce&&Pi(q,x,S,"beforeUpdate"),S&&Mi(S,!0);const Ee=z&&q.type!=="foreignObject";if(K?Ke(x.dynamicChildren,K,V,S,L,Ee,ee):Q||qe(x,q,V,null,S,L,Ee,ee,!1),re>0){if(re&16)Wt(V,q,oe,ue,S,L,z);else if(re&2&&oe.class!==ue.class&&l(V,"class",null,ue.class,z),re&4&&l(V,"style",oe.style,ue.style,z),re&8){const He=q.dynamicProps;for(let Pe=0;Pe{be&&yr(be,S,q,x),ce&&Pi(q,x,S,"updated")},L)},Ke=(x,q,S,L,z,ee,Q)=>{for(let V=0;V{if(S!==L){if(S!==ft)for(const V in S)!qu(V)&&!(V in L)&&l(x,V,S[V],null,Q,q.children,z,ee,pn);for(const V in L){if(qu(V))continue;const re=L[V],K=S[V];re!==K&&V!=="value"&&l(x,V,K,re,Q,q.children,z,ee,pn)}"value"in L&&l(x,"value",S.value,L.value)}},It=(x,q,S,L,z,ee,Q,V,re)=>{const K=q.el=x?x.el:w(""),ce=q.anchor=x?x.anchor:w("");let{patchFlag:oe,dynamicChildren:ue,slotScopeIds:be}=q;be&&(V=V?V.concat(be):be),x==null?(i(K,S,L),i(ce,S,L),xe(q.children,S,ce,z,ee,Q,V,re)):oe>0&&oe&64&&ue&&x.dynamicChildren?(Ke(x.dynamicChildren,ue,S,z,ee,Q,V),(q.key!=null||z&&q===z.subTree)&&Td(x,q,!0)):qe(x,q,S,ce,z,ee,Q,V,re)},je=(x,q,S,L,z,ee,Q,V,re)=>{q.slotScopeIds=V,x==null?q.shapeFlag&512?z.ctx.activate(q,S,L,Q,re):Jt(q,S,L,z,ee,Q,re):dn(x,q,re)},Jt=(x,q,S,L,z,ee,Q)=>{const V=x.component=Jy(x,L,z);if(Uc(x)&&(V.ctx.renderer=Hn),Xy(V),V.asyncDep){if(z&&z.registerDep(V,gt),!x.el){const re=V.subTree=cs(Dr);N(null,re,q,S)}return}gt(V,x,q,S,z,ee,Q)},dn=(x,q,S)=>{const L=q.component=x.component;if(ty(x,q,S))if(L.asyncDep&&!L.asyncResolved){ge(L,q,S);return}else L.next=q,Km(L.update),L.update();else q.el=x.el,L.vnode=q},gt=(x,q,S,L,z,ee,Q)=>{const V=()=>{if(x.isMounted){let{next:ce,bu:oe,u:ue,parent:be,vnode:Ee}=x,He=ce,Pe;Mi(x,!1),ce?(ce.el=Ee.el,ge(x,ce,Q)):ce=Ee,oe&&cl(oe),(Pe=ce.props&&ce.props.onVnodeBeforeUpdate)&&yr(Pe,be,ce,Ee),Mi(x,!0);const st=ll(x),me=x.subTree;x.subTree=st,b(me,st,M(me.el),fe(me),x,z,ee),ce.el=st.el,He===null&&ny(x,st.el),ue&&bn(ue,z),(Pe=ce.props&&ce.props.onVnodeUpdated)&&bn(()=>yr(Pe,be,ce,Ee),z)}else{let ce;const{el:oe,props:ue}=q,{bm:be,m:Ee,parent:He}=x,Pe=Wu(q);if(Mi(x,!1),be&&cl(be),!Pe&&(ce=ue&&ue.onVnodeBeforeMount)&&yr(ce,He,q),Mi(x,!0),oe&&Je){const st=()=>{x.subTree=ll(x),Je(oe,x.subTree,x,z,null)};Pe?q.type.__asyncLoader().then(()=>!x.isUnmounted&&st()):st()}else{const st=x.subTree=ll(x);b(null,st,S,L,x,z,ee),q.el=st.el}if(Ee&&bn(Ee,z),!Pe&&(ce=ue&&ue.onVnodeMounted)){const st=q;bn(()=>yr(ce,He,st),z)}(q.shapeFlag&256||He&&Wu(He.vnode)&&He.vnode.shapeFlag&256)&&x.a&&bn(x.a,z),x.isMounted=!0,q=S=L=null}},re=x.effect=new nf(V,()=>ff(K),x.scope),K=x.update=()=>re.run();K.id=x.uid,Mi(x,!0),K()},ge=(x,q,S)=>{q.component=x;const L=x.vnode.props;x.vnode=q,x.next=null,Iy(x,q.props,L,S),ky(x,q.children,S),Co(),Uf(),qo()},qe=(x,q,S,L,z,ee,Q,V,re=!1)=>{const K=x&&x.children,ce=x?x.shapeFlag:0,oe=q.children,{patchFlag:ue,shapeFlag:be}=q;if(ue>0){if(ue&128){we(K,oe,S,L,z,ee,Q,V,re);return}else if(ue&256){ct(K,oe,S,L,z,ee,Q,V,re);return}}be&8?(ce&16&&pn(K,z,ee),oe!==K&&I(S,oe)):ce&16?be&16?we(K,oe,S,L,z,ee,Q,V,re):pn(K,z,ee,!0):(ce&8&&I(S,""),be&16&&xe(oe,S,L,z,ee,Q,V,re))},ct=(x,q,S,L,z,ee,Q,V,re)=>{x=x||Fs,q=q||Fs;const K=x.length,ce=q.length,oe=Math.min(K,ce);let ue;for(ue=0;uece?pn(x,z,ee,!0,!1,oe):xe(q,S,L,z,ee,Q,V,re,oe)},we=(x,q,S,L,z,ee,Q,V,re)=>{let K=0;const ce=q.length;let oe=x.length-1,ue=ce-1;for(;K<=oe&&K<=ue;){const be=x[K],Ee=q[K]=re?ei(q[K]):_r(q[K]);if($i(be,Ee))b(be,Ee,S,null,z,ee,Q,V,re);else break;K++}for(;K<=oe&&K<=ue;){const be=x[oe],Ee=q[ue]=re?ei(q[ue]):_r(q[ue]);if($i(be,Ee))b(be,Ee,S,null,z,ee,Q,V,re);else break;oe--,ue--}if(K>oe){if(K<=ue){const be=ue+1,Ee=beue)for(;K<=oe;)Mt(x[K],z,ee,!0),K++;else{const be=K,Ee=K,He=new Map;for(K=Ee;K<=ue;K++){const le=q[K]=re?ei(q[K]):_r(q[K]);le.key!=null&&He.set(le.key,K)}let Pe,st=0;const me=ue-Ee+1;let Cn=!1,gi=0;const Xt=new Array(me);for(K=0;K=me){Mt(le,z,ee,!0);continue}let Bt;if(le.key!=null)Bt=He.get(le.key);else for(Pe=Ee;Pe<=ue;Pe++)if(Xt[Pe-Ee]===0&&$i(le,q[Pe])){Bt=Pe;break}Bt===void 0?Mt(le,z,ee,!0):(Xt[Bt-Ee]=K+1,Bt>=gi?gi=Bt:Cn=!0,b(le,q[Bt],S,null,z,ee,Q,V,re),st++)}const ds=Cn?Py(Xt):Fs;for(Pe=ds.length-1,K=me-1;K>=0;K--){const le=Ee+K,Bt=q[le],te=le+1{const{el:ee,type:Q,transition:V,children:re,shapeFlag:K}=x;if(K&6){De(x.component.subTree,q,S,L);return}if(K&128){x.suspense.move(q,S,L);return}if(K&64){Q.move(x,q,S,Hn);return}if(Q===or){i(ee,q,S);for(let oe=0;oeV.enter(ee),z);else{const{leave:oe,delayLeave:ue,afterLeave:be}=V,Ee=()=>i(ee,q,S),He=()=>{oe(ee,()=>{Ee(),be&&be()})};ue?ue(ee,Ee,He):He()}else i(ee,q,S)},Mt=(x,q,S,L=!1,z=!1)=>{const{type:ee,props:Q,ref:V,children:re,dynamicChildren:K,shapeFlag:ce,patchFlag:oe,dirs:ue}=x;if(V!=null&&Tl(V,null,S,x,!0),ce&256){q.ctx.deactivate(x);return}const be=ce&1&&ue,Ee=!Wu(x);let He;if(Ee&&(He=Q&&Q.onVnodeBeforeUnmount)&&yr(He,q,x),ce&6)En(x.component,S,L);else{if(ce&128){x.suspense.unmount(S,L);return}be&&Pi(x,null,q,"beforeUnmount"),ce&64?x.type.remove(x,q,S,z,Hn,L):K&&(ee!==or||oe>0&&oe&64)?pn(K,q,S,!1,!0):(ee===or&&oe&384||!z&&ce&16)&&pn(re,q,S),L&&Or(x)}(Ee&&(He=Q&&Q.onVnodeUnmounted)||be)&&bn(()=>{He&&yr(He,q,x),be&&Pi(x,null,q,"unmounted")},S)},Or=x=>{const{type:q,el:S,anchor:L,transition:z}=x;if(q===or){hs(S,L);return}if(q===pl){ne(x);return}const ee=()=>{a(S),z&&!z.persisted&&z.afterLeave&&z.afterLeave()};if(x.shapeFlag&1&&z&&!z.persisted){const{leave:Q,delayLeave:V}=z,re=()=>Q(S,ee);V?V(x.el,ee,re):re()}else ee()},hs=(x,q)=>{let S;for(;x!==q;)S=B(x),a(x),x=S;a(q)},En=(x,q,S)=>{const{bum:L,scope:z,update:ee,subTree:Q,um:V}=x;L&&cl(L),z.stop(),ee&&(ee.active=!1,Mt(Q,x,q,S)),V&&bn(V,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,S,L=!1,z=!1,ee=0)=>{for(let Q=ee;Qx.shapeFlag&6?fe(x.component.subTree):x.shapeFlag&128?x.suspense.next():B(x.anchor||x.el),Be=(x,q,S)=>{x==null?q._vnode&&Mt(q._vnode,null,null,!0):b(q._vnode||null,x,q,null,null,null,S),Uf(),hd(),q._vnode=x},Hn={p:b,um:Mt,m:De,r:Or,mt:Jt,mc:xe,pc:qe,pbc:Ke,n:fe,o:t};let Gt,Je;return e&&([Gt,Je]=e(Hn)),{render:Be,hydrate:Gt,createApp:Ry(Be,Gt)}}function Mi({effect:t,update:e},n){t.allowRecurse=e.allowRecurse=n}function Td(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 My=t=>t.__isTeleport,or=Symbol(void 0),Qc=Symbol(void 0),Dr=Symbol(void 0),pl=Symbol(void 0),na=[];let cr=null;function By(t=!1){na.push(cr=t?null:[])}function Fy(){na.pop(),cr=na[na.length-1]||null}let pa=1;function Gf(t){pa+=t}function Uy(t){return t.dynamicChildren=pa>0?cr||Fs:null,Fy(),pa>0&&cr&&cr.push(t),t}function $y(t,e,n,i,a,l){return Uy(qt(t,e,n,i,a,l,!0))}function Qy(t){return t?t.__v_isVNode===!0:!1}function $i(t,e){return t.type===e.type&&t.key===e.key}const jc="__vInternal",kd=({key:t})=>t??null,Iu=({ref:t,ref_key:e,ref_for:n})=>t!=null?Pt(t)||rn(t)||Se(t)?{i:ur,r:t,k:e,f:!!n}:t:null;function qt(t,e=null,n=null,i=0,a=null,l=t===or?0:1,m=!1,w=!1){const v={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&kd(e),ref:e&&Iu(e),scopeId:md,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:ur};return w?(pf(v,n),l&128&&t.normalize(v)):n&&(v.shapeFlag|=Pt(n)?8:16),pa>0&&!m&&cr&&(v.patchFlag>0||l&6)&&v.patchFlag!==32&&cr.push(v),v}const cs=jy;function jy(t,e=null,n=null,i=0,a=null,l=!1){if((!t||t===vy)&&(t=Dr),Qy(t)){const w=mi(t,e,!0);return n&&pf(w,n),pa>0&&!l&&cr&&(w.shapeFlag&6?cr[cr.indexOf(t)]=w:cr.push(w)),w.patchFlag|=-2,w}if(tw(t)&&(t=t.__vccOpts),e){e=Hy(e);let{class:w,style:v}=e;w&&!Pt(w)&&(e.class=Gl(w)),wt(v)&&(rd(v)&&!Ie(v)&&(v=on({},v)),e.style=Jl(v))}const m=Pt(t)?1:ry(t)?128:My(t)?64:wt(t)?4:Se(t)?2:0;return qt(t,e,n,i,a,m,l,!0)}function Hy(t){return t?rd(t)||jc in t?on({},t):t:null}function mi(t,e,n=!1){const{props:i,ref:a,patchFlag:l,children:m}=t,w=e?Vy(i||{},e):i;return{__v_isVNode:!0,__v_skip:!0,type:t.type,props:w,key:w&&kd(w),ref:e&&e.ref?n&&a?Ie(a)?a.concat(Iu(e)):[a,Iu(e)]:Iu(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!==or?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&&mi(t.ssContent),ssFallback:t.ssFallback&&mi(t.ssFallback),el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce}}function ma(t=" ",e=0){return cs(Qc,null,t,e)}function _r(t){return t==null||typeof t=="boolean"?cs(Dr):Ie(t)?cs(or,null,t.slice()):typeof t=="object"?ei(t):cs(Qc,null,String(t))}function ei(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:mi(t)}function pf(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),pf(t,a()),a._c&&(a._d=!0));return}else{n=32;const a=e._;!a&&!(jc in e)?e._ctx=ur:a===3&&ur&&(ur.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else Se(e)?(e={default:e,_ctx:ur},n=32):(e=String(e),i&64?(n=16,e=[ma(e)]):n=8);t.children=e,t.shapeFlag|=n}function Vy(...t){const e={};for(let n=0;nOt||ur,wo=t=>{Ot=t,t.scope.on()},ls=()=>{Ot&&Ot.scope.off(),Ot=null};function Sd(t){return t.vnode.shapeFlag&4}let ya=!1;function Xy(t,e=!1){ya=e;const{props:n,children:i}=t.vnode,a=Sd(t);Wy(t,n,a,e),Ty(t,i);const l=a?Yy(t,e):void 0;return ya=!1,l}function Yy(t,e){const n=t.type;t.accessCache=Object.create(null),t.proxy=id(new Proxy(t.ctx,_y));const{setup:i}=n;if(i){const a=t.setupContext=i.length>1?ew(t):null;wo(t),Co();const l=hi(i,t,0,[t.props,a]);if(qo(),ls(),$h(l)){if(l.then(ls,ls),e)return l.then(m=>{Xf(t,m,e)}).catch(m=>{Bc(m,t,0)});t.asyncDep=l}else Xf(t,l,e)}else Rd(t,e)}function Xf(t,e,n){Se(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:wt(e)&&(t.setupState=ud(e)),Rd(t,n)}let Yf;function Rd(t,e,n){const i=t.type;if(!t.render){if(!e&&Yf&&!i.render){const a=i.template||hf(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=Yf(a,d)}}t.render=i.render||fr}wo(t),Co(),xy(t),qo(),ls()}function Zy(t){return new Proxy(t.attrs,{get(e,n){return xn(t,"get","$attrs"),e[n]}})}function ew(t){const e=i=>{t.exposed=i||{}};let n;return{get attrs(){return n||(n=Zy(t))},slots:t.slots,emit:t.emit,expose:e}}function mf(t){if(t.exposed)return t.exposeProxy||(t.exposeProxy=new Proxy(ud(id(t.exposed)),{get(e,n){if(n in e)return e[n];if(n in ta)return ta[n](t)},has(e,n){return n in e||n in ta}}))}function tw(t){return Se(t)&&"__vccOpts"in t}const nw=(t,e)=>jm(t,e,ya),rw=Symbol(""),iw=()=>Ou(rw),sw="3.2.47",ow="http://www.w3.org/2000/svg",Qi=typeof document<"u"?document:null,Zf=Qi&&Qi.createElement("template"),aw={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?Qi.createElementNS(ow,t):Qi.createElement(t,n?{is:n}:void 0);return t==="select"&&i&&i.multiple!=null&&a.setAttribute("multiple",i.multiple),a},createText:t=>Qi.createTextNode(t),createComment:t=>Qi.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>Qi.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{Zf.innerHTML=i?`${t}`:t;const w=Zf.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 uw(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 cw(t,e,n){const i=t.style,a=Pt(n);if(n&&!a){if(e&&!Pt(e))for(const l in e)n[l]==null&&kl(i,l,"");for(const l in n)kl(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 kl(t,e,n){if(Ie(n))n.forEach(i=>kl(t,e,i));else if(n==null&&(n=""),e.startsWith("--"))t.setProperty(e,n);else{const i=lw(t,e);eh.test(n)?t.setProperty(Eo(i),n.replace(eh,""),"important"):t[i]=n}}const th=["Webkit","Moz","ms"],ml={};function lw(t,e){const n=ml[e];if(n)return n;let i=mo(e);if(i!=="filter"&&i in t)return ml[e]=i;i=Hh(i);for(let a=0;ayl||(ww.then(()=>yl=0),yl=Date.now());function bw(t,e){const n=i=>{if(!i._vts)i._vts=Date.now();else if(i._vts<=n.attached)return;Qn(Nw(i,n.value),e,5,[i])};return n.value=t,n.attached=gw(),n}function Nw(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 ih=/^on[a-z]/,vw=(t,e,n,i,a=!1,l,m,w,v)=>{e==="class"?uw(t,i,a):e==="style"?cw(t,n,i):Dc(e)?Xl(e)||mw(t,e,n,i,m):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):_w(t,e,i,a))?hw(t,e,i,l,m,w,v):(e==="true-value"?t._trueValue=i:e==="false-value"&&(t._falseValue=i),fw(t,e,i,a))};function _w(t,e,n,i){return i?!!(e==="innerHTML"||e==="textContent"||e in t&&ih.test(e)&&Se(n)):e==="spellcheck"||e==="draggable"||e==="translate"||e==="form"||e==="list"&&t.tagName==="INPUT"||e==="type"&&t.tagName==="TEXTAREA"||ih.test(e)&&Pt(n)?!1:e in t}const xw={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};cy.props;const Ew=on({patchProp:vw},aw);let sh;function Cw(){return sh||(sh=Dy(Ew))}const qw=(...t)=>{const e=Cw().createApp(...t),{mount:n}=e;return e.mount=i=>{const a=Ow(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 Ow(t){return Pt(t)?document.querySelector(t):t}function ra(t){return typeof t>"u"||t===void 0}function hr(t){return typeof t=="string"}function Ww(t){return typeof t=="number"}function Dd(t){return typeof t=="boolean"}function Ld(t){return t===null}function Iw(t){return t instanceof Date}function Aw(t){return typeof t=="bigint"}function jn(t){return typeof t=="function"}function Cr(t){return typeof t=="object"&&t!==null}function p(t){return Object.freeze(t)}function Ka(t){return Array.isArray(t)}function go(t){return t}const Ct=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]})}}),yt=p({is(t){return t.kind==="IdentifierNode"},create(t){return p({kind:"IdentifierNode",name:t})}}),Yr=p({is(t){return t.kind==="CreateIndexNode"},create(t){return p({kind:"CreateIndexNode",name:yt.create(t)})},cloneWith(t,e){return p({...t,...e})},cloneWithColumns(t,e){return p({...t,columns:[...t.columns||[],...e]})}}),Pd=p({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return p({kind:"CreateSchemaNode",schema:yt.create(t),...e})},cloneWith(t,e){return p({...t,...e})}}),Tw=["preserve rows","delete rows","drop"],Xn=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})}}),yi=p({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return p({kind:"SchemableIdentifierNode",identifier:yt.create(t)})},createWithSchema(t,e){return p({kind:"SchemableIdentifierNode",schema:yt.create(t),identifier:yt.create(e)})}}),Au=p({is(t){return t.kind==="DropIndexNode"},create(t,e){return p({kind:"DropIndexNode",name:yi.create(t),...e})},cloneWith(t,e){return p({...t,...e})}}),Sl=p({is(t){return t.kind==="DropSchemaNode"},create(t,e){return p({kind:"DropSchemaNode",schema:yt.create(t),...e})},cloneWith(t,e){return p({...t,...e})}}),Rl=p({is(t){return t.kind==="DropTableNode"},create(t,e){return p({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return p({...t,...e})}}),fs=p({is(t){return t.kind==="AliasNode"},create(t,e){return p({kind:"AliasNode",node:t,alias:e})}}),di=p({is(t){return t.kind==="TableNode"},create(t){return p({kind:"TableNode",table:yi.create(t)})},createWithSchema(t,e){return p({kind:"TableNode",table:yi.createWithSchema(t,e)})}});function hn(t){return Cr(t)&&jn(t.toOperationNode)}function kw(t){return Cr(t)&&"expressionType"in t&&hn(t)}function Sw(t){return Cr(t)&&"expression"in t&&hr(t.alias)&&hn(t)}const Ir=p({is(t){return t.kind==="SelectModifierNode"},create(t){return p({kind:"SelectModifierNode",modifier:t})},createWithExpression(t){return p({kind:"SelectModifierNode",rawModifier:t})}}),wa=p({is(t){return t.kind==="AndNode"},create(t,e){return p({kind:"AndNode",left:t,right:e})}}),ga=p({is(t){return t.kind==="OrNode"},create(t,e){return p({kind:"OrNode",left:t,right:e})}}),Go=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"?wa.create(t.on,n):ga.create(t.on,n)})}}),$n=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:Go.create(n)})},cloneWithOn(t,e){return p({...t,on:t.on?Go.cloneWithOperation(t.on,"And",e):Go.create(e)})},cloneWithOrOn(t,e){return p({...t,on:t.on?Go.cloneWithOperation(t.on,"Or",e):Go.create(e)})}}),Hc=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)}}),Md=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->"],Rw=["+","-","*","/","%","^","&","|","#","<<",">>"],Bd=[...Md,...Rw,"&&","||"],Dw=["exists","not exists"],Lw=["not","-",...Dw],Pw=[...Bd,...Lw],yf=p({is(t){return t.kind==="OperatorNode"},create(t){return p({kind:"OperatorNode",operator:t})}});function Fd(t){return hr(t)&&Bd.includes(t)}function Ud(t){return hr(t)&&Md.includes(t)}const js=p({is(t){return t.kind==="ParensNode"},create(t){return p({kind:"ParensNode",node:t})}}),vt=p({is(t){return t.kind==="ColumnNode"},create(t){return p({kind:"ColumnNode",column:yt.create(t)})}}),wf=p({is(t){return t.kind==="SelectAllNode"},create(){return p({kind:"SelectAllNode"})}}),Vc=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:wf.create()})}}),Mw=p({is(t){return t.kind==="OrderByItemNode"},create(t,e){return p({kind:"OrderByItemNode",orderBy:t,direction:e})}});function Bw(t){return t==="asc"||t==="desc"}function zc(t,e){return Mw.create(Fw(t),Uw(e))}function Fw(t){return Fr(t)}function Uw(t){if(t)return t==="asc"||t==="desc"?en.createWithSql(t):t.toOperationNode()}function $d(t){return hr(t)?bo(t):t.toOperationNode()}function ba(t){return Ka(t)?t.map(e=>Fr(e)):[Fr(t)]}function Fr(t){return Zc(t)?Yc(t):$d(t)}function bo(t){const e=".";if(t.includes(e)){const n=t.split(e).map(gf);if(n.length===3)return Qw(n);if(n.length===2)return jw(n);throw new Error(`invalid column reference ${t}`)}else return vt.create(t)}function $w(t){const e=" as ";if(t.includes(e)){const[n,i]=t.split(e).map(gf);return fs.create(bo(n),yt.create(i))}else return bo(t)}function Qd(t){return vt.create(t)}function oh(t){const e=" ";if(t.includes(e)){const[n,i]=t.split(e).map(gf);if(!Bw(i))throw new Error(`invalid order direction "${i}" next to "${n}"`);return zc(n,i)}else return Qd(t)}function Qw(t){const[e,n,i]=t;return Vc.create(di.createWithSchema(e,n),vt.create(i))}function jw(t){const[e,n]=t;return Vc.create(di.create(e),vt.create(n))}function gf(t){return t.trim()}const jd=p({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return p({kind:"PrimitiveValueListNode",values:p([...t])})}}),bf=p({is(t){return t.kind==="ValueListNode"},create(t){return p({kind:"ValueListNode",values:p(t)})}}),qr=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 Hd(t){return Ka(t)?Hw(t):Lr(t)}function Lr(t){return Zc(t)?Yc(t):qr.create(t)}function Hw(t){return t.some(Zc)?bf.create(t.map(e=>Lr(e))):jd.create(t)}const No=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])})}}),ah=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])})}}),Dl=p({is(t){return t.kind==="OverNode"},create(){return p({kind:"OverNode"})},cloneWithOrderByItem(t,e){return p({...t,orderBy:t.orderBy?No.cloneWithItem(t.orderBy,e):No.create(e)})},cloneWithPartitionByItems(t,e){return p({...t,partitionBy:t.partitionBy?ah.cloneWithItems(t.partitionBy,e):ah.create(e)})}}),Uu=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])})}}),uh=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])})}}),_u=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"?wa.create(t.having,n):ga.create(t.having,n)})}}),We=p({is(t){return t.kind==="SelectQueryNode"},create(t,e){return p({kind:"SelectQueryNode",from:Uu.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?No.cloneWithItem(t.orderBy,e):No.create(e)})},cloneWithGroupByItems(t,e){return p({...t,groupBy:t.groupBy?uh.cloneWithItems(t.groupBy,e):uh.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?_u.cloneWithOperation(t.having,"And",e):_u.create(e)})},cloneWithOrHaving(t,e){return p({...t,having:t.having?_u.cloneWithOperation(t.having,"Or",e):_u.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})}}),Vd=p({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return p({kind:"UnaryOperationNode",operator:t,operand:e})}});function sn(t){return Nf("exists",t)}function zt(t){return Nf("not exists",t)}function Nf(t,e){return Vd.create(yf.create(t),Fr(e))}function Qe(t,e){Object.defineProperties(t.prototype,{then:{enumerable:!1,value:()=>{throw new Error(e)}}})}var ht;const Zn=class{constructor(e){F(this,ht,void 0);J(this,ht,p(e))}on(...e){return new Zn({...r(this,ht),joinNode:$n.cloneWithOn(r(this,ht).joinNode,Nh(e))})}orOn(...e){return new Zn({...r(this,ht),joinNode:$n.cloneWithOrOn(r(this,ht).joinNode,Nh(e))})}onRef(e,n,i){return new Zn({...r(this,ht),joinNode:$n.cloneWithOn(r(this,ht).joinNode,Kt(e,n,i))})}orOnRef(e,n,i){return new Zn({...r(this,ht),joinNode:$n.cloneWithOrOn(r(this,ht).joinNode,Kt(e,n,i))})}onExists(e){return new Zn({...r(this,ht),joinNode:$n.cloneWithOn(r(this,ht).joinNode,sn(e))})}onNotExists(e){return new Zn({...r(this,ht),joinNode:$n.cloneWithOn(r(this,ht).joinNode,zt(e))})}orOnExists(e){return new Zn({...r(this,ht),joinNode:$n.cloneWithOrOn(r(this,ht).joinNode,sn(e))})}orOnNotExists(e){return new Zn({...r(this,ht),joinNode:$n.cloneWithOrOn(r(this,ht).joinNode,zt(e))})}onTrue(){return new Zn({...r(this,ht),joinNode:$n.cloneWithOn(r(this,ht).joinNode,en.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return r(this,ht).joinNode}};let $u=Zn;ht=new WeakMap;Qe($u,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const Vw=p({is(t){return t.kind==="PartitionByItemNode"},create(t){return p({kind:"PartitionByItemNode",partitionBy:t})}});function zw(t){return ba(t).map(Vw.create)}var Ji;const fc=class{constructor(e){F(this,Ji,void 0);J(this,Ji,p(e))}orderBy(e,n){return new fc({overNode:Dl.cloneWithOrderByItem(r(this,Ji).overNode,zc(e,n))})}partitionBy(e){return new fc({overNode:Dl.cloneWithPartitionByItems(r(this,Ji).overNode,zw(e))})}$call(e){return e(this)}toOperationNode(){return r(this,Ji).overNode}};let Qu=fc;Ji=new WeakMap;Qe(Qu,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");const ia=p({is(t){return t.kind==="SelectionNode"},create(t){return p({kind:"SelectionNode",selection:t})},createSelectAll(){return p({kind:"SelectionNode",selection:wf.create()})},createSelectAllFromTable(t){return p({kind:"SelectionNode",selection:Vc.createSelectAll(t)})}});var Hs;class Kw{constructor(e){F(this,Hs,void 0);J(this,Hs,e)}get dynamicReference(){return r(this,Hs)}get refType(){}toOperationNode(){return $d(r(this,Hs))}}Hs=new WeakMap;function Jw(t){return Cr(t)&&hn(t)&&hr(t.dynamicReference)}function Ja(t){return jn(t)?Ja(t(Pr())):Ka(t)?t.map(e=>ch(e)):[ch(t)]}function ch(t){return hr(t)?ia.create($w(t)):Jw(t)?ia.create(t.toOperationNode()):ia.create(lp(t))}function Ga(t){return t?Array.isArray(t)?t.map(lh):[lh(t)]:[ia.createSelectAll()]}function lh(t){if(hr(t))return ia.createSelectAllFromTable(_n(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const Gw=p({is(t){return t.kind==="ValuesNode"},create(t){return p({kind:"ValuesNode",values:p(t)})}}),Xw=p({is(t){return t.kind==="DefaultInsertValueNode"},create(){return p({kind:"DefaultInsertValueNode"})}});function Yw(t){const e=jn(t)?t(Pr()):t,n=Ka(e)?e:p([e]);return Zw(n)}function Zw(t){const e=eg(t);return[p([...e.keys()].map(vt.create)),Gw.create(t.map(n=>tg(n,e)))]}function eg(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 tg(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(ra(w))continue;const v=t[m];(ra(v)||Zc(v))&&(a=!0),i[w]=v}if(n.lengthra(w)?m:Lr(w)))}return jd.create(i)}const xr=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})}}),ju=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?Uu.cloneWithFroms(t.from,e):Uu.create(e)})},cloneWithUpdates(t,e){return p({...t,updates:t.updates?p([...t.updates,...e]):e})}}),fh=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])})}}),sa=p({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return p({kind:"DeleteQueryNode",from:Uu.create(t),...e&&{with:e}})},cloneWithOrderByItem(t,e){return p({...t,orderBy:t.orderBy?No.cloneWithItem(t.orderBy,e):No.create(e)})},cloneWithLimit(t,e){return p({...t,limit:e})},cloneWithUsing(t,e){return p({...t,using:t.using!==void 0?fh.cloneWithTables(t.using,e):fh.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"?wa.create(t.where,n):ga.create(t.where,n)})}}),hh=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)})}}),ng=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)||xr.is(t)||ju.is(t)||sa.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?hh.cloneWithSelections(t.returning,e):hh.create(e)})},cloneWithoutWhere(t){return p({...t,where:void 0})},cloneWithExplain(t,e,n){return p({...t,explain:ng.create(e,n==null?void 0:n.toOperationNode())})}}),rg=p({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return p({kind:"ColumnUpdateNode",column:t,value:e})}});function vf(t){const e=jn(t)?t(Pr()):t;return Object.entries(e).filter(([n,i])=>i!==void 0).map(([n,i])=>rg.create(vt.create(n),Lr(i)))}const ig=p({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return p({kind:"OnDuplicateKeyNode",updates:t})}});var Ca,qa;class zd{constructor(e,n){F(this,Ca,void 0);F(this,qa,void 0);J(this,Ca,e),J(this,qa,n)}get insertId(){return r(this,Ca)}get numInsertedOrUpdatedRows(){return r(this,qa)}}Ca=new WeakMap,qa=new WeakMap;for(const t of["insertId","numInsertedOrUpdatedRows"])Object.defineProperty(zd.prototype,t,{enumerable:!0});class Kc extends Error{constructor(n){super("no result");Te(this,"node");this.node=n}}function Jc(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const ut=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 Re;const cn=class{constructor(e){F(this,Re,void 0);J(this,Re,p(e))}column(e){const n=vt.create(e);return new cn({...r(this,Re),onConflictNode:ut.cloneWith(r(this,Re).onConflictNode,{columns:r(this,Re).onConflictNode.columns?p([...r(this,Re).onConflictNode.columns,n]):p([n])})})}columns(e){const n=e.map(vt.create);return new cn({...r(this,Re),onConflictNode:ut.cloneWith(r(this,Re).onConflictNode,{columns:r(this,Re).onConflictNode.columns?p([...r(this,Re).onConflictNode.columns,...n]):p(n)})})}constraint(e){return new cn({...r(this,Re),onConflictNode:ut.cloneWith(r(this,Re).onConflictNode,{constraint:yt.create(e)})})}expression(e){return new cn({...r(this,Re),onConflictNode:ut.cloneWith(r(this,Re).onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new cn({...r(this,Re),onConflictNode:ut.cloneWithIndexWhere(r(this,Re).onConflictNode,kn(e))})}whereRef(e,n,i){return new cn({...r(this,Re),onConflictNode:ut.cloneWithIndexWhere(r(this,Re).onConflictNode,Kt(e,n,i))})}orWhere(...e){return new cn({...r(this,Re),onConflictNode:ut.cloneWithIndexOrWhere(r(this,Re).onConflictNode,kn(e))})}orWhereRef(e,n,i){return new cn({...r(this,Re),onConflictNode:ut.cloneWithIndexOrWhere(r(this,Re).onConflictNode,Kt(e,n,i))})}whereExists(e){return new cn({...r(this,Re),onConflictNode:ut.cloneWithIndexWhere(r(this,Re).onConflictNode,sn(e))})}whereNotExists(e){return new cn({...r(this,Re),onConflictNode:ut.cloneWithIndexWhere(r(this,Re).onConflictNode,zt(e))})}orWhereExists(e){return new cn({...r(this,Re),onConflictNode:ut.cloneWithIndexOrWhere(r(this,Re).onConflictNode,sn(e))})}orWhereNotExists(e){return new cn({...r(this,Re),onConflictNode:ut.cloneWithIndexOrWhere(r(this,Re).onConflictNode,zt(e))})}clearWhere(){return new cn({...r(this,Re),onConflictNode:ut.cloneWithoutIndexWhere(r(this,Re).onConflictNode)})}doNothing(){return new Kd({...r(this,Re),onConflictNode:ut.cloneWith(r(this,Re).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new Vu({...r(this,Re),onConflictNode:ut.cloneWith(r(this,Re).onConflictNode,{updates:vf(e)})})}$call(e){return e(this)}};let Hu=cn;Re=new WeakMap;Qe(Hu,"don't await OnConflictBuilder instances.");var Oa;class Kd{constructor(e){F(this,Oa,void 0);J(this,Oa,p(e))}toOperationNode(){return r(this,Oa).onConflictNode}}Oa=new WeakMap;Qe(Kd,"don't await OnConflictDoNothingBuilder instances.");var dt;const er=class{constructor(e){F(this,dt,void 0);J(this,dt,p(e))}where(...e){return new er({...r(this,dt),onConflictNode:ut.cloneWithUpdateWhere(r(this,dt).onConflictNode,kn(e))})}whereRef(e,n,i){return new er({...r(this,dt),onConflictNode:ut.cloneWithUpdateWhere(r(this,dt).onConflictNode,Kt(e,n,i))})}orWhere(...e){return new er({...r(this,dt),onConflictNode:ut.cloneWithUpdateOrWhere(r(this,dt).onConflictNode,kn(e))})}orWhereRef(e,n,i){return new er({...r(this,dt),onConflictNode:ut.cloneWithUpdateOrWhere(r(this,dt).onConflictNode,Kt(e,n,i))})}whereExists(e){return new er({...r(this,dt),onConflictNode:ut.cloneWithUpdateWhere(r(this,dt).onConflictNode,sn(e))})}whereNotExists(e){return new er({...r(this,dt),onConflictNode:ut.cloneWithUpdateWhere(r(this,dt).onConflictNode,zt(e))})}orWhereExists(e){return new er({...r(this,dt),onConflictNode:ut.cloneWithUpdateOrWhere(r(this,dt).onConflictNode,sn(e))})}orWhereNotExists(e){return new er({...r(this,dt),onConflictNode:ut.cloneWithUpdateOrWhere(r(this,dt).onConflictNode,zt(e))})}clearWhere(){return new er({...r(this,dt),onConflictNode:ut.cloneWithoutUpdateWhere(r(this,dt).onConflictNode)})}$call(e){return e(this)}toOperationNode(){return r(this,dt).onConflictNode}};let Vu=er;dt=new WeakMap;Qe(Vu,"don't await OnConflictUpdateBuilder instances.");var ke;const kt=class{constructor(e){F(this,ke,void 0);J(this,ke,p(e))}values(e){const[n,i]=Yw(e);return new kt({...r(this,ke),queryNode:xr.cloneWith(r(this,ke).queryNode,{columns:n,values:i})})}columns(e){return new kt({...r(this,ke),queryNode:xr.cloneWith(r(this,ke).queryNode,{columns:p(e.map(vt.create))})})}expression(e){return new kt({...r(this,ke),queryNode:xr.cloneWith(r(this,ke).queryNode,{values:Yc(e)})})}ignore(){return new kt({...r(this,ke),queryNode:xr.cloneWith(r(this,ke).queryNode,{ignore:!0})})}onConflict(e){return new kt({...r(this,ke),queryNode:xr.cloneWith(r(this,ke).queryNode,{onConflict:e(new Hu({onConflictNode:ut.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new kt({...r(this,ke),queryNode:xr.cloneWith(r(this,ke).queryNode,{onDuplicateKey:ig.create(vf(e))})})}returning(e){return new kt({...r(this,ke),queryNode:ye.cloneWithReturning(r(this,ke).queryNode,Ja(e))})}returningAll(){return new kt({...r(this,ke),queryNode:ye.cloneWithReturning(r(this,ke).queryNode,Ga())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,n){return e?n(this):new kt({...r(this,ke)})}if(e,n){return e?n(this):new kt({...r(this,ke)})}$castTo(){return new kt(r(this,ke))}castTo(){return this.$castTo()}$narrowType(){return new kt(r(this,ke))}$assertType(){return new kt(r(this,ke))}assertType(){return new kt(r(this,ke))}withPlugin(e){return new kt({...r(this,ke),executor:r(this,ke).executor.withPlugin(e)})}toOperationNode(){return r(this,ke).executor.transformQuery(r(this,ke).queryNode,r(this,ke).queryId)}compile(){return r(this,ke).executor.compileQuery(this.toOperationNode(),r(this,ke).queryId)}async execute(){const e=this.compile(),n=e.query,i=await r(this,ke).executor.executeQuery(e,r(this,ke).queryId);return r(this,ke).executor.adapter.supportsReturning&&n.returning?i.rows:[new zd(i.insertId,i.numAffectedRows??i.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Kc){const n=await this.executeTakeFirst();if(n===void 0)throw Jc(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),i=r(this,ke).executor.stream(n,e,r(this,ke).queryId);for await(const a of i)yield*a.rows}async explain(e,n){return await new kt({...r(this,ke),queryNode:ye.cloneWithExplain(r(this,ke).queryNode,e,n)}).execute()}};let Na=kt;ke=new WeakMap;Qe(Na,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");var Wa;class Jd{constructor(e){F(this,Wa,void 0);J(this,Wa,e)}get numDeletedRows(){return r(this,Wa)}}Wa=new WeakMap;Object.defineProperty(Jd.prototype,"numDeletedRows",{enumerable:!0});const Gd=p({is(t){return t.kind==="LimitNode"},create(t){return p({kind:"LimitNode",limit:qr.create(t)})}});var de;const Ye=class{constructor(e){F(this,de,void 0);J(this,de,p(e))}where(...e){return new Ye({...r(this,de),queryNode:ye.cloneWithWhere(r(this,de).queryNode,kn(e))})}whereRef(e,n,i){return new Ye({...r(this,de),queryNode:ye.cloneWithWhere(r(this,de).queryNode,Kt(e,n,i))})}orWhere(...e){return new Ye({...r(this,de),queryNode:ye.cloneWithOrWhere(r(this,de).queryNode,kn(e))})}orWhereRef(e,n,i){return new Ye({...r(this,de),queryNode:ye.cloneWithOrWhere(r(this,de).queryNode,Kt(e,n,i))})}whereExists(e){return new Ye({...r(this,de),queryNode:ye.cloneWithWhere(r(this,de).queryNode,sn(e))})}whereNotExists(e){return new Ye({...r(this,de),queryNode:ye.cloneWithWhere(r(this,de).queryNode,zt(e))})}orWhereExists(e){return new Ye({...r(this,de),queryNode:ye.cloneWithOrWhere(r(this,de).queryNode,sn(e))})}orWhereNotExists(e){return new Ye({...r(this,de),queryNode:ye.cloneWithOrWhere(r(this,de).queryNode,zt(e))})}clearWhere(){return new Ye({...r(this,de),queryNode:ye.cloneWithoutWhere(r(this,de).queryNode)})}using(e){return new Ye({...r(this,de),queryNode:sa.cloneWithUsing(r(this,de).queryNode,_o(e))})}innerJoin(...e){return new Ye({...r(this,de),queryNode:ye.cloneWithJoin(r(this,de).queryNode,vn("InnerJoin",e))})}leftJoin(...e){return new Ye({...r(this,de),queryNode:ye.cloneWithJoin(r(this,de).queryNode,vn("LeftJoin",e))})}rightJoin(...e){return new Ye({...r(this,de),queryNode:ye.cloneWithJoin(r(this,de).queryNode,vn("RightJoin",e))})}fullJoin(...e){return new Ye({...r(this,de),queryNode:ye.cloneWithJoin(r(this,de).queryNode,vn("FullJoin",e))})}returning(e){return new Ye({...r(this,de),queryNode:ye.cloneWithReturning(r(this,de).queryNode,Ja(e))})}returningAll(e){return new Ye({...r(this,de),queryNode:ye.cloneWithReturning(r(this,de).queryNode,Ga(e))})}orderBy(e,n){return new Ye({...r(this,de),queryNode:sa.cloneWithOrderByItem(r(this,de).queryNode,zc(e,n))})}limit(e){return new Ye({...r(this,de),queryNode:sa.cloneWithLimit(r(this,de).queryNode,Gd.create(e))})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,n){return e?n(this):new Ye({...r(this,de)})}if(e,n){return this.$if(e,n)}$castTo(){return new Ye(r(this,de))}castTo(){return this.$castTo()}$narrowType(){return new Ye(r(this,de))}$assertType(){return new Ye(r(this,de))}assertType(){return new Ye(r(this,de))}withPlugin(e){return new Ye({...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 Jd(i.numAffectedRows??i.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Kc){const n=await this.executeTakeFirst();if(n===void 0)throw Jc(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 Ye({...r(this,de),queryNode:ye.cloneWithExplain(r(this,de).queryNode,e,n)}).execute()}};let zu=Ye;de=new WeakMap;Qe(zu,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");var Ia;class Xd{constructor(e){F(this,Ia,void 0);J(this,Ia,e)}get numUpdatedRows(){return r(this,Ia)}}Ia=new WeakMap;Object.defineProperty(Xd.prototype,"numUpdatedRows",{enumerable:!0});var pe;const rt=class{constructor(e){F(this,pe,void 0);J(this,pe,p(e))}where(...e){return new rt({...r(this,pe),queryNode:ye.cloneWithWhere(r(this,pe).queryNode,kn(e))})}whereRef(e,n,i){return new rt({...r(this,pe),queryNode:ye.cloneWithWhere(r(this,pe).queryNode,Kt(e,n,i))})}orWhere(...e){return new rt({...r(this,pe),queryNode:ye.cloneWithOrWhere(r(this,pe).queryNode,kn(e))})}orWhereRef(e,n,i){return new rt({...r(this,pe),queryNode:ye.cloneWithOrWhere(r(this,pe).queryNode,Kt(e,n,i))})}whereExists(e){return new rt({...r(this,pe),queryNode:ye.cloneWithWhere(r(this,pe).queryNode,sn(e))})}whereNotExists(e){return new rt({...r(this,pe),queryNode:ye.cloneWithWhere(r(this,pe).queryNode,zt(e))})}orWhereExists(e){return new rt({...r(this,pe),queryNode:ye.cloneWithOrWhere(r(this,pe).queryNode,sn(e))})}orWhereNotExists(e){return new rt({...r(this,pe),queryNode:ye.cloneWithOrWhere(r(this,pe).queryNode,zt(e))})}clearWhere(){return new rt({...r(this,pe),queryNode:ye.cloneWithoutWhere(r(this,pe).queryNode)})}from(e){return new rt({...r(this,pe),queryNode:ju.cloneWithFromItems(r(this,pe).queryNode,_o(e))})}innerJoin(...e){return new rt({...r(this,pe),queryNode:ye.cloneWithJoin(r(this,pe).queryNode,vn("InnerJoin",e))})}leftJoin(...e){return new rt({...r(this,pe),queryNode:ye.cloneWithJoin(r(this,pe).queryNode,vn("LeftJoin",e))})}rightJoin(...e){return new rt({...r(this,pe),queryNode:ye.cloneWithJoin(r(this,pe).queryNode,vn("RightJoin",e))})}fullJoin(...e){return new rt({...r(this,pe),queryNode:ye.cloneWithJoin(r(this,pe).queryNode,vn("FullJoin",e))})}set(e){return new rt({...r(this,pe),queryNode:ju.cloneWithUpdates(r(this,pe).queryNode,vf(e))})}returning(e){return new rt({...r(this,pe),queryNode:ye.cloneWithReturning(r(this,pe).queryNode,Ja(e))})}returningAll(){return new rt({...r(this,pe),queryNode:ye.cloneWithReturning(r(this,pe).queryNode,Ga())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,n){return e?n(this):new rt({...r(this,pe)})}if(e,n){return this.$if(e,n)}$castTo(){return new rt(r(this,pe))}castTo(){return this.$castTo()}$narrowType(){return new rt(r(this,pe))}$assertType(){return new rt(r(this,pe))}assertType(){return new rt(r(this,pe))}withPlugin(e){return new rt({...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 Xd(i.numAffectedRows??i.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Kc){const n=await this.executeTakeFirst();if(n===void 0)throw Jc(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 rt({...r(this,pe),queryNode:ye.cloneWithExplain(r(this,pe).queryNode,e,n)}).execute()}};let Ku=rt;pe=new WeakMap;Qe(Ku,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");const sg=p({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return p({kind:"CommonTableExpressionNode",name:t,expression:e})}}),dh=p({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return p({kind:"CommonTableExpressionNameNode",table:di.create(t),columns:e?p(e.map(vt.create)):void 0})}});function ph(t,e){const n=e(mg());return sg.create(og(t),n.toOperationNode())}function og(t){if(t.includes("(")){const e=t.split(/[\(\)]/),n=e[0],i=e[1].split(",").map(a=>a.trim());return dh.create(n,i)}else return dh.create(t)}const xu=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])})}}),mh=["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 ag(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}}hc=new WeakMap;const lg=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 zs,Gi,dc,Yd,pc,Zd,Xi,Zo,Aa,Ll,mc,ep;class fg extends _f{constructor(n){super();F(this,dc);F(this,pc);F(this,Xi);F(this,Aa);F(this,mc);F(this,zs,void 0);F(this,Gi,new Set);J(this,zs,n)}transformNodeImpl(n){if(!Oe(this,dc,Yd).call(this,n))return super.transformNodeImpl(n);const i=Oe(this,pc,Zd).call(this,n);for(const l of i)r(this,Gi).add(l);const a=super.transformNodeImpl(n);for(const l of i)r(this,Gi).delete(l);return a}transformSchemableIdentifier(n){const i=super.transformSchemableIdentifier(n);return i.schema||!r(this,Gi).has(n.identifier.name)?i:{...i,schema:yt.create(r(this,zs))}}transformReferences(n){const i=super.transformReferences(n);return i.table.table.schema?i:{...i,table:di.createWithSchema(r(this,zs),i.table.table.identifier.name)}}}zs=new WeakMap,Gi=new WeakMap,dc=new WeakSet,Yd=function(n){return n.kind in lg},pc=new WeakSet,Zd=function(n){const i=new Set;if("name"in n&&n.name&&yi.is(n.name)&&Oe(this,Aa,Ll).call(this,n.name,i),"from"in n&&n.from)for(const a of n.from.froms)Oe(this,Xi,Zo).call(this,a,i);if("into"in n&&n.into&&Oe(this,Xi,Zo).call(this,n.into,i),"table"in n&&n.table&&Oe(this,Xi,Zo).call(this,n.table,i),"joins"in n&&n.joins)for(const a of n.joins)Oe(this,Xi,Zo).call(this,a.table,i);return"with"in n&&n.with&&Oe(this,mc,ep).call(this,n.with,i),i},Xi=new WeakSet,Zo=function(n,i){const a=di.is(n)?n:fs.is(n)&&di.is(n.node)?n.node:null;a&&Oe(this,Aa,Ll).call(this,a.table,i)},Aa=new WeakSet,Ll=function(n,i){r(this,Gi).has(n.identifier.name)||i.add(n.identifier.name)},mc=new WeakSet,ep=function(n,i){for(const a of n.expressions)i.delete(a.name.table.table.identifier.name)};var Ta;class Xa{constructor(e){F(this,Ta,void 0);J(this,Ta,new fg(e))}transformQuery(e){return r(this,Ta).transformNode(e.node)}async transformResult(e){return e.result}}Ta=new WeakMap;var it;const Vi=class{constructor(e){F(this,it,void 0);J(this,it,p(e))}selectFrom(e){return new vo({queryId:tt(),executor:r(this,it).executor,queryNode:We.create(_o(e),r(this,it).withNode)})}insertInto(e){return new Na({queryId:tt(),executor:r(this,it).executor,queryNode:xr.create(_n(e),r(this,it).withNode)})}replaceInto(e){return new Na({queryId:tt(),executor:r(this,it).executor,queryNode:xr.create(_n(e),r(this,it).withNode,!0)})}deleteFrom(e){return new zu({queryId:tt(),executor:r(this,it).executor,queryNode:sa.create(_o(e),r(this,it).withNode)})}updateTable(e){return new Ku({queryId:tt(),executor:r(this,it).executor,queryNode:ju.create(_a(e),r(this,it).withNode)})}with(e,n){const i=ph(e,n);return new Vi({...r(this,it),withNode:r(this,it).withNode?xu.cloneWithExpression(r(this,it).withNode,i):xu.create(i)})}withRecursive(e,n){const i=ph(e,n);return new Vi({...r(this,it),withNode:r(this,it).withNode?xu.cloneWithExpression(r(this,it).withNode,i):xu.create(i,{recursive:!0})})}withPlugin(e){return new Vi({...r(this,it),executor:r(this,it).executor.withPlugin(e)})}withoutPlugins(){return new Vi({...r(this,it),executor:r(this,it).executor.withoutPlugins()})}withSchema(e){return new Vi({...r(this,it),executor:r(this,it).executor.withPluginAtFront(new Xa(e))})}};let Ju=Vi;it=new WeakMap;var ka,Ks,Js;class yh{constructor(){F(this,ka,void 0);F(this,Ks,void 0);F(this,Js,void 0);Te(this,"resolve",e=>{r(this,Ks)&&r(this,Ks).call(this,e)});Te(this,"reject",e=>{r(this,Js)&&r(this,Js).call(this,e)});J(this,ka,new Promise((e,n)=>{J(this,Js,n),J(this,Ks,e)}))}get promise(){return r(this,ka)}}ka=new WeakMap,Ks=new WeakMap,Js=new WeakMap;const wh=new Set;function hg(t){wh.has(t)||(wh.add(t),console.log(t))}const dg=p([]);var Yi,Sa,Pl;class tp{constructor(e=dg){F(this,Sa);F(this,Yi,void 0);J(this,Yi,e)}get plugins(){return r(this,Yi)}transformQuery(e,n){for(const i of r(this,Yi)){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,Sa,Pl).call(this,a,n);return pg(a,l),l})}async*stream(e,n,i){const a=new yh,l=new yh;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 Oe(this,Sa,Pl).call(this,w,i)}finally{l.resolve()}}}Yi=new WeakMap,Sa=new WeakSet,Pl=async function(e,n){for(const i of r(this,Yi))e=await i.transformResult({result:e,queryId:n});return e};function pg(t,e){const{numAffectedRows:n}=t;n===void 0&&t.numUpdatedOrDeletedRows===void 0||n!==void 0&&e.numAffectedRows!==void 0||hg("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class Ls extends tp{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 Ls([...this.plugins,e])}withPlugins(e){return new Ls([...this.plugins,...e])}withPluginAtFront(e){return new Ls([e,...this.plugins])}withoutPlugins(){return new Ls([])}}const Gc=new Ls;function gh(){return new vo({queryId:tt(),executor:Gc,queryNode:We.create(_o([]))})}function mg(){return new Ju({executor:Gc})}function np(t,e){return new $u({joinNode:$n.create(t,_a(e))})}function yg(){return new Qu({overNode:Dl.create()})}const xf=p({is(t){return t.kind==="WhenNode"},create(t){return p({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return p({...t,result:e})}}),lr=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),xf.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return p({...t,...e})}});function Ml(t,e,n){if(!Fd(e)&&!hn(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return bg(e,n)?Ng(t,e,n):Hc.create(Fr(t),Ef(e),Hd(n))}function wg(t,e,n){if(!Fd(e)&&!hn(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return Hc.create(Fr(t),Ef(e),Fr(n))}function gg(t,e,n){if(!Ud(e)&&!hn(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return Ml(t,e,n)}function Kt(t,e,n){if(!Ud(e)&&!hn(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return wg(t,e,n)}function kn(t){return Xc("where",t)}function bh(t){return Xc("having",t)}function Nh(t){return Xc("on",t)}function rp(t){return Xc("when",t)}function Xc(t,e){if(e.length===3)return gg(e[0],e[1],e[2]);if(e.length===1)return vg(t,e[0]);throw ip(t,e)}function bg(t,e){return(t==="is"||t==="is not")&&(Ld(e)||Dd(e))}function Ng(t,e,n){return Hc.create(Fr(t),Ef(e),qr.createImmediate(n))}function Ef(t){if(hr(t)&&Pw.includes(t))return yf.create(t);if(hn(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function vg(t,e){if(jn(e)){if(t==="when")throw new Error("when method doesn't accept a callback as an argument");return _g[t](e)}else if(hn(e)){const n=e.toOperationNode();if(en.is(n)||Hc.is(n)||Vd.is(n)||js.is(n)||lr.is(n))return n}else if(t==="when")return qr.create(e);throw ip(t,e)}function ip(t,e){return new Error(`invalid arguments passed to a '${t}' method: ${JSON.stringify(e)}`)}const _g=p({where(t){const e=gh(),n=Pr(),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 js.create(a.where.where)}else return a},having(t){const e=gh(),n=Pr(),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 js.create(a.having.having)}else return a},on(t){const e=np("InnerJoin","table"),n=Pr(),a=t(Object.assign(e,n)).toOperationNode();if($n.is(a)){if(!a.on)throw new Error("no `on` methods called inside a group callback");return js.create(a.on.on)}else return a}});function vn(t,e){if(e.length===3)return Eg(t,e[0],e[1],e[2]);if(e.length===2)return xg(t,e[0],e[1]);throw new Error("not implemented")}function xg(t,e,n){return n(np(t,e)).toOperationNode()}function Eg(t,e,n,i){return $n.createWithOn(t,_a(e),Kt(n,"=",i))}const Cg=p({is(t){return t.kind==="OffsetNode"},create(t){return p({kind:"OffsetNode",offset:qr.create(t)})}}),qg=p({is(t){return t.kind==="GroupByItemNode"},create(t){return p({kind:"GroupByItemNode",groupBy:t})}});function Og(t){return t=jn(t)?t(Pr()):t,ba(t).map(qg.create)}const sp=p({is(t){return t.kind==="SetOperationNode"},create(t,e,n){return p({kind:"SetOperationNode",operator:t,expression:e,all:n})}});function Ts(t,e,n){return sp.create(t,e.toOperationNode(),n)}var U;const he=class{constructor(e){F(this,U,void 0);J(this,U,p(e))}get expressionType(){}where(...e){return new he({...r(this,U),queryNode:ye.cloneWithWhere(r(this,U).queryNode,kn(e))})}whereRef(e,n,i){return new he({...r(this,U),queryNode:ye.cloneWithWhere(r(this,U).queryNode,Kt(e,n,i))})}orWhere(...e){return new he({...r(this,U),queryNode:ye.cloneWithOrWhere(r(this,U).queryNode,kn(e))})}orWhereRef(e,n,i){return new he({...r(this,U),queryNode:ye.cloneWithOrWhere(r(this,U).queryNode,Kt(e,n,i))})}whereExists(e){return new he({...r(this,U),queryNode:ye.cloneWithWhere(r(this,U).queryNode,sn(e))})}whereNotExists(e){return new he({...r(this,U),queryNode:ye.cloneWithWhere(r(this,U).queryNode,zt(e))})}orWhereExists(e){return new he({...r(this,U),queryNode:ye.cloneWithOrWhere(r(this,U).queryNode,sn(e))})}orWhereNotExists(e){return new he({...r(this,U),queryNode:ye.cloneWithOrWhere(r(this,U).queryNode,zt(e))})}having(...e){return new he({...r(this,U),queryNode:We.cloneWithHaving(r(this,U).queryNode,bh(e))})}havingRef(e,n,i){return new he({...r(this,U),queryNode:We.cloneWithHaving(r(this,U).queryNode,Kt(e,n,i))})}orHaving(...e){return new he({...r(this,U),queryNode:We.cloneWithOrHaving(r(this,U).queryNode,bh(e))})}orHavingRef(e,n,i){return new he({...r(this,U),queryNode:We.cloneWithOrHaving(r(this,U).queryNode,Kt(e,n,i))})}havingExists(e){return new he({...r(this,U),queryNode:We.cloneWithHaving(r(this,U).queryNode,sn(e))})}havingNotExist(e){return new he({...r(this,U),queryNode:We.cloneWithHaving(r(this,U).queryNode,zt(e))})}havingNotExists(e){return new he({...r(this,U),queryNode:We.cloneWithHaving(r(this,U).queryNode,zt(e))})}orHavingExists(e){return new he({...r(this,U),queryNode:We.cloneWithOrHaving(r(this,U).queryNode,sn(e))})}orHavingNotExists(e){return new he({...r(this,U),queryNode:We.cloneWithOrHaving(r(this,U).queryNode,zt(e))})}select(e){return new he({...r(this,U),queryNode:We.cloneWithSelections(r(this,U).queryNode,Ja(e))})}distinctOn(e){return new he({...r(this,U),queryNode:We.cloneWithDistinctOn(r(this,U).queryNode,ba(e))})}modifyFront(e){return new he({...r(this,U),queryNode:We.cloneWithFrontModifier(r(this,U).queryNode,Ir.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new he({...r(this,U),queryNode:We.cloneWithEndModifier(r(this,U).queryNode,Ir.createWithExpression(e.toOperationNode()))})}distinct(){return new he({...r(this,U),queryNode:We.cloneWithFrontModifier(r(this,U).queryNode,Ir.create("Distinct"))})}forUpdate(){return new he({...r(this,U),queryNode:We.cloneWithEndModifier(r(this,U).queryNode,Ir.create("ForUpdate"))})}forShare(){return new he({...r(this,U),queryNode:We.cloneWithEndModifier(r(this,U).queryNode,Ir.create("ForShare"))})}forKeyShare(){return new he({...r(this,U),queryNode:We.cloneWithEndModifier(r(this,U).queryNode,Ir.create("ForKeyShare"))})}forNoKeyUpdate(){return new he({...r(this,U),queryNode:We.cloneWithEndModifier(r(this,U).queryNode,Ir.create("ForNoKeyUpdate"))})}skipLocked(){return new he({...r(this,U),queryNode:We.cloneWithEndModifier(r(this,U).queryNode,Ir.create("SkipLocked"))})}noWait(){return new he({...r(this,U),queryNode:We.cloneWithEndModifier(r(this,U).queryNode,Ir.create("NoWait"))})}selectAll(e){return new he({...r(this,U),queryNode:We.cloneWithSelections(r(this,U).queryNode,Ga(e))})}innerJoin(...e){return new he({...r(this,U),queryNode:ye.cloneWithJoin(r(this,U).queryNode,vn("InnerJoin",e))})}leftJoin(...e){return new he({...r(this,U),queryNode:ye.cloneWithJoin(r(this,U).queryNode,vn("LeftJoin",e))})}rightJoin(...e){return new he({...r(this,U),queryNode:ye.cloneWithJoin(r(this,U).queryNode,vn("RightJoin",e))})}fullJoin(...e){return new he({...r(this,U),queryNode:ye.cloneWithJoin(r(this,U).queryNode,vn("FullJoin",e))})}innerJoinLateral(...e){return new he({...r(this,U),queryNode:ye.cloneWithJoin(r(this,U).queryNode,vn("LateralInnerJoin",e))})}leftJoinLateral(...e){return new he({...r(this,U),queryNode:ye.cloneWithJoin(r(this,U).queryNode,vn("LateralLeftJoin",e))})}orderBy(e,n){return new he({...r(this,U),queryNode:We.cloneWithOrderByItem(r(this,U).queryNode,zc(e,n))})}groupBy(e){return new he({...r(this,U),queryNode:We.cloneWithGroupByItems(r(this,U).queryNode,Og(e))})}limit(e){return new he({...r(this,U),queryNode:We.cloneWithLimit(r(this,U).queryNode,Gd.create(e))})}offset(e){return new he({...r(this,U),queryNode:We.cloneWithOffset(r(this,U).queryNode,Cg.create(e))})}union(e){return new he({...r(this,U),queryNode:We.cloneWithSetOperation(r(this,U).queryNode,Ts("union",e,!1))})}unionAll(e){return new he({...r(this,U),queryNode:We.cloneWithSetOperation(r(this,U).queryNode,Ts("union",e,!0))})}intersect(e){return new he({...r(this,U),queryNode:We.cloneWithSetOperation(r(this,U).queryNode,Ts("intersect",e,!1))})}intersectAll(e){return new he({...r(this,U),queryNode:We.cloneWithSetOperation(r(this,U).queryNode,Ts("intersect",e,!0))})}except(e){return new he({...r(this,U),queryNode:We.cloneWithSetOperation(r(this,U).queryNode,Ts("except",e,!1))})}exceptAll(e){return new he({...r(this,U),queryNode:We.cloneWithSetOperation(r(this,U).queryNode,Ts("except",e,!0))})}as(e){return new Wg(this,e)}clearSelect(){return new he({...r(this,U),queryNode:We.cloneWithoutSelections(r(this,U).queryNode)})}clearWhere(){return new he({...r(this,U),queryNode:ye.cloneWithoutWhere(r(this,U).queryNode)})}clearLimit(){return new he({...r(this,U),queryNode:We.cloneWithoutLimit(r(this,U).queryNode)})}clearOffset(){return new he({...r(this,U),queryNode:We.cloneWithoutOffset(r(this,U).queryNode)})}clearOrderBy(){return new he({...r(this,U),queryNode:We.cloneWithoutOrderBy(r(this,U).queryNode)})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,n){return e?n(this):new he({...r(this,U)})}if(e,n){return this.$if(e,n)}$castTo(){return new he(r(this,U))}castTo(){return this.$castTo()}$narrowType(){return new he(r(this,U))}$assertType(){return new he(r(this,U))}assertType(){return new he(r(this,U))}withPlugin(e){return new he({...r(this,U),executor:r(this,U).executor.withPlugin(e)})}toOperationNode(){return r(this,U).executor.transformQuery(r(this,U).queryNode,r(this,U).queryId)}compile(){return r(this,U).executor.compileQuery(this.toOperationNode(),r(this,U).queryId)}async execute(){const e=this.compile();return(await r(this,U).executor.executeQuery(e,r(this,U).queryId)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Kc){const n=await this.executeTakeFirst();if(n===void 0)throw Jc(e)?new e(this.toOperationNode()):e(this.toOperationNode());return n}async*stream(e=100){const n=this.compile(),i=r(this,U).executor.stream(n,e,r(this,U).queryId);for await(const a of i)yield*a.rows}async explain(e,n){return await new he({...r(this,U),queryNode:ye.cloneWithExplain(r(this,U).queryNode,e,n)}).execute()}};let vo=he;U=new WeakMap;Qe(vo,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");var Gs,Xs;class Wg{constructor(e,n){F(this,Gs,void 0);F(this,Xs,void 0);J(this,Gs,e),J(this,Xs,n)}get expression(){return r(this,Gs)}get alias(){return r(this,Xs)}toOperationNode(){return fs.create(r(this,Gs).toOperationNode(),yt.create(r(this,Xs)))}}Gs=new WeakMap,Xs=new WeakMap;var Ys;const Wf=class{constructor(e){F(this,Ys,void 0);J(this,Ys,e)}get expressionType(){}as(e){return new Ig(this,e)}$castTo(){return new Wf(r(this,Ys))}toOperationNode(){return r(this,Ys)}};let Lt=Wf;Ys=new WeakMap;var Zs,ii;class Ig{constructor(e,n){F(this,Zs,void 0);F(this,ii,void 0);J(this,Zs,e),J(this,ii,n)}get expression(){return r(this,Zs)}get alias(){return r(this,ii)}toOperationNode(){return fs.create(r(this,Zs).toOperationNode(),hn(r(this,ii))?r(this,ii).toOperationNode():yt.create(r(this,ii)))}}Zs=new WeakMap,ii=new WeakMap;const Bn=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})}}),Ag=p({is(t){return t.kind==="FunctionNode"},create(t,e){return p({kind:"FunctionNode",func:t,arguments:e})}});var ot;const Fn=class{constructor(e){F(this,ot,void 0);J(this,ot,p(e))}get expressionType(){}as(e){return new Tg(this,e)}distinct(){return new Fn({...r(this,ot),aggregateFunctionNode:Bn.cloneWithDistinct(r(this,ot).aggregateFunctionNode)})}filterWhere(...e){return new Fn({...r(this,ot),aggregateFunctionNode:Bn.cloneWithFilter(r(this,ot).aggregateFunctionNode,kn(e))})}filterWhereExists(e){return new Fn({...r(this,ot),aggregateFunctionNode:Bn.cloneWithFilter(r(this,ot).aggregateFunctionNode,sn(e))})}filterWhereNotExists(e){return new Fn({...r(this,ot),aggregateFunctionNode:Bn.cloneWithFilter(r(this,ot).aggregateFunctionNode,zt(e))})}filterWhereRef(e,n,i){return new Fn({...r(this,ot),aggregateFunctionNode:Bn.cloneWithFilter(r(this,ot).aggregateFunctionNode,Kt(e,n,i))})}orFilterWhere(...e){return new Fn({...r(this,ot),aggregateFunctionNode:Bn.cloneWithOrFilter(r(this,ot).aggregateFunctionNode,kn(e))})}orFilterWhereExists(e){return new Fn({...r(this,ot),aggregateFunctionNode:Bn.cloneWithOrFilter(r(this,ot).aggregateFunctionNode,sn(e))})}orFilterWhereNotExists(e){return new Fn({...r(this,ot),aggregateFunctionNode:Bn.cloneWithOrFilter(r(this,ot).aggregateFunctionNode,zt(e))})}orFilterWhereRef(e,n,i){return new Fn({...r(this,ot),aggregateFunctionNode:Bn.cloneWithOrFilter(r(this,ot).aggregateFunctionNode,Kt(e,n,i))})}over(e){const n=yg();return new Fn({...r(this,ot),aggregateFunctionNode:Bn.cloneWithOver(r(this,ot).aggregateFunctionNode,(e?e(n):n).toOperationNode())})}$call(e){return e(this)}toOperationNode(){return r(this,ot).aggregateFunctionNode}};let va=Fn;ot=new WeakMap;Qe(va,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");var eo,to;class Tg{constructor(e,n){F(this,eo,void 0);F(this,to,void 0);J(this,eo,e),J(this,to,n)}get expression(){return r(this,eo)}get alias(){return r(this,to)}toOperationNode(){return fs.create(r(this,eo).toOperationNode(),yt.create(r(this,to)))}}eo=new WeakMap,to=new WeakMap;function op(){const t=(n,i)=>new Lt(Ag.create(n,ba(i))),e=(n,i)=>new va({aggregateFunctionNode:Bn.create(n,i?ba(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 va({aggregateFunctionNode:Bn.create("count",Ga(n))})},max(n){return e("max",[n])},min(n){return e("min",[n])},sum(n){return e("sum",[n])}})}var no;class ap{constructor(e){F(this,no,void 0);J(this,no,p(e))}when(...e){return new up({...r(this,no),node:lr.cloneWithWhen(r(this,no).node,xf.create(rp(e)))})}}no=new WeakMap;var ro;class up{constructor(e){F(this,ro,void 0);J(this,ro,p(e))}then(e){return new kg({...r(this,ro),node:lr.cloneWithThen(r(this,ro).node,Lr(e))})}}ro=new WeakMap;var br;class kg{constructor(e){F(this,br,void 0);J(this,br,p(e))}when(...e){return new up({...r(this,br),node:lr.cloneWithWhen(r(this,br).node,xf.create(rp(e)))})}else(e){return new Sg({...r(this,br),node:lr.cloneWith(r(this,br).node,{else:Lr(e)})})}end(){return new Lt(lr.cloneWith(r(this,br).node,{isStatement:!1}))}endCase(){return new Lt(lr.cloneWith(r(this,br).node,{isStatement:!0}))}}br=new WeakMap;var io;class Sg{constructor(e){F(this,io,void 0);J(this,io,p(e))}end(){return new Lt(lr.cloneWith(r(this,io).node,{isStatement:!1}))}endCase(){return new Lt(lr.cloneWith(r(this,io).node,{isStatement:!0}))}}io=new WeakMap;function cp(t=Gc){function e(n,i){return new Lt(Nf(n,i))}return{get fn(){return op()},selectFrom(n){return new vo({queryId:tt(),executor:t,queryNode:We.create(_o(n))})},case(n){return new ap({node:lr.create(ra(n)?void 0:Fr(n))})},ref(n){return new Lt(bo(n))},val(n){return new Lt(Hd(n))},cmpr(n,i,a){return new Lt(Ml(n,i,a))},bxp(n,i,a){return new Lt(Ml(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 Lt(qr.createImmediate(!0));if(n.length===1)return new Lt(n[0].toOperationNode());let i=wa.create(n[0].toOperationNode(),n[1].toOperationNode());for(let a=2;a_a(e)):[_a(t)]}function _a(t){return hr(t)?Rg(t):lp(t)}function Rg(t){const e=" as ";if(t.includes(e)){const[n,i]=t.split(e).map(fp);return fs.create(_n(n),yt.create(i))}else return _n(t)}function _n(t){const e=".";if(t.includes(e)){const[n,i]=t.split(e).map(fp);return di.createWithSchema(n,i)}else return di.create(t)}function fp(t){return t.trim()}const hp=p({is(t){return t.kind==="AddColumnNode"},create(t){return p({kind:"AddColumnNode",column:t})}}),ji=p({is(t){return t.kind==="AlterColumnNode"},create(t){return p({kind:"AlterColumnNode",column:vt.create(t)})},cloneWith(t,e){return p({...t,...e})}}),Nt=p({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return p({kind:"ColumnDefinitionNode",column:vt.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})}}),dp=p({is(t){return t.kind==="DropColumnNode"},create(t){return p({kind:"DropColumnNode",column:vt.create(t)})}}),pp=p({is(t){return t.kind==="RenameColumnNode"},create(t,e){return p({kind:"RenameColumnNode",column:vt.create(t),renameTo:vt.create(e)})}}),Cf=p({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return p({kind:"CheckConstraintNode",expression:t,name:e?yt.create(e):void 0})}}),Dg=["no action","restrict","cascade","set null","set default"],Tu=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 mp(t){return hn(t)?t.toOperationNode():qr.createImmediate(t)}const Eu=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})}}),Lg=p({is(t){return t.kind==="DefaultValueNode"},create(t){return p({kind:"DefaultValueNode",defaultValue:t})}});function Gu(t){if(Dg.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}var Ze;const St=class{constructor(e){F(this,Ze,void 0);J(this,Ze,e)}autoIncrement(){return new St(Nt.cloneWith(r(this,Ze),{autoIncrement:!0}))}primaryKey(){return new St(Nt.cloneWith(r(this,Ze),{primaryKey:!0}))}references(e){const n=bo(e);if(!Vc.is(n)||wf.is(n.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new St(Nt.cloneWith(r(this,Ze),{references:Tu.create(n.table,[n.column])}))}onDelete(e){if(!r(this,Ze).references)throw new Error("on delete constraint can only be added for foreign keys");return new St(Nt.cloneWith(r(this,Ze),{references:Tu.cloneWithOnDelete(r(this,Ze).references,Gu(e))}))}onUpdate(e){if(!r(this,Ze).references)throw new Error("on update constraint can only be added for foreign keys");return new St(Nt.cloneWith(r(this,Ze),{references:Tu.cloneWithOnUpdate(r(this,Ze).references,Gu(e))}))}unique(){return new St(Nt.cloneWith(r(this,Ze),{unique:!0}))}notNull(){return new St(Nt.cloneWith(r(this,Ze),{notNull:!0}))}unsigned(){return new St(Nt.cloneWith(r(this,Ze),{unsigned:!0}))}defaultTo(e){return new St(Nt.cloneWith(r(this,Ze),{defaultTo:Lg.create(mp(e))}))}check(e){return new St(Nt.cloneWith(r(this,Ze),{check:Cf.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new St(Nt.cloneWith(r(this,Ze),{generated:Eu.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new St(Nt.cloneWith(r(this,Ze),{generated:Eu.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new St(Nt.cloneWith(r(this,Ze),{generated:Eu.create({identity:!0,byDefault:!0})}))}stored(){if(!r(this,Ze).generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new St(Nt.cloneWith(r(this,Ze),{generated:Eu.cloneWith(r(this,Ze).generated,{stored:!0})}))}modifyFront(e){return new St(Nt.cloneWithFrontModifier(r(this,Ze),e.toOperationNode()))}modifyEnd(e){return new St(Nt.cloneWithEndModifier(r(this,Ze),e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return r(this,Ze)}};let wi=St;Ze=new WeakMap;Qe(wi,"don't await ColumnDefinitionBuilder instances directly.");const yp=p({is(t){return t.kind==="ModifyColumnNode"},create(t){return p({kind:"ModifyColumnNode",column:t})}}),Pg=p({is(t){return t.kind==="DataTypeNode"},create(t){return p({kind:"DataTypeNode",dataType:t})}});function xo(t){return hn(t)?t.toOperationNode():Pg.create(t)}const Xu=p({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,n,i){return p({kind:"ForeignKeyConstraintNode",columns:t,references:Tu.create(e,n),name:i?yt.create(i):void 0})},cloneWith(t,e){return p({...t,...e})}});var Zi;const yc=class{constructor(e){F(this,Zi,void 0);J(this,Zi,e)}onDelete(e){return new yc(Xu.cloneWith(r(this,Zi),{onDelete:Gu(e)}))}onUpdate(e){return new yc(Xu.cloneWith(r(this,Zi),{onUpdate:Gu(e)}))}$call(e){return e(this)}toOperationNode(){return r(this,Zi)}};let xa=yc;Zi=new WeakMap;Qe(xa,"don't await ForeignKeyConstraintBuilder instances directly.");const Bl=p({is(t){return t.kind==="AddConstraintNode"},create(t){return p({kind:"AddConstraintNode",constraint:t})}}),wp=p({is(t){return t.kind==="UniqueConstraintNode"},create(t,e){return p({kind:"UniqueConstraintNode",columns:p(t.map(vt.create)),name:e?yt.create(e):void 0})}}),ku=p({is(t){return t.kind==="DropConstraintNode"},create(t){return p({kind:"DropConstraintNode",constraintName:yt.create(t)})},cloneWith(t,e){return p({...t,...e})}});class el{constructor(e){Te(this,"alterColumnNode");this.alterColumnNode=e}setDataType(e){return new Xo(ji.cloneWith(this.alterColumnNode,{dataType:xo(e)}))}setDefault(e){return new Xo(ji.cloneWith(this.alterColumnNode,{setDefault:mp(e)}))}dropDefault(){return new Xo(ji.cloneWith(this.alterColumnNode,{dropDefault:!0}))}setNotNull(){return new Xo(ji.cloneWith(this.alterColumnNode,{setNotNull:!0}))}dropNotNull(){return new Xo(ji.cloneWith(this.alterColumnNode,{dropNotNull:!0}))}$call(e){return e(this)}}class Xo extends el{toOperationNode(){return this.alterColumnNode}}var nr;class ea{constructor(e){F(this,nr,void 0);J(this,nr,p(e))}toOperationNode(){return r(this,nr).executor.transformQuery(r(this,nr).node,r(this,nr).queryId)}compile(){return r(this,nr).executor.compileQuery(this.toOperationNode(),r(this,nr).queryId)}async execute(){await r(this,nr).executor.executeQuery(this.compile(),r(this,nr).queryId)}}nr=new WeakMap;Qe(ea,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");var Zt;const wc=class{constructor(e){F(this,Zt,void 0);J(this,Zt,p(e))}onDelete(e){return new wc({...r(this,Zt),constraintBuilder:r(this,Zt).constraintBuilder.onDelete(e)})}onUpdate(e){return new wc({...r(this,Zt),constraintBuilder:r(this,Zt).constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return r(this,Zt).executor.transformQuery(Ct.cloneWithTableProps(r(this,Zt).node,{addConstraint:Bl.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 Yu=wc;Zt=new WeakMap;Qe(Yu,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");var xt;const oa=class{constructor(e){F(this,xt,void 0);J(this,xt,p(e))}ifExists(){return new oa({...r(this,xt),node:Ct.cloneWithTableProps(r(this,xt).node,{dropConstraint:ku.cloneWith(r(this,xt).node.dropConstraint,{ifExists:!0})})})}cascade(){return new oa({...r(this,xt),node:Ct.cloneWithTableProps(r(this,xt).node,{dropConstraint:ku.cloneWith(r(this,xt).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new oa({...r(this,xt),node:Ct.cloneWithTableProps(r(this,xt).node,{dropConstraint:ku.cloneWith(r(this,xt).node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return r(this,xt).executor.transformQuery(r(this,xt).node,r(this,xt).queryId)}compile(){return r(this,xt).executor.compileQuery(this.toOperationNode(),r(this,xt).queryId)}async execute(){await r(this,xt).executor.executeQuery(this.compile(),r(this,xt).queryId)}};let Zu=oa;xt=new WeakMap;Qe(Zu,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");var at;class gp{constructor(e){F(this,at,void 0);J(this,at,p(e))}renameTo(e){return new ea({...r(this,at),node:Ct.cloneWithTableProps(r(this,at).node,{renameTo:_n(e)})})}setSchema(e){return new ea({...r(this,at),node:Ct.cloneWithTableProps(r(this,at).node,{setSchema:yt.create(e)})})}alterColumn(e,n){const i=n(new el(ji.create(e)));return new ri({...r(this,at),node:Ct.cloneWithColumnAlteration(r(this,at).node,i.toOperationNode())})}dropColumn(e){return new ri({...r(this,at),node:Ct.cloneWithColumnAlteration(r(this,at).node,dp.create(e))})}renameColumn(e,n){return new ri({...r(this,at),node:Ct.cloneWithColumnAlteration(r(this,at).node,pp.create(e,n))})}addColumn(e,n,i=go){const a=i(new wi(Nt.create(e,xo(n))));return new ri({...r(this,at),node:Ct.cloneWithColumnAlteration(r(this,at).node,hp.create(a.toOperationNode()))})}modifyColumn(e,n,i=go){const a=i(new wi(Nt.create(e,xo(n))));return new ri({...r(this,at),node:Ct.cloneWithColumnAlteration(r(this,at).node,yp.create(a.toOperationNode()))})}addUniqueConstraint(e,n){return new ea({...r(this,at),node:Ct.cloneWithTableProps(r(this,at).node,{addConstraint:Bl.create(wp.create(n,e))})})}addCheckConstraint(e,n){return new ea({...r(this,at),node:Ct.cloneWithTableProps(r(this,at).node,{addConstraint:Bl.create(Cf.create(n.toOperationNode(),e))})})}addForeignKeyConstraint(e,n,i,a){return new Yu({...r(this,at),constraintBuilder:new xa(Xu.create(n.map(vt.create),_n(i),a.map(vt.create),e))})}dropConstraint(e){return new Zu({...r(this,at),node:Ct.cloneWithTableProps(r(this,at).node,{dropConstraint:ku.create(e)})})}$call(e){return e(this)}call(e){return this.$call(e)}}at=new WeakMap;var bt;const zi=class{constructor(e){F(this,bt,void 0);J(this,bt,p(e))}alterColumn(e,n){const i=n(new el(ji.create(e)));return new zi({...r(this,bt),node:Ct.cloneWithColumnAlteration(r(this,bt).node,i.toOperationNode())})}dropColumn(e){return new zi({...r(this,bt),node:Ct.cloneWithColumnAlteration(r(this,bt).node,dp.create(e))})}renameColumn(e,n){return new zi({...r(this,bt),node:Ct.cloneWithColumnAlteration(r(this,bt).node,pp.create(e,n))})}addColumn(e,n,i=go){const a=i(new wi(Nt.create(e,xo(n))));return new zi({...r(this,bt),node:Ct.cloneWithColumnAlteration(r(this,bt).node,hp.create(a.toOperationNode()))})}modifyColumn(e,n,i=go){const a=i(new wi(Nt.create(e,xo(n))));return new zi({...r(this,bt),node:Ct.cloneWithColumnAlteration(r(this,bt).node,yp.create(a.toOperationNode()))})}toOperationNode(){return r(this,bt).executor.transformQuery(r(this,bt).node,r(this,bt).queryId)}compile(){return r(this,bt).executor.compileQuery(this.toOperationNode(),r(this,bt).queryId)}async execute(){await r(this,bt).executor.executeQuery(this.compile(),r(this,bt).queryId)}};let ri=zi;bt=new WeakMap;Qe(gp,"don't await AlterTableBuilder instances");Qe(el,"don't await AlterColumnBuilder instances");Qe(ri,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class bp extends _f{transformValue(e){return{...super.transformValue(e),immediate:!0}}}var et;const wr=class{constructor(e){F(this,et,void 0);J(this,et,p(e))}ifNotExists(){return new wr({...r(this,et),node:Yr.cloneWith(r(this,et).node,{ifNotExists:!0})})}unique(){return new wr({...r(this,et),node:Yr.cloneWith(r(this,et).node,{unique:!0})})}on(e){return new wr({...r(this,et),node:Yr.cloneWith(r(this,et).node,{table:_n(e)})})}column(e){return new wr({...r(this,et),node:Yr.cloneWithColumns(r(this,et).node,[oh(e)])})}columns(e){return new wr({...r(this,et),node:Yr.cloneWithColumns(r(this,et).node,e.map(oh))})}expression(e){return new wr({...r(this,et),node:Yr.cloneWithColumns(r(this,et).node,[e.toOperationNode()])})}using(e){return new wr({...r(this,et),node:Yr.cloneWith(r(this,et).node,{using:en.createWithSql(e)})})}where(...e){const n=new bp;return new wr({...r(this,et),node:ye.cloneWithWhere(r(this,et).node,n.transformNode(kn(e)))})}$call(e){return e(this)}toOperationNode(){return r(this,et).executor.transformQuery(r(this,et).node,r(this,et).queryId)}compile(){return r(this,et).executor.compileQuery(this.toOperationNode(),r(this,et).queryId)}async execute(){await r(this,et).executor.executeQuery(this.compile(),r(this,et).queryId)}};let ec=wr;et=new WeakMap;Qe(ec,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");var Wn;const If=class{constructor(e){F(this,Wn,void 0);J(this,Wn,p(e))}ifNotExists(){return new If({...r(this,Wn),node:Pd.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 tc=If;Wn=new WeakMap;Qe(tc,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");const Mg=p({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return p({kind:"PrimaryKeyConstraintNode",columns:p(t.map(vt.create)),name:e?yt.create(e):void 0})}});function Bg(t){if(Tw.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}var $e;const Un=class{constructor(e){F(this,$e,void 0);J(this,$e,p(e))}temporary(){return new Un({...r(this,$e),node:Xn.cloneWith(r(this,$e).node,{temporary:!0})})}onCommit(e){return new Un({...r(this,$e),node:Xn.cloneWith(r(this,$e).node,{onCommit:Bg(e)})})}ifNotExists(){return new Un({...r(this,$e),node:Xn.cloneWith(r(this,$e).node,{ifNotExists:!0})})}addColumn(e,n,i=go){const a=i(new wi(Nt.create(e,xo(n))));return new Un({...r(this,$e),node:Xn.cloneWithColumn(r(this,$e).node,a.toOperationNode())})}addPrimaryKeyConstraint(e,n){return new Un({...r(this,$e),node:Xn.cloneWithConstraint(r(this,$e).node,Mg.create(n,e))})}addUniqueConstraint(e,n){return new Un({...r(this,$e),node:Xn.cloneWithConstraint(r(this,$e).node,wp.create(n,e))})}addCheckConstraint(e,n){return new Un({...r(this,$e),node:Xn.cloneWithConstraint(r(this,$e).node,Cf.create(n.toOperationNode(),e))})}addForeignKeyConstraint(e,n,i,a,l=go){const m=l(new xa(Xu.create(n.map(vt.create),_n(i),a.map(vt.create),e)));return new Un({...r(this,$e),node:Xn.cloneWithConstraint(r(this,$e).node,m.toOperationNode())})}modifyFront(e){return new Un({...r(this,$e),node:Xn.cloneWithFrontModifier(r(this,$e).node,e.toOperationNode())})}modifyEnd(e){return new Un({...r(this,$e),node:Xn.cloneWithEndModifier(r(this,$e).node,e.toOperationNode())})}$call(e){return e(this)}call(e){return this.$call(e)}toOperationNode(){return r(this,$e).executor.transformQuery(r(this,$e).node,r(this,$e).queryId)}compile(){return r(this,$e).executor.compileQuery(this.toOperationNode(),r(this,$e).queryId)}async execute(){await r(this,$e).executor.executeQuery(this.compile(),r(this,$e).queryId)}};let nc=Un;$e=new WeakMap;Qe(nc,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");var $t;const aa=class{constructor(e){F(this,$t,void 0);J(this,$t,p(e))}on(e){return new aa({...r(this,$t),node:Au.cloneWith(r(this,$t).node,{table:_n(e)})})}ifExists(){return new aa({...r(this,$t),node:Au.cloneWith(r(this,$t).node,{ifExists:!0})})}cascade(){return new aa({...r(this,$t),node:Au.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 rc=aa;$t=new WeakMap;Qe(rc,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");var ln;const gc=class{constructor(e){F(this,ln,void 0);J(this,ln,p(e))}ifExists(){return new gc({...r(this,ln),node:Sl.cloneWith(r(this,ln).node,{ifExists:!0})})}cascade(){return new gc({...r(this,ln),node:Sl.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 ic=gc;ln=new WeakMap;Qe(ic,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");var fn;const bc=class{constructor(e){F(this,fn,void 0);J(this,fn,p(e))}ifExists(){return new bc({...r(this,fn),node:Rl.cloneWith(r(this,fn).node,{ifExists:!0})})}cascade(){return new bc({...r(this,fn),node:Rl.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 sc=bc;fn=new WeakMap;Qe(sc,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");const ti=p({is(t){return t.kind==="CreateViewNode"},create(t){return p({kind:"CreateViewNode",name:yi.create(t)})},cloneWith(t,e){return p({...t,...e})}});var Nc;class Fg{constructor(){F(this,Nc,new bp)}transformQuery(e){return r(this,Nc).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}Nc=new WeakMap;var pt;const ni=class{constructor(e){F(this,pt,void 0);J(this,pt,p(e))}temporary(){return new ni({...r(this,pt),node:ti.cloneWith(r(this,pt).node,{temporary:!0})})}materialized(){return new ni({...r(this,pt),node:ti.cloneWith(r(this,pt).node,{materialized:!0})})}ifNotExists(){return new ni({...r(this,pt),node:ti.cloneWith(r(this,pt).node,{ifNotExists:!0})})}orReplace(){return new ni({...r(this,pt),node:ti.cloneWith(r(this,pt).node,{orReplace:!0})})}columns(e){return new ni({...r(this,pt),node:ti.cloneWith(r(this,pt).node,{columns:e.map(Qd)})})}as(e){const n=e.withPlugin(new Fg).toOperationNode();return new ni({...r(this,pt),node:ti.cloneWith(r(this,pt).node,{as:n})})}$call(e){return e(this)}toOperationNode(){return r(this,pt).executor.transformQuery(r(this,pt).node,r(this,pt).queryId)}compile(){return r(this,pt).executor.compileQuery(this.toOperationNode(),r(this,pt).queryId)}async execute(){await r(this,pt).executor.executeQuery(this.compile(),r(this,pt).queryId)}};let oc=ni;pt=new WeakMap;Qe(oc,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const Su=p({is(t){return t.kind==="DropViewNode"},create(t){return p({kind:"DropViewNode",name:yi.create(t)})},cloneWith(t,e){return p({...t,...e})}});var Qt;const ua=class{constructor(e){F(this,Qt,void 0);J(this,Qt,p(e))}materialized(){return new ua({...r(this,Qt),node:Su.cloneWith(r(this,Qt).node,{materialized:!0})})}ifExists(){return new ua({...r(this,Qt),node:Su.cloneWith(r(this,Qt).node,{ifExists:!0})})}cascade(){return new ua({...r(this,Qt),node:Su.cloneWith(r(this,Qt).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return r(this,Qt).executor.transformQuery(r(this,Qt).node,r(this,Qt).queryId)}compile(){return r(this,Qt).executor.compileQuery(this.toOperationNode(),r(this,Qt).queryId)}async execute(){await r(this,Qt).executor.executeQuery(this.compile(),r(this,Qt).queryId)}};let ac=ua;Qt=new WeakMap;Qe(ac,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const Np=p({is(t){return t.kind==="CreateTypeNode"},create(t){return p({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return p({...t,enum:bf.create(e.map(n=>qr.createImmediate(n)))})}});var In;const Af=class{constructor(e){F(this,In,void 0);J(this,In,p(e))}toOperationNode(){return r(this,In).executor.transformQuery(r(this,In).node,r(this,In).queryId)}asEnum(e){return new Af({...r(this,In),node:Np.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 uc=Af;In=new WeakMap;Qe(uc,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const vp=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 Tf=class{constructor(e){F(this,An,void 0);J(this,An,p(e))}ifExists(){return new Tf({...r(this,An),node:vp.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 cc=Tf;An=new WeakMap;Qe(cc,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function vh(t){const e=".";if(t.includes(e)){const n=t.split(e).map(Ug);if(n.length===2)return yi.createWithSchema(n[0],n[1]);throw new Error(`invalid schemable identifier ${t}`)}else return yi.create(t)}function Ug(t){return t.trim()}var Rt;const ca=class{constructor(e){F(this,Rt,void 0);J(this,Rt,e)}createTable(e){return new nc({queryId:tt(),executor:r(this,Rt),node:Xn.create(_n(e))})}dropTable(e){return new sc({queryId:tt(),executor:r(this,Rt),node:Rl.create(_n(e))})}createIndex(e){return new ec({queryId:tt(),executor:r(this,Rt),node:Yr.create(e)})}dropIndex(e){return new rc({queryId:tt(),executor:r(this,Rt),node:Au.create(e)})}createSchema(e){return new tc({queryId:tt(),executor:r(this,Rt),node:Pd.create(e)})}dropSchema(e){return new ic({queryId:tt(),executor:r(this,Rt),node:Sl.create(e)})}alterTable(e){return new gp({queryId:tt(),executor:r(this,Rt),node:Ct.create(_n(e))})}createView(e){return new oc({queryId:tt(),executor:r(this,Rt),node:ti.create(e)})}dropView(e){return new ac({queryId:tt(),executor:r(this,Rt),node:Su.create(e)})}createType(e){return new uc({queryId:tt(),executor:r(this,Rt),node:Np.create(vh(e))})}dropType(e){return new cc({queryId:tt(),executor:r(this,Rt),node:vp.create(vh(e))})}withPlugin(e){return new ca(r(this,Rt).withPlugin(e))}withoutPlugins(){return new ca(r(this,Rt).withoutPlugins())}withSchema(e){return new ca(r(this,Rt).withPluginAtFront(new Xa(e)))}};let Fl=ca;Rt=new WeakMap;class $g{ref(e){return new Kw(e)}}var so;class Qg{constructor(e){F(this,so,void 0);J(this,so,e)}async provideConnection(e){const n=await r(this,so).acquireConnection();try{return await e(n)}finally{await r(this,so).releaseConnection(n)}}}so=new WeakMap;var Nr,vr,kr;const Ki=class extends tp{constructor(n,i,a,l=[]){super(l);F(this,Nr,void 0);F(this,vr,void 0);F(this,kr,void 0);J(this,Nr,n),J(this,vr,i),J(this,kr,a)}get adapter(){return r(this,vr)}compileQuery(n){return r(this,Nr).compileQuery(n)}provideConnection(n){return r(this,kr).provideConnection(n)}withPlugins(n){return new Ki(r(this,Nr),r(this,vr),r(this,kr),[...this.plugins,...n])}withPlugin(n){return new Ki(r(this,Nr),r(this,vr),r(this,kr),[...this.plugins,n])}withPluginAtFront(n){return new Ki(r(this,Nr),r(this,vr),r(this,kr),[n,...this.plugins])}withConnectionProvider(n){return new Ki(r(this,Nr),r(this,vr),n,[...this.plugins])}withoutPlugins(){return new Ki(r(this,Nr),r(this,vr),r(this,kr),[])}};let Ul=Ki;Nr=new WeakMap,vr=new WeakMap,kr=new WeakMap;function _h(){return typeof performance<"u"&&jn(performance.now)?performance.now():Date.now()}var rr,si,Sr,es,Ra,vc,_p,_c,xp,xc,Ep,Ec,Cp,Da,$l;class jg{constructor(e,n){F(this,vc);F(this,_c);F(this,xc);F(this,Ec);F(this,Da);F(this,rr,void 0);F(this,si,void 0);F(this,Sr,void 0);F(this,es,void 0);F(this,Ra,new WeakSet);J(this,rr,e),J(this,si,n)}async init(){r(this,Sr)||J(this,Sr,r(this,rr).init().catch(e=>(J(this,Sr,void 0),Promise.reject(e)))),await r(this,Sr)}async acquireConnection(){await this.init();const e=await r(this,rr).acquireConnection();return r(this,Ra).has(e)||(Oe(this,vc,_p).call(this)&&Oe(this,_c,xp).call(this,e),r(this,Ra).add(e)),e}async releaseConnection(e){await r(this,rr).releaseConnection(e)}beginTransaction(e,n){return r(this,rr).beginTransaction(e,n)}commitTransaction(e){return r(this,rr).commitTransaction(e)}rollbackTransaction(e){return r(this,rr).rollbackTransaction(e)}async destroy(){r(this,Sr)&&(await r(this,Sr),r(this,es)||J(this,es,r(this,rr).destroy().catch(e=>(J(this,es,void 0),Promise.reject(e)))),await r(this,es))}}rr=new WeakMap,si=new WeakMap,Sr=new WeakMap,es=new WeakMap,Ra=new WeakMap,vc=new WeakSet,_p=function(){return r(this,si).isLevelEnabled("query")||r(this,si).isLevelEnabled("error")},_c=new WeakSet,xp=function(e){const n=e.executeQuery;e.executeQuery=async i=>{const a=_h();try{return await n.call(e,i)}catch(l){throw await Oe(this,xc,Ep).call(this,l,i,a),l}finally{await Oe(this,Ec,Cp).call(this,i,a)}}},xc=new WeakSet,Ep=async function(e,n,i){await r(this,si).error(()=>({level:"error",error:e,query:n,queryDurationMillis:Oe(this,Da,$l).call(this,i)}))},Ec=new WeakSet,Cp=async function(e,n){await r(this,si).query(()=>({level:"query",query:e,queryDurationMillis:Oe(this,Da,$l).call(this,n)}))},Da=new WeakSet,$l=function(e){return _h()-e};var La,oi,Cc,Op;class qp{constructor(e){F(this,Cc);F(this,La,void 0);F(this,oi,void 0);J(this,La,e)}async provideConnection(e){for(;r(this,oi);)await r(this,oi);const n=Oe(this,Cc,Op).call(this,e);return J(this,oi,n.then(()=>{J(this,oi,void 0)}).catch(()=>{J(this,oi,void 0)})),n}}La=new WeakMap,oi=new WeakMap,Cc=new WeakSet,Op=async function(e){return await e(r(this,La))};const Hg=["read uncommitted","read committed","repeatable read","serializable"];p(["query","error"]);var ai,ts;class Vg{constructor(e){F(this,ai,void 0);F(this,ts,void 0);jn(e)?(J(this,ts,e),J(this,ai,p({query:!0,error:!0}))):(J(this,ts,zg),J(this,ai,p({query:e.includes("query"),error:e.includes("error")})))}isLevelEnabled(e){return r(this,ai)[e]}async query(e){r(this,ai).query&&await r(this,ts).call(this,e())}async error(e){r(this,ai).error&&await r(this,ts).call(this,e())}}ai=new WeakMap,ts=new WeakMap;function zg(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 Kg(t){return Cr(t)&&jn(t.compile)}var jt;const Ms=class extends Ju{constructor(n){let i,a;if(Jg(n))i={executor:n.executor},a={...n};else{const l=n.dialect,m=l.createDriver(),w=l.createQueryCompiler(),v=l.createAdapter(),d=new Vg(n.log??[]),I=new jg(m,d),M=new Qg(I),B=new Ul(w,v,M,n.plugins??[]);i={executor:B},a={config:n,executor:B,dialect:l,driver:I}}super(i);F(this,jt,void 0);J(this,jt,p(a))}get schema(){return new Fl(r(this,jt).executor)}get dynamic(){return new $g}get introspection(){return r(this,jt).dialect.createIntrospector(this.withoutPlugins())}case(n){return new ap({node:lr.create(ra(n)?void 0:Yc(n))})}get fn(){return op()}transaction(){return new lc({...r(this,jt)})}connection(){return new Wp({...r(this,jt)})}withPlugin(n){return new Ms({...r(this,jt),executor:r(this,jt).executor.withPlugin(n)})}withoutPlugins(){return new Ms({...r(this,jt),executor:r(this,jt).executor.withoutPlugins()})}withSchema(n){return new Ms({...r(this,jt),executor:r(this,jt).executor.withPluginAtFront(new Xa(n))})}withTables(){return new Ms({...r(this,jt)})}async destroy(){await r(this,jt).driver.destroy()}get isTransaction(){return!1}getExecutor(){return r(this,jt).executor}executeQuery(n,i=tt()){const a=Kg(n)?n.compile():n;return this.getExecutor().executeQuery(a,i)}};let Ea=Ms;jt=new WeakMap;var ir;const Bs=class extends Ea{constructor(n){super(n);F(this,ir,void 0);J(this,ir,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 Bs({...r(this,ir),executor:r(this,ir).executor.withPlugin(n)})}withoutPlugins(){return new Bs({...r(this,ir),executor:r(this,ir).executor.withoutPlugins()})}withSchema(n){return new Bs({...r(this,ir),executor:r(this,ir).executor.withPluginAtFront(new Xa(n))})}withTables(){return new Bs({...r(this,ir)})}};let Ql=Bs;ir=new WeakMap;function Jg(t){return Cr(t)&&Cr(t.config)&&Cr(t.driver)&&Cr(t.executor)&&Cr(t.dialect)}var ns;class Wp{constructor(e){F(this,ns,void 0);J(this,ns,p(e))}async execute(e){return r(this,ns).executor.provideConnection(async n=>{const i=r(this,ns).executor.withConnectionProvider(new qp(n)),a=new Ea({...r(this,ns),executor:i});return await e(a)})}}ns=new WeakMap;Qe(Wp,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");var sr;const kf=class{constructor(e){F(this,sr,void 0);J(this,sr,p(e))}setIsolationLevel(e){return new kf({...r(this,sr),isolationLevel:e})}async execute(e){const{isolationLevel:n,...i}=r(this,sr),a={isolationLevel:n};return Gg(a),r(this,sr).executor.provideConnection(async l=>{const m=r(this,sr).executor.withConnectionProvider(new qp(l)),w=new Ql({...i,executor:m});try{await r(this,sr).driver.beginTransaction(l,a);const v=await e(w);return await r(this,sr).driver.commitTransaction(l),v}catch(v){throw await r(this,sr).driver.rollbackTransaction(l),v}})}};let lc=kf;sr=new WeakMap;Qe(lc,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function Gg(t){if(t.isolationLevel&&!Hg.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}var Nn,oo,Ru,Pa,jl,Ma,Hl;const qc=class{constructor(e){F(this,oo);F(this,Pa);F(this,Ma);F(this,Nn,void 0);J(this,Nn,p(e))}get expressionType(){}as(e){return new Xg(this,e)}$castTo(){return new qc({...r(this,Nn)})}castTo(){return this.$castTo()}withPlugin(e){return new qc({...r(this,Nn),plugins:r(this,Nn).plugins!==void 0?p([...r(this,Nn).plugins,e]):p([e])})}toOperationNode(){return Oe(this,Pa,jl).call(this,Oe(this,oo,Ru).call(this))}compile(e){return Oe(this,Ma,Hl).call(this,Oe(this,oo,Ru).call(this,e))}async execute(e){const n=Oe(this,oo,Ru).call(this,e);return n.executeQuery(Oe(this,Ma,Hl).call(this,n),r(this,Nn).queryId)}};let tr=qc;Nn=new WeakMap,oo=new WeakSet,Ru=function(e){const n=e!==void 0?e.getExecutor():Gc;return r(this,Nn).plugins!==void 0?n.withPlugins(r(this,Nn).plugins):n},Pa=new WeakSet,jl=function(e){return e.transformQuery(r(this,Nn).rawNode,r(this,Nn).queryId)},Ma=new WeakSet,Hl=function(e){return e.compileQuery(Oe(this,Pa,jl).call(this,e),r(this,Nn).queryId)};Qe(tr,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");var ao,ui;class Xg{constructor(e,n){F(this,ao,void 0);F(this,ui,void 0);J(this,ao,e),J(this,ui,n)}get expression(){return r(this,ao)}get alias(){return r(this,ui)}toOperationNode(){return fs.create(r(this,ao).toOperationNode(),hn(r(this,ui))?r(this,ui).toOperationNode():yt.create(r(this,ui)))}}ao=new WeakMap,ui=new WeakMap;const Tn=Object.assign((t,...e)=>new tr({queryId:tt(),rawNode:en.create(t,(e==null?void 0:e.map(Lr))??[])}),{ref(t){return new tr({queryId:tt(),rawNode:en.createWithChild(bo(t))})},val(t){return new tr({queryId:tt(),rawNode:en.createWithChild(Lr(t))})},value(t){return this.val(t)},table(t){return new tr({queryId:tt(),rawNode:en.createWithChild(_n(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",new tr({queryId:tt(),rawNode:en.create(e,t.map(yt.create))})},lit(t){return new tr({queryId:tt(),rawNode:en.createWithChild(qr.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return new tr({queryId:tt(),rawNode:en.createWithSql(t)})},join(t,e=Tn`, `){const n=new Array(2*t.length-1),i=e.toOperationNode();for(let a=0;a{this.nodeStack.push(e),r(this,Oc)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}Oc=new WeakMap;var uo,rs;class Zg extends Yg{constructor(){super(...arguments);F(this,uo,"");F(this,rs,[])}get numParameters(){return r(this,rs).length}compileQuery(n){return J(this,uo,""),J(this,rs,[]),this.visitNode(n),p({query:n,sql:this.getSql(),parameters:[...r(this,rs)]})}getSql(){return r(this,uo)}visitSelectQuery(n){const i=this.parentNode!==void 0&&!xr.is(this.parentNode)&&!ti.is(this.parentNode)&&!sp.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(eb[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 yf.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){J(this,uo,r(this,uo)+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,rs).push(n)}appendImmediateValue(n){if(hr(n))this.append(`'${n}'`);else if(Ww(n)||Dd(n))this.append(n.toString());else if(Ld(n))this.append("null");else if(Iw(n))this.appendImmediateValue(n.toISOString());else if(Aw(n))this.appendImmediateValue(n.toString());else throw new Error(`invalid immediate value ${n}`)}}uo=new WeakMap,rs=new WeakMap;const eb=p({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),tb=p({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral"}),Mr=p({raw(t){return p({sql:t,query:en.createWithSql(t),parameters:p([])})}}),nb=/"/g;class Ip extends Zg{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(e){return e.replace(nb,'""')}visitDefaultInsertValue(e){this.append("null")}}const rb="kysely_migration",ib="kysely_migration_lock";p({__noMigrations__:!0});var co,Wc,Tp;class Ap{constructor(e){F(this,Wc);F(this,co,void 0);J(this,co,e)}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let n=r(this,co).selectFrom("sqlite_schema").where("type","in",["table","view"]).where("name","not like","sqlite_%").select("name").orderBy("name").$castTo();e.withInternalKyselyTables||(n=n.where("name","!=",rb).where("name","!=",ib));const i=await n.execute();return Promise.all(i.map(({name:a})=>Oe(this,Wc,Tp).call(this,a)))}async getMetadata(e){return{tables:await this.getTables(e)}}}co=new WeakMap,Wc=new WeakSet,Tp=async function(e){var m,w,v,d,I,M;const n=r(this,co),i=await n.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),a=(M=(I=(d=(v=(w=(m=i.sql)==null?void 0:m.split(/[\(\),]/))==null?void 0:w.find(B=>B.toLowerCase().includes("autoincrement")))==null?void 0:v.trimStart())==null?void 0:d.split(/\s+/))==null?void 0:I[0])==null?void 0:M.replace(/["`]/g,""),l=await n.selectFrom(Tn`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(B=>({name:B.name,dataType:B.type,isNullable:!B.notnull,isAutoIncrementing:B.name===a,hasDefaultValue:B.dflt_value!=null}))}};class kp{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var Sp=class{createQueryCompiler(){return new Ip}createAdapter(){return new kp}createIntrospector(t){return new Ap(t)}},Ba,Dh,Rp=(Dh=class{constructor(){F(this,Ba,new sb);Te(this,"connection")}async acquireConnection(){return await r(this,Ba).lock(),this.connection}async beginTransaction(t){await t.executeQuery(Mr.raw("begin"))}async commitTransaction(t){await t.executeQuery(Mr.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(Mr.raw("rollback"))}async releaseConnection(){r(this,Ba).unlock()}},Ba=new WeakMap,Dh),sb=class{constructor(){Te(this,"promise");Te(this,"resolve")}async lock(){for(;this.promise;)await this.promise;this.promise=new Promise(e=>{this.resolve=e})}unlock(){const e=this.resolve;this.promise=void 0,this.resolve=void 0,e==null||e()}},Dp=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 ob({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 ab=class extends Rp{constructor(e){super();Te(this,"config");Te(this,"db");this.config=e}async init(){var e,n,i,a;if(this.db=typeof this.config.database=="function"?await this.config.database():this.config.database,!this.db)throw new Error("no database");this.connection=new ub(this.db,(e=this.config.onWrite)==null?void 0:e.func,(n=this.config.onWrite)==null?void 0:n.isThrottle,(i=this.config.onWrite)==null?void 0:i.maxCalls,(a=this.config.onWrite)==null?void 0:a.delay),this.config.onCreateConnection&&await this.config.onCreateConnection(this.connection)}async beginTransaction(e){await e.executeQuery(Mr.raw("begin")),e.transactionNum++}async commitTransaction(e){await e.executeQuery(Mr.raw("commit")),e.transactionNum--}async rollbackTransaction(e){await e.executeQuery(Mr.raw("rollback")),e.transactionNum--}async destroy(){var e;(e=this.db)==null||e.close()}},ub=class extends Dp{constructor(e,n,i=!1,a=1e3,l=2e3){super();Te(this,"db");Te(this,"onWrite");Te(this,"transactionNum",0);this.db=e,this.onWrite=n?i?ob({func:n,maxCalls:a,delay:l}):n:void 0}query(e,n){const i=this.db.prepare(e);i.bind(n);const a=[];for(;i.step();)a.push(i.getAsObject());return i.free(),a}exec(e,n){this.db.run(e,n);const i=BigInt(this.query("SELECT last_insert_rowid() as id")[0].id),a=BigInt(this.db.getRowsModified());return this.transactionNum===0&&this.onWrite&&this.onWrite(this.db.export()),{numAffectedRows:a,insertId:i}}},Fa,Lh,cb=(Lh=class extends Sp{constructor(e){super();F(this,Fa,void 0);J(this,Fa,e)}createDriver(){return new ab(r(this,Fa))}},Fa=new WeakMap,Lh),lb=class extends Rp{constructor(e){super();Te(this,"config");Te(this,"db");this.config=e}async init(){this.db=typeof this.config.database=="function"?await this.config.database():this.config.database,this.connection=new fb(this.db),this.config.onCreateConnection&&await this.config.onCreateConnection(this.connection)}async destroy(){var e;await((e=this.db)==null?void 0:e.sqlite.close(this.db.db))}},fb=class extends Dp{constructor(e){super();Te(this,"sqlite");Te(this,"db");this.db=e.db,this.sqlite=e.sqlite}async run(e){const n=this.sqlite.str_new(this.db,e.sql),i=await this.sqlite.prepare_v2(this.db,this.sqlite.str_value(n));if(i===null)return[];const a=i.stmt;try{typeof e.param<"u"&&this.sqlite.bind_collection(a,e.param);const l=[];let m=[];for(;await this.sqlite.step(a)===100;){m=m.length===0?this.sqlite.column_names(a):m;const w=this.sqlite.row(a);l.push(m.reduce((v,d,I)=>(v[d]=w[I],v),{}))}return l}finally{await this.sqlite.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(this.sqlite.changes(this.db))}}},Ua,Ph,hb=(Ph=class extends Sp{constructor(e){super();F(this,Ua,void 0);J(this,Ua,e)}createDriver(){return new lb(r(this,Ua))}},Ua=new WeakMap,Ph);function db(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function pb(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 Lp={exports:{}};const mb={},yb=Object.freeze(Object.defineProperty({__proto__:null,default:mb},Symbol.toStringTag,{value:"Module"})),Cu=pb(yb);(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(W,G){switch(typeof G){case"boolean":mu(W,G?1:0);break;case"number":du(W,G);break;case"string":Ko(W,G,-1,-1);break;case"object":if(G===null)zo(W);else if(G.length!=null){var s=Os(G);pu(W,s,G.length,-1),Si(s)}else Li(W,"Wrong API use : tried to return a value of an unknown type ("+G+").",-1);break;default:zo(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:bi(s),u=G?ue(s+"/"+G):s),G=mn(!0,!0),u=vi(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{ne||(T=Cu,ne=Cu)},C=function(o,c){return Ne(),o=ne.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=ne.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},Y&&(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 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,I),I=null,d.thisProgram&&(M=d.thisProgram);var xe;d.wasmBinary&&(xe=d.wasmBinary),d.noExitRuntime,typeof WebAssembly!="object"&&x("no native wasm support detected");var nt,Ke=!1,Wt=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function It(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 je(o,c){return o?It(qe,o,c):""}function Jt(o,c,h,g){if(!(0=$){var ve=o.charCodeAt(++R);$=65536+(($&1023)<<10)|ve&1023}if(127>=$){if(h>=g)break;c[h++]=$}else{if(2047>=$){if(h+1>=g)break;c[h++]=192|$>>6}else{if(65535>=$){if(h+2>=g)break;c[h++]=224|$>>12}else{if(h+3>=g)break;c[h++]=240|$>>18,c[h++]=128|$>>12&63}c[h++]=128|$>>6&63}c[h++]=128|$&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 gt,ge,qe,ct,we,De,Mt,Or;function hs(){var o=nt.buffer;gt=o,d.HEAP8=ge=new Int8Array(o),d.HEAP16=ct=new Int16Array(o),d.HEAP32=we=new Int32Array(o),d.HEAPU8=qe=new Uint8Array(o),d.HEAPU16=new Uint16Array(o),d.HEAPU32=De=new Uint32Array(o),d.HEAPF32=Mt=new Float32Array(o),d.HEAPF64=Or=new Float64Array(o)}var En,pn=[],fe=[],Be=[];function Hn(){var o=d.preRun.shift();pn.unshift(o)}var Gt=0,Je=null;function x(o){throw d.onAbort&&d.onAbort(o),o="Aborted("+o+")",_e(o),Ke=!0,new WebAssembly.RuntimeError(o+". Build with -sASSERTIONS for more info.")}function q(){return S.startsWith("data:application/octet-stream;base64,")}var S;if(S="sql-wasm.wasm",!q()){var L=S;S=d.locateFile?d.locateFile(L,b):b+L}function z(){var o=S;try{if(o==S&&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 ee(){if(!xe&&(B||Y)){if(typeof fetch=="function"&&!S.startsWith("file://"))return fetch(S,{credentials:"same-origin"}).then(function(o){if(!o.ok)throw"failed to load wasm binary file at '"+S+"'";return o.arrayBuffer()}).catch(function(){return z()});if(N)return new Promise(function(o,c){N(S,function(h){o(new Uint8Array(h))},c)})}return Promise.resolve().then(function(){return z()})}var Q,V;function re(o){for(;0>0];case"i8":return ge[o>>0];case"i16":return ct[o>>1];case"i32":return we[o>>2];case"i64":return we[o>>2];case"float":return Mt[o>>2];case"double":return Or[o>>3];case"*":return De[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":ct[o>>1]=0;break;case"i32":we[o>>2]=0;break;case"i64":V=[0,(Q=0,1<=+Math.abs(Q)?0>>0:~~+Math.ceil((Q-+(~~Q>>>0))/4294967296)>>>0:0)],we[o>>2]=V[0],we[o+4>>2]=V[1];break;case"float":Mt[o>>2]=0;break;case"double":Or[o>>3]=0;break;case"*":De[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 He(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var o=new Uint8Array(1);return()=>(crypto.getRandomValues(o),o[0])}if(Z)try{var c=Cu;return()=>c.randomBytes(1)[0]}catch{}return()=>x("randomDevice")}function Pe(){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 st(o,c){var h=Array(dn(o)+1);return o=Jt(o,h,0,h.length),c&&(h.length=o),h}var me=[];function Cn(o,c){me[o]={input:[],output:[],Xa:c},Ni(o,gi)}var gi={open:function(o){var c=me[o.node.rdev];if(!c)throw new j(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 j(60);for(var E=0,R=0;R=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 j(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 j(43);if(o=o.node.Ia,E&2||o.buffer!==gt){if((0{if(o=Pe("/",o),!o)return{path:"",node:null};if(c=Object.assign({rb:!0,kb:0},c),8!!$),!1);for(var h=Bt,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}},ms=(o,c)=>{for(var h=0,g=0;g>>0)%qn.length},Wr=o=>{var c=ms(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}},dr=(o,c)=>{var h;if(h=(h=$r(o,"x"))?h:o.Ga.lookup?0:2)throw new j(h,o);for(h=qn[ms(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)},Oo=(o,c,h,g)=>(o=new Mo(o,c,h,g),c=ms(o.parent.id,o.name),o.Wa=qn[c],qn[c]=o),tl={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Wo=o=>{var c=["r","w","rw"][o&3];return o&512&&(c+="w"),c},$r=(o,c)=>{if(ps)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},ys=(o,c)=>{try{return dr(o,c),20}catch{}return $r(o,"wx")},Io=(o,c,h)=>{try{var g=dr(o,c)}catch(E){return E.Ka}if(o=$r(o,"wx"))return o;if(h){if((g.mode&61440)!==16384)return 54;if(g===g.parent||bi(g)==="/")return 10}else if((g.mode&61440)===16384)return 31;return 0},Ao=(o=0)=>{for(;4096>=o;o++)if(!Sn[o])return o;throw new j(33)},On=(o,c)=>(Wi||(Wi=function(){this.$a={}},Wi.prototype={},Object.defineProperties(Wi.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 Wi,o),c=Ao(c),o.fd=c,Sn[c]=o),ws={open:o=>{o.Ha=te[o.node.rdev].Ha,o.Ha.open&&o.Ha.open(o)},Ta:()=>{throw new j(70)}},Ni=(o,c)=>{te[o]={Ha:c}},To=(o,c)=>{var h=c==="/",g=!c;if(h&&Bt)throw new j(10);if(!h&&!g){var E=Ft(c,{rb:!1});if(c=E.path,E=E.node,E.Va)throw new j(10);if((E.mode&61440)!==16384)throw new j(54)}c={type:o,Kb:{},ub:c,Eb:[]},o=o.Ra(c),o.Ra=c,c.root=o,h?Bt=o:E&&(E.Va=c,E.Ra&&E.Ra.Eb.push(c))},vi=(o,c,h)=>{var g=Ft(o,{parent:!0}).node;if(o=Ee(o),!o||o==="."||o==="..")throw new j(28);var E=ys(g,o);if(E)throw new j(E);if(!g.Ga.ab)throw new j(63);return g.Ga.ab(g,o,c,h)},an=(o,c)=>vi(o,(c!==void 0?c:511)&1023|16384,0),_i=(o,c,h)=>{typeof h>"u"&&(h=c,c=438),vi(o,c|8192,h)},gs=(o,c)=>{if(!Pe(o))throw new j(44);var h=Ft(c,{parent:!0}).node;if(!h)throw new j(44);c=Ee(c);var g=ys(h,c);if(g)throw new j(g);if(!h.Ga.symlink)throw new j(63);h.Ga.symlink(h,c,o)},ko=o=>{var c=Ft(o,{parent:!0}).node;o=Ee(o);var h=dr(c,o),g=Io(c,o,!0);if(g)throw new j(g);if(!c.Ga.rmdir)throw new j(63);if(h.Va)throw new j(10);c.Ga.rmdir(c,o),Wr(h)},xi=o=>{var c=Ft(o,{parent:!0}).node;if(!c)throw new j(44);o=Ee(o);var h=dr(c,o),g=Io(c,o,!1);if(g)throw new j(g);if(!c.Ga.unlink)throw new j(63);if(h.Va)throw new j(10);c.Ga.unlink(c,o),Wr(h)},So=o=>{if(o=Ft(o).node,!o)throw new j(44);if(!o.Ga.readlink)throw new j(28);return Pe(bi(o.parent),o.Ga.readlink(o))},Qr=(o,c)=>{if(o=Ft(o,{Sa:!c}).node,!o)throw new j(44);if(!o.Ga.Pa)throw new j(63);return o.Ga.Pa(o)},Ro=o=>Qr(o,!0),bs=(o,c)=>{if(o=typeof o=="string"?Ft(o,{Sa:!0}).node:o,!o.Ga.Oa)throw new j(63);o.Ga.Oa(o,{mode:c&4095|o.mode&-4096,timestamp:Date.now()})},jr=(o,c)=>{if(0>c)throw new j(28);if(o=typeof o=="string"?Ft(o,{Sa:!0}).node:o,!o.Ga.Oa)throw new j(63);if((o.mode&61440)===16384)throw new j(31);if((o.mode&61440)!==32768)throw new j(28);var h=$r(o,"w");if(h)throw new j(h);o.Ga.Oa(o,{size:c,timestamp:Date.now()})},pr=(o,c,h)=>{if(o==="")throw new j(44);if(typeof c=="string"){var g=tl[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=Ft(o,{Sa:!(c&131072)}).node}catch{}}if(g=!1,c&64)if(E){if(c&128)throw new j(20)}else E=vi(o,h,0),g=!0;if(!E)throw new j(44);if((E.mode&61440)===8192&&(c&=-513),c&65536&&(E.mode&61440)!==16384)throw new j(54);if(!g&&(h=E?(E.mode&61440)===40960?32:(E.mode&61440)===16384&&(Wo(c)!=="r"||c&512)?31:$r(E,Wo(c)):44))throw new j(h);return c&512&&!g&&jr(E,0),c&=-131713,E=On({node:E,path:bi(E),flags:c,seekable:!0,position:0,Ha:E.Ha,Ib:[],error:!1}),E.Ha.open&&E.Ha.open(E),!d.logReadFiles||c&1||(Ii||(Ii={}),o in Ii||(Ii[o]=1)),E},Ve=o=>{if(o.fd===null)throw new j(8);o.hb&&(o.hb=null);try{o.Ha.close&&o.Ha.close(o)}catch(c){throw c}finally{Sn[o.fd]=null}o.fd=null},Hr=(o,c,h)=>{if(o.fd===null)throw new j(8);if(!o.seekable||!o.Ha.Ta)throw new j(70);if(h!=0&&h!=1&&h!=2)throw new j(28);o.position=o.Ha.Ta(o,c,h),o.Ib=[]},Ei=(o,c,h,g,E)=>{if(0>g||0>E)throw new j(28);if(o.fd===null)throw new j(8);if((o.flags&2097155)===1)throw new j(8);if((o.node.mode&61440)===16384)throw new j(31);if(!o.Ha.read)throw new j(28);var R=typeof E<"u";if(!R)E=o.position;else if(!o.seekable)throw new j(70);return c=o.Ha.read(o,c,h,g,E),R||(o.position+=c),c},mr=(o,c,h,g,E)=>{if(0>g||0>E)throw new j(28);if(o.fd===null)throw new j(8);if(!(o.flags&2097155))throw new j(8);if((o.node.mode&61440)===16384)throw new j(31);if(!o.Ha.write)throw new j(28);o.seekable&&o.flags&1024&&Hr(o,0,2);var R=typeof E<"u";if(!R)E=o.position;else if(!o.seekable)throw new j(70);return c=o.Ha.write(o,c,h,g,E,void 0),R||(o.position+=c),c},Ns=o=>{var c,h=pr(o,h||0);o=Qr(o).size;var g=new Uint8Array(o);return Ei(h,g,0,o,0),c=g,Ve(h),c},Ci=()=>{j||(j=function(o,c){this.node=c,this.Hb=function(h){this.Ka=h},this.Hb(o),this.message="FS error"},j.prototype=Error(),j.prototype.constructor=j,[44].forEach(o=>{Vn[o]=new j(o),Vn[o].stack=""}))},qi,mn=(o,c)=>{var h=0;return o&&(h|=365),c&&(h|=146),h},Rn=(o,c,h)=>{o=ue("/dev/"+o);var g=mn(!!c,!!h);Oi||(Oi=64);var E=Oi++<<8|0;Ni(E,{open:R=>{R.seekable=!1},close:()=>{h&&h.buffer&&h.buffer.length&&h(10)},read:(R,$,ve,Me)=>{for(var Le=0,lt=0;lt{for(var Le=0;Le>2]=g.dev,we[h+8>>2]=g.ino,we[h+12>>2]=g.mode,De[h+16>>2]=g.nlink,we[h+20>>2]=g.uid,we[h+24>>2]=g.gid,we[h+28>>2]=g.rdev,V=[g.size>>>0,(Q=g.size,1<=+Math.abs(Q)?0>>0:~~+Math.ceil((Q-+(~~Q>>>0))/4294967296)>>>0:0)],we[h+40>>2]=V[0],we[h+44>>2]=V[1],we[h+48>>2]=4096,we[h+52>>2]=g.blocks,V=[Math.floor(g.atime.getTime()/1e3)>>>0,(Q=Math.floor(g.atime.getTime()/1e3),1<=+Math.abs(Q)?0>>0:~~+Math.ceil((Q-+(~~Q>>>0))/4294967296)>>>0:0)],we[h+56>>2]=V[0],we[h+60>>2]=V[1],De[h+64>>2]=0,V=[Math.floor(g.mtime.getTime()/1e3)>>>0,(Q=Math.floor(g.mtime.getTime()/1e3),1<=+Math.abs(Q)?0>>0:~~+Math.ceil((Q-+(~~Q>>>0))/4294967296)>>>0:0)],we[h+72>>2]=V[0],we[h+76>>2]=V[1],De[h+80>>2]=0,V=[Math.floor(g.ctime.getTime()/1e3)>>>0,(Q=Math.floor(g.ctime.getTime()/1e3),1<=+Math.abs(Q)?0>>0:~~+Math.ceil((Q-+(~~Q>>>0))/4294967296)>>>0:0)],we[h+88>>2]=V[0],we[h+92>>2]=V[1],De[h+96>>2]=0,V=[g.ino>>>0,(Q=g.ino,1<=+Math.abs(Q)?0>>0:~~+Math.ceil((Q-+(~~Q>>>0))/4294967296)>>>0:0)],we[h+104>>2]=V[0],we[h+108>>2]=V[1],0}var Vr=void 0;function Ti(){return Vr+=4,we[Vr-4>>2]}function yn(o){if(o=Sn[o],!o)throw new j(8);return o}function vs(o){return De[o>>2]+4294967296*we[o+4>>2]}function Do(o){var c=dn(o)+1,h=ki(c);return h&&Jt(o,ge,h,c),h}function Ya(o,c,h){function g(Me){return(Me=Me.toTimeString().match(/\(([A-Za-z ]+)\)$/))?Me[1]:"GMT"}var E=new Date().getFullYear(),R=new Date(E,0,1),$=new Date(E,6,1);E=R.getTimezoneOffset();var ve=$.getTimezoneOffset();we[o>>2]=60*Math.max(E,ve),we[c>>2]=+(E!=ve),o=g(R),c=g($),o=Do(o),c=Do(c),ve>2]=o,De[h+4>>2]=c):(De[h>>2]=c,De[h+4>>2]=o)}function _s(o,c,h){_s.Bb||(_s.Bb=!0,Ya(o,c,h))}var Lo;Lo=Z?()=>{var o=process.hrtime();return 1e3*o[0]+o[1]/1e6}:()=>performance.now();var xs={};function Po(){if(!Es){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",_:M||"./this.program"},c;for(c in xs)xs[c]===void 0?delete o[c]:o[c]=xs[c];var h=[];for(c in o)h.push(c+"="+o[c]);Es=h}return Es}var Es,Kn=void 0,Cs=[];function qs(o,c){if(!Kn){Kn=new WeakMap;var h=En.length;if(Kn)for(var g=0;g<0+h;g++){var E=En.get(g);E&&Kn.set(E,g)}}if(Kn.has(o))return Kn.get(o);if(Cs.length)h=Cs.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 R={parameters:[],results:c[0]=="v"?[]:[E[c[0]]]},$=1;$$?g.push($):g.push($%128|128,$>>7),$=0;$E?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 Kn.set(o,h),h}function zr(o){Kn.delete(En.get(o)),Cs.push(o)}function Os(o){var c=ki(o.length);return o.subarray||o.slice||(o=new Uint8Array(o)),qe.set(o,c),c}function Za(o,c,h,g){var E={string:Le=>{var lt=0;if(Le!=null&&Le!==0){var Dn=(Le.length<<2)+1;lt=Jn(Dn),Jt(Le,qe,lt,Dn)}return lt},array:Le=>{var lt=Jn(Le.length);return ge.set(Le,lt),lt}};o=d["_"+o];var R=[],$=0;if(g)for(var ve=0;ve{an("/dev"),Ni(259,{read:()=>0,write:(c,h,g,E)=>E}),_i("/dev/null",259),Cn(1280,Xt),Cn(1536,ds),_i("/dev/tty",1280),_i("/dev/tty1",1536);var o=He();Rn("random",o),Rn("urandom",o),an("/dev/shm"),an("/dev/shm/tmp")})(),(()=>{an("/proc");var o=an("/proc/self");an("/proc/self/fd"),To({Ra:()=>{var c=Oo(o,"fd",16895,73);return c.Ga={lookup:(h,g)=>{var E=Sn[+g];if(!E)throw new j(8);return h={parent:null,Ra:{ub:"fake"},Ga:{readlink:()=>E.path}},h.parent=h}},c}},"/proc/self/fd")})();var eu={a:function(o,c,h,g){x("Assertion failed: "+je(o)+", at: "+[c?je(c):"unknown filename",h,g?je(g):"unknown function"])},h:function(o,c){try{return o=je(o),bs(o,c),0}catch(h){if(typeof Ge>"u"||!(h instanceof j))throw h;return-h.Ka}},H:function(o,c,h){try{if(c=je(c),c=zn(o,c),h&-8)return-28;var g=Ft(c,{Sa:!0}).node;return g?(o="",h&4&&(o+="r"),h&2&&(o+="w"),h&1&&(o+="x"),o&&$r(g,o)?-2:0):-44}catch(E){if(typeof Ge>"u"||!(E instanceof j))throw E;return-E.Ka}},i:function(o,c){try{var h=Sn[o];if(!h)throw new j(8);return bs(h.node,c),0}catch(g){if(typeof Ge>"u"||!(g instanceof j))throw g;return-g.Ka}},g:function(o){try{var c=Sn[o];if(!c)throw new j(8);var h=c.node,g=typeof h=="string"?Ft(h,{Sa:!0}).node:h;if(!g.Ga.Oa)throw new j(63);return g.Ga.Oa(g,{timestamp:Date.now()}),0}catch(E){if(typeof Ge>"u"||!(E instanceof j))throw E;return-E.Ka}},b:function(o,c,h){Vr=h;try{var g=yn(o);switch(c){case 0:var E=Ti();return 0>E?-28:On(g,E).fd;case 1:case 2:return 0;case 3:return g.flags;case 4:return E=Ti(),g.flags|=E,0;case 5:return E=Ti(),ct[E+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return we[Bo()>>2]=28,-1;default:return-28}}catch(R){if(typeof Ge>"u"||!(R instanceof j))throw R;return-R.Ka}},G:function(o,c){try{var h=yn(o);return Ai(Qr,h.path,c)}catch(g){if(typeof Ge>"u"||!(g instanceof j))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=Sn[o];if(!g)throw new j(8);if(!(g.flags&2097155))throw new j(28);return jr(g.node,c),0}catch(E){if(typeof Ge>"u"||!(E instanceof j))throw E;return-E.Ka}},B:function(o,c){try{if(c===0)return-28;var h=dn("/")+1;return c"u"||!(g instanceof j))throw g;return-g.Ka}},E:function(o,c){try{return o=je(o),Ai(Ro,o,c)}catch(h){if(typeof Ge>"u"||!(h instanceof j))throw h;return-h.Ka}},y:function(o,c,h){try{return c=je(c),c=zn(o,c),c=ue(c),c[c.length-1]==="/"&&(c=c.substr(0,c.length-1)),an(c,h),0}catch(g){if(typeof Ge>"u"||!(g instanceof j))throw g;return-g.Ka}},D:function(o,c,h,g){try{c=je(c);var E=g&256;return c=zn(o,c,g&4096),Ai(E?Ro:Qr,c,h)}catch(R){if(typeof Ge>"u"||!(R instanceof j))throw R;return-R.Ka}},v:function(o,c,h,g){Vr=g;try{c=je(c),c=zn(o,c);var E=g?Ti():0;return pr(c,h,E).fd}catch(R){if(typeof Ge>"u"||!(R instanceof j))throw R;return-R.Ka}},t:function(o,c,h,g){try{if(c=je(c),c=zn(o,c),0>=g)return-28;var E=So(c),R=Math.min(g,dn(E)),$=ge[h+R];return Jt(E,qe,h,g+1),ge[h+R]=$,R}catch(ve){if(typeof Ge>"u"||!(ve instanceof j))throw ve;return-ve.Ka}},s:function(o){try{return o=je(o),ko(o),0}catch(c){if(typeof Ge>"u"||!(c instanceof j))throw c;return-c.Ka}},F:function(o,c){try{return o=je(o),Ai(Qr,o,c)}catch(h){if(typeof Ge>"u"||!(h instanceof j))throw h;return-h.Ka}},p:function(o,c,h){try{return c=je(c),c=zn(o,c),h===0?xi(c):h===512?ko(c):x("Invalid flags passed to unlinkat"),0}catch(g){if(typeof Ge>"u"||!(g instanceof j))throw g;return-g.Ka}},o:function(o,c,h){try{if(c=je(c),c=zn(o,c,!0),h){var g=vs(h),E=we[h+8>>2];R=1e3*g+E/1e6,h+=16,g=vs(h),E=we[h+8>>2],$=1e3*g+E/1e6}else var R=Date.now(),$=R;o=R;var ve=Ft(c,{Sa:!0}).node;return ve.Ga.Oa(ve,{timestamp:Math.max(o,$)}),0}catch(Me){if(typeof Ge>"u"||!(Me instanceof j))throw Me;return-Me.Ka}},e:function(){return Date.now()},j:function(o,c){o=new Date(1e3*vs(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,R){try{var $=yn(g);if(c&2&&!(h&2)&&($.flags&2097155)!==2)throw new j(2);if(($.flags&2097155)===1)throw new j(2);if(!$.Ha.bb)throw new j(43);var ve=$.Ha.bb($,o,E,c,h),Me=ve.Fb;return we[R>>2]=ve.vb,Me}catch(Le){if(typeof Ge>"u"||!(Le instanceof j))throw Le;return-Le.Ka}},x:function(o,c,h,g,E,R){try{var $=yn(E);if(h&2){var ve=qe.slice(o,o+c);$&&$.Ha.cb&&$.Ha.cb($,ve,R,c,g)}}catch(Me){if(typeof Ge>"u"||!(Me instanceof j))throw Me;return-Me.Ka}},n:_s,q:function(){return 2147483648},d:Lo,c:function(o){var c=qe.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{nt.grow(E-gt.byteLength+65535>>>16),hs();var R=1;break e}catch{}R=void 0}if(R)return!0}return!1},z:function(o,c){var h=0;return Po().forEach(function(g,E){var R=c+h;for(E=De[o+4*E>>2]=R,R=0;R>0]=g.charCodeAt(R);ge[E>>0]=0,h+=g.length+1}),0},A:function(o,c){var h=Po();De[o>>2]=h.length;var g=0;return h.forEach(function(E){g+=E.length+1}),De[c>>2]=g,0},f:function(o){try{var c=yn(o);return Ve(c),0}catch(h){if(typeof Ge>"u"||!(h instanceof j))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 Ge>"u"||!(g instanceof j))throw g;return g.Ka}},u:function(o,c,h,g){try{e:{var E=yn(o);o=c;for(var R=c=0;R>2],ve=De[o+4>>2];o+=8;var Me=Ei(E,ge,$,ve);if(0>Me){var Le=-1;break e}if(c+=Me,Me>2]=Le,0}catch(lt){if(typeof Ge>"u"||!(lt instanceof j))throw lt;return lt.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 R=yn(o);return Hr(R,c,g),V=[R.position>>>0,(Q=R.position,1<=+Math.abs(Q)?0>>0:~~+Math.ceil((Q-+(~~Q>>>0))/4294967296)>>>0:0)],we[E>>2]=V[0],we[E+4>>2]=V[1],R.hb&&c===0&&g===0&&(R.hb=null),0}catch($){if(typeof Ge>"u"||!($ instanceof j))throw $;return $.Ka}},C:function(o){try{var c=yn(o);return c.Ha&&c.Ha.fsync?c.Ha.fsync(c):0}catch(h){if(typeof Ge>"u"||!(h instanceof j))throw h;return h.Ka}},r:function(o,c,h,g){try{e:{var E=yn(o);o=c;for(var R=c=0;R>2],ve=De[o+4>>2];o+=8;var Me=mr(E,ge,$,ve);if(0>Me){var Le=-1;break e}c+=Me}Le=c}return De[g>>2]=Le,0}catch(lt){if(typeof Ge>"u"||!(lt instanceof j))throw lt;return lt.Ka}}};(function(){function o(E){d.asm=E.exports,nt=d.asm.I,hs(),En=d.asm.Aa,fe.unshift(d.asm.J),Gt--,d.monitorRunDependencies&&d.monitorRunDependencies(Gt),Gt==0&&Je&&(E=Je,Je=null,E())}function c(E){o(E.instance)}function h(E){return ee().then(function(R){return WebAssembly.instantiate(R,g)}).then(function(R){return R}).then(E,function(R){_e("failed to asynchronously prepare wasm: "+R),x(R)})}var g={a:eu};if(Gt++,d.monitorRunDependencies&&d.monitorRunDependencies(Gt),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"||q()||S.startsWith("file://")||Z||typeof fetch!="function"?h(c):fetch(S,{credentials:"same-origin"}).then(function(E){return WebAssembly.instantiateStreaming(E,g).then(c,function(R){return _e("wasm streaming compile failed: "+R),_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 Bo=d.___errno_location=function(){return(Bo=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 ki=d._malloc=function(){return(ki=d._malloc=d.asm.ya).apply(null,arguments)},Si=d._free=function(){return(Si=d._free=d.asm.za).apply(null,arguments)};d._RegisterExtensionFunctions=function(){return(d._RegisterExtensionFunctions=d.asm.Ba).apply(null,arguments)};var Fo=d._emscripten_builtin_memalign=function(){return(Fo=d._emscripten_builtin_memalign=d.asm.Ca).apply(null,arguments)},Kr=d.stackSave=function(){return(Kr=d.stackSave=d.asm.Da).apply(null,arguments)},Jr=d.stackRestore=function(){return(Jr=d.stackRestore=d.asm.Ea).apply(null,arguments)},Jn=d.stackAlloc=function(){return(Jn=d.stackAlloc=d.asm.Fa).apply(null,arguments)};d.UTF8ToString=je,d.stackAlloc=Jn,d.stackSave=Kr,d.stackRestore=Jr,d.cwrap=function(o,c,h,g){h=h||[];var E=h.every(R=>R==="number"||R==="boolean");return c!=="string"&&E&&!g?d["_"+o]:function(){return Za(o,c,h,arguments)}};var Ri;Je=function o(){Ri||Uo(),Ri||(Je=o)};function Uo(){function o(){if(!Ri&&(Ri=!0,d.calledRun=!0,!Ke)){if(d.noFSInit||qi||(qi=!0,Ci(),d.stdin=d.stdin,d.stdout=d.stdout,d.stderr=d.stderr,d.stdin?Rn("stdin",d.stdin):gs("/dev/tty","/dev/stdin"),d.stdout?Rn("stdout",null,d.stdout):gs("/dev/tty","/dev/stdout"),d.stderr?Rn("stderr",null,d.stderr):gs("/dev/tty1","/dev/stderr"),pr("/dev/stdin",0),pr("/dev/stdout",1),pr("/dev/stderr",1)),ps=!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();Be.unshift(c)}re(Be)}}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(_b,Math.max(vb,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 Eb=self.indexedDB||window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB||window.shimIndexedDB,qf=new Promise((t,e)=>{const n=Eb.open(Nb,1);n.onupgradeneeded=()=>n.result.createObjectStore("files",{keyPath:"name"}),n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error)});async function Cb(t){const e=await qf,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&&!Ps.has(t)){const i=new xb(n.data);return Ps.set(t,i),i}else return Ps.has(t)?Ps.get(t):null}async function qb(t,e){const n=await qf;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 xh(t){const e=await qf;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 Ob(t,e){if(await qb(t,e),Ps.has(t)){const n=Ps.get(t);n.truncate(0),n.write(0,e)}}var Wb=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),Ib=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},Ab=class extends _f{constructor(e){super();Te(this,"serializer");this.serializer=e||Wb}transformPrimitiveValueList(e){return{...e,values:e.values.map(this.serializer)}}transformColumnUpdate(e){const{value:n}=e;if(n.kind!=="ValueNode")return super.transformColumnUpdate(e);const{value:i,...a}=n,l=this.serializer(i);return i===l?super.transformColumnUpdate(e):super.transformColumnUpdate({...e,value:{...a,value:l}})}transformValue(e){return{...e,value:this.serializer(e.value)}}},Tb=class{constructor(t={}){Te(this,"serializeParametersTransformer");Te(this,"deserializer");Te(this,"ctx");this.serializeParametersTransformer=new Ab(t.serializer),this.deserializer=t.deserializer||Ib,this.ctx=new WeakMap}transformQuery(t){const{node:e,queryId:n}=t;return e.kind==="SelectQueryNode"&&this.ctx.set(n,e.kind),this.serializeParametersTransformer.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 this.deserializer(n[i]);return n}))}async transformResult(t){const{result:e,queryId:n}=t,{rows:i}=e,a=this.ctx.get(n);return i&&a==="SelectQueryNode"?{...t.result,rows:await this.parseResult(i)}:t.result}};function wl(t){return typeof t=="string"}function kb(t){return typeof t=="boolean"}async function Eh(t,e,n,i,a="rowid"){await Tn` + create trigger if not exists ${Tn.raw(e)}_${Tn.raw(i)} + after ${Tn.raw(n)} + on ${Tn.table(e)} + begin + update ${Tn.table(e)} + set ${Tn.ref(i)} = datetime('now','localtime') + where ${Tn.ref(a)} = NEW.${Tn.ref(a)}; + end + `.execute(t).catch(l=>{console.error(l)})}function Sb(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 Rb(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,I="createAt",M="updateAt";if(m!=null&&m.timestamp&&!kb(m.timestamp)){const{create:B,update:Y}=m.timestamp;I=B??"createAt",M=Y??"updateAt"}for(const B in l){if(!Object.prototype.hasOwnProperty.call(l,B))continue;const Y=l[B];let Z="text";const{type:b,notNull:C,defaultTo:N}=Y;switch(b){case"boolean":case"date":case"object":case"string":Z="text";break;case"increments":v=B;case"number":Z="integer";break;case"blob":Z="blob"}[I,M].includes(B)||(w=w.addColumn(B,Z,O=>b==="increments"?(d=!0,O.autoIncrement().primaryKey()):(C&&(O=O.notNull()),N!==void 0&&(O=O.defaultTo(N instanceof Function?N(Tn):N)),O)))}if(m){const B=m.primary,Y=m.unique;if(m.timestamp&&(I&&(w=w.addColumn(I,"text")),M&&(w=w.addColumn(M,"text"))),!d&&B){const Z=wl(B);v=Z?B:B[0],w=w.addPrimaryKeyConstraint(`pk_${Z?B:B.join("_")}`,Z?[B]:B)}Y==null||Y.forEach(Z=>{const b=wl(Z);v=!B&&!d?b?Z:Z[0]:v,w=w.addUniqueConstraint(`un_${b?Z:Z.join("_")}`,b?[Z]:Z)})}if(await w.ifNotExists().execute(),m!=null&&m.index)for(const B of m.index){const Y=wl(B);let Z=t.schema.createIndex(`idx_${Y?B:B.join("_")}`).on(i);Z=Y?Z.column(B):Z.columns(B),await Z.ifNotExists().execute()}m!=null&&m.timestamp&&(I&&await Eh(t,i,"insert",I,v),M&&await Eh(t,i,"update",M,v))}}var Db=class{constructor(t){Te(this,"kysely");Te(this,"status");Te(this,"tableMap");const{dialect:e,tables:n,dropTableBeforeInit:i,onError:a,onQuery:l,plugins:m}=t,w=m??[];w.push(new Tb),this.kysely=new Ea({dialect:e,log:v=>{v.level==="error"?a&&a(v.error):l&&l(v.query,v.queryDurationMillis)},plugins:w}),this.status=i?0:1,this.tableMap=Sb(n)}async init(t=!1){const e=t||this.status===0;return await Rb(this.kysely,this.tableMap,e),this.status=2,this}async checkInit(){if(this.status!==2&&await this.init(),this.status!==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(Tn).execute(this.kysely)}};async function Of(t){const e=await new Db({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 Lb=new cb({async database(){const t=await gb({locateFile:()=>bb});return new t.Database(await Cb("sqljs"))},onWrite:{func(t){console.log(`[sqljs] write to indexeddb, length: ${t.length}`),Ob("sqljs",t)},isThrottle:!0}});function Pb(){const t=Bm();function e(){Of(Lb).then(n=>{t.value=n})}return{result:t,run:e}}function Mb(){return new Worker(""+new URL("sqljsWorker-6340e5b0.js",import.meta.url).href)}function Bb(){return new Worker(""+new URL("officialWasmWorker-155b9b7a.js",import.meta.url).href)}const ze=0,Fb=5,Et=10,Pp=12,Mp=14,Bi=21,gl=25,Ub=27,Ch=100,$b=101,Qb=3850,jb=522,Hb=1,Vb=2,Bp=4,zb=8,Ss=0,Hi=1,Du=2,Kb=3,Lu=4,Jb=512,Gb=1024,Xb=2048,Yb=16384,qh=1,Oh=2,Wh=3,Ih=4,Ah=5,Th=0x7fffffffffffffffn,kh=-0x8000000000000000n;class Ar extends Error{constructor(e,n){super(e),this.code=n}}const ks=!0;function Zb(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,O){return O>b||O2147483647||T<-2147483648)return gl;const ne=C(N,O,T);return Z(b,ne,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(M(N),T>Th||T>32n,ae=C(N,O,Number(ne),Number(Ne));return Z(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){M(N);const T=C(N,O);return Z(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 M(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){M(N);const ne=l(T),Ne=C(N,O,ne,-1,n);return Z(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:ks});return async function(N){d(N);const O=await C(N);return v.delete(N),Z(b,O,N)}}(),e.column=function(b,C){M(b);const N=e.column_type(b,C);switch(N){case Ih:return e.column_blob(b,C);case Oh:return e.column_double(b,C);case qh:const O=e.column_int(b,C),T=t.getTempRet0();return w(O,T);case Ah:return null;case Wh:return e.column_text(b,C);default:throw new Ar("unknown type",N)}},e.column_blob=function(){const b="sqlite3_column_blob",C=t.cwrap(b,...Ce("nn:n"));return function(N,O){M(N);const T=e.column_bytes(N,O),ne=C(N,O);return t.HEAPU8.subarray(ne,ne+T)}}(),e.column_bytes=function(){const b="sqlite3_column_bytes",C=t.cwrap(b,...Ce("nn:n"));return function(N,O){return M(N),C(N,O)}}(),e.column_count=function(){const b="sqlite3_column_count",C=t.cwrap(b,...Ce("n:n"));return function(N){return M(N),C(N)}}(),e.column_double=function(){const b="sqlite3_column_double",C=t.cwrap(b,...Ce("nn:n"));return function(N,O){return M(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 M(N),C(N,O)}}(),e.column_int64=function(){const b="sqlite3_column_int64",C=t.cwrap(b,...Ce("nn:n"));return function(N,O){M(N);const T=C(N,O),ne=t.getTempRet0();return m(T,ne)}}(),e.column_name=function(){const b="sqlite3_column_name",C=t.cwrap(b,...Ce("nn:s"));return function(N,O){return M(N),C(N,O)}}(),e.column_names=function(b){const C=[],N=e.column_count(b);for(let O=0;OTh||O>32n;C(N,Number(T),Number(ne))}}(),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",w=(s,u)=>{throw u},v=typeof window=="object",d=typeof importScripts=="function",I="",M;(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&&(M=s=>{var u=new XMLHttpRequest;return u.open("GET",s,!1),u.responseType="arraybuffer",u.send(null),new Uint8Array(u.response)}));var B=n.print||console.log.bind(console),Y=n.printErr||console.warn.bind(console);Object.assign(n,l),l=null,n.thisProgram&&(m=n.thisProgram),n.quit&&(w=n.quit);var Z;n.wasmBinary&&(Z=n.wasmBinary);var b=n.noExitRuntime||!0;typeof WebAssembly!="object"&&ct("no native wasm support detected");var C,N=!1,O,T,ne,Ne,ae,_e,xe,nt;function Ke(){var s=C.buffer;n.HEAP8=T=new Int8Array(s),n.HEAP16=Ne=new Int16Array(s),n.HEAP32=ae=new Int32Array(s),n.HEAPU8=ne=new Uint8Array(s),n.HEAPU16=new Uint16Array(s),n.HEAPU32=_e=new Uint32Array(s),n.HEAPF32=xe=new Float32Array(s),n.HEAPF64=nt=new Float64Array(s)}var Wt=[],It=[],je=[],Jt=[],dn=0;function gt(){var s=n.preRun.shift();Wt.unshift(s)}var ge=0,qe=null;function ct(s){throw n.onAbort&&n.onAbort(s),s="Aborted("+s+")",Y(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 De;if(n.locateFile){if(De="wa-sqlite-async.wasm",!we(De)){var Mt=De;De=n.locateFile?n.locateFile(Mt,I):I+Mt}}else De=new URL(""+new URL("wa-sqlite-async-24800831.wasm",import.meta.url).href,self.location).href;function Or(s){try{if(s==De&&Z)return new Uint8Array(Z);if(M)return M(s);throw"both async and sync fetching of the wasm failed"}catch(u){ct(u)}}function hs(s){return Z||!v&&!d||typeof fetch!="function"?Promise.resolve().then(()=>Or(s)):fetch(s,{credentials:"same-origin"}).then(u=>{if(!u.ok)throw"failed to load wasm binary file at '"+s+"'";return u.arrayBuffer()}).catch(()=>Or(s))}function En(s,u,f){return hs(s).then(y=>WebAssembly.instantiate(y,u)).then(y=>y).then(f,y=>{Y("failed to asynchronously prepare wasm: "+y),ct(y)})}function pn(s,u){var f=De;return Z||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 Y("wasm streaming compile failed: "+_),Y("falling back to ArrayBuffer instantiation"),En(f,s,u)}))}var fe,Be;function Hn(s){this.name="ExitStatus",this.message="Program terminated with exit("+s+")",this.status=s}function Gt(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 nt[s>>3];case"*":return _e[s>>2];default:ct("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":Be=[u>>>0,(fe=u,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[s>>2]=Be[0],ae[s+4>>2]=Be[1];break;case"float":xe[s>>2]=u;break;case"double":nt[s>>3]=u;break;case"*":_e[s>>2]=u;break;default:ct("invalid type for setValue: "+f)}}var q=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function S(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 L(s,u){return s?S(ne,s,u):""}var z=(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},ee=s=>{var u=s.charAt(0)==="/",f=s.substr(-1)==="/";return(s=z(s.split("/").filter(y=>!!y),!u).join("/"))||u||(s="."),s&&f&&(s+="/"),(u?"/":"")+s},Q=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)},V=s=>{if(s==="/")return"/";s=ee(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);ct("initRandomDevice")}function K(s){return(K=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=z(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 H=s.charCodeAt(++k);A=65536+((A&1023)<<10)|H&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},ys(s,He)}var He={open:function(s){var u=be[s.node.ec];if(!u)throw new te(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 te(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 te(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 te(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}},ps=(s,u)=>{for(var f=0,y=0;y>>0)%le.length},j=s=>{var u=ps(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}},Vn=(s,u)=>{var f;if(f=(f=Wr(s,"x"))?f:s.Cb.cc?0:2)throw new te(f,s);for(f=le[ps(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)},Ft=(s,u,f,y)=>(s=new uu(s,u,f,y),u=ps(s.parent.id,s.name),s.ac=le[u],le[u]=s),bi={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},ms=s=>{var u=["r","w","rw"][s&3];return s&512&&(u+="w"),u},Wr=(s,u)=>{if(Bt)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},dr=(s,u)=>{try{return Vn(s,u),20}catch{}return Wr(s,"wx")},Oo=(s,u,f)=>{try{var y=Vn(s,u)}catch(_){return _.Ob}if(s=Wr(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},tl=(s=0)=>{for(;4096>=s;s++)if(!Xt[s])return s;throw new te(33)},Wo=(s,u)=>(Hr||(Hr=function(){this.hc={}},Hr.prototype={},Object.defineProperties(Hr.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 Hr,s),u=tl(u),s.Wb=u,Xt[u]=s),$r={open:s=>{s.Mb=gi[s.node.ec].Mb,s.Mb.open&&s.Mb.open(s)},Zb:()=>{throw new te(70)}},ys=(s,u)=>{gi[s]={Mb:u}},Io=(s,u)=>{var f=u==="/",y=!u;if(f&&Cn)throw new te(10);if(!f&&!y){var _=Yt(u,{yc:!1});if(u=_.path,_=_.node,_.$b)throw new te(10);if((_.mode&61440)!==16384)throw new te(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))},Ao=(s,u,f)=>{var y=Yt(s,{parent:!0}).node;if(s=V(s),!s||s==="."||s==="..")throw new te(28);var _=dr(y,s);if(_)throw new te(_);if(!y.Cb.jc)throw new te(63);return y.Cb.jc(y,s,u,f)},On=(s,u)=>Ao(s,(u!==void 0?u:511)&1023|16384,0),ws=(s,u,f)=>{typeof f>"u"&&(f=u,u=438),Ao(s,u|8192,f)},Ni=(s,u)=>{if(!ce(s))throw new te(44);var f=Yt(u,{parent:!0}).node;if(!f)throw new te(44);u=V(u);var y=dr(f,u);if(y)throw new te(y);if(!f.Cb.nc)throw new te(63);f.Cb.nc(f,u,s)},To=s=>{var u=Yt(s,{parent:!0}).node;s=V(s);var f=Vn(u,s),y=Oo(u,s,!0);if(y)throw new te(y);if(!u.Cb.mc)throw new te(63);if(f.$b)throw new te(10);u.Cb.mc(u,s),j(f)},vi=s=>{if(s=Yt(s).node,!s)throw new te(44);if(!s.Cb.fc)throw new te(28);return ce(qn(s.parent),s.Cb.fc(s))},an=(s,u)=>{if(s=Yt(s,{Yb:!u}).node,!s)throw new te(44);if(!s.Cb.Tb)throw new te(63);return s.Cb.Tb(s)},_i=s=>an(s,!0),gs=(s,u)=>{if(s=typeof s=="string"?Yt(s,{Yb:!0}).node:s,!s.Cb.Qb)throw new te(63);s.Cb.Qb(s,{mode:u&4095|s.mode&-4096,timestamp:Date.now()})},ko=(s,u)=>{if(0>u)throw new te(28);if(s=typeof s=="string"?Yt(s,{Yb:!0}).node:s,!s.Cb.Qb)throw new te(63);if((s.mode&61440)===16384)throw new te(31);if((s.mode&61440)!==32768)throw new te(28);var f=Wr(s,"w");if(f)throw new te(f);s.Cb.Qb(s,{size:u,timestamp:Date.now()})},xi=(s,u,f)=>{if(s==="")throw new te(44);if(typeof u=="string"){var y=bi[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=ee(s);try{_=Yt(s,{Yb:!(u&131072)}).node}catch{}}if(y=!1,u&64)if(_){if(u&128)throw new te(20)}else _=Ao(s,f,0),y=!0;if(!_)throw new te(44);if((_.mode&61440)===8192&&(u&=-513),u&65536&&(_.mode&61440)!==16384)throw new te(54);if(!y&&(f=_?(_.mode&61440)===40960?32:(_.mode&61440)===16384&&(ms(u)!=="r"||u&512)?31:Wr(_,ms(u)):44))throw new te(f);return u&512&&!y&&ko(_,0),u&=-131713,_=Wo({node:_,path:qn(_),flags:u,seekable:!0,position:0,Mb:_.Mb,Tc:[],error:!1}),_.Mb.open&&_.Mb.open(_),!n.logReadFiles||u&1||(Ei||(Ei={}),s in Ei||(Ei[s]=1)),_},So=(s,u,f)=>{if(s.Wb===null)throw new te(8);if(!s.seekable||!s.Mb.Zb)throw new te(70);if(f!=0&&f!=1&&f!=2)throw new te(28);s.position=s.Mb.Zb(s,u,f),s.Tc=[]},Qr=()=>{te||(te=function(s,u){this.name="ErrnoError",this.node=u,this.Rc=function(f){this.Ob=f},this.Rc(s),this.message="FS error"},te.prototype=Error(),te.prototype.constructor=te,[44].forEach(s=>{Sn[s]=new te(s),Sn[s].stack=""}))},Ro,bs=(s,u)=>{var f=0;return s&&(f|=365),u&&(f|=146),f},jr=(s,u,f)=>{s=ee("/dev/"+s);var y=bs(!!u,!!f);pr||(pr=64);var _=pr++<<8|0;ys(_,{open:k=>{k.seekable=!1},close:()=>{f&&f.buffer&&f.buffer.length&&f(10)},read:(k,A,H,D)=>{for(var P=0,ie=0;ie{for(var P=0;P>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,Be=[y.size>>>0,(fe=y.size,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[f+40>>2]=Be[0],ae[f+44>>2]=Be[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 Be=[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]=Be[0],ae[f+60>>2]=Be[1],_e[f+64>>2]=s%1e3*1e3,Be=[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]=Be[0],ae[f+76>>2]=Be[1],_e[f+80>>2]=u%1e3*1e3,Be=[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]=Be[0],ae[f+92>>2]=Be[1],_e[f+96>>2]=_%1e3*1e3,Be=[y.qc>>>0,(fe=y.qc,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[f+104>>2]=Be[0],ae[f+108>>2]=Be[1],0}var Ci=void 0;function qi(){return Ci+=4,ae[Ci-4>>2]}function mn(s){if(s=Xt[s],!s)throw new te(8);return s}function Rn(s,u,f){return ue(s,ne,u,f)}function Oi(s){return _e[s>>2]+4294967296*ae[s+4>>2]}var Ge=[0,31,60,91,121,152,182,213,244,274,305,335],Wi=[0,31,59,90,120,151,181,212,243,273,304,334];function Ii(s){var u=oe(s)+1,f=Vo(u);return f&&Rn(s,f,u),f}var zn={};function Ai(){if(!Vr){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 zn)zn[u]===void 0?delete s[u]:s[u]=zn[u];var f=[];for(u in s)f.push(u+"="+s[u]);Vr=f}return Vr}var Vr;function Ti(){}function yn(){}function vs(){}function Do(){}function Ya(){}function _s(){}function Lo(){}function xs(){}function Po(){}function Es(){}function Kn(){}function Cs(){}function qs(){}function zr(){}function Os(){}function Za(){}function Mo(){}function eu(){}function Bo(){}function ki(){}function Si(){}function Fo(){}function Kr(){}function Jr(){}function Jn(){}function Ri(){}function Uo(){}function o(){}function c(){}function h(){}function g(){}function E(){}function R(){}function $(){}function ve(){}function Me(){}function Le(){}function lt(){}function Dn(){}function $o(s){O=s,b||0{jo={resolve:s,reject:u}})}function sl(){var s=Vo(12300),u=s+12;ae[s>>2]=u,ae[s+4>>2]=u+12288,u=Ws[0];var f=nu[u];return f===void 0&&(f=rl++,nu[u]=f,ru[f]=u),ae[s+8>>2]=f,s}function su(s){if(!N){if(Gn===0){var u=!1,f=!1;s((y=0)=>{if(!N&&(tu=y,u=!0,f)){Gn=2,Di(()=>Li(Ln)),y=!1;try{var _=(0,n.asm[ru[ae[Ln+8>>2]]])()}catch(H){_=H,y=!0}var k=!1;if(!Ln){var A=jo;A&&(jo=null,(y?A.reject:A.resolve)(_),k=!0)}if(y&&!k)throw _}}),f=!0,u||(Gn=1,Ln=sl(),Di(()=>pu(Ln)))}else Gn===2?(Gn=0,Di(Jo),cu(Ln),Ln=null,il.forEach(y=>{if(!N)try{if(y(),!(b||0{s().then(u)})}var au={};function Pn(s,u,f,y,_){function k(X){return--dn,D!==0&&zo(D),u==="string"?L(X):u==="boolean"?!!X:X}var A={string:X=>{var se=0;if(X!=null&&X!==0){se=oe(X)+1;var Ae=Ko(se);Rn(X,Ae,se),se=Ae}return se},array:X=>{var se=Ko(X.length);return T.set(X,se),se}};s=n["_"+s];var H=[],D=0;if(y)for(var P=0;P{On("/dev"),ys(259,{read:()=>0,write:(y,_,k,A)=>A}),ws("/dev/null",259),Ee(1280,Pe),Ee(1536,st),ws("/dev/tty",1280),ws("/dev/tty1",1536);var s=new Uint8Array(1024),u=0,f=()=>(u===0&&(u=K(s).byteLength),s[--u]);jr("random",f),jr("urandom",f),On("/dev/shm"),On("/dev/shm/tmp")})(),(()=>{On("/proc");var s=On("/proc/self");On("/proc/self/fd"),Io({Ub:()=>{var u=Ft(s,"fd",16895,73);return u.Cb={cc:(f,y)=>{var _=Xt[+y];if(!_)throw new te(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),Pn("set_authorizer","number",["number"],[u])},Ti=function(u,f,y,_,k,A){if(s.has(u)){const{f:H,uc:D}=s.get(u);return H(D,f,y?L(y):null,_?L(_):null,k?L(k):null,A?L(A):null)}return 0}}(),function(){const s=new Map,u=new Map;n.createFunction=function(f,y,_,k,A,H){const D=s.size;return s.set(D,{f:H,Xb:A}),Pn("create_function","number","number string number number number number".split(" "),[f,y,_,k,D,0])},n.createAggregate=function(f,y,_,k,A,H,D){const P=s.size;return s.set(P,{step:H,Jc:D,Xb:A}),Pn("create_function","number","number string number number number number".split(" "),[f,y,_,k,P,1])},n.getFunctionUserData=function(f){return u.get(f)},vs=function(f,y,_,k){f=s.get(f),u.set(y,f.Xb),f.f(y,new Uint32Array(ne.buffer,k,_)),u.delete(y)},Ya=function(f,y,_,k){f=s.get(f),u.set(y,f.Xb),f.step(y,new Uint32Array(ne.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),Pn("progress_handler",null,["number","number"],[u,f])},Do=function(u){if(s.has(u)){const{f,uc:y}=s.get(u);return f(y)}return 0}}(),function(){function s(D,P){const ie=`get${D}`,X=`set${D}`;return new Proxy(new DataView(ne.buffer,P,D==="Int32"?4:8),{get(se,Ae){if(Ae===ie)return function(Xe,Tt){if(!Tt)throw Error("must be little endian");return se[Ae](Xe,Tt)};if(Ae===X)return function(Xe,Tt,_t){if(!_t)throw Error("must be little endian");return se[Ae](Xe,Tt,_t)};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,H=new Map;Fo=function(D,P,ie,X){H.set(L(D),{size:P,dc:Array.from(new Uint32Array(ne.buffer,X,ie))})},n.createModule=function(D,P,ie,X){u&&(ie.handleAsync=ou);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),Pn("create_module","number",["number","string","number","number"],[D,P,se,X])},Cs=function(D,P,ie,X,se,Ae){if(P=f.get(P),y.set(se,P),u){k.delete(se);for(const Xe of k)y.delete(Xe)}return X=Array.from(new Uint32Array(ne.buffer,X,ie)).map(Xe=>L(Xe)),P.module.xCreate(D,P.Xb,X,se,s("Int32",Ae))},Kn=function(D,P,ie,X,se,Ae){if(P=f.get(P),y.set(se,P),u){k.delete(se);for(const Xe of k)y.delete(Xe)}return X=Array.from(new Uint32Array(ne.buffer,X,ie)).map(Xe=>L(Xe)),P.module.xConnect(D,P.Xb,X,se,s("Int32",Ae))},Lo=function(D,P){var ie=y.get(D),X=H.get("sqlite3_index_info").dc;const se={};se.nConstraint=Je(P+X[0],"i32"),se.aConstraint=[];for(var Ae=Je(P+X[1],"*"),Xe=H.get("sqlite3_index_constraint").size,Tt=0;Tt>=2,_e[A]+_e[A+1]*2**32}const f=typeof au=="object",y=new Map,_=new Map;n.registerVFS=function(A,H){if(Pn("sqlite3_vfs_find","number",["string"],[A.name]))throw Error(`VFS '${A.name}' already registered`);f&&(A.handleAsync=ou);var D=A.Vc??64;const P=n._malloc(4);return H=Pn("register_vfs","number",["string","number","number","number"],[A.name,D,H?1:0,P]),H||(D=Je(P,"*"),y.set(D,A)),n._free(P),H};const k=f?new Set:null;Uo=function(A){const H=_.get(A);return f?k.add(A):_.delete(A),H.xClose(A)},$=function(A,H,D,P){return _.get(A).xRead(A,ne.subarray(H,H+D),u(P))},Dn=function(A,H,D,P){return _.get(A).xWrite(A,ne.subarray(H,H+D),u(P))},Le=function(A,H){return _.get(A).xTruncate(A,u(H))},Me=function(A,H){return _.get(A).xSync(A,H)},g=function(A,H){const D=_.get(A);return H=s("BigInt64",H),D.xFileSize(A,H)},E=function(A,H){return _.get(A).xLock(A,H)},lt=function(A,H){return _.get(A).xUnlock(A,H)},Ri=function(A,H){const D=_.get(A);return H=s("Int32",H),D.xCheckReservedLock(A,H)},h=function(A,H,D){const P=_.get(A);return D=new DataView(ne.buffer,D),P.xFileControl(A,H,D)},ve=function(A){return _.get(A).xSectorSize(A)},c=function(A){return _.get(A).xDeviceCharacteristics(A)},R=function(A,H,D,P,ie){if(A=y.get(A),_.set(D,A),f){k.delete(D);for(var X of k)_.delete(X)}if(X=null,P&64){X=1;const se=[];for(;X;){const Ae=ne[H++];if(Ae)se.push(Ae);else switch(ne[H]||(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 H&&(X=L(H));return ie=s("Int32",ie),A.xOpen(X,D,P,ie)},o=function(A,H,D){return y.get(A).xDelete(L(H),D)},Jn=function(A,H,D,P){return A=y.get(A),P=s("Int32",P),A.xAccess(L(H),D,P)}}();var ol={a:function(s,u,f,y){ct("Assertion failed: "+L(s)+", at: "+[u?L(u):"unknown filename",f,y?L(y):"unknown function"])},K:function(s,u){try{return s=L(s),gs(s,u),0}catch(f){if(typeof Ve>"u"||f.name!=="ErrnoError")throw f;return-f.Ob}},M:function(s,u,f){try{if(u=L(u),u=mr(s,u),f&-8)return-28;var y=Yt(u,{Yb:!0}).node;return y?(s="",f&4&&(s+="r"),f&2&&(s+="w"),f&1&&(s+="x"),s&&Wr(y,s)?-2:0):-44}catch(_){if(typeof Ve>"u"||_.name!=="ErrnoError")throw _;return-_.Ob}},L:function(s,u){try{var f=Xt[s];if(!f)throw new te(8);return gs(f.node,u),0}catch(y){if(typeof Ve>"u"||y.name!=="ErrnoError")throw y;return-y.Ob}},J:function(s){try{var u=Xt[s];if(!u)throw new te(8);var f=u.node,y=typeof f=="string"?Yt(f,{Yb:!0}).node:f;if(!y.Cb.Qb)throw new te(63);return y.Cb.Qb(y,{timestamp:Date.now()}),0}catch(_){if(typeof Ve>"u"||_.name!=="ErrnoError")throw _;return-_.Ob}},b:function(s,u,f){Ci=f;try{var y=mn(s);switch(u){case 0:var _=qi();return 0>_?-28:Wo(y,_).Wb;case 1:case 2:return 0;case 3:return y.flags;case 4:return _=qi(),y.flags|=_,0;case 5:return _=qi(),Ne[_+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return ae[Ho()>>2]=28,-1;default:return-28}}catch(k){if(typeof Ve>"u"||k.name!=="ErrnoError")throw k;return-k.Ob}},I:function(s,u){try{var f=mn(s);return Ns(an,f.path,u)}catch(y){if(typeof Ve>"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=Xt[s];if(!y)throw new te(8);if(!(y.flags&2097155))throw new te(28);return ko(y.node,u),0}catch(_){if(typeof Ve>"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=L(s),Ns(_i,s,u)}catch(f){if(typeof Ve>"u"||f.name!=="ErrnoError")throw f;return-f.Ob}},z:function(s,u,f){try{return u=L(u),u=mr(s,u),u=ee(u),u[u.length-1]==="/"&&(u=u.substr(0,u.length-1)),On(u,f),0}catch(y){if(typeof Ve>"u"||y.name!=="ErrnoError")throw y;return-y.Ob}},E:function(s,u,f,y){try{u=L(u);var _=y&256;return u=mr(s,u,y&4096),Ns(_?_i:an,u,f)}catch(k){if(typeof Ve>"u"||k.name!=="ErrnoError")throw k;return-k.Ob}},u:function(s,u,f,y){Ci=y;try{u=L(u),u=mr(s,u);var _=y?qi():0;return xi(u,f,_).Wb}catch(k){if(typeof Ve>"u"||k.name!=="ErrnoError")throw k;return-k.Ob}},s:function(s,u,f,y){try{if(u=L(u),u=mr(s,u),0>=y)return-28;var _=vi(u),k=Math.min(y,oe(_)),A=T[f+k];return Rn(_,f,y+1),T[f+k]=A,k}catch(H){if(typeof Ve>"u"||H.name!=="ErrnoError")throw H;return-H.Ob}},r:function(s){try{return s=L(s),To(s),0}catch(u){if(typeof Ve>"u"||u.name!=="ErrnoError")throw u;return-u.Ob}},H:function(s,u){try{return s=L(s),Ns(an,s,u)}catch(f){if(typeof Ve>"u"||f.name!=="ErrnoError")throw f;return-f.Ob}},o:function(s,u,f){try{if(u=L(u),u=mr(s,u),f===0){s=u;var y=Yt(s,{parent:!0}).node;if(!y)throw new te(44);var _=V(s),k=Vn(y,_),A=Oo(y,_,!1);if(A)throw new te(A);if(!y.Cb.oc)throw new te(63);if(k.$b)throw new te(10);y.Cb.oc(y,_),j(k)}else f===512?To(u):ct("Invalid flags passed to unlinkat");return 0}catch(H){if(typeof Ve>"u"||H.name!=="ErrnoError")throw H;return-H.Ob}},n:function(s,u,f){try{if(u=L(u),u=mr(s,u,!0),f){var y=Oi(f),_=ae[f+8>>2];k=1e3*y+_/1e6,f+=16,y=Oi(f),_=ae[f+8>>2],A=1e3*y+_/1e6}else var k=Date.now(),A=k;s=k;var H=Yt(u,{Yb:!0}).node;return H.Cb.Qb(H,{timestamp:Math.max(s,A)}),0}catch(D){if(typeof Ve>"u"||D.name!=="ErrnoError")throw D;return-D.Ob}},y:function(s,u){s=new Date(1e3*Oi(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?Wi:Ge)[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 H=mn(y);if(u&2&&!(f&2)&&(H.flags&2097155)!==2)throw new te(2);if((H.flags&2097155)===1)throw new te(2);if(!H.Mb.kc)throw new te(43);var D=H.Mb.kc(H,s,_,u,f),P=D.Pc;return ae[k>>2]=D.Dc,_e[A>>2]=P,0}catch(ie){if(typeof Ve>"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 te(43);y&2||A.Mb.lc&&A.Mb.lc(A,ne.slice(s,s+u),k,u,y)}}catch(H){if(typeof Ve>"u"||H.name!=="ErrnoError")throw H;return-H.Ob}},p:function(s,u,f){function y(D){return(D=D.toTimeString().match(/\(([A-Za-z ]+)\)$/))?D[1]:"GMT"}var _=new Date().getFullYear(),k=new Date(_,0,1),A=new Date(_,6,1);_=k.getTimezoneOffset();var H=A.getTimezoneOffset();_e[s>>2]=60*Math.max(_,H),ae[u>>2]=+(_!=H),s=y(k),u=y(A),s=Ii(s),u=Ii(u),H<_?(_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=ne.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),Ke();var H=1;break e}catch{}H=void 0}if(H)return!0}return!1},A:function(s,u){var f=0;return Ai().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=Ai();_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 te(8);u.pc&&(u.pc=null);try{u.Mb.close&&u.Mb.close(u)}catch(f){throw f}finally{Xt[u.Wb]=null}return u.Wb=null,0}catch(f){if(typeof Ve>"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,Be=[0,(fe=0,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[u+8>>2]=Be[0],ae[u+12>>2]=Be[1],Be=[0,(fe=0,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[u+16>>2]=Be[0],ae[u+20>>2]=Be[1],0}catch(y){if(typeof Ve>"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],D=_e[s+4>>2];s+=8;var P=_,ie=H,X=D,se=k,Ae=T;if(0>X||0>se)throw new te(28);if(P.Wb===null)throw new te(8);if((P.flags&2097155)===1)throw new te(8);if((P.node.mode&61440)===16384)throw new te(31);if(!P.Mb.read)throw new te(28);var Xe=typeof se<"u";if(!Xe)se=P.position;else if(!P.seekable)throw new te(70);var Tt=P.Mb.read(P,Ae,ie,X,se);Xe||(P.position+=Tt);var _t=Tt;if(0>_t){var wn=-1;break e}if(u+=_t,_t>2]=wn,0}catch(Ut){if(typeof Ve>"u"||Ut.name!=="ErrnoError")throw Ut;return Ut.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 So(k,u,y),Be=[k.position>>>0,(fe=k.position,1<=+Math.abs(fe)?0>>0:~~+Math.ceil((fe-+(~~fe>>>0))/4294967296)>>>0:0)],ae[_>>2]=Be[0],ae[_+4>>2]=Be[1],k.pc&&u===0&&y===0&&(k.pc=null),0}catch(A){if(typeof Ve>"u"||A.name!=="ErrnoError")throw A;return A.Ob}},D:function(s){try{var u=mn(s);return su(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 Ve>"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],D=_e[s+4>>2];s+=8;var P=_,ie=H,X=D,se=k,Ae=T;if(0>X||0>se)throw new te(28);if(P.Wb===null)throw new te(8);if(!(P.flags&2097155))throw new te(8);if((P.node.mode&61440)===16384)throw new te(31);if(!P.Mb.write)throw new te(28);P.seekable&&P.flags&1024&&So(P,0,2);var Xe=typeof se<"u";if(!Xe)se=P.position;else if(!P.seekable)throw new te(70);var Tt=P.Mb.write(P,Ae,ie,X,se,void 0);Xe||(P.position+=Tt);var _t=Tt;if(0>_t){var wn=-1;break e}u+=_t,typeof k<"u"&&(k+=_t)}wn=u}return _e[y>>2]=wn,0}catch(Ut){if(typeof Ve>"u"||Ut.name!=="ErrnoError")throw Ut;return Ut.Ob}},ra:Ti,N:yn,ga:vs,ca:Do,Y:Ya,la:_s,G:Lo,h:xs,oa:Po,ja:Es,ea:Kn,fa:Cs,k:qs,v:zr,pa:Os,g:Za,qa:Mo,da:eu,ha:Bo,ia:ki,na:Si,c:Fo,ka:Kr,ma:Jr,aa:Jn,V:Ri,$:Uo,ba:o,S:c,U:h,Z:g,X:E,R,Q:$,T:ve,_:Me,O:Le,W:lt,P:Dn};(function(){function s(f){if(f=f.exports,f=nl(f),n.asm=f,C=n.asm.sa,Ke(),It.unshift(n.asm.ta),ge--,n.monitorRunDependencies&&n.monitorRunDependencies(ge),ge==0&&qe){var y=qe;qe=null,y()}return f}var u={a:ol};if(ge++,n.monitorRunDependencies&&n.monitorRunDependencies(ge),n.instantiateWasm)try{return n.instantiateWasm(u,s)}catch(f){Y("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 Ho(){return(Ho=n.asm.rb).apply(null,arguments)}var Vo=n._malloc=function(){return(Vo=n._malloc=n.asm.sb).apply(null,arguments)},cu=n._free=function(){return(cu=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 lu=n._main=function(){return(lu=n._main=n.asm.Bb).apply(null,arguments)};function fu(){return(fu=n.asm.Db).apply(null,arguments)}function hu(){return(hu=n.asm.Eb).apply(null,arguments)}function du(){return(du=n.asm.Fb).apply(null,arguments)}function zo(){return(zo=n.asm.Gb).apply(null,arguments)}function Ko(){return(Ko=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 Li(){return(Li=n.asm.Kb).apply(null,arguments)}function Jo(){return(Jo=n.asm.Lb).apply(null,arguments)}n.getTempRet0=hu,n.ccall=Pn,n.cwrap=function(s,u,f,y){var _=!f||f.every(k=>k==="number"||k==="boolean");return u!=="string"&&_&&!y?n["_"+s]:function(){return Pn(s,u,f,arguments,y)}},n.setValue=x,n.getValue=Je,n.UTF8ToString=L,n.stringToUTF8=Rn,n.lengthBytesUTF8=oe;var Is;qe=function s(){Is||W(),Is||(qe=s)};function W(){function s(){if(!Is&&(Is=!0,n.calledRun=!0,!N)){if(n.noFSInit||Ro||(Ro=!0,Qr(),n.stdin=n.stdin,n.stdout=n.stdout,n.stderr=n.stderr,n.stdin?jr("stdin",n.stdin):Ni("/dev/tty","/dev/stdin"),n.stdout?jr("stdout",null,n.stdout):Ni("/dev/tty","/dev/stdout"),n.stderr?jr("stderr",null,n.stderr):Ni("/dev/tty1","/dev/stderr"),xi("/dev/stdin",0),xi("/dev/stdout",1),xi("/dev/stderr",1)),Bt=!1,Gt(It),Gt(je),i(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),G){var u=lu;try{var f=u(0,0);O=f,$o(f)}catch(y){Qo(y)}}if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)u=n.postRun.shift(),Jt.unshift(u);Gt(Jt)}}if(!(0{try{await navigator.locks.request(e,n,l=>{if(i(l),l)return new Promise(m=>r(this,lo).set(e,m))})}catch(l){a(l)}})}_releaseWebLock(e){var n;(n=r(this,lo).get(e))==null||n(),r(this,lo).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}}}Ht=new WeakMap,lo=new WeakMap,$a=new WeakMap,Qa=new WeakSet,Vl=async function(e,n){const i=n&nN;try{const a=()=>e.call(this,i);return await J(this,$a,r(this,$a).then(a,a)),J(this,Ht,i),ze}catch(a){return a.name==="AbortError"?Fb:(console.error(a),Qb)}},Ic=new WeakSet,Fp=async function(e){if(e===r(this,Ht))return ze;switch(r(this,Ht)){case Ss:switch(e){case Hi:return this._NONEtoSHARED();default:throw new Error(`unexpected transition ${r(this,Ht)} -> ${e}`)}case Hi:switch(e){case Du:return this._SHAREDtoRESERVED();case Lu:return this._SHAREDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${r(this,Ht)} -> ${e}`)}case Du:switch(e){case Lu:return this._RESERVEDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${r(this,Ht)} -> ${e}`)}default:throw new Error(`unexpected transition ${r(this,Ht)} -> ${e}`)}},Ac=new WeakSet,Up=async function(e){if(e===r(this,Ht))return ze;switch(r(this,Ht)){case Lu:switch(e){case Hi:return this._EXCLUSIVEtoSHARED();case Ss:return this._EXCLUSIVEtoNONE();default:throw new Error(`unexpected transition ${r(this,Ht)} -> ${e}`)}case Du:switch(e){case Hi:return this._RESERVEDtoSHARED();case Ss:return this._RESERVEDtoNONE();default:throw new Error(`unexpected transition ${r(this,Ht)} -> ${e}`)}case Hi:switch(e){case Ss:return this._SHAREDtoNONE();default:throw new Error(`unexpected transition ${r(this,Ht)} -> ${e}`)}default:throw new Error(`unexpected transition ${r(this,Ht)} -> ${e}`)}};class iN extends rN{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 sN=5e3;let oN=0;const bl=new WeakMap;function gr(...t){}var fo,ho,ja,Dt,Ha,po,is,Tc,$p;class aN{constructor(e,n={durability:"default"}){F(this,Tc);F(this,fo,void 0);F(this,ho,void 0);F(this,ja,void 0);F(this,Dt,null);F(this,Ha,0);F(this,po,Promise.resolve());F(this,is,Promise.resolve());J(this,ho,Promise.resolve(e).then(i=>J(this,fo,i))),J(this,ja,n)}async close(){const e=r(this,fo)??await r(this,ho);await r(this,po),await this.sync(),e.close()}async run(e,n){const i=r(this,po).then(()=>Oe(this,Tc,$p).call(this,e,n));return J(this,po,i.catch(()=>{})),i}async sync(){await r(this,is),J(this,is,Promise.resolve())}}fo=new WeakMap,ho=new WeakMap,ja=new WeakMap,Dt=new WeakMap,Ha=new WeakMap,po=new WeakMap,is=new WeakMap,Tc=new WeakSet,$p=async function(e,n){var a,l;const i=r(this,fo)??await r(this,ho);if(e==="readwrite"&&((a=r(this,Dt))==null?void 0:a.mode)==="readonly")J(this,Dt,null);else if(performance.now()-r(this,Ha)>sN){try{(l=r(this,Dt))==null||l.commit()}catch(m){if(m.name!=="InvalidStateError")throw m}await new Promise(m=>setTimeout(m)),J(this,Dt,null)}for(let m=0;m<2;++m){if(!r(this,Dt)){J(this,Dt,i.transaction(i.objectStoreNames,e,r(this,ja)));const w=J(this,Ha,performance.now());J(this,is,r(this,is).then(()=>new Promise((v,d)=>{r(this,Dt).addEventListener("complete",I=>{v(),r(this,Dt)===I.target&&J(this,Dt,null),gr(`transaction ${bl.get(I.target)} complete`)}),r(this,Dt).addEventListener("abort",I=>{console.warn("tx abort",(performance.now()-w)/1e3);const M=I.target.error;d(M),r(this,Dt)===I.target&&J(this,Dt,null),gr(`transaction ${bl.get(I.target)} aborted`,M)})}))),bl.set(r(this,Dt),oN++)}try{const w=Object.fromEntries(Array.from(i.objectStoreNames,v=>[v,new uN(r(this,Dt).objectStore(v))]));return await n(w)}catch(w){if(J(this,Dt,null),m)throw w}}};function Zr(t){return new Promise((e,n)=>{t.addEventListener("success",()=>e(t.result)),t.addEventListener("error",()=>n(t.error))})}var At;class uN{constructor(e){F(this,At,void 0);J(this,At,e)}get(e){gr(`get ${r(this,At).name}`,e);const n=r(this,At).get(e);return Zr(n)}getAll(e,n){gr(`getAll ${r(this,At).name}`,e,n);const i=r(this,At).getAll(e,n);return Zr(i)}getKey(e){gr(`getKey ${r(this,At).name}`,e);const n=r(this,At).getKey(e);return Zr(n)}getAllKeys(e,n){gr(`getAllKeys ${r(this,At).name}`,e,n);const i=r(this,At).getAllKeys(e,n);return Zr(i)}put(e,n){gr(`put ${r(this,At).name}`,e,n);const i=r(this,At).put(e,n);return Zr(i)}delete(e){gr(`delete ${r(this,At).name}`,e);const n=r(this,At).delete(e);return Zr(n)}clear(){gr(`clear ${r(this,At).name}`);const e=r(this,At).clear();return Zr(e)}index(e){return new cN(r(this,At).index(e))}}At=new WeakMap;var ss;class cN{constructor(e){F(this,ss,void 0);J(this,ss,e)}getAllKeys(e,n){gr(`IDBIndex.getAllKeys ${r(this,ss).objectStore.name}<${r(this,ss).name}>`,e,n);const i=r(this,ss).getAllKeys(e,n);return Zr(i)}}ss=new WeakMap;const lN=512,Sh=3e3,Rh={durability:"default",purge:"deferred",purgeAtLeast:16};function gn(...t){}var ci,Vt,mt,os,as,Rr,Va,zl,kc,Qp,Sc,jp,li,Rs,Rc,Hp;class fN extends tN{constructor(n="wa-sqlite",i=Rh){super();F(this,Va);F(this,kc);F(this,Sc);F(this,li);F(this,Rc);F(this,ci,void 0);F(this,Vt,new Map);F(this,mt,void 0);F(this,os,new Set);F(this,as,performance.now());F(this,Rr,new Set);this.name=n,J(this,ci,Object.assign({},Rh,i)),J(this,mt,new aN(hN(n),{durability:r(this,ci).durability}))}async close(){var n;for(const i of r(this,Vt).keys())await this.xClose(i);await((n=r(this,mt))==null?void 0:n.close()),J(this,mt,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 iN(m.pathname)};return r(this,Vt).set(i,w),await r(this,mt).run("readwrite",async({blocks:v})=>{if(w.block0=await v.get(Oe(this,li,Rs).call(this,w,0)),!w.block0)if(a&Bp)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&Hb,!0),ze}catch(m){return console.error(m),Mp}})}xClose(n){return this.handleAsync(async()=>{try{const i=r(this,Vt).get(n);return i&&(gn(`xClose ${i.path}`),r(this,Vt).delete(n),i.flags&zb&&r(this,mt).run("readwrite",({blocks:a})=>{a.delete(IDBKeyRange.bound([i.path],[i.path,[]]))})),ze}catch(i){return console.error(i),Et}})}xRead(n,i,a){return this.handleAsync(async()=>{const l=r(this,Vt).get(n);gn(`xRead ${l.path} ${i.byteLength} ${a}`);try{return await r(this,mt).run("readonly",async({blocks:w})=>{let v=0;for(;vSh){const m=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&r(this,Rr).add(n),await new Promise(v=>setTimeout(v));const w=Oe(this,Va,zl).call(this,n,i,a);return J(this,as,performance.now()),w});return l&&r(this,Rr).delete(n),m}return Oe(this,Va,zl).call(this,n,i,a)}xTruncate(n,i){const a=r(this,Vt).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,mt).run("readwrite",({blocks:m})=>{m.delete(Oe(this,li,Rs).call(this,a,-1/0,-i)),m.put(l)}),ze}catch(l){return console.error(l),Et}}xSync(n,i){const a=r(this,Rr).has(n);if(a||r(this,ci).durability!=="relaxed"||performance.now()-r(this,as)>Sh){const m=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&r(this,Rr).add(n);const w=await Oe(this,kc,Qp).call(this,n,i);return J(this,as,performance.now()),w});return a&&r(this,Rr).delete(n),m}const l=r(this,Vt).get(n);return gn(`xSync ${l.path} ${i}`),ze}xFileSize(n,i){const a=r(this,Vt).get(n);return gn(`xFileSize ${a.path}`),i.setBigInt64(0,BigInt(a.block0.fileSize),!0),ze}xLock(n,i){return this.handleAsync(async()=>{const a=r(this,Vt).get(n);gn(`xLock ${a.path} ${i}`);try{const l=await a.locks.lock(i);return l===ze&&a.locks.state===Hi&&(a.block0=await r(this,mt).run("readonly",({blocks:m})=>m.get(Oe(this,li,Rs).call(this,a,0)))),l}catch(l){return console.error(l),Et}})}xUnlock(n,i){return this.handleAsync(async()=>{const a=r(this,Vt).get(n);gn(`xUnlock ${a.path} ${i}`);try{return a.locks.unlock(i)}catch(l){return console.error(l),Et}})}xCheckReservedLock(n,i){return this.handleAsync(async()=>{const a=r(this,Vt).get(n);gn(`xCheckReservedLock ${a.path}`);const l=await a.locks.isSomewhereReserved();return i.setInt32(0,l?1:0,!0),ze})}xSectorSize(n){return lN}xDeviceCharacteristics(n){return Yb|Jb|Gb|Xb}xFileControl(n,i,a){const l=r(this,Vt).get(n);switch(gn(`xFileControl ${l.path} ${i}`),i){case 11:return l.overwrite=!0,ze;case 21:if(l.overwrite)try{return this.handleAsync(async()=>(await Oe(this,Rc,Hp).call(this,l),ze))}catch(m){return console.error(m),Et}return ze;case 22:return l.overwrite=!1,ze;case 31:return this.handleAsync(async()=>{try{return l.block0.version--,l.changedPages=new Set,r(this,mt).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)}),ze}catch(m){return console.error(m),Et}});case 32:try{const m=Object.assign({},l.block0);m.data=m.data.slice();const w=l.changedPages;return l.changedPages=null,r(this,mt).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 I of w)d.data.set(I,m.version);v.put(d),Oe(this,Sc,jp).call(this,l.path,d.count)}),ze}catch(m){return console.error(m),Et}case 33:return this.handleAsync(async()=>{try{return l.changedPages=null,l.block0=await r(this,mt).run("readonly",({blocks:m})=>m.get([l.path,0,l.block0.version+1])),ze}catch(m){return console.error(m),Et}});default:return Pp}}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,mt).run("readonly",({blocks:w})=>w.getKey(Oe(this,li,Rs).call(this,{path:l},0)));return a.setInt32(0,m?1:0,!0),ze}catch(l){return console.error(l),Et}})}xDelete(n,i){return this.handleAsync(async()=>{const a=new URL(n,"file://localhost/").pathname;try{return r(this,mt).run("readwrite",({blocks:l})=>l.delete(IDBKeyRange.bound([a],[a,[]]))),i&&await r(this,mt).sync(),ze}catch(l){return console.error(l),Et}})}async purge(n){const i=Date.now();await r(this,mt).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`)})}}ci=new WeakMap,Vt=new WeakMap,mt=new WeakMap,os=new WeakMap,as=new WeakMap,Rr=new WeakMap,Va=new WeakSet,zl=function(n,i,a){const l=r(this,Vt).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,mt).run("readwrite",({blocks:v})=>v.put(w))):r(this,mt).run("readwrite",({blocks:v})=>v.put(w)),ze}catch(m){return console.error(m),Et}},kc=new WeakSet,Qp=async function(n,i){const a=r(this,Vt).get(n);gn(`xSync ${a.path} ${i}`);try{await r(this,mt).sync()}catch(l){return console.error(l),Et}return ze},Sc=new WeakSet,jp=function(n,i){r(this,ci).purge==="manual"||r(this,os).has(n)||i{this.purge(n),r(this,os).delete(n)}):setTimeout(()=>{this.purge(n),r(this,os).delete(n)}),r(this,os).add(n))},li=new WeakSet,Rs=function(n,i,a=0){const l=!i||-i{const Y=await B.index("version").getAllKeys(IDBKeyRange.bound([n.path,M+1],[n.path,1/0]));for(const Z of Y)B.delete(Z);B.delete([n.path,"purge",0]);for(let Z=0;Z=I)break;const T={path:C.path,offset:O,version:M,data:C.data.subarray(N*l,(N+1)*l)};T.offset===0&&(T.fileSize=I,n.block0=T),B.put(T)}}}})};function hN(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 dN=""+new URL("wa-sqlite-async-24800831.wasm",import.meta.url).href,pN=new hb({async database(){const t=await eN({locateFile:()=>dN}),e=Zb(t),n="wa-sqlite-test";e.vfs_register(new fN(n));const i=await e.open_v2(n,void 0,n);return{sqlite:e,db:i}}});function mN(){console.log("start wa-sqlite test"),Of(pN).then(t=>{t==null||t.forEach(e=>console.log("[wa-sqlite]",e))})}function yN(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)})}}}function wN(t){const e=yN(t);return{...e,once(n,i){const a=l=>{e.off(n,a),i(l)};e.on(n,a)}}}var gN=class{constructor(t){Te(this,"config");Te(this,"worker");Te(this,"connection");Te(this,"connectionMutex",new bN);Te(this,"mitt");this.config=t}async init(){this.worker=this.config.worker??new Worker(new URL(""+new URL("worker-72ad2512.js",import.meta.url).href,self.location),{type:"module"}),this.mitt=wN(),this.worker.onmessage=({data:{msg:e,type:n}})=>{var i;(i=this.mitt)==null||i.emit(n,e)};const t={type:"init",dbName:this.config.dbName,url:this.config.url};this.worker.postMessage(t),await new Promise((e,n)=>{var i;(i=this.mitt)==null||i.once("init",({err:a})=>{a?n(a):e()})}),this.connection=new NN(this.worker,this.mitt),this.config.onCreateConnection&&await this.config.onCreateConnection(this.connection)}async acquireConnection(){return await this.connectionMutex.lock(),this.connection}async beginTransaction(t){await t.executeQuery(Mr.raw("begin"))}async commitTransaction(t){await t.executeQuery(Mr.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(Mr.raw("rollback"))}async releaseConnection(){this.connectionMutex.unlock()}async destroy(){if(this.worker)return this.worker.postMessage({type:"close"}),new Promise((t,e)=>{var n;(n=this.mitt)==null||n.once("close",({err:i})=>{var a,l;i?e(i):((a=this.worker)==null||a.terminate(),(l=this.mitt)==null||l.all.clear(),this.mitt=void 0,t())})})}},bN=class{constructor(){Te(this,"promise");Te(this,"resolve")}async lock(){for(;this.promise;)await this.promise;this.promise=new Promise(t=>{this.resolve=t})}unlock(){const t=this.resolve;this.promise=void 0,this.resolve=void 0,t==null||t()}},NN=class{constructor(t,e){Te(this,"worker");Te(this,"mitt");this.worker=t,this.mitt=e}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 this.worker.postMessage(l),new Promise((m,w)=>{this.mitt||w("kysely instance has been destroyed"),this.mitt.once("run",({data:v,err:d})=>{!d&&v?m(v):w(d)})})}},za,Mh,vN=(Mh=class{constructor(t){F(this,za,void 0);J(this,za,t)}createDriver(){return new gN(r(this,za))}createQueryCompiler(){return new Ip}createAdapter(){return new kp}createIntrospector(t){return new Ap(t)}},za=new WeakMap,Mh);const _N=""+new URL("wa-sqlite-async-24800831.wasm",import.meta.url).href,xN=new vN({dbName:"wa-sqlite-worker-test",url:_N});function EN(){console.log("start wa-sqlite-worker test"),Of(xN).then(t=>{t==null||t.forEach(e=>console.log("[wa-sqlite-worker]",e))})}const CN=qt("h1",null,[ma(" test "),qt("a",{href:"https://github.com/kysely-org/kysely",target:"_blank"},"Kysely"),ma(" WASM dialect ")],-1),qN=qt("br",null,null,-1),ON=qt("h3",null,"see worker result in console",-1),WN=qt("h3",null,[ma(" you can explore "),qt("a",{href:"https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API#origin_private_file_system",target:"_blank"}," OPFS "),ma(" file using "),qt("a",{href:"https://chrome.google.com/webstore/detail/opfs-explorer/acndjpgkpaclldomagafnognkcgjignd",target:"_blank"}," opfs-explorer ")],-1),IN=qt("br",null,null,-1),AN={class:"buttons"},TN=qt("br",null,null,-1),kN=qt("div",null," result run in main thread: ",-1),SN=ly({__name:"App",setup(t){const e=new Mb,{result:n,run:i}=Pb(),a=new Bb;function l(){i()}function m(){e.postMessage("")}function w(){a.postMessage("")}function v(){mN()}function d(){EN()}async function I(){(await window.indexedDB.databases()).forEach(Y=>{window.indexedDB.deleteDatabase(Y.name)})}async function M(){const B=await navigator.storage.getDirectory();await xh("sqljs"),await xh("sqlijsWorker"),await I();try{await B.removeEntry("test.db")}catch{}try{await B.removeEntry("test.db-journal")}catch{}console.log("clear all")}return(B,Y)=>(By(),$y(or,null,[CN,qN,ON,WN,IN,qt("div",AN,[qt("button",{onClick:Y[0]||(Y[0]=Z=>l())}," test sqljs in main thread "),qt("button",{onClick:Y[1]||(Y[1]=Z=>m())}," test sqljs in Worker "),qt("button",{onClick:Y[2]||(Y[2]=Z=>w())}," test officialWasm in Worker "),qt("button",{onClick:Y[3]||(Y[3]=Z=>v())}," test wa-sqlite in main thread "),qt("button",{onClick:Y[4]||(Y[4]=Z=>d())}," test wa-sqlite in Worker "),qt("button",{onClick:Y[5]||(Y[5]=Z=>M())}," clear ")]),TN,kN,qt("pre",null,""+em(ad(n))+` + `,1)],64))}});qw(SN).mount("#root"); diff --git a/assets/index-cc70787f.js b/assets/index-cc70787f.js deleted file mode 100644 index 7184220..0000000 --- a/assets/index-cc70787f.js +++ /dev/null @@ -1,15 +0,0 @@ -var Wm=Object.defineProperty;var Im=(t,e,n)=>e in t?Wm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Yt=(t,e,n)=>(Im(t,typeof e!="symbol"?e+"":e,n),n),kl=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var r=(t,e,n)=>(kl(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)},D=(t,e,n,i)=>(kl(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n);var qe=(t,e,n)=>(kl(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 Nf(t,e){const n=Object.create(null),i=t.split(",");for(let a=0;a!!n[a.toLowerCase()]:a=>!!n[a]}function vf(t){if(Ie(t)){const e={};for(let n=0;n{if(n){const i=n.split(Tm);i.length>1&&(e[i[0].trim()]=i[1].trim())}}),e}function _f(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===Cd||!ke(t.toString))?JSON.stringify(t,_d,2):String(t),_d=(t,e)=>e&&e.__v_isRef?_d(t,e.value):eo(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((n,[i,a])=>(n[`${i} =>`]=a,n),{})}:xd(e)?{[`Set(${e.size})`]:[...e.values()]}:yt(e)&&!Ie(e)&&!Od(e)?String(e):e,lt={},Zs=[],dr=()=>{},Pm=()=>!1,Mm=/^on[^a-z]/,ol=t=>Mm.test(t),xf=t=>t.startsWith("onUpdate:"),on=Object.assign,Ef=(t,e)=>{const n=t.indexOf(e);n>-1&&t.splice(n,1)},Bm=Object.prototype.hasOwnProperty,Be=(t,e)=>Bm.call(t,e),Ie=Array.isArray,eo=t=>al(t)==="[object Map]",xd=t=>al(t)==="[object Set]",ke=t=>typeof t=="function",Lt=t=>typeof t=="string",Cf=t=>typeof t=="symbol",yt=t=>t!==null&&typeof t=="object",Ed=t=>yt(t)&&ke(t.then)&&ke(t.catch),Cd=Object.prototype.toString,al=t=>Cd.call(t),Fm=t=>al(t).slice(8,-1),Od=t=>al(t)==="[object Object]",Of=t=>Lt(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,Gu=Nf(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),ul=t=>{const e=Object.create(null);return n=>e[n]||(e[n]=t(n))},Um=/-(\w)/g,Ro=ul(t=>t.replace(Um,(e,n)=>n?n.toUpperCase():"")),$m=/\B([A-Z])/g,Qo=ul(t=>t.replace($m,"-$1").toLowerCase()),qd=ul(t=>t.charAt(0).toUpperCase()+t.slice(1)),Sl=ul(t=>t?`on${qd(t)}`:""),Ia=(t,e)=>!Object.is(t,e),Rl=(t,e)=>{for(let n=0;n{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})},Qm=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let ih;const jm=()=>ih||(ih=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});let er;class Hm{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},Wd=t=>(t.w&_i)>0,Id=t=>(t.n&_i)>0,Km=({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)&&w.push(d)})}else switch(n!==void 0&&w.push(m.get(n)),e){case"add":Ie(t)?Of(n)&&w.push(m.get("length")):(w.push(m.get(vs)),eo(t)&&w.push(m.get(zl)));break;case"delete":Ie(t)||(w.push(m.get(vs)),eo(t)&&w.push(m.get(zl)));break;case"set":eo(t)&&w.push(m.get(vs));break}if(w.length===1)w[0]&&Kl(w[0]);else{const v=[];for(const d of w)d&&v.push(...d);Kl(qf(v))}}function Kl(t,e){const n=Ie(t)?t:[...t];for(const i of n)i.computed&&oh(i);for(const i of n)i.computed||oh(i)}function oh(t,e){(t!==cr||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const Gm=Nf("__proto__,__v_isRef,__isVue"),kd=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(Cf)),Xm=If(),Ym=If(!1,!0),Zm=If(!0),ah=ey();function ey(){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 ty(t){const e=Fe(this);return xn(e,"has",t),e.hasOwnProperty(t)}function If(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?wy:Pd:e?Ld:Dd).get(i))return i;const m=Ie(i);if(!t){if(m&&Be(ah,a))return Reflect.get(ah,a,l);if(a==="hasOwnProperty")return ty}const w=Reflect.get(i,a,l);return(Cf(a)?kd.has(a):Gm(a))||(t||xn(i,"get",a),e)?w:rn(w)?m&&Of(a)?w:w.value:yt(w)?t?Md(w):kf(w):w}}const ny=Sd(),ry=Sd(!0);function Sd(t=!1){return function(n,i,a,l){let m=n[i];if(Do(m)&&rn(m)&&!rn(a))return!1;if(!t&&(!uc(a)&&!Do(a)&&(m=Fe(m),a=Fe(a)),!Ie(n)&&rn(m)&&!rn(a)))return m.value=a,!0;const w=Ie(n)&&Of(i)?Number(i)t,cl=t=>Reflect.getPrototypeOf(t);function Fu(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}=cl(a),w=i?Af:n?Rf:Aa;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 Uu(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 $u(t,e=!1){return t=t.__v_raw,!e&&xn(Fe(t),"iterate",vs),Reflect.get(t,"size",t)}function uh(t){t=Fe(t);const e=Fe(this);return cl(e).has.call(e,t)||(e.add(t),Hr(e,"add",t,t)),this}function ch(t,e){e=Fe(e);const n=Fe(this),{has:i,get:a}=cl(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 lh(t){const e=Fe(this),{has:n,get:i}=cl(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 fh(){const t=Fe(this),e=t.size!==0,n=t.clear();return e&&Hr(t,"clear",void 0,void 0),n}function Qu(t,e){return function(i,a){const l=this,m=l.__v_raw,w=Fe(m),v=e?Af:t?Rf:Aa;return!t&&xn(w,"iterate",vs),m.forEach((d,I)=>i.call(a,v(d),v(I),l))}}function ju(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),I=n?Af:e?Rf:Aa;return!e&&xn(l,"iterate",v?zl:vs),{next(){const{value:F,done:U}=d.next();return U?{value:F,done:U}:{value:w?[I(F[0]),I(F[1])]:I(F),done:U}},[Symbol.iterator](){return this}}}}function ri(t){return function(...e){return t==="delete"?!1:this}}function cy(){const t={get(l){return Fu(this,l)},get size(){return $u(this)},has:Uu,add:uh,set:ch,delete:lh,clear:fh,forEach:Qu(!1,!1)},e={get(l){return Fu(this,l,!1,!0)},get size(){return $u(this)},has:Uu,add:uh,set:ch,delete:lh,clear:fh,forEach:Qu(!1,!0)},n={get(l){return Fu(this,l,!0)},get size(){return $u(this,!0)},has(l){return Uu.call(this,l,!0)},add:ri("add"),set:ri("set"),delete:ri("delete"),clear:ri("clear"),forEach:Qu(!0,!1)},i={get(l){return Fu(this,l,!0,!0)},get size(){return $u(this,!0)},has(l){return Uu.call(this,l,!0)},add:ri("add"),set:ri("set"),delete:ri("delete"),clear:ri("clear"),forEach:Qu(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(l=>{t[l]=ju(l,!1,!1),n[l]=ju(l,!0,!1),e[l]=ju(l,!1,!0),i[l]=ju(l,!0,!0)}),[t,n,e,i]}const[ly,fy,hy,dy]=cy();function Tf(t,e){const n=e?t?dy:hy:t?fy:ly;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 py={get:Tf(!1,!1)},my={get:Tf(!1,!0)},yy={get:Tf(!0,!1)},Dd=new WeakMap,Ld=new WeakMap,Pd=new WeakMap,wy=new WeakMap;function gy(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function by(t){return t.__v_skip||!Object.isExtensible(t)?0:gy(Fm(t))}function kf(t){return Do(t)?t:Sf(t,!1,Rd,py,Dd)}function Ny(t){return Sf(t,!1,uy,my,Ld)}function Md(t){return Sf(t,!0,ay,yy,Pd)}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=by(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 Do(t)?to(t.__v_raw):!!(t&&t.__v_isReactive)}function Do(t){return!!(t&&t.__v_isReadonly)}function uc(t){return!!(t&&t.__v_isShallow)}function Bd(t){return to(t)||Do(t)}function Fe(t){const e=t&&t.__v_raw;return e?Fe(e):t}function Fd(t){return ac(t,"__v_skip",!0),t}const Aa=t=>yt(t)?kf(t):t,Rf=t=>yt(t)?Md(t):t;function Ud(t){bi&&cr&&(t=Fe(t),Td(t.dep||(t.dep=qf())))}function $d(t,e){t=Fe(t);const n=t.dep;n&&Kl(n)}function rn(t){return!!(t&&t.__v_isRef===!0)}function vy(t){return _y(t,!1)}function _y(t,e){return rn(t)?t:new xy(t,e)}class xy{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 Ud(this),this._value}set value(e){const n=this.__v_isShallow||uc(e)||Do(e);e=n?e:Fe(e),Ia(e,this._rawValue)&&(this._rawValue=e,this._value=n?e:Aa(e),$d(this))}}function Qd(t){return rn(t)?t.value:t}const Ey={get:(t,e,n)=>Qd(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 jd(t){return to(t)?t:new Proxy(t,Ey)}var Hd;class Cy{constructor(e,n,i,a){this._setter=n,this.dep=void 0,this.__v_isRef=!0,this[Hd]=!1,this._dirty=!0,this.effect=new Wf(e,()=>{this._dirty||(this._dirty=!0,$d(this))}),this.effect.computed=this,this.effect.active=this._cacheable=!a,this.__v_isReadonly=i}get value(){const e=Fe(this);return Ud(e),(e._dirty||!e._cacheable)&&(e._dirty=!1,e._value=e.effect.run()),e._value}set value(e){this._setter(e)}}Hd="__v_isReadonly";function Oy(t,e,n=!1){let i,a;const l=ke(t);return l?(i=t,a=dr):(i=t.get,a=t.set),new Cy(i,a,l||!a,n)}function Ni(t,e,n,i){let a;try{a=i?t(...i):t()}catch(l){ll(l,e,n)}return a}function Hn(t,e,n,i){if(ke(t)){const l=Ni(t,e,n,i);return l&&Ed(l)&&l.catch(m=>{ll(m,e,n)}),l}const a=[];for(let l=0;l>>1;ka(nn[i])Wr&&nn.splice(e,1)}function Ty(t){Ie(t)?no.push(...t):(!Dr||!Dr.includes(t,t.allowRecurse?Ji+1:Ji))&&no.push(t),zd()}function hh(t,e=Ta?Wr+1:0){for(;eka(n)-ka(i)),Ji=0;Jit.id==null?1/0:t.id,ky=(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 Jd(t){Jl=!1,Ta=!0,nn.sort(ky);const e=dr;try{for(Wr=0;WrLt(Y)?Y.trim():Y)),F&&(a=n.map(Qm))}let w,v=i[w=Sl(e)]||i[w=Sl(Ro(e))];!v&&l&&(v=i[w=Sl(Qo(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 Gd(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(!ke(t)){const v=d=>{const I=Gd(d,e,!0);I&&(w=!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&&!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 fl(t,e){return!t||!ol(e)?!1:(e=e.slice(2).replace(/Once$/,""),Be(t,e[0].toLowerCase()+e.slice(1))||Be(t,Qo(e))||Be(t,e))}let lr=null,Xd=null;function cc(t){const e=lr;return lr=t,Xd=t&&t.type.__scopeId||null,e}function Ry(t,e=lr,n){if(!e||t._n)return t;const i=(...a)=>{i._d&&vh(-1);const l=cc(e);let m;try{m=t(...a)}finally{cc(l),i._d&&vh(1)}return m};return i._n=!0,i._c=!0,i._d=!0,i}function Dl(t){const{type:e,vnode:n,proxy:i,withProxy:a,props:l,propsOptions:[m],slots:w,attrs:v,emit:d,render:I,renderCache:F,data:U,setupState:Y,ctx:Z,inheritAttrs:b}=t;let C,N;const q=cc(t);try{if(n.shapeFlag&4){const ne=a||i;C=Or(I.call(ne,ne,F,l,Y,U,Z)),N=v}else{const ne=e;C=Or(ne.length>1?ne(l,{attrs:v,slots:w,emit:d}):ne(l,null)),N=e.props?v:Dy(v)}}catch(ne){va.length=0,ll(ne,t,1),C=_s(Ur)}let T=C;if(N&&b!==!1){const ne=Object.keys(N),{shapeFlag:Ne}=T;ne.length&&Ne&7&&(m&&ne.some(xf)&&(N=Ly(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,cc(q),C}const Dy=t=>{let e;for(const n in t)(n==="class"||n==="style"||ol(n))&&((e||(e={}))[n]=t[n]);return e},Ly=(t,e)=>{const n={};for(const i in t)(!xf(i)||!(i.slice(9)in e))&&(n[i]=t[i]);return n};function Py(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?dh(i,m,d):!!m;if(v&8){const I=e.dynamicProps;for(let F=0;Ft.__isSuspense;function Fy(t,e){e&&e.pendingBranch?Ie(t)?e.effects.push(...t):e.effects.push(t):Ty(t)}function Uy(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 Xu(t,e,n=!1){const i=Ot||lr;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 Hu={};function Ll(t,e,n){return Yd(t,e,n)}function Yd(t,e,{immediate:n,deep:i,flush:a,onTrack:l,onTrigger:m}=lt){const w=zm()===(Ot==null?void 0:Ot.scope)?Ot:null;let v,d=!1,I=!1;if(rn(t)?(v=()=>t.value,d=uc(t)):to(t)?(v=()=>t,i=!0):Ie(t)?(I=!0,d=t.some(T=>to(T)||uc(T)),v=()=>t.map(T=>{if(rn(T))return T.value;if(to(T))return Ks(T);if(ke(T))return Ni(T,w,2)})):ke(t)?e?v=()=>Ni(t,w,2):v=()=>{if(!(w&&w.isUnmounted))return F&&F(),Hn(t,w,3,[U])}:v=dr,e&&i){const T=v;v=()=>Ks(T())}let F,U=T=>{F=N.onStop=()=>{Ni(T,w,4)}},Y;if(Da)if(U=dr,e?n&&Hn(e,w,3,[v(),I?[]:void 0,U]):v(),a==="sync"){const T=Fw();Y=T.__watcherHandles||(T.__watcherHandles=[])}else return dr;let Z=I?new Array(t.length).fill(Hu):Hu;const b=()=>{if(N.active)if(e){const T=N.run();(i||d||(I?T.some((ne,Ne)=>Ia(ne,Z[Ne])):Ia(T,Z)))&&(F&&F(),Hn(e,w,3,[T,Z===Hu?void 0:I&&Z[0]===Hu?[]:Z,U]),Z=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=()=>Lf(b));const N=new Wf(v,C);e?n?b():Z=N.run():a==="post"?bn(N.run.bind(N),w&&w.suspense):N.run();const q=()=>{N.stop(),w&&w.scope&&Ef(w.scope.effects,N)};return Y&&Y.push(q),q}function $y(t,e,n){const i=this.proxy,a=Lt(t)?t.includes(".")?Zd(i,t):()=>i[t]:t.bind(i,i);let l;ke(e)?l=e:(l=e.handler,n=e);const m=Ot;Lo(this);const w=Yd(a,l.bind(i),n);return m?Lo(m):xs(),w}function Zd(t,e){const n=e.split(".");return()=>{let i=t;for(let a=0;a{Ks(n,e)});else if(Od(t))for(const n in t)Ks(t[n],e);return t}function Qy(){const t={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return rp(()=>{t.isMounted=!0}),ip(()=>{t.isUnmounting=!0}),t}const Fn=[Function,Array],jy={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=kw(),i=Qy();let a;return()=>{const l=e.default&&tp(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 w=Fe(t),{mode:v}=w;if(i.isLeaving)return Pl(m);const d=ph(m);if(!d)return Pl(m);const I=Gl(d,w,i,n);Xl(d,I);const F=n.subTree,U=F&&ph(F);let Y=!1;const{getTransitionKey:Z}=d.type;if(Z){const b=Z();a===void 0?a=b:b!==a&&(a=b,Y=!0)}if(U&&U.type!==Ur&&(!Gi(d,U)||Y)){const b=Gl(U,w,i,n);if(Xl(U,b),v==="out-in")return i.isLeaving=!0,b.afterLeave=()=>{i.isLeaving=!1,n.update.active!==!1&&n.update()},Pl(m);v==="in-out"&&d.type!==Ur&&(b.delayLeave=(C,N,q)=>{const T=ep(i,U);T[String(U.key)]=U,C._leaveCb=()=>{N(),C._leaveCb=void 0,delete I.delayedLeave},I.delayedLeave=q})}return m}}},Hy=jy;function ep(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 Gl(t,e,n,i){const{appear:a,mode:l,persisted:m=!1,onBeforeEnter:w,onEnter:v,onAfterEnter:d,onEnterCancelled:I,onBeforeLeave:F,onLeave:U,onAfterLeave:Y,onLeaveCancelled:Z,onBeforeAppear:b,onAppear:C,onAfterAppear:N,onAppearCancelled:q}=e,T=String(t.key),ne=ep(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=ne[T];ze&&Gi(t,ze)&&ze.el._leaveCb&&ze.el._leaveCb(),Ne(tt,[xe])},enter(xe){let tt=v,ze=d,qt=I;if(!n.isMounted)if(a)tt=C||v,ze=N||d,qt=q||I;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(F,[xe]);let qt=!1;const Wt=xe._leaveCb=Qe=>{qt||(qt=!0,tt(),Qe?Ne(Z,[xe]):Ne(Y,[xe]),xe._leaveCb=void 0,ne[ze]===t&&delete ne[ze])};ne[ze]=t,U?ae(U,[xe,Wt]):Wt()},clone(xe){return Gl(xe,e,n,i)}};return _e}function Pl(t){if(hl(t))return t=xi(t),t.children=null,t}function ph(t){return hl(t)?t.children?t.children[0]:void 0:t}function Xl(t,e){t.shapeFlag&6&&t.component?Xl(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 tp(t,e=!1,n){let i=[],a=0;for(let l=0;l1)for(let l=0;l!!t.type.__asyncLoader,hl=t=>t.type.__isKeepAlive;function zy(t,e){np(t,"a",e)}function Ky(t,e){np(t,"da",e)}function np(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(dl(e,i,n),n){let a=n.parent;for(;a&&a.parent;)hl(a.parent.vnode)&&Jy(i,e,n,a),a=a.parent}}function Jy(t,e,n,i){const a=dl(e,t,i,!0);sp(()=>{Ef(i[e],a)},n)}function dl(t,e,n=Ot,i=!1){if(n){const a=n[t]||(n[t]=[]),l=e.__weh||(e.__weh=(...m)=>{if(n.isUnmounted)return;jo(),Lo(n);const w=Hn(e,n,t,m);return xs(),Ho(),w});return i?a.unshift(l):a.push(l),l}}const zr=t=>(e,n=Ot)=>(!Da||t==="sp")&&dl(t,(...i)=>e(...i),n),Gy=zr("bm"),rp=zr("m"),Xy=zr("bu"),Yy=zr("u"),ip=zr("bum"),sp=zr("um"),Zy=zr("sp"),ew=zr("rtg"),tw=zr("rtc");function nw(t,e=Ot){dl("ec",t,e)}function Hi(t,e,n,i){const a=t.dirs,l=e&&e.dirs;for(let m=0;mt?mp(t)?Ff(t)||t.proxy:Yl(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=>Yl(t.parent),$root:t=>Yl(t.root),$emit:t=>t.emit,$options:t=>Pf(t),$forceUpdate:t=>t.f||(t.f=()=>Lf(t.update)),$nextTick:t=>t.n||(t.n=Wy.bind(t.proxy)),$watch:t=>$y.bind(t)}),Ml=(t,e)=>t!==lt&&!t.__isScriptSetup&&Be(t,e),iw={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 Y=m[e];if(Y!==void 0)switch(Y){case 1:return i[e];case 2:return a[e];case 4:return n[e];case 3:return l[e]}else{if(Ml(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];Zl&&(m[e]=0)}}const I=Na[e];let F,U;if(I)return e==="$attrs"&&xn(t,"get",e),I(t);if((F=w.__cssModules)&&(F=F[e]))return F;if(n!==lt&&Be(n,e))return m[e]=4,n[e];if(U=v.config.globalProperties,Be(U,e))return U[e]},set({_:t},e,n){const{data:i,setupState:a,ctx:l}=t;return Ml(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)||Ml(e,m)||(w=l[0])&&Be(w,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 Zl=!0;function sw(t){const e=Pf(t),n=t.proxy,i=t.ctx;Zl=!1,e.beforeCreate&&mh(e.beforeCreate,t,"bc");const{data:a,computed:l,methods:m,watch:w,provide:v,inject:d,created:I,beforeMount:F,mounted:U,beforeUpdate:Y,updated:Z,activated:b,deactivated:C,beforeDestroy:N,beforeUnmount:q,destroyed:T,unmounted:ne,render:Ne,renderTracked:ae,renderTriggered:_e,errorCaptured:xe,serverPrefetch:tt,expose:ze,inheritAttrs:qt,components:Wt,directives:Qe,filters:Kt}=e;if(d&&ow(d,i,null,t.appContext.config.unwrapInjectedRef),m)for(const ge in m){const Oe=m[ge];ke(Oe)&&(i[ge]=Oe.bind(n))}if(a){const ge=a.call(n,n);yt(ge)&&(t.data=kf(ge))}if(Zl=!0,l)for(const ge in l){const Oe=l[ge],ut=ke(Oe)?Oe.bind(n,n):ke(Oe.get)?Oe.get.bind(n,n):dr,we=!ke(Oe)&&ke(Oe.set)?Oe.set.bind(n):dr,Re=Mw({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)op(w[ge],i,n,ge);if(v){const ge=ke(v)?v.call(n):v;Reflect.ownKeys(ge).forEach(Oe=>{Uy(Oe,ge[Oe])})}I&&mh(I,t,"c");function wt(ge,Oe){Ie(Oe)?Oe.forEach(ut=>ge(ut.bind(n))):Oe&&ge(Oe.bind(n))}if(wt(Gy,F),wt(rp,U),wt(Xy,Y),wt(Yy,Z),wt(zy,b),wt(Ky,C),wt(nw,xe),wt(tw,ae),wt(ew,_e),wt(ip,q),wt(sp,ne),wt(Zy,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===dr&&(t.render=Ne),qt!=null&&(t.inheritAttrs=qt),Wt&&(t.components=Wt),Qe&&(t.directives=Qe)}function ow(t,e,n=dr,i=!1){Ie(t)&&(t=ef(t));for(const a in t){const l=t[a];let m;yt(l)?"default"in l?m=Xu(l.from||a,l.default,!0):m=Xu(l.from||a):m=Xu(l),rn(m)&&i?Object.defineProperty(e,a,{enumerable:!0,configurable:!0,get:()=>m.value,set:w=>m.value=w}):e[a]=m}}function mh(t,e,n){Hn(Ie(t)?t.map(i=>i.bind(e.proxy)):t.bind(e.proxy),e,n)}function op(t,e,n,i){const a=i.includes(".")?Zd(n,i):()=>n[i];if(Lt(t)){const l=e[t];ke(l)&&Ll(a,l)}else if(ke(t))Ll(a,t.bind(n));else if(yt(t))if(Ie(t))t.forEach(l=>op(l,e,n,i));else{const l=ke(t.handler)?t.handler.bind(n):e[t.handler];ke(l)&&Ll(a,l,t)}}function Pf(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=>lc(v,d,m,!0)),lc(v,e,m)),yt(e)&&l.set(e,v),v}function lc(t,e,n,i=!1){const{mixins:a,extends:l}=e;l&&lc(t,l,n,!0),a&&a.forEach(m=>lc(t,m,n,!0));for(const m in e)if(!(i&&m==="expose")){const w=aw[m]||n&&n[m];t[m]=w?w(t[m],e[m]):e[m]}return t}const aw={data:yh,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:cw,provide:yh,inject:uw};function yh(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 uw(t,e){return Ki(ef(t),ef(e))}function ef(t){if(Ie(t)){const e={};for(let n=0;n0)&&!(m&16)){if(m&8){const I=t.vnode.dynamicProps;for(let F=0;F{v=!0;const[U,Y]=up(F,e,!0);on(m,U),Y&&w.push(...Y)};!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,Y[1]=b<0||Z-1||Be(Y,"default"))&&w.push(F)}}}const d=[m,w];return yt(t)&&i.set(t,d),d}function wh(t){return t[0]!=="$"}function gh(t){const e=t&&t.toString().match(/^\s*(function|class) (\w+)/);return e?e[2]:t===null?"null":""}function bh(t,e){return gh(t)===gh(e)}function Nh(t,e){return Ie(e)?e.findIndex(n=>bh(n,t)):ke(e)&&bh(e,t)?0:-1}const cp=t=>t[0]==="_"||t==="$stable",Mf=t=>Ie(t)?t.map(Or):[Or(t)],hw=(t,e,n)=>{if(e._n)return e;const i=Ry((...a)=>Mf(e(...a)),n);return i._c=!1,i},lp=(t,e,n)=>{const i=t._ctx;for(const a in t){if(cp(a))continue;const l=t[a];if(ke(l))e[a]=hw(a,l,i);else if(l!=null){const m=Mf(l);e[a]=()=>m}}},fp=(t,e)=>{const n=Mf(e);t.slots.default=()=>n},dw=(t,e)=>{if(t.vnode.shapeFlag&32){const n=e._;n?(t.slots=Fe(e),ac(e,"_",n)):lp(e,t.slots={})}else t.slots={},e&&fp(t,e);ac(t.slots,ml,1)},pw=(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,lp(e,a)),m=e}else e&&(fp(t,e),m={default:1});if(l)for(const w in a)!cp(w)&&!(w in m)&&delete a[w]};function hp(){return{app:null,config:{isNativeTag:Pm,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 mw=0;function yw(t,e){return function(i,a=null){ke(i)||(i=Object.assign({},i)),a!=null&&!yt(a)&&(a=null);const l=hp(),m=new Set;let w=!1;const v=l.app={_uid:mw++,_component:i,_props:a,_container:null,_context:l,_instance:null,version:Uw,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,F){if(!w){const U=_s(i,a);return U.appContext=l,I&&e?e(U,d):t(U,d,F),w=!0,v._container=d,d.__vue_app__=v,Ff(U.component)||U.component.proxy}},unmount(){w&&(t(null,v._container),delete v._container.__vue_app__)},provide(d,I){return l.provides[d]=I,v}};return v}}function nf(t,e,n,i,a=!1){if(Ie(t)){t.forEach((U,Y)=>nf(U,e&&(Ie(e)?e[Y]:e),n,i,a));return}if(Yu(i)&&!a)return;const l=i.shapeFlag&4?Ff(i.component)||i.component.proxy:i.el,m=a?null:l,{i:w,r:v}=t,d=e&&e.r,I=w.refs===lt?w.refs={}:w.refs,F=w.setupState;if(d!=null&&d!==v&&(Lt(d)?(I[d]=null,Be(F,d)&&(F[d]=null)):rn(d)&&(d.value=null)),ke(v))Ni(v,w,12,[m,I]);else{const U=Lt(v),Y=rn(v);if(U||Y){const Z=()=>{if(t.f){const b=U?Be(F,v)?F[v]:I[v]:v.value;a?Ie(b)&&Ef(b,l):Ie(b)?b.includes(l)||b.push(l):U?(I[v]=[l],Be(F,v)&&(F[v]=I[v])):(v.value=[l],t.k&&(I[t.k]=v.value))}else U?(I[v]=m,Be(F,v)&&(F[v]=m)):Y&&(v.value=m,t.k&&(I[t.k]=m))};m?(Z.id=-1,bn(Z,n)):Z()}}}const bn=Fy;function ww(t){return gw(t)}function gw(t,e){const n=jm();n.__VUE__=!0;const{insert:i,remove:a,patchProp:l,createElement:m,createText:w,createComment:v,setText:d,setElementText:I,parentNode:F,nextSibling:U,setScopeId:Y=dr,insertStaticContent:Z}=t,b=(x,O,R,M=null,K=null,ee=null,j=!1,z=null,re=!!O.dynamicChildren)=>{if(x===O)return;x&&!Gi(x,O)&&(M=fe(x),Pt(x,K,ee,!0),x=null),O.patchFlag===-2&&(re=!1,O.dynamicChildren=null);const{type:J,ref:ce,shapeFlag:oe}=O;switch(J){case pl:C(x,O,R,M);break;case Ur:N(x,O,R,M);break;case Bl:x==null&&q(O,R,M,j);break;case ur:Wt(x,O,R,M,K,ee,j,z,re);break;default:oe&1?Ne(x,O,R,M,K,ee,j,z,re):oe&6?Qe(x,O,R,M,K,ee,j,z,re):(oe&64||oe&128)&&J.process(x,O,R,M,K,ee,j,z,re,zn)}ce!=null&&K&&nf(ce,x&&x.ref,ee,O||x,!O)},C=(x,O,R,M)=>{if(x==null)i(O.el=w(O.children),R,M);else{const K=O.el=x.el;O.children!==x.children&&d(K,O.children)}},N=(x,O,R,M)=>{x==null?i(O.el=v(O.children||""),R,M):O.el=x.el},q=(x,O,R,M)=>{[x.el,x.anchor]=Z(x.children,O,R,M,x.el,x.anchor)},T=({el:x,anchor:O},R,M)=>{let K;for(;x&&x!==O;)K=U(x),i(x,R,M),x=K;i(O,R,M)},ne=({el:x,anchor:O})=>{let R;for(;x&&x!==O;)R=U(x),a(x),x=R;a(O)},Ne=(x,O,R,M,K,ee,j,z,re)=>{j=j||O.type==="svg",x==null?ae(O,R,M,K,ee,j,z,re):tt(x,O,K,ee,j,z,re)},ae=(x,O,R,M,K,ee,j,z)=>{let re,J;const{type:ce,props:oe,shapeFlag:ue,transition:be,dirs:Ee}=x;if(re=x.el=m(x.type,ee,oe&&oe.is,oe),ue&8?I(re,x.children):ue&16&&xe(x.children,re,null,M,K,ee&&ce!=="foreignObject",j,z),Ee&&Hi(x,null,M,"created"),_e(re,x,x.scopeId,j,M),oe){for(const Le in oe)Le!=="value"&&!Gu(Le)&&l(re,Le,null,oe[Le],ee,x.children,M,K,pn);"value"in oe&&l(re,"value",null,oe.value),(J=oe.onVnodeBeforeMount)&&gr(J,M,x)}Ee&&Hi(x,null,M,"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&&gr(J,M,x),je&&be.enter(re),Ee&&Hi(x,null,M,"mounted")},K)},_e=(x,O,R,M,K)=>{if(R&&Y(x,R),M)for(let ee=0;ee{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&&Vi(R,!1),(be=ue.onVnodeBeforeUpdate)&&gr(be,R,O,x),ce&&Hi(O,x,R,"beforeUpdate"),R&&Vi(R,!0);const Ee=K&&O.type!=="foreignObject";if(J?ze(x.dynamicChildren,J,z,R,M,Ee,ee):j||Oe(x,O,z,null,R,M,Ee,ee,!1),re>0){if(re&16)qt(z,O,oe,ue,R,M,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&&gr(be,R,O,x),ce&&Hi(O,x,R,"updated")},M)},ze=(x,O,R,M,K,ee,j)=>{for(let z=0;z{if(R!==M){if(R!==lt)for(const z in R)!Gu(z)&&!(z in M)&&l(x,z,R[z],null,j,O.children,K,ee,pn);for(const z in M){if(Gu(z))continue;const re=M[z],J=R[z];re!==J&&z!=="value"&&l(x,z,J,re,j,O.children,K,ee,pn)}"value"in M&&l(x,"value",R.value,M.value)}},Wt=(x,O,R,M,K,ee,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,M),i(ce,R,M),xe(O.children,R,ce,K,ee,j,z,re)):oe>0&&oe&64&&ue&&x.dynamicChildren?(ze(x.dynamicChildren,ue,R,K,ee,j,z),(O.key!=null||K&&O===K.subTree)&&dp(x,O,!0)):Oe(x,O,R,ce,K,ee,j,z,re)},Qe=(x,O,R,M,K,ee,j,z,re)=>{O.slotScopeIds=z,x==null?O.shapeFlag&512?K.ctx.activate(O,R,M,j,re):Kt(O,R,M,K,ee,j,re):dn(x,O,re)},Kt=(x,O,R,M,K,ee,j)=>{const z=x.component=Tw(x,M,K);if(hl(x)&&(z.ctx.renderer=zn),Sw(z),z.asyncDep){if(K&&K.registerDep(z,wt),!x.el){const re=z.subTree=_s(Ur);N(null,re,O,R)}return}wt(z,x,O,R,K,ee,j)},dn=(x,O,R)=>{const M=O.component=x.component;if(Py(x,O,R))if(M.asyncDep&&!M.asyncResolved){ge(M,O,R);return}else M.next=O,Ay(M.update),M.update();else O.el=x.el,M.vnode=O},wt=(x,O,R,M,K,ee,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&&Rl(oe),(Le=ce.props&&ce.props.onVnodeBeforeUpdate)&&gr(Le,be,ce,Ee),Vi(x,!0);const it=Dl(x),me=x.subTree;x.subTree=it,b(me,it,F(me.el),fe(me),x,K,ee),ce.el=it.el,je===null&&My(x,it.el),ue&&bn(ue,K),(Le=ce.props&&ce.props.onVnodeUpdated)&&bn(()=>gr(Le,be,ce,Ee),K)}else{let ce;const{el:oe,props:ue}=O,{bm:be,m:Ee,parent:je}=x,Le=Yu(O);if(Vi(x,!1),be&&Rl(be),!Le&&(ce=ue&&ue.onVnodeBeforeMount)&&gr(ce,je,O),Vi(x,!0),oe&&Ke){const it=()=>{x.subTree=Dl(x),Ke(oe,x.subTree,x,K,null)};Le?O.type.__asyncLoader().then(()=>!x.isUnmounted&&it()):it()}else{const it=x.subTree=Dl(x);b(null,it,R,M,x,K,ee),O.el=it.el}if(Ee&&bn(Ee,K),!Le&&(ce=ue&&ue.onVnodeMounted)){const it=O;bn(()=>gr(ce,je,it),K)}(O.shapeFlag&256||je&&Yu(je.vnode)&&je.vnode.shapeFlag&256)&&x.a&&bn(x.a,K),x.isMounted=!0,O=R=M=null}},re=x.effect=new Wf(z,()=>Lf(J),x.scope),J=x.update=()=>re.run();J.id=x.uid,Vi(x,!0),J()},ge=(x,O,R)=>{O.component=x;const M=x.vnode.props;x.vnode=O,x.next=null,fw(x,O.props,M,R),pw(x,O.children,R),jo(),hh(),Ho()},Oe=(x,O,R,M,K,ee,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,M,K,ee,j,z,re);return}else if(ue&256){ut(J,oe,R,M,K,ee,j,z,re);return}}be&8?(ce&16&&pn(J,K,ee),oe!==J&&I(R,oe)):ce&16?be&16?we(J,oe,R,M,K,ee,j,z,re):pn(J,K,ee,!0):(ce&8&&I(R,""),be&16&&xe(oe,R,M,K,ee,j,z,re))},ut=(x,O,R,M,K,ee,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,ee,!0,!1,oe):xe(O,R,M,K,ee,j,z,re,oe)},we=(x,O,R,M,K,ee,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?oi(O[J]):Or(O[J]);if(Gi(be,Ee))b(be,Ee,R,null,K,ee,j,z,re);else break;J++}for(;J<=oe&&J<=ue;){const be=x[oe],Ee=O[ue]=re?oi(O[ue]):Or(O[ue]);if(Gi(be,Ee))b(be,Ee,R,null,K,ee,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,ee,!0),J++;else{const be=J,Ee=J,je=new Map;for(J=Ee;J<=ue;J++){const le=O[J]=re?oi(O[J]):Or(O[J]);le.key!=null&&je.set(le.key,J)}let Le,it=0;const me=ue-Ee+1;let Cn=!1,Oi=0;const Gt=new Array(me);for(J=0;J=me){Pt(le,K,ee,!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,O[Le])){Mt=Le;break}Mt===void 0?Pt(le,K,ee,!0):(Gt[Mt-Ee]=J+1,Mt>=Oi?Oi=Mt:Cn=!0,b(le,O[Mt],R,null,K,ee,j,z,re),it++)}const Os=Cn?bw(Gt):Zs;for(Le=Os.length-1,J=me-1;J>=0;J--){const le=Ee+J,Mt=O[le],te=le+1{const{el:ee,type:j,transition:z,children:re,shapeFlag:J}=x;if(J&6){Re(x.component.subTree,O,R,M);return}if(J&128){x.suspense.move(O,R,M);return}if(J&64){j.move(x,O,R,zn);return}if(j===ur){i(ee,O,R);for(let oe=0;oez.enter(ee),K);else{const{leave:oe,delayLeave:ue,afterLeave:be}=z,Ee=()=>i(ee,O,R),je=()=>{oe(ee,()=>{Ee(),be&&be()})};ue?ue(ee,Ee,je):je()}else i(ee,O,R)},Pt=(x,O,R,M=!1,K=!1)=>{const{type:ee,props:j,ref:z,children:re,dynamicChildren:J,shapeFlag:ce,patchFlag:oe,dirs:ue}=x;if(z!=null&&nf(z,null,R,x,!0),ce&256){O.ctx.deactivate(x);return}const be=ce&1&&ue,Ee=!Yu(x);let je;if(Ee&&(je=j&&j.onVnodeBeforeUnmount)&&gr(je,O,x),ce&6)En(x.component,R,M);else{if(ce&128){x.suspense.unmount(R,M);return}be&&Hi(x,null,O,"beforeUnmount"),ce&64?x.type.remove(x,O,R,K,zn,M):J&&(ee!==ur||oe>0&&oe&64)?pn(J,O,R,!1,!0):(ee===ur&&oe&384||!K&&ce&16)&&pn(re,O,R),M&&Tr(x)}(Ee&&(je=j&&j.onVnodeUnmounted)||be)&&bn(()=>{je&&gr(je,O,x),be&&Hi(x,null,O,"unmounted")},R)},Tr=x=>{const{type:O,el:R,anchor:M,transition:K}=x;if(O===ur){Cs(R,M);return}if(O===Bl){ne(x);return}const ee=()=>{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,ee);z?z(x.el,ee,re):re()}else ee()},Cs=(x,O)=>{let R;for(;x!==O;)R=U(x),a(x),x=R;a(O)},En=(x,O,R)=>{const{bum:M,scope:K,update:ee,subTree:j,um:z}=x;M&&Rl(M),K.stop(),ee&&(ee.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,M=!1,K=!1,ee=0)=>{for(let j=ee;jx.shapeFlag&6?fe(x.component.subTree):x.shapeFlag&128?x.suspense.next():U(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),hh(),Kd(),O._vnode=x},zn={p:b,um:Pt,m:Re,r:Tr,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:yw(Me,Jt)}}function Vi({effect:t,update:e},n){t.allowRecurse=e.allowRecurse=n}function dp(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 Nw=t=>t.__isTeleport,ur=Symbol(void 0),pl=Symbol(void 0),Ur=Symbol(void 0),Bl=Symbol(void 0),va=[];let fr=null;function vw(t=!1){va.push(fr=t?null:[])}function _w(){va.pop(),fr=va[va.length-1]||null}let Sa=1;function vh(t){Sa+=t}function xw(t){return t.dynamicChildren=Sa>0?fr||Zs:null,_w(),Sa>0&&fr&&fr.push(t),t}function Ew(t,e,n,i,a,l){return xw(Ct(t,e,n,i,a,l,!0))}function Cw(t){return t?t.__v_isVNode===!0:!1}function Gi(t,e){return t.type===e.type&&t.key===e.key}const ml="__vInternal",pp=({key:t})=>t??null,Zu=({ref:t,ref_key:e,ref_for:n})=>t!=null?Lt(t)||rn(t)||ke(t)?{i:lr,r:t,k:e,f:!!n}:t:null;function Ct(t,e=null,n=null,i=0,a=null,l=t===ur?0:1,m=!1,w=!1){const v={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&pp(e),ref:e&&Zu(e),scopeId:Xd,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:lr};return w?(Bf(v,n),l&128&&t.normalize(v)):n&&(v.shapeFlag|=Lt(n)?8:16),Sa>0&&!m&&fr&&(v.patchFlag>0||l&6)&&v.patchFlag!==32&&fr.push(v),v}const _s=Ow;function Ow(t,e=null,n=null,i=0,a=null,l=!1){if((!t||t===rw)&&(t=Ur),Cw(t)){const w=xi(t,e,!0);return n&&Bf(w,n),Sa>0&&!l&&fr&&(w.shapeFlag&6?fr[fr.indexOf(t)]=w:fr.push(w)),w.patchFlag|=-2,w}if(Pw(t)&&(t=t.__vccOpts),e){e=qw(e);let{class:w,style:v}=e;w&&!Lt(w)&&(e.class=_f(w)),yt(v)&&(Bd(v)&&!Ie(v)&&(v=on({},v)),e.style=vf(v))}const m=Lt(t)?1:By(t)?128:Nw(t)?64:yt(t)?4:ke(t)?2:0;return Ct(t,e,n,i,a,m,l,!0)}function qw(t){return t?Bd(t)||ml in t?on({},t):t:null}function xi(t,e,n=!1){const{props:i,ref:a,patchFlag:l,children:m}=t,w=e?Ww(i||{},e):i;return{__v_isVNode:!0,__v_skip:!0,type:t.type,props:w,key:w&&pp(w),ref:e&&e.ref?n&&a?Ie(a)?a.concat(Zu(e)):[a,Zu(e)]:Zu(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!==ur?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(pl,null,t,e)}function Or(t){return t==null||typeof t=="boolean"?_s(Ur):Ie(t)?_s(ur,null,t.slice()):typeof t=="object"?oi(t):_s(pl,null,String(t))}function oi(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:xi(t)}function Bf(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),Bf(t,a()),a._c&&(a._d=!0));return}else{n=32;const a=e._;!a&&!(ml in e)?e._ctx=lr:a===3&&lr&&(lr.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else ke(e)?(e={default:e,_ctx:lr},n=32):(e=String(e),i&64?(n=16,e=[Ra(e)]):n=8);t.children=e,t.shapeFlag|=n}function Ww(...t){const e={};for(let n=0;nOt||lr,Lo=t=>{Ot=t,t.scope.on()},xs=()=>{Ot&&Ot.scope.off(),Ot=null};function mp(t){return t.vnode.shapeFlag&4}let Da=!1;function Sw(t,e=!1){Da=e;const{props:n,children:i}=t.vnode,a=mp(t);lw(t,n,a,e),dw(t,i);const l=a?Rw(t,e):void 0;return Da=!1,l}function Rw(t,e){const n=t.type;t.accessCache=Object.create(null),t.proxy=Fd(new Proxy(t.ctx,iw));const{setup:i}=n;if(i){const a=t.setupContext=i.length>1?Lw(t):null;Lo(t),jo();const l=Ni(i,t,0,[t.props,a]);if(Ho(),xs(),Ed(l)){if(l.then(xs,xs),e)return l.then(m=>{_h(t,m,e)}).catch(m=>{ll(m,t,0)});t.asyncDep=l}else _h(t,l,e)}else yp(t,e)}function _h(t,e,n){ke(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:yt(e)&&(t.setupState=jd(e)),yp(t,n)}let xh;function yp(t,e,n){const i=t.type;if(!t.render){if(!e&&xh&&!i.render){const a=i.template||Pf(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=xh(a,d)}}t.render=i.render||dr}Lo(t),jo(),sw(t),Ho(),xs()}function Dw(t){return new Proxy(t.attrs,{get(e,n){return xn(t,"get","$attrs"),e[n]}})}function Lw(t){const e=i=>{t.exposed=i||{}};let n;return{get attrs(){return n||(n=Dw(t))},slots:t.slots,emit:t.emit,expose:e}}function Ff(t){if(t.exposed)return t.exposeProxy||(t.exposeProxy=new Proxy(jd(Fd(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 Pw(t){return ke(t)&&"__vccOpts"in t}const Mw=(t,e)=>Oy(t,e,Da),Bw=Symbol(""),Fw=()=>Xu(Bw),Uw="3.2.47",$w="http://www.w3.org/2000/svg",Xi=typeof document<"u"?document:null,Eh=Xi&&Xi.createElement("template"),Qw={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($w,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{Eh.innerHTML=i?`${t}`:t;const w=Eh.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 jw(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 Hw(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&&rf(i,l,"");for(const l in n)rf(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 Ch=/\s*!important$/;function rf(t,e,n){if(Ie(n))n.forEach(i=>rf(t,e,i));else if(n==null&&(n=""),e.startsWith("--"))t.setProperty(e,n);else{const i=Vw(t,e);Ch.test(n)?t.setProperty(Qo(i),n.replace(Ch,""),"important"):t[i]=n}}const Oh=["Webkit","Moz","ms"],Fl={};function Vw(t,e){const n=Fl[e];if(n)return n;let i=Ro(e);if(i!=="filter"&&i in t)return Fl[e]=i;i=qd(i);for(let a=0;aUl||(Zw.then(()=>Ul=0),Ul=Date.now());function tg(t,e){const n=i=>{if(!i._vts)i._vts=Date.now();else if(i._vts<=n.attached)return;Hn(ng(i,n.value),e,5,[i])};return n.value=t,n.attached=eg(),n}function ng(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 Ih=/^on[a-z]/,rg=(t,e,n,i,a=!1,l,m,w,v)=>{e==="class"?jw(t,i,a):e==="style"?Hw(t,n,i):ol(e)?xf(e)||Xw(t,e,n,i,m):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):ig(t,e,i,a))?Kw(t,e,i,l,m,w,v):(e==="true-value"?t._trueValue=i:e==="false-value"&&(t._falseValue=i),zw(t,e,i,a))};function ig(t,e,n,i){return i?!!(e==="innerHTML"||e==="textContent"||e in t&&Ih.test(e)&&ke(n)):e==="spellcheck"||e==="draggable"||e==="translate"||e==="form"||e==="list"&&t.tagName==="INPUT"||e==="type"&&t.tagName==="TEXTAREA"||Ih.test(e)&&Lt(n)?!1:e in t}const sg={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};Hy.props;const og=on({patchProp:rg},Qw);let Ah;function ag(){return Ah||(Ah=ww(og))}const ug=(...t)=>{const e=ag().createApp(...t),{mount:n}=e;return e.mount=i=>{const a=cg(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 cg(t){return Lt(t)?document.querySelector(t):t}function _a(t){return typeof t>"u"||t===void 0}function pr(t){return typeof t=="string"}function lg(t){return typeof t=="number"}function wp(t){return typeof t=="boolean"}function gp(t){return t===null}function fg(t){return t instanceof Date}function hg(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 gu(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]})}}),bp=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})}}),dg=["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)})}}),ec=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})}}),sf=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})}}),of=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 pg(t){return Ir(t)&&"expressionType"in t&&hn(t)}function mg(t){return Ir(t)&&"expression"in t&&pr(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)})}}),yl=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)}}),Np=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->"],yg=["+","-","*","/","%","^","&","|","#","<<",">>"],vp=[...Np,...yg,"&&","||"],wg=["exists","not exists"],gg=["not","-",...wg],bg=[...vp,...gg],Uf=p({is(t){return t.kind==="OperatorNode"},create(t){return p({kind:"OperatorNode",operator:t})}});function _p(t){return pr(t)&&vp.includes(t)}function xp(t){return pr(t)&&Np.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)})}}),$f=p({is(t){return t.kind==="SelectAllNode"},create(){return p({kind:"SelectAllNode"})}}),wl=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:$f.create()})}}),Ng=p({is(t){return t.kind==="OrderByItemNode"},create(t,e){return p({kind:"OrderByItemNode",orderBy:t,direction:e})}});function vg(t){return t==="asc"||t==="desc"}function gl(t,e){return Ng.create(_g(t),xg(e))}function _g(t){return Vr(t)}function xg(t){if(t)return t==="asc"||t==="desc"?en.createWithSql(t):t.toOperationNode()}function Ep(t){return pr(t)?Mo(t):t.toOperationNode()}function Ma(t){return gu(t)?t.map(e=>Vr(e)):[Vr(t)]}function Vr(t){return El(t)?xl(t):Ep(t)}function Mo(t){const e=".";if(t.includes(e)){const n=t.split(e).map(Qf);if(n.length===3)return Cg(n);if(n.length===2)return Og(n);throw new Error(`invalid column reference ${t}`)}else return Nt.create(t)}function Eg(t){const e=" as ";if(t.includes(e)){const[n,i]=t.split(e).map(Qf);return Es.create(Mo(n),mt.create(i))}else return Mo(t)}function Cp(t){return Nt.create(t)}function Th(t){const e=" ";if(t.includes(e)){const[n,i]=t.split(e).map(Qf);if(!vg(i))throw new Error(`invalid order direction "${i}" next to "${n}"`);return gl(n,i)}else return Cp(t)}function Cg(t){const[e,n,i]=t;return wl.create(vi.createWithSchema(e,n),Nt.create(i))}function Og(t){const[e,n]=t;return wl.create(vi.create(e),Nt.create(n))}function Qf(t){return t.trim()}const Op=p({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return p({kind:"PrimitiveValueListNode",values:p([...t])})}}),jf=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 gu(t)?qg(t):$r(t)}function $r(t){return El(t)?xl(t):Ar.create(t)}function qg(t){return t.some(El)?jf.create(t.map(e=>$r(e))):Op.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])})}}),kh=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])})}}),af=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?kh.cloneWithItems(t.partitionBy,e):kh.create(e)})}}),fc=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])})}}),Vu=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:fc.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?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?Vu.cloneWithOperation(t.having,"And",e):Vu.create(e)})},cloneWithOrHaving(t,e){return p({...t,having:t.having?Vu.cloneWithOperation(t.having,"Or",e):Vu.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})}}),Wp=p({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return p({kind:"UnaryOperationNode",operator:t,operand:e})}});function sn(t){return Hf("exists",t)}function Vt(t){return Hf("not exists",t)}function Hf(t,e){return Wp.create(Uf.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);D(this,ft,p(e))}on(...e){return new tr({...r(this,ft),joinNode:jn.cloneWithOn(r(this,ft).joinNode,Hh(e))})}orOn(...e){return new tr({...r(this,ft),joinNode:jn.cloneWithOrOn(r(this,ft).joinNode,Hh(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 hc=tr;ft=new WeakMap;$e(hc,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const Wg=p({is(t){return t.kind==="PartitionByItemNode"},create(t){return p({kind:"PartitionByItemNode",partitionBy:t})}});function Ig(t){return Ma(t).map(Wg.create)}var rs;const Dc=class{constructor(e){k(this,rs,void 0);D(this,rs,p(e))}orderBy(e,n){return new Dc({overNode:af.cloneWithOrderByItem(r(this,rs).overNode,gl(e,n))})}partitionBy(e){return new Dc({overNode:af.cloneWithPartitionByItems(r(this,rs).overNode,Ig(e))})}$call(e){return e(this)}toOperationNode(){return r(this,rs).overNode}};let dc=Dc;rs=new WeakMap;$e(dc,"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:$f.create()})},createSelectAllFromTable(t){return p({kind:"SelectionNode",selection:wl.createSelectAll(t)})}});var io;class Ag{constructor(e){k(this,io,void 0);D(this,io,e)}get dynamicReference(){return r(this,io)}get refType(){}toOperationNode(){return Ep(r(this,io))}}io=new WeakMap;function Tg(t){return Ir(t)&&hn(t)&&pr(t.dynamicReference)}function bu(t){return Vn(t)?bu(t(Qr())):gu(t)?t.map(e=>Rh(e)):[Rh(t)]}function Rh(t){return pr(t)?xa.create(Eg(t)):Tg(t)?xa.create(t.toOperationNode()):xa.create(Vp(t))}function Nu(t){return t?Array.isArray(t)?t.map(Dh):[Dh(t)]:[xa.createSelectAll()]}function Dh(t){if(pr(t))return xa.createSelectAllFromTable(_n(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const kg=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 Rg(t){const e=Vn(t)?t(Qr()):t,n=gu(e)?e:p([e]);return Dg(n)}function Dg(t){const e=Lg(t);return[p([...e.keys()].map(Nt.create)),kg.create(t.map(n=>Pg(n,e)))]}function Lg(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 Pg(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(_a(w))continue;const v=t[m];(_a(v)||El(v))&&(a=!0),i[w]=v}if(n.length_a(w)?m:$r(w)))}return Op.create(i)}const qr=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})}}),pc=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?fc.cloneWithFroms(t.from,e):fc.create(e)})},cloneWithUpdates(t,e){return p({...t,updates:t.updates?p([...t.updates,...e]):e})}}),Lh=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:fc.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?Lh.cloneWithTables(t.using,e):Lh.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)})}}),Ph=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)})}}),Mg=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)||qr.is(t)||pc.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?Ph.cloneWithSelections(t.returning,e):Ph.create(e)})},cloneWithoutWhere(t){return p({...t,where:void 0})},cloneWithExplain(t,e,n){return p({...t,explain:Mg.create(e,n==null?void 0:n.toOperationNode())})}}),Bg=p({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return p({kind:"ColumnUpdateNode",column:t,value:e})}});function Vf(t){const e=Vn(t)?t(Qr()):t;return Object.entries(e).filter(([n,i])=>i!==void 0).map(([n,i])=>Bg.create(Nt.create(n),$r(i)))}const Fg=p({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return p({kind:"OnDuplicateKeyNode",updates:t})}});var ja,Ha;class Ip{constructor(e,n){k(this,ja,void 0);k(this,Ha,void 0);D(this,ja,e),D(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(Ip.prototype,t,{enumerable:!0});class bl extends Error{constructor(n){super("no result");Yt(this,"node");this.node=n}}function Nl(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);D(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 Ap({...r(this,Se),onConflictNode:at.cloneWith(r(this,Se).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new yc({...r(this,Se),onConflictNode:at.cloneWith(r(this,Se).onConflictNode,{updates:Vf(e)})})}$call(e){return e(this)}};let mc=cn;Se=new WeakMap;$e(mc,"don't await OnConflictBuilder instances.");var Va;class Ap{constructor(e){k(this,Va,void 0);D(this,Va,p(e))}toOperationNode(){return r(this,Va).onConflictNode}}Va=new WeakMap;$e(Ap,"don't await OnConflictDoNothingBuilder instances.");var ht;const nr=class{constructor(e){k(this,ht,void 0);D(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 yc=nr;ht=new WeakMap;$e(yc,"don't await OnConflictUpdateBuilder instances.");var Te;const Tt=class{constructor(e){k(this,Te,void 0);D(this,Te,p(e))}values(e){const[n,i]=Rg(e);return new Tt({...r(this,Te),queryNode:qr.cloneWith(r(this,Te).queryNode,{columns:n,values:i})})}columns(e){return new Tt({...r(this,Te),queryNode:qr.cloneWith(r(this,Te).queryNode,{columns:p(e.map(Nt.create))})})}expression(e){return new Tt({...r(this,Te),queryNode:qr.cloneWith(r(this,Te).queryNode,{values:xl(e)})})}ignore(){return new Tt({...r(this,Te),queryNode:qr.cloneWith(r(this,Te).queryNode,{ignore:!0})})}onConflict(e){return new Tt({...r(this,Te),queryNode:qr.cloneWith(r(this,Te).queryNode,{onConflict:e(new mc({onConflictNode:at.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new Tt({...r(this,Te),queryNode:qr.cloneWith(r(this,Te).queryNode,{onDuplicateKey:Fg.create(Vf(e))})})}returning(e){return new Tt({...r(this,Te),queryNode:ye.cloneWithReturning(r(this,Te).queryNode,bu(e))})}returningAll(){return new Tt({...r(this,Te),queryNode:ye.cloneWithReturning(r(this,Te).queryNode,Nu())})}$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 Ip(i.insertId,i.numAffectedRows??i.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=bl){const n=await this.executeTakeFirst();if(n===void 0)throw Nl(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 Tp{constructor(e){k(this,za,void 0);D(this,za,e)}get numDeletedRows(){return r(this,za)}}za=new WeakMap;Object.defineProperty(Tp.prototype,"numDeletedRows",{enumerable:!0});const kp=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);D(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,bu(e))})}returningAll(e){return new Xe({...r(this,de),queryNode:ye.cloneWithReturning(r(this,de).queryNode,Nu(e))})}orderBy(e,n){return new Xe({...r(this,de),queryNode:Ea.cloneWithOrderByItem(r(this,de).queryNode,gl(e,n))})}limit(e){return new Xe({...r(this,de),queryNode:Ea.cloneWithLimit(r(this,de).queryNode,kp.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 Tp(i.numAffectedRows??i.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=bl){const n=await this.executeTakeFirst();if(n===void 0)throw Nl(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 wc=Xe;de=new WeakMap;$e(wc,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");var Ka;class Sp{constructor(e){k(this,Ka,void 0);D(this,Ka,e)}get numUpdatedRows(){return r(this,Ka)}}Ka=new WeakMap;Object.defineProperty(Sp.prototype,"numUpdatedRows",{enumerable:!0});var pe;const nt=class{constructor(e){k(this,pe,void 0);D(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:pc.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:pc.cloneWithUpdates(r(this,pe).queryNode,Vf(e))})}returning(e){return new nt({...r(this,pe),queryNode:ye.cloneWithReturning(r(this,pe).queryNode,bu(e))})}returningAll(){return new nt({...r(this,pe),queryNode:ye.cloneWithReturning(r(this,pe).queryNode,Nu())})}$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=bl){const n=await this.executeTakeFirst();if(n===void 0)throw Nl(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 gc=nt;pe=new WeakMap;$e(gc,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");const Ug=p({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return p({kind:"CommonTableExpressionNode",name:t,expression:e})}}),Mh=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 Bh(t,e){const n=e(Xg());return Ug.create($g(t),n.toOperationNode())}function $g(t){if(t.includes("(")){const e=t.split(/[\(\)]/),n=e[0],i=e[1].split(",").map(a=>a.trim());return Mh.create(n,i)}else return Mh.create(t)}const zu=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])})}}),Fh=["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 Qg(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}}Lc=new WeakMap;const Vg=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,Pc,Rp,Mc,Dp,ss,ga,Ja,uf,Bc,Lp;class zg extends zf{constructor(n){super();k(this,Pc);k(this,Mc);k(this,ss);k(this,Ja);k(this,Bc);k(this,oo,void 0);k(this,is,new Set);D(this,oo,n)}transformNodeImpl(n){if(!qe(this,Pc,Rp).call(this,n))return super.transformNodeImpl(n);const i=qe(this,Mc,Dp).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,Pc=new WeakSet,Rp=function(n){return n.kind in Vg},Mc=new WeakSet,Dp=function(n){const i=new Set;if("name"in n&&n.name&&Ei.is(n.name)&&qe(this,Ja,uf).call(this,n.name,i),"from"in n&&n.from)for(const a of n.from.froms)qe(this,ss,ga).call(this,a,i);if("into"in n&&n.into&&qe(this,ss,ga).call(this,n.into,i),"table"in n&&n.table&&qe(this,ss,ga).call(this,n.table,i),"joins"in n&&n.joins)for(const a of n.joins)qe(this,ss,ga).call(this,a.table,i);return"with"in n&&n.with&&qe(this,Bc,Lp).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&&qe(this,Ja,uf).call(this,a.table,i)},Ja=new WeakSet,uf=function(n,i){r(this,is).has(n.identifier.name)||i.add(n.identifier.name)},Bc=new WeakSet,Lp=function(n,i){for(const a of n.expressions)i.delete(a.name.table.table.identifier.name)};var Ga;class vu{constructor(e){k(this,Ga,void 0);D(this,Ga,new zg(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);D(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:qr.create(_n(e),r(this,rt).withNode)})}replaceInto(e){return new Ba({queryId:et(),executor:r(this,rt).executor,queryNode:qr.create(_n(e),r(this,rt).withNode,!0)})}deleteFrom(e){return new wc({queryId:et(),executor:r(this,rt).executor,queryNode:Ea.create(Uo(e),r(this,rt).withNode)})}updateTable(e){return new gc({queryId:et(),executor:r(this,rt).executor,queryNode:pc.create(Ua(e),r(this,rt).withNode)})}with(e,n){const i=Bh(e,n);return new es({...r(this,rt),withNode:r(this,rt).withNode?zu.cloneWithExpression(r(this,rt).withNode,i):zu.create(i)})}withRecursive(e,n){const i=Bh(e,n);return new es({...r(this,rt),withNode:r(this,rt).withNode?zu.cloneWithExpression(r(this,rt).withNode,i):zu.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 vu(e))})}};let bc=es;rt=new WeakMap;var Xa,ao,uo;class Uh{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)});D(this,Xa,new Promise((e,n)=>{D(this,uo,n),D(this,ao,e)}))}get promise(){return r(this,Xa)}}Xa=new WeakMap,ao=new WeakMap,uo=new WeakMap;const $h=new Set;function Kg(t){$h.has(t)||($h.add(t),console.log(t))}const Jg=p([]);var os,Ya,cf;class Pp{constructor(e=Jg){k(this,Ya);k(this,os,void 0);D(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,Ya,cf).call(this,a,n);return Gg(a,l),l})}async*stream(e,n,i){const a=new Uh,l=new Uh;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,Ya,cf).call(this,w,i)}finally{l.resolve()}}}os=new WeakMap,Ya=new WeakSet,cf=async function(e,n){for(const i of r(this,os))e=await i.transformResult({result:e,queryId:n});return e};function Gg(t,e){const{numAffectedRows:n}=t;n===void 0&&t.numUpdatedOrDeletedRows===void 0||n!==void 0&&e.numAffectedRows!==void 0||Kg("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class Js extends Pp{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 vl=new Js;function Qh(){return new Fo({queryId:et(),executor:vl,queryNode:We.create(Uo([]))})}function Xg(){return new bc({executor:vl})}function Mp(t,e){return new hc({joinNode:jn.create(t,Ua(e))})}function Yg(){return new dc({overNode:af.create()})}const Kf=p({is(t){return t.kind==="WhenNode"},create(t){return p({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return p({...t,result:e})}}),hr=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),Kf.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return p({...t,...e})}});function lf(t,e,n){if(!_p(e)&&!hn(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return tb(e,n)?nb(t,e,n):yl.create(Vr(t),Jf(e),qp(n))}function Zg(t,e,n){if(!_p(e)&&!hn(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return yl.create(Vr(t),Jf(e),Vr(n))}function eb(t,e,n){if(!xp(e)&&!hn(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return lf(t,e,n)}function zt(t,e,n){if(!xp(e)&&!hn(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return Zg(t,e,n)}function Rn(t){return _l("where",t)}function jh(t){return _l("having",t)}function Hh(t){return _l("on",t)}function Bp(t){return _l("when",t)}function _l(t,e){if(e.length===3)return eb(e[0],e[1],e[2]);if(e.length===1)return rb(t,e[0]);throw Fp(t,e)}function tb(t,e){return(t==="is"||t==="is not")&&(gp(e)||wp(e))}function nb(t,e,n){return yl.create(Vr(t),Jf(e),Ar.createImmediate(n))}function Jf(t){if(pr(t)&&bg.includes(t))return Uf.create(t);if(hn(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function rb(t,e){if(Vn(e)){if(t==="when")throw new Error("when method doesn't accept a callback as an argument");return ib[t](e)}else if(hn(e)){const n=e.toOperationNode();if(en.is(n)||yl.is(n)||Wp.is(n)||ro.is(n)||hr.is(n))return n}else if(t==="when")return Ar.create(e);throw Fp(t,e)}function Fp(t,e){return new Error(`invalid arguments passed to a '${t}' method: ${JSON.stringify(e)}`)}const ib=p({where(t){const e=Qh(),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=Qh(),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=Mp("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 ob(t,e[0],e[1],e[2]);if(e.length===2)return sb(t,e[0],e[1]);throw new Error("not implemented")}function sb(t,e,n){return n(Mp(t,e)).toOperationNode()}function ob(t,e,n,i){return jn.createWithOn(t,Ua(e),zt(n,"=",i))}const ab=p({is(t){return t.kind==="OffsetNode"},create(t){return p({kind:"OffsetNode",offset:Ar.create(t)})}}),ub=p({is(t){return t.kind==="GroupByItemNode"},create(t){return p({kind:"GroupByItemNode",groupBy:t})}});function cb(t){return t=Vn(t)?t(Qr()):t,Ma(t).map(ub.create)}const Up=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 Up.create(t,e.toOperationNode(),n)}var $;const he=class{constructor(e){k(this,$,void 0);D(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,jh(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,jh(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,bu(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,Nu(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,gl(e,n))})}groupBy(e){return new he({...r(this,$),queryNode:We.cloneWithGroupByItems(r(this,$).queryNode,cb(e))})}limit(e){return new he({...r(this,$),queryNode:We.cloneWithLimit(r(this,$).queryNode,kp.create(e))})}offset(e){return new he({...r(this,$),queryNode:We.cloneWithOffset(r(this,$).queryNode,ab.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 lb(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=bl){const n=await this.executeTakeFirst();if(n===void 0)throw Nl(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 lb{constructor(e,n){k(this,co,void 0);k(this,lo,void 0);D(this,co,e),D(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 Zf=class{constructor(e){k(this,fo,void 0);D(this,fo,e)}get expressionType(){}as(e){return new fb(this,e)}$castTo(){return new Zf(r(this,fo))}toOperationNode(){return r(this,fo)}};let Dt=Zf;fo=new WeakMap;var ho,li;class fb{constructor(e,n){k(this,ho,void 0);k(this,li,void 0);D(this,ho,e),D(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})}}),hb=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);D(this,st,p(e))}get expressionType(){}as(e){return new db(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=Yg();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 db{constructor(e,n){k(this,po,void 0);k(this,mo,void 0);D(this,po,e),D(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 $p(){const t=(n,i)=>new Dt(hb.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",Nu(n))})},max(n){return e("max",[n])},min(n){return e("min",[n])},sum(n){return e("sum",[n])}})}var yo;class Qp{constructor(e){k(this,yo,void 0);D(this,yo,p(e))}when(...e){return new jp({...r(this,yo),node:hr.cloneWithWhen(r(this,yo).node,Kf.create(Bp(e)))})}}yo=new WeakMap;var wo;class jp{constructor(e){k(this,wo,void 0);D(this,wo,p(e))}then(e){return new pb({...r(this,wo),node:hr.cloneWithThen(r(this,wo).node,$r(e))})}}wo=new WeakMap;var vr;class pb{constructor(e){k(this,vr,void 0);D(this,vr,p(e))}when(...e){return new jp({...r(this,vr),node:hr.cloneWithWhen(r(this,vr).node,Kf.create(Bp(e)))})}else(e){return new mb({...r(this,vr),node:hr.cloneWith(r(this,vr).node,{else:$r(e)})})}end(){return new Dt(hr.cloneWith(r(this,vr).node,{isStatement:!1}))}endCase(){return new Dt(hr.cloneWith(r(this,vr).node,{isStatement:!0}))}}vr=new WeakMap;var go;class mb{constructor(e){k(this,go,void 0);D(this,go,p(e))}end(){return new Dt(hr.cloneWith(r(this,go).node,{isStatement:!1}))}endCase(){return new Dt(hr.cloneWith(r(this,go).node,{isStatement:!0}))}}go=new WeakMap;function Hp(t=vl){function e(n,i){return new Dt(Hf(n,i))}return{get fn(){return $p()},selectFrom(n){return new Fo({queryId:et(),executor:t,queryNode:We.create(Uo(n))})},case(n){return new Qp({node:hr.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(lf(n,i,a))},bxp(n,i,a){return new Dt(lf(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 pr(t)?yb(t):Vp(t)}function yb(t){const e=" as ";if(t.includes(e)){const[n,i]=t.split(e).map(zp);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(zp);return vi.createWithSchema(n,i)}else return vi.create(t)}function zp(t){return t.trim()}const Kp=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})}}),Jp=p({is(t){return t.kind==="DropColumnNode"},create(t){return p({kind:"DropColumnNode",column:Nt.create(t)})}}),Gp=p({is(t){return t.kind==="RenameColumnNode"},create(t,e){return p({kind:"RenameColumnNode",column:Nt.create(t),renameTo:Nt.create(e)})}}),Gf=p({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return p({kind:"CheckConstraintNode",expression:t,name:e?mt.create(e):void 0})}}),wb=["no action","restrict","cascade","set null","set default"],tc=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 Xp(t){return hn(t)?t.toOperationNode():Ar.createImmediate(t)}const Ku=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})}}),gb=p({is(t){return t.kind==="DefaultValueNode"},create(t){return p({kind:"DefaultValueNode",defaultValue:t})}});function Nc(t){if(wb.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}var Ye;const kt=class{constructor(e){k(this,Ye,void 0);D(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(!wl.is(n)||$f.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:tc.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:tc.cloneWithOnDelete(r(this,Ye).references,Nc(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:tc.cloneWithOnUpdate(r(this,Ye).references,Nc(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:gb.create(Xp(e))}))}check(e){return new kt(bt.cloneWith(r(this,Ye),{check:Gf.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new kt(bt.cloneWith(r(this,Ye),{generated:Ku.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new kt(bt.cloneWith(r(this,Ye),{generated:Ku.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new kt(bt.cloneWith(r(this,Ye),{generated:Ku.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:Ku.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 Yp=p({is(t){return t.kind==="ModifyColumnNode"},create(t){return p({kind:"ModifyColumnNode",column:t})}}),bb=p({is(t){return t.kind==="DataTypeNode"},create(t){return p({kind:"DataTypeNode",dataType:t})}});function $o(t){return hn(t)?t.toOperationNode():bb.create(t)}const vc=p({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,n,i){return p({kind:"ForeignKeyConstraintNode",columns:t,references:tc.create(e,n),name:i?mt.create(i):void 0})},cloneWith(t,e){return p({...t,...e})}});var as;const Fc=class{constructor(e){k(this,as,void 0);D(this,as,e)}onDelete(e){return new Fc(vc.cloneWith(r(this,as),{onDelete:Nc(e)}))}onUpdate(e){return new Fc(vc.cloneWith(r(this,as),{onUpdate:Nc(e)}))}$call(e){return e(this)}toOperationNode(){return r(this,as)}};let $a=Fc;as=new WeakMap;$e($a,"don't await ForeignKeyConstraintBuilder instances directly.");const ff=p({is(t){return t.kind==="AddConstraintNode"},create(t){return p({kind:"AddConstraintNode",constraint:t})}}),Zp=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})}}),nc=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 Cl{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:Xp(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 Cl{toOperationNode(){return this.alterColumnNode}}var ir;class ba{constructor(e){k(this,ir,void 0);D(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 Uc=class{constructor(e){k(this,Zt,void 0);D(this,Zt,p(e))}onDelete(e){return new Uc({...r(this,Zt),constraintBuilder:r(this,Zt).constraintBuilder.onDelete(e)})}onUpdate(e){return new Uc({...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:ff.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 _c=Uc;Zt=new WeakMap;$e(_c,"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);D(this,_t,p(e))}ifExists(){return new Ca({...r(this,_t),node:Et.cloneWithTableProps(r(this,_t).node,{dropConstraint:nc.cloneWith(r(this,_t).node.dropConstraint,{ifExists:!0})})})}cascade(){return new Ca({...r(this,_t),node:Et.cloneWithTableProps(r(this,_t).node,{dropConstraint:nc.cloneWith(r(this,_t).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new Ca({...r(this,_t),node:Et.cloneWithTableProps(r(this,_t).node,{dropConstraint:nc.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 xc=Ca;_t=new WeakMap;$e(xc,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");var ot;class em{constructor(e){k(this,ot,void 0);D(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 Cl(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,Jp.create(e))})}renameColumn(e,n){return new ci({...r(this,ot),node:Et.cloneWithColumnAlteration(r(this,ot).node,Gp.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,Kp.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,Yp.create(a.toOperationNode()))})}addUniqueConstraint(e,n){return new ba({...r(this,ot),node:Et.cloneWithTableProps(r(this,ot).node,{addConstraint:ff.create(Zp.create(n,e))})})}addCheckConstraint(e,n){return new ba({...r(this,ot),node:Et.cloneWithTableProps(r(this,ot).node,{addConstraint:ff.create(Gf.create(n.toOperationNode(),e))})})}addForeignKeyConstraint(e,n,i,a){return new _c({...r(this,ot),constraintBuilder:new $a(vc.create(n.map(Nt.create),_n(i),a.map(Nt.create),e))})}dropConstraint(e){return new xc({...r(this,ot),node:Et.cloneWithTableProps(r(this,ot).node,{dropConstraint:nc.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);D(this,gt,p(e))}alterColumn(e,n){const i=n(new Cl(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,Jp.create(e))})}renameColumn(e,n){return new ts({...r(this,gt),node:Et.cloneWithColumnAlteration(r(this,gt).node,Gp.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,Kp.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,Yp.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(em,"don't await AlterTableBuilder instances");$e(Cl,"don't await AlterColumnBuilder instances");$e(ci,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class tm extends zf{transformValue(e){return{...super.transformValue(e),immediate:!0}}}var Ze;const br=class{constructor(e){k(this,Ze,void 0);D(this,Ze,p(e))}ifNotExists(){return new br({...r(this,Ze),node:ii.cloneWith(r(this,Ze).node,{ifNotExists:!0})})}unique(){return new br({...r(this,Ze),node:ii.cloneWith(r(this,Ze).node,{unique:!0})})}on(e){return new br({...r(this,Ze),node:ii.cloneWith(r(this,Ze).node,{table:_n(e)})})}column(e){return new br({...r(this,Ze),node:ii.cloneWithColumns(r(this,Ze).node,[Th(e)])})}columns(e){return new br({...r(this,Ze),node:ii.cloneWithColumns(r(this,Ze).node,e.map(Th))})}expression(e){return new br({...r(this,Ze),node:ii.cloneWithColumns(r(this,Ze).node,[e.toOperationNode()])})}using(e){return new br({...r(this,Ze),node:ii.cloneWith(r(this,Ze).node,{using:en.createWithSql(e)})})}where(...e){const n=new tm;return new br({...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 Ec=br;Ze=new WeakMap;$e(Ec,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");var Wn;const eh=class{constructor(e){k(this,Wn,void 0);D(this,Wn,p(e))}ifNotExists(){return new eh({...r(this,Wn),node:bp.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 Cc=eh;Wn=new WeakMap;$e(Cc,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");const Nb=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 vb(t){if(dg.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}var Ue;const Qn=class{constructor(e){k(this,Ue,void 0);D(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:vb(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,Nb.create(n,e))})}addUniqueConstraint(e,n){return new Qn({...r(this,Ue),node:Zn.cloneWithConstraint(r(this,Ue).node,Zp.create(n,e))})}addCheckConstraint(e,n){return new Qn({...r(this,Ue),node:Zn.cloneWithConstraint(r(this,Ue).node,Gf.create(n.toOperationNode(),e))})}addForeignKeyConstraint(e,n,i,a,l=Po){const m=l(new $a(vc.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 Oc=Qn;Ue=new WeakMap;$e(Oc,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");var Ut;const Oa=class{constructor(e){k(this,Ut,void 0);D(this,Ut,p(e))}on(e){return new Oa({...r(this,Ut),node:ec.cloneWith(r(this,Ut).node,{table:_n(e)})})}ifExists(){return new Oa({...r(this,Ut),node:ec.cloneWith(r(this,Ut).node,{ifExists:!0})})}cascade(){return new Oa({...r(this,Ut),node:ec.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=Oa;Ut=new WeakMap;$e(qc,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");var ln;const $c=class{constructor(e){k(this,ln,void 0);D(this,ln,p(e))}ifExists(){return new $c({...r(this,ln),node:sf.cloneWith(r(this,ln).node,{ifExists:!0})})}cascade(){return new $c({...r(this,ln),node:sf.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 Wc=$c;ln=new WeakMap;$e(Wc,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");var fn;const Qc=class{constructor(e){k(this,fn,void 0);D(this,fn,p(e))}ifExists(){return new Qc({...r(this,fn),node:of.cloneWith(r(this,fn).node,{ifExists:!0})})}cascade(){return new Qc({...r(this,fn),node:of.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 Ic=Qc;fn=new WeakMap;$e(Ic,"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 jc;class _b{constructor(){k(this,jc,new tm)}transformQuery(e){return r(this,jc).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}jc=new WeakMap;var dt;const ui=class{constructor(e){k(this,dt,void 0);D(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(Cp)})})}as(e){const n=e.withPlugin(new _b).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 Ac=ui;dt=new WeakMap;$e(Ac,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const rc=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 qa=class{constructor(e){k(this,$t,void 0);D(this,$t,p(e))}materialized(){return new qa({...r(this,$t),node:rc.cloneWith(r(this,$t).node,{materialized:!0})})}ifExists(){return new qa({...r(this,$t),node:rc.cloneWith(r(this,$t).node,{ifExists:!0})})}cascade(){return new qa({...r(this,$t),node:rc.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 Tc=qa;$t=new WeakMap;$e(Tc,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const nm=p({is(t){return t.kind==="CreateTypeNode"},create(t){return p({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return p({...t,enum:jf.create(e.map(n=>Ar.createImmediate(n)))})}});var In;const th=class{constructor(e){k(this,In,void 0);D(this,In,p(e))}toOperationNode(){return r(this,In).executor.transformQuery(r(this,In).node,r(this,In).queryId)}asEnum(e){return new th({...r(this,In),node:nm.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 kc=th;In=new WeakMap;$e(kc,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const rm=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 nh=class{constructor(e){k(this,An,void 0);D(this,An,p(e))}ifExists(){return new nh({...r(this,An),node:rm.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=nh;An=new WeakMap;$e(Sc,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function Vh(t){const e=".";if(t.includes(e)){const n=t.split(e).map(xb);if(n.length===2)return Ei.createWithSchema(n[0],n[1]);throw new Error(`invalid schemable identifier ${t}`)}else return Ei.create(t)}function xb(t){return t.trim()}var St;const Wa=class{constructor(e){k(this,St,void 0);D(this,St,e)}createTable(e){return new Oc({queryId:et(),executor:r(this,St),node:Zn.create(_n(e))})}dropTable(e){return new Ic({queryId:et(),executor:r(this,St),node:of.create(_n(e))})}createIndex(e){return new Ec({queryId:et(),executor:r(this,St),node:ii.create(e)})}dropIndex(e){return new qc({queryId:et(),executor:r(this,St),node:ec.create(e)})}createSchema(e){return new Cc({queryId:et(),executor:r(this,St),node:bp.create(e)})}dropSchema(e){return new Wc({queryId:et(),executor:r(this,St),node:sf.create(e)})}alterTable(e){return new em({queryId:et(),executor:r(this,St),node:Et.create(_n(e))})}createView(e){return new Ac({queryId:et(),executor:r(this,St),node:ai.create(e)})}dropView(e){return new Tc({queryId:et(),executor:r(this,St),node:rc.create(e)})}createType(e){return new kc({queryId:et(),executor:r(this,St),node:nm.create(Vh(e))})}dropType(e){return new Sc({queryId:et(),executor:r(this,St),node:rm.create(Vh(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 vu(e)))}};let hf=Wa;St=new WeakMap;class Eb{ref(e){return new Ag(e)}}var bo;class Cb{constructor(e){k(this,bo,void 0);D(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 _r,xr,Lr;const ns=class extends Pp{constructor(n,i,a,l=[]){super(l);k(this,_r,void 0);k(this,xr,void 0);k(this,Lr,void 0);D(this,_r,n),D(this,xr,i),D(this,Lr,a)}get adapter(){return r(this,xr)}compileQuery(n){return r(this,_r).compileQuery(n)}provideConnection(n){return r(this,Lr).provideConnection(n)}withPlugins(n){return new ns(r(this,_r),r(this,xr),r(this,Lr),[...this.plugins,...n])}withPlugin(n){return new ns(r(this,_r),r(this,xr),r(this,Lr),[...this.plugins,n])}withPluginAtFront(n){return new ns(r(this,_r),r(this,xr),r(this,Lr),[n,...this.plugins])}withConnectionProvider(n){return new ns(r(this,_r),r(this,xr),n,[...this.plugins])}withoutPlugins(){return new ns(r(this,_r),r(this,xr),r(this,Lr),[])}};let df=ns;_r=new WeakMap,xr=new WeakMap,Lr=new WeakMap;function zh(){return typeof performance<"u"&&Vn(performance.now)?performance.now():Date.now()}var sr,fi,Pr,us,Za,Hc,im,Vc,sm,zc,om,Kc,am,eu,pf;class Ob{constructor(e,n){k(this,Hc);k(this,Vc);k(this,zc);k(this,Kc);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);D(this,sr,e),D(this,fi,n)}async init(){r(this,Pr)||D(this,Pr,r(this,sr).init().catch(e=>(D(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)||(qe(this,Hc,im).call(this)&&qe(this,Vc,sm).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)||D(this,us,r(this,sr).destroy().catch(e=>(D(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,Hc=new WeakSet,im=function(){return r(this,fi).isLevelEnabled("query")||r(this,fi).isLevelEnabled("error")},Vc=new WeakSet,sm=function(e){const n=e.executeQuery;e.executeQuery=async i=>{const a=zh();try{return await n.call(e,i)}catch(l){throw await qe(this,zc,om).call(this,l,i,a),l}finally{await qe(this,Kc,am).call(this,i,a)}}},zc=new WeakSet,om=async function(e,n,i){await r(this,fi).error(()=>({level:"error",error:e,query:n,queryDurationMillis:qe(this,eu,pf).call(this,i)}))},Kc=new WeakSet,am=async function(e,n){await r(this,fi).query(()=>({level:"query",query:e,queryDurationMillis:qe(this,eu,pf).call(this,n)}))},eu=new WeakSet,pf=function(e){return zh()-e};var tu,hi,Jc,cm;class um{constructor(e){k(this,Jc);k(this,tu,void 0);k(this,hi,void 0);D(this,tu,e)}async provideConnection(e){for(;r(this,hi);)await r(this,hi);const n=qe(this,Jc,cm).call(this,e);return D(this,hi,n.then(()=>{D(this,hi,void 0)}).catch(()=>{D(this,hi,void 0)})),n}}tu=new WeakMap,hi=new WeakMap,Jc=new WeakSet,cm=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 Wb{constructor(e){k(this,di,void 0);k(this,cs,void 0);Vn(e)?(D(this,cs,e),D(this,di,p({query:!0,error:!0}))):(D(this,cs,Ib),D(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 Ib(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 Ab(t){return Ir(t)&&Vn(t.compile)}var Qt;const Xs=class extends bc{constructor(n){let i,a;if(Tb(n))i={executor:n.executor},a={...n};else{const l=n.dialect,m=l.createDriver(),w=l.createQueryCompiler(),v=l.createAdapter(),d=new Wb(n.log??[]),I=new Ob(m,d),F=new Cb(I),U=new df(w,v,F,n.plugins??[]);i={executor:U},a={config:n,executor:U,dialect:l,driver:I}}super(i);k(this,Qt,void 0);D(this,Qt,p(a))}get schema(){return new hf(r(this,Qt).executor)}get dynamic(){return new Eb}get introspection(){return r(this,Qt).dialect.createIntrospector(this.withoutPlugins())}case(n){return new Qp({node:hr.create(_a(n)?void 0:xl(n))})}get fn(){return $p()}transaction(){return new Rc({...r(this,Qt)})}connection(){return new lm({...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 vu(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=Ab(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);D(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 vu(n))})}withTables(){return new Ys({...r(this,or)})}};let mf=Ys;or=new WeakMap;function Tb(t){return Ir(t)&&Ir(t.config)&&Ir(t.driver)&&Ir(t.executor)&&Ir(t.dialect)}var ls;class lm{constructor(e){k(this,ls,void 0);D(this,ls,p(e))}async execute(e){return r(this,ls).executor.provideConnection(async n=>{const i=r(this,ls).executor.withConnectionProvider(new um(n)),a=new Qa({...r(this,ls),executor:i});return await e(a)})}}ls=new WeakMap;$e(lm,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");var ar;const rh=class{constructor(e){k(this,ar,void 0);D(this,ar,p(e))}setIsolationLevel(e){return new rh({...r(this,ar),isolationLevel:e})}async execute(e){const{isolationLevel:n,...i}=r(this,ar),a={isolationLevel:n};return kb(a),r(this,ar).executor.provideConnection(async l=>{const m=r(this,ar).executor.withConnectionProvider(new um(l)),w=new mf({...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 Rc=rh;ar=new WeakMap;$e(Rc,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function kb(t){if(t.isolationLevel&&!qb.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}var Nn,No,ic,nu,yf,ru,wf;const Gc=class{constructor(e){k(this,No);k(this,nu);k(this,ru);k(this,Nn,void 0);D(this,Nn,p(e))}get expressionType(){}as(e){return new Sb(this,e)}$castTo(){return new Gc({...r(this,Nn)})}castTo(){return this.$castTo()}withPlugin(e){return new Gc({...r(this,Nn),plugins:r(this,Nn).plugins!==void 0?p([...r(this,Nn).plugins,e]):p([e])})}toOperationNode(){return qe(this,nu,yf).call(this,qe(this,No,ic).call(this))}compile(e){return qe(this,ru,wf).call(this,qe(this,No,ic).call(this,e))}async execute(e){const n=qe(this,No,ic).call(this,e);return n.executeQuery(qe(this,ru,wf).call(this,n),r(this,Nn).queryId)}};let rr=Gc;Nn=new WeakMap,No=new WeakSet,ic=function(e){const n=e!==void 0?e.getExecutor():vl;return r(this,Nn).plugins!==void 0?n.withPlugins(r(this,Nn).plugins):n},nu=new WeakSet,yf=function(e){return e.transformQuery(r(this,Nn).rawNode,r(this,Nn).queryId)},ru=new WeakSet,wf=function(e){return e.compileQuery(qe(this,nu,yf).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 Sb{constructor(e,n){k(this,vo,void 0);k(this,pi,void 0);D(this,vo,e),D(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,Xc)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}Xc=new WeakMap;var _o,fs;class Db extends Rb{constructor(){super(...arguments);k(this,_o,"");k(this,fs,[])}get numParameters(){return r(this,fs).length}compileQuery(n){return D(this,_o,""),D(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&&!qr.is(this.parentNode)&&!ai.is(this.parentNode)&&!Up.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(Lb[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 Uf.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){D(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(pr(n))this.append(`'${n}'`);else if(lg(n)||wp(n))this.append(n.toString());else if(gp(n))this.append("null");else if(fg(n))this.appendImmediateValue(n.toISOString());else if(hg(n))this.appendImmediateValue(n.toString());else throw new Error(`invalid immediate value ${n}`)}}_o=new WeakMap,fs=new WeakMap;const Lb=p({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),Pb=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([])})}}),Mb=/"/g;class fm extends Db{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(e){return e.replace(Mb,'""')}visitDefaultInsertValue(e){this.append("null")}}const Bb="kysely_migration",Fb="kysely_migration_lock";p({__noMigrations__:!0});var xo,Yc,dm;class hm{constructor(e){k(this,Yc);k(this,xo,void 0);D(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","!=",Bb).where("name","!=",Fb));const i=await n.execute();return Promise.all(i.map(({name:a})=>qe(this,Yc,dm).call(this,a)))}async getMetadata(e){return{tables:await this.getTables(e)}}}xo=new WeakMap,Yc=new WeakSet,dm=async function(e){var m,w,v,d,I,F;const n=r(this,xo),i=await n.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),a=(F=(I=(d=(v=(w=(m=i.sql)==null?void 0:m.split(/[\(\),]/))==null?void 0:w.find(U=>U.toLowerCase().includes("autoincrement")))==null?void 0:v.trimStart())==null?void 0:d.split(/\s+/))==null?void 0:I[0])==null?void 0:F.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(U=>({name:U.name,dataType:U.type,isNullable:!U.notnull,isAutoIncrementing:U.name===a,hasDefaultValue:U.dflt_value!=null}))}};class pm{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var mm=class{createQueryCompiler(){return new fm}createAdapter(){return new pm}createIntrospector(t){return new hm(t)}},iu,Zc,od,ym=(od=class{constructor(){k(this,iu,new Ub);Yt(this,"connection");k(this,Zc,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,Zc))==null||t.close()}},iu=new WeakMap,Zc=new WeakMap,od),hs,Eo,ad,Ub=(ad=class{constructor(){k(this,hs,void 0);k(this,Eo,void 0)}async lock(){for(;r(this,hs);)await r(this,hs);D(this,hs,new Promise(e=>{D(this,Eo,e)}))}unlock(){const e=r(this,Eo);D(this,hs,void 0),D(this,Eo,void 0),e==null||e()}},hs=new WeakMap,Eo=new WeakMap,ad),wm=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 $b({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,ud,Qb=(ud=class extends ym{constructor(e){super();k(this,Tn,void 0);k(this,Co,void 0);D(this,Tn,e)}async init(){var e,n,i,a;if(D(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 jb(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,ud),mi,Oo,cd,jb=(cd=class extends wm{constructor(e,n,i=!1,a=1e3,l=2e3){super();k(this,mi,void 0);k(this,Oo,void 0);Yt(this,"transactionNum",0);D(this,mi,e),D(this,Oo,n?i?$b({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,Oo)&&r(this,Oo).call(this,r(this,mi).export()),{numAffectedRows:a,insertId:i}}},mi=new WeakMap,Oo=new WeakMap,cd),su,ld,Hb=(ld=class extends mm{constructor(e){super();k(this,su,void 0);D(this,su,e)}createDriver(){return new Qb(r(this,su))}},su=new WeakMap,ld),Mr,ds,fd,Vb=(fd=class extends ym{constructor(e){super();k(this,Mr,void 0);k(this,ds,void 0);D(this,Mr,e)}async init(){D(this,ds,typeof r(this,Mr).database=="function"?await r(this,Mr).database():r(this,Mr).database),this.connection=new zb(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,fd),kn,ps,hd,zb=(hd=class extends wm{constructor(e){super();k(this,kn,void 0);k(this,ps,void 0);D(this,ps,e.db),D(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 w=r(this,kn).row(a);l.push(m.reduce((v,d,I)=>(v[d]=w[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,hd),ou,dd,Kb=(dd=class extends mm{constructor(e){super();k(this,ou,void 0);D(this,ou,e)}createDriver(){return new Vb(r(this,ou))}},ou=new WeakMap,dd);function Jb(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Gb(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 gm={exports:{}};const Xb={},Yb=Object.freeze(Object.defineProperty({__proto__:null,default:Xb},Symbol.toStringTag,{value:"Module"})),Ju=Gb(Yb);(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(W,G){switch(typeof G){case"boolean":Bu(W,G?1:0);break;case"number":Pu(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);Mu(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:qi(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{ne||(T=Ju,ne=Ju)},C=function(o,c){return Ne(),o=ne.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=ne.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},Y&&(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,I),I=null,d.thisProgram&&(F=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,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=Oe=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 O(){return R.startsWith("data:application/octet-stream;base64,")}var R;if(R="sql-wasm.wasm",!O()){var M=R;R=d.locateFile?d.locateFile(M,b):b+M}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 ee(){if(!xe&&(U||Y)){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,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(Z)try{var c=Ju;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},Wi(o,Oi)}var Oi={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,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},kr=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}},mr=(o,c)=>{var h;if(h=(h=Kr(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)},Vo=(o,c,h,g)=>(o=new ra(o,c,h,g),c=Ws(o.parent.id,o.name),o.Wa=On[c],On[c]=o),Ol={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(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 mr(o,c),20}catch{}return Kr(o,"wx")},Ko=(o,c,h)=>{try{var g=mr(o,c)}catch(E){return E.Ka}if(o=Kr(o,"wx"))return o;if(h){if((g.mode&61440)!==16384)return 54;if(g===g.parent||qi(g)==="/")return 10}else if((g.mode&61440)===16384)return 31;return 0},Jo=(o=0)=>{for(;4096>=o;o++)if(!Dn[o])return o;throw new H(33)},qn=(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=te[o.node.rdev].Ha,o.Ha.open&&o.Ha.open(o)},Ta:()=>{throw new H(70)}},Wi=(o,c)=>{te[o]={Ha:c}},Go=(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))},Ii=(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)=>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 g=Is(h,c);if(g)throw new H(g);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=mr(c,o),g=Ko(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),kr(h)},Ti=o=>{var c=Bt(o,{parent:!0}).node;if(!c)throw new H(44);o=Ee(o);var h=mr(c,o),g=Ko(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),kr(h)},Yo=o=>{if(o=Bt(o).node,!o)throw new H(44);if(!o.Ga.readlink)throw new H(28);return Le(qi(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()})},yr=(o,c,h)=>{if(o==="")throw new H(44);if(typeof c=="string"){var g=Ol[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=Ii(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&&(zo(c)!=="r"||c&512)?31:Kr(E,zo(c)):44))throw new H(h);return c&512&&!g&&Gr(E,0),c&=-131713,E=qn({node:E,path:qi(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,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},wr=(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&&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,g,E,void 0),L||(o.position+=c),c},Ss=o=>{var c,h=yr(o,h||0);o=Jr(o).size;var g=new Uint8Array(o);return ki(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=""}))},Ri,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);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]=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 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 _u(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=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,_u(o,c,h))}var ta;ta=Z?()=>{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",_:F||"./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 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)),Oe.set(o,c),c}function xu(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"),Wi(259,{read:()=>0,write:(c,h,g,E)=>E}),Ai("/dev/null",259),Cn(1280,Gt),Cn(1536,Os),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,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 Eu={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),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 g=Bt(c,{Sa:!0}).node;return g?(o="",h&4&&(o+="r"),h&2&&(o+="w"),h&1&&(o+="x"),o&&Kr(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 ks(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){Yr=h;try{var g=yn(o);switch(c){case 0:var E=Bi();return 0>E?-28:qn(g,E).fd;case 1:case 2:return 0;case 3:return g.flags;case 4:return E=Bi(),g.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(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 Gr(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),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(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),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,g){Yr=g;try{c=Qe(c),c=Jn(o,c);var E=g?Bi():0;return yr(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=Yo(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),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(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:ta,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 na().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=na();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=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,g,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,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=wr(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 ee().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:Eu};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://")||Z||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 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,g){h=h||[];var E=h.every(L=>L==="number"||L==="boolean");return c!=="string"&&E&&!g?d["_"+o]:function(){return xu(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"),yr("/dev/stdin",0),yr("/dev/stdout",1),yr("/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(iN,Math.max(rN,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 oN=self.indexedDB||window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB||window.shimIndexedDB,Xf=new Promise((t,e)=>{const n=oN.open(nN,1);n.onupgradeneeded=()=>n.result.createObjectStore("files",{keyPath:"name"}),n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error)});async function aN(t){const e=await Xf,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 sN(n.data);return Gs.set(t,i),i}else return Gs.has(t)?Gs.get(t):null}async function uN(t,e){const n=await Xf;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 Kh(t){const e=await Xf;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 cN(t,e){if(await uN(t,e),Gs.has(t)){const n=Gs.get(t);n.truncate(0),n.write(0,e)}}var lN=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),fN=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,pd,hN=(pd=class extends zf{constructor(e){super();k(this,ms,void 0);D(this,ms,e||lN)}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,pd),au,uu,qo,md,dN=(md=class{constructor(t={}){k(this,au,void 0);k(this,uu,void 0);k(this,qo,void 0);D(this,au,new hN(t.serializer)),D(this,uu,t.deserializer||fN),D(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,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,qo).get(n);return i&&a==="SelectQueryNode"?{...t.result,rows:await this.parseResult(i)}:t.result}},au=new WeakMap,uu=new WeakMap,qo=new WeakMap,md);function $l(t){return typeof t=="string"}function pN(t){return typeof t=="boolean"}async function Jh(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)} - begin - update ${Sn.table(e)} - set ${Sn.ref(i)} = datetime('now','localtime') - where ${Sn.ref(a)} = NEW.${Sn.ref(a)}; - end - `.execute(t).catch(l=>{console.error(l)})}function mN(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 yN(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,I="createAt",F="updateAt";if(m!=null&&m.timestamp&&!pN(m.timestamp)){const{create:U,update:Y}=m.timestamp;I=U??"createAt",F=Y??"updateAt"}for(const U in l){if(!Object.prototype.hasOwnProperty.call(l,U))continue;const Y=l[U];let Z="text";const{type:b,notNull:C,defaultTo:N}=Y;switch(b){case"boolean":case"date":case"object":case"string":Z="text";break;case"increments":v=U;case"number":Z="integer";break;case"blob":Z="blob"}[I,F].includes(U)||(w=w.addColumn(U,Z,q=>b==="increments"?(d=!0,q.autoIncrement().primaryKey()):(C&&(q=q.notNull()),N!==void 0&&(q=q.defaultTo(N instanceof Function?N(Sn):N)),q)))}if(m){const U=m.primary,Y=m.unique;if(m.timestamp&&(I&&(w=w.addColumn(I,"text")),F&&(w=w.addColumn(F,"text"))),!d&&U){const Z=$l(U);v=Z?U:U[0],w=w.addPrimaryKeyConstraint(`pk_${Z?U:U.join("_")}`,Z?[U]:U)}Y==null||Y.forEach(Z=>{const b=$l(Z);v=!U&&!d?b?Z:Z[0]:v,w=w.addUniqueConstraint(`un_${b?Z:Z.join("_")}`,b?[Z]:Z)})}if(await w.ifNotExists().execute(),m!=null&&m.index)for(const U of m.index){const Y=$l(U);let Z=t.schema.createIndex(`idx_${Y?U:U.join("_")}`).on(i);Z=Y?Z.column(U):Z.columns(U),await Z.ifNotExists().execute()}m!=null&&m.timestamp&&(I&&await Jh(t,i,"insert",I,v),F&&await Jh(t,i,"update",F,v))}}var yi,cu,yd,wN=(yd=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,w=m??[];w.push(new dN),this.kysely=new Qa({dialect:e,log:v=>{v.level==="error"?a&&a(v.error):l&&l(v.query,v.queryDurationMillis)},plugins:w}),D(this,yi,i?0:1),D(this,cu,mN(n))}async init(t=!1){const e=t||r(this,yi)===0;return await yN(this.kysely,r(this,cu),e),D(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,yd);async function Yf(t){const e=await new wN({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 gN=new Hb({async database(){const t=await eN({locateFile:()=>tN});return new t.Database(await aN("sqljs"))},onWrite:{func(t){console.log(`[sqljs] write to indexeddb, length: ${t.length}`),cN("sqljs",t)},isThrottle:!0}});function bN(){const t=vy();function e(){Yf(gN).then(n=>{t.value=n})}return{result:t,run:e}}function NN(){return new Worker(""+new URL("sqljsWorker-9211ff35.js",import.meta.url).href)}function vN(){return new Worker(""+new URL("officialWasmWorker-f13be864.js",import.meta.url).href)}const Ve=0,_N=5,xt=10,bm=12,Nm=14,zi=21,Ql=25,xN=27,Gh=100,EN=101,CN=3850,ON=522,qN=1,WN=2,vm=4,IN=8,Vs=0,Zi=1,sc=2,AN=3,oc=4,TN=512,kN=1024,SN=2048,RN=16384,Xh=1,Yh=2,Zh=3,ed=4,td=5,nd=0x7fffffffffffffffn,rd=-0x8000000000000000n;class Rr extends Error{constructor(e,n){super(e),this.code=n}}const Hs=!0;function DN(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 Ql;const ne=C(N,q,T);return Z(b,ne,I.get(N))}}(),e.bind_int64=function(){const b="sqlite3_bind_int64",C=t.cwrap(b,...Ce("nnnn:n"));return function(N,q,T){if(F(N),T>nd||T>32n,ae=C(N,q,Number(ne),Number(Ne));return Z(b,ae,I.get(N))}}(),e.bind_null=function(){const b="sqlite3_bind_null",C=t.cwrap(b,...Ce("nn:n"));return function(N,q){F(N);const T=C(N,q);return Z(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,q){return F(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){F(N);const ne=l(T),Ne=C(N,q,ne,-1,n);return Z(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 q=await C(N);return v.delete(N),Z(b,q,N)}}(),e.column=function(b,C){F(b);const N=e.column_type(b,C);switch(N){case ed:return e.column_blob(b,C);case Yh:return e.column_double(b,C);case Xh:const q=e.column_int(b,C),T=t.getTempRet0();return w(q,T);case td:return null;case Zh: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,q){F(N);const T=e.column_bytes(N,q),ne=C(N,q);return t.HEAPU8.subarray(ne,ne+T)}}(),e.column_bytes=function(){const b="sqlite3_column_bytes",C=t.cwrap(b,...Ce("nn:n"));return function(N,q){return F(N),C(N,q)}}(),e.column_count=function(){const b="sqlite3_column_count",C=t.cwrap(b,...Ce("n:n"));return function(N){return F(N),C(N)}}(),e.column_double=function(){const b="sqlite3_column_double",C=t.cwrap(b,...Ce("nn:n"));return function(N,q){return F(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 F(N),C(N,q)}}(),e.column_int64=function(){const b="sqlite3_column_int64",C=t.cwrap(b,...Ce("nn:n"));return function(N,q){F(N);const T=C(N,q),ne=t.getTempRet0();return m(T,ne)}}(),e.column_name=function(){const b="sqlite3_column_name",C=t.cwrap(b,...Ce("nn:s"));return function(N,q){return F(N),C(N,q)}}(),e.column_names=function(b){const C=[],N=e.column_count(b);for(let q=0;qnd||q>32n;C(N,Number(T),Number(ne))}}(),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",I="",F;(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&&(F=s=>{var u=new XMLHttpRequest;return u.open("GET",s,!1),u.responseType="arraybuffer",u.send(null),new Uint8Array(u.response)}));var U=n.print||console.log.bind(console),Y=n.printErr||console.warn.bind(console);Object.assign(n,l),l=null,n.thisProgram&&(m=n.thisProgram),n.quit&&(w=n.quit);var Z;n.wasmBinary&&(Z=n.wasmBinary);var b=n.noExitRuntime||!0;typeof WebAssembly!="object"&&ut("no native wasm support detected");var C,N=!1,q,T,ne,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=ne=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+")",Y(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,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&&Z)return new Uint8Array(Z);if(F)return F(s);throw"both async and sync fetching of the wasm failed"}catch(u){ut(u)}}function Cs(s){return Z||!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=>{Y("failed to asynchronously prepare wasm: "+y),ut(y)})}function pn(s,u){var f=Re;return Z||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 Y("wasm streaming compile failed: "+_),Y("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 M(s,u){return s?R(ne,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},ee=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=ee(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 te(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 te(60);for(var _=0,S=0;S=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 te(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 te(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=kr(s,"x"))?f:s.Cb.cc?0:2)throw new te(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 ku(s,u,f,y),u=qs(s.parent.id,s.name),s.ac=le[u],le[u]=s),qi={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},mr=(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||On(y)==="/")return 10}else if((y.mode&61440)===16384)return 31;return 0},Ol=(s=0)=>{for(;4096>=s;s++)if(!Gt[s])return s;throw new te(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=Ol(u),s.Wb=u,Gt[u]=s),Kr={open:s=>{s.Mb=Oi[s.node.ec].Mb,s.Mb.open&&s.Mb.open(s)},Zb:()=>{throw new te(70)}},Is=(s,u)=>{Oi[s]={Mb:u}},Ko=(s,u)=>{var f=u==="/",y=!u;if(f&&Cn)throw new te(10);if(!f&&!y){var _=Xt(u,{yc:!1});if(u=_.path,_=_.node,_.$b)throw new te(10);if((_.mode&61440)!==16384)throw new te(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 te(28);var _=mr(y,s);if(_)throw new te(_);if(!y.Cb.jc)throw new te(63);return y.Cb.jc(y,s,u,f)},qn=(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 te(44);var f=Xt(u,{parent:!0}).node;if(!f)throw new te(44);u=z(u);var y=mr(f,u);if(y)throw new te(y);if(!f.Cb.nc)throw new te(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 te(y);if(!u.Cb.mc)throw new te(63);if(f.$b)throw new te(10);u.Cb.mc(u,s),H(f)},Ii=s=>{if(s=Xt(s).node,!s)throw new te(44);if(!s.Cb.fc)throw new te(28);return ce(On(s.parent),s.Cb.fc(s))},an=(s,u)=>{if(s=Xt(s,{Yb:!u}).node,!s)throw new te(44);if(!s.Cb.Tb)throw new te(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 te(63);s.Cb.Qb(s,{mode:u&4095|s.mode&-4096,timestamp:Date.now()})},Xo=(s,u)=>{if(0>u)throw new te(28);if(s=typeof s=="string"?Xt(s,{Yb:!0}).node:s,!s.Cb.Qb)throw new te(63);if((s.mode&61440)===16384)throw new te(31);if((s.mode&61440)!==32768)throw new te(28);var f=kr(s,"w");if(f)throw new te(f);s.Cb.Qb(s,{size:u,timestamp:Date.now()})},Ti=(s,u,f)=>{if(s==="")throw new te(44);if(typeof u=="string"){var y=qi[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=ee(s);try{_=Xt(s,{Yb:!(u&131072)}).node}catch{}}if(y=!1,u&64)if(_){if(u&128)throw new te(20)}else _=Jo(s,f,0),y=!0;if(!_)throw new te(44);if((_.mode&61440)===8192&&(u&=-513),u&65536&&(_.mode&61440)!==16384)throw new te(54);if(!y&&(f=_?(_.mode&61440)===40960?32:(_.mode&61440)===16384&&(Ws(u)!=="r"||u&512)?31:kr(_,Ws(u)):44))throw new te(f);return u&512&&!y&&Xo(_,0),u&=-131713,_=zo({node:_,path:On(_),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 te(8);if(!s.seekable||!s.Mb.Zb)throw new te(70);if(f!=0&&f!=1&&f!=2)throw new te(28);s.position=s.Mb.Zb(s,u,f),s.Tc=[]},Jr=()=>{te||(te=function(s,u){this.name="ErrnoError",this.node=u,this.Rc=function(f){this.Ob=f},this.Rc(s),this.message="FS error"},te.prototype=Error(),te.prototype.constructor=te,[44].forEach(s=>{Dn[s]=new te(s),Dn[s].stack=""}))},Zo,ks=(s,u)=>{var f=0;return s&&(f|=365),u&&(f|=146),f},Gr=(s,u,f)=>{s=ee("/dev/"+s);var y=ks(!!u,!!f);yr||(yr=64);var _=yr++<<8|0;Is(_,{open:S=>{S.seekable=!1},close:()=>{f&&f.buffer&&f.buffer.length&&f(10)},read:(S,A,V,P)=>{for(var B=0,ie=0;ie{for(var B=0;B>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 te(8);return s}function Ln(s,u,f){return ue(s,ne,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 _u(){}function Ds(){}function ta(){}function Ls(){}function na(){}function Ps(){}function Gn(){}function Ms(){}function Bs(){}function Zr(){}function Fs(){}function xu(){}function ra(){}function Eu(){}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 g(){}function E(){}function L(){}function Q(){}function ve(){}function Pe(){}function De(){}function ct(){}function Pn(){}function aa(s){q=s,b||0{ca={resolve:s,reject:u}})}function Al(){var s=fa(12300),u=s+12;ae[s>>2]=u,ae[s+4>>2]=u+12288,u=Us[0];var f=Ou[u];return f===void 0&&(f=Wl++,Ou[u]=f,qu[f]=u),ae[s+8>>2]=f,s}function Iu(s){if(!N){if(Yn===0){var u=!1,f=!1;s((y=0)=>{if(!N&&(Cu=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=Al(),Qi(()=>Mu(Mn)))}else Yn===2?(Yn=0,Qi(pa),Su(Mn),Mn=null,Il.forEach(y=>{if(!N)try{if(y(),!(b||0{s().then(u)})}var Tu={};function Bn(s,u,f,y,_){function S(X){return--dn,P!==0&&ha(P),u==="string"?M(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=[],P=0;if(y)for(var B=0;B{qn("/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),qn("/dev/shm"),qn("/dev/shm/tmp")})(),(()=>{qn("/proc");var s=qn("/proc/self");qn("/proc/self/fd"),Ko({Ub:()=>{var u=Bt(s,"fd",16895,73);return u.Cb={cc:(f,y)=>{var _=Gt[+y];if(!_)throw new te(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:P}=s.get(u);return V(P,f,y?M(y):null,_?M(_):null,S?M(S):null,A?M(A):null)}return 0}}(),function(){const s=new Map,u=new Map;n.createFunction=function(f,y,_,S,A,V){const P=s.size;return s.set(P,{f:V,Xb:A}),Bn("create_function","number","number string number number number number".split(" "),[f,y,_,S,P,0])},n.createAggregate=function(f,y,_,S,A,V,P){const B=s.size;return s.set(B,{step:V,Jc:P,Xb:A}),Bn("create_function","number","number string number number number number".split(" "),[f,y,_,S,B,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(ne.buffer,S,_)),u.delete(y)},_u=function(f,y,_,S){f=s.get(f),u.set(y,f.Xb),f.step(y,new Uint32Array(ne.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(P,B){const ie=`get${P}`,X=`set${P}`;return new Proxy(new DataView(ne.buffer,B,P==="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 Tu=="object",f=new Map,y=new Map,_=new Map,S=u?new Set:null,A=u?new Set:null,V=new Map;sa=function(P,B,ie,X){V.set(M(P),{size:B,dc:Array.from(new Uint32Array(ne.buffer,X,ie))})},n.createModule=function(P,B,ie,X){u&&(ie.handleAsync=Au);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"],[P,B,se,X])},Ms=function(P,B,ie,X,se,Ae){if(B=f.get(B),y.set(se,B),u){S.delete(se);for(const Ge of S)y.delete(Ge)}return X=Array.from(new Uint32Array(ne.buffer,X,ie)).map(Ge=>M(Ge)),B.module.xCreate(P,B.Xb,X,se,s("Int32",Ae))},Gn=function(P,B,ie,X,se,Ae){if(B=f.get(B),y.set(se,B),u){S.delete(se);for(const Ge of S)y.delete(Ge)}return X=Array.from(new Uint32Array(ne.buffer,X,ie)).map(Ge=>M(Ge)),B.module.xConnect(P,B.Xb,X,se,s("Int32",Ae))},ta=function(P,B){var ie=y.get(P),X=V.get("sqlite3_index_info").dc;const se={};se.nConstraint=Ke(B+X[0],"i32"),se.aConstraint=[];for(var Ae=Ke(B+X[1],"*"),Ge=V.get("sqlite3_index_constraint").size,At=0;At>=2,_e[A]+_e[A+1]*2**32}const f=typeof Tu=="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=Au);var P=A.Vc??64;const B=n._malloc(4);return V=Bn("register_vfs","number",["string","number","number","number"],[A.name,P,V?1:0,B]),V||(P=Ke(B,"*"),y.set(P,A)),n._free(B),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,P,B){return _.get(A).xRead(A,ne.subarray(V,V+P),u(B))},Pn=function(A,V,P,B){return _.get(A).xWrite(A,ne.subarray(V,V+P),u(B))},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 P=_.get(A);return V=s("BigInt64",V),P.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 P=_.get(A);return V=s("Int32",V),P.xCheckReservedLock(A,V)},h=function(A,V,P){const B=_.get(A);return P=new DataView(ne.buffer,P),B.xFileControl(A,V,P)},ve=function(A){return _.get(A).xSectorSize(A)},c=function(A){return _.get(A).xDeviceCharacteristics(A)},L=function(A,V,P,B,ie){if(A=y.get(A),_.set(P,A),f){S.delete(P);for(var X of S)_.delete(X)}if(X=null,B&64){X=1;const se=[];for(;X;){const Ae=ne[V++];if(Ae)se.push(Ae);else switch(ne[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=M(V));return ie=s("Int32",ie),A.xOpen(X,P,B,ie)},o=function(A,V,P){return y.get(A).xDelete(M(V),P)},Xn=function(A,V,P,B){return A=y.get(A),B=s("Int32",B),A.xAccess(M(V),P,B)}}();var Tl={a:function(s,u,f,y){ut("Assertion failed: "+M(s)+", at: "+[u?M(u):"unknown filename",f,y?M(y):"unknown function"])},K:function(s,u){try{return s=M(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=M(u),u=wr(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 te(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 te(8);var f=u.node,y=typeof f=="string"?Xt(f,{Yb:!0}).node:f;if(!y.Cb.Qb)throw new te(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 te(8);if(!(y.flags&2097155))throw new te(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=M(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=M(u),u=wr(s,u),u=ee(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=M(u);var _=y&256;return u=wr(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=M(u),u=wr(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=M(u),u=wr(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=M(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=M(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=M(u),u=wr(s,u),f===0){s=u;var y=Xt(s,{parent:!0}).node;if(!y)throw new te(44);var _=z(s),S=Kn(y,_),A=Vo(y,_,!1);if(A)throw new te(A);if(!y.Cb.oc)throw new te(63);if(S.$b)throw new te(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=M(u),u=wr(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(P){if(typeof He>"u"||P.name!=="ErrnoError")throw P;return-P.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 te(2);if((V.flags&2097155)===1)throw new te(2);if(!V.Mb.kc)throw new te(43);var P=V.Mb.kc(V,s,_,u,f),B=P.Pc;return ae[S>>2]=P.Dc,_e[A>>2]=B,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 te(43);y&2||A.Mb.lc&&A.Mb.lc(A,ne.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(P){return(P=P.toTimeString().match(/\(([A-Za-z ]+)\)$/))?P[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=ne.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 te(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],P=_e[s+4>>2];s+=8;var B=_,ie=V,X=P,se=S,Ae=T;if(0>X||0>se)throw new te(28);if(B.Wb===null)throw new te(8);if((B.flags&2097155)===1)throw new te(8);if((B.node.mode&61440)===16384)throw new te(31);if(!B.Mb.read)throw new te(28);var Ge=typeof se<"u";if(!Ge)se=B.position;else if(!B.seekable)throw new te(70);var At=B.Mb.read(B,Ae,ie,X,se);Ge||(B.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 Iu(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],P=_e[s+4>>2];s+=8;var B=_,ie=V,X=P,se=S,Ae=T;if(0>X||0>se)throw new te(28);if(B.Wb===null)throw new te(8);if(!(B.flags&2097155))throw new te(8);if((B.node.mode&61440)===16384)throw new te(31);if(!B.Mb.write)throw new te(28);B.seekable&&B.flags&1024&&Yo(B,0,2);var Ge=typeof se<"u";if(!Ge)se=B.position;else if(!B.seekable)throw new te(70);var At=B.Mb.write(B,Ae,ie,X,se,void 0);Ge||(B.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:_u,la:Ds,G:ta,h:Ls,oa:na,ja:Ps,ea:Gn,fa:Ms,k:Bs,v:Zr,pa:Fs,g:xu,qa:ra,da:Eu,ha:ia,ia:Fi,na:Ui,c:sa,ka:ei,ma:ti,aa:Xn,V:$i,$:oa,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=ql(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:Tl};if(ge++,n.monitorRunDependencies&&n.monitorRunDependencies(ge),n.instantiateWasm)try{return n.instantiateWasm(u,s)}catch(f){Y("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)},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 Ru=n._main=function(){return(Ru=n._main=n.asm.Bb).apply(null,arguments)};function Du(){return(Du=n.asm.Db).apply(null,arguments)}function Lu(){return(Lu=n.asm.Eb).apply(null,arguments)}function Pu(){return(Pu=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 Mu(){return(Mu=n.asm.Ib).apply(null,arguments)}function Bu(){return(Bu=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=Lu,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=M,n.stringToUTF8=Ln,n.lengthBytesUTF8=oe;var $s;Oe=function s(){$s||W(),$s||(Oe=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=Ru;try{var f=u(0,0);q=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,gf=async function(e,n){const i=n&MN;try{const a=()=>e.call(this,i);return await D(this,lu,r(this,lu).then(a,a)),D(this,jt,i),Ve}catch(a){return a.name==="AbortError"?_N:(console.error(a),CN)}},el=new WeakSet,_m=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 sc:return this._SHAREDtoRESERVED();case oc:return this._SHAREDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}case sc:switch(e){case oc:return this._RESERVEDtoEXCLUSIVE();default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}},tl=new WeakSet,xm=async function(e){if(e===r(this,jt))return Ve;switch(r(this,jt)){case oc:switch(e){case Zi:return this._EXCLUSIVEtoSHARED();case Vs:return this._EXCLUSIVEtoNONE();default:throw new Error(`unexpected transition ${r(this,jt)} -> ${e}`)}case sc: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 FN extends BN{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 UN=5e3;let $N=0;const jl=new WeakMap;function Nr(...t){}var Io,Ao,hu,Rt,du,To,ys,nl,Em;class QN{constructor(e,n={durability:"default"}){k(this,nl);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());D(this,Ao,Promise.resolve(e).then(i=>D(this,Io,i))),D(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(()=>qe(this,nl,Em).call(this,e,n));return D(this,To,i.catch(()=>{})),i}async sync(){await r(this,ys),D(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,nl=new WeakSet,Em=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")D(this,Rt,null);else if(performance.now()-r(this,du)>UN){try{(l=r(this,Rt))==null||l.commit()}catch(m){if(m.name!=="InvalidStateError")throw m}await new Promise(m=>setTimeout(m)),D(this,Rt,null)}for(let m=0;m<2;++m){if(!r(this,Rt)){D(this,Rt,i.transaction(i.objectStoreNames,e,r(this,hu)));const w=D(this,du,performance.now());D(this,ys,r(this,ys).then(()=>new Promise((v,d)=>{r(this,Rt).addEventListener("complete",I=>{v(),r(this,Rt)===I.target&&D(this,Rt,null),Nr(`transaction ${jl.get(I.target)} complete`)}),r(this,Rt).addEventListener("abort",I=>{console.warn("tx abort",(performance.now()-w)/1e3);const F=I.target.error;d(F),r(this,Rt)===I.target&&D(this,Rt,null),Nr(`transaction ${jl.get(I.target)} aborted`,F)})}))),jl.set(r(this,Rt),$N++)}try{const w=Object.fromEntries(Array.from(i.objectStoreNames,v=>[v,new jN(r(this,Rt).objectStore(v))]));return await n(w)}catch(w){if(D(this,Rt,null),m)throw w}}};function si(t){return new Promise((e,n)=>{t.addEventListener("success",()=>e(t.result)),t.addEventListener("error",()=>n(t.error))})}var It;class jN{constructor(e){k(this,It,void 0);D(this,It,e)}get(e){Nr(`get ${r(this,It).name}`,e);const n=r(this,It).get(e);return si(n)}getAll(e,n){Nr(`getAll ${r(this,It).name}`,e,n);const i=r(this,It).getAll(e,n);return si(i)}getKey(e){Nr(`getKey ${r(this,It).name}`,e);const n=r(this,It).getKey(e);return si(n)}getAllKeys(e,n){Nr(`getAllKeys ${r(this,It).name}`,e,n);const i=r(this,It).getAllKeys(e,n);return si(i)}put(e,n){Nr(`put ${r(this,It).name}`,e,n);const i=r(this,It).put(e,n);return si(i)}delete(e){Nr(`delete ${r(this,It).name}`,e);const n=r(this,It).delete(e);return si(n)}clear(){Nr(`clear ${r(this,It).name}`);const e=r(this,It).clear();return si(e)}index(e){return new HN(r(this,It).index(e))}}It=new WeakMap;var ws;class HN{constructor(e){k(this,ws,void 0);D(this,ws,e)}getAllKeys(e,n){Nr(`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 VN=512,id=3e3,sd={durability:"default",purge:"deferred",purgeAtLeast:16};function gn(...t){}var wi,Ht,pt,gs,bs,Br,pu,bf,rl,Cm,il,Om,gi,zs,sl,qm;class zN extends PN{constructor(n="wa-sqlite",i=sd){super();k(this,pu);k(this,rl);k(this,il);k(this,gi);k(this,sl);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,D(this,wi,Object.assign({},sd,i)),D(this,pt,new QN(KN(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()),D(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 FN(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,gi,zs).call(this,w,0)),!w.block0)if(a&vm)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&qN,!0),Ve}catch(m){return console.error(m),Nm}})}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&IN&&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(;vid){const m=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&r(this,Br).add(n),await new Promise(v=>setTimeout(v));const w=qe(this,pu,bf).call(this,n,i,a);return D(this,bs,performance.now()),w});return l&&r(this,Br).delete(n),m}return qe(this,pu,bf).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,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)>id){const m=this.handleAsync(async()=>{this.handleAsync!==super.handleAsync&&r(this,Br).add(n);const w=await qe(this,rl,Cm).call(this,n,i);return D(this,bs,performance.now()),w});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(qe(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 VN}xDeviceCharacteristics(n){return RN|TN|kN|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,sl,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 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 I of w)d.data.set(I,m.version);v.put(d),qe(this,il,Om).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 bm}}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,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,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`)})}}wi=new WeakMap,Ht=new WeakMap,pt=new WeakMap,gs=new WeakMap,bs=new WeakMap,Br=new WeakMap,pu=new WeakSet,bf=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}},rl=new WeakSet,Cm=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},il=new WeakSet,Om=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 Y=await U.index("version").getAllKeys(IDBKeyRange.bound([n.path,F+1],[n.path,1/0]));for(const Z of Y)U.delete(Z);U.delete([n.path,"purge",0]);for(let Z=0;Z=I)break;const T={path:C.path,offset:q,version:F,data:C.data.subarray(N*l,(N+1)*l)};T.offset===0&&(T.fileSize=I,n.block0=T),U.put(T)}}}})};function KN(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 JN=""+new URL("wa-sqlite-async-24800831.wasm",import.meta.url).href,GN=new Kb({async database(){const t=await LN({locateFile:()=>JN}),e=DN(t),n="wa-sqlite-test";e.vfs_register(new zN(n));const i=await e.open_v2(n,void 0,n);return{sqlite:e,db:i}}});function XN(){console.log("start wa-sqlite test"),Yf(GN).then(t=>{t==null||t.forEach(e=>console.log("[wa-sqlite]",e))})}function YN(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)})}}}function ZN(t){const e=YN(t);return{...e,once(n,i){const a=l=>{e.off(n,a),i(l)};e.on(n,a)}}}var Fr,Er,mu,Cr,wd,e0=(wd=class{constructor(t){k(this,Fr,void 0);k(this,Er,void 0);Yt(this,"connection");k(this,mu,new t0);k(this,Cr,void 0);D(this,Fr,Object.freeze({...t}))}async init(){D(this,Er,r(this,Fr).worker??new Worker(new URL(""+new URL("worker-72ad2512.js",import.meta.url).href,self.location),{type:"module"})),D(this,Cr,ZN()),r(this,Er).onmessage=({data:{msg:e,type:n}})=>{var i;(i=r(this,Cr))==null||i.emit(n,e)};const t={type:"init",dbName:r(this,Fr).dbName,url:r(this,Fr).url};r(this,Er).postMessage(t),await new Promise((e,n)=>{var i;(i=r(this,Cr))==null||i.once("init",({err:a})=>{a?n(a):e()})}),this.connection=new n0(r(this,Er),r(this,Cr)),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,Er))return r(this,Er).postMessage({type:"close"}),new Promise((t,e)=>{var n;(n=r(this,Cr))==null||n.once("close",({err:i})=>{var a,l;i?e(i):((a=r(this,Er))==null||a.terminate(),(l=r(this,Cr))==null||l.all.clear(),D(this,Cr,void 0),t())})})}},Fr=new WeakMap,Er=new WeakMap,mu=new WeakMap,Cr=new WeakMap,wd),Ns,ko,gd,t0=(gd=class{constructor(){k(this,Ns,void 0);k(this,ko,void 0)}async lock(){for(;r(this,Ns);)await r(this,Ns);D(this,Ns,new Promise(t=>{D(this,ko,t)}))}unlock(){const t=r(this,ko);D(this,Ns,void 0),D(this,ko,void 0),t==null||t()}},Ns=new WeakMap,ko=new WeakMap,gd),yu,So,bd,n0=(bd=class{constructor(t,e){k(this,yu,void 0);k(this,So,void 0);D(this,yu,t),D(this,So,e)}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,yu).postMessage(l),new Promise((m,w)=>{r(this,So)||w("kysely instance has been destroyed"),r(this,So).once("run",({data:v,err:d})=>{!d&&v?m(v):w(d)})})}},yu=new WeakMap,So=new WeakMap,bd),wu,Nd,r0=(Nd=class{constructor(t){k(this,wu,void 0);D(this,wu,t)}createDriver(){return new e0(r(this,wu))}createQueryCompiler(){return new fm}createAdapter(){return new pm}createIntrospector(t){return new hm(t)}},wu=new WeakMap,Nd);const i0=""+new URL("wa-sqlite-async-24800831.wasm",import.meta.url).href,s0=new r0({dbName:"wa-sqlite-worker-test",url:i0});function o0(){console.log("start wa-sqlite-worker test"),Yf(s0).then(t=>{t==null||t.forEach(e=>console.log("[wa-sqlite-worker]",e))})}const a0=Ct("h1",null,[Ra(" test "),Ct("a",{href:"https://github.com/kysely-org/kysely",target:"_blank"},"Kysely"),Ra(" WASM dialect ")],-1),u0=Ct("br",null,null,-1),c0=Ct("h3",null,"see worker result in console",-1),l0=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),f0=Ct("br",null,null,-1),h0={class:"buttons"},d0=Ct("br",null,null,-1),p0=Ct("div",null," result run in main thread: ",-1),m0=Vy({__name:"App",setup(t){const e=new NN,{result:n,run:i}=bN(),a=new vN;function l(){i()}function m(){e.postMessage("")}function w(){a.postMessage("")}function v(){XN()}function d(){o0()}async function I(){(await window.indexedDB.databases()).forEach(Y=>{window.indexedDB.deleteDatabase(Y.name)})}async function F(){const U=await navigator.storage.getDirectory();await Kh("sqljs"),await Kh("sqlijsWorker"),await I();try{await U.removeEntry("test.db")}catch{}try{await U.removeEntry("test.db-journal")}catch{}console.log("clear all")}return(U,Y)=>(vw(),Ew(ur,null,[a0,u0,c0,l0,f0,Ct("div",h0,[Ct("button",{onClick:Y[0]||(Y[0]=Z=>l())}," test sqljs in main thread "),Ct("button",{onClick:Y[1]||(Y[1]=Z=>m())}," test sqljs in Worker "),Ct("button",{onClick:Y[2]||(Y[2]=Z=>w())}," test officialWasm in Worker "),Ct("button",{onClick:Y[3]||(Y[3]=Z=>v())}," test wa-sqlite in main thread "),Ct("button",{onClick:Y[4]||(Y[4]=Z=>d())}," test wa-sqlite in Worker "),Ct("button",{onClick:Y[5]||(Y[5]=Z=>F())}," clear ")]),d0,p0,Ct("pre",null,""+Lm(Qd(n))+` - `,1)],64))}});ug(m0).mount("#root"); diff --git a/assets/officialWasmWorker-155b9b7a.js b/assets/officialWasmWorker-155b9b7a.js new file mode 100644 index 0000000..67bca38 --- /dev/null +++ b/assets/officialWasmWorker-155b9b7a.js @@ -0,0 +1,13 @@ +var Zc=Object.defineProperty;var ed=(Te,Ne,et)=>Ne in Te?Zc(Te,Ne,{enumerable:!0,configurable:!0,writable:!0,value:et}):Te[Ne]=et;var ze=(Te,Ne,et)=>(ed(Te,typeof Ne!="symbol"?Ne+"":Ne,et),et),ao=(Te,Ne,et)=>{if(!Ne.has(Te))throw TypeError("Cannot "+et)};var s=(Te,Ne,et)=>(ao(Te,Ne,"read from private field"),et?et.call(Te):Ne.get(Te)),M=(Te,Ne,et)=>{if(Ne.has(Te))throw TypeError("Cannot add the same private member more than once");Ne instanceof WeakSet?Ne.add(Te):Ne.set(Te,et)},$=(Te,Ne,et,Ir)=>(ao(Te,Ne,"write to private field"),Ir?Ir.call(Te,et):Ne.set(Te,et),et);var Le=(Te,Ne,et)=>(ao(Te,Ne,"access private method"),et);(function(){var Ve,Pn,sr,Hr,$r,ge,Gr,He,ye,Jr,Z,Kr,te,or,as,ar,Ln,ls,Ma,us,Ua,Dn,gi,Xr,lo,cs,ja,Yr,Re,Zr,lr,ur,Bn,ei,uo,F,cr,dr,fr,hr,Sn,Ue,pr,_r,mr,yr,sn,gr,Fe,Mn,Xt,bt,nt,je,Ze,Pe,Ft,ke,pt,xt,Et,_s,$e,_t,Pt,Lt,ut,wr,an,ln,_n,Yt,In,mn,Qn,si,ms,Qa,ys,za,gs,Va,ws,Ha,oi,co,ai,On,qs,$a,An,zn,mt,Zt,Vn,en,At,Nr,Os,li,fo,ui,ho,vr,Tn,Ns,xr,Hn,Er,vs,Ga,ci,ya,di,ga;"use strict";function Te(t){return typeof t>"u"||t===void 0}function Ne(t){return typeof t=="string"}function et(t){return typeof t=="number"}function Ir(t){return typeof t=="boolean"}function po(t){return t===null}function Ja(t){return t instanceof Date}function Ka(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 Or(t){return Array.isArray(t)}function Kn(t){return t}const tt=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]})}}),Je=h({is(t){return t.kind==="IdentifierNode"},create(t){return h({kind:"IdentifierNode",name:t})}}),qn=h({is(t){return t.kind==="CreateIndexNode"},create(t){return h({kind:"CreateIndexNode",name:Je.create(t)})},cloneWith(t,e){return h({...t,...e})},cloneWithColumns(t,e){return h({...t,columns:[...t.columns||[],...e]})}}),_o=h({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return h({kind:"CreateSchemaNode",schema:Je.create(t),...e})},cloneWith(t,e){return h({...t,...e})}}),Xa=["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})}}),bn=h({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return h({kind:"SchemableIdentifierNode",identifier:Je.create(t)})},createWithSchema(t,e){return h({kind:"SchemableIdentifierNode",schema:Je.create(t),identifier:Je.create(e)})}}),wi=h({is(t){return t.kind==="DropIndexNode"},create(t,e){return h({kind:"DropIndexNode",name:bn.create(t),...e})},cloneWith(t,e){return h({...t,...e})}}),As=h({is(t){return t.kind==="DropSchemaNode"},create(t,e){return h({kind:"DropSchemaNode",schema:Je.create(t),...e})},cloneWith(t,e){return h({...t,...e})}}),Ts=h({is(t){return t.kind==="DropTableNode"},create(t,e){return h({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return h({...t,...e})}}),Wn=h({is(t){return t.kind==="AliasNode"},create(t,e){return h({kind:"AliasNode",node:t,alias:e})}}),Nn=h({is(t){return t.kind==="TableNode"},create(t){return h({kind:"TableNode",table:bn.create(t)})},createWithSchema(t,e){return h({kind:"TableNode",table:bn.createWithSchema(t,e)})}});function Nt(t){return tn(t)&&Rt(t.toOperationNode)}function Ya(t){return tn(t)&&"expressionType"in t&&Nt(t)}function Za(t){return tn(t)&&"expression"in t&&Ne(t.alias)&&Nt(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})}}),Ar=h({is(t){return t.kind==="AndNode"},create(t,e){return h({kind:"AndNode",left:t,right:e})}}),Tr=h({is(t){return t.kind==="OrNode"},create(t,e){return h({kind:"OrNode",left:t,right:e})}}),Cr=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"?Ar.create(t.on,r):Tr.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:Cr.create(r)})},cloneWithOn(t,e){return h({...t,on:t.on?Cr.cloneWithOperation(t.on,"And",e):Cr.create(e)})},cloneWithOrOn(t,e){return h({...t,on:t.on?Cr.cloneWithOperation(t.on,"Or",e):Cr.create(e)})}}),qi=h({is(t){return t.kind==="BinaryOperationNode"},create(t,e,r){return h({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:r})}}),gt=h({is(t){return t.kind==="RawNode"},create(t,e){return h({kind:"RawNode",sqlFragments:h(t),parameters:h(e)})},createWithSql(t){return gt.create([t],[])},createWithChild(t){return gt.create(["",""],[t])},createWithChildren(t){return gt.create(new Array(t.length+1).fill(""),t)}}),mo=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->"],el=["+","-","*","/","%","^","&","|","#","<<",">>"],yo=[...mo,...el,"&&","||"],tl=["not","-",...["exists","not exists"]],nl=[...yo,...tl],Cs=h({is(t){return t.kind==="OperatorNode"},create(t){return h({kind:"OperatorNode",operator:t})}});function go(t){return Ne(t)&&yo.includes(t)}function wo(t){return Ne(t)&&mo.includes(t)}const Xn=h({is(t){return t.kind==="ParensNode"},create(t){return h({kind:"ParensNode",node:t})}}),Xe=h({is(t){return t.kind==="ColumnNode"},create(t){return h({kind:"ColumnNode",column:Je.create(t)})}}),Ws=h({is(t){return t.kind==="SelectAllNode"},create(){return h({kind:"SelectAllNode"})}}),bi=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:Ws.create()})}}),rl=h({is(t){return t.kind==="OrderByItemNode"},create(t,e){return h({kind:"OrderByItemNode",orderBy:t,direction:e})}});function il(t){return t==="asc"||t==="desc"}function Ni(t,e){return rl.create(sl(t),ol(e))}function sl(t){return fn(t)}function ol(t){if(t)return t==="asc"||t==="desc"?gt.createWithSql(t):t.toOperationNode()}function qo(t){return Ne(t)?Yn(t):t.toOperationNode()}function Wr(t){return Or(t)?t.map(e=>fn(e)):[fn(t)]}function fn(t){return Bi(t)?Ri(t):qo(t)}function Yn(t){const e=".";if(t.includes(e)){const r=t.split(e).map(Fs);if(r.length===3)return ll(r);if(r.length===2)return ul(r);throw new Error(`invalid column reference ${t}`)}else return Xe.create(t)}function al(t){const e=" as ";if(t.includes(e)){const[r,n]=t.split(e).map(Fs);return Wn.create(Yn(r),Je.create(n))}else return Yn(t)}function bo(t){return Xe.create(t)}function No(t){const e=" ";if(t.includes(e)){const[r,n]=t.split(e).map(Fs);if(!il(n))throw new Error(`invalid order direction "${n}" next to "${r}"`);return Ni(r,n)}else return bo(t)}function ll(t){const[e,r,n]=t;return bi.create(Nn.createWithSchema(e,r),Xe.create(n))}function ul(t){const[e,r]=t;return bi.create(Nn.create(e),Xe.create(r))}function Fs(t){return t.trim()}const vo=h({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return h({kind:"PrimitiveValueListNode",values:h([...t])})}}),Ps=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 xo(t){return Or(t)?cl(t):hn(t)}function hn(t){return Bi(t)?Ri(t):nn.create(t)}function cl(t){return t.some(Bi)?Ps.create(t.map(e=>hn(e))):vo.create(t)}const Zn=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])})}}),Eo=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])})}}),Ls=h({is(t){return t.kind==="OverNode"},create(){return h({kind:"OverNode"})},cloneWithOrderByItem(t,e){return h({...t,orderBy:t.orderBy?Zn.cloneWithItem(t.orderBy,e):Zn.create(e)})},cloneWithPartitionByItems(t,e){return h({...t,partitionBy:t.partitionBy?Eo.cloneWithItems(t.partitionBy,e):Eo.create(e)})}}),vi=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])})}}),So=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])})}}),xi=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"?Ar.create(t.having,r):Tr.create(t.having,r)})}}),_e=h({is(t){return t.kind==="SelectQueryNode"},create(t,e){return h({kind:"SelectQueryNode",from:vi.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?Zn.cloneWithItem(t.orderBy,e):Zn.create(e)})},cloneWithGroupByItems(t,e){return h({...t,groupBy:t.groupBy?So.cloneWithItems(t.groupBy,e):So.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?xi.cloneWithOperation(t.having,"And",e):xi.create(e)})},cloneWithOrHaving(t,e){return h({...t,having:t.having?xi.cloneWithOperation(t.having,"Or",e):xi.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})}}),ko=h({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return h({kind:"UnaryOperationNode",operator:t,operand:e})}});function wt(t){return Ds("exists",t)}function ft(t){return Ds("not exists",t)}function Ds(t,e){return ko.create(Cs.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){M(this,Ve,void 0);$(this,Ve,h(e))}on(...e){return new Jt({...s(this,Ve),joinNode:Bt.cloneWithOn(s(this,Ve).joinNode,Ho(e))})}orOn(...e){return new Jt({...s(this,Ve),joinNode:Bt.cloneWithOrOn(s(this,Ve).joinNode,Ho(e))})}onRef(e,r,n){return new Jt({...s(this,Ve),joinNode:Bt.cloneWithOn(s(this,Ve).joinNode,ht(e,r,n))})}orOnRef(e,r,n){return new Jt({...s(this,Ve),joinNode:Bt.cloneWithOrOn(s(this,Ve).joinNode,ht(e,r,n))})}onExists(e){return new Jt({...s(this,Ve),joinNode:Bt.cloneWithOn(s(this,Ve).joinNode,wt(e))})}onNotExists(e){return new Jt({...s(this,Ve),joinNode:Bt.cloneWithOn(s(this,Ve).joinNode,ft(e))})}orOnExists(e){return new Jt({...s(this,Ve),joinNode:Bt.cloneWithOrOn(s(this,Ve).joinNode,wt(e))})}orOnNotExists(e){return new Jt({...s(this,Ve),joinNode:Bt.cloneWithOrOn(s(this,Ve).joinNode,ft(e))})}onTrue(){return new Jt({...s(this,Ve),joinNode:Bt.cloneWithOn(s(this,Ve).joinNode,gt.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return s(this,Ve).joinNode}};let Ei=Jt;Ve=new WeakMap,Se(Ei,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const dl=h({is(t){return t.kind==="PartitionByItemNode"},create(t){return h({kind:"PartitionByItemNode",partitionBy:t})}});function fl(t){return Wr(t).map(dl.create)}const os=class{constructor(e){M(this,Pn,void 0);$(this,Pn,h(e))}orderBy(e,r){return new os({overNode:Ls.cloneWithOrderByItem(s(this,Pn).overNode,Ni(e,r))})}partitionBy(e){return new os({overNode:Ls.cloneWithPartitionByItems(s(this,Pn).overNode,fl(e))})}$call(e){return e(this)}toOperationNode(){return s(this,Pn).overNode}};let Si=os;Pn=new WeakMap,Se(Si,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");const Fr=h({is(t){return t.kind==="SelectionNode"},create(t){return h({kind:"SelectionNode",selection:t})},createSelectAll(){return h({kind:"SelectionNode",selection:Ws.create()})},createSelectAllFromTable(t){return h({kind:"SelectionNode",selection:bi.createSelectAll(t)})}});class hl{constructor(e){M(this,sr,void 0);$(this,sr,e)}get dynamicReference(){return s(this,sr)}get refType(){}toOperationNode(){return qo(s(this,sr))}}sr=new WeakMap;function pl(t){return tn(t)&&Nt(t)&&Ne(t.dynamicReference)}function Pr(t){return Rt(t)?Pr(t(pn())):Or(t)?t.map(e=>Io(e)):[Io(t)]}function Io(t){return Ne(t)?Fr.create(al(t)):pl(t)?Fr.create(t.toOperationNode()):Fr.create(ea(t))}function Lr(t){return t?Array.isArray(t)?t.map(Oo):[Oo(t)]:[Fr.createSelectAll()]}function Oo(t){if(Ne(t))return Fr.createSelectAllFromTable(Ot(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const _l=h({is(t){return t.kind==="ValuesNode"},create(t){return h({kind:"ValuesNode",values:h(t)})}}),ml=h({is(t){return t.kind==="DefaultInsertValueNode"},create(){return h({kind:"DefaultInsertValueNode"})}});function yl(t){const e=Rt(t)?t(pn()):t,r=Or(e)?e:h([e]);return gl(r)}function gl(t){const e=wl(t);return[h([...e.keys()].map(Xe.create)),_l.create(t.map(r=>ql(r,e)))]}function wl(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 ql(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)||Bi(Oe))&&(A=!0),n[me]=Oe}if(r.lengthTe(me)?ae:hn(me)))}return vo.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})}}),ki=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?vi.cloneWithFroms(t.from,e):vi.create(e)})},cloneWithUpdates(t,e){return h({...t,updates:t.updates?h([...t.updates,...e]):e})}}),Ao=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])})}}),Dr=h({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return h({kind:"DeleteQueryNode",from:vi.create(t),...e&&{with:e}})},cloneWithOrderByItem(t,e){return h({...t,orderBy:t.orderBy?Zn.cloneWithItem(t.orderBy,e):Zn.create(e)})},cloneWithLimit(t,e){return h({...t,limit:e})},cloneWithUsing(t,e){return h({...t,using:t.using!==void 0?Ao.cloneWithTables(t.using,e):Ao.create(e)})}}),qt=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"?Ar.create(t.where,r):Tr.create(t.where,r)})}}),To=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)||ki.is(t)||Dr.is(t)},cloneWithWhere(t,e){return h({...t,where:t.where?qt.cloneWithOperation(t.where,"And",e):qt.create(e)})},cloneWithOrWhere(t,e){return h({...t,where:t.where?qt.cloneWithOperation(t.where,"Or",e):qt.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?To.cloneWithSelections(t.returning,e):To.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())})}}),Nl=h({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return h({kind:"ColumnUpdateNode",column:t,value:e})}});function Rs(t){const e=Rt(t)?t(pn()):t;return Object.entries(e).filter(([r,n])=>n!==void 0).map(([r,n])=>Nl.create(Xe.create(r),hn(n)))}const vl=h({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return h({kind:"OnDuplicateKeyNode",updates:t})}});class Co{constructor(e,r){M(this,Hr,void 0);M(this,$r,void 0);$(this,Hr,e),$(this,$r,r)}get insertId(){return s(this,Hr)}get numInsertedOrUpdatedRows(){return s(this,$r)}}Hr=new WeakMap,$r=new WeakMap;for(const t of["insertId","numInsertedOrUpdatedRows"])Object.defineProperty(Co.prototype,t,{enumerable:!0});class Ii extends Error{constructor(r){super("no result");ze(this,"node");this.node=r}}function Oi(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?qt.cloneWithOperation(t.indexWhere,"And",e):qt.create(e)})},cloneWithIndexOrWhere(t,e){return h({...t,indexWhere:t.indexWhere?qt.cloneWithOperation(t.indexWhere,"Or",e):qt.create(e)})},cloneWithUpdateWhere(t,e){return h({...t,updateWhere:t.updateWhere?qt.cloneWithOperation(t.updateWhere,"And",e):qt.create(e)})},cloneWithUpdateOrWhere(t,e){return h({...t,updateWhere:t.updateWhere?qt.cloneWithOperation(t.updateWhere,"Or",e):qt.create(e)})},cloneWithoutIndexWhere(t){return h({...t,indexWhere:void 0})},cloneWithoutUpdateWhere(t){return h({...t,updateWhere:void 0})}}),vt=class{constructor(e){M(this,ge,void 0);$(this,ge,h(e))}column(e){const r=Xe.create(e);return new vt({...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(Xe.create);return new vt({...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 vt({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{constraint:Je.create(e)})})}expression(e){return new vt({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new vt({...s(this,ge),onConflictNode:Me.cloneWithIndexWhere(s(this,ge).onConflictNode,Ct(e))})}whereRef(e,r,n){return new vt({...s(this,ge),onConflictNode:Me.cloneWithIndexWhere(s(this,ge).onConflictNode,ht(e,r,n))})}orWhere(...e){return new vt({...s(this,ge),onConflictNode:Me.cloneWithIndexOrWhere(s(this,ge).onConflictNode,Ct(e))})}orWhereRef(e,r,n){return new vt({...s(this,ge),onConflictNode:Me.cloneWithIndexOrWhere(s(this,ge).onConflictNode,ht(e,r,n))})}whereExists(e){return new vt({...s(this,ge),onConflictNode:Me.cloneWithIndexWhere(s(this,ge).onConflictNode,wt(e))})}whereNotExists(e){return new vt({...s(this,ge),onConflictNode:Me.cloneWithIndexWhere(s(this,ge).onConflictNode,ft(e))})}orWhereExists(e){return new vt({...s(this,ge),onConflictNode:Me.cloneWithIndexOrWhere(s(this,ge).onConflictNode,wt(e))})}orWhereNotExists(e){return new vt({...s(this,ge),onConflictNode:Me.cloneWithIndexOrWhere(s(this,ge).onConflictNode,ft(e))})}clearWhere(){return new vt({...s(this,ge),onConflictNode:Me.cloneWithoutIndexWhere(s(this,ge).onConflictNode)})}doNothing(){return new Wo({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new Ti({...s(this,ge),onConflictNode:Me.cloneWith(s(this,ge).onConflictNode,{updates:Rs(e)})})}$call(e){return e(this)}};let Ai=vt;ge=new WeakMap,Se(Ai,"don't await OnConflictBuilder instances.");class Wo{constructor(e){M(this,Gr,void 0);$(this,Gr,h(e))}toOperationNode(){return s(this,Gr).onConflictNode}}Gr=new WeakMap,Se(Wo,"don't await OnConflictDoNothingBuilder instances.");const Kt=class{constructor(e){M(this,He,void 0);$(this,He,h(e))}where(...e){return new Kt({...s(this,He),onConflictNode:Me.cloneWithUpdateWhere(s(this,He).onConflictNode,Ct(e))})}whereRef(e,r,n){return new Kt({...s(this,He),onConflictNode:Me.cloneWithUpdateWhere(s(this,He).onConflictNode,ht(e,r,n))})}orWhere(...e){return new Kt({...s(this,He),onConflictNode:Me.cloneWithUpdateOrWhere(s(this,He).onConflictNode,Ct(e))})}orWhereRef(e,r,n){return new Kt({...s(this,He),onConflictNode:Me.cloneWithUpdateOrWhere(s(this,He).onConflictNode,ht(e,r,n))})}whereExists(e){return new Kt({...s(this,He),onConflictNode:Me.cloneWithUpdateWhere(s(this,He).onConflictNode,wt(e))})}whereNotExists(e){return new Kt({...s(this,He),onConflictNode:Me.cloneWithUpdateWhere(s(this,He).onConflictNode,ft(e))})}orWhereExists(e){return new Kt({...s(this,He),onConflictNode:Me.cloneWithUpdateOrWhere(s(this,He).onConflictNode,wt(e))})}orWhereNotExists(e){return new Kt({...s(this,He),onConflictNode:Me.cloneWithUpdateOrWhere(s(this,He).onConflictNode,ft(e))})}clearWhere(){return new Kt({...s(this,He),onConflictNode:Me.cloneWithoutUpdateWhere(s(this,He).onConflictNode)})}$call(e){return e(this)}toOperationNode(){return s(this,He).onConflictNode}};let Ti=Kt;He=new WeakMap,Se(Ti,"don't await OnConflictUpdateBuilder instances.");const at=class{constructor(e){M(this,ye,void 0);$(this,ye,h(e))}values(e){const[r,n]=yl(e);return new at({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{columns:r,values:n})})}columns(e){return new at({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{columns:h(e.map(Xe.create))})})}expression(e){return new at({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{values:Ri(e)})})}ignore(){return new at({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{ignore:!0})})}onConflict(e){return new at({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{onConflict:e(new Ai({onConflictNode:Me.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new at({...s(this,ye),queryNode:rn.cloneWith(s(this,ye).queryNode,{onDuplicateKey:vl.create(Rs(e))})})}returning(e){return new at({...s(this,ye),queryNode:re.cloneWithReturning(s(this,ye).queryNode,Pr(e))})}returningAll(){return new at({...s(this,ye),queryNode:re.cloneWithReturning(s(this,ye).queryNode,Lr())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new at({...s(this,ye)})}if(e,r){return e?r(this):new at({...s(this,ye)})}$castTo(){return new at(s(this,ye))}castTo(){return this.$castTo()}$narrowType(){return new at(s(this,ye))}$assertType(){return new at(s(this,ye))}assertType(){return new at(s(this,ye))}withPlugin(e){return new at({...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 Co(n.insertId,n.numAffectedRows??n.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Ii){const r=await this.executeTakeFirst();if(r===void 0)throw Oi(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 at({...s(this,ye),queryNode:re.cloneWithExplain(s(this,ye).queryNode,e,r)}).execute()}};let Rr=at;ye=new WeakMap,Se(Rr,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Fo{constructor(e){M(this,Jr,void 0);$(this,Jr,e)}get numDeletedRows(){return s(this,Jr)}}Jr=new WeakMap,Object.defineProperty(Fo.prototype,"numDeletedRows",{enumerable:!0});const Po=h({is(t){return t.kind==="LimitNode"},create(t){return h({kind:"LimitNode",limit:nn.create(t)})}}),We=class{constructor(e){M(this,Z,void 0);$(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,ht(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,ht(e,r,n))})}whereExists(e){return new We({...s(this,Z),queryNode:re.cloneWithWhere(s(this,Z).queryNode,wt(e))})}whereNotExists(e){return new We({...s(this,Z),queryNode:re.cloneWithWhere(s(this,Z).queryNode,ft(e))})}orWhereExists(e){return new We({...s(this,Z),queryNode:re.cloneWithOrWhere(s(this,Z).queryNode,wt(e))})}orWhereNotExists(e){return new We({...s(this,Z),queryNode:re.cloneWithOrWhere(s(this,Z).queryNode,ft(e))})}clearWhere(){return new We({...s(this,Z),queryNode:re.cloneWithoutWhere(s(this,Z).queryNode)})}using(e){return new We({...s(this,Z),queryNode:Dr.cloneWithUsing(s(this,Z).queryNode,rr(e))})}innerJoin(...e){return new We({...s(this,Z),queryNode:re.cloneWithJoin(s(this,Z).queryNode,It("InnerJoin",e))})}leftJoin(...e){return new We({...s(this,Z),queryNode:re.cloneWithJoin(s(this,Z).queryNode,It("LeftJoin",e))})}rightJoin(...e){return new We({...s(this,Z),queryNode:re.cloneWithJoin(s(this,Z).queryNode,It("RightJoin",e))})}fullJoin(...e){return new We({...s(this,Z),queryNode:re.cloneWithJoin(s(this,Z).queryNode,It("FullJoin",e))})}returning(e){return new We({...s(this,Z),queryNode:re.cloneWithReturning(s(this,Z).queryNode,Pr(e))})}returningAll(e){return new We({...s(this,Z),queryNode:re.cloneWithReturning(s(this,Z).queryNode,Lr(e))})}orderBy(e,r){return new We({...s(this,Z),queryNode:Dr.cloneWithOrderByItem(s(this,Z).queryNode,Ni(e,r))})}limit(e){return new We({...s(this,Z),queryNode:Dr.cloneWithLimit(s(this,Z).queryNode,Po.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 Fo(n.numAffectedRows??n.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Ii){const r=await this.executeTakeFirst();if(r===void 0)throw Oi(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 Ci=We;Z=new WeakMap,Se(Ci,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Lo{constructor(e){M(this,Kr,void 0);$(this,Kr,e)}get numUpdatedRows(){return s(this,Kr)}}Kr=new WeakMap,Object.defineProperty(Lo.prototype,"numUpdatedRows",{enumerable:!0});const De=class{constructor(e){M(this,te,void 0);$(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,ht(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,ht(e,r,n))})}whereExists(e){return new De({...s(this,te),queryNode:re.cloneWithWhere(s(this,te).queryNode,wt(e))})}whereNotExists(e){return new De({...s(this,te),queryNode:re.cloneWithWhere(s(this,te).queryNode,ft(e))})}orWhereExists(e){return new De({...s(this,te),queryNode:re.cloneWithOrWhere(s(this,te).queryNode,wt(e))})}orWhereNotExists(e){return new De({...s(this,te),queryNode:re.cloneWithOrWhere(s(this,te).queryNode,ft(e))})}clearWhere(){return new De({...s(this,te),queryNode:re.cloneWithoutWhere(s(this,te).queryNode)})}from(e){return new De({...s(this,te),queryNode:ki.cloneWithFromItems(s(this,te).queryNode,rr(e))})}innerJoin(...e){return new De({...s(this,te),queryNode:re.cloneWithJoin(s(this,te).queryNode,It("InnerJoin",e))})}leftJoin(...e){return new De({...s(this,te),queryNode:re.cloneWithJoin(s(this,te).queryNode,It("LeftJoin",e))})}rightJoin(...e){return new De({...s(this,te),queryNode:re.cloneWithJoin(s(this,te).queryNode,It("RightJoin",e))})}fullJoin(...e){return new De({...s(this,te),queryNode:re.cloneWithJoin(s(this,te).queryNode,It("FullJoin",e))})}set(e){return new De({...s(this,te),queryNode:ki.cloneWithUpdates(s(this,te).queryNode,Rs(e))})}returning(e){return new De({...s(this,te),queryNode:re.cloneWithReturning(s(this,te).queryNode,Pr(e))})}returningAll(){return new De({...s(this,te),queryNode:re.cloneWithReturning(s(this,te).queryNode,Lr())})}$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 Lo(n.numAffectedRows??n.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=Ii){const r=await this.executeTakeFirst();if(r===void 0)throw Oi(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 Wi=De;te=new WeakMap,Se(Wi,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");const xl=h({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return h({kind:"CommonTableExpressionNode",name:t,expression:e})}}),Do=h({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return h({kind:"CommonTableExpressionNameNode",table:Nn.create(t),columns:e?h(e.map(Xe.create)):void 0})}});function Ro(t,e){const r=e(Fl());return xl.create(El(t),r.toOperationNode())}function El(t){if(t.includes("(")){const e=t.split(/[\(\)]/),r=e[0],n=e[1].split(",").map(A=>A.trim());return Do.create(r,n)}else return Do.create(t)}const Fi=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])})}}),Bo=["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 Sl(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}}as=new WeakMap;const Ol=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 Al extends Bs{constructor(r){super();M(this,ls);M(this,us);M(this,Dn);M(this,Xr);M(this,cs);M(this,ar,void 0);M(this,Ln,new Set);$(this,ar,r)}transformNodeImpl(r){if(!Le(this,ls,Ma).call(this,r))return super.transformNodeImpl(r);const n=Le(this,us,Ua).call(this,r);for(const X of n)s(this,Ln).add(X);const A=super.transformNodeImpl(r);for(const X of n)s(this,Ln).delete(X);return A}transformSchemableIdentifier(r){const n=super.transformSchemableIdentifier(r);return n.schema||!s(this,Ln).has(r.identifier.name)?n:{...n,schema:Je.create(s(this,ar))}}transformReferences(r){const n=super.transformReferences(r);return n.table.table.schema?n:{...n,table:Nn.createWithSchema(s(this,ar),n.table.table.identifier.name)}}}ar=new WeakMap,Ln=new WeakMap,ls=new WeakSet,Ma=function(r){return r.kind in Ol},us=new WeakSet,Ua=function(r){const n=new Set;if("name"in r&&r.name&&bn.is(r.name)&&Le(this,Xr,lo).call(this,r.name,n),"from"in r&&r.from)for(const A of r.from.froms)Le(this,Dn,gi).call(this,A,n);if("into"in r&&r.into&&Le(this,Dn,gi).call(this,r.into,n),"table"in r&&r.table&&Le(this,Dn,gi).call(this,r.table,n),"joins"in r&&r.joins)for(const A of r.joins)Le(this,Dn,gi).call(this,A.table,n);return"with"in r&&r.with&&Le(this,cs,ja).call(this,r.with,n),n},Dn=new WeakSet,gi=function(r,n){const A=Nn.is(r)?r:Wn.is(r)&&Nn.is(r.node)?r.node:null;A&&Le(this,Xr,lo).call(this,A.table,n)},Xr=new WeakSet,lo=function(r,n){s(this,Ln).has(r.identifier.name)||n.add(r.identifier.name)},cs=new WeakSet,ja=function(r,n){for(const A of r.expressions)n.delete(A.name.table.table.identifier.name)};class Br{constructor(e){M(this,Yr,void 0);$(this,Yr,new Al(e))}transformQuery(e){return s(this,Yr).transformNode(e.node)}async transformResult(e){return e.result}}Yr=new WeakMap;const Rn=class{constructor(e){M(this,Re,void 0);$(this,Re,h(e))}selectFrom(e){return new nr({queryId:Ce(),executor:s(this,Re).executor,queryNode:_e.create(rr(e),s(this,Re).withNode)})}insertInto(e){return new Rr({queryId:Ce(),executor:s(this,Re).executor,queryNode:rn.create(Ot(e),s(this,Re).withNode)})}replaceInto(e){return new Rr({queryId:Ce(),executor:s(this,Re).executor,queryNode:rn.create(Ot(e),s(this,Re).withNode,!0)})}deleteFrom(e){return new Ci({queryId:Ce(),executor:s(this,Re).executor,queryNode:Dr.create(rr(e),s(this,Re).withNode)})}updateTable(e){return new Wi({queryId:Ce(),executor:s(this,Re).executor,queryNode:ki.create(Ur(e),s(this,Re).withNode)})}with(e,r){const n=Ro(e,r);return new Rn({...s(this,Re),withNode:s(this,Re).withNode?Fi.cloneWithExpression(s(this,Re).withNode,n):Fi.create(n)})}withRecursive(e,r){const n=Ro(e,r);return new Rn({...s(this,Re),withNode:s(this,Re).withNode?Fi.cloneWithExpression(s(this,Re).withNode,n):Fi.create(n,{recursive:!0})})}withPlugin(e){return new Rn({...s(this,Re),executor:s(this,Re).executor.withPlugin(e)})}withoutPlugins(){return new Rn({...s(this,Re),executor:s(this,Re).executor.withoutPlugins()})}withSchema(e){return new Rn({...s(this,Re),executor:s(this,Re).executor.withPluginAtFront(new Br(e))})}};let Pi=Rn;Re=new WeakMap;class Mo{constructor(){M(this,Zr,void 0);M(this,lr,void 0);M(this,ur,void 0);ze(this,"resolve",e=>{s(this,lr)&&s(this,lr).call(this,e)});ze(this,"reject",e=>{s(this,ur)&&s(this,ur).call(this,e)});$(this,Zr,new Promise((e,r)=>{$(this,ur,r),$(this,lr,e)}))}get promise(){return s(this,Zr)}}Zr=new WeakMap,lr=new WeakMap,ur=new WeakMap;const Uo=new Set;function Tl(t){Uo.has(t)||(Uo.add(t),console.log(t))}const Cl=h([]);class jo{constructor(e=Cl){M(this,ei);M(this,Bn,void 0);$(this,Bn,e)}get plugins(){return s(this,Bn)}transformQuery(e,r){for(const n of s(this,Bn)){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,ei,uo).call(this,A,r);return Wl(A,X),X})}async*stream(e,r,n){const A=new Mo,X=new Mo;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,ei,uo).call(this,me,n)}finally{X.resolve()}}}Bn=new WeakMap,ei=new WeakSet,uo=async function(e,r){for(const n of s(this,Bn))e=await n.transformResult({result:e,queryId:r});return e};function Wl(t,e){const{numAffectedRows:r}=t;r===void 0&&t.numUpdatedOrDeletedRows===void 0||r!==void 0&&e.numAffectedRows!==void 0||Tl("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class er extends jo{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 er([...this.plugins,e])}withPlugins(e){return new er([...this.plugins,...e])}withPluginAtFront(e){return new er([e,...this.plugins])}withoutPlugins(){return new er([])}}const Li=new er;function Qo(){return new nr({queryId:Ce(),executor:Li,queryNode:_e.create(rr([]))})}function Fl(){return new Pi({executor:Li})}function zo(t,e){return new Ei({joinNode:Bt.create(t,Ur(e))})}function Pl(){return new Si({overNode:Ls.create()})}const Ms=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),Ms.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return h({...t,...e})}});function Us(t,e,r){if(!go(e)&&!Nt(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return Rl(e,r)?Bl(t,e,r):qi.create(fn(t),js(e),xo(r))}function Ll(t,e,r){if(!go(e)&&!Nt(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return qi.create(fn(t),js(e),fn(r))}function Dl(t,e,r){if(!wo(e)&&!Nt(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return Us(t,e,r)}function ht(t,e,r){if(!wo(e)&&!Nt(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return Ll(t,e,r)}function Ct(t){return Di("where",t)}function Vo(t){return Di("having",t)}function Ho(t){return Di("on",t)}function $o(t){return Di("when",t)}function Di(t,e){if(e.length===3)return Dl(e[0],e[1],e[2]);if(e.length===1)return Ml(t,e[0]);throw Go(t,e)}function Rl(t,e){return(t==="is"||t==="is not")&&(po(e)||Ir(e))}function Bl(t,e,r){return qi.create(fn(t),js(e),nn.createImmediate(r))}function js(t){if(Ne(t)&&nl.includes(t))return Cs.create(t);if(Nt(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function Ml(t,e){if(Rt(e)){if(t==="when")throw new Error("when method doesn't accept a callback as an argument");return Ul[t](e)}else if(Nt(e)){const r=e.toOperationNode();if(gt.is(r)||qi.is(r)||ko.is(r)||Xn.is(r)||$t.is(r))return r}else if(t==="when")return nn.create(e);throw Go(t,e)}function Go(t,e){return new Error(`invalid arguments passed to a '${t}' method: ${JSON.stringify(e)}`)}const Ul=h({where(t){const e=Qo(),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 Xn.create(A.where.where)}else return A},having(t){const e=Qo(),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 Xn.create(A.having.having)}else return A},on(t){const e=zo("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 Xn.create(A.on.on)}else return A}});function It(t,e){if(e.length===3)return Ql(t,e[0],e[1],e[2]);if(e.length===2)return jl(t,e[0],e[1]);throw new Error("not implemented")}function jl(t,e,r){return r(zo(t,e)).toOperationNode()}function Ql(t,e,r,n){return Bt.createWithOn(t,Ur(e),ht(r,"=",n))}const zl=h({is(t){return t.kind==="OffsetNode"},create(t){return h({kind:"OffsetNode",offset:nn.create(t)})}}),Vl=h({is(t){return t.kind==="GroupByItemNode"},create(t){return h({kind:"GroupByItemNode",groupBy:t})}});function Hl(t){return t=Rt(t)?t(pn()):t,Wr(t).map(Vl.create)}const Jo=h({is(t){return t.kind==="SetOperationNode"},create(t,e,r){return h({kind:"SetOperationNode",operator:t,expression:e,all:r})}});function tr(t,e,r){return Jo.create(t,e.toOperationNode(),r)}const ee=class{constructor(e){M(this,F,void 0);$(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,ht(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,ht(e,r,n))})}whereExists(e){return new ee({...s(this,F),queryNode:re.cloneWithWhere(s(this,F).queryNode,wt(e))})}whereNotExists(e){return new ee({...s(this,F),queryNode:re.cloneWithWhere(s(this,F).queryNode,ft(e))})}orWhereExists(e){return new ee({...s(this,F),queryNode:re.cloneWithOrWhere(s(this,F).queryNode,wt(e))})}orWhereNotExists(e){return new ee({...s(this,F),queryNode:re.cloneWithOrWhere(s(this,F).queryNode,ft(e))})}having(...e){return new ee({...s(this,F),queryNode:_e.cloneWithHaving(s(this,F).queryNode,Vo(e))})}havingRef(e,r,n){return new ee({...s(this,F),queryNode:_e.cloneWithHaving(s(this,F).queryNode,ht(e,r,n))})}orHaving(...e){return new ee({...s(this,F),queryNode:_e.cloneWithOrHaving(s(this,F).queryNode,Vo(e))})}orHavingRef(e,r,n){return new ee({...s(this,F),queryNode:_e.cloneWithOrHaving(s(this,F).queryNode,ht(e,r,n))})}havingExists(e){return new ee({...s(this,F),queryNode:_e.cloneWithHaving(s(this,F).queryNode,wt(e))})}havingNotExist(e){return new ee({...s(this,F),queryNode:_e.cloneWithHaving(s(this,F).queryNode,ft(e))})}havingNotExists(e){return new ee({...s(this,F),queryNode:_e.cloneWithHaving(s(this,F).queryNode,ft(e))})}orHavingExists(e){return new ee({...s(this,F),queryNode:_e.cloneWithOrHaving(s(this,F).queryNode,wt(e))})}orHavingNotExists(e){return new ee({...s(this,F),queryNode:_e.cloneWithOrHaving(s(this,F).queryNode,ft(e))})}select(e){return new ee({...s(this,F),queryNode:_e.cloneWithSelections(s(this,F).queryNode,Pr(e))})}distinctOn(e){return new ee({...s(this,F),queryNode:_e.cloneWithDistinctOn(s(this,F).queryNode,Wr(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,Lr(e))})}innerJoin(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,It("InnerJoin",e))})}leftJoin(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,It("LeftJoin",e))})}rightJoin(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,It("RightJoin",e))})}fullJoin(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,It("FullJoin",e))})}innerJoinLateral(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,It("LateralInnerJoin",e))})}leftJoinLateral(...e){return new ee({...s(this,F),queryNode:re.cloneWithJoin(s(this,F).queryNode,It("LateralLeftJoin",e))})}orderBy(e,r){return new ee({...s(this,F),queryNode:_e.cloneWithOrderByItem(s(this,F).queryNode,Ni(e,r))})}groupBy(e){return new ee({...s(this,F),queryNode:_e.cloneWithGroupByItems(s(this,F).queryNode,Hl(e))})}limit(e){return new ee({...s(this,F),queryNode:_e.cloneWithLimit(s(this,F).queryNode,Po.create(e))})}offset(e){return new ee({...s(this,F),queryNode:_e.cloneWithOffset(s(this,F).queryNode,zl.create(e))})}union(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,tr("union",e,!1))})}unionAll(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,tr("union",e,!0))})}intersect(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,tr("intersect",e,!1))})}intersectAll(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,tr("intersect",e,!0))})}except(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,tr("except",e,!1))})}exceptAll(e){return new ee({...s(this,F),queryNode:_e.cloneWithSetOperation(s(this,F).queryNode,tr("except",e,!0))})}as(e){return new $l(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=Ii){const r=await this.executeTakeFirst();if(r===void 0)throw Oi(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 nr=ee;F=new WeakMap,Se(nr,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class $l{constructor(e,r){M(this,cr,void 0);M(this,dr,void 0);$(this,cr,e),$(this,dr,r)}get expression(){return s(this,cr)}get alias(){return s(this,dr)}toOperationNode(){return Wn.create(s(this,cr).toOperationNode(),Je.create(s(this,dr)))}}cr=new WeakMap,dr=new WeakMap;const Ks=class{constructor(e){M(this,fr,void 0);$(this,fr,e)}get expressionType(){}as(e){return new Gl(this,e)}$castTo(){return new Ks(s(this,fr))}toOperationNode(){return s(this,fr)}};let ot=Ks;fr=new WeakMap;class Gl{constructor(e,r){M(this,hr,void 0);M(this,Sn,void 0);$(this,hr,e),$(this,Sn,r)}get expression(){return s(this,hr)}get alias(){return s(this,Sn)}toOperationNode(){return Wn.create(s(this,hr).toOperationNode(),Nt(s(this,Sn))?s(this,Sn).toOperationNode():Je.create(s(this,Sn)))}}hr=new WeakMap,Sn=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?qt.cloneWithOperation(t.filter,"And",e):qt.create(e)})},cloneWithOrFilter(t,e){return h({...t,filter:t.filter?qt.cloneWithOperation(t.filter,"Or",e):qt.create(e)})},cloneWithOver(t,e){return h({...t,over:e})}}),Jl=h({is(t){return t.kind==="FunctionNode"},create(t,e){return h({kind:"FunctionNode",func:t,arguments:e})}}),Ut=class{constructor(e){M(this,Ue,void 0);$(this,Ue,h(e))}get expressionType(){}as(e){return new Kl(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,wt(e))})}filterWhereNotExists(e){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithFilter(s(this,Ue).aggregateFunctionNode,ft(e))})}filterWhereRef(e,r,n){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithFilter(s(this,Ue).aggregateFunctionNode,ht(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,wt(e))})}orFilterWhereNotExists(e){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithOrFilter(s(this,Ue).aggregateFunctionNode,ft(e))})}orFilterWhereRef(e,r,n){return new Ut({...s(this,Ue),aggregateFunctionNode:Mt.cloneWithOrFilter(s(this,Ue).aggregateFunctionNode,ht(e,r,n))})}over(e){const r=Pl();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 Mr=Ut;Ue=new WeakMap,Se(Mr,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");class Kl{constructor(e,r){M(this,pr,void 0);M(this,_r,void 0);$(this,pr,e),$(this,_r,r)}get expression(){return s(this,pr)}get alias(){return s(this,_r)}toOperationNode(){return Wn.create(s(this,pr).toOperationNode(),Je.create(s(this,_r)))}}pr=new WeakMap,_r=new WeakMap;function Ko(){const t=(r,n)=>new ot(Jl.create(r,Wr(n))),e=(r,n)=>new Mr({aggregateFunctionNode:Mt.create(r,n?Wr(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 Mr({aggregateFunctionNode:Mt.create("count",Lr(r))})},max(r){return e("max",[r])},min(r){return e("min",[r])},sum(r){return e("sum",[r])}})}class Xo{constructor(e){M(this,mr,void 0);$(this,mr,h(e))}when(...e){return new Yo({...s(this,mr),node:$t.cloneWithWhen(s(this,mr).node,Ms.create($o(e)))})}}mr=new WeakMap;class Yo{constructor(e){M(this,yr,void 0);$(this,yr,h(e))}then(e){return new Xl({...s(this,yr),node:$t.cloneWithThen(s(this,yr).node,hn(e))})}}yr=new WeakMap;class Xl{constructor(e){M(this,sn,void 0);$(this,sn,h(e))}when(...e){return new Yo({...s(this,sn),node:$t.cloneWithWhen(s(this,sn).node,Ms.create($o(e)))})}else(e){return new Yl({...s(this,sn),node:$t.cloneWith(s(this,sn).node,{else:hn(e)})})}end(){return new ot($t.cloneWith(s(this,sn).node,{isStatement:!1}))}endCase(){return new ot($t.cloneWith(s(this,sn).node,{isStatement:!0}))}}sn=new WeakMap;class Yl{constructor(e){M(this,gr,void 0);$(this,gr,h(e))}end(){return new ot($t.cloneWith(s(this,gr).node,{isStatement:!1}))}endCase(){return new ot($t.cloneWith(s(this,gr).node,{isStatement:!0}))}}gr=new WeakMap;function Zo(t=Li){function e(r,n){return new ot(Ds(r,n))}return{get fn(){return Ko()},selectFrom(r){return new nr({queryId:Ce(),executor:t,queryNode:_e.create(rr(r))})},case(r){return new Xo({node:$t.create(Te(r)?void 0:fn(r))})},ref(r){return new ot(Yn(r))},val(r){return new ot(xo(r))},cmpr(r,n,A){return new ot(Us(r,n,A))},bxp(r,n,A){return new ot(Us(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 ot(nn.createImmediate(!0));if(r.length===1)return new ot(r[0].toOperationNode());let n=Ar.create(r[0].toOperationNode(),r[1].toOperationNode());for(let A=2;AUr(e)):[Ur(t)]}function Ur(t){return Ne(t)?Zl(t):ea(t)}function Zl(t){const e=" as ";if(t.includes(e)){const[r,n]=t.split(e).map(ta);return Wn.create(Ot(r),Je.create(n))}else return Ot(t)}function Ot(t){const e=".";if(t.includes(e)){const[r,n]=t.split(e).map(ta);return Nn.createWithSchema(r,n)}else return Nn.create(t)}function ta(t){return t.trim()}const na=h({is(t){return t.kind==="AddColumnNode"},create(t){return h({kind:"AddColumnNode",column:t})}}),Fn=h({is(t){return t.kind==="AlterColumnNode"},create(t){return h({kind:"AlterColumnNode",column:Xe.create(t)})},cloneWith(t,e){return h({...t,...e})}}),Ye=h({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return h({kind:"ColumnDefinitionNode",column:Xe.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})}}),ra=h({is(t){return t.kind==="DropColumnNode"},create(t){return h({kind:"DropColumnNode",column:Xe.create(t)})}}),ia=h({is(t){return t.kind==="RenameColumnNode"},create(t,e){return h({kind:"RenameColumnNode",column:Xe.create(t),renameTo:Xe.create(e)})}}),Qs=h({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return h({kind:"CheckConstraintNode",expression:t,name:e?Je.create(e):void 0})}}),eu=["no action","restrict","cascade","set null","set default"],Mi=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 sa(t){return Nt(t)?t.toOperationNode():nn.createImmediate(t)}const Ui=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})}}),tu=h({is(t){return t.kind==="DefaultValueNode"},create(t){return h({kind:"DefaultValueNode",defaultValue:t})}});function ji(t){if(eu.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}const lt=class{constructor(e){M(this,Fe,void 0);$(this,Fe,e)}autoIncrement(){return new lt(Ye.cloneWith(s(this,Fe),{autoIncrement:!0}))}primaryKey(){return new lt(Ye.cloneWith(s(this,Fe),{primaryKey:!0}))}references(e){const r=Yn(e);if(!bi.is(r)||Ws.is(r.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new lt(Ye.cloneWith(s(this,Fe),{references:Mi.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 lt(Ye.cloneWith(s(this,Fe),{references:Mi.cloneWithOnDelete(s(this,Fe).references,ji(e))}))}onUpdate(e){if(!s(this,Fe).references)throw new Error("on update constraint can only be added for foreign keys");return new lt(Ye.cloneWith(s(this,Fe),{references:Mi.cloneWithOnUpdate(s(this,Fe).references,ji(e))}))}unique(){return new lt(Ye.cloneWith(s(this,Fe),{unique:!0}))}notNull(){return new lt(Ye.cloneWith(s(this,Fe),{notNull:!0}))}unsigned(){return new lt(Ye.cloneWith(s(this,Fe),{unsigned:!0}))}defaultTo(e){return new lt(Ye.cloneWith(s(this,Fe),{defaultTo:tu.create(sa(e))}))}check(e){return new lt(Ye.cloneWith(s(this,Fe),{check:Qs.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new lt(Ye.cloneWith(s(this,Fe),{generated:Ui.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new lt(Ye.cloneWith(s(this,Fe),{generated:Ui.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new lt(Ye.cloneWith(s(this,Fe),{generated:Ui.create({identity:!0,byDefault:!0})}))}stored(){if(!s(this,Fe).generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new lt(Ye.cloneWith(s(this,Fe),{generated:Ui.cloneWith(s(this,Fe).generated,{stored:!0})}))}modifyFront(e){return new lt(Ye.cloneWithFrontModifier(s(this,Fe),e.toOperationNode()))}modifyEnd(e){return new lt(Ye.cloneWithEndModifier(s(this,Fe),e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return s(this,Fe)}};let vn=lt;Fe=new WeakMap,Se(vn,"don't await ColumnDefinitionBuilder instances directly.");const oa=h({is(t){return t.kind==="ModifyColumnNode"},create(t){return h({kind:"ModifyColumnNode",column:t})}}),nu=h({is(t){return t.kind==="DataTypeNode"},create(t){return h({kind:"DataTypeNode",dataType:t})}});function ir(t){return Nt(t)?t.toOperationNode():nu.create(t)}const Qi=h({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,r,n){return h({kind:"ForeignKeyConstraintNode",columns:t,references:Mi.create(e,r),name:n?Je.create(n):void 0})},cloneWith(t,e){return h({...t,...e})}}),ds=class{constructor(e){M(this,Mn,void 0);$(this,Mn,e)}onDelete(e){return new ds(Qi.cloneWith(s(this,Mn),{onDelete:ji(e)}))}onUpdate(e){return new ds(Qi.cloneWith(s(this,Mn),{onUpdate:ji(e)}))}$call(e){return e(this)}toOperationNode(){return s(this,Mn)}};let jr=ds;Mn=new WeakMap,Se(jr,"don't await ForeignKeyConstraintBuilder instances directly.");const zs=h({is(t){return t.kind==="AddConstraintNode"},create(t){return h({kind:"AddConstraintNode",constraint:t})}}),aa=h({is(t){return t.kind==="UniqueConstraintNode"},create(t,e){return h({kind:"UniqueConstraintNode",columns:h(t.map(Xe.create)),name:e?Je.create(e):void 0})}}),zi=h({is(t){return t.kind==="DropConstraintNode"},create(t){return h({kind:"DropConstraintNode",constraintName:Je.create(t)})},cloneWith(t,e){return h({...t,...e})}});class Vi{constructor(e){ze(this,"alterColumnNode");this.alterColumnNode=e}setDataType(e){return new Qr(Fn.cloneWith(this.alterColumnNode,{dataType:ir(e)}))}setDefault(e){return new Qr(Fn.cloneWith(this.alterColumnNode,{setDefault:sa(e)}))}dropDefault(){return new Qr(Fn.cloneWith(this.alterColumnNode,{dropDefault:!0}))}setNotNull(){return new Qr(Fn.cloneWith(this.alterColumnNode,{setNotNull:!0}))}dropNotNull(){return new Qr(Fn.cloneWith(this.alterColumnNode,{dropNotNull:!0}))}$call(e){return e(this)}}class Qr extends Vi{toOperationNode(){return this.alterColumnNode}}class zr{constructor(e){M(this,Xt,void 0);$(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(zr,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");const fs=class{constructor(e){M(this,bt,void 0);$(this,bt,h(e))}onDelete(e){return new fs({...s(this,bt),constraintBuilder:s(this,bt).constraintBuilder.onDelete(e)})}onUpdate(e){return new fs({...s(this,bt),constraintBuilder:s(this,bt).constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return s(this,bt).executor.transformQuery(tt.cloneWithTableProps(s(this,bt).node,{addConstraint:zs.create(s(this,bt).constraintBuilder.toOperationNode())}),s(this,bt).queryId)}compile(){return s(this,bt).executor.compileQuery(this.toOperationNode(),s(this,bt).queryId)}async execute(){await s(this,bt).executor.executeQuery(this.compile(),s(this,bt).queryId)}};let Hi=fs;bt=new WeakMap,Se(Hi,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");const ti=class{constructor(e){M(this,nt,void 0);$(this,nt,h(e))}ifExists(){return new ti({...s(this,nt),node:tt.cloneWithTableProps(s(this,nt).node,{dropConstraint:zi.cloneWith(s(this,nt).node.dropConstraint,{ifExists:!0})})})}cascade(){return new ti({...s(this,nt),node:tt.cloneWithTableProps(s(this,nt).node,{dropConstraint:zi.cloneWith(s(this,nt).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new ti({...s(this,nt),node:tt.cloneWithTableProps(s(this,nt).node,{dropConstraint:zi.cloneWith(s(this,nt).node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return s(this,nt).executor.transformQuery(s(this,nt).node,s(this,nt).queryId)}compile(){return s(this,nt).executor.compileQuery(this.toOperationNode(),s(this,nt).queryId)}async execute(){await s(this,nt).executor.executeQuery(this.compile(),s(this,nt).queryId)}};let $i=ti;nt=new WeakMap,Se($i,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");class la{constructor(e){M(this,je,void 0);$(this,je,h(e))}renameTo(e){return new zr({...s(this,je),node:tt.cloneWithTableProps(s(this,je).node,{renameTo:Ot(e)})})}setSchema(e){return new zr({...s(this,je),node:tt.cloneWithTableProps(s(this,je).node,{setSchema:Je.create(e)})})}alterColumn(e,r){const n=r(new Vi(Fn.create(e)));return new xn({...s(this,je),node:tt.cloneWithColumnAlteration(s(this,je).node,n.toOperationNode())})}dropColumn(e){return new xn({...s(this,je),node:tt.cloneWithColumnAlteration(s(this,je).node,ra.create(e))})}renameColumn(e,r){return new xn({...s(this,je),node:tt.cloneWithColumnAlteration(s(this,je).node,ia.create(e,r))})}addColumn(e,r,n=Kn){const A=n(new vn(Ye.create(e,ir(r))));return new xn({...s(this,je),node:tt.cloneWithColumnAlteration(s(this,je).node,na.create(A.toOperationNode()))})}modifyColumn(e,r,n=Kn){const A=n(new vn(Ye.create(e,ir(r))));return new xn({...s(this,je),node:tt.cloneWithColumnAlteration(s(this,je).node,oa.create(A.toOperationNode()))})}addUniqueConstraint(e,r){return new zr({...s(this,je),node:tt.cloneWithTableProps(s(this,je).node,{addConstraint:zs.create(aa.create(r,e))})})}addCheckConstraint(e,r){return new zr({...s(this,je),node:tt.cloneWithTableProps(s(this,je).node,{addConstraint:zs.create(Qs.create(r.toOperationNode(),e))})})}addForeignKeyConstraint(e,r,n,A){return new Hi({...s(this,je),constraintBuilder:new jr(Qi.create(r.map(Xe.create),Ot(n),A.map(Xe.create),e))})}dropConstraint(e){return new $i({...s(this,je),node:tt.cloneWithTableProps(s(this,je).node,{dropConstraint:zi.create(e)})})}$call(e){return e(this)}call(e){return this.$call(e)}}je=new WeakMap;const Un=class{constructor(e){M(this,Ze,void 0);$(this,Ze,h(e))}alterColumn(e,r){const n=r(new Vi(Fn.create(e)));return new Un({...s(this,Ze),node:tt.cloneWithColumnAlteration(s(this,Ze).node,n.toOperationNode())})}dropColumn(e){return new Un({...s(this,Ze),node:tt.cloneWithColumnAlteration(s(this,Ze).node,ra.create(e))})}renameColumn(e,r){return new Un({...s(this,Ze),node:tt.cloneWithColumnAlteration(s(this,Ze).node,ia.create(e,r))})}addColumn(e,r,n=Kn){const A=n(new vn(Ye.create(e,ir(r))));return new Un({...s(this,Ze),node:tt.cloneWithColumnAlteration(s(this,Ze).node,na.create(A.toOperationNode()))})}modifyColumn(e,r,n=Kn){const A=n(new vn(Ye.create(e,ir(r))));return new Un({...s(this,Ze),node:tt.cloneWithColumnAlteration(s(this,Ze).node,oa.create(A.toOperationNode()))})}toOperationNode(){return s(this,Ze).executor.transformQuery(s(this,Ze).node,s(this,Ze).queryId)}compile(){return s(this,Ze).executor.compileQuery(this.toOperationNode(),s(this,Ze).queryId)}async execute(){await s(this,Ze).executor.executeQuery(this.compile(),s(this,Ze).queryId)}};let xn=Un;Ze=new WeakMap,Se(la,"don't await AlterTableBuilder instances"),Se(Vi,"don't await AlterColumnBuilder instances"),Se(xn,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class ua extends Bs{transformValue(e){return{...super.transformValue(e),immediate:!0}}}const on=class{constructor(e){M(this,Pe,void 0);$(this,Pe,h(e))}ifNotExists(){return new on({...s(this,Pe),node:qn.cloneWith(s(this,Pe).node,{ifNotExists:!0})})}unique(){return new on({...s(this,Pe),node:qn.cloneWith(s(this,Pe).node,{unique:!0})})}on(e){return new on({...s(this,Pe),node:qn.cloneWith(s(this,Pe).node,{table:Ot(e)})})}column(e){return new on({...s(this,Pe),node:qn.cloneWithColumns(s(this,Pe).node,[No(e)])})}columns(e){return new on({...s(this,Pe),node:qn.cloneWithColumns(s(this,Pe).node,e.map(No))})}expression(e){return new on({...s(this,Pe),node:qn.cloneWithColumns(s(this,Pe).node,[e.toOperationNode()])})}using(e){return new on({...s(this,Pe),node:qn.cloneWith(s(this,Pe).node,{using:gt.createWithSql(e)})})}where(...e){const r=new ua;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 Gi=on;Pe=new WeakMap,Se(Gi,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");const Xs=class{constructor(e){M(this,Ft,void 0);$(this,Ft,h(e))}ifNotExists(){return new Xs({...s(this,Ft),node:_o.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 Ji=Xs;Ft=new WeakMap,Se(Ji,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");const ru=h({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return h({kind:"PrimaryKeyConstraintNode",columns:h(t.map(Xe.create)),name:e?Je.create(e):void 0})}});function iu(t){if(Xa.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}const jt=class{constructor(e){M(this,ke,void 0);$(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:iu(e)})})}ifNotExists(){return new jt({...s(this,ke),node:Ht.cloneWith(s(this,ke).node,{ifNotExists:!0})})}addColumn(e,r,n=Kn){const A=n(new vn(Ye.create(e,ir(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,ru.create(r,e))})}addUniqueConstraint(e,r){return new jt({...s(this,ke),node:Ht.cloneWithConstraint(s(this,ke).node,aa.create(r,e))})}addCheckConstraint(e,r){return new jt({...s(this,ke),node:Ht.cloneWithConstraint(s(this,ke).node,Qs.create(r.toOperationNode(),e))})}addForeignKeyConstraint(e,r,n,A,X=Kn){const ae=X(new jr(Qi.create(r.map(Xe.create),Ot(n),A.map(Xe.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 Ki=jt;ke=new WeakMap,Se(Ki,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");const ni=class{constructor(e){M(this,pt,void 0);$(this,pt,h(e))}on(e){return new ni({...s(this,pt),node:wi.cloneWith(s(this,pt).node,{table:Ot(e)})})}ifExists(){return new ni({...s(this,pt),node:wi.cloneWith(s(this,pt).node,{ifExists:!0})})}cascade(){return new ni({...s(this,pt),node:wi.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 Xi=ni;pt=new WeakMap,Se(Xi,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");const hs=class{constructor(e){M(this,xt,void 0);$(this,xt,h(e))}ifExists(){return new hs({...s(this,xt),node:As.cloneWith(s(this,xt).node,{ifExists:!0})})}cascade(){return new hs({...s(this,xt),node:As.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 Yi=hs;xt=new WeakMap,Se(Yi,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");const ps=class{constructor(e){M(this,Et,void 0);$(this,Et,h(e))}ifExists(){return new ps({...s(this,Et),node:Ts.cloneWith(s(this,Et).node,{ifExists:!0})})}cascade(){return new ps({...s(this,Et),node:Ts.cloneWith(s(this,Et).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return s(this,Et).executor.transformQuery(s(this,Et).node,s(this,Et).queryId)}compile(){return s(this,Et).executor.compileQuery(this.toOperationNode(),s(this,Et).queryId)}async execute(){await s(this,Et).executor.executeQuery(this.compile(),s(this,Et).queryId)}};let Zi=ps;Et=new WeakMap,Se(Zi,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");const En=h({is(t){return t.kind==="CreateViewNode"},create(t){return h({kind:"CreateViewNode",name:bn.create(t)})},cloneWith(t,e){return h({...t,...e})}});class su{constructor(){M(this,_s,new ua)}transformQuery(e){return s(this,_s).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}_s=new WeakMap;const kn=class{constructor(e){M(this,$e,void 0);$(this,$e,h(e))}temporary(){return new kn({...s(this,$e),node:En.cloneWith(s(this,$e).node,{temporary:!0})})}materialized(){return new kn({...s(this,$e),node:En.cloneWith(s(this,$e).node,{materialized:!0})})}ifNotExists(){return new kn({...s(this,$e),node:En.cloneWith(s(this,$e).node,{ifNotExists:!0})})}orReplace(){return new kn({...s(this,$e),node:En.cloneWith(s(this,$e).node,{orReplace:!0})})}columns(e){return new kn({...s(this,$e),node:En.cloneWith(s(this,$e).node,{columns:e.map(bo)})})}as(e){const r=e.withPlugin(new su).toOperationNode();return new kn({...s(this,$e),node:En.cloneWith(s(this,$e).node,{as:r})})}$call(e){return e(this)}toOperationNode(){return s(this,$e).executor.transformQuery(s(this,$e).node,s(this,$e).queryId)}compile(){return s(this,$e).executor.compileQuery(this.toOperationNode(),s(this,$e).queryId)}async execute(){await s(this,$e).executor.executeQuery(this.compile(),s(this,$e).queryId)}};let es=kn;$e=new WeakMap,Se(es,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const ts=h({is(t){return t.kind==="DropViewNode"},create(t){return h({kind:"DropViewNode",name:bn.create(t)})},cloneWith(t,e){return h({...t,...e})}}),ri=class{constructor(e){M(this,_t,void 0);$(this,_t,h(e))}materialized(){return new ri({...s(this,_t),node:ts.cloneWith(s(this,_t).node,{materialized:!0})})}ifExists(){return new ri({...s(this,_t),node:ts.cloneWith(s(this,_t).node,{ifExists:!0})})}cascade(){return new ri({...s(this,_t),node:ts.cloneWith(s(this,_t).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return s(this,_t).executor.transformQuery(s(this,_t).node,s(this,_t).queryId)}compile(){return s(this,_t).executor.compileQuery(this.toOperationNode(),s(this,_t).queryId)}async execute(){await s(this,_t).executor.executeQuery(this.compile(),s(this,_t).queryId)}};let ns=ri;_t=new WeakMap,Se(ns,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const ca=h({is(t){return t.kind==="CreateTypeNode"},create(t){return h({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return h({...t,enum:Ps.create(e.map(r=>nn.createImmediate(r)))})}}),Ys=class{constructor(e){M(this,Pt,void 0);$(this,Pt,h(e))}toOperationNode(){return s(this,Pt).executor.transformQuery(s(this,Pt).node,s(this,Pt).queryId)}asEnum(e){return new Ys({...s(this,Pt),node:ca.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 rs=Ys;Pt=new WeakMap,Se(rs,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const da=h({is(t){return t.kind==="DropTypeNode"},create(t){return h({kind:"DropTypeNode",name:t})},cloneWith(t,e){return h({...t,...e})}}),Zs=class{constructor(e){M(this,Lt,void 0);$(this,Lt,h(e))}ifExists(){return new Zs({...s(this,Lt),node:da.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 is=Zs;Lt=new WeakMap,Se(is,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function fa(t){const e=".";if(t.includes(e)){const r=t.split(e).map(ou);if(r.length===2)return bn.createWithSchema(r[0],r[1]);throw new Error(`invalid schemable identifier ${t}`)}else return bn.create(t)}function ou(t){return t.trim()}const ii=class{constructor(e){M(this,ut,void 0);$(this,ut,e)}createTable(e){return new Ki({queryId:Ce(),executor:s(this,ut),node:Ht.create(Ot(e))})}dropTable(e){return new Zi({queryId:Ce(),executor:s(this,ut),node:Ts.create(Ot(e))})}createIndex(e){return new Gi({queryId:Ce(),executor:s(this,ut),node:qn.create(e)})}dropIndex(e){return new Xi({queryId:Ce(),executor:s(this,ut),node:wi.create(e)})}createSchema(e){return new Ji({queryId:Ce(),executor:s(this,ut),node:_o.create(e)})}dropSchema(e){return new Yi({queryId:Ce(),executor:s(this,ut),node:As.create(e)})}alterTable(e){return new la({queryId:Ce(),executor:s(this,ut),node:tt.create(Ot(e))})}createView(e){return new es({queryId:Ce(),executor:s(this,ut),node:En.create(e)})}dropView(e){return new ns({queryId:Ce(),executor:s(this,ut),node:ts.create(e)})}createType(e){return new rs({queryId:Ce(),executor:s(this,ut),node:ca.create(fa(e))})}dropType(e){return new is({queryId:Ce(),executor:s(this,ut),node:da.create(fa(e))})}withPlugin(e){return new ii(s(this,ut).withPlugin(e))}withoutPlugins(){return new ii(s(this,ut).withoutPlugins())}withSchema(e){return new ii(s(this,ut).withPluginAtFront(new Br(e)))}};let Vs=ii;ut=new WeakMap;class au{ref(e){return new hl(e)}}class lu{constructor(e){M(this,wr,void 0);$(this,wr,e)}async provideConnection(e){const r=await s(this,wr).acquireConnection();try{return await e(r)}finally{await s(this,wr).releaseConnection(r)}}}wr=new WeakMap;const jn=class extends jo{constructor(r,n,A,X=[]){super(X);M(this,an,void 0);M(this,ln,void 0);M(this,_n,void 0);$(this,an,r),$(this,ln,n),$(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 jn(s(this,an),s(this,ln),s(this,_n),[...this.plugins,...r])}withPlugin(r){return new jn(s(this,an),s(this,ln),s(this,_n),[...this.plugins,r])}withPluginAtFront(r){return new jn(s(this,an),s(this,ln),s(this,_n),[r,...this.plugins])}withConnectionProvider(r){return new jn(s(this,an),s(this,ln),r,[...this.plugins])}withoutPlugins(){return new jn(s(this,an),s(this,ln),s(this,_n),[])}};let Hs=jn;an=new WeakMap,ln=new WeakMap,_n=new WeakMap;function ha(){return typeof performance<"u"&&Rt(performance.now)?performance.now():Date.now()}class uu{constructor(e,r){M(this,ms);M(this,ys);M(this,gs);M(this,ws);M(this,oi);M(this,Yt,void 0);M(this,In,void 0);M(this,mn,void 0);M(this,Qn,void 0);M(this,si,new WeakSet);$(this,Yt,e),$(this,In,r)}async init(){s(this,mn)||$(this,mn,s(this,Yt).init().catch(e=>($(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,si).has(e)||(Le(this,ms,Qa).call(this)&&Le(this,ys,za).call(this,e),s(this,si).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,Qn)||$(this,Qn,s(this,Yt).destroy().catch(e=>($(this,Qn,void 0),Promise.reject(e)))),await s(this,Qn))}}Yt=new WeakMap,In=new WeakMap,mn=new WeakMap,Qn=new WeakMap,si=new WeakMap,ms=new WeakSet,Qa=function(){return s(this,In).isLevelEnabled("query")||s(this,In).isLevelEnabled("error")},ys=new WeakSet,za=function(e){const r=e.executeQuery;e.executeQuery=async n=>{const A=ha();try{return await r.call(e,n)}catch(X){throw await Le(this,gs,Va).call(this,X,n,A),X}finally{await Le(this,ws,Ha).call(this,n,A)}}},gs=new WeakSet,Va=async function(e,r,n){await s(this,In).error(()=>({level:"error",error:e,query:r,queryDurationMillis:Le(this,oi,co).call(this,n)}))},ws=new WeakSet,Ha=async function(e,r){await s(this,In).query(()=>({level:"query",query:e,queryDurationMillis:Le(this,oi,co).call(this,r)}))},oi=new WeakSet,co=function(e){return ha()-e};class pa{constructor(e){M(this,qs);M(this,ai,void 0);M(this,On,void 0);$(this,ai,e)}async provideConnection(e){for(;s(this,On);)await s(this,On);const r=Le(this,qs,$a).call(this,e);return $(this,On,r.then(()=>{$(this,On,void 0)}).catch(()=>{$(this,On,void 0)})),r}}ai=new WeakMap,On=new WeakMap,qs=new WeakSet,$a=async function(e){return await e(s(this,ai))};const cu=["read uncommitted","read committed","repeatable read","serializable"];h(["query","error"]);class du{constructor(e){M(this,An,void 0);M(this,zn,void 0);Rt(e)?($(this,zn,e),$(this,An,h({query:!0,error:!0}))):($(this,zn,fu),$(this,An,h({query:e.includes("query"),error:e.includes("error")})))}isLevelEnabled(e){return s(this,An)[e]}async query(e){s(this,An).query&&await s(this,zn).call(this,e())}async error(e){s(this,An).error&&await s(this,zn).call(this,e())}}An=new WeakMap,zn=new WeakMap;function fu(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 hu(t){return tn(t)&&Rt(t.compile)}const qr=class extends Pi{constructor(r){let n,A;if(pu(r))n={executor:r.executor},A={...r};else{const X=r.dialect,ae=X.createDriver(),me=X.createQueryCompiler(),Oe=X.createAdapter(),Tt=new du(r.log??[]),rt=new uu(ae,Tt),it=new lu(rt),ue=new Hs(me,Oe,it,r.plugins??[]);n={executor:ue},A={config:r,executor:ue,dialect:X,driver:rt}}super(n);M(this,mt,void 0);$(this,mt,h(A))}get schema(){return new Vs(s(this,mt).executor)}get dynamic(){return new au}get introspection(){return s(this,mt).dialect.createIntrospector(this.withoutPlugins())}case(r){return new Xo({node:$t.create(Te(r)?void 0:Ri(r))})}get fn(){return Ko()}transaction(){return new ss({...s(this,mt)})}connection(){return new _a({...s(this,mt)})}withPlugin(r){return new qr({...s(this,mt),executor:s(this,mt).executor.withPlugin(r)})}withoutPlugins(){return new qr({...s(this,mt),executor:s(this,mt).executor.withoutPlugins()})}withSchema(r){return new qr({...s(this,mt),executor:s(this,mt).executor.withPluginAtFront(new Br(r))})}withTables(){return new qr({...s(this,mt)})}async destroy(){await s(this,mt).driver.destroy()}get isTransaction(){return!1}getExecutor(){return s(this,mt).executor}executeQuery(r,n=Ce()){const A=hu(r)?r.compile():r;return this.getExecutor().executeQuery(A,n)}};let Vr=qr;mt=new WeakMap;const br=class extends Vr{constructor(r){super(r);M(this,Zt,void 0);$(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 br({...s(this,Zt),executor:s(this,Zt).executor.withPlugin(r)})}withoutPlugins(){return new br({...s(this,Zt),executor:s(this,Zt).executor.withoutPlugins()})}withSchema(r){return new br({...s(this,Zt),executor:s(this,Zt).executor.withPluginAtFront(new Br(r))})}withTables(){return new br({...s(this,Zt)})}};let $s=br;Zt=new WeakMap;function pu(t){return tn(t)&&tn(t.config)&&tn(t.driver)&&tn(t.executor)&&tn(t.dialect)}class _a{constructor(e){M(this,Vn,void 0);$(this,Vn,h(e))}async execute(e){return s(this,Vn).executor.provideConnection(async r=>{const n=s(this,Vn).executor.withConnectionProvider(new pa(r)),A=new Vr({...s(this,Vn),executor:n});return await e(A)})}}Vn=new WeakMap,Se(_a,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");const eo=class{constructor(e){M(this,en,void 0);$(this,en,h(e))}setIsolationLevel(e){return new eo({...s(this,en),isolationLevel:e})}async execute(e){const{isolationLevel:r,...n}=s(this,en),A={isolationLevel:r};return _u(A),s(this,en).executor.provideConnection(async X=>{const ae=s(this,en).executor.withConnectionProvider(new pa(X)),me=new $s({...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 ss=eo;en=new WeakMap,Se(ss,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function _u(t){if(t.isolationLevel&&!cu.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}const bs=class{constructor(e){M(this,Nr);M(this,li);M(this,ui);M(this,At,void 0);$(this,At,h(e))}get expressionType(){}as(e){return new mu(this,e)}$castTo(){return new bs({...s(this,At)})}castTo(){return this.$castTo()}withPlugin(e){return new bs({...s(this,At),plugins:s(this,At).plugins!==void 0?h([...s(this,At).plugins,e]):h([e])})}toOperationNode(){return Le(this,li,fo).call(this,Le(this,Nr,Os).call(this))}compile(e){return Le(this,ui,ho).call(this,Le(this,Nr,Os).call(this,e))}async execute(e){const r=Le(this,Nr,Os).call(this,e);return r.executeQuery(Le(this,ui,ho).call(this,r),s(this,At).queryId)}};let Gt=bs;At=new WeakMap,Nr=new WeakSet,Os=function(e){const r=e!==void 0?e.getExecutor():Li;return s(this,At).plugins!==void 0?r.withPlugins(s(this,At).plugins):r},li=new WeakSet,fo=function(e){return e.transformQuery(s(this,At).rawNode,s(this,At).queryId)},ui=new WeakSet,ho=function(e){return e.compileQuery(Le(this,li,fo).call(this,e),s(this,At).queryId)},Se(Gt,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");class mu{constructor(e,r){M(this,vr,void 0);M(this,Tn,void 0);$(this,vr,e),$(this,Tn,r)}get expression(){return s(this,vr)}get alias(){return s(this,Tn)}toOperationNode(){return Wn.create(s(this,vr).toOperationNode(),Nt(s(this,Tn))?s(this,Tn).toOperationNode():Je.create(s(this,Tn)))}}vr=new WeakMap,Tn=new WeakMap;const Wt=Object.assign((t,...e)=>new Gt({queryId:Ce(),rawNode:gt.create(t,(e==null?void 0:e.map(hn))??[])}),{ref(t){return new Gt({queryId:Ce(),rawNode:gt.createWithChild(Yn(t))})},val(t){return new Gt({queryId:Ce(),rawNode:gt.createWithChild(hn(t))})},value(t){return this.val(t)},table(t){return new Gt({queryId:Ce(),rawNode:gt.createWithChild(Ot(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",new Gt({queryId:Ce(),rawNode:gt.create(e,t.map(Je.create))})},lit(t){return new Gt({queryId:Ce(),rawNode:gt.createWithChild(nn.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return new Gt({queryId:Ce(),rawNode:gt.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,Ns)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}Ns=new WeakMap;class gu extends yu{constructor(){super(...arguments);M(this,xr,"");M(this,Hn,[])}get numParameters(){return s(this,Hn).length}compileQuery(r){return $(this,xr,""),$(this,Hn,[]),this.visitNode(r),h({query:r,sql:this.getSql(),parameters:[...s(this,Hn)]})}getSql(){return s(this,xr)}visitSelectQuery(r){const n=this.parentNode!==void 0&&!rn.is(this.parentNode)&&!En.is(this.parentNode)&&!Jo.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(wu[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 Cs.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){$(this,xr,s(this,xr)+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,Hn).push(r)}appendImmediateValue(r){if(Ne(r))this.append(`'${r}'`);else if(et(r)||Ir(r))this.append(r.toString());else if(po(r))this.append("null");else if(Ja(r))this.appendImmediateValue(r.toISOString());else if(Ka(r))this.appendImmediateValue(r.toString());else throw new Error(`invalid immediate value ${r}`)}}xr=new WeakMap,Hn=new WeakMap;const wu=h({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),qu=h({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral"}),Gs=h({raw(t){return h({sql:t,query:gt.createWithSql(t),parameters:h([])})}}),bu=/"/g;class Nu extends gu{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 vu="kysely_migration",xu="kysely_migration_lock";h({__noMigrations__:!0});class Eu{constructor(e){M(this,vs);M(this,Er,void 0);$(this,Er,e)}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let r=s(this,Er).selectFrom("sqlite_schema").where("type","in",["table","view"]).where("name","not like","sqlite_%").select("name").orderBy("name").$castTo();e.withInternalKyselyTables||(r=r.where("name","!=",vu).where("name","!=",xu));const n=await r.execute();return Promise.all(n.map(({name:A})=>Le(this,vs,Ga).call(this,A)))}async getMetadata(e){return{tables:await this.getTables(e)}}}Er=new WeakMap,vs=new WeakSet,Ga=async function(e){var ae,me,Oe,Tt,rt,it;const r=s(this,Er),n=await r.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),A=(it=(rt=(Tt=(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:Tt.split(/\s+/))==null?void 0:rt[0])==null?void 0:it.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 Su{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var ku=class{createQueryCompiler(){return new Nu}createAdapter(){return new Su}createIntrospector(t){return new Eu(t)}},Iu=(ya=class{constructor(){M(this,ci,new Ou);ze(this,"connection")}async acquireConnection(){return await s(this,ci).lock(),this.connection}async beginTransaction(t){await t.executeQuery(Gs.raw("begin"))}async commitTransaction(t){await t.executeQuery(Gs.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(Gs.raw("rollback"))}async releaseConnection(){s(this,ci).unlock()}},ci=new WeakMap,ya),Ou=class{constructor(){ze(this,"promise");ze(this,"resolve")}async lock(){for(;this.promise;)await this.promise;this.promise=new Promise(t=>{this.resolve=t})}unlock(){const t=this.resolve;this.promise=void 0,this.resolve=void 0,t==null||t()}},Au=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)}}},Tu=class extends Iu{constructor(e){super();ze(this,"config");ze(this,"db");this.config=e}async init(){this.db=typeof this.config.database=="function"?await this.config.database():this.config.database,this.connection=new Cu(this.db),this.config.onCreateConnection&&await this.config.onCreateConnection(this.connection)}async destroy(){var e;(e=this.db)==null||e.close()}},Cu=class extends Au{constructor(e){super();ze(this,"db");this.db=e}query(e,r){const n=[];return this.db.exec({sql:e,bind:r??[],rowMode:"object",resultRows:n}),n}exec(e,r){return this.db.exec({sql:e,bind:r??[]}),{numAffectedRows:BigInt(this.db.changes(!1,!0)),insertId:BigInt(this.query("SELECT last_insert_rowid() as id")[0].id)}}},Wu=(ga=class extends ku{constructor(e){super();M(this,di,void 0);$(this,di,e)}createDriver(){return new Tu(s(this,di))}},di=new WeakMap,ga),Fu=(()=>{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),Tt="./this.program",rt=typeof window=="object",it=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,yn,fi;(rt||it)&&(it?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},it&&(fi=o=>{var i=new XMLHttpRequest;return i.open("GET",o,!1),i.responseType="arraybuffer",i.send(null),new Uint8Array(i.response)}),yn=(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 gn=n.print||console.log.bind(console),St=n.printErr||console.warn.bind(console);Object.assign(n,Oe),Oe=null,n.arguments&&n.arguments,n.thisProgram&&(Tt=n.thisProgram),n.quit&&n.quit;var hi;n.wasmBinary&&(hi=n.wasmBinary),n.noExitRuntime,typeof WebAssembly!="object"&&Gn("no native wasm support detected");var Cn,wa=!1;function Hu(o,i){o||Gn(i)}var qa=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Sr(o,i,l){for(var a=i+l,u=i;o[u]&&!(u>=a);)++u;if(u-i>16&&o.buffer&&qa)return qa.decode(o.subarray(i,u));for(var d="";i>10,56320|z&1023)}}return d}function $u(o,i){return o?Sr(_i,o,i):""}function xs(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 xs(o,_i,i,l)}function pi(o){for(var i=0,l=0;l=55296&&a<=57343?(i+=4,++l):i+=3}return i}var Dt,_i,Na,we,st;function va(){var o=Cn.buffer;n.HEAP8=Dt=new Int8Array(o),n.HEAP16=Na=new Int16Array(o),n.HEAP32=we=new Int32Array(o),n.HEAPU8=_i=new Uint8Array(o),n.HEAPU16=new Uint16Array(o),n.HEAPU32=st=new Uint32Array(o),n.HEAPF32=new Float32Array(o),n.HEAPF64=new Float64Array(o),n.HEAP64=new BigInt64Array(o),n.HEAPU64=new BigUint64Array(o)}var xa=n.INITIAL_MEMORY||16777216;n.wasmMemory?Cn=n.wasmMemory:Cn=new WebAssembly.Memory({initial:xa/65536,maximum:2147483648/65536}),va(),xa=Cn.buffer.byteLength;var Ea=[],Sa=[],ka=[];function Gu(){if(n.preRun)for(typeof n.preRun=="function"&&(n.preRun=[n.preRun]);n.preRun.length;)Xu(n.preRun.shift());no(Ea)}function Ju(){!n.noFSInit&&!c.init.initialized&&c.init(),c.ignorePermissions=!1,no(Sa)}function Ku(){if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)Zu(n.postRun.shift());no(ka)}function Xu(o){Ea.unshift(o)}function Yu(o){Sa.unshift(o)}function Zu(o){ka.unshift(o)}var $n=0,mi=null;function rd(o){return o}function to(o){$n++,n.monitorRunDependencies&&n.monitorRunDependencies($n)}function Es(o){if($n--,n.monitorRunDependencies&&n.monitorRunDependencies($n),$n==0&&mi){var i=mi;mi=null,i()}}function Gn(o){n.onAbort&&n.onAbort(o),o="Aborted("+o+")",St(o),wa=!0,o+=". Build with -sASSERTIONS for more info.";var i=new WebAssembly.RuntimeError(o);throw X(i),i}var ec="data:application/octet-stream;base64,";function Ia(o){return o.startsWith(ec)}var zt;n.locateFile?(zt="sqlite3.wasm",Ia(zt)||(zt=Qt(zt))):zt=new URL(""+new URL("sqlite3-14470338.wasm",self.location.href).href,self.location).href;function Oa(o){try{if(o==zt&&hi)return new Uint8Array(hi);if(fi)return fi(o);throw"both async and sync fetching of the wasm failed"}catch(i){Gn(i)}}function tc(){return!hi&&(rt||it)&&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 Oa(zt)}):Promise.resolve().then(function(){return Oa(zt)})}function nc(){var o={env:Pa,wasi_snapshot_preview1:Pa};function i(N,S){var C=N.exports;n.asm=C,n.asm.__indirect_function_table,Yu(n.asm.__wasm_call_ctors),Es()}to();function l(N){i(N.instance)}function a(N){return tc().then(function(S){return WebAssembly.instantiate(S,o)}).then(function(S){return S}).then(N,function(S){St("failed to asynchronously prepare wasm: "+S),Gn(S)})}function u(){return!hi&&typeof WebAssembly.instantiateStreaming=="function"&&!Ia(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 St("wasm streaming compile failed: "+C),St("falling back to ArrayBuffer instantiation"),a(l)})}):a(l)}if(n.instantiateWasm)try{var d=n.instantiateWasm(o,i);return d}catch(N){St("Module.instantiateWasm callback failed with error: "+N),X(N)}return u().catch(X),{}}var qe,ct;function no(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 rc(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var o=new Uint8Array(1);return()=>(crypto.getRandomValues(o),o[0])}else return()=>Gn("randomDevice")}var wn={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=wn.resolve(o).substr(1),i=wn.resolve(i).substr(1);function l(z){for(var J=0;J=0&&z[ie]==="";ie--);return J>ie?[]:z.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:pi(o)+1,u=new Array(a),d=xs(o,u,0,u.length);return i&&(u.length=d),u}var Jn={ttys:[],init:function(){},shutdown:function(){},register:function(o,i){Jn.ttys[o]={input:[],output:[],ops:i},c.registerDevice(o,Jn.stream_ops)},stream_ops:{open:function(o){var i=Jn.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&&(gn(Sr(o.output,0)),o.output=[])}},default_tty1_ops:{put_char:function(o,i){i===null||i===10?(St(Sr(o.output,0)),o.output=[]):i!=0&&o.output.push(i)},fsync:function(o){o.output&&o.output.length>0&&(St(Sr(o.output,0)),o.output=[])}}};function Aa(o){Gn()}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{Hu(d,'Loading data file "'+o+'" failed (no arrayBuffer).'),i(new Uint8Array(d)),u&&Es()},d=>{if(l)l();else throw'Loading data file "'+o+'" failed.'}),u&&to()}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=wn.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&&St("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(!wn.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 z=c.lookupNode(S,u),J=wn.relative(o,a);if(J.charAt(0)!==".")throw new c.ErrnoError(28);if(J=wn.relative(i,l),J.charAt(0)!==".")throw new c.ErrnoError(55);var ie;try{ie=c.lookupNode(C,d)}catch{}if(z!==ie){var k=c.isDir(z.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(z)||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(z);try{S.node_ops.rename(z,C,d)}catch(y){throw y}finally{c.hashAddNode(z)}}},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 wn.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=Sr(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(pi(i)+1),d=xs(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)),Jn.register(c.makedev(5,0),Jn.default_tty_ops),Jn.register(c.makedev(6,0),Jn.default_tty1_ops),c.mkdev("/dev/tty",c.makedev(5,0)),c.mkdev("/dev/tty1",c.makedev(6,0));var o=rc();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 z=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,z,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=ro(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 B=(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 Q=new XMLHttpRequest;if(Q.open("GET",l,!1),y!==P&&Q.setRequestHeader("Range","bytes="+D+"-"+le),Q.responseType="arraybuffer",Q.overrideMimeType&&Q.overrideMimeType("text/plain; charset=x-user-defined"),Q.send(null),!(Q.status>=200&&Q.status<300||Q.status===304))throw new Error("Couldn't load "+l+". Status: "+Q.status);return Q.response!==void 0?new Uint8Array(Q.response||[]):ro(Q.responseText||"",!0)},R=this;R.setDataGetter(D=>{var le=D*P,Q=(D+1)*P-1;if(Q=Math.min(Q,y-1),typeof R.chunks[D]>"u"&&(R.chunks[D]=B(le,Q)),typeof R.chunks[D]>"u")throw new Error("doXHR failed!");return R.chunks[D]}),(b||!y)&&(P=y=1,y=this.getter(0).length,P=y,gn("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(!it)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 z={},J=Object.keys(C.stream_ops);J.forEach(k=>{var m=C.stream_ops[k];z[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 B=0;B(c.forceLoadFile(C),ie(k,m,y,x,E)),z.mmap=(k,m,y,x,E)=>{c.forceLoadFile(C);var b=Aa();if(!b)throw new c.ErrnoError(48);return ie(k,Dt,b,m,y),{ptr:b,allocated:!0}},C.stream_ops=z,C},createPreloadedFile:(o,i,l,a,u,d,N,S,C,z)=>{var J=i?wn.resolve(Ee.join2(o,i)):o;function ie(k){function m(y){z&&z(),S||c.createDataFile(o,i,y,a,u,C),d&&d(),Es()}Browser.handledByPreloadPlugin(k,J,m,()=>{N&&N(),Es()})||m(k)}to(),typeof l=="string"?ic(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=()=>{gn("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,z=0,J=o.length;function ie(){z==0?i():l()}o.forEach(k=>{var m=S.put(c.analyzePath(k).object.contents,k);m.onsuccess=()=>{C++,C+z==J&&ie()},m.onerror=()=>{z++,C+z==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,z=0,J=o.length;function ie(){z==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+z==J&&ie()},m.onerror=()=>{z++,C+z==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,st[l+16>>2]=a.nlink,we[l+20>>2]=a.uid,we[l+24>>2]=a.gid,we[l+28>>2]=a.rdev,ct=[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]=ct[0],we[l+44>>2]=ct[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 ct=[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]=ct[0],we[l+60>>2]=ct[1],st[l+64>>2]=u%1e3*1e3,ct=[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]=ct[0],we[l+76>>2]=ct[1],st[l+80>>2]=d%1e3*1e3,ct=[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]=ct[0],we[l+92>>2]=ct[1],st[l+96>>2]=N%1e3*1e3,ct=[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]=ct[0],we[l+108>>2]=ct[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=_i.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=$u(o);return i},getStreamFromFD:function(o){var i=c.getStream(o);if(!i)throw new c.ErrnoError(8);return i}};function sc(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 oc(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 ac(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 lc(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 uc(o){return we[La()>>2]=o,o}function cc(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 Na[u+N>>1]=2,0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:return uc(28),-1;default:return-28}}catch(S){if(typeof c>"u"||!(S instanceof c.ErrnoError))throw S;return-S.errno}}function dc(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 fc=9007199254740992,hc=-9007199254740992;function Ta(o){return ofc?NaN:Number(o)}function pc(o,i){try{return i=Ta(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 _c(o,i){try{if(i===0)return-28;var l=c.cwd(),a=pi(l)+1;return i"u"||!(u instanceof c.ErrnoError))throw u;return-u.errno}}function mc(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 yc(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 gc(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 wc(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 qc(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,pi(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 Nc(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 vc(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 xc(o,i,l){try{return i=fe.getStr(i),i=fe.calculateAt(o,i),l===0?c.unlink(i):l===512?c.rmdir(i):Gn("Invalid flags passed to unlinkat"),0}catch(a){if(typeof c>"u"||!(a instanceof c.ErrnoError))throw a;return-a.errno}}function io(o){return st[o>>2]+we[o+4>>2]*4294967296}function Ec(o,i,l,a){try{if(i=fe.getStr(i),i=fe.calculateAt(o,i,!0),l){var N=io(l),S=we[l+8>>2];u=N*1e3+S/(1e3*1e3),l+=16,N=io(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 Sc=!0;function kc(){return Sc}function Ic(o){return o%4===0&&(o%100!==0||o%400===0)}var Oc=[0,31,60,91,121,152,182,213,244,274,305,335],Ac=[0,31,59,90,120,151,181,212,243,273,304,334];function Tc(o){var i=Ic(o.getFullYear()),l=i?Oc:Ac,a=l[o.getMonth()]+o.getDate()-1;return a}function Cc(o,i){var l=new Date(io(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=Tc(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 Ca(o){var i=pi(o)+1,l=Da(i);return l&&xs(o,Dt,l,i),l}function Wc(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);st[o>>2]=C*60,we[i>>2]=+(N!=S);function z(y){var x=y.toTimeString().match(/\(([A-Za-z ]+)\)$/);return x?x[1]:"GMT"}var J=z(u),ie=z(d),k=Ca(J),m=Ca(ie);S>2]=k,st[l+4>>2]=m):(st[l>>2]=m,st[l+4>>2]=k)}function Fc(){return Date.now()}var Wa;Wa=()=>performance.now();function Pc(){return 2147483648}function Lc(o){var i=Cn.buffer;try{return Cn.grow(o-i.byteLength+65535>>>16),va(),1}catch{}}function Dc(o){var i=_i.length;o=o>>>0;var l=Pc();if(o>l)return!1;let a=(C,z)=>C+(z-C%z)%z;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=Lc(N);if(S)return!0}return!1}var so={};function Rc(){return Tt||"./this.program"}function yi(){if(!yi.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,_:Rc()};for(var l in so)so[l]===void 0?delete i[l]:i[l]=so[l];var a=[];for(var l in i)a.push(l+"="+i[l]);yi.strings=a}return yi.strings}function Bc(o,i,l){for(var a=0;a>0]=o.charCodeAt(a);l||(Dt[i>>0]=0)}function Mc(o,i){var l=0;return yi().forEach(function(a,u){var d=i+l;st[o+u*4>>2]=d,Bc(a,d),l+=a.length+1}),0}function Uc(o,i){var l=yi();st[o>>2]=l.length;var a=0;return l.forEach(function(u){a+=u.length+1}),st[i>>2]=a,0}function jc(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 Qc(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 zc(o,i,l,a){for(var u=0,d=0;d>2],S=st[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 Hc(o,i,l,a){try{if(i=Ta(i),isNaN(i))return 61;var u=fe.getStreamFromFD(o);return c.llseek(u,i,l),ct=[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]=ct[0],we[a+4>>2]=ct[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 $c(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 Gc(o,i,l,a){for(var u=0,d=0;d>2],S=st[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 Jc(o,i,l,a){try{var u=fe.getStreamFromFD(o),d=Gc(u,i,l);return st[a>>2]=d,0}catch(N){if(typeof c>"u"||!(N instanceof c.ErrnoError))throw N;return N.errno}}var Fa=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},Ss=365,ks=146;Object.defineProperties(Fa.prototype,{read:{get:function(){return(this.mode&Ss)===Ss},set:function(o){o?this.mode|=Ss:this.mode&=~Ss}},write:{get:function(){return(this.mode&ks)===ks},set:function(o){o?this.mode|=ks:this.mode&=~ks}},isFolder:{get:function(){return c.isDir(this.mode)}},isDevice:{get:function(){return c.isChrdev(this.mode)}}}),c.FSNode=Fa,c.staticInit();var Pa={__syscall_chmod:sc,__syscall_faccessat:oc,__syscall_fchmod:ac,__syscall_fchown32:lc,__syscall_fcntl64:cc,__syscall_fstat64:dc,__syscall_ftruncate64:pc,__syscall_getcwd:_c,__syscall_ioctl:mc,__syscall_lstat64:yc,__syscall_mkdirat:gc,__syscall_newfstatat:wc,__syscall_openat:qc,__syscall_readlinkat:bc,__syscall_rmdir:Nc,__syscall_stat64:vc,__syscall_unlinkat:xc,__syscall_utimensat:Ec,_emscripten_get_now_is_monotonic:kc,_localtime_js:Cc,_tzset_js:Wc,emscripten_date_now:Fc,emscripten_get_now:Wa,emscripten_resize_heap:Dc,environ_get:Mc,environ_sizes_get:Uc,fd_close:jc,fd_fdstat_get:Qc,fd_read:Vc,fd_seek:Hc,fd_sync:$c,fd_write:Jc,memory:Cn};nc(),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 La=n.___errno_location=function(){return(La=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 Da=n._malloc=function(){return(Da=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=Cn;var Is;mi=function o(){Is||Ra(),Is||(mi=o)};function Ra(o){if($n>0||(Gu(),$n>0))return;function i(){Is||(Is=!0,n.calledRun=!0,!wa&&(Ju(),A(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),Ku()))}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 Ra(),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 z=C.toss;a.wasmfsOpfsDir&&!/^\/[^/]+$/.test(a.wasmfsOpfsDir)&&z("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),B=f=>f&&(f instanceof Uint8Array||f instanceof Int8Array||f instanceof ArrayBuffer),R=f=>P(f)||z("Value is not of a supported TypedArray type."),D=new TextDecoder("utf-8"),le=function(f,p,_){return D.decode(b(f,p,_))},Q=function(f){return B(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:R,flexibleString:Q,bigIntFits32:k,bigIntFits64:ie,bigIntFitsDouble:m,isBindableTypedArray:P,isInt32:J,isSQLableTypedArray:B,isTypedArray:y,typedArrayToString:le,isUIThread:()=>globalThis.window===globalThis&&!!globalThis.document,isSharedTypedArray:E,toss:function(...f){throw new Error(f.join(" "))},toss3:z,typedArrayPart:b};Object.assign(d,{ptrSizeof:a.wasmPtrSizeof||4,ptrIR:a.wasmPtrIR||"i32",bigIntEnabled:!!a.bigIntEnabled,exports:a.exports||z("Missing API config.exports (WASM module exports)."),memory:a.memory||a.exports.memory||z("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)),R(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||z("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||z("Invalid sqlite3* argument."),d.bigIntEnabled||z("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&&z("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 Q;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,z=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?z(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 B=class{constructor(g){this.name=g.name||"unnamed adapter"}convertArg(g,v,I){l("AbstractArgAdapter must be subclassed.")}};x.FuncPtrAdapter=(Q=class extends B{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)."),Q.bindScopes.indexOf(v.bindScope)<0&&l("Invalid options.bindScope ("+v.bindMod+") for FuncPtrAdapter. Expecting one of: ("+Q.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(Q.debugFuncInstall&&Q.debugOut("FuncPtrAdapter installed",this,this.contextKey(I,q),"@"+f,v),w){if(w[1]){Q.debugFuncInstall&&Q.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){Q.debugFuncInstall&&Q.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+".")}},ze(Q,"warnOnUse",!1),ze(Q,"debugFuncInstall",!1),ze(Q,"debugOut",console.debug.bind(console)),ze(Q,"bindScopes",["transient","context","singleton","permanent"]),Q);const R=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)=>R(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 B?x.set(p,(..._)=>p.convertArg(..._)):R(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=(...z)=>{throw new Error(z.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 z=N.instance.exports;C.alloc=function(J){return z.malloc(J)||S("Allocation of",J,"bytes failed.")},C.dealloc=function(J){z.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),z=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 V=function H(K){return arguments.length===0?H.__flags:(K<0?(delete H.__flags.getter,delete H.__flags.setter,delete H.__flags.alloc,delete H.__flags.dealloc):(H.__flags.getter=(1&K)!==0,H.__flags.setter=(2&K)!==0,H.__flags.alloc=(4&K)!==0,H.__flags.dealloc=(8&K)!==0),H._flags)};return Object.defineProperty(V,"__flags",{iterable:!1,writable:!1,value:Object.create(T)}),T||V(0),V},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",B=T=>b(T)?"p":T[0],R=function(T){switch(B(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(B(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)},Q=function(T){switch(B(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(B(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,V)=>T+"::"+V,I=function(T,V){return()=>a(v(T,V),"is read-only.")},q=new WeakMap,w="(pointer-is-external)",f=function(T,V,H){if(H||(H=q.get(V)),H){if(q.delete(V),Array.isArray(V.ondispose)){let K;for(;K=V.ondispose.shift();)try{K instanceof Function?K.call(V):K instanceof be?K.dispose():typeof K=="number"&&S(K)}catch(Ie){console.warn("ondispose() for",T.structName,"@",H,"threw. NOT propagating it.",Ie)}}else if(V.ondispose instanceof Function)try{V.ondispose()}catch(K){console.warn("ondispose() for",T.structName,"@",H,"threw. NOT propagating it.",K)}delete V.ondispose,T.debugFlags.__flags.dealloc&&C("debug.dealloc:",V[w]?"EXTERNAL":"",T.structName,"instance:",T.structInfo.sizeof,"bytes @"+H),V[w]||S(H)}},p=T=>({configurable:!1,writable:!1,iterable:!1,value:T}),_=function(T,V,H){let K=!H;H?Object.defineProperty(V,w,p(H)):(H=N(T.structInfo.sizeof),H||a("Allocation of",T.structName,"structure failed."));try{T.debugFlags.__flags.alloc&&C("debug.alloc:",K?"":"EXTERNAL",T.structName,"instance:",T.structInfo.sizeof,"bytes @"+H),K&&d().fill(0,H,H+T.structInfo.sizeof),q.set(V,H)}catch(Ie){throw f(T,V,H),Ie}},W=function(){const T=this.pointer;return T?new Uint8Array(d().slice(T,T+this.structInfo.sizeof)):null},se=p(T=>z+T+J),oe=function(T,V,H=!0){let K=T.members[V];if(!K&&(z||J)){for(const Ie of Object.values(T.members))if(Ie.key===V){K=Ie;break}!K&&H&&a(v(T.name,V),"is not a mapped struct member.")}return K},ce=function T(V,H,K=!1){T._||(T._=Be=>Be.replace(/[^vipPsjrdcC]/g,"").replace(/[pPscC]/g,"i"));const Ie=oe(V.structInfo,H,!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 V of Object.keys(this.structInfo.members))T.push(this.memberKey(V));return T}),ve=new TextDecoder("utf-8"),Ke=new TextEncoder,yt=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,un=function(T,V,H){return ve.decode(T.buffer instanceof yt?T.slice(V,H):T.subarray(V,H))},O=function(T,V,H=!1){const K=oe(T.structInfo,V,H);return K&&K.signature.length===1&&K.signature[0]==="s"?K:!1},U=function(T){T.signature!=="s"&&a("Invalid member type signature for C-string value:",JSON.stringify(T))},j=function(V,H){const K=oe(V.structInfo,H,!0);U(K);const Ie=V[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,...V){T.ondispose?Array.isArray(T.ondispose)||(T.ondispose=[T.ondispose]):T.ondispose=[],T.ondispose.push(...V)},G=function(T){const V=Ke.encode(T),H=N(V.length+1);H||a("Allocation error while duplicating string:",T);const K=d();return K.set(V,H),K[H+V.length]=0,H},xe=function(T,V,H){const K=oe(T.structInfo,V,!0);U(K);const Ie=G(H);return T[K.key]=Ie,Y(T,Ie),T},be=function(V,H){arguments[2]!==p&&a("Do not call the StructType constructor","from client-level code."),Object.defineProperties(this,{structName:p(V),structInfo:p(H)})};be.prototype=Object.create(null,{dispose:p(function(){f(this.constructor,this)}),lookupMember:p(function(T,V=!0){return oe(this.structInfo,T,V)}),memberToJsString:p(function(T){return j(this,T)}),memberIsString:p(function(T,V=!0){return O(this,T,V)}),memberKey:se,memberKeys:de,memberSignature:p(function(T,V=!1){return ce(this,T,V)}),memoryDump:p(W),pointer:pe,setMemberCString:p(function(T,V){return xe(this,T,V)})}),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(V,H,K){if(!T._){T._={getters:{},setters:{},sw:{}};const kt=["i","c","C","p","P","s","f","d","v()"];ie&&kt.push("j"),kt.forEach(function(cn){T._.getters[cn]=le(cn),T._.setters[cn]=Q(cn),T._.sw[cn]=g(cn)});const Kc=/^[ipPsjfdcC]$/,Xc=/^[vipPsjfdcC]\([ipPsjfdcC]*\)$/;T.sigCheck=function(cn,Yc,Ba,oo){Object.prototype.hasOwnProperty.call(cn,Ba)&&a(cn.structName,"already has a property named",Ba+"."),Kc.test(oo)||Xc.test(oo)||a("Malformed signature for",v(cn.structName,Yc)+":",oo)}}const Ie=V.memberKey(H);T.sigCheck(V.prototype,H,Ie,K.signature),K.key=Ie,K.name=H;const Be=B(K.signature),Ae=v(V.prototype.structName,Ie),Ge=V.prototype.debugFlags.__flags,kr=Object.create(null);kr.configurable=!1,kr.enumerable=!1,kr.get=function(){Ge.getter&&C("debug.getter:",T._.getters[Be],"for",R(Be),Ae,"@",this.pointer,"+",K.offset,"sz",K.sizeof);let kt=new DataView(d().buffer,this.pointer+K.offset,K.sizeof)[T._.getters[Be]](0,E);return Ge.getter&&C("debug.getter:",Ae,"result =",kt),kt},K.readOnly?kr.set=I(V.prototype.structName,Ie):kr.set=function(kt){if(Ge.setter&&C("debug.setter:",T._.setters[Be],"for",R(Be),Ae,"@",this.pointer,"+",K.offset,"sz",K.sizeof,kt),this.pointer||a("Cannot set struct property on disposed instance."),kt===null)kt=0;else for(;!ne(kt);){if(P(K.signature)&&kt instanceof be){kt=kt.pointer||0,Ge.setter&&C("debug.setter:",Ae,"resolved to",kt);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](kt),E)},Object.defineProperty(V.prototype,Ie,kr)},dt=function T(V,H){arguments.length===1?(H=V,V=H.name):H.name||(H.name=V),V||a("Struct name is required.");let K=!1;Object.keys(H.members).forEach(Ae=>{const Ge=H.members[Ae];Ge.sizeof?Ge.sizeof===1?Ge.signature==="c"||Ge.signature==="C"||a("Unexpected sizeof==1 member",v(H.name,Ae),"with signature",Ge.signature):(Ge.sizeof%4!==0&&(console.warn("Invalid struct member description =",Ge,"from",H),a(V,"member",Ae,"sizeof is not aligned. sizeof="+Ge.sizeof)),Ge.offset%4!==0&&(console.warn("Invalid struct member description =",Ge,"from",H),a(V,"member",Ae,"offset is not aligned. offset="+Ge.offset))):a(V,"member",Ae,"is missing sizeof."),(!K||K.offsetAe instanceof Be),memberKey:se,memberKeys:de,methodInfoForKey:p(function(Ae){}),structInfo:p(H),structName:p(V)}),Be.prototype=new be(V,H,p),Object.defineProperties(Be.prototype,{debugFlags:Ie,constructor:p(Be)}),Object.keys(H.members).forEach(Ae=>Vt(Be,Ae,H.members[Ae])),Be};return dt.StructType=be,dt.config=l,dt.allocCString=G,dt.debugFlags||(dt.debugFlags=u.__makeDebugFlags(u.debugFlags)),dt},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(B){return B.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,B)=>{k(m,y,x,u.cstrToJs(E),u.cstrToJs(b),P,B)}}),"*"]],["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,B,R){return B instanceof i.WasmAllocError?(B=a.SQLITE_NOMEM,R=0):B instanceof Error&&(R=R||""+B,B=B.resultCode||a.SQLITE_ERROR),P?b(P,B,R):B}}else d.sqlite3_wasm_db_error=function(b,P,B){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),z=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(z(m).toLowerCase())},J._addUDF=function(k,m,y,x){m=z(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 B=P[0],R=P[1],D=[k,B,0,a.SQLITE_UTF8,0,0,0,0,0];x&&D.push(0);for(const le of R)try{D[2]=le,b.apply(null,D)}catch{}R.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,B){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 R=m(y,x,E,b,P,B);return R===0&&P instanceof Function&&J.addCollation(y,x),R}catch(R){return d.sqlite3_wasm_db_error(y,R)}},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,B)=>{try{E(b,...a.sqlite3_values_to_js(P,B))}catch(R){a.sqlite3_result_error_js(b,R)}}},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,B)=>{try{a.sqlite3_result_js(b,E(b,...a.sqlite3_values_to_js(P,B)))}catch(R){a.sqlite3_result_error_js(b,R)}}},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,B,R,D,le,Q,g,v){if(E.length!==arguments.length)return N(b,"sqlite3_create_function_v2",E.length);if(!(R&15))R|=a.SQLITE_UTF8;else if(a.SQLITE_UTF8!==(R&15))return S(b);try{const I=y(b,P,B,R,D,le,Q,g,v);return I===0&&(le instanceof Function||Q instanceof Function||g instanceof Function||v instanceof Function)&&J.addFunction(b,P,B),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,B,R,D,le,Q,g){return E.length===arguments.length?a.sqlite3_create_function_v2(b,P,B,R,D,le,Q,g,0):N(b,"sqlite3_create_function",E.length)},a.sqlite3_create_window_function=function E(b,P,B,R,D,le,Q,g,v,I){if(E.length!==arguments.length)return N(b,"sqlite3_create_window_function",E.length);if(!(R&15))R|=a.SQLITE_UTF8;else if(a.SQLITE_UTF8!==(R&15))return S(b);try{const q=x(b,P,B,R,D,le,Q,g,v,I);return q===0&&(le instanceof Function||Q instanceof Function||g instanceof Function||v instanceof Function||I instanceof Function)&&J.addWindowFunc(b,P,B),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,B,R){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,B,null);case"number":return m.full(x,D,le,P,B,R);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,B){return y.length===arguments.length?a.sqlite3_prepare_v3(x,E,b,0,P,B):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,B){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,B);b instanceof ArrayBuffer?b=new Uint8Array(b):Array.isArray(pMem)&&(b=pMem.join(""));let R,D;try{if(d.isSQLableTypedArray(b))R=u.allocFromTypedArray(b),D=b.byteLength;else if(typeof b=="string")[R,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,R,D,a.SQLITE_WASM_DEALLOC)}catch(le){return u.dealloc(R),d.sqlite3_wasm_db_error(a.sqlite3_db_handle(x),le)}},a.sqlite3_bind_blob=function y(x,E,b,P,B){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,B);b instanceof ArrayBuffer?b=new Uint8Array(b):Array.isArray(b)&&(b=b.join(""));let R,D;try{if(d.isBindableTypedArray(b))R=u.allocFromTypedArray(b),D=P>=0?P:b.byteLength;else if(typeof b=="string")[R,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,R,D,a.SQLITE_WASM_DEALLOC)}catch(le){return u.dealloc(R),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,B,R)=>{const D=y.pointer,le=u.scopedAllocPush();try{const Q=m(b,P);if(!Q)return-3;const g=u.cstrToJs(Q),v=x(b).getItem(g);if(!v)return-1;const I=v.length;if(R<=0)return I;if(R===1)return u.poke(B,0),I;const q=u.scopedAllocCString(v);return R>I+1&&(R=I+1),u.heap8u().copyWithin(B,q,q+R-1),u.poke(B+R-1,0),R-1}catch(Q){return console.error("kvstorageRead()",Q),-2}finally{y.restore(D),u.scopedAllocPop(le)}},xWrite:(b,P,B)=>{const R=y.pointer;try{const D=m(b,P);if(!D)return 1;const le=u.cstrToJs(D);return x(b).setItem(le,u.cstrToJs(B)),0}catch(D){return console.error("kvstorageWrite()",D),a.SQLITE_IOERR}finally{y.restore(R)}},xDelete:(b,P)=>{const B=y.pointer;try{const R=m(b,P);return R?(x(b).removeItem(u.cstrToJs(R)),0):1}catch(R){return console.error("kvstorageDelete()",R),a.SQLITE_IOERR}finally{y.restore(B)}}};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},z=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),z(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&&z(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},B=(q,w,f,...p)=>{const _=q.prepare(w);try{return _.bind(f).step()?_.get(...p):void 0}finally{_.finalize()}},R=(q,w,f,p)=>q.exec({sql:w,bind:f,rowMode:p,returnValue:"resultRows"});m.checkRc=(q,w)=>z(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 Ke=ve+u.ptrSizeof;const yt=Ke+pe;for(ce?u.heap8().set(q.sql,Ke):u.jstrcpy(q.sql,u.heap8(),Ke,pe,!1),u.poke(Ke+pe,0);Ke&&u.peek(Ke,"i8");){u.pokePtr([de,ve],0),m.checkRc(this,a.sqlite3_prepare_v3(this.pointer,Ke,pe,0,de,ve));const un=u.peekPtr(de);if(Ke=u.peekPtr(ve),pe=yt-Ke,!!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 _=U=>U 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 Ke=f||W,yt=C(p,"arity"),un=typeof yt=="number"?yt:Ke.length?Ke.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 B(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 B(this,q,w,[])},selectObject:function(q,w){return B(this,q,w,{})},selectArrays:function(q,w){return R(this,q,w,"array")},selectObjects:function(q,w){return R(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}},Q=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)}}),Q(_),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,Q(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,Q(w[f]),w[f])),this):I(this,q,Q(w),w)))},bindAsBlob:function(q,w){D(this),arguments.length===1&&(w=q,q=1);const f=Q(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},z=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 R;try{R=a.wasm.allocFromTypedArray(b);const D=a.wasm.sqlite3_wasm_vfs_create_file(P,y.filename,R,b.byteLength);D&&a.SQLite3Error.toss(D)}catch(D){throw new a.SQLite3Error(D.name+" creating "+x.filename+": "+D.message,{cause:D})}finally{R&&a.wasm.dealloc(R)}}const B=N.open(y);return E.filename=B.filename,E.persistent=!!a.capi.sqlite3_js_db_uses_vfs(B.pointer,"opfs"),E.dbId=d(B),E.vfs=B.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(B,R){N.post({type:E,columnNames:y.columnNames,rowNumber:++b,row:B},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||z()),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 z=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,Q,g){return function(...v){return Q.length!==arguments.length&&u("Argument mismatch for",D.structInfo.name+"::"+le+": Native signature is:",g),Q.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 B=y.memberKey(x),R=b&&!l.isPtr(E)?m.argcProxy(y,B,E,P):E;if(l.isPtr(R))R&&!l.functionEntry(R)&&u("Pointer",R,"is not a WASM function table entry."),y[B]=R;else{const D=l.installFunction(R,y.memberSignature(x,!0));y[B]=D,(!y.ondispose||!y.ondispose.__removeFuncList)&&(y.addOnDispose("ondispose.__removeFuncList handler",m.removeFuncList),y.ondispose.__removeFuncList=[]),y.ondispose.__removeFuncList.push(B,D)}return(D,le)=>m(y,D,le,b)};z.installMethodArgcCheck=!1;const J=function(m,y,x=z.installMethodArgcCheck){const E=new Map;for(const b of Object.keys(y)){const P=y[b],B=E.get(P);if(B){const R=m.memberKey(b);m[R]=m[m.memberKey(B)]}else z(m,b,P,x),E.set(P,b)}return m};S.StructType.prototype.installMethod=function(y,x,E=z.installMethodArgcCheck){return arguments.length<3&&y&&typeof y=="object"?J(this,...arguments):z(this,...arguments)},S.StructType.prototype.installMethods=function(m,y=z.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],B=b[1];E[P]===!0?E[P]=E[B]:E[B]===!0&&(E[B]=E[P])}if(m.catchExceptions){const b=function(R,D){return["xConnect","xCreate"].indexOf(R)>=0?function(le,Q,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(R,w)}}:function(...le){try{return D(...le)||0}catch(Q){return N.xError(R,Q)}}},P=["xCreate","xConnect","xBestIndex","xDisconnect","xDestroy","xOpen","xClose","xFilter","xNext","xEof","xColumn","xRowid","xUpdate","xBegin","xSync","xCommit","xRollback","xFindFunction","xRename","xSavepoint","xRelease","xRollbackTo","xShadowName"],B=Object.create(null);for(const R of P){const D=E[R];if(D instanceof Function)R==="xConnect"&&E.xCreate===D?B[R]=E.xCreate:R==="xCreate"&&E.xConnect===D?B[R]=E.xConnect:B[R]=b(R,D);else continue}J(x,B,!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,z){const J={0:i.config.error,1:i.config.warn,2:i.config.log},ie=(O,...U)=>{u.verbose>O&&J[O]("OPFS syncer:",...U)},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,B=E.sqlite3_file,R=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,U=0,j=0,Y=0;for(O in _.opIds){const G=W[O];U+=G.count,j+=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`,U,"op(s) for",j,"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 U=Y=>Y.count=Y.time=Y.wait=0;for(O in _.opIds)U(W[O]=Object.create(null));let j=W.s11n=Object.create(null);j=j.serialize=Object.create(null),j.count=j.time=0,j=W.s11n.deserialize=Object.create(null),j.count=j.time=0}};const Q=new P,g=new R;let v;const I=O=>(v=!0,Q.dispose(),z(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;Q.$iVersion=2,Q.$szOsFile=E.sqlite3_file.structInfo.sizeof,Q.$mxPathname=1024,Q.$zName=b.allocCString("opfs"),Q.$xDlOpen=Q.$xDlError=Q.$xDlSym=Q.$xDlClose=null,Q.ondispose=["$zName",Q.$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=Q.$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,...U)=>{const j=_.opIds[O]||x("Invalid op ID:",O);_.s11n.serialize(...U),Atomics.store(_.sabOPView,_.opIds.rc,-1),Atomics.store(_.sabOPView,_.opIds.whichOp,j),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,U=new TextEncoder("utf-8"),j=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(),dt=j[0],T=dt?[]:null;if(dt){const V=[];let H=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,Ke={xCheckReservedLock:function(O,U){const j=ce[O];return b.poke(U,j.lockType?1:0,"i32"),0},xClose:function(O){de("xClose");let U=0;const j=ce[O];return j&&(delete ce[O],U=L("xClose",O),j.sq3File&&j.sq3File.dispose()),ve(),U},xDeviceCharacteristics:function(O){return E.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(O,U,j){return E.SQLITE_NOTFOUND},xFileSize:function(O,U){de("xFileSize");let j=L("xFileSize",O);if(j==0)try{const Y=_.s11n.deserialize()[0];b.poke(U,Y,"i64")}catch(Y){y("Unexpected error reading xFileSize() result:",Y),j=_.sq3Codes.SQLITE_IOERR}return ve(),j},xLock:function(O,U){de("xLock");const j=ce[O];let Y=0;return j.lockType?j.lockType=U:(Y=L("xLock",O,U),Y===0&&(j.lockType=U)),ve(),Y},xRead:function(O,U,j,Y){de("xRead");const G=ce[O];let xe;try{xe=L("xRead",O,j,Number(Y)),(xe===0||E.SQLITE_IOERR_SHORT_READ===xe)&&b.heap8u().set(G.sabView.subarray(0,j),U)}catch(be){y("xRead(",arguments,") failed:",be,G),xe=E.SQLITE_IOERR_READ}return ve(),xe},xSync:function(O,U){de("xSync"),++W.xSync.count;const j=L("xSync",O,U);return ve(),j},xTruncate:function(O,U){de("xTruncate");const j=L("xTruncate",O,Number(U));return ve(),j},xUnlock:function(O,U){de("xUnlock");const j=ce[O];let Y=0;return E.SQLITE_LOCK_NONE===U&&j.lockType&&(Y=L("xUnlock",O,U)),Y===0&&(j.lockType=U),ve(),Y},xWrite:function(O,U,j,Y){de("xWrite");const G=ce[O];let xe;try{G.sabView.set(b.heap8u().subarray(U,U+j)),xe=L("xWrite",O,j,Number(Y))}catch(be){y("xWrite(",arguments,") failed:",be,G),xe=E.SQLITE_IOERR_WRITE}return ve(),xe}},yt={xAccess:function(O,U,j,Y){de("xAccess");const G=L("xAccess",b.cstrToJs(U));return b.poke(Y,G?0:1,"i32"),ve(),0},xCurrentTime:function(O,U){return b.poke(U,24405875e-1+new Date().getTime()/864e5,"double"),0},xCurrentTimeInt64:function(O,U){return b.poke(U,24405875e-1*864e5+new Date().getTime(),"i64"),0},xDelete:function(O,U,j){return de("xDelete"),L("xDelete",b.cstrToJs(U),j,!1),ve(),0},xFullPathname:function(O,U,j,Y){return b.cstrncpy(Y,U,j)!!Y):j},D.getDirForFilename=async function(U,j=!1){const Y=D.getResolvedPath(U,!0),G=Y.pop();let xe=D.rootDirectory;for(const be of Y)be&&(xe=await xe.getDirectoryHandle(be,{create:!!j}));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[U,j]=await D.getDirForFilename(O);return await U.getFileHandle(j),!0}catch{return!1}},D.randomFilename=oe,D.registerVfs=(O=!1)=>b.exports.sqlite3_vfs_register(Q.pointer,O?1:0),D.treeList=async function(){const O=async function j(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 j(xe,be)}else G.files.push(xe.name)},U=Object.create(null);return await O(D.rootDirectory,U),U},D.rmfr=async function(){const O=D.rootDirectory,U={recurse:!0};for await(const j of O.values())O.removeEntry(j.name,U)},D.unlink=async function(O,U=!1,j=!1){try{const[Y,G]=await D.getDirForFilename(O,!1);return await Y.removeEntry(G,{recursive:U}),!0}catch(Y){if(j)throw new Error("unlink(",arguments[0],") failed: "+Y.message,{cause:Y});return!1}},D.traverse=async function(O){const U={recursive:!0,directory:D.rootDirectory};typeof O=="function"&&(O={callback:O}),O=Object.assign(U,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(...U){const j=i.oo1.DB.dbCtorHelper.normalizeArgs(...U);j.vfs=Q.$zName,i.oo1.DB.dbCtorHelper.call(this,j)};O.prototype=Object.create(i.oo1.DB.prototype),i.oo1.OpfsDb=O,i.oo1.DB.dbCtorHelper.setVfsPostOpenSql(Q.pointer,function(U,j){j.capi.sqlite3_busy_timeout(U,1e4),j.capi.sqlite3_exec(U,["pragma journal_mode=persist;","pragma cache_size=-16384;"],0,0,0)})}const un=function(){const O=b.scopedAllocPush(),U=new B;try{const j=U.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."),yt.xAccess(Q.pointer,be,0,G),ne=b.peek(G,"i32"),k("xAccess(",xe,") exists ?=",ne),ne=yt.xOpen(Q.pointer,be,j,Y,G),k("open rc =",ne,"state.sabOPView[xOpen] =",_.sabOPView[_.opIds.xOpen]),ne!==0){y("open failed with code",ne);return}yt.xAccess(Q.pointer,be,0,G),ne=b.peek(G,"i32"),ne||x("xAccess() failed to detect file."),ne=Ke.xSync(U.pointer,0),ne&&x("sync failed w/ rc",ne),ne=Ke.xTruncate(U.pointer,1024),ne&&x("truncate failed w/ rc",ne),b.poke(G,0,"i64"),ne=Ke.xFileSize(U.pointer,G),ne&&x("xFileSize failed w/ rc",ne),k("xFileSize says:",b.peek(G,"i64")),ne=Ke.xWrite(U.pointer,be,10,1),ne&&x("xWrite() failed!");const Vt=b.scopedAlloc(16);ne=Ke.xRead(U.pointer,Vt,6,2),b.poke(Vt+6,0);let dt=b.cstrToJs(Vt);k("xRead() got:",dt),dt!=="sanity"&&x("Unexpected xRead() value."),yt.xSleep&&(k("xSleep()ing before close()ing..."),yt.xSleep(Q.pointer,2e3),k("waking up from xSleep()")),ne=Ke.xClose(j),k("xClose rc =",ne,"sabOPView =",_.sabOPView),k("Deleting file:",xe),yt.xDelete(Q.pointer,be,4660),yt.xAccess(Q.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{U.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:Ke},vfs:{struct:Q,methods:yt}}),_.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(U=>{w.onerror=w._originalOnError,delete w._originalOnError,i.opfs=D,D.rootDirectory=U,k("End of OPFS sqlite3_vfs setup.",Q),q(i)}).catch(I):q(i)}catch(U){y(U),I(U)}break}default:{const U="Unexpected message from the OPFS async worker: "+JSON.stringify(O);y(U),I(new Error(U));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 Pu=function(){var r,n;const t=Fu;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 Tt,rt,it;if(typeof WorkerGlobalScope<"u"&&(ae.ENVIRONMENT_IS_PTHREAD||ae._pthread_self||typeof threadAlert=="function"||(it=(rt=(Tt=globalThis==null?void 0:globalThis.location)==null?void 0:Tt.pathname)==null?void 0:rt.endsWith)!=null&&it.call(rt,".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 Lu=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),Du=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},Ru=class extends Bs{constructor(e){super();ze(this,"serializer");this.serializer=e||Lu}transformPrimitiveValueList(e){return{...e,values:e.values.map(this.serializer)}}transformColumnUpdate(e){const{value:r}=e;if(r.kind!=="ValueNode")return super.transformColumnUpdate(e);const{value:n,...A}=r,X=this.serializer(n);return n===X?super.transformColumnUpdate(e):super.transformColumnUpdate({...e,value:{...A,value:X}})}transformValue(e){return{...e,value:this.serializer(e.value)}}},Bu=class{constructor(t={}){ze(this,"serializeParametersTransformer");ze(this,"deserializer");ze(this,"ctx");this.serializeParametersTransformer=new Ru(t.serializer),this.deserializer=t.deserializer||Du,this.ctx=new WeakMap}transformQuery(t){const{node:e,queryId:r}=t;return e.kind==="SelectQueryNode"&&this.ctx.set(r,e.kind),this.serializeParametersTransformer.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 this.deserializer(r[n]);return r}))}async transformResult(t){const{result:e,queryId:r}=t,{rows:n}=e,A=this.ctx.get(r);return n&&A==="SelectQueryNode"?{...t.result,rows:await this.parseResult(n)}:t.result}};function Js(t){return typeof t=="string"}function Mu(t){return typeof t=="boolean"}async function ma(t,e,r,n,A="rowid"){await Wt` + create trigger if not exists ${Wt.raw(e)}_${Wt.raw(n)} + after ${Wt.raw(r)} + on ${Wt.table(e)} + begin + update ${Wt.table(e)} + set ${Wt.ref(n)} = datetime('now','localtime') + where ${Wt.ref(A)} = NEW.${Wt.ref(A)}; + end + `.execute(t).catch(X=>{console.error(X)})}function Uu(t){const e=new Map;for(const r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;const n=t[r];e.set(r,n)}return e}async function ju(t,e,r=!1){for(const[n,A]of e){const{columns:X,property:ae}=A;r&&await t.schema.dropTable(n).ifExists().execute().catch();let me=t.schema.createTable(n),Oe="rowid",Tt=!1,rt="createAt",it="updateAt";if(ae!=null&&ae.timestamp&&!Mu(ae.timestamp)){const{create:ue,update:Qt}=ae.timestamp;rt=ue??"createAt",it=Qt??"updateAt"}for(const ue in X){if(!Object.prototype.hasOwnProperty.call(X,ue))continue;const Qt=X[ue];let Qe="text";const{type:yn,notNull:fi,defaultTo:gn}=Qt;switch(yn){case"boolean":case"date":case"object":case"string":Qe="text";break;case"increments":Oe=ue;case"number":Qe="integer";break;case"blob":Qe="blob"}[rt,it].includes(ue)||(me=me.addColumn(ue,Qe,St=>yn==="increments"?(Tt=!0,St.autoIncrement().primaryKey()):(fi&&(St=St.notNull()),gn!==void 0&&(St=St.defaultTo(gn instanceof Function?gn(Wt):gn)),St)))}if(ae){const ue=ae.primary,Qt=ae.unique;if(ae.timestamp&&(rt&&(me=me.addColumn(rt,"text")),it&&(me=me.addColumn(it,"text"))),!Tt&&ue){const Qe=Js(ue);Oe=Qe?ue:ue[0],me=me.addPrimaryKeyConstraint(`pk_${Qe?ue:ue.join("_")}`,Qe?[ue]:ue)}Qt==null||Qt.forEach(Qe=>{const yn=Js(Qe);Oe=!ue&&!Tt?yn?Qe:Qe[0]:Oe,me=me.addUniqueConstraint(`un_${yn?Qe:Qe.join("_")}`,yn?[Qe]:Qe)})}if(await me.ifNotExists().execute(),ae!=null&&ae.index)for(const ue of ae.index){const Qt=Js(ue);let Qe=t.schema.createIndex(`idx_${Qt?ue:ue.join("_")}`).on(n);Qe=Qt?Qe.column(ue):Qe.columns(ue),await Qe.ifNotExists().execute()}ae!=null&&ae.timestamp&&(rt&&await ma(t,n,"insert",rt,Oe),it&&await ma(t,n,"update",it,Oe))}}var Qu=class{constructor(t){ze(this,"kysely");ze(this,"status");ze(this,"tableMap");const{dialect:e,tables:r,dropTableBeforeInit:n,onError:A,onQuery:X,plugins:ae}=t,me=ae??[];me.push(new Bu),this.kysely=new Vr({dialect:e,log:Oe=>{Oe.level==="error"?A&&A(Oe.error):X&&X(Oe.query,Oe.queryDurationMillis)},plugins:me}),this.status=n?0:1,this.tableMap=Uu(r)}async init(t=!1){const e=t||this.status===0;return await ju(this.kysely,this.tableMap,e),this.status=2,this}async checkInit(){if(this.status!==2&&await this.init(),this.status!==2)throw new Error("fail to init table")}async transaction(t,e=!1){return await this.checkInit(),await this.kysely.transaction().execute(t).catch(r=>{e&&console.error(r)})}async exec(t,e=!1){return await this.checkInit(),t(this.kysely).catch(r=>{e&&console.error(r)})}async toSQL(t){return await this.checkInit(),t(this.kysely).compile()}async raw(t){return await this.checkInit(),t(Wt).execute(this.kysely)}};async function zu(t){const e=await new Qu({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(r=>r`PRAGMA table_info(${r.table("test")});`)),console.log(await e.raw(r=>r`select last_insert_rowid()`));for(let r=0;r<100;r++)await e.transaction(n=>n.insertInto("test").values({name:`test at ${Date.now()}`,blobtest:Uint8Array.from([2,3,4,5,6,7,8])}).execute());return e.exec(r=>r.selectFrom("test").selectAll().execute())}const Vu=new Wu({database:async()=>{const t=(await Pu()).oo1;if(!t)return Promise.reject("fail to load sqlite");const e="/test.db";return t.OpfsDb?(console.log("support OPFS"),new t.OpfsDb(e)):(console.log("doesn't support OPFS"),new t.DB(e))}});onmessage=()=>{console.log("start official wasm test"),zu(Vu).then(t=>{t==null||t.forEach(e=>console.log("[official wasm]",e))})}})(); diff --git a/assets/officialWasmWorker-f13be864.js b/assets/officialWasmWorker-f13be864.js deleted file mode 100644 index 9541966..0000000 --- a/assets/officialWasmWorker-f13be864.js +++ /dev/null @@ -1,13 +0,0 @@ -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["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` - create trigger if not exists ${Wt.raw(e)}_${Wt.raw(n)} - after ${Wt.raw(r)} - on ${Wt.table(e)} - begin - update ${Wt.table(e)} - set ${Wt.ref(n)} = datetime('now','localtime') - where ${Wt.ref(A)} = NEW.${Wt.ref(A)}; - end - `.execute(t).catch(X=>{console.error(X)})}function sc(t){const e=new Map;for(const r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;const n=t[r];e.set(r,n)}return e}async function oc(t,e,r=!1){for(const[n,A]of e){const{columns:X,property:ae}=A;r&&await t.schema.dropTable(n).ifExists().execute().catch();let me=t.schema.createTable(n),Oe="rowid",At=!1,nt="createAt",rt="updateAt";if(ae!=null&&ae.timestamp&&!ic(ae.timestamp)){const{create:ue,update:Qt}=ae.timestamp;nt=ue??"createAt",rt=Qt??"updateAt"}for(const ue in X){if(!Object.prototype.hasOwnProperty.call(X,ue))continue;const Qt=X[ue];let Qe="text";const{type:gn,notNull:vi,defaultTo:wn}=Qt;switch(gn){case"boolean":case"date":case"object":case"string":Qe="text";break;case"increments":Oe=ue;case"number":Qe="integer";break;case"blob":Qe="blob"}[nt,rt].includes(ue)||(me=me.addColumn(ue,Qe,Et=>gn==="increments"?(At=!0,Et.autoIncrement().primaryKey()):(vi&&(Et=Et.notNull()),wn!==void 0&&(Et=Et.defaultTo(wn instanceof Function?wn(Wt):wn)),Et)))}if(ae){const ue=ae.primary,Qt=ae.unique;if(ae.timestamp&&(nt&&(me=me.addColumn(nt,"text")),rt&&(me=me.addColumn(rt,"text"))),!At&&ue){const Qe=ao(ue);Oe=Qe?ue:ue[0],me=me.addPrimaryKeyConstraint(`pk_${Qe?ue:ue.join("_")}`,Qe?[ue]:ue)}Qt==null||Qt.forEach(Qe=>{const gn=ao(Qe);Oe=!ue&&!At?gn?Qe:Qe[0]:Oe,me=me.addUniqueConstraint(`un_${gn?Qe:Qe.join("_")}`,gn?[Qe]:Qe)})}if(await me.ifNotExists().execute(),ae!=null&&ae.index)for(const ue of ae.index){const Qt=ao(ue);let Qe=t.schema.createIndex(`idx_${Qt?ue:ue.join("_")}`).on(n);Qe=Qt?Qe.column(ue):Qe.columns(ue),await Qe.ifNotExists().execute()}ae!=null&&ae.timestamp&&(nt&&await Ia(t,n,"insert",nt,Oe),rt&&await Ia(t,n,"update",rt,Oe))}}var ac=(La=class{constructor(t){Tt(this,"kysely");R(this,Wn,void 0);R(this,Ni,void 0);const{dialect:e,tables:r,dropTableBeforeInit:n,onError:A,onQuery:X,plugins:ae}=t,me=ae??[];me.push(new rc),this.kysely=new Yr({dialect:e,log:Oe=>{Oe.level==="error"?A&&A(Oe.error):X&&X(Oe.query,Oe.queryDurationMillis)},plugins:me}),U(this,Wn,n?0:1),U(this,Ni,sc(r))}async init(t=!1){const e=t||s(this,Wn)===0;return await oc(this.kysely,s(this,Ni),e),U(this,Wn,2),this}async checkInit(){if(s(this,Wn)!==2&&await this.init(),s(this,Wn)!==2)throw new Error("fail to init table")}async transaction(t,e=!1){return await this.checkInit(),await this.kysely.transaction().execute(t).catch(r=>{e&&console.error(r)})}async exec(t,e=!1){return await this.checkInit(),t(this.kysely).catch(r=>{e&&console.error(r)})}async toSQL(t){return await this.checkInit(),t(this.kysely).compile()}async raw(t){return await this.checkInit(),t(Wt).execute(this.kysely)}},Wn=new WeakMap,Ni=new WeakMap,La);async function lc(t){const e=await new ac({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(r=>r`PRAGMA table_info(${r.table("test")});`)),console.log(await e.raw(r=>r`select last_insert_rowid()`));for(let r=0;r<100;r++)await e.transaction(n=>n.insertInto("test").values({name:`test at ${Date.now()}`,blobtest:Uint8Array.from([2,3,4,5,6,7,8])}).execute());return e.exec(r=>r.selectFrom("test").selectAll().execute())}const uc=new Xu({database:async()=>{const t=(await Zu()).oo1;if(!t)return Promise.reject("fail to load sqlite");const e="/test.db";return t.OpfsDb?(console.log("support OPFS"),new t.OpfsDb(e)):(console.log("doesn't support OPFS"),new t.DB(e))}});onmessage=()=>{console.log("start official wasm test"),lc(uc).then(t=>{t==null||t.forEach(e=>console.log("[official wasm]",e))})}})(); diff --git a/assets/sqljsWorker-6340e5b0.js b/assets/sqljsWorker-6340e5b0.js new file mode 100644 index 0000000..62b6247 --- /dev/null +++ b/assets/sqljsWorker-6340e5b0.js @@ -0,0 +1,12 @@ +var Al=Object.defineProperty;var Sl=(J,_,ye)=>_ in J?Al(J,_,{enumerable:!0,configurable:!0,writable:!0,value:ye}):J[_]=ye;var se=(J,_,ye)=>(Sl(J,typeof _!="symbol"?_+"":_,ye),ye),yo=(J,_,ye)=>{if(!_.has(J))throw TypeError("Cannot "+ye)};var i=(J,_,ye)=>(yo(J,_,"read from private field"),ye?ye.call(J):_.get(J)),v=(J,_,ye)=>{if(_.has(J))throw TypeError("Cannot add the same private member more than once");_ instanceof WeakSet?_.add(J):_.set(J,ye)},g=(J,_,ye,ri)=>(yo(J,_,"write to private field"),ri?ri.call(J,ye):_.set(J,ye),ye);var X=(J,_,ye)=>(yo(J,_,"access private method"),ye);(function(){var oe,ir,Sr,gi,bi,B,xi,ae,L,Wi,x,Oi,q,Dr,jn,Rr,nr,$n,xu,Jn,Wu,sr,Zi,qi,No,Gn,Ou,Ci,ee,ki,Lr,Br,ar,Ii,wo,m,Mr,Pr,_r,Fr,Vt,re,Qr,Ur,Vr,jr,gt,$r,K,ur,lt,Re,we,ie,de,H,ze,U,ke,Pe,_e,Xn,ue,Ie,Ke,He,We,Jr,xt,Wt,At,dt,$t,St,lr,Di,Zn,qu,es,Cu,ts,ku,rs,Iu,Ri,vo,Li,Jt,is,Eu,Gt,dr,Ee,ft,fr,pt,je,Kr,Ws,Bi,go,Mi,bo,Hr,zt,ss,Yr,pr,Xr,os,Tu,Pi,ka,_i,Ia;"use strict";function J(t){return typeof t>"u"||t===void 0}function _(t){return typeof t=="string"}function ye(t){return typeof t=="number"}function ri(t){return typeof t=="boolean"}function xo(t){return t===null}function Au(t){return t instanceof Date}function Su(t){return typeof t=="bigint"}function Xe(t){return typeof t=="function"}function Nt(t){return typeof t=="object"&&t!==null}function a(t){return Object.freeze(t)}function ii(t){return Array.isArray(t)}function br(t){return t}const Ne=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]})}}),he=a({is(t){return t.kind==="IdentifierNode"},create(t){return a({kind:"IdentifierNode",name:t})}}),Mt=a({is(t){return t.kind==="CreateIndexNode"},create(t){return a({kind:"CreateIndexNode",name:he.create(t)})},cloneWith(t,e){return a({...t,...e})},cloneWithColumns(t,e){return a({...t,columns:[...t.columns||[],...e]})}}),Wo=a({is(t){return t.kind==="CreateSchemaNode"},create(t,e){return a({kind:"CreateSchemaNode",schema:he.create(t),...e})},cloneWith(t,e){return a({...t,...e})}}),Du=["preserve rows","delete rows","drop"],ot=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})}}),Pt=a({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return a({kind:"SchemableIdentifierNode",identifier:he.create(t)})},createWithSchema(t,e){return a({kind:"SchemableIdentifierNode",schema:he.create(t),identifier:he.create(e)})}}),en=a({is(t){return t.kind==="DropIndexNode"},create(t,e){return a({kind:"DropIndexNode",name:Pt.create(t),...e})},cloneWith(t,e){return a({...t,...e})}}),Os=a({is(t){return t.kind==="DropSchemaNode"},create(t,e){return a({kind:"DropSchemaNode",schema:he.create(t),...e})},cloneWith(t,e){return a({...t,...e})}}),qs=a({is(t){return t.kind==="DropTableNode"},create(t,e){return a({kind:"DropTableNode",table:t,...e})},cloneWith(t,e){return a({...t,...e})}}),tr=a({is(t){return t.kind==="AliasNode"},create(t,e){return a({kind:"AliasNode",node:t,alias:e})}}),_t=a({is(t){return t.kind==="TableNode"},create(t){return a({kind:"TableNode",table:Pt.create(t)})},createWithSchema(t,e){return a({kind:"TableNode",table:Pt.createWithSchema(t,e)})}});function Be(t){return Nt(t)&&Xe(t.toOperationNode)}function Ru(t){return Nt(t)&&"expressionType"in t&&Be(t)}function Lu(t){return Nt(t)&&"expression"in t&&_(t.alias)&&Be(t)}const kt=a({is(t){return t.kind==="SelectModifierNode"},create(t){return a({kind:"SelectModifierNode",modifier:t})},createWithExpression(t){return a({kind:"SelectModifierNode",rawModifier:t})}}),ni=a({is(t){return t.kind==="AndNode"},create(t,e){return a({kind:"AndNode",left:t,right:e})}}),si=a({is(t){return t.kind==="OrNode"},create(t,e){return a({kind:"OrNode",left:t,right:e})}}),oi=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"?ni.create(t.on,r):si.create(t.on,r)})}}),Ze=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:oi.create(r)})},cloneWithOn(t,e){return a({...t,on:t.on?oi.cloneWithOperation(t.on,"And",e):oi.create(e)})},cloneWithOrOn(t,e){return a({...t,on:t.on?oi.cloneWithOperation(t.on,"Or",e):oi.create(e)})}}),tn=a({is(t){return t.kind==="BinaryOperationNode"},create(t,e,r){return a({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:r})}}),Ae=a({is(t){return t.kind==="RawNode"},create(t,e){return a({kind:"RawNode",sqlFragments:a(t),parameters:a(e)})},createWithSql(t){return Ae.create([t],[])},createWithChild(t){return Ae.create(["",""],[t])},createWithChildren(t){return Ae.create(new Array(t.length+1).fill(""),t)}}),Oo=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","?","?&","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->"],Bu=["+","-","*","/","%","^","&","|","#","<<",">>"],qo=[...Oo,...Bu,"&&","||"],Mu=["not","-",...["exists","not exists"]],Pu=[...qo,...Mu],Cs=a({is(t){return t.kind==="OperatorNode"},create(t){return a({kind:"OperatorNode",operator:t})}});function Co(t){return _(t)&&qo.includes(t)}function ko(t){return _(t)&&Oo.includes(t)}const xr=a({is(t){return t.kind==="ParensNode"},create(t){return a({kind:"ParensNode",node:t})}}),ce=a({is(t){return t.kind==="ColumnNode"},create(t){return a({kind:"ColumnNode",column:he.create(t)})}}),ks=a({is(t){return t.kind==="SelectAllNode"},create(){return a({kind:"SelectAllNode"})}}),rn=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:ks.create()})}}),_u=a({is(t){return t.kind==="OrderByItemNode"},create(t,e){return a({kind:"OrderByItemNode",orderBy:t,direction:e})}});function Fu(t){return t==="asc"||t==="desc"}function nn(t,e){return _u.create(Qu(t),Uu(e))}function Qu(t){return It(t)}function Uu(t){if(t)return t==="asc"||t==="desc"?Ae.createWithSql(t):t.toOperationNode()}function Io(t){return _(t)?Wr(t):t.toOperationNode()}function ai(t){return ii(t)?t.map(e=>It(e)):[It(t)]}function It(t){return bn(t)?gn(t):Io(t)}function Wr(t){const e=".";if(t.includes(e)){const r=t.split(e).map(Is);if(r.length===3)return ju(r);if(r.length===2)return $u(r);throw new Error(`invalid column reference ${t}`)}else return ce.create(t)}function Vu(t){const e=" as ";if(t.includes(e)){const[r,u]=t.split(e).map(Is);return tr.create(Wr(r),he.create(u))}else return Wr(t)}function Eo(t){return ce.create(t)}function To(t){const e=" ";if(t.includes(e)){const[r,u]=t.split(e).map(Is);if(!Fu(u))throw new Error(`invalid order direction "${u}" next to "${r}"`);return nn(r,u)}else return Eo(t)}function ju(t){const[e,r,u]=t;return rn.create(_t.createWithSchema(e,r),ce.create(u))}function $u(t){const[e,r]=t;return rn.create(_t.create(e),ce.create(r))}function Is(t){return t.trim()}const Ao=a({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return a({kind:"PrimitiveValueListNode",values:a([...t])})}}),Es=a({is(t){return t.kind==="ValueListNode"},create(t){return a({kind:"ValueListNode",values:a(t)})}}),wt=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 So(t){return ii(t)?Ju(t):Et(t)}function Et(t){return bn(t)?gn(t):wt.create(t)}function Ju(t){return t.some(bn)?Es.create(t.map(e=>Et(e))):Ao.create(t)}const Or=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])})}}),Do=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])})}}),Ts=a({is(t){return t.kind==="OverNode"},create(){return a({kind:"OverNode"})},cloneWithOrderByItem(t,e){return a({...t,orderBy:t.orderBy?Or.cloneWithItem(t.orderBy,e):Or.create(e)})},cloneWithPartitionByItems(t,e){return a({...t,partitionBy:t.partitionBy?Do.cloneWithItems(t.partitionBy,e):Do.create(e)})}}),sn=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])})}}),Ro=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])})}}),on=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"?ni.create(t.having,r):si.create(t.having,r)})}}),D=a({is(t){return t.kind==="SelectQueryNode"},create(t,e){return a({kind:"SelectQueryNode",from:sn.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?Or.cloneWithItem(t.orderBy,e):Or.create(e)})},cloneWithGroupByItems(t,e){return a({...t,groupBy:t.groupBy?Ro.cloneWithItems(t.groupBy,e):Ro.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?on.cloneWithOperation(t.having,"And",e):on.create(e)})},cloneWithOrHaving(t,e){return a({...t,having:t.having?on.cloneWithOperation(t.having,"Or",e):on.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})}}),Lo=a({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return a({kind:"UnaryOperationNode",operator:t,operand:e})}});function Se(t){return As("exists",t)}function qe(t){return As("not exists",t)}function As(t,e){return Lo.create(Cs.create(t),It(e))}function Q(t,e){Object.defineProperties(t.prototype,{then:{enumerable:!1,value:()=>{throw new Error(e)}}})}const ht=class{constructor(e){v(this,oe,void 0);g(this,oe,a(e))}on(...e){return new ht({...i(this,oe),joinNode:Ze.cloneWithOn(i(this,oe).joinNode,ea(e))})}orOn(...e){return new ht({...i(this,oe),joinNode:Ze.cloneWithOrOn(i(this,oe).joinNode,ea(e))})}onRef(e,r,u){return new ht({...i(this,oe),joinNode:Ze.cloneWithOn(i(this,oe).joinNode,Ce(e,r,u))})}orOnRef(e,r,u){return new ht({...i(this,oe),joinNode:Ze.cloneWithOrOn(i(this,oe).joinNode,Ce(e,r,u))})}onExists(e){return new ht({...i(this,oe),joinNode:Ze.cloneWithOn(i(this,oe).joinNode,Se(e))})}onNotExists(e){return new ht({...i(this,oe),joinNode:Ze.cloneWithOn(i(this,oe).joinNode,qe(e))})}orOnExists(e){return new ht({...i(this,oe),joinNode:Ze.cloneWithOrOn(i(this,oe).joinNode,Se(e))})}orOnNotExists(e){return new ht({...i(this,oe),joinNode:Ze.cloneWithOrOn(i(this,oe).joinNode,qe(e))})}onTrue(){return new ht({...i(this,oe),joinNode:Ze.cloneWithOn(i(this,oe).joinNode,Ae.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return i(this,oe).joinNode}};let an=ht;oe=new WeakMap,Q(an,"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");const Gu=a({is(t){return t.kind==="PartitionByItemNode"},create(t){return a({kind:"PartitionByItemNode",partitionBy:t})}});function zu(t){return ai(t).map(Gu.create)}const Vn=class{constructor(e){v(this,ir,void 0);g(this,ir,a(e))}orderBy(e,r){return new Vn({overNode:Ts.cloneWithOrderByItem(i(this,ir).overNode,nn(e,r))})}partitionBy(e){return new Vn({overNode:Ts.cloneWithPartitionByItems(i(this,ir).overNode,zu(e))})}$call(e){return e(this)}toOperationNode(){return i(this,ir).overNode}};let un=Vn;ir=new WeakMap,Q(un,"don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");const ui=a({is(t){return t.kind==="SelectionNode"},create(t){return a({kind:"SelectionNode",selection:t})},createSelectAll(){return a({kind:"SelectionNode",selection:ks.create()})},createSelectAllFromTable(t){return a({kind:"SelectionNode",selection:rn.createSelectAll(t)})}});class Ku{constructor(e){v(this,Sr,void 0);g(this,Sr,e)}get dynamicReference(){return i(this,Sr)}get refType(){}toOperationNode(){return Io(i(this,Sr))}}Sr=new WeakMap;function Hu(t){return Nt(t)&&Be(t)&&_(t.dynamicReference)}function hi(t){return Xe(t)?hi(t(Tt())):ii(t)?t.map(e=>Bo(e)):[Bo(t)]}function Bo(t){return _(t)?ui.create(Vu(t)):Hu(t)?ui.create(t.toOperationNode()):ui.create(ua(t))}function ci(t){return t?Array.isArray(t)?t.map(Mo):[Mo(t)]:[ui.createSelectAll()]}function Mo(t){if(_(t))return ui.createSelectAllFromTable(Ve(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const Yu=a({is(t){return t.kind==="ValuesNode"},create(t){return a({kind:"ValuesNode",values:a(t)})}}),Xu=a({is(t){return t.kind==="DefaultInsertValueNode"},create(){return a({kind:"DefaultInsertValueNode"})}});function Zu(t){const e=Xe(t)?t(Tt()):t,r=ii(e)?e:a([e]);return eh(r)}function eh(t){const e=th(t);return[a([...e.keys()].map(ce.create)),Yu.create(t.map(r=>rh(r,e)))]}function th(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 rh(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)||bn(j))&&(d=!0),u[I]=j}if(r.lengthJ(I)?k:Et(I)))}return Ao.create(u)}const vt=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})}}),hn=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?sn.cloneWithFroms(t.from,e):sn.create(e)})},cloneWithUpdates(t,e){return a({...t,updates:t.updates?a([...t.updates,...e]):e})}}),Po=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])})}}),li=a({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return a({kind:"DeleteQueryNode",from:sn.create(t),...e&&{with:e}})},cloneWithOrderByItem(t,e){return a({...t,orderBy:t.orderBy?Or.cloneWithItem(t.orderBy,e):Or.create(e)})},cloneWithLimit(t,e){return a({...t,limit:e})},cloneWithUsing(t,e){return a({...t,using:t.using!==void 0?Po.cloneWithTables(t.using,e):Po.create(e)})}}),De=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"?ni.create(t.where,r):si.create(t.where,r)})}}),_o=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)})}}),ih=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)||vt.is(t)||hn.is(t)||li.is(t)},cloneWithWhere(t,e){return a({...t,where:t.where?De.cloneWithOperation(t.where,"And",e):De.create(e)})},cloneWithOrWhere(t,e){return a({...t,where:t.where?De.cloneWithOperation(t.where,"Or",e):De.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?_o.cloneWithSelections(t.returning,e):_o.create(e)})},cloneWithoutWhere(t){return a({...t,where:void 0})},cloneWithExplain(t,e,r){return a({...t,explain:ih.create(e,r==null?void 0:r.toOperationNode())})}}),nh=a({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return a({kind:"ColumnUpdateNode",column:t,value:e})}});function Ss(t){const e=Xe(t)?t(Tt()):t;return Object.entries(e).filter(([r,u])=>u!==void 0).map(([r,u])=>nh.create(ce.create(r),Et(u)))}const sh=a({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return a({kind:"OnDuplicateKeyNode",updates:t})}});class Fo{constructor(e,r){v(this,gi,void 0);v(this,bi,void 0);g(this,gi,e),g(this,bi,r)}get insertId(){return i(this,gi)}get numInsertedOrUpdatedRows(){return i(this,bi)}}gi=new WeakMap,bi=new WeakMap;for(const t of["insertId","numInsertedOrUpdatedRows"])Object.defineProperty(Fo.prototype,t,{enumerable:!0});class cn extends Error{constructor(r){super("no result");se(this,"node");this.node=r}}function ln(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?De.cloneWithOperation(t.indexWhere,"And",e):De.create(e)})},cloneWithIndexOrWhere(t,e){return a({...t,indexWhere:t.indexWhere?De.cloneWithOperation(t.indexWhere,"Or",e):De.create(e)})},cloneWithUpdateWhere(t,e){return a({...t,updateWhere:t.updateWhere?De.cloneWithOperation(t.updateWhere,"And",e):De.create(e)})},cloneWithUpdateOrWhere(t,e){return a({...t,updateWhere:t.updateWhere?De.cloneWithOperation(t.updateWhere,"Or",e):De.create(e)})},cloneWithoutIndexWhere(t){return a({...t,indexWhere:void 0})},cloneWithoutUpdateWhere(t){return a({...t,updateWhere:void 0})}}),Me=class{constructor(e){v(this,B,void 0);g(this,B,a(e))}column(e){const r=ce.create(e);return new Me({...i(this,B),onConflictNode:te.cloneWith(i(this,B).onConflictNode,{columns:i(this,B).onConflictNode.columns?a([...i(this,B).onConflictNode.columns,r]):a([r])})})}columns(e){const r=e.map(ce.create);return new Me({...i(this,B),onConflictNode:te.cloneWith(i(this,B).onConflictNode,{columns:i(this,B).onConflictNode.columns?a([...i(this,B).onConflictNode.columns,...r]):a(r)})})}constraint(e){return new Me({...i(this,B),onConflictNode:te.cloneWith(i(this,B).onConflictNode,{constraint:he.create(e)})})}expression(e){return new Me({...i(this,B),onConflictNode:te.cloneWith(i(this,B).onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new Me({...i(this,B),onConflictNode:te.cloneWithIndexWhere(i(this,B).onConflictNode,Je(e))})}whereRef(e,r,u){return new Me({...i(this,B),onConflictNode:te.cloneWithIndexWhere(i(this,B).onConflictNode,Ce(e,r,u))})}orWhere(...e){return new Me({...i(this,B),onConflictNode:te.cloneWithIndexOrWhere(i(this,B).onConflictNode,Je(e))})}orWhereRef(e,r,u){return new Me({...i(this,B),onConflictNode:te.cloneWithIndexOrWhere(i(this,B).onConflictNode,Ce(e,r,u))})}whereExists(e){return new Me({...i(this,B),onConflictNode:te.cloneWithIndexWhere(i(this,B).onConflictNode,Se(e))})}whereNotExists(e){return new Me({...i(this,B),onConflictNode:te.cloneWithIndexWhere(i(this,B).onConflictNode,qe(e))})}orWhereExists(e){return new Me({...i(this,B),onConflictNode:te.cloneWithIndexOrWhere(i(this,B).onConflictNode,Se(e))})}orWhereNotExists(e){return new Me({...i(this,B),onConflictNode:te.cloneWithIndexOrWhere(i(this,B).onConflictNode,qe(e))})}clearWhere(){return new Me({...i(this,B),onConflictNode:te.cloneWithoutIndexWhere(i(this,B).onConflictNode)})}doNothing(){return new Qo({...i(this,B),onConflictNode:te.cloneWith(i(this,B).onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new fn({...i(this,B),onConflictNode:te.cloneWith(i(this,B).onConflictNode,{updates:Ss(e)})})}$call(e){return e(this)}};let dn=Me;B=new WeakMap,Q(dn,"don't await OnConflictBuilder instances.");class Qo{constructor(e){v(this,xi,void 0);g(this,xi,a(e))}toOperationNode(){return i(this,xi).onConflictNode}}xi=new WeakMap,Q(Qo,"don't await OnConflictDoNothingBuilder instances.");const ct=class{constructor(e){v(this,ae,void 0);g(this,ae,a(e))}where(...e){return new ct({...i(this,ae),onConflictNode:te.cloneWithUpdateWhere(i(this,ae).onConflictNode,Je(e))})}whereRef(e,r,u){return new ct({...i(this,ae),onConflictNode:te.cloneWithUpdateWhere(i(this,ae).onConflictNode,Ce(e,r,u))})}orWhere(...e){return new ct({...i(this,ae),onConflictNode:te.cloneWithUpdateOrWhere(i(this,ae).onConflictNode,Je(e))})}orWhereRef(e,r,u){return new ct({...i(this,ae),onConflictNode:te.cloneWithUpdateOrWhere(i(this,ae).onConflictNode,Ce(e,r,u))})}whereExists(e){return new ct({...i(this,ae),onConflictNode:te.cloneWithUpdateWhere(i(this,ae).onConflictNode,Se(e))})}whereNotExists(e){return new ct({...i(this,ae),onConflictNode:te.cloneWithUpdateWhere(i(this,ae).onConflictNode,qe(e))})}orWhereExists(e){return new ct({...i(this,ae),onConflictNode:te.cloneWithUpdateOrWhere(i(this,ae).onConflictNode,Se(e))})}orWhereNotExists(e){return new ct({...i(this,ae),onConflictNode:te.cloneWithUpdateOrWhere(i(this,ae).onConflictNode,qe(e))})}clearWhere(){return new ct({...i(this,ae),onConflictNode:te.cloneWithoutUpdateWhere(i(this,ae).onConflictNode)})}$call(e){return e(this)}toOperationNode(){return i(this,ae).onConflictNode}};let fn=ct;ae=new WeakMap,Q(fn,"don't await OnConflictUpdateBuilder instances.");const be=class{constructor(e){v(this,L,void 0);g(this,L,a(e))}values(e){const[r,u]=Zu(e);return new be({...i(this,L),queryNode:vt.cloneWith(i(this,L).queryNode,{columns:r,values:u})})}columns(e){return new be({...i(this,L),queryNode:vt.cloneWith(i(this,L).queryNode,{columns:a(e.map(ce.create))})})}expression(e){return new be({...i(this,L),queryNode:vt.cloneWith(i(this,L).queryNode,{values:gn(e)})})}ignore(){return new be({...i(this,L),queryNode:vt.cloneWith(i(this,L).queryNode,{ignore:!0})})}onConflict(e){return new be({...i(this,L),queryNode:vt.cloneWith(i(this,L).queryNode,{onConflict:e(new dn({onConflictNode:te.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new be({...i(this,L),queryNode:vt.cloneWith(i(this,L).queryNode,{onDuplicateKey:sh.create(Ss(e))})})}returning(e){return new be({...i(this,L),queryNode:C.cloneWithReturning(i(this,L).queryNode,hi(e))})}returningAll(){return new be({...i(this,L),queryNode:C.cloneWithReturning(i(this,L).queryNode,ci())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new be({...i(this,L)})}if(e,r){return e?r(this):new be({...i(this,L)})}$castTo(){return new be(i(this,L))}castTo(){return this.$castTo()}$narrowType(){return new be(i(this,L))}$assertType(){return new be(i(this,L))}assertType(){return new be(i(this,L))}withPlugin(e){return new be({...i(this,L),executor:i(this,L).executor.withPlugin(e)})}toOperationNode(){return i(this,L).executor.transformQuery(i(this,L).queryNode,i(this,L).queryId)}compile(){return i(this,L).executor.compileQuery(this.toOperationNode(),i(this,L).queryId)}async execute(){const e=this.compile(),r=e.query,u=await i(this,L).executor.executeQuery(e,i(this,L).queryId);return i(this,L).executor.adapter.supportsReturning&&r.returning?u.rows:[new Fo(u.insertId,u.numAffectedRows??u.numUpdatedOrDeletedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=cn){const r=await this.executeTakeFirst();if(r===void 0)throw ln(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=i(this,L).executor.stream(r,e,i(this,L).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new be({...i(this,L),queryNode:C.cloneWithExplain(i(this,L).queryNode,e,r)}).execute()}};let di=be;L=new WeakMap,Q(di,"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Uo{constructor(e){v(this,Wi,void 0);g(this,Wi,e)}get numDeletedRows(){return i(this,Wi)}}Wi=new WeakMap,Object.defineProperty(Uo.prototype,"numDeletedRows",{enumerable:!0});const Vo=a({is(t){return t.kind==="LimitNode"},create(t){return a({kind:"LimitNode",limit:wt.create(t)})}}),z=class{constructor(e){v(this,x,void 0);g(this,x,a(e))}where(...e){return new z({...i(this,x),queryNode:C.cloneWithWhere(i(this,x).queryNode,Je(e))})}whereRef(e,r,u){return new z({...i(this,x),queryNode:C.cloneWithWhere(i(this,x).queryNode,Ce(e,r,u))})}orWhere(...e){return new z({...i(this,x),queryNode:C.cloneWithOrWhere(i(this,x).queryNode,Je(e))})}orWhereRef(e,r,u){return new z({...i(this,x),queryNode:C.cloneWithOrWhere(i(this,x).queryNode,Ce(e,r,u))})}whereExists(e){return new z({...i(this,x),queryNode:C.cloneWithWhere(i(this,x).queryNode,Se(e))})}whereNotExists(e){return new z({...i(this,x),queryNode:C.cloneWithWhere(i(this,x).queryNode,qe(e))})}orWhereExists(e){return new z({...i(this,x),queryNode:C.cloneWithOrWhere(i(this,x).queryNode,Se(e))})}orWhereNotExists(e){return new z({...i(this,x),queryNode:C.cloneWithOrWhere(i(this,x).queryNode,qe(e))})}clearWhere(){return new z({...i(this,x),queryNode:C.cloneWithoutWhere(i(this,x).queryNode)})}using(e){return new z({...i(this,x),queryNode:li.cloneWithUsing(i(this,x).queryNode,Ir(e))})}innerJoin(...e){return new z({...i(this,x),queryNode:C.cloneWithJoin(i(this,x).queryNode,Ue("InnerJoin",e))})}leftJoin(...e){return new z({...i(this,x),queryNode:C.cloneWithJoin(i(this,x).queryNode,Ue("LeftJoin",e))})}rightJoin(...e){return new z({...i(this,x),queryNode:C.cloneWithJoin(i(this,x).queryNode,Ue("RightJoin",e))})}fullJoin(...e){return new z({...i(this,x),queryNode:C.cloneWithJoin(i(this,x).queryNode,Ue("FullJoin",e))})}returning(e){return new z({...i(this,x),queryNode:C.cloneWithReturning(i(this,x).queryNode,hi(e))})}returningAll(e){return new z({...i(this,x),queryNode:C.cloneWithReturning(i(this,x).queryNode,ci(e))})}orderBy(e,r){return new z({...i(this,x),queryNode:li.cloneWithOrderByItem(i(this,x).queryNode,nn(e,r))})}limit(e){return new z({...i(this,x),queryNode:li.cloneWithLimit(i(this,x).queryNode,Vo.create(e))})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new z({...i(this,x)})}if(e,r){return this.$if(e,r)}$castTo(){return new z(i(this,x))}castTo(){return this.$castTo()}$narrowType(){return new z(i(this,x))}$assertType(){return new z(i(this,x))}assertType(){return new z(i(this,x))}withPlugin(e){return new z({...i(this,x),executor:i(this,x).executor.withPlugin(e)})}toOperationNode(){return i(this,x).executor.transformQuery(i(this,x).queryNode,i(this,x).queryId)}compile(){return i(this,x).executor.compileQuery(this.toOperationNode(),i(this,x).queryId)}async execute(){const e=this.compile(),r=e.query,u=await i(this,x).executor.executeQuery(e,i(this,x).queryId);return i(this,x).executor.adapter.supportsReturning&&r.returning?u.rows:[new Uo(u.numAffectedRows??u.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=cn){const r=await this.executeTakeFirst();if(r===void 0)throw ln(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=i(this,x).executor.stream(r,e,i(this,x).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new z({...i(this,x),queryNode:C.cloneWithExplain(i(this,x).queryNode,e,r)}).execute()}};let pn=z;x=new WeakMap,Q(pn,"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class jo{constructor(e){v(this,Oi,void 0);g(this,Oi,e)}get numUpdatedRows(){return i(this,Oi)}}Oi=new WeakMap,Object.defineProperty(jo.prototype,"numUpdatedRows",{enumerable:!0});const Z=class{constructor(e){v(this,q,void 0);g(this,q,a(e))}where(...e){return new Z({...i(this,q),queryNode:C.cloneWithWhere(i(this,q).queryNode,Je(e))})}whereRef(e,r,u){return new Z({...i(this,q),queryNode:C.cloneWithWhere(i(this,q).queryNode,Ce(e,r,u))})}orWhere(...e){return new Z({...i(this,q),queryNode:C.cloneWithOrWhere(i(this,q).queryNode,Je(e))})}orWhereRef(e,r,u){return new Z({...i(this,q),queryNode:C.cloneWithOrWhere(i(this,q).queryNode,Ce(e,r,u))})}whereExists(e){return new Z({...i(this,q),queryNode:C.cloneWithWhere(i(this,q).queryNode,Se(e))})}whereNotExists(e){return new Z({...i(this,q),queryNode:C.cloneWithWhere(i(this,q).queryNode,qe(e))})}orWhereExists(e){return new Z({...i(this,q),queryNode:C.cloneWithOrWhere(i(this,q).queryNode,Se(e))})}orWhereNotExists(e){return new Z({...i(this,q),queryNode:C.cloneWithOrWhere(i(this,q).queryNode,qe(e))})}clearWhere(){return new Z({...i(this,q),queryNode:C.cloneWithoutWhere(i(this,q).queryNode)})}from(e){return new Z({...i(this,q),queryNode:hn.cloneWithFromItems(i(this,q).queryNode,Ir(e))})}innerJoin(...e){return new Z({...i(this,q),queryNode:C.cloneWithJoin(i(this,q).queryNode,Ue("InnerJoin",e))})}leftJoin(...e){return new Z({...i(this,q),queryNode:C.cloneWithJoin(i(this,q).queryNode,Ue("LeftJoin",e))})}rightJoin(...e){return new Z({...i(this,q),queryNode:C.cloneWithJoin(i(this,q).queryNode,Ue("RightJoin",e))})}fullJoin(...e){return new Z({...i(this,q),queryNode:C.cloneWithJoin(i(this,q).queryNode,Ue("FullJoin",e))})}set(e){return new Z({...i(this,q),queryNode:hn.cloneWithUpdates(i(this,q).queryNode,Ss(e))})}returning(e){return new Z({...i(this,q),queryNode:C.cloneWithReturning(i(this,q).queryNode,hi(e))})}returningAll(){return new Z({...i(this,q),queryNode:C.cloneWithReturning(i(this,q).queryNode,ci())})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new Z({...i(this,q)})}if(e,r){return this.$if(e,r)}$castTo(){return new Z(i(this,q))}castTo(){return this.$castTo()}$narrowType(){return new Z(i(this,q))}$assertType(){return new Z(i(this,q))}assertType(){return new Z(i(this,q))}withPlugin(e){return new Z({...i(this,q),executor:i(this,q).executor.withPlugin(e)})}toOperationNode(){return i(this,q).executor.transformQuery(i(this,q).queryNode,i(this,q).queryId)}compile(){return i(this,q).executor.compileQuery(this.toOperationNode(),i(this,q).queryId)}async execute(){const e=this.compile(),r=e.query,u=await i(this,q).executor.executeQuery(e,i(this,q).queryId);return i(this,q).executor.adapter.supportsReturning&&r.returning?u.rows:[new jo(u.numAffectedRows??u.numUpdatedOrDeletedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=cn){const r=await this.executeTakeFirst();if(r===void 0)throw ln(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=i(this,q).executor.stream(r,e,i(this,q).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new Z({...i(this,q),queryNode:C.cloneWithExplain(i(this,q).queryNode,e,r)}).execute()}};let mn=Z;q=new WeakMap,Q(mn,"don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");const oh=a({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return a({kind:"CommonTableExpressionNode",name:t,expression:e})}}),$o=a({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return a({kind:"CommonTableExpressionNameNode",table:_t.create(t),columns:e?a(e.map(ce.create)):void 0})}});function Jo(t,e){const r=e(yh());return oh.create(ah(t),r.toOperationNode())}function ah(t){if(t.includes("(")){const e=t.split(/[\(\)]/),r=e[0],u=e[1].split(",").map(d=>d.trim());return $o.create(r,u)}else return $o.create(t)}const yn=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])})}}),Go=["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 uh(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}}jn=new WeakMap;const lh=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 dh extends Ds{constructor(r){super();v(this,$n);v(this,Jn);v(this,sr);v(this,qi);v(this,Gn);v(this,Rr,void 0);v(this,nr,new Set);g(this,Rr,r)}transformNodeImpl(r){if(!X(this,$n,xu).call(this,r))return super.transformNodeImpl(r);const u=X(this,Jn,Wu).call(this,r);for(const b of u)i(this,nr).add(b);const d=super.transformNodeImpl(r);for(const b of u)i(this,nr).delete(b);return d}transformSchemableIdentifier(r){const u=super.transformSchemableIdentifier(r);return u.schema||!i(this,nr).has(r.identifier.name)?u:{...u,schema:he.create(i(this,Rr))}}transformReferences(r){const u=super.transformReferences(r);return u.table.table.schema?u:{...u,table:_t.createWithSchema(i(this,Rr),u.table.table.identifier.name)}}}Rr=new WeakMap,nr=new WeakMap,$n=new WeakSet,xu=function(r){return r.kind in lh},Jn=new WeakSet,Wu=function(r){const u=new Set;if("name"in r&&r.name&&Pt.is(r.name)&&X(this,qi,No).call(this,r.name,u),"from"in r&&r.from)for(const d of r.from.froms)X(this,sr,Zi).call(this,d,u);if("into"in r&&r.into&&X(this,sr,Zi).call(this,r.into,u),"table"in r&&r.table&&X(this,sr,Zi).call(this,r.table,u),"joins"in r&&r.joins)for(const d of r.joins)X(this,sr,Zi).call(this,d.table,u);return"with"in r&&r.with&&X(this,Gn,Ou).call(this,r.with,u),u},sr=new WeakSet,Zi=function(r,u){const d=_t.is(r)?r:tr.is(r)&&_t.is(r.node)?r.node:null;d&&X(this,qi,No).call(this,d.table,u)},qi=new WeakSet,No=function(r,u){i(this,nr).has(r.identifier.name)||u.add(r.identifier.name)},Gn=new WeakSet,Ou=function(r,u){for(const d of r.expressions)u.delete(d.name.table.table.identifier.name)};class fi{constructor(e){v(this,Ci,void 0);g(this,Ci,new dh(e))}transformQuery(e){return i(this,Ci).transformNode(e.node)}async transformResult(e){return e.result}}Ci=new WeakMap;const or=class{constructor(e){v(this,ee,void 0);g(this,ee,a(e))}selectFrom(e){return new kr({queryId:G(),executor:i(this,ee).executor,queryNode:D.create(Ir(e),i(this,ee).withNode)})}insertInto(e){return new di({queryId:G(),executor:i(this,ee).executor,queryNode:vt.create(Ve(e),i(this,ee).withNode)})}replaceInto(e){return new di({queryId:G(),executor:i(this,ee).executor,queryNode:vt.create(Ve(e),i(this,ee).withNode,!0)})}deleteFrom(e){return new pn({queryId:G(),executor:i(this,ee).executor,queryNode:li.create(Ir(e),i(this,ee).withNode)})}updateTable(e){return new mn({queryId:G(),executor:i(this,ee).executor,queryNode:hn.create(mi(e),i(this,ee).withNode)})}with(e,r){const u=Jo(e,r);return new or({...i(this,ee),withNode:i(this,ee).withNode?yn.cloneWithExpression(i(this,ee).withNode,u):yn.create(u)})}withRecursive(e,r){const u=Jo(e,r);return new or({...i(this,ee),withNode:i(this,ee).withNode?yn.cloneWithExpression(i(this,ee).withNode,u):yn.create(u,{recursive:!0})})}withPlugin(e){return new or({...i(this,ee),executor:i(this,ee).executor.withPlugin(e)})}withoutPlugins(){return new or({...i(this,ee),executor:i(this,ee).executor.withoutPlugins()})}withSchema(e){return new or({...i(this,ee),executor:i(this,ee).executor.withPluginAtFront(new fi(e))})}};let Nn=or;ee=new WeakMap;class zo{constructor(){v(this,ki,void 0);v(this,Lr,void 0);v(this,Br,void 0);se(this,"resolve",e=>{i(this,Lr)&&i(this,Lr).call(this,e)});se(this,"reject",e=>{i(this,Br)&&i(this,Br).call(this,e)});g(this,ki,new Promise((e,r)=>{g(this,Br,r),g(this,Lr,e)}))}get promise(){return i(this,ki)}}ki=new WeakMap,Lr=new WeakMap,Br=new WeakMap;const Ko=new Set;function fh(t){Ko.has(t)||(Ko.add(t),console.log(t))}const ph=a([]);class Ho{constructor(e=ph){v(this,Ii);v(this,ar,void 0);g(this,ar,e)}get plugins(){return i(this,ar)}transformQuery(e,r){for(const u of i(this,ar)){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,Ii,wo).call(this,d,r);return mh(d,b),b})}async*stream(e,r,u){const d=new zo,b=new zo;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,Ii,wo).call(this,I,u)}finally{b.resolve()}}}ar=new WeakMap,Ii=new WeakSet,wo=async function(e,r){for(const u of i(this,ar))e=await u.transformResult({result:e,queryId:r});return e};function mh(t,e){const{numAffectedRows:r}=t;r===void 0&&t.numUpdatedOrDeletedRows===void 0||r!==void 0&&e.numAffectedRows!==void 0||fh("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.")}class qr extends Ho{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 qr([...this.plugins,e])}withPlugins(e){return new qr([...this.plugins,...e])}withPluginAtFront(e){return new qr([e,...this.plugins])}withoutPlugins(){return new qr([])}}const wn=new qr;function Yo(){return new kr({queryId:G(),executor:wn,queryNode:D.create(Ir([]))})}function yh(){return new Nn({executor:wn})}function Xo(t,e){return new an({joinNode:Ze.create(t,mi(e))})}function Nh(){return new un({overNode:Ts.create()})}const Rs=a({is(t){return t.kind==="WhenNode"},create(t){return a({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return a({...t,result:e})}}),at=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),Rs.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return a({...t,...e})}});function Ls(t,e,r){if(!Co(e)&&!Be(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return gh(e,r)?bh(t,e,r):tn.create(It(t),Bs(e),So(r))}function wh(t,e,r){if(!Co(e)&&!Be(e))throw new Error(`invalid binary operator ${JSON.stringify(e)}`);return tn.create(It(t),Bs(e),It(r))}function vh(t,e,r){if(!ko(e)&&!Be(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return Ls(t,e,r)}function Ce(t,e,r){if(!ko(e)&&!Be(e))throw new Error(`invalid comparison operator ${JSON.stringify(e)}`);return wh(t,e,r)}function Je(t){return vn("where",t)}function Zo(t){return vn("having",t)}function ea(t){return vn("on",t)}function ta(t){return vn("when",t)}function vn(t,e){if(e.length===3)return vh(e[0],e[1],e[2]);if(e.length===1)return xh(t,e[0]);throw ra(t,e)}function gh(t,e){return(t==="is"||t==="is not")&&(xo(e)||ri(e))}function bh(t,e,r){return tn.create(It(t),Bs(e),wt.createImmediate(r))}function Bs(t){if(_(t)&&Pu.includes(t))return Cs.create(t);if(Be(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function xh(t,e){if(Xe(e)){if(t==="when")throw new Error("when method doesn't accept a callback as an argument");return Wh[t](e)}else if(Be(e)){const r=e.toOperationNode();if(Ae.is(r)||tn.is(r)||Lo.is(r)||xr.is(r)||at.is(r))return r}else if(t==="when")return wt.create(e);throw ra(t,e)}function ra(t,e){return new Error(`invalid arguments passed to a '${t}' method: ${JSON.stringify(e)}`)}const Wh=a({where(t){const e=Yo(),r=Tt(),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 xr.create(d.where.where)}else return d},having(t){const e=Yo(),r=Tt(),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 xr.create(d.having.having)}else return d},on(t){const e=Xo("InnerJoin","table"),r=Tt(),d=t(Object.assign(e,r)).toOperationNode();if(Ze.is(d)){if(!d.on)throw new Error("no `on` methods called inside a group callback");return xr.create(d.on.on)}else return d}});function Ue(t,e){if(e.length===3)return qh(t,e[0],e[1],e[2]);if(e.length===2)return Oh(t,e[0],e[1]);throw new Error("not implemented")}function Oh(t,e,r){return r(Xo(t,e)).toOperationNode()}function qh(t,e,r,u){return Ze.createWithOn(t,mi(e),Ce(r,"=",u))}const Ch=a({is(t){return t.kind==="OffsetNode"},create(t){return a({kind:"OffsetNode",offset:wt.create(t)})}}),kh=a({is(t){return t.kind==="GroupByItemNode"},create(t){return a({kind:"GroupByItemNode",groupBy:t})}});function Ih(t){return t=Xe(t)?t(Tt()):t,ai(t).map(kh.create)}const ia=a({is(t){return t.kind==="SetOperationNode"},create(t,e,r){return a({kind:"SetOperationNode",operator:t,expression:e,all:r})}});function Cr(t,e,r){return ia.create(t,e.toOperationNode(),r)}const W=class{constructor(e){v(this,m,void 0);g(this,m,a(e))}get expressionType(){}where(...e){return new W({...i(this,m),queryNode:C.cloneWithWhere(i(this,m).queryNode,Je(e))})}whereRef(e,r,u){return new W({...i(this,m),queryNode:C.cloneWithWhere(i(this,m).queryNode,Ce(e,r,u))})}orWhere(...e){return new W({...i(this,m),queryNode:C.cloneWithOrWhere(i(this,m).queryNode,Je(e))})}orWhereRef(e,r,u){return new W({...i(this,m),queryNode:C.cloneWithOrWhere(i(this,m).queryNode,Ce(e,r,u))})}whereExists(e){return new W({...i(this,m),queryNode:C.cloneWithWhere(i(this,m).queryNode,Se(e))})}whereNotExists(e){return new W({...i(this,m),queryNode:C.cloneWithWhere(i(this,m).queryNode,qe(e))})}orWhereExists(e){return new W({...i(this,m),queryNode:C.cloneWithOrWhere(i(this,m).queryNode,Se(e))})}orWhereNotExists(e){return new W({...i(this,m),queryNode:C.cloneWithOrWhere(i(this,m).queryNode,qe(e))})}having(...e){return new W({...i(this,m),queryNode:D.cloneWithHaving(i(this,m).queryNode,Zo(e))})}havingRef(e,r,u){return new W({...i(this,m),queryNode:D.cloneWithHaving(i(this,m).queryNode,Ce(e,r,u))})}orHaving(...e){return new W({...i(this,m),queryNode:D.cloneWithOrHaving(i(this,m).queryNode,Zo(e))})}orHavingRef(e,r,u){return new W({...i(this,m),queryNode:D.cloneWithOrHaving(i(this,m).queryNode,Ce(e,r,u))})}havingExists(e){return new W({...i(this,m),queryNode:D.cloneWithHaving(i(this,m).queryNode,Se(e))})}havingNotExist(e){return new W({...i(this,m),queryNode:D.cloneWithHaving(i(this,m).queryNode,qe(e))})}havingNotExists(e){return new W({...i(this,m),queryNode:D.cloneWithHaving(i(this,m).queryNode,qe(e))})}orHavingExists(e){return new W({...i(this,m),queryNode:D.cloneWithOrHaving(i(this,m).queryNode,Se(e))})}orHavingNotExists(e){return new W({...i(this,m),queryNode:D.cloneWithOrHaving(i(this,m).queryNode,qe(e))})}select(e){return new W({...i(this,m),queryNode:D.cloneWithSelections(i(this,m).queryNode,hi(e))})}distinctOn(e){return new W({...i(this,m),queryNode:D.cloneWithDistinctOn(i(this,m).queryNode,ai(e))})}modifyFront(e){return new W({...i(this,m),queryNode:D.cloneWithFrontModifier(i(this,m).queryNode,kt.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new W({...i(this,m),queryNode:D.cloneWithEndModifier(i(this,m).queryNode,kt.createWithExpression(e.toOperationNode()))})}distinct(){return new W({...i(this,m),queryNode:D.cloneWithFrontModifier(i(this,m).queryNode,kt.create("Distinct"))})}forUpdate(){return new W({...i(this,m),queryNode:D.cloneWithEndModifier(i(this,m).queryNode,kt.create("ForUpdate"))})}forShare(){return new W({...i(this,m),queryNode:D.cloneWithEndModifier(i(this,m).queryNode,kt.create("ForShare"))})}forKeyShare(){return new W({...i(this,m),queryNode:D.cloneWithEndModifier(i(this,m).queryNode,kt.create("ForKeyShare"))})}forNoKeyUpdate(){return new W({...i(this,m),queryNode:D.cloneWithEndModifier(i(this,m).queryNode,kt.create("ForNoKeyUpdate"))})}skipLocked(){return new W({...i(this,m),queryNode:D.cloneWithEndModifier(i(this,m).queryNode,kt.create("SkipLocked"))})}noWait(){return new W({...i(this,m),queryNode:D.cloneWithEndModifier(i(this,m).queryNode,kt.create("NoWait"))})}selectAll(e){return new W({...i(this,m),queryNode:D.cloneWithSelections(i(this,m).queryNode,ci(e))})}innerJoin(...e){return new W({...i(this,m),queryNode:C.cloneWithJoin(i(this,m).queryNode,Ue("InnerJoin",e))})}leftJoin(...e){return new W({...i(this,m),queryNode:C.cloneWithJoin(i(this,m).queryNode,Ue("LeftJoin",e))})}rightJoin(...e){return new W({...i(this,m),queryNode:C.cloneWithJoin(i(this,m).queryNode,Ue("RightJoin",e))})}fullJoin(...e){return new W({...i(this,m),queryNode:C.cloneWithJoin(i(this,m).queryNode,Ue("FullJoin",e))})}innerJoinLateral(...e){return new W({...i(this,m),queryNode:C.cloneWithJoin(i(this,m).queryNode,Ue("LateralInnerJoin",e))})}leftJoinLateral(...e){return new W({...i(this,m),queryNode:C.cloneWithJoin(i(this,m).queryNode,Ue("LateralLeftJoin",e))})}orderBy(e,r){return new W({...i(this,m),queryNode:D.cloneWithOrderByItem(i(this,m).queryNode,nn(e,r))})}groupBy(e){return new W({...i(this,m),queryNode:D.cloneWithGroupByItems(i(this,m).queryNode,Ih(e))})}limit(e){return new W({...i(this,m),queryNode:D.cloneWithLimit(i(this,m).queryNode,Vo.create(e))})}offset(e){return new W({...i(this,m),queryNode:D.cloneWithOffset(i(this,m).queryNode,Ch.create(e))})}union(e){return new W({...i(this,m),queryNode:D.cloneWithSetOperation(i(this,m).queryNode,Cr("union",e,!1))})}unionAll(e){return new W({...i(this,m),queryNode:D.cloneWithSetOperation(i(this,m).queryNode,Cr("union",e,!0))})}intersect(e){return new W({...i(this,m),queryNode:D.cloneWithSetOperation(i(this,m).queryNode,Cr("intersect",e,!1))})}intersectAll(e){return new W({...i(this,m),queryNode:D.cloneWithSetOperation(i(this,m).queryNode,Cr("intersect",e,!0))})}except(e){return new W({...i(this,m),queryNode:D.cloneWithSetOperation(i(this,m).queryNode,Cr("except",e,!1))})}exceptAll(e){return new W({...i(this,m),queryNode:D.cloneWithSetOperation(i(this,m).queryNode,Cr("except",e,!0))})}as(e){return new Eh(this,e)}clearSelect(){return new W({...i(this,m),queryNode:D.cloneWithoutSelections(i(this,m).queryNode)})}clearWhere(){return new W({...i(this,m),queryNode:C.cloneWithoutWhere(i(this,m).queryNode)})}clearLimit(){return new W({...i(this,m),queryNode:D.cloneWithoutLimit(i(this,m).queryNode)})}clearOffset(){return new W({...i(this,m),queryNode:D.cloneWithoutOffset(i(this,m).queryNode)})}clearOrderBy(){return new W({...i(this,m),queryNode:D.cloneWithoutOrderBy(i(this,m).queryNode)})}$call(e){return e(this)}call(e){return this.$call(e)}$if(e,r){return e?r(this):new W({...i(this,m)})}if(e,r){return this.$if(e,r)}$castTo(){return new W(i(this,m))}castTo(){return this.$castTo()}$narrowType(){return new W(i(this,m))}$assertType(){return new W(i(this,m))}assertType(){return new W(i(this,m))}withPlugin(e){return new W({...i(this,m),executor:i(this,m).executor.withPlugin(e)})}toOperationNode(){return i(this,m).executor.transformQuery(i(this,m).queryNode,i(this,m).queryId)}compile(){return i(this,m).executor.compileQuery(this.toOperationNode(),i(this,m).queryId)}async execute(){const e=this.compile();return(await i(this,m).executor.executeQuery(e,i(this,m).queryId)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=cn){const r=await this.executeTakeFirst();if(r===void 0)throw ln(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),u=i(this,m).executor.stream(r,e,i(this,m).queryId);for await(const d of u)yield*d.rows}async explain(e,r){return await new W({...i(this,m),queryNode:C.cloneWithExplain(i(this,m).queryNode,e,r)}).execute()}};let kr=W;m=new WeakMap,Q(kr,"don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");class Eh{constructor(e,r){v(this,Mr,void 0);v(this,Pr,void 0);g(this,Mr,e),g(this,Pr,r)}get expression(){return i(this,Mr)}get alias(){return i(this,Pr)}toOperationNode(){return tr.create(i(this,Mr).toOperationNode(),he.create(i(this,Pr)))}}Mr=new WeakMap,Pr=new WeakMap;const Vs=class{constructor(e){v(this,_r,void 0);g(this,_r,e)}get expressionType(){}as(e){return new Th(this,e)}$castTo(){return new Vs(i(this,_r))}toOperationNode(){return i(this,_r)}};let ge=Vs;_r=new WeakMap;class Th{constructor(e,r){v(this,Fr,void 0);v(this,Vt,void 0);g(this,Fr,e),g(this,Vt,r)}get expression(){return i(this,Fr)}get alias(){return i(this,Vt)}toOperationNode(){return tr.create(i(this,Fr).toOperationNode(),Be(i(this,Vt))?i(this,Vt).toOperationNode():he.create(i(this,Vt)))}}Fr=new WeakMap,Vt=new WeakMap;const et=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?De.cloneWithOperation(t.filter,"And",e):De.create(e)})},cloneWithOrFilter(t,e){return a({...t,filter:t.filter?De.cloneWithOperation(t.filter,"Or",e):De.create(e)})},cloneWithOver(t,e){return a({...t,over:e})}}),Ah=a({is(t){return t.kind==="FunctionNode"},create(t,e){return a({kind:"FunctionNode",func:t,arguments:e})}}),tt=class{constructor(e){v(this,re,void 0);g(this,re,a(e))}get expressionType(){}as(e){return new Sh(this,e)}distinct(){return new tt({...i(this,re),aggregateFunctionNode:et.cloneWithDistinct(i(this,re).aggregateFunctionNode)})}filterWhere(...e){return new tt({...i(this,re),aggregateFunctionNode:et.cloneWithFilter(i(this,re).aggregateFunctionNode,Je(e))})}filterWhereExists(e){return new tt({...i(this,re),aggregateFunctionNode:et.cloneWithFilter(i(this,re).aggregateFunctionNode,Se(e))})}filterWhereNotExists(e){return new tt({...i(this,re),aggregateFunctionNode:et.cloneWithFilter(i(this,re).aggregateFunctionNode,qe(e))})}filterWhereRef(e,r,u){return new tt({...i(this,re),aggregateFunctionNode:et.cloneWithFilter(i(this,re).aggregateFunctionNode,Ce(e,r,u))})}orFilterWhere(...e){return new tt({...i(this,re),aggregateFunctionNode:et.cloneWithOrFilter(i(this,re).aggregateFunctionNode,Je(e))})}orFilterWhereExists(e){return new tt({...i(this,re),aggregateFunctionNode:et.cloneWithOrFilter(i(this,re).aggregateFunctionNode,Se(e))})}orFilterWhereNotExists(e){return new tt({...i(this,re),aggregateFunctionNode:et.cloneWithOrFilter(i(this,re).aggregateFunctionNode,qe(e))})}orFilterWhereRef(e,r,u){return new tt({...i(this,re),aggregateFunctionNode:et.cloneWithOrFilter(i(this,re).aggregateFunctionNode,Ce(e,r,u))})}over(e){const r=Nh();return new tt({...i(this,re),aggregateFunctionNode:et.cloneWithOver(i(this,re).aggregateFunctionNode,(e?e(r):r).toOperationNode())})}$call(e){return e(this)}toOperationNode(){return i(this,re).aggregateFunctionNode}};let pi=tt;re=new WeakMap,Q(pi,"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");class Sh{constructor(e,r){v(this,Qr,void 0);v(this,Ur,void 0);g(this,Qr,e),g(this,Ur,r)}get expression(){return i(this,Qr)}get alias(){return i(this,Ur)}toOperationNode(){return tr.create(i(this,Qr).toOperationNode(),he.create(i(this,Ur)))}}Qr=new WeakMap,Ur=new WeakMap;function na(){const t=(r,u)=>new ge(Ah.create(r,ai(u))),e=(r,u)=>new pi({aggregateFunctionNode:et.create(r,u?ai(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 pi({aggregateFunctionNode:et.create("count",ci(r))})},max(r){return e("max",[r])},min(r){return e("min",[r])},sum(r){return e("sum",[r])}})}class sa{constructor(e){v(this,Vr,void 0);g(this,Vr,a(e))}when(...e){return new oa({...i(this,Vr),node:at.cloneWithWhen(i(this,Vr).node,Rs.create(ta(e)))})}}Vr=new WeakMap;class oa{constructor(e){v(this,jr,void 0);g(this,jr,a(e))}then(e){return new Dh({...i(this,jr),node:at.cloneWithThen(i(this,jr).node,Et(e))})}}jr=new WeakMap;class Dh{constructor(e){v(this,gt,void 0);g(this,gt,a(e))}when(...e){return new oa({...i(this,gt),node:at.cloneWithWhen(i(this,gt).node,Rs.create(ta(e)))})}else(e){return new Rh({...i(this,gt),node:at.cloneWith(i(this,gt).node,{else:Et(e)})})}end(){return new ge(at.cloneWith(i(this,gt).node,{isStatement:!1}))}endCase(){return new ge(at.cloneWith(i(this,gt).node,{isStatement:!0}))}}gt=new WeakMap;class Rh{constructor(e){v(this,$r,void 0);g(this,$r,a(e))}end(){return new ge(at.cloneWith(i(this,$r).node,{isStatement:!1}))}endCase(){return new ge(at.cloneWith(i(this,$r).node,{isStatement:!0}))}}$r=new WeakMap;function aa(t=wn){function e(r,u){return new ge(As(r,u))}return{get fn(){return na()},selectFrom(r){return new kr({queryId:G(),executor:t,queryNode:D.create(Ir(r))})},case(r){return new sa({node:at.create(J(r)?void 0:It(r))})},ref(r){return new ge(Wr(r))},val(r){return new ge(So(r))},cmpr(r,u,d){return new ge(Ls(r,u,d))},bxp(r,u,d){return new ge(Ls(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 ge(wt.createImmediate(!0));if(r.length===1)return new ge(r[0].toOperationNode());let u=ni.create(r[0].toOperationNode(),r[1].toOperationNode());for(let d=2;dmi(e)):[mi(t)]}function mi(t){return _(t)?Lh(t):ua(t)}function Lh(t){const e=" as ";if(t.includes(e)){const[r,u]=t.split(e).map(ha);return tr.create(Ve(r),he.create(u))}else return Ve(t)}function Ve(t){const e=".";if(t.includes(e)){const[r,u]=t.split(e).map(ha);return _t.createWithSchema(r,u)}else return _t.create(t)}function ha(t){return t.trim()}const ca=a({is(t){return t.kind==="AddColumnNode"},create(t){return a({kind:"AddColumnNode",column:t})}}),rr=a({is(t){return t.kind==="AlterColumnNode"},create(t){return a({kind:"AlterColumnNode",column:ce.create(t)})},cloneWith(t,e){return a({...t,...e})}}),le=a({is(t){return t.kind==="ColumnDefinitionNode"},create(t,e){return a({kind:"ColumnDefinitionNode",column:ce.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})}}),la=a({is(t){return t.kind==="DropColumnNode"},create(t){return a({kind:"DropColumnNode",column:ce.create(t)})}}),da=a({is(t){return t.kind==="RenameColumnNode"},create(t,e){return a({kind:"RenameColumnNode",column:ce.create(t),renameTo:ce.create(e)})}}),Ms=a({is(t){return t.kind==="CheckConstraintNode"},create(t,e){return a({kind:"CheckConstraintNode",expression:t,name:e?he.create(e):void 0})}}),Bh=["no action","restrict","cascade","set null","set default"],xn=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 fa(t){return Be(t)?t.toOperationNode():wt.createImmediate(t)}const Wn=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})}}),Mh=a({is(t){return t.kind==="DefaultValueNode"},create(t){return a({kind:"DefaultValueNode",defaultValue:t})}});function On(t){if(Bh.includes(t))return t;throw new Error(`invalid OnModifyForeignAction ${t}`)}const xe=class{constructor(e){v(this,K,void 0);g(this,K,e)}autoIncrement(){return new xe(le.cloneWith(i(this,K),{autoIncrement:!0}))}primaryKey(){return new xe(le.cloneWith(i(this,K),{primaryKey:!0}))}references(e){const r=Wr(e);if(!rn.is(r)||ks.is(r.column))throw new Error(`invalid call references('${e}'). The reference must have format table.column or schema.table.column`);return new xe(le.cloneWith(i(this,K),{references:xn.create(r.table,[r.column])}))}onDelete(e){if(!i(this,K).references)throw new Error("on delete constraint can only be added for foreign keys");return new xe(le.cloneWith(i(this,K),{references:xn.cloneWithOnDelete(i(this,K).references,On(e))}))}onUpdate(e){if(!i(this,K).references)throw new Error("on update constraint can only be added for foreign keys");return new xe(le.cloneWith(i(this,K),{references:xn.cloneWithOnUpdate(i(this,K).references,On(e))}))}unique(){return new xe(le.cloneWith(i(this,K),{unique:!0}))}notNull(){return new xe(le.cloneWith(i(this,K),{notNull:!0}))}unsigned(){return new xe(le.cloneWith(i(this,K),{unsigned:!0}))}defaultTo(e){return new xe(le.cloneWith(i(this,K),{defaultTo:Mh.create(fa(e))}))}check(e){return new xe(le.cloneWith(i(this,K),{check:Ms.create(e.toOperationNode())}))}generatedAlwaysAs(e){return new xe(le.cloneWith(i(this,K),{generated:Wn.createWithExpression(e.toOperationNode())}))}generatedAlwaysAsIdentity(){return new xe(le.cloneWith(i(this,K),{generated:Wn.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new xe(le.cloneWith(i(this,K),{generated:Wn.create({identity:!0,byDefault:!0})}))}stored(){if(!i(this,K).generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new xe(le.cloneWith(i(this,K),{generated:Wn.cloneWith(i(this,K).generated,{stored:!0})}))}modifyFront(e){return new xe(le.cloneWithFrontModifier(i(this,K),e.toOperationNode()))}modifyEnd(e){return new xe(le.cloneWithEndModifier(i(this,K),e.toOperationNode()))}$call(e){return e(this)}toOperationNode(){return i(this,K)}};let Ft=xe;K=new WeakMap,Q(Ft,"don't await ColumnDefinitionBuilder instances directly.");const pa=a({is(t){return t.kind==="ModifyColumnNode"},create(t){return a({kind:"ModifyColumnNode",column:t})}}),Ph=a({is(t){return t.kind==="DataTypeNode"},create(t){return a({kind:"DataTypeNode",dataType:t})}});function Er(t){return Be(t)?t.toOperationNode():Ph.create(t)}const qn=a({is(t){return t.kind==="ForeignKeyConstraintNode"},create(t,e,r,u){return a({kind:"ForeignKeyConstraintNode",columns:t,references:xn.create(e,r),name:u?he.create(u):void 0})},cloneWith(t,e){return a({...t,...e})}}),zn=class{constructor(e){v(this,ur,void 0);g(this,ur,e)}onDelete(e){return new zn(qn.cloneWith(i(this,ur),{onDelete:On(e)}))}onUpdate(e){return new zn(qn.cloneWith(i(this,ur),{onUpdate:On(e)}))}$call(e){return e(this)}toOperationNode(){return i(this,ur)}};let yi=zn;ur=new WeakMap,Q(yi,"don't await ForeignKeyConstraintBuilder instances directly.");const Ps=a({is(t){return t.kind==="AddConstraintNode"},create(t){return a({kind:"AddConstraintNode",constraint:t})}}),ma=a({is(t){return t.kind==="UniqueConstraintNode"},create(t,e){return a({kind:"UniqueConstraintNode",columns:a(t.map(ce.create)),name:e?he.create(e):void 0})}}),Cn=a({is(t){return t.kind==="DropConstraintNode"},create(t){return a({kind:"DropConstraintNode",constraintName:he.create(t)})},cloneWith(t,e){return a({...t,...e})}});class kn{constructor(e){se(this,"alterColumnNode");this.alterColumnNode=e}setDataType(e){return new Ni(rr.cloneWith(this.alterColumnNode,{dataType:Er(e)}))}setDefault(e){return new Ni(rr.cloneWith(this.alterColumnNode,{setDefault:fa(e)}))}dropDefault(){return new Ni(rr.cloneWith(this.alterColumnNode,{dropDefault:!0}))}setNotNull(){return new Ni(rr.cloneWith(this.alterColumnNode,{setNotNull:!0}))}dropNotNull(){return new Ni(rr.cloneWith(this.alterColumnNode,{dropNotNull:!0}))}$call(e){return e(this)}}class Ni extends kn{toOperationNode(){return this.alterColumnNode}}class wi{constructor(e){v(this,lt,void 0);g(this,lt,a(e))}toOperationNode(){return i(this,lt).executor.transformQuery(i(this,lt).node,i(this,lt).queryId)}compile(){return i(this,lt).executor.compileQuery(this.toOperationNode(),i(this,lt).queryId)}async execute(){await i(this,lt).executor.executeQuery(this.compile(),i(this,lt).queryId)}}lt=new WeakMap,Q(wi,"don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`");const Kn=class{constructor(e){v(this,Re,void 0);g(this,Re,a(e))}onDelete(e){return new Kn({...i(this,Re),constraintBuilder:i(this,Re).constraintBuilder.onDelete(e)})}onUpdate(e){return new Kn({...i(this,Re),constraintBuilder:i(this,Re).constraintBuilder.onUpdate(e)})}$call(e){return e(this)}toOperationNode(){return i(this,Re).executor.transformQuery(Ne.cloneWithTableProps(i(this,Re).node,{addConstraint:Ps.create(i(this,Re).constraintBuilder.toOperationNode())}),i(this,Re).queryId)}compile(){return i(this,Re).executor.compileQuery(this.toOperationNode(),i(this,Re).queryId)}async execute(){await i(this,Re).executor.executeQuery(this.compile(),i(this,Re).queryId)}};let In=Kn;Re=new WeakMap,Q(In,"don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`");const Ei=class{constructor(e){v(this,we,void 0);g(this,we,a(e))}ifExists(){return new Ei({...i(this,we),node:Ne.cloneWithTableProps(i(this,we).node,{dropConstraint:Cn.cloneWith(i(this,we).node.dropConstraint,{ifExists:!0})})})}cascade(){return new Ei({...i(this,we),node:Ne.cloneWithTableProps(i(this,we).node,{dropConstraint:Cn.cloneWith(i(this,we).node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new Ei({...i(this,we),node:Ne.cloneWithTableProps(i(this,we).node,{dropConstraint:Cn.cloneWith(i(this,we).node.dropConstraint,{modifier:"restrict"})})})}$call(e){return e(this)}toOperationNode(){return i(this,we).executor.transformQuery(i(this,we).node,i(this,we).queryId)}compile(){return i(this,we).executor.compileQuery(this.toOperationNode(),i(this,we).queryId)}async execute(){await i(this,we).executor.executeQuery(this.compile(),i(this,we).queryId)}};let En=Ei;we=new WeakMap,Q(En,"don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`");class ya{constructor(e){v(this,ie,void 0);g(this,ie,a(e))}renameTo(e){return new wi({...i(this,ie),node:Ne.cloneWithTableProps(i(this,ie).node,{renameTo:Ve(e)})})}setSchema(e){return new wi({...i(this,ie),node:Ne.cloneWithTableProps(i(this,ie).node,{setSchema:he.create(e)})})}alterColumn(e,r){const u=r(new kn(rr.create(e)));return new Qt({...i(this,ie),node:Ne.cloneWithColumnAlteration(i(this,ie).node,u.toOperationNode())})}dropColumn(e){return new Qt({...i(this,ie),node:Ne.cloneWithColumnAlteration(i(this,ie).node,la.create(e))})}renameColumn(e,r){return new Qt({...i(this,ie),node:Ne.cloneWithColumnAlteration(i(this,ie).node,da.create(e,r))})}addColumn(e,r,u=br){const d=u(new Ft(le.create(e,Er(r))));return new Qt({...i(this,ie),node:Ne.cloneWithColumnAlteration(i(this,ie).node,ca.create(d.toOperationNode()))})}modifyColumn(e,r,u=br){const d=u(new Ft(le.create(e,Er(r))));return new Qt({...i(this,ie),node:Ne.cloneWithColumnAlteration(i(this,ie).node,pa.create(d.toOperationNode()))})}addUniqueConstraint(e,r){return new wi({...i(this,ie),node:Ne.cloneWithTableProps(i(this,ie).node,{addConstraint:Ps.create(ma.create(r,e))})})}addCheckConstraint(e,r){return new wi({...i(this,ie),node:Ne.cloneWithTableProps(i(this,ie).node,{addConstraint:Ps.create(Ms.create(r.toOperationNode(),e))})})}addForeignKeyConstraint(e,r,u,d){return new In({...i(this,ie),constraintBuilder:new yi(qn.create(r.map(ce.create),Ve(u),d.map(ce.create),e))})}dropConstraint(e){return new En({...i(this,ie),node:Ne.cloneWithTableProps(i(this,ie).node,{dropConstraint:Cn.create(e)})})}$call(e){return e(this)}call(e){return this.$call(e)}}ie=new WeakMap;const hr=class{constructor(e){v(this,de,void 0);g(this,de,a(e))}alterColumn(e,r){const u=r(new kn(rr.create(e)));return new hr({...i(this,de),node:Ne.cloneWithColumnAlteration(i(this,de).node,u.toOperationNode())})}dropColumn(e){return new hr({...i(this,de),node:Ne.cloneWithColumnAlteration(i(this,de).node,la.create(e))})}renameColumn(e,r){return new hr({...i(this,de),node:Ne.cloneWithColumnAlteration(i(this,de).node,da.create(e,r))})}addColumn(e,r,u=br){const d=u(new Ft(le.create(e,Er(r))));return new hr({...i(this,de),node:Ne.cloneWithColumnAlteration(i(this,de).node,ca.create(d.toOperationNode()))})}modifyColumn(e,r,u=br){const d=u(new Ft(le.create(e,Er(r))));return new hr({...i(this,de),node:Ne.cloneWithColumnAlteration(i(this,de).node,pa.create(d.toOperationNode()))})}toOperationNode(){return i(this,de).executor.transformQuery(i(this,de).node,i(this,de).queryId)}compile(){return i(this,de).executor.compileQuery(this.toOperationNode(),i(this,de).queryId)}async execute(){await i(this,de).executor.executeQuery(this.compile(),i(this,de).queryId)}};let Qt=hr;de=new WeakMap,Q(ya,"don't await AlterTableBuilder instances"),Q(kn,"don't await AlterColumnBuilder instances"),Q(Qt,"don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`");class Na extends Ds{transformValue(e){return{...super.transformValue(e),immediate:!0}}}const bt=class{constructor(e){v(this,H,void 0);g(this,H,a(e))}ifNotExists(){return new bt({...i(this,H),node:Mt.cloneWith(i(this,H).node,{ifNotExists:!0})})}unique(){return new bt({...i(this,H),node:Mt.cloneWith(i(this,H).node,{unique:!0})})}on(e){return new bt({...i(this,H),node:Mt.cloneWith(i(this,H).node,{table:Ve(e)})})}column(e){return new bt({...i(this,H),node:Mt.cloneWithColumns(i(this,H).node,[To(e)])})}columns(e){return new bt({...i(this,H),node:Mt.cloneWithColumns(i(this,H).node,e.map(To))})}expression(e){return new bt({...i(this,H),node:Mt.cloneWithColumns(i(this,H).node,[e.toOperationNode()])})}using(e){return new bt({...i(this,H),node:Mt.cloneWith(i(this,H).node,{using:Ae.createWithSql(e)})})}where(...e){const r=new Na;return new bt({...i(this,H),node:C.cloneWithWhere(i(this,H).node,r.transformNode(Je(e)))})}$call(e){return e(this)}toOperationNode(){return i(this,H).executor.transformQuery(i(this,H).node,i(this,H).queryId)}compile(){return i(this,H).executor.compileQuery(this.toOperationNode(),i(this,H).queryId)}async execute(){await i(this,H).executor.executeQuery(this.compile(),i(this,H).queryId)}};let Tn=bt;H=new WeakMap,Q(Tn,"don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`");const js=class{constructor(e){v(this,ze,void 0);g(this,ze,a(e))}ifNotExists(){return new js({...i(this,ze),node:Wo.cloneWith(i(this,ze).node,{ifNotExists:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,ze).executor.transformQuery(i(this,ze).node,i(this,ze).queryId)}compile(){return i(this,ze).executor.compileQuery(this.toOperationNode(),i(this,ze).queryId)}async execute(){await i(this,ze).executor.executeQuery(this.compile(),i(this,ze).queryId)}};let An=js;ze=new WeakMap,Q(An,"don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`");const _h=a({is(t){return t.kind==="PrimaryKeyConstraintNode"},create(t,e){return a({kind:"PrimaryKeyConstraintNode",columns:a(t.map(ce.create)),name:e?he.create(e):void 0})}});function Fh(t){if(Du.includes(t))return t;throw new Error(`invalid OnCommitAction ${t}`)}const rt=class{constructor(e){v(this,U,void 0);g(this,U,a(e))}temporary(){return new rt({...i(this,U),node:ot.cloneWith(i(this,U).node,{temporary:!0})})}onCommit(e){return new rt({...i(this,U),node:ot.cloneWith(i(this,U).node,{onCommit:Fh(e)})})}ifNotExists(){return new rt({...i(this,U),node:ot.cloneWith(i(this,U).node,{ifNotExists:!0})})}addColumn(e,r,u=br){const d=u(new Ft(le.create(e,Er(r))));return new rt({...i(this,U),node:ot.cloneWithColumn(i(this,U).node,d.toOperationNode())})}addPrimaryKeyConstraint(e,r){return new rt({...i(this,U),node:ot.cloneWithConstraint(i(this,U).node,_h.create(r,e))})}addUniqueConstraint(e,r){return new rt({...i(this,U),node:ot.cloneWithConstraint(i(this,U).node,ma.create(r,e))})}addCheckConstraint(e,r){return new rt({...i(this,U),node:ot.cloneWithConstraint(i(this,U).node,Ms.create(r.toOperationNode(),e))})}addForeignKeyConstraint(e,r,u,d,b=br){const k=b(new yi(qn.create(r.map(ce.create),Ve(u),d.map(ce.create),e)));return new rt({...i(this,U),node:ot.cloneWithConstraint(i(this,U).node,k.toOperationNode())})}modifyFront(e){return new rt({...i(this,U),node:ot.cloneWithFrontModifier(i(this,U).node,e.toOperationNode())})}modifyEnd(e){return new rt({...i(this,U),node:ot.cloneWithEndModifier(i(this,U).node,e.toOperationNode())})}$call(e){return e(this)}call(e){return this.$call(e)}toOperationNode(){return i(this,U).executor.transformQuery(i(this,U).node,i(this,U).queryId)}compile(){return i(this,U).executor.compileQuery(this.toOperationNode(),i(this,U).queryId)}async execute(){await i(this,U).executor.executeQuery(this.compile(),i(this,U).queryId)}};let Sn=rt;U=new WeakMap,Q(Sn,"don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`");const Ti=class{constructor(e){v(this,ke,void 0);g(this,ke,a(e))}on(e){return new Ti({...i(this,ke),node:en.cloneWith(i(this,ke).node,{table:Ve(e)})})}ifExists(){return new Ti({...i(this,ke),node:en.cloneWith(i(this,ke).node,{ifExists:!0})})}cascade(){return new Ti({...i(this,ke),node:en.cloneWith(i(this,ke).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,ke).executor.transformQuery(i(this,ke).node,i(this,ke).queryId)}compile(){return i(this,ke).executor.compileQuery(this.toOperationNode(),i(this,ke).queryId)}async execute(){await i(this,ke).executor.executeQuery(this.compile(),i(this,ke).queryId)}};let Dn=Ti;ke=new WeakMap,Q(Dn,"don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`");const Hn=class{constructor(e){v(this,Pe,void 0);g(this,Pe,a(e))}ifExists(){return new Hn({...i(this,Pe),node:Os.cloneWith(i(this,Pe).node,{ifExists:!0})})}cascade(){return new Hn({...i(this,Pe),node:Os.cloneWith(i(this,Pe).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,Pe).executor.transformQuery(i(this,Pe).node,i(this,Pe).queryId)}compile(){return i(this,Pe).executor.compileQuery(this.toOperationNode(),i(this,Pe).queryId)}async execute(){await i(this,Pe).executor.executeQuery(this.compile(),i(this,Pe).queryId)}};let Rn=Hn;Pe=new WeakMap,Q(Rn,"don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`");const Yn=class{constructor(e){v(this,_e,void 0);g(this,_e,a(e))}ifExists(){return new Yn({...i(this,_e),node:qs.cloneWith(i(this,_e).node,{ifExists:!0})})}cascade(){return new Yn({...i(this,_e),node:qs.cloneWith(i(this,_e).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,_e).executor.transformQuery(i(this,_e).node,i(this,_e).queryId)}compile(){return i(this,_e).executor.compileQuery(this.toOperationNode(),i(this,_e).queryId)}async execute(){await i(this,_e).executor.executeQuery(this.compile(),i(this,_e).queryId)}};let Ln=Yn;_e=new WeakMap,Q(Ln,"don't await DropTableBuilder instances directly. To execute the query you need to call `execute`");const Ut=a({is(t){return t.kind==="CreateViewNode"},create(t){return a({kind:"CreateViewNode",name:Pt.create(t)})},cloneWith(t,e){return a({...t,...e})}});class Qh{constructor(){v(this,Xn,new Na)}transformQuery(e){return i(this,Xn).transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}}Xn=new WeakMap;const jt=class{constructor(e){v(this,ue,void 0);g(this,ue,a(e))}temporary(){return new jt({...i(this,ue),node:Ut.cloneWith(i(this,ue).node,{temporary:!0})})}materialized(){return new jt({...i(this,ue),node:Ut.cloneWith(i(this,ue).node,{materialized:!0})})}ifNotExists(){return new jt({...i(this,ue),node:Ut.cloneWith(i(this,ue).node,{ifNotExists:!0})})}orReplace(){return new jt({...i(this,ue),node:Ut.cloneWith(i(this,ue).node,{orReplace:!0})})}columns(e){return new jt({...i(this,ue),node:Ut.cloneWith(i(this,ue).node,{columns:e.map(Eo)})})}as(e){const r=e.withPlugin(new Qh).toOperationNode();return new jt({...i(this,ue),node:Ut.cloneWith(i(this,ue).node,{as:r})})}$call(e){return e(this)}toOperationNode(){return i(this,ue).executor.transformQuery(i(this,ue).node,i(this,ue).queryId)}compile(){return i(this,ue).executor.compileQuery(this.toOperationNode(),i(this,ue).queryId)}async execute(){await i(this,ue).executor.executeQuery(this.compile(),i(this,ue).queryId)}};let Bn=jt;ue=new WeakMap,Q(Bn,"don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`");const Mn=a({is(t){return t.kind==="DropViewNode"},create(t){return a({kind:"DropViewNode",name:Pt.create(t)})},cloneWith(t,e){return a({...t,...e})}}),Ai=class{constructor(e){v(this,Ie,void 0);g(this,Ie,a(e))}materialized(){return new Ai({...i(this,Ie),node:Mn.cloneWith(i(this,Ie).node,{materialized:!0})})}ifExists(){return new Ai({...i(this,Ie),node:Mn.cloneWith(i(this,Ie).node,{ifExists:!0})})}cascade(){return new Ai({...i(this,Ie),node:Mn.cloneWith(i(this,Ie).node,{cascade:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,Ie).executor.transformQuery(i(this,Ie).node,i(this,Ie).queryId)}compile(){return i(this,Ie).executor.compileQuery(this.toOperationNode(),i(this,Ie).queryId)}async execute(){await i(this,Ie).executor.executeQuery(this.compile(),i(this,Ie).queryId)}};let Pn=Ai;Ie=new WeakMap,Q(Pn,"don't await DropViewBuilder instances directly. To execute the query you need to call `execute`");const wa=a({is(t){return t.kind==="CreateTypeNode"},create(t){return a({kind:"CreateTypeNode",name:t})},cloneWithEnum(t,e){return a({...t,enum:Es.create(e.map(r=>wt.createImmediate(r)))})}}),$s=class{constructor(e){v(this,Ke,void 0);g(this,Ke,a(e))}toOperationNode(){return i(this,Ke).executor.transformQuery(i(this,Ke).node,i(this,Ke).queryId)}asEnum(e){return new $s({...i(this,Ke),node:wa.cloneWithEnum(i(this,Ke).node,e)})}$call(e){return e(this)}compile(){return i(this,Ke).executor.compileQuery(this.toOperationNode(),i(this,Ke).queryId)}async execute(){await i(this,Ke).executor.executeQuery(this.compile(),i(this,Ke).queryId)}};let _n=$s;Ke=new WeakMap,Q(_n,"don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`");const va=a({is(t){return t.kind==="DropTypeNode"},create(t){return a({kind:"DropTypeNode",name:t})},cloneWith(t,e){return a({...t,...e})}}),Js=class{constructor(e){v(this,He,void 0);g(this,He,a(e))}ifExists(){return new Js({...i(this,He),node:va.cloneWith(i(this,He).node,{ifExists:!0})})}$call(e){return e(this)}toOperationNode(){return i(this,He).executor.transformQuery(i(this,He).node,i(this,He).queryId)}compile(){return i(this,He).executor.compileQuery(this.toOperationNode(),i(this,He).queryId)}async execute(){await i(this,He).executor.executeQuery(this.compile(),i(this,He).queryId)}};let Fn=Js;He=new WeakMap,Q(Fn,"don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`");function ga(t){const e=".";if(t.includes(e)){const r=t.split(e).map(Uh);if(r.length===2)return Pt.createWithSchema(r[0],r[1]);throw new Error(`invalid schemable identifier ${t}`)}else return Pt.create(t)}function Uh(t){return t.trim()}const Si=class{constructor(e){v(this,We,void 0);g(this,We,e)}createTable(e){return new Sn({queryId:G(),executor:i(this,We),node:ot.create(Ve(e))})}dropTable(e){return new Ln({queryId:G(),executor:i(this,We),node:qs.create(Ve(e))})}createIndex(e){return new Tn({queryId:G(),executor:i(this,We),node:Mt.create(e)})}dropIndex(e){return new Dn({queryId:G(),executor:i(this,We),node:en.create(e)})}createSchema(e){return new An({queryId:G(),executor:i(this,We),node:Wo.create(e)})}dropSchema(e){return new Rn({queryId:G(),executor:i(this,We),node:Os.create(e)})}alterTable(e){return new ya({queryId:G(),executor:i(this,We),node:Ne.create(Ve(e))})}createView(e){return new Bn({queryId:G(),executor:i(this,We),node:Ut.create(e)})}dropView(e){return new Pn({queryId:G(),executor:i(this,We),node:Mn.create(e)})}createType(e){return new _n({queryId:G(),executor:i(this,We),node:wa.create(ga(e))})}dropType(e){return new Fn({queryId:G(),executor:i(this,We),node:va.create(ga(e))})}withPlugin(e){return new Si(i(this,We).withPlugin(e))}withoutPlugins(){return new Si(i(this,We).withoutPlugins())}withSchema(e){return new Si(i(this,We).withPluginAtFront(new fi(e)))}};let _s=Si;We=new WeakMap;class Vh{ref(e){return new Ku(e)}}class jh{constructor(e){v(this,Jr,void 0);g(this,Jr,e)}async provideConnection(e){const r=await i(this,Jr).acquireConnection();try{return await e(r)}finally{await i(this,Jr).releaseConnection(r)}}}Jr=new WeakMap;const cr=class extends Ho{constructor(r,u,d,b=[]){super(b);v(this,xt,void 0);v(this,Wt,void 0);v(this,At,void 0);g(this,xt,r),g(this,Wt,u),g(this,At,d)}get adapter(){return i(this,Wt)}compileQuery(r){return i(this,xt).compileQuery(r)}provideConnection(r){return i(this,At).provideConnection(r)}withPlugins(r){return new cr(i(this,xt),i(this,Wt),i(this,At),[...this.plugins,...r])}withPlugin(r){return new cr(i(this,xt),i(this,Wt),i(this,At),[...this.plugins,r])}withPluginAtFront(r){return new cr(i(this,xt),i(this,Wt),i(this,At),[r,...this.plugins])}withConnectionProvider(r){return new cr(i(this,xt),i(this,Wt),r,[...this.plugins])}withoutPlugins(){return new cr(i(this,xt),i(this,Wt),i(this,At),[])}};let Fs=cr;xt=new WeakMap,Wt=new WeakMap,At=new WeakMap;function ba(){return typeof performance<"u"&&Xe(performance.now)?performance.now():Date.now()}class $h{constructor(e,r){v(this,Zn);v(this,es);v(this,ts);v(this,rs);v(this,Ri);v(this,dt,void 0);v(this,$t,void 0);v(this,St,void 0);v(this,lr,void 0);v(this,Di,new WeakSet);g(this,dt,e),g(this,$t,r)}async init(){i(this,St)||g(this,St,i(this,dt).init().catch(e=>(g(this,St,void 0),Promise.reject(e)))),await i(this,St)}async acquireConnection(){await this.init();const e=await i(this,dt).acquireConnection();return i(this,Di).has(e)||(X(this,Zn,qu).call(this)&&X(this,es,Cu).call(this,e),i(this,Di).add(e)),e}async releaseConnection(e){await i(this,dt).releaseConnection(e)}beginTransaction(e,r){return i(this,dt).beginTransaction(e,r)}commitTransaction(e){return i(this,dt).commitTransaction(e)}rollbackTransaction(e){return i(this,dt).rollbackTransaction(e)}async destroy(){i(this,St)&&(await i(this,St),i(this,lr)||g(this,lr,i(this,dt).destroy().catch(e=>(g(this,lr,void 0),Promise.reject(e)))),await i(this,lr))}}dt=new WeakMap,$t=new WeakMap,St=new WeakMap,lr=new WeakMap,Di=new WeakMap,Zn=new WeakSet,qu=function(){return i(this,$t).isLevelEnabled("query")||i(this,$t).isLevelEnabled("error")},es=new WeakSet,Cu=function(e){const r=e.executeQuery;e.executeQuery=async u=>{const d=ba();try{return await r.call(e,u)}catch(b){throw await X(this,ts,ku).call(this,b,u,d),b}finally{await X(this,rs,Iu).call(this,u,d)}}},ts=new WeakSet,ku=async function(e,r,u){await i(this,$t).error(()=>({level:"error",error:e,query:r,queryDurationMillis:X(this,Ri,vo).call(this,u)}))},rs=new WeakSet,Iu=async function(e,r){await i(this,$t).query(()=>({level:"query",query:e,queryDurationMillis:X(this,Ri,vo).call(this,r)}))},Ri=new WeakSet,vo=function(e){return ba()-e};class xa{constructor(e){v(this,is);v(this,Li,void 0);v(this,Jt,void 0);g(this,Li,e)}async provideConnection(e){for(;i(this,Jt);)await i(this,Jt);const r=X(this,is,Eu).call(this,e);return g(this,Jt,r.then(()=>{g(this,Jt,void 0)}).catch(()=>{g(this,Jt,void 0)})),r}}Li=new WeakMap,Jt=new WeakMap,is=new WeakSet,Eu=async function(e){return await e(i(this,Li))};const Jh=["read uncommitted","read committed","repeatable read","serializable"];a(["query","error"]);class Gh{constructor(e){v(this,Gt,void 0);v(this,dr,void 0);Xe(e)?(g(this,dr,e),g(this,Gt,a({query:!0,error:!0}))):(g(this,dr,zh),g(this,Gt,a({query:e.includes("query"),error:e.includes("error")})))}isLevelEnabled(e){return i(this,Gt)[e]}async query(e){i(this,Gt).query&&await i(this,dr).call(this,e())}async error(e){i(this,Gt).error&&await i(this,dr).call(this,e())}}Gt=new WeakMap,dr=new WeakMap;function zh(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 Kh(t){return Nt(t)&&Xe(t.compile)}const Gr=class extends Nn{constructor(r){let u,d;if(Hh(r))u={executor:r.executor},d={...r};else{const b=r.dialect,k=b.createDriver(),I=b.createQueryCompiler(),j=b.createAdapter(),c=new Gh(r.log??[]),Fe=new $h(k,c),Qe=new jh(Fe),P=new Fs(I,j,Qe,r.plugins??[]);u={executor:P},d={config:r,executor:P,dialect:b,driver:Fe}}super(u);v(this,Ee,void 0);g(this,Ee,a(d))}get schema(){return new _s(i(this,Ee).executor)}get dynamic(){return new Vh}get introspection(){return i(this,Ee).dialect.createIntrospector(this.withoutPlugins())}case(r){return new sa({node:at.create(J(r)?void 0:gn(r))})}get fn(){return na()}transaction(){return new Qn({...i(this,Ee)})}connection(){return new Wa({...i(this,Ee)})}withPlugin(r){return new Gr({...i(this,Ee),executor:i(this,Ee).executor.withPlugin(r)})}withoutPlugins(){return new Gr({...i(this,Ee),executor:i(this,Ee).executor.withoutPlugins()})}withSchema(r){return new Gr({...i(this,Ee),executor:i(this,Ee).executor.withPluginAtFront(new fi(r))})}withTables(){return new Gr({...i(this,Ee)})}async destroy(){await i(this,Ee).driver.destroy()}get isTransaction(){return!1}getExecutor(){return i(this,Ee).executor}executeQuery(r,u=G()){const d=Kh(r)?r.compile():r;return this.getExecutor().executeQuery(d,u)}};let vi=Gr;Ee=new WeakMap;const zr=class extends vi{constructor(r){super(r);v(this,ft,void 0);g(this,ft,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({...i(this,ft),executor:i(this,ft).executor.withPlugin(r)})}withoutPlugins(){return new zr({...i(this,ft),executor:i(this,ft).executor.withoutPlugins()})}withSchema(r){return new zr({...i(this,ft),executor:i(this,ft).executor.withPluginAtFront(new fi(r))})}withTables(){return new zr({...i(this,ft)})}};let Qs=zr;ft=new WeakMap;function Hh(t){return Nt(t)&&Nt(t.config)&&Nt(t.driver)&&Nt(t.executor)&&Nt(t.dialect)}class Wa{constructor(e){v(this,fr,void 0);g(this,fr,a(e))}async execute(e){return i(this,fr).executor.provideConnection(async r=>{const u=i(this,fr).executor.withConnectionProvider(new xa(r)),d=new vi({...i(this,fr),executor:u});return await e(d)})}}fr=new WeakMap,Q(Wa,"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method");const Gs=class{constructor(e){v(this,pt,void 0);g(this,pt,a(e))}setIsolationLevel(e){return new Gs({...i(this,pt),isolationLevel:e})}async execute(e){const{isolationLevel:r,...u}=i(this,pt),d={isolationLevel:r};return Yh(d),i(this,pt).executor.provideConnection(async b=>{const k=i(this,pt).executor.withConnectionProvider(new xa(b)),I=new Qs({...u,executor:k});try{await i(this,pt).driver.beginTransaction(b,d);const j=await e(I);return await i(this,pt).driver.commitTransaction(b),j}catch(j){throw await i(this,pt).driver.rollbackTransaction(b),j}})}};let Qn=Gs;pt=new WeakMap,Q(Qn,"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method");function Yh(t){if(t.isolationLevel&&!Jh.includes(t.isolationLevel))throw new Error(`invalid transaction isolation level ${t.isolationLevel}`)}const ns=class{constructor(e){v(this,Kr);v(this,Bi);v(this,Mi);v(this,je,void 0);g(this,je,a(e))}get expressionType(){}as(e){return new Xh(this,e)}$castTo(){return new ns({...i(this,je)})}castTo(){return this.$castTo()}withPlugin(e){return new ns({...i(this,je),plugins:i(this,je).plugins!==void 0?a([...i(this,je).plugins,e]):a([e])})}toOperationNode(){return X(this,Bi,go).call(this,X(this,Kr,Ws).call(this))}compile(e){return X(this,Mi,bo).call(this,X(this,Kr,Ws).call(this,e))}async execute(e){const r=X(this,Kr,Ws).call(this,e);return r.executeQuery(X(this,Mi,bo).call(this,r),i(this,je).queryId)}};let ut=ns;je=new WeakMap,Kr=new WeakSet,Ws=function(e){const r=e!==void 0?e.getExecutor():wn;return i(this,je).plugins!==void 0?r.withPlugins(i(this,je).plugins):r},Bi=new WeakSet,go=function(e){return e.transformQuery(i(this,je).rawNode,i(this,je).queryId)},Mi=new WeakSet,bo=function(e){return e.compileQuery(X(this,Bi,go).call(this,e),i(this,je).queryId)},Q(ut,"don't await RawBuilder instances directly. To execute the query you need to call `execute`");class Xh{constructor(e,r){v(this,Hr,void 0);v(this,zt,void 0);g(this,Hr,e),g(this,zt,r)}get expression(){return i(this,Hr)}get alias(){return i(this,zt)}toOperationNode(){return tr.create(i(this,Hr).toOperationNode(),Be(i(this,zt))?i(this,zt).toOperationNode():he.create(i(this,zt)))}}Hr=new WeakMap,zt=new WeakMap;const Ge=Object.assign((t,...e)=>new ut({queryId:G(),rawNode:Ae.create(t,(e==null?void 0:e.map(Et))??[])}),{ref(t){return new ut({queryId:G(),rawNode:Ae.createWithChild(Wr(t))})},val(t){return new ut({queryId:G(),rawNode:Ae.createWithChild(Et(t))})},value(t){return this.val(t)},table(t){return new ut({queryId:G(),rawNode:Ae.createWithChild(Ve(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",new ut({queryId:G(),rawNode:Ae.create(e,t.map(he.create))})},lit(t){return new ut({queryId:G(),rawNode:Ae.createWithChild(wt.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return new ut({queryId:G(),rawNode:Ae.createWithSql(t)})},join(t,e=Ge`, `){const r=new Array(2*t.length-1),u=e.toOperationNode();for(let d=0;d{this.nodeStack.push(e),i(this,ss)[e.kind](e),this.nodeStack.pop()})}get parentNode(){return this.nodeStack[this.nodeStack.length-2]}}ss=new WeakMap;class ec extends Zh{constructor(){super(...arguments);v(this,Yr,"");v(this,pr,[])}get numParameters(){return i(this,pr).length}compileQuery(r){return g(this,Yr,""),g(this,pr,[]),this.visitNode(r),a({query:r,sql:this.getSql(),parameters:[...i(this,pr)]})}getSql(){return i(this,Yr)}visitSelectQuery(r){const u=this.parentNode!==void 0&&!vt.is(this.parentNode)&&!Ut.is(this.parentNode)&&!ia.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(tc[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 Cs.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,Yr,i(this,Yr)+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){i(this,pr).push(r)}appendImmediateValue(r){if(_(r))this.append(`'${r}'`);else if(ye(r)||ri(r))this.append(r.toString());else if(xo(r))this.append("null");else if(Au(r))this.appendImmediateValue(r.toISOString());else if(Su(r))this.appendImmediateValue(r.toString());else throw new Error(`invalid immediate value ${r}`)}}Yr=new WeakMap,pr=new WeakMap;const tc=a({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),rc=a({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral"}),Tr=a({raw(t){return a({sql:t,query:Ae.createWithSql(t),parameters:a([])})}}),ic=/"/g;class nc extends ec{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(e){return e.replace(ic,'""')}visitDefaultInsertValue(e){this.append("null")}}const sc="kysely_migration",oc="kysely_migration_lock";a({__noMigrations__:!0});class ac{constructor(e){v(this,os);v(this,Xr,void 0);g(this,Xr,e)}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let r=i(this,Xr).selectFrom("sqlite_schema").where("type","in",["table","view"]).where("name","not like","sqlite_%").select("name").orderBy("name").$castTo();e.withInternalKyselyTables||(r=r.where("name","!=",sc).where("name","!=",oc));const u=await r.execute();return Promise.all(u.map(({name:d})=>X(this,os,Tu).call(this,d)))}async getMetadata(e){return{tables:await this.getTables(e)}}}Xr=new WeakMap,os=new WeakSet,Tu=async function(e){var k,I,j,c,Fe,Qe;const r=i(this,Xr),u=await r.selectFrom("sqlite_master").where("name","=",e).select(["sql","type"]).$castTo().executeTakeFirstOrThrow(),d=(Qe=(Fe=(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:Fe[0])==null?void 0:Qe.replace(/["`]/g,""),b=await r.selectFrom(Ge`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 uc{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}}var hc=class{createQueryCompiler(){return new nc}createAdapter(){return new uc}createIntrospector(t){return new ac(t)}},cc=(ka=class{constructor(){v(this,Pi,new lc);se(this,"connection")}async acquireConnection(){return await i(this,Pi).lock(),this.connection}async beginTransaction(t){await t.executeQuery(Tr.raw("begin"))}async commitTransaction(t){await t.executeQuery(Tr.raw("commit"))}async rollbackTransaction(t){await t.executeQuery(Tr.raw("rollback"))}async releaseConnection(){i(this,Pi).unlock()}},Pi=new WeakMap,ka),lc=class{constructor(){se(this,"promise");se(this,"resolve")}async lock(){for(;this.promise;)await this.promise;this.promise=new Promise(t=>{this.resolve=t})}unlock(){const t=this.resolve;this.promise=void 0,this.resolve=void 0,t==null||t()}},dc=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 fc({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 pc=class extends cc{constructor(e){super();se(this,"config");se(this,"db");this.config=e}async init(){var e,r,u,d;if(this.db=typeof this.config.database=="function"?await this.config.database():this.config.database,!this.db)throw new Error("no database");this.connection=new mc(this.db,(e=this.config.onWrite)==null?void 0:e.func,(r=this.config.onWrite)==null?void 0:r.isThrottle,(u=this.config.onWrite)==null?void 0:u.maxCalls,(d=this.config.onWrite)==null?void 0:d.delay),this.config.onCreateConnection&&await this.config.onCreateConnection(this.connection)}async beginTransaction(e){await e.executeQuery(Tr.raw("begin")),e.transactionNum++}async commitTransaction(e){await e.executeQuery(Tr.raw("commit")),e.transactionNum--}async rollbackTransaction(e){await e.executeQuery(Tr.raw("rollback")),e.transactionNum--}async destroy(){var e;(e=this.db)==null||e.close()}},mc=class extends dc{constructor(e,r,u=!1,d=1e3,b=2e3){super();se(this,"db");se(this,"onWrite");se(this,"transactionNum",0);this.db=e,this.onWrite=r?u?fc({func:r,maxCalls:d,delay:b}):r:void 0}query(e,r){const u=this.db.prepare(e);u.bind(r);const d=[];for(;u.step();)d.push(u.getAsObject());return u.free(),d}exec(e,r){this.db.run(e,r);const u=BigInt(this.query("SELECT last_insert_rowid() as id")[0].id),d=BigInt(this.db.getRowsModified());return this.transactionNum===0&&this.onWrite&&this.onWrite(this.db.export()),{numAffectedRows:d,insertId:u}}},yc=(Ia=class extends hc{constructor(e){super();v(this,_i,void 0);g(this,_i,e)}createDriver(){return new pc(i(this,_i))}},_i=new WeakMap,Ia);function Nc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function wc(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 Oa={exports:{}},vc={},gc=Object.freeze({__proto__:null,default:vc}),Un=wc(gc);(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(n){k(new Error(n)),j&&j(n)},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 n(f,w){switch(typeof w){case"boolean":Il(f,w?1:0);break;case"number":ql(f,w);break;case"string":Cl(f,w,-1,-1);break;case"object":if(w===null)gu(f);else if(w.length!=null){var O=mo(w);kl(f,O,w.length,-1),gs(O)}else xs(f,"Wrong API use : tried to return a value of an unknown type ("+w+").",-1);break;default:gu(f)}}function s(f,w){for(var O=[],E=0;E>>0),f!=null){var w=this.filename,O="/",E=w;if(O&&(O=typeof O=="string"?O:$i(O),E=w?Lt(O+"/"+w):O),w=au(!0,!0),E=ds(E,(w!==void 0?w: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}ps(E,w|146),O=ti(E,577),nu(O,f,0,f.length,0),oo(O),ps(E,w)}}this.handleError(A(this.filename,p)),this.db=Rt(p,"i32"),El(this.db),this.Za={},this.Na={}}var p=er(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"]),me=y("sqlite3_changes","number",["number"]),Bt=y("sqlite3_prepare_v2","number",["number","string","number","number","number"]),mu=y("sqlite3_sql","string",["number"]),il=y("sqlite3_normalized_sql","string",["number"]),yu=y("sqlite3_prepare_v2","number",["number","number","number","number","number"]),nl=y("sqlite3_bind_text","number",["number","number","number","number","number"]),Nu=y("sqlite3_bind_blob","number",["number","number","number","number","number"]),sl=y("sqlite3_bind_double","number",["number","number","number"]),ol=y("sqlite3_bind_int","number",["number","number","number"]),al=y("sqlite3_bind_parameter_index","number",["number","string"]),ul=y("sqlite3_step","number",["number"]),hl=y("sqlite3_errmsg","string",["number"]),cl=y("sqlite3_column_count","number",["number"]),ll=y("sqlite3_data_count","number",["number"]),dl=y("sqlite3_column_double","number",["number","number"]),wu=y("sqlite3_column_text","string",["number","number"]),fl=y("sqlite3_column_blob","number",["number","number"]),pl=y("sqlite3_column_bytes","number",["number","number"]),ml=y("sqlite3_column_type","number",["number","number"]),yl=y("sqlite3_column_name","string",["number","number"]),Nl=y("sqlite3_reset","number",["number"]),wl=y("sqlite3_clear_bindings","number",["number"]),vl=y("sqlite3_finalize","number",["number"]),vu=y("sqlite3_create_function_v2","number","number string number number number number number number number".split(" ")),gl=y("sqlite3_value_type","number",["number"]),bl=y("sqlite3_value_bytes","number",["number"]),xl=y("sqlite3_value_text","string",["number"]),Wl=y("sqlite3_value_blob","number",["number"]),Ol=y("sqlite3_value_double","number",["number"]),ql=y("sqlite3_result_double","",["number","number"]),gu=y("sqlite3_result_null","",["number"]),Cl=y("sqlite3_result_text","",["number","string","number","number"]),kl=y("sqlite3_result_blob","",["number","number","number","number"]),Il=y("sqlite3_result_int","",["number","number"]),xs=y("sqlite3_result_error","",["number","string","number"]),bu=y("sqlite3_aggregate_context","number",["number","number"]),El=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=ul(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),dl(this.La,f)},o.prototype.Cb=function(f){if(f==null&&(f=this.Ja,this.Ja+=1),f=wu(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),wu(this.La,f)},o.prototype.getBlob=function(f){f==null&&(f=this.Ja,this.Ja+=1);var w=pl(this.La,f);f=fl(this.La,f);for(var O=new Uint8Array(w),E=0;E{us||(as=Un,us=Un)},Fi=function(n,s){return zs(),n=us.normalize(n),as.readFileSync(n,s?void 0:"utf8")},mt=n=>(n=Fi(n,!0),n.buffer||(n=new Uint8Array(n)),n),Dt=(n,s,o)=>{zs(),n=us.normalize(n),as.readFile(n,function(h,l){h?o(h):s(l.buffer)})},1{var s=new XMLHttpRequest;return s.open("GET",n,!1),s.send(null),s.responseText},Le&&(mt=n=>{var s=new XMLHttpRequest;return s.open("GET",n,!1),s.responseType="arraybuffer",s.send(null),new Uint8Array(s.response)}),Dt=(n,s,o)=>{var h=new XMLHttpRequest;h.open("GET",n,!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 Ea=c.print||console.log.bind(console),mr=c.printErr||console.warn.bind(console);Object.assign(c,Fe),Fe=null,c.thisProgram&&(Qe=c.thisProgram);var Qi;c.wasmBinary&&(Qi=c.wasmBinary),c.noExitRuntime,typeof WebAssembly!="object"&&Ht("no native wasm support detected");var Ks,Ta=!1,Aa=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Ui(n,s,o){var h=s+o;for(o=s;n[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 Oe(n,s){return n?Ui(Ot,n,s):""}function yr(n,s,o,h){if(!(0=y){var A=n.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 Zr(n){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 Hs,ve,Ot,hs,T,fe,Ys,Xs;function Sa(){var n=Ks.buffer;Hs=n,c.HEAP8=ve=new Int8Array(n),c.HEAP16=hs=new Int16Array(n),c.HEAP32=T=new Int32Array(n),c.HEAPU8=Ot=new Uint8Array(n),c.HEAPU16=new Uint16Array(n),c.HEAPU32=fe=new Uint32Array(n),c.HEAPF32=Ys=new Float32Array(n),c.HEAPF64=Xs=new Float64Array(n)}var Kt,Da=[],Ra=[],La=[];function Uc(){var n=c.preRun.shift();Da.unshift(n)}var Nr=0,Vi=null;function Ht(n){throw c.onAbort&&c.onAbort(n),n="Aborted("+n+")",mr(n),Ta=!0,new WebAssembly.RuntimeError(n+". Build with -sASSERTIONS for more info.")}function Ba(){return it.startsWith("data:application/octet-stream;base64,")}var it;if(it="sql-wasm.wasm",!Ba()){var Ma=it;it=c.locateFile?c.locateFile(Ma,Te):Te+Ma}function Pa(){var n=it;try{if(n==it&&Qi)return new Uint8Array(Qi);if(mt)return mt(n);throw"both async and sync fetching of the wasm failed"}catch(s){Ht(s)}}function Vc(){if(!Qi&&(P||Le)){if(typeof fetch=="function"&&!it.startsWith("file://"))return fetch(it,{credentials:"same-origin"}).then(function(n){if(!n.ok)throw"failed to load wasm binary file at '"+it+"'";return n.arrayBuffer()}).catch(function(){return Pa()});if(Dt)return new Promise(function(n,s){Dt(it,function(o){n(new Uint8Array(o))},s)})}return Promise.resolve().then(function(){return Pa()})}var S,pe;function Zs(n){for(;0>0];case"i8":return ve[n>>0];case"i16":return hs[n>>1];case"i32":return T[n>>2];case"i64":return T[n>>2];case"float":return Ys[n>>2];case"double":return Xs[n>>3];case"*":return fe[n>>2];default:Ht("invalid type for getValue: "+s)}return null}function ji(n){var s="i32";switch(s.endsWith("*")&&(s="*"),s){case"i1":ve[n>>0]=0;break;case"i8":ve[n>>0]=0;break;case"i16":hs[n>>1]=0;break;case"i32":T[n>>2]=0;break;case"i64":pe=[0,(S=0,1<=+Math.abs(S)?0>>0:~~+Math.ceil((S-+(~~S>>>0))/4294967296)>>>0:0)],T[n>>2]=pe[0],T[n+4>>2]=pe[1];break;case"float":Ys[n>>2]=0;break;case"double":Xs[n>>3]=0;break;case"*":fe[n>>2]=0;break;default:Ht("invalid type for setValue: "+s)}}var eo=(n,s)=>{for(var o=0,h=n.length-1;0<=h;h--){var l=n[h];l==="."?n.splice(h,1):l===".."?(n.splice(h,1),o++):o&&(n.splice(h,1),o--)}if(s)for(;o;o--)n.unshift("..");return n},Lt=n=>{var s=n.charAt(0)==="/",o=n.substr(-1)==="/";return(n=eo(n.split("/").filter(h=>!!h),!s).join("/"))||s||(n="."),n&&o&&(n+="/"),(s?"/":"")+n},jc=n=>{var s=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(n).slice(1);return n=s[0],s=s[1],!n&&!s?".":(s&&(s=s.substr(0,s.length-1)),n+s)},cs=n=>{if(n==="/")return"/";n=Lt(n),n=n.replace(/\/$/,"");var s=n.lastIndexOf("/");return s===-1?n:n.substr(s+1)};function $c(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var n=new Uint8Array(1);return()=>(crypto.getRandomValues(n),n[0])}if(Y)try{var s=Un;return()=>s.randomBytes(1)[0]}catch{}return()=>Ht("randomDevice")}function ls(){for(var n="",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"";n=s+"/"+n,s=s.charAt(0)==="/"}return n=eo(n.split("/").filter(h=>!!h),!s).join("/"),(s?"/":"")+n||"."}function _a(n,s){var o=Array(Zr(n)+1);return n=yr(n,o,0,o.length),s&&(o.length=n),o}var Fa=[];function Qa(n,s){Fa[n]={input:[],output:[],Xa:s},no(n,Jc)}var Jc={open:function(n){var s=Fa[n.node.rdev];if(!s)throw new N(43);n.tty=s,n.seekable=!1},close:function(n){n.tty.Xa.fsync(n.tty)},fsync:function(n){n.tty.Xa.fsync(n.tty)},read:function(n,s,o,h){if(!n.tty||!n.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=n.Ia,n.Ia=new Uint8Array(s),0=n.node.Ma)return 0;if(n=Math.min(n.node.Ma-l,h),8s)throw new N(28);return s},lb:function(n,s,o){R.qb(n.node,s+o),n.node.Ma=Math.max(n.node.Ma,s+o)},bb:function(n,s,o,h,l){if((n.node.mode&61440)!==32768)throw new N(43);if(n=n.node.Ia,l&2||n.buffer!==Hs){if((0{if(n=ls("/",n),!n)return{path:"",node:null};if(s=Object.assign({rb:!0,kb:0},s),8!!y),!1);for(var o=to,h="/",l=0;l{for(var s;;){if(n===n.parent)return n=n.Ra.ub,s?n[n.length-1]!=="/"?n+"/"+s:n+s:n;s=s?n.name+"/"+s:n.name,n=n.parent}},io=(n,s)=>{for(var o=0,h=0;h>>0)%Xt.length},ja=n=>{var s=io(n.parent.id,n.name);if(Xt[s]===n)Xt[s]=n.Wa;else for(s=Xt[s];s;){if(s.Wa===n){s.Wa=n.Wa;break}s=s.Wa}},wr=(n,s)=>{var o;if(o=(o=ei(n,"x"))?o:n.Ga.lookup?0:2)throw new N(o,n);for(o=Xt[io(n.id,s)];o;o=o.Wa){var h=o.name;if(o.parent.id===n.id&&h===s)return o}return n.Ga.lookup(n,s)},$a=(n,s,o,h)=>(n=new lu(n,s,o,h),s=io(n.parent.id,n.name),n.Wa=Xt[s],Xt[s]=n),Hc={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Ja=n=>{var s=["r","w","rw"][n&3];return n&512&&(s+="w"),s},ei=(n,s)=>{if(Va)return 0;if(!s.includes("r")||n.mode&292){if(s.includes("w")&&!(n.mode&146)||s.includes("x")&&!(n.mode&73))return 2}else return 2;return 0},Ga=(n,s)=>{try{return wr(n,s),20}catch{}return ei(n,"wx")},za=(n,s,o)=>{try{var h=wr(n,s)}catch(l){return l.Ka}if(n=ei(n,"wx"))return n;if(o){if((h.mode&61440)!==16384)return 54;if(h===h.parent||$i(h)==="/")return 10}else if((h.mode&61440)===16384)return 31;return 0},Yc=(n=0)=>{for(;4096>=n;n++)if(!Yt[n])return n;throw new N(33)},Ka=(n,s)=>(zi||(zi=function(){this.$a={}},zi.prototype={},Object.defineProperties(zi.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}}})),n=Object.assign(new zi,n),s=Yc(s),n.fd=s,Yt[s]=n),Xc={open:n=>{n.Ha=Ua[n.node.rdev].Ha,n.Ha.open&&n.Ha.open(n)},Ta:()=>{throw new N(70)}},no=(n,s)=>{Ua[n]={Ha:s}},Ha=(n,s)=>{var o=s==="/",h=!s;if(o&&to)throw new N(10);if(!o&&!h){var l=$e(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:n,Kb:{},ub:s,Eb:[]},n=n.Ra(s),n.Ra=s,s.root=n,o?to=n:l&&(l.Va=s,l.Ra&&l.Ra.Eb.push(s))},ds=(n,s,o)=>{var h=$e(n,{parent:!0}).node;if(n=cs(n),!n||n==="."||n==="..")throw new N(28);var l=Ga(h,n);if(l)throw new N(l);if(!h.Ga.ab)throw new N(63);return h.Ga.ab(h,n,s,o)},qt=(n,s)=>ds(n,(s!==void 0?s:511)&1023|16384,0),fs=(n,s,o)=>{typeof o>"u"&&(o=s,s=438),ds(n,s|8192,o)},so=(n,s)=>{if(!ls(n))throw new N(44);var o=$e(s,{parent:!0}).node;if(!o)throw new N(44);s=cs(s);var h=Ga(o,s);if(h)throw new N(h);if(!o.Ga.symlink)throw new N(63);o.Ga.symlink(o,s,n)},Ya=n=>{var s=$e(n,{parent:!0}).node;n=cs(n);var o=wr(s,n),h=za(s,n,!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,n),ja(o)},Xa=n=>{var s=$e(n,{parent:!0}).node;if(!s)throw new N(44);n=cs(n);var o=wr(s,n),h=za(s,n,!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,n),ja(o)},Za=n=>{if(n=$e(n).node,!n)throw new N(44);if(!n.Ga.readlink)throw new N(28);return ls($i(n.parent),n.Ga.readlink(n))},Ji=(n,s)=>{if(n=$e(n,{Sa:!s}).node,!n)throw new N(44);if(!n.Ga.Pa)throw new N(63);return n.Ga.Pa(n)},eu=n=>Ji(n,!0),ps=(n,s)=>{if(n=typeof n=="string"?$e(n,{Sa:!0}).node:n,!n.Ga.Oa)throw new N(63);n.Ga.Oa(n,{mode:s&4095|n.mode&-4096,timestamp:Date.now()})},tu=(n,s)=>{if(0>s)throw new N(28);if(n=typeof n=="string"?$e(n,{Sa:!0}).node:n,!n.Ga.Oa)throw new N(63);if((n.mode&61440)===16384)throw new N(31);if((n.mode&61440)!==32768)throw new N(28);var o=ei(n,"w");if(o)throw new N(o);n.Ga.Oa(n,{size:s,timestamp:Date.now()})},ti=(n,s,o)=>{if(n==="")throw new N(44);if(typeof s=="string"){var h=Hc[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 n=="object")var l=n;else{n=Lt(n);try{l=$e(n,{Sa:!(s&131072)}).node}catch{}}if(h=!1,s&64)if(l){if(s&128)throw new N(20)}else l=ds(n,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&&(Ja(s)!=="r"||s&512)?31:ei(l,Ja(s)):44))throw new N(o);return s&512&&!h&&tu(l,0),s&=-131713,l=Ka({node:l,path:$i(l),flags:s,seekable:!0,position:0,Ha:l.Ha,Ib:[],error:!1}),l.Ha.open&&l.Ha.open(l),!c.logReadFiles||s&1||(ms||(ms={}),n in ms||(ms[n]=1)),l},oo=n=>{if(n.fd===null)throw new N(8);n.hb&&(n.hb=null);try{n.Ha.close&&n.Ha.close(n)}catch(s){throw s}finally{Yt[n.fd]=null}n.fd=null},ru=(n,s,o)=>{if(n.fd===null)throw new N(8);if(!n.seekable||!n.Ha.Ta)throw new N(70);if(o!=0&&o!=1&&o!=2)throw new N(28);n.position=n.Ha.Ta(n,s,o),n.Ib=[]},iu=(n,s,o,h,l)=>{if(0>h||0>l)throw new N(28);if(n.fd===null)throw new N(8);if((n.flags&2097155)===1)throw new N(8);if((n.node.mode&61440)===16384)throw new N(31);if(!n.Ha.read)throw new N(28);var p=typeof l<"u";if(!p)l=n.position;else if(!n.seekable)throw new N(70);return s=n.Ha.read(n,s,o,h,l),p||(n.position+=s),s},nu=(n,s,o,h,l)=>{if(0>h||0>l)throw new N(28);if(n.fd===null)throw new N(8);if(!(n.flags&2097155))throw new N(8);if((n.node.mode&61440)===16384)throw new N(31);if(!n.Ha.write)throw new N(28);n.seekable&&n.flags&1024&&ru(n,0,2);var p=typeof l<"u";if(!p)l=n.position;else if(!n.seekable)throw new N(70);return s=n.Ha.write(n,s,o,h,l,void 0),p||(n.position+=s),s},Zc=n=>{var s,o=ti(n,o||0);n=Ji(n).size;var h=new Uint8Array(n);return iu(o,h,0,n,0),s=h,oo(o),s},su=()=>{N||(N=function(n,s){this.node=s,this.Hb=function(o){this.Ka=o},this.Hb(n),this.message="FS error"},N.prototype=Error(),N.prototype.constructor=N,[44].forEach(n=>{ro[n]=new N(n),ro[n].stack=""}))},ou,au=(n,s)=>{var o=0;return n&&(o|=365),s&&(o|=146),o},Gi=(n,s,o)=>{n=Lt("/dev/"+n);var h=au(!!s,!!o);ao||(ao=64);var l=ao++<<8|0;no(l,{open:p=>{p.seekable=!1},close:()=>{o&&o.buffer&&o.buffer.length&&o(10)},read:(p,y,A,V)=>{for(var F=0,me=0;me{for(var F=0;F>2]=h.dev,T[o+8>>2]=h.ino,T[o+12>>2]=h.mode,fe[o+16>>2]=h.nlink,T[o+20>>2]=h.uid,T[o+24>>2]=h.gid,T[o+28>>2]=h.rdev,pe=[h.size>>>0,(S=h.size,1<=+Math.abs(S)?0>>0:~~+Math.ceil((S-+(~~S>>>0))/4294967296)>>>0:0)],T[o+40>>2]=pe[0],T[o+44>>2]=pe[1],T[o+48>>2]=4096,T[o+52>>2]=h.blocks,pe=[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]=pe[0],T[o+60>>2]=pe[1],fe[o+64>>2]=0,pe=[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]=pe[0],T[o+76>>2]=pe[1],fe[o+80>>2]=0,pe=[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]=pe[0],T[o+92>>2]=pe[1],fe[o+96>>2]=0,pe=[h.ino>>>0,(S=h.ino,1<=+Math.abs(S)?0>>0:~~+Math.ceil((S-+(~~S>>>0))/4294967296)>>>0:0)],T[o+104>>2]=pe[0],T[o+108>>2]=pe[1],0}var Ns=void 0;function ws(){return Ns+=4,T[Ns-4>>2]}function yt(n){if(n=Yt[n],!n)throw new N(8);return n}function uo(n){return fe[n>>2]+4294967296*T[n+4>>2]}function uu(n){var s=Zr(n)+1,o=vs(s);return o&&yr(n,ve,o,s),o}function el(n,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[n>>2]=60*Math.max(l,A),T[s>>2]=+(l!=A),n=h(p),s=h(y),n=uu(n),s=uu(s),A>2]=n,fe[o+4>>2]=s):(fe[o>>2]=s,fe[o+4>>2]=n)}function ho(n,s,o){ho.Bb||(ho.Bb=!0,el(n,s,o))}var hu;hu=Y?()=>{var n=process.hrtime();return 1e3*n[0]+n[1]/1e6}:()=>performance.now();var co={};function cu(){if(!lo){var n={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",_:Qe||"./this.program"},s;for(s in co)co[s]===void 0?delete n[s]:n[s]=co[s];var o=[];for(s in n)o.push(s+"="+n[s]);lo=o}return lo}var lo,Zt=void 0,fo=[];function po(n,s){if(!Zt){Zt=new WeakMap;var o=Kt.length;if(Zt)for(var h=0;h<0+o;h++){var l=Kt.get(h);l&&Zt.set(l,h)}}if(Zt.has(n))return Zt.get(n);if(fo.length)o=fo.pop();else{try{Kt.grow(1)}catch(A){throw A instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":A}o=Kt.length-1}try{Kt.set(o,n)}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:n}}).exports.f}Kt.set(o,s)}return Zt.set(n,o),o}function Ki(n){Zt.delete(Kt.get(n)),fo.push(n)}function mo(n){var s=vs(n.length);return n.subarray||n.slice||(n=new Uint8Array(n)),Ot.set(n,s),s}function tl(n,s,o,h){var l={string:F=>{var me=0;if(F!=null&&F!==0){var Bt=(F.length<<2)+1;me=er(Bt),yr(F,Ot,me,Bt)}return me},array:F=>{var me=er(F.length);return ve.set(F,me),me}};n=c["_"+n];var p=[],y=0;if(h)for(var A=0;A{qt("/dev"),no(259,{read:()=>0,write:(s,o,h,l)=>l}),fs("/dev/null",259),Qa(1280,Gc),Qa(1536,zc),fs("/dev/tty",1280),fs("/dev/tty1",1536);var n=$c();Gi("random",n),Gi("urandom",n),qt("/dev/shm"),qt("/dev/shm/tmp")})(),(()=>{qt("/proc");var n=qt("/proc/self");qt("/proc/self/fd"),Ha({Ra:()=>{var s=$a(n,"fd",16895,73);return s.Ga={lookup:(o,h)=>{var l=Yt[+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 rl={a:function(n,s,o,h){Ht("Assertion failed: "+Oe(n)+", at: "+[s?Oe(s):"unknown filename",o,h?Oe(h):"unknown function"])},h:function(n,s){try{return n=Oe(n),ps(n,s),0}catch(o){if(typeof ne>"u"||!(o instanceof N))throw o;return-o.Ka}},H:function(n,s,o){try{if(s=Oe(s),s=vr(n,s),o&-8)return-28;var h=$e(s,{Sa:!0}).node;return h?(n="",o&4&&(n+="r"),o&2&&(n+="w"),o&1&&(n+="x"),n&&ei(h,n)?-2:0):-44}catch(l){if(typeof ne>"u"||!(l instanceof N))throw l;return-l.Ka}},i:function(n,s){try{var o=Yt[n];if(!o)throw new N(8);return ps(o.node,s),0}catch(h){if(typeof ne>"u"||!(h instanceof N))throw h;return-h.Ka}},g:function(n){try{var s=Yt[n];if(!s)throw new N(8);var o=s.node,h=typeof o=="string"?$e(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 ne>"u"||!(l instanceof N))throw l;return-l.Ka}},b:function(n,s,o){Ns=o;try{var h=yt(n);switch(s){case 0:var l=ws();return 0>l?-28:Ka(h,l).fd;case 1:case 2:return 0;case 3:return h.flags;case 4:return l=ws(),h.flags|=l,0;case 5:return l=ws(),hs[l+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return T[du()>>2]=28,-1;default:return-28}}catch(p){if(typeof ne>"u"||!(p instanceof N))throw p;return-p.Ka}},G:function(n,s){try{var o=yt(n);return ys(Ji,o.path,s)}catch(h){if(typeof ne>"u"||!(h instanceof N))throw h;return-h.Ka}},l:function(n,s,o){try{if(s=o+2097152>>>0<4194305-!!s?(s>>>0)+4294967296*o:NaN,isNaN(s))return-61;var h=Yt[n];if(!h)throw new N(8);if(!(h.flags&2097155))throw new N(28);return tu(h.node,s),0}catch(l){if(typeof ne>"u"||!(l instanceof N))throw l;return-l.Ka}},B:function(n,s){try{if(s===0)return-28;var o=Zr("/")+1;return s"u"||!(h instanceof N))throw h;return-h.Ka}},E:function(n,s){try{return n=Oe(n),ys(eu,n,s)}catch(o){if(typeof ne>"u"||!(o instanceof N))throw o;return-o.Ka}},y:function(n,s,o){try{return s=Oe(s),s=vr(n,s),s=Lt(s),s[s.length-1]==="/"&&(s=s.substr(0,s.length-1)),qt(s,o),0}catch(h){if(typeof ne>"u"||!(h instanceof N))throw h;return-h.Ka}},D:function(n,s,o,h){try{s=Oe(s);var l=h&256;return s=vr(n,s,h&4096),ys(l?eu:Ji,s,o)}catch(p){if(typeof ne>"u"||!(p instanceof N))throw p;return-p.Ka}},v:function(n,s,o,h){Ns=h;try{s=Oe(s),s=vr(n,s);var l=h?ws():0;return ti(s,o,l).fd}catch(p){if(typeof ne>"u"||!(p instanceof N))throw p;return-p.Ka}},t:function(n,s,o,h){try{if(s=Oe(s),s=vr(n,s),0>=h)return-28;var l=Za(s),p=Math.min(h,Zr(l)),y=ve[o+p];return yr(l,Ot,o,h+1),ve[o+p]=y,p}catch(A){if(typeof ne>"u"||!(A instanceof N))throw A;return-A.Ka}},s:function(n){try{return n=Oe(n),Ya(n),0}catch(s){if(typeof ne>"u"||!(s instanceof N))throw s;return-s.Ka}},F:function(n,s){try{return n=Oe(n),ys(Ji,n,s)}catch(o){if(typeof ne>"u"||!(o instanceof N))throw o;return-o.Ka}},p:function(n,s,o){try{return s=Oe(s),s=vr(n,s),o===0?Xa(s):o===512?Ya(s):Ht("Invalid flags passed to unlinkat"),0}catch(h){if(typeof ne>"u"||!(h instanceof N))throw h;return-h.Ka}},o:function(n,s,o){try{if(s=Oe(s),s=vr(n,s,!0),o){var h=uo(o),l=T[o+8>>2];p=1e3*h+l/1e6,o+=16,h=uo(o),l=T[o+8>>2],y=1e3*h+l/1e6}else var p=Date.now(),y=p;n=p;var A=$e(s,{Sa:!0}).node;return A.Ga.Oa(A,{timestamp:Math.max(n,y)}),0}catch(V){if(typeof ne>"u"||!(V instanceof N))throw V;return-V.Ka}},e:function(){return Date.now()},j:function(n,s){n=new Date(1e3*uo(n)),T[s>>2]=n.getSeconds(),T[s+4>>2]=n.getMinutes(),T[s+8>>2]=n.getHours(),T[s+12>>2]=n.getDate(),T[s+16>>2]=n.getMonth(),T[s+20>>2]=n.getFullYear()-1900,T[s+24>>2]=n.getDay();var o=new Date(n.getFullYear(),0,1);T[s+28>>2]=(n.getTime()-o.getTime())/864e5|0,T[s+36>>2]=-(60*n.getTimezoneOffset());var h=new Date(n.getFullYear(),6,1).getTimezoneOffset();o=o.getTimezoneOffset(),T[s+32>>2]=(h!=o&&n.getTimezoneOffset()==Math.min(o,h))|0},w:function(n,s,o,h,l,p){try{var y=yt(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,n,l,s,o),V=A.Fb;return T[p>>2]=A.vb,V}catch(F){if(typeof ne>"u"||!(F instanceof N))throw F;return-F.Ka}},x:function(n,s,o,h,l,p){try{var y=yt(l);if(o&2){var A=Ot.slice(n,n+s);y&&y.Ha.cb&&y.Ha.cb(y,A,p,s,h)}}catch(V){if(typeof ne>"u"||!(V instanceof N))throw V;return-V.Ka}},n:ho,q:function(){return 2147483648},d:hu,c:function(n){var s=Ot.length;if(n>>>=0,2147483648=o;o*=2){var h=s*(1+.2/o);h=Math.min(h,n+100663296);var l=Math;h=Math.max(n,h),l=l.min.call(l,2147483648,h+(65536-h%65536)%65536);e:{try{Ks.grow(l-Hs.byteLength+65535>>>16),Sa();var p=1;break e}catch{}p=void 0}if(p)return!0}return!1},z:function(n,s){var o=0;return cu().forEach(function(h,l){var p=s+o;for(l=fe[n+4*l>>2]=p,p=0;p>0]=h.charCodeAt(p);ve[l>>0]=0,o+=h.length+1}),0},A:function(n,s){var o=cu();fe[n>>2]=o.length;var h=0;return o.forEach(function(l){h+=l.length+1}),fe[s>>2]=h,0},f:function(n){try{var s=yt(n);return oo(s),0}catch(o){if(typeof ne>"u"||!(o instanceof N))throw o;return o.Ka}},m:function(n,s){try{var o=yt(n);return ve[s>>0]=o.tty?2:(o.mode&61440)===16384?3:(o.mode&61440)===40960?7:4,0}catch(h){if(typeof ne>"u"||!(h instanceof N))throw h;return h.Ka}},u:function(n,s,o,h){try{e:{var l=yt(n);n=s;for(var p=s=0;p>2],A=fe[n+4>>2];n+=8;var V=iu(l,ve,y,A);if(0>V){var F=-1;break e}if(s+=V,V>2]=F,0}catch(me){if(typeof ne>"u"||!(me instanceof N))throw me;return me.Ka}},k:function(n,s,o,h,l){try{if(s=o+2097152>>>0<4194305-!!s?(s>>>0)+4294967296*o:NaN,isNaN(s))return 61;var p=yt(n);return ru(p,s,h),pe=[p.position>>>0,(S=p.position,1<=+Math.abs(S)?0>>0:~~+Math.ceil((S-+(~~S>>>0))/4294967296)>>>0:0)],T[l>>2]=pe[0],T[l+4>>2]=pe[1],p.hb&&s===0&&h===0&&(p.hb=null),0}catch(y){if(typeof ne>"u"||!(y instanceof N))throw y;return y.Ka}},C:function(n){try{var s=yt(n);return s.Ha&&s.Ha.fsync?s.Ha.fsync(s):0}catch(o){if(typeof ne>"u"||!(o instanceof N))throw o;return o.Ka}},r:function(n,s,o,h){try{e:{var l=yt(n);n=s;for(var p=s=0;p>2],A=fe[n+4>>2];n+=8;var V=nu(l,ve,y,A);if(0>V){var F=-1;break e}s+=V}F=s}return fe[h>>2]=F,0}catch(me){if(typeof ne>"u"||!(me instanceof N))throw me;return me.Ka}}};(function(){function n(l){c.asm=l.exports,Ks=c.asm.I,Sa(),Kt=c.asm.Aa,Ra.unshift(c.asm.J),Nr--,c.monitorRunDependencies&&c.monitorRunDependencies(Nr),Nr==0&&Vi&&(l=Vi,Vi=null,l())}function s(l){n(l.instance)}function o(l){return Vc().then(function(p){return WebAssembly.instantiate(p,h)}).then(function(p){return p}).then(l,function(p){mr("failed to asynchronously prepare wasm: "+p),Ht(p)})}var h={a:rl};if(Nr++,c.monitorRunDependencies&&c.monitorRunDependencies(Nr),c.instantiateWasm)try{return c.instantiateWasm(h,n)}catch(l){return mr("Module.instantiateWasm callback failed with error: "+l),!1}return function(){return Qi||typeof WebAssembly.instantiateStreaming!="function"||Ba()||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 mr("wasm streaming compile failed: "+p),mr("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 du=c.___errno_location=function(){return(du=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 vs=c._malloc=function(){return(vs=c._malloc=c.asm.ya).apply(null,arguments)},gs=c._free=function(){return(gs=c._free=c.asm.za).apply(null,arguments)};c._RegisterExtensionFunctions=function(){return(c._RegisterExtensionFunctions=c.asm.Ba).apply(null,arguments)};var fu=c._emscripten_builtin_memalign=function(){return(fu=c._emscripten_builtin_memalign=c.asm.Ca).apply(null,arguments)},Hi=c.stackSave=function(){return(Hi=c.stackSave=c.asm.Da).apply(null,arguments)},Yi=c.stackRestore=function(){return(Yi=c.stackRestore=c.asm.Ea).apply(null,arguments)},er=c.stackAlloc=function(){return(er=c.stackAlloc=c.asm.Fa).apply(null,arguments)};c.UTF8ToString=Oe,c.stackAlloc=er,c.stackSave=Hi,c.stackRestore=Yi,c.cwrap=function(n,s,o,h){o=o||[];var l=o.every(p=>p==="number"||p==="boolean");return s!=="string"&&l&&!h?c["_"+n]:function(){return tl(n,s,o,arguments)}};var bs;Vi=function n(){bs||pu(),bs||(Vi=n)};function pu(){function n(){if(!bs&&(bs=!0,c.calledRun=!0,!Ta)){if(c.noFSInit||ou||(ou=!0,su(),c.stdin=c.stdin,c.stdout=c.stdout,c.stderr=c.stderr,c.stdin?Gi("stdin",c.stdin):so("/dev/tty","/dev/stdin"),c.stdout?Gi("stdout",null,c.stdout):so("/dev/tty","/dev/stdout"),c.stderr?Gi("stderr",null,c.stderr):so("/dev/tty1","/dev/stderr"),ti("/dev/stdin",0),ti("/dev/stdout",1),ti("/dev/stderr",1)),Va=!1,Zs(Ra),c.onRuntimeInitialized&&c.onRuntimeInitialized(),c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;){var s=c.postRun.shift();La.unshift(s)}Zs(La)}}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(Cc,Math.max(qc,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 Ic=self.indexedDB||window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB||window.shimIndexedDB,qa=new Promise((t,e)=>{const r=Ic.open(Oc,1);r.onupgradeneeded=()=>r.result.createObjectStore("files",{keyPath:"name"}),r.onsuccess=()=>t(r.result),r.onerror=()=>e(r.error)});async function Ec(t){const e=await qa,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&&!Ar.has(t)){const u=new kc(r.data);return Ar.set(t,u),u}else return Ar.has(t)?Ar.get(t):null}async function Tc(t,e){const r=await qa;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 Ac(t,e){if(await Tc(t,e),Ar.has(t)){const r=Ar.get(t);r.truncate(0),r.write(0,e)}}var Sc=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),Dc=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},Rc=class extends Ds{constructor(e){super();se(this,"serializer");this.serializer=e||Sc}transformPrimitiveValueList(e){return{...e,values:e.values.map(this.serializer)}}transformColumnUpdate(e){const{value:r}=e;if(r.kind!=="ValueNode")return super.transformColumnUpdate(e);const{value:u,...d}=r,b=this.serializer(u);return u===b?super.transformColumnUpdate(e):super.transformColumnUpdate({...e,value:{...d,value:b}})}transformValue(e){return{...e,value:this.serializer(e.value)}}},Lc=class{constructor(t={}){se(this,"serializeParametersTransformer");se(this,"deserializer");se(this,"ctx");this.serializeParametersTransformer=new Rc(t.serializer),this.deserializer=t.deserializer||Dc,this.ctx=new WeakMap}transformQuery(t){const{node:e,queryId:r}=t;return e.kind==="SelectQueryNode"&&this.ctx.set(r,e.kind),this.serializeParametersTransformer.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 this.deserializer(r[u]);return r}))}async transformResult(t){const{result:e,queryId:r}=t,{rows:u}=e,d=this.ctx.get(r);return u&&d==="SelectQueryNode"?{...t.result,rows:await this.parseResult(u)}:t.result}};function Us(t){return typeof t=="string"}function Bc(t){return typeof t=="boolean"}async function Ca(t,e,r,u,d="rowid"){await Ge` + create trigger if not exists ${Ge.raw(e)}_${Ge.raw(u)} + after ${Ge.raw(r)} + on ${Ge.table(e)} + begin + update ${Ge.table(e)} + set ${Ge.ref(u)} = datetime('now','localtime') + where ${Ge.ref(d)} = NEW.${Ge.ref(d)}; + end + `.execute(t).catch(b=>{console.error(b)})}function Mc(t){const e=new Map;for(const r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;const u=t[r];e.set(r,u)}return e}async function Pc(t,e,r=!1){for(const[u,d]of e){const{columns:b,property:k}=d;r&&await t.schema.dropTable(u).ifExists().execute().catch();let I=t.schema.createTable(u),j="rowid",c=!1,Fe="createAt",Qe="updateAt";if(k!=null&&k.timestamp&&!Bc(k.timestamp)){const{create:P,update:Le}=k.timestamp;Fe=P??"createAt",Qe=Le??"updateAt"}for(const P in b){if(!Object.prototype.hasOwnProperty.call(b,P))continue;const Le=b[P];let Y="text";const{type:Te,notNull:Fi,defaultTo:Dt}=Le;switch(Te){case"boolean":case"date":case"object":case"string":Y="text";break;case"increments":j=P;case"number":Y="integer";break;case"blob":Y="blob"}[Fe,Qe].includes(P)||(I=I.addColumn(P,Y,mt=>Te==="increments"?(c=!0,mt.autoIncrement().primaryKey()):(Fi&&(mt=mt.notNull()),Dt!==void 0&&(mt=mt.defaultTo(Dt instanceof Function?Dt(Ge):Dt)),mt)))}if(k){const P=k.primary,Le=k.unique;if(k.timestamp&&(Fe&&(I=I.addColumn(Fe,"text")),Qe&&(I=I.addColumn(Qe,"text"))),!c&&P){const Y=Us(P);j=Y?P:P[0],I=I.addPrimaryKeyConstraint(`pk_${Y?P:P.join("_")}`,Y?[P]:P)}Le==null||Le.forEach(Y=>{const Te=Us(Y);j=!P&&!c?Te?Y:Y[0]:j,I=I.addUniqueConstraint(`un_${Te?Y:Y.join("_")}`,Te?[Y]:Y)})}if(await I.ifNotExists().execute(),k!=null&&k.index)for(const P of k.index){const Le=Us(P);let Y=t.schema.createIndex(`idx_${Le?P:P.join("_")}`).on(u);Y=Le?Y.column(P):Y.columns(P),await Y.ifNotExists().execute()}k!=null&&k.timestamp&&(Fe&&await Ca(t,u,"insert",Fe,j),Qe&&await Ca(t,u,"update",Qe,j))}}var _c=class{constructor(t){se(this,"kysely");se(this,"status");se(this,"tableMap");const{dialect:e,tables:r,dropTableBeforeInit:u,onError:d,onQuery:b,plugins:k}=t,I=k??[];I.push(new Lc),this.kysely=new vi({dialect:e,log:j=>{j.level==="error"?d&&d(j.error):b&&b(j.query,j.queryDurationMillis)},plugins:I}),this.status=u?0:1,this.tableMap=Mc(r)}async init(t=!1){const e=t||this.status===0;return await Pc(this.kysely,this.tableMap,e),this.status=2,this}async checkInit(){if(this.status!==2&&await this.init(),this.status!==2)throw new Error("fail to init table")}async transaction(t,e=!1){return await this.checkInit(),await this.kysely.transaction().execute(t).catch(r=>{e&&console.error(r)})}async exec(t,e=!1){return await this.checkInit(),t(this.kysely).catch(r=>{e&&console.error(r)})}async toSQL(t){return await this.checkInit(),t(this.kysely).compile()}async raw(t){return await this.checkInit(),t(Ge).execute(this.kysely)}};async function Fc(t){const e=await new _c({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(r=>r`PRAGMA table_info(${r.table("test")});`)),console.log(await e.raw(r=>r`select last_insert_rowid()`));for(let r=0;r<100;r++)await e.transaction(u=>u.insertInto("test").values({name:`test at ${Date.now()}`,blobtest:Uint8Array.from([2,3,4,5,6,7,8])}).execute());return e.exec(r=>r.selectFrom("test").selectAll().execute())}const Qc=new yc({async database(){const t=await xc({locateFile:()=>Wc});return new t.Database(await Ec("sqlijsWorker"))},onWrite:{func(t){console.log(`[sqljs worker] write to indexeddb, length: ${t.length}`),Ac("sqlijsWorker",t)}}});onmessage=()=>{console.log("start sqljs test"),Fc(Qc).then(t=>{t==null||t.forEach(e=>console.log("[sqlijs]",e))})}})(); diff --git a/assets/sqljsWorker-9211ff35.js b/assets/sqljsWorker-9211ff35.js deleted file mode 100644 index 0954d1c..0000000 --- a/assets/sqljsWorker-9211ff35.js +++ /dev/null @@ -1,12 +0,0 @@ -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["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)} - after ${Je.raw(r)} - on ${Je.table(e)} - begin - update ${Je.table(e)} - set ${Je.ref(u)} = datetime('now','localtime') - where ${Je.ref(d)} = NEW.${Je.ref(d)}; - end - `.execute(t).catch(b=>{console.error(b)})}function rl(t){const e=new Map;for(const r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;const u=t[r];e.set(r,u)}return e}async function nl(t,e,r=!1){for(const[u,d]of e){const{columns:b,property:k}=d;r&&await t.schema.dropTable(u).ifExists().execute().catch();let I=t.schema.createTable(u),j="rowid",c=!1,_e="createAt",Fe="updateAt";if(k!=null&&k.timestamp&&!tl(k.timestamp)){const{create:P,update:Re}=k.timestamp;_e=P??"createAt",Fe=Re??"updateAt"}for(const P in b){if(!Object.prototype.hasOwnProperty.call(b,P))continue;const Re=b[P];let Y="text";const{type:Ee,notNull:Zn,defaultTo:Rt}=Re;switch(Ee){case"boolean":case"date":case"object":case"string":Y="text";break;case"increments":j=P;case"number":Y="integer";break;case"blob":Y="blob"}[_e,Fe].includes(P)||(I=I.addColumn(P,Y,yt=>Ee==="increments"?(c=!0,yt.autoIncrement().primaryKey()):(Zn&&(yt=yt.notNull()),Rt!==void 0&&(yt=yt.defaultTo(Rt instanceof Function?Rt(Je):Rt)),yt)))}if(k){const P=k.primary,Re=k.unique;if(k.timestamp&&(_e&&(I=I.addColumn(_e,"text")),Fe&&(I=I.addColumn(Fe,"text"))),!c&&P){const Y=to(P);j=Y?P:P[0],I=I.addPrimaryKeyConstraint(`pk_${Y?P:P.join("_")}`,Y?[P]:P)}Re==null||Re.forEach(Y=>{const Ee=to(Y);j=!P&&!c?Ee?Y:Y[0]:j,I=I.addUniqueConstraint(`un_${Ee?Y:Y.join("_")}`,Ee?[Y]:Y)})}if(await I.ifNotExists().execute(),k!=null&&k.index)for(const P of k.index){const Re=to(P);let Y=t.schema.createIndex(`idx_${Re?P:P.join("_")}`).on(u);Y=Re?Y.column(P):Y.columns(P),await Y.ifNotExists().execute()}k!=null&&k.timestamp&&(_e&&await _a(t,u,"insert",_e,j),Fe&&await _a(t,u,"update",Fe,j))}}var il=(Ga=class{constructor(t){Xe(this,"kysely");w(this,Yt,void 0);w(this,Xn,void 0);const{dialect:e,tables:r,dropTableBeforeInit:u,onError:d,onQuery:b,plugins:k}=t,I=k??[];I.push(new el),this.kysely=new En({dialect:e,log:j=>{j.level==="error"?d&&d(j.error):b&&b(j.query,j.queryDurationMillis)},plugins:I}),g(this,Yt,u?0:1),g(this,Xn,rl(r))}async init(t=!1){const e=t||n(this,Yt)===0;return await nl(this.kysely,n(this,Xn),e),g(this,Yt,2),this}async checkInit(){if(n(this,Yt)!==2&&await this.init(),n(this,Yt)!==2)throw new Error("fail to init table")}async transaction(t,e=!1){return await this.checkInit(),await this.kysely.transaction().execute(t).catch(r=>{e&&console.error(r)})}async exec(t,e=!1){return await this.checkInit(),t(this.kysely).catch(r=>{e&&console.error(r)})}async toSQL(t){return await this.checkInit(),t(this.kysely).compile()}async raw(t){return await this.checkInit(),t(Je).execute(this.kysely)}},Yt=new WeakMap,Xn=new WeakMap,Ga);async function sl(t){const e=await new il({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(r=>r`PRAGMA table_info(${r.table("test")});`)),console.log(await e.raw(r=>r`select last_insert_rowid()`));for(let r=0;r<100;r++)await e.transaction(u=>u.insertInto("test").values({name:`test at ${Date.now()}`,blobtest:Uint8Array.from([2,3,4,5,6,7,8])}).execute());return e.exec(r=>r.selectFrom("test").selectAll().execute())}const ol=new Lc({async database(){const t=await Qc({locateFile:()=>Uc});return new t.Database(await Kc("sqlijsWorker"))},onWrite:{func(t){console.log(`[sqljs worker] write to indexeddb, length: ${t.length}`),Hc("sqlijsWorker",t)}}});onmessage=()=>{console.log("start sqljs test"),sl(ol).then(t=>{t==null||t.forEach(e=>console.log("[sqlijs]",e))})}})(); diff --git a/index.html b/index.html index 10bbf64..9c49517 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ test - +